slackbuilds/xap/x49gp/SlackBuild
2023-04-07 11:54:16 +02:00

130 lines
3.8 KiB
Bash
Executable file

#!/bin/bash
set -x
CWD=$(pwd)
PRGNAM=$(basename $CWD)
GITHUB_REPO=gwenhael-le-moine/x49gp #claudiobsd/x49gp
VERSION=${VERSION:-latest}
NEWRPL_VERSION=1487
BUILD=8
ARCH=$(uname -m)
LIBSUFFIX=$(echo $ARCH | grep -o "\(64\)")
TAG=gwh
OUTPUT=/tmp
TMP=/tmp/$TAG
PKG=$TMP/pkg-$PRGNAM
REPOSITORIES=/home/installs/SlackBuilds/_repositories
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
git pull --all
cp -R $REPOSITORY $TMP/$PRGNAM
cd $TMP/$PRGNAM
[ "x$VERSION" == "xlatest" ] && VERSION=$(git describe --tags --abbrev=0)
[ "x$VERSION" == "x" ] && VERSION=trunk
[ "x$VERSION" == "xtrunk" ] && VERSION="git_r$(git rev-list --count HEAD)_$(git log -1 --format=%h)" || git checkout $VERSION
# 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 sdcard INSTALL_PREFIX=/usr INSTALL_MAN_DIR=/usr/man/man1
# 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* sdcard $PKG$PREFIX/doc/$PRGNAM/
mkdir -p $PKG$PREFIX/share/applications/
cat <<EOF > $PKG$PREFIX/share/applications/$PRGNAM.desktop
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=$PREFIX/bin/x49gp
Name=x49gp
Icon=/usr/share/x49gp/hp50g.png
EOF
cat <<EOF > $PKG$PREFIX/doc/$PRGNAM/post-install.sh
#!/bin/bash
mkdir -p $PREFIX/share/$PRGNAM
[ ! -e $PREFIX/doc/$PRGNAM/hp-arm-models-bootloader.zip ] && wget -c -O $PREFIX/doc/$PRGNAM/hp-arm-models-bootloader.zip https://www.hpcalc.org/hp49/pc/rom/hp-arm-models-bootloader.zip
unzip -d $PREFIX/share/$PRGNAM/firmware/ $PREFIX/doc/$PRGNAM/hp-arm-models-bootloader.zip
rm $PREFIX/doc/$PRGNAM/hp-arm-models-bootloader.zip
[ ! -e $PREFIX/doc/$PRGNAM/hp4950v215.zip ] && wget -c -O $PREFIX/doc/$PRGNAM/hp4950v215.zip https://www.hpcalc.org/hp49/pc/rom/hp4950v215.zip
unzip -d $PREFIX/share/$PRGNAM/ $PREFIX/doc/$PRGNAM/hp4950v215.zip
rm $PREFIX/doc/$PRGNAM/hp4950v215.zip
mkdir -p $PREFIX/share/$PRGNAM/newrpl/
wget -c -O $PREFIX/share/$PRGNAM/newrpl/newrplfw.bin.new https://www.hpgcc3.org/downloads/newrplfw.bin
mv $PREFIX/share/$PRGNAM/newrpl/newrplfw.bin.new $PREFIX/share/$PRGNAM/newrpl/newrplfw.bin
echo "newrplfw.bin" > $PREFIX/share/$PRGNAM/newrpl/update.scp
EOF
# # Cleaning
# cd $PKG
# 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
cd $PKG
[ -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/x49gp/README.md | grep "First launch setup" --before-context=2 --after-context=28
echo "Run $PREFIX/doc/$PRGNAM/post-install.sh"
EOF
cat <<EOF > install/slack-desc
$PRGNAM: $PRGNAM (HP49/50 emulator)
$PRGNAM:
$PRGNAM: Emulator of the newer Hewlett Packard Handheld Calculator Models with ARM CPU
$PRGNAM: (HP49g+ HP50).
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM: https://sourceforge.net/projects/x49gp/
$PRGNAM: https://github.com/${GITHUB_REPO}
EOF
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$(echo $VERSION | tr -d '-')-$ARCH-$BUILD$TAG.txz