fixup! Add tix-upgrade(8).

This commit is contained in:
Jonas 'Sortie' Termansen 2023-09-03 23:03:38 +02:00
parent fa8dcef53a
commit d992f098c2
2 changed files with 47 additions and 83 deletions

View File

@ -35,14 +35,12 @@ output_release_file= # TODO: A better term for this?
output_release_sig_file= # TODO: A better term for this?
output_sha256sum=
patch=false
port=false
porttix=false
package=false
release=false
sha256=false
sha256sum=false
source=false
source_full=false
srctix=false
sysroot=""
toolchain=false
url=false
@ -115,15 +113,12 @@ for argument do
--output-sha256sum) previous_option=output_sha256sum ;;
--output-upgrade-file=*) output_upgrade_file=$parameter ;;
--output-upgrade-file) previous_option=output_upgrade_file ;;
--package) package=true ;;
--patch) patch=true ;;
--port) port=true ;;
--porttix) porttix=true ;;
--release) release=true ;;
--sha256) sha256=true ;;
--sha256sum) sha256sum=true ;;
--source-full) source_full=true ;;
--source) source=true ;;
--srctix) srctix=true ;;
--sysroot) previous_option=sysroot ;;
--sysroot=*) sysroot=$parameter ;;
--toolchain) toolchain=true ;;
@ -158,7 +153,7 @@ conf() {
tix-vars -d "$2" - "$4"
}
tmpdir=$(mktemp -dt tix-fetch-port.XXXXXX)
tmpdir=$(mktemp -dt tix-fetch.XXXXXX)
trap 'rm -rf -- "$tmpdir"' EXIT HUP INT QUIT TERM
upgrade_conf="${collection%/}/etc/upgrade.conf"
@ -428,8 +423,7 @@ fi
# Fetch each of the specified signed files from the mirror.
for REQUEST; do
# If --port then fetch the port by the requested name.
if $port; then
if $package; then
REQUEST="$REQUEST.tix.tar.xz"
REQUESTDIR="repository/$MACHINE-sortix/"
elif $boot; then
@ -444,12 +438,6 @@ for REQUEST; do
elif $normalize; then
REQUEST="$REQUEST.normalize"
REQUESTDIR="patches/"
elif $srctix; then
REQUEST="$REQUEST.srctix.tar.xz"
REQUESTDIR="srctix/"
elif $porttix; then
REQUEST="$REQUEST.porttix.tar.xz"
REQUESTDIR="porttix/"
elif $toolchain; then
REQUESTDIR="toolchain/"
else

View File

