#!/bin/bash # Run this script in an unpacked upstream tarball directory, and it will update # (i.e. overwrite) the "unused deps" part of Files-Excluded in d/copyright. set -e scriptdir=$(dirname "$(dirname "$(readlink -f "$0")")") had_config_toml=$(if test -e "$scriptdir/debian/config.toml"; then echo true; else echo false; fi) ( cd "$scriptdir" && debian/rules debian/config.toml ) cp "$scriptdir/debian/config.toml" config.toml for i in "$scriptdir/debian/patches"/d-00*.patch; do "$scriptdir/debian/ensure-patch" -N "$i" done test -f Cargo.lock.orig || cp Cargo.lock Cargo.lock.orig test -f src/bootstrap/Cargo.lock.orig || cp src/bootstrap/Cargo.lock src/bootstrap/Cargo.lock.orig test -f src/tools/rust-analyzer/Cargo.lock.orig || cp src/tools/rust-analyzer/Cargo.lock src/tools/rust-analyzer/Cargo.lock.orig test -f src/tools/cargo/Cargo.lock.orig || cp src/tools/cargo/Cargo.lock src/tools/cargo/Cargo.lock.orig rm -f Cargo.lock src/bootstrap/Cargo.lock src/tools/rust-analyzer/Cargo.lock src/tools/cargo/Cargo.lock find vendor -name .cargo-checksum.json -execdir "$scriptdir/debian/prune-checksums" "{}" + # TEMP: cc 1.0.83 is broken, see https://github.com/rust-lang/cc-rs/issues/913 # this forces a downgrade to 1.0.79, and can be removed once a fixed version is vendored rm -rf vendor/cc # re-generate Cargo.lock after patching cargo update --offline # temporary, versions until 1.85 are broken for bootstrapping, and this would pick up 1.83 otherwise # re-generate src/bootstrap/Cargo.lock after patching (cd src/bootstrap && cargo update --offline) # re-generate src/tools/rust-analyzer/Cargo.lock after patching ( cd src/tools/rust-analyzer && cargo update --offline ) # re-generate src/tools/cargo/Cargo.lock after patching ( cd src/tools/cargo && cargo update --offline ) needed_crates() { cat Cargo.lock \ src/bootstrap/Cargo.lock \ src/tools/rust-analyzer/Cargo.lock \ src/tools/cargo/Cargo.lock \ | sed -z -e 's/\nname = /name = /g' -e 's/\nversion = /version = /g' \ | sed -ne 's/\[\[package\]\]name = "\(.*\)"version = "\(.*\)"/\1 \2/gp' } ghetto_parse_cargo() { cat "$1" \ | tr '\n' '\t' \ | sed -e 's/\t\[/\n[/g' \ | perl -ne 'print if s/^\[(?:package|project)\].*\tname\s*=\s*"(.*?)".*\tversion\s*=\s*"(.*?)".*/\1 \2/g' } pruned_paths() { for i in vendor/*/Cargo.toml; do pkgnamever= pkgnamever=$(ghetto_parse_cargo "$i") if [ -z "$pkgnamever" ]; then echo >&2 "failed to parse: $i" exit 1 fi echo "$pkgnamever $i" done | grep -v -F -f <(needed_crates) | cut '-d ' -f3 | while read x; do echo " $(dirname $x)" done } header='# DO NOT EDIT below, AUTOGENERATED' footer='# DO NOT EDIT above, AUTOGENERATED' { echo "$header" pruned_paths echo "$footer" } > $scriptdir/debian/copyright.unused-deps cd $scriptdir/debian sed -i -e "/^$header/,/^$footer/d" -e '/^# unused dependencies/rcopyright.unused-deps' copyright rm copyright.unused-deps $had_config_toml || rm "$scriptdir/debian/config.toml"