This commit is contained in:
Michal S.
2026-08-04 17:59:44 +01:00
commit 69071efd58
123 changed files with 7728 additions and 0 deletions
+154
View File
@@ -0,0 +1,154 @@
#!/bin/sh
set -eu
if [ "$#" -ne 1 ]; then
printf '%s\n' "usage: audit-static-base.sh ROOTFS" >&2
exit 2
fi
rootfs=$1
failed=0
count=0
for directory in bin sbin usr/bin usr/sbin; do
if [ ! -d "$rootfs/$directory" ] || [ -L "$rootfs/$directory" ]; then
printf '%s\n' "FHS command directory must be a real directory: /$directory" >&2
exit 1
fi
done
for executable in \
/bin/chgrp /bin/login /bin/sh /bin/su /bin/tcsh \
/sbin/agetty /sbin/blkid /sbin/bridge /sbin/btrfs /sbin/dhcpcd /sbin/dmesg \
/sbin/depmod /sbin/insmod /sbin/kmod /sbin/lsmod /sbin/mdevd \
/sbin/mdevd-coldplug /sbin/mkfs.btrfs /sbin/modinfo /sbin/modprobe \
/sbin/mount /sbin/fdisk /sbin/ip /sbin/losetup /sbin/nft /sbin/rmmod \
/sbin/sfdisk /sbin/ss /sbin/swapoff /sbin/swapon /sbin/sysctl /sbin/tc \
/sbin/umount /sbin/wipefs \
/usr/bin/setsid /usr/sbin/mouse-bootenv \
/usr/bin/awk /usr/bin/basename /usr/bin/cmp /usr/bin/cut \
/usr/bin/diff /usr/bin/dirname /usr/bin/fetch /usr/bin/groups /usr/bin/ldd \
/usr/bin/install /usr/bin/m4 /usr/bin/nc /usr/bin/patch \
/usr/bin/sort /usr/bin/test /usr/bin/tr /usr/bin/whoami \
/usr/bin/xargs \
/usr/bin/apropos /usr/bin/bzip2 /usr/bin/crontab \
/usr/bin/file /usr/bin/findmnt /usr/bin/flock /usr/bin/free \
/usr/bin/gzip /usr/bin/less /usr/bin/lsblk /usr/bin/man /usr/bin/mandoc \
/usr/bin/nvi /usr/bin/openssl /usr/bin/passwd /usr/bin/pgrep \
/usr/bin/pkill /usr/bin/readlink /usr/bin/sha256 /usr/bin/tar \
/usr/bin/top /usr/bin/tput /usr/bin/unzip \
/usr/bin/uptime /usr/bin/vmstat /usr/bin/watch /usr/bin/xz /usr/bin/zstd \
/bin/ping /bin/ps /usr/bin/vi /usr/sbin/makewhatis \
/usr/sbin/cron /usr/sbin/groupadd /usr/sbin/ntpd /usr/sbin/syslogd \
/usr/sbin/useradd
do
if [ ! -x "$rootfs$executable" ]; then
printf '%s\n' "missing executable at its FHS path: $executable" >&2
exit 1
fi
done
if [ ! -f "$rootfs/etc/ssl/cert.pem" ]; then
printf '%s\n' "missing TLS trust bundle: /etc/ssl/cert.pem" >&2
exit 1
fi
if [ ! -f "$rootfs/usr/share/man/mandoc.db" ]; then
printf '%s\n' "missing World manual-page database" >&2
exit 1
fi
if [ -e "$rootfs/etc/mouse-release" ]; then
for executable in /sbin/cheesed /sbin/poweroff /sbin/reboot /sbin/service /sbin/shutdown; do
if [ ! -x "$rootfs$executable" ]; then
printf '%s\n' "missing executable at its FHS path: $executable" >&2
exit 1
fi
done
fi
if [ -e "$rootfs/usr/share/mouse/pkgsrc.version" ]; then
if [ "$(cat "$rootfs/usr/share/mouse/pkgsrc.version")" != 2026Q2 ]; then
printf '%s\n' "unexpected pkgsrc version" >&2
exit 1
fi
fi
if [ -e "$rootfs/usr/bin/cc" ]; then
for tool in \
/usr/bin/ar /usr/bin/c++ /usr/bin/clang /usr/bin/clang++ \
/usr/bin/gmake /usr/bin/ld.lld /usr/bin/make /usr/bin/objdump \
/usr/bin/pkgconf /usr/bin/readelf
do
if [ ! -x "$rootfs$tool" ]; then
printf '%s\n' "incomplete native toolchain: $tool" >&2
exit 1
fi
done
for development_file in \
/usr/include/stdio.h /usr/include/c++/v1/filesystem \
/usr/include/openssl/ssl.h /usr/include/zlib.h \
/lib/ld-musl-x86_64.so.1 /usr/lib/libc.so \
/usr/lib/crt1.o /usr/lib/Scrt1.o /usr/lib/crtbegin.o \
/usr/lib/crtbeginS.o /usr/lib/crtendS.o \
/usr/lib/libc.a /usr/lib/libc++.a /usr/lib/libc++.so \
/usr/lib/libc++abi.so /usr/lib/libunwind.so \
/usr/lib/libc++abi.a /usr/lib/libcrypto.a /usr/lib/libssl.a \
/usr/lib/libunwind.a /usr/lib/libz.a
do
if [ ! -f "$rootfs$development_file" ]; then
printf '%s\n' "incomplete development sysroot: $development_file" >&2
exit 1
fi
done
fi
if [ -e "$rootfs/usr/share/mk" ] || [ -e "$rootfs/usr/bin/bmake" ]; then
printf '%s\n' "base image must leave BSD make to pkgsrc under /usr/local" >&2
exit 1
fi
if [ -e "$rootfs/usr/bin/make" ]; then
if [ ! -L "$rootfs/usr/bin/gmake" ] || \
[ "$(readlink "$rootfs/usr/bin/gmake")" != make ]; then
printf '%s\n' "/usr/bin/gmake must alias the base GNU make" >&2
exit 1
fi
fi
if [ -e "$rootfs/usr/bin/rc-update" ] ||
[ -e "$rootfs/sbin/rc-update" ]; then
printf '%s\n' "forbidden persistent-policy tool in base image: rc-update" >&2
exit 1
fi
while IFS= read -r executable; do
description=$(file "$executable")
case "$description" in
*ELF*)
if objdump -p "$executable" |
grep -Eq '^[[:space:]]*SONAME[[:space:]]'; then
continue
fi
count=$((count + 1))
if objdump -p "$executable" |
grep -Eq '^[[:space:]]*(INTERP|NEEDED)[[:space:]]'; then
printf '%s\n' "dynamic base executable: $executable" >&2
failed=1
fi
;;
esac
done <<EOF
$(find "$rootfs" -path "$rootfs/usr/local" -prune -o \
-type f -perm -0100 -print | LC_ALL=C sort)
EOF
if [ "$count" -eq 0 ]; then
printf '%s\n' "no ELF executables found under $rootfs" >&2
exit 1
fi
if [ "$failed" -ne 0 ]; then
exit 1
fi
printf '%s\n' "static ELF audit passed: $count executables"
+76
View File
@@ -0,0 +1,76 @@
#!/bin/sh
set -eu
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
repo_dir=$(dirname "$script_dir")
build_dir=${MOUSE_BUILD_DIR:-"$repo_dir/build"}
source_dir=${MOUSE_SOURCE_DIR:-"$build_dir/sources"}
rootfs_image=${MOUSE_ROOTFS_IMAGE:-"$build_dir/mouse-rootfs.btrfs"}
kernel_image=${MOUSE_KERNEL_IMAGE:-"$build_dir/vmlinuz-virt"}
disk_image=${MOUSE_DISK_IMAGE_OUTPUT:-"$build_dir/mouse-disk.img"}
limine_archive=${MOUSE_LIMINE_ARCHIVE:-"$source_dir/limine-binary-12.3.2.tar.xz"}
limine_config=${MOUSE_LIMINE_CONFIG:-"$repo_dir/base/limine.conf"}
for command in cc make mcopy mformat mmd sfdisk; do
if ! command -v "$command" >/dev/null 2>&1; then
printf '%s\n' "$command is required to build the boot disk" >&2
exit 1
fi
done
for input in "$rootfs_image" "$kernel_image" \
"$limine_archive" "$limine_config"; do
if [ ! -f "$input" ]; then
printf '%s\n' "missing boot-disk input: $input" >&2
exit 1
fi
done
rootfs_bytes=$(stat -c %s "$rootfs_image")
sector_size=512
boot_start=2048
boot_sectors=262144
root_start=$((boot_start + boot_sectors))
root_sectors=$(((rootfs_bytes + sector_size - 1) / sector_size))
disk_sectors=$((root_start + root_sectors + 2048))
working=$(mktemp -d "${TMPDIR:-/tmp}/mouse-boot-disk.XXXXXX")
cleanup() {
rm -rf "$working"
}
trap cleanup EXIT HUP INT TERM
tar -xf "$limine_archive" -C "$working"
limine_source="$working/limine-binary"
make -s -C "$limine_source"
boot_image="$working/mouse-boot.fat"
truncate -s $((boot_sectors * sector_size)) "$boot_image"
mformat -i "$boot_image" -F -v MOUSE_BOOT ::
mmd -i "$boot_image" ::/EFI ::/EFI/BOOT
mcopy -i "$boot_image" \
"$limine_source/BOOTX64.EFI" ::/EFI/BOOT/BOOTX64.EFI
mcopy -i "$boot_image" \
"$limine_source/limine-bios.sys" ::/limine-bios.sys
mcopy -i "$boot_image" "$limine_config" ::/limine.conf
mcopy -i "$boot_image" "$kernel_image" ::/vmlinuz-mouse
rm -f "$disk_image"
truncate -s $((disk_sectors * sector_size)) "$disk_image"
sfdisk --quiet "$disk_image" <<EOF
label: gpt
label-id: 4d4f5553-4500-4000-8000-000000000000
unit: sectors
start=34, size=$((boot_start - 34)), type=21686148-6449-6e6f-744e-656564454649, uuid=4d4f5553-4500-4000-8000-000000000003, name="MOUSE_BIOS"
start=$boot_start, size=$boot_sectors, type=c12a7328-f81f-11d2-ba4b-00a0c93ec93b, uuid=4d4f5553-4500-4000-8000-000000000001, name="MOUSE_BOOT"
start=$root_start, size=$root_sectors, type=0fc63daf-8483-4772-8e79-3d69d8477de4, uuid=4d4f5553-4500-4000-8000-000000000002, name="MOUSE_ROOT"
EOF
dd if="$boot_image" of="$disk_image" bs="$sector_size" \
seek="$boot_start" conv=notrunc status=none
dd if="$rootfs_image" of="$disk_image" bs="$sector_size" \
seek="$root_start" conv=notrunc status=none
"$limine_source/limine" bios-install "$disk_image"
printf '%s\n' "built $disk_image with Limine BIOS and UEFI boot support"
+24
View File
@@ -0,0 +1,24 @@
#!/bin/sh
set -eu
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
repo_dir=$(dirname "$script_dir")
build_dir=${MOUSE_BUILD_DIR:-"$repo_dir/build"}
static_dir="$build_dir/static"
base_root="$static_dir/rootfs"
cc="$static_dir/cross-tools/bin/x86_64-mouse-linux-musl-cc"
for requirement in \
"$cc" \
"$static_dir/sysroot/usr/lib/libc.a"
do
if [ ! -x "$requirement" ] && [ ! -f "$requirement" ]; then
printf '%s\n' "missing static-base input: $requirement" >&2
exit 1
fi
done
install -m 0755 \
"$repo_dir/base/support/mouse-bootenv" \
"$base_root/usr/sbin/mouse-bootenv"
ln -sfn ../usr/lib/libc.so "$base_root/lib/ld-musl-x86_64.so.1"
+211
View File
@@ -0,0 +1,211 @@
#!/bin/sh
set -eu
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
repo_dir=$(dirname "$script_dir")
cheesed_dir="$repo_dir/base/cheesed"
build_dir=${MOUSE_BUILD_DIR:-"$repo_dir/build"}
target=${CHEESED_TARGET:-x86_64-unknown-linux-musl}
test_fixtures=${MOUSE_INCLUDE_TEST_FIXTURES:-0}
kernel_modules=${MOUSE_KERNEL_MODULES:-"$build_dir/kernel/modules"}
staging=
image_staging=
cleanup() {
for directory in "$staging" "$image_staging"; do
if [ -n "$directory" ] && [ -d "$directory" ]; then
rm -rf "$directory"
fi
done
}
trap cleanup EXIT HUP INT TERM
case "$test_fixtures" in
0|1) ;;
*)
printf '%s\n' "MOUSE_INCLUDE_TEST_FIXTURES must be 0 or 1" >&2
exit 1
;;
esac
base_root="$build_dir/static/rootfs"
pkgsrc_seed=${MOUSE_PKGSRC_SEED:-"$build_dir/pkgsrc-seed"}
for input in "$base_root" "$build_dir/vmlinuz-virt"; do
if [ ! -e "$input" ]; then
printf '%s\n' "missing prepared image input: $input" >&2
exit 1
fi
done
for seed_directory in "$pkgsrc_seed/usr/local" "$pkgsrc_seed/var/db/pkg"; do
if [ ! -d "$seed_directory" ]; then
printf '%s\n' "missing pkgsrc seed directory: $seed_directory" >&2
exit 1
fi
done
btrfs_image_tool=${MOUSE_BTRFS_IMAGE_TOOL:-"$base_root/sbin/mkfs.btrfs"}
if [ ! -x "$btrfs_image_tool" ]; then
printf '%s\n' "missing btrfs image tool: $btrfs_image_tool" >&2
exit 1
fi
if [ -n "${MOUSE_CHEESED_BINARY:-}" ]; then
cheesed_binary=$MOUSE_CHEESED_BINARY
else
cheesed_binary=$(CHEESED_TARGET="$target" "$cheesed_dir/scripts/build-static.sh")
fi
staging=$(mktemp -d "${TMPDIR:-/tmp}/mouse-rootfs.XXXXXX")
image_staging=$(mktemp -d "${TMPDIR:-/tmp}/mouse-btrfs.XXXXXX")
install -d -m 0755 \
"$staging/dev" \
"$staging/bin" \
"$staging/etc" \
"$staging/etc/default" \
"$staging/etc/rc.d" \
"$staging/etc/skel" \
"$staging/home" \
"$staging/media" \
"$staging/mnt" \
"$staging/proc" \
"$staging/root" \
"$staging/run" \
"$staging/sbin" \
"$staging/srv" \
"$staging/sys" \
"$staging/usr/bin" \
"$staging/usr/local/etc/rc.d" \
"$staging/usr/lib/mouse" \
"$staging/usr/sbin" \
"$staging/var/cache/pkgsrc/distfiles" \
"$staging/var/cache/pkgsrc/packages" \
"$staging/var/db" \
"$staging/var/lib/dhcpcd" \
"$staging/var/empty" \
"$staging/var/log" \
"$staging/var/mail" \
"$staging/var/spool/cron"
chmod 0755 "$staging"
chmod 0700 "$staging/root"
chmod 0755 "$staging/var/empty"
chmod 0700 "$staging/var/spool/cron"
install -d -m 1777 \
"$staging/tmp" \
"$staging/var/tmp" \
"$staging/var/tmp/vi.recover"
ln -s /run "$staging/var/run"
cp -R "$base_root/." "$staging/"
cp -R "$pkgsrc_seed/usr/local/." "$staging/usr/local/"
cp -R "$pkgsrc_seed/var/db/pkg" "$staging/var/db/"
if [ ! -d "$kernel_modules/lib/modules" ]; then
printf '%s\n' "missing kernel module tree: $kernel_modules/lib/modules" >&2
exit 1
fi
cp -R "$kernel_modules/lib/." "$staging/lib/"
if [ "$test_fixtures" -eq 1 ] && [ -d "$kernel_modules/usr/local" ]; then
cp -R "$kernel_modules/usr/local/." "$staging/usr/local/"
fi
install -m 0755 "$cheesed_binary" "$staging/sbin/cheesed"
for command in service shutdown poweroff reboot; do
ln -s cheesed "$staging/sbin/$command"
done
cp -R "$repo_dir/base/rootfs/." "$staging/"
if [ "$test_fixtures" -eq 1 ]; then
cp -R "$repo_dir/tests/fixtures/mouse-echo/rootfs/." "$staging/"
install -m 0755 \
"${MOUSE_MOUSE_ECHO_BINARY:?missing test mouse-echo binary}" \
"$staging/usr/libexec/mouse-echo"
printf '%s\n' "enable_mouse_echo=YES" >>"$staging/etc/rc.conf"
fi
install -d -m 0755 "$staging/usr/share/mouse"
if [ "$test_fixtures" -eq 1 ]; then
install -d -m 0755 "$staging/usr/share/mouse/pkgsrc-fixture"
cp -R "$repo_dir/tests/fixtures/pkgsrc/local" \
"$staging/usr/share/mouse/pkgsrc-fixture/"
fi
printf '%s\n' 2026Q2 >"$staging/usr/share/mouse/pkgsrc.version"
rc_subr_source="$staging/usr/local/src/pkgsrc/pkgtools/rc.subr/files/rc.subr"
[ -f "$rc_subr_source" ] || {
printf '%s\n' "pkgsrc seed lacks rc.subr source" >&2
exit 1
}
sed 's|@SYSCONFBASE@|/usr/local/etc|g' "$rc_subr_source" \
>"$staging/etc/rc.subr"
patch "$staging/etc/rc.subr" \
<"$repo_dir/base/patches/pkgsrc-rc.subr-cgroup.patch"
chmod 0444 "$staging/etc/rc.subr"
ln -s mouse-release "$staging/etc/os-release"
chmod 0755 \
"$staging/etc/rc.d/console_login" \
"$staging/etc/rc.d/cron" \
"$staging/etc/rc.d/daemon" \
"$staging/etc/rc.d/login" \
"$staging/etc/rc.d/loopback" \
"$staging/etc/rc.d/machine_identity" \
"$staging/etc/rc.d/mdevd" \
"$staging/etc/rc.d/network" \
"$staging/etc/rc.d/ntpd" \
"$staging/etc/rc.d/servers" \
"$staging/etc/rc.d/syslogd" \
"$staging/usr/libexec/mouse-dhcpcd-hook"
if [ "$test_fixtures" -eq 1 ]; then
chmod 0755 "$staging/etc/rc.d/mouse_echo"
fi
chmod 0600 "$staging/etc/shadow"
chmod 0444 "$staging/usr/share/mouse/pkgsrc.version"
"$script_dir/audit-static-base.sh" "$staging"
mkdir -p "$build_dir"
btrfs_image="$build_dir/mouse-rootfs.btrfs"
rootfs_size=${MOUSE_ROOTFS_SIZE:-4G}
install -d -m 0755 \
"$image_staging/ROOT/default" \
"$image_staging/ROOT/alternate" \
"$image_staging/usr-local" \
"$image_staging/var" \
"$image_staging/home" \
"$image_staging/srv"
cp -R "$staging/." "$image_staging/ROOT/default/"
cp -R "$staging/." "$image_staging/ROOT/alternate/"
printf '%s\n' default \
>"$image_staging/ROOT/default/etc/mouse-boot-environment"
printf '%s\n' alternate \
>"$image_staging/ROOT/alternate/etc/mouse-boot-environment"
for persistent in \
usr/local:usr-local \
var:var \
home:home \
srv:srv
do
root_path=${persistent%%:*}
subvolume=${persistent#*:}
cp -R "$staging/$root_path/." "$image_staging/$subvolume/"
for environment in default alternate; do
rm -rf "$image_staging/ROOT/$environment/$root_path"
install -d -m 0755 \
"$image_staging/ROOT/$environment/$root_path"
done
done
rm -f "$btrfs_image"
truncate -s "$rootfs_size" "$btrfs_image"
"$btrfs_image_tool" \
--force \
--label MOUSE_ROOT \
--uuid 4d4f5553-4500-4000-8000-00000000000b \
--rootdir "$image_staging" \
--subvol default:ROOT/default \
--subvol rw:ROOT/alternate \
--subvol rw:usr-local \
--subvol rw:var \
--subvol rw:home \
--subvol rw:srv \
"$btrfs_image"
printf '%s\n' "built $build_dir/vmlinuz-virt"
printf '%s\n' "built $btrfs_image"
sh "$script_dir/build-boot-disk.sh"
+191
View File
@@ -0,0 +1,191 @@
#!/bin/sh
set -eu
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
repo_dir=$(dirname "$script_dir")
output_dir=${MOUSE_BUILD_DIR:-"$repo_dir/build"}
test_fixtures=${MOUSE_INCLUDE_TEST_FIXTURES:-0}
builder_cpus=${MOUSE_BUILDER_CPUS:-8}
builder_memory=${MOUSE_BUILDER_MEMORY:-8G}
build_jobs=${MOUSE_BUILD_JOBS:-8}
die() {
printf '%s\n' "$*" >&2
exit 1
}
require_positive() {
case "$1" in
''|*[!0-9]*|0) die "$2 must be a positive integer" ;;
esac
}
memory_mib() {
case "$1" in
*[Kk]) value=${1%?}; divisor=1024 ;;
*[Mm]) value=${1%?}; divisor=1 ;;
*[Gg]) value=${1%?}; divisor=0 ;;
*[Tt]) value=${1%?}; divisor=-1 ;;
*) value=$1; divisor=1048576 ;;
esac
require_positive "$value" MOUSE_BUILDER_MEMORY
case "$divisor" in
0) printf '%s\n' "$((value * 1024))" ;;
-1) printf '%s\n' "$((value * 1024 * 1024))" ;;
1) printf '%s\n' "$value" ;;
*) printf '%s\n' "$(((value + divisor - 1) / divisor))" ;;
esac
}
case "$test_fixtures" in
0|1) ;;
*) die "MOUSE_INCLUDE_TEST_FIXTURES must be 0 or 1" ;;
esac
case "$test_fixtures" in
0) rootfs_stage=rootfs-builder ;;
1) rootfs_stage=rootfs-test-builder ;;
esac
require_positive "$builder_cpus" MOUSE_BUILDER_CPUS
require_positive "$build_jobs" MOUSE_BUILD_JOBS
[ -n "$builder_memory" ] || die "MOUSE_BUILDER_MEMORY must not be empty"
if [ -n "${MOUSE_BUILDER_PLATFORM:-}" ]; then
builder_platform=$MOUSE_BUILDER_PLATFORM
else
case "$(uname -m)" in
arm64|aarch64) builder_platform=linux/arm64 ;;
x86_64|amd64) builder_platform=linux/amd64 ;;
*) die "unsupported container host architecture: $(uname -m)" ;;
esac
fi
if [ -n "${CONTAINER_CLI:-}" ]; then
container_cli=$CONTAINER_CLI
elif command -v container >/dev/null 2>&1; then
container_cli=$(command -v container)
elif [ -x /usr/local/bin/container ]; then
container_cli=/usr/local/bin/container
elif command -v docker >/dev/null 2>&1; then
container_cli=$(command -v docker)
elif command -v podman >/dev/null 2>&1; then
container_cli=$(command -v podman)
else
die "no supported container CLI found (container, docker, or podman)"
fi
container_frontend=$(basename "$container_cli")
case "$container_frontend" in
container)
"$container_cli" system start >/dev/null
builder_resources=$("$container_cli" builder status 2>/dev/null |
awk 'NR == 2 { print $5, $6 }')
if [ -n "$builder_resources" ]; then
set -- $builder_resources
actual_cpus=$1
actual_memory_mib=$2
expected_memory_mib=$(memory_mib "$builder_memory")
if [ "$actual_cpus" != "$builder_cpus" ] ||
[ "$actual_memory_mib" != "$expected_memory_mib" ]; then
die "Apple Container builder has $actual_cpus CPUs and ${actual_memory_mib} MB; expected $builder_cpus CPUs and ${expected_memory_mib} MB. Recreate it with: container builder stop; container builder delete; container builder start --cpus $builder_cpus --memory $builder_memory (deleting it discards the build cache)"
fi
fi
;;
docker|podman) ;;
*) die "unsupported container CLI: $container_frontend" ;;
esac
"$repo_dir/scripts/check-source-locks.sh"
"$repo_dir/scripts/fetch-sources.sh"
mkdir -p "$output_dir"
build_context=$(mktemp -d "$output_dir/.container-context.XXXXXX")
build_context=$(CDPATH= cd -- "$build_context" && pwd)
export_dir=$(mktemp -d "$output_dir/.container-output.XXXXXX")
export_dir=$(CDPATH= cd -- "$export_dir" && pwd)
artifact_temp=
cleanup() {
[ -z "$artifact_temp" ] || rm -f "$artifact_temp"
rm -rf "$build_context" "$export_dir"
}
trap cleanup EXIT HUP INT TERM
(
cd "$repo_dir/.."
tar -cf - \
--exclude='mouse-src/.git/*' \
--exclude='mouse-src/build/*' \
--exclude='mouse-src/Containerfile' \
--exclude='mouse-src/.containerignore' \
--exclude='mouse-src/scripts/build-in-container.sh' \
--exclude='mouse-src/base/cheesed/target/*' \
mouse-src
) | tar -xf - -C "$build_context"
cp "$repo_dir/Containerfile" "$build_context/Dockerfile"
cp "$repo_dir/.containerignore" "$build_context/.dockerignore"
source_dir=${MOUSE_SOURCE_DIR:-"$output_dir/sources"}
for domain in toolchain kernel firmware facilities storage pkgsrc software; do
domain_dir="$build_context/mouse-sources/$domain"
mkdir -p "$domain_dir"
while read -r checksum url filename extra; do
case "$checksum" in
''|\#*) continue ;;
esac
install -m 0444 "$source_dir/$filename" "$domain_dir/$filename"
done <"$repo_dir/release/$domain.lock"
done
(
cd "$build_context"
set -- build
case "$container_frontend" in
container)
set -- "$@" --cpus "$builder_cpus" --memory "$builder_memory"
;;
docker|podman)
set -- "$@" \
--cpu-period 100000 \
--cpu-quota "$((builder_cpus * 100000))" \
--memory "$builder_memory"
;;
esac
set -- "$@" \
--platform "$builder_platform" \
--target artifacts \
--build-arg "MOUSE_BUILD_JOBS=$build_jobs" \
--build-arg "MOUSE_ROOTFS_STAGE=$rootfs_stage" \
--output "type=local,dest=$export_dir" \
.
"$container_cli" "$@"
)
artifacts_dir=$export_dir
if [ ! -f "$artifacts_dir/vmlinuz-virt" ]; then
platform_dir=$(printf '%s\n' "$builder_platform" | tr / _)
artifacts_dir="$export_dir/out.tar/$platform_dir"
fi
for artifact in vmlinuz-virt ovmf-code.fd; do
[ -f "$artifacts_dir/$artifact" ] || \
die "container build did not export $artifact"
install -m 0644 "$artifacts_dir/$artifact" "$output_dir/$artifact"
done
artifact=mouse-disk.img
[ -f "$artifacts_dir/$artifact.gz" ] || \
die "container build did not export $artifact.gz"
artifact_temp="$output_dir/.$artifact.tmp"
gzip -dc "$artifacts_dir/$artifact.gz" >"$artifact_temp"
chmod 0644 "$artifact_temp"
mv -f "$artifact_temp" "$output_dir/$artifact"
artifact_temp=
for artifact in \
vmlinuz-virt \
ovmf-code.fd \
mouse-disk.img
do
printf '%s\n' "exported $output_dir/$artifact"
done
+29
View File
@@ -0,0 +1,29 @@
#!/bin/sh
set -eu
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
repo_dir=$(dirname "$script_dir")
build_dir=${MOUSE_BUILD_DIR:-"$repo_dir/build"}
kernel_version=$(cat "$build_dir/kernel/release")
kernel_source="$build_dir/kernel/linux-6.18.35"
kernel_output="$build_dir/kernel/output"
module_output="$build_dir/kernel/module-test"
module_root="$build_dir/kernel/test-modules"
rm -rf "$module_output" "$module_root"
mkdir -p "$module_output"
cp "$repo_dir/tests/fixtures/kernel-module/mouse_test.c" \
"$repo_dir/tests/fixtures/kernel-module/Makefile" \
"$module_output/"
make -s -C "$kernel_source" \
O="$kernel_output" \
ARCH=x86_64 \
LLVM=1 \
M="$module_output" \
modules
cp -R "$build_dir/kernel/modules" "$module_root"
install -d -m 0755 \
"$module_root/usr/local/lib/modules/$kernel_version/extra"
install -m 0644 "$module_output/mouse_test.ko" \
"$module_root/usr/local/lib/modules/$kernel_version/extra/mouse_test.ko"
+80
View File
@@ -0,0 +1,80 @@
#!/bin/sh
set -eu
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
repo_dir=$(dirname "$script_dir")
build_dir=${MOUSE_BUILD_DIR:-"$repo_dir/build"}
source_dir=${MOUSE_SOURCE_DIR:-"$build_dir/sources"}
kernel_version=6.18.35
kernel_archive="$source_dir/linux-$kernel_version.tar.xz"
kernel_source="$build_dir/kernel/linux-$kernel_version"
kernel_output="$build_dir/kernel/output"
kernel_config="$repo_dir/base/kernel/x86_64.config"
jobs=${MOUSE_BUILD_JOBS:-$(getconf _NPROCESSORS_ONLN 2>/dev/null || printf '1\n')}
if [ ! -f "$kernel_archive" ]; then
printf '%s\n' "missing $kernel_archive; run scripts/fetch-sources.sh first" >&2
exit 1
fi
if [ ! -f "$kernel_config" ]; then
printf '%s\n' "missing MOUSE kernel config: $kernel_config" >&2
exit 1
fi
mkdir -p "$build_dir/kernel"
rm -rf "$kernel_source" "$kernel_output"
tar -C "$build_dir/kernel" -xf "$kernel_archive"
mkdir -p "$kernel_output"
make -C "$kernel_source" \
O="$kernel_output" \
ARCH=x86_64 \
LLVM=1 \
KCONFIG_ALLCONFIG="$kernel_config" \
allnoconfig
while IFS= read -r requested || [ -n "$requested" ]; do
case "$requested" in
CONFIG_*=*) ;;
*) continue ;;
esac
if ! grep -Fqx "$requested" "$kernel_output/.config"; then
printf '%s\n' \
"kernel did not enable requested setting: $requested" >&2
exit 1
fi
done <"$kernel_config"
make -C "$kernel_source" \
O="$kernel_output" \
ARCH=x86_64 \
LLVM=1 \
KBUILD_BUILD_USER=mouse \
KBUILD_BUILD_HOST=mouse \
-j"$jobs" \
bzImage modules
kernel_release=$(make -s -C "$kernel_source" \
O="$kernel_output" \
ARCH=x86_64 \
LLVM=1 \
kernelrelease)
module_root="$build_dir/kernel/modules"
rm -rf "$module_root"
make -s -C "$kernel_source" \
O="$kernel_output" \
ARCH=x86_64 \
LLVM=1 \
INSTALL_MOD_PATH="$module_root" \
modules_install
printf '%s\n' "$kernel_release" >"$build_dir/kernel/release"
install -m 0644 "$kernel_output/.config" \
"$module_root/lib/modules/$kernel_release/config"
install -m 0644 "$kernel_output/Module.symvers" \
"$module_root/lib/modules/$kernel_release/Module.symvers"
install -m 0644 \
"$kernel_output/arch/x86/boot/bzImage" \
"$build_dir/vmlinuz-virt"
printf '%s\n' \
"built Linux $kernel_release with built-in btrfs and loadable-module support"
+89
View File
@@ -0,0 +1,89 @@
#!/bin/sh
set -eu
archive=${MOUSE_PKGSRC_ARCHIVE:-/usr/share/mouse/pkgsrc-2026Q2.tar.gz}
patch_file=${MOUSE_PKGSRC_PATCH:-/usr/share/mouse/pkgsrc-bootstrap-mouse.patch}
source_parent=/usr/local/src
pkgsrc=$source_parent/pkgsrc
mk_conf=/usr/local/etc/mk.conf
build_busybox=/usr/libexec/mouse-build-busybox
fail() {
printf '%s\n' "build-pkgsrc-seed: $*" >&2
exit 1
}
[ "$(id -u)" -eq 0 ] || fail "must run as root"
[ -f "$archive" ] || fail "missing pinned pkgsrc archive: $archive"
[ -f "$patch_file" ] || fail "missing MOUSE pkgsrc bootstrap patch: $patch_file"
[ -x "$build_busybox" ] || fail "missing build-only copy helper"
[ ! -e /usr/local/bin/bmake ] || fail "pkgsrc seed root is not empty"
[ ! -e /var/db/pkg ] || fail "pkgsrc package database already exists"
mkdir -p \
"$source_parent" \
/usr/local/etc/rc.d \
/tmp \
/var/cache/pkgsrc/distfiles \
/var/cache/pkgsrc/packages
chmod 1777 /tmp
tar -xzf "$archive" -C "$source_parent"
[ -x "$pkgsrc/bootstrap/bootstrap" ] || fail "archive did not produce a pkgsrc tree"
[ -f "$pkgsrc/mk/init/bsd.init.mk" ] || fail "pkgsrc tree lacks init-system support"
patch -d "$pkgsrc" -p1 <"$patch_file"
grep -Fq 'bootstrap_awk=/usr/bin/awk' "$pkgsrc/bootstrap/bootstrap" ||
fail "pkgsrc tree lacks the MOUSE World awk policy"
# Apple Rosetta reports ENOSYS for the copy operation used by MOUSE's static
# cp. Use an amd64 build-only applet while pkgsrc populates its work directory;
# only /usr/local and /var/db/pkg leave this stage.
mv /bin/cp /bin/cp.mouse
ln -s "$build_busybox" /bin/cp
(
cd "$pkgsrc/bootstrap"
env \
AWK=/usr/bin/awk \
CC=/usr/bin/cc \
CXX=/usr/bin/c++ \
SH=/bin/sh \
./bootstrap \
--compiler clang \
--make-jobs "${MOUSE_BUILD_JOBS:-1}" \
--pkgdbdir /var/db/pkg \
--prefer-pkgsrc yes \
--prefix /usr/local \
--sysconfbase /usr/local/etc \
--sysconfdir /usr/local/etc \
--varbase /var
)
rm /bin/cp
mv /bin/cp.mouse /bin/cp
rm "$build_busybox"
cat >>"$mk_conf" <<'EOF'
# MOUSE pkgsrc policy
PKGSRC_COMPILER= clang
LOCALBASE= /usr/local
PKG_SYSCONFBASE= /usr/local/etc
PKG_DBDIR= /var/db/pkg
VARBASE= /var
DISTDIR= /var/cache/pkgsrc/distfiles
PACKAGES= /var/cache/pkgsrc/packages
INIT_SYSTEM= rc.d
RCD_SCRIPTS_DIR= /usr/local/etc/rc.d
PKG_RCD_SCRIPTS= YES
PREFER_PKGSRC= yes
EOF
ln -s /etc/rc.subr /usr/local/etc/rc.subr
rm -rf "$pkgsrc/bootstrap/work"
[ -x /usr/local/bin/bmake ] || fail "bootstrap did not install bmake"
[ -x /usr/local/sbin/pkg_info ] || fail "bootstrap did not install pkg_info"
[ -d /var/db/pkg ] || fail "bootstrap did not create the package database"
grep -Eq '^TOOLS_PLATFORM\.awk\?=[[:space:]]*/usr/bin/awk$' "$mk_conf" ||
fail "bootstrap did not preserve the World awk policy"
printf '%s\n' "built pkgsrc 2026Q2 seed"
+197
View File
@@ -0,0 +1,197 @@
#!/bin/sh
set -eu
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
repo_dir=$(dirname "$script_dir")
lock_dir="$repo_dir/release"
temporary=$(mktemp -d "${TMPDIR:-/tmp}/mouse-source-lock-check.XXXXXX")
cleanup() {
rm -rf "$temporary"
}
trap cleanup EXIT HUP INT TERM
MOUSE_VALIDATE_ONLY=1 "$script_dir/fetch-sources.sh"
awk 'NF && $1 !~ /^#/ { print $3 }' \
"$lock_dir/toolchain.lock" \
"$lock_dir/kernel.lock" \
"$lock_dir/facilities.lock" \
"$lock_dir/storage.lock" \
"$lock_dir/software.lock" |
LC_ALL=C sort -u >"$temporary/locked"
awk '$1 == "extract" { print $2 }' "$script_dir/static-base"/*.sh |
LC_ALL=C sort -u >"$temporary/referenced-archives"
sed -n 's/.*"$source_dir\/\([^"$]*\)".*/\1/p' \
"$script_dir/static-base"/*.sh \
"$script_dir/build-boot-disk.sh" |
LC_ALL=C sort -u >"$temporary/referenced-files"
cat "$temporary/referenced-archives" "$temporary/referenced-files" |
LC_ALL=C sort -u >"$temporary/referenced"
if ! diff -u "$temporary/locked" "$temporary/referenced"; then
printf '%s\n' "source locks do not match static-base component inputs" >&2
exit 1
fi
toolchain_count=$(awk 'NF && $1 !~ /^#/ { count++ } END { print count + 0 }' \
"$lock_dir/toolchain.lock")
kernel_count=$(awk 'NF && $1 !~ /^#/ { count++ } END { print count + 0 }' \
"$lock_dir/kernel.lock")
if [ "$toolchain_count" -ne 1 ] || \
! awk 'NF && $1 !~ /^#/ { print $3 }' "$lock_dir/toolchain.lock" |
grep -Eq '^llvm-project-[^/]+$'
then
printf '%s\n' "toolchain.lock must contain exactly the LLVM source" >&2
exit 1
fi
if [ "$kernel_count" -ne 1 ] || \
! awk 'NF && $1 !~ /^#/ { print $3 }' "$lock_dir/kernel.lock" |
grep -Eq '^linux-[^/]+$'
then
printf '%s\n' "kernel.lock must contain exactly the Linux source" >&2
exit 1
fi
pkgsrc_count=$(awk 'NF && $1 !~ /^#/ { count++ } END { print count + 0 }' \
"$lock_dir/pkgsrc.lock")
if [ "$pkgsrc_count" -ne 1 ] || \
! awk 'NF && $1 !~ /^#/ { print $3 }' "$lock_dir/pkgsrc.lock" |
grep -Eq '^pkgsrc-[0-9]{4}Q[1-4]\.tar\.gz$'
then
printf '%s\n' "pkgsrc.lock must contain exactly one stable pkgsrc archive" >&2
exit 1
fi
firmware_count=$(awk 'NF && $1 !~ /^#/ { count++ } END { print count + 0 }' \
"$lock_dir/firmware.lock")
if [ "$firmware_count" -ne 1 ] || \
! awk 'NF && $1 !~ /^#/ { print $3 }' "$lock_dir/firmware.lock" |
grep -Eq '^ovmf-[^/]+\.apk$'
then
printf '%s\n' "firmware.lock must contain exactly one OVMF package" >&2
exit 1
fi
storage_count=$(awk 'NF && $1 !~ /^#/ { count++ } END { print count + 0 }' \
"$lock_dir/storage.lock")
if [ "$storage_count" -lt 1 ] || \
! awk 'NF && $1 !~ /^#/ { print $3 }' "$lock_dir/storage.lock" |
grep -Eq '^btrfs-progs-[^/]+$'
then
printf '%s\n' "storage.lock must contain the btrfs-progs source" >&2
exit 1
fi
if awk 'NF && $1 !~ /^#/ { print $3 }' "$lock_dir/software.lock" |
grep -Eq '^(llvm-project|linux|btrfs-progs|less|mandoc|iproute2|nftables)-'
then
printf '%s\n' "software.lock contains a source owned by another cache domain" >&2
exit 1
fi
if awk 'NF && $1 !~ /^#/ { print $3 }' "$lock_dir/facilities.lock" |
grep -Eq '^(llvm-project|linux|btrfs-progs)-'
then
printf '%s\n' "facilities.lock contains a kernel, toolchain, or storage source" >&2
exit 1
fi
awk '
/^FROM toolchain AS kernel-builder$/ { in_kernel = 1; next }
/^FROM / && in_kernel { exit }
in_kernel { print }
' "$repo_dir/Containerfile" >"$temporary/kernel-stage"
if ! grep -Fq 'COPY --from=kernel-sources ' "$temporary/kernel-stage"; then
printf '%s\n' "kernel-builder does not import kernel-sources" >&2
exit 1
fi
if grep -Eq 'COPY --from=(toolchain|storage|software)-sources ' \
"$temporary/kernel-stage"
then
printf '%s\n' "kernel-builder imports an unrelated source domain" >&2
exit 1
fi
if grep -Fq 'tests/fixtures' "$temporary/kernel-stage"; then
printf '%s\n' "production kernel stage imports test fixtures" >&2
exit 1
fi
awk '
/^FROM kernel-builder AS kernel-ready$/ { in_marker = 1; next }
/^FROM / && in_marker { exit }
in_marker { print }
' "$repo_dir/Containerfile" >"$temporary/kernel-ready-stage"
if ! grep -Fq 'RUN install -m 0444 /dev/null /kernel-ready' \
"$temporary/kernel-ready-stage"
then
printf '%s\n' "kernel-ready does not create its completion marker" >&2
exit 1
fi
for stage_script in \
static-base-bootstrap:bootstrap.sh \
static-base-libraries:libraries-and-accounts.sh \
static-base-system:system-services.sh \
static-base-facilities:facilities.sh \
static-base-toolchain:native-toolchain.sh \
static-base-storage:storage.sh \
static-base-builder:finish.sh
do
stage=${stage_script%%:*}
component=${stage_script#*:}
awk -v heading="AS $stage" '
/^FROM / {
if (active) exit
active = index($0, heading) != 0
next
}
active { print }
' "$repo_dir/Containerfile" >"$temporary/$stage"
if ! grep -Fq \
"COPY mouse-src/scripts/static-base/$component " \
"$temporary/$stage"
then
printf '%s\n' \
"$stage does not own static-base component $component" >&2
exit 1
fi
if [ "$(grep -Fc \
"COPY mouse-src/scripts/static-base/$component " \
"$repo_dir/Containerfile")" -ne 1 ]
then
printf '%s\n' \
"$component must enter exactly one container cache stage" >&2
exit 1
fi
done
if ! grep -Fq \
'COPY --from=kernel-ready /kernel-ready /tmp/kernel-ready' \
"$temporary/static-base-bootstrap"
then
printf '%s\n' "static-base build does not wait for kernel completion" >&2
exit 1
fi
for production_stage in image-commands-builder rootfs-builder; do
awk -v heading="AS $production_stage" '
/^FROM / {
if (active) exit
active = index($0, heading) != 0
next
}
active { print }
' "$repo_dir/Containerfile" >"$temporary/$production_stage"
if grep -Fq 'tests/fixtures' "$temporary/$production_stage"; then
printf '%s\n' "$production_stage imports test fixtures" >&2
exit 1
fi
done
for test_stage in kernel-test-builder test-fixtures-builder rootfs-test-builder; do
if ! grep -Fq "AS $test_stage" "$repo_dir/Containerfile"; then
printf '%s\n' "missing isolated test stage: $test_stage" >&2
exit 1
fi
done
printf '%s\n' "source lock and cache-boundary checks passed"
+51
View File
@@ -0,0 +1,51 @@
#!/bin/sh
set -eu
if [ "$#" -ne 9 ]; then
printf '%s\n' \
"usage: configure-cross-toolchain.sh DEST SYSROOT CLANG CLANGXX LLD BUILTINS RUST_EH_PERSONALITY LLVM_AR LLVM_STRIP" >&2
exit 2
fi
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
repo_dir=$(dirname "$script_dir")
destination=$1
sysroot=$2
clang=$3
clangxx=$4
lld=$5
builtins=$6
rust_eh_personality=$7
llvm_ar=$8
llvm_strip=$9
target=x86_64-mouse-linux-musl
for requirement in \
"$clang" "$clangxx" "$lld" "$builtins" "$rust_eh_personality" "$llvm_ar" "$llvm_strip"
do
if [ ! -f "$requirement" ]; then
printf '%s\n' "missing cross-toolchain input: $requirement" >&2
exit 1
fi
done
install -d -m 0755 "$destination/bin"
install -m 0755 \
"$repo_dir/base/support/cross-compiler-driver" \
"$destination/bin/compiler-driver"
printf '%s\n' \
"$clang" \
"$clangxx" \
"$sysroot" \
"$lld" \
"$builtins" \
"$rust_eh_personality" \
>"$destination/compiler.conf"
ln -sf compiler-driver "$destination/bin/$target-cc"
ln -sf compiler-driver "$destination/bin/$target-c++"
ln -sf compiler-driver "$destination/bin/$target-bootstrap-c++"
ln -sf "$llvm_ar" "$destination/bin/$target-ar"
ln -sf "$llvm_ar" "$destination/bin/$target-ranlib"
ln -sf "$llvm_strip" "$destination/bin/$target-strip"
+114
View File
@@ -0,0 +1,114 @@
#!/bin/sh
set -eu
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
repo_dir=$(dirname "$script_dir")
build_dir=${MOUSE_BUILD_DIR:-"$repo_dir/build"}
source_dir=${MOUSE_SOURCE_DIR:-"$build_dir/sources"}
lock_dir="$repo_dir/release"
if [ "$#" -eq 0 ]; then
set -- \
"$lock_dir/toolchain.lock" \
"$lock_dir/kernel.lock" \
"$lock_dir/firmware.lock" \
"$lock_dir/facilities.lock" \
"$lock_dir/pkgsrc.lock" \
"$lock_dir/storage.lock" \
"$lock_dir/software.lock"
fi
seen=$(mktemp "${TMPDIR:-/tmp}/mouse-source-locks.XXXXXX")
cleanup() {
rm -f "$seen"
}
trap cleanup EXIT HUP INT TERM
for lock_file in "$@"; do
if [ ! -f "$lock_file" ]; then
printf '%s\n' "missing source lock: $lock_file" >&2
exit 1
fi
line_number=0
while read -r expected url filename extra; do
line_number=$((line_number + 1))
case "$expected" in
""|\#*) continue ;;
esac
if [ -n "${extra:-}" ]; then
printf '%s\n' "$lock_file:$line_number: expected three fields" >&2
exit 1
fi
if [ "${#expected}" -ne 64 ]; then
printf '%s\n' "$lock_file:$line_number: SHA-256 must have 64 characters" >&2
exit 1
fi
case "$expected" in
*[!0-9a-f]*)
printf '%s\n' "$lock_file:$line_number: SHA-256 must be lowercase hexadecimal" >&2
exit 1
;;
esac
case "$url" in
https://*) ;;
*)
printf '%s\n' "$lock_file:$line_number: source URL must use HTTPS" >&2
exit 1
;;
esac
case "$filename" in
""|.|..|*/*)
printf '%s\n' "$lock_file:$line_number: invalid source filename: $filename" >&2
exit 1
;;
esac
if grep -Fqx "$filename" "$seen"; then
printf '%s\n' "$lock_file:$line_number: duplicate source filename: $filename" >&2
exit 1
fi
printf '%s\n' "$filename" >>"$seen"
done <"$lock_file"
done
if [ "${MOUSE_VALIDATE_ONLY:-0}" = 1 ]; then
exit 0
fi
mkdir -p "$source_dir"
for lock_file in "$@"; do
while read -r expected url filename extra; do
case "$expected" in
""|\#*) continue ;;
esac
destination="$source_dir/$filename"
if [ ! -f "$destination" ]; then
temporary="$destination.part"
printf '%s\n' "fetching $filename"
curl \
--fail \
--location \
--proto '=https' \
--tlsv1.2 \
--connect-timeout 20 \
--retry 4 \
--retry-all-errors \
"$url" \
-o "$temporary"
mv "$temporary" "$destination"
fi
if command -v sha256sum >/dev/null 2>&1; then
actual=$(sha256sum "$destination" | awk '{print $1}')
else
actual=$(shasum -a 256 "$destination" | awk '{print $1}')
fi
if [ "$actual" != "$expected" ]; then
printf '%s\n' "checksum mismatch: $filename" >&2
printf '%s\n' "expected: $expected" >&2
printf '%s\n' "actual: $actual" >&2
exit 1
fi
done <"$lock_file"
done
+152
View File
@@ -0,0 +1,152 @@
#!/bin/sh
set -eu
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
repo_dir=$(dirname "$script_dir")
build_dir=${MOUSE_BUILD_DIR:-"$repo_dir/build"}
boot_mode=${MOUSE_BOOT_MODE:-firmware}
kernel_args=${MOUSE_KERNEL_ARGS:-}
disk_image=${MOUSE_DISK_IMAGE:-"$build_dir/mouse-disk.img"}
disk_bus=${MOUSE_DISK_BUS:-virtio}
firmware=${MOUSE_FIRMWARE:-bios}
uefi_code=${MOUSE_UEFI_CODE:-"$build_dir/ovmf-code.fd"}
network=${MOUSE_NETWORK:-0}
network_backend=${MOUSE_NETWORK_BACKEND:-user}
network_device=${MOUSE_NETWORK_DEVICE:-virtio}
memory=${MOUSE_MEMORY:-512M}
if [ -n "${QEMU_SYSTEM_X86_64:-}" ]; then
qemu=$QEMU_SYSTEM_X86_64
else
qemu=qemu-system-x86_64
fi
case "$qemu" in
*/*)
if [ ! -x "$qemu" ]; then
printf '%s\n' "$qemu is not executable" >&2
exit 1
fi
;;
*)
if ! command -v "$qemu" >/dev/null 2>&1; then
printf '%s\n' "qemu-system-x86_64 is required to boot the image" >&2
exit 1
fi
;;
esac
if [ ! -f "$build_dir/vmlinuz-virt" ]; then
printf '%s\n' "run 'make image' before booting MOUSE" >&2
exit 1
fi
disk_drive="file=$disk_image,format=raw,if=none,id=mouse-root"
disk_controller=
case "$disk_bus" in
virtio)
disk_device="virtio-blk-pci,drive=mouse-root,disable-legacy=on"
;;
sata)
disk_controller="ich9-ahci,id=mouse-ahci"
disk_device="ide-hd,drive=mouse-root,bus=mouse-ahci.0"
;;
nvme)
disk_device="nvme,drive=mouse-root,serial=MOUSE0001"
;;
*)
printf '%s\n' "invalid MOUSE_DISK_BUS: $disk_bus" >&2
exit 2
;;
esac
set -- "$qemu" \
-machine q35,accel=tcg \
-cpu max \
-m "$memory" \
-no-reboot \
-display none \
-nographic \
-nic none
case "$firmware" in
bios) ;;
uefi)
if [ ! -f "$uefi_code" ]; then
printf '%s\n' "missing pinned UEFI firmware: $uefi_code" >&2
exit 1
fi
set -- "$@" \
-drive "if=pflash,format=raw,readonly=on,file=$uefi_code"
;;
*)
printf '%s\n' "invalid MOUSE_FIRMWARE: $firmware" >&2
exit 2
;;
esac
case "$boot_mode" in
firmware)
if [ ! -f "$disk_image" ]; then
printf '%s\n' "missing boot disk: $disk_image" >&2
exit 1
fi
set -- "$@" -drive "$disk_drive"
if [ -n "$disk_controller" ]; then
set -- "$@" -device "$disk_controller"
fi
set -- "$@" -device "$disk_device"
;;
disk)
if [ ! -f "$disk_image" ]; then
printf '%s\n' "missing root disk: $disk_image" >&2
exit 1
fi
kernel_args=${kernel_args:-"console=ttyS0 root=PARTUUID=4d4f5553-4500-4000-8000-000000000002 rootfstype=btrfs rw rootwait init=/sbin/cheesed panic=-1"}
set -- "$@" \
-kernel "$build_dir/vmlinuz-virt" \
-drive "$disk_drive"
if [ -n "$disk_controller" ]; then
set -- "$@" -device "$disk_controller"
fi
set -- "$@" -device "$disk_device"
;;
*)
printf '%s\n' "invalid MOUSE_BOOT_MODE: $boot_mode" >&2
exit 2
;;
esac
case "$network" in
0) ;;
1)
if ! "$qemu" -netdev help 2>&1 |
grep -Fxq "$network_backend"; then
printf '%s\n' \
"QEMU does not provide the requested network backend: $network_backend" \
"install a QEMU build with that backend or set MOUSE_NETWORK_BACKEND" >&2
exit 1
fi
case "$network_device" in
virtio) nic_device="virtio-net-pci,netdev=mouse-net,disable-legacy=on" ;;
e1000) nic_device="e1000,netdev=mouse-net" ;;
e1000e) nic_device="e1000e,netdev=mouse-net" ;;
*)
printf '%s\n' "invalid MOUSE_NETWORK_DEVICE: $network_device" >&2
exit 2
;;
esac
set -- "$@" \
-netdev "$network_backend,id=mouse-net" \
-device "$nic_device"
;;
*)
printf '%s\n' "invalid MOUSE_NETWORK: $network" >&2
exit 2
;;
esac
if [ "$boot_mode" = disk ]; then
set -- "$@" -append "$kernel_args"
fi
exec "$@"
+221
View File
@@ -0,0 +1,221 @@
#!/bin/sh
set -eu
component_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
. "$component_dir/common.sh"
rm -rf "$static_dir"
install -d -m 0755 \
"$source_build_dir" \
"$sysroot" \
"$base_root/bin" \
"$base_root/sbin" \
"$base_root/usr/bin" \
"$base_root/usr/sbin" \
"$tools_dir/bin"
# llvm-ar selects ranlib mode from argv[0]. This gives build systems a real
# ranlib frontend even on the Rust toolchain for macOS, which ships only the
# underlying multi-call binary.
ln -s "$llvm_ar" "$tools_dir/bin/llvm-ranlib"
llvm_ranlib="$tools_dir/bin/llvm-ranlib"
extract() {
tar -xf "$source_dir/$1" -C "$source_build_dir"
}
extract meson-1.9.1.tar.gz
extract ninja-1.13.1.tar.gz
extract pkgconf-2.5.1.tar.gz
extract linux-6.18.35.tar.xz
extract musl-1.2.6.tar.gz
extract zlib-1.3.2.tar.gz
extract libarchive-3.8.7.tar.xz
extract llvm-project-22.1.3.src.tar.xz
extract netbsd-curses-0.3.2.tar.gz
extract attr-2.5.2.tar.gz
extract acl-2.3.2.tar.gz
extract libxo-1.7.5.tar.gz
extract tcsh-6.24.16.tar.gz
extract chimerautils-15.0.3.tar.gz
extract openssl-3.5.7.tar.gz
extract util-linux-2.42.2.tar.xz
extract libxcrypt-4.5.2.tar.xz
extract shadow-4.19.4.tar.xz
extract dhcpcd-8b312918d8f1885d7fe8fcc03a7e06ae8a0314b4.tar.gz
extract make-4.4.1.tar.gz
extract cronie-1.7.2.tar.gz
extract openntpd-7.9p1.tar.gz
extract procps-ng-4.0.5.tar.xz
extract iputils-20250605.tar.gz
extract kmod-34.2.tar.xz
extract skalibs-2.15.1.0.tar.gz
extract mdevd-0.1.8.2.tar.gz
extract sysklogd-2.7.2.tar.gz
(
cd "$source_build_dir/ninja-1.13.1"
python3 configure.py --bootstrap
install -m 0755 ninja "$tools_dir/bin/ninja"
)
meson_source="$source_build_dir/meson-1.9.1/meson.py"
PATH="$tools_dir/bin:$PATH"
export PATH
python3 "$meson_source" setup \
"$source_build_dir/pkgconf-pkgconf-2.5.1/build" \
"$source_build_dir/pkgconf-pkgconf-2.5.1" \
--prefix="$tools_dir" \
--buildtype=release \
--default-library=static
python3 "$meson_source" compile -C "$source_build_dir/pkgconf-pkgconf-2.5.1/build"
python3 "$meson_source" install -C "$source_build_dir/pkgconf-pkgconf-2.5.1/build"
musl_cc="$clang --target=x86_64-unknown-linux-musl --ld-path=$lld"
musl_mulxc3="$static_dir/musl-mulxc3.o"
"$clang" \
--target=x86_64-unknown-linux-musl \
--sysroot="$sysroot" \
-fPIC \
-I"$source_build_dir/llvm-project-22.1.3.src/compiler-rt/lib/builtins" \
-c "$source_build_dir/llvm-project-22.1.3.src/compiler-rt/lib/builtins/mulxc3.c" \
-o "$musl_mulxc3"
(
cd "$source_build_dir/musl-1.2.6"
CC="$musl_cc" \
AR="$llvm_ar" \
RANLIB="$llvm_ranlib" \
./configure \
--target=x86_64 \
--prefix=/usr \
--syslibdir=/lib
make -s -j"$jobs" LIBCC="$builtins $musl_mulxc3"
make -s DESTDIR="$sysroot" LIBCC="$builtins $musl_mulxc3" install
)
make -s -C "$source_build_dir/linux-6.18.35" \
ARCH=x86 \
headers_install \
INSTALL_HDR_PATH="$sysroot/usr"
install -d -m 0755 "$sysroot/usr/include/sys"
install -m 0644 "$source_dir/cdefs.h" "$sysroot/usr/include/sys/cdefs.h"
install -m 0644 "$source_dir/queue.h" "$sysroot/usr/include/sys/queue.h"
install -m 0644 "$source_dir/tree.h" "$sysroot/usr/include/sys/tree.h"
install -m 0644 "$source_dir/error.h" "$sysroot/usr/include/error.h"
rust_eh_personality="$static_dir/rust-eh-personality.o"
"$clang" \
--target=x86_64-unknown-linux-musl \
--sysroot="$sysroot" \
-c "$repo_dir/base/support/rust-eh-personality.c" \
-o "$rust_eh_personality"
"$script_dir/configure-cross-toolchain.sh" \
"$cross_tools_dir" \
"$sysroot" \
"$clang" \
"$clangxx" \
"$lld" \
"$builtins" \
"$rust_eh_personality" \
"$llvm_ar" \
"$llvm_strip"
target=x86_64-mouse-linux-musl
cc="$cross_tools_dir/bin/$target-cc"
cxx="$cross_tools_dir/bin/$target-c++"
bootstrap_cxx="$cross_tools_dir/bin/$target-bootstrap-c++"
ar="$cross_tools_dir/bin/$target-ar"
ranlib="$cross_tools_dir/bin/$target-ranlib"
strip="$cross_tools_dir/bin/$target-strip"
llvm_runtimes_build="$source_build_dir/llvm-runtimes-build"
cmake \
-G Ninja \
-S "$source_build_dir/llvm-project-22.1.3.src/runtimes" \
-B "$llvm_runtimes_build" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_C_COMPILER="$cc" \
-DCMAKE_C_COMPILER_TARGET=x86_64-unknown-linux-musl \
-DCMAKE_CXX_COMPILER="$bootstrap_cxx" \
-DCMAKE_CXX_COMPILER_TARGET=x86_64-unknown-linux-musl \
-DCMAKE_AR="$ar" \
-DCMAKE_RANLIB="$ranlib" \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
-DLLVM_ENABLE_RUNTIMES="compiler-rt;libcxx;libcxxabi;libunwind" \
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
-DCOMPILER_RT_BUILD_BUILTINS=ON \
-DCOMPILER_RT_BUILD_CRT=ON \
-DCOMPILER_RT_BUILD_GWP_ASAN=OFF \
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
-DCOMPILER_RT_BUILD_MEMPROF=OFF \
-DCOMPILER_RT_BUILD_ORC=OFF \
-DCOMPILER_RT_BUILD_PROFILE=OFF \
-DCOMPILER_RT_BUILD_SANITIZERS=OFF \
-DCOMPILER_RT_BUILD_XRAY=OFF \
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
-DLIBCXX_ENABLE_SHARED=OFF \
-DLIBCXX_ENABLE_STATIC=ON \
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=OFF \
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF \
-DLIBCXX_INCLUDE_BENCHMARKS=OFF \
-DLIBCXX_INCLUDE_TESTS=OFF \
-DLIBCXX_HAS_MUSL_LIBC=ON \
-DLIBCXXABI_ENABLE_SHARED=OFF \
-DLIBCXXABI_ENABLE_STATIC=ON \
-DLIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL=OFF \
-DLIBCXXABI_INCLUDE_TESTS=OFF \
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
-DLIBUNWIND_ENABLE_SHARED=OFF \
-DLIBUNWIND_ENABLE_STATIC=ON \
-DLIBUNWIND_INCLUDE_TESTS=OFF
cmake --build "$llvm_runtimes_build" -j "$jobs"
DESTDIR="$sysroot" cmake --install "$llvm_runtimes_build"
clang_runtime_dir="$sysroot/usr/lib/clang/22/lib/x86_64-unknown-linux-musl"
install -d -m 0755 "$clang_runtime_dir"
install -m 0644 \
"$sysroot/usr/lib/linux/libclang_rt.builtins-x86_64.a" \
"$clang_runtime_dir/libclang_rt.builtins.a"
for runtime_object in \
clang_rt.crtbegin-x86_64.o \
clang_rt.crtend-x86_64.o
do
install -m 0644 \
"$sysroot/usr/lib/linux/$runtime_object" \
"$clang_runtime_dir/$runtime_object"
done
install -m 0644 \
"$sysroot/usr/lib/linux/clang_rt.crtbegin-x86_64.o" \
"$sysroot/usr/lib/crtbeginT.o"
install -m 0644 \
"$sysroot/usr/lib/linux/clang_rt.crtend-x86_64.o" \
"$sysroot/usr/lib/crtend.o"
{
printf '%s\n' \
'[binaries]' \
"c = '$cc'" \
"cpp = '$cxx'" \
"ar = '$ar'" \
"strip = '$strip'" \
"pkg-config = '$tools_dir/bin/pkgconf'" \
'' \
'[host_machine]' \
"system = 'linux'" \
"cpu_family = 'x86_64'" \
"cpu = 'x86_64'" \
"endian = 'little'" \
'' \
'[built-in options]' \
"c_args = ['-O2']" \
"cpp_args = ['-O2']" \
"c_link_args = ['-static']" \
"cpp_link_args = ['-static']" \
"default_library = 'static'" \
"prefer_static = true"
} >"$cross_file"
+55
View File
@@ -0,0 +1,55 @@
#!/bin/sh
component_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
script_dir=$(dirname "$component_dir")
repo_dir=$(dirname "$script_dir")
build_dir=${MOUSE_BUILD_DIR:-"$repo_dir/build"}
source_dir=${MOUSE_SOURCE_DIR:-"$build_dir/sources"}
static_dir="$build_dir/static"
source_build_dir="$static_dir/src"
sysroot="$static_dir/sysroot"
base_root="$static_dir/rootfs"
tools_dir="$static_dir/tools"
cross_tools_dir="$static_dir/cross-tools"
jobs=${MOUSE_BUILD_JOBS:-$(getconf _NPROCESSORS_ONLN 2>/dev/null || printf '2')}
case "$static_dir" in
"$repo_dir"/build/static) ;;
*)
printf '%s\n' "refusing to clear unexpected static build path: $static_dir" >&2
exit 1
;;
esac
target_libdir=$(rustc --print target-libdir --target x86_64-unknown-linux-musl)
builtins=$(find "$target_libdir" -maxdepth 1 -name 'libcompiler_builtins-*.rlib' -print | head -1)
clang=$(command -v clang)
clangxx=$(command -v clang++)
lld=$(command -v ld.lld)
llvm_ar=$(command -v llvm-ar)
llvm_strip=$(command -v llvm-strip)
build_triplet=$(cc -dumpmachine)
native_cc=cc
for requirement in \
"$clang" "$clangxx" "$lld" "$builtins" "$llvm_ar" "$llvm_strip"
do
if [ ! -f "$requirement" ]; then
printf '%s\n' "missing LLVM/Rust cross-build component: $requirement" >&2
exit 1
fi
done
llvm_ranlib="$tools_dir/bin/llvm-ranlib"
meson_source="$source_build_dir/meson-1.9.1/meson.py"
PATH="$tools_dir/bin:$PATH"
export PATH
target=x86_64-mouse-linux-musl
cc="$cross_tools_dir/bin/$target-cc"
cxx="$cross_tools_dir/bin/$target-c++"
bootstrap_cxx="$cross_tools_dir/bin/$target-bootstrap-c++"
ar="$cross_tools_dir/bin/$target-ar"
ranlib="$cross_tools_dir/bin/$target-ranlib"
strip="$cross_tools_dir/bin/$target-strip"
cross_file="$static_dir/chimerautils.cross"
+125
View File
@@ -0,0 +1,125 @@
#!/bin/sh
set -eu
component_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
. "$component_dir/common.sh"
for runtime_file in \
/lib/ld-musl-x86_64.so.1 \
/usr/lib/libc.so \
/usr/lib/crt1.o \
/usr/lib/Scrt1.o \
/usr/lib/crti.o \
/usr/lib/crtn.o \
/usr/lib/crtbeginT.o \
/usr/lib/crtend.o
do
if [ ! -f "$base_root$runtime_file" ]; then
printf '%s\n' "missing dynamic runtime file: $runtime_file" >&2
exit 1
fi
done
for root in "$sysroot" "$base_root"; do
ln -sf crtbeginT.o "$root/usr/lib/crtbegin.o"
ln -sf crtbeginT.o "$root/usr/lib/crtbeginS.o"
ln -sf crtend.o "$root/usr/lib/crtendS.o"
done
make_dynamic_compiler() {
wrapper=$1
compiler=$2
cat >"$wrapper" <<EOF
#!/bin/sh
set -eu
shared=no
for argument do
if [ "\$argument" = -shared ]; then
shared=yes
break
fi
done
if [ "\$shared" = no ]; then
exec "$compiler" "\$@"
fi
exec "$compiler" \
-nostdlib \
"$sysroot/usr/lib/crti.o" \
"$sysroot/usr/lib/crtbeginS.o" \
-L"$sysroot/usr/lib" \
"\$@" \
"$dynamic_builtins" \
-lc \
"$sysroot/usr/lib/crtendS.o" \
"$sysroot/usr/lib/crtn.o"
EOF
chmod 0755 "$wrapper"
}
dynamic_cc="$cross_tools_dir/bin/x86_64-mouse-linux-musl-dynamic-cc"
dynamic_cxx="$cross_tools_dir/bin/x86_64-mouse-linux-musl-dynamic-c++"
dynamic_builtins="$sysroot/usr/lib/clang/22/lib/x86_64-unknown-linux-musl/libclang_rt.builtins.a"
if [ ! -f "$dynamic_builtins" ]; then
printf '%s\n' "missing compiler-rt builtins: $dynamic_builtins" >&2
exit 1
fi
make_dynamic_compiler "$dynamic_cc" "$cc"
make_dynamic_compiler "$dynamic_cxx" "$bootstrap_cxx"
shared_runtimes_build="$source_build_dir/llvm-shared-runtimes-build"
cmake \
-G Ninja \
-S "$source_build_dir/llvm-project-22.1.3.src/runtimes" \
-B "$shared_runtimes_build" \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_C_COMPILER="$dynamic_cc" \
-DCMAKE_C_COMPILER_TARGET=x86_64-unknown-linux-musl \
-DCMAKE_CXX_COMPILER="$dynamic_cxx" \
-DCMAKE_CXX_COMPILER_TARGET=x86_64-unknown-linux-musl \
-DCMAKE_AR="$ar" \
-DCMAKE_RANLIB="$ranlib" \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF \
-DLIBCXX_ENABLE_SHARED=ON \
-DLIBCXX_ENABLE_STATIC=OFF \
-DLIBCXX_HAS_MUSL_LIBC=ON \
-DLIBCXX_HAS_ATOMIC_LIB=NO \
-DLIBCXX_INCLUDE_BENCHMARKS=OFF \
-DLIBCXX_INCLUDE_TESTS=OFF \
-DLIBCXX_USE_COMPILER_RT=ON \
-DLIBCXXABI_ENABLE_SHARED=ON \
-DLIBCXXABI_ENABLE_STATIC=OFF \
-DLIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL=OFF \
-DLIBCXXABI_INCLUDE_TESTS=OFF \
-DLIBCXXABI_USE_COMPILER_RT=ON \
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
-DLIBUNWIND_ENABLE_SHARED=ON \
-DLIBUNWIND_ENABLE_STATIC=OFF \
-DLIBUNWIND_INCLUDE_TESTS=OFF \
-DLIBUNWIND_USE_COMPILER_RT=ON
cmake --build "$shared_runtimes_build" -j "$jobs"
DESTDIR="$sysroot" cmake --install "$shared_runtimes_build"
cp -R "$sysroot/usr/lib/." "$base_root/usr/lib/"
cat >"$base_root/usr/bin/clang.cfg" <<'EOF'
--target=x86_64-unknown-linux-musl
--sysroot=/
--ld-path=/usr/bin/ld.lld
--rtlib=compiler-rt
--unwindlib=libunwind
EOF
cat >"$base_root/usr/bin/clang++.cfg" <<'EOF'
--target=x86_64-unknown-linux-musl
--sysroot=/
--ld-path=/usr/bin/ld.lld
-stdlib=libc++
--rtlib=compiler-rt
--unwindlib=libunwind
-lc++abi
EOF
+352
View File
@@ -0,0 +1,352 @@
#!/bin/sh
set -eu
component_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
. "$component_dir/common.sh"
extract() {
tar -xf "$source_dir/$1" -C "$source_build_dir"
}
extract less-704.tar.gz
extract mandoc-1.14.6.tar.gz
extract file-5.47.tar.gz
extract gzip-1.14.tar.xz
extract bzip2-1.0.8.tar.gz
extract xz-5.8.3.tar.bz2
extract iproute2-7.1.0.tar.xz
extract libmnl-1.0.5.tar.bz2
extract libnftnl-1.3.1.tar.xz
extract nftables-1.1.6.tar.xz
pkgconfig_path="$sysroot/usr/lib/pkgconfig:$sysroot/usr/share/pkgconfig"
install_man_page() {
page=$1
name=${2:-${page##*/}}
section=${name##*.}
install -d -m 0755 "$base_root/usr/share/man/man$section"
install -m 0644 "$page" "$base_root/usr/share/man/man$section/$name"
}
install_command_man_page() {
tree=$1
command=$2
page=$(find "$tree" -type f -name "$command.[1-9]" -print | head -1)
if [ -n "$page" ]; then
install_man_page "$page"
fi
}
(
cd "$source_build_dir/less-704"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
LIBS="-lcurses -lterminfo" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--sysconfdir=/etc \
--with-regex=posix
make -s -j"$jobs" less lesskey lessecho
install -m 0755 less lesskey lessecho "$base_root/usr/bin/"
)
install_man_page "$source_build_dir/less-704/less.nro" less.1
install_man_page "$source_build_dir/less-704/lesskey.nro" lesskey.1
install_man_page "$source_build_dir/less-704/lessecho.nro" lessecho.1
(
cd "$source_build_dir/bzip2-1.0.8"
make -s -j"$jobs" \
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
CFLAGS="-O2" \
LDFLAGS="-static" \
bzip2 bzip2recover libbz2.a
install -m 0644 bzlib.h "$sysroot/usr/include/bzlib.h"
install -m 0644 libbz2.a "$sysroot/usr/lib/libbz2.a"
install -m 0755 bzip2 bzip2recover "$base_root/usr/bin/"
)
ln -s bzip2 "$base_root/usr/bin/bunzip2"
ln -s bzip2 "$base_root/usr/bin/bzcat"
for page in bzip2.1 bzgrep.1 bzmore.1 bzdiff.1; do
install_man_page "$source_build_dir/bzip2-1.0.8/$page"
done
(
cd "$source_build_dir/xz-5.8.3"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-shared \
--enable-static \
--disable-nls \
--disable-doc \
--disable-xzdec \
--disable-lzmadec \
--disable-lzmainfo
make -s -j"$jobs" -C src/liblzma
make -s -C src/liblzma DESTDIR="$sysroot" install
make -s -j"$jobs" -C src/xz xz
install -m 0755 src/xz/xz "$base_root/usr/bin/xz"
)
for command in unxz xzcat lzma unlzma lzcat; do
ln -s xz "$base_root/usr/bin/$command"
done
for page in xz.1; do
install_man_page "$source_build_dir/xz-5.8.3/src/xz/$page"
done
(
cd "$source_build_dir/gzip-1.14"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
gl_cv_func_getcwd_path_max=yes \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-nls
make -s -j"$jobs"
install -m 0755 gzip "$base_root/usr/bin/gzip"
for script in gunzip zcat zcmp zdiff zgrep zless zmore; do
install -m 0755 "$script" "$base_root/usr/bin/$script"
done
)
for page in gzip.1 gunzip.1 zcat.1 zcmp.1 zdiff.1 zgrep.1 zless.1 zmore.1; do
install_man_page "$source_build_dir/gzip-1.14/$page"
done
(
cd "$source_build_dir/file-5.47"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
PKG_CONFIG="$tools_dir/bin/pkgconf" \
PKG_CONFIG_LIBDIR="$pkgconfig_path" \
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-shared \
--enable-static \
--disable-zstdlib \
--disable-lzlib \
--disable-libseccomp
make -s -C src magic.h
make -s -j"$jobs" -C src file
make -s -C magic magic.mgc
install -m 0755 src/file "$base_root/usr/bin/file"
install -d -m 0755 "$base_root/usr/share/misc"
install -m 0644 magic/magic.mgc "$base_root/usr/share/misc/magic.mgc"
)
install_man_page "$source_build_dir/file-5.47/doc/file.man" file.1
install_man_page "$source_build_dir/file-5.47/doc/magic.man" magic.5
unzip_source="$source_build_dir/libarchive-unzip-3.8.7"
install -d -m 0755 "$unzip_source"
tar -xf "$source_dir/libarchive-3.8.7.tar.xz" \
-C "$unzip_source" \
--strip-components=1
(
cd "$unzip_source"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
PKG_CONFIG="$tools_dir/bin/pkgconf" \
PKG_CONFIG_LIBDIR="$pkgconfig_path" \
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-shared \
--enable-static \
--disable-bsdtar \
--disable-bsdcat \
--disable-bsdcpio \
--enable-bsdunzip=static \
--disable-acl \
--disable-xattr \
--without-libb2 \
--without-iconv \
--without-lz4 \
--without-zstd \
--without-xml2 \
--without-expat \
--without-openssl \
--without-cng
make -s -j"$jobs" bsdunzip
install -m 0755 bsdunzip "$base_root/usr/bin/unzip"
)
install_man_page "$unzip_source/unzip/bsdunzip.1" unzip.1
mandoc_source="$source_build_dir/mandoc-1.14.6"
cat >"$mandoc_source/configure.local" <<EOF
CC="$cc"
AR="$ar"
CFLAGS="-O2"
LDFLAGS="-static"
STATIC="-static"
PREFIX="/usr"
BINDIR="/usr/bin"
SBINDIR="/usr/sbin"
MANDIR="/usr/share/man"
MANPATH_BASE="/usr/share/man:/usr/local/man"
MANPATH_DEFAULT="/usr/share/man:/usr/local/man"
OSENUM=MANDOC_OS_OTHER
OSNAME="MOUSE"
BINM_PAGER="less"
LN="ln -sf"
EOF
(
cd "$mandoc_source"
./configure
make -s -j"$jobs"
make -s DESTDIR="$base_root" base-install
)
iproute_source="$source_build_dir/iproute2-7.1.0"
(
cd "$iproute_source"
CC="$cc" \
AR="$ar" \
YACC=byacc \
PKG_CONFIG="$tools_dir/bin/pkgconf" \
PKG_CONFIG_LIBDIR="$pkgconfig_path" \
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
sh ./configure
# Enter component directories through the top-level makefile. It defines
# and exports iproute2's path constants, feature macros, and UAPI includes;
# invoking the sub-makes directly silently drops them.
make -s -j"$jobs" \
CC="$cc" \
AR="$ar" \
YACC=byacc \
SHARED_LIBS=n \
LDFLAGS="-static" \
SUBDIRS=lib
make -s -j"$jobs" \
CC="$cc" \
AR="$ar" \
YACC=byacc \
SHARED_LIBS=n \
LDFLAGS="-static" \
SUBDIRS="ip tc bridge misc"
for target in ip/ip tc/tc bridge/bridge misc/ss; do
install -m 0755 "$target" "$base_root/sbin/${target##*/}"
done
)
for command in ip tc bridge ss; do
install_command_man_page "$iproute_source/man" "$command"
done
(
cd "$source_build_dir/libmnl-1.0.5"
CC="$cc" AR="$ar" RANLIB="$ranlib" ./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-shared \
--enable-static
make -s -j"$jobs"
make -s DESTDIR="$sysroot" install
)
(
cd "$source_build_dir/libnftnl-1.3.1"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
PKG_CONFIG="$tools_dir/bin/pkgconf" \
PKG_CONFIG_LIBDIR="$pkgconfig_path" \
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-shared \
--enable-static
make -s -j"$jobs"
make -s DESTDIR="$sysroot" install
)
# These are static-only cross-build dependencies. Libtool archives retain the
# target's /usr/lib prefix and make nftables' host libtool look outside the
# sysroot; the real .a archives and pkg-config metadata are sufficient.
rm -f "$sysroot/usr/lib/libmnl.la" "$sysroot/usr/lib/libnftnl.la"
(
cd "$source_build_dir/nftables-1.1.6"
patch -p1 <"$repo_dir/base/patches/nftables-posix-configure.patch"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
YACC=byacc \
PKG_CONFIG="$tools_dir/bin/pkgconf" \
PKG_CONFIG_LIBDIR="$pkgconfig_path" \
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--sbindir=/sbin \
--disable-shared \
--enable-static \
--disable-man-doc \
--with-mini-gmp \
--without-cli \
--without-xtables \
--without-json \
--without-unitdir
make -s -j"$jobs" src/nft
install -m 0755 src/nft "$base_root/sbin/nft"
)
install_man_page "$source_build_dir/nftables-1.1.6/doc/nft.8"
for command in \
blkid dmesg fdisk findmnt flock losetup lsblk mount sfdisk swapoff swapon umount wipefs
do
install_command_man_page "$source_build_dir/util-linux-2.42.2" "$command"
done
for command in free pgrep pkill ps sysctl top uptime vmstat watch; do
install_command_man_page "$source_build_dir/procps-ng-4.0.5" "$command"
done
install_command_man_page "$source_build_dir/iputils-20250605" ping
while IFS= read -r page; do
filename=${page##*/}
command=${filename%.*}
if [ -x "$base_root/bin/$command" ] ||
[ -x "$base_root/sbin/$command" ] ||
[ -x "$base_root/usr/bin/$command" ] ||
[ -x "$base_root/usr/sbin/$command" ]
then
install_man_page "$page"
fi
done <<EOF
$(find "$source_build_dir/chimerautils-15.0.3" -type f -name '*.[1-9]' -print | LC_ALL=C sort)
EOF
host_mandoc_source="$static_dir/host-mandoc-1.14.6"
install -d -m 0755 "$host_mandoc_source"
tar -xf "$source_dir/mandoc-1.14.6.tar.gz" \
-C "$host_mandoc_source" \
--strip-components=1
cat >"$host_mandoc_source/configure.local" <<EOF
CC="$native_cc"
PREFIX="$tools_dir/mandoc-host"
EOF
(
cd "$host_mandoc_source"
./configure
make -s -j"$jobs" mandoc
install -d -m 0755 "$tools_dir/mandoc-host"
install -m 0755 mandoc "$tools_dir/mandoc-host/makewhatis"
)
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
set -eu
component_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
. "$component_dir/common.sh"
printf '%s\n' '#!/bin/sh' 'exec /usr/bin/tput clear' >"$base_root/usr/bin/clear"
chmod 0755 "$base_root/usr/bin/clear"
printf '%s\n' "$base_root"
@@ -0,0 +1,263 @@
#!/bin/sh
set -eu
component_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
. "$component_dir/common.sh"
(
cd "$source_build_dir/zlib-1.3.2"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
./configure \
--prefix=/usr \
--static
make -s -j"$jobs"
make -s DESTDIR="$sysroot" install
)
(
cd "$source_build_dir/libarchive-3.8.7"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
CPPFLAGS="-I$sysroot/usr/include" \
LDFLAGS="-L$sysroot/usr/lib" \
PKG_CONFIG="$tools_dir/bin/pkgconf" \
PKG_CONFIG_LIBDIR="$sysroot/usr/lib/pkgconfig" \
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-shared \
--enable-static \
--enable-bsdtar=static \
--disable-bsdcat \
--disable-bsdcpio \
--disable-bsdunzip \
--disable-acl \
--disable-xattr \
--without-bz2lib \
--without-libb2 \
--without-iconv \
--without-lz4 \
--without-lzma \
--without-zstd \
--without-xml2 \
--without-expat \
--without-openssl \
--without-cng
make -s -j"$jobs" bsdtar
install -m 0755 bsdtar "$base_root/usr/bin/tar"
)
(
cd "$source_build_dir/openssl-3.5.7"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
./Configure \
linux-x86_64 \
--prefix=/usr \
--libdir=lib \
--openssldir=/etc/ssl \
no-afalgeng \
no-apps \
no-docs \
no-dso \
no-module \
no-secure-memory \
no-shared \
no-tests
make -s -j"$jobs" build_libs
make -s DESTDIR="$sysroot" install_sw
)
install -d -m 0755 "$base_root/etc/ssl"
install -m 0644 \
"$source_dir/cacert-2026-07-16.pem" \
"$base_root/etc/ssl/cert.pem"
(
cd "$source_build_dir/libxcrypt-4.5.2"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-shared \
--enable-static \
--disable-obsolete-api \
--disable-symvers \
--enable-hashes=sha512crypt
make -s -j"$jobs"
make -s DESTDIR="$sysroot" install
)
(
cd "$source_build_dir/shadow-4.19.4"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
PKG_CONFIG="$tools_dir/bin/pkgconf" \
PKG_CONFIG_LIBDIR="$sysroot/usr/lib/pkgconfig" \
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-shared \
--enable-static \
--disable-logind \
--disable-nls \
--disable-shadowgrp \
--without-audit \
--without-libpam \
--without-selinux \
--without-acl \
--without-attr \
--without-libbsd \
--without-skey \
--without-tcb \
--without-nscd
make -s -j"$jobs" -C lib
shadow_commands="
groupadd groupdel groupmod login passwd su
useradd userdel usermod
"
MOUSE_CROSS_EXTRA_STATIC_LIBS="$sysroot/usr/lib/libcrypt.a" \
make -s -j"$jobs" -C src $shadow_commands
for command in $shadow_commands; do
mode=0755
destination="$base_root/usr/sbin"
case "$command" in
login) destination="$base_root/bin" ;;
passwd)
mode=4755
destination="$base_root/usr/bin"
;;
su)
mode=4755
destination="$base_root/bin"
;;
esac
install -m "$mode" "src/$command" "$destination/$command"
done
)
(
cd "$source_build_dir/dhcpcd-8b312918d8f1885d7fe8fcc03a7e06ae8a0314b4"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
./configure \
--os=linux \
--target=x86_64-linux-musl \
--prefix=/usr \
--sbindir=/usr/bin \
--sysconfdir=/etc \
--libexecdir=/usr/libexec \
--dbdir=/var/lib/dhcpcd \
--rundir=/run \
--enable-static \
--disable-ipv6 \
--disable-auth \
--enable-privsep \
--privsepuser=dhcpcd \
--disable-ntp \
--without-udev \
--without-libpcap \
--without-openssl \
--with-hooks=
make -s -j"$jobs" -C src
install -m 0755 src/dhcpcd "$base_root/sbin/dhcpcd"
)
(
cd "$source_build_dir/netbsd-curses-0.3.2"
make -s -f GNUmakefile -j"$jobs" \
CC="$cc" \
HOSTCC="$native_cc" \
AR="$ar" \
RANLIB="$ranlib" \
CFLAGS="-O2" \
CPPFLAGS="-I. -I./libterminfo -DTERMINFO_COMPILE -DTERMINFO_DB -DTERMINFO_COMPAT" \
LDFLAGS="-static" \
PREFIX=/usr \
all-static
make -s -f GNUmakefile \
CC="$cc" \
HOSTCC="$native_cc" \
AR="$ar" \
RANLIB="$ranlib" \
CFLAGS="-O2" \
CPPFLAGS="-I. -I./libterminfo -DTERMINFO_COMPILE -DTERMINFO_DB -DTERMINFO_COMPAT" \
LDFLAGS="-static" \
PREFIX=/usr \
DESTDIR="$sysroot" \
install-static
)
build_autoconf_library() {
source_name=$1
build_target=$2
shift 2
(
cd "$source_build_dir/$source_name"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
PKG_CONFIG="$tools_dir/bin/pkgconf" \
PKG_CONFIG_LIBDIR="$sysroot/usr/lib/pkgconfig" \
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-shared \
--enable-static \
"$@"
make -s -j"$jobs" "$build_target"
make -s DESTDIR="$sysroot" \
install-libLTLIBRARIES \
install-data-local \
install-pkgconfDATA
)
}
build_autoconf_library attr-2.5.2 libattr.la
build_autoconf_library acl-2.3.2 libacl.la
# The projects' install-time EXPORT substitution uses a GNU sed word-boundary
# extension which macOS sed accepts but does not apply. Normalize the installed
# public declarations for consumers of the cross-built static libraries.
find "$sysroot/usr/include/attr" "$sysroot/usr/include/acl" \
"$sysroot/usr/include/sys/acl.h" \
-type f -exec perl -pi -e 's/\bEXPORT\b/extern/g' {} +
(
cd "$source_build_dir/libxo-1.7.5"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
ac_cv_func_malloc_0_nonnull=yes \
ac_cv_func_realloc_0_nonnull=yes \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-shared \
--enable-static \
--disable-libxo-options \
--disable-gettext \
--enable-text-only
make -s -C libxo -j"$jobs" libxo.la
make -s -C libxo DESTDIR="$sysroot" \
install-libLTLIBRARIES \
install-libxoincHEADERS
make -s DESTDIR="$sysroot" install-pkgconfigDATA
)
+159
View File
@@ -0,0 +1,159 @@
#!/bin/sh
set -eu
component_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
. "$component_dir/common.sh"
build_llvm() {
llvm_host_build="$source_build_dir/llvm-host-tools-build"
cmake \
-G Ninja \
-S "$source_build_dir/llvm-project-22.1.3.src/llvm" \
-B "$llvm_host_build" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER="$native_cc" \
-DCMAKE_CXX_COMPILER=c++ \
-DLLVM_ENABLE_PROJECTS=clang \
-DLLVM_TARGETS_TO_BUILD=X86 \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DCLANG_INCLUDE_TESTS=OFF
cmake --build "$llvm_host_build" -j "$jobs" \
--target llvm-tblgen clang-tblgen
llvm_target_build="$source_build_dir/llvm-target-build"
llvm_target_install="$static_dir/llvm-target-install"
cmake \
-G Ninja \
-S "$source_build_dir/llvm-project-22.1.3.src/llvm" \
-B "$llvm_target_build" \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_C_COMPILER="$cc" \
-DCMAKE_CXX_COMPILER="$cxx" \
-DCMAKE_AR="$ar" \
-DCMAKE_RANLIB="$ranlib" \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=x86_64 \
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
-DLLVM_TABLEGEN="$llvm_host_build/bin/llvm-tblgen" \
-DCLANG_TABLEGEN="$llvm_host_build/bin/clang-tblgen" \
-DLLVM_ENABLE_PROJECTS="clang;lld" \
-DLLVM_TARGETS_TO_BUILD=X86 \
-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-linux-musl \
-DLLVM_HOST_TRIPLE=x86_64-unknown-linux-musl \
-DLLVM_ENABLE_BINDINGS=OFF \
-DLLVM_ENABLE_FFI=OFF \
-DLLVM_ENABLE_LIBEDIT=OFF \
-DLLVM_ENABLE_LIBXML2=OFF \
-DLLVM_ENABLE_PIC=OFF \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_ZLIB=OFF \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_UTILS=ON \
-DCLANG_ENABLE_ARCMT=OFF \
-DCLANG_ENABLE_STATIC_ANALYZER=OFF \
-DCLANG_INCLUDE_TESTS=OFF \
-DLLVM_DISTRIBUTION_COMPONENTS="clang;clang-resource-headers;lld;llvm-ar;llvm-nm;llvm-objdump;llvm-readelf;llvm-size;llvm-strings;llvm-strip"
DESTDIR="$llvm_target_install" \
cmake --build "$llvm_target_build" -j "$jobs" \
--target install-distribution
cp -R "$sysroot/usr/include" "$base_root/usr/"
cp -R "$sysroot/usr/lib/." "$base_root/usr/lib/"
cp -R "$sysroot/lib" "$base_root/"
cp -R "$llvm_target_install/usr/." "$base_root/usr/"
}
build_package_tools() {
pkgconf_target_build="$source_build_dir/pkgconf-pkgconf-2.5.1/build-target"
python3 "$meson_source" setup \
"$pkgconf_target_build" \
"$source_build_dir/pkgconf-pkgconf-2.5.1" \
--cross-file="$cross_file" \
--prefix=/usr \
--buildtype=release \
--default-library=static
python3 "$meson_source" compile -C "$pkgconf_target_build"
DESTDIR="$base_root" \
python3 "$meson_source" install -C "$pkgconf_target_build"
ln -s pkgconf "$base_root/usr/bin/pkg-config"
(
cd "$source_build_dir/make-4.4.1"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-load \
--disable-nls \
--without-guile
make -j"$jobs"
make DESTDIR="$base_root" install
)
ln -s make "$base_root/usr/bin/gmake"
ln -s clang "$base_root/usr/bin/cc"
ln -s clang++ "$base_root/usr/bin/c++"
ln -s ld.lld "$base_root/usr/bin/ld"
ln -s llvm-ar "$base_root/usr/bin/ar"
ln -s llvm-nm "$base_root/usr/bin/nm"
ln -s llvm-objdump "$base_root/usr/bin/objdump"
ln -s llvm-readelf "$base_root/usr/bin/readelf"
ln -s llvm-ar "$base_root/usr/bin/llvm-ranlib"
cat >"$base_root/usr/bin/ranlib" <<'EOF'
#!/bin/sh
set -eu
# BSD ranlib accepts -t to refresh an existing archive index. LLVM's ranlib
# does not expose that option, but rebuilding the index is equivalent for the
# package build that requested it.
if [ "${1-}" = "-t" ]; then
shift
fi
exec /usr/bin/llvm-ranlib "$@"
EOF
chmod 0755 "$base_root/usr/bin/ranlib"
ln -s llvm-strip "$base_root/usr/bin/strip"
ln -s ../../lib/ld-musl-x86_64.so.1 "$base_root/usr/bin/ldd"
cat >"$base_root/usr/bin/clang.cfg" <<'EOF'
--target=x86_64-unknown-linux-musl
--sysroot=/
--ld-path=/usr/bin/ld.lld
--rtlib=compiler-rt
--unwindlib=libunwind
-static
EOF
cat >"$base_root/usr/bin/clang++.cfg" <<'EOF'
--target=x86_64-unknown-linux-musl
--sysroot=/
--ld-path=/usr/bin/ld.lld
-stdlib=libc++
--rtlib=compiler-rt
--unwindlib=libunwind
-lc++abi
-static
EOF
}
case "${MOUSE_NATIVE_TOOLCHAIN_PHASE:-all}" in
llvm) build_llvm ;;
package-tools) build_package_tools ;;
all)
build_llvm
build_package_tools
;;
*)
printf '%s\n' "invalid MOUSE_NATIVE_TOOLCHAIN_PHASE" >&2
exit 2
;;
esac
+107
View File
@@ -0,0 +1,107 @@
#!/bin/sh
set -eu
component_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
. "$component_dir/common.sh"
extract() {
tar -xf "$source_dir/$1" -C "$source_build_dir"
}
extract btrfs-progs-v7.0.tar.xz
extract zstd-1.5.7.tar.gz
install -d -m 0755 \
"$sysroot/usr/include" \
"$sysroot/usr/lib" \
"$sysroot/usr/lib/pkgconfig"
make -s -C "$source_build_dir/zstd-1.5.7/lib" -j"$jobs" \
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
libzstd.a
make -s -C "$source_build_dir/zstd-1.5.7/lib" \
PREFIX=/usr \
LIBDIR=/usr/lib \
PKGCONFIGDIR=/usr/lib/pkgconfig \
DESTDIR="$sysroot" \
install-static install-includes install-pc
make -s -C "$source_build_dir/zstd-1.5.7/programs" -j"$jobs" \
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
LDFLAGS="-static" \
ZSTD_LEGACY_SUPPORT=0 \
ZSTD_MULTITHREAD=0 \
zstd-release
install -m 0755 \
"$source_build_dir/zstd-1.5.7/programs/zstd" \
"$base_root/usr/bin/zstd"
ln -s zstd "$base_root/usr/bin/unzstd"
ln -s zstd "$base_root/usr/bin/zstdcat"
install -d -m 0755 "$base_root/usr/share/man/man1"
install -m 0644 \
"$source_build_dir/zstd-1.5.7/programs/zstd.1" \
"$base_root/usr/share/man/man1/zstd.1"
(
cd "$source_build_dir/util-linux-2.42.2"
CC="$cc" \
CXX="$cxx" \
AR="$ar" \
RANLIB="$ranlib" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-all-programs \
--enable-libblkid \
--enable-libuuid \
--disable-shared \
--enable-static
make -s -j"$jobs"
make -s DESTDIR="$sysroot" install
)
btrfs_source="$source_build_dir/btrfs-progs-v7.0"
pkgconfig_path="$sysroot/usr/lib/pkgconfig:$sysroot/usr/share/pkgconfig"
compiler_rt="$sysroot/usr/lib/clang/22/lib/x86_64-unknown-linux-musl/libclang_rt.builtins.a"
(
cd "$btrfs_source"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
CFLAGS="-O2" \
LDFLAGS="-static" \
ac_cv_func_malloc_0_nonnull=yes \
ac_cv_func_realloc_0_nonnull=yes \
PKG_CONFIG="$tools_dir/bin/pkgconf" \
PKG_CONFIG_ALL_STATIC=1 \
PKG_CONFIG_LIBDIR="$pkgconfig_path" \
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-backtrace \
--disable-documentation \
--disable-shared \
--enable-static \
--disable-convert \
--disable-lzo \
--disable-libudev \
--disable-python \
--disable-zoned \
--with-crypto=builtin
MOUSE_CROSS_EXTRA_STATIC_LIBS="$compiler_rt" \
make -s -j"$jobs" btrfs.static mkfs.btrfs.static
"$strip" btrfs.static mkfs.btrfs.static
install -m 0755 btrfs.static "$base_root/sbin/btrfs"
install -m 0755 mkfs.btrfs.static "$base_root/sbin/mkfs.btrfs"
)
ln -s btrfs "$base_root/sbin/btrfsck"
"$tools_dir/mandoc-host/makewhatis" "$base_root/usr/share/man"
+489
View File
@@ -0,0 +1,489 @@
#!/bin/sh
set -eu
component_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
. "$component_dir/common.sh"
patch -d "$source_build_dir/tcsh-TCSH6_24_16" -p1 \
<"$repo_dir/base/patches/tcsh-gethost-native.patch"
patch -d "$source_build_dir/chimerautils-15.0.3" -p1 \
<"$repo_dir/base/patches/chimerautils-native-cdefs.patch"
patch -d "$source_build_dir/chimerautils-15.0.3" -p1 \
<"$repo_dir/base/patches/chimerautils-scanflike.patch"
(
cd "$source_build_dir/tcsh-TCSH6_24_16"
CC="$cc" \
LIBS="-lcurses -lterminfo" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--bindir=/bin \
--disable-nls-catalogs
make -j"$jobs"
install -m 0755 tcsh "$base_root/bin/tcsh"
)
util_linux_build="$source_build_dir/util-linux-build"
install -d -m 0755 "$util_linux_build"
(
cd "$util_linux_build"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
CFLAGS="-O2" \
LDFLAGS="-static" \
PKG_CONFIG="$tools_dir/bin/pkgconf" \
PKG_CONFIG_LIBDIR="$sysroot/usr/lib/pkgconfig:$sysroot/usr/share/pkgconfig" \
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
"$source_build_dir/util-linux-2.42.2/configure" \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-shared \
--enable-static \
--disable-nls \
--disable-all-programs \
--enable-libuuid \
--enable-libblkid \
--enable-libmount \
--enable-libsmartcols \
--enable-libfdisk \
--enable-agetty \
--enable-nologin \
--enable-setsid \
--enable-mount \
--enable-blkid \
--enable-fdisks \
--enable-losetup \
--enable-wipefs \
--enable-swapon \
--enable-lsblk \
--enable-findmnt \
--enable-flock \
--enable-dmesg \
--enable-static-programs=blkid,fdisk,losetup,mount,sfdisk,umount
make -s -j"$jobs" \
agetty nologin setsid mount umount blkid fdisk sfdisk losetup \
wipefs swapon swapoff lsblk findmnt flock dmesg
)
install_util_linux() {
command=$1
destination=$2
binary=$(find "$util_linux_build" -type f -name "$command" -perm -0100 -print | head -1)
if [ -z "$binary" ]; then
printf '%s\n' "missing util-linux build output: $command" >&2
exit 1
fi
install -m 0755 "$binary" "$destination"
}
install_util_linux agetty "$base_root/sbin/agetty"
install_util_linux nologin "$base_root/sbin/nologin"
install_util_linux setsid "$base_root/usr/bin/setsid"
install_util_linux mount "$base_root/sbin/mount"
install_util_linux umount "$base_root/sbin/umount"
install_util_linux blkid "$base_root/sbin/blkid"
install_util_linux fdisk "$base_root/sbin/fdisk"
install_util_linux sfdisk "$base_root/sbin/sfdisk"
install_util_linux losetup "$base_root/sbin/losetup"
install_util_linux wipefs "$base_root/sbin/wipefs"
install_util_linux swapon "$base_root/sbin/swapon"
install_util_linux swapoff "$base_root/sbin/swapoff"
install_util_linux lsblk "$base_root/usr/bin/lsblk"
install_util_linux findmnt "$base_root/usr/bin/findmnt"
install_util_linux flock "$base_root/usr/bin/flock"
install_util_linux dmesg "$base_root/sbin/dmesg"
chimerautils_build="$source_build_dir/chimerautils-15.0.3/build"
PKG_CONFIG_LIBDIR="$sysroot/usr/lib/pkgconfig:$sysroot/usr/share/pkgconfig" \
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
python3 "$meson_source" setup \
"$chimerautils_build" \
"$source_build_dir/chimerautils-15.0.3" \
--cross-file="$cross_file" \
--prefix=/usr \
--buildtype=release \
-Dopenssl=enabled \
-Dlibedit=disabled \
-Dzlib=disabled \
-Dlzma=disabled \
-Dbzip2=disabled \
-Dzstd=disabled \
-Dpam=disabled \
-Dselinux=disabled \
-Dchimera_realpath=disabled
commands="
awk basename cat chmod chown chroot cksum cmp col colrm column comm
cp csplit cut date dd df diff diff3 dirname du echo env expand expr false
ed fetch find fmt fold gencat getopt grep head hexdump hostname id join kill
ln logger logname ls m4 md5 mesg mkdir mkfifo mknod mktemp mv nc nice nl nohup
nproc paste patch pathchk pr printenv printf pwd realpath renice rev rm rmdir script
sdiff sed seq sh sleep sort split stat stty sync tail tee time timeout touch tr true
truncate tsort tty ul uname unexpand uniq users vis wc whereis which who xargs yes
vi
"
targets="
src.freebsd/awk/awk
src.freebsd/coreutils/basename/basename
src.freebsd/coreutils/cat/cat
src.freebsd/coreutils/chmod/chmod
src.freebsd/coreutils/chown/chown
src.freebsd/coreutils/chroot/chroot
src.freebsd/coreutils/cksum/cksum
src.freebsd/diffutils/cmp/cmp
src.freebsd/miscutils/col/col
src.freebsd/miscutils/colrm/colrm
src.freebsd/miscutils/column/column
src.freebsd/coreutils/comm/comm
src.freebsd/coreutils/cp/cp
src.freebsd/coreutils/csplit/csplit
src.freebsd/coreutils/cut/cut
src.freebsd/coreutils/date/date
src.freebsd/coreutils/dd/dd
src.freebsd/coreutils/df/df
src.freebsd/diffutils/diff/diff
src.freebsd/diffutils/diff3/diff3
src.freebsd/coreutils/dirname/dirname
src.freebsd/coreutils/du/du
src.freebsd/ed/ed
src.freebsd/coreutils/echo/echo
src.freebsd/coreutils/env/env
src.freebsd/coreutils/expand/expand
src.freebsd/coreutils/expr/expr
src.freebsd/coreutils/false/false
src.freebsd/fetch/fetch
src.freebsd/findutils/find/find
src.freebsd/coreutils/fmt/fmt
src.freebsd/coreutils/fold/fold
src.freebsd/gencat/gencat
src.freebsd/miscutils/getopt/getopt
src.freebsd/grep/grep
src.freebsd/coreutils/head/head
src.freebsd/miscutils/hexdump/hexdump
src.freebsd/coreutils/hostname/hostname
src.freebsd/coreutils/id/id
src.freebsd/coreutils/join/join
src.freebsd/miscutils/kill/kill
src.freebsd/coreutils/ln/ln
src.freebsd/miscutils/logger/logger
src.freebsd/coreutils/logname/logname
src.freebsd/coreutils/ls/ls
src.freebsd/m4/m4
src.freebsd/coreutils/md5/md5
src.freebsd/miscutils/mesg/mesg
src.freebsd/coreutils/mkdir/mkdir
src.freebsd/coreutils/mkfifo/mkfifo
src.freebsd/coreutils/mknod/mknod
src.freebsd/coreutils/mktemp/mktemp
src.freebsd/coreutils/mv/mv
src.freebsd/netcat/nc
src.freebsd/coreutils/nice/nice
src.freebsd/coreutils/nl/nl
src.freebsd/coreutils/nohup/nohup
src.freebsd/coreutils/nproc/nproc
src.freebsd/nvi/vi
src.freebsd/coreutils/paste/paste
src.freebsd/patch/patch
src.freebsd/coreutils/pathchk/pathchk
src.freebsd/coreutils/pr/pr
src.freebsd/coreutils/printenv/printenv
src.freebsd/coreutils/printf/printf
src.freebsd/coreutils/pwd/pwd
src.freebsd/coreutils/realpath/realpath
src.freebsd/miscutils/renice/renice
src.freebsd/miscutils/rev/rev
src.freebsd/coreutils/rm/rm
src.freebsd/coreutils/rmdir/rmdir
src.freebsd/miscutils/script/script
src.freebsd/diffutils/sdiff/sdiff
src.freebsd/sed/sed
src.freebsd/coreutils/seq/seq
src.freebsd/sh/sh
src.freebsd/coreutils/sleep/sleep
src.freebsd/coreutils/sort/sort
src.freebsd/coreutils/split/split
src.freebsd/coreutils/stat/stat
src.freebsd/coreutils/stty/stty
src.freebsd/coreutils/sync/sync
src.freebsd/coreutils/tail/tail
src.freebsd/coreutils/tee/tee
src.freebsd/miscutils/time/time
src.freebsd/coreutils/timeout/timeout
src.freebsd/coreutils/touch/touch
src.freebsd/coreutils/tr/tr
src.freebsd/coreutils/true/true
src.freebsd/coreutils/truncate/truncate
src.freebsd/coreutils/tsort/tsort
src.freebsd/coreutils/tty/tty
src.freebsd/miscutils/ul/ul
src.freebsd/coreutils/uname/uname
src.freebsd/coreutils/unexpand/unexpand
src.freebsd/coreutils/uniq/uniq
src.freebsd/coreutils/users/users
src.freebsd/vis/vis
src.freebsd/coreutils/wc/wc
src.freebsd/miscutils/whereis/whereis
src.freebsd/which/which
src.freebsd/coreutils/who/who
src.freebsd/findutils/xargs/xargs
src.freebsd/coreutils/yes/yes
src.freebsd/coreutils/xinstall/xinstall
src.freebsd/coreutils/test/xtest
"
PKG_CONFIG_LIBDIR="$sysroot/usr/lib/pkgconfig:$sysroot/usr/share/pkgconfig" \
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
python3 "$meson_source" compile -C "$chimerautils_build" $targets
for command in $commands; do
binary=$(find "$chimerautils_build" -type f -name "$command" -perm -0100 -print | head -1)
if [ -z "$binary" ]; then
printf '%s\n' "missing ChimeraUtils build output: $command" >&2
exit 1
fi
destination="$base_root/usr/bin"
case "$command" in
cat|chmod|chown|cp|date|dd|df|echo|hostname|kill|ln|ls|mkdir|mv|pwd|rm|rmdir|sed|sh|sleep|stty|sync|touch|uname)
destination="$base_root/bin"
;;
esac
install -m 0755 "$binary" "$destination/$command"
done
ln -s chown "$base_root/bin/chgrp"
ln -s vi "$base_root/usr/bin/nvi"
ln -s vi "$base_root/usr/bin/view"
(
cd "$source_build_dir/procps-ng-4.0.5"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
ac_cv_func_malloc_0_nonnull=yes \
ac_cv_func_realloc_0_nonnull=yes \
LDFLAGS="-static" \
PKG_CONFIG="$tools_dir/bin/pkgconf" \
PKG_CONFIG_LIBDIR="$sysroot/usr/lib/pkgconfig" \
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--disable-shared \
--enable-static \
--disable-nls \
--disable-pidof \
--disable-pidwait \
--disable-kill \
--disable-w \
--disable-numa \
--without-systemd \
--without-elogind
make -s -j"$jobs" \
src/ps/pscommand \
src/pgrep \
src/pkill \
src/top/top \
src/free \
src/uptime \
src/vmstat \
src/watch \
src/sysctl
install -m 0755 src/ps/pscommand "$base_root/bin/ps"
install -m 0755 src/pgrep "$base_root/usr/bin/pgrep"
install -m 0755 src/pkill "$base_root/usr/bin/pkill"
install -m 0755 src/top/top "$base_root/usr/bin/top"
install -m 0755 src/free "$base_root/usr/bin/free"
install -m 0755 src/uptime "$base_root/usr/bin/uptime"
install -m 0755 src/vmstat "$base_root/usr/bin/vmstat"
install -m 0755 src/watch "$base_root/usr/bin/watch"
install -m 0755 src/sysctl "$base_root/sbin/sysctl"
)
iputils_build="$source_build_dir/iputils-20250605/build"
PKG_CONFIG_LIBDIR="$sysroot/usr/lib/pkgconfig:$sysroot/usr/share/pkgconfig" \
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
python3 "$meson_source" setup \
"$iputils_build" \
"$source_build_dir/iputils-20250605" \
--cross-file="$cross_file" \
--prefix=/usr \
--buildtype=release \
--default-library=static \
-DUSE_CAP=false \
-DUSE_IDN=false \
-DUSE_GETTEXT=false \
-DBUILD_ARPING=false \
-DBUILD_CLOCKDIFF=false \
-DBUILD_TRACEPATH=false \
-DBUILD_MANS=false \
-DSKIP_TESTS=true
python3 "$meson_source" compile -C "$iputils_build" ping
install -m 4755 "$iputils_build/ping/ping" "$base_root/bin/ping"
(
cd "$source_build_dir/cronie-1.7.2"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
LDFLAGS="-static" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--runstatedir=/run \
--disable-anacron \
--without-pam \
--without-selinux \
--without-audit
make -s -j"$jobs"
install -m 0755 src/crond "$base_root/usr/sbin/cron"
install -m 4755 src/crontab "$base_root/usr/bin/crontab"
)
(
cd "$source_build_dir/openntpd-7.9p1"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
YACC=byacc \
LDFLAGS="-static" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--runstatedir=/run \
--with-privsep-user=_ntp \
--disable-https-constraint \
--disable-shared \
--enable-static
make -s -j"$jobs" -C compat
make -s -j"$jobs" -C src ntpd
install -m 0755 src/ntpd "$base_root/usr/sbin/ntpd"
ln -s ntpd "$base_root/usr/sbin/ntpctl"
)
(
cd "$source_build_dir/sysklogd-2.7.2"
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
LDFLAGS="-static" \
PKG_CONFIG="$tools_dir/bin/pkgconf" \
./configure \
--build="$build_triplet" \
--host=x86_64-linux-musl \
--prefix=/usr \
--sysconfdir=/etc \
--runstatedir=/run \
--disable-shared \
--enable-static \
--without-logger \
--with-systemd=no
make -s -j"$jobs" -C src syslogd
install -m 0755 src/syslogd "$base_root/usr/sbin/syslogd"
)
(
cd "$source_build_dir/skalibs-2.15.1.0"
CC="$cc" AR="$ar" RANLIB="$ranlib" ./configure \
--prefix=/usr \
--build="$build_triplet" \
--target=x86_64-linux-musl \
--with-include="$sysroot/usr/include" \
--with-lib="$sysroot/usr/lib" \
--with-sysdep-devurandom=yes \
--with-sysdep-posixspawnearlyreturn=no \
--with-sysdep-procselfexe=/proc/self/exe \
--with-sysdep-selectinfinite=yes \
--disable-shared
make -s -j"$jobs" CC="$cc" AR="$ar" RANLIB="$ranlib"
make -s DESTDIR="$sysroot" install
)
(
cd "$source_build_dir/mdevd-0.1.8.2"
CC="$cc" AR="$ar" RANLIB="$ranlib" ./configure \
--prefix=/usr \
--build="$build_triplet" \
--target=x86_64-linux-musl \
--with-sysdeps="$sysroot/usr/lib/skalibs/sysdeps" \
--with-include="$sysroot/usr/include" \
--with-lib="$sysroot/usr/lib" \
--enable-static-libc \
--disable-shared
make -s -j"$jobs" CC="$cc" AR="$ar" RANLIB="$ranlib"
install -m 0755 mdevd "$base_root/sbin/mdevd"
install -m 0755 mdevd-coldplug "$base_root/sbin/mdevd-coldplug"
)
kmod_build="$source_build_dir/kmod-34.2/build"
PKG_CONFIG_LIBDIR="$sysroot/usr/lib/pkgconfig:$sysroot/usr/share/pkgconfig" \
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
python3 "$meson_source" setup \
"$kmod_build" \
"$source_build_dir/kmod-34.2" \
--cross-file="$cross_file" \
--prefix=/usr \
--buildtype=release \
--default-library=static \
-Dzstd=disabled \
-Dxz=disabled \
-Dzlib=disabled \
-Dopenssl=disabled \
-Dmanpages=false \
-Ddocs=false \
-Dbuild-tests=false
python3 "$meson_source" compile -C "$kmod_build" kmod:executable
install -m 0755 "$kmod_build/kmod" "$base_root/sbin/kmod"
for command in depmod insmod lsmod modinfo modprobe rmmod; do
ln -s kmod "$base_root/sbin/$command"
done
(
cd "$source_build_dir/openssl-3.5.7"
make -s distclean
CC="$cc" \
AR="$ar" \
RANLIB="$ranlib" \
./Configure \
linux-x86_64 \
--prefix=/usr \
--libdir=lib \
--openssldir=/etc/ssl \
no-afalgeng \
no-docs \
no-dso \
no-module \
no-secure-memory \
no-shared \
no-tests
make -s -j"$jobs" build_generated
make -s depend
make -s -j"$jobs" apps/openssl
install -m 0755 apps/openssl "$base_root/usr/bin/openssl"
)
install -m 0755 \
"$chimerautils_build/src.freebsd/coreutils/xinstall/xinstall" \
"$base_root/usr/bin/install"
install -m 0755 \
"$chimerautils_build/src.freebsd/coreutils/test/xtest" \
"$base_root/usr/bin/test"
ln -s test "$base_root/usr/bin/["
ln -s install "$base_root/usr/bin/binstall"
ln -s id "$base_root/usr/bin/groups"
ln -s id "$base_root/usr/bin/whoami"
ln -s md5 "$base_root/usr/bin/sha256"
ln -s stat "$base_root/usr/bin/readlink"
install -m 0755 "$sysroot/usr/bin/tput" "$base_root/usr/bin/tput"
ln -s tcsh "$base_root/bin/csh"