Integrated Treetap into Maple Linux #1

Merged
ahill merged 74 commits from treetap into main 2026-01-25 22:51:04 +00:00
3 changed files with 68 additions and 49 deletions
Showing only changes of commit f8787a8911 - Show all commits

View File

@ -8,6 +8,7 @@ ARCH=$(echo $TARGET | cut -d"-" -f1)
BOOTSTRAP=$(pwd)/.bootstrap BOOTSTRAP=$(pwd)/.bootstrap
PROCS=$(nproc) PROCS=$(nproc)
SOURCES=$(pwd)/.treetap/sources SOURCES=$(pwd)/.treetap/sources
SPEC=$(pwd)/sources
export AR=llvm-ar export AR=llvm-ar
export CC=clang export CC=clang
export CFLAGS="-fuse-ld=lld -O3 -march=$MICROARCH -pipe --sysroot=$BOOTSTRAP/root -Wno-unused-command-line-argument" export CFLAGS="-fuse-ld=lld -O3 -march=$MICROARCH -pipe --sysroot=$BOOTSTRAP/root -Wno-unused-command-line-argument"
@ -15,8 +16,9 @@ export CXX=clang++
export CXXFLAGS=$CFLAGS export CXXFLAGS=$CFLAGS
export RANLIB=llvm-ranlib export RANLIB=llvm-ranlib
export LD=ld.lld export LD=ld.lld
export TREETAP_SYSROOT=$BOOTSTRAP/root export LDFLAGS="--sysroot=$BOOTSTRAP/root"
export TREETAP_TARGET=$TARGET export TT_SYSROOT=$BOOTSTRAP/root
export TT_TARGET=$TARGET
# Fetch sources required for a bootstrap # Fetch sources required for a bootstrap
./treetap fetch sources/busybox.spec ./treetap fetch sources/busybox.spec
@ -57,7 +59,8 @@ set(CMAKE_SYSTEM_NAME Linux)
EOF EOF
# Install headers for Linux # Install headers for Linux
tar xf $SOURCES/linux/*/linux-*.tar* LINUX_VERSION=$(sed -En "s/SRC_VERSION=\"?(.+)\"/\1/p" $SPEC/linux.spec)
tar xf $SOURCES/linux/$LINUX_VERSION/linux-*.tar*
cd linux-*/ cd linux-*/
# NOTE: LLVM=1 is required here because GCC and other GNU tools are required in # NOTE: LLVM=1 is required here because GCC and other GNU tools are required in
# some places still. This allows us to use LLVM and bypass the parts that # some places still. This allows us to use LLVM and bypass the parts that
@ -71,7 +74,8 @@ cp -r usr/include $BOOTSTRAP/root/usr
cd .. cd ..
# Install headers for musl # Install headers for musl
tar xf $SOURCES/musl/*/musl-*.tar* MUSL_VERSION=$(sed -En "s/SRC_VERSION=\"?(.+)\"/\1/p" $SPEC/musl.spec)
tar xf $SOURCES/musl/$MUSL_VERSION/musl-*.tar*
cd musl-*/ cd musl-*/
# NOTE: We are intentionally not passing --target here because musl follows the # NOTE: We are intentionally not passing --target here because musl follows the
# GNU approach when it comes to cross-compiling. This means the build # GNU approach when it comes to cross-compiling. This means the build
@ -90,7 +94,8 @@ make -O -j $PROCS install-headers DESTDIR=$BOOTSTRAP/root
cd .. cd ..
# Build and install compiler-rt builtins # Build and install compiler-rt builtins
tar xf $SOURCES/llvm/*/llvm-project-*.tar* LLVM_VERSION=$(sed -En "s/SRC_VERSION=\"?(.+)\"/\1/p" $SPEC/llvm.spec)
tar xf $SOURCES/llvm/$LLVM_VERSION/llvm-project-*.tar*
cd llvm-project-*/ cd llvm-project-*/
cmake -S compiler-rt/lib/builtins -B build-builtins \ cmake -S compiler-rt/lib/builtins -B build-builtins \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
@ -187,7 +192,8 @@ cmake --install build-llvm --parallel $PROCS
cd .. cd ..
# Build Busybox # Build Busybox
tar xf $SOURCES/busybox/*/busybox-*.tar* BUSYBOX_VERSION=$(sed -En "s/SRC_VERSION=\"?(.+)\"/\1/p" $SPEC/busybox.spec)
tar xf $SOURCES/busybox/$BUSYBOX_VERSION/busybox-*.tar*
cd busybox-*/ cd busybox-*/
# NOTE: Like we did with musl before, we don't set CROSS_COMPILE because LLVM is # NOTE: Like we did with musl before, we don't set CROSS_COMPILE because LLVM is
# smart and doesn't need a compiler to cross-compile code. With that said, # smart and doesn't need a compiler to cross-compile code. With that said,

