commit: ef0030bbf3314d1c4f8fe8774d1304cfa68d8770
parent 594fd62e7e4a3471d4f353c045ab9adb927213b4
Author: Andrius Štikonas <andrius@stikonas.eu>
Date: Sun, 8 May 2022 20:04:29 +0100
Reinstall system from packages during sysa->sysc and sysb->sysc transitions.
Diffstat:
11 files changed, 98 insertions(+), 41 deletions(-)
diff --git a/.cirrus.yml b/.cirrus.yml
@@ -24,7 +24,7 @@ shell_lint_task:
- apt-get -y install shellcheck
- apt-get -y clean
check_script:
- - shellcheck sysa/run.sh sysb/run.sh sysc/run.sh sysc/run2.sh sysa/helpers.sh
+ - shellcheck sysa/run.sh sysb/init sysb/run.sh sysc/init sysc/run.sh sysc/run2.sh sysa/helpers.sh
reuse_lint_task:
container:
diff --git a/sysa/SHA256SUMS.pkgs b/sysa/SHA256SUMS.pkgs
@@ -160,7 +160,7 @@ b418ef47a65ba1f52f0b79a96ce2ebf1bb1f4f2a78e3985fa512e6c41477f100 perl5.005-03_0
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 perl-5.10.1_0.links
0e216f189404be18ef7463665e9288258058b322f0636e9b9c19b5262af7980a perl-5.10.1_0.tar.bz2
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 perl-5.32.1_0.links
-9ed0a0c9ff88af07ea2cb2eea6367365da42a346a81b537f6e4a3dc80076953d perl-5.32.1_0.tar.bz2
+de89e006bed3db40681e3d3f7a485526299d3bebbf4a2ed825f62a7fa94b5947 perl-5.32.1_0.tar.bz2
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 perl-5.6.2_0.links
b5fce312b381d0135d44b1bd30089e89e17ce35e6cf5e326eac87baf6c554dd4 perl-5.6.2_0.tar.bz2
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 pkg-config-0.29.2_0.links
diff --git a/sysa/helpers.sh b/sysa/helpers.sh
@@ -310,28 +310,33 @@ src_apply() {
if command -v xbps-install >/dev/null 2>&1; then
xbps-install -y -R /usr/src/repo "${pkg%%-[0-9]*}"
else
- # Overwriting files is mega busted, so do it manually
- # shellcheck disable=SC2162
- if [ -e /tmp/filelist.txt ]; then
- while IFS= read -d $'\0' file; do
- rm -f "/${file}" >/dev/null 2>&1 || true
- done < /tmp/filelist.txt
- fi
- bzip2 -dc "/usr/src/repo/${pkg}_${revision}.tar.bz2" | \
- tar -C / -xpf -
- # shellcheck disable=SC2162
- # ^ read -r unsupported in old bash
- while read line; do
- # shellcheck disable=SC2001
- # ^ cannot use variable expansion here
- fname="$(echo "${line}" | sed 's/.* //')"
- rm -f "${fname}"
- # shellcheck disable=SC2226,SC2086
- # ^ ${line} expands into two arguments
- ln -s ${line}
- touch -t 197001010000.00 "${fname}"
- done < "/usr/src/repo/${pkg}_${revision}.links"
+ src_apply_tar "${pkg}" "${revision}"
+ fi
+}
+
+src_apply_tar() {
+ local pkg=$1 revision=$2
+ # Overwriting files is mega busted, so do it manually
+ # shellcheck disable=SC2162
+ if [ -e /tmp/filelist.txt ]; then
+ while IFS= read -d $'\0' file; do
+ rm -f "/${file}" >/dev/null 2>&1 || true
+ done < /tmp/filelist.txt
fi
+ bzip2 -dc "/usr/src/repo/${pkg}_${revision}.tar.bz2" | \
+ tar -C / -xpf -
+ # shellcheck disable=SC2162
+ # ^ read -r unsupported in old bash
+ while read line; do
+ # shellcheck disable=SC2001
+ # ^ cannot use variable expansion here
+ fname="$(echo "${line}" | sed 's/.* //')"
+ rm -f "${fname}"
+ # shellcheck disable=SC2226,SC2086
+ # ^ ${line} expands into two arguments
+ ln -s ${line}
+ touch -t 197001010000.00 "${fname}"
+ done < "/usr/src/repo/${pkg}_${revision}.links"
}
# Check if bash function exists
@@ -376,3 +381,22 @@ populate_device_nodes() {
test -c "${1}/dev/console" || mknod -m 666 "${1}/dev/console" c 5 1
fi
}
+
+sys_transfer() {
+ local dest=$1
+
+ mkdir -p "${dest}/${PREFIX}/bin" "${dest}/${PREFIX}/src"
+
+ # Bash, Tar and Bzip2 are required to install packages
+ cp "${PREFIX}/bin/bash" "${PREFIX}/bin/tar" "${PREFIX}/bin/bzip2" "${dest}${PREFIX}/bin/"
+
+ # Transfer misc files
+ cp "${SOURCES}/helpers.sh" "${SOURCES}/SHA256SUMS.pkgs" "${SOURCES}/bootstrap.cfg" "${dest}/"
+
+ cp -r "${PREFIX}/src/" "${dest}${PREFIX}/"
+
+ shift
+ # Copy additional binaries
+ set -- "${@/#/${PREFIX}/bin/}"
+ cp "$@" "${dest}${PREFIX}/bin/"
+}
diff --git a/sysa/run.sh b/sysa/run.sh
@@ -253,7 +253,6 @@ if [ "${CHROOT}" = False ]; then
fi
# In chroot mode transition directly into System C.
-SYSC="/sysc"
-cp -R "${PREFIX}" "${SYSC}"
-cp "${SOURCES}/helpers.sh" "${SOURCES}/SHA256SUMS.pkgs" "${SOURCES}/bootstrap.cfg" "${SYSC}/usr/src/"
+SYSC=/sysc
+sys_transfer "${SYSC}" gzip patch
exec chroot "${SYSC}" /init
diff --git a/sysb/run.sh b/sysb/run.sh
@@ -55,6 +55,10 @@ if [ -z "${DISK}" ] || ! [ -e "/dev/${DISK}" ]; then
ask_disk
fi
+PREFIX=/usr
+SOURCES="${PREFIX}/src"
+SYSC=/sysc
+
echo "export DISK=${DISK}" >> /usr/src/bootstrap.cfg
# Otherwise, add stuff from sysa to sysb
@@ -64,13 +68,7 @@ mount -t ext4 "/dev/${DISK}" /sysc
# Copy over appropriate data
echo "Copying data into sysc"
-cp -r /dev /sysc/
-mkdir -p /sysc/usr/src
-# Don't include /usr/src
-find /usr -mindepth 1 -maxdepth 1 -type d -not -name src -exec cp -r {} /sysc/{} \;
-# Except for a few files
-cp /usr/src/helpers.sh /usr/src/SHA256SUMS.pkgs /usr/src/bootstrap.cfg /sysc/usr/src/
-cp -r /usr/src/repo /sysc/usr/src/repo
+sys_transfer "${SYSC}" gzip patch
sync
# switch_root into sysc 1. for simplicity 2. to avoid kexecing again
diff --git a/sysc/autoconf-2.69/autoconf-2.69.sh b/sysc/autoconf-2.69/autoconf-2.69.sh
@@ -3,8 +3,6 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
-SRCS="autoconf-2.69.tar.xz"
-
src_prepare() {
rm doc/standards.info man/*.1
autoreconf-2.64 -f
diff --git a/sysc/autoconf-2.71/autoconf-2.71.sh b/sysc/autoconf-2.71/autoconf-2.71.sh
@@ -2,8 +2,6 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
-SRCS="autoconf-2.71.tar.xz"
-
src_prepare() {
rm doc/standards.info
autoreconf-2.69 -fi
diff --git a/sysc/autoconf-archive-2021.02.19/autoconf-archive-2021.02.19.sh b/sysc/autoconf-archive-2021.02.19/autoconf-archive-2021.02.19.sh
@@ -2,8 +2,6 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
-SRCS="autoconf-archive-2021.02.19.tar.xz"
-
src_prepare() {
autoreconf-2.69 -fi
}
diff --git a/sysc/bash-5.1/bash-5.1.sh b/sysc/bash-5.1/bash-5.1.sh
@@ -11,7 +11,7 @@ src_prepare() {
# Rebuild configure script
rm configure
- autoconf-2.61
+ autoconf-2.64
# avoid non-deterministic build:
printf '%s\n%s\n' \
diff --git a/sysc/init b/sysc/init
@@ -6,9 +6,51 @@
set -e
+# shellcheck source=sysa/helpers.sh
+. helpers.sh
+
+echo
+echo "Installing packages into sysc"
+
+install_tar() {
+ echo "${1}: installing package"
+ src_apply_tar "$@"
+}
+
+# Install packages.
+# First two packages must be coreutils and sed
+
+install_tar coreutils-5.0 0
+install_tar sed-4.0.9 0
+
+install_tar autoconf-2.64 0
+install_tar automake-1.10.3 0
+install_tar binutils-2.14 0
+install_tar bzip2-1.0.8 0
+install_tar bison-3.4.1 2
+install_tar coreutils-6.10 0
+install_tar diffutils-2.7 0
+install_tar findutils-4.2.33 0
+install_tar flex-2.6.4 0
+install_tar gawk-3.0.4 0
+install_tar gcc-4.0.4 1
+install_tar grep-2.4 0
+install_tar help2man-1.36.4 0
+install_tar libtool-2.2.4 0
+install_tar linux-headers-5.10.41 0
+install_tar m4-1.4.7 0
+install_tar make-3.82 0
+install_tar musl-1.2.2 0
+install_tar perl-5.6.2 0
+install_tar util-linux-2.19.1 0
+
+# Fix invocation of bash from perl
+ln -s /usr/bin/bash /usr/bin/sh
+
# Prepare sysc directory structure
mkdir -p /usr/src
mv run*.sh /usr/src
+mv helpers.sh SHA256SUMS.pkgs bootstrap.cfg /usr/src
mv /*-* /usr/src # build scripts
# Begin sysc bootstrapping process
diff --git a/sysc/run.sh b/sysc/run.sh
@@ -20,7 +20,7 @@ export DISTFILES=/distfiles
create_fhs() {
# Add the rest of the FHS that we will use and is not created pre-boot
rm -rf /sbin /usr/sbin
- ln -s bin /usr/sbin
+ ln -s bin /usr/sbin # Hack to fix xbps (alternatively need to install which)
for d in bin lib sbin; do
ln -s "usr/${d}" "/${d}"
done