limine: update to 8.6.0.
[void-pkg.git] / common / hooks / post-install / 80-prepare-32bit.sh
blob4bc0bde0f76f53203f3a52115724662d0a5dca4e
1 # This hook creates a new PKGDESTDIR with 32bit files for x86_64.
3 # Variables that can be used in templates:
4 # - lib32depends: if set, 32bit pkg will use this rather than "depends".
5 # - lib32disabled: if set, no 32bit pkg will be created.
6 # - lib32files: additional files to add to the 32bit pkg (abs paths, separated by blanks).
7 # - lib32symlinks: makes a symlink from lib32 to lib of the specified file (basename).
8 # - lib32mode:
9 # * if unset only files for libraries will be copied.
10 # * if set to "full" all files will be copied.
12 hook() {
13 local destdir32=${XBPS_DESTDIR}/${pkgname}-32bit-${version}
15 # By default always enabled unless "lib32disabled" is set.
16 if [ -n "$lib32disabled" ]; then
17 return
19 # This hook will only work when building for x86.
20 if [ "$XBPS_TARGET_MACHINE" != "i686" ]; then
21 return
23 if [ -z "$lib32mode" ]; then
24 # Library mode, copy only relevant files to new destdir.
26 # If /usr/lib does not exist don't continue...
27 # except for devel packages, for which empty 32bit package will be created
28 if ! [ -d ${PKGDESTDIR}/usr/lib ] && ! [[ ${pkgname} == *-devel ]]; then
29 return
32 mkdir -p ${destdir32}/usr/lib32
33 if [ -d ${PKGDESTDIR}/usr/lib ]; then
34 cp -a ${PKGDESTDIR}/usr/lib/* ${destdir32}/usr/lib32
37 # Only keep shared libs, static libs, and pkg-config files.
38 find "${destdir32}" -not \( \
39 -name '*.pc' -or \
40 -name '*.so' -or \
41 -name '*.so.*' -or \
42 -name '*.a' -or \
43 -name '*.la' -or \
44 -name '*.o' -or \
45 -type d \
46 \) -delete
48 # Remove empty dirs.
49 while IFS= read -r -d '' f; do
50 _dir="${f##${destdir32}}"
51 [ -z "${_dir}" ] && continue
52 rmdir --ignore-fail-on-non-empty -p "$f" &>/dev/null
53 done < <(find ${destdir32} -type d -empty -print0 | sort -uz)
55 # Switch pkg-config files to lib32.
56 if [ -d ${destdir32}/usr/lib32/pkgconfig ]; then
57 sed -e 's,/usr/lib$,/usr/lib32,g' \
58 -e 's,${exec_prefix}/lib$,${exec_prefix}/lib32,g' \
59 -i ${destdir32}/usr/lib32/pkgconfig/*.pc
61 elif [ "$lib32mode" = "full" ]; then
62 # Full 32bit mode; copy everything to new destdir.
63 mkdir -p ${destdir32}
64 cp -a ${PKGDESTDIR}/. ${destdir32}/
65 # remove symlink
66 if [ -h ${destdir32}/usr/lib32 ]; then
67 rm ${destdir32}/usr/lib32
69 # if /usr/lib dir exists move it to lib32.
70 if [ -d ${destdir32}/usr/lib ]; then
71 mv ${destdir32}/usr/lib ${destdir32}/usr/lib32
74 if [[ ${pkgname} == *-devel ]]; then
75 mkdir -p ${destdir32}
78 if [ ! -d ${destdir32} ]; then
79 return
82 # Also install additional files set via "lib32files".
83 for f in ${lib32files}; do
84 echo "$pkgver: installing additional files: $f ..."
85 _targetdir=${destdir32}/${f%/*}/
86 mkdir -p ${_targetdir/\/usr\/lib/\/usr\/lib32}
87 cp -a ${PKGDESTDIR}/${f} ${_targetdir/\/usr\/lib/\/usr\/lib32}
88 done
90 # Additional symlinks to the native libdir.
91 for f in ${lib32symlinks}; do
92 echo "$pkgver: symlinking $f to the native libdir..."
93 if [ "${f%/*}" != "${f}" ]; then
94 mkdir -p ${destdir32}/usr/lib{,32}/${f%/*}/
95 else
96 mkdir -p ${destdir32}/usr/lib{,32}/
98 ln -sfr ${destdir32}/usr/lib32/$f ${destdir32}/usr/lib/$f
99 done