From dafcd0f5e0d5456e450e2fd1a5f5209035cbbcf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Wed, 26 Aug 2026 19:35:00 -0300 Subject: [PATCH] fix(build): leave binary metadata stale in source-only mode Finalize and describe the binary repository only when binary artifacts were built. Source-only builds still publish and index their SRPMs without rewriting metadata for older binary RPMs. --- build-utils/buildcore-source-only.sh | 43 ++++++++++++++++++++++++++++ buildcore.sh | 39 ++++++------------------- 2 files changed, 52 insertions(+), 30 deletions(-) diff --git a/build-utils/buildcore-source-only.sh b/build-utils/buildcore-source-only.sh index da0ffcf58..f03a3f080 100644 --- a/build-utils/buildcore-source-only.sh +++ b/build-utils/buildcore-source-only.sh @@ -86,3 +86,46 @@ function xcat_publish_tarball_link { fi fi } + +function xcat_finalize_repository { + local artifact_kind="$1" + local repository="$2" + + if [ "$artifact_kind" = "binary" ] && xcat_source_only; then + return + fi + + if [ "$RPMSIGN" = "1" ]; then + if [ "$artifact_kind" = "binary" ]; then + build-utils/rpmsign.exp `find "$repository" -type f -name '*.rpm'` | grep -v -E '(already contains identical signature|was already signed|rpm --quiet --resign|WARNING: standard input reopened)' + else + build-utils/rpmsign.exp "$repository"/*rpm | grep -v -E '(already contains identical signature|was already signed|rpm --quiet --resign|WARNING: standard input reopened)' + fi + fi + + createrepo "$repository" + + if [ "$RPMSIGN" = "1" ]; then + rm -f "$repository/repodata/repomd.xml.asc" + gpg -a --detach-sign --default-key "xCAT Automatic Signing Key" "$repository/repodata/repomd.xml" + if [ ! -f "$repository/repodata/repomd.xml.key" ]; then + gpg -a --export "xCAT Automatic Signing Key" > "$repository/repodata/repomd.xml.key" + fi + fi +} + +function xcat_write_binary_buildinfo { + local buildinfo="$1" + + if xcat_source_only; then + echo "Not updating $buildinfo: a source-only build makes no binary bundle." + return + fi + + echo "VERSION=$VER" > "$buildinfo" + echo "RELEASE=$XCAT_RELEASE" >> "$buildinfo" + echo "BUILD_TIME=$BUILD_TIME" >> "$buildinfo" + echo "BUILD_MACHINE=$BUILD_MACHINE" >> "$buildinfo" + echo "COMMIT_ID=$COMMIT_ID" >> "$buildinfo" + echo "COMMIT_ID_LONG=$COMMIT_ID_LONG" >> "$buildinfo" +} diff --git a/buildcore.sh b/buildcore.sh index 65952cf3f..192ddf101 100755 --- a/buildcore.sh +++ b/buildcore.sh @@ -450,35 +450,19 @@ if [ "$OSNAME" != "AIX" ]; then echo '%_gpg_name xCAT Automatic Signing Key' >> $MACROS fi echo "Signing RPMs..." - build-utils/rpmsign.exp `find $DESTDIR -type f -name '*.rpm'` | grep -v -E '(already contains identical signature|was already signed|rpm --quiet --resign|WARNING: standard input reopened)' - build-utils/rpmsign.exp $SRCDIR/*rpm | grep -v -E '(already contains identical signature|was already signed|rpm --quiet --resign|WARNING: standard input reopened)' - # RHEL5 is archaic. Use the default hash algorithm to do the checksum. - # Which is SHA-256 on RHEL6. - createrepo $DESTDIR - createrepo $SRCDIR - rm -f $SRCDIR/repodata/repomd.xml.asc - rm -f $DESTDIR/repodata/repomd.xml.asc - # Use the xCAT Automatic Signing Key to do the signing - gpg -a --detach-sign --default-key "xCAT Automatic Signing Key" $DESTDIR/repodata/repomd.xml - gpg -a --detach-sign --default-key "xCAT Automatic Signing Key" $SRCDIR/repodata/repomd.xml - if [ ! -f $DESTDIR/repodata/repomd.xml.key ]; then - gpg -a --export "xCAT Automatic Signing Key" > $DESTDIR/repodata/repomd.xml.key - fi - if [ ! -f $SRCDIR/repodata/repomd.xml.key ]; then - gpg -a --export "xCAT Automatic Signing Key" > $SRCDIR/repodata/repomd.xml.key - fi - else - createrepo $DESTDIR - createrepo $SRCDIR fi + xcat_finalize_repository binary "$DESTDIR" + xcat_finalize_repository source "$SRCDIR" fi # set group and permissions correctly on the built rpms if [ "$OSNAME" = "AIX" ]; then chmod +x $DESTDIR/instxcat fi -chgrp -R $SYSGRP $DESTDIR -chmod -R g+w $DESTDIR +if ! xcat_source_only; then + chgrp -R $SYSGRP $DESTDIR + chmod -R g+w $DESTDIR +fi chgrp -R $SYSGRP $SRCDIR chmod -R g+w $SRCDIR @@ -496,7 +480,7 @@ fi cd $DESTDIR -if [ "$OSNAME" != "AIX" ]; then +if [ "$OSNAME" != "AIX" ] && ! xcat_source_only; then # Modify the repo file to point to either xcat-core or core-snap # Always recreate it, in case the whole dir was copied from devel to 2.x @@ -550,12 +534,7 @@ fi # Add a buildinfo file into the tar.bz2 file to track information about the build # BUILDINFO=$XCATCORE/buildinfo -echo "VERSION=$VER" > $BUILDINFO -echo "RELEASE=$XCAT_RELEASE" >> $BUILDINFO -echo "BUILD_TIME=$BUILD_TIME" >> $BUILDINFO -echo "BUILD_MACHINE=$BUILD_MACHINE" >> $BUILDINFO -echo "COMMIT_ID=$COMMIT_ID" >> $BUILDINFO -echo "COMMIT_ID_LONG=$COMMIT_ID_LONG" >> $BUILDINFO +xcat_write_binary_buildinfo "$BUILDINFO" xcat_create_binary_tarball xcat_publish_tarball_link @@ -572,7 +551,7 @@ if [ "$OSNAME" = "AIX" ]; then else YUM=yum fi -if [ ! -e core-snap ]; then +if ! xcat_source_only && [ ! -e core-snap ]; then ln -s xcat-core core-snap fi if xcat_source_only; then