summaryrefslogtreecommitdiffstats
path: root/python/python3-bcrypt/python3-bcrypt.SlackBuild
diff options
context:
space:
mode:
Diffstat (limited to 'python/python3-bcrypt/python3-bcrypt.SlackBuild')
-rw-r--r--python/python3-bcrypt/python3-bcrypt.SlackBuild114
1 files changed, 110 insertions, 4 deletions
diff --git a/python/python3-bcrypt/python3-bcrypt.SlackBuild b/python/python3-bcrypt/python3-bcrypt.SlackBuild
index c2155df029..9d7fc49b58 100644
--- a/python/python3-bcrypt/python3-bcrypt.SlackBuild
+++ b/python/python3-bcrypt/python3-bcrypt.SlackBuild
@@ -24,7 +24,7 @@ cd $(dirname $0) ; CWD=$(pwd)
PRGNAM=python3-bcrypt
SRCNAM=${PRGNAM#python3-*}
-VERSION=${VERSION:-3.2.2}
+VERSION=${VERSION:-4.1.2}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}
@@ -35,11 +35,14 @@ if [ -z "$ARCH" ]; then
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
+
+ if [ "$ARCH" = "i586" ]; then
+ if rustc -Vv | grep host | grep i686 > /dev/null ; then
+ ARCH=i686
+ fi
+ fi
fi
-# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
-# the name of the created package would be, and then exit. This information
-# could be useful to other scripts.
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
exit 0
@@ -49,6 +52,27 @@ TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
+if [ "$ARCH" = "i586" ]; then
+ SLKCFLAGS="-O2 -march=i586 -mtune=i686"
+ LIBDIRSUFFIX=""
+ CARGOTARGET="--target $ARCH-unknown-linux-gnu"
+elif [ "$ARCH" = "i686" ]; then
+ SLKCFLAGS="-O2 -march=i686 -mtune=i686"
+ LIBDIRSUFFIX=""
+ CARGOTARGET="--target $ARCH-unknown-linux-gnu"
+elif [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "aarch64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+ CARGOTARGET="--target $ARCH-unknown-linux-gnu"
+elif [ "$ARCH" = "aarch64" ]; then
+ SLKCFLAGS="-O2 -fPIC"
+ LIBDIRSUFFIX="64"
+else
+ SLKCFLAGS="-O2"
+ LIBDIRSUFFIX=""
+ CARGOTARGET=""
+fi
+
set -e
rm -rf $PKG
@@ -57,6 +81,79 @@ cd $TMP
rm -rf $SRCNAM-$VERSION
tar xvf $CWD/$SRCNAM-$VERSION.tar.gz
cd $SRCNAM-$VERSION
+
+# Using more recent rust version
+export PATH="/opt/rust16/bin:$PATH"
+if [ -z "$LD_LIBRARY_PATH" ]; then
+ export LD_LIBRARY_PATH="/opt/rust16/lib$LIBDIRSUFFIX"
+else
+ export LD_LIBRARY_PATH="/opt/rust16/lib$LIBDIRSUFFIX:$LD_LIBRARY_PATH"
+fi
+
+# build offline
+# configuration tells cargo to use the configured directory
+# for dependencies intead of downloading from crates.io
+mkdir .cargo
+cat << EOF >> .cargo/config.toml
+[source]
+[source.crates-io]
+replace-with = "vendored-sources"
+
+[source.vendored-sources]
+directory = "vendor"
+EOF
+
+# deps and versions come from Cargo.lock
+mkdir vendor
+(
+ cd vendor
+
+ grep -h -A 4 "\[\[package\]\]" \
+ $(find "../" -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)"
+
+ CRATE_FILE=$CWD/$dep-$ver.crate
+
+ if [ -z "$cksum" ] ; then
+ mkdir $dep-$ver
+ tar xvf $CRATE_FILE -C $dep-$ver --strip-components=1
+ cksum="null"
+ else
+ tar xvf $CRATE_FILE
+ fi
+
+ 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
+ done
+)
+
chown -R root:root .
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
@@ -64,8 +161,17 @@ find -L . \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
+PYVER=$(python3 -c 'import sys; print("%d.%d" % sys.version_info[:2])')
+export PYTHONPATH=/opt/python$PYVER/site-packages/
+
+CARGO_HOME=.cargo \
+CFLAGS="$SLKCFLAGS" \
+CXXFLAGS="$SLKCFLAGS" \
python3 setup.py install --root=$PKG
+find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
+ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
+
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a README.rst LICENSE MANIFEST.in $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild