aboutsummaryrefslogtreecommitdiff
path: root/python/cryptography/cryptography.SlackBuild
diff options
context:
space:
mode:
authorAndrew Clemons <andrew.clemons@gmail.com>2021-10-24 22:10:18 +1300
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2021-10-27 08:40:37 +0700
commit5610d162930ea422f5c38dad8c22c1afab4bd7bf (patch)
treeaa6c618d7501a2e8cdf7b535f392b648b20783b5 /python/cryptography/cryptography.SlackBuild
parent472a754492f9c7856ea21ea38af27a38309488a4 (diff)
python/cryptography: Fix offline build.
The rust component tries to download crates during the build. Signed-off-by: Andrew Clemons <andrew.clemons@gmail.com> Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'python/cryptography/cryptography.SlackBuild')
-rw-r--r--python/cryptography/cryptography.SlackBuild53
1 files changed, 53 insertions, 0 deletions
diff --git a/python/cryptography/cryptography.SlackBuild b/python/cryptography/cryptography.SlackBuild
index a2a609684dde0..7fa20362b6f33 100644
--- a/python/cryptography/cryptography.SlackBuild
+++ b/python/cryptography/cryptography.SlackBuild
@@ -71,6 +71,59 @@ cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
cd $PRGNAM-$VERSION
+
+# build offline
+# configuration tells cargo to use the configured directory
+# for dependencies intead of downloading from crates.io
+mkdir .cargo
+cat << EOF >> .cargo/config
+[source.crates-io]
+registry = 'https://github.com/rust-lang/crates.io-index'
+replace-with = 'vendored-sources'
+
+[source.vendored-sources]
+directory = '$(pwd)/src/rust/vendor'
+EOF
+
+(
+ cd src/rust
+
+ # deps and versions come from Cargo.lock
+ mkdir vendor
+ cd vendor
+
+ grep -h -A 3 "\[\[package\]\]" $(find ../ -maxdepth 1 -mindepth 1 -name Cargo.lock | tr '\n' ' ') | \
+ sed 's/[[:space:]]*=[[:space:]]*/=/g;s/^--//;s/^\[\[/--\n[[/' | \
+ awk 'BEGIN { RS = "--\n" ; FS="\n" } { print $2, $3, $4 }' | sed 's/"//g;s/name=//;s/ version=/=/' | \
+ grep crates\.io-index | sed 's/ source=.*$//' | sort -u | while read -r dep ; do
+
+ ver="$(printf "%s\n" "$dep" | cut -d= -f2)"
+ dep="$(printf "%s\n" "$dep" | cut -d= -f1)"
+
+ tar xvf $CWD/$dep-$ver.crate
+
+ touch $dep-$ver/.cargo-ok
+
+ # generate checksum
+ {
+ printf "{\n"
+ printf ' "files": {\n'
+
+ (
+ cd $dep-$ver
+ find . -type f -print0 | xargs -0 sha256sum | sed -n '/\.cargo-checksum\.json/!p' | sed 's/\.\///;s/^\([^ ]*\)[[:space:]][[:space:]]*\(.*\)$/"\2":"\1",/'
+ ) | sed '$ s/,$//'
+
+ printf " },\n"
+ printf ' "package": "'
+
+ sha256sum "$CWD/$dep-$ver.crate" | cut -f1 -d' ' | sed 's/$/"/'
+
+ printf "}\n"
+ } > $dep-$ver/.cargo-checksum.json
+ done
+)
+
chown -R root:root .
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \