]>
Commit | Line | Data |
---|---|---|
8bba2981 | 1 | #!/bin/bash |
b1076f25 XL |
2 | # Run this script in an unpacked upstream tarball directory, and it will update |
3 | # (i.e. overwrite) the "unused deps" part of Files-Excluded in d/copyright. | |
8bba2981 XL |
4 | |
5 | set -e | |
6 | ||
b1076f25 XL |
7 | scriptdir=$(dirname "$(dirname "$(readlink -f "$0")")") |
8 | had_configure_upstream=$(if test -e "$scriptdir/debian/configure-upstream"; then echo true; else echo false; fi) | |
9 | ( cd "$scriptdir" && debian/rules debian/configure-upstream ) | |
10 | ||
11 | "$scriptdir/debian/configure-upstream" | |
12 | "$scriptdir/debian/ensure-patch" -N "$scriptdir/debian/patches/d-ignore-removed-submodules.patch" | |
13 | test -f src/Cargo.lock.orig || cp src/Cargo.lock src/Cargo.lock.orig | |
885d43c6 | 14 | ./x.py build nonexistent/path/to/trigger/cargo/metadata src/bootstrap |
b1076f25 | 15 | |
8bba2981 | 16 | not_needed() { |
b1076f25 | 17 | diff -ru src/Cargo.lock.orig src/Cargo.lock | grep '^-"checksum' | cut '-d ' -f2-3 |
8bba2981 XL |
18 | } |
19 | ||
20 | ghetto_parse_cargo() { | |
21 | cat "$1" \ | |
22 | | tr '\n' '\t' \ | |
23 | | sed -e 's/\t\[/\n[/g' \ | |
24 | | perl -ne 'print if s/^\[(?:package|project)\].*\tname\s*=\s*"(.*?)".*\tversion\s*=\s*"(.*?)".*/\1 \2/g' | |
25 | } | |
26 | ||
b1076f25 XL |
27 | pruned_paths() { |
28 | for i in src/vendor/*/Cargo.toml; do | |
29 | pkgnamever= | |
30 | pkgnamever=$(ghetto_parse_cargo "$i") | |
31 | if [ -z "$pkgnamever" ]; then | |
32 | echo >&2 "failed to parse: $i" | |
33 | exit 1 | |
34 | fi | |
35 | echo "$pkgnamever $i" | |
36 | done | grep -F -f <(not_needed) | cut '-d ' -f3 | while read x; do | |
bf621149 | 37 | echo " $(dirname $x)" |
b1076f25 XL |
38 | done |
39 | } | |
40 | ||
41 | header='# DO NOT EDIT below, AUTOGENERATED' | |
42 | footer='# DO NOT EDIT above, AUTOGENERATED' | |
43 | { | |
44 | echo "$header" | |
45 | pruned_paths | |
46 | echo "$footer" | |
47 | } > $scriptdir/debian/copyright.unused-deps | |
48 | ||
49 | cd $scriptdir/debian | |
50 | sed -i -e "/^$header/,/^$footer/d" -e '/^# unused dependencies/rcopyright.unused-deps' copyright | |
51 | rm copyright.unused-deps | |
52 | $had_configure_upstream || rm "$scriptdir/debian/configure-upstream" |