From ca9a5301df2c26278875bd26c5ca8a197d0d0bfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Mon, 12 Oct 2026 12:33:26 -0300 Subject: [PATCH] fix(packaging): embed upgrade functions in package scripts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generate self-contained RPM and Debian upgrade scripts from the shared source. Package transactions no longer load functions from the node-facing postscript payload. Keep the existing command, logging and failure policies. Signed-off-by: Vinícius Ferrão <2031761+viniciusferrao@users.noreply.github.com> --- buildrpms.pl | 2 ++ xCAT/debian/postinst | 1 - xCAT/debian/rules | 6 ++++++ xCAT/xCAT.spec | 8 ++++++-- .../xcatupgradeutils.sh => xcat-upgrade-functions.sh} | 0 5 files changed, 14 insertions(+), 3 deletions(-) rename xCAT/{postscripts/xcatupgradeutils.sh => xcat-upgrade-functions.sh} (100%) diff --git a/buildrpms.pl b/buildrpms.pl index 8a55e448c..fc756a621 100755 --- a/buildrpms.pl +++ b/buildrpms.pl @@ -374,6 +374,8 @@ sub buildsources { } if ($pkg eq "xCAT") { + cp 'xCAT/xcat-upgrade-functions.sh', "$SOURCES/xcat-upgrade-functions.sh" + or die "FATAL: unable to stage upgrade functions: $!\n"; my @files = ("bmcsetup", "getipmi"); for my $f (@files) { cp "xCAT-genesis-scripts/usr/bin/$f", "$pkg/postscripts/$f"; diff --git a/xCAT/debian/postinst b/xCAT/debian/postinst index 952bcf235..bbb179ede 100644 --- a/xCAT/debian/postinst +++ b/xCAT/debian/postinst @@ -35,7 +35,6 @@ case "$1" in if [ -r "/tmp/xcat/mainservice.pid" ]; then mv /tmp/xcat/mainservice.pid /var/run/xcat/mainservice.pid fi - . /install/postscripts/xcatupgradeutils.sh xcat_run_upgrade xcatconfig -u -V rm /tmp/xCAT_upgrade.tmp else diff --git a/xCAT/debian/rules b/xCAT/debian/rules index 89a91529c..170320c1f 100755 --- a/xCAT/debian/rules +++ b/xCAT/debian/rules @@ -59,6 +59,12 @@ binary-arch: dh_perl dh_makeshlibs dh_installdeb + set -e; scriptfile=debian/xcat/DEBIAN/postinst; \ + { head -n 1 "$$scriptfile"; \ + cat xcat-upgrade-functions.sh; \ + tail -n +2 "$$scriptfile"; } > "$$scriptfile.tmp"; \ + chmod 755 "$$scriptfile.tmp"; \ + mv "$$scriptfile.tmp" "$$scriptfile" dh_shlibdeps dh_gencontrol -- -Vperl:Depends=perl dh_md5sums diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index c0e674b32..ee174a1cb 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -23,6 +23,7 @@ Source9: xcat-apache-pretrans.lua %endif Source7: xcat.conf.apach24 +Source10: xcat-upgrade-functions.sh Provides: xCAT = %{version} Conflicts: xCATsn @@ -246,7 +247,8 @@ mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT -%post +cat %{SOURCE10} > xcat-post.sh +cat >> xcat-post.sh <<'XCAT_POST' %ifos linux # On SUSE apache2, mod_headers is not loaded by default; enable it so the # security response headers in xcat.conf take effect (a no-op where a2enmod @@ -285,7 +287,6 @@ if [ -r "/tmp/xcat/mainservice.pid" ]; then mv /tmp/xcat/mainservice.pid /var/run/xcat/mainservice.pid fi -. /install/postscripts/xcatupgradeutils.sh xcat_run_upgrade $RPM_INSTALL_PREFIX0/sbin/xcatconfig -u -V # rpm has either updated a stock xcat.conf or preserved a modified one and left @@ -308,6 +309,9 @@ if [ -f "/proc/cmdline" ] && [ "x$(stat -c '%i %d' /)" == "x$(stat -c '%i %d' /p fi fi exit 0 +XCAT_POST + +%post -f xcat-post.sh %clean diff --git a/xCAT/postscripts/xcatupgradeutils.sh b/xCAT/xcat-upgrade-functions.sh similarity index 100% rename from xCAT/postscripts/xcatupgradeutils.sh rename to xCAT/xcat-upgrade-functions.sh