blob: 6da63e98f4cb8c752c71aa52c3d0297f4b571285 [file] [log] [blame]
Mike Frysinger5366fe62012-09-10 14:09:11 -04001# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Darin Petkovada04fb2011-05-20 13:37:41 -07002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4# $Header: $
5
Mike Frysinger5366fe62012-09-10 14:09:11 -04006# @ECLASS: appid.eclass
7# @BLURB: Eclass for setting up the omaha appid field in /etc/lsb-release
Darin Petkovada04fb2011-05-20 13:37:41 -07008
Mike Frysinger5366fe62012-09-10 14:09:11 -04009# @FUNCTION: doappid
10# @USAGE: <appid>
11# @DESCRIPTION:
12# Initializes /etc/lsb-release with the appid. Note that appid is really
13# just a UUID in the canonical {8-4-4-4-12} format (all uppercase). e.g.
14# {01234567-89AB-CDEF-0123-456789ABCDEF}
Darin Petkovada04fb2011-05-20 13:37:41 -070015doappid() {
Mike Frysinger5366fe62012-09-10 14:09:11 -040016 [[ $# -eq 1 && -n $1 ]] || die "Usage: ${FUNCNAME} <appid>"
17 local appid=$1
18
19 # Validate the UUID is formatted correctly. Except for mario --
20 # it was created before we had strict rules, and so it violates :(.
21 if [[ ${appid} != '{87efface-864d-49a5-9bb3-4b050a7c227a}' ]] ; then
22 local uuid_regex='[{][0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12}[}]'
23 local filtered_appid=$(echo "${appid}" | LC_ALL=C sed -r "s:${uuid_regex}::")
24 if [[ -n ${filtered_appid} ]] ; then
25 eerror "Invalid appid: ${appid} -> ${filtered_appid}"
26 eerror " - must start with '{' and end with '}'"
27 eerror " - must be all upper case"
28 eerror " - be a valid UUID (8-4-4-4-12 hex digits)"
29 die "invalid appid: ${appid}"
30 fi
31 fi
32
33 dodir /etc
34
35 local lsb="${D}/etc/lsb-release"
36 [[ -e ${lsb} ]] && die "${lsb} already exists!"
37 echo "CHROMEOS_RELEASE_APPID=${appid}" > "${lsb}" || die "creating ${lsb} failed!"
Darin Petkovada04fb2011-05-20 13:37:41 -070038}