summaryrefslogtreecommitdiff
path: root/main/apk-tools/APKBUILD
blob: 1d1b59c5aca381ac9951255c93478484d00f3c57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=apk-tools
pkgver=2.12.10
pkgrel=1
pkgdesc="Alpine Package Keeper - package manager for alpine"
arch="all"
url="https://gitlab.alpinelinux.org/alpine/apk-tools"
license="GPL-2.0-only"
subpackages="$pkgname-dbg $pkgname-dev $pkgname-static $pkgname-doc $pkgname-zsh-completion"
# Musl 1.2 introduced new ABI for time64 => upgrading apk-tools
# while staying on musl <1.2 causes missing symbols
depends="musl>=1.2"
makedepends_build="openssl>3 lua5.3 lua5.3-lzlib scdoc"
makedepends_host="zlib-dev openssl-dev zlib-static openssl-libs-static linux-headers"
makedepends="$makedepends_build $makedepends_host"
_lua="no"
if [ "$CBUILD" = "$CHOST" ]; then
	_lua="lua5.3"
	subpackages="$subpackages $_lua-apk:luaapk"
	makedepends="$makedepends $_lua-dev"

	# ca-certificates-bundle needed for https certificate validation
	depends="$depends ca-certificates-bundle"
fi
source="https://gitlab.alpinelinux.org/alpine/apk-tools/-/archive/v$pkgver/apk-tools-v$pkgver.tar.gz
	increase-index-meta-buffer.patch
	_apk
	"
builddir="$srcdir/$pkgname-v$pkgver"

# secfixes:
#   2.12.6-r0:
#     - CVE-2021-36159
#   2.12.5-r0:
#     - CVE-2021-30139

prepare() {
	default_prepare
	sed -i -e 's:-Werror::' Make.rules
	echo "FULL_VERSION=$pkgver-r$pkgrel" > config.mk
}

build() {
	make LUA="$_lua"
	make static LUA="$_lua"
}

check() {
	make check LUA="$_lua"
}

package() {
	make DESTDIR="$pkgdir" LUA="$_lua" install
	install -d "$pkgdir"/var/lib/apk \
		"$pkgdir"/lib/apk/exec \
		"$pkgdir"/etc/apk/keys \
		"$pkgdir"/etc/apk/protected_paths.d

	install -Dm644 "$srcdir"/_apk "$pkgdir"/usr/share/zsh/site-functions/_apk
	rm -r "$pkgdir"/usr/share/doc
}

static() {
	pkgdesc="Alpine Package Keeper - static binary"
	install -Dm755 "$builddir"/src/apk.static \
		"$subpkgdir"/sbin/apk.static

	# lets sign the static binary so it can be vefified from distros
	# that does not have apk-tools
	local abuild_conf=${ABUILD_CONF:-"/etc/abuild.conf"}
	local abuild_home=${ABUILD_USERDIR:-"$HOME/.abuild"}
	local abuild_userconf=${ABUILD_USERCONF:-"$abuild_home/abuild.conf"}
	[ -f "$abuild_userconf" ] && . "$abuild_userconf"
	local privkey="$PACKAGER_PRIVKEY"
	local pubkey=${PACKAGER_PUBKEY:-"$privkey.pub"}
	local keyname=${pubkey##*/}
	${CROSS_COMPILE}strip "$subpkgdir"/sbin/apk.static
	openssl dgst -sha1 -sign "$privkey" \
		-out "$subpkgdir"/sbin/apk.static.SIGN.RSA.$keyname \
		"$subpkgdir"/sbin/apk.static
}

luaapk() {
	pkgdesc="Lua module for apk-tools"
	mkdir -p "$subpkgdir"/usr/
	mv "$pkgdir"/usr/lib "$subpkgdir"/usr/lib/
}

sha512sums="
7be1a659e58ced1c2be3d058127391b92078a3560746149e1b53bf7b877ad5ded755e9a7cf2a68d8cdd49bfaf10afb7dfe361ef8ae9590aede8ce422c85ea389  apk-tools-v2.12.10.tar.gz
3807fe95357855a8b682a13dc6178db9d0396ed905bee694ef923867b1f79c61801ba4d4240adeb27825bc472006a74a5e7898b4683c548ee826e825710ce3e1  increase-index-meta-buffer.patch
7870676720f5007eee9482786e02246f8e3474afb90e76c9c83aebe914747a8e007b5d2eed6441933f4922024b3f0664db270f21981ad6c2db877a110b0cd79e  _apk
"