From c532fd9824829da6c4e5d7bb8eed64ab3946dfd7 Mon Sep 17 00:00:00 2001 From: Mike Lowis Date: Wed, 27 Jan 2016 09:10:51 +0000 Subject: [PATCH] Base chroot system is now fully functional and theoretically capable of rebuilding all of its component packages --- build.sh | 125 +++++++++++------- clean.sh | 6 + config.sh | 25 +++- enter-chroot.sh | 2 +- scripts/configopts.sh | 10 ++ kernel-config => scripts/kernel-config | 0 .../musl-cross-config.sh | 3 +- scripts/musl-static-config.sh | 12 ++ 8 files changed, 124 insertions(+), 59 deletions(-) create mode 100755 clean.sh create mode 100755 scripts/configopts.sh rename kernel-config => scripts/kernel-config (100%) rename musl-cross-config.sh => scripts/musl-cross-config.sh (94%) create mode 100644 scripts/musl-static-config.sh diff --git a/build.sh b/build.sh index 4853112..c4a41f6 100755 --- a/build.sh +++ b/build.sh @@ -3,7 +3,6 @@ ############################################################################### # Configuration Settings ############################################################################### - # Turn off command hashing and make the script exit when a command errors. set -e @@ -15,13 +14,13 @@ set -e ############################################################################### fetch(){ if [ ! -d "$3" ]; then - mkdir -p "$AL_TARBALLS" - if [ ! -f "$AL_TARBALLS/$1" ]; then - echo curl -L --retry 5 "$2/$1" > "$AL_TARBALLS/$1" - curl -L --retry 5 "$2/$1" > "$AL_TARBALLS/$1" + mkdir -p "$AL_SOURCES" + if [ ! -f "$AL_SOURCES/$1" ]; then + echo curl -L --retry 5 "$2/$1" > "$AL_SOURCES/$1" + curl -L --retry 5 "$2/$1" > "$AL_SOURCES/$1" fi mkdir -p "$3" - tar -xvf "$AL_TARBALLS/$1" -C "$3" --strip-components 1 + tar -xvf "$AL_SOURCES/$1" -C "$3" --strip-components 1 fi } @@ -31,68 +30,96 @@ gitclone(){ fi } -############################################################################### -# Build the Cross-Compiler -############################################################################### -if [ ! -d "$AL_TOOLS/$(uname -m)-linux-musl" ]; then - mkdir -vp $AL_TOOLS - gitclone https://github.com/sabotage-linux/musl-cross.git "$AL_SOURCES/musl-cross" - cd "$AL_SOURCES/musl-cross" - cp "$AL/musl-cross-config.sh" config.sh - ./build.sh - cd "$AL" -fi - -############################################################################### -# Setup the Build Environment -############################################################################### -export CC="$(uname -m)-linux-musl-gcc" -export CXX="$(uname -m)-linux-musl-g++" -export AR="$(uname -m)-linux-musl-ar" -export AS="$(uname -m)-linux-musl-as" -export LD="$(uname -m)-linux-musl-ld" -export RANLIB="$(uname -m)-linux-musl-ranlib" -export READELF="$(uname -m)-linux-musl-readelf" -export STRIP="$(uname -m)-linux-musl-strip" -export LDFLAGS="--static" - ############################################################################### # Install the Base Packages ############################################################################### +# Fetch the prebuilt cross compiler +fetch crossx86-x86_64-linux-musl-1.1.12.tar.xz \ + https://e82b27f594c813a5a4ea5b07b06f16c3777c3b8c.googledrive.com/host/0BwnS5DMB0YQ6bDhPZkpOYVFhbk0/musl-1.1.12/ \ + "$AL_TOOLS" # Install sbase gitclone http://git.suckless.org/sbase "$AL_SOURCES/sbase" -cd "$AL_SOURCES/sbase" -make CC="$CC" LD="$LD" LDFLAGS="$LDFLAGS" -j8 -make PREFIX=$AL_ROOT install -cd $AL +if [ ! -f "$AL_ROOT/bin/ls" ]; then + cd "$AL_SOURCES/sbase" + make $MAKEFLAGS CC="$CC" LD="$LD" LDFLAGS="$LDFLAGS" + make $MAKEFLAGS PREFIX=$AL_ROOT install + rm -f "$AL_ROOT/bin/grep" + cd $AL +fi # Install ubase gitclone http://git.suckless.org/ubase "$AL_SOURCES/ubase" -cd "$AL_SOURCES/ubase" -make CC="$CC" LD="$LD" LDFLAGS="$LDFLAGS" -j8 -make PREFIX=$AL_ROOT install -cd $AL +if [ ! -f "$AL_ROOT/bin/clear" ]; then + echo ubase + cd "$AL_SOURCES/ubase" + make $MAKEFLAGS CC="$CC" LD="$LD" LDFLAGS="$LDFLAGS" + make $MAKEFLAGS PREFIX=$AL_ROOT install + cd $AL +fi # Install mksh fetch mksh-R52b.tgz https://www.mirbsd.org/MirOS/dist/mir/mksh/ "$AL_SOURCES/mksh" -cd "$AL_SOURCES/mksh" -if [ ! -f mksh ]; then +if [ ! -f "$AL_ROOT/bin/mksh" ]; then + cd "$AL_SOURCES/mksh" chmod +x Build.sh ./Build.sh + mkdir -p "$AL_ROOT/etc/" "$AL_ROOT/share/doc/mksh/examples" + cp -f mksh "$AL_ROOT/bin/" + chmod 555 "$AL_ROOT/bin/mksh" + cp -f dot.mkshrc "$AL_ROOT/share/doc/mksh/examples" + ln -svf mksh "$AL_ROOT/bin/sh" + cd $AL +fi + +# Install GNU grep +fetch grep-2.9.tar.xz http://ftp.gnu.org/gnu/grep/ "$AL_SOURCES/grep" +if [ ! -f "$AL_ROOT/bin/grep" ]; then + cd "$AL_SOURCES/grep" + ./configure \ + LDFLAGS="--static" \ + --prefix="$AL_ROOT" \ + --disable-threads \ + --disable-rpath \ + --disable-nls + make $MAKEFLAGS install + cd $AL +fi + +# Install GNU awk +fetch gawk-4.1.3.tar.xz http://ftp.gnu.org/gnu/gawk/ "$AL_SOURCES/gawk" +if [ ! -f "$AL_ROOT/bin/gawk" ]; then + cd "$AL_SOURCES/gawk" + ./configure \ + LDFLAGS="--static" \ + --prefix="$AL_ROOT" \ + --disable-extensions \ + --disable-rpath \ + --disable-nls \ + --without-readline + make $MAKEFLAGS gawk + cp "$AL_SOURCES/gawk/gawk" "$AL_ROOT/bin" + cd $AL +fi + +# Install GNU make +fetch make-4.1.tar.gz http://ftp.gnu.org/gnu/make/ "$AL_SOURCES/make" +if [ ! -f "$AL_ROOT/bin/make" ]; then + cd "$AL_SOURCES/make" + ./configure \ + LDFLAGS="--static" \ + --prefix="$AL_ROOT" \ + --without-guile + make $MAKEFLAGS install + cd $AL fi -mkdir -p "$AL_ROOT/etc/" "$AL_ROOT/share/doc/mksh/examples" -cp -f mksh "$AL_ROOT/bin/" -chmod 555 "$AL_ROOT/bin/mksh" -cp -f dot.mkshrc "$AL_ROOT/share/doc/mksh/examples" -ln -svf mksh "$AL_ROOT/bin/sh" -cd $AL ############################################################################### # Install Sources ############################################################################### fetch linux-4.4.tar.xz https://cdn.kernel.org/pub/linux/kernel/v4.x/ "$AL_ROOT/src/linux" -fetch make-4.1.tar.gz http://ftp.gnu.org/gnu/make/ "$AL_ROOT/src/make" +#fetch make-4.1.tar.gz http://ftp.gnu.org/gnu/make/ "$AL_ROOT/src/make" +#fetch musl-1.1.12.tar.gz http://www.musl-libc.org/releases/ "$AL_SOURCES/musl" ############################################################################### # Finalize the Chroot @@ -102,5 +129,3 @@ mkdir -pv "$AL_ROOT/proc" mkdir -pv "$AL_ROOT/sys" mkdir -pv "$AL_ROOT/tmp" mkdir -pv "$AL_ROOT/root" -#mkdir -pv "$AL_ROOT/$AL_ROOT" -#ln -svf /tools "$AL_ROOT/$AL_TOOLS" diff --git a/clean.sh b/clean.sh new file mode 100755 index 0000000..0e35f67 --- /dev/null +++ b/clean.sh @@ -0,0 +1,6 @@ +#!/bin/sh +. ./config.sh +echo rm -r "$AL_ROOT" +rm -rf "$AL_ROOT" +echo rm -r "$AL_SOURCES" +rm -rf "$AL_SOURCES" diff --git a/config.sh b/config.sh index e97c8fd..d5383a0 100644 --- a/config.sh +++ b/config.sh @@ -1,7 +1,6 @@ ############################################################################### # Aardvark Linux Build Config ############################################################################### - # Define a variable to point to the root of the project export AL=$PWD @@ -22,12 +21,24 @@ export AL_TARBALLS=$AL/tarballs # Variable pointing to the sources directory export AL_SOURCES=$AL/sources +# Choose the target triple. This will select the prebuilt cross compiler to use. +export AL_TGT=$(uname -m)-linux-musl + +# Options to use for every invocation of make +export MAKEFLAGS="-j8" + ############################################################################### # Build Environment Settings ############################################################################### - -# Setup the path to use the cross-tools when they're available -export AL_TGT=$(uname -m)-linux-musl - -# -export PATH=$AL_ROOT/tools/$AL_TGT/bin:$PATH +# These settings should not have to change from the defaults. They are mainly +# here for informational purposes. +export PATH="$AL_TOOLS/bin:$PATH" +export CC="$AL_TGT-gcc" +export CXX="$AL_TGT-g++" +export AR="$AL_TGT-ar" +export AS="$AL_TGT-as" +export LD="$AL_TGT-ld" +export RANLIB="$AL_TGT-ranlib" +export READELF="$AL_TGT-readelf" +export STRIP="$AL_TGT-strip" +export LDFLAGS="--static" diff --git a/enter-chroot.sh b/enter-chroot.sh index c11712c..f7e52ce 100755 --- a/enter-chroot.sh +++ b/enter-chroot.sh @@ -11,7 +11,7 @@ mount --rbind /dev "$AL_ROOT/dev" mount --make-rslave "$AL_ROOT/dev" # Setup env variables -export PATH=/bin:/tools/$AL_TGT/bin +export PATH=/bin:/tools/bin # Enter the chroot chroot "$AL_ROOT" /bin/sh diff --git a/scripts/configopts.sh b/scripts/configopts.sh new file mode 100755 index 0000000..df87f78 --- /dev/null +++ b/scripts/configopts.sh @@ -0,0 +1,10 @@ +#!/bin/sh +cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_ENABLE_ZLIB=OFF \ + -DLLVM_TARGETS_TO_BUILD=X86 \ + -DLLVM_ENABLE_THREADS=OFF \ + -DLLVM_ENABLE_PIC=ON \ + -DLLVM_ENABLE_ZLIB=OFF \ + -G"Unix Makefiles" \ + ../ diff --git a/kernel-config b/scripts/kernel-config similarity index 100% rename from kernel-config rename to scripts/kernel-config diff --git a/musl-cross-config.sh b/scripts/musl-cross-config.sh similarity index 94% rename from musl-cross-config.sh rename to scripts/musl-cross-config.sh index 6b36085..17f41dd 100644 --- a/musl-cross-config.sh +++ b/scripts/musl-cross-config.sh @@ -7,7 +7,7 @@ #ARCH=mips #ARCH=mipsel -CC_BASE_PREFIX=$AL_TOOLS +CC_BASE_PREFIX=/tmp/ # If you use arm, you may need more fine-tuning: # arm hardfloat v7 @@ -20,6 +20,7 @@ CC_BASE_PREFIX=$AL_TOOLS #GCC_BOOTSTRAP_CONFFLAGS="--with-arch=armv7-a --with-float=softfp" #GCC_CONFFLAGS="--with-arch=armv7-a --with-float=softfp" +GCC_BUILTIN_PREREQS=yes MAKEFLAGS=-j8 # Enable this to build the bootstrap gcc (thrown away) without optimization, to reduce build time diff --git a/scripts/musl-static-config.sh b/scripts/musl-static-config.sh new file mode 100644 index 0000000..5178431 --- /dev/null +++ b/scripts/musl-static-config.sh @@ -0,0 +1,12 @@ +# ARCH will be auto-detected as the host if not specified +#ARCH=i486 +CC_BASE_PREFIX="$AL_TOOLS" +MAKEFLAGS=-j8 + +GCC_BOOTSTRAP_CONFFLAGS=--disable-lto-plugin +GCC_CONFFLAGS=--disable-lto-plugin +MUSL_CC_PREFIX="musl-" +# Disable these three lines when running build-gcc-deps.sh +CC="'"${MUSL_CC_PREFIX}gcc"' -Wl,-Bstatic -static-libgcc" +CXX="'"${MUSL_CC_PREFIX}g++"' -Wl,-Bstatic -static-libgcc" +export CC CXX -- 2.54.0