From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Petazzoni Date: Sat, 19 Dec 2020 16:35:24 +0100 Subject: [Buildroot] [PATCH v2 11/12] support/download/cargo-post-process, package/pkg-cargo.mk: enable vendoring for Cargo packages In-Reply-To: <20201219153525.1361175-1-thomas.petazzoni@bootlin.com> References: <20201219153525.1361175-1-thomas.petazzoni@bootlin.com> Message-ID: <20201219153525.1361175-12-thomas.petazzoni@bootlin.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: buildroot@busybox.net This commit adds support/download/cargo-post-process to perform the vendoring on Cargo packages, and enables it in package/pkg-cargo.mk. Since it changes the contents of the tarballs for ripgrep and sentry-cli, it changes their hashes. To not have a different hash for the same version of ripgrep and sentry-cli, we bump their versions. It has to be done in the same commit as the Cargo vendoring to make the series bisectable. The _LICENSE variable of cargo packages is expanded with ", vendored dependencies licenses probably not listed" as currently for all packages, the licenses of the vendored dependencies are not taken into account. Signed-off-by: Thomas Petazzoni --- package/pkg-cargo.mk | 13 ++++++++-- package/ripgrep/ripgrep.hash | 2 +- package/ripgrep/ripgrep.mk | 2 +- package/sentry-cli/sentry-cli.hash | 2 +- package/sentry-cli/sentry-cli.mk | 2 +- support/download/cargo-post-process | 38 +++++++++++++++++++++++++++++ 6 files changed, 53 insertions(+), 6 deletions(-) create mode 100755 support/download/cargo-post-process diff --git a/package/pkg-cargo.mk b/package/pkg-cargo.mk index 058c6756bb..371b8dd424 100644 --- a/package/pkg-cargo.mk +++ b/package/pkg-cargo.mk @@ -37,10 +37,17 @@ define inner-cargo-package # We need host-rustc to run cargo -$(2)_DEPENDENCIES += host-rustc +$(2)_DOWNLOAD_DEPENDENCIES += host-rustc $(2)_CARGO_ENV += CARGO_HOME=$$(HOST_DIR)/share/cargo +$(2)_DOWNLOAD_POST_PROCESS = cargo +$(2)_DL_ENV = CARGO_HOME=$$(HOST_DIR)/share/cargo + +# Due to vendoring, it is pretty likely that not all licenses are +# listed in _LICENSE. +$(2)_LICENSE += , vendored dependencies licenses probably not listed + # Note: in all the steps below, we "cd" into the build directory to # execute the "cargo" tool instead of passing $(@D)/Cargo.toml as the # manifest-path. Indeed while the latter seems to work, it in fact @@ -50,7 +57,9 @@ $(2)_CARGO_ENV += CARGO_HOME=$$(HOST_DIR)/share/cargo # directory, its configuration file will not be taken into account. # # Also, we pass: -# * --offline to prevent cargo from downloading anything +# * --offline to prevent cargo from downloading anything: all +# dependencies should have been built by the download post +# process logic # * --locked to force cargo to use the Cargo.lock file, which ensures # that a fixed set of dependency versions is used diff --git a/package/ripgrep/ripgrep.hash b/package/ripgrep/ripgrep.hash index 0841c0185c..81ac905d3d 100644 --- a/package/ripgrep/ripgrep.hash +++ b/package/ripgrep/ripgrep.hash @@ -1,3 +1,3 @@ # Locally calculated -sha256 7035379fce0c1e32552e8ee528b92c3d01b8d3935ea31d26c51a73287be74bb3 ripgrep-0.8.1.tar.gz +sha256 80d7f07325f4d485c5e4baf061b0376b45a497ee7a1c540d7894057bb9ac3a59 ripgrep-12.1.1.tar.gz sha256 0f96a83840e146e43c0ec96a22ec1f392e0680e6c1226e6f3ba87e0740af850f LICENSE-MIT diff --git a/package/ripgrep/ripgrep.mk b/package/ripgrep/ripgrep.mk index 97e9e2ce5f..d21f88a6e8 100644 --- a/package/ripgrep/ripgrep.mk +++ b/package/ripgrep/ripgrep.mk @@ -4,7 +4,7 @@ # ################################################################################ -RIPGREP_VERSION = 0.8.1 +RIPGREP_VERSION = 12.1.1 RIPGREP_SITE = $(call github,burntsushi,ripgrep,$(RIPGREP_VERSION)) RIPGREP_LICENSE = MIT RIPGREP_LICENSE_FILES = LICENSE-MIT diff --git a/package/sentry-cli/sentry-cli.hash b/package/sentry-cli/sentry-cli.hash index 3b0733a276..63b0c812bc 100644 --- a/package/sentry-cli/sentry-cli.hash +++ b/package/sentry-cli/sentry-cli.hash @@ -1,3 +1,3 @@ # locally calculated -sha256 5d0f7acf6a139d1c1716b9a8ff76c8bfaab09104ba663c957bb9a5dba2ffbabd sentry-cli-1.57.0.tar.gz +sha256 a657dd1a46e3de044deff4c311b7276c5a9409582e707e6e6a78b0cf712591c4 sentry-cli-1.59.0.tar.gz sha256 9503def7b54ceb6e3cd182fd59bc05d3a30d7eae481e65aaba4b495133c83c14 LICENSE diff --git a/package/sentry-cli/sentry-cli.mk b/package/sentry-cli/sentry-cli.mk index 40ca22fdf9..58f5f1e325 100644 --- a/package/sentry-cli/sentry-cli.mk +++ b/package/sentry-cli/sentry-cli.mk @@ -4,7 +4,7 @@ # ################################################################################ -SENTRY_CLI_VERSION = 1.57.0 +SENTRY_CLI_VERSION = 1.59.0 SENTRY_CLI_SITE = $(call github,getsentry,sentry-cli,$(SENTRY_CLI_VERSION)) SENTRY_CLI_LICENSE = BSD-3-clause SENTRY_CLI_LICENSE_FILES = LICENSE diff --git a/support/download/cargo-post-process b/support/download/cargo-post-process new file mode 100755 index 0000000000..5081476385 --- /dev/null +++ b/support/download/cargo-post-process @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -e + +. $(dirname $0)/post-process-helpers + +while getopts "n:o:" OPT; do + case "${OPT}" in + o) output="${OPTARG}";; + n) base_name="${OPTARG}";; + :) error "option '%s' expects a mandatory argument\n" "${OPTARG}";; + \?) error "unknown option '%s'\n" "${OPTARG}";; + esac +done + +# Already vendored tarball, nothing to do +if tar tf ${output} | grep -q "^[^/]*/VENDOR" ; then + exit 0 +fi + +unpack ${base_name} ${output} + +# Do the Cargo vendoring +pushd ${base_name} > /dev/null +cargo vendor --locked VENDOR +echo $? +# Create the local .cargo/config with vendor info +mkdir -p .cargo/ +cat <.cargo/config +[source.crates-io] +replace-with = "vendored-sources" + +[source.vendored-sources] +directory = "VENDOR" +EOF +popd > /dev/null + +repack ${base_name} ${output} -- 2.29.2