#!/bin/bash # Slackware build script for pwntools # Ioannis Anagnostakis # 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. cd $(dirname $0) ; CWD=$(pwd) PRGNAM=pwntools VERSION=${VERSION:-4.15.0} BUILD=${BUILD:-1} TAG=${TAG:-_SBo} PKGTYPE=${PKGTYPE:-tgz} if [ -z "$ARCH" ]; then case "$( uname -m )" in i?86) ARCH=i586 ;; 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 LIBDIRSUFFIX="" elif [ "$ARCH" = "i686" ]; then LIBDIRSUFFIX="" elif [ "$ARCH" = "x86_64" ]; then LIBDIRSUFFIX="64" elif [ "$ARCH" = "aarch64" ]; then LIBDIRSUFFIX="64" else LIBDIRSUFFIX="" fi set -e rm -rf $PKG mkdir -p $TMP $PKG $OUTPUT cd $TMP rm -rf $PRGNAM-$VERSION tar xvf $CWD/$PRGNAM-$VERSION.tar.gz cd $PRGNAM-$VERSION # Upstream blacklists unicorn 2.1.3 and 2.1.4 due to a bug in the Python # bindings build process (https://github.com/unicorn-engine/unicorn/issues/2134). # Testing confirms this does not affect Slackware's separately installed # system unicorn library and Python bindings. sed -i 's/unicorn>=2.0.1, !=2.1.3, !=2.1.4/unicorn>=2.0.1/' \ pyproject.toml || exit 1 sed -i "s/compat = {}/compat = {'name': 'pwntools'}/" setup.py || exit 1 chown -R root:root . find . -type f \( -perm -4000 -o -perm -2000 \) -exec chmod -s {} + find . ! -type l -type d ! -perm 755 -exec chmod -f 755 {} + find . ! -type l -type f -perm /111 ! -perm 755 -exec chmod -f 755 {} + find . ! -type l -type f ! -perm /111 ! -perm 644 -exec chmod -f 644 {} + PYVER=$(python3 -c 'import sys; print("%d.%d" % sys.version_info[:2])') export PYTHONPATH=/opt/python$PYVER/site-packages export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PWNTOOLS="$VERSION" python3 -m build --wheel --no-isolation # Clean up fmtstr example build artifacts pushd examples/fmtstr make clean 2>/dev/null || true popd python3 -m installer --destdir="$PKG" --prefix=/usr dist/*.whl if [ "$LIBDIRSUFFIX" = "64" ]; then if [ -d "$PKG/usr/lib" ]; then mkdir -p $PKG/usr/lib${LIBDIRSUFFIX} cp -R $PKG/usr/lib/* $PKG/usr/lib${LIBDIRSUFFIX}/ rm -rf $PKG/usr/lib fi fi 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 *.txt \ $PKG/usr/doc/$PRGNAM-$VERSION cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild mv "$PKG"/usr/pwntools-doc $PKG/usr/doc/$PRGNAM-$VERSION cp -R examples $PKG/usr/doc/$PRGNAM-$VERSION/ 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