diff options
| author | Danilo M. <danix@danix.xyz> | 2026-06-26 10:07:36 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-06-26 10:07:36 +0200 |
| commit | 3800559f3301343abc49c5db7543001a9c5b8dde (patch) | |
| tree | f9e1e3b530633223be4d56a6a85f2c8bbaecc150 | |
| parent | 07ca5beb3738aa09cba308787a3250602f417b42 (diff) | |
| download | my-slackbuilds-3800559f3301343abc49c5db7543001a9c5b8dde.tar.gz my-slackbuilds-3800559f3301343abc49c5db7543001a9c5b8dde.zip | |
cargo-vendor-filterer: add version 0.5.18
Import the existing SlackBuilds.org package (maintainer fourtysixandtwo)
verbatim to test whether it builds on -current with the system Rust
toolchain instead of rust-opt. Only change is the SlackBuild file mode
(0755 -> 0644) to satisfy sbolint.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| -rw-r--r-- | .extras/nvchecker.toml | 6 | ||||
| -rw-r--r-- | cargo-vendor-filterer/README | 10 | ||||
| -rw-r--r-- | cargo-vendor-filterer/cargo-mkvendored.sh | 151 | ||||
| -rw-r--r-- | cargo-vendor-filterer/cargo-vendor-filterer.SlackBuild | 132 | ||||
| -rw-r--r-- | cargo-vendor-filterer/cargo-vendor-filterer.info | 12 | ||||
| -rw-r--r-- | cargo-vendor-filterer/slack-desc | 19 |
6 files changed, 330 insertions, 0 deletions
diff --git a/.extras/nvchecker.toml b/.extras/nvchecker.toml index c4365f3..c13be74 100644 --- a/.extras/nvchecker.toml +++ b/.extras/nvchecker.toml @@ -106,3 +106,9 @@ use_max_tag = true [playwright-cli] source = "npm" npm = "@playwright/cli" + +[cargo-vendor-filterer] +source = "github" +github = "coreos/cargo-vendor-filterer" +use_max_tag = true +prefix = "v" diff --git a/cargo-vendor-filterer/README b/cargo-vendor-filterer/README new file mode 100644 index 0000000..83f9687 --- /dev/null +++ b/cargo-vendor-filterer/README @@ -0,0 +1,10 @@ +cargo-vendor-filterer (Vendor rust libraries based on filters) + +cargo-vendor-filterer works like "cargo vendor", but supports filters +that allow excluding libraries one isn't interested in, like +libraries only needed on other platforms, etc. + +NOTE: +I've included a "cargo-mkvendored.sh" script to generate filtered +vendored sources for a rust or python/rust slackbuild. It needs to be +run from within a slackbuild directory. diff --git a/cargo-vendor-filterer/cargo-mkvendored.sh b/cargo-vendor-filterer/cargo-mkvendored.sh new file mode 100644 index 0000000..8ba7aa2 --- /dev/null +++ b/cargo-vendor-filterer/cargo-mkvendored.sh @@ -0,0 +1,151 @@ +#!/bin/bash + +# Create $PRGNAM-vendored-sources-$VERSION-$VSBUILD.tar.xz +# Requires network access, but does not require root privilege. +# Requires that $PRGNAM's REQUIRES need to be installed first (rust-opt) +# and cargo-vendor-filterer installed to include just the linux deps +# +# Expects to be run within a slackbuild dir with the source archive +# already downloaded. +# +# Variables to use in your SlackBuild: +# VSBUILD # same use as BUILD but for vendored sources +# VSDIR=/sub/dir/ # (optional) alternate location in src for vendor dir +# +# Vendors sources for the following targets +# i686-unknown-linux-gnu +# x86_64-unknown-linux-gnu +# arm-unknown-linux-gnueabihf +# aarch64-unknown-linux-gnu + +SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date +%s)}" + +INFO="$( echo *.info )" +if [ ! -e "$INFO" ]; then + echo "No (or multiple) .info file in current dir" 1>&2 + exit 1 +fi + +SBUILD="$( echo *.SlackBuild )" +if [ ! -e "$SBUILD" ]; then + echo "No (or multiple) .SlackBuild file in current dir" 1>&2 + exit 1 +fi + +CWD=$(pwd) +source ./$INFO + +INFOERR="variable not set, are you sure you have a valid *.info file?" +echo ${PRGNAM:?$INFOERR} +echo VERSION=${VERSION:?$INFOERR} + +set -e +WORKDIR=$( mktemp -d ) +cd $WORKDIR + +# don't depend on user's ~/.cargo +mkdir -p cargohome +export CARGO_HOME=$(pwd)/cargohome + +egrep "^BUILD=|^VSBUILD=|^VSDIR=|^SRCNAM=" $CWD/$SBUILD > sbvars +source ./sbvars + +# if no SRCNAM in slackbuild set to PRGNAM +SRCNAM=${SRCNAM:-$PRGNAM} + +tar xvf $CWD/$SRCNAM-$VERSION.tar.?z +cd $SRCNAM-$VERSION/$VSDIR || exit 1 + +if [ ! -e "Cargo.toml" ]; then + echo "No Cargo.toml file in $SRCNAM-$VERSION dir" 1>&2 + exit 1 +elif [ -e "$CWD/Cargo-toml.patch" ]; then + echo "INFO: Applying Cargo.toml patch" + patch -Np1 < $CWD/Cargo-toml.patch +elif [ -e "$CWD/no-git-patch-builds.patch" ]; then + echo "INFO: Applying no-git-patch-builds.patch patch" + patch -Np1 < $CWD/no-git-patch-builds.patch +fi + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i686 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +fi + +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O2 -march=i686 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" + LIBDIRSUFFIX="64" +elif [ "$ARCH" = "aarch64" ]; then + SLKCFLAGS="-O2 -fPIC" + LIBDIRSUFFIX="64" +else + SLKCFLAGS="-O2" + LIBDIRSUFFIX="" +fi + +# check if rust-opt is installed +if [ ! -d /opt/rust/bin ]; then + echo "ERROR: The rust-opt slackbuild is required to be installed" + exit 1 +else + export PATH="/opt/rust/bin:$PATH" + if [ -z "$LD_LIBRARY_PATH" ]; then + export LD_LIBRARY_PATH="/opt/rust/lib$LIBDIRSUFFIX" + else + export LD_LIBRARY_PATH="/opt/rust/lib$LIBDIRSUFFIX:$LD_LIBRARY_PATH" + fi +fi + +# Configure cargo-vendor-filterer +if [ "$(grep -c "^\[package\]$" Cargo.toml)" -eq 1 ]; then + echo "This is a normal cargo package." + SRCTYPE="package" +elif [ "$(grep -c "^\[workspace\]$" Cargo.toml)" -eq 1 ]; then + echo "This is a cargo workspace." + SRCTYPE="workspace" +else + echo "Cargo.toml does not contain [package] or [workspace], exiting." + exit 1 +fi + + cat << EOF >> Cargo.toml +[$SRCTYPE.metadata.vendor-filter] +platforms = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "arm-unknown-linux-gnueabihf"] +all-features = true +EOF + +if [ -f /usr/bin/cargo-vendor-filterer ]; then + echo "INFO: Creating filtered vendor libs tarball..." + /usr/bin/cargo-vendor-filterer | tee $WORKDIR/tmpconfig.toml +else + echo "WARNING: Creating unfiltered vendor libs tarball!" + cargo vendor | tee $WORKDIR/tmpconfig.toml +fi + +# build would fail if the .a files were removed +#find vendor -type f -a -name \*.a -print0 | xargs -0 rm -f + +# add vendored-sources section generated by cargo-vendor-filterer +mkdir -p .cargo +cat $WORKDIR/tmpconfig.toml >> .cargo/config.toml +cd - + +cd $WORKDIR +echo "Creating vendored tar file..." +tar --totals --checkpoint=100 --checkpoint-action=dot \ + --sort=name --mtime="@0" --owner=0 --group=0 --numeric-owner \ + --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \ + -cJf $CWD/$SRCNAM-vendored-sources-$VERSION-$VSBUILD.tar.xz \ + $SRCNAM-$VERSION/$VSDIR/{vendor,.cargo} +md5sum $CWD/$SRCNAM-vendored-sources-$VERSION-$VSBUILD.tar.xz +cd $CWD +rm -rf $WORKDIR diff --git a/cargo-vendor-filterer/cargo-vendor-filterer.SlackBuild b/cargo-vendor-filterer/cargo-vendor-filterer.SlackBuild new file mode 100644 index 0000000..fd4349b --- /dev/null +++ b/cargo-vendor-filterer/cargo-vendor-filterer.SlackBuild @@ -0,0 +1,132 @@ +#!/bin/bash + +# Copyright 2023-2025 fourtysixandtwo <fourtysixandtwo@sliderr.net> +# Copyright 2022 Patrick J. Volkerding, Sebeka, MN, USA +# Copyright 2022 Heinz Wiesinger, Amsterdam, The Netherlands +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# 20230925 46and2: Bump build, changes to mkvendored script. +# 20230927 46and2: 32-bit fix thanks to Eugene Carlson. Min ARCH=i686. +# 20240102 46and2: modify to use VSBUILD instead of BUILD for vendored sources +# above requested by Andrew Clemons to avoid CI issues +# -also added VSDIR option to included script, see cargo-mkvendored.sh +# 20240213 46and2: Fix FTB on arm + +cd $(dirname $0) ; CWD=$(pwd) + +PRGNAM=cargo-vendor-filterer +VERSION=${VERSION:-0.5.18} +BUILD=${BUILD:-3} +TAG=${TAG:-_SBo} +PKGTYPE=${PKGTYPE:-tgz} +VSBUILD=${VSBUILD:-1} + +if [ -z "$ARCH" ]; then + case "$( uname -m )" in + i?86) ARCH=i686 ;; + arm*) ARCH=arm ;; + *) ARCH=$( uname -m ) ;; + esac +fi + +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" + exit 0 +fi + +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +if [ "$ARCH" = "i586" ]; then + SLKCFLAGS="-O2 -march=i586 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O2 -march=i686 -mtune=i686" + LIBDIRSUFFIX="" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2 -fPIC" + LIBDIRSUFFIX="64" +elif [ "$ARCH" = "aarch64" ]; then + SLKCFLAGS="-O2 -fPIC" + LIBDIRSUFFIX="64" +else + SLKCFLAGS="-O2" + LIBDIRSUFFIX="" +fi + +if [ "$ARCH" = "arm" ]; then + TRIPLET="$ARCH-unknown-linux-gnueabihf" +else + TRIPLET="$ARCH-unknown-linux-gnu" +fi + +set -e + +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $PRGNAM-$VERSION +tar xvf $CWD/$PRGNAM-$VERSION.tar.?z +tar xvf $CWD/$PRGNAM-vendored-sources-$VERSION-$VSBUILD.tar.?z +cd $PRGNAM-$VERSION + +chown -R root:root . +find -L . \ + \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ + -o -perm 511 \) -exec chmod 755 {} \+ -o \ + \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ + -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+ + +export PATH="/opt/rust/bin:$PATH" +if [ -z "$LD_LIBRARY_PATH" ]; then + export LD_LIBRARY_PATH="/opt/rust/lib$LIBDIRSUFFIX" +else + export LD_LIBRARY_PATH="/opt/rust/lib$LIBDIRSUFFIX:$LD_LIBRARY_PATH" +fi + +CFLAGS="$SLKCFLAGS" \ +CXXFLAGS="$SLKCFLAGS" \ +OPENSSL_NO_VENDOR=1 \ +cargo build \ + --offline \ + --release \ + --target $TRIPLET + +mkdir -p $PKG/usr/bin +install -m 755 target/$TRIPLET/release/cargo-vendor-filterer \ + $PKG/usr/bin/ + +# add script to generate filtered vendor sources +install -m 755 $CWD/cargo-mkvendored.sh $PKG/usr/bin/ + +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 *.md LICENSE \ + $PKG/usr/doc/$PRGNAM-$VERSION +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc + +cd $PKG +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE diff --git a/cargo-vendor-filterer/cargo-vendor-filterer.info b/cargo-vendor-filterer/cargo-vendor-filterer.info new file mode 100644 index 0000000..e3f294f --- /dev/null +++ b/cargo-vendor-filterer/cargo-vendor-filterer.info @@ -0,0 +1,12 @@ +PRGNAM="cargo-vendor-filterer" +VERSION="0.5.18" +HOMEPAGE="https://github.com/coreos/cargo-vendor-filterer" +DOWNLOAD="https://github.com/coreos/cargo-vendor-filterer/archive/v0.5.18/cargo-vendor-filterer-0.5.18.tar.gz \ + https://slackware.uk/~fourtysixandtwo/src/cargo-vendor-filterer-vendored-sources-0.5.18-1.tar.xz" +MD5SUM="fa5e8e4c56ba81b12adf70bcb984e855 \ + 85e04b08ba9625051f98c1967beccdc7" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +REQUIRES="rust-opt" +MAINTAINER="fourtysixandtwo" +EMAIL="fourtysixandtwo@sliderr.net" diff --git a/cargo-vendor-filterer/slack-desc b/cargo-vendor-filterer/slack-desc new file mode 100644 index 0000000..1c8d67c --- /dev/null +++ b/cargo-vendor-filterer/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. +# Line up the first '|' above the ':' following the base package name, and +# the '|' on the right side marks the last column you can put a character in. +# You must make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +cargo-vendor-filterer: cargo-vendor-filterer (Vendor rust libraries based on filters) +cargo-vendor-filterer: +cargo-vendor-filterer: cargo-vendor-filterer works like "cargo vendor", but supports filters +cargo-vendor-filterer: that allow excluding libraries one isn't interested in, like +cargo-vendor-filterer: libraries only needed on other platforms, etc. +cargo-vendor-filterer: +cargo-vendor-filterer: Homepage: https://github.com/coreos/cargo-vendor-filterer +cargo-vendor-filterer: +cargo-vendor-filterer: +cargo-vendor-filterer: +cargo-vendor-filterer: |
