Skip to content

Commit

Permalink
Package validation: also detect packages that failed to install
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mika committed Jan 15, 2012
1 parent d54f224 commit 7477e43
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
17 changes: 14 additions & 3 deletions etc/grml/fai/config/scripts/GRMLBASE/01-packages
Expand Up @@ -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 #################################################################
Expand Down
7 changes: 4 additions & 3 deletions grml-live
Expand Up @@ -754,11 +754,12 @@ else
<testsuite name="grml-live-missing-packages" tests="${package_count}" time="1" failures="${package_errors}" errors="${package_errors}" skipped="0" assertions="0">
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
<testcase name="test_missing_packages_${package}" time="0" assertions="0">
<failure type="RuntimeError" message="Package ${package} is missing">
Package $package is missing in chroot
<failure type="${failure_reason}" message="Package ${package} is missing">
Package $package is missing in chroot (${failure_reason})
</failure>
</testcase>
EOF
Expand Down

0 comments on commit 7477e43

Please sign in to comment.