# Maintainer: Eli Schwartz # All my PKGBUILDs are managed at https://github.com/eli-schwartz/pkgbuilds pkgname=pacman-static pkgver=5.1.2 _cares_ver=1.15.0 _nghttp2_ver=1.35.1 _curlver=7.63.0 _sslver=1.1.1a _xzver=5.2.4 _bzipver=1.0.6 _zstdver=1.3.7 _libarchive_ver=3.3.3 _gpgerrorver=1.33 _libassuanver=2.5.2 _gpgmever=1.12.0 _gnupgver=2.2.12 pkgrel=1 pkgdesc="Statically-compiled pacman (to fix or install systems without libc)" arch=('i686' 'x86_64' 'arm' 'armv6h' 'armv7h' 'aarch64') url="https://www.archlinux.org/pacman/" license=('GPL') depends=('pacman') makedepends=('musl' 'kernel-headers-musl') # pacman source=("https://sources.archlinux.org/other/pacman/pacman-${pkgver}.tar.gz"{,.sig}) validpgpkeys=('6645B0A8C7005E78DB1D7864F99FFE0FEAE999BD' # Allan McRae 'B8151B117037781095514CA7BBDFFC92306B1121') # Andrew Gregory (pacman) # nghttp2 source+=("https://github.com/nghttp2/nghttp2/releases/download/v$_nghttp2_ver/nghttp2-$_nghttp2_ver.tar.xz") # c-ares source+=("https://c-ares.haxx.se/download/c-ares-${_cares_ver}.tar.gz"{,.asc}) validpgpkeys+=('27EDEAF22F3ABCEB50DB9A125CC908FDB71E12C2') # Daniel Stenberg # curl source+=("https://curl.haxx.se/download/curl-${_curlver}.tar.gz"{,.asc} "curl-3399.patch::https://github.com/curl/curl/pull/3399.patch") # openssl source+=("https://www.openssl.org/source/openssl-${_sslver}.tar.gz"{,.asc} "ca-dir.patch") validpgpkeys+=('8657ABB260F056B1E5190839D9C4D26D0E604491') # Matt Caswell # xz source+=("https://tukaani.org/xz/xz-${_xzver}.tar.gz"{,.sig}) validpgpkeys+=('3690C240CE51B4670D30AD1C38EE757D69184620') # Lasse Collin # bzip2 source+=("https://sources.archlinux.org/other/packages/bzip2/bzip2-${_bzipver}.tar.gz") # zstd source+=("https://github.com/facebook/zstd/releases/download/v${_zstdver}/zstd-${_zstdver}.tar.gz") # libgpg-error source+=("https://gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-${_gpgerrorver}.tar.bz2"{,.sig}) validpgpkeys+=('D8692123C4065DEA5E0F3AB5249B39D24F25E3B6' # Werner Koch '031EC2536E580D8EA286A9F22071B08A33BD3F06') # NIIBE Yutaka (GnuPG Release Key) # libassuan source+=("https://gnupg.org/ftp/gcrypt/libassuan/libassuan-${_libassuanver}.tar.bz2"{,.sig}) # gpgme source+=("https://www.gnupg.org/ftp/gcrypt/gpgme/gpgme-${_gpgmever}.tar.bz2"{,.sig}) # libarchive source+=("libarchive-${_libarchive_ver}.tar.gz::https://github.com/libarchive/libarchive/archive/v${_libarchive_ver}.tar.gz") sha512sums=('3c123005587359315ab0c24d50a58d10f365eb92b24840213559cd951c863beaa2e3805bf728975fdae55dc2619e1c2dfeafaef2ee57f3882a30c4d5e8777750' 'SKIP' 'fcd3f79f913afbeee1c75003bb39df918e6122bbf728b3ad4192d5849d8fb96705e04f5505465d63f25a565b2f1da6abd8fabdebb6e3347500f7abd31980861d' 'a1de6c5e7e1a6a13c926aae690e83d5caa51e7313d63da1cf2af6bc757c41d585aad5466bc3ba7b7f7793cb1748fa589f40972b196728851c8b059cfc8c3be50' 'SKIP' '25ad69a1978de2178ac7a456e72152907203931ad895234c14781c27681ea2c5d6669794880c4ebae6e38b8014c6538bc88a6afec2c192210b6d491d60b8f691' 'SKIP' '233ccf215722657f8db5fd8e959836515361aa76bb67ae058ab8d946ae7673e623acb144b72ef429a240075ea23fd57adbbc0248a575537f4fcd18910bac289f' '1523985ba90f38aa91aa6c2d57652f4e243cb2a095ce6336bf34b39b5a9b5b876804299a6825c758b65990e57948da532cca761aa12b10958c97478d04dd6d34' 'SKIP' '3857c298663728a465b5f95a3ef44547efbfb420d755e9dde7f20aa3905171b400e1c126d8db5c2b916c733bbd0724d8753cad16c9baf7b12dcd225a3ee04a97' 'e5bf6eb88365d2dbdc774db49261fb9fae0544ed297891fc20f1ed223f4072cb0357cbd98146ac35b6d29410a12b6739bbd111cd57d4a225bef255ed46988578' 'SKIP' '00ace5438cfa0c577e5f578d8a808613187eff5217c35164ffe044fbafdfec9e98f4192c02a7d67e01e5a5ccced630583ad1003c37697219b0f147343a3fdd12' 'fb9ac61b79b22a628e602e68f7c59c85a00020f7f25b8653076895da7589ca1203adc7fe3d9b865f36648bc30d765b9630cf0955f970596253da74c089b97af1' 'c0396a63ea54e321b207d84fb4eac247ba8a791058db00a8bbf1dd7698c6593b13c77de08fc0971cccd6c3c27925637d1f9fdc59c4cac1344ddfe4c25adc2e42' 'SKIP' '1c6f87e3f785a053e6b736eb3554fa704c798c7078307391ca45961e06d9282c659c8e46d230d1f52e67acc2cc12d841f9ec0d5184443f68555d3f0d240865b3' 'SKIP' 'c228b3df28377df882be536ada56dc9c73150048a58e591aa4495f89c854af95820152cd60139840f994c249e9c7df50d8b89eb9d6dc4ce02aa80bbfebcdd014' 'SKIP' '10063764b610c0c966ba0177cac0d2cb781e297a45545cc8a587741513089af26f40769670894c86e7985b73c47e9cb985253bc3bef3a12fa83fe2a6a30acb6d') export LDFLAGS="$LDFLAGS -static" export CC=musl-gcc export CXX=musl-gcc # https://www.openwall.com/lists/musl/2014/11/05/3 # fstack-protector and musl do not get along but only on i686 if [[ $CARCH = i686 ]]; then # silly build systems have configure checks or buildtime programs that don't CFLAGS but do do CC export CC="musl-gcc -fno-stack-protector" export CXX="musl-gcc -fno-stack-protector" export CFLAGS="${CFLAGS/-fstack-protector-strong/}" export CXXFLAGS="${CXXFLAGS/-fstack-protector-strong/}" fi prepare() { cd "${srcdir}"/libarchive-${_libarchive_ver} autoreconf -fi cd "${srcdir}"/curl-${_curlver} # See https://github.com/curl/curl/issues/3392 patch -p1 -i "${srcdir}"/curl-3399.patch } build() { export PKG_CONFIG_PATH="${srcdir}"/temp/usr/lib/pkgconfig export PATH="${srcdir}/temp/usr/bin:${PATH}" # openssl cd "${srcdir}"/openssl-${_sslver} case ${CARCH} in x86_64) openssltarget='linux-x86_64' optflags='enable-ec_nistp_64_gcc_128' ;; i686) openssltarget='linux-elf' optflags='' ;; arm|armv6h|armv7h) openssltarget='linux-armv4' optflags='' ;; aarch64) openssltarget='linux-aarch64' optflags='no-afalgeng' ;; esac # mark stack as non-executable: http://bugs.archlinux.org/task/12434 ./Configure --prefix="${srcdir}"/temp/usr \ --openssldir=/etc/ssl \ --libdir=lib \ -static \ no-ssl3-method \ ${optflags} \ "${openssltarget}" \ "-Wa,--noexecstack ${CPPFLAGS} ${CFLAGS} ${LDFLAGS}" make build_libs make install_dev # xz cd "${srcdir}"/xz-${_xzver} ./configure --prefix="${srcdir}"/temp/usr \ --disable-shared cd src/liblzma make make install # bzip2 cd "${srcdir}"/bzip2-${_bzipver} sed -i "s|-O2|${CFLAGS}|g" Makefile make libbz2.a install -Dvm644 bzlib.h "${srcdir}"/temp/usr/include/ install -Dvm644 libbz2.a "${srcdir}"/temp/usr/lib/ cd "${srcdir}"/zstd-${_zstdver}/lib make libzstd.a make PREFIX="${srcdir}"/temp/usr install-pc install-static install-includes # libarchive cd "${srcdir}"/libarchive-${_libarchive_ver} CPPFLAGS="-I${srcdir}/temp/usr/include" CFLAGS="-L${srcdir}/temp/usr/lib" \ ./configure --prefix="${srcdir}"/temp/usr \ --without-xml2 \ --without-nettle \ --disable-{bsdtar,bsdcat,bsdcpio} \ --without-expat \ --disable-shared make make install-{includeHEADERS,libLTLIBRARIES,pkgconfigDATA,includeHEADERS} # nghttp2 cd "${srcdir}"/nghttp2-${_nghttp2_ver} ./configure --prefix="${srcdir}"/temp/usr \ --disable-shared \ --disable-examples \ --disable-python-bindings make -C lib make -C lib install # c-ares # needed for curl, which does not use it in the repos # but seems to be needed for static builds cd "${srcdir}"/c-ares-${_cares_ver} ./configure --prefix="${srcdir}"/temp/usr \ --disable-shared make make install-{libcares_laHEADERS,libLTLIBRARIES,pkgconfigDATA} # curl cd "${srcdir}"/curl-${_curlver} # c-ares is not detected via pkg-config :( ./configure --prefix="${srcdir}"/temp/usr \ --disable-shared \ --with-ca-bundle=/etc/ssl/certs/ca-certificates.crt \ --disable-{dict,gopher,imap,imaps,ldap,ldaps,manual,pop3,pop3s,rtsp,scp,sftp,smb,smbs,smtp,smtps,telnet,tftp} \ --without-{brotli,libidn2,librtmp,libssh2} \ --disable-libcurl-option \ --with-ssl \ --enable-ares="${srcdir}"/temp/usr make -C lib make install-pkgconfigDATA make -C lib install make -C include install # libgpg-error cd "${srcdir}"/libgpg-error-${_gpgerrorver} ./configure --prefix="${srcdir}"/temp/usr \ --disable-shared make -C src make -C src install-libLTLIBRARIES install-binSCRIPTS install-nodist_includeHEADERS # libassuan cd "${srcdir}"/libassuan-${_libassuanver} ./configure --prefix="${srcdir}"/temp/usr \ --disable-shared make -C src make -C src install-libLTLIBRARIES install-binSCRIPTS install-nodist_includeHEADERS # gpgme cd "${srcdir}"/gpgme-${_gpgmever} ./configure --prefix="${srcdir}"/temp/usr \ --disable-fd-passing \ --disable-shared \ --disable-languages make -C src make -C src install-libLTLIBRARIES install-binSCRIPTS install-nodist_includeHEADERS # ew libtool rm "${srcdir}"/temp/usr/lib/lib*.la export PKG_CONFIG='pkg-config --static' # Finally, it's a pacman! cd "${srcdir}"/pacman-${pkgver} ./configure --prefix=/usr \ --libdir=/usr/lib/pacman/lib \ --sysconfdir=/etc \ --localstatedir=/var \ --program-suffix=-static \ --with-scriptlet-shell=/usr/bin/bash \ --with-ldconfig=/usr/bin/ldconfig \ --disable-shared \ --disable-doc make V=1 AM_LDFLAGS=-all-static } package() { cd "${srcdir}"/pacman-${pkgver} make -C lib/libalpm DESTDIR="${pkgdir}" install-libLTLIBRARIES install-pkgconfigDATA make -C src/util DESTDIR="${pkgdir}" install make -C src/pacman DESTDIR="${pkgdir}" install-binPROGRAMS cp -a "${srcdir}"/temp/usr/{include,lib} "${pkgdir}"/usr/lib/pacman/ sed -i "s@${srcdir}/temp/usr@/usr/lib/pacman@g" "${pkgdir}"/usr/lib/pacman/lib/pkgconfig/*.pc }