2014-03-08 10:36:51 +00:00
|
|
|
# This hook creates a new PKGDESTDIR with 32bit files for x86_64.
|
|
|
|
#
|
|
|
|
# Variables that can be used in templates:
|
|
|
|
# - lib32depends: if set, 32bit pkg will use this rather than "depends".
|
|
|
|
# - lib32disabled: if set, no 32bit pkg will be created.
|
2014-03-09 10:23:58 +00:00
|
|
|
# - lib32files: additional files to add to the 32bit pkg (abs paths, separated by blanks).
|
2015-01-28 15:29:45 +00:00
|
|
|
# - lib32symlinks: makes a symlink from lib32 to lib of the specified file (basename).
|
2014-03-08 10:36:51 +00:00
|
|
|
# - lib32mode:
|
|
|
|
# * if unset only files for libraries will be copied.
|
|
|
|
# * if set to "full" all files will be copied.
|
2014-03-02 11:26:24 +00:00
|
|
|
|
|
|
|
hook() {
|
2014-03-06 20:03:23 +00:00
|
|
|
local destdir32=${XBPS_DESTDIR}/${pkgname}-32bit-${version}
|
2014-03-02 11:26:24 +00:00
|
|
|
|
2014-03-08 10:36:51 +00:00
|
|
|
# By default always enabled unless "lib32disabled" is set.
|
|
|
|
if [ -n "$lib32disabled" ]; then
|
2014-03-02 11:26:24 +00:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
# This hook will only work when building for x86.
|
2014-03-07 08:49:41 +00:00
|
|
|
if [ "$XBPS_TARGET_MACHINE" != "i686" ]; then
|
2014-03-02 11:26:24 +00:00
|
|
|
return
|
|
|
|
fi
|
2014-03-08 10:36:51 +00:00
|
|
|
if [ -z "$lib32mode" ]; then
|
|
|
|
# Library mode, copy only relevant files to new destdir.
|
|
|
|
#
|
|
|
|
# If /usr/lib does not exist don't continue...
|
2021-05-29 17:43:09 +00:00
|
|
|
# except for devel packages, for which empty 32bit package will be created
|
|
|
|
if ! [ -d ${PKGDESTDIR}/usr/lib ] && ! [[ ${pkgname} == *-devel ]]; then
|
2014-03-08 10:36:51 +00:00
|
|
|
return
|
|
|
|
fi
|
2021-05-29 17:43:09 +00:00
|
|
|
|
2014-03-08 10:36:51 +00:00
|
|
|
mkdir -p ${destdir32}/usr/lib32
|
2021-05-29 17:43:09 +00:00
|
|
|
if [ -d ${PKGDESTDIR}/usr/lib ]; then
|
|
|
|
cp -a ${PKGDESTDIR}/usr/lib/* ${destdir32}/usr/lib32
|
|
|
|
fi
|
2014-03-02 11:26:24 +00:00
|
|
|
|
2014-03-08 10:36:51 +00:00
|
|
|
# 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 \
|
|
|
|
-name '*.o' -or \
|
|
|
|
-type d \
|
|
|
|
\) -delete
|
2014-03-02 11:26:24 +00:00
|
|
|
|
2014-03-08 10:36:51 +00:00
|
|
|
# Remove empty dirs.
|
2019-04-06 14:13:48 +00:00
|
|
|
while IFS= read -r -d '' f; do
|
2014-03-08 10:36:51 +00:00
|
|
|
_dir="${f##${destdir32}}"
|
|
|
|
[ -z "${_dir}" ] && continue
|
|
|
|
rmdir --ignore-fail-on-non-empty -p "$f" &>/dev/null
|
2019-04-06 14:13:48 +00:00
|
|
|
done < <(find ${destdir32} -type d -empty -print0 | sort -uz)
|
2014-03-02 11:26:24 +00:00
|
|
|
|
2014-03-08 10:36:51 +00:00
|
|
|
# Switch pkg-config files to lib32.
|
|
|
|
if [ -d ${destdir32}/usr/lib32/pkgconfig ]; then
|
2014-08-18 08:54:33 +00:00
|
|
|
sed -e 's,/usr/lib$,/usr/lib32,g' \
|
|
|
|
-e 's,${exec_prefix}/lib$,${exec_prefix}/lib32,g' \
|
2014-03-08 10:36:51 +00:00
|
|
|
-i ${destdir32}/usr/lib32/pkgconfig/*.pc
|
|
|
|
fi
|
|
|
|
elif [ "$lib32mode" = "full" ]; then
|
|
|
|
# Full 32bit mode; copy everything to new destdir.
|
|
|
|
mkdir -p ${destdir32}
|
|
|
|
cp -a ${PKGDESTDIR}/* ${destdir32}/
|
2014-05-27 16:48:18 +00:00
|
|
|
# remove symlink
|
2014-05-28 10:41:25 +00:00
|
|
|
if [ -h ${destdir32}/usr/lib32 ]; then
|
|
|
|
rm ${destdir32}/usr/lib32
|
|
|
|
fi
|
|
|
|
# if /usr/lib dir exists move it to lib32.
|
|
|
|
if [ -d ${destdir32}/usr/lib ]; then
|
|
|
|
mv ${destdir32}/usr/lib ${destdir32}/usr/lib32
|
|
|
|
fi
|
2014-03-08 10:36:51 +00:00
|
|
|
fi
|
2021-05-29 17:43:09 +00:00
|
|
|
if [[ ${pkgname} == *-devel ]]; then
|
|
|
|
mkdir -p ${destdir32}
|
|
|
|
fi
|
2014-03-07 08:49:41 +00:00
|
|
|
if [ ! -d ${destdir32} ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2014-03-02 11:26:24 +00:00
|
|
|
# If the rdeps file exist (runtime deps), copy and then modify it for
|
|
|
|
# 32bit dependencies.
|
|
|
|
trap - ERR
|
|
|
|
|
2014-03-06 20:03:23 +00:00
|
|
|
: > ${destdir32}/rdeps
|
|
|
|
|
2014-03-02 11:26:24 +00:00
|
|
|
if [ -s "$PKGDESTDIR/rdeps" ]; then
|
2014-03-08 10:36:51 +00:00
|
|
|
if [ -n "$lib32depends" ]; then
|
|
|
|
_deps="${lib32depends}"
|
|
|
|
else
|
2019-04-13 20:36:13 +00:00
|
|
|
_deps="$(<${PKGDESTDIR}/rdeps)"
|
2014-03-08 10:36:51 +00:00
|
|
|
fi
|
|
|
|
for f in ${_deps}; do
|
2021-01-20 11:55:11 +00:00
|
|
|
unset found pkgn pkgv _shprovides
|
2014-03-08 10:36:51 +00:00
|
|
|
|
2014-03-02 11:26:24 +00:00
|
|
|
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
|
2014-03-06 20:03:23 +00:00
|
|
|
pkgv="-$($XBPS_UHELPER_CMD getpkgversion ${f})"
|
2014-03-02 11:26:24 +00:00
|
|
|
else
|
|
|
|
pkgv="$($XBPS_UHELPER_CMD getpkgdepversion ${f})"
|
|
|
|
fi
|
2014-08-18 08:12:37 +00:00
|
|
|
# If dependency is a development pkg switch it to 32bit.
|
2021-05-07 19:39:12 +00:00
|
|
|
if [[ $pkgn == *-devel ]]; then
|
2014-08-18 11:43:39 +00:00
|
|
|
echo " RDEP: $f -> ${pkgn}-32bit${pkgv} (development)"
|
2014-08-18 08:12:37 +00:00
|
|
|
printf "${pkgn}-32bit${pkgv} " >> ${destdir32}/rdeps
|
|
|
|
continue
|
|
|
|
fi
|
2014-03-30 11:07:33 +00:00
|
|
|
# If dependency does not have "shlib-provides" do not
|
|
|
|
# change it to 32bit.
|
2014-05-28 13:20:23 +00:00
|
|
|
for x in ${subpackages}; do
|
|
|
|
if [ "$x" = "$pkgn" ]; then
|
|
|
|
found=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ -z "$found" ]; then
|
|
|
|
# Dependency is not a subpkg, check shlib-provides
|
|
|
|
# via binpkgs.
|
2014-08-18 11:43:39 +00:00
|
|
|
_shprovides="$($XBPS_QUERY_CMD -R --property=shlib-provides "$pkgn")"
|
2014-05-28 13:20:23 +00:00
|
|
|
if [ -n "${_shprovides}" ]; then
|
2014-08-18 11:43:39 +00:00
|
|
|
echo " RDEP: $f -> ${pkgn}-32bit${pkgv} (shlib-provides)"
|
2014-05-28 13:20:23 +00:00
|
|
|
printf "${pkgn}-32bit${pkgv} " >> ${destdir32}/rdeps
|
|
|
|
else
|
2014-08-18 11:17:49 +00:00
|
|
|
echo " RDEP: $f -> ${pkgn}${pkgv} (no shlib-provides)"
|
2014-05-28 13:20:23 +00:00
|
|
|
printf "${pkgn}${pkgv} " >> ${destdir32}/rdeps
|
|
|
|
fi
|
|
|
|
else
|
2014-07-23 10:54:37 +00:00
|
|
|
if [ -s ${XBPS_DESTDIR}/${pkgn}-${version}/shlib-provides ]; then
|
2014-07-20 09:18:21 +00:00
|
|
|
# Dependency is a subpkg; check if it provides any shlib
|
|
|
|
# and convert to 32bit if true.
|
2014-08-18 11:43:39 +00:00
|
|
|
echo " RDEP: $f -> ${pkgn}-32bit${pkgv} (subpkg, shlib-provides)"
|
2014-07-20 09:18:21 +00:00
|
|
|
printf "${pkgn}-32bit${pkgv} " >> ${destdir32}/rdeps
|
|
|
|
else
|
2014-08-18 11:17:49 +00:00
|
|
|
echo " RDEP: $f -> ${pkgn}${pkgv} (subpkg, no shlib-provides)"
|
2014-07-20 09:18:21 +00:00
|
|
|
printf "${pkgn}${pkgv} " >> ${destdir32}/rdeps
|
|
|
|
fi
|
2014-03-30 11:07:33 +00:00
|
|
|
fi
|
2014-03-02 11:26:24 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2014-03-09 10:23:58 +00:00
|
|
|
# Also install additional files set via "lib32files".
|
|
|
|
for f in ${lib32files}; do
|
|
|
|
echo "$pkgver: installing additional files: $f ..."
|
2019-04-13 20:47:41 +00:00
|
|
|
_targetdir=${destdir32}/${f%/*}/
|
2015-01-13 14:51:01 +00:00
|
|
|
mkdir -p ${_targetdir/\/usr\/lib/\/usr\/lib32}
|
|
|
|
cp -a ${PKGDESTDIR}/${f} ${_targetdir/\/usr\/lib/\/usr\/lib32}
|
2014-03-09 10:23:58 +00:00
|
|
|
done
|
2015-01-28 15:29:45 +00:00
|
|
|
# Additional symlinks to the native libdir.
|
|
|
|
for f in ${lib32symlinks}; do
|
|
|
|
echo "$pkgver: symlinking $f to the native libdir..."
|
2019-05-28 13:11:37 +00:00
|
|
|
if [ "${f%/*}" != "${f}" ]; then
|
|
|
|
mkdir -p ${destdir32}/usr/lib{,32}/${f%/*}/
|
|
|
|
else
|
|
|
|
mkdir -p ${destdir32}/usr/lib{,32}/
|
|
|
|
fi
|
2015-01-28 15:29:45 +00:00
|
|
|
ln -sfr ${destdir32}/usr/lib32/$f ${destdir32}/usr/lib/$f
|
|
|
|
done
|
2014-03-02 11:26:24 +00:00
|
|
|
# If it's a development pkg add a dependency to the 64bit pkg.
|
2021-05-07 19:39:12 +00:00
|
|
|
if [[ $pkgn == *-devel ]]; then
|
2014-08-18 11:11:46 +00:00
|
|
|
echo " RDEP: ${pkgver}"
|
2014-03-06 20:03:23 +00:00
|
|
|
printf "${pkgver} " >> ${destdir32}/rdeps
|
2014-03-02 11:26:24 +00:00
|
|
|
fi
|
2014-03-06 20:03:23 +00:00
|
|
|
printf "\n" >> ${destdir32}/rdeps
|
2014-03-02 11:26:24 +00:00
|
|
|
}
|