2011-04-26 21:39:44 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# test01_pkgquality -- @package@ test (rpm quality checks)
|
2014-12-30 21:30:11 +01:00
|
|
|
# Copyright (C) 2008,2012-2014 Davide Madrisan <davide.madrisan@gmail.com>
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
[ -z "$BASH" ] || [ ${BASH_VERSION:0:1} -lt 2 ] &&
|
|
|
|
echo $"this script requires bash version 2 or better" >&2 && exit 1
|
|
|
|
|
2012-11-30 22:02:42 +01:00
|
|
|
me=("test01_pkgquality" "@version@" "@date@")
|
|
|
|
|
2011-04-26 21:39:44 +02:00
|
|
|
[ -r @libdir@/libmsgmng.lib ] ||
|
|
|
|
{ echo "$me: "$"library not found"": @libdir@/libmsgmng.lib" 1>&2
|
|
|
|
exit 1; }
|
|
|
|
|
|
|
|
. @libdir@/libmsgmng.lib
|
|
|
|
|
2012-11-30 22:02:42 +01:00
|
|
|
[ -r @libdir@/libtranslate.lib ] ||
|
|
|
|
{ echo "$me: "$"library not found"": @libdir@/libtranslate.lib" 1>&2
|
|
|
|
exit 1; }
|
|
|
|
. @libdir@/libtranslate.lib
|
2011-04-26 21:39:44 +02:00
|
|
|
|
2012-12-01 17:54:46 +01:00
|
|
|
notify.debug $"loading"": \`test01_pkgquality'..."
|
|
|
|
|
2012-05-08 22:50:53 +02:00
|
|
|
# check if all the needed tools are available
|
2013-07-19 21:47:18 +02:00
|
|
|
for tool in file find getopt grep ls ldd wc; do
|
2012-05-08 22:50:53 +02:00
|
|
|
[ "$(type -p $tool)" ] ||
|
|
|
|
notify.error $"utility not found"": \`$tool'"
|
|
|
|
done
|
|
|
|
|
2011-04-26 21:39:44 +02:00
|
|
|
function alltests() {
|
2012-05-19 00:03:42 +02:00
|
|
|
notify.note " ${NOTE}"$"performing quality checks""${NORM}""..."
|
2011-04-26 21:39:44 +02:00
|
|
|
|
2012-01-02 21:16:48 +01:00
|
|
|
TEMP=`LC_ALL=C getopt \
|
2011-04-26 21:39:44 +02:00
|
|
|
-o i:t: --long infofile:,tmpdir: \
|
|
|
|
-n "$FUNCNAME" -- "$@"`
|
|
|
|
[ $? = 0 ] || return 1
|
|
|
|
eval set -- "$TEMP"
|
|
|
|
|
|
|
|
while :; do
|
|
|
|
case "$1" in
|
|
|
|
-i|--infofile)
|
|
|
|
rpminfofile="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-t|--tmpdir)
|
|
|
|
tmpextractdir="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--) shift; break ;;
|
|
|
|
*) notify.error $"\
|
|
|
|
(bug)"" -- $FUNCNAME: "$"\`getopt' error" ;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
[ "$rpminfofile" ] || notify.error $"\
|
|
|
|
(bug)"" -- $FUNCNAME: "$"missing mandatory arg"" (--infofile)"
|
|
|
|
[ -r "$rpminfofile" ] || notify.error $"\
|
|
|
|
(bug)"" -- $FUNCNAME: "$"cannot read"" \`$rpminfofile'"
|
|
|
|
|
|
|
|
. $rpminfofile
|
|
|
|
|
|
|
|
[ "$tmpextractdir" ] || notify.error $"\
|
|
|
|
(bug)"" -- $FUNCNAME: "$"missing mandatory arg"" (--tmpdir)"
|
|
|
|
[ -d "$tmpextractdir" ] || notify.error $"\
|
|
|
|
(bug)"" -- $FUNCNAME: "$"no such file or directory"" \`$tmpextractdir'"
|
|
|
|
|
2012-01-13 00:17:57 +01:00
|
|
|
local total_issues=0
|
|
|
|
|
2011-04-26 21:39:44 +02:00
|
|
|
# check for broken symlinks
|
|
|
|
# - symlinks to files in the buildroot directory for rpm
|
|
|
|
# (usable for a symlink attacks)
|
|
|
|
# - symlinks not pointing to existing files
|
2012-05-19 14:16:01 +02:00
|
|
|
|
|
|
|
test.skip $test_number || {
|
|
|
|
notify.note "$(test.num2str). ${NOTE}"\
|
2012-05-19 00:03:42 +02:00
|
|
|
$"checking for wrong symbolic links""${NORM}..."
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
# local rpmbuildroot=`sed -n "/%description/q;{
|
|
|
|
# /^BuildRoot[ ]*:/{s/[^ ]*[ ]*//;p}}" \
|
|
|
|
# $spec_dir/$SRPM_SPECFILE | \
|
|
|
|
# sed "s,%[{]*name[}]*,$SPEC_NAME,
|
|
|
|
# s,%[{]*version[}]*,$SPEC_VERSION,
|
|
|
|
# s,%[{]*_tmppath[}]*,$tmppath_dir,;p"`
|
|
|
|
|
|
|
|
# FIXME: 'tmppath_dir' should be get from configuration files
|
|
|
|
tmppath_dir=`rpm --eval %_tmppath 2>/dev/null`
|
|
|
|
|
|
|
|
[ "$tmppath_dir" ] ||
|
|
|
|
notify.error $"(bug)"" -- $FUNCNAME: ""empty string"" (tmppath_dir)"
|
|
|
|
|
|
|
|
notify.debug "tmppath_dir = $tmppath_dir"
|
|
|
|
|
|
|
|
let "i = 0"
|
|
|
|
for pck in ${rpmpkg_name[@]}; do
|
|
|
|
pushd $tmpextractdir/$i >/dev/null
|
|
|
|
for f in $(find -mindepth 1 -type l); do
|
|
|
|
notify.debug "$f --> `readlink $f`"
|
|
|
|
# FIXME: the check fails if 'BuildRoot' doesn't start
|
|
|
|
# by '%_{tmppath}'
|
|
|
|
# note: the first condition check for wrong links, like
|
|
|
|
# /usr/share/man/man1/zcmp.1.gz -> .gz
|
|
|
|
# made by the broken `brp-compress' script in rpm 4.0.4
|
2012-01-08 23:37:58 +01:00
|
|
|
if [[ "$(readlink $f)" = ".gz" || \
|
|
|
|
"$(readlink $f)" =~ $tmppath_dir ]]; then
|
|
|
|
notify.warning "${NOTE}${pck##*/}${NORM}"
|
|
|
|
notify.note $"\
|
2011-04-26 21:39:44 +02:00
|
|
|
wrong symlink"": \`${NOTE}${f/./}${NORM}' --> \`${NOTE}$(readlink $f)${NORM}'"
|
2012-01-13 00:17:57 +01:00
|
|
|
let "total_issues += 1"
|
2012-01-08 23:37:58 +01:00
|
|
|
fi
|
2011-04-26 21:39:44 +02:00
|
|
|
done
|
|
|
|
popd >/dev/null
|
|
|
|
let "i += 1"
|
2012-05-19 14:16:01 +02:00
|
|
|
done; }
|
2012-05-19 00:03:42 +02:00
|
|
|
test_number=$(($test_number + 1))
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
# check for `%buildroot' strings
|
2012-05-19 14:16:01 +02:00
|
|
|
test.skip $test_number || {
|
2011-04-26 21:39:44 +02:00
|
|
|
if [ "$rpm_ignores_buildroot" = 1 ]; then
|
2012-05-19 14:16:01 +02:00
|
|
|
if [ "$SPEC_BUILDROOT" ]; then
|
2012-05-19 00:03:42 +02:00
|
|
|
notify.note \
|
2012-05-19 14:16:01 +02:00
|
|
|
"$(test.num2str). ${NOTE}"\
|
2012-05-19 00:03:42 +02:00
|
|
|
$"checking for \`$SPEC_BUILDROOT' (%buildroot) strings"\
|
2012-05-19 14:16:01 +02:00
|
|
|
"${NORM}... "$"skipped"
|
|
|
|
else
|
2012-05-19 00:03:42 +02:00
|
|
|
notify.note \
|
2012-05-19 14:16:01 +02:00
|
|
|
"$(test.num2str). ${NOTE}"\
|
2012-05-19 00:03:42 +02:00
|
|
|
$"checking for %buildroot strings""${NORM}... "$"N/A"
|
2012-05-19 14:16:01 +02:00
|
|
|
fi
|
2011-04-26 21:39:44 +02:00
|
|
|
else
|
2012-05-19 14:16:01 +02:00
|
|
|
notify.note "$(test.num2str). "\
|
2012-05-19 00:03:42 +02:00
|
|
|
$"checking for \`$SPEC_BUILDROOT' (%buildroot) strings"
|
|
|
|
|
2012-01-08 23:37:58 +01:00
|
|
|
[ "$SPEC_BUILDROOT" ] || notify.error \
|
2011-04-26 21:39:44 +02:00
|
|
|
$"(bug)"" -- $FUNCNAME: ""empty string"" (SPEC_BUILDROOT)"
|
|
|
|
|
|
|
|
let "i = 0"
|
|
|
|
for pck in ${rpmpkg_name[@]}; do
|
2012-01-18 00:09:22 +01:00
|
|
|
pushd $tmpextractdir/$i >/dev/null
|
|
|
|
for f in $(find -type f \
|
|
|
|
-exec grep -ls "$SPEC_BUILDROOT" {} \;2>/dev/null); do
|
2012-01-08 23:37:58 +01:00
|
|
|
notify.warning "${NOTE}${pck##*/}${NORM}"
|
|
|
|
notify.note "\
|
2012-01-18 00:09:22 +01:00
|
|
|
${NOTE}$(echo $f | sed "s,$tmpextractdir/$i,," )${NORM}"
|
2012-08-23 19:45:17 +02:00
|
|
|
notify.note "\
|
|
|
|
"$"mime type: ""${NOTE}$(file --brief --mime --uncompress $f)${NORM}"
|
2011-04-26 21:39:44 +02:00
|
|
|
notify.note "$(\
|
2012-01-18 00:09:22 +01:00
|
|
|
strings -a $f | grep "^$SPEC_BUILDROOT" | sort -bu | \
|
2012-01-08 23:37:58 +01:00
|
|
|
sed "s,$SPEC_BUILDROOT\(.*\), - [%buildroot]\1,")"
|
2012-01-13 00:17:57 +01:00
|
|
|
let "total_issues += 1"
|
2011-04-26 21:39:44 +02:00
|
|
|
done
|
2012-01-18 00:09:22 +01:00
|
|
|
popd >/dev/null
|
2011-04-26 21:39:44 +02:00
|
|
|
let "i += 1"
|
|
|
|
done
|
2012-05-19 14:16:01 +02:00
|
|
|
fi; }
|
2012-05-19 00:03:42 +02:00
|
|
|
test_number=$(($test_number + 1))
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
# check for `%_builddir' strings
|
|
|
|
BUILDDIR="$(rpm --eval=%_builddir 2>/dev/null)"
|
2012-05-19 14:16:01 +02:00
|
|
|
test.skip $test_number || {
|
|
|
|
notify.note "$(test.num2str). ${NOTE}"\
|
2012-05-19 00:03:42 +02:00
|
|
|
$"checking for \`$BUILDDIR' (%_builddir) strings""${NORM}... "
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
[ "$BUILDDIR" ] ||
|
|
|
|
notify.error $"(bug)"" -- $FUNCNAME: ""empty string"" (BUILDDIR)"
|
|
|
|
|
|
|
|
let "i = 0"
|
|
|
|
for pck in ${rpmpkg_name[@]}; do
|
2012-01-18 00:09:22 +01:00
|
|
|
pushd $tmpextractdir/$i >/dev/null
|
|
|
|
for f in $(find -type f \
|
|
|
|
-exec grep -ls "$BUILDDIR" {} \; 2>/dev/null); do
|
|
|
|
notify.warning "${NOTE}${pck##*/}${NORM}"
|
|
|
|
notify.note "\
|
|
|
|
${NOTE}$(echo $f | sed "s,$tmpextractdir/$i,," )${NORM}"
|
2012-08-23 19:45:17 +02:00
|
|
|
notify.note "\
|
|
|
|
"$"mime type: ""${NOTE}$(file --brief --mime --uncompress $f)${NORM}"
|
2012-01-18 00:09:22 +01:00
|
|
|
notify.note "$(\
|
|
|
|
strings -a $f | grep "$BUILDDIR" | sort -bu | \
|
2012-01-08 23:37:58 +01:00
|
|
|
sed "s,$BUILDDIR,[%_builddir],g;s,.*, - &,")"
|
2012-01-18 00:09:22 +01:00
|
|
|
let "total_issues += 1"
|
|
|
|
done
|
|
|
|
popd >/dev/null
|
2011-04-26 21:39:44 +02:00
|
|
|
let "i += 1"
|
2012-05-19 14:16:01 +02:00
|
|
|
done; }
|
2012-05-19 00:03:42 +02:00
|
|
|
test_number=$(($test_number + 1))
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
# check for suspected plugins (.la, .so) in devel packages
|
|
|
|
# note: pure plugins must be in the main package, not in devel
|
2012-05-19 14:16:01 +02:00
|
|
|
test.skip $test_number || {
|
|
|
|
notify.note "$(test.num2str). ${NOTE}"\
|
|
|
|
$"checking for suspicious plugins in devel packages""${NORM}..."
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
let "i = 0"
|
|
|
|
for pck in ${rpmpkg_name[@]}; do
|
|
|
|
# skip non devel packages
|
|
|
|
[[ "${pck##*/}" =~ -devel- ]] || { let "i += 1"; continue; }
|
|
|
|
|
|
|
|
pushd $tmpextractdir/$i >/dev/null
|
|
|
|
# find *.so files that are not symlinks to dynamic libraries
|
|
|
|
for f in `\
|
|
|
|
find -mindepth 1 -type f -name \*.so -exec file {} \; | \
|
|
|
|
grep ' shared object,' | sed -n 's/.\(.*\):.*/\1/p'`; do
|
2012-01-08 23:37:58 +01:00
|
|
|
notify.warning "${NOTE}${pck##*/}${NORM}"
|
|
|
|
notify.note $"found suspect plugin \`${NOTE}$f${NORM}'"
|
2012-01-13 00:17:57 +01:00
|
|
|
let "total_issues += 1"
|
2011-04-26 21:39:44 +02:00
|
|
|
done
|
|
|
|
popd >/dev/null
|
|
|
|
let "i += 1"
|
2012-05-19 14:16:01 +02:00
|
|
|
done; }
|
2012-05-19 00:03:42 +02:00
|
|
|
test_number=$(($test_number + 1))
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
# check for wrong file attributes in lib and bin dirs
|
2012-05-19 14:16:01 +02:00
|
|
|
test.skip $test_number || {
|
|
|
|
notify.note "$(test.num2str). ${NOTE}"\
|
|
|
|
$"checking for wrong file attributes in bin and lib directories""${NORM}..."
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
warning=0
|
|
|
|
let "i = 0"
|
|
|
|
for pck in ${rpmpkg_name[@]}; do
|
|
|
|
pushd $tmpextractdir/$i >/dev/null
|
2012-01-16 21:59:51 +01:00
|
|
|
for f in $( find . -type f \( \
|
2013-07-19 18:39:18 +02:00
|
|
|
\( -name '*.so.*' -and -not -name '*.so.owner' \
|
|
|
|
-and -not -perm 755 \) -or \
|
|
|
|
\( -name '*.so' -and -not -perm 755 \) -or \
|
2011-04-26 21:39:44 +02:00
|
|
|
\( \( -path './bin/*' -or \
|
|
|
|
-path './sbin/*' -or \
|
|
|
|
-path './usr/bin/*' -or \
|
|
|
|
-path './usr/sbin/*' \) \
|
2012-01-16 21:59:51 +01:00
|
|
|
-not -perm -111 \) 2>/dev/null \) ); do
|
2011-04-26 21:39:44 +02:00
|
|
|
let "warning = 1" &&
|
2012-01-08 23:37:58 +01:00
|
|
|
notify.warning "${NOTE}${pck##*/}${NORM}"
|
|
|
|
notify.note $"found suspect file"": \
|
2011-04-26 21:39:44 +02:00
|
|
|
\`${NOTE}${f/./}${NORM}' [$(ls -l "$f" | sed 's, .*,,')]"
|
2012-01-13 00:17:57 +01:00
|
|
|
let "total_issues += 1"
|
2011-04-26 21:39:44 +02:00
|
|
|
done
|
|
|
|
let "i += 1"
|
|
|
|
popd >/dev/null
|
|
|
|
done
|
|
|
|
[[ $warning -eq 0 ]] || notify.note "\
|
|
|
|
-----------------------------
|
|
|
|
${NOTE}"$"Hint"":${NORM}
|
|
|
|
# fixup strange shared library permissions
|
|
|
|
chmod 755 %{buildroot}%{_libdir}/*.so*
|
|
|
|
|
|
|
|
%files
|
|
|
|
%defattr(-,root,root)
|
|
|
|
...
|
|
|
|
%attr(0755,root,root) %{_bindir}/<program>
|
2012-05-19 14:16:01 +02:00
|
|
|
-----------------------------"; }
|
2012-05-19 00:03:42 +02:00
|
|
|
test_number=$(($test_number + 1))
|
2011-04-26 21:39:44 +02:00
|
|
|
|
2012-05-08 22:50:53 +02:00
|
|
|
# check for libraries with undefined symbols
|
2012-05-19 14:16:01 +02:00
|
|
|
test.skip $test_number || {
|
|
|
|
notify.note "$(test.num2str). ${NOTE}"\
|
|
|
|
$"checking for libraries with undefined symbols after relocation""${NORM}..."
|
2012-05-08 22:50:53 +02:00
|
|
|
|
|
|
|
let "i = 0"
|
|
|
|
local undefsyms
|
|
|
|
for pck in ${rpmpkg_name[@]}; do
|
|
|
|
# skip debug packages
|
|
|
|
[[ "${pck##*/}" =~ -debug- ]] && { let "i += 1"; continue; }
|
|
|
|
|
|
|
|
pushd $tmpextractdir/$i >/dev/null
|
|
|
|
for f in `find -mindepth 1 -type f \
|
|
|
|
\( -name *\.so\.* -not -name *.debug \) -exec file {} \; | \
|
|
|
|
grep 'shared object' | sed -n 's/.\([^:]*\):.*/\1/p'`; do
|
|
|
|
undefsyms="\
|
|
|
|
$(LC_ALL=C ldd -d -r "$f" 2>/dev/null |& grep "undefined symbol")"
|
|
|
|
if [ "$undefsyms" ]; then
|
|
|
|
notify.warning "${NOTE}${pck##*/}${NORM}"
|
|
|
|
echo -n "${CRIT}"
|
2012-10-11 21:20:34 +02:00
|
|
|
LC_ALL=C ldd -d -r "$f" 2>&1 | \
|
2012-05-08 22:50:53 +02:00
|
|
|
grep "undefined symbol" | sed "s,.*, - &,"
|
|
|
|
echo -n "${NORM}"
|
|
|
|
let "total_issues += 1"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
popd >/dev/null
|
|
|
|
let "i += 1"
|
2012-05-19 14:16:01 +02:00
|
|
|
done; }
|
2012-05-19 00:03:42 +02:00
|
|
|
test_number=$(($test_number + 1))
|
2012-05-08 22:50:53 +02:00
|
|
|
|
2011-04-26 21:39:44 +02:00
|
|
|
# check for binary files in etc (see FHS-2.2)
|
2012-05-19 14:16:01 +02:00
|
|
|
test.skip $test_number || {
|
|
|
|
notify.note "$(test.num2str). ${NOTE}"\
|
|
|
|
$"checking for binary files installed in /etc (see FHS)""${NORM}..."
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
warning=0
|
|
|
|
let "i = 0"
|
|
|
|
for pck in ${rpmpkg_name[@]}; do
|
|
|
|
pushd $tmpextractdir/$i >/dev/null
|
2014-09-16 22:03:24 +02:00
|
|
|
for f in $( find ./etc -type f -perm /111 2>/dev/null ); do
|
2011-04-26 21:39:44 +02:00
|
|
|
case $f in
|
|
|
|
./etc/rc.d/init.d/*) ;;
|
|
|
|
*) let "warning = 1" &&
|
2012-01-13 00:17:57 +01:00
|
|
|
{ notify.warning "${NOTE}${pck##*/}${NORM}"
|
|
|
|
notify.note $"found suspect file"": \
|
|
|
|
\`${NOTE}${f/./}${NORM}' [$(ls -l "$f" | sed 's, .*,,')]"
|
|
|
|
let "total_issues += 1"; } ;;
|
2011-04-26 21:39:44 +02:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
popd >/dev/null
|
|
|
|
let "i += 1"
|
|
|
|
done
|
|
|
|
[ "$warning" = 0 ] || notify.note "\
|
|
|
|
-----------------------------
|
|
|
|
${NOTE}"$"Hint"":${NORM}
|
|
|
|
%files
|
|
|
|
%defattr(-,root,root)
|
|
|
|
...
|
|
|
|
%attr(0644,root,root) %{_sysconfdir}/<...file>
|
2012-05-19 14:16:01 +02:00
|
|
|
-----------------------------"; } #|| exit 1
|
2012-05-19 00:03:42 +02:00
|
|
|
test_number=$(($test_number + 1))
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
# check for installation code needed by info pages
|
2012-05-19 14:16:01 +02:00
|
|
|
test.skip $test_number || {
|
|
|
|
notify.note "$(test.num2str). ${NOTE}"\
|
|
|
|
$"checking if the info catalog is updated when necessary""${NORM}..."
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
error=0
|
|
|
|
let "i = 0"
|
|
|
|
for pck in ${rpmpkg_name[@]}; do
|
|
|
|
[[ -e $pck ]] || notify.error $"package not found"": \`${pck##*/}'"
|
|
|
|
|
|
|
|
[[ "$(rpm -p -ql $pck |
|
|
|
|
# FIXME: this check only works for FHS-compliant distros
|
|
|
|
grep "^$(rpm --eval %_infodir)")" ]] ||
|
|
|
|
{ let "i += 1"; continue; } # no info pages found
|
|
|
|
#notify.debug "$FUNCNAME: info page(s) found"
|
|
|
|
|
2013-07-19 21:47:18 +02:00
|
|
|
[[ "$(rpm -p -q --requires $pck 2>/dev/null | sed -n '
|
|
|
|
/^[ \t]*\/sbin\/install-info/p')" ]] || let "error+=1"
|
2011-04-26 21:39:44 +02:00
|
|
|
|
2013-07-19 21:47:18 +02:00
|
|
|
# note: we just check for at list two occurences of the command
|
|
|
|
# '/sbin/install-info' in the package scriptlets
|
|
|
|
[[ "$(rpm -p -q --scripts $pck 2>/dev/null | sed -n '
|
|
|
|
/^[ \t]*\/sbin\/install-info/p' | wc -l)" -ge 2 ]] || let "error+=1"
|
2011-04-26 21:39:44 +02:00
|
|
|
|
2012-01-08 23:37:58 +01:00
|
|
|
[ "$error" = "0" ] ||
|
|
|
|
{ notify.warning "${NOTE}${pck##*/}${NORM}"
|
|
|
|
notify.note $"info pages should be installed/uninstalled""${NORM}
|
2011-04-26 21:39:44 +02:00
|
|
|
---------------------------------------
|
|
|
|
${NOTE}"$"Hint"":${NORM}
|
2013-07-19 21:47:18 +02:00
|
|
|
%package [<subpackage>]
|
|
|
|
...
|
|
|
|
$(if [[ "$rpm_macro_installinfo_binary" ]]; then
|
|
|
|
echo "\
|
|
|
|
Requires(post):$rpm_macro_installinfo_binary
|
|
|
|
Requires(preun):$rpm_macro_installinfo_binary"
|
|
|
|
else
|
|
|
|
echo "\
|
|
|
|
Requires(post):${path_installinfo:-/sbin/install-info}
|
|
|
|
Requires(preun):${path_installinfo:-/sbin/install-info}"
|
|
|
|
fi)
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
%post [<subpackage>]
|
|
|
|
$([[ "$rpm_macro_installinfo" ]] &&
|
|
|
|
echo "$rpm_macro_installinfo %{name}.info" ||
|
|
|
|
echo "${path_installinfo:-/sbin/install-info} %{name}.info")
|
2013-07-19 21:47:18 +02:00
|
|
|
exit 0
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
%preun [<subpackage>]
|
|
|
|
$([[ "$rpm_macro_uninstallinfo" ]] &&
|
|
|
|
echo "$rpm_macro_uninstallinfo %{name}.info" ||
|
|
|
|
echo "${path_installinfo:-/sbin/install-info} --delete %{name}.info")
|
|
|
|
exit 0
|
2012-01-13 00:17:57 +01:00
|
|
|
---------------------------------------"
|
|
|
|
let "total_issues += $error"; }
|
2012-05-19 14:16:01 +02:00
|
|
|
done; }
|
2012-05-19 00:03:42 +02:00
|
|
|
test_number=$(($test_number + 1))
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
# check packages for wrong user and/or group ownerships
|
2012-05-19 14:16:01 +02:00
|
|
|
test.skip $test_number || {
|
|
|
|
notify.note "$(test.num2str). ${NOTE}"\
|
|
|
|
$"checking packages for wrong user and/or group ownerships""${NORM}..."
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
error=0
|
|
|
|
idun="$(id -un)" idgn="$(id -gn)"
|
|
|
|
let "i = 0"
|
|
|
|
for pck in ${rpmpkg_name[@]}; do
|
|
|
|
[[ -e $pck ]] || notify.error $"\
|
|
|
|
package not found"": \`${pck##*/}'"
|
2012-01-02 21:16:48 +01:00
|
|
|
( LC_ALL=C rpm -p -qlv $pck | \
|
2011-04-26 21:39:44 +02:00
|
|
|
while read line; do
|
|
|
|
set -- $line
|
|
|
|
# FIXME : find a better check, perhaps using a range
|
|
|
|
# of uid reserved for users
|
2012-01-08 23:37:58 +01:00
|
|
|
if [[ "$idun" = "$3" || "$idgn" = "$4" ]]; then
|
|
|
|
notify.warning "${NOTE}${pck##*/}${NORM}"
|
|
|
|
notify.note $"found suspect file"": \
|
2011-04-26 21:39:44 +02:00
|
|
|
\`${NOTE}$9${NORM}' [uid:\`${NOTE}$3${NORM}', gid:\`${NOTE}$4${NORM}']"
|
2012-01-13 00:17:57 +01:00
|
|
|
let "total_issues += 1"
|
2012-01-08 23:37:58 +01:00
|
|
|
fi
|
2011-04-26 21:39:44 +02:00
|
|
|
done )
|
2012-05-19 14:16:01 +02:00
|
|
|
done; }
|
2012-05-19 00:03:42 +02:00
|
|
|
test_number=$(($test_number + 1))
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
# check for desktop files installed in non standard applnk dir
|
2012-05-19 14:16:01 +02:00
|
|
|
test.skip $test_number || {
|
|
|
|
notify.note "$(test.num2str). ${NOTE}"\
|
|
|
|
$"checking packages for desktop files installed in the applnk dir""${NORM}..."
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
warning=0
|
|
|
|
rpmdatadir=$(rpm --eval %_datadir 2>/dev/null)
|
|
|
|
let "i = 0"
|
|
|
|
for pck in ${rpmpkg_name[@]}; do
|
|
|
|
pushd $tmpextractdir/$i >/dev/null
|
|
|
|
for f in $( find .${rpmdatadir} -type f 2>/dev/null ); do
|
|
|
|
case $f in
|
|
|
|
.${rpmdatadir}/applnk/*.desktop)
|
|
|
|
let "warning = 1" &&
|
2012-01-13 00:17:57 +01:00
|
|
|
{ notify.warning "${NOTE}${pck##*/}${NORM}"
|
|
|
|
notify.note $"found suspect file"": \
|
|
|
|
\`${NOTE}${f/./}${NORM}' [$(ls -l "$f" | sed 's, .*,,')]"
|
|
|
|
let "total_issues += 1"; } ;;
|
2011-04-26 21:39:44 +02:00
|
|
|
*) ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
popd >/dev/null
|
|
|
|
done
|
|
|
|
[ "$warning" = 0 ] || notify.note "\
|
|
|
|
-----------------------------
|
|
|
|
${NOTE}"$"Hint"":${NORM}
|
|
|
|
"$"create desktop files for:"" ${rpmdatadir}/applications
|
|
|
|
"$"see:"" <http://www.freedesktop.org/>
|
2012-05-19 14:16:01 +02:00
|
|
|
-----------------------------"; }
|
2012-05-19 00:03:42 +02:00
|
|
|
test_number=$(($test_number + 1))
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
# check if a package that do not contains binaries is tagged noarch
|
2012-05-19 14:16:01 +02:00
|
|
|
test.skip $test_number || {
|
|
|
|
notify.note "$(test.num2str). ${NOTE}"\
|
2012-05-19 00:03:42 +02:00
|
|
|
$"checking for packages with bad BuildArch tag""${NORM}..."
|
2011-04-26 21:39:44 +02:00
|
|
|
|
|
|
|
warning=0
|
|
|
|
let "i = 0"
|
|
|
|
for pck in ${rpmpkg_name[@]}; do
|
|
|
|
pushd $tmpextractdir/$i >/dev/null
|
2013-07-19 18:37:44 +02:00
|
|
|
for f in $(LC_ALL=C find -mindepth 2 -type f \
|
|
|
|
-exec file {} \; 2>/dev/null | grep -E "(\
|
|
|
|
ELF | OCaml library | ar archive |\
|
|
|
|
dynamically linked | statically linked )"); do
|
|
|
|
notify.debug "found binary or library file: \`${NOTE}${f/./}${NORM}'"
|
2011-04-26 21:39:44 +02:00
|
|
|
let "warning = 1"
|
|
|
|
break
|
|
|
|
done
|
|
|
|
popd >/dev/null
|
|
|
|
done
|
|
|
|
if [ "$warning" = 0 ]; then
|
2012-01-08 23:37:58 +01:00
|
|
|
[ "$SPEC_BUILDARCH" = "noarch" ] ||
|
|
|
|
{ notify.warning "${NOTE}${pck##*/}${NORM}"
|
|
|
|
notify.note $"this package should be tagged \`noarch'""
|
2011-04-26 21:39:44 +02:00
|
|
|
-----------------------------
|
|
|
|
${NOTE}"$"Hint"":${NORM}
|
|
|
|
BuildArch: noarch
|
2012-01-13 00:17:57 +01:00
|
|
|
-----------------------------"
|
|
|
|
let "total_issues += 1"; }
|
2012-05-19 14:16:01 +02:00
|
|
|
fi; }
|
2012-05-19 00:03:42 +02:00
|
|
|
test_number=$(($test_number + 1))
|
2012-01-13 00:17:57 +01:00
|
|
|
|
2012-05-19 00:03:42 +02:00
|
|
|
notify.note "
|
2012-11-11 23:41:11 +01:00
|
|
|
--> "$"${NOTE}Quality checks: ${#rpmpkg_name[@]} \
|
|
|
|
package(s) checked: ${NORM}${WARN}$total_issues${NORM}${NOTE} warning(s).${NORM}""
|
2012-05-19 00:03:42 +02:00
|
|
|
"
|
2011-04-26 21:39:44 +02:00
|
|
|
}
|