rpm-packaging/tools/run_speccleaner.sh
Thomas Bechtold ccdae17907 Allow lint runs for a single spec
Currently, a "tox -e lint" run takes a lot of time. But when
developing locally and changing a single spec template, this is
annoying.
So allow a second positional argument for the 3 tools from the tools/
directory which is a string used by the "-name" argument from
"find". With that, it is possible to call lint for a single spec
template with eg:

tox -elint python-cliff

Change-Id: I1ba05ed4e353728d251105fc7ad356d759813481
2019-04-10 13:36:09 +02:00

48 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -e
# 1st positional arg is the working dir
basedir=${1:-$PWD}
# 2nd positional arg is the find -name parameter
FIND_STR=${2:-*}
WORKSPACE=${WORKSPACE:-$basedir}
# tempfile to store the spec-cleaner diff for all specs
tmpdir=$(mktemp -d)
MAXPROC=4
echo "run spec-cleaner over specfiles from $WORKSPACE/logs/"
count=0
# TODO(toabctl): also run spec-cleaner with non-SUSE specs
# but the current problem is that the license check works for SUSE only
for spec in `find $WORKSPACE/logs/suse/ -name "${FIND_STR}.spec" -type f -print` ; do
echo "spec-cleaner checking $spec"
# NOTE(toabctl):spec-cleaner can not ignore epochs currently
sed -i '/^Epoch:.*/d' $spec
# NOTE(jpena): spec-cleaner wants python2/python3 instead of
# %{__python2}/%{__python3}
# https://github.com/openSUSE/spec-cleaner/issues/173
sed -i 's/%{__python2}/python2/g' $spec
sed -i 's/%{__python3}/python3/g' $spec
spec-cleaner -m -d --no-copyright --diff-prog "diff -uw" \
$spec > $tmpdir/`basename ${spec}`.cleaner.diff &
let count+=1
[[ count -eq $MAXPROC ]] && wait && count=0
done
wait
# check if some diffs are available
failed=0
for specdiff in $tmpdir/*; do
if [ -s "$specdiff" ]; then
echo "##### `basename ${specdiff}` ##### "
cat $specdiff
failed=1
fi
done
exit $failed