root/build-tools/build_minimal_iso/build.sh
Scott Little d81920c349 Build script readiness for renaming cgcs-tis-repo to local-repo
I want the build to work with either local-repo or cgcs-tis-repo.
In many places we will be testing for the existance local-repo as
the prefered path, then fall back to cgcs-tis-repo as an
alternative.  If neither are present, either exit or continue but
assuming the new path is intended.

Story: 2006387
Task: 36910
Change-Id: I2e97dc8cd5d4a54158d4b1cefeecd2000ec11cf2
Signed-off-by: Scott Little <scott.little@windriver.com>
2020-09-24 12:03:00 -04:00

65 lines
1.7 KiB
Bash
Executable File

#!/bin/sh
CREATEREPO=$(which createrepo_c)
if [ $? -ne 0 ]; then
CREATEREPO="createrepo"
fi
# For backward compatibility. Old repo location or new?
CENTOS_REPO=${MY_REPO}/centos-repo
if [ ! -d ${CENTOS_REPO} ]; then
CENTOS_REPO=${MY_REPO}/cgcs-centos-repo
if [ ! -d ${CENTOS_REPO} ]; then
echo "ERROR: directory ${MY_REPO}/centos-repo not found."
exit 1
fi
fi
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
# If a file listed in list.txt is missing, this function attempts to find the
# RPM and copy it to the local directory. This should not be required normally
# and is only used when collecting the source RPMs initially.
function findSrc {
local lookingFor=$1
find ${CENTOS_REPO}/Source -name $lookingFor | xargs -I '{}' cp '{}' .
find ${LOCAL_REPO}/Source -name $lookingFor | xargs -I '{}' cp '{}' .
find $MY_WORKSPACE/std/rpmbuild/SRPMS -name $lookingFor | xargs -I '{}' cp '{}' .
}
rm -f success.txt
rm -f fail.txt
rm -f missing.txt
mkdir -p results
infile=list.txt
while read p; do
if [ ! -f "$p" ]; then
findSrc $p
if [ ! -f "$p" ]; then
echo "couldn't find" >> missing.txt
echo "couldn't find $p" >> missing.txt
continue
fi
echo "found $p"
fi
mock -r build.cfg $p --resultdir=results --no-clean
if [ $? -eq 0 ]; then
echo "$p" >> success.txt
cd results
$CREATEREPO .
cd ..
else
echo "$p" >> fail.txt
fi
done < $infile