slackbuilds/l/tree-sitter-module/SlackBuild
2024-02-08 13:00:38 +01:00

85 lines
2.2 KiB
Bash
Executable file

#!/bin/bash
CWD=$(pwd)
PRGNAM=$(basename "$CWD")
GITHUB_REPO=casouri/tree-sitter-module
VERSION=${VERSION:-trunk}
BUILD=${BUILD:-1}
TAG=${TAG:-gwh}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i486 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
TMP=${TMP:-/tmp/$TAG}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
PREFIX=${PREFIX:-/usr}
REPOSITORY=/home/installs/SlackBuilds/_repositories/$PRGNAM
set -e
rm -rf "$PKG"
mkdir -p "$TMP" "$PKG" "$OUTPUT"
cd "$TMP"
rm -rf "$PRGNAM"
[ ! -e "$REPOSITORY" ] && git clone https://github.com/${GITHUB_REPO} "$REPOSITORY"
cd "$REPOSITORY" || exit 1
git pull --all
cp -R "$REPOSITORY" "$TMP/$PRGNAM"
cd "$TMP/$PRGNAM"
[ "$VERSION" == "latest" ] && VERSION=$(git tag --sort=-taggerdate | head -n1)
[ "$VERSION" == "" ] && VERSION=trunk
[ "$VERSION" == "trunk" ] && VERSION="git_r$(git rev-list --count HEAD)_$(git log -1 --format=%h)"
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 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
sed -i 's|cc -c -I. parser.c|cc -fPIC -c -I. parser.c|' build.sh
bash ./batch.sh
mkdir -p "$PKG${PREFIX}/lib$(uname -m | grep -o 64)/"
cp dist/*.so "$PKG${PREFIX}/lib$(uname -m | grep -o 64)/"
mkdir -p "$PKG/usr/doc/$PRGNAM"
cp README "$PKG/usr/doc/$PRGNAM/"
mkdir -p "$PKG/install"
cat <<EOF > "$PKG/install/slack-desc"
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
$PRGNAM: $PRGNAM (Tree-sitter grammers)
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM: https://github.com/${GITHUB_REPO}
EOF
cd "$PKG" || exit 1
/sbin/makepkg --linkadd y --chown n --prepend "$OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-txz}"