527e098821
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
182 lines
4.0 KiB
Bash
Executable File
182 lines
4.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
USAGE=0
|
|
|
|
if [ x"$1" = x ] ; then
|
|
echo "ERROR: You must specify a prefix for patch and patch branch names"
|
|
USAGE=1
|
|
fi
|
|
PREFIX=$1
|
|
|
|
if [ x"$2" = x ] ; then
|
|
echo "ERROR: You must specify a sw_version"
|
|
USAGE=1
|
|
fi
|
|
SW_VERSION=$2
|
|
|
|
if [ x"$3" = x ] ; then
|
|
echo "ERROR: You must specify a job directory"
|
|
USAGE=1
|
|
fi
|
|
JOB=$3
|
|
|
|
PATCH_BRANCH=$PREFIX"_"$SW_VERSION"_PATCHING"
|
|
PATCH_ID0=$PREFIX"_"$SW_VERSION"_PATCH_0000"
|
|
PATCH_TAG0=v$PATCH_ID0
|
|
MY_LOCAL_DISK=/localdisk/designer/$USER/$JOB
|
|
MY_REPO=$MY_LOCAL_DISK/cgcs-root
|
|
MY_WORKSPACE=/localdisk/loadbuild/$USER/$JOB
|
|
|
|
if [[ "$JOB" = /* ]]
|
|
then
|
|
MY_LOCAL_DISK=$JOB
|
|
MY_REPO=$JOB/cgcs-root
|
|
MY_WORKSPACE=$JOB
|
|
fi
|
|
|
|
if [ x"$4" != x ] ; then
|
|
MY_WORKSPACE=$4
|
|
fi
|
|
|
|
if [ x"$5" != x ] ; then
|
|
MY_LOCAL_DISK=$(realpath $5/..)
|
|
fi
|
|
MY_REPO=$MY_LOCAL_DISK/cgcs-root
|
|
|
|
if [ $USAGE -ne 0 ] ; then
|
|
echo "USAGE: make_patching_workspace <prefix> <sw_version> <repo_dir> [<workspace> [<sscache> [<repo>]]]"
|
|
echo " e.g. make_patching_workspace TC 18.03 testpatch"
|
|
echo " e.g. make_patching_workspace TC 18.03 mypatch $MY_WORKSPACE $MY_REPO"
|
|
exit 1
|
|
fi
|
|
|
|
RPM_DB_DIR=$MY_WORKSPACE/export/patch_data
|
|
RPM_DB=$RPM_DB_DIR/$PATCH_ID0.rpm_db
|
|
|
|
echo "PREFIX=$PREFIX"
|
|
echo "SW_VERSION=$SW_VERSION"
|
|
echo "JOB=$JOB"
|
|
echo "MY_LOCAL_DISK=$MY_LOCAL_DISK"
|
|
echo "MY_REPO=$MY_REPO"
|
|
echo "MY_WORKSPACE=$MY_WORKSPACE"
|
|
echo "PATCH_BRANCH=$PATCH_BRANCH"
|
|
echo "PATCH_TAG0=$PATCH_TAG0"
|
|
echo "RPM_DB_DIR=$RPM_DB_DIR"
|
|
echo "RPM_DB=$RPM_DB"
|
|
|
|
|
|
cd $MY_LOCAL_DISK/bin
|
|
if [ $? -ne 0 ] ; then
|
|
echo "ERROR: failed to change to directory '$MY_LOCAL_DISK/bin'"
|
|
exit 1
|
|
fi
|
|
|
|
export PATH=`pwd`:$PATH
|
|
|
|
cd $MY_REPO
|
|
if [ $? -ne 0 ] ; then
|
|
echo "ERROR: failed to change to directory '$MY_REPO'"
|
|
exit 1
|
|
fi
|
|
|
|
# Make sure gits are free of changes that would prevent checkout or pull
|
|
for d in $(find . -type d -name .git | xargs --max-args=1 dirname)
|
|
do
|
|
(cd $d
|
|
echo $d
|
|
git clean -df
|
|
git reset --hard
|
|
git ls-files --others --exclude-standard | xargs --no-run-if-empty rm
|
|
if [ ! -f .subgits ]; then
|
|
if [ -f .gitignore ]; then
|
|
git ls-files --others --ignored --exclude-from=.gitignore | xargs --no-run-if-empty rm
|
|
fi
|
|
fi
|
|
)
|
|
done
|
|
|
|
wrgit checkout $PATCH_TAG0
|
|
if [ $? -ne 0 ] ; then
|
|
echo "ERROR: wrgit checkout '$PATCH_TAG0' failed"
|
|
exit 1
|
|
fi
|
|
|
|
# Create workspace
|
|
echo "01: mkdir $MY_WORKSPACE"
|
|
if [ ! -d $MY_WORKSPACE ] ; then
|
|
mkdir -p $MY_WORKSPACE
|
|
if [ $? -ne 0 ] ; then
|
|
echo "ERROR: failed to create directory '$MY_WORKSPACE'"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
echo "02: cd $MY_WORKSPACE"
|
|
cd $MY_WORKSPACE
|
|
if [ $? -ne 0 ] ; then
|
|
echo "ERROR: failed to change to directory '$MY_WORKSPACE'"
|
|
exit 1
|
|
fi
|
|
|
|
echo "03: build"
|
|
if [ ! -f export/bootimage.iso ] ; then
|
|
echo "04: build pkgs"
|
|
nice -n 20 ionice -c Idle build-pkgs
|
|
if [ $? -ne 0 ] ; then
|
|
echo "ERROR: build-pkgs failed"
|
|
exit 1
|
|
fi
|
|
|
|
echo "05: build iso"
|
|
nice -n 20 ionice -c Idle build-iso
|
|
if [ $? -ne 0 ] ; then
|
|
echo "ERROR: build-iso failed "
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
echo "06: rpm db"
|
|
mkdir -p $RPM_DB_DIR
|
|
if [ $? -ne 0 ] ; then
|
|
echo "ERROR: failed to make directory '$RPM_DB_DIR'"
|
|
exit 1
|
|
fi
|
|
|
|
echo "" > $RPM_DB
|
|
if [ $? -ne 0 ] ; then
|
|
echo "ERROR: failed to write file '$RPM_DB'"
|
|
exit 1
|
|
fi
|
|
|
|
for build_type in std rt; do
|
|
RPM_ROOT_DIR=$MY_WORKSPACE/$build_type/rpmbuild/RPMS
|
|
echo "RPM_ROOT_DIR=$RPM_ROOT_DIR"
|
|
cd $RPM_ROOT_DIR
|
|
if [ $? -ne 0 ] ; then
|
|
echo "ERROR: failed to change to directory '$RPM_ROOT_DIR'"
|
|
exit 1
|
|
fi
|
|
|
|
for d in `find * -type d`; do
|
|
pushd $d > /dev/null
|
|
if [ $? -ne 0 ] ; then
|
|
echo "ERROR: failed to change to directory '$d'"
|
|
exit 1
|
|
fi
|
|
|
|
rpm -qp --queryformat "$d %{NAME} %{RELEASE}\n" *rpm >> $RPM_DB 2> /dev/null
|
|
if [ $? -ne 0 ] ; then
|
|
echo "ERROR: rpm query failed in directory '$d'"
|
|
exit 1
|
|
fi
|
|
|
|
popd > /dev/null
|
|
done
|
|
done
|
|
|
|
|
|
echo 'Build is complete'
|
|
|
|
|
|
|