mirror of
https://github.com/blazblue547-afk/aero3.git
synced 2026-12-02 14:24:17 -05:00
Initial AeroOS source
This commit is contained in:
commit
b27732ad89
42 files changed
+3775
No files matched your search
Executable
+135
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/00-prepare.sh — host checks, directory layout, source download.
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/lib/common.sh"
|
||||
|
||||
HOST_TOOLS=(bash ld bison gawk gcc g++ grep gzip m4 make patch perl
|
||||
python3 sed tar makeinfo xz find)
|
||||
|
||||
check_host() {
|
||||
step "Host requirements"
|
||||
local missing=()
|
||||
for cmd in "${HOST_TOOLS[@]}"; do
|
||||
command -v "$cmd" >/dev/null 2>&1 || missing+=("$cmd")
|
||||
done
|
||||
# need at least one downloader
|
||||
if ! command -v curl >/dev/null 2>&1 && ! command -v wget >/dev/null 2>&1; then
|
||||
missing+=("curl-or-wget")
|
||||
fi
|
||||
|
||||
if ((${#missing[@]})); then
|
||||
warn "Missing host build tools: ${missing[*]}"
|
||||
cat <<EOF
|
||||
Install them, e.g. on Debian/Ubuntu/WSL2:
|
||||
sudo apt-get install build-essential bison gawk texinfo \\
|
||||
gettext python3 m4 patch xz-utils wget curl libssl-dev \\
|
||||
flex meson ninja-build cmake pkg-config gperf
|
||||
On Fedora:
|
||||
sudo dnf groupinstall "Development Tools" && sudo dnf install bison flex \\
|
||||
texinfo gettext openssl-devel meson ninja-build cmake
|
||||
EOF
|
||||
die "host is missing required tools"
|
||||
fi
|
||||
|
||||
# version sanity (LFS host requirements)
|
||||
local kver gccver
|
||||
gccver=$(gcc -dumpversion | cut -d. -f1)
|
||||
(( gccver >= 9 )) || warn "GCC $gccver is old; >= 9 recommended"
|
||||
kver=$(uname -r)
|
||||
log "host kernel: $kver, gcc: $(gcc -dumpversion)"
|
||||
|
||||
# disk space
|
||||
local avail_gb
|
||||
avail_gb=$(df -BG --output=avail "$AEROS_TOP" | tail -1 | tr -dc '0-9')
|
||||
(( avail_gb >= 30 )) || warn "only ${avail_gb}G free under $AEROS_TOP; >= 30G recommended"
|
||||
ok "host looks usable (${avail_gb}G free)"
|
||||
}
|
||||
|
||||
make_layout() {
|
||||
step "Directory layout"
|
||||
mkdir -pv "$AEROS_ROOT" "$AEROS_SOURCES" "$AEROS_OUT" "$AEROS_LOGDIR"
|
||||
mkdir -pv "$AEROS_ROOT"/{etc,var,tools} "$AEROS_ROOT"/usr/{bin,lib,sbin}
|
||||
for d in bin lib sbin; do
|
||||
[[ -e "$AEROS_ROOT/$d" ]] || ln -sv "usr/$d" "$AEROS_ROOT/$d"
|
||||
done
|
||||
case "$AEROS_ARCH" in
|
||||
x86_64) mkdir -pv "$AEROS_ROOT/usr/lib64"
|
||||
[[ -e "$AEROS_ROOT/lib64" ]] || ln -sv usr/lib64 "$AEROS_ROOT/lib64" ;;
|
||||
esac
|
||||
ok "layout ready at $AEROS_ROOT"
|
||||
}
|
||||
|
||||
# Build a list of mirror candidates for a URL (handles slow/blocked hosts).
|
||||
mirror_candidates() {
|
||||
local url="$1"
|
||||
# GNU: ftp.gnu.org is often slow/blocked; ftpmirror picks a fast mirror.
|
||||
case "$url" in
|
||||
https://ftp.gnu.org/gnu/*)
|
||||
echo "${url/https:\/\/ftp.gnu.org\/gnu\//https://ftpmirror.gnu.org/}"
|
||||
echo "${url/https:\/\/ftp.gnu.org\/gnu\//https://mirrors.kernel.org/gnu/}"
|
||||
;;
|
||||
esac
|
||||
echo "$url" # original tried last
|
||||
}
|
||||
|
||||
# download_one <url> <dest> : try mirrors with curl, then wget; hard timeouts
|
||||
# (--speed-limit/--speed-time aborts a stalled transfer instead of hanging).
|
||||
download_one() {
|
||||
local url="$1" dest="$2" cand
|
||||
while read -r cand; do
|
||||
[[ -n "$cand" ]] || continue
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
if curl -fL --retry 2 --retry-delay 2 --connect-timeout 15 \
|
||||
--max-time 900 --speed-time 30 --speed-limit 1024 \
|
||||
-o "$dest" "$cand"; then return 0; fi
|
||||
fi
|
||||
if command -v wget >/dev/null 2>&1; then
|
||||
if wget -q --tries=2 --connect-timeout=15 --read-timeout=30 \
|
||||
-O "$dest" "$cand"; then return 0; fi
|
||||
fi
|
||||
warn " mirror failed: $cand"
|
||||
done < <(mirror_candidates "$url")
|
||||
return 1
|
||||
}
|
||||
|
||||
fetch_sources() {
|
||||
step "Fetch upstream sources"
|
||||
mkdir -p "$AEROS_SOURCES"
|
||||
command -v curl >/dev/null 2>&1 || command -v wget >/dev/null 2>&1 \
|
||||
|| die "need curl or wget to fetch sources"
|
||||
local fails=0
|
||||
for name in "${!PKG[@]}"; do
|
||||
[[ "${PKG[$name]}" == *"|http"* ]] || continue # skip note entries
|
||||
local url tb dest
|
||||
url="$(pkg_url "$name")"
|
||||
tb="$(pkg_tarball "$name")"
|
||||
dest="$AEROS_SOURCES/$tb"
|
||||
if [[ -s "$dest" ]]; then ok "have $tb"; continue; fi
|
||||
log "download $name -> $tb"
|
||||
if download_one "$url" "$dest.part"; then
|
||||
mv "$dest.part" "$dest"
|
||||
else
|
||||
warn "FAILED: $name ($url)"; rm -f "$dest.part"; ((fails++))
|
||||
fi
|
||||
done
|
||||
# optional checksum verification
|
||||
if [[ -f "$AEROS_TOP/config/checksums.sha256" ]]; then
|
||||
log "verifying checksums"
|
||||
( cd "$AEROS_SOURCES" && sha256sum -c "$AEROS_TOP/config/checksums.sha256" ) \
|
||||
|| die "checksum verification failed"
|
||||
else
|
||||
warn "no config/checksums.sha256 — skipping integrity check"
|
||||
warn "generate one with: (cd sources && sha256sum * > ../config/checksums.sha256)"
|
||||
fi
|
||||
(( fails == 0 )) || die "$fails source(s) failed to download"
|
||||
ok "all sources present in $AEROS_SOURCES"
|
||||
}
|
||||
|
||||
main() {
|
||||
case "${1:-all}" in
|
||||
check) check_host ;;
|
||||
fetch) fetch_sources ;;
|
||||
all) check_host; make_layout; fetch_sources ;;
|
||||
*) die "usage: 00-prepare.sh [check|fetch|all]" ;;
|
||||
esac
|
||||
}
|
||||
main "$@"
|
||||
Executable
+112
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/01-toolchain.sh — cross toolchain in $AEROS_TOOLS (LFS ch. 5).
|
||||
# Builds: binutils (pass1) -> gcc (pass1) -> linux headers -> glibc -> libstdc++.
|
||||
# Run as the unprivileged build user with write access to $AEROS_ROOT.
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/lib/common.sh"
|
||||
deny_root
|
||||
|
||||
export LFS="$AEROS_ROOT"
|
||||
export LC_ALL=POSIX
|
||||
export AEROS_TGT="$AEROS_TARGET_TRIPLET"
|
||||
export PATH="$AEROS_TOOLS/bin:/usr/bin:/bin"
|
||||
export CONFIG_SITE="$LFS/usr/share/config.site"
|
||||
WORK="$AEROS_SOURCES/work-toolchain"
|
||||
mkdir -p "$WORK"; cd "$WORK"
|
||||
|
||||
# ---------------------------------------------------------------- binutils p1
|
||||
build_binutils_pass1() {
|
||||
local d; d="$(cd "$WORK" && unpack binutils)"; cd "$WORK/$d"
|
||||
mkdir -v build; cd build
|
||||
../configure --prefix="$AEROS_TOOLS" \
|
||||
--with-sysroot="$LFS" --target="$AEROS_TGT" \
|
||||
--disable-nls --enable-gprofng=no --disable-werror \
|
||||
--enable-new-dtags --enable-default-hash-style=gnu
|
||||
make
|
||||
make install
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- gcc pass1
|
||||
build_gcc_pass1() {
|
||||
local d; d="$(cd "$WORK" && unpack gcc)"; cd "$WORK/$d"
|
||||
( cd "$WORK/$d"; tar -xf "$AEROS_SOURCES/$(pkg_tarball mpfr)"; mv -v "$(pkg_srcdir mpfr)" mpfr
|
||||
tar -xf "$AEROS_SOURCES/$(pkg_tarball gmp)"; mv -v "$(pkg_srcdir gmp)" gmp
|
||||
tar -xf "$AEROS_SOURCES/$(pkg_tarball mpc)"; mv -v "$(pkg_srcdir mpc)" mpc )
|
||||
case "$AEROS_ARCH" in
|
||||
x86_64) sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64 ;;
|
||||
esac
|
||||
mkdir -v build; cd build
|
||||
../configure --target="$AEROS_TGT" --prefix="$AEROS_TOOLS" \
|
||||
--with-glibc-version=2.41 --with-sysroot="$LFS" --with-newlib \
|
||||
--without-headers --enable-default-pie --enable-default-ssp \
|
||||
--disable-nls --disable-shared --disable-multilib \
|
||||
--disable-threads --disable-libatomic --disable-libgomp \
|
||||
--disable-libquadmath --disable-libssp --disable-libvtv \
|
||||
--disable-libstdcxx --enable-languages=c,c++
|
||||
make
|
||||
make install
|
||||
# full internal headers (limits.h)
|
||||
local gccsrc="$WORK/$d"
|
||||
cat "$gccsrc"/gcc/limitx.h "$gccsrc"/gcc/glimits.h "$gccsrc"/gcc/limity.h > \
|
||||
"$(dirname "$("$AEROS_TGT"-gcc -print-libgcc-file-name)")/include/limits.h"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- linux headers
|
||||
build_linux_headers() {
|
||||
local d; d="$(cd "$WORK" && unpack linux)"; cd "$WORK/$d"
|
||||
make mrproper
|
||||
make headers
|
||||
find usr/include -type f ! -name '*.h' -delete
|
||||
mkdir -p "$LFS/usr"
|
||||
cp -rv usr/include "$LFS/usr"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- glibc
|
||||
build_glibc() {
|
||||
local d; d="$(cd "$WORK" && unpack glibc)"; cd "$WORK/$d"
|
||||
case "$AEROS_ARCH" in
|
||||
x86_64) ln -sfv ../lib/ld-linux-x86-64.so.2 "$LFS/lib64"
|
||||
ln -sfv ../lib/ld-linux-x86-64.so.2 "$LFS/lib64/ld-lsb-x86-64.so.3" ;;
|
||||
esac
|
||||
# glibc <= 2.41 unconditionally redefines OPEN_TREE_CLONE (and a couple of
|
||||
# siblings) *after* including <linux/mount.h>. Linux >= 7.x defines
|
||||
# OPEN_TREE_CLONE with different macro text, so -Werror aborts. Keep the
|
||||
# include (so linux/mount.h's guard coordinates struct mount_attr) and just
|
||||
# guard the conflicting macros with #ifndef.
|
||||
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
|
||||
mkdir -v build; cd build
|
||||
echo "rootsbindir=/usr/sbin" > configparms
|
||||
../configure --prefix=/usr --host="$AEROS_TGT" --build="$(../scripts/config.guess)" \
|
||||
--enable-kernel=5.4 --with-headers="$LFS/usr/include" \
|
||||
--disable-nscd libc_cv_slibdir=/usr/lib
|
||||
make
|
||||
make DESTDIR="$LFS" install
|
||||
sed '/RTLDLIST=/s@/usr@@g' -i "$LFS/usr/bin/ldd"
|
||||
# sanity check
|
||||
echo 'int main(){}' > /tmp/aeros-dummy.c
|
||||
"$AEROS_TGT"-gcc /tmp/aeros-dummy.c -o /tmp/aeros-dummy
|
||||
readelf -l /tmp/aeros-dummy | grep -q 'ld-linux' \
|
||||
&& ok "glibc toolchain links correctly" || die "toolchain sanity check FAILED"
|
||||
rm -f /tmp/aeros-dummy*
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- libstdc++
|
||||
build_libstdcxx() {
|
||||
local d; d="$(cd "$WORK" && unpack gcc)"; cd "$WORK/$d"
|
||||
mkdir -v build-libstdcxx; cd build-libstdcxx
|
||||
../libstdc++-v3/configure --host="$AEROS_TGT" --build="$(../config.guess)" \
|
||||
--prefix=/usr --disable-multilib --disable-nls \
|
||||
--disable-libstdcxx-pch \
|
||||
--with-gxx-include-dir="/tools/$AEROS_TGT/include/c++/15.1.0"
|
||||
make
|
||||
make DESTDIR="$LFS" install
|
||||
rm -v "$LFS"/usr/lib/lib{stdc++{,exp,fs},supc++}.la 2>/dev/null || true
|
||||
}
|
||||
|
||||
step "AeroOS cross-toolchain → $AEROS_TOOLS"
|
||||
once tc-binutils-pass1 build_binutils_pass1
|
||||
once tc-gcc-pass1 build_gcc_pass1
|
||||
once tc-linux-headers build_linux_headers
|
||||
once tc-glibc build_glibc
|
||||
once tc-libstdcxx build_libstdcxx
|
||||
ok "cross-toolchain complete"
|
||||
Executable
+108
@@ -0,0 +1,108 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/02-temp-tools.sh — temporary tools in $AEROS_ROOT (LFS ch. 6).
|
||||
# Cross-compiled against the stage-01 toolchain; gives us enough to chroot.
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/lib/common.sh"
|
||||
deny_root
|
||||
|
||||
export LFS="$AEROS_ROOT"
|
||||
export LC_ALL=POSIX
|
||||
export AEROS_TGT="$AEROS_TARGET_TRIPLET"
|
||||
export PATH="$AEROS_TOOLS/bin:/usr/bin:/bin"
|
||||
export CONFIG_SITE="$LFS/usr/share/config.site"
|
||||
WORK="$AEROS_SOURCES/work-temp"
|
||||
mkdir -p "$WORK"
|
||||
|
||||
# generic cross autotools temp-tool: _xtool <pkg> <configure-args...>
|
||||
_xtool() {
|
||||
local pkg="$1"; shift
|
||||
local d; d="$(cd "$WORK" && unpack "$pkg")"; cd "$WORK/$d"
|
||||
[[ -x ./configure ]] || die "$pkg: no configure script"
|
||||
./configure --prefix=/usr --host="$AEROS_TGT" --build="$(build-aux/config.guess 2>/dev/null || ./config.guess 2>/dev/null || echo x86_64-pc-linux-gnu)" "$@"
|
||||
make
|
||||
make DESTDIR="$LFS" install
|
||||
}
|
||||
|
||||
t_m4() { _xtool m4; }
|
||||
t_ncurses() { local d; d="$(cd "$WORK" && unpack ncurses)"; cd "$WORK/$d"
|
||||
mkdir build; pushd build; ../configure AWK=gawk >/dev/null; make -C include; make -C progs tic; popd
|
||||
./configure --prefix=/usr --host="$AEROS_TGT" --build="$(./config.guess)" \
|
||||
--mandir=/usr/share/man --with-manpage-format=normal \
|
||||
--with-shared --without-normal --without-cxx-binding \
|
||||
--without-debug --without-ada --disable-stripping AWK=gawk
|
||||
make
|
||||
make DESTDIR="$LFS" TIC_PATH="$(pwd)/build/progs/tic" install
|
||||
ln -sv libncursesw.so "$LFS/usr/lib/libncurses.so"
|
||||
sed -e 's/^#if.*XOPEN.*$/#if 1/' -i "$LFS/usr/include/curses.h"; }
|
||||
t_bash() { _xtool bash --without-bash-malloc bash_cv_strtold_broken=no
|
||||
ln -sv bash "$LFS/bin/sh"; }
|
||||
t_coreutils() { _xtool coreutils --enable-install-program=hostname \
|
||||
--enable-no-install-program=kill,uptime gl_cv_macro_MB_CUR_MAX_good=y
|
||||
mkdir -pv "$LFS/usr/sbin"; }
|
||||
t_diffutils() { _xtool diffutils gl_cv_func_strcasecmp_works=y; }
|
||||
t_file() { local d; d="$(cd "$WORK" && unpack file)"; cd "$WORK/$d"
|
||||
mkdir build; pushd build
|
||||
../configure --disable-bzlib --disable-libseccomp \
|
||||
--disable-xzlib --disable-zlib; make; popd
|
||||
./configure --prefix=/usr --host="$AEROS_TGT" --build="$(./config.guess)"
|
||||
make FILE_COMPILE="$(pwd)/build/src/file"
|
||||
make DESTDIR="$LFS" install; rm -v "$LFS/usr/lib/libmagic.la"; }
|
||||
t_findutils() { _xtool findutils --localstatedir=/var/lib/locate; }
|
||||
t_gawk() { local d; d="$(cd "$WORK" && unpack gawk)"; cd "$WORK/$d"
|
||||
sed -i 's/extras//' Makefile.in; _xtool_done=1
|
||||
./configure --prefix=/usr --host="$AEROS_TGT" --build="$(./config.guess)"
|
||||
make; make DESTDIR="$LFS" install; }
|
||||
t_grep() { _xtool grep; }
|
||||
t_gzip() { _xtool gzip; }
|
||||
t_make() { _xtool make; }
|
||||
t_patch() { _xtool patch; }
|
||||
t_sed() { _xtool sed; }
|
||||
t_tar() { _xtool tar; }
|
||||
t_xz() { _xtool xz; rm -v "$LFS"/usr/lib/liblzma.la; }
|
||||
|
||||
t_binutils2() { local d; d="$(cd "$WORK" && unpack binutils)"; cd "$WORK/$d"
|
||||
sed '6031s/$add_dir//' -i ltmain.sh
|
||||
mkdir build; cd build
|
||||
../configure --prefix=/usr --build="$(../config.guess)" \
|
||||
--host="$AEROS_TGT" --disable-nls --enable-shared \
|
||||
--enable-gprofng=no --disable-werror \
|
||||
--enable-64-bit-bfd --enable-new-dtags \
|
||||
--enable-default-hash-style=gnu
|
||||
make; make DESTDIR="$LFS" install
|
||||
rm -v "$LFS"/usr/lib/lib{bfd,ctf,ctf-nobfd,opcodes,sframe}.{a,la} 2>/dev/null || true; }
|
||||
|
||||
t_gcc2() { local d; d="$(cd "$WORK" && unpack gcc)"; cd "$WORK/$d"
|
||||
tar -xf "$AEROS_SOURCES/$(pkg_tarball mpfr)"; mv "$(pkg_srcdir mpfr)" mpfr
|
||||
tar -xf "$AEROS_SOURCES/$(pkg_tarball gmp)"; mv "$(pkg_srcdir gmp)" gmp
|
||||
tar -xf "$AEROS_SOURCES/$(pkg_tarball mpc)"; mv "$(pkg_srcdir mpc)" mpc
|
||||
case "$AEROS_ARCH" in x86_64) sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64;; esac
|
||||
sed '/thread_header =/s/@.*@/gthr-posix.h/' -i libgcc/Makefile.in libstdc++-v3/include/Makefile.in
|
||||
mkdir build; cd build
|
||||
../configure --build="$(../config.guess)" --host="$AEROS_TGT" \
|
||||
--target="$AEROS_TGT" LDFLAGS_FOR_TARGET=-L$PWD/$AEROS_TGT/libgcc \
|
||||
--prefix=/usr --with-build-sysroot="$LFS" --enable-default-pie \
|
||||
--enable-default-ssp --disable-nls --disable-multilib \
|
||||
--disable-libatomic --disable-libgomp --disable-libquadmath \
|
||||
--disable-libsanitizer --disable-libssp --disable-libvtv \
|
||||
--enable-languages=c,c++
|
||||
make; make DESTDIR="$LFS" install
|
||||
ln -sfv gcc "$LFS/usr/bin/cc"; }
|
||||
|
||||
step "Temporary tools (cross-compiled into $AEROS_ROOT)"
|
||||
once tt-m4 t_m4
|
||||
once tt-ncurses t_ncurses
|
||||
once tt-bash t_bash
|
||||
once tt-coreutils t_coreutils
|
||||
once tt-diffutils t_diffutils
|
||||
once tt-file t_file
|
||||
once tt-findutils t_findutils
|
||||
once tt-gawk t_gawk
|
||||
once tt-grep t_grep
|
||||
once tt-gzip t_gzip
|
||||
once tt-make t_make
|
||||
once tt-patch t_patch
|
||||
once tt-sed t_sed
|
||||
once tt-tar t_tar
|
||||
once tt-xz t_xz
|
||||
once tt-binutils2 t_binutils2
|
||||
once tt-gcc2 t_gcc2
|
||||
ok "temporary tools complete — system is now chroot-ready"
|
||||
Executable
+120
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/03-chroot-base.sh — own the tree, enter chroot, build base system.
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/lib/common.sh"
|
||||
require_root
|
||||
|
||||
LFS="$AEROS_ROOT"
|
||||
|
||||
# Guard: stage 03 chowns the tree to root, which makes the unprivileged
|
||||
# stages 01/02 unable to write to it. Refuse to proceed (and chown) unless
|
||||
# stage 02 actually finished, otherwise a premature run wedges the build.
|
||||
if ! stamped tt-gcc2; then
|
||||
die "stage 02 (temporary tools) is not complete — refusing to chroot.
|
||||
Run it first: ./build.sh stage 02
|
||||
(If a previous root run already chowned the tree, restore it first:
|
||||
sudo chown -R \"\${SUDO_USER:-\$USER}\":\"\${SUDO_USER:-\$USER}\" \"$LFS\")"
|
||||
fi
|
||||
|
||||
prepare_chroot() {
|
||||
step "Take ownership + essential files/dirs"
|
||||
chown -R root:root "$LFS"/{usr,lib,var,etc,bin,sbin,tools}
|
||||
case "$AEROS_ARCH" in x86_64) chown -R root:root "$LFS/lib64" 2>/dev/null || true;; esac
|
||||
|
||||
mkdir -pv "$LFS"/{boot,home,mnt,opt,srv}
|
||||
mkdir -pv "$LFS"/etc/{opt,sysconfig}
|
||||
mkdir -pv "$LFS"/lib/firmware
|
||||
mkdir -pv "$LFS"/media/{floppy,cdrom}
|
||||
mkdir -pv "$LFS"/usr/{,local/}{include,src}
|
||||
mkdir -pv "$LFS"/usr/lib/locale
|
||||
mkdir -pv "$LFS"/usr/local/{bin,lib,sbin}
|
||||
mkdir -pv "$LFS"/usr/{,local/}share/{color,dict,doc,info,locale,man}
|
||||
mkdir -pv "$LFS"/usr/{,local/}share/{misc,terminfo,zoneinfo}
|
||||
mkdir -pv "$LFS"/usr/{,local/}share/man/man{1..8}
|
||||
mkdir -pv "$LFS"/var/{cache,local,log,mail,opt,spool}
|
||||
mkdir -pv "$LFS"/var/lib/{color,misc,locate}
|
||||
ln -sfv /run "$LFS/var/run"
|
||||
ln -sfv /run/lock "$LFS/var/lock"
|
||||
install -dv -m 0750 "$LFS/root"
|
||||
install -dv -m 1777 "$LFS/tmp" "$LFS/var/tmp"
|
||||
|
||||
# minimal /etc/passwd & group so chroot processes resolve ids
|
||||
cat > "$LFS/etc/passwd" <<'EOF'
|
||||
root:x:0:0:root:/root:/bin/bash
|
||||
bin:x:1:1:bin:/dev/null:/usr/bin/false
|
||||
daemon:x:6:6:Daemon User:/dev/null:/usr/bin/false
|
||||
messagebus:x:18:18:D-Bus Message Daemon User:/run/dbus:/usr/bin/false
|
||||
systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/usr/bin/false
|
||||
systemd-journal-remote:x:74:74:systemd Journal Remote:/:/usr/bin/false
|
||||
systemd-journal-upload:x:75:75:systemd Journal Upload:/:/usr/bin/false
|
||||
systemd-network:x:76:76:systemd Network Management:/:/usr/bin/false
|
||||
systemd-resolve:x:77:77:systemd Resolver:/:/usr/bin/false
|
||||
systemd-timesync:x:78:78:systemd Time Synchronization:/:/usr/bin/false
|
||||
systemd-coredump:x:79:79:systemd Core Dumper:/:/usr/bin/false
|
||||
uuidd:x:80:80:UUID Generation Daemon User:/dev/null:/usr/bin/false
|
||||
systemd-oom:x:81:81:systemd Out Of Memory Daemon:/:/usr/bin/false
|
||||
nobody:x:65534:65534:Unprivileged User:/dev/null:/usr/bin/false
|
||||
EOF
|
||||
cat > "$LFS/etc/group" <<'EOF'
|
||||
root:x:0:
|
||||
bin:x:1:daemon
|
||||
sys:x:2:
|
||||
kmem:x:3:
|
||||
tape:x:4:
|
||||
tty:x:5:
|
||||
daemon:x:6:
|
||||
floppy:x:7:
|
||||
disk:x:8:
|
||||
lp:x:9:
|
||||
dialout:x:10:
|
||||
audio:x:11:
|
||||
video:x:12:
|
||||
utmp:x:13:
|
||||
cdrom:x:15:
|
||||
adm:x:16:
|
||||
messagebus:x:18:
|
||||
systemd-journal:x:23:
|
||||
input:x:24:
|
||||
mail:x:34:
|
||||
kvm:x:61:
|
||||
render:x:62:
|
||||
seat:x:63:
|
||||
systemd-journal-gateway:x:73:
|
||||
systemd-journal-remote:x:74:
|
||||
systemd-journal-upload:x:75:
|
||||
systemd-network:x:76:
|
||||
systemd-resolve:x:77:
|
||||
systemd-timesync:x:78:
|
||||
systemd-coredump:x:79:
|
||||
uuidd:x:80:
|
||||
systemd-oom:x:81:
|
||||
wheel:x:97:
|
||||
users:x:999:
|
||||
nogroup:x:65534:
|
||||
EOF
|
||||
echo "aeros" > "$LFS/etc/hostname"
|
||||
touch "$LFS"/var/log/{btmp,lastlog,faillog,wtmp}
|
||||
chgrp -v utmp "$LFS/var/log/lastlog" 2>/dev/null || true
|
||||
chmod -v 664 "$LFS/var/log/lastlog"; chmod -v 600 "$LFS/var/log/btmp"
|
||||
ok "chroot scaffolding ready"
|
||||
}
|
||||
|
||||
run_inner() {
|
||||
step "Mounting virtual kernel filesystems"
|
||||
mount_vkfs
|
||||
mkdir -p "$LFS/sources"
|
||||
mountpoint -q "$LFS/sources" || mount --bind "$AEROS_SOURCES" "$LFS/sources"
|
||||
install -m755 "$AEROS_TOP/packages/chroot-base.sh" "$LFS/root/build-base.sh"
|
||||
|
||||
step "Entering chroot to build base system (this is the long part)"
|
||||
in_chroot "MAKEFLAGS='-j${AEROS_JOBS}' /root/build-base.sh"
|
||||
|
||||
step "Unmounting"
|
||||
mountpoint -q "$LFS/sources" && umount -l "$LFS/sources" || true
|
||||
umount_vkfs
|
||||
}
|
||||
|
||||
trap 'mountpoint -q "$LFS/sources" && umount -l "$LFS/sources"; umount_vkfs 2>/dev/null || true' EXIT
|
||||
|
||||
prepare_chroot
|
||||
run_inner
|
||||
ok "base system complete"
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/04-kernel.sh — configure + build Linux 7.1 and install into chroot.
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/lib/common.sh"
|
||||
require_root
|
||||
|
||||
LFS="$AEROS_ROOT"
|
||||
KVER="$(pkg_version linux)"
|
||||
|
||||
trap 'mountpoint -q "$LFS/sources" && umount -l "$LFS/sources"; umount_vkfs 2>/dev/null || true' EXIT
|
||||
|
||||
step "Linux kernel $KVER (x86-64)"
|
||||
mount_vkfs
|
||||
mkdir -p "$LFS/sources"
|
||||
mountpoint -q "$LFS/sources" || mount --bind "$AEROS_SOURCES" "$LFS/sources"
|
||||
install -Dm644 "$AEROS_TOP/config/kernel/aeros.config" "$LFS/root/aeros.config"
|
||||
|
||||
[[ -x "$LFS/usr/bin/bc" ]] || die "stage 04 requires bc inside the chroot; run: sudo ./build.sh stage 03"
|
||||
[[ -x "$LFS/usr/bin/rsync" ]] || die "stage 04 requires rsync inside the chroot; run: sudo ./build.sh stage 03"
|
||||
|
||||
# Inner build: defconfig + merge our fragment + build + modules_install + install
|
||||
cat > "$LFS/root/build-kernel.sh" <<INNER
|
||||
#!/bin/bash
|
||||
set -Eeuo pipefail
|
||||
export MAKEFLAGS="-j${AEROS_JOBS}"
|
||||
cd /tmp; rm -rf linux-src; mkdir linux-src
|
||||
tar -xf "/sources/$(pkg_tarball linux)" -C linux-src --strip-components=1
|
||||
cd linux-src
|
||||
make mrproper
|
||||
make x86_64_defconfig
|
||||
# merge AeroOS options on top of defconfig
|
||||
scripts/kconfig/merge_config.sh -m .config /root/aeros.config
|
||||
make olddefconfig
|
||||
# build kernel image + modules
|
||||
make
|
||||
make modules_install
|
||||
# install kernel + map + config to /boot
|
||||
install -Dm644 arch/x86/boot/bzImage /boot/vmlinuz-aeros-${KVER}
|
||||
install -Dm644 System.map /boot/System.map-${KVER}
|
||||
install -Dm644 .config /boot/config-${KVER}
|
||||
# kernel headers for building DKMS/userspace later
|
||||
make headers_install INSTALL_HDR_PATH=/usr
|
||||
echo "kernel ${KVER} installed to /boot"
|
||||
INNER
|
||||
chmod +x "$LFS/root/build-kernel.sh"
|
||||
|
||||
in_chroot "/root/build-kernel.sh"
|
||||
|
||||
mountpoint -q "$LFS/sources" && umount -l "$LFS/sources" || true
|
||||
umount_vkfs
|
||||
ok "kernel $KVER built and installed"
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/05-systemd-boot.sh — build systemd/dbus/shadow/grub + configure system.
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/lib/common.sh"
|
||||
require_root
|
||||
LFS="$AEROS_ROOT"
|
||||
|
||||
trap 'mountpoint -q "$LFS/sources" && umount -l "$LFS/sources"; umount_vkfs 2>/dev/null || true' EXIT
|
||||
|
||||
step "systemd / D-Bus / shadow / GRUB"
|
||||
mount_vkfs
|
||||
mkdir -p "$LFS/sources"
|
||||
mountpoint -q "$LFS/sources" || mount --bind "$AEROS_SOURCES" "$LFS/sources"
|
||||
|
||||
install -m755 "$AEROS_TOP/packages/chroot-buildtools.sh" "$LFS/root/build-tools.sh"
|
||||
install -m755 "$AEROS_TOP/packages/chroot-systemd.sh" "$LFS/root/build-systemd.sh"
|
||||
|
||||
[[ -f "$LFS/usr/include/crypt.h" && -e "$LFS/usr/lib/libcrypt.so" ]] || \
|
||||
die "stage 05 requires libxcrypt inside the chroot; run: sudo ./build.sh stage 03"
|
||||
|
||||
# pass branding/config env into the chroot build
|
||||
ENVS="AEROS_NAME='$AEROS_NAME' AEROS_VERSION='$AEROS_VERSION' \
|
||||
AEROS_CODENAME='$AEROS_CODENAME' AEROS_DISTRO_ID='$AEROS_DISTRO_ID' \
|
||||
AEROS_HOSTNAME='$AEROS_HOSTNAME' AEROS_LOCALE='$AEROS_LOCALE' \
|
||||
AEROS_TIMEZONE='$AEROS_TIMEZONE' AEROS_KEYMAP='$AEROS_KEYMAP' \
|
||||
AEROS_ROOT_PASS='$AEROS_ROOT_PASS' MAKEFLAGS='-j${AEROS_JOBS}'"
|
||||
|
||||
in_chroot "$ENVS /root/build-tools.sh"
|
||||
in_chroot "$ENVS /root/build-systemd.sh"
|
||||
|
||||
mountpoint -q "$LFS/sources" && umount -l "$LFS/sources" || true
|
||||
umount_vkfs
|
||||
ok "init + boot layer complete"
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/06-desktop.sh — copy compositor source into the tree, build the
|
||||
# Wayland/wlroots desktop stack + aerowm inside the chroot.
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/lib/common.sh"
|
||||
require_root
|
||||
LFS="$AEROS_ROOT"
|
||||
|
||||
trap 'mountpoint -q "$LFS/sources" && umount -l "$LFS/sources"; umount_vkfs 2>/dev/null || true' EXIT
|
||||
|
||||
step "Wayland desktop + aerowm compositor"
|
||||
mount_vkfs
|
||||
mkdir -p "$LFS/sources"
|
||||
mountpoint -q "$LFS/sources" || mount --bind "$AEROS_SOURCES" "$LFS/sources"
|
||||
|
||||
# stage compositor source into /usr/src/aerowm inside the new system
|
||||
log "installing aerowm source into /usr/src/aerowm"
|
||||
rm -rf "$LFS/usr/src/aerowm"
|
||||
mkdir -p "$LFS/usr/src/aerowm"
|
||||
cp -a "$AEROS_TOP/desktop/aerowm/." "$LFS/usr/src/aerowm/"
|
||||
|
||||
install -m755 "$AEROS_TOP/packages/chroot-buildtools.sh" "$LFS/root/build-tools.sh"
|
||||
install -m755 "$AEROS_TOP/packages/chroot-desktop.sh" "$LFS/root/build-desktop.sh"
|
||||
|
||||
ENVS="MAKEFLAGS='-j${AEROS_JOBS}'"
|
||||
in_chroot "$ENVS /root/build-tools.sh" # ensure ninja/meson exist
|
||||
in_chroot "$ENVS /root/build-desktop.sh"
|
||||
|
||||
mountpoint -q "$LFS/sources" && umount -l "$LFS/sources" || true
|
||||
umount_vkfs
|
||||
ok "desktop stack + compositor built"
|
||||
Executable
+125
@@ -0,0 +1,125 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/07-aero-theme.sh — Frutiger Aero wallpaper, subtle lofi service,
|
||||
# glassmorphism theme, session launcher, autologin to the home screen.
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/lib/common.sh"
|
||||
require_root
|
||||
LFS="$AEROS_ROOT"
|
||||
|
||||
trap 'umount_vkfs 2>/dev/null || true' EXIT
|
||||
|
||||
# ---------------------------------------------------------------- wallpaper
|
||||
make_wallpaper() {
|
||||
step "Wallpaper (Frutiger Aero)"
|
||||
local dst="$LFS/usr/share/backgrounds/aeros"
|
||||
install -d "$dst"
|
||||
local svg="$AEROS_TOP/assets/wallpaper/frutiger-aero.svg"
|
||||
local png="$dst/frutiger-aero.png"
|
||||
if command -v rsvg-convert >/dev/null 2>&1; then
|
||||
rsvg-convert -w 1920 -h 1080 "$svg" -o "$png" && ok "rasterized SVG via rsvg-convert"
|
||||
elif command -v inkscape >/dev/null 2>&1; then
|
||||
inkscape "$svg" --export-type=png -w 1920 -h 1080 -o "$png" && ok "via inkscape"
|
||||
elif command -v convert >/dev/null 2>&1; then
|
||||
convert -background none -resize 1920x1080 "$svg" "$png" && ok "via ImageMagick"
|
||||
else
|
||||
warn "no SVG rasterizer found — using stdlib procedural generator"
|
||||
python3 "$AEROS_TOP/assets/wallpaper/gen_wallpaper.py" "$png" 1920 1080
|
||||
fi
|
||||
# also keep the SVG source on the system
|
||||
install -m644 "$svg" "$dst/frutiger-aero.svg"
|
||||
ok "wallpaper installed -> /usr/share/backgrounds/aeros/frutiger-aero.png"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- lofi
|
||||
make_lofi() {
|
||||
step "Subtle lofi loop"
|
||||
local dst="$LFS/usr/share/aeros/lofi"
|
||||
install -d "$dst"
|
||||
if [[ ! -s "$dst/aero-lofi.wav" ]]; then
|
||||
python3 "$AEROS_TOP/assets/lofi/generate_lofi.py" "$dst/aero-lofi.wav"
|
||||
fi
|
||||
install -m644 "$AEROS_TOP/assets/lofi/generate_lofi.py" "$dst/generate_lofi.py"
|
||||
ok "lofi track -> /usr/share/aeros/lofi/aero-lofi.wav"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- theme
|
||||
make_theme() {
|
||||
step "Glassmorphism theme (AeroGlass)"
|
||||
install -d "$LFS/usr/share/themes/AeroGlass/gtk-4.0"
|
||||
install -m644 "$AEROS_TOP/assets/theme/AeroGlass/gtk-4.0/gtk.css" \
|
||||
"$LFS/usr/share/themes/AeroGlass/gtk-4.0/gtk.css"
|
||||
install -d "$LFS/etc/gtk-4.0" "$LFS/etc/gtk-3.0"
|
||||
install -m644 "$AEROS_TOP/assets/theme/settings.ini" "$LFS/etc/gtk-4.0/settings.ini"
|
||||
install -m644 "$AEROS_TOP/assets/theme/settings.ini" "$LFS/etc/gtk-3.0/settings.ini"
|
||||
# system-wide env so toolkits pick the theme + wayland
|
||||
cat >> "$LFS/etc/environment" <<'EOF'
|
||||
GTK_THEME=AeroGlass
|
||||
QT_QPA_PLATFORM=wayland
|
||||
MOZ_ENABLE_WAYLAND=1
|
||||
XDG_CURRENT_DESKTOP=AeroOS
|
||||
EOF
|
||||
ok "AeroGlass theme installed"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- session + services
|
||||
make_session() {
|
||||
step "Session launcher + services"
|
||||
install -m755 "$AEROS_TOP/desktop/aero-session/aero-session" "$LFS/usr/bin/aero-session"
|
||||
install -m755 "$AEROS_TOP/desktop/aero-lofi/aero-lofi" "$LFS/usr/bin/aero-lofi"
|
||||
install -d "$LFS/usr/lib/systemd/user"
|
||||
install -m644 "$AEROS_TOP/desktop/aero-lofi/aero-lofi.service" \
|
||||
"$LFS/usr/lib/systemd/user/aero-lofi.service"
|
||||
ok "session + lofi service installed"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- users/autologin (chroot)
|
||||
configure_users() {
|
||||
step "Live user + autologin to the AeroOS home screen"
|
||||
mount_vkfs
|
||||
cat > "$LFS/root/setup-users.sh" <<INNER
|
||||
#!/bin/bash
|
||||
set -e
|
||||
# groups a desktop user needs
|
||||
for g in video input render seat audio wheel users; do getent group \$g >/dev/null || groupadd -r \$g 2>/dev/null || true; done
|
||||
id ${AEROS_LIVE_USER} >/dev/null 2>&1 || useradd -m -G wheel,video,input,render,seat,audio,users -s /bin/bash ${AEROS_LIVE_USER}
|
||||
echo "${AEROS_LIVE_USER}:${AEROS_LIVE_PASS}" | chpasswd
|
||||
echo "root:${AEROS_ROOT_PASS}" | chpasswd
|
||||
|
||||
# autologin the live user on tty1
|
||||
mkdir -p /etc/systemd/system/getty@tty1.service.d
|
||||
cat > /etc/systemd/system/getty@tty1.service.d/autologin.conf <<EOF
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=-/sbin/agetty --autologin ${AEROS_LIVE_USER} --noclear %I \$TERM
|
||||
EOF
|
||||
|
||||
# start the Aero session automatically on tty1 login
|
||||
cat > /home/${AEROS_LIVE_USER}/.bash_profile <<'EOF'
|
||||
# Launch the AeroOS glassmorphism desktop on the first VT, once.
|
||||
if [ -z "\$WAYLAND_DISPLAY" ] && [ "\$(tty)" = "/dev/tty1" ]; then
|
||||
exec aero-session
|
||||
fi
|
||||
EOF
|
||||
chown ${AEROS_LIVE_USER}:${AEROS_LIVE_USER} /home/${AEROS_LIVE_USER}/.bash_profile
|
||||
|
||||
# enable lofi for the live user by default
|
||||
loginctl enable-linger ${AEROS_LIVE_USER} 2>/dev/null || true
|
||||
mkdir -p /home/${AEROS_LIVE_USER}/.config/systemd/user/default.target.wants
|
||||
ln -sf /usr/lib/systemd/user/aero-lofi.service \
|
||||
/home/${AEROS_LIVE_USER}/.config/systemd/user/default.target.wants/aero-lofi.service
|
||||
chown -R ${AEROS_LIVE_USER}:${AEROS_LIVE_USER} /home/${AEROS_LIVE_USER}/.config
|
||||
|
||||
# seatd for the compositor's DRM/input session
|
||||
systemctl enable seatd 2>/dev/null || true
|
||||
echo "users + autologin configured"
|
||||
INNER
|
||||
chmod +x "$LFS/root/setup-users.sh"
|
||||
in_chroot "AEROS_LIVE_USER='$AEROS_LIVE_USER' AEROS_LIVE_PASS='$AEROS_LIVE_PASS' AEROS_ROOT_PASS='$AEROS_ROOT_PASS' /root/setup-users.sh"
|
||||
umount_vkfs
|
||||
}
|
||||
|
||||
make_wallpaper
|
||||
make_lofi
|
||||
make_theme
|
||||
make_session
|
||||
configure_users
|
||||
ok "Aero identity applied"
|
||||
Executable
+118
@@ -0,0 +1,118 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/08-image.sh — assemble the bootable hybrid (BIOS+UEFI) live ISO.
|
||||
#
|
||||
# Layout produced:
|
||||
# ISO/
|
||||
# boot/vmlinuz-aeros (kernel)
|
||||
# boot/initrd-aeros.img (busybox initramfs: squashfs+overlay+switch_root)
|
||||
# boot/grub/grub.cfg
|
||||
# boot/grub/aero-splash.png (wallpaper, as boot splash)
|
||||
# LiveOS/aeros.squashfs (the whole AeroOS root, compressed)
|
||||
# -> xorriso/grub-mkrescue -> out/aeros-<ver>-x86_64.iso (isohybrid)
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/lib/common.sh"
|
||||
require_root
|
||||
LFS="$AEROS_ROOT"
|
||||
WORK="$AEROS_OUT/imgwork"
|
||||
ISODIR="$WORK/iso"
|
||||
|
||||
trap 'mountpoint -q "$LFS/sources" && umount -l "$LFS/sources"; umount_vkfs 2>/dev/null || true' EXIT
|
||||
|
||||
build_image_tools() {
|
||||
step "Image tooling (busybox/squashfs/xorriso/grub-efi)"
|
||||
mount_vkfs
|
||||
mkdir -p "$LFS/sources"
|
||||
mountpoint -q "$LFS/sources" || mount --bind "$AEROS_SOURCES" "$LFS/sources"
|
||||
install -m755 "$AEROS_TOP/packages/chroot-imagetools.sh" "$LFS/root/build-imgtools.sh"
|
||||
in_chroot "MAKEFLAGS='-j${AEROS_JOBS}' /root/build-imgtools.sh"
|
||||
mountpoint -q "$LFS/sources" && umount -l "$LFS/sources" || true
|
||||
umount_vkfs
|
||||
}
|
||||
|
||||
make_initramfs() {
|
||||
step "Initramfs"
|
||||
local IR="$WORK/initramfs"
|
||||
rm -rf "$IR"; mkdir -p "$IR"/{bin,sbin,proc,sys,dev,run,sysroot,etc}
|
||||
mknod -m 600 "$IR/dev/console" c 5 1
|
||||
mknod -m 666 "$IR/dev/null" c 1 3
|
||||
mknod -m 666 "$IR/dev/tty" c 5 0
|
||||
# busybox provides sh, mount, switch_root, blkid, etc. (static => no libs)
|
||||
install -Dm755 "$LFS/usr/bin/busybox-static" "$IR/bin/busybox"
|
||||
# init script with the ISO label substituted in
|
||||
sed "s/@@ISO_LABEL@@/$AEROS_ISO_LABEL/g" "$AEROS_TOP/assets/live/init" \
|
||||
> "$IR/init"
|
||||
chmod +x "$IR/init"
|
||||
ln -sf bin/busybox "$IR/sbin/busybox" 2>/dev/null || true
|
||||
( cd "$IR" && find . | cpio -o -H newc 2>/dev/null | gzip -9 ) \
|
||||
> "$ISODIR/boot/initrd-aeros.img"
|
||||
ok "initramfs -> boot/initrd-aeros.img ($(du -h "$ISODIR/boot/initrd-aeros.img" | cut -f1))"
|
||||
}
|
||||
|
||||
make_squashfs() {
|
||||
step "SquashFS root (compressing the AeroOS system)"
|
||||
install -d "$ISODIR/LiveOS"
|
||||
# exclude build-only/transient content from the shipped root
|
||||
local EXCL=(
|
||||
--exclude-regex '^sources(/|$)'
|
||||
--exclude-regex '^tools(/|$)'
|
||||
--exclude-regex '^root/build-.*\.sh$'
|
||||
--exclude-regex '^root/setup-users\.sh$'
|
||||
--exclude-regex '^root/aeros\.config$'
|
||||
--exclude-regex '^\.stamps(/|$)'
|
||||
--exclude-regex '^tmp/.+'
|
||||
--exclude-regex '^usr/src/aerowm/build(/|$)'
|
||||
)
|
||||
"$LFS/usr/bin/mksquashfs" "$LFS" "$ISODIR/LiveOS/aeros.squashfs" \
|
||||
-comp zstd -Xcompression-level 19 -noappend -no-progress \
|
||||
-e sources tools 2>/dev/null \
|
||||
|| mksquashfs "$LFS" "$ISODIR/LiveOS/aeros.squashfs" -comp zstd -noappend \
|
||||
-e sources tools
|
||||
ok "squashfs -> LiveOS/aeros.squashfs ($(du -h "$ISODIR/LiveOS/aeros.squashfs" | cut -f1))"
|
||||
}
|
||||
|
||||
assemble_iso() {
|
||||
step "GRUB config + kernel + splash"
|
||||
install -d "$ISODIR/boot/grub"
|
||||
# kernel
|
||||
cp -v "$LFS"/boot/vmlinuz-aeros-* "$ISODIR/boot/vmlinuz-aeros"
|
||||
# grub.cfg
|
||||
sed -e "s/@@ISO_LABEL@@/$AEROS_ISO_LABEL/g" \
|
||||
-e "s/@@VERSION@@/$AEROS_VERSION/g" \
|
||||
"$AEROS_TOP/assets/live/grub.cfg" > "$ISODIR/boot/grub/grub.cfg"
|
||||
# boot splash = wallpaper
|
||||
cp -v "$LFS/usr/share/backgrounds/aeros/frutiger-aero.png" \
|
||||
"$ISODIR/boot/grub/aero-splash.png" 2>/dev/null || true
|
||||
|
||||
step "Building hybrid ISO with grub-mkrescue"
|
||||
mkdir -p "$AEROS_OUT"
|
||||
local OUT="$AEROS_OUT/$AEROS_ISO_NAME"
|
||||
rm -f "$OUT"
|
||||
# Run grub-mkrescue from inside the chroot so it uses the AeroOS grub +
|
||||
# xorriso + mtools we built; bind-mount the iso tree in.
|
||||
mount_vkfs
|
||||
in_chroot "mkdir -p /usr/share/grub && if [ ! -s /usr/share/grub/unicode.pf2 ]; then grub-mkfont -o /usr/share/grub/unicode.pf2 /usr/share/fonts/dejavu/DejaVuSans.ttf; fi"
|
||||
mkdir -p "$LFS/mnt/isobuild" "$LFS/mnt/isoout"
|
||||
mount --bind "$ISODIR" "$LFS/mnt/isobuild"
|
||||
mount --bind "$AEROS_OUT" "$LFS/mnt/isoout"
|
||||
if ! in_chroot "set -o pipefail; grub-mkrescue -o /mnt/isoout/$AEROS_ISO_NAME /mnt/isobuild \
|
||||
--volid $AEROS_ISO_LABEL 2>&1 | tail -20"; then
|
||||
rm -f "$OUT"
|
||||
warn "chroot grub-mkrescue failed; trying host grub-mkrescue"
|
||||
fi
|
||||
umount "$LFS/mnt/isobuild" 2>/dev/null || true
|
||||
umount "$LFS/mnt/isoout" 2>/dev/null || true
|
||||
umount_vkfs
|
||||
|
||||
if [[ ! -s "$OUT" ]] && command -v grub-mkrescue >/dev/null 2>&1; then
|
||||
grub-mkrescue -o "$OUT" "$ISODIR" --volid "$AEROS_ISO_LABEL"
|
||||
fi
|
||||
[[ -s "$OUT" ]] || die "ISO build failed"
|
||||
ok "ISO ready: $OUT ($(du -h "$OUT" | cut -f1))"
|
||||
echo "$OUT" > "$AEROS_OUT/.last-iso"
|
||||
}
|
||||
|
||||
mkdir -p "$ISODIR/boot/grub"
|
||||
build_image_tools
|
||||
make_squashfs
|
||||
make_initramfs
|
||||
assemble_iso
|
||||
ok "live image complete"
|
||||
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/lib/common.sh — shared helpers sourced by every stage.
|
||||
set -Eeuo pipefail
|
||||
|
||||
# Resolve repo top from this file's location, then load config + versions.
|
||||
_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
AEROS_TOP="$(cd "$_LIB_DIR/../.." && pwd)"
|
||||
# shellcheck source=/dev/null
|
||||
source "$AEROS_TOP/config/aeros.conf"
|
||||
# shellcheck source=/dev/null
|
||||
source "$AEROS_TOP/config/versions.sh"
|
||||
|
||||
# ---- pretty logging ---------------------------------------------------------
|
||||
if [[ -t 1 ]]; then
|
||||
C_RESET=$'\e[0m'; C_BLUE=$'\e[1;34m'; C_GREEN=$'\e[1;32m'
|
||||
C_YELLOW=$'\e[1;33m'; C_RED=$'\e[1;31m'; C_CYAN=$'\e[1;36m'
|
||||
else
|
||||
C_RESET=""; C_BLUE=""; C_GREEN=""; C_YELLOW=""; C_RED=""; C_CYAN=""
|
||||
fi
|
||||
|
||||
log() { printf '%s>>%s %s\n' "$C_BLUE" "$C_RESET" "$*" >&2; }
|
||||
ok() { printf '%s ✓%s %s\n' "$C_GREEN" "$C_RESET" "$*" >&2; }
|
||||
warn() { printf '%s !!%s %s\n' "$C_YELLOW" "$C_RESET" "$*" >&2; }
|
||||
die() { printf '%sxx%s %s\n' "$C_RED" "$C_RESET" "$*" >&2; exit 1; }
|
||||
step() { printf '\n%s== %s ==%s\n' "$C_CYAN" "$*" "$C_RESET" >&2; }
|
||||
|
||||
# ---- guards -----------------------------------------------------------------
|
||||
require_cmd() { command -v "$1" >/dev/null 2>&1 || die "missing host command: $1"; }
|
||||
require_root(){ [[ $EUID -eq 0 ]] || die "this stage must run as root (use sudo)"; }
|
||||
deny_root() { [[ $EUID -ne 0 ]] || die "do NOT run this stage as root"; }
|
||||
|
||||
# Stamp files mark a stage/sub-step as complete so re-runs are idempotent.
|
||||
_stamp_dir() { mkdir -p "$AEROS_ROOT/.stamps"; echo "$AEROS_ROOT/.stamps"; }
|
||||
stamped() { [[ -f "$(_stamp_dir)/$1" ]]; }
|
||||
stamp() { touch "$(_stamp_dir)/$1"; }
|
||||
# run a build step once: once <name> <command...>
|
||||
once() {
|
||||
local name="$1"; shift
|
||||
if stamped "$name"; then ok "skip $name (done)"; return 0; fi
|
||||
log "build $name"
|
||||
"$@"
|
||||
stamp "$name"
|
||||
ok "done $name"
|
||||
}
|
||||
|
||||
# ---- sources ----------------------------------------------------------------
|
||||
# unpack <pkg-name> → extracts tarball into current dir, echoes src dir path
|
||||
unpack() {
|
||||
local pkg="$1" tb dir
|
||||
tb="$AEROS_SOURCES/$(pkg_tarball "$pkg")"
|
||||
[[ -f "$tb" ]] || die "source not fetched: $tb (run ./build.sh fetch)"
|
||||
dir="$(pkg_srcdir "$pkg")"
|
||||
rm -rf "$dir"
|
||||
log "extract $(basename "$tb")"
|
||||
case "$tb" in
|
||||
*.tar.xz|*.txz) tar -xf "$tb" ;;
|
||||
*.tar.gz|*.tgz) tar -xzf "$tb" ;;
|
||||
*.tar.bz2) tar -xjf "$tb" ;;
|
||||
*) die "unknown archive type: $tb" ;;
|
||||
esac
|
||||
# Some archives (gitlab) extract to a differently-named dir; normalize.
|
||||
if [[ ! -d "$dir" ]]; then
|
||||
dir="$(tar -tf "$tb" 2>/dev/null | head -1 | cut -d/ -f1)"
|
||||
fi
|
||||
[[ -d "$dir" ]] || die "extracted dir not found for $pkg"
|
||||
printf '%s\n' "$dir"
|
||||
}
|
||||
|
||||
# ---- chroot helpers ---------------------------------------------------------
|
||||
mount_vkfs() {
|
||||
require_root
|
||||
local r="$AEROS_ROOT"
|
||||
# ensure the virtual-fs mount points exist (stages 03-08 all rely on this)
|
||||
mkdir -p "$r"/dev "$r"/dev/pts "$r"/dev/shm "$r"/proc "$r"/sys "$r"/run
|
||||
mountpoint -q "$r/dev" || mount --bind /dev "$r/dev"
|
||||
mountpoint -q "$r/dev/pts" || mount -t devpts devpts -o gid=5,mode=0620 "$r/dev/pts"
|
||||
mountpoint -q "$r/proc" || mount -t proc proc "$r/proc"
|
||||
mountpoint -q "$r/sys" || mount -t sysfs sysfs "$r/sys"
|
||||
mountpoint -q "$r/run" || mount -t tmpfs tmpfs "$r/run"
|
||||
if [[ -h "$r/dev/shm" ]]; then mkdir -p "$r/$(readlink "$r/dev/shm")"
|
||||
else mountpoint -q "$r/dev/shm" || mount -t tmpfs -o nosuid,nodev tmpfs "$r/dev/shm"; fi
|
||||
}
|
||||
umount_vkfs() {
|
||||
require_root
|
||||
local r="$AEROS_ROOT"
|
||||
for m in dev/shm dev/pts run sys proc dev; do
|
||||
mountpoint -q "$r/$m" && umount -l "$r/$m" || true
|
||||
done
|
||||
}
|
||||
# run a command string inside the chroot with a clean env
|
||||
in_chroot() {
|
||||
require_root
|
||||
chroot "$AEROS_ROOT" /usr/bin/env -i \
|
||||
HOME=/root TERM="$TERM" PS1='(aeros chroot) \u:\w\$ ' \
|
||||
PATH=/usr/bin:/usr/sbin \
|
||||
MAKEFLAGS="-j${AEROS_JOBS}" \
|
||||
/bin/bash --login -c "$*"
|
||||
}
|
||||
|
||||
export -f log ok warn die step
|
||||
Reference in new issue
Block a user