diff --git a/astronaut b/astronaut index 4ad460f..2c3ce84 100755 --- a/astronaut +++ b/astronaut @@ -25,13 +25,13 @@ while getopts "h?s:b:i:" opt; do exit 0 ;; s) - dir_source=$(realpath "$OPTARG") + dir_source="$(realpath "$OPTARG")" ;; b) - dir_build=$(realpath "$OPTARG") + dir_build="$(realpath "$OPTARG")" ;; i) - dir_install=$(realpath "$OPTARG") + dir_install="$(realpath "$OPTARG")" ;; esac done @@ -44,7 +44,7 @@ if [ ! "$1" ]; then exit 1 fi -satellite=$(realpath "$1") +satellite="$(realpath "$1")" # Tools for the astronaut msg() { @@ -56,11 +56,11 @@ mksum() { } download() { - local name=$(basename "$1") + local name="$(basename "$1")" local path="$dir_source/$name" local checksum="" if [ "$2" -a -f "$path" ]; then - checksum=$(mksum "$path") + checksum="$(mksum "$path")" fi if [ ! -f "$path" -o "$checksum" != "$2" ]; then msg "Downloading $name" @@ -70,7 +70,7 @@ download() { else curl -#L -o "$path" "$1" fi - checksum=$(mksum "$path") + checksum="$(mksum "$path")" if [ "$2" -a "$checksum" != "$2" ]; then msg "Houston, we have a problem: Checksum failed." msg "Checksum: $checksum" @@ -91,11 +91,11 @@ extract() { dlextract() { download "$1" "$2" - extract "$(basename ""$1"")" + extract "$(basename "$1")" } extrafile() { - cp "$(dirname ""$satellite"")/$1" "$dir_build/$1" + cp "$(dirname "$satellite")/$1" "$dir_build/$1" } # Create the satellite diff --git a/tools/env b/tools/env new file mode 100755 index 0000000..4c9687d --- /dev/null +++ b/tools/env @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ "$(basename "$(readlink /bin/sh)")" = "bash" ]; then + shellopts="+h" + moreps1="\u:\w " +fi + +umask 022 +env -i \ + HOME=$HOME \ + TERM=$TERM \ + PS1="(buildenv) $moreps1\$ " \ + LC_ALL=C \ + PATH=/tools/bin:$PATH \ + MAKEFLAGS=$MAKEFLAGS \ + rocket=$rocket \ + target=$(uname -m)-rocket-linux-gnu \ + /bin/sh $shellopts diff --git a/chroot/library-check.sh b/tools/library-check.sh similarity index 100% rename from chroot/library-check.sh rename to tools/library-check.sh diff --git a/tools/satellites/binutils-1.sat b/tools/satellites/binutils-1.sat new file mode 100644 index 0000000..cd3dd6d --- /dev/null +++ b/tools/satellites/binutils-1.sat @@ -0,0 +1,23 @@ +name=binutils +version=2.24 + +dlextract "http://ftp.gnu.org/gnu/$name/$name-$version.tar.bz2" \ + "e0f71a7b2ddab0f8612336ac81d9636b" + +mkdir "$name-build"; cd "$name-build" + +"../$name-$version/configure" \ + --prefix=/tools \ + --with-sysroot="$dir_install" \ + --with-lib-path=/tools/lib \ + --target="$target" \ + --disable-nls \ + --disable-werror + +make + +case $(uname -m) in + x86_64) mkdir "$dir_install/tools/lib" && ln -s lib "$dir_install/tools/lib64" ;; +esac + +make DESTDIR="$dir_install" install diff --git a/tools/satellites/binutils-2.sat b/tools/satellites/binutils-2.sat new file mode 100644 index 0000000..50b811b --- /dev/null +++ b/tools/satellites/binutils-2.sat @@ -0,0 +1,23 @@ +name=binutils +version=2.24 + +dlextract "http://ftp.gnu.org/gnu/$name/$name-$version.tar.bz2" \ + "e0f71a7b2ddab0f8612336ac81d9636b" + +mkdir "$name-build"; cd "$name-build" + +CC="$target-gcc" \ +AR="$target-ar" \ +RANLIB="$target-ranlib" \ +"../$name-$version/configure" \ + --prefix=/tools \ + --disable-nls \ + --disable-werror \ + --with-lib-path=/tools/lib \ + --with-sysroot + +make; make DESTDIR="$dir_install" install + +make -C ld clean +make -C ld LIB_PATH=/usr/lib:/lib +cp ld/ld-new "$dir_install/tools/bin/ld-new" diff --git a/tools/satellites/gcc-1.sat b/tools/satellites/gcc-1.sat new file mode 100644 index 0000000..a17296a --- /dev/null +++ b/tools/satellites/gcc-1.sat @@ -0,0 +1,68 @@ +name=gcc +version=4.9.2 +gmp_version=6.0.0 +gmp_minver=a +mpfr_version=3.1.2 +mpc_version=1.0.2 + +dlextract "http://ftp.gnu.org/gnu/$name/$name-$version/$name-$version.tar.bz2" \ + "4df8ee253b7f3863ad0b86359cd39c43" +download "http://ftp.gnu.org/gnu/gmp/gmp-$gmp_version$gmp_minver.tar.xz" \ + "1e6da4e434553d2811437aa42c7f7c76" +download "http://ftp.gnu.org/gnu/mpfr/mpfr-$mpfr_version.tar.xz" \ + "e3d203d188b8fe60bb6578dd3152e05c" +download "http://ftp.gnu.org/gnu/mpc/mpc-$mpc_version.tar.gz" \ + "68fadff3358fb3e7976c7a398a0af4c3" + +cd "$name-$version" + +extract "gmp-$gmp_version$gmp_minver.tar.xz" +extract "mpfr-$mpfr_version.tar.xz" +extract "mpc-$mpc_version.tar.gz" +mv "gmp-$gmp_version" gmp +mv "mpfr-$mpfr_version" mpfr +mv "mpc-$mpc_version" mpc + +for file in \ + $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h) +do + cp -u $file $file.orig + sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \ + -e 's@/usr@/tools@g' $file.orig > $file + echo ' +#undef STANDARD_STARTFILE_PREFIX_1 +#undef STANDARD_STARTFILE_PREFIX_2 +#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/" +#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file + touch $file.orig +done + +sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure + +mkdir "../$name-build"; cd "../$name-build" + +"../$name-$version/configure" \ + --target="$target" \ + --prefix=/tools \ + --with-sysroot="$dir_install" \ + --with-newlib \ + --without-headers \ + --with-local-prefix=/tools \ + --with-native-system-header-dir=/tools/include \ + --disable-nls \ + --disable-shared \ + --disable-multilib \ + --disable-decimal-float \ + --disable-threads \ + --disable-libatomic \ + --disable-libgomp \ + --disable-libitm \ + --disable-libquadmath \ + --disable-libsanitizer \ + --disable-libssp \ + --disable-libvtv \ + --disable-libcilkrts \ + --disable-libstdc++-v3 \ + --enable-languages=c,c++ + +make; make DESTDIR="$dir_install" install diff --git a/tools/satellites/gcc-2.sat b/tools/satellites/gcc-2.sat new file mode 100644 index 0000000..aceef43 --- /dev/null +++ b/tools/satellites/gcc-2.sat @@ -0,0 +1,62 @@ +name=gcc +version=4.9.2 +gmp_version=6.0.0 +gmp_minver=a +mpfr_version=3.1.2 +mpc_version=1.0.2 + +dlextract "http://ftp.gnu.org/gnu/$name/$name-$version/$name-$version.tar.bz2" \ + "4df8ee253b7f3863ad0b86359cd39c43" +download "http://ftp.gnu.org/gnu/gmp/gmp-$gmp_version$gmp_minver.tar.xz" \ + "1e6da4e434553d2811437aa42c7f7c76" +download "http://ftp.gnu.org/gnu/mpfr/mpfr-$mpfr_version.tar.xz" \ + "e3d203d188b8fe60bb6578dd3152e05c" +download "http://ftp.gnu.org/gnu/mpc/mpc-$mpc_version.tar.gz" \ + "68fadff3358fb3e7976c7a398a0af4c3" + +cd "$name-$version" + +extract "gmp-$gmp_version$gmp_minver.tar.xz" +extract "mpfr-$mpfr_version.tar.xz" +extract "mpc-$mpc_version.tar.gz" +mv "gmp-$gmp_version" gmp +mv "mpfr-$mpfr_version" mpfr +mv "mpc-$mpc_version" mpc + +for file in \ + $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h) +do + cp -u $file $file.orig + sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \ + -e 's@/usr@/tools@g' $file.orig > $file + echo ' +#undef STANDARD_STARTFILE_PREFIX_1 +#undef STANDARD_STARTFILE_PREFIX_2 +#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/" +#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file + touch $file.orig +done + +sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure + +cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \ + "`dirname "$($target-gcc -print-libgcc-file-name)"`/include-fixed/limits.h" + +mkdir "../$name-build"; cd "../$name-build" + +CC="$target-gcc" \ +CXX="$target-g++" \ +AR="$target-ar" \ +RANLIB="$target-ranlib" \ +"../$name-$version/configure" \ + --prefix=/tools \ + --with-local-prefix=/tools \ + --with-native-system-header-dir=/tools/include \ + --enable-languages=c,c++ \ + --disable-libstdcxx-pch \ + --disable-multilib \ + --disable-bootstrap \ + --disable-libgomp + +make; make DESTDIR="$dir_install" install +ln -s gcc "$dir_install/tools/bin/cc" diff --git a/tools/satellites/glibc.sat b/tools/satellites/glibc.sat new file mode 100644 index 0000000..4396b02 --- /dev/null +++ b/tools/satellites/glibc.sat @@ -0,0 +1,20 @@ +name=glibc +version=2.20 + +dlextract "http://ftp.gnu.org/gnu/libc/glibc-2.20.tar.xz" \ + "948a6e06419a01bd51e97206861595b0" + +mkdir "$name-build"; cd "$name-build" + +"../$name-$version/configure" \ + --prefix=/tools \ + --host="$target" \ + --build="$(../glibc-2.20/scripts/config.guess)" \ + --disable-profile \ + --enable-kernel=2.6.32 \ + --with-headers="$dir_install/tools/include" \ + libc_cv_forced_unwind=yes \ + libc_cv_ctors_header=yes \ + libc_cv_c_cleanup=yes + +make; make DESTDIR="$dir_install" install diff --git a/tools/satellites/libstdc.sat b/tools/satellites/libstdc.sat new file mode 100644 index 0000000..3bba1f8 --- /dev/null +++ b/tools/satellites/libstdc.sat @@ -0,0 +1,19 @@ +name=gcc +version=4.9.2 + +dlextract "http://ftp.gnu.org/gnu/$name/$name-$version/$name-$version.tar.bz2" \ + "4df8ee253b7f3863ad0b86359cd39c43" + +mkdir "$name-build"; cd "$name-build" + +"../$name-$version/libstdc++-v3/configure" \ + --host="$target" \ + --prefix=/tools \ + --disable-multilib \ + --disable-shared \ + --disable-nls \ + --disable-libstdcxx-threads \ + --disable-libstdcxx-pch \ + --with-gxx-include-dir="/tools/$target/include/c++/$version" + +make; make DESTDIR="$dir_install" install diff --git a/tools/satellites/linux-api.sat b/tools/satellites/linux-api.sat new file mode 100644 index 0000000..180cd19 --- /dev/null +++ b/tools/satellites/linux-api.sat @@ -0,0 +1,10 @@ +name=linux +version=3.17.2 + +dlextract "https://www.kernel.org/pub/$name/kernel/v3.x/$name-$version.tar.xz" \ + "87444e6f0906e2ec783cf0ed6aab1a56" + +cd "$name-$version" + +make mrproper +make INSTALL_HDR_PATH="$dir_install/tools" headers_install diff --git a/chroot/version-check.sh b/tools/version-check.sh similarity index 100% rename from chroot/version-check.sh rename to tools/version-check.sh