Last active
November 25, 2021 03:50
-
-
Save bensallen/764b94ad702bc144ca04d861f50cbeef to your computer and use it in GitHub Desktop.
MUSL libc - busybox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
MUSL_VERS=1.1.14 | |
BUSYBOX_VERS=1.24.2 | |
BASE=$PWD | |
mkdir -p $BASE/warewulf4/initramfs | |
mkdir -p $BASE/warewulf4/initramfs/3rd_party/MIT | |
mkdir -p $BASE/warewulf4/initramfs/3rd_party/GPL | |
INSTALLROOT=$BASE/warewulf4/initramfs/_install | |
mkdir -p $INSTALLROOT | |
BUILDROOT=$BASE/warewulf4/initramfs/BUILD | |
mkdir -p $BUILDROOT | |
KHDR_BASE=/usr | |
# MUSL-C | |
cd $BASE/warewulf4/initramfs/3rd_party/MIT | |
curl -O https://www.musl-libc.org/releases/musl-$MUSL_VERS.tar.gz | |
tar -C $BUILDROOT -xf musl-$MUSL_VERS.tar.gz | |
cd $BUILDROOT/musl-$MUSL_VERS | |
./configure --prefix=$BUILDROOT/_work/musl-$MUSL_VERS --disable-shared | |
make -j2 && make install | |
PATH=$BUILDROOT/_work/musl-$MUSL_VERS/bin:$PATH | |
# Ugh hacks, use binutils and linux-headers from the buildhost | |
mkdir -p $BUILDROOT/_work/musl-$MUSL_VERS/bin | |
cd $BUILDROOT/_work/musl-$MUSL_VERS/bin | |
ln -s `which ar` musl-ar | |
ln -s `which strip` musl-strip | |
cd $BUILDROOT/_work/musl-$MUSL_VERS/include | |
ln -s $KHDR_BASE/include/linux linux | |
ln -s $KHDR_BASE/include/mtd mtd | |
if [ -d $KHDR_BASE/include/asm ] | |
then | |
ln -s $KHDR_BASE/include/asm asm | |
else | |
ln -s $KHDR_BASE/include/asm-generic asm | |
fi | |
ln -s $KHDR_BASE/include/asm-generic asm-generic | |
# Busybox (static) | |
cd $BASE/warewulf4/initramfs/3rd_party/GPL | |
curl -O https://www.busybox.net/downloads/busybox-$BUSYBOX_VERS.tar.bz2 | |
tar -C $BUILDROOT -xf busybox-$BUSYBOX_VERS.tar.bz2 | |
cd $BUILDROOT/busybox-$BUSYBOX_VERS | |
curl https://raw.githubusercontent.com/alpinelinux/aports/master/main/busybox/busyboxconfig > .config | |
sed -i -e "s/CONFIG_EXTRA_COMPAT=y/CONFIG_EXTRA_COMPAT=n/" \ | |
-e "s/.*CONFIG_CROSS_COMPILER_PREFIX.*/CONFIG_CROSS_COMPILER_PREFIX=\"musl-\"/" \ | |
-e "s|.*CONFIG_PREFIX.*|CONFIG_PREFIX=\"$INSTALLROOT\"|" \ | |
-e "s/.*CONFIG_PIE.*/\# CONFIG_PIE is not set/" \ | |
-e "s/.*CONFIG_INSTALL_APPLET_DONT.*/\# CONFIG_INSTALL_APPLET_DONT is not set/" \ | |
-e "s/.*CONFIG_STATIC.*/CONFIG_STATIC=y/" \ | |
-e "s/.*CONFIG_INSTALL_APPLET_SYMLINKS.*/CONFIG_INSTALL_APPLET_SYMLINKS=y/" \ | |
.config | |
make V=1 -j2 | |
make install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment