void-packages

Void Source Packages
git clone git://ezup.dev/void-packages.git
Log | Files | Refs | README | LICENSE

99-pkglint.sh (5790B)


      1# This hook checks for common issues related to void.
      2
      3hook() {
      4	local error=0 filename= rev= libname= conflictPkg= conflictFile=
      5	local conflictRev= ignore= found= mapshlibs=$XBPS_COMMONDIR/shlibs
      6	local emptypkg=yes
      7
      8	set +E
      9
     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
     15				continue
     16			fi
     17			msg_red "${pkgver}: /${f} must be a symlink.\n"
     18			error=1
     19		else
     20			msg_red "${pkgver}: /${f} must not exist.\n"
     21			error=1
     22		fi
     23	done
     24	
     25	for f in var/run usr/local; do
     26		if [ -d ${PKGDESTDIR}/${f} ]; then
     27			msg_red "${pkgver}: /${f} directory is not allowed, remove it!\n"
     28			error=1
     29		fi
     30	done
     31
     32	for f in "$PKGDESTDIR"/*; do
     33		f="${f##*/}"
     34		case "$f" in
     35		'*')	# The filename is exactly '*'
     36			if [ -e "${PKGDESTDIR}/*" ]; then
     37				msg_red "${pkgver}: File /* is not allowed\n"
     38				error=1
     39			fi
     40			;;
     41		lib|bin|sbin|lib64|lib32|usr|var|opt|etc|boot|srv)
     42			emptypkg=no
     43			;;
     44		INSTALL|INSTALL.msg|REMOVE|REMOVE.msg|rdeps|shlib-requires|shlib-provides)
     45			if [ ! -f "${PKGDESTDIR}/$f" ]; then
     46				msg_red "${pkgver}: /${f} is not allowed\n"
     47				error=1
     48			fi
     49			;;
     50		*)
     51			msg_red "${pkgver}: /${f} directory is not allowed, remove it!\n"
     52			error=1
     53			;;
     54		esac
     55	done
     56
     57	# Forbid empty packages unless build_style=meta
     58	if [ "$build_style" != meta -a "$emptypkg" != no ]; then
     59		msg_red "${pkgver}: PKGDESTDIR is empty and build_style != meta\n"
     60		error=1
     61	fi
     62
     63	# Check that configuration files really exist.
     64	for f in $(expand_destdir "${conf_files}"); do
     65		if [ ! -f "${PKGDESTDIR}/${f}" ]; then
     66			msg_red "${pkgver}: '$f' configuration file not in PKGDESTDIR!\n"
     67			error=1
     68		fi
     69	done
     70
     71	# Check for l10n files in usr/lib/locale
     72	if [ -d ${PKGDESTDIR}/usr/lib/locale ]; then
     73		msg_red "${pkgver}: /usr/lib/locale is forbidden, use /usr/share/locale!\n"
     74		error=1
     75	fi
     76
     77	# Check for bash completions in etc/bash_completion.d
     78	# should be on usr/share/bash-completion/completions
     79	if [ -d ${PKGDESTDIR}/etc/bash_completion.d ]; then
     80		msg_red "${pkgver}: /etc/bash_completion.d is forbidden. Use /usr/share/bash-completion/completions.\n"
     81		error=1
     82	fi
     83
     84	# Prevent packages from installing to these paths in etc, they should use
     85	# their equivalent in usr/lib
     86	for f in udev/{rules.d,hwdb.d} modprobe.d sysctl.d; do
     87		if [ -d ${PKGDESTDIR}/etc/${f} ]; then
     88			msg_red "${pkgver}: /etc/${f} is forbidden. Use /usr/lib/${f}.\n"
     89			error=1
     90		fi
     91	done
     92
     93	# Likewise with the comment above but for usr/share
     94	for f in X11/xorg.conf.d gconf/schemas; do
     95		if [ -d ${PKGDESTDIR}/etc/${f} ]; then
     96			msg_red "${pkgver}: /etc/${f} is forbidden. Use /usr/share/${f}.\n"
     97			error=1
     98		fi
     99	done
    100
    101	if [ -d ${PKGDESTDIR}/etc/dracut.conf.d ]; then
    102		msg_red "${pkgver}: /etc/dracut.conf.d is forbidden. Use /usr/lib/dracut/dracut.conf.d.\n"
    103		error=1
    104	fi
    105
    106	if [ -d ${PKGDESTDIR}/usr/man ]; then
    107		msg_red "${pkgver}: /usr/man is forbidden, use /usr/share/man.\n"
    108		error=1
    109	fi
    110
    111	if [ -d ${PKGDESTDIR}/usr/doc ]; then
    112		msg_red "${pkgver}: /usr/doc is forbidden. Use /usr/share/doc.\n"
    113		error=1
    114	fi
    115
    116	if [ -d ${PKGDESTDIR}/usr/dict ]; then
    117		msg_red "${pkgver}: /usr/dict is forbidden. Use /usr/share/dict.\n"
    118		error=1
    119	fi
    120
    121	# Forbid files would be generated by mimedb trigger
    122	for f in XMLnamespaces aliases generic-icons globs globs2 icons \
    123		magic mime.cache subclasses treemagic types version ; do
    124		if [ -f "${PKGDESTDIR}/usr/share/mime/$f" ]; then
    125			msg_red "${pkgver}: /usr/share/mime/$f is forbidden. Delete it.\n"
    126			error=1
    127		fi
    128	done
    129
    130	if [ $error -gt 0 ]; then
    131		msg_error "${pkgver}: cannot continue with installation!\n"
    132	fi
    133
    134	# Check for missing shlibs and SONAME bumps.
    135	if [ ! -s "${PKGDESTDIR}/shlib-provides" ]; then
    136		return 0
    137	fi
    138
    139	for filename in $(<${PKGDESTDIR}/shlib-provides); do
    140		rev=${filename#*.so.}
    141		libname=${filename%.so*}
    142		_shlib=$(echo "$libname"|sed -E 's|\+|\\+|g')
    143		_pkgname=$(echo "$pkgname"|sed -E 's|\+|\\+|g')
    144		if [ "$rev" = "$filename" ]; then
    145			_pattern="^${_shlib}\.so[[:blank:]]+${_pkgname}-[^-]+_[0-9]+"
    146		else
    147			_pattern="^${_shlib}\.so\.[0-9]+(.*)[[:blank:]]+${_pkgname}-[^-]+_[0-9]+"
    148		fi
    149		grep -E "${_pattern}" $mapshlibs | { \
    150			while read conflictFile conflictPkg ignore; do
    151				found=1
    152				conflictRev=${conflictFile#*.so.}
    153				if [ -n "$ignore" -a "$ignore" != "$XBPS_TARGET_MACHINE" ]; then
    154					continue
    155				elif [ "$rev" = "$conflictRev" ]; then
    156					continue
    157				elif [[ ${rev}.* =~ $conflictRev ]]; then
    158					continue
    159				fi
    160				msg_red "${pkgver}: SONAME bump detected: ${libname}.so.${conflictRev} -> ${libname}.so.${rev}\n"
    161				msg_red "${pkgver}: please update common/shlibs with this line: \"${libname}.so.${rev} ${pkgver}\"\n"
    162				msg_red "${pkgver}: all reverse dependencies should also be revbumped to be rebuilt against ${libname}.so.${rev}:\n"
    163				_revdeps=$($XBPS_QUERY_XCMD -Rs ${libname}.so -p shlib-requires|cut -d ' ' -f1)
    164				for x in ${_revdeps}; do
    165					msg_red "   ${x%:}\n"
    166				done
    167				msg_error "${pkgver}: cannot continue with installation!\n"
    168			done
    169			# Try to match provided shlibs in virtual packages.
    170			for f in ${provides}; do
    171				_vpkgname="$($XBPS_UHELPER_CMD getpkgname ${f} 2>/dev/null)"
    172				_spkgname="$(grep "^${filename}" $mapshlibs | cut -d ' ' -f2)"
    173				_libpkgname="$($XBPS_UHELPER_CMD getpkgname ${_spkgname} 2>/dev/null)"
    174				if [ -z "${_spkgname}" -o  -z "${_libpkgname}" ]; then
    175					continue
    176				fi
    177				if [ "${_vpkgname}" = "${_libpkgname}" ]; then
    178					found=1
    179					break
    180				fi
    181			done;
    182			if [ -z "$found" ]; then
    183				_myshlib="${libname}.so"
    184				[ "${_myshlib}" != "${rev}" ] && _myshlib+=".${rev}"
    185				msg_warn "${pkgver}: ${_myshlib} not found in common/shlibs!\n"
    186			fi;
    187		}
    188	done
    189}