kick/install.sh

80 lines
3.1 KiB
Bash
Executable file

#!/bin/sh
# ./install.sh [--prefix PREFIX]
#
# Release-build kick and install it by plain copy (no meson install):
# $DESTDIR$PREFIX/bin/kick
# $DESTDIR$PREFIX/bin/kick-session (login wrapper: per-boot logs, then execs kick)
# $DESTDIR$PREFIX/bin/kick-pi (Pi session entry: setup_env + runtime dir
# + pixman fallback, then execs kick; labwc-pi analogue, no logging)
# $DESTDIR$PREFIX/share/applications/kick.desktop
# $DESTDIR$PREFIX/share/wayland-sessions/kick.desktop (from kick-session.desktop)
# $DESTDIR$PREFIX/lib/<multiarch>/libwlroots-0.20.so (only when kick linked
# against the pinned subproject fallback and no system wlroots-0.20 exists)
#
# Defaults to PREFIX=/usr so the login entry lands in
# /usr/share/wayland-sessions, where lightdm/gdm/sddm/greetd look.
# DESTDIR is honoured for staging (e.g. DESTDIR=/tmp/stage ./install.sh).
set -e
cd "$(dirname "$0")"
PREFIX=/usr
if [ "$1" = "--prefix" ]; then
[ $# -ge 2 ] || { echo "usage: $0 [--prefix PREFIX]" >&2; exit 2; }
PREFIX=$2
shift 2
fi
[ $# -eq 0 ] || { echo "usage: $0 [--prefix PREFIX]" >&2; exit 2; }
[ -n "$PREFIX" ] || { echo "install: empty --prefix" >&2; exit 2; }
case "$PREFIX" in
/*) ;;
*) echo "install: --prefix must be absolute: $PREFIX" >&2; exit 2 ;;
esac
./build.sh release
DEST=${DESTDIR:-}
ROOT="$DEST$PREFIX"
# Need root only when the target isn't writable (system prefix, no DESTDIR):
# walk up to the first existing ancestor and test that.
SUDO=
_anc="$ROOT"
while [ ! -e "$_anc" ] && [ "$_anc" != "/" ]; do
_anc=$(dirname "$_anc")
done
[ -w "$_anc" ] || SUDO=sudo
set -x
$SUDO mkdir -p "$ROOT/bin" \
"$ROOT/share/applications" \
"$ROOT/share/wayland-sessions"
$SUDO cp -f build-release/kick "$ROOT/bin/kick"
$SUDO cp -f kick-session "$ROOT/bin/kick-session"
$SUDO cp -f kick-pi "$ROOT/bin/kick-pi"
$SUDO chmod 755 "$ROOT/bin/kick" "$ROOT/bin/kick-session" "$ROOT/bin/kick-pi"
$SUDO cp -f kick.desktop "$ROOT/share/applications/kick.desktop"
$SUDO cp -f kick-session.desktop "$ROOT/share/wayland-sessions/kick.desktop"
$SUDO chmod 644 "$ROOT/share/applications/kick.desktop" \
"$ROOT/share/wayland-sessions/kick.desktop"
# Fallback wlroots: when kick linked against the pinned subproject build
# (no system wlroots-0.20), ship that .so too -- otherwise the installed
# kick dies at exec with "libwlroots-0.20.so: cannot open shared object".
# Skipped when the system already provides wlroots-0.20 (ldconfig finds it).
FALLBACK_LIB=build-release/subprojects/wlroots-0.20.2/libwlroots-0.20.so
if [ -f "$FALLBACK_LIB" ] && ! ldconfig -p 2>/dev/null | grep -q libwlroots-0.20; then
MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null \
|| gcc -print-multiarch 2>/dev/null) || MULTIARCH=
if [ -n "$MULTIARCH" ]; then
LIBDIR="$ROOT/lib/$MULTIARCH"
else
LIBDIR="$ROOT/lib"
fi
$SUDO mkdir -p "$LIBDIR"
$SUDO cp -f "$FALLBACK_LIB" "$LIBDIR/libwlroots-0.20.so"
$SUDO chmod 644 "$LIBDIR/libwlroots-0.20.so"
# Refresh the loader cache on real installs (never under DESTDIR staging).
if [ -z "$DEST" ]; then
$SUDO ldconfig
fi
fi