diffpkg: support multiple diff modes to compare with
This adds support for the following diff modes: - content list (default) - diffoscope - .PKGINFO diff - .BUILDINFO diff
This commit is contained in:
parent
11edc45048
commit
c339536a37
83
diffpkg.in
83
diffpkg.in
|
@ -8,19 +8,32 @@ m4_include(lib/common.sh)
|
|||
|
||||
usage() {
|
||||
cat <<- _EOF_
|
||||
Usage: ${BASH_SOURCE[0]##*/} [OPTIONS]
|
||||
Usage: ${BASH_SOURCE[0]##*/} [OPTIONS] [MODES]
|
||||
|
||||
Searches for a locally built package corresponding to the PKGBUILD, and
|
||||
downloads the last version of that package from the Pacman repositories.
|
||||
It then compares them with diffoscope.
|
||||
It then compares them using different modes while using simple tar
|
||||
content list by default.
|
||||
|
||||
OPTIONS
|
||||
-M, --makepkg-config Set an alternate makepkg configuration file
|
||||
-v, --verbose Provide more detailed/unfiltered output
|
||||
-h, --help Show this help text
|
||||
|
||||
MODES
|
||||
-l, --list Activate content list diff mode (default)
|
||||
-d, --diffoscope Activate diffoscope diff mode
|
||||
-p, --pkginfo Activate .PKGINFO diff mode
|
||||
-b, --buildinfo Activate .BUILDINFO diff mode
|
||||
_EOF_
|
||||
}
|
||||
|
||||
MAKEPKG_CONF=/etc/makepkg.conf
|
||||
VERBOSE=0
|
||||
TARLIST=0
|
||||
DIFFOSCOPE=0
|
||||
PKGINFO=0
|
||||
BUILDINFO=0
|
||||
|
||||
# option checking
|
||||
while (( $# )); do
|
||||
|
@ -33,6 +46,26 @@ while (( $# )); do
|
|||
MAKEPKG_CONF="$2"
|
||||
shift 2
|
||||
;;
|
||||
-l|--list)
|
||||
TARLIST=1
|
||||
shift
|
||||
;;
|
||||
-d|--diffoscope)
|
||||
DIFFOSCOPE=1
|
||||
shift
|
||||
;;
|
||||
-p|--pkginfo)
|
||||
PKGINFO=1
|
||||
shift
|
||||
;;
|
||||
-b|--buildinfo)
|
||||
BUILDINFO=1
|
||||
shift
|
||||
;;
|
||||
-v|--verbose)
|
||||
VERBOSE=1
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
|
@ -46,6 +79,10 @@ while (( $# )); do
|
|||
esac
|
||||
done
|
||||
|
||||
if ! (( DIFFOSCOPE || TARLIST || PKGINFO || BUILDINFO )); then
|
||||
TARLIST=1
|
||||
fi
|
||||
|
||||
# Source makepkg.conf; fail if it is not found
|
||||
if [[ -r "${MAKEPKG_CONF}" ]]; then
|
||||
# shellcheck source=makepkg-x86_64.conf
|
||||
|
@ -75,7 +112,45 @@ fi
|
|||
|
||||
STARTDIR=$(pwd)
|
||||
trap 'rm -rf $TEMPDIR' EXIT INT TERM QUIT
|
||||
TEMPDIR=$(mktemp -d --tmpdir diffpkg-script.XXXX)
|
||||
TEMPDIR=$(mktemp -d --tmpdir diffpkg-script.XXXXXXXX)
|
||||
|
||||
tar_list() {
|
||||
bsdtar tf "$*" | if (( VERBOSE )); then
|
||||
cat
|
||||
else
|
||||
sed -E 's|^usr/lib/modules/[0-9][^/]+|usr/lib/modules/[…]|g'
|
||||
fi | sort
|
||||
}
|
||||
|
||||
diff_pkgs() {
|
||||
local oldpkg=$1
|
||||
local newpkg=$2
|
||||
|
||||
if (( TARLIST )); then
|
||||
tar_list "$oldpkg" > "$TEMPDIR/filelist-old"
|
||||
tar_list "$newpkg" > "$TEMPDIR/filelist"
|
||||
|
||||
sdiff -s "$TEMPDIR/filelist-old" "$TEMPDIR/filelist"
|
||||
fi
|
||||
|
||||
if (( PKGINFO )); then
|
||||
bsdtar xOqf "$oldpkg" .PKGINFO > "$TEMPDIR/pkginfo-old"
|
||||
bsdtar xOqf "$newpkg" .PKGINFO > "$TEMPDIR/pkginfo"
|
||||
|
||||
sdiff -s "$TEMPDIR/pkginfo-old" "$TEMPDIR/pkginfo"
|
||||
fi
|
||||
|
||||
if (( BUILDINFO )); then
|
||||
bsdtar xOqf "$oldpkg" .BUILDINFO > "$TEMPDIR/buildinfo-old"
|
||||
bsdtar xOqf "$newpkg" .BUILDINFO > "$TEMPDIR/buildinfo"
|
||||
|
||||
sdiff -s "$TEMPDIR/buildinfo-old" "$TEMPDIR/buildinfo"
|
||||
fi
|
||||
|
||||
if (( DIFFOSCOPE )); then
|
||||
diffoscope "$(readlink -e "$oldpkg")" "$(readlink -e "$newpkg")"
|
||||
fi
|
||||
}
|
||||
|
||||
for _pkgname in "${pkgname[@]}"; do
|
||||
comparepkg=$_pkgname
|
||||
|
@ -121,5 +196,5 @@ for _pkgname in "${pkgname[@]}"; do
|
|||
curl -fsLC - --retry 3 --retry-delay 3 -o "$TEMPDIR/$oldpkg" "$pkgurl"
|
||||
fi
|
||||
|
||||
diffoscope $TEMPDIR/$oldpkg $pkgfile
|
||||
diff_pkgs "$TEMPDIR/$oldpkg" "$pkgfile"
|
||||
done
|
||||
|
|
|
@ -3,31 +3,48 @@ diffpkg(1)
|
|||
|
||||
Name
|
||||
----
|
||||
diffpkg - Diffoscope the current build package with the repository version
|
||||
diffpkg - Compare package files using different modes.
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
diffpkg
|
||||
diffpkg [OPTIONS] [MODES]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Searches for a locally built package corresponding to the PKGBUILD, and
|
||||
downloads the last version of that package from the Pacman repositories.
|
||||
It then compares them with diffoscope.
|
||||
It then compares them using different modes while using simple tar
|
||||
content list by default.
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
*-M, --makepkg-config*::
|
||||
Set an alternate makepkg configuration file.
|
||||
Set an alternate makepkg configuration file
|
||||
|
||||
*-v, --verbose*::
|
||||
Provide more detailed/unfiltered output
|
||||
|
||||
*-h, --help*::
|
||||
Show a help text
|
||||
|
||||
Modes
|
||||
-----
|
||||
|
||||
*-l, --list*::
|
||||
Activate tar content list diff mode (default)
|
||||
|
||||
*-d, --diffoscope*::
|
||||
Activate diffoscope diff mode
|
||||
|
||||
*-p, --pkginfo*::
|
||||
Activate .PKGINFO diff mode
|
||||
|
||||
*-b, --buildinfo*::
|
||||
Activate .BUILDINFO diff mode
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
linkman:find-libprovides[1]
|
||||
|
||||
include::footer.asciidoc[]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#compdef archbuild archco arch-nspawn archrelease commitpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-x86_64-build=archbuild testing-x86_64-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-x86_64-build=archbuild communityco=archco checkpkg sogrep offload-build makerepropkg
|
||||
#compdef archbuild archco arch-nspawn archrelease commitpkg diffpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-x86_64-build=archbuild testing-x86_64-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-x86_64-build=archbuild communityco=archco checkpkg sogrep offload-build makerepropkg
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
|
@ -41,6 +41,16 @@ _commitpkg_args=(
|
|||
'1:commit_msg'
|
||||
)
|
||||
|
||||
_diffpkg_args=(
|
||||
'(-l --list)'{-l,--list}'[Tar content list diff mode]'
|
||||
'(-d --diffoscope)'{-d,--diffoscope}'[Diffoscope diff mode]'
|
||||
'(-p --pkginfo)'{-p,--pkginfo}'[.PKGINFO diff mode]'
|
||||
'(-b --buildinfo)'{-b,--buildinfo}'[.BUILDINFO diff mode]'
|
||||
'(-m --makepkg-config)'{-m,--makepkg-config}'[Location of a makepkg config file]:makepkg_config:_files -g "*.conf(.)"'
|
||||
'(-v --verbose)'{-v,--verbose}'[Provide more detailed/unfiltered output]'
|
||||
'(-h --help)'{-h,--help}'[Display usage]'
|
||||
)
|
||||
|
||||
_finddeps_args=(
|
||||
'1:packages:_devtools_completions_all_packages'
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue