aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'dev-lang/rust/files/rehash-crate.sh')
-rw-r--r--dev-lang/rust/files/rehash-crate.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/dev-lang/rust/files/rehash-crate.sh b/dev-lang/rust/files/rehash-crate.sh
new file mode 100644
index 0000000..c43f542
--- /dev/null
+++ b/dev-lang/rust/files/rehash-crate.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+# $1 = crate patch file
+
+set -euf
+
+cargo='.cargo-checksum.json'
+
+grep -- '^[+][+][+] ' "${1:?}" | while read -r _ f; do
+ file="${f#*/}"
+ orig_sum="$(grep -Eo "\"${file}\":\"[0-9a-fA-F]+\"" "${cargo}" |
+ cut -d':' -f2 | tr -d '"')"
+ if [ -n "${orig_sum}" ]; then
+ sum="$(sha256sum "${file}")"
+ sed -i "s|${orig_sum}|${sum%% *}|" "${cargo}"
+ fi
+done
+
+exit 0