@ -24,7 +24,6 @@ clean=false
collection=/
download_only=false
fetch_options=
ports_only=false
sysroot=""
upgrade=--upgrade
upgrade_ports=false
@ -107,6 +106,12 @@ if [ ! -e "$collection/tix/manifest/system" ]; then
upgrade_system=false
fi
case "$upgrade_system$upgrade_ports" in
truefalse) what_to_upgrade=--system;;
falsetrue) what_to_upgrade=--ports;;
*) what_to_upgrade=;;
esac
if [ -z "$cachedir" ]; then
cachedir="${collection%/}/var/cache/tix"
fi
@ -120,7 +125,6 @@ if $cancel; then
sysmerge -t "$collection" --cancel
exit
fi
mkdir -p -- "$cachedir"
mkdir -p -- "$cachedir/new"
@ -164,50 +168,42 @@ if [ -n "$UPGRADE_SIG_URL" ]; then
fi
fi
mkdir -p -- "$cachedir/boot"
# Decide what binary packages to upgrade.
installed_packages=$(LC_ALL=C ls -- "$collection/tix/tixinfo")
if $upgrade_system && $upgrade_ports; then
upgrade_packages="$installed_packages"
else
upgrade_packages=
for package in $installed_packages; do
is_system=$(tix-vars -d false "$collection/tix/tixinfo/$package" SYSTEM)
if ($upgrade_system && [ "$is_system" = true ]) ||
($upgrade_ports && [ "$is_system" = false ]); then
upgrade_packages="$upgrade_packages $package"
fi
done
fi
# Fetch each binary package from the mirror.
# TODO: Handle new mandatory / recommended ports.
# TODO: Handle renamed ports.
mkdir -p -- "$cachedir/repository"
# TODO: DO NOT SUBMIT: Temporary -d system compatibility until builds roll.
SYSTEM_INITRDS=$(tix-vars -d system "$cachedir/release.sh" SYSTEM_INITRDS)
# TODO: What about the system source code in /src?
if $upgrade_system; then
# Fetch the base system initrds from the mirror.
for initrd in $SYSTEM_INITRDS; do
packages=""
for package in $(LC_ALL=C ls -- "$collection/tix/tixinfo"); do
# The package exists upstream if it has a hash.
sha256=$(tix-fetch $fetch_options \
--collection="$collection" \
--input-release-file="$cachedir/release.sh" \
--input-sha256sum="$cachedir/sha256sum" \
--sha256 --package -- $package)
if [ -n "$sha256" ]; then
tix-fetch $fetch_options \
--collection="$collection" \
--input-release-file="$cachedir/release.sh" \
--input-sha256sum="$cachedir/sha256sum" \
-c --initrd -O "$cachedir/boot" -- "$initrd"
done
fi
if $upgrade_ports; then
# Fetch each port from the mirror.
# TODO: Handle new mandatory / recommended ports.
# TODO: Handle renamed ports.
mkdir -p "$cachedir/repository"
ports=""
for port in $(LC_ALL=C ls -- "$collection/tix/tixinfo"); do
# The port has a hash if if it exists upstream.
sha256=$(tix-fetch $fetch_options \
--collection="$collection" \
--input-release-file="$cachedir/release.sh" \
--input-sha256sum="$cachedir/sha256sum" \
--sha256 --port -- $port)
# If the port exists upstream, get the latest version and note its name down
# for the extraction step.
if [ -n "$sha256" ]; then
tix-fetch $fetch_options \
--collection="$collection" \
--input-release-file="$cachedir/release.sh" \
--input-sha256sum="$cachedir/sha256sum" \
-c --port -O "$cachedir/repository" -- $port
ports="$ports $port"
fi
done
fi
-c --package -O "$cachedir/repository" -- $package
packages="$packages $package"
fi
done
# Stop if only downloading.
if $download_only; then
@ -229,35 +225,15 @@ release_sig_url = $UPGRADE_SIG_URL
EOF
fi
# Extract the base system into the sysroot.
if $upgrade_system; then
for initrd in $SYSTEM_INITRDS; do
echo "Extracting $initrd.tar.xz..."
tar -C "$cachedir/sysroot" -xJf "$cachedir/boot/$initrd.tar.xz"
rm -f "$cachedir/boot/$initrd.tar.xz"
done
fi
# Extract the ports into the sysroot.
full=
if $upgrade_ports; then
full=--full
for port in $ports; do
echo "Extracting $port.tix.tar.xz..."
tar -C "$cachedir/sysroot" -xJf "$cachedir/repository/$port.tix.tar.xz"
rm -f "$cachedir/repository/$port.tix.tar.xz"
done
fi
case "$upgrade_system$upgrade_ports" in
truefalse) what_to_upgrade=--system;;
falsetrue) what_to_upgrade=--ports;;
*) what_to_upgrade=;;
esac
# Extract the binary packages into the sysroot.
for package in $packages; do
echo "Extracting $package.tix.tar.xz..."
tar -C "$cachedir/sysroot" -xJf "$cachedir/repository/$package.tix.tar.xz"
rm -f "$cachedir/repository/$package.tix.tar.xz"
done
# Merge the new sysroot onto the installation.
sysmerge -t "$collection" $what_to_upgrade $full $wait "$cachedir/sysroot"
rm -rf -- "$cachedir/boot"
rm -rf -- "$cachedir/repository"
rm -rf -- "$cachedir/sysroot"