Codebase list rust-libslirp / 86d6fa6
list-rdeps: hide cruft packages Ximin Luo 4 years ago
1 changed file(s) with 21 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
00 #!/bin/bash
11
22 set -e
3 shopt -s lastpipe # important for populating associative arrays via pipes
34
45 abort() { local x=$1; shift; for i in "$@"; do echo >&2 "$0: abort: $i"; done; exit "$x"; }
56
3233 aptitude versions --disable-columns -F '%p %t' --group-by=none "~rnative $1" || true
3334 }
3435
36 # versions of source packages in unstable. used to ignore cruft (i.e. binary
37 # packages left over in unstable after an update, no longer built by a source)
38 declare -A srcver
39 src_version() {
40 local src="$1"
41 if [ -z "${srcver[$src]}" ]; then
42 srcver["$src"]="$(apt_versions "librust-${src}-dev" | grep "$ARCHIVE" | cut '-d ' -f2)"
43 fi
44 echo "${srcver[$src]}"
45 }
46
3547 if [ -n "$INST_CACHE" ]; then
3648 inst_cache="$INST_CACHE"
3749 else
5870 # variables for BFS over rdeps
5971 declare -A seen
6072 declare -a queue
61 shopt -s lastpipe
6273
6374 list_rdeps() {
6475 pkg="${1//_/-}"
6677
6778 echo "Versions of rust-${pkg} in $ARCHIVE:"
6879 apt_versions "~e^rust-${pkg}$" | grep "$ARCHIVE" | sort | while read binpkg ver archive; do
80 if [ "$ver" != "$(src_version "$pkg")" ]; then continue; fi
6981 local stat="$(installability "$binpkg" "$ver")"
7082 printf "%s %-48s %-16s\n" "$stat" "$binpkg" "$ver"
7183 done
7284 echo
7385
7486 echo "Versions of rdeps of rust-${pkg} in $ARCHIVE, that also exist in $ARCHIVT:"
75 local versions="$(apt_versions "~D^librust-${pkg}~(\+~|-[0-9]~).*-dev$")"
76 printf "%s\n" "$versions" | grep "$ARCHIVE" | while read rdep ver archive; do
87 local rdeps="$(apt_versions "~D^librust-${pkg}~(\+~|-[0-9]~).*-dev$")"
88 printf "%s\n" "$rdeps" | grep "$ARCHIVE" | while read rdep ver archive; do
7789 # we're interested in packages in both archives.
78 if ! printf "%s\n" "$versions" | grep "$ARCHIVT" | grep -qF "$rdep"; then
90 if ! printf "%s\n" "$rdeps" | grep "$ARCHIVT" | grep -qF "$rdep"; then
7991 local rdepv="$(echo "$rdep" | sed -E -e 's/-[0-9.]+-dev$/-dev/')"
8092 # we're also interested in old-semver packages where the main version is in testing,
8193 # since this implies that we're interested in trying to migrate the old-semver package
82 if ! printf "%s\n" "$versions" | grep "$ARCHIVT" | grep -qF "$rdepv"; then
94 if ! printf "%s\n" "$rdeps" | grep "$ARCHIVT" | grep -qF "$rdepv"; then
8395 # if a rdep matches none of these, we're not interested (at this time) in migrating them;
8496 # they will show up on `dev/rust-excuses.mk` later in a more obvious way
8597 continue
90102 | cut -d: -f2 | cut '-d ' -f2- \
91103 | sed -z -e 's/\n\n/\t/g' -e 's/\n/ /g' -e 's/\t/\n/g'
92104 done | sort | while read rdep ver deps; do
93 local rustdeps="$(printf "%s" "$deps" | tr ',' '\n' | egrep -wo "librust-${pkg}(\+|-[0-9])\S*-dev[^,]*" | tr '\n' '\t' | sed -e 's/\t/, /g')"
94 local stat="$(installability "$rdep" "$ver")"
95 printf "%s %-48s %-16s depends on %s\n" "$stat" "$rdep" "$ver" "$rustdeps"
96105 local src="$(apt-cache show "$rdep=$ver" | grep-dctrl -n -sSource - | sed -Ee 's/^rust-(\S*).*/\1/g')"
97106 if [ -n "$src" ] && [ -z "${seen[$src]}" ]; then
98107 seen["$src"]="1"
99108 queue+=("$src") # subprocess, var doesn't write to parent
100109 fi
110 if [ "$ver" != "$(src_version "$src")" ]; then continue; fi
111 local rustdeps="$(printf "%s" "$deps" | tr ',' '\n' | egrep -wo "librust-${pkg}(\+|-[0-9])\S*-dev[^,]*" | tr '\n' '\t' | sed -e 's/\t/, /g')"
112 local stat="$(installability "$rdep" "$ver")"
113 printf "%s %-48s %-16s depends on %s\n" "$stat" "$rdep" "$ver" "$rustdeps"
101114 done
102115 echo
103116 }