summaryrefslogtreecommitdiffstats
path: root/development/dfsimage/dfsimage.SlackBuild
blob: 6538bfbb81a16b33ad47c470aac8ac40453a8e20 (plain)
#!/bin/bash

# Slackware build script for dfsimage

# Written by B. Watson (urchlay@slackware.uk)

# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.

# In theory, the full docs can be generated with Sphinx. However, I'm
# unwilling to make it a dependency. The only thing missing is the API
# doc, which 99% of users would never read anyway. The user's manual
# is the important bit, we install it as a man page.

cd $(dirname $0) ; CWD=$(pwd)

PRGNAM=dfsimage
VERSION=${VERSION:-0.9rc3_20210220_de24cf0}
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}

# No C, so no C flags. No lib(64)? stuffs needed either.

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.xz
cd $PRGNAM-$VERSION
chown -R root:root .
find -L .  -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
        \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+

python3 setup.py install --root=$PKG

# Format readme.rst as a man page, not HTML.
patch -p1 < $CWD/man_page.diff
mkdir -p $PKG/usr/man/man1
rst2man.py readme.rst | gzip -9c > $PKG/usr/man/man1/$PRGNAM.1.gz

PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
sed 's,\r,,' LICENSE > $PKGDOC/LICENSE
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$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