diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2021-07-03 22:39:47 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2021-07-03 22:39:47 +0100 |
commit | 7f0ccc917c7abe6223784c703d86cd14755691fb (patch) | |
tree | 8c6793f68896b341e22f33d7e6cef88e481f4a8b /eclass/cargo.eclass | |
parent | 9aa80713372911cec499b3adb2cd746790920916 (diff) |
gentoo resync : 03.07.2021
Diffstat (limited to 'eclass/cargo.eclass')
-rw-r--r-- | eclass/cargo.eclass | 78 |
1 files changed, 63 insertions, 15 deletions
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass index 15b9d455bdef..938511e410fc 100644 --- a/eclass/cargo.eclass +++ b/eclass/cargo.eclass @@ -7,20 +7,38 @@ # @AUTHOR: # Doug Goldstein <cardoe@gentoo.org> # Georgy Yakovlev <gyakovlev@genotoo.org> -# @SUPPORTED_EAPIS: 7 +# @SUPPORTED_EAPIS: 7 8 # @BLURB: common functions and variables for cargo builds if [[ -z ${_CARGO_ECLASS} ]]; then _CARGO_ECLASS=1 -# we need this for 'cargo vendor' subcommand and net.offline config knob -RUST_DEPEND=">=virtual/rust-1.37.0" +# check and document RUST_DEPEND and options we need below in case conditions. +# https://github.com/rust-lang/cargo/blob/master/CHANGELOG.md +RUST_DEPEND="virtual/rust" case "${EAPI:-0}" in 0|1|2|3|4|5|6) die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" ;; 7) + # 1.37 added 'cargo vendor' subcommand and net.offline config knob + RUST_DEPEND=">=virtual/rust-1.37.0" + ;; + + 8) + # 1.39 added --workspace + # 1.46 added --target dir + # 1.48 added term.progress config option + # 1.51 added split-debuginfo profile option + # 1.52 may need setting RUSTC_BOOTSTRAP envvar for some crates + # 1.53 added cargo update --offline, can be used to update vulnerable crates from pre-fetched registry without editing toml + RUST_DEPEND=">=virtual/rust-1.53" + + if [[ -z ${CRATES} && "${PV}" != *9999* ]]; then + eerror "undefined CRATES variable in non-live EAPI=8 ebuild" + die "CRATES variable not defined" + fi ;; *) die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" @@ -39,6 +57,24 @@ IUSE="${IUSE} debug" ECARGO_HOME="${WORKDIR}/cargo_home" ECARGO_VENDOR="${ECARGO_HOME}/gentoo" +# @ECLASS-VARIABLE: CRATES +# @DEFAULT_UNSET +# @PRE_INHERIT +# @DESCRIPTION: +# bash string containing all crates package wants to download +# used by cargo_crate_uris() +# Example: +# @CODE +# CRATES=" +# metal-1.2.3 +# bar-4.5.6 +# iron_oxide-0.0.1 +# " +# inherit cargo +# ... +# SRC_URI="$(cargo_crate_uris)" +# @CODE + # @ECLASS-VARIABLE: CARGO_OPTIONAL # @DEFAULT_UNSET # @PRE_INHERIT @@ -101,10 +137,22 @@ ECARGO_VENDOR="${ECARGO_HOME}/gentoo" # @FUNCTION: cargo_crate_uris # @DESCRIPTION: # Generates the URIs to put in SRC_URI to help fetch dependencies. +# Uses first argument as crate list. +# If no argument provided, uses CRATES variable. cargo_crate_uris() { local -r regex='^([a-zA-Z0-9_\-]+)-([0-9]+\.[0-9]+\.[0-9]+.*)$' - local crate - for crate in "$@"; do + local crate crates + + if [[ -n ${@} ]]; then + crates="$@" + elif [[ -n ${CRATES} ]]; then + crates="${CRATES}" + else + eerror "CRATES variable is not defined and nothing passed as argument" + die "Can't generate SRC_URI from empty input" + fi + + for crate in ${crates}; do local name version url [[ $crate =~ $regex ]] || die "Could not parse name and version from crate: $crate" name="${BASH_REMATCH[1]}" @@ -184,15 +232,6 @@ cargo_src_unpack() { fi eend $? ;; - cargo-snapshot*) - ebegin "Unpacking ${archive}" - mkdir -p "${S}"/target/snapshot - tar -xzf "${DISTDIR}"/${archive} -C "${S}"/target/snapshot --strip-components 2 || die - # cargo's makefile needs this otherwise it will try to - # download it - touch "${S}"/target/snapshot/bin/cargo || die - eend $? - ;; *) unpack ${archive} ;; @@ -376,7 +415,16 @@ cargo_src_install() { rm -f "${ED}/usr/.crates.toml" || die rm -f "${ED}/usr/.crates2.json" || die - [ -d "${S}/man" ] && doman "${S}/man" || return 0 + # it turned out to be non-standard dir, so get rid of it future EAPI + # and only run for EAPI=7 + # https://bugs.gentoo.org/715890 + case ${EAPI:-0} in + 7) + if [ -d "${S}/man" ]; then + doman "${S}/man" || return 0 + fi + ;; + esac } # @FUNCTION: cargo_src_test |