mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-05 12:37:54 +00:00
refactor(build): retire makerpm, buildcore.sh and buildlocal.sh
buildrpms.pl is what actually builds xcat-core now: every core CD pipeline calls
it (ci/{el,suse,ubuntu}/Jenkinsfile.core-*), and it reaches none of these
scripts. What is left of them is a second, diverging build path that nothing
runs -- buildcore.sh has no caller at all (its one mention in
Jenkinsfile.core-el-stable is a comment), makerpm's only caller is
buildlocal.sh, and buildlocal.sh has no caller.
That divergence broke master. #7774 added a source-only mode to these scripts
rather than to buildrpms.pl, giving makerpm an unguarded
. "$(dirname "$0")/build-utils/source-only.sh"
at line 13, used on every build path (xcat_configure_rpm_build_mode,
xcat_announce_build), not only under SRCONLY. apache_config_sources.t stages
makerpm into a fixture that creates build-utils/ but copies only
sync-xcat-apache-configs into it, so makerpm died at line 13 and nothing reached
SOURCES/. Because prove -r xCAT-test/unit runs the whole suite, that reddened
xcat_pr_test on every open PR. It merged on a green run from 2026-08-27;
apache_config_sources.t landed 2026-08-30, and nothing rebuilt it in between.
Removed: makerpm, buildcore.sh, buildlocal.sh, build-utils/source-only.sh,
build-utils/buildcore-source-only.sh, and the tests that covered only them
(makerpm_source_only.t, buildcore_source_only.t). The makerpm half of
apache_config_sources.t goes with makerpm; its sync-xcat-apache-configs half
stays, because buildrpms.pl invokes that helper directly. The source-only
capability is preserved as buildrpms.pl --source-only, in the preceding commit.
build-ubunturepo is deliberately NOT touched. It is not a legacy script: both
Ubuntu core CD pipelines invoke it, github_action_xcat_test.pl:325 invokes it on
every PR, and it was last fixed this week. buildrpms.pl is RPM-only -- mock and
createrepo_c, no dpkg path -- so there is nothing to migrate it to. Giving
Debian builds an equivalent modern builder is separate work.
Verified: prove -r xCAT-test/unit before and after differs by exactly one file
-- apache_config_sources.t fails on upstream/master (4a0d9e0bb, tests 64-65) and
passes here. The other six failures are identical on both and are missing DB
modules on the machine that ran it. No remaining reference to any removed file
except the one comment in buildrpms.pl naming where its templates came from.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -1,131 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Source-only artifact delivery used by buildcore.sh.
|
||||
|
||||
function xcat_deliver_noarch_package {
|
||||
local rpmname="$1"
|
||||
|
||||
if ! xcat_source_only; then
|
||||
rm -f $DESTDIR/$rpmname*rpm
|
||||
mv $source/RPMS/$NOARCH/$rpmname-$VER*rpm $DESTDIR
|
||||
fi
|
||||
rm -f $SRCDIR/$rpmname*rpm
|
||||
mv $source/SRPMS/$rpmname-$VER*rpm $SRCDIR
|
||||
}
|
||||
|
||||
function xcat_deliver_genesis_packages {
|
||||
if ! xcat_source_only; then
|
||||
rm -f $DESTDIR/xCAT-genesis-scripts*rpm
|
||||
mv $source/RPMS/noarch/xCAT-genesis-scripts-*rpm $DESTDIR
|
||||
fi
|
||||
rm -f $SRCDIR/xCAT-genesis-scripts*rpm
|
||||
mv $source/SRPMS/xCAT-genesis-scripts-*rpm $SRCDIR
|
||||
}
|
||||
|
||||
function xcat_deliver_arch_package {
|
||||
local rpmname="$1"
|
||||
|
||||
if ! xcat_source_only; then
|
||||
rm -f $DESTDIR/$rpmname-$SHORTSHORTVER*rpm
|
||||
mv $source/RPMS/*/$rpmname-$VER*rpm $DESTDIR
|
||||
fi
|
||||
rm -f $SRCDIR/$rpmname-$SHORTSHORTVER*rpm
|
||||
mv $source/SRPMS/$rpmname-$VER*rpm $SRCDIR
|
||||
}
|
||||
|
||||
function xcat_deliver_embed_links {
|
||||
if xcat_source_only; then
|
||||
return
|
||||
fi
|
||||
if [ -n "$EMBED" -a -n "$EMBEDLINK" ]; then
|
||||
cd $DESTDIR
|
||||
maindir="../../$XCATCORE"
|
||||
for rpmname in $EMBEDLINK; do
|
||||
if [ "$rpmname" = "xCAT" -o "$rpmname" = "xCATsn" ]; then
|
||||
if [ "$EMBED" = "zvm" ]; then
|
||||
echo "Creating link for $rpmname-$SHORTSHORTVER"'*.s390x.rpm'
|
||||
rm -f $rpmname-$SHORTSHORTVER*rpm
|
||||
ln -s $maindir/$rpmname-$SHORTSHORTVER*.s390x.rpm .
|
||||
fi
|
||||
else
|
||||
echo "Creating link for $rpmname-$SHORTSHORTVER"'*rpm'
|
||||
rm -f $rpmname-$SHORTSHORTVER*rpm
|
||||
ln -s $maindir/$rpmname-$SHORTSHORTVER*rpm .
|
||||
fi
|
||||
done
|
||||
cd - >/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
function xcat_create_binary_tarball {
|
||||
if xcat_source_only; then
|
||||
echo "Not creating $TARNAME: a source-only build makes no binary rpms."
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Creating $(dirname $DESTDIR)/$TARNAME ..."
|
||||
if [[ -e $TARNAME ]]; then
|
||||
mkdir -p previous
|
||||
mv -f $TARNAME previous
|
||||
fi
|
||||
if [ "$OSNAME" = "AIX" ]; then
|
||||
tar $verboseflag -hcf ${TARNAME%.gz} $XCATCORE
|
||||
gzip ${TARNAME%.gz}
|
||||
else
|
||||
tar $verboseflag -hjcf $TARNAME $XCATCORE
|
||||
fi
|
||||
chgrp $SYSGRP $TARNAME
|
||||
chmod g+w $TARNAME
|
||||
}
|
||||
|
||||
function xcat_publish_tarball_link {
|
||||
if [ -n "$DEST" ] && ! xcat_source_only; then
|
||||
ln -sf $(basename `pwd`)/$TARNAME ../$TARNAME
|
||||
if [ $? != 0 ]; then
|
||||
echo "ERROR: Failed to make symbol link $DEST/$TARNAME"
|
||||
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"
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Shared source-only build decisions used by makerpm and buildcore.sh.
|
||||
|
||||
function xcat_source_only {
|
||||
[ "$SRCONLY" = "1" -o "$SRCONLY" = "yes" -o "$SRCONLY" = "true" ]
|
||||
}
|
||||
|
||||
function xcat_rpm_build_arches {
|
||||
if xcat_source_only; then
|
||||
printf '%s\n' "$1"
|
||||
else
|
||||
printf '%s\n' "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function xcat_configure_rpm_build_mode {
|
||||
local osname="$1"
|
||||
|
||||
if xcat_source_only; then
|
||||
if [ "$osname" = "AIX" ]; then
|
||||
echo "Error: SRCONLY is not supported on AIX."
|
||||
return 1
|
||||
fi
|
||||
SPECBUILD="-bs"
|
||||
TARBUILD="-ts"
|
||||
else
|
||||
SPECBUILD="-ba"
|
||||
TARBUILD="-ta"
|
||||
fi
|
||||
}
|
||||
|
||||
function xcat_announce_build {
|
||||
if [ "$SPECBUILD" = "-bs" ]; then
|
||||
echo "Building $RPMROOT/SRPMS/$1-snap*.src.rpm $EMBEDTXT..."
|
||||
else
|
||||
echo "Building $2 $EMBEDTXT..."
|
||||
fi
|
||||
}
|
||||
|
||||
function xcat_rpmbuild_spec {
|
||||
rpmbuild $QUIET "$SPECBUILD" "$@"
|
||||
}
|
||||
|
||||
function xcat_rpmbuild_tar {
|
||||
rpmbuild $QUIET "$TARBUILD" "$@"
|
||||
}
|
||||
|
||||
function xcat_require_binary_build {
|
||||
local package="$1"
|
||||
|
||||
if xcat_source_only; then
|
||||
echo "Error: SRCONLY is not supported for $package."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
-592
@@ -1,592 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Build and upload the xcat-core code, on either linux or aix.
|
||||
|
||||
# Getting Started:
|
||||
# - Clone the xcat-core GitHub repository
|
||||
# - On Linux: make sure createrepo is installed on the build machine
|
||||
# - On AIX: Install openssl and openssh installp pkgs and run updtvpkg. Install from http://www.perzl.org/aix/ :
|
||||
# apr, apr-util, bash, bzip2, db4, expat, gdbm, gettext, glib2, gmp, info, libidn, neon, openssl (won't
|
||||
# conflict with the installp version - but i don't think you need this), pcre, perl-DBD-SQLite, perl-DBI,
|
||||
# popt, python, readline, rsynce, sqlite, subversion, unixODBC, zlib.
|
||||
# Install wget from http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/alpha.html
|
||||
# - Run this script from the xcat-core directory. It will create the other directories that are needed.
|
||||
#
|
||||
# Usage: buildcore.sh [attr=value attr=value ...]
|
||||
# Before running buildcore.sh, you must change the local git repo to the branch you want built, using: git checkout <branch>
|
||||
# PROMOTE=1 - if the attribute "PROMOTE" is specified, means an official dot release. This does not actually build
|
||||
# xcat, just uploads the most recent snap build to http://xcat.org/files/xcat/ .
|
||||
# If not specified, a snap build is assumed, which uploads to http://xcat.org/files/xcat/repos/yum/
|
||||
# or http//xcat.org/files/aix/.
|
||||
# PREGA=1 - use this option with PROMOTE=1 on a branch that already has a released dot release, but this build is
|
||||
# a GA candidate build, not to be released yet. This will result in the tarball being uploaded to
|
||||
# http://xcar.org/files/xcat/repos/yum/
|
||||
# (but the tarball file name will be like a released tarball, not a snap build). When you are ready to
|
||||
# release this build, use PROMOTE=1 without PREGA
|
||||
# BUILDALL=1 - build all rpms, whether they changed or not. Should be used for snap builds that are in prep for a release.
|
||||
# UP=0 or UP=1 - override the default upload behavior
|
||||
# GITUP=<filename> - control which rpms get built by specifying a coregitup file
|
||||
# EMBED=<embedded-environment> - the environment for which a minimal version of xcat should be built, e.g. zvm or flex
|
||||
# VERBOSE=1 - to see lots of verbose output
|
||||
# LOG=<filename> - provide an LOG file option to redirect some output into log file
|
||||
# GPGSIGN/RPMSIGN=0 or GPGSIGN/RPMSIGN=1 - Sign the RPMs using the keys on GSA, the default is to sign the rpms without GPGSIGN/RPMSIGN specified
|
||||
# DEST=<directory> - provide a directory to contains the build result
|
||||
#
|
||||
# The following environment variables can be modified if you need
|
||||
#
|
||||
|
||||
SCRIPT=$(readlink -f $0)
|
||||
SCRIPTPATH=`dirname $SCRIPT`
|
||||
|
||||
. "$SCRIPTPATH/build-utils/source-only.sh"
|
||||
. "$SCRIPTPATH/build-utils/buildcore-source-only.sh"
|
||||
|
||||
UPLOADUSER=litingt
|
||||
USER=xcat
|
||||
SERVER=xcat.org
|
||||
FILES_PATH="files"
|
||||
FRS="/var/www/${SERVER}/${FILES_PATH}"
|
||||
RELEASE=github.com/xcat2/xcat-core/releases
|
||||
|
||||
YUMDIR="${FRS}"
|
||||
YUMREPOURL="http://${SERVER}/${FILES_PATH}/xcat/repos/yum"
|
||||
|
||||
if [ "$1" = "-h" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then
|
||||
echo "Usage:"
|
||||
echo " ./buildcore.sh [-h | --help]"
|
||||
echo " ./buildcore.sh [UP=1] [GPGSIGN=1] [EMBED=<embedded-environment>] [COMMITID=<id>] [GITPULL=0]"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# These are the rpms that should be built for each kind of xcat build
|
||||
ALLBUILD="perl-xCAT xCAT-client xCAT-server xCAT-test xCAT-buildkit xCAT xCATsn xCAT-genesis-scripts xCAT-SoftLayer xCAT-vlan xCAT-confluent xCAT-probe xCAT-csm xCAT-openbmc-py"
|
||||
ZVMBUILD="perl-xCAT xCAT-server xCAT-UI"
|
||||
ZVMLINK="xCAT-client xCAT xCATsn"
|
||||
# xCAT and xCATsn have PCM specific configuration - conserver-xcat, syslinux-xcat
|
||||
# xCAT-server has PCM specific configuration - RESTAPI(perl-JSON)
|
||||
# xCAT-client has PCM specific configuration - getxcatdocs(perl-JSON)
|
||||
PCMBUILD="xCAT xCAT-server xCAT-client xCATsn"
|
||||
PCMLINK="perl-xCAT xCAT-buildkit xCAT-genesis-scripts-x86_64 xCAT-genesis-scripts-ppc64 xCAT-vlan xCAT-probe"
|
||||
# Note: for FSM, the FlexCAT rpm is built separately from gsa/git
|
||||
FSMBUILD="perl-xCAT xCAT-client xCAT-server"
|
||||
FSMLINK=""
|
||||
# If you add more embed cases, also change the if [ -n "$EMBED" ]... below
|
||||
|
||||
# Process cmd line variable assignments, assigning each attr=val pair to a variable of same name
|
||||
for i in $*; do
|
||||
# upper case the variable name
|
||||
varstring=`echo "$i"|cut -d '=' -f 1|tr '[a-z]' '[A-Z]'`=`echo "$i"|cut -d '=' -f 2`
|
||||
export $varstring
|
||||
done
|
||||
if [ "$VERBOSE" = "1" -o "$VERBOSE" = "yes" ]; then
|
||||
set -x
|
||||
VERBOSEMODE=1
|
||||
fi
|
||||
|
||||
# For users to build from source code, simply run ./buildcore.sh
|
||||
# 1. Do not sign RPM by default
|
||||
# 2. Build all packages by default
|
||||
# 3. Do not upload to sourcefore by default
|
||||
|
||||
if [ -z "$RPMSIGN" ] && [ -z "$GPGSIGN" ]; then
|
||||
RPMSIGN=0
|
||||
elif [ -n "$GPGSIGN" ]; then # use GPGSIGN in first
|
||||
RPMSIGN=$GPGSIGN
|
||||
fi
|
||||
if [ -z "$RPMSIGN" -o "$RPMSIGN" != "1" ]; then
|
||||
RPMSIGN=0
|
||||
fi
|
||||
if [ -z "$BUILDALL" ]; then
|
||||
BUILDALL=1
|
||||
fi
|
||||
if [ -z "$UP" ]; then
|
||||
UP=0
|
||||
fi
|
||||
|
||||
# Find where this script is located to set some build variables
|
||||
cd `dirname $0`
|
||||
# strip the /src/xcat-core from the end of the dir to get the next dir up and use as the release
|
||||
if [ -z "$REL" ]; then
|
||||
curdir=`pwd`
|
||||
D=${curdir%/src/xcat-core}
|
||||
REL=`basename $D`
|
||||
fi
|
||||
OSNAME=$(uname)
|
||||
|
||||
if [ "$OSNAME" != "AIX" ]; then
|
||||
GSA=http://pokgsa.ibm.com/projects/x/xcat/build/linux
|
||||
|
||||
if [ "$(id -u)" == "0" ]; then
|
||||
# Some docker containers are missing /var/run/lock to which
|
||||
# /var/lock is linked. Add here if missing.
|
||||
if [ ! -e /var/run/lock ]; then
|
||||
mkdir -p /var/run/lock
|
||||
fi
|
||||
# Get a lock, so can not do 2 builds at once
|
||||
exec 8>/var/lock/xcatbld-$REL.lock
|
||||
if ! flock -n 8; then
|
||||
echo "Can't get lock /var/lock/xcatbld-$REL.lock. Someone else must be doing a build right now. Exiting...."
|
||||
exit 1
|
||||
fi
|
||||
# This is so rpm and gpg will know home, even in sudo
|
||||
export HOME=/root
|
||||
fi
|
||||
fi
|
||||
|
||||
# for the git case, query the current branch and set REL (changing master to devel if necessary)
|
||||
function setbranch {
|
||||
# Get the current branch name
|
||||
branch=`git rev-parse --abbrev-ref HEAD`
|
||||
if [ "$branch" = "master" ]; then
|
||||
REL="devel"
|
||||
elif [ "$branch" = "HEAD" ]; then
|
||||
# Special handling when in a 'detached HEAD' state
|
||||
branch=`git describe --abbrev=0 HEAD`
|
||||
[[ -n "$branch" ]] && REL=`echo $branch|cut -d. -f 1,2`
|
||||
else
|
||||
REL=$branch
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$REL" = "xcat-core" ]; then # using git
|
||||
GIT=1
|
||||
setbranch # this changes the REL variable
|
||||
fi
|
||||
|
||||
# Set variables based on which type of build we are doing
|
||||
if [ -n "$EMBED" ]; then
|
||||
EMBEDDIR="/$EMBED"
|
||||
if [ "$EMBED" = "zvm" ]; then
|
||||
EMBEDBUILD=$ZVMBUILD
|
||||
EMBEDLINK=$ZVMLINK
|
||||
elif [ "$EMBED" = "pcm" ]; then
|
||||
EMBEDBUILD=$PCMBUILD
|
||||
EMBEDLINK=$PCMLINK
|
||||
elif [ "$EMBED" = "fsm" ]; then
|
||||
EMBEDBUILD=$FSMBUILD
|
||||
EMBEDLINK=$FSMLINK
|
||||
else
|
||||
echo "Error: EMBED setting $EMBED not recognized."
|
||||
exit 2
|
||||
fi
|
||||
else
|
||||
EMBEDDIR=""
|
||||
EMBEDBUILD=$ALLBUILD
|
||||
EMBEDLINK=""
|
||||
fi
|
||||
|
||||
XCATCORE="xcat-core" # core-snap is a sym link to xcat-core
|
||||
SRCD=core-snap-srpms
|
||||
|
||||
if [ "$GIT" = "1" ]; then # using git - need to include REL in the path where we put the built rpms
|
||||
#DESTDIR=../../$REL$EMBEDDIR/$XCATCORE
|
||||
[ -z "$DEST" ] && DESTDIR=$HOME/xcatbuild/$REL$EMBEDDIR/$XCATCORE \
|
||||
|| DESTDIR=$DEST/$REL$EMBEDDIR/$XCATCORE
|
||||
else
|
||||
[ -z "$DEST" ] && DESTDIR=$HOME/xcatbuild/..$EMBEDDIR/$XCATCORE \
|
||||
|| DESTDIR=$DEST/xcatbuild/..$EMBEDDIR/$XCATCORE
|
||||
fi
|
||||
|
||||
# currently aix builds ppc rpms, but someday it should build noarch
|
||||
if [ "$OSNAME" = "AIX" ]; then
|
||||
NOARCH=ppc
|
||||
SYSGRP=system
|
||||
else
|
||||
NOARCH=noarch
|
||||
SYSGRP=$(id -g)
|
||||
fi
|
||||
|
||||
function setversionvars {
|
||||
if [ ! -z "$USEGITVER" ]; then
|
||||
VER=`git describe --tags`
|
||||
VER=${VER/-/.post}
|
||||
VER=${VER/-/.}
|
||||
else
|
||||
VER=`cat Version`
|
||||
fi
|
||||
XCATVER=$VER
|
||||
#export XCATVER
|
||||
SHORTVER=`echo $VER|cut -d. -f 1,2`
|
||||
SHORTSHORTVER=`echo $VER|cut -d. -f 1`
|
||||
BUILD_TIME=`date`
|
||||
BUILD_MACHINE=`hostname`
|
||||
COMMIT_ID_LONG=`git rev-parse HEAD`
|
||||
COMMIT_ID="${COMMIT_ID_LONG:0:7}"
|
||||
XCAT_RELEASE="snap$(date '+%Y%m%d%H%M')"
|
||||
echo "$XCAT_RELEASE" >Release
|
||||
}
|
||||
|
||||
RELEASE_FILE="${SCRIPTPATH}/Release"
|
||||
RELEASE_FILE_SAVE="${RELEASE_FILE}.save.998"
|
||||
|
||||
function internal_backup()
|
||||
{
|
||||
# Create a backup for file `Release'
|
||||
if [ ! -f "${RELEASE_FILE_SAVE}" ]
|
||||
then
|
||||
mv "${RELEASE_FILE}" "${RELEASE_FILE_SAVE}"
|
||||
cp "${RELEASE_FILE_SAVE}" "${RELEASE_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
function internal_cleanup()
|
||||
{
|
||||
# Restore file `Release'
|
||||
if [ -f "${RELEASE_FILE_SAVE}" ]
|
||||
then
|
||||
mv "${RELEASE_FILE_SAVE}" "${RELEASE_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
internal_backup
|
||||
trap internal_cleanup 0
|
||||
|
||||
if [ "$PROMOTE" != 1 ]; then # very long if statement to not do builds if we are promoting ### @LINE460 ###
|
||||
# we are doing a snap build
|
||||
CORE="core-snap"
|
||||
if [ "$OSNAME" = "AIX" ]; then
|
||||
TARNAME=core-aix-snap.tar.gz
|
||||
else
|
||||
TARNAME=core-rpms-snap.tar.bz2
|
||||
fi
|
||||
mkdir -p $DESTDIR
|
||||
SRCDIR=$DESTDIR/../$SRCD
|
||||
mkdir -p $SRCDIR
|
||||
if [ -n "$VERBOSEMODE" ]; then
|
||||
GREP=grep
|
||||
else
|
||||
GREP="grep -q"
|
||||
fi
|
||||
UPLOAD=0
|
||||
if [ "$OSNAME" = "AIX" ]; then
|
||||
source=/opt/freeware/src/packages
|
||||
else
|
||||
source=`rpmbuild --eval '%_topdir' xCATsn/xCATsn.spec`
|
||||
if [ $? -gt 0 ]; then
|
||||
echo "Error: Could not determine rpmbuild's root directory."
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# If no pre-defined update file is provided, do a "git pull" to try and detect
|
||||
# if anything has changed in the source directories
|
||||
#
|
||||
SOMETHINGCHANGED=0
|
||||
if [ "$GIT" = "1" ]; then
|
||||
#
|
||||
# To enable local sandbox build, GITPULL is disabled by default.
|
||||
#
|
||||
if [ "$GITPULL" = "1" ] || [ ${PWD} == *"autobuild"* ]; then
|
||||
# Do some checking for modified files
|
||||
MODIFIED_FILES=`git ls-files --modified | tr '\n' ', '`
|
||||
if [ $MODIFIED_FILES ]; then
|
||||
echo "WARNING: The following files have been modified in the local repository: $MODIFIED_FILES..."
|
||||
fi
|
||||
# Do some checking for untracked files
|
||||
UNTRACKED_FILES=`git ls-files --others | tr '\n' ', '`
|
||||
if [ -n "$UNTRACKED_FILES" ]; then
|
||||
echo "WARNING: The following files are not tracked in git: $UNTRACKED_FILES..."
|
||||
fi
|
||||
if [ -z "$GITUP" ]; then
|
||||
if [ ! -z "$COMMITID" ]; then
|
||||
echo "git checkout $COMMITID"
|
||||
git checkout $COMMITID
|
||||
if [[ $? != 0 ]]; then
|
||||
# do not continue so we do not build with old files
|
||||
echo "The 'git checkout' command failed. Exiting the build."
|
||||
exit 3
|
||||
fi
|
||||
else
|
||||
GITUP=../coregitup
|
||||
echo "git pull > $GITUP"
|
||||
git pull > $GITUP
|
||||
if [[ $? != 0 ]]; then
|
||||
# do not continue so we do not build with old files
|
||||
echo "The 'git pull' command failed. Exiting the build."
|
||||
exit 3
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ -f "$GITUP" ]; then
|
||||
if ! $GREP 'Already up-to-date' $GITUP; then
|
||||
SOMETHINGCHANGED=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
setversionvars
|
||||
|
||||
# Function for making the noarch rpms
|
||||
function maker {
|
||||
rpmname="$1"
|
||||
./makerpm $rpmname "$EMBED"
|
||||
if [ $? -ne 0 ]; then
|
||||
FAILEDRPMS="$FAILEDRPMS $rpmname"
|
||||
else
|
||||
xcat_deliver_noarch_package "$rpmname"
|
||||
fi
|
||||
}
|
||||
|
||||
# If anything has changed, we should always rebuild perl-xCAT
|
||||
if [ $SOMETHINGCHANGED == 1 -o "$BUILDALL" == 1 ]; then # Use to be: $GREP perl-xCAT $GITUP; then
|
||||
if [[ " $EMBEDBUILD " = *\ perl-xCAT\ * ]]; then
|
||||
UPLOAD=1
|
||||
maker perl-xCAT
|
||||
fi
|
||||
fi
|
||||
if [ "$OSNAME" = "AIX" ]; then
|
||||
# For the 1st one we overwrite, not append
|
||||
echo "rpm -Uvh perl-xCAT-$SHORTSHORTVER*rpm" > $DESTDIR/instxcat
|
||||
fi
|
||||
|
||||
# Build the rest of the noarch rpms
|
||||
for rpmname in xCAT-client xCAT-server xCAT-IBMhpc xCAT-rmc xCAT-UI xCAT-test xCAT-buildkit xCAT-SoftLayer xCAT-vlan xCAT-confluent xCAT-probe xCAT-csm xCAT-openbmc-py; do
|
||||
if [[ " $EMBEDBUILD " != *\ $rpmname\ * ]]; then continue; fi
|
||||
if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-buildkit" ]; then continue; fi # do not build xCAT-buildkit on aix
|
||||
if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-SoftLayer" ]; then continue; fi # do not build xCAT-softlayer on aix
|
||||
if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-vlan" ]; then continue; fi # do not build xCAT-vlan on aix
|
||||
if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-confluent" ]; then continue; fi # do not build xCAT-confluent on aix
|
||||
if [ "$BUILDALL" == 1 ] || $GREP $rpmname $GITUP; then
|
||||
UPLOAD=1
|
||||
maker $rpmname
|
||||
fi
|
||||
if [ "$OSNAME" = "AIX" ]; then
|
||||
if [ "$rpmname" = "xCAT-client" -o "$rpmname" = "xCAT-server" ]; then
|
||||
# we do not automatically install the rest of the rpms on AIX
|
||||
echo "rpm -Uvh $rpmname-$SHORTSHORTVER*rpm" >> $DESTDIR/instxcat
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Build xCAT-genesis-scripts for xcat-core. xCAT-genesis-base gets built by hand and put in xcat-dep.
|
||||
# The mknb cmd combines them at install time.
|
||||
if [ "$OSNAME" != "AIX" ]; then
|
||||
if [[ " $EMBEDBUILD " = *\ xCAT-genesis-scripts\ * ]]; then
|
||||
if [ "$BUILDALL" == 1 ] || $GREP xCAT-genesis-scripts $GITUP; then
|
||||
UPLOAD=1
|
||||
ORIGFAILEDRPMS="$FAILEDRPMS"
|
||||
for arch in x86_64 ppc64; do
|
||||
./makerpm xCAT-genesis-scripts $arch "$EMBED"
|
||||
if [ $? -ne 0 ]; then FAILEDRPMS="$FAILEDRPMS xCAT-genesis-scripts-$arch"; fi
|
||||
done
|
||||
# Do not build xCAT-genesis-scripts-aarch64 yet
|
||||
#./makerpm xCAT-genesis-scripts aarch64 "$EMBED"
|
||||
#if [ $? -ne 0 ]; then FAILEDRPMS="$FAILEDRPMS xCAT-genesis-scripts-aarch64"; fi
|
||||
if [ "$FAILEDRPMS" = "$ORIGFAILEDRPMS" ]; then # all succeeded
|
||||
xcat_deliver_genesis_packages
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Build the xCAT and xCATsn rpms for all platforms
|
||||
for rpmname in xCAT xCATsn; do
|
||||
if [[ " $EMBEDBUILD " != *\ $rpmname\ * ]]; then continue; fi
|
||||
if [ $SOMETHINGCHANGED == 1 -o "$BUILDALL" == 1 ]; then # used to be: if $GREP -E "^[UAD] +$rpmname/" $GITUP; then
|
||||
UPLOAD=1
|
||||
ORIGFAILEDRPMS="$FAILEDRPMS"
|
||||
if [ "$OSNAME" = "AIX" ]; then
|
||||
if [ "$rpmname" = "xCAT-OpenStack" ] || [ "$rpmname" = "xCAT-OpenStack-baremetal" ]; then continue; fi # do not bld openstack on aix
|
||||
./makerpm $rpmname "$EMBED"
|
||||
if [ $? -ne 0 ]; then FAILEDRPMS="$FAILEDRPMS $rpmname"; fi
|
||||
else
|
||||
for arch in $(xcat_rpm_build_arches x86_64 ppc64 ppc64le s390x aarch64); do
|
||||
if [ "$rpmname" = "xCAT-OpenStack" -a "$arch" != "x86_64" ] || [ "$rpmname" = "xCAT-OpenStack-baremetal" -a "$arch" != "x86_64" ] ; then continue; fi # only bld openstack for x86_64 for now
|
||||
./makerpm $rpmname $arch "$EMBED"
|
||||
if [ $? -ne 0 ]; then FAILEDRPMS="$FAILEDRPMS $rpmname-$arch"; fi
|
||||
done
|
||||
fi
|
||||
if [ "$FAILEDRPMS" = "$ORIGFAILEDRPMS" ]; then # all succeeded
|
||||
xcat_deliver_arch_package "$rpmname"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
# no longer put in xCAT-rmc
|
||||
if [ "$OSNAME" = "AIX" ]; then
|
||||
echo "rpm -Uvh xCAT-$SHORTSHORTVER*rpm" >> $DESTDIR/instxcat
|
||||
fi
|
||||
|
||||
# Make sym links in the embed subdirs for the rpms we do not have to build special
|
||||
xcat_deliver_embed_links
|
||||
|
||||
|
||||
# Decide if anything was built or not
|
||||
if [ -n "$FAILEDRPMS" ]; then
|
||||
echo "Error: build of the following RPMs failed: $FAILEDRPMS"
|
||||
exit 2
|
||||
fi
|
||||
if [ $UPLOAD == 0 -a "$UP" != 1 ]; then
|
||||
echo "Nothing new detected"
|
||||
exit 0
|
||||
fi
|
||||
#else we will continue
|
||||
|
||||
# Prepare the RPMs for pkging and upload
|
||||
WGET_CMD="wget"
|
||||
if [ ! -z ${LOG} ]; then
|
||||
WGET_CMD="wget -o ${LOG}"
|
||||
fi
|
||||
|
||||
# get gpg keys in place
|
||||
if [ "$OSNAME" != "AIX" ]; then
|
||||
if [ "$RPMSIGN" == "1" ]; then
|
||||
mkdir -p $HOME/.gnupg
|
||||
for i in pubring.gpg secring.gpg trustdb.gpg; do
|
||||
if [ ! -f $HOME/.gnupg/$i ] ||
|
||||
[ `wc -c $HOME/.gnupg/$i|cut -f 1 -d' '` == 0 ]; then
|
||||
rm -f $HOME/.gnupg/$i
|
||||
${WGET_CMD} -P $HOME/.gnupg $GSA/keys/$i
|
||||
chmod 600 $HOME/.gnupg/$i
|
||||
fi
|
||||
done
|
||||
# tell rpm to use gpg to sign
|
||||
MACROS=$HOME/.rpmmacros
|
||||
if ! $GREP '%_signature gpg' $MACROS 2>/dev/null; then
|
||||
echo '%_signature gpg' >> $MACROS
|
||||
fi
|
||||
if ! $GREP '%_gpg_name' $MACROS 2>/dev/null; then
|
||||
echo '%_gpg_name xCAT Automatic Signing Key' >> $MACROS
|
||||
fi
|
||||
echo "Signing RPMs..."
|
||||
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
|
||||
if ! xcat_source_only; then
|
||||
chgrp -R $SYSGRP $DESTDIR
|
||||
chmod -R g+w $DESTDIR
|
||||
fi
|
||||
chgrp -R $SYSGRP $SRCDIR
|
||||
chmod -R g+w $SRCDIR
|
||||
|
||||
else # end of very long if-not-promote ### @LINE193 ###
|
||||
# we are only promoting (not building)
|
||||
setversionvars
|
||||
setbranch
|
||||
CORE="xcat-core"
|
||||
if [ "$OSNAME" = "AIX" ]; then
|
||||
TARNAME=core-aix-$VER.tar.gz
|
||||
else
|
||||
TARNAME=xcat-core-$VER.tar.bz2
|
||||
fi
|
||||
fi
|
||||
|
||||
cd $DESTDIR
|
||||
|
||||
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
|
||||
if [ -n "$1" ]; then embed="$1/"
|
||||
else embed=""; fi
|
||||
cat >xcat-core.repo << EOF
|
||||
[xcat-core]
|
||||
name=xCAT 2 Core packages
|
||||
baseurl=$YUMREPOURL/$REL$EMBEDDIR/$CORE
|
||||
enabled=1
|
||||
gpgcheck=1
|
||||
gpgkey=$YUMREPOURL/$REL$EMBEDDIR/$CORE/repodata/repomd.xml.key
|
||||
EOF
|
||||
|
||||
|
||||
# Create the mklocalrepo script
|
||||
cat >mklocalrepo.sh << 'EOF2'
|
||||
#!/bin/sh
|
||||
cd `dirname $0`
|
||||
REPOFILE=`basename xcat-*.repo`
|
||||
if [[ $REPOFILE == "xcat-*.repo" ]]; then
|
||||
echo "ERROR: For xcat-dep, please execute $0 in the correct <os>/<arch> subdirectory"
|
||||
exit 1
|
||||
fi
|
||||
#
|
||||
# default to RHEL yum, if doesn't exist try Zypper
|
||||
#
|
||||
DIRECTORY="/etc/yum.repos.d"
|
||||
if [ ! -d "$DIRECTORY" ]; then
|
||||
DIRECTORY="/etc/zypp/repos.d"
|
||||
fi
|
||||
sed -e 's|baseurl=.*|baseurl=file://'"`pwd`"'|' $REPOFILE | sed -e 's|gpgkey=.*|gpgkey=file://'"`pwd`"'/repodata/repomd.xml.key|' > "$DIRECTORY/$REPOFILE"
|
||||
if [ -f "$DIRECTORY/xCAT-core.repo" ]; then
|
||||
mv "$DIRECTORY/xCAT-core.repo" "$DIRECTORY/xCAT-core.repo.nouse"
|
||||
fi
|
||||
cd -
|
||||
EOF2
|
||||
chmod 775 mklocalrepo.sh
|
||||
|
||||
fi # not AIX
|
||||
|
||||
# Build the tarball
|
||||
cd ..
|
||||
if [ -n "$VERBOSEMODE" ]; then
|
||||
verboseflag="-v"
|
||||
else
|
||||
verboseflag=""
|
||||
fi
|
||||
|
||||
#
|
||||
# Add a buildinfo file into the tar.bz2 file to track information about the build
|
||||
#
|
||||
BUILDINFO=$XCATCORE/buildinfo
|
||||
xcat_write_binary_buildinfo "$BUILDINFO"
|
||||
|
||||
xcat_create_binary_tarball
|
||||
xcat_publish_tarball_link
|
||||
|
||||
# Decide whether to upload or not
|
||||
if [ -n "$UP" ] && [ "$UP" == 0 ]; then
|
||||
exit 0;
|
||||
fi
|
||||
#else we will continue
|
||||
|
||||
# Upload the individual RPMs to xcat.org
|
||||
if [ "$OSNAME" = "AIX" ]; then
|
||||
YUM=aix
|
||||
else
|
||||
YUM=yum
|
||||
fi
|
||||
if ! xcat_source_only && [ ! -e core-snap ]; then
|
||||
ln -s xcat-core core-snap
|
||||
fi
|
||||
if xcat_source_only; then
|
||||
echo "Not uploading the binary rpms: a source-only build makes none."
|
||||
elif [ "$REL" = "devel" -o "$PREGA" != 1 ]; then
|
||||
i=0
|
||||
echo "Uploading RPMs from $CORE to $YUMDIR/$YUM/$REL$EMBEDDIR/ ..."
|
||||
while [ $((i+=1)) -le 5 ] && ! rsync -urLv --delete $CORE $USER@$SERVER:$YUMDIR/$YUM/$REL$EMBEDDIR/
|
||||
do : ; done
|
||||
fi
|
||||
|
||||
# Upload the individual source RPMs to xcat.org
|
||||
i=0
|
||||
echo "Uploading src RPMs from $SRCD to $YUMDIR/$YUM/$REL$EMBEDDIR/ ..."
|
||||
while [ $((i+=1)) -le 5 ] && ! rsync -urLv --delete $SRCD $USER@$SERVER:$YUMDIR/$YUM/$REL$EMBEDDIR/
|
||||
do : ; done
|
||||
|
||||
# Upload the tarball to xcat.org
|
||||
if xcat_source_only; then
|
||||
echo "Not uploading $TARNAME: a source-only build makes no binary rpms."
|
||||
elif [ "$PROMOTE" = 1 -a "$REL" != "devel" -a "$PREGA" != 1 ]; then
|
||||
# upload tarball to FRS area
|
||||
i=0
|
||||
echo "Uploading $TARNAME to $FRS/xcat/$REL.x_$OSNAME$EMBEDDIR/ ..."
|
||||
while [ $((i+=1)) -le 5 ] && ! rsync -v --force $TARNAME $USER@$SERVER:$FRS/xcat/$REL.x_$OSNAME$EMBEDDIR/
|
||||
do : ; done
|
||||
|
||||
# upload tarball to github when we release the build.
|
||||
i=0
|
||||
echo "Uploading $TARNAME to https://github.com/xcat2/xcat-core/releases ..."
|
||||
while [ $((i+=1)) -le 5 ] && ! rsync -v --force $TARNAME $UPLOADUSER@$RELEASE/
|
||||
do : ; done
|
||||
else
|
||||
i=0
|
||||
echo "Uploading $TARNAME to $YUMDIR/$YUM/$REL$EMBEDDIR/ ..."
|
||||
while [ $((i+=1)) -le 5 ] && ! rsync -v --force $TARNAME $USER@$SERVER:$YUMDIR/$YUM/$REL$EMBEDDIR/
|
||||
do : ; done
|
||||
fi
|
||||
-164
@@ -1,164 +0,0 @@
|
||||
#!/bin/sh
|
||||
#######################################################################
|
||||
#build script for local usage
|
||||
#used for Linux/AIX/Ubuntu
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
|
||||
OSNAME=$(uname)
|
||||
NAMEALL=$(uname -a)
|
||||
|
||||
for i in $*; do
|
||||
# upper case the variable name
|
||||
varstring=`echo "$i"|cut -d '=' -f 1|tr '[a-z]' '[A-Z]'`=`echo "$i"|cut -d '=' -f 2`
|
||||
export $varstring
|
||||
done
|
||||
|
||||
if [ -z "$CURDIR" ]; then
|
||||
echo "get current directory!"
|
||||
CURDIR=$(pwd)
|
||||
fi
|
||||
|
||||
echo "CURDIR is $CURDIR"
|
||||
echo "OSNAME is $OSNAME!"
|
||||
echo "NAMEALL is $NAMEALL"
|
||||
|
||||
grep -i 'SUSE' /etc/issue
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "This is a SUSE system!"
|
||||
OS="SUSE";
|
||||
fi
|
||||
|
||||
|
||||
ls $CURDIR/makerpm
|
||||
|
||||
if [ $? -gt 0 ]; then
|
||||
echo "Error:no repo exist, exit 1."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get a lock, so can not do 2 builds at once
|
||||
exec 8>/var/lock/xcatbld.lock
|
||||
if ! flock -n 8; then
|
||||
echo "Can't get lock /var/lock/xcatbld.lock. Someone else must be doing a build right now. Exiting...."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#delete old package if there is
|
||||
rm -rf $CURDIR/build/
|
||||
cd $CURDIR
|
||||
|
||||
echo "==============================================="
|
||||
echo $NAMEALL | egrep "Ubuntu"
|
||||
|
||||
#Check if it is an Ubuntu system
|
||||
if [ $? -eq 0 ]; then
|
||||
|
||||
echo "This is an Ubuntu system"
|
||||
pkg_type="snap"
|
||||
build_string="Snap_Build"
|
||||
cur_date=`date +%Y%m%d`
|
||||
short_ver=`cat Version|cut -d. -f 1,2`
|
||||
pkg_version="${short_ver}-${pkg_type}${cur_date}"
|
||||
|
||||
mkdir -p $CURDIR/build
|
||||
|
||||
for rpmname in xCAT-client xCAT-genesis-scripts perl-xCAT xCAT-server xCAT xCATsn xCAT-test xCAT-vlan; do
|
||||
rpmname_low=`echo $rpmname | tr '[A-Z]' '[a-z]'`
|
||||
echo "============================================"
|
||||
echo "$rpmname_low"
|
||||
cd $rpmname
|
||||
dch -v $pkg_version -b -c debian/changelog $build_string
|
||||
dpkg-buildpackage -uc -us
|
||||
rc=$?
|
||||
if [ $rc -gt 0 ]; then
|
||||
echo "Error: $rpmname build package failed exit code $rc"
|
||||
fi
|
||||
cd -
|
||||
mv ${rpmname_low}* $CURDIR/build
|
||||
|
||||
done
|
||||
#delete all files except .deb file
|
||||
find $CURDIR/build/* ! -name *.deb | xargs rm -f
|
||||
|
||||
else
|
||||
#This is not an Ubuntu system
|
||||
echo "This is an $OSNAME system"
|
||||
|
||||
if [ "$OS" = "SUSE" ]; then
|
||||
rm -rf /usr/src/packages/RPMS/noarch/*
|
||||
rm -rf /usr/src/packages/RPMS/x86_64/*
|
||||
rm -rf /usr/src/packages/RPMS/ppc64/*
|
||||
else
|
||||
rm -rf /root/rpmbuild/RPMS/noarch/*
|
||||
rm -rf /root/rpmbuild/RPMS/x86_64/*
|
||||
rm -rf /root/rpmbuild/RPMS/ppc64/*
|
||||
fi
|
||||
|
||||
mkdir -p $CURDIR/build/
|
||||
|
||||
#always build perl-xCAT
|
||||
$CURDIR/makerpm perl-xCAT
|
||||
|
||||
|
||||
# Build the rest of the noarch rpms
|
||||
for rpmname in xCAT-client xCAT-server xCAT-IBMhpc xCAT-rmc xCAT-test xCAT-buildkit xCAT-vlan; do
|
||||
if [ "$OSNAME" = "AIX" -a "$rpmname" = "xCAT-buildkit" ]; then continue; fi
|
||||
$CURDIR/makerpm $rpmname
|
||||
done
|
||||
|
||||
#build xCAT-genesis-scripts if it is x86_64 platform
|
||||
ARCH=$(uname -p)
|
||||
if [ "$ARCH" = "x86_64" ]; then
|
||||
$CURDIR/makerpm xCAT-genesis-scripts x86_64
|
||||
else
|
||||
$CURDIR/makerpm xCAT-genesis-scripts ppc64
|
||||
fi
|
||||
|
||||
|
||||
# Build the xCAT and xCATsn rpms for all platforms
|
||||
for rpmname in xCAT xCATsn; do
|
||||
if [ "$OSNAME" = "AIX" ]; then
|
||||
$CURDIR/makerpm $rpmname
|
||||
if [ $? -ne 0 ]; then FAILEDRPMS="$FAILEDRPMS $rpmname"; fi
|
||||
else
|
||||
for arch in x86_64 ppc64 s390x aarch64; do
|
||||
$CURDIR/makerpm $rpmname $arch
|
||||
if [ $? -ne 0 ]; then FAILEDRPMS="$FAILEDRPMS $rpmname-$arch"; fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$OS" = "SUSE" ]; then
|
||||
cp /usr/src/packages/RPMS/noarch/* $CURDIR/build/
|
||||
cp /usr/src/packages/RPMS/x86_64/* $CURDIR/build/
|
||||
cp /usr/src/packages/RPMS/ppc64/* $CURDIR/build/
|
||||
else
|
||||
cp /root/rpmbuild/RPMS/noarch/* $CURDIR/build/
|
||||
cp /root/rpmbuild/RPMS/x86_64/* $CURDIR/build/
|
||||
cp /root/rpmbuild/RPMS/ppc64/* $CURDIR/build/
|
||||
fi
|
||||
|
||||
#begin to create repo for redhat platform
|
||||
|
||||
grep -i 'Red' /etc/*release*;
|
||||
if [ "$OSNAME" != "AIX" -a $? -eq 0 ]; then
|
||||
cat >$CURDIR/build/xcat-core.repo << EOF
|
||||
[xcat-core]
|
||||
name=xCAT 2 Core packages
|
||||
baseurl=file://$CURDIR/build
|
||||
enabled=1
|
||||
gpgcheck=0
|
||||
EOF
|
||||
|
||||
cp $CURDIR/build/xcat-core.repo /etc/yum.repos.d/
|
||||
createrepo $CURDIR/build
|
||||
else
|
||||
rm -f /etc/zypp/repos.d/xcat-core.repo
|
||||
zypper ar file://$CURDIR/build xcat-core
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
|
||||
@@ -4,21 +4,38 @@ Building Source Code
|
||||
xcat-core
|
||||
---------
|
||||
|
||||
Clone the xCAT project from `GitHub <https://github.com/xcat2/xcat-core>`_::
|
||||
Clone the xCAT project from `GitHub <https://github.com/xcat2/xcat-core>`_ and
|
||||
build the rpms with ``buildrpms.pl``::
|
||||
|
||||
cd xcat-core
|
||||
./buildcore.sh
|
||||
./buildrpms.pl --target alma+epel-9-x86_64
|
||||
|
||||
To build the source rpms and no binary rpms, set ``SRCONLY``::
|
||||
Each package is built in its own ``mock`` chroot, so the build does not depend on
|
||||
what happens to be installed on the build host. Pass ``--target`` once per target
|
||||
to build several; the default is every supported EL target. ``./buildrpms.pl
|
||||
--help`` lists the rest.
|
||||
|
||||
To build the source rpms and no binary rpms, pass ``--source-only``::
|
||||
|
||||
cd xcat-core
|
||||
./buildcore.sh SRCONLY=1
|
||||
./buildrpms.pl --target alma+epel-9-x86_64 --source-only
|
||||
|
||||
A source rpm is the input that a build service such as mock, koji, COPR or OBS
|
||||
takes, and it lets one machine make the source rpms while another makes the
|
||||
binary rpms for each architecture. ``rpmbuild`` does not need the packages named
|
||||
in ``BuildRequires`` to make a source rpm, so this also builds on a machine that
|
||||
cannot complete a full build. ``SRCONLY`` is not supported on AIX.
|
||||
cannot complete a full build.
|
||||
|
||||
The source rpms land in ``dist/<target>/rpms/SRPMS/``. The binary repository
|
||||
metadata is left as the last full build wrote it, and no ``.repo`` file is
|
||||
emitted, because a source-only run has no binary packages to advertise.
|
||||
|
||||
.. note::
|
||||
|
||||
``buildcore.sh``, ``makerpm`` and ``buildlocal.sh`` were removed in 2.19.
|
||||
``buildrpms.pl`` replaces all three, and its ``--source-only`` replaces the
|
||||
old ``SRCONLY=1``. Debian and Ubuntu packages are still built by
|
||||
``./build-ubunturepo``.
|
||||
|
||||
xcat-deps
|
||||
---------
|
||||
|
||||
@@ -1,307 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
# Common script to make any one the xcat rpms. To build locally, run in the top dir of local svn repository, for example:
|
||||
# ./makerpm xCAT-server
|
||||
# ./makerpm xCAT x86_64
|
||||
# If you want verbose output: export VERBOSE=1
|
||||
# If you want source rpms only: export SRCONLY=1
|
||||
|
||||
# set -x
|
||||
|
||||
. "$(dirname "$0")/build-utils/source-only.sh"
|
||||
|
||||
function xcat_probe_copy {
|
||||
# xCAT-probe uses some functions shipped with xCAT, copying for the following reasons:
|
||||
# 1. make xCAT-probe code be self-contained
|
||||
# 2. do not maintain two files for each script
|
||||
RPMNAME=${1}
|
||||
if [ $RPMNAME = "xCAT-probe" ]; then
|
||||
mkdir -p ${RPMNAME}/lib/perl/xCAT/
|
||||
files=("NetworkUtils.pm" "GlobalDef.pm" "ServiceNodeUtils.pm")
|
||||
for f in "${files[@]}"; do
|
||||
cp perl-xCAT/xCAT/$f ${RPMNAME}/lib/perl/xCAT/
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function xcat_probe_cleanup {
|
||||
RPMNAME=${1}
|
||||
if [ $RPMNAME = "xCAT-probe" ]; then
|
||||
rm -rf ${RPMNAME}/lib/perl/xCAT/
|
||||
fi
|
||||
}
|
||||
|
||||
# Make the noarch rpms
|
||||
function makenoarch {
|
||||
RPMNAME=$1
|
||||
if [ "$OSNAME" = "AIX" ]; then
|
||||
echo '.svn' > /tmp/xcat-excludes
|
||||
tar -X /tmp/xcat-excludes -cf $RPMROOT/SOURCES/$RPMNAME-$VER.tar $RPMNAME
|
||||
gzip -f $RPMROOT/SOURCES/$RPMNAME-$VER.tar
|
||||
rm -f $RPMROOT/SRPMS/$RPMNAME-$VER*rpm $RPMROOT/RPMS/ppc/$RPMNAME-$VER*rpm
|
||||
echo "Building $RPMROOT/RPMS/ppc/$RPMNAME-$VER-snap*.ppc.rpm $EMBEDTXT..."
|
||||
rpm $QUIET -ba $RPMNAME/$RPMNAME.spec
|
||||
RC=$?
|
||||
else # linux
|
||||
xcat_announce_build "$RPMNAME-$VER" "$RPMROOT/RPMS/noarch/$RPMNAME-$VER-snap*.noarch.rpm"
|
||||
# TODO: should fix this up, this is a hack for the new build machine
|
||||
if [ $RPMNAME = "xCAT-UI" ]; then
|
||||
# Only if the old compiler.jar file does not exist.....
|
||||
if [ ! -e /xcat2/build/tools/compiler.jar ]; then
|
||||
# look for the dynamic location of the compiler.jar file
|
||||
DIRNAME=`dirname $(readlink -f $0)`
|
||||
COMPILER_JAR=`echo "${DIRNAME%%linux_rpm/*}tools/compiler.jar"`
|
||||
if [ -f $COMPILER_JAR ]; then
|
||||
sed -i "s#/xcat2/build/tools/compiler.jar#${COMPILER_JAR}#g" xCAT-UI/xCAT-UI.spec
|
||||
else
|
||||
# In c910, if using the old buildxcat scripts...
|
||||
COMPILER_JAR=`echo "${DIRNAME%%old/*}xcat2/tools/compiler.jar"`
|
||||
if [ -f $COMPILER_JAR ]; then
|
||||
sed -i "s#/xcat2/build/tools/compiler.jar#${COMPILER_JAR}#g" xCAT-UI/xCAT-UI.spec
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
xcat_probe_copy ${RPMNAME}
|
||||
|
||||
tar --exclude .svn -czf $RPMROOT/SOURCES/$RPMNAME-$VER.tar.gz $RPMNAME
|
||||
rm -f $RPMROOT/SRPMS/$RPMNAME-$VER*rpm $RPMROOT/RPMS/noarch/$RPMNAME-$VER*rpm
|
||||
xcat_rpmbuild_tar $RPMROOT/SOURCES/$RPMNAME-$VER.tar.gz --define "version $VER" $REL "$EASE"
|
||||
RC=$?
|
||||
|
||||
if [ $RPMNAME = "xCAT-UI" ]; then
|
||||
# undo the modifications above to leave the sandbox prestine on the build machine
|
||||
git checkout xCAT-UI/xCAT-UI.spec
|
||||
fi
|
||||
|
||||
xcat_probe_cleanup ${RPMNAME}
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Make one of the following rpms: xCAT, xCATsn, xCAT-buildkit, xCAT-OpenStack
|
||||
function makexcat {
|
||||
if [ "$OSNAME" != "AIX" -a "$1" != "xCAT-buildkit" -a -z "$2" ]; then
|
||||
echo 'Usage: makerpm <RPMname> <arch> [<embedded-system>]'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RPMNAME="$1"
|
||||
|
||||
if [ "$OSNAME" = "AIX" ]; then
|
||||
source=/opt/freeware/src/packages
|
||||
cd `dirname $0`/$RPMNAME
|
||||
echo '.svn' > /tmp/xcat-excludes
|
||||
echo 'upflag' >> /tmp/xcat-excludes
|
||||
|
||||
if [ "$RPMNAME" = "xCAT" ]; then
|
||||
tar -X /tmp/xcat-excludes -cf $RPMROOT/SOURCES/postscripts.tar postscripts LICENSE.html
|
||||
gzip -f $RPMROOT/SOURCES/postscripts.tar
|
||||
tar -X /tmp/xcat-excludes -cf $RPMROOT/SOURCES/templates.tar templates
|
||||
gzip -f $RPMROOT/SOURCES/templates.tar
|
||||
cp xcat.conf $RPMROOT/SOURCES
|
||||
cp xcat.conf.apach24 $RPMROOT/SOURCES
|
||||
cp xCATMN $RPMROOT/SOURCES
|
||||
else # xCATsn
|
||||
tar -X /tmp/xcat-excludes -cf $RPMROOT/SOURCES/license.tar LICENSE.html
|
||||
gzip -f $RPMROOT/SOURCES/license.tar
|
||||
cp xCATSN $RPMROOT/SOURCES
|
||||
fi
|
||||
|
||||
rm -f $RPMROOT/SRPMS/$RPMNAME-$VER*rpm $RPMROOT/RPMS/ppc/$RPMNAME-$VER*rpm
|
||||
cd - >/dev/null
|
||||
|
||||
echo "Building $RPMROOT/RPMS/ppc/$RPMNAME-$VER-snap*.ppc.rpm $EMBEDTXT..."
|
||||
rpm $QUIET -ba $RPMNAME/$RPMNAME.spec
|
||||
RC=$?
|
||||
else # linux
|
||||
ARCH="$2"
|
||||
TARGET="--target $ARCH"
|
||||
|
||||
if [ "$RPMNAME" = "xCAT" ]; then
|
||||
cd `dirname $0`/
|
||||
# shipping bmcsetup and getipmi scripts as part of postscripts
|
||||
files=("bmcsetup" "getipmi")
|
||||
for f in "${files[@]}"; do
|
||||
cp "xCAT-genesis-scripts/usr/bin/"$f ${RPMNAME}/postscripts/$f
|
||||
sed -i "s/xcat.genesis.$f/$f/g" ${RPMNAME}/postscripts/$f
|
||||
done
|
||||
cd `dirname $0`/$RPMNAME
|
||||
tar --exclude .svn --exclude upflag -czf $RPMROOT/SOURCES/postscripts.tar.gz postscripts LICENSE.html
|
||||
tar --exclude .svn -czf $RPMROOT/SOURCES/prescripts.tar.gz prescripts
|
||||
tar --exclude .svn -czf $RPMROOT/SOURCES/templates.tar.gz templates
|
||||
tar --exclude .svn -czf $RPMROOT/SOURCES/winpostscripts.tar.gz winpostscripts
|
||||
tar --exclude .svn -czf $RPMROOT/SOURCES/etc.tar.gz etc
|
||||
cp xcat.conf $RPMROOT/SOURCES
|
||||
cp xcat.conf.apach24 $RPMROOT/SOURCES
|
||||
cp xCATMN $RPMROOT/SOURCES
|
||||
cd - >/dev/null
|
||||
elif [ "$RPMNAME" = "xCATsn" ]; then
|
||||
cd `dirname $0`/$RPMNAME
|
||||
tar --exclude .svn -czf $RPMROOT/SOURCES/license.tar.gz LICENSE.html
|
||||
../build-utils/sync-xcat-apache-configs --stage "$RPMROOT/SOURCES" || {
|
||||
RC=$?
|
||||
cd - >/dev/null
|
||||
return $RC
|
||||
}
|
||||
cp xCATSN $RPMROOT/SOURCES
|
||||
cp -a ../xCAT/etc/rsyslog.d $RPMROOT/
|
||||
cp -a ../xCAT/etc/logrotate.d $RPMROOT/
|
||||
cd - >/dev/null
|
||||
elif [ "$RPMNAME" = "xCAT-buildkit" ]; then
|
||||
ARCH="noarch"
|
||||
TARGET=""
|
||||
tar --exclude .svn --exclude xCAT-buildkit.spec -czf $RPMROOT/SOURCES/$RPMNAME-$VER.tar.gz $RPMNAME
|
||||
elif [ "$RPMNAME" = "xCAT-OpenStack" ]; then
|
||||
tar --exclude .svn --exclude xCAT-OpenStack.spec -czf $RPMROOT/SOURCES/$RPMNAME-$VER.tar.gz $RPMNAME
|
||||
else # do not recognize rpm
|
||||
echo "Unrecognized rpm: $RPMNAME"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
rm -f $RPMROOT/SRPMS/$RPMNAME-$VER*rpm $RPMROOT/RPMS/$ARCH/$RPMNAME-$VER*rpm
|
||||
xcat_announce_build "$RPMNAME-$VER" "$RPMROOT/RPMS/$ARCH/$RPMNAME-$VER-snap*.$ARCH.rpm"
|
||||
xcat_rpmbuild_spec $RPMNAME/$RPMNAME.spec $TARGET --define "version $VER" $REL "$EASE"
|
||||
RC=$?
|
||||
if [ "$RPMNAME" = "xCAT" ]; then
|
||||
files=("bmcsetup" "getipmi")
|
||||
for f in "${files[@]}"; do
|
||||
rm -f `dirname $0`/${RPMNAME}/postscripts/$f
|
||||
done
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# make ironic rpm for ironic baremetal driver
|
||||
function makeironic {
|
||||
RPMNAME="$1"
|
||||
ARCH="$2"
|
||||
cd `dirname $0`/$RPMNAME
|
||||
cp -rf ironic_baremetal /tmp/
|
||||
cd /tmp/ironic_baremetal
|
||||
git init
|
||||
git add *
|
||||
git commit -a -m "generate rpm"
|
||||
python setup.py bdist_rpm
|
||||
rm -rf $RPMROOT/RPMS/$ARCH/
|
||||
mkdir -p $RPMROOT/RPMS/$ARCH/
|
||||
cp -rf dist/*.rpm $RPMROOT/RPMS/$ARCH/
|
||||
rm -rf /tmp/ironic_baremetal
|
||||
}
|
||||
|
||||
# Make the xCAT-genesis rpm
|
||||
function makegenesis {
|
||||
DIR="xCAT-genesis-builder"
|
||||
SPEC_FILE="xCAT-genesis-base.spec"
|
||||
RPMNAME="$1"
|
||||
cd `dirname $0`/$DIR
|
||||
sed -i s/%%REPLACE_CURRENT_VERSION%%/${VER}/g ${SPEC_FILE}
|
||||
tar --exclude .svn -cjf $RPMROOT/SOURCES/$RPMNAME.tar.bz2 .
|
||||
# undo the changes from the SED command above so it's not tracked by Git
|
||||
git checkout ${SPEC_FILE}
|
||||
cp LICENSE.html $RPMROOT/BUILD
|
||||
cp $RPMNAME.spec $RPMROOT/SOURCES
|
||||
cd - >/dev/null
|
||||
rm -f $RPMROOT/SRPMS/$RPMNAME-$VER*rpm $RPMROOT/RPMS/noarch/$RPMNAME-$VER*rpm
|
||||
xcat_announce_build "$RPMNAME-$VER" "$RPMROOT/RPMS/noarch/$RPMNAME-$VER-snap*.noarch.rpm"
|
||||
xcat_rpmbuild_spec $DIR/$RPMNAME.spec --define "version $VER" $REL "$EASE"
|
||||
}
|
||||
|
||||
function makegenesisscripts {
|
||||
DIR="xCAT-genesis-scripts"
|
||||
if [ -z "$2" ]; then
|
||||
echo 'Usage: makerpm xCAT-genesis-scripts <arch> [<embedded-system>]'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RPMNAME="$1"
|
||||
ARCH="$2"
|
||||
TARGET="--target $ARCH"
|
||||
cd `dirname $0`/
|
||||
tar --exclude .svn -cjf $RPMROOT/SOURCES/$RPMNAME.tar.bz2 $DIR
|
||||
cp $DIR/LICENSE.html $RPMROOT/BUILD
|
||||
cp $DIR/$RPMNAME.spec $RPMROOT/SOURCES
|
||||
cd - >/dev/null
|
||||
rm -f $RPMROOT/SRPMS/$RPMNAME-$ARCH-$VER*rpm $RPMROOT/RPMS/noarch/$RPMNAME-$ARCH-$VER*rpm
|
||||
xcat_announce_build "$RPMNAME-$ARCH-$VER" "$RPMROOT/RPMS/noarch/$RPMNAME-$ARCH-$VER-snap*.noarch.rpm"
|
||||
xcat_rpmbuild_spec $DIR/$RPMNAME.spec $TARGET --define "version $VER" $REL "$EASE"
|
||||
}
|
||||
|
||||
|
||||
# Export the name of the embedded system we are building for
|
||||
function exportEmbed {
|
||||
if [ -n "$1" ]; then
|
||||
export "$1=1"
|
||||
EMBEDTXT="for $1 "
|
||||
else
|
||||
EMBEDTXT=""
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Main code....
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo 'Usage: makerpm <RPMname> [<arch>] [<embedded-system>]'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OSNAME=$(uname)
|
||||
if [ -z "$XCATVER" ] ; then
|
||||
VER=`cat Version`
|
||||
REL="--define"
|
||||
EASE='usedate 1'
|
||||
else
|
||||
VER=$XCATVER
|
||||
REL="--define"
|
||||
EASE='release 1'
|
||||
fi
|
||||
if [ "$VERBOSE" = "1" -o "$VERBOSE" = "yes" ];then
|
||||
QUIET=""
|
||||
else
|
||||
QUIET="--quiet"
|
||||
fi
|
||||
if ! xcat_configure_rpm_build_mode "$OSNAME"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$OSNAME" = "AIX" ]; then
|
||||
RPMROOT=/opt/freeware/src/packages
|
||||
else # linux
|
||||
rpmbuild --version > /dev/null
|
||||
if [ $? -gt 0 ]; then
|
||||
echo "Error: rpmbuild does not appear to be installed or working."
|
||||
exit 2
|
||||
fi
|
||||
RPMROOT=`rpmbuild --eval '%_topdir' xCATsn/xCATsn.spec`
|
||||
if [ $? -gt 0 ]; then
|
||||
echo "Error: Could not determine rpmbuild's root directory."
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$1" = "xCAT" -o "$1" = "xCATsn" -o "$1" = "xCAT-buildkit" -o "$1" = "xCAT-OpenStack" ]; then
|
||||
exportEmbed $3
|
||||
makexcat $1 $2
|
||||
elif [ "$1" = "xCAT-genesis-builder" ]; then
|
||||
exportEmbed $2
|
||||
makegenesis $1
|
||||
elif [ "$1" = "xCAT-genesis-scripts" ]; then
|
||||
exportEmbed $3
|
||||
makegenesisscripts $1 $2
|
||||
elif [ "$1" = "xCAT-OpenStack-ironic" ]; then
|
||||
if ! xcat_require_binary_build "$1"; then
|
||||
exit 1
|
||||
fi
|
||||
makeironic $1 $2
|
||||
else # must be one of the noarch rpms
|
||||
exportEmbed $2
|
||||
makenoarch $1
|
||||
fi
|
||||
|
||||
exit $RC
|
||||
@@ -190,83 +190,9 @@ is( $status, 1, '--stage rejects a missing destination directory' );
|
||||
like( $output, qr{ is not a directory$}m,
|
||||
'--stage identifies the invalid destination directory' );
|
||||
|
||||
my $rpm_fixture = tempdir( CLEANUP => 1 );
|
||||
my $rpm_root = stage_makerpm_fixture($rpm_fixture);
|
||||
my $fake_bin = File::Spec->catdir( $rpm_fixture, 'fake-bin' );
|
||||
make_path($fake_bin);
|
||||
write_executable(
|
||||
File::Spec->catfile( $fake_bin, 'uname' ),
|
||||
"#!/bin/sh\nprintf '%s\\n' Linux\n"
|
||||
);
|
||||
write_executable(
|
||||
File::Spec->catfile( $fake_bin, 'rpmbuild' ),
|
||||
<<'EOF'
|
||||
#!/bin/sh
|
||||
case ${1:-} in
|
||||
--version)
|
||||
exit 0
|
||||
;;
|
||||
--eval)
|
||||
printf '%s\n' "$FAKE_RPMROOT"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
printf 'build\n' >>"$FAKE_RPMBUILD_LOG"
|
||||
exit 0
|
||||
EOF
|
||||
);
|
||||
|
||||
my $rpm_build_log = File::Spec->catfile( $rpm_fixture, 'rpmbuild.log' );
|
||||
write_text( $rpm_build_log, '' );
|
||||
my %rpm_environment = (
|
||||
FAKE_RPMBUILD_LOG => $rpm_build_log,
|
||||
FAKE_RPMROOT => $rpm_root,
|
||||
PATH => "$fake_bin:$ENV{PATH}",
|
||||
);
|
||||
( $status, $output ) = run_command(
|
||||
\%rpm_environment,
|
||||
File::Spec->catfile( $rpm_fixture, 'makerpm' ),
|
||||
'xCATsn', 'x86_64'
|
||||
);
|
||||
is( $status, 0, 'the legacy RPM builder stages service-node sources' )
|
||||
or diag($output);
|
||||
is( read_text($rpm_build_log), "build\n",
|
||||
'the legacy RPM builder reaches rpmbuild after successful staging' );
|
||||
for my $name ( 'xcat.conf', 'xcat.conf.apach24' ) {
|
||||
is(
|
||||
read_text( File::Spec->catfile( $rpm_root, 'SOURCES', $name ) ),
|
||||
read_text( File::Spec->catfile( $rpm_fixture, 'xCAT', $name ) ),
|
||||
"the legacy RPM builder stages canonical $name content"
|
||||
);
|
||||
}
|
||||
|
||||
write_text( $rpm_build_log, '' );
|
||||
my $rpm_canonical = File::Spec->catfile( $rpm_fixture, 'xCAT', 'xcat.conf' );
|
||||
my $rpm_canonical_target =
|
||||
File::Spec->catfile( $rpm_fixture, 'invalid-canonical-target' );
|
||||
write_text( $rpm_canonical_target, read_text($rpm_canonical) );
|
||||
unlink($rpm_canonical) or die "Unable to remove $rpm_canonical: $!";
|
||||
symlink( $rpm_canonical_target, $rpm_canonical )
|
||||
or die "Unable to create $rpm_canonical symlink: $!";
|
||||
for my $name ( 'xcat.conf', 'xcat.conf.apach24' ) {
|
||||
write_text( File::Spec->catfile( $rpm_root, 'SOURCES', $name ),
|
||||
"stale $name\n" );
|
||||
}
|
||||
( $status, $output ) = run_command(
|
||||
\%rpm_environment,
|
||||
File::Spec->catfile( $rpm_fixture, 'makerpm' ),
|
||||
'xCATsn', 'x86_64'
|
||||
);
|
||||
is( $status, 1, 'the legacy RPM builder propagates staging failure' );
|
||||
like( $output, qr{^xCAT/xcat\.conf must be a regular file$}m,
|
||||
'the legacy RPM builder reports the rejected canonical source' );
|
||||
is( read_text($rpm_build_log), '',
|
||||
'the legacy RPM builder does not reach rpmbuild after staging failure' );
|
||||
for my $name ( 'xcat.conf', 'xcat.conf.apach24' ) {
|
||||
is( read_text( File::Spec->catfile( $rpm_root, 'SOURCES', $name ) ),
|
||||
"stale $name\n",
|
||||
"failed legacy staging does not disguise the stale $name source" );
|
||||
}
|
||||
# The legacy `makerpm` half of this file went with makerpm itself; buildrpms.pl
|
||||
# invokes build-utils/sync-xcat-apache-configs directly, and the helper's own
|
||||
# behaviour is covered above.
|
||||
|
||||
my $management_debian = slurp_repo_file('xCAT/debian/install');
|
||||
my $service_debian = slurp_repo_file('xCATsn/debian/install');
|
||||
@@ -299,57 +225,7 @@ sub stage_sync_fixture {
|
||||
return $destination;
|
||||
}
|
||||
|
||||
sub stage_makerpm_fixture {
|
||||
my ($root) = @_;
|
||||
copy( repo_path('makerpm'), File::Spec->catfile( $root, 'makerpm' ) )
|
||||
or die "Unable to stage makerpm: $!";
|
||||
chmod 0755, File::Spec->catfile( $root, 'makerpm' )
|
||||
or die "Unable to make staged makerpm executable: $!";
|
||||
write_text( File::Spec->catfile( $root, 'Version' ), "2.19.0\n" );
|
||||
|
||||
make_path(
|
||||
File::Spec->catdir( $root, 'build-utils' ),
|
||||
File::Spec->catdir( $root, 'xCAT' ),
|
||||
File::Spec->catdir( $root, 'xCAT', 'etc', 'rsyslog.d' ),
|
||||
File::Spec->catdir( $root, 'xCAT', 'etc', 'logrotate.d' ),
|
||||
File::Spec->catdir( $root, 'xCATsn' ),
|
||||
);
|
||||
copy( $sync_helper,
|
||||
File::Spec->catfile( $root, 'build-utils', 'sync-xcat-apache-configs' ) )
|
||||
or die "Unable to stage the Apache configuration helper: $!";
|
||||
chmod 0755,
|
||||
File::Spec->catfile( $root, 'build-utils', 'sync-xcat-apache-configs' )
|
||||
or die "Unable to make the Apache configuration helper executable: $!";
|
||||
copy( repo_path('build-utils/source-only.sh'),
|
||||
File::Spec->catfile( $root, 'build-utils', 'source-only.sh' ) )
|
||||
or die "Unable to stage the source-only build helper: $!";
|
||||
write_text( File::Spec->catfile( $root, 'xCAT', 'xcat.conf' ),
|
||||
"canonical apache22\n" );
|
||||
write_text( File::Spec->catfile( $root, 'xCAT', 'xcat.conf.apach24' ),
|
||||
"canonical apache24\n" );
|
||||
write_text( File::Spec->catfile( $root, 'xCATsn', 'xcat.conf' ),
|
||||
"stale service-node apache22\n" );
|
||||
write_text( File::Spec->catfile( $root, 'xCATsn', 'xcat.conf.apach24' ),
|
||||
"stale service-node apache24\n\n" );
|
||||
write_text( File::Spec->catfile( $root, 'xCATsn', 'LICENSE.html' ),
|
||||
"fixture license\n" );
|
||||
write_text( File::Spec->catfile( $root, 'xCATsn', 'xCATSN' ),
|
||||
"fixture service-node configuration\n" );
|
||||
|
||||
my $rpm_root = File::Spec->catdir( $root, 'rpmbuild' );
|
||||
make_path(
|
||||
File::Spec->catdir( $rpm_root, 'SOURCES' ),
|
||||
File::Spec->catdir( $rpm_root, 'SRPMS' ),
|
||||
File::Spec->catdir( $rpm_root, 'RPMS', 'x86_64' ),
|
||||
);
|
||||
return $rpm_root;
|
||||
}
|
||||
|
||||
sub write_executable {
|
||||
my ( $path, $contents ) = @_;
|
||||
write_text( $path, $contents );
|
||||
chmod 0755, $path or die "Unable to make $path executable: $!";
|
||||
}
|
||||
|
||||
sub run_command {
|
||||
my ( $environment, @command ) = @_;
|
||||
|
||||
@@ -1,332 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Path qw(make_path);
|
||||
use File::Slurper qw(read_text write_text);
|
||||
use File::Temp qw(tempdir);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
|
||||
use XCAT::Test::File qw(repo_path);
|
||||
|
||||
my $helper = repo_path('build-utils/source-only.sh');
|
||||
my $buildcore_helper = repo_path('build-utils/buildcore-source-only.sh');
|
||||
plan skip_all => 'source-only build helper not found' unless -r $helper;
|
||||
plan skip_all => 'buildcore source-only helper not found' unless -r $buildcore_helper;
|
||||
plan skip_all => 'bash not found' unless -x '/bin/bash';
|
||||
|
||||
sub _touch {
|
||||
write_text( $_[0], '' );
|
||||
}
|
||||
|
||||
sub run_helper {
|
||||
my ( $root, $name, $body ) = @_;
|
||||
my $script = "$root/$name.sh";
|
||||
write_text( $script,
|
||||
"#!/bin/bash\nset -e\n. \"$helper\"\n. \"$buildcore_helper\"\n$body\n" );
|
||||
my $output = `/bin/bash "$script" 2>&1`;
|
||||
return ( $output, $? >> 8 );
|
||||
}
|
||||
|
||||
sub deliver_noarch {
|
||||
my ($source_only) = @_;
|
||||
my $root = tempdir( CLEANUP => 1 );
|
||||
make_path( "$root/rpmbuild/RPMS/noarch", "$root/rpmbuild/SRPMS",
|
||||
"$root/dest", "$root/src" );
|
||||
_touch("$root/rpmbuild/RPMS/noarch/xCAT-server-2.19.0-snap1.noarch.rpm");
|
||||
_touch("$root/rpmbuild/SRPMS/xCAT-server-2.19.0-snap1.src.rpm");
|
||||
_touch("$root/dest/xCAT-server-2.19.0-snap0.noarch.rpm");
|
||||
_touch("$root/src/xCAT-server-2.19.0-snap0.src.rpm");
|
||||
|
||||
my ( $said, $status ) = run_helper( $root, 'deliver-noarch', <<"SH" );
|
||||
SRCONLY=$source_only
|
||||
source=$root/rpmbuild
|
||||
DESTDIR=$root/dest
|
||||
SRCDIR=$root/src
|
||||
NOARCH=noarch
|
||||
VER=2.19.0
|
||||
xcat_deliver_noarch_package xCAT-server
|
||||
SH
|
||||
return {
|
||||
said => $said,
|
||||
status => $status,
|
||||
delivered => [ sort map { s{.*/}{}r } glob("$root/dest/*") ],
|
||||
sources => [ sort map { s{.*/}{}r } glob("$root/src/*") ],
|
||||
left => [ sort map { s{.*/}{}r } glob("$root/rpmbuild/RPMS/noarch/*") ],
|
||||
};
|
||||
}
|
||||
|
||||
sub deliver_arch {
|
||||
my ($source_only) = @_;
|
||||
my $root = tempdir( CLEANUP => 1 );
|
||||
make_path( "$root/rpmbuild/RPMS/riscv64", "$root/rpmbuild/SRPMS",
|
||||
"$root/dest", "$root/src" );
|
||||
_touch("$root/rpmbuild/RPMS/riscv64/xCAT-2.19.0-snap1.riscv64.rpm");
|
||||
_touch("$root/rpmbuild/SRPMS/xCAT-2.19.0-snap1.src.rpm");
|
||||
_touch("$root/dest/xCAT-2-snap0.riscv64.rpm");
|
||||
_touch("$root/src/xCAT-2-snap0.src.rpm");
|
||||
|
||||
my ( $said, $status ) = run_helper( $root, 'deliver-arch', <<"SH" );
|
||||
SRCONLY=$source_only
|
||||
source=$root/rpmbuild
|
||||
DESTDIR=$root/dest
|
||||
SRCDIR=$root/src
|
||||
VER=2.19.0
|
||||
SHORTSHORTVER=2
|
||||
xcat_deliver_arch_package xCAT
|
||||
SH
|
||||
return {
|
||||
said => $said,
|
||||
status => $status,
|
||||
delivered => [ sort map { s{.*/}{}r } glob("$root/dest/*") ],
|
||||
sources => [ sort map { s{.*/}{}r } glob("$root/src/*") ],
|
||||
left => [ sort map { s{.*/}{}r } glob("$root/rpmbuild/RPMS/riscv64/*") ],
|
||||
};
|
||||
}
|
||||
|
||||
sub deliver_genesis {
|
||||
my ($source_only) = @_;
|
||||
my $root = tempdir( CLEANUP => 1 );
|
||||
make_path( "$root/rpmbuild/RPMS/noarch", "$root/rpmbuild/SRPMS",
|
||||
"$root/dest", "$root/src" );
|
||||
for my $arch (qw(x86_64 ppc64)) {
|
||||
_touch("$root/rpmbuild/RPMS/noarch/xCAT-genesis-scripts-$arch-2.19.0-snap1.noarch.rpm");
|
||||
_touch("$root/rpmbuild/SRPMS/xCAT-genesis-scripts-$arch-2.19.0-snap1.src.rpm");
|
||||
_touch("$root/src/xCAT-genesis-scripts-$arch-2.19.0-snap0.src.rpm");
|
||||
}
|
||||
|
||||
my ( $said, $status ) = run_helper( $root, 'deliver-genesis', <<"SH" );
|
||||
SRCONLY=$source_only
|
||||
source=$root/rpmbuild
|
||||
DESTDIR=$root/dest
|
||||
SRCDIR=$root/src
|
||||
xcat_deliver_genesis_packages
|
||||
SH
|
||||
return {
|
||||
said => $said,
|
||||
status => $status,
|
||||
delivered => [ sort map { s{.*/}{}r } glob("$root/dest/*") ],
|
||||
sources => [ sort map { s{.*/}{}r } glob("$root/src/*") ],
|
||||
};
|
||||
}
|
||||
|
||||
sub deliver_tarball {
|
||||
my ($source_only) = @_;
|
||||
my $root = tempdir( CLEANUP => 1 );
|
||||
make_path( "$root/build/xcat-core", "$root/dest" );
|
||||
_touch("$root/build/xcat-core/build-input");
|
||||
|
||||
my ( $said, $status ) = run_helper( $root, 'deliver-tarball', <<"SH" );
|
||||
cd "$root/build"
|
||||
SRCONLY=$source_only
|
||||
TARNAME=xCAT-core-test.tar.bz2
|
||||
XCATCORE=xcat-core
|
||||
DESTDIR="$root/dest"
|
||||
DEST=1
|
||||
OSNAME=Linux
|
||||
SYSGRP=\$(id -gn)
|
||||
verboseflag=
|
||||
xcat_create_binary_tarball
|
||||
xcat_publish_tarball_link
|
||||
SH
|
||||
return {
|
||||
said => $said,
|
||||
status => $status,
|
||||
tarball => -f "$root/build/xCAT-core-test.tar.bz2" ? 1 : 0,
|
||||
link => -l "$root/xCAT-core-test.tar.bz2" ? 1 : 0,
|
||||
link_target => -l "$root/xCAT-core-test.tar.bz2"
|
||||
? readlink("$root/xCAT-core-test.tar.bz2") : undef,
|
||||
};
|
||||
}
|
||||
|
||||
sub deliver_embed_link {
|
||||
my ($source_only) = @_;
|
||||
my $root = tempdir( CLEANUP => 1 );
|
||||
make_path( "$root/core", "$root/stage/embed" );
|
||||
_touch("$root/core/xCAT-server-2.19.0-snap1.noarch.rpm");
|
||||
|
||||
my ( $said, $status ) = run_helper( $root, 'deliver-embed', <<"SH" );
|
||||
cd "$root"
|
||||
SRCONLY=$source_only
|
||||
EMBED=linux
|
||||
EMBEDLINK=xCAT-server
|
||||
DESTDIR="$root/stage/embed"
|
||||
XCATCORE=core
|
||||
SHORTSHORTVER=2.19.0
|
||||
xcat_deliver_embed_links
|
||||
SH
|
||||
my $link = "$root/stage/embed/xCAT-server-2.19.0-snap1.noarch.rpm";
|
||||
return {
|
||||
said => $said,
|
||||
status => $status,
|
||||
link => -l $link ? 1 : 0,
|
||||
link_target => -l $link ? readlink($link) : undef,
|
||||
};
|
||||
}
|
||||
|
||||
my $normal = deliver_noarch('');
|
||||
is( $normal->{status}, 0, 'normal noarch delivery exits cleanly' );
|
||||
is_deeply( $normal->{delivered}, ['xCAT-server-2.19.0-snap1.noarch.rpm'],
|
||||
'a normal build replaces the delivered binary package' );
|
||||
is_deeply( $normal->{sources}, ['xCAT-server-2.19.0-snap1.src.rpm'],
|
||||
'a normal build replaces the delivered source package' );
|
||||
is_deeply( $normal->{left}, [],
|
||||
'a normal build moves the binary package out of the build tree' );
|
||||
|
||||
my $source_only = deliver_noarch('1');
|
||||
is( $source_only->{status}, 0, 'source-only noarch delivery exits cleanly' );
|
||||
is_deeply( $source_only->{delivered}, ['xCAT-server-2.19.0-snap0.noarch.rpm'],
|
||||
'a source-only build keeps the earlier binary package' );
|
||||
is_deeply( $source_only->{sources}, ['xCAT-server-2.19.0-snap1.src.rpm'],
|
||||
'a source-only build delivers the new source package' );
|
||||
is_deeply( $source_only->{left}, ['xCAT-server-2.19.0-snap1.noarch.rpm'],
|
||||
'a source-only build leaves the binary artifact in the build tree' );
|
||||
|
||||
my $normal_arch = deliver_arch('0');
|
||||
is( $normal_arch->{status}, 0, 'normal architecture delivery exits cleanly' );
|
||||
is_deeply( $normal_arch->{delivered}, ['xCAT-2.19.0-snap1.riscv64.rpm'],
|
||||
'a normal architecture build replaces the delivered binary package' );
|
||||
is_deeply( $normal_arch->{sources}, ['xCAT-2.19.0-snap1.src.rpm'],
|
||||
'a normal architecture build replaces the delivered source package' );
|
||||
|
||||
my $source_arch = deliver_arch('yes');
|
||||
is( $source_arch->{status}, 0, 'source-only architecture delivery exits cleanly' );
|
||||
is_deeply( $source_arch->{delivered}, ['xCAT-2-snap0.riscv64.rpm'],
|
||||
'a source-only architecture build keeps the earlier binary package' );
|
||||
is_deeply( $source_arch->{sources}, ['xCAT-2.19.0-snap1.src.rpm'],
|
||||
'a source-only architecture build delivers the new source package' );
|
||||
|
||||
my $source_genesis = deliver_genesis('1');
|
||||
is( $source_genesis->{status}, 0,
|
||||
'source-only Genesis delivery exits cleanly' );
|
||||
is_deeply( $source_genesis->{delivered}, [],
|
||||
'source-only Genesis delivery publishes no binary packages' );
|
||||
is_deeply(
|
||||
$source_genesis->{sources},
|
||||
[
|
||||
'xCAT-genesis-scripts-ppc64-2.19.0-snap1.src.rpm',
|
||||
'xCAT-genesis-scripts-x86_64-2.19.0-snap1.src.rpm',
|
||||
],
|
||||
'source-only delivery preserves both architecture-specific Genesis SRPMs',
|
||||
);
|
||||
|
||||
my $normal_tarball = deliver_tarball('0');
|
||||
is( $normal_tarball->{status}, 0, 'normal tarball delivery exits cleanly' );
|
||||
ok( $normal_tarball->{tarball}, 'a normal build creates the binary tarball' );
|
||||
ok( $normal_tarball->{link}, 'a normal build publishes the tarball link' );
|
||||
is( $normal_tarball->{link_target}, 'build/xCAT-core-test.tar.bz2',
|
||||
'the tarball link points to the generated archive' );
|
||||
|
||||
my $source_tarball = deliver_tarball('1');
|
||||
is( $source_tarball->{status}, 0, 'source-only tarball delivery exits cleanly' );
|
||||
ok( !$source_tarball->{tarball}, 'a source-only build creates no binary tarball' );
|
||||
ok( !$source_tarball->{link}, 'a source-only build creates no dangling tarball link' );
|
||||
like( $source_tarball->{said}, qr/Not creating xCAT-core-test\.tar\.bz2/,
|
||||
'source-only tarball delivery explains the omission' );
|
||||
|
||||
my $normal_embed = deliver_embed_link('');
|
||||
is( $normal_embed->{status}, 0, 'normal embedded-link delivery exits cleanly' );
|
||||
ok( $normal_embed->{link}, 'a normal build publishes the embedded-package link' );
|
||||
is( $normal_embed->{link_target}, '../../core/xCAT-server-2.19.0-snap1.noarch.rpm',
|
||||
'the embedded-package link points to the built binary package' );
|
||||
|
||||
my $source_embed = deliver_embed_link('1');
|
||||
is( $source_embed->{status}, 0, 'source-only embedded-link delivery exits cleanly' );
|
||||
ok( !$source_embed->{link}, 'a source-only build creates no embedded-package link' );
|
||||
|
||||
my ( $binary_arches, $binary_arches_status ) = run_helper(
|
||||
tempdir( CLEANUP => 1 ),
|
||||
'binary-arches',
|
||||
"SRCONLY=0\nxcat_rpm_build_arches x86_64 ppc64 ppc64le s390x aarch64\n",
|
||||
);
|
||||
is( $binary_arches_status, 0, 'normal architecture selection exits cleanly' );
|
||||
is(
|
||||
$binary_arches,
|
||||
"x86_64\nppc64\nppc64le\ns390x\naarch64\n",
|
||||
'a binary build keeps every target architecture',
|
||||
);
|
||||
|
||||
my ( $source_xcat_arches, $source_xcat_arches_status ) = run_helper(
|
||||
tempdir( CLEANUP => 1 ),
|
||||
'source-arches',
|
||||
"SRCONLY=true\nxcat_rpm_build_arches x86_64 ppc64 ppc64le s390x aarch64\n",
|
||||
);
|
||||
is( $source_xcat_arches_status, 0,
|
||||
'source architecture selection exits cleanly' );
|
||||
is( $source_xcat_arches, "x86_64\n",
|
||||
'a source-only xCAT or xCATsn build creates its target-independent SRPM once' );
|
||||
|
||||
sub finalized_repositories {
|
||||
my ($source_only) = @_;
|
||||
my $root = tempdir( CLEANUP => 1 );
|
||||
make_path( "$root/binary", "$root/source" );
|
||||
my ( $output, $status ) = run_helper( $root, 'repositories', <<"SH" );
|
||||
function createrepo {
|
||||
printf 'indexed %s\n' "\$1"
|
||||
}
|
||||
SRCONLY=$source_only
|
||||
RPMSIGN=0
|
||||
xcat_finalize_repository binary "$root/binary"
|
||||
xcat_finalize_repository source "$root/source"
|
||||
SH
|
||||
return ( $output, $status, $root );
|
||||
}
|
||||
|
||||
my ( $binary_repositories, $binary_repositories_status, $binary_root ) =
|
||||
finalized_repositories('0');
|
||||
is( $binary_repositories_status, 0, 'normal repository finalization exits cleanly' );
|
||||
is(
|
||||
$binary_repositories,
|
||||
"indexed $binary_root/binary\nindexed $binary_root/source\n",
|
||||
'a normal build refreshes both binary and source repositories',
|
||||
);
|
||||
|
||||
my ( $source_repositories, $source_repositories_status, $source_root ) =
|
||||
finalized_repositories('1');
|
||||
is( $source_repositories_status, 0, 'source repository finalization exits cleanly' );
|
||||
is(
|
||||
$source_repositories,
|
||||
"indexed $source_root/source\n",
|
||||
'a source-only build refreshes only the source repository',
|
||||
);
|
||||
|
||||
sub write_buildinfo {
|
||||
my ($source_only) = @_;
|
||||
my $root = tempdir( CLEANUP => 1 );
|
||||
my $buildinfo = "$root/buildinfo";
|
||||
write_text( $buildinfo, "previous binary build\n" );
|
||||
my ( $output, $status ) = run_helper( $root, 'buildinfo', <<"SH" );
|
||||
SRCONLY=$source_only
|
||||
VER=2.19.0
|
||||
XCAT_RELEASE=snap1
|
||||
BUILD_TIME=2026-08-26T12:00:00Z
|
||||
BUILD_MACHINE=builder.example.test
|
||||
COMMIT_ID=abc123
|
||||
COMMIT_ID_LONG=abc123def456
|
||||
xcat_write_binary_buildinfo "$buildinfo"
|
||||
SH
|
||||
return ( $output, $status, read_text($buildinfo) );
|
||||
}
|
||||
|
||||
my ( $binary_buildinfo_output, $binary_buildinfo_status, $binary_buildinfo ) =
|
||||
write_buildinfo('0');
|
||||
is( $binary_buildinfo_status, 0, 'normal buildinfo generation exits cleanly' );
|
||||
is( $binary_buildinfo_output, '', 'normal buildinfo generation is quiet' );
|
||||
is(
|
||||
$binary_buildinfo,
|
||||
"VERSION=2.19.0\nRELEASE=snap1\nBUILD_TIME=2026-08-26T12:00:00Z\n"
|
||||
. "BUILD_MACHINE=builder.example.test\nCOMMIT_ID=abc123\nCOMMIT_ID_LONG=abc123def456\n",
|
||||
'a normal build describes the newly built binary bundle',
|
||||
);
|
||||
|
||||
my ( $source_buildinfo_output, $source_buildinfo_status, $source_buildinfo ) =
|
||||
write_buildinfo('yes');
|
||||
is( $source_buildinfo_status, 0, 'source-only buildinfo handling exits cleanly' );
|
||||
like( $source_buildinfo_output, qr/source-only build makes no binary bundle/,
|
||||
'source-only buildinfo handling explains the omission' );
|
||||
is( $source_buildinfo, "previous binary build\n",
|
||||
'a source-only build leaves the previous binary buildinfo untouched' );
|
||||
|
||||
done_testing();
|
||||
@@ -1,168 +0,0 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Cwd qw(getcwd);
|
||||
use File::Path qw(make_path);
|
||||
use File::Slurper qw(write_text);
|
||||
use File::Spec;
|
||||
use File::Temp qw(tempdir);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
|
||||
use XCAT::Test::File qw(repo_path);
|
||||
|
||||
my $helper = repo_path('build-utils/source-only.sh');
|
||||
my $makerpm = repo_path('makerpm');
|
||||
plan skip_all => 'source-only build helper not found' unless -r $helper;
|
||||
plan skip_all => 'bash not found' unless -x '/bin/bash';
|
||||
|
||||
my $dir = tempdir( CLEANUP => 1 );
|
||||
my $sequence = 0;
|
||||
|
||||
sub run_shell {
|
||||
my ($body) = @_;
|
||||
my $script = "$dir/run-" . ++$sequence . '.sh';
|
||||
write_text( $script, "#!/bin/bash\nset -e\n. \"$helper\"\n$body\n" );
|
||||
my $output = `/bin/bash "$script" 2>&1`;
|
||||
return ( $output, $? >> 8 );
|
||||
}
|
||||
|
||||
my @modes = (
|
||||
[ 'unset', 'unset SRCONLY', '-ba -ta' ],
|
||||
[ 'empty', 'SRCONLY=', '-ba -ta' ],
|
||||
[ 'SRCONLY=0', 'SRCONLY=0', '-ba -ta' ],
|
||||
[ 'SRCONLY=no', 'SRCONLY=no', '-ba -ta' ],
|
||||
[ 'SRCONLY=1', 'SRCONLY=1', '-bs -ts' ],
|
||||
[ 'SRCONLY=yes', 'SRCONLY=yes', '-bs -ts' ],
|
||||
[ 'SRCONLY=true', 'SRCONLY=true', '-bs -ts' ],
|
||||
);
|
||||
foreach my $case (@modes) {
|
||||
my ( $name, $assignment, $expected ) = @{$case};
|
||||
my ( $got, $rc ) = run_shell(<<"SH");
|
||||
$assignment
|
||||
xcat_configure_rpm_build_mode Linux
|
||||
echo "\$SPECBUILD \$TARBUILD"
|
||||
SH
|
||||
chomp $got;
|
||||
is( $got, $expected, "$name selects '$expected'" );
|
||||
is( $rc, 0, "$name exits cleanly" );
|
||||
}
|
||||
|
||||
my ( $aix, $aix_rc ) = run_shell(<<'SH');
|
||||
SRCONLY=1
|
||||
xcat_configure_rpm_build_mode AIX
|
||||
SH
|
||||
isnt( $aix_rc, 0, 'a source-only build on AIX stops with an error' );
|
||||
like( $aix, qr/not supported on AIX/, 'the error names AIX' );
|
||||
|
||||
my ( $aix_default, $aix_default_rc ) = run_shell(<<'SH');
|
||||
unset SRCONLY
|
||||
xcat_configure_rpm_build_mode AIX
|
||||
echo "$SPECBUILD $TARBUILD"
|
||||
SH
|
||||
is( $aix_default_rc, 0, 'a normal build on AIX is unchanged' );
|
||||
like( $aix_default, qr/^-ba -ta$/m, 'a normal AIX build keeps its flags' );
|
||||
|
||||
my ( $binary_message, undef ) = run_shell(<<'SH');
|
||||
SPECBUILD=-ba
|
||||
RPMROOT=/build
|
||||
EMBEDTXT=
|
||||
xcat_announce_build xCAT-server-2.19.0 /build/RPMS/noarch/xCAT-server-2.19.0-snap\*.noarch.rpm
|
||||
SH
|
||||
like( $binary_message, qr{/build/RPMS/noarch/xCAT-server-2\.19\.0-snap\*\.noarch\.rpm},
|
||||
'a normal build names the binary package' );
|
||||
unlike( $binary_message, qr/src\.rpm/, 'a normal build names no source package' );
|
||||
|
||||
my ( $source_message, undef ) = run_shell(<<'SH');
|
||||
SPECBUILD=-bs
|
||||
RPMROOT=/build
|
||||
EMBEDTXT=
|
||||
xcat_announce_build xCAT-server-2.19.0 /build/RPMS/noarch/xCAT-server-2.19.0-snap\*.noarch.rpm
|
||||
SH
|
||||
like( $source_message, qr{/build/SRPMS/xCAT-server-2\.19\.0-snap\*\.src\.rpm},
|
||||
'a source-only build names the source package' );
|
||||
unlike( $source_message, qr{RPMS/noarch}, 'a source-only build names no binary package' );
|
||||
|
||||
my ( $build_calls, $build_calls_rc ) = run_shell(<<'SH');
|
||||
function rpmbuild {
|
||||
printf 'rpmbuild'
|
||||
printf ' <%s>' "$@"
|
||||
printf '\n'
|
||||
}
|
||||
QUIET=--quiet
|
||||
SRCONLY=1
|
||||
xcat_configure_rpm_build_mode Linux
|
||||
xcat_rpmbuild_spec package.spec --target riscv64 --define 'version 2.19.0'
|
||||
xcat_rpmbuild_tar package.tar.gz --define 'version 2.19.0'
|
||||
SH
|
||||
is( $build_calls_rc, 0, 'source-only rpm wrappers exit cleanly' );
|
||||
like( $build_calls, qr/^rpmbuild <--quiet> <-bs> <package\.spec>/m,
|
||||
'spec builds receive the source-only mode' );
|
||||
like( $build_calls, qr/^rpmbuild <--quiet> <-ts> <package\.tar\.gz>/m,
|
||||
'tar builds receive the source-only mode' );
|
||||
unlike( $build_calls, qr/<-ba>|<-ta>/, 'source-only wrappers pass no binary mode' );
|
||||
|
||||
my ( $ironic, $ironic_rc ) = run_shell(<<'SH');
|
||||
SRCONLY=1
|
||||
xcat_require_binary_build xCAT-OpenStack-ironic
|
||||
SH
|
||||
isnt( $ironic_rc, 0, 'the ironic package refuses source-only mode' );
|
||||
like( $ironic, qr/not supported for xCAT-OpenStack-ironic/,
|
||||
'the ironic error names the package' );
|
||||
|
||||
my ( undef, $ironic_normal_rc ) = run_shell(<<'SH');
|
||||
SRCONLY=0
|
||||
xcat_require_binary_build xCAT-OpenStack-ironic
|
||||
SH
|
||||
is( $ironic_normal_rc, 0, 'the ironic package still accepts a normal build' );
|
||||
|
||||
my $makerpm_root = tempdir( CLEANUP => 1 );
|
||||
my $makerpm_bin = File::Spec->catdir( $makerpm_root, 'bin' );
|
||||
my $rpm_root = File::Spec->catdir( $makerpm_root, 'rpmbuild' );
|
||||
my $rpmbuild_log = File::Spec->catfile( $makerpm_root, 'rpmbuild.log' );
|
||||
make_path( $makerpm_bin, map { File::Spec->catdir( $rpm_root, $_ ) }
|
||||
qw(SOURCES SRPMS RPMS BUILD) );
|
||||
my $fake_rpmbuild = File::Spec->catfile( $makerpm_bin, 'rpmbuild' );
|
||||
write_text( $fake_rpmbuild, <<'SH' );
|
||||
#!/bin/sh
|
||||
case "$1" in
|
||||
--version) exit 0 ;;
|
||||
--eval) printf '%s\n' "$XCAT_TEST_RPMROOT"; exit 0 ;;
|
||||
esac
|
||||
printf '%s\n' "$*" >>"$XCAT_TEST_RPMBUILD_LOG"
|
||||
exit 0
|
||||
SH
|
||||
chmod 0755, $fake_rpmbuild
|
||||
or die "Unable to make $fake_rpmbuild executable: $!";
|
||||
|
||||
my $original_directory = getcwd();
|
||||
my $repository_root = File::Spec->catdir( $FindBin::Bin, '..', '..' );
|
||||
chdir($repository_root) or die "Unable to enter $repository_root: $!";
|
||||
my $makerpm_status;
|
||||
{
|
||||
local %ENV = (
|
||||
%ENV,
|
||||
PATH => "$makerpm_bin:$ENV{PATH}",
|
||||
SRCONLY => 1,
|
||||
XCATVER => '2.19.0',
|
||||
XCAT_TEST_RPMROOT => $rpm_root,
|
||||
XCAT_TEST_RPMBUILD_LOG => $rpmbuild_log,
|
||||
);
|
||||
$makerpm_status = system( $makerpm, 'perl-xCAT' ) >> 8;
|
||||
}
|
||||
chdir($original_directory)
|
||||
or die "Unable to return to $original_directory: $!";
|
||||
is( $makerpm_status, 0,
|
||||
'the real makerpm caller completes a source-only tar build' );
|
||||
open( my $rpmbuild_fh, '<', $rpmbuild_log )
|
||||
or die "Unable to read $rpmbuild_log: $!";
|
||||
my $rpmbuild_arguments = do { local $/; <$rpmbuild_fh> };
|
||||
close($rpmbuild_fh);
|
||||
like( $rpmbuild_arguments, qr/(?:^|\s)-ts(?:\s|$)/m,
|
||||
'the real makerpm caller passes the source-only tar mode to rpmbuild' );
|
||||
unlike( $rpmbuild_arguments, qr/(?:^|\s)-ta(?:\s|$)/m,
|
||||
'the real makerpm caller does not request a binary tar build' );
|
||||
|
||||
done_testing();
|
||||
Reference in New Issue
Block a user