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

NOTE: The patch_rebase_1/2/3/4 scripts remain broken, but I hope
to salvage them one day.  The current coding assumes content under
centos-repo/cgcs-centos-repo is managed by a git, which is not
currently true.

Story: 2006387
Task: 36912
Change-Id: I8f694814c41957c5b37eb2e64b653b7d42f2e2c9
Signed-off-by: Scott Little <scott.little@windriver.com>
2020-09-24 11:59:55 -04:00

81 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
rpm_compare () {
local r="$1"
local r2="$2"
local line
local f=$(basename $r)
local f2=$(basename $r2)
rpm -q --dump --nosignature -p $r | awk ' { print $1 "\n" $1 " " $5 " " $6 " " $7 " " $8 " " $9 " " $10 " " $11 } ' > /tmp/dump.new
rpm -q --dump --nosignature -p $r2 | awk ' { print $1 "\n" $1 " " $5 " " $6 " " $7 " " $8 " " $9 " " $10 " " $11 } ' > /tmp/dump.old
first_line=1
diff -y -W 200 --suppress-common-lines /tmp/dump.new /tmp/dump.old | grep '|' |
while read -r line; do
left=$(echo "$line" | awk -F '|' '{ print $1 }')
right=$(echo "$line" | awk -F '|' '{ print $2 }')
left_f=$(echo "$left" | awk '{ print $1 }')
right_f=$(echo "$right" | awk '{ print $1 }')
if [ "$left_f" != "$right_f" ];then
continue
fi
if [ $first_line -eq 1 ]; then
echo ""
echo "$f vs $f2"
first_line=0
fi
echo "$line"
done
}
# 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
echo ""
echo "======================================================"
echo "Auditing built packages vs unpatched upstream packages"
echo "======================================================"
for r in $(find $MY_WORKSPACE/*/rpmbuild/RPMS -name '*.rpm' | grep -v '.src.rpm' | grep -v debuginfo); do
f=$(basename $r)
f2=$(echo $f | sed 's#[.]tis[.][0-9]*[.]#.#' | sed 's#[.]tis[.]#.#')
r2=$(find ${CENTOS_REPO}/Binary/ -name $f2)
if [ "$r2" == "" ]; then
# Probably one of our own
# echo "Couldn't find '$f2'"
continue
fi
rpm_compare "$r" "$r2"
done
echo ""
echo "============================"
echo "Auditing built for conflicts"
echo "============================"
grep 'conflicts with file from package' -r --binary-files=without-match $MY_WORKSPACE/*/results/ |
while read -r line; do
w=$(echo "$line" | awk '{ print $8 }')".rpm"
w2=$(echo "$line" | awk '{ print $14 }')".rpm"
echo "$w $w2"
done | sort --unique | sed 's#bash-completion-1:#bash-completion-#' |
while read -r line2; do
f=$(echo "$line2" | awk '{ print $1 }')
f2=$(echo "$line2" | awk '{ print $2 }')
r=$(find ${CENTOS_REPO}/Binary/ $MY_WORKSPACE/*/rpmbuild/RPMS -name $f)
r2=$(find ${CENTOS_REPO}/Binary/ $MY_WORKSPACE/*/rpmbuild/RPMS -name $f2)
# echo ""
# echo "$f vs $f2"
# echo "$r vs $r2"
if [ "$r" != "" ] && [ "$r2" != "" ]; then
rpm_compare "$r" "$r2"
fi
done