2012-12-30 14:09:57 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2013-07-05 04:21:12 +00:00
|
|
|
# checkapk - find ABI breakages in package upgrades
|
|
|
|
# Copyright (c) 2012 Natanael Copa <natanael.copa@gmail.com>
|
|
|
|
#
|
|
|
|
# Distributed under GPL-2
|
|
|
|
#
|
|
|
|
|
2013-10-25 07:26:05 +00:00
|
|
|
program_version=@VERSION@
|
2013-07-05 04:21:16 +00:00
|
|
|
datadir=@datadir@
|
|
|
|
|
|
|
|
if ! [ -f "$datadir/functions.sh" ]; then
|
|
|
|
echo "$datadir/functions.sh: not found" >&2
|
2012-12-30 14:09:57 +00:00
|
|
|
exit 1
|
2013-07-05 04:21:16 +00:00
|
|
|
fi
|
|
|
|
. "$datadir/functions.sh"
|
2012-12-30 14:09:57 +00:00
|
|
|
|
|
|
|
|
2013-07-05 04:21:19 +00:00
|
|
|
usage() {
|
2016-08-20 13:16:48 +00:00
|
|
|
cat >&2 <<-__EOF__
|
|
|
|
$program $program_version - find ABI breakages in package upgrades
|
|
|
|
Usage: $program
|
2012-12-30 14:09:57 +00:00
|
|
|
|
2016-08-20 13:16:48 +00:00
|
|
|
Run in the directory of a built package.
|
2012-12-30 14:09:57 +00:00
|
|
|
|
2016-08-20 13:16:48 +00:00
|
|
|
__EOF__
|
2013-07-05 04:21:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
usage
|
|
|
|
exit 2
|
|
|
|
fi
|
2013-07-05 04:21:16 +00:00
|
|
|
|
2013-07-05 04:21:39 +00:00
|
|
|
if ! [ -f "$ABUILD_CONF" ] && ! [ -f "$ABUILD_USERCONF" ]; then
|
2013-07-05 04:21:16 +00:00
|
|
|
die "no abuild.conf found"
|
|
|
|
fi
|
2012-12-30 14:09:57 +00:00
|
|
|
|
|
|
|
if ! [ -f APKBUILD ]; then
|
2013-07-05 04:21:37 +00:00
|
|
|
die 'must be run in the directory of a built package'
|
2012-12-30 14:09:57 +00:00
|
|
|
fi
|
|
|
|
|
2013-10-25 07:19:30 +00:00
|
|
|
if ! [ -n "$CARCH" ]; then
|
|
|
|
die "failed to detect CARCH"
|
|
|
|
fi
|
|
|
|
|
2012-12-30 14:09:57 +00:00
|
|
|
. ./APKBUILD
|
|
|
|
|
|
|
|
startdir="$PWD"
|
|
|
|
tmpdir=$(mktemp -d -t checkpkg-script.XXXXXX)
|
2013-07-05 04:21:37 +00:00
|
|
|
cd "$tmpdir" || die "failed to create temp dir"
|
2012-12-30 14:09:57 +00:00
|
|
|
|
|
|
|
for i in $pkgname $subpackages; do
|
2016-07-27 11:50:15 +00:00
|
|
|
_pkgname=${i%%:*}
|
2012-12-30 14:09:57 +00:00
|
|
|
pkg=${_pkgname}-$pkgver-r$pkgrel
|
|
|
|
pkgfile=${pkg}.apk
|
2013-02-13 07:30:09 +00:00
|
|
|
repodir=${startdir%/*}
|
|
|
|
repo=${repodir##*/}
|
2012-12-30 14:09:57 +00:00
|
|
|
|
2013-02-13 07:30:09 +00:00
|
|
|
for filepath in "$PKGDEST"/$pkgfile "$REPODEST"/$repo/$CARCH/$pkgfile "$startdir"/$pkgfile; do
|
2012-12-30 14:09:57 +00:00
|
|
|
if [ -f "$filepath" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2013-07-05 04:21:37 +00:00
|
|
|
[ -f "$filepath" ] || die "can't find $pkgfile"
|
2012-12-30 14:09:57 +00:00
|
|
|
|
2016-08-09 13:02:17 +00:00
|
|
|
# generate a temp repositories file with only the http(s) repos
|
|
|
|
grep -E "^https?:" /etc/apk/repositories > $tmpdir/repositories
|
2012-12-30 14:09:57 +00:00
|
|
|
|
|
|
|
oldpkg=$(apk fetch --repositories-file $tmpdir/repositories --simulate 2>&1 | sed 's/^Downloading //')
|
|
|
|
if [ "${oldpkg}" = "${pkg}" ]; then
|
2013-07-05 04:21:37 +00:00
|
|
|
die "the built package ($_pkgname) is already in the repo"
|
2012-12-30 14:09:57 +00:00
|
|
|
fi
|
|
|
|
|
2014-01-23 07:25:54 +00:00
|
|
|
apk fetch --quiet --repositories-file $tmpdir/repositories --stdout $_pkgname \
|
2012-12-30 14:09:57 +00:00
|
|
|
| tar -zt | grep -v '^\.SIGN\.' | sort > filelist-$_pkgname-old \
|
2013-07-05 04:21:37 +00:00
|
|
|
|| die "failed to download old pkg, maybe run 'apk update'?"
|
2012-12-30 14:09:57 +00:00
|
|
|
|
|
|
|
tar -ztf "$filepath" | grep -v '^\.SIGN\.' | sort > "filelist-$_pkgname"
|
|
|
|
|
|
|
|
diff -u "filelist-$_pkgname-old" "filelist-$_pkgname"
|
|
|
|
|
|
|
|
if diff "filelist-$_pkgname-old" "filelist-$_pkgname" | grep '\.so' > /dev/null 2>&1; then
|
|
|
|
mkdir -p pkg
|
|
|
|
cd pkg
|
|
|
|
tar -zxf "$filepath" > /dev/null
|
|
|
|
diff "../filelist-$_pkgname-old" "../filelist-$_pkgname" | awk '/>.*\.so/{$1 = ""; print $0}' | while read i; do
|
|
|
|
echo "${i}: " "$(objdump -p "$i" | grep SONAME)"
|
|
|
|
done
|
|
|
|
cd ..
|
|
|
|
else
|
|
|
|
msg "No soname differences for $_pkgname."
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
msg "Files saved to $tmpdir"
|