aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-04-04 17:42:34 +0000
committermerakor <cem@ckyln.com>2020-04-04 17:42:34 +0000
commit6a3d8f9a449a0c9ee955c2422872607ec36c626b (patch)
treeab86f19e58e4326b6a0174a3c2f0614c9955ea0f /contrib
parent30000558407f29b4fde3c6780bbd91b01987ad3c (diff)
downloadcpt-6a3d8f9a449a0c9ee955c2422872607ec36c626b.tar.gz
contrib: add kiss-cargolock-urlgen
FossilOrigin-Name: ea230030c051cd92b8b4e3324f9ee1e11c768eca7b10565b6834cfb152f0de98
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/kiss-cargolock-urlgen21
1 files changed, 21 insertions, 0 deletions
diff --git a/contrib/kiss-cargolock-urlgen b/contrib/kiss-cargolock-urlgen
new file mode 100755
index 0000000..a67b374
--- /dev/null
+++ b/contrib/kiss-cargolock-urlgen
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# Converts the given Cargo.lock file to static cargo urls
+
+[ -r "$1" ] || {
+ printf 'usage: %s <Cargo.lock file>\n' "${0##*/}"
+ exit 1
+}
+
+# Word splitting is intentional
+# shellcheck disable=2046
+set -- $(sed '/name =/b;/version =/b;d' "$1" |
+ sed 's/version = /#/g;s/name = //;s/"//g' |
+ tr '\n' ' ' | sed 's/ #/#/g')
+
+# We convert the name-version seperator to '#' and back to '-'
+# to avoid issues that may arise from version names with a '-'
+for crate in "$@" ; do
+ printf 'https://static.crates.io/crates/%s/%s.crate vendor\n' \
+ "${crate%#*}" "$crate" | sed 's/#/-/g'
+done