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 |
Mike Frysinger | f11c41a | 2013-01-10 12:22:37 -0500 | [diff] [blame^] | 7 | # @MAINTAINER: |
| 8 | # ChromiumOS Build Team |
| 9 | # @BUGREPORTS: |
| 10 | # Please report bugs via http://crosbug.com/new (with label Area-Build) |
| 11 | # @VCSURL: http://git.chromium.org/gitweb/?p=chromiumos/overlays/chromiumos-overlay.git;a=blob;f=eclass/@ECLASS@ |
Mike Frysinger | 5366fe6 | 2012-09-10 14:09:11 -0400 | [diff] [blame] | 12 | # @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] | 13 | |
Mike Frysinger | 5366fe6 | 2012-09-10 14:09:11 -0400 | [diff] [blame] | 14 | # @FUNCTION: doappid |
| 15 | # @USAGE: <appid> |
| 16 | # @DESCRIPTION: |
| 17 | # Initializes /etc/lsb-release with the appid. Note that appid is really |
| 18 | # just a UUID in the canonical {8-4-4-4-12} format (all uppercase). e.g. |
| 19 | # {01234567-89AB-CDEF-0123-456789ABCDEF} |
Darin Petkov | ada04fb | 2011-05-20 13:37:41 -0700 | [diff] [blame] | 20 | doappid() { |
Mike Frysinger | 5366fe6 | 2012-09-10 14:09:11 -0400 | [diff] [blame] | 21 | [[ $# -eq 1 && -n $1 ]] || die "Usage: ${FUNCNAME} <appid>" |
| 22 | local appid=$1 |
| 23 | |
| 24 | # Validate the UUID is formatted correctly. Except for mario -- |
| 25 | # it was created before we had strict rules, and so it violates :(. |
| 26 | if [[ ${appid} != '{87efface-864d-49a5-9bb3-4b050a7c227a}' ]] ; then |
| 27 | local uuid_regex='[{][0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12}[}]' |
| 28 | local filtered_appid=$(echo "${appid}" | LC_ALL=C sed -r "s:${uuid_regex}::") |
| 29 | if [[ -n ${filtered_appid} ]] ; then |
| 30 | eerror "Invalid appid: ${appid} -> ${filtered_appid}" |
| 31 | eerror " - must start with '{' and end with '}'" |
| 32 | eerror " - must be all upper case" |
| 33 | eerror " - be a valid UUID (8-4-4-4-12 hex digits)" |
| 34 | die "invalid appid: ${appid}" |
| 35 | fi |
| 36 | fi |
| 37 | |
| 38 | dodir /etc |
| 39 | |
| 40 | local lsb="${D}/etc/lsb-release" |
| 41 | [[ -e ${lsb} ]] && die "${lsb} already exists!" |
| 42 | echo "CHROMEOS_RELEASE_APPID=${appid}" > "${lsb}" || die "creating ${lsb} failed!" |
Darin Petkov | ada04fb | 2011-05-20 13:37:41 -0700 | [diff] [blame] | 43 | } |