root/build-tools/mirror_rebase/link_cgcs_centos_repo_3

41 lines
917 B
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
#
# This step removes broken Binary links
#
MIRROR_ROOT=/import/mirrors/CentOS/tis-r5-CentOS/newton
cd $MY_REPO/cgcs-centos-repo
if [ $? -ne 0 ]; then
echo 'ERROR: failed to cd to $MY_REPO/cgcs-centos-repo'
return 1
fi
# Clean broken rpm links
for r in $(find Binary -name '*.rpm' | grep -v '.src.rpm$' | sort -r -V); do
b=$(basename $r)
link=$(readlink $r)
if [ ! -f $link ]; then
echo "ERROR: '$b' link to non-existant file '$link'"
echo "SUGGEST: rm $r"
git rm -f $r
continue
fi
echo $link | grep "$MIRROR_ROOT" >> /dev/null
if [ $? -ne 0 ]; then
echo "ERROR: '$b' links to unexpected file '$link'"
echo "SUGGEST: rm $r"
git rm -f $r
continue
fi
done