2 # Filename: ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/01-packages
3 # Purpose: check for packages that have been requested but could not be installed
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2 or any later version.
7 ################################################################################
12 echo -n > "${LOGDIR}"/package_errors.log # ensure we start with an empty file
14 if ! [ -e "${LOGDIR}"/software.log ] ; then
15 echo "Warning: no ${LOGDIR}/software.log found (build/update run?), skipping check for unknown packages."
17 if grep -q 'These unknown packages' "${LOGDIR}"/software.log ; then
18 echo "Identified unknown packages in ${LOGDIR}/software.log"
19 grep 'These unknown packages' "${LOGDIR}"/software.log | \
20 sed 's/.*These unknown packages.*: //; s/ / not_installable\n/g' >> "${LOGDIR}/package_errors.log"
24 PACKAGE_LIST=/var/log/install_packages.list
25 # shellcheck disable=SC2154
26 if ! [ -r "${target}/${PACKAGE_LIST}" ] ; then
27 echo "No ${target}/${PACKAGE_LIST} found, will not run package validation check."
29 echo "Validating package list against dpkg state..."
34 # 1) catch packages that aren't in state 'ii' (marked for installation
35 # and successfully instead) on stdout
36 # 2) catch error messages like 'dpkg-query: no packages found matching $package"
37 # for packages unknown to dpkg on stderr
38 # NOTE: 'grep -v -- '-$' ignores packages in FAI's package list that are
40 # shellcheck disable=SC2046
41 ${ROOTCMD} dpkg --list $(grep -v '^#' "${target}/${PACKAGE_LIST}" | grep -v -- '-$') 2>"${TMPSTDERR}" | \
42 grep -e '^[urph][ncufhWt]' > "${TMPSTDOUT}" || true
44 # extract packages from stdout
45 awk '/^un/ {print $2 " not_installable"}' "${TMPSTDOUT}" >> "${LOGDIR}/package_errors.log"
47 # extract packages from stderr
48 grep 'packages found matching' "${TMPSTDERR}" | \
49 sed 's/dpkg-query: [Nn]o packages found matching \(.*\)/\1 not_installable/' >> "${LOGDIR}/package_errors.log"
51 rm -f "${TMPSTDOUT}" "${TMPSTDERR}"
54 if [ -s "${LOGDIR}/package_errors.log" ] ; then
55 echo "Warning: failed (there have been errors, find them at ${LOGDIR}/package_errors.log)."
57 echo "Done - no errors found."
60 ## END OF FILE #################################################################
61 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2