Diff two rpms? - linux

Some unknown changes were made to my baseline (java / C ++) and installed in the new rpm. I would like to compare the contents of this RPM with the old one to see the changes made. Is it possible?

If there is no easy way to do this, is there a way to get a list of the contents of the rpm file names inside it, organized by date?

+5
source share
3 answers

If you have a previous rpm package file, you can unzip it, for example, using it unrpmin a temporary directory and using diff -rit to compare the results.

Here is an example I made to illustrate between two versions of ncurses:

#!/bin/sh

failed() {
    echo "? $*" >&2
    exit 1
}

# get the package filename as parameter, defaulting to one used for example
oldpkg=$(readlink -f "${1:-/tmp/ncurses6-6.0-20150926.x86_64.rpm}")
pkgname=$(rpm -qip "$oldpkg" 2>/dev/null | awk '/^Name .*:/ { print $3; exit 0; }')

[ -f "$oldpkg" ] || failed "no package file found: $oldpkg"
[ -n "$pkgname" ] || failed "no package name found in $oldpkg"

# The tags for this question are "linux" and "rpm", so mktemp and bash are assumed.
tempdir=$(mktemp -d "${TMPDIR:-/tmp}/pkgcompare.XXXXXX")
trap 'rm -rf "$tempdir"' EXIT ERR

# Fedora sets CDPATH, which would echo (cancel that).
unset CDPATH

mkdir -p "$tempdir"/{new-version,old-version}

cd "$tempdir/new-version" || exit
# the query returns absolute pathnames beginning with "/"
rpm -ql "$pkgname" | while :
do
    read path
    [ -z "$path" ] && break
    [ -d "$path" ] && mkdir -p ".$path"
    [ -f "$path" ] && mkdir -p "./${path%/*}"
    [ -f "$path" ] && cp -p "$path" ".$path"
done

cd "$tempdir/old-version" || exit
rpm2cpio "$oldpkg" | cpio -i -d 2>/dev/null

cd $tempdir || exit
# I would usually pipe this into diffstat, but you may want the actual diffs
diff -r -u -N old-version new-version | diffstat

( diffstat, ):

 bin/ncursesw6-config           |    2 +-
 include/ncursesw6/curses.h     |    8 ++++----
 include/ncursesw6/ncurses.h    |    8 ++++----
 lib64/libncurses++w6.so        |binary
 lib64/libncurses++w6.so.6      |binary
 lib64/libncurses++w6.so.6.0    |binary
 lib64/libncursesw6.so          |binary
 lib64/libncursesw6.so.6        |binary
 lib64/libncursesw6.so.6.0      |binary
 lib64/libtinfow6.so            |binary
 lib64/libtinfow6.so.6          |binary
 lib64/libtinfow6.so.6.0        |binary
 lib64/pkgconfig/formw6.pc      |    2 +-
 lib64/pkgconfig/menuw6.pc      |    2 +-
 lib64/pkgconfig/ncurses++w6.pc |    2 +-
 lib64/pkgconfig/ncursesw6.pc   |    2 +-
 lib64/pkgconfig/panelw6.pc     |    2 +-
 lib64/pkgconfig/ticw6.pc       |    2 +-
 lib64/pkgconfig/tinfow6.pc     |    2 +-
 19 files changed, 16 insertions(+), 16 deletions(-)

, rpm; , , .

+1

pkgdiff, RPM:

pkgdiff PKG-0.rpm PKG-1.rpm

SRC.RPM, ( -skip-subarchives).

enter image description here

enter image description here

+8

rpm ( one.rpm another.rpm), , pre- post- [un] ( ):

$ diff <(rpm -q --dump --scripts -p one.rpm) <(rpm -q --dump --scripts -p another.rpm)

You can also compare signatories (if any):

$ diff <(rpm -q --qf '%{SIGPGP:pgpsig}\n%{SIGPGP:armor}\n' -p one.rpm) <(rpm -q --qf '%{SIGPGP:pgpsig}\n%{SIGPGP:armor}\n' -p another.rpm)

(or if you are especially pedantic :

$ diff <(rpm -q --qf '%{DSAHEADER:pgpsig}\n%{DSAHEADER:armor}\n%{RSAHEADER:pgpsig}\n%{DSAHEADER:armor}\n%{SIGGPG:pgpsig}\n%{SIGGPG:armor}\n%{SIGPGP:pgpsig}\n%{SIGPGP:armor}\n' -p one.rpm) <(rpm -q --qf '%{DSAHEADER:pgpsig}\n%{DSAHEADER:armor}\n%{RSAHEADER:pgpsig}\n%{DSAHEADER:armor}\n%{SIGGPG:pgpsig}\n%{SIGGPG:armor}\n%{SIGPGP:pgpsig}\n%{SIGPGP:armor}\n' -p another.rpm)
)

0
source

Source: https://habr.com/ru/post/1619974/


All Articles