projects/aports·blob v2.21.0 · refs

95 lines · 2.3 KiB

1#!/bin/sh
2
3# checkapk - find ABI breakages in package upgrades
4# Copyright (c) 2012 Natanael Copa <[email protected]>
5#
6# Distributed under GPL-2
7#
8
9program_version=@VERSION@
10datadir=@datadir@
11
12if ! [ -f "$datadir/functions.sh" ]; then
13 echo "$datadir/functions.sh: not found" >&2
14 exit 1
15fi
16. "$datadir/functions.sh"
17
18
19usage() {
20 cat >&2 <<__EOF__
21$program $program_version - find ABI breakages in package upgrades
22Usage: $program
23
24Run in the directory of a built package.
25
26__EOF__
27}
28
29if [ $# -gt 0 ]; then
30 usage
31 exit 2
32fi
33
34if ! [ -f "$ABUILD_CONF" ] && ! [ -f "$ABUILD_USERCONF" ]; then
35 die "no abuild.conf found"
36fi
37
38if ! [ -f APKBUILD ]; then
39 die 'must be run in the directory of a built package'
40fi
41
42if ! [ -n "$CARCH" ]; then
43 die "failed to detect CARCH"
44fi
45
46. ./APKBUILD
47
48startdir="$PWD"
49tmpdir=$(mktemp -d -t checkpkg-script.XXXXXX)
50cd "$tmpdir" || die "failed to create temp dir"
51
52for i in $pkgname $subpackages; do
53 _pkgname=${i%:*}
54 pkg=${_pkgname}-$pkgver-r$pkgrel
55 pkgfile=${pkg}.apk
56 repodir=${startdir%/*}
57 repo=${repodir##*/}
58
59 for filepath in "$PKGDEST"/$pkgfile "$REPODEST"/$repo/$CARCH/$pkgfile "$startdir"/$pkgfile; do
60 if [ -f "$filepath" ]; then
61 break
62 fi
63 done
64 [ -f "$filepath" ] || die "can't find $pkgfile"
65
66 # generate a temp repositories file with only the http repos
67 grep ^http: /etc/apk/repositories > $tmpdir/repositories
68
69 oldpkg=$(apk fetch --repositories-file $tmpdir/repositories --simulate 2>&1 | sed 's/^Downloading //')
70 if [ "${oldpkg}" = "${pkg}" ]; then
71 die "the built package ($_pkgname) is already in the repo"
72 fi
73
74 apk fetch --quiet --repositories-file $tmpdir/repositories --stdout $_pkgname \
75 | tar -zt | grep -v '^\.SIGN\.' | sort > filelist-$_pkgname-old \
76 || die "failed to download old pkg, maybe run 'apk update'?"
77
78 tar -ztf "$filepath" | grep -v '^\.SIGN\.' | sort > "filelist-$_pkgname"
79
80 diff -u "filelist-$_pkgname-old" "filelist-$_pkgname"
81
82 if diff "filelist-$_pkgname-old" "filelist-$_pkgname" | grep '\.so' > /dev/null 2>&1; then
83 mkdir -p pkg
84 cd pkg
85 tar -zxf "$filepath" > /dev/null
86 diff "../filelist-$_pkgname-old" "../filelist-$_pkgname" | awk '/>.*\.so/{$1 = ""; print $0}' | while read i; do
87 echo "${i}: " "$(objdump -p "$i" | grep SONAME)"
88 done
89 cd ..
90 else
91 msg "No soname differences for $_pkgname."
92 fi
93done
94
95msg "Files saved to $tmpdir"