Mike Frysinger | 4ed918e | 2012-05-09 15:44:12 -0400 | [diff] [blame] | 1 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | |
| 4 | # |
| 5 | # Original Author: The Chromium OS Authors <chromium-os-dev@chromium.org> |
| 6 | # Purpose: Install binary packages for Chromium OS |
| 7 | # |
| 8 | |
Mike Frysinger | 7483e86 | 2015-11-30 16:44:40 -0500 | [diff] [blame] | 9 | # Reject old users of cros-binary eclass that expected us to download files |
| 10 | # directly rather than going through SRC_URI. |
| 11 | cros-binary_dead_usage() { |
| 12 | die "You must add files to SRC_URI now" |
| 13 | } |
| 14 | if [[ ${CROS_BINARY_STORE_DIR:+set} == "set" || |
| 15 | ${CROS_BINARY_SUM:+set} == "set" || |
| 16 | ${CROS_BINARY_FETCH_REQUIRED:+set} == "set" ]]; then |
| 17 | cros-binary_dead_usage |
| 18 | fi |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 19 | |
| 20 | # @ECLASS-FUNCTION: cros-binary_add_uri |
| 21 | # @DESCRIPTION: |
| 22 | # Add a fetch uri to SRC_URI for the given uri. See |
| 23 | # CROS_BINARY_URI for what is accepted. Note you cannot |
| 24 | # intermix a non-rewritten ssh w/ (http|https|gs). |
| 25 | cros-binary_add_uri() |
| 26 | { |
| 27 | if [[ $# -ne 1 ]]; then |
| 28 | die "cros-binary_add_uri takes exactly one argument; $# given." |
| 29 | fi |
| 30 | local uri="$1" |
| 31 | if [[ "${uri}" =~ ^ssh://([^@]+)@git.chromium.org[^/]*/(.*)$ ]]; then |
| 32 | uri="gs://chromeos-binaries/HOME/${BASH_REMATCH[1]}/${BASH_REMATCH[2]}" |
| 33 | fi |
| 34 | case "${uri}" in |
| 35 | http://*|https://*|gs://*) |
| 36 | SRC_URI+=" ${uri}" |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 37 | ;; |
| 38 | *) |
| 39 | die "Unknown protocol: ${uri}" |
| 40 | ;; |
| 41 | esac |
Mike Frysinger | 6300c4b | 2013-04-06 22:48:39 -0400 | [diff] [blame] | 42 | RESTRICT+=" mirror" |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | # @ECLASS-FUNCTION: cros-binary_add_gs_uri |
| 46 | # @DESCRIPTION: |
| 47 | # Wrapper around cros-binary_add_uri. Invoked with 3 arguments; |
| 48 | # the bcs user, the overlay, and the filename (or bcs://<uri> for |
| 49 | # backwards compatibility). |
| 50 | cros-binary_add_gs_uri() { |
| 51 | if [[ $# -ne 3 ]]; then |
| 52 | die "cros-binary_add_bcs_uri needs 3 arguments; $# given." |
| 53 | fi |
| 54 | # Strip leading bcs://... |
| 55 | [[ "${3:0:6}" == "bcs://" ]] && set -- "${1}" "${2}" "${3#bcs://}" |
| 56 | cros-binary_add_uri "gs://chromeos-binaries/HOME/$1/$2/$3" |
| 57 | } |
| 58 | |
| 59 | # @ECLASS-FUNCTION: cros-binary_add_overlay_uri |
| 60 | # @DESCRIPTION: |
| 61 | # Wrapper around cros-binary_add_bcs_uri. Invoked with 2 arguments; |
| 62 | # the basic board target (x86-alex for example), and the filename; that filename |
| 63 | # is automatically prefixed with "${CATEGORY}/${PN}/" . |
| 64 | cros-binary_add_overlay_uri() { |
| 65 | if [[ $# -ne 2 ]]; then |
| 66 | die "cros-binary_add_bcs_uri_simple needs 2 arguments; $# given." |
| 67 | fi |
| 68 | cros-binary_add_gs_uri bcs-"$1" overlay-"$1" "${CATEGORY}/${PN}/$2" |
| 69 | } |
| 70 | |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 71 | # @ECLASS-VARIABLE: CROS_BINARY_URI |
| 72 | # @DESCRIPTION: |
| 73 | # URI for the binary may be one of: |
| 74 | # http:// |
| 75 | # https:// |
| 76 | # ssh:// |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 77 | # gs:// |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 78 | # file:// (file is relative to the files directory) |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 79 | # Additionally, all bcs ssh:// urls are rewritten to gs:// automatically |
| 80 | # the appropriate GS bucket- although cros-binary_add_uri is the preferred |
| 81 | # way to do that. |
| 82 | # TODO: Deprecate this variable's support for ssh and http/https. |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 83 | : ${CROS_BINARY_URI:=} |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 84 | if [[ -n "${CROS_BINARY_URI}" ]]; then |
| 85 | cros-binary_add_uri "${CROS_BINARY_URI}" |
| 86 | fi |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 87 | |
Puneet Kumar | 0cc9c65 | 2010-08-25 13:35:17 -0700 | [diff] [blame] | 88 | # @ECLASS-VARIABLE: CROS_BINARY_INSTALL_FLAGS |
| 89 | # @DESCRIPTION: |
| 90 | # Optional Flags to use while installing the binary |
| 91 | : ${CROS_BINARY_INSTALL_FLAGS:=} |
| 92 | |
Allen Martin | 967a824 | 2012-03-27 04:51:34 +0000 | [diff] [blame] | 93 | # @ECLASS-VARIABLE: CROS_BINARY_LOCAL_URI_BASE |
| 94 | # @DESCRIPTION: |
| 95 | # Optional URI to override CROS_BINARY_URI location. If this variable |
| 96 | # is used the filename from CROS_BINARY_URI will be used, but the path |
| 97 | # to the binary will be changed. |
| 98 | : ${CROS_BINARY_LOCAL_URI_BASE:=} |
| 99 | |
Mike Frysinger | 4ed918e | 2012-05-09 15:44:12 -0400 | [diff] [blame] | 100 | # Check for EAPI 2+ |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 101 | case "${EAPI:-0}" in |
Mike Frysinger | de80d30 | 2015-12-23 12:24:05 -0500 | [diff] [blame] | 102 | 2|3|4|5|6) ;; |
| 103 | *) die "unsupported EAPI (${EAPI}) in eclass (${ECLASS})" ;; |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 104 | esac |
| 105 | |
| 106 | cros-binary_check_file() { |
Mike Frysinger | c8e92f5 | 2017-06-08 20:50:34 -0400 | [diff] [blame] | 107 | cros-binary_dead_usage |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | cros-binary_fetch() { |
Mike Frysinger | 7483e86 | 2015-11-30 16:44:40 -0500 | [diff] [blame] | 111 | cros-binary_dead_usage |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | cros-binary_src_unpack() { |
Mike Frysinger | 7483e86 | 2015-11-30 16:44:40 -0500 | [diff] [blame] | 115 | cros-binary_dead_usage |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | cros-binary_src_install() { |
Mike Frysinger | fdd64d5 | 2017-08-02 01:03:30 -0400 | [diff] [blame] | 119 | local target="${DISTDIR}/${CROS_BINARY_URI##*/}" |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 120 | local extension="${CROS_BINARY_URI##*.}" |
| 121 | local flags |
| 122 | |
| 123 | case "${CROS_BINARY_URI##*.}" in |
| 124 | gz|tgz) flags="z";; |
| 125 | bz2|tbz2) flags="j";; |
| 126 | *) die "Unsupported binary file format ${CROS_BINARY_URI##*.}" |
| 127 | esac |
| 128 | |
| 129 | cd "${D}" || die |
Mike Frysinger | b39ef8a | 2017-06-08 20:51:35 -0400 | [diff] [blame] | 130 | tar "${flags}xpf" "${target}" --no-same-owner ${CROS_BINARY_INSTALL_FLAGS} || die "Failed to unpack" |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Mike Frysinger | 7483e86 | 2015-11-30 16:44:40 -0500 | [diff] [blame] | 133 | EXPORT_FUNCTIONS src_install |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 134 | |