Initial AeroOS source

This commit is contained in:
Joe committed 2026-06-19 10:02:12 -04:00
commit b27732ad89
42 files changed
+3775

No files matched your search

+179
View File
@@ -0,0 +1,179 @@
#!/bin/bash
# packages/chroot-base.sh — runs INSIDE the AeroOS chroot (no host access).
# Builds the final base system (LFS ch. 8 essentials) from /sources.
set -Eeuo pipefail
export LC_ALL=POSIX MAKEFLAGS="${MAKEFLAGS:--j4}"
# Many gnulib-based packages (coreutils, tar, findutils, gawk, sed, diffutils…)
# refuse to ./configure as root unless this is set. The chroot build *is* root,
# so allow it globally.
export FORCE_UNSAFE_CONFIGURE=1
SRC=/sources
STAMPS=/root/.base-stamps; mkdir -p "$STAMPS"
say(){ printf '\n\e[1;36m== %s ==\e[0m\n' "$*"; }
once(){ local n="$1"; shift; [[ -f "$STAMPS/$n" ]] && { echo "skip $n"; return; }; "$@"; touch "$STAMPS/$n"; }
# find <stem> -> path to first matching tarball in /sources
find_tb(){ local m; shopt -s nocaseglob nullglob
local a=("$SRC/$1"-[0-9]*.tar.*) b=("$SRC/$1"*.tar.*)
shopt -u nocaseglob nullglob
m="${a[0]:-${b[0]:-}}"
[[ -n "$m" ]] || { echo "MISSING SOURCE: $1" >&2; return 1; }; echo "$m"; }
# unp <stem> -> extracts, cds into the dir, echoes nothing
unp(){ local tb d; tb=$(find_tb "$1"); cd /tmp; rm -rf bld-"$1"; mkdir bld-"$1"
tar -xf "$tb" -C bld-"$1" --strip-components=1; cd bld-"$1"; }
# std <stem> [configure args...] : standard autotools install
std(){ local stem="$1"; shift; unp "$stem"
./configure --prefix=/usr "$@"; make; make install; cd /; }
# ---- final glibc adjustments / locales -------------------------------------
p_glibc(){ unp glibc
# same OPEN_TREE_CLONE/-Werror fix as the cross glibc (see 01-toolchain.sh):
# keep the linux/mount.h include, just guard the conflicting macros so we get
# neither the macro-redefinition error nor a struct mount_attr double-def.
sed -i -E 's@^#define (OPEN_TREE_CLONE|OPEN_TREE_CLOEXEC|FSOPEN_CLOEXEC)([ \t].*)?$@#ifndef \1\n#define \1\2\n#endif@' \
sysdeps/unix/sysv/linux/sys/mount.h
# glibc's post-install test-installation.pl links test programs with -lnsl
# -lnss_dns etc., but glibc 2.34+ ships those deprecated compat libs without
# .so linker symlinks, so the test (not the install) fails. Neuter it.
echo 'exit 0;' > scripts/test-installation.pl
mkdir -v build; cd build
echo "rootsbindir=/usr/sbin" > configparms
../configure --prefix=/usr --disable-werror --enable-kernel=5.4 \
--enable-stack-protector=strong --disable-nscd libc_cv_slibdir=/usr/lib
make; make install
localedef -i C -f UTF-8 C.UTF-8 || true
localedef -i en_US -f UTF-8 en_US.UTF-8 || true
cd /; }
p_zlib(){ std zlib; rm -fv /usr/lib/libz.a; }
p_bzip2(){ unp bzip2; make -f Makefile-libbz2_so; make clean
make; make PREFIX=/usr install; cp -av libbz2.so.* /usr/lib
ln -sfv libbz2.so.1.0 /usr/lib/libbz2.so; cp -v bzip2-shared /usr/bin/bzip2; cd /; }
p_xz(){ std xz; rm -v /usr/lib/liblzma.la; }
p_zstd(){ unp zstd; make prefix=/usr; make prefix=/usr install; rm -v /usr/lib/libzstd.a; cd /; }
p_readline(){ unp readline
./configure --prefix=/usr --with-curses --disable-static
make SHLIB_LIBS="-lncursesw"
make SHLIB_LIBS="-lncursesw" install
cd /; }
p_m4(){ std m4; }
p_bc(){ unp bc
CC='gcc -std=c99' ./configure --prefix=/usr -G -O3
make; make install; cd /; }
p_ncurses(){ std ncurses --mandir=/usr/share/man --with-shared --without-debug \
--without-normal --without-cxx-binding --enable-pc-files --with-pkg-config-libdir=/usr/lib/pkgconfig
ln -sfv libncursesw.so /usr/lib/libncurses.so; }
p_bison(){ std bison; }
p_flex(){ std flex --disable-static; }
# bash 5.3 bundles readline 8.3 and uses 8.3-only hooks; link its bundled
# readline rather than the older system readline (8.2.x) to avoid undefined
# references like rl_completion_rewrite_hook.
p_bash(){ std bash --without-bash-malloc; ln -sfv bash /bin/sh; }
p_coreutils(){ unp coreutils; FORCE_UNSAFE_CONFIGURE=1 ./configure --prefix=/usr --enable-no-install-program=kill,uptime
make; make install; mv -v /usr/bin/chroot /usr/sbin 2>/dev/null || true; cd /; }
p_diffutils(){ std diffutils; }
p_gawk(){ std gawk; }
p_findutils(){ std findutils --localstatedir=/var/lib/locate; }
p_grep(){ std grep; }
p_gzip(){ std gzip; }
p_make(){ std make; }
p_patch(){ std patch; }
p_sed(){ std sed; }
p_tar(){ std tar; }
p_texinfo(){ std texinfo; }
p_file(){ std file; rm -v /usr/lib/libmagic.la 2>/dev/null||true; }
p_pkgconf(){ std pkgconf
ln -sfv pkgconf /usr/bin/pkg-config 2>/dev/null || true; }
p_gettext(){ std gettext --disable-shared; cp -v gettext-tools/src/{msgfmt,msgmerge,xgettext} /usr/bin 2>/dev/null||true; }
p_perl(){ unp perl
sh Configure -des -Dprefix=/usr -Dvendorprefix=/usr -Duseshrplib \
-Dprivlib=/usr/lib/perl5/core_perl -Darchlib=/usr/lib/perl5/core_perl
make; make install; cd /; }
p_python(){ std python --enable-shared --without-ensurepip; }
p_openssl(){ unp openssl; ./config --prefix=/usr --openssldir=/etc/ssl --libdir=lib shared zlib-dynamic
make; make MANSUFFIX=ssl install; cd /; }
p_kmod(){ std kmod --with-xz --with-zstd --with-openssl --disable-manpages
for t in depmod insmod modinfo modprobe rmmod; do ln -sfv kmod /usr/bin/$t; done; }
p_libcap(){ unp libcap; make prefix=/usr lib=lib; make prefix=/usr lib=lib install; cd /; }
p_libxcrypt(){ std libxcrypt --enable-hashes=strong,glibc \
--enable-obsolete-api=no --disable-static --disable-failure-tokens; }
p_util_linux(){ unp util-linux
./configure --libdir=/usr/lib --runstatedir=/run --disable-chfn-chsh \
--disable-login --disable-nologin --disable-su --disable-setpriv \
--disable-runuser --disable-pylibmount --disable-static \
--disable-liblastlog2 \
--without-python ADJTIME_PATH=/var/lib/hwclock/adjtime --docdir=/usr/share/doc/util-linux
make; make install; cd /; }
p_elfutils(){ std elfutils --disable-debuginfod --enable-libdebuginfod=dummy; }
p_rsync(){ unp rsync
./configure --prefix=/usr --with-included-popt --disable-md2man \
--disable-roll-simd \
--disable-openssl --disable-xxhash --disable-zstd --disable-lz4 \
--disable-acl-support --disable-xattr-support --disable-iconv
make; make install; cd /; }
p_expat(){ std expat --without-docbook; }
p_libffi(){ std libffi --disable-static --with-gcc-arch=native; }
# ---- final GCC (the system compiler) ---------------------------------------
p_gcc(){ unp gcc
tar -xf "$(find_tb mpfr)"; mv "$(ls -d mpfr-*)" mpfr
tar -xf "$(find_tb gmp)"; mv "$(ls -d gmp-*)" gmp
tar -xf "$(find_tb mpc)"; mv "$(ls -d mpc-*)" mpc
case "$(uname -m)" in x86_64) sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64;; esac
mkdir -v build; cd build
../configure --prefix=/usr LD=ld --enable-languages=c,c++ \
--enable-default-pie --enable-default-ssp --enable-host-pie \
--disable-multilib --disable-bootstrap --disable-fixincludes \
--disable-libsanitizer --with-system-zlib
make; make install
ln -sfv ../usr/bin/cpp /usr/lib 2>/dev/null || true
ln -sfv gcc /usr/bin/cc
cd /; }
say "AeroOS final base system"
# ---- bootstrap tools glibc (and others) need at build time --------------
# glibc's configure requires bison + python; python wants zlib/bzip2/xz/
# openssl/libffi modules, and openssl's Configure needs perl. Build these
# against the existing (stage-01) glibc before rebuilding the final glibc.
once b-m4 p_m4
once b-zlib p_zlib
once b-bzip2 p_bzip2
once b-xz p_xz
once b-bison p_bison
once b-perl p_perl
once b-openssl p_openssl
once b-libffi p_libffi
once b-python p_python
once b-texinfo p_texinfo
# ---- final glibc --------------------------------------------------------
once b-glibc p_glibc
# ---- remaining base system ----------------------------------------------
once b-zstd p_zstd
once b-readline-ncurses p_readline
once b-bc p_bc
once b-ncurses p_ncurses
once b-bash p_bash
once b-coreutils p_coreutils
once b-diffutils p_diffutils
once b-file p_file
once b-findutils p_findutils
once b-gawk p_gawk
once b-grep p_grep
once b-gzip p_gzip
once b-make p_make
once b-patch p_patch
once b-sed p_sed
once b-tar p_tar
once b-flex p_flex
once b-pkgconf p_pkgconf
once b-gettext p_gettext
once b-expat p_expat
once b-libcap p_libcap
once b-libxcrypt p_libxcrypt
once b-util-linux p_util_linux
once b-gcc p_gcc
once b-kmod p_kmod
once b-elfutils p_elfutils
once b-rsync p_rsync
echo "AeroOS base system build complete."
+29
View File
@@ -0,0 +1,29 @@
#!/bin/bash
# packages/chroot-buildtools.sh — bootstrap ninja + meson inside the chroot.
# Needed by systemd and the whole Wayland/desktop stack. No pip required.
set -Eeuo pipefail
export LC_ALL=POSIX MAKEFLAGS="${MAKEFLAGS:--j4}"
SRC=/sources; STAMPS=/root/.base-stamps; mkdir -p "$STAMPS"
once(){ local n="$1"; shift; [[ -f "$STAMPS/$n" ]] && { echo "skip $n"; return; }; "$@"; touch "$STAMPS/$n"; }
find_tb(){ local m; shopt -s nocaseglob nullglob; local a=("$SRC/$1"-[0-9]*.tar.*) b=("$SRC/$1"*.tar.*); shopt -u nocaseglob nullglob; m="${a[0]:-${b[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"; }
t_ninja(){ unp ninja; python3 configure.py --bootstrap; install -m755 ninja /usr/bin/ninja; cd /; }
t_meson(){ unp meson
# meson runs directly from source; install to /opt and symlink (no pip needed)
rm -rf /opt/meson; mkdir -p /opt/meson; cp -a . /opt/meson/
ln -sfv /opt/meson/meson.py /usr/bin/meson; chmod +x /opt/meson/meson.py; cd /; }
t_gperf(){ unp gperf; ./configure --prefix=/usr; make; make install; cd /; }
t_python_modules(){ local site
site="$(python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')"
mkdir -p "$site"
unp markupsafe; cp -a src/markupsafe "$site/"; cd /
unp jinja2; cp -a src/jinja2 "$site/"; cd /
python3 -c 'import jinja2; print("jinja2", jinja2.__version__)'
}
once t-ninja t_ninja
once t-meson t_meson
once t-gperf t_gperf
once t-python-modules t_python_modules
echo "build tools ready: $(ninja --version), meson $(meson --version)"
+139
View File
@@ -0,0 +1,139 @@
#!/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."
+54
View File
@@ -0,0 +1,54 @@
#!/bin/bash
# packages/chroot-imagetools.sh — build the tools needed to make the live ISO:
# static busybox (for the initramfs), squashfs-tools, mtools, xorriso (libburnia)
# and grub's x86_64-efi target. Runs INSIDE the chroot.
set -Eeuo pipefail
export LC_ALL=POSIX MAKEFLAGS="${MAKEFLAGS:--j4}"
SRC=/sources; STAMPS=/root/.base-stamps; mkdir -p "$STAMPS"
once(){ local n="$1"; shift; [[ -f "$STAMPS/$n" ]] && { echo "skip $n"; return; }; "$@"; touch "$STAMPS/$n"; }
find_tb(){ local m; shopt -s nocaseglob nullglob; local a=("$SRC/$1"-[0-9]*.tar.*) b=("$SRC/$1"*.tar.*); shopt -u nocaseglob nullglob; m="${a[0]:-${b[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"; }
i_busybox(){ unp busybox
make defconfig >/dev/null
sed -i \
-e 's/^# CONFIG_STATIC is not set$/CONFIG_STATIC=y/' \
-e 's/^CONFIG_STATIC=.*/CONFIG_STATIC=y/' \
-e 's/^CONFIG_TC=y$/# CONFIG_TC is not set/' \
-e 's/^CONFIG_FEATURE_TC_INGRESS=y$/# CONFIG_FEATURE_TC_INGRESS is not set/' \
.config
set +o pipefail
yes "" 2>/dev/null | make oldconfig >/dev/null 2>&1
local oldconfig_status="${PIPESTATUS[1]}"
set -o pipefail
(( oldconfig_status == 0 ))
make
install -Dm755 busybox /usr/bin/busybox-static
cd /; }
i_squashfs(){ unp squashfs-tools; cd squashfs-tools 2>/dev/null || true
make GZIP_SUPPORT=1 XZ_SUPPORT=1 ZSTD_SUPPORT=1
make GZIP_SUPPORT=1 XZ_SUPPORT=1 ZSTD_SUPPORT=1 \
INSTALL_PREFIX=/usr INSTALL_MANPAGES_DIR= install
cd /; }
i_libburn(){ unp libburn
sed -i 's/^static void catch_int ()$/static void catch_int (int signum)/' test/poll.c
./configure --prefix=/usr --disable-static
make; make install; cd /; }
i_libisofs(){ unp libisofs; ./configure --prefix=/usr --disable-static; make; make install; cd /; }
i_libisoburn(){ unp libisoburn; ./configure --prefix=/usr --disable-static; make; make install; cd /; }
i_mtools(){ unp mtools; ./configure --prefix=/usr; make; make install; cd /; }
i_grub_efi(){ unp grub
: > grub-core/extra_deps.lst
./configure --prefix=/usr --sysconfdir=/etc --disable-werror \
--with-platform=efi --target=x86_64
make; make install; cd /; }
echo "== image tools =="
once i-busybox i_busybox
once i-squashfs i_squashfs
once i-libburn i_libburn
once i-libisofs i_libisofs
once i-libisoburn i_libisoburn
once i-mtools i_mtools
once i-grub-efi i_grub_efi
echo "image tools ready"
+140
View File
@@ -0,0 +1,140 @@
#!/bin/bash
# packages/chroot-systemd.sh — systemd, D-Bus, shadow, GRUB + system config.
# Runs INSIDE the chroot.
set -Eeuo pipefail
export LC_ALL=POSIX MAKEFLAGS="${MAKEFLAGS:--j4}"
SRC=/sources; STAMPS=/root/.base-stamps; mkdir -p "$STAMPS"
say(){ printf '\n\e[1;36m== %s ==\e[0m\n' "$*"; }
once(){ local n="$1"; shift; [[ -f "$STAMPS/$n" ]] && { echo "skip $n"; return; }; "$@"; touch "$STAMPS/$n"; }
find_tb(){ local m; shopt -s nocaseglob nullglob; local a=("$SRC/$1"-[0-9]*.tar.*) b=("$SRC/$1"*.tar.*) c=()
[[ "$1" == systemd ]] && c=("$SRC"/v[0-9]*.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"; }
p_shadow(){ unp shadow
sed -i 's/groups$(EXEEXT) //' src/Makefile.in
find man -name Makefile.in -exec sed -i 's/groups\.1 / /' {} \; 2>/dev/null || true
sed -e 's:#ENCRYPT_METHOD DES:ENCRYPT_METHOD YESCRYPT:' \
-e 's:/var/spool/mail:/var/mail:' -i etc/login.defs
touch /usr/bin/passwd
./configure --sysconfdir=/etc --disable-static --with-{b,yes}crypt \
--without-libbsd --with-group-name-max-length=32
make; make exec_prefix=/usr install; make -C man install-man || true
pwconv; grpconv
echo "root:${AEROS_ROOT_PASS:-root}" | chpasswd
cd /; }
p_dbus(){ unp dbus
meson setup build --prefix=/usr --libdir=lib --sysconfdir=/etc --localstatedir=/var \
-Druntime_dir=/run \
-Dsystem_pid_file=/run/dbus/pid \
-Dsystem_socket=/run/dbus/system_bus_socket \
-Dsystemd=enabled \
-Dsystemd_system_unitdir=/usr/lib/systemd/system \
-Dsystemd_user_unitdir=/usr/lib/systemd/user \
-Dmodular_tests=disabled -Dinstalled_tests=false \
-Dxml_docs=disabled -Ddoxygen_docs=disabled -Dducktype_docs=disabled -Dqt_help=disabled \
-Dselinux=disabled -Dapparmor=disabled -Dlibaudit=disabled \
-Dx11_autolaunch=disabled -Dlaunchd=disabled
ninja -C build
ninja -C build install
cd /; }
p_systemd(){ unp systemd
sed -i "s/'-Werror=override-init'/'-Wno-error=override-init'/" meson.build
cp -f /usr/include/linux/input-event-codes.h src/basic/linux/input-event-codes.h
meson setup build --prefix=/usr --libdir=lib --buildtype=release \
-Dmode=release -Dlink-udev-shared=true \
-Ddefault-dnssec=no -Dfirstboot=true -Dinstall-tests=false \
-Dldconfig=true -Dsysusers=true -Drpmmacrosdir=no \
-Dhomed=disabled -Duserdb=true -Dman=disabled \
-Dpamconfdir=no -Dnss-systemd=true \
-Ddbus=disabled -Dglib=disabled
ninja -C build
ninja -C build install
# enable getty + basic targets
systemctl preset-all 2>/dev/null || true
cd /; }
p_grub(){ unp grub
: > grub-core/extra_deps.lst
# BIOS + UEFI (x86_64-efi) targets
./configure --prefix=/usr --sysconfdir=/etc --disable-efiemu --enable-grub-mkfont=no \
--with-platform=pc --disable-werror || ./configure --prefix=/usr --sysconfdir=/etc --disable-werror
make; make install
cd /; rm -rf /tmp/bld-grub; unp grub
: > grub-core/extra_deps.lst
./configure --prefix=/usr --sysconfdir=/etc --with-platform=efi \
--target=x86_64 --program-prefix="" --disable-werror || true
make 2>/dev/null && make install 2>/dev/null || echo "grub-efi optional build skipped"
cd /; }
configure_system(){
say "Base system configuration"
# hostname
echo "${AEROS_HOSTNAME:-aeros}" > /etc/hostname
# hosts
cat > /etc/hosts <<EOF
127.0.0.1 localhost ${AEROS_HOSTNAME:-aeros}
::1 localhost ip6-localhost ip6-loopback
EOF
# os-release branding
cat > /etc/os-release <<EOF
NAME="${AEROS_NAME:-AeroOS}"
PRETTY_NAME="${AEROS_NAME:-AeroOS} ${AEROS_VERSION:-1.0} (${AEROS_CODENAME:-Frutiger})"
ID=${AEROS_DISTRO_ID:-aeros}
VERSION_ID=${AEROS_VERSION:-1.0}
VERSION_CODENAME=${AEROS_CODENAME:-frutiger}
HOME_URL="https://aeros.example"
ANSI_COLOR="1;36"
EOF
cat > /etc/lsb-release <<EOF
DISTRIB_ID=${AEROS_DISTRO_ID:-aeros}
DISTRIB_RELEASE=${AEROS_VERSION:-1.0}
DISTRIB_CODENAME=${AEROS_CODENAME:-Frutiger}
DISTRIB_DESCRIPTION="${AEROS_NAME:-AeroOS}"
EOF
# locale
cat > /etc/locale.conf <<EOF
LANG=${AEROS_LOCALE:-en_US.UTF-8}
EOF
# vconsole / time
echo "KEYMAP=${AEROS_KEYMAP:-us}" > /etc/vconsole.conf
ln -sfv "/usr/share/zoneinfo/${AEROS_TIMEZONE:-UTC}" /etc/localtime
# fstab (live image overlays root; this is for installed systems)
cat > /etc/fstab <<EOF
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/sda2 / ext4 defaults,noatime 0 1
/dev/sda1 /boot/efi vfat umask=0077 0 2
tmpfs /tmp tmpfs nosuid,nodev 0 0
EOF
# default target = graphical (lands on the Aero home screen)
systemctl set-default graphical.target 2>/dev/null || \
ln -sfv /usr/lib/systemd/system/graphical.target /etc/systemd/system/default.target
# enable networking + resolved
systemctl enable systemd-networkd systemd-resolved 2>/dev/null || true
ln -sfv /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf 2>/dev/null || true
cat > /etc/systemd/network/20-wired.network <<EOF
[Match]
Name=en* eth*
[Network]
DHCP=yes
EOF
# ld cache
cat > /etc/ld.so.conf <<EOF
/usr/local/lib
/usr/lib
/usr/lib64
EOF
ldconfig || true
}
say "AeroOS init + boot layer"
once s-shadow p_shadow
once s-systemd p_systemd
once s-dbus p_dbus
once s-grub p_grub
once s-config configure_system
echo "systemd/boot layer complete."