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() { |
Mike Frysinger | e9a29e9 | 2017-08-02 01:10:27 -0400 | [diff] [blame] | 12 | die "You must add files to SRC_URI now and install them manually" |
Mike Frysinger | 7483e86 | 2015-11-30 16:44:40 -0500 | [diff] [blame] | 13 | } |
| 14 | if [[ ${CROS_BINARY_STORE_DIR:+set} == "set" || |
| 15 | ${CROS_BINARY_SUM:+set} == "set" || |
Mike Frysinger | e83a147b | 2017-09-01 16:52:50 -0400 | [diff] [blame] | 16 | ${CROS_BINARY_FETCH_REQUIRED:+set} == "set" || |
| 17 | ${CROS_BINARY_INSTALL_FLAGS:+set} == "set" ]]; then |
Mike Frysinger | 7483e86 | 2015-11-30 16:44:40 -0500 | [diff] [blame] | 18 | cros-binary_dead_usage |
| 19 | fi |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 20 | |
| 21 | # @ECLASS-FUNCTION: cros-binary_add_uri |
| 22 | # @DESCRIPTION: |
| 23 | # Add a fetch uri to SRC_URI for the given uri. See |
| 24 | # CROS_BINARY_URI for what is accepted. Note you cannot |
| 25 | # intermix a non-rewritten ssh w/ (http|https|gs). |
| 26 | cros-binary_add_uri() |
| 27 | { |
| 28 | if [[ $# -ne 1 ]]; then |
| 29 | die "cros-binary_add_uri takes exactly one argument; $# given." |
| 30 | fi |
| 31 | local uri="$1" |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 32 | case "${uri}" in |
| 33 | http://*|https://*|gs://*) |
| 34 | SRC_URI+=" ${uri}" |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 35 | ;; |
| 36 | *) |
| 37 | die "Unknown protocol: ${uri}" |
| 38 | ;; |
| 39 | esac |
Mike Frysinger | 6300c4b | 2013-04-06 22:48:39 -0400 | [diff] [blame] | 40 | RESTRICT+=" mirror" |
Mike Frysinger | a77ff1f | 2017-09-02 15:05:16 -0400 | [diff] [blame] | 41 | |
| 42 | if [[ ${uri} =~ -r[0-9]+\.tbz2 ]]; then |
Mike Frysinger | d82dcaf | 2019-10-08 14:00:48 -0400 | [diff] [blame^] | 43 | ewarn "${P}: Tarballs should not encode ebuild rev numbers (-r#)." |
Mike Frysinger | a77ff1f | 2017-09-02 15:05:16 -0400 | [diff] [blame] | 44 | ewarn "The ebuild revision field is only for changes to the ebuild itself." |
| 45 | ewarn "If you want to update the source tarball, update the PV instead." |
| 46 | ewarn " bad: foo-0.0.1-r8.tbz2 or foo-0.0.1.tbz2 -> foo-0.0.1-r1.tbz2" |
| 47 | ewarn " good: foo-0.0.8.tbz2 or foo-0.0.1.tbz2 -> foo-0.0.2.tbz2" |
| 48 | fi |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | # @ECLASS-FUNCTION: cros-binary_add_gs_uri |
| 52 | # @DESCRIPTION: |
| 53 | # Wrapper around cros-binary_add_uri. Invoked with 3 arguments; |
| 54 | # the bcs user, the overlay, and the filename (or bcs://<uri> for |
| 55 | # backwards compatibility). |
| 56 | cros-binary_add_gs_uri() { |
| 57 | if [[ $# -ne 3 ]]; then |
Mike Frysinger | b7c1877 | 2017-09-26 16:05:49 -0400 | [diff] [blame] | 58 | die "cros-binary_add_gs_uri needs 3 arguments; $# given." |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 59 | fi |
| 60 | # Strip leading bcs://... |
| 61 | [[ "${3:0:6}" == "bcs://" ]] && set -- "${1}" "${2}" "${3#bcs://}" |
| 62 | cros-binary_add_uri "gs://chromeos-binaries/HOME/$1/$2/$3" |
| 63 | } |
| 64 | |
| 65 | # @ECLASS-FUNCTION: cros-binary_add_overlay_uri |
| 66 | # @DESCRIPTION: |
Mike Frysinger | b7c1877 | 2017-09-26 16:05:49 -0400 | [diff] [blame] | 67 | # Wrapper around cros-binary_add_gs_uri. Invoked with 2 arguments; |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 68 | # the basic board target (x86-alex for example), and the filename; that filename |
| 69 | # is automatically prefixed with "${CATEGORY}/${PN}/" . |
| 70 | cros-binary_add_overlay_uri() { |
| 71 | if [[ $# -ne 2 ]]; then |
Mike Frysinger | b7c1877 | 2017-09-26 16:05:49 -0400 | [diff] [blame] | 72 | die "cros-binary_add_overlay_uri needs 2 arguments; $# given." |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 73 | fi |
| 74 | cros-binary_add_gs_uri bcs-"$1" overlay-"$1" "${CATEGORY}/${PN}/$2" |
| 75 | } |
| 76 | |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 77 | # @ECLASS-VARIABLE: CROS_BINARY_URI |
| 78 | # @DESCRIPTION: |
| 79 | # URI for the binary may be one of: |
| 80 | # http:// |
| 81 | # https:// |
| 82 | # ssh:// |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 83 | # gs:// |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 84 | # file:// (file is relative to the files directory) |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 85 | # Additionally, all bcs ssh:// urls are rewritten to gs:// automatically |
| 86 | # the appropriate GS bucket- although cros-binary_add_uri is the preferred |
| 87 | # way to do that. |
| 88 | # TODO: Deprecate this variable's support for ssh and http/https. |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 89 | : ${CROS_BINARY_URI:=} |
Brian Harring | cf0c766 | 2012-12-19 23:06:44 -0800 | [diff] [blame] | 90 | if [[ -n "${CROS_BINARY_URI}" ]]; then |
| 91 | cros-binary_add_uri "${CROS_BINARY_URI}" |
| 92 | fi |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 93 | |
Allen Martin | 967a824 | 2012-03-27 04:51:34 +0000 | [diff] [blame] | 94 | # @ECLASS-VARIABLE: CROS_BINARY_LOCAL_URI_BASE |
| 95 | # @DESCRIPTION: |
| 96 | # Optional URI to override CROS_BINARY_URI location. If this variable |
| 97 | # is used the filename from CROS_BINARY_URI will be used, but the path |
| 98 | # to the binary will be changed. |
| 99 | : ${CROS_BINARY_LOCAL_URI_BASE:=} |
| 100 | |
Mike Frysinger | 4ed918e | 2012-05-09 15:44:12 -0400 | [diff] [blame] | 101 | # Check for EAPI 2+ |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 102 | case "${EAPI:-0}" in |
Mike Frysinger | de80d30 | 2015-12-23 12:24:05 -0500 | [diff] [blame] | 103 | 2|3|4|5|6) ;; |
| 104 | *) die "unsupported EAPI (${EAPI}) in eclass (${ECLASS})" ;; |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 105 | esac |
| 106 | |
| 107 | cros-binary_check_file() { |
Mike Frysinger | c8e92f5 | 2017-06-08 20:50:34 -0400 | [diff] [blame] | 108 | cros-binary_dead_usage |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | cros-binary_fetch() { |
Mike Frysinger | 7483e86 | 2015-11-30 16:44:40 -0500 | [diff] [blame] | 112 | cros-binary_dead_usage |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | cros-binary_src_unpack() { |
Mike Frysinger | 7483e86 | 2015-11-30 16:44:40 -0500 | [diff] [blame] | 116 | cros-binary_dead_usage |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | cros-binary_src_install() { |
Mike Frysinger | e9a29e9 | 2017-08-02 01:10:27 -0400 | [diff] [blame] | 120 | cros-binary_dead_usage |
Kenneth Waters | 512eb16 | 2010-06-02 10:19:12 -0700 | [diff] [blame] | 121 | } |