Add layer awareness to mirror-check.sh

This tool was missed when layered builds were introduced.
It looks for lst files under the wrong path. I've added
a layer arguement and fixed the path.

It also needs to ignore commented lines within lst files.

I also add dnf support.  Cloned from pkg-manager-utils.sh
since stx-tools is sometimes expected to stand on it's own.

One gap that I'm not addressing in this update.  It only
looks at the upstream repo, never at the cengn mirror.
If a package has been dropped by upstream, it reports as
missing.

Closes-Bug: 1908751
Signed-off-by: Scott Little <scott.little@windriver.com>
Change-Id: Idf4c9010c195f2fe8f7d0432c41c94fab00aec2c
This commit is contained in:
Scott Little 2020-12-17 16:14:49 -05:00
parent a2194c6ca7
commit be49af9525
2 changed files with 53 additions and 6 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@ localrc
toCOPY/.gitconfig toCOPY/.gitconfig
centos-mirror-tools/logs/ centos-mirror-tools/logs/
centos-mirror-tools/output/ centos-mirror-tools/output/
centos-mirror-tools/mirror-check-failures.log
# Sphinx documentation # Sphinx documentation
doc/build/ doc/build/

View File

@ -40,14 +40,43 @@ ERROR_LOG_FILE="mirror-check-failures.log"
truncate -s 0 $ERROR_LOG_FILE truncate -s 0 $ERROR_LOG_FILE
retcode=0 retcode=0
extra_opts="" extra_opts=""
layer="$LAYER"
valid_layers=('compiler' 'distro' 'flock')
# Cloned from cgcs-root/build-tools/pkg-manager-utils.sh
# Ideally this can still be used when tools is the only git
# that has been cloned.
# Yum vs DNF compatibility
YUM=$(which yum 2>> /dev/null)
DNF=$(which dnf 2>> /dev/null)
PKG_MANAGER=""
REPOQUERY=$(which repoquery 2>> /dev/null)
REPOQUERY_SUB_COMMAND=""
REPOQUERY_RESOLVE="--resolve"
REPOQUERY_WHATPROVIDES_DELIM=" "
if [ ! -z ${DNF} ]; then
PKG_MANAGER="dnf"
REPOQUERY=${DNF}
REPOQUERY_SUB_COMMAND="repoquery --disable-modular-filtering"
REPOQUERY_RESOLVE=""
REPOQUERY_WHATPROVIDES_DELIM=","
elif [ ! -z ${YUM} ]; then
PKG_MANAGER="yum"
else
>&2 echo "ERROR: Couldn't find a supported package manager"
exit 1
fi
usage() { usage() {
echo "$0 [-c <yum.conf>]" echo "$0 [-c <yum.conf>] [-l <layer>]"
echo "" echo ""
echo "Options:" echo "Options:"
echo " -c: Use an alternate yum.conf rather than the system file (option passed" echo " -c: Use an alternate yum.conf rather than the system file (option passed"
echo " on to subscripts when appropriate)" echo " on to subscripts when appropriate)"
echo " -l: Check specific layer (one of 'all ${valid_layers[@]}')"
echo "" echo ""
} }
@ -79,8 +108,10 @@ get_repoquery_info() {
else else
repoquery_opts= repoquery_opts=
fi fi
repoquery $extra_opts ${RELEASEVER} -C --qf '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}' \ $REPOQUERY $REPOQUERY_SUB_COMMAND \
$repoquery_opts "$_package_name" $extra_opts ${RELEASEVER} -C \
--qf '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}' \
$repoquery_opts "$_package_name"
} }
_check_rpms() { _check_rpms() {
@ -113,12 +144,27 @@ check_rpms() {
done done
} }
while getopts "c:" opt; do while getopts "c:l:" opt; do
case $opt in case $opt in
c) c)
extra_opts="-c ${OPTARG}" extra_opts="-c ${OPTARG}"
grep -q "releasever=" $OPTARG && RELEASEVER="--$(grep releasever= ${OPTARG})" grep -q "releasever=" $OPTARG && RELEASEVER="--$(grep releasever= ${OPTARG})"
;; ;;
l)
layer="${OPTARG}"
if [ "$layer" == "all" ]; then
layer=""
else
case " ${valid_layers[@]} " in
*" $layer "* ) echo "found layer $layer"
;;
*) echo "'$layer' is invalid"
usage
exit 1
;;
esac
fi
;;
\?) \?)
echo "Invalid option: -$OPTARG" >&2 echo "Invalid option: -$OPTARG" >&2
usage usage
@ -133,11 +179,11 @@ if ! yum $extra_opts ${RELEASEVER} makecache; then
exit 1 exit 1
fi fi
for rpm_list in "$RPMS_CENTOS_LIST" "$RPMS_3RD_PARTY_LIST"; do for rpm_list in $(find config/centos/$layer -name "$RPMS_CENTOS_LIST" -o -name "$RPMS_3RD_PARTY_LIST"); do
info "Reading $rpm_list..." info "Reading $rpm_list..."
for arch in "src" "noarch" "x86_64"; do for arch in "src" "noarch" "x86_64"; do
info "Getting info for $arch packages..." info "Getting info for $arch packages..."
rpms=$(echo "$(grep -F "$arch.rpm" < $rpm_list)") rpms=$(echo "$(grep -v '^#' $rpm_list | grep -F "$arch.rpm")")
check_rpms "$rpms" check_rpms "$rpms"
done done
done done