View File

@ -9,13 +9,13 @@ build() {
tar xf ../musl-*.tar* tar xf ../musl-*.tar*
cd musl-*/ cd musl-*/
./configure \ ./configure \
--bindir=$TREETAP_BINDIR \ --bindir=$TT_BINDIR \
--build=$TREETAP_BUILD \ --build=$TT_BUILD \
--includedir=$TREETAP_INCLUDEDIR \ --includedir=$TT_INCLUDEDIR \
--libdir=$TREETAP_LIBDIR \ --libdir=$TT_LIBDIR \
--prefix=$TREETAP_PREFIX \ --prefix=$TT_PREFIX \
--target=$TREETAP_TARGET --target=$TT_TARGET
make -j $TREETAP_PROCS make -O -j $TT_PROCS
} }
clean() { clean() {
@ -24,5 +24,5 @@ clean() {
package() { package() {
cd musl-*/ cd musl-*/
DESTDIR=$TREETAP_INSTALLDIR make install DESTDIR=$TT_INSTALLDIR make install
} }

83
treetap
View File

@ -18,6 +18,11 @@
# Changelog # # Changelog #
############# #############
# November 13, 2025 (1.0.2)
# + Added the target triple to the package path
# * Prevented fetch from re-downloading packages given a valid hash
# * Renamed all TREETAP_* variables to TT_*
# November 11, 2025 (1.0.1) # November 11, 2025 (1.0.1)
# - Removed bashisms to become POSIX compliant # - Removed bashisms to become POSIX compliant
@ -28,10 +33,10 @@
# Global Variables # # Global Variables #
#################### ####################
[ -z "$TREETAP_DIR" ] && TREETAP_DIR="$(pwd)/.treetap" [ -z "$TT_DIR" ] && TT_DIR="$(pwd)/.treetap"
[ -z "$TREETAP_PKGDIR" ] && TREETAP_PKGDIR="$TREETAP_DIR/packages" [ -z "$TT_PKGDIR" ] && TT_PKGDIR="$TT_DIR/packages"
[ -z "$TREETAP_SYSROOT" ] && TREETAP_SYSROOT=/ [ -z "$TT_SYSROOT" ] && TT_SYSROOT=/
TREETAP_VERSION="1.0.1" TT_VERSION="1.0.2"
##################### #####################
# Utility Functions # # Utility Functions #
@ -39,7 +44,7 @@ TREETAP_VERSION="1.0.1"
# Displays the usage information for treetap # Displays the usage information for treetap
help_message() { help_message() {
echo "treetap $TREETAP_VERSION" echo "treetap $TT_VERSION"
echo echo
echo "Package Commands:" echo "Package Commands:"
echo " $0 install <package> [sysroot]" echo " $0 install <package> [sysroot]"
@ -82,15 +87,15 @@ source_spec() {
[ -z "$SRC_FILENAME" ] && SRC_FILENAME=$(basename $SRC_URL) [ -z "$SRC_FILENAME" ] && SRC_FILENAME=$(basename $SRC_URL)
# Environmental Variables # Environmental Variables
[ -z "$TREETAP_BINDIR" ] && TREETAP_BINDIR=/bin [ -z "$TT_BINDIR" ] && TT_BINDIR=/bin
TREETAP_BUILD=$(clang -dumpmachine) TT_BUILD=$(clang -dumpmachine)
[ -z "$TREETAP_TARGET" ] && TREETAP_TARGET=$TREETAP_BUILD [ -z "$TT_TARGET" ] && TT_TARGET=$TT_BUILD
TREETAP_BUILDDIR="$TREETAP_DIR/sources/$SRC_NAME/$SRC_VERSION/$TREETAP_TARGET" TT_BUILDDIR="$TT_DIR/sources/$SRC_NAME/$SRC_VERSION/$TT_TARGET"
[ -z "$TREETAP_INCLUDEDIR" ] && TREETAP_INCLUDEDIR=/usr/include [ -z "$TT_INCLUDEDIR" ] && TT_INCLUDEDIR=/usr/include
TREETAP_INSTALLDIR="$TREETAP_BUILDDIR/install" TT_INSTALLDIR="$TT_BUILDDIR/install"
[ -z "$TREETAP_LIBDIR" ] && TREETAP_LIBDIR=/lib [ -z "$TT_LIBDIR" ] && TT_LIBDIR=/lib
[ -z "$TREETAP_PREFIX" ] && TREETAP_PREFIX=/ [ -z "$TT_PREFIX" ] && TT_PREFIX=/
[ -z "$TREETAP_PROCS" ] && TREETAP_PROCS=$(nproc) [ -z "$TT_PROCS" ] && TT_PROCS=$(nproc)
true true
} }
@ -101,12 +106,12 @@ source_spec() {
# Installs a package to the sysroot # Installs a package to the sysroot
package_install() { package_install() {
[ ! -z "$2" ] && TREETAP_SYSROOT=$2 [ ! -z "$2" ] && TT_SYSROOT=$2
package_check $1 $TREETAP_SYSROOT package_check $1 $TT_SYSROOT
echo "Installing $(basename $1)" echo "Installing $(basename $1)"
FULLPATH=$(pwd)/$1 FULLPATH=$(pwd)/$1
PUSHD=$(pwd) PUSHD=$(pwd)
cd $TREETAP_SYSROOT cd $TT_SYSROOT
xz -cd $FULLPATH | cpio -idmu --quiet xz -cd $FULLPATH | cpio -idmu --quiet
cd $PUSHD cd $PUSHD
exit 0 exit 0
@ -114,12 +119,12 @@ package_install() {
# Uninstalls a package from the sysroot # Uninstalls a package from the sysroot
package_uninstall() { package_uninstall() {
[ ! -z "$2" ] && TREETAP_SYSROOT=$2 [ ! -z "$2" ] && TT_SYSROOT=$2
package_check $1 $TREETAP_SYSROOT package_check $1 $TT_SYSROOT
echo "Uninstalling $(basename $1)" echo "Uninstalling $(basename $1)"
FULLPATH=$(pwd)/$1 FULLPATH=$(pwd)/$1
PUSHD=$(pwd) PUSHD=$(pwd)
cd $TREETAP_SYSROOT cd $TT_SYSROOT
xz -cd $FULLPATH | cpio -it --quiet | tail -n +2 | sort -r | while read path; do xz -cd $FULLPATH | cpio -it --quiet | tail -n +2 | sort -r | while read path; do
if [ -d $path ]; then if [ -d $path ]; then
rmdir --ignore-fail-on-non-empty $path rmdir --ignore-fail-on-non-empty $path
@ -134,9 +139,9 @@ package_uninstall() {
# Builds the source from the previously fetched tarball # Builds the source from the previously fetched tarball
source_build() { source_build() {
source_spec $1 source_spec $1
mkdir -p $TREETAP_BUILDDIR mkdir -p $TT_BUILDDIR
PUSHD=$(pwd) PUSHD=$(pwd)
cd $TREETAP_BUILDDIR cd $TT_BUILDDIR
echo "Building $SRC_NAME $SRC_VERSION" echo "Building $SRC_NAME $SRC_VERSION"
build > build-$(date +%Y%m%d%H%M%S).log 2>&1 build > build-$(date +%Y%m%d%H%M%S).log 2>&1
cd $PUSHD cd $PUSHD
@ -146,12 +151,12 @@ source_build() {
# Cleans the source from the previous build # Cleans the source from the previous build
source_clean() { source_clean() {
source_spec $1 source_spec $1
mkdir -p $TREETAP_BUILDDIR mkdir -p $TT_BUILDDIR
PUSHD=$(pwd) PUSHD=$(pwd)
cd $TREETAP_BUILDDIR cd $TT_BUILDDIR
echo "Cleaning $SRC_NAME $SRC_VERSION" echo "Cleaning $SRC_NAME $SRC_VERSION"
clean clean
rm -rf $TREETAP_INSTALLDIR rm -rf $TT_INSTALLDIR
cd $PUSHD cd $PUSHD
exit 0 exit 0
} }
@ -159,9 +164,17 @@ source_clean() {
# Fetches and verifies the integrity of the source tarball # Fetches and verifies the integrity of the source tarball
source_fetch() { source_fetch() {
source_spec $1 source_spec $1
mkdir -p $TREETAP_BUILDDIR mkdir -p $TT_BUILDDIR
PUSHD=$(pwd) PUSHD=$(pwd)
cd $TREETAP_BUILDDIR/.. cd $TT_BUILDDIR/..
if [ -f $SRC_FILENAME ]; then
if (echo "$SRC_HASH $SRC_FILENAME" | sha256sum -c - > /dev/null); then
echo "Skipping $SRC_FILENAME"
exit 0
else
rm -f $SRC_FILENAME
fi
fi
echo "Fetching $SRC_FILENAME" echo "Fetching $SRC_FILENAME"
curl -L -sS $SRC_URL -o $SRC_FILENAME curl -L -sS $SRC_URL -o $SRC_FILENAME
echo "Verifying $SRC_FILENAME" echo "Verifying $SRC_FILENAME"
@ -173,17 +186,17 @@ source_fetch() {
# Packages the built artifacts for distribution # Packages the built artifacts for distribution
source_package() { source_package() {
source_spec $1 source_spec $1
mkdir -p $TREETAP_BUILDDIR mkdir -p $TT_BUILDDIR
mkdir -p $TREETAP_INSTALLDIR mkdir -p $TT_INSTALLDIR
mkdir -p $TREETAP_PKGDIR mkdir -p $TT_PKGDIR/$TT_TARGET
PUSHD=$(pwd) PUSHD=$(pwd)
cd $TREETAP_BUILDDIR cd $TT_BUILDDIR
echo "Moving artifacts for $SRC_NAME $SRC_VERSION" echo "Moving artifacts for $SRC_NAME $SRC_VERSION"
package > package-$(date +%Y%m%d%H%M%S).log package > package-$(date +%Y%m%d%H%M%S).log
echo "Archiving $SRC_NAME $SRC_VERSION" echo "Archiving $SRC_NAME $SRC_VERSION"
cd $TREETAP_INSTALLDIR cd $TT_INSTALLDIR
find | cpio -o --quiet | xz -cz > "$TREETAP_PKGDIR/$SRC_NAME-$SRC_VERSION.cpio.xz" find | cpio -o --quiet | xz -cz > "$TT_PKGDIR/$TT_TARGET/$SRC_NAME-$SRC_VERSION.cpio.xz"
rm -rf $TREETAP_INSTALLDIR rm -rf $TT_INSTALLDIR
cd $PUSHD cd $PUSHD
exit 0 exit 0
} }
@ -191,7 +204,7 @@ source_package() {
# Purges the entire build directory for a source # Purges the entire build directory for a source
source_purge() { source_purge() {
source_spec $1 source_spec $1
rm -rf $TREETAP_BUILDDIR rm -rf $TT_BUILDDIR
exit 0 exit 0
} }