slackbuilds/wayland/Hyprland/SlackBuild
2023-08-16 12:23:26 +02:00

171 lines
5.2 KiB
Bash
Executable file

#!/bin/bash
# variables
GITHUB_REPO=hyprwm/Hyprland
VERSION=${VERSION:-"latest"}
BUILD=1
TAG=gwh
OUTPUT=/tmp
TMP=/tmp/$TAG
CWD=$(pwd)
PRGNAM=$(basename "$CWD")
PKG=$TMP/pkg-$PRGNAM
ARCH=$(uname -m)
REPOSITORY=/home/installs/SlackBuilds/_repositories/$PRGNAM
PREFIX=/usr
# nettoyage préalable
rm -fr "$PKG" "${TMP:?}/$PRGNAM"
mkdir -p "$PKG"
# mise en place
[ ! -e "$REPOSITORY" ] && git clone https://github.com/${GITHUB_REPO} "$REPOSITORY"
cd "$REPOSITORY" || exit 1
git pull --all
cp -R "$REPOSITORY" $TMP/
cd "$TMP/$PRGNAM/" || exit 1
case $VERSION in
trunk)
PKGVERSION="r$(git rev-list --count HEAD)_$(git log -1 --format=%h)"
;;
latest)
PKGVERSION=$(git describe --tags --abbrev=0)
git checkout "$PKGVERSION"
;;
*)
git checkout "$PKGVERSION"
;;
esac
PKGNAM=${PRGNAM}
######################
# EMBED DEPENDENCIES #
######################
git submodule update --init --recursive
# libliftoff
EMBED_LIBLIFTOFF=${EMBED_LIBLIFTOFF:-"yes"}
if [ "$EMBED_LIBLIFTOFF" = "yes" ]; then
LIBLIFTOFF_VERSION=${LIBLIFTOFF_VERSION:-$VERSION}
LIBLIFTOFF_REPOSITORY=/home/installs/SlackBuilds/_repositories/libliftoff
[ ! -e "$LIBLIFTOFF_REPOSITORY" ] && git clone https://gitlab.freedesktop.org/emersion/libliftoff.git "$LIBLIFTOFF_REPOSITORY"
cd "$LIBLIFTOFF_REPOSITORY" || exit 1
git reset --hard HEAD
git pull --all
mkdir -p "$TMP/$PRGNAM"/subprojects/
cp -a "$LIBLIFTOFF_REPOSITORY" "$TMP/$PRGNAM"/subprojects/libliftoff
cd "$TMP/$PRGNAM"/subprojects/libliftoff || exit 1
case $LIBLIFTOFF_VERSION in
trunk)
# LIBLIFTOFF_VERSION="git_r$(git log -1 --format=%h_%ad --date=format:%Y.%m.%d)"
LIBLIFTOFF_VERSION="r$(git rev-list --count HEAD)_$(git log -1 --format=%h)"
;;
latest)
LIBLIFTOFF_VERSION=$(git describe --tags --abbrev=0)
git checkout "$LIBLIFTOFF_VERSION"
;;
*)
git checkout "$LIBLIFTOFF_VERSION"
;;
esac
PKGNAM="${PKGNAM}+libliftoff"
PKGVERSION="${PKGVERSION}+${LIBLIFTOFF_VERSION}"
fi
# libdisplay-info
EMBED_LIBDISPLAYINFO=${EMBED_LIBDISPLAYINFO:-"yes"}
if [ "$EMBED_LIBDISPLAYINFO" = "yes" ]; then
LIBDISPLAYINFO_VERSION=${LIBDISPLAYINFO_VERSION:-$VERSION}
LIBDISPLAYINFO_REPOSITORY=/home/installs/SlackBuilds/_repositories/libdisplay-info
[ ! -e "$LIBDISPLAYINFO_REPOSITORY" ] && git clone https://gitlab.freedesktop.org/emersion/libdisplay-info.git "$LIBDISPLAYINFO_REPOSITORY"
cd "$LIBDISPLAYINFO_REPOSITORY" || exit 1
git reset --hard HEAD
git pull --all
mkdir -p "$TMP/$PRGNAM"/subprojects/
cp -a "$LIBDISPLAYINFO_REPOSITORY" "$TMP/$PRGNAM"/subprojects/libdisplay-info
cd "$TMP/$PRGNAM"/subprojects/libdisplay-info || exit 1
case $LIBDISPLAYINFO_VERSION in
trunk)
# LIBDISPLAYINFO_VERSION="git_r$(git log -1 --format=%h_%ad --date=format:%Y.%m.%d)"
LIBDISPLAYINFO_VERSION="r$(git rev-list --count HEAD)_$(git log -1 --format=%h)"
;;
latest)
LIBDISPLAYINFO_VERSION=$(git describe --tags --abbrev=0)
git checkout "$LIBDISPLAYINFO_VERSION"
;;
*)
git checkout "$LIBDISPLAYINFO_VERSION"
;;
esac
PKGNAM="${PKGNAM}+libdisplay_info"
PKGVERSION="${PKGVERSION}+${LIBDISPLAYINFO_VERSION}"
fi
# Back to compiling
cd "$TMP/$PRGNAM/" || exit 1
meson setup \
--prefix /usr \
--mandir /usr/man/ \
-Dxwayland=enabled \
build/
ninja -C build/
cd build/ || exit 1
meson install --destdir="$PKG"
cd ../
mkdir -p "$PKG$PREFIX/doc/$PRGNAM"
cp -r ./docs/ ./LICENSE ./*.md "$PKG$PREFIX/doc/$PRGNAM/"
# correction
cd "$PKG" || exit 1
chown -R root:root ./*
[ -d "$PKG$PREFIX/man" ] && find "$PKG$PREFIX/man" -name "*.?" -type f -exec gzip -9 {} \;
# Don't package wlroots includes or .so link as we don't want to interfere with SBo's wlroots
find "$PKG$PREFIX/lib$(uname -m | grep -o 64)/" -type l -exec rm {} \;
rm -r "$PKG$PREFIX/lib$(uname -m | grep -o 64)/pkgconfig/"
rm -r "$PKG$PREFIX/include/"
# embaumement
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 ':'.
|-----handy-ruler------------------------------------------------------|
$PRGNAM: $PRGNAM (a dynamic tiling Wayland compositor)
$PRGNAM:
$PRGNAM: Hyprland is a dynamic tiling Wayland compositor based on wlroots
$PRGNAM: that doesn't sacrifice on its looks.
$PRGNAM:
$PRGNAM: It supports multiple layouts, fancy effects, has a very flexible
$PRGNAM: IPC model allowing for a lot of customization, and more.
$PRGNAM:
$PRGNAM:
$PRGNAM: https://hyprland.org/
$PRGNAM: https://github.com/${GITHUB_REPO}
EOF
# empaquetage
rm -f "$PKG"/{,usr/}lib"$(uname -m | grep -o 64)"/*.la
/sbin/makepkg --linkadd y --chown n --prepend "$OUTPUT"/"$PKGNAM"-"$(echo $PKGVERSION | tr - _)"-"$ARCH"-"$BUILD$TAG".txz