projects/aports·blob v3.3.0_pre1 · refs

94 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
22 Usage: $program
23
24 Run 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)
50trap "rm -rf '$tmpdir'" INT EXIT
51cd "$tmpdir" || die "failed to create temp dir"
52
53for i in $pkgname $subpackages; do
54 _pkgname=${i%%:*}
55 pkg=${_pkgname}-$pkgver-r$pkgrel
56 pkgfile=${pkg}.apk
57 repodir=${startdir%/*}
58 repo=${repodir##*/}
59
60 for filepath in "$PKGDEST"/$pkgfile "$REPODEST"/$repo/$CARCH/$pkgfile "$startdir"/$pkgfile; do
61 if [ -f "$filepath" ]; then
62 break
63 fi
64 done
65 [ -f "$filepath" ] || die "can't find $pkgfile"
66
67 # generate a temp repositories file with only the http(s) repos
68 grep -E "^https?:" /etc/apk/repositories > $tmpdir/repositories
69
70 oldpkg=$(apk fetch --repositories-file $tmpdir/repositories --simulate 2>&1 | sed 's/^Downloading //')
71 if [ "${oldpkg}" = "${pkg}" ]; then
72 die "the built package ($_pkgname) is already in the repo"
73 fi
74
75 apk fetch --quiet --repositories-file $tmpdir/repositories --stdout $_pkgname \
76 | tar -zt | grep -v '^\.SIGN\.' | sort > filelist-$_pkgname-old \
77 || die "failed to download old pkg, maybe run 'apk update'?"
78
79 tar -ztf "$filepath" | grep -v '^\.SIGN\.' | sort > "filelist-$_pkgname"
80
81 diff -u "filelist-$_pkgname-old" "filelist-$_pkgname"
82
83 if diff "filelist-$_pkgname-old" "filelist-$_pkgname" | grep '\.so' > /dev/null 2>&1; then
84 mkdir -p pkg
85 cd pkg
86 tar -zxf "$filepath" > /dev/null
87 diff "../filelist-$_pkgname-old" "../filelist-$_pkgname" | awk '/>.*\.so/{$1 = ""; print $0}' | while read i; do
88 echo "${i}: " "$(objdump -p "$i" | grep SONAME)"
89 done
90 cd ..
91 else
92 msg "No soname differences for $_pkgname."
93 fi
94done