Reinstall system from packages during sysa->sysc and sysb->sysc transitions.

This commit is contained in:
Andrius Štikonas 2022-05-08 20:04:29 +01:00
parent 594fd62e7e
commit ef0030bbf3
11 changed files with 98 additions and 41 deletions

View file

@ -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

View file

@ -310,30 +310,35 @@ 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
fn_exists() {
test "$(type -t "$1")" == 'function'
@ -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/"
}

View file

@ -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