Skip to content

Commit

Permalink
test: support NO_BUILD=yes on Fedora
Browse files Browse the repository at this point in the history
  • Loading branch information
mrc0mmand committed Nov 20, 2023
1 parent 09c4057 commit 054d141
Showing 1 changed file with 52 additions and 6 deletions.
58 changes: 52 additions & 6 deletions test/test-functions
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ os_release=$(test -e /etc/os-release && echo /etc/os-release || echo /usr/lib/os
source "$os_release"
[[ "$ID" == "debian" || " $ID_LIKE " == *" debian "* ]] && LOOKS_LIKE_DEBIAN=yes || LOOKS_LIKE_DEBIAN=no
[[ "$ID" == "arch" || " $ID_LIKE " == *" arch "* ]] && LOOKS_LIKE_ARCH=yes || LOOKS_LIKE_ARCH=no
[[ "$ID" == "fedora" ]] && LOOKS_LIKE_FEDORA=yes || LOOKS_LIKE_FEDORA=no
[[ " $ID_LIKE " == *" suse "* ]] && LOOKS_LIKE_SUSE=yes || LOOKS_LIKE_SUSE=no

KERNEL_VER="${KERNEL_VER-$(uname -r)}"
Expand Down Expand Up @@ -1313,6 +1314,25 @@ install_debian_systemd() {
done < <(grep -E '^Package:' "${SOURCE_DIR}/debian/control" | cut -d ':' -f 2)
}

install_rpm() {
local rpm="${1:?}"
local file

if ! rpm -q "$rpm" >/dev/null; then
derror "RPM $rpm is not installed"
return 1
fi

dinfo "Installing contents of RPM $rpm"
while read -r file; do
# Skip missing files (like /etc/machine-info)
[[ ! -e "$file" ]] && continue
# Skip directories unless they are a symlink (both -L and -d pass in this case)
[[ -d "$file" && ! -L "$file" ]] && continue
image_install "$file"
done < <(rpm -ql "$rpm")
}

install_suse_systemd() {
local pkgs

Expand All @@ -1335,12 +1355,7 @@ install_suse_systemd() {
for p in "${pkgs[@]}"; do
rpm -q "$p" &>/dev/null || continue

ddebug "Install files from package $p"
while read -r f; do
[ -e "$f" ] || continue
[ ! -L "$f" ] && [ -d "$f" ] && continue
inst "$f"
done < <(rpm -ql "$p")
install_rpm "$p"
done

dinfo "Install the data needed by the tests at runtime"
Expand All @@ -1352,13 +1367,44 @@ install_suse_systemd() {
mkdir -p "$initdir/var/log/journal/remote"
}

install_fedora_systemd() {
local required_packages=(
systemd
systemd-container
systemd-libs
systemd-pam
systemd-tests
systemd-udev
)
local optional_packages=(
systemd-boot-unsigned
systemd-bootchart
systemd-journal-remote
systemd-networkd
systemd-oomd-defaults
systemd-resolved
)
local package

for package in "${required_packages[@]}"; do
install_rpm "$package"
done

for package in "${optional_packages[@]}"; do
rpm -q "$package" || continue
install_rpm "$package"
done
}

install_distro_systemd() {
dinfo "Install distro systemd"

if get_bool "$LOOKS_LIKE_DEBIAN"; then
install_debian_systemd
elif get_bool "$LOOKS_LIKE_SUSE"; then
install_suse_systemd
elif get_bool "$LOOKS_LIKE_FEDORA"; then
install_fedora_systemd
else
dfatal "NO_BUILD not supported for this distro"
exit 1
Expand Down

0 comments on commit 054d141

Please sign in to comment.