slackbuilds/wayland/sway/SlackBuild

217 lines
5.7 KiB
Text
Raw Normal View History

2021-06-15 10:26:26 +02:00
#!/bin/bash
2021-04-26 00:06:40 +02:00
# variables
GITHUB_REPO=swaywm/sway
2022-01-21 11:29:29 +01:00
VERSION=${VERSION:-"latest"}
WLROOTS_VERSION=${WLROOTS_VERSION:-$VERSION}
2023-02-21 13:02:25 +01:00
LIBLIFTOFF_VERSION=${LIBLIFTOFF_VERSION:-$VERSION}
BUILD=10
2021-04-26 00:06:40 +02:00
TAG=gwh
OUTPUT=/tmp
TMP=/tmp/$TAG
CWD=$(pwd)
PRGNAM=$(basename "$CWD")
2021-04-26 00:06:40 +02:00
PKG=$TMP/pkg-$PRGNAM
ARCH=$(uname -m)
2022-01-22 19:52:02 +01:00
REPOSITORY=/home/installs/SlackBuilds/_repositories/$PRGNAM
WLROOTS_REPOSITORY=/home/installs/SlackBuilds/_repositories/wlroots
2023-02-21 13:02:25 +01:00
LIBLIFTOFF_REPOSITORY=/home/installs/SlackBuilds/_repositories/libliftoff
2021-04-26 00:06:40 +02:00
PREFIX=/usr
# nettoyage préalable
rm -fr "$PKG" "${TMP:?}/$PRGNAM"
2021-04-26 00:06:40 +02:00
2022-08-25 13:22:56 +02:00
mkdir -p "$PKG"
2021-04-26 00:06:40 +02:00
# mise en place
2022-08-25 13:22:56 +02:00
[ ! -e "$REPOSITORY" ] && git clone https://github.com/${GITHUB_REPO} "$REPOSITORY"
cd "$REPOSITORY" || exit 1
git reset --hard HEAD
2021-06-15 10:59:49 +02:00
git pull --all
2021-04-26 00:06:40 +02:00
2022-08-25 13:22:56 +02:00
cp -R "$REPOSITORY" $TMP/
2022-08-25 13:22:56 +02:00
cd "$TMP/$PRGNAM/" || exit 1
2022-01-21 11:29:29 +01:00
case $VERSION in
trunk)
VERSION="git_$(git log -1 --format=%h_%ad --date=format:%Y.%m.%d)"
;;
latest)
2022-10-03 16:35:04 +02:00
VERSION=$(git describe --tags --abbrev=0)
2022-08-25 13:22:56 +02:00
git checkout "$VERSION"
2022-01-21 11:29:29 +01:00
;;
*)
2022-08-25 13:22:56 +02:00
git checkout "$VERSION"
2022-01-21 11:29:29 +01:00
;;
esac
2022-11-12 22:20:23 +01:00
[ -e "$CWD"/patches/6249-tray-menu.patch ] && mv "$CWD"/patches/6249-tray-menu.patch{,.previous}
wget -c https://patch-diff.githubusercontent.com/raw/swaywm/sway/pull/6249.patch -O "$CWD"/patches/6249-tray-menu.patch
patch -p1 < "$CWD"/patches/6249-tray-menu.patch
2022-11-12 22:20:23 +01:00
# for p in "$CWD"/patches/*.patch; do
# git am --show-current-patch=diff "$p"
# done
2021-10-25 14:21:36 +02:00
# Embed wlroots
[ ! -e "$WLROOTS_REPOSITORY" ] && git clone https://gitlab.freedesktop.org/wlroots/wlroots.git "$WLROOTS_REPOSITORY"
cd "$WLROOTS_REPOSITORY" || exit 1
git reset --hard HEAD
git pull --all
mkdir -p "$TMP/$PRGNAM"/subprojects/
cp -a "$WLROOTS_REPOSITORY" "$TMP/$PRGNAM"/subprojects/wlroots
cd "$TMP/$PRGNAM"/subprojects/wlroots || exit 1
case $WLROOTS_VERSION in
trunk)
WLROOTS_VERSION="git_$(git log -1 --format=%h_%ad --date=format:%Y.%m.%d)"
;;
latest)
WLROOTS_VERSION=$(git describe --tags --abbrev=0)
git checkout "$WLROOTS_VERSION"
;;
*)
git checkout "$WLROOTS_VERSION"
;;
esac
2023-02-21 13:02:25 +01:00
# Embed 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_$(git log -1 --format=%h_%ad --date=format:%Y.%m.%d)"
;;
latest)
LIBLIFTOFF_VERSION=$(git describe --tags --abbrev=0)
git checkout "$LIBLIFTOFF_VERSION"
;;
*)
git checkout "$LIBLIFTOFF_VERSION"
;;
esac
# Back to compiling sway…
2023-02-21 13:02:25 +01:00
cd "$TMP/$PRGNAM/" || exit 1
2021-05-01 12:07:45 +02:00
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 \
2021-05-01 12:07:45 +02:00
build/
2022-04-16 15:03:04 +02:00
2021-04-26 00:06:40 +02:00
ninja -C build/
2022-08-25 13:22:56 +02:00
cd build/ || exit 1
meson install --destdir="$PKG"
2021-04-26 00:06:40 +02:00
cd ../
# 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/"
2022-08-25 13:22:56 +02:00
cat <<EOF > "$PKG$PREFIX/bin/start_sway.sh"
2021-06-15 10:26:26 +02:00
#!/bin/bash
2021-05-01 12:07:45 +02:00
2022-10-06 13:19:26 +02:00
#set -e
2022-10-15 18:43:02 +02:00
LOGFILE=~/.wsession-errors
2022-10-06 13:19:26 +02:00
true > \$LOGFILE
exec &> \$LOGFILE
set -x
echo "sway Starting: \$( date )"
2022-08-30 13:44:05 +02:00
2022-08-25 13:22:56 +02:00
# Uncomment if mouse pointer is invisible
#export WLR_NO_HARDWARE_CURSORS=1
2021-05-01 12:07:45 +02:00
2022-10-06 12:36:35 +02:00
unset QT_QPA_PLATFORM
export WLR_RENDERER=vulkan
export CLUTTER_BACKEND=wayland
export SDL_VIDEODRIVER=wayland
export XDG_SESSION_DESKTOP=sway
export XDG_SESSION_TYPE=wayland
export QT_PLATFORMTHEME=qt5ct
export QT_PLATFORM_PLUGIN=qt5ct
2022-10-06 12:36:35 +02:00
export QT_QPA_PLATFORMTHEME=qt5ct
export MOZ_ENABLE_WAYLAND=1
export XDG_CURRENT_DESKTOP=sway
2022-10-15 18:43:02 +02:00
export XDG_PICTURES_DIR=~/.wallpapers
2022-10-06 12:36:35 +02:00
2022-08-25 13:22:56 +02:00
export SWAYSOCK=/run/user/\$(id -u)/sway-ipc.\$(id -u).\$(pgrep -x sway).sock
2022-07-13 13:38:21 +02:00
export XDG_RUNTIME_DIR=/tmp/xdg-runtime-\$(id -u)
2022-08-25 13:22:56 +02:00
2022-07-13 13:38:21 +02:00
mkdir -p \$XDG_RUNTIME_DIR
chmod 0700 \$XDG_RUNTIME_DIR
2022-07-13 13:38:21 +02:00
2022-10-06 12:36:35 +02:00
# avoid wlr error
unset DISPLAY
2022-10-15 18:43:21 +02:00
exec dbus-run-session /usr/bin/sway
#dbus-launch --sh-syntax --exit-with-session /usr/bin/sway
#exec /usr/bin/sway
2021-05-01 12:07:45 +02:00
EOF
2022-08-25 13:22:56 +02:00
chmod +x "$PKG$PREFIX/bin/start_sway.sh"
2021-05-01 12:07:45 +02:00
2022-08-25 13:22:56 +02:00
sed -i 's|Exec=sway|Exec=/usr/bin/start_sway.sh|' "$PKG$PREFIX/share/wayland-sessions/sway.desktop"
2021-05-01 12:07:45 +02:00
2022-08-25 13:22:56 +02:00
mkdir -p "$PKG$PREFIX/doc/$PRGNAM"
cp LICENSE ./*.md "$PKG$PREFIX/doc/$PRGNAM/"
2021-04-26 00:06:40 +02:00
# correction
2022-08-25 13:22:56 +02:00
cd "$PKG" || exit 1
chown -R root:root ./*
[ -d "$PKG$PREFIX/man" ] && find "$PKG$PREFIX/man" -name "*.?" -type f -exec gzip -9 {} \;
2021-04-26 00:06:40 +02:00
# embaumement
2022-08-25 13:22:56 +02:00
mkdir -p "$PKG/install"
2021-04-26 00:06:40 +02:00
2022-08-25 13:22:56 +02:00
cat <<EOF > "$PKG/install/slack-desc"
2021-04-26 00:06:40 +02:00
# 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}
2021-04-26 00:06:40 +02:00
EOF
# empaquetage
2022-08-25 13:22:56 +02:00
rm -f "$PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la"
2023-02-21 13:02:25 +01:00
/sbin/makepkg -l y -c n "$OUTPUT/${PRGNAM}+wlroots+libliftoff-$(echo "${VERSION}+${WLROOTS_VERSION}+${LIBLIFTOFF_VERSION}" | tr - _)-$ARCH-$BUILD$TAG.txz"