rio: update to 0.2.0
[void-pkg.git] / common / hooks / post-install / 98-shlib-provides.sh
bloba2ccff794b2e660ca9ba92e552d359b5209185fb
1 # This hook executes the following tasks:
2 # - generates shlib-provides file for xbps-create(1)
4 collect_sonames() {
5 local _destdir="$1" f _soname _fname _pattern
6 local _pattern="^[[:alnum:]]+(.*)+\.so(\.[0-9]+)*$"
7 local _versioned_pattern="^[[:alnum:]]+(.*)+\.so(\.[0-9]+)+$"
8 local _tmpfile=$(mktemp) || exit 1
9 local _mainpkg="$2"
10 local _shlib_dir="${XBPS_STATEDIR}/shlib-provides"
11 local _no_soname=$(mktemp) || exit 1
13 mkdir -p "${_shlib_dir}" || exit 1
14 if [ ! -d ${_destdir} ]; then
15 rm -f ${_tmpfile}
16 rm -f ${_no_soname}
17 return 0
21 # real pkg
22 find ${_destdir} -type f -name "*.so*" | while read f; do
23 _fname="${f##*/}"
24 case "$(file -bi "$f")" in
25 application/x-sharedlib*|application/x-pie-executable*)
26 # shared library
27 _soname=$(${OBJDUMP} -p "$f"|awk '/SONAME/{print $2}')
28 if [ -n "$noshlibprovides" ]; then
29 # register all shared lib for rt-deps between sub-pkg
30 echo "${_fname}" >>${_no_soname}
31 continue
33 # Register all versioned sonames, and
34 # unversioned sonames only when in libdir.
35 if [[ ${_soname} =~ ${_versioned_pattern} ]] ||
36 [[ ${_soname} =~ ${_pattern} &&
37 ( -e ${_destdir}/usr/lib/${_fname} ||
38 -e ${_destdir}/usr/lib32/${_fname} ) ]]; then
39 echo "${_soname}" >> ${_tmpfile}
40 echo " SONAME ${_soname} from ${f##${_destdir}}"
41 else
42 # register all shared lib for rt-deps between sub-pkg
43 echo "${_fname}" >>${_no_soname}
46 esac
47 done
49 for f in ${shlib_provides}; do
50 echo "$f" >> ${_tmpfile}
51 done
52 if [ -s "${_tmpfile}" ]; then
53 tr '\n' ' ' < "${_tmpfile}" > ${_destdir}/shlib-provides
54 echo >> ${_destdir}/shlib-provides
55 if [ "$_mainpkg" ]; then
56 cp "${_tmpfile}" "${_shlib_dir}/${pkgname}.soname"
59 if [ "$_mainpkg" ] && [ -s "${_no_soname}" ]; then
60 mv "${_no_soname}" "${_shlib_dir}/${pkgname}.nosoname"
61 else
62 rm -f ${_no_soname}
64 rm -f ${_tmpfile}
67 hook() {
68 local _destdir32=${XBPS_DESTDIR}/${pkgname}-32bit-${version}
69 local _mainpkg=yes
70 local _pkg
72 case "$pkgname" in
73 *-32bit)
74 _pkgname=${pkgname%-32bit}
75 for _pkg in $sourcepkg $subpackages; do
76 if [ "$_pkg" = "$_pkgname" ]; then
77 _mainpkg=
78 break
80 done
82 esac
84 # native pkg
85 collect_sonames ${PKGDESTDIR} $_mainpkg
86 # 32bit pkg
87 collect_sonames ${_destdir32}