]> git.proxmox.com Git - cargo.git/commitdiff
debian-cargo-vendor: use "cargo lock list" to parse Cargo.lock
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Wed, 27 May 2020 21:10:39 +0000 (09:10 +1200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 28 Jul 2020 12:51:29 +0000 (14:51 +0200)
At some point, cargo vendor has changed to generate V2 Cargo.lock files,
which don't work with the "parsing" debian-cargo-vendor does to find
which vendored packages are no longer needed. Switch to using "cargo
lock list" to extract the sets of packages before and after the pruning.

debian/scripts/debian-cargo-vendor

index 5dc3b6e44038f2df499aa4acaa1fc0f9334638ef..5e1d59fec20188ac3d38d18acbf569bc85cdd0dc 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# To run this, you need to first install cargo-vendor.
+# To run this, you need to first install cargo-lock.
 #
 # TODO: this script has a known bug in: if the Debian patches being applied,
 # changes the set of dependencies, then "cargo vendor" is not re-run in order
@@ -11,7 +11,7 @@ set -e
 SCRIPTDIR="$(dirname "$(readlink -f "$0")")"
 
 not_needed() {
-       diff -ru Cargo.lock.orig Cargo.lock | grep '^-"checksum' | cut '-d ' -f2-3
+       diff -ur packages-before packages-after | grep "^-- " | cut -d' ' -f2-3
 }
 
 ghetto_parse_cargo() {
@@ -50,6 +50,7 @@ replace-with = "vendored-sources"
 directory = "$PWD/vendor"
 eof
 cargo update
+cargo lock list > packages-before
 cp Cargo.lock Cargo.lock.orig
 
 if [ -d debcargo-conf ]; then ( cd debcargo-conf && git pull );
@@ -105,6 +106,7 @@ done; $x ); do
 done
 find vendor/*/debian/patches -name '*~' -delete || true
 cargo update
+cargo lock list > packages-after
 pruned_paths | while read x; do echo >&2 "$0: removing, because debcargo-conf patches makes it obsolete: $x"; rm -rf "$x"; done
 
 # remove excluded files
@@ -152,7 +154,7 @@ fi
 )
 
 echo >&2 "$0: cleaning up..."
-rm -rf .cargo Cargo.lock debcargo-conf
+rm -rf .cargo Cargo.lock debcargo-conf packages-before packages-after
 
 echo >&2 "$0: restoring original Cargo.lock"
 mv Cargo.lock.orig Cargo.lock