From 4421a2bc752d69d487cfe9a8cf4841223473cfc8 Mon Sep 17 00:00:00 2001 From: "Gerd v. Egidy" Date: Sun, 5 Dec 2021 02:08:37 +0100 Subject: [PATCH] Use snapshot archive repo for pacman in SystemRescue by default This prevents huge dependency downloads by pacman when the SystemRescue version gets older by using a snapshot repo from the day the SystemRescue version is released. The classic rolling repos from Arch are also available as option. Activate with the "--config /etc/pacman-rolling.conf" option to pacman. To allow switching on a per-command basis, two different sets of remote package databases are required. But the local package database must be the same for both variants. This is achived by using two different DBPaths in the pacman config files and bind-mounting the local part together. pacman does not accept symlinks for this, so it must be a bind mount. --- airootfs/etc/os-release | 1 + airootfs/etc/pacman-rolling.conf | 95 +++++++++++++++++++ airootfs/etc/pacman-snapshot.conf | 88 +++++++++++++++++ .../var-lib-pacman\\x2drolling-local.mount" | 12 +++ airootfs/root/customize_airootfs.sh | 1 + build.sh | 16 +++- mirrorlist-snapshot-i686 | 2 +- 7 files changed, 212 insertions(+), 3 deletions(-) create mode 100644 airootfs/etc/pacman-rolling.conf create mode 100644 airootfs/etc/pacman-snapshot.conf create mode 100644 "airootfs/etc/systemd/system/var-lib-pacman\\x2drolling-local.mount" diff --git a/airootfs/etc/os-release b/airootfs/etc/os-release index 2cfdc11..95613ea 100644 --- a/airootfs/etc/os-release +++ b/airootfs/etc/os-release @@ -4,6 +4,7 @@ ID_LIKE=arch PRETTY_NAME="SystemRescue %ISO_VERSION%" VERSION="%ISO_VERSION%" VERSION_ID="%ISO_VERSION%" +BUILD_ID="%SNAPSHOT_DATE%" ANSI_COLOR="0;31" HOME_URL="https://www.system-rescue.org/" DOCUMENTATION_URL="https://www.system-rescue.org/manual/" diff --git a/airootfs/etc/pacman-rolling.conf b/airootfs/etc/pacman-rolling.conf new file mode 100644 index 0000000..a81d519 --- /dev/null +++ b/airootfs/etc/pacman-rolling.conf @@ -0,0 +1,95 @@ +# +# /etc/pacman.conf +# +# See the pacman.conf(5) manpage for option and repository directives + +# +# GENERAL OPTIONS +# +[options] +# The following paths are commented out with their default values listed. +# If you wish to use different paths, uncomment and update the paths. +#RootDir = / +#CacheDir = /var/cache/pacman/pkg/ +#LogFile = /var/log/pacman.log +#GPGDir = /etc/pacman.d/gnupg/ +#HookDir = /etc/pacman.d/hooks/ +HoldPkg = pacman glibc +#XferCommand = /usr/bin/curl -C - -f %u > %o +#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u +#CleanMethod = KeepInstalled +#UseDelta = 0.7 +Architecture = auto + +# SystemRescue offers 2 different set of repositories, snapshot and rolling. +# You can switch between them on a per-command basis. So they need to store two +# different sets of remote databases. /var/lib/pacman is used by the default +# variant (snapshot), /var/lib/pacman-rolling/ for the rolling one. +# The database of locally installed packages must be the same for both. +# This is done by bind-mounting /var/lib/pacman-rolling/local +DBPath = /var/lib/pacman-rolling/ + +# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup +#IgnorePkg = +#IgnoreGroup = + +#NoUpgrade = +#NoExtract = + +# Misc options +#UseSyslog +#Color +#TotalDownload +# We cannot check disk space from within a chroot environment +#CheckSpace +#VerbosePkgLists + +# By default, pacman accepts packages signed by keys that its local keyring +# trusts (see pacman-key and its man page), as well as unsigned packages. +SigLevel = Required DatabaseOptional +LocalFileSigLevel = Optional +#RemoteFileSigLevel = Required + +# NOTE: You must run `pacman-key --init` before first using pacman; the local +# keyring can then be populated with the keys of all official Arch Linux +# packagers with `pacman-key --populate archlinux`. + +# +# REPOSITORIES +# - can be defined here or included from another file +# - pacman will search repositories in the order defined here +# - local/custom mirrors can be added here or in separate files +# - repositories listed first will take precedence when packages +# have identical names, regardless of version number +# - URLs will have $repo replaced by the name of the current repo +# - URLs will have $arch replaced by the name of the architecture +# +# Repository entries are of the format: +# [repo-name] +# Server = ServerName +# Include = IncludePath +# +# The header [repo-name] is crucial - it must be present and +# uncommented to enable the repo. +# + +################## +# SystemRescue +################## +# offers 2 different set of repositories, snapshot (the default) and rolling. +# With snapshot you get the packages at the moment of SystemRescue release +# rolling is the traditional rolling-release repository of Arch +# +# You can switch on a per-command basis like this: +# pacman --config /etc/pacman-rolling.conf +# +# or you can change the /etc/pacman.conf symlink for a permanent change + +[core] +Include = /etc/pacman.d/mirrorlist + +[extra] +Include = /etc/pacman.d/mirrorlist + +[community] +Include = /etc/pacman.d/mirrorlist diff --git a/airootfs/etc/pacman-snapshot.conf b/airootfs/etc/pacman-snapshot.conf new file mode 100644 index 0000000..086410e --- /dev/null +++ b/airootfs/etc/pacman-snapshot.conf @@ -0,0 +1,88 @@ +# +# /etc/pacman.conf +# +# See the pacman.conf(5) manpage for option and repository directives + +# +# GENERAL OPTIONS +# +[options] +# The following paths are commented out with their default values listed. +# If you wish to use different paths, uncomment and update the paths. +#RootDir = / +#DBPath = /var/lib/pacman/ +#CacheDir = /var/cache/pacman/pkg/ +#LogFile = /var/log/pacman.log +#GPGDir = /etc/pacman.d/gnupg/ +#HookDir = /etc/pacman.d/hooks/ +HoldPkg = pacman glibc +#XferCommand = /usr/bin/curl -C - -f %u > %o +#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u +#CleanMethod = KeepInstalled +#UseDelta = 0.7 +Architecture = auto + +# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup +#IgnorePkg = +#IgnoreGroup = + +#NoUpgrade = +#NoExtract = + +# Misc options +#UseSyslog +#Color +#TotalDownload +# We cannot check disk space from within a chroot environment +#CheckSpace +#VerbosePkgLists + +# By default, pacman accepts packages signed by keys that its local keyring +# trusts (see pacman-key and its man page), as well as unsigned packages. +SigLevel = Required DatabaseOptional +LocalFileSigLevel = Optional +#RemoteFileSigLevel = Required + +# NOTE: You must run `pacman-key --init` before first using pacman; the local +# keyring can then be populated with the keys of all official Arch Linux +# packagers with `pacman-key --populate archlinux`. + +# +# REPOSITORIES +# - can be defined here or included from another file +# - pacman will search repositories in the order defined here +# - local/custom mirrors can be added here or in separate files +# - repositories listed first will take precedence when packages +# have identical names, regardless of version number +# - URLs will have $repo replaced by the name of the current repo +# - URLs will have $arch replaced by the name of the architecture +# +# Repository entries are of the format: +# [repo-name] +# Server = ServerName +# Include = IncludePath +# +# The header [repo-name] is crucial - it must be present and +# uncommented to enable the repo. +# + +################## +# SystemRescue +################## +# offers 2 different set of repositories, snapshot (the default) and rolling. +# With snapshot you get the packages at the moment of SystemRescue release +# rolling is the traditional rolling-release repository of Arch +# +# You can switch on a per-command basis like this: +# pacman --config /etc/pacman-rolling.conf +# +# or you can change the /etc/pacman.conf symlink for a permanent change + +[core] +Include = /etc/pacman.d/mirrorlist-snapshot + +[extra] +Include = /etc/pacman.d/mirrorlist-snapshot + +[community] +Include = /etc/pacman.d/mirrorlist-snapshot diff --git "a/airootfs/etc/systemd/system/var-lib-pacman\\x2drolling-local.mount" "b/airootfs/etc/systemd/system/var-lib-pacman\\x2drolling-local.mount" new file mode 100644 index 0000000..5b1658d --- /dev/null +++ "b/airootfs/etc/systemd/system/var-lib-pacman\\x2drolling-local.mount" @@ -0,0 +1,12 @@ +[Unit] +Description=Bind mount /var/lib/pacman-rolling/local to allow easy switching between snapshot/rolling repos +# See /etc/pacman-rolling.conf for details + +[Mount] +What=/var/lib/pacman/local +Where=/var/lib/pacman-rolling/local +Type=none +Options=bind + +[Install] +WantedBy=multi-user.target diff --git a/airootfs/root/customize_airootfs.sh b/airootfs/root/customize_airootfs.sh index 5d76f1e..7a0ee66 100755 --- a/airootfs/root/customize_airootfs.sh +++ b/airootfs/root/customize_airootfs.sh @@ -37,6 +37,7 @@ systemctl enable sshd.service systemctl enable sysrescue-initialize.service systemctl enable sysrescue-autorun.service systemctl enable qemu-guest-agent.service +systemctl enable var-lib-pacman\\x2drolling-local.mount systemctl set-default multi-user.target # Mask irrelevant timer units (#140) diff --git a/build.sh b/build.sh index 5ea0d2c..3108dbf 100755 --- a/build.sh +++ b/build.sh @@ -158,20 +158,32 @@ make_customize_airootfs() { s|%ISO_ARCH%|${arch}|g; s|%INSTALL_DIR%|${install_dir}|g" \ ${script_path}/airootfs/etc/issue > ${work_dir}/${arch}/airootfs/etc/issue - + # delete the target file first because it is a symlink rm -f ${work_dir}/${arch}/airootfs/etc/os-release sed "s|%ARCHISO_LABEL%|${iso_label}|g; s|%ISO_VERSION%|${iso_version}|g; s|%ISO_ARCH%|${arch}|g; - s|%INSTALL_DIR%|${install_dir}|g" \ + s|%INSTALL_DIR%|${install_dir}|g; + s|%SNAPSHOT_DATE%|${snapshot_date//\//-}|g;" \ ${script_path}/airootfs/etc/os-release > ${work_dir}/${arch}/airootfs/etc/os-release curl -o ${work_dir}/${arch}/airootfs/etc/pacman.d/mirrorlist "$mirrorlist_url" + sed "s|%SNAPSHOT_DATE%|${snapshot_date}|g;" \ + ${script_path}/${archive_mirrorlist_file} > ${work_dir}/${arch}/airootfs/etc/pacman.d/mirrorlist-snapshot + + mkdir -p ${work_dir}/${arch}/airootfs/var/lib/pacman-rolling/local + setarch ${arch} mkarchiso ${verbose} -w "${work_dir}/${arch}" -C "${work_dir}/pacman.conf" -D "${install_dir}" -r '/root/customize_airootfs.sh' run + rm -f ${work_dir}/${arch}/airootfs/root/customize_airootfs.sh + # change pacman config in airootfs to use snapshot repo by default + # we can just do this after the mkarchiso run, it would flatten the symlink otherwise + rm -f ${work_dir}/${arch}/airootfs/etc/pacman.conf + ln -s pacman-snapshot.conf ${work_dir}/${arch}/airootfs/etc/pacman.conf + # strip large binaries find ${work_dir}/${arch}/airootfs/usr/lib -type f -name "lib*.so.*" -exec strip --strip-all {} \; } diff --git a/mirrorlist-snapshot-i686 b/mirrorlist-snapshot-i686 index 2d4818e..9b9d8e1 100644 --- a/mirrorlist-snapshot-i686 +++ b/mirrorlist-snapshot-i686 @@ -2,5 +2,5 @@ # Mirrors for archive.archlinux32.org # Currently just one stable mirror known, see https://bbs.archlinux32.org/viewforum.php?id=10 # -Server = https://archive.archlinux32.org/repos/%SNAPSHOT_DATE%/$repo/os/$arch +Server = https://archive.archlinux32.org/repos/%SNAPSHOT_DATE%/$arch/$repo