From 7477e438623f7581965a95d82cba282e38fdeb6e Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Sun, 15 Jan 2012 23:05:08 +0100 Subject: [PATCH] Package validation: also detect packages that failed to install So far we detected only packages that have been requested for installation but failed because the package isn't *available* (as in not available in the configured Debian repositories). Without checking for packages that have been requested for installation but failed because of dependency issues we might be left in a state with missing packages. So let's check for both situations and generate according JUnit reports. --- etc/grml/fai/config/scripts/GRMLBASE/01-packages | 17 ++++++++++++++--- grml-live | 7 ++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/etc/grml/fai/config/scripts/GRMLBASE/01-packages b/etc/grml/fai/config/scripts/GRMLBASE/01-packages index 467586c..b13aab5 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/01-packages +++ b/etc/grml/fai/config/scripts/GRMLBASE/01-packages @@ -15,11 +15,22 @@ if ! [ -r "$target/${PACKAGE_LIST}" ] ; then echo "No $target/${PACKAGE_LIST} found, will not run package validation check." else printf "Validating package list: " - if $ROOTCMD dpkg --list $(grep -v '^#' $target/${PACKAGE_LIST} | grep -v -- '-$') >/dev/null 2>$LOGDIR/package_errors.log ; then - printf "done - no errors found\n" - else + TMPFILE=$(mktemp) + + $ROOTCMD dpkg --list $(grep -v '^#' $target/${PACKAGE_LIST} | grep -v -- '-$') 2>&1 | \ + grep -e '^un' -e 'No packages' > "$TMPFILE" || true + + awk '/^un/ {print $2 " not_installable"}' "$TMPFILE" > "$LOGDIR/package_errors.log" + awk '/^No packages found matching/ {print $5 " not_available"}' "$TMPFILE" | \ + sed 's/\. / /' >> "$LOGDIR/package_errors.log" + + if [ -s "$TMPFILE" ] ; then printf "failed (there have been errors, find them at $LOGDIR/package_errors.log)\n" + else + printf "done - no errors found\n" fi + + rm -f "$TMPFILE" fi ## END OF FILE ################################################################# diff --git a/grml-live b/grml-live index 1b119c1..efd7f7c 100755 --- a/grml-live +++ b/grml-live @@ -754,11 +754,12 @@ else EOF - for package in $(awk '{print $5}' "${CHECKLOG}/package_errors.log" | sed 's/\.$//') ; do + for package in $(awk '{print $1}' "${CHECKLOG}/package_errors.log") ; do + failure_reason="$(awk "/$package/ {print \$2}" "${CHECKLOG}/package_errors.log")" cat >> "${REPORT_MISSING_PACKAGES}" << EOF - -Package $package is missing in chroot + +Package $package is missing in chroot (${failure_reason}) EOF -- 2.1.4