slackbuilds/xap/leocad/SlackBuild
Gwenhael Le Moine 8121fb85a3
get latest tag differently
Signed-off-by: Gwenhael Le Moine <gwenhael.le.moine@gmail.com>
2024-01-11 14:48:15 +01:00

99 lines
3 KiB
Bash
Executable file

#!/bin/bash
# variables
TAG=gwh
TMP=/tmp/$TAG
CWD=$(pwd)
OUTPUT=/tmp
PRGNAM=$(basename $CWD)
PKG=$TMP/pkg-$PRGNAM
ARCH=$(uname -m)
BUILD=1
GITHUB_REPO=leozide/leocad
VERSION=${VERSION:-latest}
REPOSITORY=/home/installs/SlackBuilds/_repositories/$PRGNAM
# nettoyage préalable
rm -fr $PKG $TMP/$PRGNAM
mkdir -p $PKG
# mise en place
[ ! -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 tag --sort=-taggerdate | head -n1)
[ "x$VERSION" == "x" ] && VERSION=trunk
[ "x$VERSION" == "xtrunk" ] && VERSION="git_r$(git rev-list --count HEAD)_$(git log -1 --format=%h)" || git checkout $VERSION
qmake-qt5 DISABLE_UPDATE_CHECK=1 DOCS_DIR=/usr/doc/$PRGNAM MAN_DIR=/usr/man/man1 leocad.pro
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
make
make INSTALL_ROOT="$PKG" install
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/man/man1
cp -a docs/leocad.1 $PKG/usr/man/man1
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
LIBRARY_URL=$(curl -s https://api.github.com/repos/${GITHUB_REPO}/releases | grep -o "http.*Library-.*zip" | head -n1)
LIBRARY_FILE=$(echo $LIBRARY_URL | grep -o "Library-[0-9.]*.zip")
LIBRARY_VERSION=$(echo $LIBRARY_FILE | grep -o "[0-9.]*")
[ ! -e $REPOSITORY/$LIBRARY_FILE ] && wget -c -O $REPOSITORY/$LIBRARY_FILE $LIBRARY_URL
# Data from zip-file + set permissions
mkdir -p $PKG/usr/share/leocad
unzip $REPOSITORY/$LIBRARY_FILE -d $PKG/usr/share/leocad/
chown -R root:root $PKG
# correction
cd $PKG
chown -R root:root *
# embaumement
mkdir -p $PKG/install
cat <<EOF > $PKG/install/doinst.sh
if [ -x /usr/bin/update-desktop-database ]; then
/usr/bin/update-desktop-database -q usr/share/applications >/dev/null 2>&1
fi
if [ -x /usr/bin/update-mime-database ]; then
/usr/bin/update-mime-database usr/share/mime >/dev/null 2>&1
fi
if [ -e usr/share/icons/hicolor/icon-theme.cache ]; then
if [ -x /usr/bin/gtk-update-icon-cache ]; then
/usr/bin/gtk-update-icon-cache -f usr/share/icons/hicolor >/dev/null 2>&1
fi
fi
EOF
cat <<EOF > $PKG/install/slack-desc
|-----handy-ruler------------------------------------------------------|
$PRGNAM: $PRGNAM (CAD program for toy bricks)
$PRGNAM:
$PRGNAM: $PRGNAM is a CAD program that uses bricks similar to those
$PRGNAM: found in many toys (but they don't represent any particular brand).
$PRGNAM: Currently it uses a library of more than 7000 different pieces.
$PRGNAM:
$PRGNAM: https://www.$PRGNAM.org/
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
EOF
# empaquetage
cd $PKG
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
/sbin/makepkg --linkadd y --chown n --prepend $OUTPUT/$PRGNAM-$(echo ${VERSION}_${LIBRARY_VERSION} | sed 's/-//g')-$ARCH-$BUILD$TAG.txz