blob: bb05f957c2c612bc5c6b378e49434d332565662d [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
Mike Frysingerf11c41a2013-01-10 12:22:37 -05007# @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 Frysinger5366fe62012-09-10 14:09:11 -040012# @BLURB: Eclass for setting up the omaha appid field in /etc/lsb-release
Darin Petkovada04fb2011-05-20 13:37:41 -070013
Mike Frysinger5366fe62012-09-10 14:09:11 -040014# @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 Petkovada04fb2011-05-20 13:37:41 -070020doappid() {
Mike Frysinger5366fe62012-09-10 14:09:11 -040021 [[ $# -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 Petkovada04fb2011-05-20 13:37:41 -070043}