5 # If running this script multiple times, set this to a path where we will
6 # write data to be re-used next time. This makes the script slightly
7 # quicker, but if the data is too old it will give inaccurate results.
10 shopt -s lastpipe
# important for populating associative arrays via pipes
12 abort
() { local x
=$1; shift; for i
in "$@"; do echo >&2 "$0: abort: $i"; done; exit "$x"; }
14 type grep-dctrl
>/dev
/null || abort
1 "grep-dctrl not found, install dctrl-tools"
15 type aptitude
>/dev
/null || abort
1 "aptitude not found, install it"
16 type gawk
>/dev
/null || abort
1 "gawk not found, install gawk"
18 ARCHIVE
="${ARCHIVE:-unstable}"
19 ARCHIVT
="${ARCHIVT:-testing}"
21 grep_sources_entry
() {
22 grep '^deb[^#]*://[^#[:space:]]*[[:space:]]*'"$@"
25 if ! grep_sources_entry
"$ARCHIVE" -qR /etc
/apt
/sources.list
/etc
/apt
/sources.list.d
/ || \
26 ! grep_sources_entry
"$ARCHIVT" -qR /etc
/apt
/sources.list
/etc
/apt
/sources.list.d
/; then
28 To make this script work, you will need Debian Testing *AND* Debian Unstable
29 in your sources.list. If you want your system to prefer Debian Testing, be
30 sure to also add these lines to your /etc/apt/apt.conf:
32 APT::Default-Release "$ARCHIVT";
34 After these changes, make sure to re-run \`apt-get update\`.
39 if [ $
(($
(date +%s
) - $
(stat
-c %Y
/var
/cache
/apt
/pkgcache.bin
))) -gt 7200 ]; then
40 read -p "APT cache is a bit old, update? [Y/n] " x
41 if [ "$x" != "n" ]; then sudo apt update
; fi
45 aptitude versions
--disable-columns -F '%e %p %t' --group-by=none
"~rnative $1" || true
48 all_rust_packages
="$(apt_versions "~e^rust-
")"
49 quick_apt_versions
() {
50 printf "%s\n" "$all_rust_packages" | gawk
"\$1 ~ /$1/ && \$2 ~ /$2/ && \$3 ~ /$3/ && \$4 ~ /$4/ { ${5:-print} }"
53 # versions of source packages in unstable. used to ignore cruft (i.e. binary
54 # packages left over in unstable after an update, no longer built by a source)
58 if [ -z "${srcver[$src]}" ]; then
59 srcver
["$src"]="$(quick_apt_versions "" "^librust-
${src}-dev$
" "" "\y
$ARCHIVE\y
" 'print $3')"
61 echo "${srcver[$src]}"
64 if [ -n "$INST_CACHE" ]; then
65 inst_cache
="$INST_CACHE"
68 # https://stackoverflow.com/a/14812383 inside "trap" avoids running handler twice
69 trap 'excode=$?; rm -rf "'"$inst_cache"'"; trap - EXIT' EXIT HUP INT QUIT PIPE TERM
73 local r
=$
(grep -F "$1=$2" "$inst_cache" | cut
-f2)
77 if apt
-t "$ARCHIVE" -s install "$1=$2" 2>/dev
/null
>/dev
/null
; then
82 printf "%s=%s\t%s\n" "$1" "$2" "$r" >> "$inst_cache"
87 # variables for BFS over rdeps
96 echo "Versions of rust-${pkg} in $ARCHIVE:"
97 quick_apt_versions
"^rust-${pkg}$" "" "" "\y$ARCHIVE\y" |
sort |
while read srcpkg binpkg ver archive
; do
98 if [ "$ver" != "$(src_version "$pkg")" ]; then continue; fi
99 local stat
="$(installability "$binpkg" "$ver")"
100 printf "%s %-48s %-16s\n" "$stat" "$binpkg" "$ver"
101 binpkgs
+=("$binpkg=$ver")
105 echo "Versions of rdeps of rust-${pkg} in $ARCHIVE, that also exist in $ARCHIVT:"
106 local rdeps
="$(apt_versions "~D^librust-
${pkg}~
(\
+~|
-[0-9]~
).
*-dev$
")"
107 printf "%s\n" "$rdeps" |
grep "$ARCHIVE" |
while read src rdep ver archive
; do
108 # we're interested in packages in both archives.
109 if ! printf "%s\n" "$rdeps" |
grep "$ARCHIVT" |
grep -qF "$rdep"; then
110 local rdepv
="$(echo "$rdep" | sed -E -e 's/-[0-9.]+-dev$/-dev/')"
111 # we're also interested in old-semver packages where the main version is in testing,
112 # since this implies that we're interested in trying to migrate the old-semver package
113 if ! printf "%s\n" "$rdeps" |
grep "$ARCHIVT" |
grep -qF "$rdepv"; then
114 # if a rdep matches none of these, we're not interested (at this time) in migrating them;
115 # they will show up on `dev/rust-excuses.mk` later in a more obvious way
119 apt-cache show
"${rdep}=${ver}" \
120 | grep-dctrl
-FDepends -e "librust-${pkg}(\+|-[0-9]).*-dev" -sPackage,Version
,Depends
- \
121 | cut
-d: -f2 | cut
'-d ' -f2- \
122 |
sed -z -e 's/\n\n/\t/g' -e 's/\n/ /g' -e 's/\t/\n/g'
123 done |
sort |
while read rdep ver deps
; do
124 local src
="$(apt-cache show "$rdep=$ver" | grep-dctrl -n -sSource - | sed -Ee 's/^rust-(\S*).*/\1/g')"
125 if [ -n "$src" ] && [ -z "${seen[$src]}" ]; then
127 queue
+=("$src") # subprocess, var doesn't write to parent
129 if [ "$ver" != "$(src_version "$src")" ]; then continue; fi
130 local rustdeps
="$(printf "%s
" "$deps" | tr ',' '\n' | grep -E -wo "librust-
${pkg}(\
+|
-[0-9])\S
*-dev[^
,]*" | tr '\n' '\t' | sed -e 's/\t/, /g')"
131 local stat
="$(installability "$rdep" "$ver")"
132 printf "%s %-48s %-16s depends on %s\n" "$stat" "$rdep" "$ver" "$rustdeps"
136 echo "Source packages in unstable whose autopkgtests are triggered by rust-$pkg:"
137 while [ -n "${binpkgs[0]}" ]; do
138 local binver
="${binpkgs[0]}"
139 binpkgs
=("${binpkgs[@]:1}")
141 local binpkg
="${binver/=*/}"
142 binpkg
="$(apt-cache show "$binver" | grep-dctrl -F Package -ns Package -s Provides -e "${binpkg//\+/\\+}" | tr '\n' '|' | sed -e 's/ \+\(([^)]*)\)\?,\? */|/g' -e 's/+/\\+/g' -e 's/|\+$//g' -e 's/|{2,}/|/g')"
143 # check for bin package + all its provided virtual feature packages in one go
144 grep-dctrl
-F Testsuite-Triggers
-s Package
,Version
-w "$binpkg" /var
/lib
/apt
/lists
/*_dists_
"$ARCHIVE"_
*_source_Sources
* \
145 | cut
-d: -f2 | cut
'-d ' -f2- \
146 |
sed -z -e 's/\n\n/\t/g' -e 's/\n/ /g' -e 's/\t/\n/g' \
147 |
while read triggered ver
; do
148 printf " %-48s %-16s triggered by %s\n" "$triggered" "$ver" "$binver"
154 if [ "$1" = "@" ]; then
157 while [ -n "${queue[0]}" ]; do
158 echo "queue: ${queue[@]}"
161 queue
=("${queue[@]:1}")
165 for i
in "$@"; do list_rdeps
"$i"; done
169 If any package is marked "X" (to the left of the package) it means it is not
170 installable even in $ARCHIVE - you should check why this is so by attempting to
171 install it yourself, e.g. via aptitude, and see why it can't be installed. This
172 must be fixed before migration is attempted. For example, it may depend on a
173 package which is not yet in Debian. Make sure you give the \`-t $ARCHIVE\` flag
174 so it chooses packages from the correct archive.
176 One common reason, for an rdep, is that its dependency is out of date - check
177 the "depends" column above to see if this is the case. If so, you must upgrade
178 it to the current version, by patching Cargo.toml to accept the new version of
179 the dependency. Of course, check that the build works - if it doesn't, then
180 you'll need to further patch the source code of the rdep to use the API of the
181 new version of the dependency.
183 Alternatively, if any rdep is obsolete (i.e. nothing else depends on it) then
184 you should file a RM request to remove it from the Debian archive. See the
185 section "Remove an obsolete package" in RELEASE.rst for instructions on that.