cpt

[ARCHIVED] Carbs Packaging Tools
git clone git://git.ckyln.com/~cem/cpt.git
Log | Files | Refs | README | LICENSE

commit 565648c70f46b9211b96a1eff2894ec19480f5f8
parent 35edb789e5d85dca059883d6a56c5f460eb26683
Author: Cem Keylan <cem@ckyln.com>
Date:   Sat,  4 Apr 2020 20:42:35 +0300

contrib: add kiss-cargolock-urlgen

Diffstat:
Acontrib/kiss-cargolock-urlgen | 21+++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)

diff --git a/contrib/kiss-cargolock-urlgen 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