blob: c8b7c5a2d2b324bce5ae25cdd5d200da25ee0064 [file] [log] [blame]
Mike Frysinger4ed918e2012-05-09 15:44:12 -04001# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Kenneth Waters512eb162010-06-02 10:19:12 -07002# 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 Frysinger7483e862015-11-30 16:44:40 -05009# Reject old users of cros-binary eclass that expected us to download files
10# directly rather than going through SRC_URI.
11cros-binary_dead_usage() {
Mike Frysingere9a29e92017-08-02 01:10:27 -040012 die "You must add files to SRC_URI now and install them manually"
Mike Frysinger7483e862015-11-30 16:44:40 -050013}
14if [[ ${CROS_BINARY_STORE_DIR:+set} == "set" ||
15 ${CROS_BINARY_SUM:+set} == "set" ||
Mike Frysingere83a147b2017-09-01 16:52:50 -040016 ${CROS_BINARY_FETCH_REQUIRED:+set} == "set" ||
17 ${CROS_BINARY_INSTALL_FLAGS:+set} == "set" ]]; then
Mike Frysinger7483e862015-11-30 16:44:40 -050018 cros-binary_dead_usage
19fi
Brian Harringcf0c7662012-12-19 23:06:44 -080020
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).
26cros-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 Harringcf0c7662012-12-19 23:06:44 -080032 case "${uri}" in
33 http://*|https://*|gs://*)
34 SRC_URI+=" ${uri}"
Brian Harringcf0c7662012-12-19 23:06:44 -080035 ;;
36 *)
37 die "Unknown protocol: ${uri}"
38 ;;
39 esac
Mike Frysinger6300c4b2013-04-06 22:48:39 -040040 RESTRICT+=" mirror"
Mike Frysingera77ff1f2017-09-02 15:05:16 -040041
42 if [[ ${uri} =~ -r[0-9]+\.tbz2 ]]; then
Mike Frysingerd82dcaf2019-10-08 14:00:48 -040043 ewarn "${P}: Tarballs should not encode ebuild rev numbers (-r#)."
Mike Frysingera77ff1f2017-09-02 15:05:16 -040044 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 Harringcf0c7662012-12-19 23:06:44 -080049}
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).
56cros-binary_add_gs_uri() {
57 if [[ $# -ne 3 ]]; then
Mike Frysingerb7c18772017-09-26 16:05:49 -040058 die "cros-binary_add_gs_uri needs 3 arguments; $# given."
Brian Harringcf0c7662012-12-19 23:06:44 -080059 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 Frysingerb7c18772017-09-26 16:05:49 -040067# Wrapper around cros-binary_add_gs_uri. Invoked with 2 arguments;
Brian Harringcf0c7662012-12-19 23:06:44 -080068# the basic board target (x86-alex for example), and the filename; that filename
69# is automatically prefixed with "${CATEGORY}/${PN}/" .
70cros-binary_add_overlay_uri() {
71 if [[ $# -ne 2 ]]; then
Mike Frysingerb7c18772017-09-26 16:05:49 -040072 die "cros-binary_add_overlay_uri needs 2 arguments; $# given."
Brian Harringcf0c7662012-12-19 23:06:44 -080073 fi
74 cros-binary_add_gs_uri bcs-"$1" overlay-"$1" "${CATEGORY}/${PN}/$2"
75}
76
Kenneth Waters512eb162010-06-02 10:19:12 -070077# @ECLASS-VARIABLE: CROS_BINARY_URI
78# @DESCRIPTION:
79# URI for the binary may be one of:
80# http://
81# https://
82# ssh://
Brian Harringcf0c7662012-12-19 23:06:44 -080083# gs://
Kenneth Waters512eb162010-06-02 10:19:12 -070084# file:// (file is relative to the files directory)
Brian Harringcf0c7662012-12-19 23:06:44 -080085# 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 Waters512eb162010-06-02 10:19:12 -070089: ${CROS_BINARY_URI:=}
Brian Harringcf0c7662012-12-19 23:06:44 -080090if [[ -n "${CROS_BINARY_URI}" ]]; then
91 cros-binary_add_uri "${CROS_BINARY_URI}"
92fi
Kenneth Waters512eb162010-06-02 10:19:12 -070093
Allen Martin967a8242012-03-27 04:51:34 +000094# @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 Frysinger4ed918e2012-05-09 15:44:12 -0400101# Check for EAPI 2+
Kenneth Waters512eb162010-06-02 10:19:12 -0700102case "${EAPI:-0}" in
Mike Frysingerde80d302015-12-23 12:24:05 -05001032|3|4|5|6) ;;
104*) die "unsupported EAPI (${EAPI}) in eclass (${ECLASS})" ;;
Kenneth Waters512eb162010-06-02 10:19:12 -0700105esac
106
107cros-binary_check_file() {
Mike Frysingerc8e92f52017-06-08 20:50:34 -0400108 cros-binary_dead_usage
Kenneth Waters512eb162010-06-02 10:19:12 -0700109}
110
111cros-binary_fetch() {
Mike Frysinger7483e862015-11-30 16:44:40 -0500112 cros-binary_dead_usage
Kenneth Waters512eb162010-06-02 10:19:12 -0700113}
114
115cros-binary_src_unpack() {
Mike Frysinger7483e862015-11-30 16:44:40 -0500116 cros-binary_dead_usage
Kenneth Waters512eb162010-06-02 10:19:12 -0700117}
118
119cros-binary_src_install() {
Mike Frysingere9a29e92017-08-02 01:10:27 -0400120 cros-binary_dead_usage
Kenneth Waters512eb162010-06-02 10:19:12 -0700121}