slackbuilds/xap/x50ng/SlackBuild
2024-11-20 15:09:38 +01:00

96 lines
2.5 KiB
Bash
Executable file

#!/bin/bash
set -x
CWD=$(pwd)
PRGNAM=$(basename "$CWD")
GITHUB_REPO=gwenhael-le-moine/x50ng
VERSION=${VERSION:-latest}
BUILD=12
ARCH=$(uname -m)
TAG=gwh
OUTPUT=/tmp
TMP=/tmp/$TAG
PKG=$TMP/pkg-$PRGNAM
REPOSITORIES=/var/cache/SlackBuilds.gwh
REPOSITORY=$REPOSITORIES/$PRGNAM
PREFIX=/usr
mkdir -p $TMP
# Cleaning
rm -fr "$TMP"/"$PRGNAM" "$PKG"
# Fetching sources
[ ! -e "$REPOSITORY" ] && git clone https://github.com/${GITHUB_REPO}.git "$REPOSITORY"
cd "$REPOSITORY" || exit 1
git pull --all
cp -R "$REPOSITORY" "$TMP"/"$PRGNAM"
cd "$TMP"/"$PRGNAM" || exit 1
[ "$VERSION" == "latest" ] && VERSION=$(git tag --sort=-version:refname | head -n1)
[ "$VERSION" == "" ] && VERSION=trunk
[ "$VERSION" == "trunk" ] && VERSION="git_r$(git rev-list --count HEAD)_$(git log -1 --format=%h)"
# Preparation
chown -R root:root .
find . \
\( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
-exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
make INSTALL_PREFIX=/usr INSTALL_MAN_DIR=/usr/man/man1
make pull-firmware
# Installing
mkdir -p "$PKG"
make install DESTDIR="$PKG" INSTALL_PREFIX=/usr INSTALL_MAN_DIR=/usr/man/man1
mkdir -p "$PKG"$PREFIX/doc/"$PRGNAM"/
cp README* "$PKG"$PREFIX/doc/"$PRGNAM"/
# # Cleaning
cd "$PKG" || exit 1
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
[ -d "$PKG"$PREFIX/man ] && find "$PKG"$PREFIX/man -type f -name "*.?" -exec gzip -9 {} \;
chown -R root:root .
find . \
\( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
-exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
# Packaging
mkdir install
cat <<EOF > install/doinst.sh
#!/bin/bash
cat /usr/doc/x50ng/README.md | grep "First launch setup" --before-context=2 --after-context=28
EOF
cat <<EOF > install/slack-desc
$PRGNAM: $PRGNAM (HP49/50 emulator, rebooted)
$PRGNAM:
$PRGNAM: Emulator of the newer Hewlett Packard Handheld Calculator Models with ARM CPU
$PRGNAM: (HP49g+ and HP50).
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM: https://github.com/${GITHUB_REPO}
EOF
rm -f "$PKG"/{,usr/}"lib$(uname -m | grep -o 64)"/*.la
/sbin/makepkg --linkadd y --chown n --prepend $OUTPUT/"$PRGNAM"-"$(echo "$VERSION" | tr -d '-')"-"$ARCH"-$BUILD$TAG.txz