slackbuilds/d/zig/SlackBuild
2022-01-22 19:52:02 +01:00

59 lines
1.4 KiB
Bash
Executable file

#!/bin/bash
set -x -e
CWD=$(pwd)
PRGNAM=$(basename $CWD)
ARCH=$(uname -m)
VERSION=$(curl -s https://ziglang.org/download/index.json | jq 'keys' | grep -v master | grep -v \\\[ | grep -v \\\] | tr -d , | tr -d \" | tr -d \ | sort -V | tail -n1)
BUILD=1
TAG=gwh
OUTPUT=/tmp
TMP=/tmp/$TAG
PKG=$TMP/pkg-$PRGNAM
PREFIX=/usr
REPOSITORY=${REPOSITORY:-/home/installs/SlackBuilds/_repositories/$PRGNAM}
mkdir -p $REPOSITORY
# cleaning
rm -fr $PKG
# unpacking
[ ! -e $REPOSITORY/zig-linux-${ARCH}-${VERSION}.tar.gz ] && wget -c https://ziglang.org/download/${VERSION}/zig-linux-${ARCH}-${VERSION}.tar.xz -O $REPOSITORY/zig-linux-${ARCH}-${VERSION}.tar.gz
mkdir -p $TMP
cd $TMP
tar xvf $REPOSITORY/zig-linux-${ARCH}-${VERSION}.tar.gz
cd zig-linux-${ARCH}-${VERSION}
# installation
mkdir -p $PKG$PREFIX/bin/
install -D zig $PKG$PREFIX/bin/zig
mkdir -p $PKG$PREFIX/doc/$PRGNAM
install -D LICENSE $PKG$PREFIX/doc/zig/LICENSE
cp -r lib $PKG$PREFIX
cp -r doc/ $PKG$PREFIX/doc/zig/
# packaging
cd $PKG
mkdir install
cat <<EOF > install/slack-desc
$PRGNAM: $PRGNAM (robust, optimal, and clear programming language)
$PRGNAM:
$PRGNAM: Zig is a general-purpose programming language and toolchain for
$PRGNAM: maintaining robust, optimal, and reusable software.
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM: https://ziglang.org/
$PRGNAM:
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