root/build-tools/mirror_rebase/link_cgcs_centos_repo_7

85 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
#
# Part of the monthly mirror update
#
# Update symlinks in cgcs-centos-repo to point to the latest version of packages in /import/mirrors/CentOS/tis-r5-CentOS/newton
#
# Update srpm_path for packages to be upgraded
#
UPVERSION_LOG=$MY_WORKSPACE/upversion.log
if [ "x$ORIGIN_BRANCH" == "x" ]; then
ORIGIN_BRANCH=CGCS_DEV_0029
fi
if [ "x$WORKING_BRANCH" == "x" ]; then
WORKING_BRANCH=CGCS_DEV_0029_rebase_7_4
fi
if [ ! -f $UPVERSION_LOG ]; then
echo "ERROR: Can't find UPVERSION_LOG at '$UPVERSION_LOG'"
fi
# One step back to see the old symlinks
cd $MY_REPO
FAILED=""
for dat in $(cat $UPVERSION_LOG); do
name=$(echo $dat | awk -F '#' '{print $1}')
srpm_path=$(echo $dat | awk -F '#' '{print $2}')
old_src_rpm=$(echo $dat | awk -F '#' '{print $4}')
new_src_rpm=$(echo $dat | awk -F '#' '{print $5}')
(
cd $(dirname $srpm_path)
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$CURRENT_BRANCH" != "$WORKING_BRANCH" ]; then
git checkout $WORKING_BRANCH
if [ $? -ne 0 ]; then
git checkout $ORIGIN_BRANCH
if [ $? -ne 0 ]; then
echo "ERROR: Can't checkout branch '$ORIGIN_BRANCH' in directory '$(pwd)'"
exit 1
fi
git checkout -b $WORKING_BRANCH
if [ $? -ne 0 ]; then
echo "ERROR: failed to 'git checkout -b $WORKING_BRANCH' from '$(pwd)'"
exit 1
else
echo "created branch '$WORKING_BRANCH' at '$(pwd)'"
fi
fi
fi
sed -i "s#$old_src_rpm#$new_src_rpm#" $srpm_path
if [ $? -ne 0 ]; then
echo "ERROR: sed failed '$old_src_rpm' -> '$new_src_rpm'"
exit 1
else
echo "updated $srpm_path: '$old_src_rpm' -> '$new_src_rpm'"
fi
exit 0
)
if [ $? -ne 0 ]; then
echo "ERROR: failed while working on package '$name' at '$srpm_path'"
exit 1
fi
done
echo ""
for d in $(for dat in $(cat $UPVERSION_LOG); do srpm_path=$(echo $dat | awk -F '#' '{print $2}'); ( cd $(dirname $srpm_path); git rev-parse --show-toplevel ); done | sort --unique); do
(
cd $d
echo "cd $d"
for f in $(git status --porcelain | grep 'srpm_path$' | awk '{print $2}'); do
echo "git add $f";
done
echo "git commit -m 'srpm_path updates for centos rebase'"
)
done
echo ""