1 # This hook checks for common issues related to void.
4 local error
=0 filename
= rev= libname
= conflictPkg
= conflictFile
=
5 local conflictRev
= ignore
= found
= mapshlibs
=$XBPS_COMMONDIR/shlibs
10 # Check for forbidden directories that are symlinks in void.
11 for f
in lib bin sbin lib64 lib32 usr
/sbin usr
/lib64
; do
12 [ -e "${PKGDESTDIR}/${f}" ] ||
continue
13 if [ "${pkgname}" = "base-files" ]; then
14 if [ -L "${PKGDESTDIR}/${f}" ]; then
17 msg_red
"${pkgver}: /${f} must be a symlink.\n"
20 msg_red
"${pkgver}: /${f} must not exist.\n"
25 for f
in var
/run usr
/local usr
/etc
; do
26 if [ -d ${PKGDESTDIR}/${f} ]; then
27 msg_red
"${pkgver}: /${f} directory is not allowed, remove it!\n"
32 if [ -d ${PKGDESTDIR}/usr
/lib
/libexec
]; then
33 # Add exception for kconfig,
34 # other packages hard-coded path to its files
35 if [ "${pkgname}" != kconfig
]; then
36 msg_red
"${pkgver}: /usr/lib/libexec directory is not allowed!\n"
41 for f
in "$PKGDESTDIR"/*; do
44 '*') # The filename is exactly '*'
45 if [ -e "${PKGDESTDIR}/*" ]; then
46 msg_red
"${pkgver}: File /* is not allowed\n"
50 lib|bin|sbin|lib64|lib32|usr|var|opt|etc|boot|srv
)
53 INSTALL|INSTALL.msg|REMOVE|REMOVE.msg|rdeps|shlib-requires|shlib-provides
)
54 if [ ! -f "${PKGDESTDIR}/$f" ]; then
55 msg_red
"${pkgver}: /${f} is not allowed\n"
60 msg_red
"${pkgver}: /${f} directory is not allowed, remove it!\n"
66 # Forbid empty packages unless build_style=meta or it is 32bit devel package
67 if [ "$build_style" != meta
] && [ "$emptypkg" != no
] && [[ ${pkgname} != *-devel-32bit ]]; then
68 msg_red
"${pkgver}: PKGDESTDIR is empty and build_style != meta\n"
72 # Check that configuration files really exist.
73 for f
in $
(expand_destdir
"${conf_files}"); do
74 if [ ! -f "${PKGDESTDIR}/${f}" ]; then
75 msg_red
"${pkgver}: '$f' configuration file not in PKGDESTDIR!\n"
80 # Check for l10n files in usr/lib/locale
81 if [ -d ${PKGDESTDIR}/usr
/lib
/locale
]; then
82 local locale_allow
=0 ldir
83 local lroot
="${PKGDESTDIR}/usr/lib/locale"
85 if [ "${pkgname}" = "glibc" ]; then
86 # glibc gets an exception for its included C.utf8 locale
88 for ldir
in "${lroot}"/*; do
89 [ "${ldir}" = "${lroot}/C.utf8" ] && continue
94 if [ "${locale_allow}" -ne 1 ]; then
95 msg_red
"${pkgver}: /usr/lib/locale is forbidden, use /usr/share/locale!\n"
100 # Check for bash completions in etc/bash_completion.d
101 # should be on usr/share/bash-completion/completions
102 if [ -d ${PKGDESTDIR}/etc
/bash_completion.d
]; then
103 msg_red
"${pkgver}: /etc/bash_completion.d is forbidden. Use /usr/share/bash-completion/completions.\n"
107 # Prevent packages from installing to these paths in etc, they should use
108 # their equivalent in usr/lib
109 for f
in udev
/{rules.d
,hwdb.d
} modprobe.d sysctl.d
; do
110 if [ -d ${PKGDESTDIR}/etc
/${f} ]; then
111 msg_red
"${pkgver}: /etc/${f} is forbidden. Use /usr/lib/${f}.\n"
116 # Likewise with the comment above but for usr/share
117 for f
in X11
/xorg.conf.d gconf
/schemas
; do
118 if [ -d ${PKGDESTDIR}/etc
/${f} ]; then
119 msg_red
"${pkgver}: /etc/${f} is forbidden. Use /usr/share/${f}.\n"
124 if [ -d ${PKGDESTDIR}/etc
/dracut.conf.d
]; then
125 msg_red
"${pkgver}: /etc/dracut.conf.d is forbidden. Use /usr/lib/dracut/dracut.conf.d.\n"
129 if [ -d ${PKGDESTDIR}/usr
/usr
]; then
130 msg_red
"${pkgver}: /usr/usr is forbidden, use /usr.\n"
134 if [ -d ${PKGDESTDIR}/usr
/man
]; then
135 msg_red
"${pkgver}: /usr/man is forbidden, use /usr/share/man.\n"
139 if [[ -d ${PKGDESTDIR}/usr
/share
/man
/man
]]; then
140 msg_red
"${pkgver}: /usr/share/man/man is forbidden, use /usr/share/man.\n"
144 if [ -d ${PKGDESTDIR}/usr
/doc
]; then
145 msg_red
"${pkgver}: /usr/doc is forbidden. Use /usr/share/doc.\n"
149 if [ -d ${PKGDESTDIR}/usr
/dict
]; then
150 msg_red
"${pkgver}: /usr/dict is forbidden. Use /usr/share/dict.\n"
154 if [ -e ${PKGDESTDIR}/usr
/share
/glib-2.0
/schemas
/gschemas.compiled
]; then
155 msg_red
"${pkgver}: /usr/share/glib-2.0/schemas/gschemas.compiled is forbidden. Delete it.\n"
159 # Forbid files would be generated by mimedb trigger
160 for f
in XMLnamespaces aliases generic-icons globs globs2 icons \
161 magic mime.cache subclasses treemagic types version
; do
162 if [ -f "${PKGDESTDIR}/usr/share/mime/$f" ]; then
163 msg_red
"${pkgver}: /usr/share/mime/$f is forbidden. Delete it.\n"
168 if [ $error -gt 0 ]; then
169 msg_error
"${pkgver}: cannot continue with installation!\n"
172 # Check for missing shlibs and SONAME bumps.
173 if [ ! -s "${PKGDESTDIR}/shlib-provides" ]; then
177 for filename
in $
(<${PKGDESTDIR}/shlib-provides
); do
178 rev=${filename#*.so.}
179 libname
=${filename%.so*}
180 _shlib
=$
(echo "$libname"|
sed -E 's|\+|\\+|g')
181 _pkgname
=$
(echo "$pkgname"|
sed -E 's|\+|\\+|g')
182 if [ "$rev" = "$filename" ]; then
183 _pattern
="^${_shlib}\.so[[:blank:]]+${_pkgname}-[^-]+_[0-9]+"
185 _pattern
="^${_shlib}\.so\.[0-9]+(.*)[[:blank:]]+${_pkgname}-[^-]+_[0-9]+"
187 grep -E "${_pattern}" $mapshlibs |
{ \
188 while read -r conflictFile conflictPkg ignore
; do
190 conflictRev
=${conflictFile#*.so.}
191 if [ -n "$ignore" -a "$ignore" != "$XBPS_TARGET_MACHINE" ]; then
193 elif [ "$rev" = "$conflictRev" ]; then
195 elif [[ ${rev}.
* =~
$conflictRev ]]; then
198 msg_red
"${pkgver}: SONAME bump detected: ${libname}.so.${conflictRev} -> ${libname}.so.${rev}\n"
199 msg_red
"${pkgver}: please update common/shlibs with this line: \"${libname}.so.${rev} ${pkgver}\"\n"
200 msg_red
"${pkgver}: all reverse dependencies should also be revbumped to be rebuilt against ${libname}.so.${rev}:\n"
201 _revdeps
=$
($XBPS_QUERY_XCMD -Rs ${libname}.so
-p shlib-requires|cut
-d ' ' -f1)
202 for x
in ${_revdeps}; do
205 msg_error
"${pkgver}: cannot continue with installation!\n"
207 # Try to match provided shlibs in virtual packages.
208 for f
in ${provides}; do
209 _vpkgname
="$($XBPS_UHELPER_CMD getpkgname ${f} 2>/dev/null)"
210 _spkgname
="$(grep "^
${filename}" $mapshlibs | cut -d ' ' -f2)"
211 _libpkgname
="$($XBPS_UHELPER_CMD getpkgname ${_spkgname} 2>/dev/null)"
212 if [ -z "${_spkgname}" -o -z "${_libpkgname}" ]; then
215 if [ "${_vpkgname}" = "${_libpkgname}" ]; then
220 if [ -z "$found" ]; then
221 _myshlib
="${libname}.so"
222 [ "${_myshlib}" != "${rev}" ] && _myshlib+=".${rev}"
223 msg_normal
"${pkgver}: ${_myshlib} not found in common/shlibs.\n"