diff --git a/steps-guix/bash-4.4.23-1/pass1.sh b/steps-guix/bash-4.4.23-1/pass1.sh new file mode 100644 index 00000000..35ff0d51 --- /dev/null +++ b/steps-guix/bash-4.4.23-1/pass1.sh @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +SEED_PREFIX="/bootstrap-seeds/bash-4.4.23-1" + +src_configure() { + ./configure \ + --prefix="${SEED_PREFIX}" \ + --without-bash-malloc \ + --disable-nls \ + --enable-static-link \ + --build="${TARGET}" \ + bash_cv_dev_stdin=absent \ + bash_cv_dev_fd=whacky +} + +src_compile() { + make -j1 +} + +src_install() { + install -D -m 0755 bash "${DESTDIR}${SEED_PREFIX}/bin/bash" + ln -sf bash "${DESTDIR}${SEED_PREFIX}/bin/sh" +} diff --git a/steps-guix/bash-4.4.23-1/sources b/steps-guix/bash-4.4.23-1/sources new file mode 100644 index 00000000..b3986593 --- /dev/null +++ b/steps-guix/bash-4.4.23-1/sources @@ -0,0 +1 @@ +f https://ftp.gnu.org/gnu/bash/bash-4.4.tar.gz d86b3392c1202e8ff5a423b302e6284db7f8f435ea9f39b5b1b20fd3ac36dfcb diff --git a/steps-guix/bzip2-1.0.6/pass1.sh b/steps-guix/bzip2-1.0.6/pass1.sh new file mode 100644 index 00000000..9236e3aa --- /dev/null +++ b/steps-guix/bzip2-1.0.6/pass1.sh @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +SEED_PREFIX="/bootstrap-seeds/bzip2-1.0.6" + +src_configure() { + : +} + +src_compile() { + make "${MAKEJOBS}" CFLAGS="-O2" LDFLAGS="-static" +} + +src_install() { + make PREFIX="${SEED_PREFIX}" DESTDIR="${DESTDIR}" install +} diff --git a/steps-guix/bzip2-1.0.6/sources b/steps-guix/bzip2-1.0.6/sources new file mode 100644 index 00000000..9c5da37f --- /dev/null +++ b/steps-guix/bzip2-1.0.6/sources @@ -0,0 +1 @@ +f https://sourceware.org/pub/bzip2/bzip2-1.0.6.tar.gz a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd diff --git a/steps-guix/coreutils-8.30/pass1.sh b/steps-guix/coreutils-8.30/pass1.sh new file mode 100644 index 00000000..c1c5bb97 --- /dev/null +++ b/steps-guix/coreutils-8.30/pass1.sh @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +SEED_PREFIX="/bootstrap-seeds/coreutils-8.30" + +src_configure() { + FORCE_UNSAFE_CONFIGURE=1 ./configure \ + --prefix="${SEED_PREFIX}" \ + --disable-nls \ + --disable-silent-rules \ + --enable-no-install-program=stdbuf,libstdbuf.so \ + CFLAGS="-Os -g0" \ + LDFLAGS="-static -pthread" \ + gl_cv_func_getcwd_path_max="no, but it is partly working" \ + gl_cv_prog_perl="no" +} + +src_compile() { + make "${MAKEJOBS}" MAKEINFO=true GPERF=true +} + +src_install() { + make DESTDIR="${DESTDIR}" MAKEINFO=true install +} diff --git a/steps-guix/coreutils-8.30/sources b/steps-guix/coreutils-8.30/sources new file mode 100644 index 00000000..7a17d8bc --- /dev/null +++ b/steps-guix/coreutils-8.30/sources @@ -0,0 +1 @@ +f https://mirrors.kernel.org/gnu/coreutils/coreutils-8.30.tar.xz e831b3a86091496cdba720411f9748de81507798f6130adeaef872d206e1b057 diff --git a/steps-guix/gawk-4.2.1/pass1.sh b/steps-guix/gawk-4.2.1/pass1.sh new file mode 100644 index 00000000..49c64c11 --- /dev/null +++ b/steps-guix/gawk-4.2.1/pass1.sh @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +SEED_PREFIX="/bootstrap-seeds/gawk-4.2.1" + +src_prepare() { + default +} + +src_configure() { + CFLAGS="-O2" LDFLAGS="-static" ./configure \ + --prefix="${SEED_PREFIX}" \ + --disable-nls \ + --disable-shared +} + +src_compile() { + default_src_compile +} + +src_install() { + make DESTDIR="${DESTDIR}" install +} diff --git a/steps-guix/gawk-4.2.1/sources b/steps-guix/gawk-4.2.1/sources new file mode 100644 index 00000000..225b30a6 --- /dev/null +++ b/steps-guix/gawk-4.2.1/sources @@ -0,0 +1 @@ +f https://mirrors.kernel.org/gnu/gawk/gawk-4.2.1.tar.xz d1119785e746d46a8209d28b2de404a57f983aa48670f4e225531d3bdc175551 diff --git a/steps-guix/gdbm-1.8.3/pass1.sh b/steps-guix/gdbm-1.8.3/pass1.sh index fd76d51d..680169dd 100644 --- a/steps-guix/gdbm-1.8.3/pass1.sh +++ b/steps-guix/gdbm-1.8.3/pass1.sh @@ -5,16 +5,11 @@ src_prepare() { } src_configure() { - local host_triplet - host_triplet="$(gcc -dumpmachine)" - PATH="${PREFIX}/bin:/usr/bin:/bin" \ ./configure \ --prefix="${PREFIX}" \ --libdir="${LIBDIR}" \ --includedir="${PREFIX}/include" \ - --host="${host_triplet}" \ - --build="${host_triplet}" \ --enable-static \ --enable-shared } diff --git a/steps-guix/grep-3.1/pass1.sh b/steps-guix/grep-3.1/pass1.sh new file mode 100644 index 00000000..b86201f5 --- /dev/null +++ b/steps-guix/grep-3.1/pass1.sh @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +SEED_PREFIX="/bootstrap-seeds/grep-3.1" + +src_configure() { + CFLAGS="-O2" LDFLAGS="-static" ./configure \ + --prefix="${SEED_PREFIX}" \ + --disable-perl-regexp \ + --disable-shared +} + +src_compile() { + default_src_compile +} + +src_install() { + make DESTDIR="${DESTDIR}" install +} diff --git a/steps-guix/grep-3.1/sources b/steps-guix/grep-3.1/sources new file mode 100644 index 00000000..a3d67aac --- /dev/null +++ b/steps-guix/grep-3.1/sources @@ -0,0 +1 @@ +f https://mirrors.kernel.org/gnu/grep/grep-3.1.tar.xz db625c7ab3bb3ee757b3926a5cfa8d9e1c3991ad24707a83dde8a5ef2bf7a07e diff --git a/steps-guix/guile-2.2.4/pass1.sh b/steps-guix/guile-2.2.4/pass1.sh new file mode 100644 index 00000000..fcd89f3d --- /dev/null +++ b/steps-guix/guile-2.2.4/pass1.sh @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +SEED_PREFIX="/bootstrap-seeds/guile-2.2.4" + +src_prepare() { + default +} + +src_configure() { + ./configure \ + --prefix="${SEED_PREFIX}" \ + --disable-shared \ + --enable-static +} + +src_compile() { + default_src_compile +} + +src_install() { + local stage + stage="${DESTDIR}${SEED_PREFIX}" + + make DESTDIR="${DESTDIR}" install + seed_make_repro_tar_xz "${stage}" "${DISTFILES}/guile-static-stripped-2.2.4-i686-linux.tar.xz" +} diff --git a/steps-guix/guile-2.2.4/sources b/steps-guix/guile-2.2.4/sources new file mode 100644 index 00000000..cc64c07f --- /dev/null +++ b/steps-guix/guile-2.2.4/sources @@ -0,0 +1 @@ +f https://mirrors.kernel.org/gnu/guile/guile-2.2.4.tar.xz d9e8b94af7b206fcf52bec6501b921bd7d0bd7a31fb7e896a35ba8253678e31e diff --git a/steps-guix/guix-1.5.0/pass1.sh b/steps-guix/guix-1.5.0/pass1.sh new file mode 100755 index 00000000..68b598ff --- /dev/null +++ b/steps-guix/guix-1.5.0/pass1.sh @@ -0,0 +1,66 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +src_prepare() { + local bootstrap_scm patch_template rendered_patch + + default + + if [ ! -f /tmp/guix-bootstrap-seeds.env ]; then + echo "Missing /tmp/guix-bootstrap-seeds.env" >&2 + false + fi + . /tmp/guix-bootstrap-seeds.env + + bootstrap_scm="gnu/packages/bootstrap.scm" + patch_template="${base_dir}/patches/bootstrap-local-seeds.patch.in" + rendered_patch="/tmp/guix-bootstrap-local-seeds.patch" + + if [ ! -f "${patch_template}" ]; then + echo "Missing patch template: ${patch_template}" >&2 + false + fi + + sed \ + -e "s|@EXEC_BASH_HASH@|${EXEC_BASH_HASH}|g" \ + -e "s|@EXEC_MKDIR_HASH@|${EXEC_MKDIR_HASH}|g" \ + -e "s|@EXEC_TAR_HASH@|${EXEC_TAR_HASH}|g" \ + -e "s|@EXEC_XZ_HASH@|${EXEC_XZ_HASH}|g" \ + -e "s|@STATIC_BINARIES_SEED_HASH@|${STATIC_BINARIES_SEED_HASH}|g" \ + -e "s|@GUILE_SEED_HASH@|${GUILE_SEED_HASH}|g" \ + "${patch_template}" > "${rendered_patch}" + + if grep -Eq '@[A-Z0-9_]+@' "${rendered_patch}"; then + echo "Unexpanded placeholder found in ${rendered_patch}" >&2 + false + fi + + patch --dry-run -p1 < "${rendered_patch}" + patch -p1 < "${rendered_patch}" + + grep -q 'file:///external/distfiles/' "${bootstrap_scm}" + grep -q "${EXEC_BASH_HASH}" "${bootstrap_scm}" + grep -q "${STATIC_BINARIES_SEED_HASH}" "${bootstrap_scm}" + grep -q "${GUILE_SEED_HASH}" "${bootstrap_scm}" + grep -q "All bootstrap binaries must come from local, reproducible distfiles." "${bootstrap_scm}" + grep -q "%bootstrap-linux-headers-base-urls" "${bootstrap_scm}" + grep -q "Offline bootstrap environment: require explicit channels." guix/channels.scm +} + +src_configure() { + local host_triplet + host_triplet="$(gcc -dumpmachine)" + + ./configure \ + --prefix="${PREFIX}" \ + --libdir="${LIBDIR}" \ + --host="${host_triplet}" \ + --build="${host_triplet}" +} + +src_compile() { + default_src_compile +} + +src_install() { + default_src_install +} diff --git a/steps-guix/guix-1.5.0/patches/bootstrap-local-seeds.patch.in b/steps-guix/guix-1.5.0/patches/bootstrap-local-seeds.patch.in new file mode 100644 index 00000000..91c7209e --- /dev/null +++ b/steps-guix/guix-1.5.0/patches/bootstrap-local-seeds.patch.in @@ -0,0 +1,112 @@ +--- a/gnu/packages/bootstrap.scm ++++ b/gnu/packages/bootstrap.scm +@@ -109,13 +109,13 @@ + ,(base32 "1cqqavghjfr0iwxqf61lrssv27wfigysgq2rs4rm1gkmn04yn1k3"))) + ("i686-linux" + ("bash" +- ,(base32 "0rjaxyzjdllfkf1abczvgaf3cdcc7mmahyvdbkjmjzhgz92pv23g")) ++ ,(base32 "@EXEC_BASH_HASH@")) + ("mkdir" +- ,(base32 "133ybmfpkmsnysrzbngwvbysqnsmfi8is8zifs7i7n6n600h4s1w")) ++ ,(base32 "@EXEC_MKDIR_HASH@")) + ("tar" +- ,(base32 "07830bx29ad5i0l1ykj0g0b1jayjdblf01sr3ww9wbnwdbzinqms")) ++ ,(base32 "@EXEC_TAR_HASH@")) + ("xz" +- ,(base32 "0i9kxdi17bm5gxfi2xzm0y73p3ii0cqxli1sbljm6rh2fjgyn90k"))) ++ ,(base32 "@EXEC_XZ_HASH@"))) + ("i586-gnu" + ("bash" + ,(base32 "1as8649aqaibahhhrvkj10ci8shpi4hq5n7gnik8rhhy0dc1jarg")) +@@ -164,15 +164,12 @@ + + (define %bootstrap-executable-base-urls + ;; This is where the bootstrap executables come from. +- '("https://ftpmirror.gnu.org/guix/bootstrap/" +- "https://git.savannah.gnu.org/cgit/guix.git/plain/gnu/packages/bootstrap/" +- "https://alpha.gnu.org/gnu/guix/bootstrap/" +- "http://flashner.co.il/guix/bootstrap/" +- "http://lilypond.org/janneke/guix/")) ++ '("file:///external/distfiles/")) + + (define (bootstrap-executable-file-name system program) + "Return the FILE-NAME part of url where PROGRAM can be found for SYSTEM." + (match system ++ ("i686-linux" (string-append "i686-linux/bootstrap-exec-" program "-i686-linux")) + ("powerpc64le-linux" (string-append system "/20210106/" program)) + ("i586-gnu" (string-append system "/20200326/" program)) + ("x86_64-gnu" (string-append system "/20241122/" program)) +@@ -388,15 +385,15 @@ + ("riscv64-linux" + "/20210725/guile-3.0.2.tar.xz") + (_ +- "/20131110/guile-2.0.9.tar.xz")))) ++ "/guile-static-stripped-2.2.4-i686-linux.tar.xz")))) + + (define (bootstrap-guile-hash system) + "Return the SHA256 hash of the Guile bootstrap tarball for SYSTEM." + (match system + ("x86_64-linux" +- (base32 "1w2p5zyrglzzniqgvyn1b55vprfzhgk8vzbzkkbdgl5248si0yq3")) ++ (base32 "@GUILE_SEED_HASH@")) + ("i686-linux" +- (base32 "0im800m30abgh7msh331pcbjvb4n02smz5cfzf1srv0kpx3csmxp")) ++ (base32 "@GUILE_SEED_HASH@")) + ("mips64el-linux" + (base32 "0fzp93lvi0hn54acc0fpvhc7bvl0yc853k62l958cihk03q80ilr")) + ("armhf-linux" +@@ -458,8 +455,8 @@ + (lambda (p) + (format p "\ + #!~a +-export GUILE_SYSTEM_PATH=~a/share/guile/2.0 +-export GUILE_SYSTEM_COMPILED_PATH=~a/lib/guile/2.0/ccache ++export GUILE_SYSTEM_PATH=~a/share/guile/2.2 ++export GUILE_SYSTEM_COMPILED_PATH=~a/lib/guile/2.2/ccache + exec -a \"~a0\" ~a \"~a@\"\n" + bash out out dollar guile-real dollar))) + (chmod guile #o555) +@@ -480,8 +477,8 @@ + ~a -dc < $GUILE_TARBALL | ~a xv + + # Use the bootstrap guile to create its own wrapper to set the load path. +-GUILE_SYSTEM_PATH=$out/share/guile/2.0 \ +-GUILE_SYSTEM_COMPILED_PATH=$out/lib/guile/2.0/ccache \ ++GUILE_SYSTEM_PATH=$out/share/guile/2.2 \ ++GUILE_SYSTEM_COMPILED_PATH=$out/lib/guile/2.2/ccache \ + $out/bin/guile -c ~s $out ~a + + # Sanity check. +@@ -625,16 +622,16 @@ + ("riscv64-linux" + "/20210725/static-binaries.tar.xz") + (_ +- "/20131110/static-binaries.tar.xz"))) ++ "/static-binaries-0-i686-linux.tar.xz"))) + %bootstrap-base-urls)) + (sha256 + (match system + ("x86_64-linux" + (base32 +- "0c533p9dhczzcsa1117gmfq3pc8w362g4mx84ik36srpr7cx2bg4")) ++ "@STATIC_BINARIES_SEED_HASH@")) + ("i686-linux" + (base32 +- "0s5b3jb315n13m1k8095l0a5hfrsz8g0fv1b6riyc5hnxqyphlak")) ++ "@STATIC_BINARIES_SEED_HASH@")) + ("armhf-linux" + (base32 + "0gf0fn2kbpxkjixkmx5f4z6hv6qpmgixl69zgg74dbsfdfj8jdv5")) +--- a/guix/channels.scm ++++ b/guix/channels.scm +@@ -194,8 +194,8 @@ + (introduction %guix-channel-introduction))) + + (define %default-channels +- ;; Default list of channels. +- (list %default-guix-channel)) ++ ;; Offline bootstrap environment: require explicit channels. ++ '()) + + (define (guix-channel? channel) + "Return true if CHANNEL is the 'guix' channel." diff --git a/steps-guix/guix-1.5.0/patches/enforce-local-bootstrap-binaries-except-linux-headers.patch b/steps-guix/guix-1.5.0/patches/enforce-local-bootstrap-binaries-except-linux-headers.patch new file mode 100644 index 00000000..2ec96fc2 --- /dev/null +++ b/steps-guix/guix-1.5.0/patches/enforce-local-bootstrap-binaries-except-linux-headers.patch @@ -0,0 +1,34 @@ +--- guix-1.5.0/gnu/packages/bootstrap.scm ++++ guix-1.5.0/gnu/packages/bootstrap.scm +@@ -357,8 +357,9 @@ + ;;; Bootstrap packages. + ;;; + +-(define %bootstrap-base-urls +- ;; This is where the initial binaries come from. ++(define %bootstrap-linux-headers-base-urls ++ ;; Keep linux headers as an explicit exception: text headers can still come ++ ;; from the historical bootstrap mirrors. + '("https://ftpmirror.gnu.org/guix/bootstrap/" + "https://ftp.gnu.org/gnu/guix/bootstrap" + "https://alpha.gnu.org/gnu/guix/bootstrap" +@@ -369,6 +370,10 @@ + "http://flashner.co.il/guix/bootstrap" + "http://lilypond.org/janneke/guix/")) + ++(define %bootstrap-base-urls ++ ;; All bootstrap binaries must come from local, reproducible distfiles. ++ '("file:///external/distfiles")) ++ + (define (bootstrap-guile-url-path system) + "Return the URI for FILE." + (string-append "/" system +@@ -684,7 +689,7 @@ + (uri (map (cute string-append <> + "/i686-linux/20190815/" + "linux-libre-headers-stripped-4.14.67-i686-linux.tar.xz") +- %bootstrap-base-urls)) ++ %bootstrap-linux-headers-base-urls)) + (sha256 + (base32 + "0sm2z9x4wk45bh6qfs94p0w1d6hsy6dqx9sw38qsqbvxwa1qzk8s")))) diff --git a/steps-guix/guix-1.5.0/sources b/steps-guix/guix-1.5.0/sources new file mode 100644 index 00000000..95a73b4d --- /dev/null +++ b/steps-guix/guix-1.5.0/sources @@ -0,0 +1 @@ +f https://ftpmirror.gnu.org/gnu/guix/guix-1.5.0.tar.gz df2102eed00aff0b17275654a42f094c8a1117ec065884eb1ff76005e47415c5 diff --git a/steps-guix/guix-hash-compat-1.5.0/pass1.sh b/steps-guix/guix-hash-compat-1.5.0/pass1.sh new file mode 100644 index 00000000..41f280fe --- /dev/null +++ b/steps-guix/guix-hash-compat-1.5.0/pass1.sh @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +src_prepare() { + default +} + +src_configure() { + : +} + +src_compile() { + : +} + +src_install() { + local compat_src + compat_src="${DESTDIR}/usr/libexec/guix-hash-compat/guix-1.5.0" + + mkdir -p "${compat_src}" + cp -a . "${compat_src}/" + + install -D -m 0755 /dev/stdin "${DESTDIR}/usr/bin/guix-hash-compat" <<'EOS' +#!/bin/sh +set -e + +src_dir="/usr/libexec/guix-hash-compat/guix-1.5.0" +if [ -d /tmp/guix-1.5.0 ]; then + src_dir="/tmp/guix-1.5.0" +fi + +cd "${src_dir}" +exec ./pre-inst-env guix hash "$@" +EOS +} diff --git a/steps-guix/guix-hash-compat-1.5.0/sources b/steps-guix/guix-hash-compat-1.5.0/sources new file mode 100644 index 00000000..95a73b4d --- /dev/null +++ b/steps-guix/guix-hash-compat-1.5.0/sources @@ -0,0 +1 @@ +f https://ftpmirror.gnu.org/gnu/guix/guix-1.5.0.tar.gz df2102eed00aff0b17275654a42f094c8a1117ec065884eb1ff76005e47415c5 diff --git a/steps-guix/gzip-1.9/pass1.sh b/steps-guix/gzip-1.9/pass1.sh new file mode 100644 index 00000000..7cea8e95 --- /dev/null +++ b/steps-guix/gzip-1.9/pass1.sh @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +SEED_PREFIX="/bootstrap-seeds/gzip-1.9" + +src_configure() { + CFLAGS="-O2" LDFLAGS="-static" ./configure \ + --prefix="${SEED_PREFIX}" \ + --disable-nls \ + ac_cv_prog_LESS="less" +} + +src_compile() { + default_src_compile +} + +src_install() { + make DESTDIR="${DESTDIR}" install +} diff --git a/steps-guix/gzip-1.9/sources b/steps-guix/gzip-1.9/sources new file mode 100644 index 00000000..f593fb4f --- /dev/null +++ b/steps-guix/gzip-1.9/sources @@ -0,0 +1 @@ +f https://mirrors.kernel.org/gnu/gzip/gzip-1.9.tar.xz ae506144fc198bd8f81f1f4ad19ce63d5a2d65e42333255977cf1dcf1479089a diff --git a/steps-guix/helpers.sh b/steps-guix/helpers.sh index b05f195f..5e941421 100755 --- a/steps-guix/helpers.sh +++ b/steps-guix/helpers.sh @@ -615,3 +615,48 @@ sysroot_src_install_default() { prefix="${KERNEL_SYSROOT}" \ libdir="${KERNEL_SYSROOT}/lib" } + +seed_require_file() { + local path="$1" + if [ ! -e "${path}" ]; then + echo "Missing required seed input: ${path}" >&2 + false + fi +} + +seed_make_repro_tar_xz() { + local src_dir="$1" + local out_file="$2" + local tmp_dir + local tmp_tar + + seed_require_file "${src_dir}" + mkdir -p "$(dirname "${out_file}")" + + tmp_dir="$(mktemp -d /tmp/seed-tar.XXXXXX)" + tmp_tar="$(mktemp /tmp/seed-tarball.XXXXXX.tar)" + + cp -a "${src_dir}/." "${tmp_dir}/" + ( + cd "${tmp_dir}" + reset_timestamp + tar --sort=name --hard-dereference \ + --numeric-owner --owner=0 --group=0 --mode=go=rX,u+rw \ + -cf "${tmp_tar}" . + ) + touch -t 197001010000.00 "${tmp_tar}" + xz -T1 -c "${tmp_tar}" > "${out_file}" + touch -t 197001010000.00 "${out_file}" + + rm -rf "${tmp_dir}" + rm -f "${tmp_tar}" +} + +seed_install_exec() { + local src="$1" + local dst="$2" + + seed_require_file "${src}" + mkdir -p "$(dirname "${dst}")" + install -m 0755 "${src}" "${dst}" +} diff --git a/steps-guix/improve/after.sh b/steps-guix/improve/after.sh index f181984e..f140f5e0 100644 --- a/steps-guix/improve/after.sh +++ b/steps-guix/improve/after.sh @@ -2,4 +2,21 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -exec /steps/improve/after.sh +set -e + +. /steps/bootstrap.cfg +. /steps/env + +if [ "${INTERACTIVE}" = True ]; then + env - PATH=${PREFIX}/bin PS1="\w # " setsid openvt -fec1 -- bash -i +fi + +if [ "${CHROOT}" = False ]; then + # Ignore errors due to missing swap/fstab. + swapoff -a >/dev/null 2>&1 || true + sync + echo u > /proc/sysrq-trigger + mount -o remount,ro / + echo o > /proc/sysrq-trigger + while true; do sleep 1; done +fi diff --git a/steps-guix/improve/guix-1.5.0.sh b/steps-guix/improve/guix-1.5.0.sh new file mode 100755 index 00000000..80fbf299 --- /dev/null +++ b/steps-guix/improve/guix-1.5.0.sh @@ -0,0 +1,76 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-3.0-or-later + +set -e + +dist="${DISTFILES:-/external/distfiles}" +env_out="/tmp/guix-bootstrap-seeds.env" + +required_files=" +${dist}/static-binaries-0-i686-linux.tar.xz +${dist}/guile-static-stripped-2.2.4-i686-linux.tar.xz +${dist}/mes-minimal-stripped-0.19-i686-linux.tar.xz +${dist}/mescc-tools-static-stripped-0.5.2-i686-linux.tar.xz +${dist}/bootstrap-exec-bash-i686-linux +${dist}/bootstrap-exec-mkdir-i686-linux +${dist}/bootstrap-exec-tar-i686-linux +${dist}/bootstrap-exec-xz-i686-linux +" + +for f in ${required_files}; do + if [ ! -e "${f}" ]; then + echo "Missing required seed artifact: ${f}" >&2 + exit 1 + fi +done + +if [ ! -x /usr/bin/guix-hash-compat ]; then + echo "Missing /usr/bin/guix-hash-compat" >&2 + exit 1 +fi + +# Prepare file layout expected by bootstrap.scm for i686/x86_64. +mkdir -p "${dist}/i686-linux" "${dist}/x86_64-linux" +cp -f "${dist}/static-binaries-0-i686-linux.tar.xz" \ + "${dist}/i686-linux/static-binaries-0-i686-linux.tar.xz" +cp -f "${dist}/static-binaries-0-i686-linux.tar.xz" \ + "${dist}/x86_64-linux/static-binaries-0-i686-linux.tar.xz" +cp -f "${dist}/guile-static-stripped-2.2.4-i686-linux.tar.xz" \ + "${dist}/i686-linux/guile-static-stripped-2.2.4-i686-linux.tar.xz" +cp -f "${dist}/guile-static-stripped-2.2.4-i686-linux.tar.xz" \ + "${dist}/x86_64-linux/guile-static-stripped-2.2.4-i686-linux.tar.xz" +cp -f "${dist}/bootstrap-exec-bash-i686-linux" \ + "${dist}/i686-linux/bootstrap-exec-bash-i686-linux" +cp -f "${dist}/bootstrap-exec-mkdir-i686-linux" \ + "${dist}/i686-linux/bootstrap-exec-mkdir-i686-linux" +cp -f "${dist}/bootstrap-exec-tar-i686-linux" \ + "${dist}/i686-linux/bootstrap-exec-tar-i686-linux" +cp -f "${dist}/bootstrap-exec-xz-i686-linux" \ + "${dist}/i686-linux/bootstrap-exec-xz-i686-linux" + +static_binaries_hash="$(/usr/bin/guix-hash-compat "${dist}/static-binaries-0-i686-linux.tar.xz")" +guile_seed_hash="$(/usr/bin/guix-hash-compat "${dist}/guile-static-stripped-2.2.4-i686-linux.tar.xz")" +mes_minimal_hash="$(/usr/bin/guix-hash-compat "${dist}/mes-minimal-stripped-0.19-i686-linux.tar.xz")" +mescc_tools_hash="$(/usr/bin/guix-hash-compat "${dist}/mescc-tools-static-stripped-0.5.2-i686-linux.tar.xz")" +exec_bash_hash="$(/usr/bin/guix-hash-compat -r "${dist}/bootstrap-exec-bash-i686-linux")" +exec_mkdir_hash="$(/usr/bin/guix-hash-compat -r "${dist}/bootstrap-exec-mkdir-i686-linux")" +exec_tar_hash="$(/usr/bin/guix-hash-compat -r "${dist}/bootstrap-exec-tar-i686-linux")" +exec_xz_hash="$(/usr/bin/guix-hash-compat -r "${dist}/bootstrap-exec-xz-i686-linux")" + +cat > "${env_out}" <&2 + echo "Run improve/guix-daemon-and-pull.sh first." >&2 + exit 1 +fi + +mkdir -p "${out_dir}" + +iso_store_path="$(guix system image \ + --system=x86_64-linux \ + -t iso9660 \ + -e '(@@ (gnu system install) installation-os)' \ + --no-substitutes)" + +if [ ! -e "${iso_store_path}" ]; then + echo "guix system image did not return a valid path: ${iso_store_path}" >&2 + exit 1 +fi + +ln -sfn "${iso_store_path}" "${out_dir}/guix-system-install-x86_64.iso" diff --git a/steps-guix/improve/guix-daemon-and-pull.sh b/steps-guix/improve/guix-daemon-and-pull.sh new file mode 100644 index 00000000..485fb711 --- /dev/null +++ b/steps-guix/improve/guix-daemon-and-pull.sh @@ -0,0 +1,144 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-3.0-or-later + +set -e + +. /steps/bootstrap.cfg +. /steps/env + +daemon_socket="/var/guix/daemon-socket/socket" +channel_root="/var/lib/guix/local-channels" +channel_repo="${channel_root}/guix" +channel_work="/tmp/guix-local-channel-work" +channels_file="/root/.config/guix/channels.scm" +distfiles="${DISTFILES:-/external/distfiles}" +PATH="/usr/sbin:/sbin:${PATH}" + +have_group() { + if command -v getent >/dev/null 2>&1; then + getent group "$1" >/dev/null 2>&1 + else + grep -q "^$1:" /etc/group + fi +} + +have_user() { + if command -v getent >/dev/null 2>&1; then + getent passwd "$1" >/dev/null 2>&1 + else + grep -q "^$1:" /etc/passwd + fi +} + +mkdir -p /proc /sys /dev /var/guix/daemon-socket /var/lib/guix /root/.config/guix +mount | grep ' on /proc ' >/dev/null 2>&1 || mount -t proc proc /proc +mount | grep ' on /sys ' >/dev/null 2>&1 || mount -t sysfs sysfs /sys +mount | grep ' on /dev ' >/dev/null 2>&1 || mount -t devtmpfs devtmpfs /dev + +if ! have_group guixbuild; then + groupadd --system guixbuild +fi + +nologin_bin="$(command -v nologin || true)" +if [ -z "${nologin_bin}" ]; then + if [ -x /usr/sbin/nologin ]; then + nologin_bin=/usr/sbin/nologin + elif [ -x /sbin/nologin ]; then + nologin_bin=/sbin/nologin + else + echo "Could not find nologin binary." >&2 + exit 1 + fi +fi + +i=1 +while [ "${i}" -le 10 ]; do + idp="$(printf '%02d' "${i}")" + user="guixbuilder${idp}" + if ! have_user "${user}"; then + useradd -g guixbuild -G guixbuild \ + -d /var/empty -s "${nologin_bin}" \ + -c "Guix build user ${idp}" --system \ + "${user}" + fi + i=$((i + 1)) +done + +if [ ! -S "${daemon_socket}" ]; then + guix-daemon \ + --build-users-group=guixbuild \ + --listen="${daemon_socket}" \ + >/tmp/guix-daemon.log 2>&1 & +fi + +retry=0 +while [ "${retry}" -lt 60 ]; do + if [ -S "${daemon_socket}" ]; then + break + fi + retry=$((retry + 1)) + sleep 1 +done + +if [ ! -S "${daemon_socket}" ]; then + echo "guix-daemon did not become ready: ${daemon_socket}" >&2 + exit 1 +fi + +src_tar="" +for f in "${distfiles}"/guix-1.5.0*.tar.* "${distfiles}"/guix-v1.5.0*.tar.*; do + if [ -f "${f}" ]; then + src_tar="${f}" + break + fi +done + +if [ -z "${src_tar}" ]; then + echo "Could not find Guix 1.5.0 source tarball in ${distfiles}" >&2 + exit 1 +fi + +rm -rf "${channel_work}" "${channel_repo}" +mkdir -p "${channel_work}" "${channel_root}" + +case "${src_tar}" in + *.tar.gz|*.tgz) tar -C "${channel_work}" -xzf "${src_tar}" ;; + *.tar.xz) tar -C "${channel_work}" -xJf "${src_tar}" ;; + *.tar.bz2) tar -C "${channel_work}" -xjf "${src_tar}" ;; + *.tar) tar -C "${channel_work}" -xf "${src_tar}" ;; + *) + echo "Unsupported tarball format: ${src_tar}" >&2 + exit 1 + ;; +esac + +src_dir="$(find "${channel_work}" -mindepth 1 -maxdepth 1 -type d | head -n 1)" +if [ -z "${src_dir}" ]; then + echo "Failed to unpack Guix source from ${src_tar}" >&2 + exit 1 +fi + +mv "${src_dir}" "${channel_repo}" + +( + cd "${channel_repo}" + git init -q + git add -A + git -c user.name='guix-local' -c user.email='guix-local@example.invalid' commit -q -m 'local guix channel snapshot' +) + +channel_commit="$(git -C "${channel_repo}" rev-parse HEAD)" + +cat > "${channels_file}" <&2 + false + fi + + seed_make_repro_tar_xz "${stage}" "${DISTFILES}/mescc-tools-static-stripped-0.5.2-i686-linux.tar.xz" +} + +src_install() { + install -D -m 0644 /dev/null "${DESTDIR}/usr/share/guix-seeds/mescc-tools-static-stripped-0.5.2-i686-linux" +} diff --git a/steps-guix/patch-2.7.6/pass1.sh b/steps-guix/patch-2.7.6/pass1.sh new file mode 100644 index 00000000..5902a800 --- /dev/null +++ b/steps-guix/patch-2.7.6/pass1.sh @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +SEED_PREFIX="/bootstrap-seeds/patch-2.7.6" + +src_configure() { + CFLAGS="-O2" LDFLAGS="-static" ./configure \ + --prefix="${SEED_PREFIX}" \ + gl_cv_func_working_mktime=yes +} + +src_compile() { + make "${MAKEJOBS}" MAKEINFO=true +} + +src_install() { + make DESTDIR="${DESTDIR}" MAKEINFO=true install +} diff --git a/steps-guix/patch-2.7.6/sources b/steps-guix/patch-2.7.6/sources new file mode 100644 index 00000000..939ecbb8 --- /dev/null +++ b/steps-guix/patch-2.7.6/sources @@ -0,0 +1 @@ +f https://mirrors.kernel.org/gnu/patch/patch-2.7.6.tar.xz ac610bda97abe0d9f6b7c963255a11dcb196c25e337c61f94e4778d632f1d8fd diff --git a/steps-guix/static-binaries-0-i686-linux/pass1.sh b/steps-guix/static-binaries-0-i686-linux/pass1.sh new file mode 100644 index 00000000..e70492af --- /dev/null +++ b/steps-guix/static-binaries-0-i686-linux/pass1.sh @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +src_get() { :; } +src_unpack() { :; } +src_prepare() { :; } +src_configure() { :; } + +src_compile() { + local stage dist + stage="/tmp/static-binaries-0-i686-linux" + dist="${DISTFILES}" + + rm -rf "${stage}" + mkdir -p "${stage}/bin" + + cp -a /bootstrap-seeds/coreutils-8.30/bin/. "${stage}/bin/" + cp -a /bootstrap-seeds/gawk-4.2.1/bin/gawk "${stage}/bin/" + cp -a /bootstrap-seeds/grep-3.1/bin/grep "${stage}/bin/" + cp -a /bootstrap-seeds/grep-3.1/bin/egrep "${stage}/bin/" + cp -a /bootstrap-seeds/grep-3.1/bin/fgrep "${stage}/bin/" + cp -a /bootstrap-seeds/tar-1.30/bin/tar "${stage}/bin/" + cp -a /bootstrap-seeds/xz-5.2.4/bin/xz "${stage}/bin/" + cp -a /bootstrap-seeds/gzip-1.9/bin/gzip "${stage}/bin/" + cp -a /bootstrap-seeds/bzip2-1.0.6/bin/bzip2 "${stage}/bin/" + cp -a /bootstrap-seeds/patch-2.7.6/bin/patch "${stage}/bin/" + cp -a /bootstrap-seeds/bash-4.4.23-1/bin/bash "${stage}/bin/" + + ln -sf bash "${stage}/bin/sh" + ln -sf gawk "${stage}/bin/awk" + + seed_make_repro_tar_xz "${stage}" "${dist}/static-binaries-0-i686-linux.tar.xz" + + seed_install_exec "${stage}/bin/bash" "${dist}/bootstrap-exec-bash-i686-linux" + seed_install_exec "${stage}/bin/mkdir" "${dist}/bootstrap-exec-mkdir-i686-linux" + seed_install_exec "${stage}/bin/tar" "${dist}/bootstrap-exec-tar-i686-linux" + seed_install_exec "${stage}/bin/xz" "${dist}/bootstrap-exec-xz-i686-linux" +} + +src_install() { + install -D -m 0644 /dev/null "${DESTDIR}/usr/share/guix-seeds/static-binaries-0-i686-linux" +} diff --git a/steps-guix/tar-1.30/pass1.sh b/steps-guix/tar-1.30/pass1.sh new file mode 100644 index 00000000..c4a603a3 --- /dev/null +++ b/steps-guix/tar-1.30/pass1.sh @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +SEED_PREFIX="/bootstrap-seeds/tar-1.30" + +src_configure() { + FORCE_UNSAFE_CONFIGURE=1 CFLAGS="-O2" LDFLAGS="-static" ./configure \ + --prefix="${SEED_PREFIX}" \ + --disable-nls \ + gl_cv_func_getcwd_path_max="no, but it is partly working" +} + +src_compile() { + make "${MAKEJOBS}" MAKEINFO=true +} + +src_install() { + make DESTDIR="${DESTDIR}" MAKEINFO=true install +} diff --git a/steps-guix/tar-1.30/sources b/steps-guix/tar-1.30/sources new file mode 100644 index 00000000..fef804e0 --- /dev/null +++ b/steps-guix/tar-1.30/sources @@ -0,0 +1 @@ +f https://mirrors.kernel.org/gnu/tar/tar-1.30.tar.xz f1bf92dbb1e1ab27911a861ea8dde8208ee774866c46c0bb6ead41f4d1f4d2d3 diff --git a/steps-guix/xz-5.2.4/pass1.sh b/steps-guix/xz-5.2.4/pass1.sh new file mode 100644 index 00000000..54173667 --- /dev/null +++ b/steps-guix/xz-5.2.4/pass1.sh @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +SEED_PREFIX="/bootstrap-seeds/xz-5.2.4" + +src_configure() { + ./configure \ + --prefix="${SEED_PREFIX}" \ + --disable-shared \ + --enable-static \ + --disable-nls +} + +src_compile() { + default_src_compile +} + +src_install() { + make DESTDIR="${DESTDIR}" install +} diff --git a/steps-guix/xz-5.2.4/sources b/steps-guix/xz-5.2.4/sources new file mode 100644 index 00000000..7069c2fa --- /dev/null +++ b/steps-guix/xz-5.2.4/sources @@ -0,0 +1 @@ +f https://tukaani.org/xz/xz-5.2.4.tar.gz b512f3b726d3b37b6dc4c8570e137b9311e7552e8ccbab4d39d47ce5f4177145