Updated the build scripts and started working on Docker

This commit is contained in:
Alexander Hill 2025-07-07 23:28:32 -04:00
parent 55e7ee4239
commit 872a8c617e
3 changed files with 33 additions and 15 deletions

6
Dockerfile Normal file
View File

@ -0,0 +1,6 @@
FROM alpine:latest
RUN apk update
RUN apk upgrade
RUN apk add clang cmake curl git libc++ linux-headers makedoas python3 rsync samurai umount
RUN git clone https://github.com/cbpudding/maplelinux-bootstrap /maple

View File

@ -18,7 +18,7 @@ mkdir -p $MAPLE/lib
# TODO: Does it make sense to have this long-term? Anything that depends on
# libc++ fails to link without it, but this should be fixed via a
# configuration change in LLVM. ~ahill
ln -s . $MAPLE/lib/$HOST
ln -sf . $MAPLE/lib/$HOST
mkdir -p $MAPLE/maple/patches
mkdir -p $MAPLE/maple/sources
mkdir -p $MAPLE/mnt
@ -28,18 +28,18 @@ mkdir -p $MAPLE/sbin
mkdir -p $MAPLE/sys
mkdir -p $MAPLE/tmp
mkdir -p $MAPLE/usr
ln -s ../bin $MAPLE/usr/bin
ln -sf ../bin $MAPLE/usr/bin
mkdir -p $MAPLE/usr/include
ln -s ../lib $MAPLE/usr/lib
ln -s ../lib $MAPLE/usr/libexec
ln -s ../sbin $MAPLE/usr/sbin
ln -sf ../lib $MAPLE/usr/lib
ln -sf ../lib $MAPLE/usr/libexec
ln -sf ../sbin $MAPLE/usr/sbin
mkdir -p $MAPLE/usr/share
mkdir -p $MAPLE/var
mkdir -p $MAPLE/var/cache
mkdir -p $MAPLE/var/lib
ln -s ../run/lock $MAPLE/var/lock
ln -sf ../run/lock $MAPLE/var/lock
mkdir -p $MAPLE/var/log
ln -s ../run $MAPLE/var/run
ln -sf ../run $MAPLE/var/run
mkdir -p $MAPLE/var/spool
mkdir -p $MAPLE/var/tmp
@ -49,6 +49,11 @@ cd build
# LLVM Build
tar xf ../sources/llvm-project-*.tar*
cd llvm-project-*/
# TODO: Python is a required part of LLVM, but we can't include the latest
# version due to conflicts with LibreSSL. Maybe we can piggyback off of
# Python 3.9 for a while, but that's not a sustainable solution long-term.
# ~ahill
# See also: https://peps.python.org/pep-0644/
cmake -B stage1 -G Ninja -S llvm \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$MAPLE/maple/tools \
@ -88,6 +93,7 @@ export PATH="$MAPLE/maple/tools/bin:$PATH"
tar xf ../sources/linux-*.tar*
cd linux-*/
LLVM=1 make -j $THREADS mrproper
# TODO: Why do we need rsync to install the Linux headers? ~ahill
LLVM=1 make -j $THREADS headers_install INSTALL_HDR_PATH=$MAPLE/usr
cd ..
@ -103,13 +109,13 @@ make -j $THREADS install DESTDIR=$MAPLE
# we need, but it is needed for compatibility. As of April 5th, 2025, zsh
# is known to be misconfigured as a result of missing libraries. ~ahill
for lib in $(grep "EMPTY_LIB_NAMES =" Makefile | sed "s/EMPTY_LIB_NAMES = //"); do
ln -s libc.so $MAPLE/lib/lib$lib.so
ln -sf libc.so $MAPLE/lib/lib$lib.so
done
# NOTE: musl has some witchcraft associated with it that allows it to function
# as an implementation of ldd. Honestly, the idea of a library with as an
# entry point is something I have never thought of before, but I'm
# interested in exploring the possibilities. ~ahill
ln -s /lib/ld-musl-x86_64.so.1 $MAPLE/bin/ldd
ln -sf /lib/ld-musl-x86_64.so.1 $MAPLE/bin/ldd
cd ..
# dash Build
@ -124,7 +130,7 @@ cd dash-*/
--sharedstatedir=/usr/com
make -j $THREADS
make -j $THREADS install DESTDIR=$MAPLE
ln -s dash $MAPLE/bin/sh
ln -sf dash $MAPLE/bin/sh
cd ..
# m4 Build
@ -300,7 +306,6 @@ cd ..
# potential conflict with CMake. Adapted from Nick's contribution. ~ahill
export CFLAGS=$(echo $CFLAGS | sed "s/--sysroot=\S*//")
export CXXFLAGS=$(echo $CXXFLAGS | sed "s/--sysroot=\S*//")
tar xf ../sources/llvm-project-*.tar*
cd llvm-project-*/
TOOLCHAIN_FILE=$HOST-maple-clang.cmake
# NOTE: First time doing this. Did I do it right? ~ahill
@ -352,9 +357,9 @@ cmake -B stage2 -G Ninja -S llvm \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON
cmake --build stage2
cmake --install stage2
ln -s clang $MAPLE/bin/cc
ln -s clang++ $MAPLE/bin/c++
ln -s ld.lld $MAPLE/bin/ld
ln -sf clang $MAPLE/bin/cc
ln -sf clang++ $MAPLE/bin/c++
ln -sf ld.lld $MAPLE/bin/ld
cd ..
cd ..

View File

@ -409,6 +409,13 @@ cd ..
# xfsprogs Build
tar xf ../sources/xfsprogs-*.tar*
cd xfsprogs-*/
# NOTE: libxfs redefined PAGE_SIZE from the standard C library (limits.h), so
# we simply undefine it to get it to play nice with musl. ~ahill
sed -i "/#define PAGE_SIZE/d" libxfs/libxfs_priv.h
# NOTE: io/stat.c relies on the internal STATX__RESERVED definition to function.
# musl doesn't have STATX__RESERVED, so we replace it with STATX_ALL since
# that's what we're actually trying to achieve here. ~ahill
sed -i "s/~STATX__RESERVED/STATX_ALL/" io/stat.c
# Overriding system statx fixes an issue with musl compatability.
# Gentoo bugzilla for reference: https://bugs.gentoo.org/948468
CFLAGS=-DOVERRIDE_SYSTEM_STATX ./configure \