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.
This commit is contained in:
Gerd v. Egidy 2021-12-05 02:08:37 +01:00
parent 1b1e63c883
commit 4421a2bc75
7 changed files with 212 additions and 3 deletions

View file

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

View file

@ -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 <regular-pacman-command>
#
# 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

View file

@ -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 <regular-pacman-command>
#
# 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

View file

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

View file

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

View file

@ -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 {} \;
}

View file

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