[Slackbuilds-users] Rust question for python3-bcrypt

Erich Ritz erich.public at protonmail.com
Wed Mar 8 14:07:14 UTC 2023


------- Original Message -------
On Wednesday, March 8th, 2023 at 4:09 AM, Arnaud via SlackBuilds-users <slackbuilds-users at slackbuilds.org> wrote:


> 
> 
> 
> Hi fellow Slack(Build)ers,
> 
> I have a package (namely python3-bcrypt) that recently added some Rust
> stuff.
> If we simply bump the version to 4.0.1, and add python3-setuptools-rust as
> requirement it builds fine.
> See files included for anyone wanting to try it.
> 
> It builds fine, but...
> It downloads a lot of crates.
> And that is not SBo policy to download stuff during a build.
> So I need to add those crates to the download URLs, and make the SlackBuild use
> them.
> 
> And I am not Rust-proficient.
> 
> Hence I'm asking for some help here on how to do that, and how to maintain it
> properly thereafter.
> 
> Thanks !
> 
> - Yth.

See for example https://slackbuilds.org/repository/15.0/system/bat/

The SlackBuild has an extra bit that forces cargo to look on the local filesystem instead of the net.

Additionally, here are my scripts to create the the "DOWNLOAD" and "MD5SUM" parts of the info file.  Someone has a better script posted on LQ which I can't find right now and never got around to integrating into my process.  It just creates pkg.info directly instead of having you copy and paste bits around.

$ cat download_and_extract.sh
PRGNAM="bat"
VERSION="0.22.1"
OWNER="sharkdp"

DOWNLOAD="https://github.com/$OWNER/$PRGNAM/archive/v$VERSION/$PRGNAM-$VERSION.tar.gz"

wget $DOWNLOAD
tar -xzf "$PRGNAM-$VERSION.tar.gz"
$ cat create_info.sh
#!/bin/bash

PKG="bat"
VERSION="0.22.0"

BASEURL="https://crates-io.s3-us-west-1.amazonaws.com/crates"

if [ ! -r vendor ] ; then
    mkdir vendor
fi

(
    cd vendor
    rm download.txt
    rm md5sum.txt

    grep -h -A 4 "\[\[package\]\]" \
            $(find "../$PKG-$VERSION" -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 crates\.io-index | \
            sed 's/ source=.* checksum\(=[0-9a-fA-F]\{64\}\)$/\1/' | sort -u | \
            while read -r dep ; do

        #echo "full string=$dep"
        cksum="$(printf "%s\n" "$dep" | cut -d= -f3)"
        ver="$(printf "%s\n" "$dep" | cut -d= -f2)"
        dep="$(printf "%s\n" "$dep" | cut -d= -f1)"

        #echo "ver=$ver  dep=$dep"
        #echo "checksum=$cksum"

        FILENAME="$dep-$ver.crate"
        URL="$BASEURL/$dep/$FILENAME"
        if [ ! -r "$FILENAME" ] ; then
            wget "$URL"
        fi

        downloadsum=$(sha256sum "$FILENAME" | cut -d' ' -f 1)
        if [ "$cksum" != "$downloadsum" ] ; then
            echo "sha256sum for $dep mismatch!"
            echo "Cargo.lock sha256sum=$cksum"
            echo "Downloaded sha256sum=$downloadsum"
            exit
        fi

        MD5SUM=$(md5sum "$FILENAME" | cut -d' ' -f 1)

        echo "          $URL \\" >> download.txt
        echo "        $MD5SUM \\" >> md5sum.txt
    done
)
$ 

Erich


More information about the SlackBuilds-users mailing list