common/hooks: new hook to generate 32bit pkgs for x86_64 (WIP).
This commit is contained in:
parent
dd86f41ce0
commit
908af511f9
|
@ -0,0 +1,78 @@
|
||||||
|
# This hook creates a new PKGDESTDIR with 32bit libraries for x86_64.
|
||||||
|
#
|
||||||
|
# XXX remaining issues:
|
||||||
|
# - Conditionalized for now with "lib32" template var.
|
||||||
|
# - due to ${pkgname} -> ${pkgname}32 renaming, some pkgs have wrong deps
|
||||||
|
# (noarch pkgs, dependencies without shlibs).
|
||||||
|
|
||||||
|
hook() {
|
||||||
|
local destdir32=${XBPS_DESTDIR}/${pkgname}32-${version}
|
||||||
|
|
||||||
|
if [ -z "$lib32" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# This hook will only work when building for x86.
|
||||||
|
if [ "$XBPS_MACHINE" != "i686" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# Ignore noarch pkgs.
|
||||||
|
if [ -n "$noarch" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
# If /usr/lib does not exist don't continue...
|
||||||
|
if [ ! -d ${PKGDESTDIR}/usr/lib ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
mkdir -p ${destdir32}/usr/lib32
|
||||||
|
cp -a ${PKGDESTDIR}/usr/lib/* ${destdir32}/usr/lib32
|
||||||
|
|
||||||
|
# Only keep shared libs, static libs, and pkg-config files.
|
||||||
|
find "${destdir32}" -not \( \
|
||||||
|
-name '*.pc' -or \
|
||||||
|
-name '*.so' -or \
|
||||||
|
-name '*.so.*' -or \
|
||||||
|
-name '*.a' -or \
|
||||||
|
-name '*.la' -or \
|
||||||
|
-type d \
|
||||||
|
\) -delete
|
||||||
|
|
||||||
|
# Remove empty dirs.
|
||||||
|
for f in $(find ${destdir32} -type d -empty|sort -r); do
|
||||||
|
_dir="${f##${destdir32}}"
|
||||||
|
[ -z "${_dir}" ] && continue
|
||||||
|
rmdir --ignore-fail-on-non-empty -p "$f" &>/dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
# Switch pkg-config files to lib32.
|
||||||
|
if [ -d ${destdir32}/usr/lib32/pkgconfig ]; then
|
||||||
|
sed -e 's,/usr/lib,/usr/lib32,g' \
|
||||||
|
-e 's,${exec_prefix}/lib,${exec_prefix}/lib32,g' \
|
||||||
|
-i ${destdir32}/usr/lib32/pkgconfig/*.pc
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the rdeps file exist (runtime deps), copy and then modify it for
|
||||||
|
# 32bit dependencies.
|
||||||
|
trap - ERR
|
||||||
|
|
||||||
|
if [ -s "$PKGDESTDIR/rdeps" ]; then
|
||||||
|
: > $destdir32/rdeps
|
||||||
|
for f in $(cat ${PKGDESTDIR}/rdeps); do
|
||||||
|
pkgn="$($XBPS_UHELPER_CMD getpkgdepname $f)"
|
||||||
|
if [ -z "${pkgn}" ]; then
|
||||||
|
pkgn="$($XBPS_UHELPER_CMD getpkgname $f)"
|
||||||
|
if [ -z "${pkgn}" ]; then
|
||||||
|
msg_error "$pkgver: invalid dependency $f\n"
|
||||||
|
fi
|
||||||
|
pkgv="$($XBPS_UHELPER_CMD getpkgversion ${f})"
|
||||||
|
else
|
||||||
|
pkgv="$($XBPS_UHELPER_CMD getpkgdepversion ${f})"
|
||||||
|
fi
|
||||||
|
echo "${pkgn}32${pkgv}" >> $destdir32/rdeps
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If it's a development pkg add a dependency to the 64bit pkg.
|
||||||
|
if [[ $pkgname =~ '-devel' ]]; then
|
||||||
|
echo "${pkgver}" >> $destdir32/rdeps
|
||||||
|
fi
|
||||||
|
}
|
|
@ -1,12 +1,15 @@
|
||||||
# This hook registers a XBPS binary package into the specified local repository.
|
# This hook registers a XBPS binary package into the specified local repository.
|
||||||
|
|
||||||
registerpkg() {
|
registerpkg() {
|
||||||
local repo="$1" pkg="$2"
|
local repo="$1" pkg="$2" arch="$3"
|
||||||
|
|
||||||
if [ ! -f ${repo}/${pkg} ]; then
|
if [ ! -f ${repo}/${pkg} ]; then
|
||||||
msg_error "Unexistent binary package ${repo}/${pkg}!\n"
|
msg_error "Unexistent binary package ${repo}/${pkg}!\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${arch}" ]; then
|
||||||
|
export XBPS_TARGET_ARCH=${arch}
|
||||||
|
fi
|
||||||
msg_normal "Registering ${pkg} into ${repo} ...\n"
|
msg_normal "Registering ${pkg} into ${repo} ...\n"
|
||||||
|
|
||||||
if [ -n "$XBPS_CROSS_BUILD" ]; then
|
if [ -n "$XBPS_CROSS_BUILD" ]; then
|
||||||
|
@ -14,6 +17,7 @@ registerpkg() {
|
||||||
else
|
else
|
||||||
$XBPS_RINDEX_CMD ${XBPS_BUILD_FORCEMODE:+-f} -a ${repo}/${pkg}
|
$XBPS_RINDEX_CMD ${XBPS_BUILD_FORCEMODE:+-f} -a ${repo}/${pkg}
|
||||||
fi
|
fi
|
||||||
|
unset XBPS_TARGET_ARCH
|
||||||
}
|
}
|
||||||
|
|
||||||
hook() {
|
hook() {
|
||||||
|
@ -35,6 +39,7 @@ hook() {
|
||||||
pkgdir=$XBPS_REPOSITORY
|
pkgdir=$XBPS_REPOSITORY
|
||||||
fi
|
fi
|
||||||
binpkg=${pkgver}.${arch}.xbps
|
binpkg=${pkgver}.${arch}.xbps
|
||||||
|
binpkg32=${pkgname}32-${version}_${revision}.x86_64.xbps
|
||||||
binpkg_dbg=${pkgname}-dbg-${version}_${revision}.${arch}.xbps
|
binpkg_dbg=${pkgname}-dbg-${version}_${revision}.${arch}.xbps
|
||||||
|
|
||||||
# Register binpkg.
|
# Register binpkg.
|
||||||
|
@ -46,4 +51,9 @@ hook() {
|
||||||
if [ -f ${pkgdir}/${binpkg_dbg} ]; then
|
if [ -f ${pkgdir}/${binpkg_dbg} ]; then
|
||||||
registerpkg ${pkgdir} ${binpkg_dbg}
|
registerpkg ${pkgdir} ${binpkg_dbg}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Register 32bit binpkg if it exists.
|
||||||
|
if [ -f ${pkgdir}/${binpkg32} ]; then
|
||||||
|
registerpkg ${pkgdir} ${binpkg32} x86_64
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,4 +143,12 @@ hook() {
|
||||||
PKGDESTDIR="${XBPS_DESTDIR}/${XBPS_CROSS_TRIPLET}/${pkgname}-dbg-${version}"
|
PKGDESTDIR="${XBPS_DESTDIR}/${XBPS_CROSS_TRIPLET}/${pkgname}-dbg-${version}"
|
||||||
genpkg ${repo} ${arch} "${_desc}" ${_pkgver} ${binpkg}
|
genpkg ${repo} ${arch} "${_desc}" ${_pkgver} ${binpkg}
|
||||||
fi
|
fi
|
||||||
|
# Generate 32bit pkg.
|
||||||
|
if [ -d "${XBPS_DESTDIR}/${pkgname}32-${version}" ]; then
|
||||||
|
_pkgver=${pkgname}32-${version}_${revision}
|
||||||
|
_desc="${short_desc} (32bit)"
|
||||||
|
binpkg=${_pkgver}.x86_64.xbps
|
||||||
|
PKGDESTDIR="${XBPS_DESTDIR}/${pkgname}32-${version}"
|
||||||
|
genpkg ${repo} x86_64 "${_desc}" ${_pkgver} ${binpkg}
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue