Accepting request 830269 from openSUSE:Tools

- write changelogs in UTF-8 encoding

- speedup it a lot to avoid timeout errors

- running based on .report instead of .packages files

OBS-URL: https://build.opensuse.org/request/show/830269
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/release-compare?expand=0&rev=2
This commit is contained in:
Dominique Leuenberger 2020-08-28 19:21:43 +00:00 committed by Git OBS Bridge
commit e5fbb6c9f0
3 changed files with 88 additions and 27 deletions

View File

@ -25,41 +25,84 @@
out=/.build.packages/obsgendiff
outreleased=/.build.packages/obsgendiff.released
echo "Running obsgendiff data differ..."
eol=$'\n'
# extract released obsgendiff aggregates
for obsgendiff in /.build.packages/SOURCES/*.obsgendiff; do
[ -e "$obsgendiff" ] || continue
mkdir -p "${outreleased}"
tar xfv "$obsgendiff" -C "${outreleased}"
done
echo "Running obsgendiff data differ..."
# create changelogs based on the packaged rpms
mkdir -p $out/{changelogs,disturl}
for packages in /.build.packages/KIWI/*.packages; do
cat "$packages" | while read line; do
IFS='|' read -r -a a <<< "$line"
name="${a[0]}"
rpm="${name}.rpm"
for report in /.build.packages/OTHER/*.report; do
# only the worker knows where it was downloaded from....
file=`find /.build.packages/SOURCES/repos/ -name $rpm`
rpm -qp "$file" --changelog 2>/dev/null > $out/changelogs/${name}
rpm -qp "$file" --qf '%{DISTURL}\n' 2>/dev/null > $out/disturl/${name}
# skip source and debug media
[ "$report" = "${report/-Media2/}" ] || continue
[ "$report" = "${report/-Media3/}" ] || continue
# find and extract right obsgendiff archive
oldobsgendiff=${report%.report}.obsgendiff
oldobsgendiff=/.build.packages/SOURCES/${oldobsgendiff##*/}
oldobsgendiff=`echo ${oldobsgendiff/-Build*-/-Build*-}` # find old build number
if [ -e "$oldobsgendiff" ]; then
echo "Extracting $oldobsgendiff"
mkdir -p "${outreleased}"
tar xf "$oldobsgendiff" -C "${outreleased}"
else
echo "WARNING no old obsgendiff found: $oldobsgendiff"
fi
sed -n -e 's,.*<binary .*obs:\(//.*\)</binary>,\1,p' "$report" | while read disturl; do
rpm="${disturl##*/}"
name="${rpm%-*}"
name="${name%-*}"
# only the worker knows where it was downloaded from....
# the disturl may contained a different build repo
file=`echo /.build.packages/SOURCES/repos/*/*/*/$rpm`
file="${file//${eol}*/}" # bash internal "head -n 1"
LC_ALL=C.UTF-8 rpm -qp "$file" --changelog --nodigest --nosignature 2>/dev/null > $out/changelogs/${name}
echo "$disturl" > $out/disturl/${name}
done
# create archive
cd $out
gendiff=${packages%.packages}.obsgendiff
tar cfJ /.build.packages/OTHER/${gendiff##*/} *
cd -
pushd $out
gendiff=${report%.report}.obsgendiff
tar cfJ /.build.packages/OTHER/${gendiff##*/} .
popd
# create diff to released archive
# NOTE: it had to be published or it won't exist
if [ -d "${outreleased}" ]; then
changelog=/.build.packages/OTHER/ChangeLog.${report##*/}
changelog=${changelog%.report}.txt
echo ""> $changelog
# removed packages
echo "Removed packages">> $changelog
echo "================">> $changelog
echo "">> $changelog
find "$outreleased/changelogs/" -type f | sort | sed "s,^$outreleased/changelogs/,," | while read file; do
[ -e "${out}/changelogs/$file" ] || echo " - ${file##*::}" >> $changelog
done
echo "">> $changelog
# new packages
echo "New packages">> $changelog
echo "============">> $changelog
echo "">> $changelog
find "$out/changelogs/" -type f | sort | sed "s,^$out/changelogs/,," | while read file; do
[ -e "${outreleased}/changelogs/$file" ] || echo " - ${file##*::}" >> $changelog
done
echo "">> $changelog
# changed packages
echo "Package updates">> $changelog
echo "===============">> $changelog
echo "">> $changelog
diff -ur "${outreleased}/changelogs/" "$out/changelogs/" | grep -v '^Only in ' | grep '^[+-]' | grep -v '^--- ' | sed 's,^+++ .*/\([^\t]*\).*$,\1,' >> $changelog
fi
done
# create diff to released archive
# NOTE: it had to be published or it won't exist
if [ -d "${outreleased}" ]; then
diff -urN "${outreleased}/" "$out/" > /.build.packages/OTHER/changelog.diff
fi
exit 0

View File

@ -1,3 +1,18 @@
-------------------------------------------------------------------
Wed Aug 26 13:44:48 UTC 2020 - Adrian Schröter <adrian@suse.de>
- write changelogs in UTF-8 encoding
-------------------------------------------------------------------
Tue Aug 25 07:34:24 UTC 2020 - Adrian Schröter <adrian@suse.de>
- speedup it a lot to avoid timeout errors
-------------------------------------------------------------------
Wed Aug 19 09:13:35 UTC 2020 - Adrian Schröter <adrian@suse.de>
- running based on .report instead of .packages files
-------------------------------------------------------------------
Mon Feb 3 14:11:03 UTC 2020 - Adrian Schröter <adrian@suse.de>

View File

@ -44,6 +44,9 @@ Note: you need to use a releasetarget definition in your OBS repository
mkdir -p $RPM_BUILD_ROOT/usr/lib/build/ $RPM_BUILD_ROOT/%_defaultdocdir/%name
install -m 0755 %SOURCE2 $RPM_BUILD_ROOT/usr/lib/build/
%check
bash -n $RPM_BUILD_ROOT/usr/lib/build/obsgendiff || exit 1
%files
/usr/lib/build