| 1 | # Maintainer: Natanael Copa <[email protected]> |
| 2 | pkgname=apk-tools |
| 3 | pkgver=3.0.8 |
| 4 | pkgrel=0 |
| 5 | pkgdesc="Alpine Package Keeper - package manager for alpine" |
| 6 | arch="all" |
| 7 | url="https://gitlab.alpinelinux.org/alpine/apk-tools" |
| 8 | license="GPL-2.0-only" |
| 9 | subpackages="$pkgname-dbg $pkgname-dev $pkgname-static $pkgname-doc $pkgname-bash-completion $pkgname-zsh-completion libapk" |
| 10 | # Musl 1.2 introduced new ABI for time64 => upgrading apk-tools |
| 11 | # while staying on musl <1.2 causes missing symbols |
| 12 | # starting with musl 1.2.3_git (pre 1.2.3), we added DT_RELR |
| 13 | # it is possible for old systems to upgrade, and apk-tools would upgrade first, |
| 14 | # which would upgrade to a binary that cannot run until musl is upgraded. |
| 15 | # forcing this constraint makes apk upgrade musl as part of the 'critical' transaction, |
| 16 | # and update musl first. |
| 17 | # openssl 3.5(?) introduced new symbols: |
| 18 | # https://gitlab.alpinelinux.org/alpine/aports/-/issues/17199 |
| 19 | depends=" |
| 20 | musl>=1.2.3_git20230424 |
| 21 | libcrypto3>=3.5 |
| 22 | libapk=$pkgver-r$pkgrel |
| 23 | " |
| 24 | _lua="5.5" |
| 25 | makedepends_build="meson openssl-dev>=3.5 lua$_lua lua$_lua-lzlib scdoc" |
| 26 | makedepends_host=" |
| 27 | linux-headers |
| 28 | openssl-dev |
| 29 | openssl-libs-static |
| 30 | zlib-dev |
| 31 | zlib-static |
| 32 | " |
| 33 | checkdepends="cmocka-dev" |
| 34 | if [ -z "$BOOTSTRAP" ]; then |
| 35 | subpackages="$subpackages lua$_lua-apk:luaapk py3-apk:pyapk" |
| 36 | makedepends_host="$makedepends_host lua$_lua-dev python3-dev" |
| 37 | |
| 38 | # ca-certificates-bundle needed for https certificate validation |
| 39 | depends="$depends ca-certificates-bundle" |
| 40 | fi |
| 41 | source="https://gitlab.alpinelinux.org/alpine/apk-tools/-/archive/v$pkgver/apk-tools-v$pkgver.tar.gz |
| 42 | repo-hash-sha1.patch |
| 43 | " |
| 44 | builddir="$srcdir/apk-tools-v$pkgver" |
| 45 | |
| 46 | provides="apk-tools3=$pkgver-r$pkgrel" |
| 47 | replaces="apk-tools3" |
| 48 | |
| 49 | # secfixes: |
| 50 | # 2.12.6-r0: |
| 51 | # - CVE-2021-36159 |
| 52 | # 2.12.5-r0: |
| 53 | # - CVE-2021-30139 |
| 54 | |
| 55 | build() { |
| 56 | export VERSION=$pkgver-r$pkgrel |
| 57 | |
| 58 | abuild-meson \ |
| 59 | --auto-features=disabled \ |
| 60 | --bindir=/sbin \ |
| 61 | -Darch="$CARCH" \ |
| 62 | -Ddocs=enabled \ |
| 63 | -Dhelp=enabled \ |
| 64 | -Dlua_version=$_lua \ |
| 65 | -Dzstd=disabled \ |
| 66 | -Dlua="$([ -z "$BOOTSTRAP" ] && echo enabled || echo disabled)" \ |
| 67 | -Dpython="$([ -z "$BOOTSTRAP" ] && echo enabled || echo disabled)" \ |
| 68 | -Dtests="$(want_check && echo enabled || echo disabled)" \ |
| 69 | output |
| 70 | ninja -C output |
| 71 | |
| 72 | abuild-meson \ |
| 73 | --auto-features=disabled \ |
| 74 | -Darch="$CARCH" \ |
| 75 | -Dc_link_args="$LDFLAGS -static" \ |
| 76 | -Ddefault_library=static \ |
| 77 | -Dprefer_static=true \ |
| 78 | output-static |
| 79 | ninja -C output-static src/apk |
| 80 | } |
| 81 | |
| 82 | check() { |
| 83 | meson test --print-errorlogs -C output |
| 84 | } |
| 85 | |
| 86 | package() { |
| 87 | DESTDIR="$pkgdir" meson install --no-rebuild -C output |
| 88 | install -d "$pkgdir"/lib/apk/db \ |
| 89 | "$pkgdir"/lib/apk/exec \ |
| 90 | "$pkgdir"/etc/apk/keys \ |
| 91 | "$pkgdir"/etc/apk/protected_paths.d \ |
| 92 | "$pkgdir"/var/cache/apk |
| 93 | } |
| 94 | |
| 95 | libapk() { |
| 96 | provides="libapk2=$pkgver-r$pkgrel" |
| 97 | depends="" |
| 98 | amove usr/lib/libapk.so.* |
| 99 | } |
| 100 | |
| 101 | static() { |
| 102 | pkgdesc="Alpine Package Keeper - static binary" |
| 103 | depends="" |
| 104 | install -Dm755 "$builddir"/output-static/src/apk \ |
| 105 | "$subpkgdir"/sbin/apk.static |
| 106 | |
| 107 | # lets sign the static binary so it can be vefified from distros |
| 108 | # that does not have apk-tools |
| 109 | local pubkey="${PACKAGER_PUBKEY:-$PACKAGER_PRIVKEY.pub}" |
| 110 | local keyname="${pubkey##*/}" |
| 111 | ${CROSS_COMPILE}strip "$subpkgdir"/sbin/apk.static |
| 112 | openssl dgst -sha1 -sign "$PACKAGER_PRIVKEY" \ |
| 113 | -out "$subpkgdir"/sbin/apk.static.SIGN.RSA."$keyname" \ |
| 114 | "$subpkgdir"/sbin/apk.static |
| 115 | openssl dgst -sha256 -sign "$PACKAGER_PRIVKEY" \ |
| 116 | -out "$subpkgdir"/sbin/apk.static.SIGN.RSA.sha256."$keyname" \ |
| 117 | "$subpkgdir"/sbin/apk.static |
| 118 | } |
| 119 | |
| 120 | luaapk() { |
| 121 | pkgdesc="Lua module for apk-tools" |
| 122 | depends="" |
| 123 | amove usr/lib/lua |
| 124 | } |
| 125 | |
| 126 | pyapk() { |
| 127 | pkgdesc="Python module for apk-tools" |
| 128 | depends="" |
| 129 | amove usr/lib/python* |
| 130 | } |
| 131 | |
| 132 | sha512sums=" |
| 133 | 3616435508dead5240f8d9fe74e87e2aa93262f9e466f50af8f60100e166403393b1e491c115395864d4179b219699831ecb61dc60960b5dfb1f10816d75f95f apk-tools-v3.0.8.tar.gz |
| 134 | 6f6442d73d994964d78f06433a611902cbb066a457f3532544278b1422aa0aa276ccec1f2438ea7e93a8a048d3fdbf72ccd9a79d210f44870fda467bc43cb9fd repo-hash-sha1.patch |
| 135 | " |