root/build-tools/build-pkgs
Scott Little 77576b7207 Add support CentOS-8/dnf/mock-2.6 based builds
This update will retain support for CentOS-7/yum/mock-1.4 based builds.
The build environment will be queried to discover which environment
it is building in, and modify the commands we issue accordingly.

In CentOS 8, DNF replaces both YUM and REPOQUERY.
While DNF tries to be a transparent replacement of the old tools,
there are also subtle changes to the supported arguments.

I will provide independent mock.cfg.prototypes for centos7 vs centos8.
Changes in generate-centos-repo.sh under stx-tools will be required to
select the correct prototype.

Add support for mock 2.6. Mock 2.6 is python 3, and it processes the
'root' and 'rootdir' arguments slightly differently.

Also change the order of arguments to tar within default_build_srpm.
The latest tar only honors '--exclude' if it precedes other arguments.

Story: 2006729
Depends-On: https://review.opendev.org/762700
Signed-off-by: Scott Little <scott.little@windriver.com>
Change-Id: I826be2051e535e6a4c08ad17124f453b04210668
2020-12-08 14:13:28 -05:00

127 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright (c) 2018-2020 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# Build first src.rpms, then rpms, from source, or from a downloaded tarball
# or src.rpm plus our additional patches.
#
# This program is a wrapper around build-pkgs-parallel and build-pkgs-serial
#
BUILD_PKGS_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )"
# Set REPOQUERY and REPOQUERY_SUB_COMMAND for our build environment.
source "${BUILD_PKGS_DIR}/pkg-manager-utils.sh"
usage () {
echo ""
echo "Usage: "
echo " Create source and binary rpms:"
echo " build-pkgs [--serial] [args]"
}
SERIAL_FLAG=0
RC=0
for arg in "$@"; do
case "$1" in
--serial) SERIAL_FLAG=1 ;;
esac
done
which mock_tmpfs_umount >> /dev/null
if [ $? -ne 0 ]; then
SERIAL_FLAG=1
fi
export TMPDIR=$MY_WORKSPACE/tmp
mkdir -p $TMPDIR
# Old repo path or new?
LOCAL_REPO=${MY_REPO}/local-repo
if [ ! -d ${LOCAL_REPO} ]; then
LOCAL_REPO=${MY_REPO}/cgcs-tis-repo
if [ ! -d ${LOCAL_REPO} ]; then
# This one isn't fatal, LOCAL_REPO is not required
LOCAL_REPO=${MY_REPO}/local-repo
fi
fi
# Make sure we have a dependency cache
DEP_CACHE="${LOCAL_REPO}/dependancy-cache"
BUILD_TYPES=(" std rt installer containers")
DEP_RPM_TYPE=(" RPMS SRPMS ")
DEP_DELTAS="$DEP_CACHE/deltas-rpms-srpms"
make_cache_current_rpms () {
FILE=${1}
if [ -z "${FILE}" ]; then
echo "File not specified"
return;
fi
if [ -f ${FILE} ]; then
rm ${FILE}
fi
for build_type in $BUILD_TYPES; do
for rpm_type in $DEP_RPM_TYPE; do
if [ -d $MY_WORKSPACE/$build_type/rpmbuild/$rpm_type/repodata ]; then
current=$MY_WORKSPACE/$build_type/rpmbuild/$rpm_type/
${REPOQUERY} \
--repofrompath=$build_type-$rpm_type,$current \
--repoid=$build_type-$rpm_type --arch=noarch,src,x86_64 \
${REPOQUERY_SUB_COMMAND} \
--all \
--qf "%-10{repoid} %-40{name} %-10{version} %-10{release}" \
>> ${FILE}
\rm -rf $TMP_DIR/yum-$USER-*
fi
done;
done;
}
if [ ! -d $DEP_CACHE ]; then
echo "Dependency cache is missing. Creating it now."
$BUILD_PKGS_DIR/create_dependancy_cache.py > $MY_WORKSPACE/create_dependancy_cache.log
make_cache_current_rpms $DEP_DELTAS
echo "Dependency cache created."
else
DEP_TMP=$(mktemp)
make_cache_current_rpms $DEP_TMP
if diff $DEP_DELTAS $DEP_TMP > /dev/null; then
echo "No changes for stx projects"
rm $DEP_TMP
else
echo "Changes detected for stx projects"
echo "Recreating dependecy cache now."
mv $DEP_TMP $DEP_DELTAS
$BUILD_PKGS_DIR/create_dependancy_cache.py > $MY_WORKSPACE/create_dependancy_cache.log
echo "Dependency cache recreated."
fi
fi
if [ $SERIAL_FLAG -eq 1 ]; then
echo "build-pkgs-serial $@"
build-pkgs-serial "$@"
RC=$?
else
echo "build-pkgs-parallel $@"
build-pkgs-parallel "$@"
RC=$?
fi
exit $RC