@@ 1,5 1,7 @@
#!/bin/bash
#
+# Slackware build script for senpai
+#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
@@ 30,31 32,39 @@ PRGNAM=senpai
VERSION=${VERSION:-0.3.0}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
-ARCH=${ARCH:-x86_64}
-
-TMP=${TMP:-/tmp/SBo}
-PKG=${TMP}/package-${PRGNAM}
PKGTYPE=${PKGTYPE:-tgz}
-OUTPUT=${OUTPUT:-/tmp}
-# 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 "$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
-# Clean up any previous build artifacts
-rm -rf "$PKG"
-mkdir -p "$TMP" "$PKG" "$OUTPUT"
-cd "$TMP"
+TMP=${TMP:-/tmp/SBo}
+PKG=$TMP/package-$PRGNAM
+OUTPUT=${OUTPUT:-/tmp}
-# Download and extract the source code
-rm -rf "${PRGNAM}-${VERSION}"
-wget -O "${PRGNAM}-v${VERSION}.tar.gz" "https://git.sr.ht/~delthas/senpai/archive/v${VERSION}.tar.gz"
-tar xvf "${PRGNAM}-v${VERSION}.tar.gz"
-cd "${PRGNAM}-v${VERSION}"
+set -e
+
+rm -rf $PKG
+mkdir -p $TMP $PKG $OUTPUT
+cd $TMP
+rm -rf $PRGNAM-v$VERSION
+tar xvf $CWD/$PRGNAM-v$VERSION.tar.gz || tar xvf $CWD/v$VERSION.tar.gz # not possible to get consistent filenames with sourcehut
+cd $PRGNAM-v$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 {} \;
# Compile the source
mkdir -p "$TMP/go-cache" "$TMP/go-tmpdir" "$TMP/go"
@@ 64,35 74,27 @@ export GOMODCACHE="${GOMODCACHE:-"$TMP/go"}"
export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
export SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date +%s)}"
-make PREFIX=/usr || exit 1
+make PREFIX=/usr
# Install the compiled binaries to the package directory
-make install PREFIX=/usr MANDIR=man DESTDIR="$PKG" || exit 1
+make install PREFIX=/usr DESTDIR="$PKG"
-# Copy documentation
-mkdir -p "$PKG/usr/doc/${PRGNAM}-${VERSION}"
-cp -a README.md LICENSE \
- "$PKG/usr/doc/${PRGNAM}-${VERSION}"
+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
-# Compress man pages and fix symlinks
-find "$PKG/usr//man" -type f -exec gzip -9 {} \;
-for i in $(find "$PKG/usr/man" -type l); do
- ln -s "$(readlink "$i").gz" "$i.gz"
- rm "$i"
-done
+mv $PKG/usr/share/man $PKG/usr
+find $PKG/usr/man -type f -exec gzip -9 {} \;
+for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
-# Copy the SlackBuild script into the package documentation
-cat "$CWD/${PRGNAM}.SlackBuild" > "$PKG/usr/doc/${PRGNAM}-${VERSION}/${PRGNAM}.SlackBuild"
-
-# Copy the slack-desc file
-mkdir -p "$PKG/install"
-cat "$CWD/slack-desc" > "$PKG/install/slack-desc"
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
+cp -a README.md LICENSE \
+ $PKG/usr/doc/$PRGNAM-$VERSION
-# Create the package
-cd "$PKG"
-/sbin/makepkg -l y -c n "$OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE}"
+cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
-# Generate MD5 checksum
-cd "$OUTPUT"
-md5sum "${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE}" > "${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE}.md5"
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+cat $CWD/doinst.sh > $PKG/install/doinst.sh
+cd $PKG
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE