slackbuilds/xap/qtile/SlackBuild
Gwenhael Le Moine 27db07babf
[qtile] desc
2023-12-06 07:54:41 +01:00

277 lines
7.7 KiB
Bash
Executable file

#!/bin/bash
# variables
GITHUB_REPO=qtile/qtile
VERSION=${VERSION:-latest}
BUILD=4
TAG=gwh
OUTPUT=/tmp
TMP=/tmp/$TAG
CWD=$(pwd)
PKGNAM=$(basename $CWD)
PKG=$TMP/pkg-$PKGNAM
ARCH=$(uname -m)
REPOSITORY=/home/installs/SlackBuilds/_repositories/$PKGNAM
PREFIX=/usr
# nettoyage préalable
rm -fr $PKG $TMP/$PKGNAM
mkdir -p $PKG
# mise en place
[ ! -e $REPOSITORY ] && git clone https://github.com/${GITHUB_REPO} $REPOSITORY
cd $REPOSITORY
git pull --all
cp -R $REPOSITORY $TMP/
cd $TMP/$PKGNAM/
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 "$VERSION"
;;
*)
PKGVERSION="$VERSION"
git checkout "$VERSION"
;;
esac
# installation
python3 ./setup.py install --root=$PKG
cat <<EOF > $PKG$PREFIX/bin/start_qtile.sh
#!/bin/bash
#set -e
LOGFILE=~/.wsession-errors
true > \$LOGFILE
exec &> \$LOGFILE
set -x
echo "$PKGNAM Starting: \$( date )"
# Uncomment if mouse pointer is invisible
#export WLR_NO_HARDWARE_CURSORS=1
unset QT_QPA_PLATFORM
export QT_QPA_PLATFORMTHEME=qt5ct
export MOZ_ENABLE_WAYLAND=1
export XDG_CURRENT_DESKTOP=sway
export XDG_PICTURES_DIR=~/.wallpapers
export XDG_RUNTIME_DIR=/tmp/xdg-runtime-\$(id -u)
mkdir -p \$XDG_RUNTIME_DIR
chmod 0700 \$XDG_RUNTIME_DIR
# avoid wlr error
unset DISPLAY
exec dbus-run-session qtile start -b wayland
EOF
chmod +x $PKG$PREFIX/bin/start_qtile.sh
mkdir -p $PKG$PREFIX/share/wayland-sessions/
cp resources/qtile-wayland.desktop $PKG$PREFIX/share/wayland-sessions/
mkdir -p $PKG$PREFIX/share/xsessions/
cp resources/qtile.desktop $PKG$PREFIX/share/xsessions/
mkdir -p $PKG/etc/X11/xinit/
cat <<EOF > $PKG/etc/X11/xinit/xinitrc.$PKGNAM
#!/bin/sh
userresources=\$HOME/.Xresources
usermodmap=\$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap
# Merge in defaults and keymaps
if [ -f \$sysresources ]; then
xrdb -merge \$sysresources
fi
if [ -f \$sysmodmap ]; then
xmodmap \$sysmodmap
fi
if [ -f \$userresources ]; then
xrdb -merge \$userresources
fi
if [ -f \$usermodmap ]; then
xmodmap \$usermodmap
fi
# Start qtile
if [ -z "\$DESKTOP_SESSION" -a -x /usr/bin/ck-launch-session ]; then
exec ck-launch-session dbus-launch --exit-with-session qtile start
else
exec dbus-launch --exit-with-session qtile start
fi
EOF
sed -i 's|Exec=qtile start -b wayland|Exec=/usr/bin/start_qtile.sh|' $PKG$PREFIX/share/wayland-sessions/qtile-wayland.desktop
mkdir -p $PKG$PREFIX/doc/$PKGNAM
cp LICENSE *.md $PKG$PREFIX/doc/$PKGNAM/
######################
# EMBED DEPENDENCIES #
######################
# qtile-extras
EMBED_EXTRAS=${EMBED_EXTRAS:-"yes"}
if [ "$EMBED_EXTRAS" = "yes" ]; then
EXTRAS_PKGNAM=qtile-extras
EXTRAS_GITHUB_REPO=elParaguayo/qtile-extras
EXTRAS_VERSION=${EXTRAS_VERSION:-$VERSION}
EXTRAS_REPOSITORY=/home/installs/SlackBuilds/_repositories/$EXTRAS_PKGNAM
[ ! -e "$EXTRAS_REPOSITORY" ] && git clone https://github.com/${EXTRAS_GITHUB_REPO}.git "$EXTRAS_REPOSITORY"
cd "$EXTRAS_REPOSITORY" || exit 1
git reset --hard HEAD
git pull --all
cp -R $EXTRAS_REPOSITORY $TMP/
cd $TMP/qtile-extras/ || exit 1
case $EXTRAS_VERSION in
trunk)
EXTRAS_VERSION="r$(git rev-list --count HEAD)_$(git log -1 --format=%h)"
;;
latest)
EXTRAS_VERSION=$(git describe --tags --abbrev=0)
git checkout "$EXTRAS_VERSION"
;;
*)
git checkout "$EXTRAS_VERSION"
;;
esac
PKGNAM="${PKGNAM}+extras"
PKGVERSION="${PKGVERSION}+${EXTRAS_VERSION}"
# installation
python3 -m build --wheel
python3 -m installer --destdir $PKG --prefix /usr dist/*.whl
mkdir -p $PKG$PREFIX/doc/qtile-extras
cp CHANGELOG LICENSE ./*.md $PKG$PREFIX/doc/qtile-extras/
fi
# pywayland
EMBED_PYWAYLAND=${EMBED_PYWAYLAND:-"yes"}
if [ "$EMBED_PYWAYLAND" = "yes" ]; then
PYWAYLAND_PKGNAM=pywayland
PYWAYLAND_GITHUB_REPO=flacjacket/pywayland
PYWAYLAND_VERSION=${PYWAYLAND_VERSION:-$VERSION}
PYWAYLAND_REPOSITORY=/home/installs/SlackBuilds/_repositories/$PYWAYLAND_PKGNAM
[ ! -e "$PYWAYLAND_REPOSITORY" ] && git clone https://github.com/${PYWAYLAND_GITHUB_REPO}.git "$PYWAYLAND_REPOSITORY"
cd "$PYWAYLAND_REPOSITORY" || exit 1
git reset --hard HEAD
git pull --all
cp -R $PYWAYLAND_REPOSITORY $TMP/
cd $TMP/pywayland/ || exit 1
case $PYWAYLAND_VERSION in
trunk)
PYWAYLAND_VERSION="r$(git rev-list --count HEAD)_$(git log -1 --format=%h)"
;;
latest)
PYWAYLAND_VERSION=$(git describe --tags --abbrev=0)
git checkout "$PYWAYLAND_VERSION"
;;
*)
git checkout "$PYWAYLAND_VERSION"
;;
esac
PKGNAM="${PKGNAM}+pywayland"
PKGVERSION="${PKGVERSION}+${PYWAYLAND_VERSION}"
# installation
python3 ./setup.py install --root=$PKG
mkdir -p $PKG$PREFIX/doc/pywayland
cp LICENSE README.rst $PKG$PREFIX/doc/pywayland/
fi
# pywlroots
EMBED_PYWLROOTS=${EMBED_PYWLROOTS:-"yes"}
if [ "$EMBED_PYWLROOTS" = "yes" ]; then
PYWLROOTS_PKGNAM=pywlroots
PYWLROOTS_GITHUB_REPO=flacjacket/pywlroots
PYWLROOTS_VERSION=${PYWLROOTS_VERSION:-$VERSION}
PYWLROOTS_REPOSITORY=/home/installs/SlackBuilds/_repositories/$PYWLROOTS_PKGNAM
[ ! -e "$PYWLROOTS_REPOSITORY" ] && git clone https://github.com/${PYWLROOTS_GITHUB_REPO}.git "$PYWLROOTS_REPOSITORY"
cd "$PYWLROOTS_REPOSITORY" || exit 1
git reset --hard HEAD
git pull --all
cp -R $PYWLROOTS_REPOSITORY $TMP/
cd $TMP/pywlroots/ || exit 1
case $PYWLROOTS_VERSION in
trunk)
PYWLROOTS_VERSION="r$(git rev-list --count HEAD)_$(git log -1 --format=%h)"
;;
latest)
PYWLROOTS_VERSION=$(git describe --tags --abbrev=0)
git checkout "$PYWLROOTS_VERSION"
;;
*)
git checkout "$PYWLROOTS_VERSION"
;;
esac
PKGNAM="${PKGNAM}+pywlroots"
PKGVERSION="${PKGVERSION}+${PYWLROOTS_VERSION}"
# installation
python3 ./setup.py install --root=$PKG
mkdir -p $PKG$PREFIX/doc/pywlroots
cp LICENSE README.rst $PKG$PREFIX/doc/pywlroots/
fi
# correction
cd $PKG
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------------------------------------------------------|
$PKGNAM: $PKGNAM (A dynamic tiling window manager)
$PKGNAM:
$PKGNAM: A full-featured, hackable tiling window manager written and
$PKGNAM: configured in Python
$PKGNAM: $([ "$EMBED_EXTRAS" = "yes" ] && echo "(includes qtile-extras)")
$PKGNAM: $([ "$EMBED_PYWAYLAND" = "yes" ] && echo "(includes pywayland)")
$PKGNAM: $([ "$EMBED_PYWLROOTS" = "yes" ] && echo "(includes pywlroots)")
$PKGNAM: https://qtile.org
$PKGNAM: $([ "$EMBED_PYWAYLAND" = "yes" ] && echo https://github.com/${PYWAYLAND_GITHUB_REPO})
$PKGNAM: $([ "$EMBED_PYWLROOTS" = "yes" ] && echo https://github.com/${PYWLROOTS_GITHUB_REPO})
$PKGNAM: $([ "$EMBED_EXTRAS" = "yes" ] && echo https://github.com/${EXTRAS_GITHUB_REPO})
EOF
# empaquetage
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
/sbin/makepkg --linkadd y --chown n --prepend $OUTPUT/$PKGNAM-$PKGVERSION-$ARCH-$BUILD$TAG.txz