slackbuilds/wayland/sway/SlackBuild

135 lines
3 KiB
Bash
Executable file

#!/bin/bash
# variables
GITHUB_REPO=swaywm/sway
VERSION=${VERSION:-"latest"}
BUILD=4
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)
VERSION="git_$(git log -1 --format=%h_%ad --date=format:%Y.%m.%d)"
;;
latest)
VERSION=$(git describe --tags --abbrev=0)
git checkout "$VERSION"
;;
*)
git checkout "$VERSION"
;;
esac
for p in "$CWD"/patches/*.patch; do
git am "$p"
done
meson setup \
--prefix /usr \
--mandir /usr/man/ \
-Dsd-bus-provider=libelogind \
-Dstrip=true \
-Ddefault-wallpaper=true \
-Dswaybar=true \
-Dxwayland=enabled \
-Dtray=enabled \
-Dgdk-pixbuf=enabled \
-Dswaynag=true \
-Dbash-completions=true \
-Dzsh-completions=true \
-Dfish-completions=true \
build/
ninja -C build/
cd build/ || exit 1
meson install --destdir="$PKG"
cd ../
cat <<EOF > "$PKG$PREFIX/bin/start_sway.sh"
#!/bin/bash
set -e
# LOGFILE=/tmp/wsession-errors
# true > \$LOGFILE
# exec &> \$LOGFILE
# set -x
# echo "sway Starting: \$( date )"
# avoid wlr error
unset DISPLAY
# Uncomment if mouse pointer is invisible
#export WLR_NO_HARDWARE_CURSORS=1
export SWAYSOCK=/run/user/\$(id -u)/sway-ipc.\$(id -u).\$(pgrep -x sway).sock
export XDG_RUNTIME_DIR=/tmp/xdg-runtime-\$(id -u)
mkdir -p \$XDG_RUNTIME_DIR
chmod 0700 \$XDG_RUNTIME_DIR
exec dbus-run-session sway
EOF
chmod +x "$PKG$PREFIX/bin/start_sway.sh"
sed -i 's|Exec=sway|Exec=/usr/bin/start_sway.sh|' "$PKG$PREFIX/share/wayland-sessions/sway.desktop"
mkdir -p "$PKG$PREFIX/doc/$PRGNAM"
cp 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 {} \;
# 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 (i3-compatible Wayland compositor)
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM:
$PRGNAM: https://github.com/${GITHUB_REPO}
EOF
# empaquetage
rm -f "$PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la"
/sbin/makepkg -l y -c n "$OUTPUT/$PRGNAM-$(echo "$VERSION" | tr - _)-$ARCH-$BUILD$TAG.txz"