Files
aero3/packages/chroot-desktop.sh
T
2026-06-19 10:02:12 -04:00

140 lines
6.2 KiB
Bash
Executable File

#!/bin/bash
# packages/chroot-desktop.sh — Wayland + wlroots + cairo/pango + PipeWire +
# the AeroOS aerowm compositor. Runs INSIDE the chroot.
#
# Uses wlroots' pixman (software) renderer so we don't need Mesa/LLVM for the
# baseline image; hardware GL accel can be layered in later via mesa.
set -Eeuo pipefail
export LC_ALL=POSIX MAKEFLAGS="${MAKEFLAGS:--j4}"
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig:/usr/share/pkgconfig
export LD_LIBRARY_PATH="/usr/lib:/usr/lib64${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
SRC=/sources; STAMPS=/root/.base-stamps; mkdir -p "$STAMPS"
say(){ printf '\n\e[1;36m== %s ==\e[0m\n' "$*"; }
ldconfig 2>/dev/null || true
once(){ local n="$1"; shift; [[ -f "$STAMPS/$n" ]] && { echo "skip $n"; return; }; "$@"; ldconfig 2>/dev/null || true; touch "$STAMPS/$n"; }
find_tb(){ local m; shopt -s nocaseglob nullglob; local a=("$SRC/$1"-[0-9]*.tar.*) b=("$SRC/$1"*.tar.*) c=()
[[ "$1" == seatd ]] && c=("$SRC"/0.9.1.tar.*)
shopt -u nocaseglob nullglob
m="${a[0]:-${b[0]:-${c[0]:-}}}"
[[ -n "$m" ]] || { echo "MISSING SOURCE: $1" >&2; return 1; }; echo "$m"; }
unp(){ cd /tmp; rm -rf bld-"$1"; mkdir bld-"$1"; tar -xf "$(find_tb "$1")" -C bld-"$1" --strip-components=1; cd bld-"$1"; }
# meson helper: mz <stem> [opts...]
mz(){ local s="$1"; shift; unp "$s"; meson setup build --prefix=/usr --libdir=lib --buildtype=release --wrap-mode=nodownload "$@"; ninja -C build; ninja -C build install; cd /; }
# autotools helper
az(){ local s="$1"; shift; unp "$s"; ./configure --prefix=/usr "$@"; make; make install; cd /; }
# ---- core libs ----
p_libpng(){ az libpng; }
p_pcre2(){ az pcre2 --enable-unicode --enable-pcre2-16 --enable-pcre2-32 --enable-jit; }
p_fribidi(){ mz fribidi; }
p_freetype(){ az freetype --enable-freetype-config --disable-static; }
p_fontconfig(){ mz fontconfig --sysconfdir=/etc --localstatedir=/var \
-Ddoc=disabled -Dtests=disabled; }
p_harfbuzz(){ mz harfbuzz -Dgraphite2=disabled; }
p_pixman(){ mz pixman; }
p_glib(){ mz glib -Dintrospection=disabled -Dman-pages=disabled; }
p_graphene(){ mz graphene -Dtests=false -Dintrospection=disabled; }
p_cairo(){ mz cairo -Dtests=disabled -Dxlib=disabled -Dxcb=disabled; }
p_pango(){ mz pango -Dintrospection=disabled; }
p_dejavu(){ unp dejavu; install -d /usr/share/fonts/dejavu
cp -v ttf/*.ttf /usr/share/fonts/dejavu/; fc-cache -f || true; cd /; }
p_hwdata(){ unp hwdata; ./configure --prefix=/usr --disable-blacklist; make 2>/dev/null||true; make install; cd /; }
p_libffi(){ az libffi --disable-static; }
# ---- input / session ----
p_libxkbcommon(){ mz libxkbcommon -Denable-x11=false -Denable-wayland=false \
-Denable-docs=false -Denable-xkbregistry=false; }
p_libdrm(){ mz libdrm -Dvalgrind=disabled -Dintel=disabled -Dnouveau=disabled \
-Dradeon=disabled -Damdgpu=disabled 2>/dev/null || mz libdrm; }
p_seatd(){ mz seatd -Dlibseat-logind=systemd -Dserver=enabled \
-Dexamples=disabled -Dman-pages=disabled; }
p_mtdev(){ az mtdev --disable-static; }
p_libevdev(){ az libevdev --disable-static; }
p_libinput(){ mz libinput -Ddebug-gui=false -Dtests=false -Ddocumentation=false \
-Dlibwacom=false; }
# ---- wayland ----
p_libxml2(){ unp libxml2
sed -i "s/run_command('git', 'describe', check: false)/run_command('false', check: false)/" meson.build
meson setup build --prefix=/usr --libdir=lib --buildtype=release --wrap-mode=nodownload \
-Dpython=disabled -Ddocs=disabled -Dreadline=disabled -Dhistory=disabled
ninja -C build; ninja -C build install; cd /; }
p_wayland(){ mz wayland -Ddocumentation=false -Dtests=false; }
p_wayland_protocols(){ mz wayland-protocols -Dtests=false; }
p_libdisplay_info(){ mz libdisplay-info; }
p_wlroots(){ unp wlroots
meson setup build --prefix=/usr --libdir=lib --buildtype=release --wrap-mode=nodownload \
-Drenderers=[] -Dallocators=[] -Dbackends=drm,libinput -Dexamples=false \
-Dxwayland=disabled -Dsession=enabled -Dcolor-management=disabled -Dlibliftoff=disabled
ninja -C build; ninja -C build install; cd /; }
# ---- audio (PipeWire; lofi played via pw-play) ----
p_alsa(){ az alsa-lib; }
p_libsndfile(){ mz libsndfile -Dtests=false || az libsndfile; }
p_lua(){ unp lua
make linux MYCFLAGS="-fPIC" INSTALL_TOP=/usr
make INSTALL_TOP=/usr INSTALL_MAN=/usr/share/man/man1 install
install -d /usr/lib/pkgconfig
cat > /usr/lib/pkgconfig/lua-5.4.pc <<'EOF'
prefix=/usr
libdir=${prefix}/lib
includedir=${prefix}/include
Name: Lua
Description: Lua language engine
Version: 5.4.8
Libs: -L${libdir} -llua -lm -ldl
Cflags: -I${includedir}
EOF
ln -sf lua-5.4.pc /usr/lib/pkgconfig/lua5.4.pc
ln -sf lua-5.4.pc /usr/lib/pkgconfig/lua54.pc
ln -sf lua-5.4.pc /usr/lib/pkgconfig/lua.pc
cd /; }
p_pipewire(){ mz pipewire -Dsystemd=enabled -Dsession-managers=[] \
-Dman=disabled -Ddocs=disabled -Dexamples=disabled -Dtests=disabled \
-Djack=disabled -Dv4l2=disabled -Dpipewire-jack=disabled \
-Dreadline=disabled; }
p_wireplumber(){ mz wireplumber -Dsystemd=enabled -Ddoc=disabled -Dtests=false \
-Ddbus-tests=false -Dsystem-lua=true -Dsystem-lua-version=5.4; }
# ---- the AeroOS compositor ----
p_aerowm(){ cd /usr/src/aerowm
rm -rf build
meson setup build --prefix=/usr --buildtype=release
ninja -C build; ninja -C build install; cd /; }
say "AeroOS desktop stack (Wayland + wlroots + cairo/pango + PipeWire)"
once d-libffi p_libffi
once d-libpng p_libpng
once d-pcre2 p_pcre2
once d-fribidi p_fribidi
once d-freetype p_freetype
once d-fontconfig p_fontconfig
once d-harfbuzz p_harfbuzz
once d-freetype2 p_freetype # rebuild w/ harfbuzz for autohinting
once d-pixman p_pixman
once d-glib p_glib
once d-graphene p_graphene
once d-cairo p_cairo
once d-pango p_pango
once d-dejavu p_dejavu
once d-hwdata p_hwdata
once d-libxkbcommon p_libxkbcommon
once d-libdrm p_libdrm
once d-seatd p_seatd
once d-mtdev p_mtdev
once d-libevdev p_libevdev
once d-libinput p_libinput
once d-libxml2 p_libxml2
once d-wayland p_wayland
once d-wayland-proto p_wayland_protocols
once d-libdisplay-info p_libdisplay_info
once d-wlroots p_wlroots
once d-alsa p_alsa
once d-libsndfile p_libsndfile
once d-pipewire p_pipewire
once d-lua p_lua
once d-wireplumber p_wireplumber
once d-aerowm p_aerowm
echo "AeroOS desktop stack complete."