hooks/prepare-32bit: new variables to improve 32bit pkg creation.
- lib32depends: if set, 32bit pkg will use this rather than "depends". - lib32disabled: if set, no 32bit pkg will be created. - lib32mode: * if unset only files for libraries will be copied. * if set to "full" all files will be copied Still not perfect but should be enough to have skype-32bit.
This commit is contained in:
parent
9b369ced1e
commit
e9e8c638a8
|
@ -1,14 +1,21 @@
|
||||||
# This hook creates a new PKGDESTDIR with 32bit libraries for x86_64.
|
# 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.
|
||||||
|
# - lib32mode:
|
||||||
|
# * if unset only files for libraries will be copied.
|
||||||
|
# * if set to "full" all files will be copied.
|
||||||
#
|
#
|
||||||
# XXX remaining issues:
|
# XXX remaining issues:
|
||||||
# - due to ${pkgname} -> ${pkgname}32 renaming, some pkgs have wrong deps
|
# - wrong dependencies in some cases.
|
||||||
# (noarch pkgs, development pkgs, etc).
|
# - no way to specify additional files.
|
||||||
|
|
||||||
hook() {
|
hook() {
|
||||||
local destdir32=${XBPS_DESTDIR}/${pkgname}-32bit-${version}
|
local destdir32=${XBPS_DESTDIR}/${pkgname}-32bit-${version}
|
||||||
|
|
||||||
# By default always enabled unless "lib32_disabled" is set.
|
# By default always enabled unless "lib32disabled" is set.
|
||||||
if [ -n "$lib32_disabled" ]; then
|
if [ -n "$lib32disabled" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
# This hook will only work when building for x86.
|
# This hook will only work when building for x86.
|
||||||
|
@ -19,42 +26,49 @@ hook() {
|
||||||
if [ -n "$noarch" ]; then
|
if [ -n "$noarch" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
# If /usr/lib does not exist don't continue...
|
if [ -z "$lib32mode" ]; then
|
||||||
if [ ! -d ${PKGDESTDIR}/usr/lib ]; then
|
# Library mode, copy only relevant files to new destdir.
|
||||||
return
|
#
|
||||||
|
# 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 \
|
||||||
|
-name '*.o' -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
|
||||||
|
elif [ "$lib32mode" = "full" ]; then
|
||||||
|
# Full 32bit mode; copy everything to new destdir.
|
||||||
|
mkdir -p ${destdir32}
|
||||||
|
cp -a ${PKGDESTDIR}/* ${destdir32}/
|
||||||
fi
|
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 \
|
|
||||||
-name '*.o' -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
|
|
||||||
|
|
||||||
if [ ! -d ${destdir32} ]; then
|
if [ ! -d ${destdir32} ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 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
|
# If the rdeps file exist (runtime deps), copy and then modify it for
|
||||||
# 32bit dependencies.
|
# 32bit dependencies.
|
||||||
trap - ERR
|
trap - ERR
|
||||||
|
@ -62,7 +76,14 @@ hook() {
|
||||||
: > ${destdir32}/rdeps
|
: > ${destdir32}/rdeps
|
||||||
|
|
||||||
if [ -s "$PKGDESTDIR/rdeps" ]; then
|
if [ -s "$PKGDESTDIR/rdeps" ]; then
|
||||||
for f in $(cat ${PKGDESTDIR}/rdeps); do
|
if [ -n "$lib32depends" ]; then
|
||||||
|
_deps="${lib32depends}"
|
||||||
|
else
|
||||||
|
_deps="$(cat ${PKGDESTDIR}/rdeps)"
|
||||||
|
fi
|
||||||
|
for f in ${_deps}; do
|
||||||
|
unset pkgn pkgv _noarch _hasdevel
|
||||||
|
|
||||||
pkgn="$($XBPS_UHELPER_CMD getpkgdepname $f)"
|
pkgn="$($XBPS_UHELPER_CMD getpkgdepname $f)"
|
||||||
if [ -z "${pkgn}" ]; then
|
if [ -z "${pkgn}" ]; then
|
||||||
pkgn="$($XBPS_UHELPER_CMD getpkgname $f)"
|
pkgn="$($XBPS_UHELPER_CMD getpkgname $f)"
|
||||||
|
@ -73,6 +94,12 @@ hook() {
|
||||||
else
|
else
|
||||||
pkgv="$($XBPS_UHELPER_CMD getpkgdepversion ${f})"
|
pkgv="$($XBPS_UHELPER_CMD getpkgdepversion ${f})"
|
||||||
fi
|
fi
|
||||||
|
# If dependency is noarch do not change it to 32bit.
|
||||||
|
_noarch=$($XBPS_QUERY_CMD -R --property=architecture "$f")
|
||||||
|
if [ "${_noarch}" = "noarch" ]; then
|
||||||
|
printf "${pkgn}${pkgv} " >> ${destdir32}/rdeps
|
||||||
|
continue
|
||||||
|
fi
|
||||||
printf "${pkgn}-32bit${pkgv} " >> $destdir32/rdeps
|
printf "${pkgn}-32bit${pkgv} " >> $destdir32/rdeps
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -82,4 +109,6 @@ hook() {
|
||||||
printf "${pkgver} " >> ${destdir32}/rdeps
|
printf "${pkgver} " >> ${destdir32}/rdeps
|
||||||
fi
|
fi
|
||||||
printf "\n" >> ${destdir32}/rdeps
|
printf "\n" >> ${destdir32}/rdeps
|
||||||
|
|
||||||
|
unset lib32depends lib32disabled lib32mode
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue