diff --git a/build.bash b/build.bash deleted file mode 100755 index 51dfafd..0000000 --- a/build.bash +++ /dev/null @@ -1,468 +0,0 @@ - - -prechroot_gettext() { - fetch $GETTEXT_URL - - sudo chroot "$SYSROOT" /usr/bin/env -i \ - MAKEFLAGS="$MAKEFLAGS" \ - PATH=/usr/bin:/usr/sbin \ - SOURCES=/sources \ - GETTEXT_VERSION=$GETTEXT_VERSION \ - /usr/bin/bash <<- "EOF" - set -euo pipefail - - cd "$SOURCES" && tar xf gettext-$GETTEXT_VERSION.tar.xz && cd gettext-$GETTEXT_VERSION - - ./configure \ - --disable-shared \ - --silent \ - --quiet - - make - - cp gettext-tools/src/{msgfmt,msgmerge,xgettext} /usr/bin - - cd "$SOURCES" && rm -rf gettext-$GETTEXT_VERSION - EOF -} - -prechroot_bison() { - fetch $BISON_URL - - sudo chroot "$SYSROOT" /usr/bin/env -i \ - MAKEFLAGS="$MAKEFLAGS" \ - PATH=/usr/bin:/usr/sbin \ - SOURCES=/sources \ - BISON_VERSION=$BISON_VERSION \ - /usr/bin/bash <<- "EOF" - set -euo pipefail - - cd "$SOURCES" && tar xf bison-$BISON_VERSION.tar.xz && cd bison-$BISON_VERSION - - ./configure \ - --prefix=/usr \ - --silent \ - --quiet - - make && make install - - cd "$SOURCES" && rm -rf bison-$BISON_VERSION - EOF -} - -prechroot_perl() { - fetch $PERL_URL - - sudo chroot "$SYSROOT" /usr/bin/env -i \ - MAKEFLAGS="$MAKEFLAGS" \ - PATH=/usr/bin:/usr/sbin \ - SOURCES=/sources \ - PERL_VERSION=$PERL_VERSION \ - /usr/bin/bash <<- "EOF" - set -euo pipefail - - cd "$SOURCES" && tar xf perl-$PERL_VERSION.tar.gz && cd perl-$PERL_VERSION - - sh Configure -des \ - -D prefix=/usr \ - -D vendorprefix=/usr \ - -D useshrplib \ - -D privlib=/usr/lib/perl5/$PERL_VERSION/core_perl \ - -D archlib=/usr/lib/perl5/$PERL_VERSION/core_perl \ - -D sitelib=/usr/lib/perl5/$PERL_VERSION/site_perl \ - -D sitearch=/usr/lib/perl5/$PERL_VERSION/site_perl \ - -D vendorlib=/usr/lib/perl5/$PERL_VERSION/vendor_perl \ - -D vendorarch=/usr/lib/perl5/$PERL_VERSION/vendor_perl - - make && make install - - cd "$SOURCES" && rm -rf perl-$PERL_VERSION - EOF -} - -prechroot_python() { - fetch $PYTHON_URL - - sudo chroot "$SYSROOT" /usr/bin/env -i \ - MAKEFLAGS="$MAKEFLAGS" \ - PATH=/usr/bin:/usr/sbin \ - SOURCES=/sources \ - PYTHON_VERSION=$PYTHON_VERSION \ - /usr/bin/bash <<- "EOF" - set -euo pipefail - - cd "$SOURCES" && tar xf Python-$PYTHON_VERSION.tar.xz && cd Python-$PYTHON_VERSION - - ./configure \ - --prefix=/usr \ - --enable-shared \ - --without-static-libpython \ - --disable-test-modules \ - --without-ensurepip \ - --silent \ - --quiet - - make && make install - - rm -rf /usr/lib/python$PYTHON_VERSION/test - - cd "$SOURCES" && rm -rf Python-$PYTHON_VERSION - EOF -} - -prechroot_util_linux() { - fetch $UTIL_LINUX_URL - - sudo chroot "$SYSROOT" /usr/bin/env -i \ - MAKEFLAGS="$MAKEFLAGS" \ - PATH=/usr/bin:/usr/sbin \ - SOURCES=/sources \ - UTIL_LINUX_VERSION=$UTIL_LINUX_VERSION \ - /usr/bin/bash <<- "EOF" - set -euo pipefail - - cd "$SOURCES" && tar xf util-linux-$UTIL_LINUX_VERSION.tar.xz && cd util-linux-$UTIL_LINUX_VERSION - - mkdir -p /var/lib/hwclock - - ./configure --libdir=/usr/lib \ - --runstatedir=/run \ - --disable-chfn-chsh \ - --disable-login \ - --disable-nologin \ - --disable-su \ - --disable-setpriv \ - --disable-runuser \ - --disable-pylibmount \ - --disable-static \ - --disable-liblastlog2 \ - --without-python \ - ADJTIME_PATH=/var/lib/hwclock/adjtime \ - --silent \ - --quiet - - make && make install - - cd "$SOURCES" && rm -rf util-linux-$UTIL_LINUX_VERSION - EOF -} - -prechroot_cleanup() { - sudo chroot "$SYSROOT" /usr/bin/env -i \ - /usr/bin/bash <<- "EOF" - - rm -rf /usr/share/{info,man,doc}/* - - find /usr/{lib,libexec} -name \*.la -delete - - rm -rf /cross - EOF -} - -chroot_tmpfs_setup() { - sudo chroot "$SYSROOT" /usr/bin/env -i /usr/bin/bash <<- "EOF" - ln -s run /var/run - ln -sfv run/lock /var/lock - - install -dv -m 0750 /root - install -dv -m 1777 /tmp /var/tmp - - ln -s proc/self/mounts /etc/mtab - - cat > /etc/hosts <<- "END_OF_FILE" - 127.0.0.1 localhost axe - ::1 localhost - END_OF_FILE - - cat > /etc/passwd <<- "END_OF_FILE" - root:x:0:0:root:/root:/usr/bin/bash - uuidd:x:6:6::/dev/null:/usr/bin/nologin - messagebus:x:7:7::/run/dbus:/usr/bin/nologin - nobody:x:65534:65534::/dev/null:/usr/bin/nologin - END_OF_FILE - - cat > /etc/group <<- "END_OF_FILE" - root:x:0: - tty:x:1: - audio:x:2: - video:x:3: - input:x:4: - wheel:x:5: - uuidd:x:6: - messagebus:x:7: - users:x:999: - nogroup:x:65534: - END_OF_FILE - EOF -} - -chroot_iana_etc() { - fetch $IANA_ETC_URL - - sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources IANA_ETC_VERSION=$IANA_ETC_VERSION /usr/bin/bash <<- "EOF" - set -euo pipefail - - cd "$SOURCES" && tar xf iana-etc-$IANA_ETC_VERSION.tar.gz && cd iana-etc-$IANA_ETC_VERSION - - cp services protocols /etc - - cd "$SOURCES" && rm -rf iana-etc-$IANA_ETC_VERSION - EOF -} - -chroot_glibc() { - fetch $TZDATA_URL - - sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources GLIBC_VERSION=$GLIBC_VERSION LINUX_VERSION=$LINUX_VERSION TZDATA_VERSION=$TZDATA_VERSION /usr/bin/bash <<- "EOF" - set -euo pipefail - - cd "$SOURCES" && tar xf glibc-$GLIBC_VERSION.tar.xz && cd glibc-$GLIBC_VERSION - - patch -Np1 -i ../glibc-fhs-1.patch - - mkdir -p build && cd build - - echo "rootsbindir=/usr/sbin" > configparms - - ../configure \ - --prefix=/usr \ - --disable-werror \ - --disable-nscd \ - libc_cv_slibdir=/usr/lib \ - --enable-stack-protector=strong \ - --enable-kernel= \ - --disable-nls \ - --enable-kernel=$LINUX_VERSION \ - --silent \ - --quiet - - make && make install - - touch /etc/ld.so.conf - sed '/RTLDLIST=/s@/usr@@g' -i /usr/bin/ldd - - cat > /etc/nsswitch.conf <<- "END_OF_FILE" - passwd: files - group: files - shadow: files - - hosts: files dns - networks: files - - protocols: files - services: files - ethers: files - rpc: files - END_OF_FILE - - tar xf $SOURCES/tzdata$TZDATA_VERSION.tar.gz - - ZONEINFO=/usr/share/zoneinfo - - mkdir -p $ZONEINFO/{posix,right} - - for tz in etcetera southamerica northamerica europe africa antarctica asia australasia backward; do - zic -L /dev/null -d $ZONEINFO ${tz} - zic -L /dev/null -d $ZONEINFO/posix ${tz} - zic -L leapseconds -d $ZONEINFO/right ${tz} - done - - cp zone.tab zone1970.tab iso3166.tab $ZONEINFO - - zic -d $ZONEINFO -p Africa/Johannesburg - - unset ZONEINFO tz - - ln -sf /usr/share/zoneinfo/Africa/Johannesburg /etc/localtime - - cat > /etc/ld.so.conf <<- "END_OF_FILE" - /usr/local/lib - /opt/lib - include /etc/ld.so.conf.d/*.conf - END_OF_FILE - - mkdir -p /etc/ld.so.conf.d - - cd "$SOURCES" && rm -rf glibc-$GLIBC_VERSION - EOF -} - -chroot_zlib() { - fetch $ZLIB_URL - - sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources ZLIB_VERSION=$ZLIB_VERSION /usr/bin/bash <<- "EOF" - set -euo pipefail - - cd "$SOURCES" && tar xf zlib-$ZLIB_VERSION.tar.gz && cd zlib-$ZLIB_VERSION - - ./configure \ - --prefix=/usr - - make && make install - - rm -f /usr/lib/libz.a - - cd "$SOURCES" && rm -rf zlib-$ZLIB_VERSION - EOF -} - -chroot_bzip2() { - fetch $BZIP2_URL - - sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources BZIP2_VERSION=$BZIP2_VERSION /usr/bin/bash <<- "EOF" - set -euo pipefail - - cd "$SOURCES" && tar xf bzip2-$BZIP2_VERSION.tar.gz && cd bzip2-$BZIP2_VERSION - - sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile - - make -f Makefile-libbz2_so - - make clean - - make && make PREFIX=/usr install - - cp -a libbz2.so.* /usr/lib - - ln -sf libbz2.so.1.0.8 /usr/lib/libbz2.so - - ln -sf libbz2.so.1.0.8 /usr/lib/libbz2.so.1 - - cp bzip2-shared /usr/bin/bzip2 - - for i in /usr/bin/{bzcat,bunzip2}; do - ln -sf bzip2 $i - done - - rm -f /usr/lib/libbz2.a - - cd "$SOURCES" && rm -rf bzip2-$BZIP2_VERSION - EOF -} - -chroot_xz() { - sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources XZ_VERSION=$XZ_VERSION /usr/bin/bash <<- "EOF" - set -euo pipefail - - cd "$SOURCES" && tar xf xz-$XZ_VERSION.tar.xz && cd xz-$XZ_VERSION - - ./configure \ - --prefix=/usr \ - --disable-static - - make && make install - - cd "$SOURCES" && rm -rf xz-$XZ_VERSION - EOF -} - -chroot_zstd() { - fetch $ZSTD_URL - - sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources ZSTD_VERSION=$ZSTD_VERSION /usr/bin/bash <<- "EOF" - set -euo pipefail - - cd "$SOURCES" && tar xf zstd-$ZSTD_VERSION.tar.gz && cd zstd-$ZSTD_VERSION - - make prefix=/usr - make prefix=/usr install - - rm /usr/lib/libzstd.a - - cd "$SOURCES" && rm -rf zstd-$ZSTD_VERSION - EOF -} - -chroot_file() { - fetch $FILE_URL - - sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources FILE_VERSION=$FILE_VERSION /usr/bin/bash <<- "EOF" - set -euo pipefail - - cd "$SOURCES" && tar xf file-$FILE_VERSION.tar.gz && cd file-$FILE_VERSION - - ./configure \ - --prefix=/usr - - make && make install - - cd "$SOURCES" && rm -rf file-$FILE_VERSION - EOF -} - -chroot_readline() { - fetch $READLINE_URL - - sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources READLINE_VERSION=$READLINE_VERSION /usr/bin/bash <<- "EOF" - set -euo pipefail - - cd "$SOURCES" && tar xf readline-$READLINE_VERSION.tar.gz && cd readline-$READLINE_VERSION - - sed -i '/MV.*old/d' Makefile.in - - sed -i '/{OLDSUFF}/c:' support/shlib-install - - sed -i 's/-Wl,-rpath,[^ ]*//' support/shobj-conf - - sed -e '270a\ - else\ - chars_avail = 1;' \ - -e '288i\ result = -1;' \ - -i.orig input.c - - ./configure \ - --prefix=/usr \ - --disable-static \ - --with-curses - - make SHLIB_LIBS="-lncursesw" && make install - - cd "$SOURCES" && rm -rf readline-$READLINE_VERSION - EOF -} - -chroot_pcre2() { - fetch $PCRE2_URL - - sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources PCRE2_VERSION=$PCRE2_VERSION /usr/bin/bash <<- "EOF" - set -euo pipefail - - cd "$SOURCES" && tar xf pcre2-$PCRE2_VERSION.tar.gz && cd pcre2-$PCRE2_VERSION - - ./configure \ - --prefix=/usr \ - --enable-unicode \ - --enable-jit \ - --enable-pcre2-16 \ - --enable-pcre2-32 \ - --enable-pcre2grep-libz \ - --enable-pcre2grep-libbz2 \ - --enable-pcre2test-libreadline \ - --disable-static - - make && make install - - cd "$SOURCES" && rm -rf pcre2-$PCRE2_VERSION - EOF -} - - - -#change_owner -#do_mount -#prechroot_gettext -#prechroot_bison -#prechroot_perl -#prechroot_python -#prechroot_util_linux -#prechroot_cleanup -#do_unmount -#chroot_iana_etc -#chroot_glibc -#chroot_zlib -#chroot_bzip2 -#chroot_xz -#chroot_zstd -#chroot_file -#chroot_readline -#chroot_pcre2 \ No newline at end of file diff --git a/build.sh b/build.sh index da0e1c1..9283ced 100755 --- a/build.sh +++ b/build.sh @@ -15,7 +15,7 @@ umask 022 create_sysroot bootstrap_builds() { - for build in binutils gcc linux glibc libstc++; do + for build in binutils gcc linux glibc libstdc++; do . "stage/bootstrap/${build}.bash" cd "$PROJDIR" done @@ -28,26 +28,47 @@ toolchain_builds() { done } +prechroot_builds() { + for build in setup bison perl python util_linux cleanup; do + . "stage/prechroot/${build}.bash" + cd "$PROJDIR" + done +} + usage() { echo "usage: build.bash " exit 1 } -if [ $# -eq 1 ]; then - case $1 in - bootstrap) - bootstrap_builds - ;; - toolchain) - toolchain_builds - ;; - *) - usage - ;; - esac -elif [ $# -eq 2 ]; then - . "stage/$1/$2.bash" -else - usage -fi +check_in_run() { + if [[ $# -ge 1 && $# -le 2 ]]; then + case $1 in + bootstap|toolchain) + if [ $# -eq 1 ]; then + "${1}_builds" + else + . "stage/$1/$2.bash" + fi + ;; + prechroot|hroot) + if [ $# -eq 1 ]; then + do_mount + "${1}_builds" + do_unmount + else + do_mount + . "stage/$1/$2.bash" + do_unmount + fi + ;; + *) + usage + ;; + esac + else + usage + fi +} + +check_in_run "$@" \ No newline at end of file diff --git a/stage/chroot/bzip2.bash b/stage/chroot/bzip2.bash new file mode 100644 index 0000000..53410ea --- /dev/null +++ b/stage/chroot/bzip2.bash @@ -0,0 +1,31 @@ +fetch $BZIP2_URL + +sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources BZIP2_VERSION=$BZIP2_VERSION /usr/bin/bash <<- "EOF" + set -euo pipefail + + cd "$SOURCES" && tar xf bzip2-$BZIP2_VERSION.tar.gz && cd bzip2-$BZIP2_VERSION + + sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile + + make -f Makefile-libbz2_so + + make clean + + make && make PREFIX=/usr install + + cp -a libbz2.so.* /usr/lib + + ln -sf libbz2.so.1.0.8 /usr/lib/libbz2.so + + ln -sf libbz2.so.1.0.8 /usr/lib/libbz2.so.1 + + cp bzip2-shared /usr/bin/bzip2 + + for i in /usr/bin/{bzcat,bunzip2}; do + ln -sf bzip2 $i + done + + rm -f /usr/lib/libbz2.a + + cd "$SOURCES" && rm -rf bzip2-$BZIP2_VERSION +EOF \ No newline at end of file diff --git a/stage/chroot/file.bash b/stage/chroot/file.bash new file mode 100644 index 0000000..c3a5a3a --- /dev/null +++ b/stage/chroot/file.bash @@ -0,0 +1,12 @@ +sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources FILE_VERSION=$FILE_VERSION /usr/bin/bash <<- "EOF" + set -euo pipefail + + cd "$SOURCES" && tar xf file-$FILE_VERSION.tar.gz && cd file-$FILE_VERSION + + ./configure \ + --prefix=/usr + + make && make install + + cd "$SOURCES" && rm -rf file-$FILE_VERSION +EOF \ No newline at end of file diff --git a/stage/chroot/glibc.bash b/stage/chroot/glibc.bash new file mode 100644 index 0000000..7e6c3f1 --- /dev/null +++ b/stage/chroot/glibc.bash @@ -0,0 +1,74 @@ +fetch $TZDATA_URL + +sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources GLIBC_VERSION=$GLIBC_VERSION LINUX_VERSION=$LINUX_VERSION TZDATA_VERSION=$TZDATA_VERSION /usr/bin/bash <<- "EOF" + set -euo pipefail + + cd "$SOURCES" && tar xf glibc-$GLIBC_VERSION.tar.xz && cd glibc-$GLIBC_VERSION + + patch -Np1 -i "$SOURCES/glibc-fhs-1.patch" + + mkdir -p build && cd build + + echo "rootsbindir=/usr/sbin" > configparms + + ../configure \ + --prefix=/usr \ + --disable-werror \ + --disable-nscd \ + libc_cv_slibdir=/usr/lib \ + --enable-stack-protector=strong \ + --enable-kernel= \ + --disable-nls \ + --enable-kernel=$LINUX_VERSION \ + --silent \ + --quiet + + make && make install + + touch /etc/ld.so.conf + sed '/RTLDLIST=/s@/usr@@g' -i /usr/bin/ldd + + cat > /etc/nsswitch.conf <<- "END_OF_FILE" + passwd: files + group: files + shadow: files + + hosts: files dns + networks: files + + protocols: files + services: files + ethers: files + rpc: files + END_OF_FILE + + tar xf $SOURCES/tzdata$TZDATA_VERSION.tar.gz + + ZONEINFO=/usr/share/zoneinfo + + mkdir -p $ZONEINFO/{posix,right} + + for tz in etcetera southamerica northamerica europe africa antarctica asia australasia backward; do + zic -L /dev/null -d $ZONEINFO ${tz} + zic -L /dev/null -d $ZONEINFO/posix ${tz} + zic -L leapseconds -d $ZONEINFO/right ${tz} + done + + cp zone.tab zone1970.tab iso3166.tab $ZONEINFO + + zic -d $ZONEINFO -p Africa/Johannesburg + + unset ZONEINFO tz + + ln -sf /usr/share/zoneinfo/Africa/Johannesburg /etc/localtime + + cat > /etc/ld.so.conf <<- "END_OF_FILE" + /usr/local/lib + /opt/lib + include /etc/ld.so.conf.d/*.conf + END_OF_FILE + + mkdir -p /etc/ld.so.conf.d + + cd "$SOURCES" && rm -rf glibc-$GLIBC_VERSION +EOF \ No newline at end of file diff --git a/stage/chroot/iana-etc.bash b/stage/chroot/iana-etc.bash new file mode 100644 index 0000000..90b9baf --- /dev/null +++ b/stage/chroot/iana-etc.bash @@ -0,0 +1,12 @@ + +fetch $IANA_ETC_URL + +sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources IANA_ETC_VERSION=$IANA_ETC_VERSION /usr/bin/bash <<- "EOF" + set -euo pipefail + + cd "$SOURCES" && tar xf iana-etc-$IANA_ETC_VERSION.tar.gz && cd iana-etc-$IANA_ETC_VERSION + + cp services protocols /etc + + cd "$SOURCES" && rm -rf iana-etc-$IANA_ETC_VERSION +EOF \ No newline at end of file diff --git a/stage/chroot/pcre2.bash b/stage/chroot/pcre2.bash new file mode 100644 index 0000000..07269f0 --- /dev/null +++ b/stage/chroot/pcre2.bash @@ -0,0 +1,22 @@ +fetch $PCRE2_URL + +sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources PCRE2_VERSION=$PCRE2_VERSION /usr/bin/bash <<- "EOF" + set -euo pipefail + + cd "$SOURCES" && tar xf pcre2-$PCRE2_VERSION.tar.gz && cd pcre2-$PCRE2_VERSION + + ./configure \ + --prefix=/usr \ + --enable-unicode \ + --enable-jit \ + --enable-pcre2-16 \ + --enable-pcre2-32 \ + --enable-pcre2grep-libz \ + --enable-pcre2grep-libbz2 \ + --enable-pcre2test-libreadline \ + --disable-static + + make && make install + + cd "$SOURCES" && rm -rf pcre2-$PCRE2_VERSION +EOF diff --git a/stage/chroot/readline.bash b/stage/chroot/readline.bash new file mode 100644 index 0000000..6922d2e --- /dev/null +++ b/stage/chroot/readline.bash @@ -0,0 +1,28 @@ +fetch $READLINE_URL + +sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources READLINE_VERSION=$READLINE_VERSION /usr/bin/bash <<- "EOF" + set -euo pipefail + + cd "$SOURCES" && tar xf readline-$READLINE_VERSION.tar.gz && cd readline-$READLINE_VERSION + + sed -i '/MV.*old/d' Makefile.in + + sed -i '/{OLDSUFF}/c:' support/shlib-install + + sed -i 's/-Wl,-rpath,[^ ]*//' support/shobj-conf + + sed -e '270a\ + else\ + chars_avail = 1;' \ + -e '288i\ result = -1;' \ + -i.orig input.c + + ./configure \ + --prefix=/usr \ + --disable-static \ + --with-curses + + make SHLIB_LIBS="-lncursesw" && make install + + cd "$SOURCES" && rm -rf readline-$READLINE_VERSION +EOF \ No newline at end of file diff --git a/stage/chroot/xz.bash b/stage/chroot/xz.bash new file mode 100644 index 0000000..e6530dc --- /dev/null +++ b/stage/chroot/xz.bash @@ -0,0 +1,13 @@ +sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources XZ_VERSION=$XZ_VERSION /usr/bin/bash <<- "EOF" + set -euo pipefail + + cd "$SOURCES" && tar xf xz-$XZ_VERSION.tar.xz && cd xz-$XZ_VERSION + + ./configure \ + --prefix=/usr \ + --disable-static + + make && make install + + cd "$SOURCES" && rm -rf xz-$XZ_VERSION +EOF \ No newline at end of file diff --git a/stage/chroot/zlib.bash b/stage/chroot/zlib.bash new file mode 100644 index 0000000..f4eef93 --- /dev/null +++ b/stage/chroot/zlib.bash @@ -0,0 +1,17 @@ + +fetch $ZLIB_URL + +sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources ZLIB_VERSION=$ZLIB_VERSION /usr/bin/bash <<- "EOF" + set -euo pipefail + + cd "$SOURCES" && tar xf zlib-$ZLIB_VERSION.tar.gz && cd zlib-$ZLIB_VERSION + + ./configure \ + --prefix=/usr + + make && make install + + rm -f /usr/lib/libz.a + + cd "$SOURCES" && rm -rf zlib-$ZLIB_VERSION +EOF \ No newline at end of file diff --git a/stage/chroot/zstd.bash b/stage/chroot/zstd.bash new file mode 100644 index 0000000..e83ffbf --- /dev/null +++ b/stage/chroot/zstd.bash @@ -0,0 +1,15 @@ + +fetch $ZSTD_URL + +sudo chroot "$SYSROOT" /usr/bin/env -i MAKEFLAGS="$MAKEFLAGS" PATH=/usr/bin:/usr/sbin SOURCES=/sources ZSTD_VERSION=$ZSTD_VERSION /usr/bin/bash <<- "EOF" + set -euo pipefail + + cd "$SOURCES" && tar xf zstd-$ZSTD_VERSION.tar.gz && cd zstd-$ZSTD_VERSION + + make prefix=/usr + make prefix=/usr install + + rm /usr/lib/libzstd.a + + cd "$SOURCES" && rm -rf zstd-$ZSTD_VERSION +EOF \ No newline at end of file diff --git a/stage/prechroot/bison.bash b/stage/prechroot/bison.bash new file mode 100644 index 0000000..787ea64 --- /dev/null +++ b/stage/prechroot/bison.bash @@ -0,0 +1,22 @@ + +fetch $BISON_URL + +sudo chroot "$SYSROOT" /usr/bin/env -i \ + MAKEFLAGS="$MAKEFLAGS" \ + PATH=/usr/bin:/usr/sbin \ + SOURCES=/sources \ + BISON_VERSION=$BISON_VERSION \ + /usr/bin/bash <<- "EOF" + set -euo pipefail + + cd "$SOURCES" && tar xf bison-$BISON_VERSION.tar.xz && cd bison-$BISON_VERSION + + ./configure \ + --prefix=/usr \ + --silent \ + --quiet + + make && make install + + cd "$SOURCES" && rm -rf bison-$BISON_VERSION +EOF \ No newline at end of file diff --git a/stage/prechroot/cleanup.bash b/stage/prechroot/cleanup.bash new file mode 100644 index 0000000..dedf7f5 --- /dev/null +++ b/stage/prechroot/cleanup.bash @@ -0,0 +1,10 @@ + +sudo chroot "$SYSROOT" /usr/bin/env -i \ + /usr/bin/bash <<- "EOF" + + rm -rf /usr/share/{info,man,doc}/* + + find /usr/{lib,libexec} -name \*.la -delete + + rm -rf /cross +EOF \ No newline at end of file diff --git a/stage/prechroot/perl.bash b/stage/prechroot/perl.bash new file mode 100644 index 0000000..19cbe5f --- /dev/null +++ b/stage/prechroot/perl.bash @@ -0,0 +1,28 @@ + +fetch $PERL_URL + +sudo chroot "$SYSROOT" /usr/bin/env -i \ + MAKEFLAGS="$MAKEFLAGS" \ + PATH=/usr/bin:/usr/sbin \ + SOURCES=/sources \ + PERL_VERSION=$PERL_VERSION \ + /usr/bin/bash <<- "EOF" + set -euo pipefail + + cd "$SOURCES" && tar xf perl-$PERL_VERSION.tar.gz && cd perl-$PERL_VERSION + + sh Configure -des \ + -D prefix=/usr \ + -D vendorprefix=/usr \ + -D useshrplib \ + -D privlib=/usr/lib/perl5/$PERL_VERSION/core_perl \ + -D archlib=/usr/lib/perl5/$PERL_VERSION/core_perl \ + -D sitelib=/usr/lib/perl5/$PERL_VERSION/site_perl \ + -D sitearch=/usr/lib/perl5/$PERL_VERSION/site_perl \ + -D vendorlib=/usr/lib/perl5/$PERL_VERSION/vendor_perl \ + -D vendorarch=/usr/lib/perl5/$PERL_VERSION/vendor_perl + + make && make install + + cd "$SOURCES" && rm -rf perl-$PERL_VERSION +EOF \ No newline at end of file diff --git a/stage/prechroot/python.bash b/stage/prechroot/python.bash new file mode 100644 index 0000000..dc8580b --- /dev/null +++ b/stage/prechroot/python.bash @@ -0,0 +1,28 @@ + +fetch $PYTHON_URL + +sudo chroot "$SYSROOT" /usr/bin/env -i \ + MAKEFLAGS="$MAKEFLAGS" \ + PATH=/usr/bin:/usr/sbin \ + SOURCES=/sources \ + PYTHON_VERSION=$PYTHON_VERSION \ + /usr/bin/bash <<- "EOF" + set -euo pipefail + + cd "$SOURCES" && tar xf Python-$PYTHON_VERSION.tar.xz && cd Python-$PYTHON_VERSION + + ./configure \ + --prefix=/usr \ + --enable-shared \ + --without-static-libpython \ + --disable-test-modules \ + --without-ensurepip \ + --silent \ + --quiet + + make && make install + + rm -rf /usr/lib/python$PYTHON_VERSION/test + + cd "$SOURCES" && rm -rf Python-$PYTHON_VERSION +EOF \ No newline at end of file diff --git a/stage/prechroot/setup.bash b/stage/prechroot/setup.bash new file mode 100644 index 0000000..e08bbb2 --- /dev/null +++ b/stage/prechroot/setup.bash @@ -0,0 +1,35 @@ + +sudo chroot "$SYSROOT" /usr/bin/env -i /usr/bin/bash <<- "EOF" + ln -s /run /var/run + ln -sfv /run/lock /var/lock + + install -dv -m 0750 /root + install -dv -m 1777 /tmp /var/tmp + + ln -s proc/self/mounts /etc/mtab + + cat > /etc/hosts <<- "END_OF_FILE" + 127.0.0.1 localhost axe + ::1 localhost + END_OF_FILE + + cat > /etc/passwd <<- "END_OF_FILE" + root:x:0:0:root:/root:/usr/bin/bash + uuidd:x:6:6::/dev/null:/usr/bin/nologin + messagebus:x:7:7::/run/dbus:/usr/bin/nologin + nobody:x:65534:65534::/dev/null:/usr/bin/nologin + END_OF_FILE + + cat > /etc/group <<- "END_OF_FILE" + root:x:0: + tty:x:1: + audio:x:2: + video:x:3: + input:x:4: + wheel:x:5: + uuidd:x:6: + messagebus:x:7: + users:x:999: + nogroup:x:65534: + END_OF_FILE +EOF \ No newline at end of file diff --git a/stage/prechroot/util_linux.bash b/stage/prechroot/util_linux.bash new file mode 100644 index 0000000..72e9380 --- /dev/null +++ b/stage/prechroot/util_linux.bash @@ -0,0 +1,35 @@ + +fetch $UTIL_LINUX_URL + +sudo chroot "$SYSROOT" /usr/bin/env -i \ + MAKEFLAGS="$MAKEFLAGS" \ + PATH=/usr/bin:/usr/sbin \ + SOURCES=/sources \ + UTIL_LINUX_VERSION=$UTIL_LINUX_VERSION \ + /usr/bin/bash <<- "EOF" + set -euo pipefail + + cd "$SOURCES" && tar xf util-linux-$UTIL_LINUX_VERSION.tar.xz && cd util-linux-$UTIL_LINUX_VERSION + + mkdir -p /var/lib/hwclock + + ./configure --libdir=/usr/lib \ + --runstatedir=/run \ + --disable-chfn-chsh \ + --disable-login \ + --disable-nologin \ + --disable-su \ + --disable-setpriv \ + --disable-runuser \ + --disable-pylibmount \ + --disable-static \ + --disable-liblastlog2 \ + --without-python \ + ADJTIME_PATH=/var/lib/hwclock/adjtime \ + --silent \ + --quiet + + make && make install + + cd "$SOURCES" && rm -rf util-linux-$UTIL_LINUX_VERSION +EOF \ No newline at end of file diff --git a/utilities.bash b/utilities.bash index 0bf84f5..36bf0b9 100644 --- a/utilities.bash +++ b/utilities.bash @@ -1,6 +1,6 @@ #!/usr/bin/env bash -create_directories() { +create_sysroot() { if [ ! -d "$SYSROOT" ]; then mkdir -p "$SYSROOT"/{etc,cross,sources,usr,dev,proc,sys,run} mkdir -p "$SYSROOT"/usr/{bin,sbin,lib,include} @@ -11,53 +11,11 @@ create_directories() { done ln -fs usr/lib "$SYSROOT"/lib64 - - ln -fs run "$SYSROOT"/var/run - ln -fs run/lock "$SYSROOT"/var/lock - - install -d -m 0750 "$SYSROOT"/root - install -d -m 1777 "$SYSROOT"/tmp "$SYSROOT"/var/tmp fi } -create_files() { - if [[ ! -L "$SYSROOT"/etc/mtab ]]; then - sudo ln -s proc/self/mounts "$SYSROOT"/etc/mtab - - cat > "$SYSROOT"/etc/hosts <<- "EOF" - 127.0.0.1 localhost axe - ::1 localhost - EOF - - cat > "$SYSROOT"/etc/passwd <<- "EOF" - root:x:0:0:root:/root:/usr/bin/bash - uuidd:x:6:6::/dev/null:/usr/bin/nologin - messagebus:x:7:7::/run/dbus:/usr/bin/nologin - nobody:x:65534:65534::/dev/null:/usr/bin/nologin - EOF - - cat > "$SYSROOT"/etc/group <<- "EOF" - root:x:0: - tty:x:1: - audio:x:2: - video:x:3: - input:x:4: - wheel:x:5: - uuidd:x:6: - messagebus:x:7: - users:x:999: - nogroup:x:65534: - EOF - fi -} - -create_sysroot() { - create_directories - create_files -} - change_owner() { - sudo chown -R root:root "$SYSROOT"/{bin,cross,dev,etc,lib,lib64,proc,sys,root,run,sbin,sys,tmp,usr,var} + sudo chown -R root:root "$SYSROOT"/{bin,cross,dev,etc,lib,lib64,proc,sys,run,sbin,sys,usr,var} } do_mount() {