summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2012-12-30 14:09:57 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2012-12-30 14:13:42 +0000
commit7ac5bd33b35809af335458664d580be072cc3617 (patch)
treea32a1e709f6bec8ab8aff2eea3633dd06bbf3d20
parent85cd8c961d30e08ac437c4338036b399ee57716e (diff)
downloadabuild-7ac5bd33b35809af335458664d580be072cc3617.tar.bz2
abuild-7ac5bd33b35809af335458664d580be072cc3617.tar.xz
checkapk: new tool
Tool to help find ABI breakages in package upgrades
-rw-r--r--.gitignore1
-rw-r--r--Makefile2
-rw-r--r--checkapk.in74
3 files changed, 76 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index b778db9..0adef34 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ newapkbuild
abump
abuild-tar
apkgrel
+checkapk
diff --git a/Makefile b/Makefile
index 959845e..0bb4b37 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ LUA_VERSION = 5.1
LUA_SHAREDIR ?= $(prefix)/share/lua/$(LUA_VERSION)/
SCRIPTS := abuild buildrepo abuild-keygen abuild-sign newapkbuild \
- abump apkgrel ap buildlab apkbuild-cpan
+ abump apkgrel ap buildlab apkbuild-cpan checkapk
USR_BIN_FILES := $(SCRIPTS) abuild-tar abuild-sudo
SAMPLES := sample.APKBUILD sample.initd sample.confd \
sample.pre-install sample.post-install
diff --git a/checkapk.in b/checkapk.in
new file mode 100644
index 0000000..8723404
--- /dev/null
+++ b/checkapk.in
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+die() {
+ echo "$@" >&2
+ exit 1
+}
+
+msg() {
+ echo "$@"
+}
+
+have_abuild_conf=
+
+for conf in /etc/abuild.conf ~/.abuild/abuild.conf; do
+ if [ -f "$conf" ]; then
+ . $conf && have_abuild_conf=yes
+ fi
+done
+
+[ -z "$have_abuild_conf" ] && die "no abuild.conf found"
+
+if ! [ -f APKBUILD ]; then
+ die 'This must be run in the directory of a built package.'
+fi
+
+. ./APKBUILD
+
+startdir="$PWD"
+tmpdir=$(mktemp -d -t checkpkg-script.XXXXXX)
+cd "$tmpdir" || die "Failed to create temp dir"
+
+for i in $pkgname $subpackages; do
+ _pkgname=${i%:*}
+ pkg=${_pkgname}-$pkgver-r$pkgrel
+ pkgfile=${pkg}.apk
+ repo=${startdir##*/}
+
+ for filepath in "$PKGDEST"/$pkgfile "$REPODEST"/$repo/$pkgfile "$startdir"/$pkgfile; do
+ if [ -f "$filepath" ]; then
+ break
+ fi
+ done
+ [ -f "$filepath" ] || die "could not find $pkgfile"
+
+ # generate a temp repositories file with only the http repos
+ grep ^http: /etc/apk/repositories > $tmpdir/repositories
+
+ oldpkg=$(apk fetch --repositories-file $tmpdir/repositories --simulate 2>&1 | sed 's/^Downloading //')
+ if [ "${oldpkg}" = "${pkg}" ]; then
+ die "The built package ($_pkgname) is the one in the repo right now!"
+ fi
+
+ apk fetch --repositories-file $tmpdir/repositories --stdout $_pkgname \
+ | tar -zt | grep -v '^\.SIGN\.' | sort > filelist-$_pkgname-old \
+ || die "Failed to download old pkg. Maybe run 'apk update'?"
+
+ 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"