nix-tools/bin/checkpkg.in

81 lines
2.5 KiB
Text
Raw Normal View History

2014-10-04 00:46:40 +02:00
#!/bin/bash
2014-11-18 19:20:53 +01:00
#
2014-10-04 15:41:22 +02:00
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
2014-10-08 13:14:28 +02:00
version=@version@
2015-06-09 00:01:31 +02:00
LIBDIR='@libdir@'
[[ -r ${LIBDIR}/util-msg.sh ]] && source ${LIBDIR}/util-msg.sh
2015-11-25 16:53:55 +01:00
import ${LIBDIR}/util-pkg.sh
2014-10-04 00:46:40 +02:00
2014-11-11 23:02:40 +01:00
shopt -s extglob
2014-11-13 13:33:38 +01:00
load_vars "$HOME/.makepkg.conf"
load_vars /etc/makepkg.conf
2014-10-04 00:46:40 +02:00
if [[ ! -f PKGBUILD ]]; then
2016-09-15 23:58:18 +02:00
die 'This must be run in the directory of a built package.'
2014-10-04 00:46:40 +02:00
fi
2014-11-11 23:02:40 +01:00
. ./PKGBUILD
2014-10-04 00:46:40 +02:00
if [[ $arch == 'any' ]]; then
2016-09-15 23:58:18 +02:00
CARCH='any'
2014-10-04 00:46:40 +02:00
fi
STARTDIR=$(pwd)
2014-11-11 23:02:40 +01:00
TEMPDIR=$(mktemp -d --tmpdir checkpkg-script.XXXX)
2014-10-04 00:46:40 +02:00
for _pkgname in "${pkgname[@]}"; do
2016-09-15 23:58:18 +02:00
target_pkgver=$(get_full_version "$_pkgname")
if ! pkgfile=$(find_cached_package "$_pkgname" "$target_pkgver" "$CARCH"); then
die 'tarball not found for package: %s' "${_pkgname}-$target_pkgver"
fi
ln -s "$pkgfile" "$TEMPDIR"
pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$_pkgname")
if [[ $? -ne 0 ]]; then
die "Couldn't download previous package for %s." "$_pkgname"
fi
oldpkg=${pkgurl##*://*/}
if [[ ${oldpkg##*/} = ${pkgfile##*/} ]]; then
die "The built package (%s) is the one in the repo right now!" "$_pkgname"
fi
if [[ $pkgurl = file://* ]]; then
ln -s "${pkgurl#file://}" "$TEMPDIR/$oldpkg"
elif [[ -f "$PKGDEST/$oldpkg" ]]; then
ln -s "$PKGDEST/$oldpkg" "$TEMPDIR/$oldpkg"
elif [[ -f "$STARTDIR/$oldpkg" ]]; then
ln -s "$STARTDIR/$oldpkg" "$TEMPDIR/$oldpkg"
else
curl -fsLC - --retry 3 --retry-delay 3 -o "$TEMPDIR/$oldpkg" "$pkgurl"
fi
bsdtar tf "$TEMPDIR/$oldpkg" | sort > "$TEMPDIR/filelist-$_pkgname-old"
bsdtar tf "$pkgfile" | sort > "$TEMPDIR/filelist-$_pkgname"
sdiff -s "$TEMPDIR/filelist-$_pkgname-old" "$TEMPDIR/filelist-$_pkgname"
find-libprovides "$TEMPDIR/$oldpkg" 2>/dev/null | sort > "$TEMPDIR/libraries-$_pkgname-old"
find-libprovides "$pkgfile" 2>/dev/null | sort > "$TEMPDIR/libraries-$_pkgname"
if ! diff_output="$(sdiff -s "$TEMPDIR/libraries-$_pkgname-old" "$TEMPDIR/libraries-$_pkgname")"; then
msg "Sonames differ in %s!" "$_pkgname"
echo "$diff_output"
else
msg "No soname differences for %s" "$_pkgname."
fi
2014-10-04 00:46:40 +02:00
done