Codebase list rust-stfu8 / abc67bc
list-rdeps: ignore packages not in both unstable and testing Ximin Luo 4 years ago
1 changed file(s) with 33 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
00 #!/bin/bash
1
12 set -e
2 set -o pipefail
33
44 abort() { local x=$1; shift; for i in "$@"; do echo >&2 "$0: abort: $i"; done; exit "$x"; }
55
77 which aptitude >/dev/null || abort 1 "aptitude not found, install it"
88
99 ARCHIVE="${ARCHIVE:-unstable}"
10 ARCHIVT="${ARCHIVT:-testing}"
11
12 if ! grep "$ARCHIVE" -qR /etc/apt/sources.list /etc/apt/sources.list.d/ || \
13 ! grep "$ARCHIVT" -qR /etc/apt/sources.list /etc/apt/sources.list.d/; then
14 cat <<-eof
15 To make this script work, you will need Debian Testing *AND* Debian Unstable
16 in your sources.list. If you want your system to prefer Debian Testing, be
17 sure to also add these lines to your /etc/apt/apt.conf:
18
19 APT::Default-Release "$ARCHIVT";
20
21 After these changes, make sure to re-run \`apt-get update\`.
22 eof
23 exit 1
24 fi
1025
1126 if [ $(($(date +%s) - $(stat -c %Y /var/cache/apt/pkgcache.bin))) -gt 7200 ]; then
1227 read -p "APT cache is a bit old, update? [Y/n] " x
1429 fi
1530
1631 apt_versions() {
17 aptitude versions --disable-columns -F '%p %t' --group-by=none "~rnative $1" | grep "$ARCHIVE"
32 aptitude versions --disable-columns -F '%p %t' --group-by=none "~rnative $1" || true
1833 }
1934
20 inst_cache=$(mktemp)
21 # https://stackoverflow.com/a/14812383 inside "trap" avoids running handler twice
22 trap 'excode=$?; rm -rf "'"$inst_cache"'"; trap - EXIT' EXIT HUP INT QUIT PIPE TERM
35 if [ -n "$INST_CACHE" ]; then
36 inst_cache="$INST_CACHE"
37 else
38 inst_cache=$(mktemp)
39 # https://stackoverflow.com/a/14812383 inside "trap" avoids running handler twice
40 trap 'excode=$?; rm -rf "'"$inst_cache"'"; trap - EXIT' EXIT HUP INT QUIT PIPE TERM
41 fi
2342
2443 installability() {
2544 local r=$(grep -F "$1=$2" "$inst_cache" | cut -f2)
4160 pkg="${pkg#rust-}"
4261
4362 echo "Versions of rust-${pkg} in $ARCHIVE:"
44 apt_versions "~e^rust-${pkg}$" | sort | while read binpkg ver archive; do
63 apt_versions "~e^rust-${pkg}$" | grep "$ARCHIVE" | sort | while read binpkg ver archive; do
4564 local stat="$(installability "$binpkg" "$ver")"
4665 printf "%s %-48s %-16s\n" "$stat" "$binpkg" "$ver"
4766 done
4867 echo
4968
50 echo "Versions of rdeps of rust-${pkg} in $ARCHIVE:"
51 apt_versions "~D^librust-${pkg}~(\+~|-[0-9]~).*-dev$" | while read rdep ver archives; do
69 echo "Versions of rdeps of rust-${pkg} in $ARCHIVE, that also exist in $ARCHIVT:"
70 local versions="$(apt_versions "~D^librust-${pkg}~(\+~|-[0-9]~).*-dev$")"
71 printf "%s\n" "$versions" | grep "$ARCHIVE" | while read rdep ver archive; do
72 if ! printf "%s\n" "$versions" | grep "$ARCHIVT" | grep -qF "$rdep"; then
73 # we're only interested in packages in both archives.
74 # if a pkg-ver is not in either archive, this doesn't affect the migration process
75 continue
76 fi
5277 apt-cache show "${rdep}=${ver}" \
5378 | grep-dctrl -FDepends -e "librust-${pkg}(\+|-[0-9]).*-dev" -sPackage,Version,Depends - \
5479 | cut -d: -f2 | cut '-d ' -f2- \