2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-21 08:33:20 +00:00

fix(xcat-core): check the absolute paths the Genesis module installs, and name the deb the rename supersedes

verify-genesis-payload dropped every name that started with "/" before checking
the payload, so the 609 absolute paths the EL dracut module installs were
checked by nothing. An image with no /usr/bin/awk passed. The filter now drops
only option words, and an absolute name is read back under the payload root.

The ppc64 to ppc64el rename left the new Genesis base deb without a relation to
the deb it replaces, so dpkg kept xcat-genesis-base-ppc64 installed beside it
with its own copy of the files under /opt/xcat/share/xcat/netboot/genesis.
builddeb-genesis-base and debuild-xcat-genesis-base now write Replaces and
Breaks for the superseded package, as the genesis-scripts control file already
does. The native path takes the architecture rewrite into rewrite_control() so
the superseded name is derived in one place.

genesis_payload_verification.t, genesis_base_deb_arch.t and
genesis_base_deb_control_rewrite.t fail without this change.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Daniel Hilst
2026-09-11 16:00:57 -03:00
parent b3ed5e6d24
commit da9e17fb53
3 changed files with 51 additions and 15 deletions
+15 -2
View File
@@ -15,6 +15,20 @@ case "$BUILDARCH" in
*) echo "ERROR: unsupported architecture: $BUILDARCH" >&2; exit 1 ;;
esac
# The Genesis debs carry the architecture in the package name, so the packages an upgrade has
# to displace carry it too. 2.19 renames the ppc64 debs to ppc64el; dpkg keeps the old package,
# and its copy of the same files, unless the new one replaces it by name.
rewrite_control() {
local control=$1 arch=$2 superseded
case "$arch" in
ppc64el) superseded="xcat-genesis-ppc64, xcat-genesis-base-ppc64" ;;
*) superseded="xcat-genesis-$arch" ;;
esac
sed -i -e "s/xcat-genesis-base-amd64/xcat-genesis-base-$arch/g" \
-e "s/xcat-genesis-scripts-amd64/xcat-genesis-scripts-$arch/g" \
-e "s/xcat-genesis-amd64/$superseded/g" "$control"
}
VERSION=$(cat "$DIR/../Version" 2>/dev/null || echo "2.18.0")
RELEASE=$(cat "$DIR/../Release" 2>/dev/null || echo "snap$(date +%Y%m%d%H%M)")
CODENAME=$(. /etc/os-release && echo "$VERSION_CODENAME")
@@ -148,8 +162,7 @@ rm -rf "$DIR/opt"
cp -a "$GENESIS_TMPDIR/opt" "$DIR/"
# Adjust control file for target arch
sed -i "s/xcat-genesis-base-amd64/xcat-genesis-base-$BUILDARCH/g" "$DIR/debian/control"
sed -i "s/xcat-genesis-scripts-amd64/xcat-genesis-scripts-$BUILDARCH/g" "$DIR/debian/control"
rewrite_control "$DIR/debian/control" "$BUILDARCH"
PKG_VERSION="${VERSION}-${RELEASE}~${CODENAME}"
rm -f "$DIR/debian/changelog"
+13 -1
View File
@@ -51,7 +51,19 @@ then
sed -i -e "s/${ALIEN_ARCH}/${DEB_ARCH}/g" "${EXTRACT_DIR}/debian/changelog"
fi
sed -i -e "/^Description:/i Breaks: xcat-genesis-scripts-${DEB_ARCH} (<< 2.13.10)" "${EXTRACT_DIR}/debian/control"
# The Genesis debs carry the architecture in the package name, so the packages an upgrade has
# to displace carry it too. 2.19 renames the ppc64 debs to ppc64el; dpkg keeps the old package,
# and its copy of the same files, unless the new one replaces it by name.
case "${DEB_ARCH}" in
ppc64el)
SUPERSEDED="xcat-genesis-ppc64, xcat-genesis-base-ppc64" ;;
*)
SUPERSEDED="xcat-genesis-${DEB_ARCH}" ;;
esac
sed -i -e "/^Description:/i Replaces: ${SUPERSEDED}" \
-e "/^Description:/i Breaks: ${SUPERSEDED}, xcat-genesis-scripts-${DEB_ARCH} (<< 2.13.10)" \
"${EXTRACT_DIR}/debian/control"
cat >"${EXTRACT_DIR}/debian/preinst" <<EOF
#!/bin/bash
+23 -12
View File
@@ -7,9 +7,11 @@
# openssl, no sshd-session and no UTF-8 locale. Check the extracted payload before it becomes
# an rpm.
#
# Paths are relative to <payload-root>. --commands-from reads back the command names the
# dracut module installs. The caller adds what only it knows (the DHCP client is not the same
# package on every release); the rules below come from the payload itself.
# Paths given on the command line are relative to <payload-root>. --commands-from reads back
# what the dracut module installs: a bare command name is looked for in the four binary
# directories, an absolute path under <payload-root> itself. The caller adds what only it
# knows (the DHCP client is not the same package on every release); the rules below come from
# the payload itself.
set -u
@@ -55,9 +57,10 @@ for path in "$@"; do
require "$path" "required by the build"
done
# The dracut module names every command Genesis runs. A name that the build root does not
# supply installs nothing and says nothing, so read the names back and check each one.
# Names under a condition are release-dependent, so only the top level of install() counts.
# The dracut module names every command and every data file Genesis needs. A name the build
# root does not supply installs nothing and says nothing, so read the names back and check
# each one. Names under a condition are release-dependent, so only the top level of install()
# counts.
if [ -n "$commands_from" ]; then
if [ ! -r "$commands_from" ]; then
echo "verify-genesis-payload: cannot read $commands_from" >&2
@@ -70,16 +73,24 @@ if [ -n "$commands_from" ]; then
sub(/#.*/, "")
sub(/^ dracut_install /, "")
print
}' "$commands_from" | tr ' \t' '\n\n' | grep -v '^$' | grep -v '^[/-]' | sort -u)
}' "$commands_from" | tr ' \t' '\n\n' | grep -v '^$' | grep -v '^-' | sort -u)
if [ -z "$commands" ]; then
echo "verify-genesis-payload: no command name read from $commands_from" >&2
exit 2
fi
for command in $commands; do
have "bin/$command" || have "sbin/$command" \
|| have "usr/bin/$command" || have "usr/sbin/$command" \
|| missing="$missing
$command (installed by $commands_from)"
for want in $commands; do
case "$want" in
# dracut_install installs an absolute path at that same path, so read it back
# under the payload root. Dropping these let an image with no /usr/bin/awk pass.
/*) have "${want#/}" || missing="$missing
$want (installed by $commands_from)"
;;
*) have "bin/$want" || have "sbin/$want" \
|| have "usr/bin/$want" || have "usr/sbin/$want" \
|| missing="$missing
$want (installed by $commands_from)"
;;
esac
done
fi