Add scripts to compare YUM and DNF gathering
There are scripts to re-run depsolving with any backend based on config and log file. There is a new script to compare logs from two runs and report differences. This script will be installed system wide in final RPM. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
99b68ca96b
commit
36f57b26b8
19
contrib/yum-dnf-compare/README
Normal file
19
contrib/yum-dnf-compare/README
Normal file
@ -0,0 +1,19 @@
|
||||
This directory contains scripts to compare YUM and DNF based gathering code in
|
||||
Pungi.
|
||||
|
||||
There are two scripts to help re-run the depsolving on existing code. As input
|
||||
they need .conf and .log file from an existing compose. They collect correct
|
||||
command line options from them and run the respective tool.
|
||||
|
||||
Run:
|
||||
|
||||
$ run-dnf.sh Server.x86_64.conf
|
||||
$ run-yum.sh Server.x86_64.conf
|
||||
|
||||
The results are stored in a file with .log.dnf or .log.yum extensions. When
|
||||
--interactive is used as second argument of the scripts, the output is printed
|
||||
to terminal (useful for running in debugger).
|
||||
|
||||
To compare the RPM package lists, run:
|
||||
|
||||
$ ./pungi-compare-depsolving Server.x86_64.log.yum Server.x86_64.log.dnf
|
62
contrib/yum-dnf-compare/pungi-compare-depsolving
Executable file
62
contrib/yum-dnf-compare/pungi-compare-depsolving
Executable file
@ -0,0 +1,62 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
here = sys.path[0]
|
||||
if here != '/usr/bin':
|
||||
# Git checkout
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
|
||||
|
||||
from kobo.rpmlib import parse_nvra, make_nvra
|
||||
from pungi.wrappers.pungi import PungiWrapper
|
||||
|
||||
|
||||
def read_rpms(fn):
|
||||
pw = PungiWrapper()
|
||||
data = pw.get_packages(open(fn, "r").read())
|
||||
result = set()
|
||||
for i in data["rpm"]:
|
||||
nvra = parse_nvra(i["path"])
|
||||
result.add(make_nvra(nvra, add_rpm=True))
|
||||
|
||||
return result
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('old', metavar='OLD', default='pungi-yum.log')
|
||||
parser.add_argument('new', metavar='NEW', default='pungi-dnf.log')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
yum_rpms = read_rpms(args.old)
|
||||
dnf_rpms = read_rpms(args.new)
|
||||
|
||||
removed = yum_rpms - dnf_rpms
|
||||
added = dnf_rpms - yum_rpms
|
||||
|
||||
|
||||
print("ADDED: %s" % len(added))
|
||||
for i in sorted(added):
|
||||
print(" %s" % i)
|
||||
|
||||
print()
|
||||
|
||||
print("REMOVED: %s" % len(removed))
|
||||
for i in sorted(removed):
|
||||
print(" %s" % i)
|
||||
|
||||
print()
|
||||
|
||||
print("ADDED: %6s" % len(added))
|
||||
print("REMOVED: %6s" % len(removed))
|
||||
print("YUM RPMS: %6s" % len(yum_rpms))
|
||||
print("DNF RPMS: %6s" % len(dnf_rpms))
|
||||
print("ALL RPMS: %6s" % len(yum_rpms | dnf_rpms))
|
||||
|
||||
if added or removed:
|
||||
sys.exit(1)
|
24
contrib/yum-dnf-compare/run-dnf.sh
Executable file
24
contrib/yum-dnf-compare/run-dnf.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
HERE=$(dirname "$0")
|
||||
PATH=$HERE/../../bin:$PATH
|
||||
PYTHONPATH=$HERE/../../:${PYTHONPATH:-}
|
||||
export PATH PYTHONPATH
|
||||
|
||||
CONF=$1
|
||||
LOG=${CONF%%.conf}.log
|
||||
ARCH=$(head -n1 "$LOG" | tr ' ' '\n' | grep -- '--arch=')
|
||||
|
||||
CMD=(pungi-gather "--config=$CONF" "$ARCH" $(head -n1 "$LOG" | tr ' ' '\n' | grep '^--\(selfhosting\|fulltree\|greedy\|multilib\)'))
|
||||
|
||||
echo "${CMD[@]}"
|
||||
if [ $# -le 1 ] || [ "$2" != "--interactive" ]; then
|
||||
exec >"$LOG.dnf"
|
||||
fi
|
||||
exec 2>&1
|
||||
|
||||
exec "${CMD[@]}"
|
28
contrib/yum-dnf-compare/run-yum.sh
Executable file
28
contrib/yum-dnf-compare/run-yum.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
set -u
|
||||
|
||||
export LANG=C
|
||||
|
||||
HERE=$(dirname "$0")
|
||||
PATH=$HERE/../../bin:$PATH
|
||||
PYTHONPATH=$HERE/../../
|
||||
export PATH PYTHONPATH
|
||||
|
||||
CONF="$1"
|
||||
LOG=${CONF%%.conf}.log
|
||||
|
||||
tempdir=$(mktemp -d)
|
||||
trap 'rm -rf $tempdir' EXIT
|
||||
|
||||
cmd=$(head -n1 "$LOG" | cut -d' ' -f2- | sed "s@--\(destdir\|cachedir\)=\(/[^/ ]*\)*@--\1=$tempdir/\1@g" | sed 's/^pungi3/pungi/' | sed "s@--config=/\([^/]*/\)*work/[^/]*/pungi/\([^ ]*\)@--config=$1@g")
|
||||
|
||||
echo "$cmd"
|
||||
if [ $# -le 1 ] || [ "$2" != "--interactive" ]; then
|
||||
exec >"$LOG.yum"
|
||||
fi
|
||||
exec 2>&1
|
||||
|
||||
$cmd
|
@ -85,6 +85,7 @@ rm -rf %{buildroot}
|
||||
%{_bindir}/%{name}-config-validate
|
||||
%{_bindir}/%{name}-fedmsg-notification
|
||||
%{_bindir}/%{name}-patch-iso
|
||||
%{_bindir}/%{name}-compare-depsolving
|
||||
|
||||
%check
|
||||
nosetests --exe
|
||||
|
Loading…
Reference in New Issue
Block a user