From b850d3c241c880b784f790dc7869fbacfedbf0ea Mon Sep 17 00:00:00 2001 From: fsLeg Date: Sun, 15 Dec 2024 13:43:51 +0300 Subject: [PATCH] shadowsocks-rust: changes to vendoring crates --- shadowsocks-rust/README | 4 -- shadowsocks-rust/shadowsocks-rust.SlackBuild | 54 ++++++-------------- shadowsocks-rust/shadowsocks-rust.info | 12 ++--- 3 files changed, 22 insertions(+), 48 deletions(-) diff --git a/shadowsocks-rust/README b/shadowsocks-rust/README index 51baed5..a53527e 100644 --- a/shadowsocks-rust/README +++ b/shadowsocks-rust/README @@ -1,7 +1,3 @@ A Rust port of shadowsocks that superceded shadowsocks-libev. Shadowsocks is a fast tunnel proxy that helps you bypass firewalls. - -This SlackBuild downloads nessessary crates to build the binaries, -so internet connection is required. Then again, if you're going to -use Shadowsocks, it shouldn't be a problem. diff --git a/shadowsocks-rust/shadowsocks-rust.SlackBuild b/shadowsocks-rust/shadowsocks-rust.SlackBuild index 5dbcfd6..e2123da 100755 --- a/shadowsocks-rust/shadowsocks-rust.SlackBuild +++ b/shadowsocks-rust/shadowsocks-rust.SlackBuild @@ -82,7 +82,7 @@ mkdir -p $TMP $PKG $OUTPUT cd $TMP rm -rf $PRGNAM-$VERSION -# Check whether content-disposition was used to download the sources +# Check whether content-disposition was used to download the tarball if [ -f $CWD/$PRGNAM-$VERSION.tar.gz ]; then tar xvf $CWD/$PRGNAM-$VERSION.tar.gz elif [ -f $CWD/v$VERSION.tar.gz ]; then @@ -104,46 +104,24 @@ replace-with = 'vendored-sources' directory = '$(pwd)/vendor' EOF -# deps and versions come from Cargo.lock +# Unpack crates and vendor them mkdir vendor ( cd vendor - grep -h -A 4 "\[\[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, $5 }' | \ - sed 's/"//g;s/name=//;s/ version=/=/' | \ - grep " source=" | \ - sed 's/ dependencies=.*$//' | \ - sed 's/ source=[^ ]*//' | \ - sed 's/ checksum=/=/' | \ - sort -u | \ - while read -r dep ; do - - cksum="$(printf "%s\n" "$dep" | cut -d= -f3)" - 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": "%s"' "$cksum" - - printf "}\n" - } > $dep-$ver/.cargo-checksum.json + for CRATE in ${CWD}/*.crate; do + CRATE_CHECKSUM=$(sha256sum ${CRATE} | cut -d' ' -f1) + tar xf ${CRATE} + cd $(basename ${CRATE%.crate}) + touch .cargo-ok + JSON='{"files":{' + for FILE in $(find -type f | sed 's/\.\///g'); do + CHECKSUM=$(sha256sum ${FILE} | cut -d' ' -f1) + JSON="${JSON}\"${FILE}\":\"${CHECKSUM}\"," + done + JSON="${JSON%,}},\"package\":\"${CRATE_CHECKSUM}\"}" + echo ${JSON} > .cargo-checksum.json + cd .. done ) @@ -162,7 +140,7 @@ else export LD_LIBRARY_PATH="/opt/rust/lib$LIBDIRSUFFIX:$LD_LIBRARY_PATH" fi -# Compile the binaries; internet access is required +# Compile the binaries CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCFLAGS" \ RUSTFLAGS="-C target-cpu=native" \ diff --git a/shadowsocks-rust/shadowsocks-rust.info b/shadowsocks-rust/shadowsocks-rust.info index feb8aa2..0dfc6ba 100644 --- a/shadowsocks-rust/shadowsocks-rust.info +++ b/shadowsocks-rust/shadowsocks-rust.info @@ -320,10 +320,10 @@ DOWNLOAD="https://github.com/shadowsocks/shadowsocks-rust/archive/v1.21.2/shadow https://static.crates.io/crates/serde_yaml/serde_yaml-0.9.34+deprecated.crate \ https://static.crates.io/crates/sha1/sha1-0.10.6.crate \ https://static.crates.io/crates/sha2/sha2-0.10.8.crate \ - https://static.crates.io/crates/shadowsocks/shadowsocks-1.21.0.crate \ + https://static.crates.io/crates/sha2/sha2-1.21.0.crate \ https://static.crates.io/crates/shadowsocks-crypto/shadowsocks-crypto-0.5.5.crate \ - https://static.crates.io/crates/shadowsocks-rust/shadowsocks-rust-1.21.2.crate \ - https://static.crates.io/crates/shadowsocks-service/shadowsocks-service-1.21.2.crate \ + https://static.crates.io/crates/shadowsocks-crypto/shadowsocks-crypto-1.21.2.crate \ + https://static.crates.io/crates/shadowsocks-crypto/shadowsocks-crypto-1.21.2.crate \ https://static.crates.io/crates/sharded-slab/sharded-slab-0.1.7.crate \ https://static.crates.io/crates/shlex/shlex-1.3.0.crate \ https://static.crates.io/crates/signal-hook-registry/signal-hook-registry-1.4.2.crate \ @@ -778,10 +778,10 @@ MD5SUM="0360ef67392ffbaa38ea53c76f323cd5 \ 39e3168b0ff2d77bcca05882310b2a06 \ d7602381c0bc21d10603cc940a837b06 \ 289b776935f2184c6ba2974877285013 \ - d8f8afb169fe1d8e464a271fd02a1be4 \ + 3172cc7eed7041f89d35715a93cac031 \ cbac6a37ea78204d483d4d224de6ab90 \ - b72a97d898d0df4d078419d1cda9a936 \ - 9f908ee8b2b1ed9847a7bc7da3231a9c \ + 7558b0d6a956faf7f1644b6fc7f53755 \ + c2fdaa2514e053b8a3180b528724696e \ 96261f3cee18842060fd64d618e056d8 \ 6c623a8eed8450399ec323a72e96855c \ a77d5770902a4260009320daafd1fff2 \ -- 2.46.3