tools: fix validation of some py3 specs

Assuming the reason run_renderspec skipped py3 was to avoid
speccleaner complaining about single line py2 and py3 BuildRequires,
this patch changes the way to achieve that while supporting other
different ways to write py3 specs that would otherwise would not be
recognized as py3 only and end up with blank BuildRequires and the
like, specifically:

* singlespecs with py3 flavor only (new networking-l2gw spec)
* py3 specs for which the package name is rendered instead of forced
  (networking-generic-switch)

Change-Id: I62fad6d140338ee9af7eca144edb4ae6e96f6007
This commit is contained in:
Jaime Caamaño Ruiz 2019-07-19 02:09:03 +02:00
parent 7c7ac3b998
commit a1fdd1d55a
2 changed files with 11 additions and 5 deletions

View File

@ -26,11 +26,7 @@ for specstyle in $specstyles; do
find ${specdir} -name "${FIND_STR}.spec.j2" -type f -print0 | \
xargs -n 1 -0 -P 0 -I __SPEC__ bash -c "
set -e
skip='--skip-pyversion py3'
if grep -q '%package -n python3-' __SPEC__; then
skip=""
fi
pkg_name=\$(pymod2pkg --dist $specstyle \$(basename __SPEC__ .spec.j2))
renderspec --spec-style $specstyle __SPEC__ \
\$skip -o $WORKSPACE/logs/$specstyle/\$pkg_name.spec"
-o $WORKSPACE/logs/$specstyle/\$pkg_name.spec"
done

View File

@ -26,6 +26,16 @@ for spec in `find $WORKSPACE/logs/suse/ -name "${FIND_STR}.spec" -type f -print`
# https://github.com/openSUSE/spec-cleaner/issues/173
sed -i 's/%{__python2}/python2/g' $spec
sed -i 's/%{__python3}/python3/g' $spec
# NOTE(jaicaa): spec-cleaner does not like py2 and py3 single
# line BuildRequires, pick py2:
# BuildRequires: python-X python3-X -> BuildRequires: python-X
# BuildRequires: python3-X python-X -> BuildRequires: python-X
# BuildRequires: python2-X python3-X -> BuildRequires: python2-X
# BuildRequires: python3-X python2-X -> BuildRequires: python2-X
sed -i 's/^\(BuildRequires:.*\)python-\(.*\b\).*python3-\2$/\1python-\2/g' $spec
sed -i 's/^\(BuildRequires:.*\)python3-\(.*\b\).*python-\2$/\1python-\2/g' $spec
sed -i 's/^\(BuildRequires:.*\)python2-\(.*\b\).*python3-\2$/\1python2-\2/g' $spec
sed -i 's/^\(BuildRequires:.*\)python3-\(.*\b\).*python2-\2$/\1python2-\2/g' $spec
spec-cleaner -m -d --no-copyright --diff-prog "diff -uw" \
$spec > $tmpdir/`basename ${spec}`.cleaner.diff &
let count+=1