差异两个转速? -- linux
diff two rpms? -- linux
对我的基线 (java/ C++) 进行了一些未知更改并安装在新的 rpm 中。我想要一种方法来将此 rpm 的内容与旧的 rpm 的内容进行比较,以查看所做的更改。这可能吗?
如果没有简单的方法来做到这一点,是否有办法获取其中按日期组织的 rpm 文件名的内容列表?
如果您有以前的 rpm 包文件,您可以将其解压,例如,使用 unrpm
到一个临时目录并使用 diff -r
比较结果。
这是我在 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 ; 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 包应用相同的方法;这个问题很明显,一个已经安装,另一个可以访问。
尝试pkgdiff可视化 RPM 包之间的差异:
pkgdiff PKG-0.rpm PKG-1.rpm
如果您比较 SRC.RPM 那么该工具也会提取并比较内部 tarball(除非定义了 -skip-subarchives 选项)。
要严格比较两个 rpm 文件(我们称它们为 one.rpm 和 another.rpm),您我想检查 digests of the constituent files as well as check the pre- and post-[un]install scripts(因为这些脚本可能会修改系统状态):
$ diff <(rpm -q --dump --scripts -p one.rpm) <(rpm -q --dump --scripts -p another.rpm)
您可能还想比较 signatories(如果有的话):
$ 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)
(或者,if you're 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)
)
对我的基线 (java/ C++) 进行了一些未知更改并安装在新的 rpm 中。我想要一种方法来将此 rpm 的内容与旧的 rpm 的内容进行比较,以查看所做的更改。这可能吗?
如果没有简单的方法来做到这一点,是否有办法获取其中按日期组织的 rpm 文件名的内容列表?
如果您有以前的 rpm 包文件,您可以将其解压,例如,使用 unrpm
到一个临时目录并使用 diff -r
比较结果。
这是我在 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 ; 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 包应用相同的方法;这个问题很明显,一个已经安装,另一个可以访问。
尝试pkgdiff可视化 RPM 包之间的差异:
pkgdiff PKG-0.rpm PKG-1.rpm
如果您比较 SRC.RPM 那么该工具也会提取并比较内部 tarball(除非定义了 -skip-subarchives 选项)。
要严格比较两个 rpm 文件(我们称它们为 one.rpm 和 another.rpm),您我想检查 digests of the constituent files as well as check the pre- and post-[un]install scripts(因为这些脚本可能会修改系统状态):
$ diff <(rpm -q --dump --scripts -p one.rpm) <(rpm -q --dump --scripts -p another.rpm)
您可能还想比较 signatories(如果有的话):
$ 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)
(或者,if you're 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)
)