2014-03-19 16:32:12 +01:00
|
|
|
# This hook checks for common issues related to void.
|
|
|
|
|
|
|
|
hook() {
|
2014-03-24 11:15:29 +01:00
|
|
|
local error=0 filename= rev= libname= conflictPkg= conflictFile=
|
2014-09-10 13:04:46 +02:00
|
|
|
local conflictRev= ignore= found= mapshlibs=$XBPS_COMMONDIR/shlibs
|
2020-05-23 13:56:08 +02:00
|
|
|
local emptypkg=yes
|
2014-03-19 16:32:12 +01:00
|
|
|
|
2014-03-27 13:57:17 +01:00
|
|
|
set +E
|
|
|
|
|
2015-04-05 18:41:01 +02:00
|
|
|
# Check for forbidden directories that are symlinks in void.
|
2019-12-02 05:07:50 +01:00
|
|
|
for f in lib bin sbin lib64 lib32 usr/sbin usr/lib64; do
|
|
|
|
[ -e "${PKGDESTDIR}/${f}" ] || continue
|
|
|
|
if [ "${pkgname}" = "base-files" ]; then
|
|
|
|
if [ -L "${PKGDESTDIR}/${f}" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
msg_red "${pkgver}: /${f} must be a symlink.\n"
|
|
|
|
error=1
|
|
|
|
else
|
|
|
|
msg_red "${pkgver}: /${f} must not exist.\n"
|
2014-03-19 16:32:12 +01:00
|
|
|
error=1
|
|
|
|
fi
|
|
|
|
done
|
2021-05-29 19:43:09 +02:00
|
|
|
|
2020-05-23 13:55:59 +02:00
|
|
|
for f in var/run usr/local; do
|
2014-03-19 16:32:12 +01:00
|
|
|
if [ -d ${PKGDESTDIR}/${f} ]; then
|
|
|
|
msg_red "${pkgver}: /${f} directory is not allowed, remove it!\n"
|
|
|
|
error=1
|
|
|
|
fi
|
|
|
|
done
|
2015-04-05 18:41:01 +02:00
|
|
|
|
2020-05-23 13:55:59 +02:00
|
|
|
for f in "$PKGDESTDIR"/*; do
|
|
|
|
f="${f##*/}"
|
|
|
|
case "$f" in
|
|
|
|
'*') # The filename is exactly '*'
|
|
|
|
if [ -e "${PKGDESTDIR}/*" ]; then
|
|
|
|
msg_red "${pkgver}: File /* is not allowed\n"
|
|
|
|
error=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
lib|bin|sbin|lib64|lib32|usr|var|opt|etc|boot|srv)
|
2020-05-23 13:56:08 +02:00
|
|
|
emptypkg=no
|
2020-05-23 13:55:59 +02:00
|
|
|
;;
|
|
|
|
INSTALL|INSTALL.msg|REMOVE|REMOVE.msg|rdeps|shlib-requires|shlib-provides)
|
|
|
|
if [ ! -f "${PKGDESTDIR}/$f" ]; then
|
|
|
|
msg_red "${pkgver}: /${f} is not allowed\n"
|
|
|
|
error=1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
msg_red "${pkgver}: /${f} directory is not allowed, remove it!\n"
|
|
|
|
error=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2021-05-29 19:43:09 +02:00
|
|
|
# Forbid empty packages unless build_style=meta or it is 32bit devel package
|
|
|
|
if [ "$build_style" != meta ] && [ "$emptypkg" != no ] && [[ ${pkgname} != *-devel-32bit ]]; then
|
2020-05-23 13:56:08 +02:00
|
|
|
msg_red "${pkgver}: PKGDESTDIR is empty and build_style != meta\n"
|
|
|
|
error=1
|
|
|
|
fi
|
|
|
|
|
2015-04-05 18:41:01 +02:00
|
|
|
# Check that configuration files really exist.
|
2015-11-18 11:19:09 +01:00
|
|
|
for f in $(expand_destdir "${conf_files}"); do
|
2015-11-18 09:44:34 +01:00
|
|
|
if [ ! -f "${PKGDESTDIR}/${f}" ]; then
|
2015-04-05 18:41:01 +02:00
|
|
|
msg_red "${pkgver}: '$f' configuration file not in PKGDESTDIR!\n"
|
|
|
|
error=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2020-12-30 17:32:47 +01:00
|
|
|
# Check for l10n files in usr/lib/locale
|
|
|
|
if [ -d ${PKGDESTDIR}/usr/lib/locale ]; then
|
|
|
|
msg_red "${pkgver}: /usr/lib/locale is forbidden, use /usr/share/locale!\n"
|
|
|
|
error=1
|
|
|
|
fi
|
|
|
|
|
2018-12-06 14:56:34 +01:00
|
|
|
# Check for bash completions in etc/bash_completion.d
|
|
|
|
# should be on usr/share/bash-completion/completions
|
|
|
|
if [ -d ${PKGDESTDIR}/etc/bash_completion.d ]; then
|
2018-12-13 13:18:27 +01:00
|
|
|
msg_red "${pkgver}: /etc/bash_completion.d is forbidden. Use /usr/share/bash-completion/completions.\n"
|
2018-12-06 14:56:34 +01:00
|
|
|
error=1
|
|
|
|
fi
|
|
|
|
|
2018-12-06 15:43:16 +01:00
|
|
|
# Prevent packages from installing to these paths in etc, they should use
|
|
|
|
# their equivalent in usr/lib
|
2021-02-28 02:00:31 +01:00
|
|
|
for f in udev/{rules.d,hwdb.d} modprobe.d sysctl.d; do
|
|
|
|
if [ -d ${PKGDESTDIR}/etc/${f} ]; then
|
|
|
|
msg_red "${pkgver}: /etc/${f} is forbidden. Use /usr/lib/${f}.\n"
|
|
|
|
error=1
|
|
|
|
fi
|
|
|
|
done
|
2018-12-06 15:43:16 +01:00
|
|
|
|
|
|
|
# Likewise with the comment above but for usr/share
|
|
|
|
for f in X11/xorg.conf.d gconf/schemas; do
|
|
|
|
if [ -d ${PKGDESTDIR}/etc/${f} ]; then
|
2018-12-13 13:18:27 +01:00
|
|
|
msg_red "${pkgver}: /etc/${f} is forbidden. Use /usr/share/${f}.\n"
|
2018-12-06 15:43:16 +01:00
|
|
|
error=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -d ${PKGDESTDIR}/etc/dracut.conf.d ]; then
|
2018-12-13 13:18:27 +01:00
|
|
|
msg_red "${pkgver}: /etc/dracut.conf.d is forbidden. Use /usr/lib/dracut/dracut.conf.d.\n"
|
|
|
|
error=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d ${PKGDESTDIR}/usr/man ]; then
|
|
|
|
msg_red "${pkgver}: /usr/man is forbidden, use /usr/share/man.\n"
|
|
|
|
error=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d ${PKGDESTDIR}/usr/doc ]; then
|
|
|
|
msg_red "${pkgver}: /usr/doc is forbidden. Use /usr/share/doc.\n"
|
|
|
|
error=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d ${PKGDESTDIR}/usr/dict ]; then
|
|
|
|
msg_red "${pkgver}: /usr/dict is forbidden. Use /usr/share/dict.\n"
|
2018-12-06 15:43:16 +01:00
|
|
|
error=1
|
|
|
|
fi
|
|
|
|
|
2020-03-08 08:08:24 +01:00
|
|
|
# Forbid files would be generated by mimedb trigger
|
|
|
|
for f in XMLnamespaces aliases generic-icons globs globs2 icons \
|
|
|
|
magic mime.cache subclasses treemagic types version ; do
|
|
|
|
if [ -f "${PKGDESTDIR}/usr/share/mime/$f" ]; then
|
|
|
|
msg_red "${pkgver}: /usr/share/mime/$f is forbidden. Delete it.\n"
|
|
|
|
error=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2014-03-19 16:32:12 +01:00
|
|
|
if [ $error -gt 0 ]; then
|
|
|
|
msg_error "${pkgver}: cannot continue with installation!\n"
|
|
|
|
fi
|
2014-03-24 11:15:29 +01:00
|
|
|
|
|
|
|
# Check for missing shlibs and SONAME bumps.
|
2015-11-13 13:05:36 +01:00
|
|
|
if [ ! -s "${PKGDESTDIR}/shlib-provides" ]; then
|
2014-03-24 11:15:29 +01:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2019-04-13 18:56:46 +02:00
|
|
|
for filename in $(<${PKGDESTDIR}/shlib-provides); do
|
2014-03-24 11:15:29 +01:00
|
|
|
rev=${filename#*.so.}
|
|
|
|
libname=${filename%.so*}
|
2014-04-04 17:24:47 +02:00
|
|
|
_shlib=$(echo "$libname"|sed -E 's|\+|\\+|g')
|
2014-03-27 13:57:17 +01:00
|
|
|
_pkgname=$(echo "$pkgname"|sed -E 's|\+|\\+|g')
|
2014-04-09 08:55:43 +02:00
|
|
|
if [ "$rev" = "$filename" ]; then
|
2014-09-10 13:04:46 +02:00
|
|
|
_pattern="^${_shlib}\.so[[:blank:]]+${_pkgname}-[^-]+_[0-9]+"
|
2014-04-09 08:55:43 +02:00
|
|
|
else
|
2014-09-10 13:04:46 +02:00
|
|
|
_pattern="^${_shlib}\.so\.[0-9]+(.*)[[:blank:]]+${_pkgname}-[^-]+_[0-9]+"
|
2014-04-09 08:55:43 +02:00
|
|
|
fi
|
|
|
|
grep -E "${_pattern}" $mapshlibs | { \
|
2014-09-10 13:04:46 +02:00
|
|
|
while read conflictFile conflictPkg ignore; do
|
2014-03-24 11:15:29 +01:00
|
|
|
found=1
|
|
|
|
conflictRev=${conflictFile#*.so.}
|
2014-09-10 13:04:46 +02:00
|
|
|
if [ -n "$ignore" -a "$ignore" != "$XBPS_TARGET_MACHINE" ]; then
|
|
|
|
continue
|
|
|
|
elif [ "$rev" = "$conflictRev" ]; then
|
2014-03-24 11:15:29 +01:00
|
|
|
continue
|
2014-03-31 18:14:52 +02:00
|
|
|
elif [[ ${rev}.* =~ $conflictRev ]]; then
|
2014-03-24 11:15:29 +01:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
msg_red "${pkgver}: SONAME bump detected: ${libname}.so.${conflictRev} -> ${libname}.so.${rev}\n"
|
|
|
|
msg_red "${pkgver}: please update common/shlibs with this line: \"${libname}.so.${rev} ${pkgver}\"\n"
|
|
|
|
msg_red "${pkgver}: all reverse dependencies should also be revbumped to be rebuilt against ${libname}.so.${rev}:\n"
|
2019-07-10 19:48:54 +02:00
|
|
|
_revdeps=$($XBPS_QUERY_XCMD -Rs ${libname}.so -p shlib-requires|cut -d ' ' -f1)
|
2014-04-04 17:24:47 +02:00
|
|
|
for x in ${_revdeps}; do
|
|
|
|
msg_red " ${x%:}\n"
|
2014-03-24 11:15:29 +01:00
|
|
|
done
|
|
|
|
msg_error "${pkgver}: cannot continue with installation!\n"
|
|
|
|
done
|
2014-03-27 13:57:17 +01:00
|
|
|
# Try to match provided shlibs in virtual packages.
|
|
|
|
for f in ${provides}; do
|
|
|
|
_vpkgname="$($XBPS_UHELPER_CMD getpkgname ${f} 2>/dev/null)"
|
2019-07-10 19:48:54 +02:00
|
|
|
_spkgname="$(grep "^${filename}" $mapshlibs | cut -d ' ' -f2)"
|
2014-03-27 13:57:17 +01:00
|
|
|
_libpkgname="$($XBPS_UHELPER_CMD getpkgname ${_spkgname} 2>/dev/null)"
|
|
|
|
if [ -z "${_spkgname}" -o -z "${_libpkgname}" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
if [ "${_vpkgname}" = "${_libpkgname}" ]; then
|
|
|
|
found=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done;
|
2014-03-24 11:15:29 +01:00
|
|
|
if [ -z "$found" ]; then
|
2014-05-09 09:22:03 +02:00
|
|
|
_myshlib="${libname}.so"
|
|
|
|
[ "${_myshlib}" != "${rev}" ] && _myshlib+=".${rev}"
|
|
|
|
msg_warn "${pkgver}: ${_myshlib} not found in common/shlibs!\n"
|
2014-03-24 11:15:29 +01:00
|
|
|
fi;
|
|
|
|
}
|
|
|
|
done
|
2014-03-19 16:32:12 +01:00
|
|
|
}
|