blob: 79561f0083143158760e76008145d908be889ece [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() {
12 die "You must add files to SRC_URI now"
13}
14if [[ ${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
18fi
Brian Harringcf0c7662012-12-19 23:06:44 -080019
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).
25cros-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"
Brian Harringcf0c7662012-12-19 23:06:44 -080031 case "${uri}" in
32 http://*|https://*|gs://*)
33 SRC_URI+=" ${uri}"
Brian Harringcf0c7662012-12-19 23:06:44 -080034 ;;
35 *)
36 die "Unknown protocol: ${uri}"
37 ;;
38 esac
Mike Frysinger6300c4b2013-04-06 22:48:39 -040039 RESTRICT+=" mirror"
Mike Frysingera77ff1f2017-09-02 15:05:16 -040040
41 if [[ ${uri} =~ -r[0-9]+\.tbz2 ]]; then
42 ewarn "Tarballs should not encode ebuild rev numbers (-r#)."
43 ewarn "The ebuild revision field is only for changes to the ebuild itself."
44 ewarn "If you want to update the source tarball, update the PV instead."
45 ewarn " bad: foo-0.0.1-r8.tbz2 or foo-0.0.1.tbz2 -> foo-0.0.1-r1.tbz2"
46 ewarn " good: foo-0.0.8.tbz2 or foo-0.0.1.tbz2 -> foo-0.0.2.tbz2"
47 fi
Brian Harringcf0c7662012-12-19 23:06:44 -080048}
49
50# @ECLASS-FUNCTION: cros-binary_add_gs_uri
51# @DESCRIPTION:
52# Wrapper around cros-binary_add_uri. Invoked with 3 arguments;
53# the bcs user, the overlay, and the filename (or bcs://<uri> for
54# backwards compatibility).
55cros-binary_add_gs_uri() {
56 if [[ $# -ne 3 ]]; then
57 die "cros-binary_add_bcs_uri needs 3 arguments; $# given."
58 fi
59 # Strip leading bcs://...
60 [[ "${3:0:6}" == "bcs://" ]] && set -- "${1}" "${2}" "${3#bcs://}"
61 cros-binary_add_uri "gs://chromeos-binaries/HOME/$1/$2/$3"
62}
63
64# @ECLASS-FUNCTION: cros-binary_add_overlay_uri
65# @DESCRIPTION:
66# Wrapper around cros-binary_add_bcs_uri. Invoked with 2 arguments;
67# the basic board target (x86-alex for example), and the filename; that filename
68# is automatically prefixed with "${CATEGORY}/${PN}/" .
69cros-binary_add_overlay_uri() {
70 if [[ $# -ne 2 ]]; then
71 die "cros-binary_add_bcs_uri_simple needs 2 arguments; $# given."
72 fi
73 cros-binary_add_gs_uri bcs-"$1" overlay-"$1" "${CATEGORY}/${PN}/$2"
74}
75
Kenneth Waters512eb162010-06-02 10:19:12 -070076# @ECLASS-VARIABLE: CROS_BINARY_URI
77# @DESCRIPTION:
78# URI for the binary may be one of:
79# http://
80# https://
81# ssh://
Brian Harringcf0c7662012-12-19 23:06:44 -080082# gs://
Kenneth Waters512eb162010-06-02 10:19:12 -070083# file:// (file is relative to the files directory)
Brian Harringcf0c7662012-12-19 23:06:44 -080084# Additionally, all bcs ssh:// urls are rewritten to gs:// automatically
85# the appropriate GS bucket- although cros-binary_add_uri is the preferred
86# way to do that.
87# TODO: Deprecate this variable's support for ssh and http/https.
Kenneth Waters512eb162010-06-02 10:19:12 -070088: ${CROS_BINARY_URI:=}
Brian Harringcf0c7662012-12-19 23:06:44 -080089if [[ -n "${CROS_BINARY_URI}" ]]; then
90 cros-binary_add_uri "${CROS_BINARY_URI}"
91fi
Kenneth Waters512eb162010-06-02 10:19:12 -070092
Puneet Kumar0cc9c652010-08-25 13:35:17 -070093# @ECLASS-VARIABLE: CROS_BINARY_INSTALL_FLAGS
94# @DESCRIPTION:
95# Optional Flags to use while installing the binary
96: ${CROS_BINARY_INSTALL_FLAGS:=}
97
Allen Martin967a8242012-03-27 04:51:34 +000098# @ECLASS-VARIABLE: CROS_BINARY_LOCAL_URI_BASE
99# @DESCRIPTION:
100# Optional URI to override CROS_BINARY_URI location. If this variable
101# is used the filename from CROS_BINARY_URI will be used, but the path
102# to the binary will be changed.
103: ${CROS_BINARY_LOCAL_URI_BASE:=}
104
Mike Frysinger4ed918e2012-05-09 15:44:12 -0400105# Check for EAPI 2+
Kenneth Waters512eb162010-06-02 10:19:12 -0700106case "${EAPI:-0}" in
Mike Frysingerde80d302015-12-23 12:24:05 -05001072|3|4|5|6) ;;
108*) die "unsupported EAPI (${EAPI}) in eclass (${ECLASS})" ;;
Kenneth Waters512eb162010-06-02 10:19:12 -0700109esac
110
111cros-binary_check_file() {
Mike Frysingerc8e92f52017-06-08 20:50:34 -0400112 cros-binary_dead_usage
Kenneth Waters512eb162010-06-02 10:19:12 -0700113}
114
115cros-binary_fetch() {
Mike Frysinger7483e862015-11-30 16:44:40 -0500116 cros-binary_dead_usage
Kenneth Waters512eb162010-06-02 10:19:12 -0700117}
118
119cros-binary_src_unpack() {
Mike Frysinger7483e862015-11-30 16:44:40 -0500120 cros-binary_dead_usage
Kenneth Waters512eb162010-06-02 10:19:12 -0700121}
122
123cros-binary_src_install() {
Mike Frysinger08938db2017-08-02 01:07:51 -0400124 ewarn "cros-binary_src_install is deprecated."
125 ewarn "Please convert this ebuild to src_install and install files manually."
126
Mike Frysingerfdd64d52017-08-02 01:03:30 -0400127 local target="${DISTDIR}/${CROS_BINARY_URI##*/}"
Kenneth Waters512eb162010-06-02 10:19:12 -0700128 local extension="${CROS_BINARY_URI##*.}"
129 local flags
130
131 case "${CROS_BINARY_URI##*.}" in
132 gz|tgz) flags="z";;
133 bz2|tbz2) flags="j";;
134 *) die "Unsupported binary file format ${CROS_BINARY_URI##*.}"
135 esac
136
137 cd "${D}" || die
Mike Frysingerb39ef8a2017-06-08 20:51:35 -0400138 tar "${flags}xpf" "${target}" --no-same-owner ${CROS_BINARY_INSTALL_FLAGS} || die "Failed to unpack"
Kenneth Waters512eb162010-06-02 10:19:12 -0700139}
140
Mike Frysinger7483e862015-11-30 16:44:40 -0500141EXPORT_FUNCTIONS src_install
Kenneth Waters512eb162010-06-02 10:19:12 -0700142