Mike Frysinger | 5366fe6 | 2012-09-10 14:09:11 -0400 | [diff] [blame] | 1 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Darin Petkov | ada04fb | 2011-05-20 13:37:41 -0700 | [diff] [blame] | 2 | # 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 Frysinger | 5366fe6 | 2012-09-10 14:09:11 -0400 | [diff] [blame] | 6 | # @ECLASS: appid.eclass |
| 7 | # @BLURB: Eclass for setting up the omaha appid field in /etc/lsb-release |
Darin Petkov | ada04fb | 2011-05-20 13:37:41 -0700 | [diff] [blame] | 8 | |
Mike Frysinger | 5366fe6 | 2012-09-10 14:09:11 -0400 | [diff] [blame] | 9 | # @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 Petkov | ada04fb | 2011-05-20 13:37:41 -0700 | [diff] [blame] | 15 | doappid() { |
Mike Frysinger | 5366fe6 | 2012-09-10 14:09:11 -0400 | [diff] [blame] | 16 | [[ $# -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 Petkov | ada04fb | 2011-05-20 13:37:41 -0700 | [diff] [blame] | 38 | } |