void-packages/common/hooks/post-pkg/00-register-pkg.sh
Enno Boland 6eb37e35b2 common: merge only_for_archs and noarch=yes into one.
* noarch=yes is replaced with archs=noarch
* only_for_archs= is renamed to archs=
* archs= allows the use of wildcards and negations; first matching rule applies:
  * archs="*-musl" will build the pkg only for musl-libcs
  * archs="~*-musl" will build the pkg only on non-musl-libc
  * archs="x86_64-musl ~*-musl" will build for x86_64-musl and any non-musl
    arch.
* archs= defaults to "*"
2019-02-15 13:19:44 +01:00

60 lines
1.6 KiB
Bash

# This hook registers a XBPS binary package into the specified local repository.
registerpkg() {
local repo="$1" pkg="$2" arch="$3"
if [ ! -f ${repo}/${pkg} ]; then
msg_error "Unexistent binary package ${repo}/${pkg}!\n"
fi
printf "%s:%s:%s\n" "${arch}" "${repo}" "${pkg}" >> "${XBPS_STATEDIR}/.${sourcepkg}_register_pkg"
}
hook() {
local arch= binpkg= pkgdir=
if [ "${archs// /}" = "noarch" ]; then
arch=noarch
elif [ -n "$XBPS_TARGET_MACHINE" ]; then
arch=$XBPS_TARGET_MACHINE
else
arch=$XBPS_MACHINE
fi
if [ "${archs// /}" != "noarch" -a -z "$XBPS_CROSS_BUILD" -a -n "$XBPS_ARCH" -a "$XBPS_ARCH" != "$XBPS_TARGET_MACHINE" ]; then
arch=${XBPS_ARCH}
fi
if [ -n "$repository" ]; then
pkgdir=$XBPS_REPOSITORY/$repository
else
pkgdir=$XBPS_REPOSITORY
fi
binpkg=${pkgver}.${arch}.xbps
binpkg32=${pkgname}-32bit-${version}_${revision}.x86_64.xbps
binpkg_dbg=${pkgname}-dbg-${version}_${revision}.${arch}.xbps
# Register binpkg.
if [ -f ${pkgdir}/${binpkg} ]; then
registerpkg ${pkgdir} ${binpkg}
fi
# Register -dbg binpkg if it exists.
pkgdir=$XBPS_REPOSITORY/debug
PKGDESTDIR="${XBPS_DESTDIR}/${XBPS_CROSS_TRIPLET}/${pkgname}-dbg-${version}"
if [ -d ${PKGDESTDIR} -a -f ${pkgdir}/${binpkg_dbg} ]; then
registerpkg ${pkgdir} ${binpkg_dbg}
fi
# Register 32bit binpkg if it exists.
if [ "$XBPS_TARGET_MACHINE" != "i686" ]; then
return
fi
if [ -n "$repository" ]; then
pkgdir=$XBPS_REPOSITORY/multilib/$repository
else
pkgdir=$XBPS_REPOSITORY/multilib
fi
PKGDESTDIR="${XBPS_DESTDIR}/${pkgname}-32bit-${version}"
if [ -d ${PKGDESTDIR} -a -f ${pkgdir}/${binpkg32} ]; then
registerpkg ${pkgdir} ${binpkg32} x86_64
fi
}