Merge remote-tracking branch 'origin/github/pr/145'
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 95-package-information
1 #!/bin/bash
2 # Filename:      ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/95-package-information
3 # Purpose:       store package information of chroot system
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 ################################################################################
8
9 set -u
10 set -e
11
12 if ! [ -w "$LOGDIR" ] ; then
13    echo "Error: can not write to ${LOGDIR}. Exiting.">&2
14    exit 1
15 else
16    # store package list for the build process logs as well:
17    COLUMNS=200 $ROOTCMD dpkg --list > "${LOGDIR}"/dpkg.list
18    COLUMNS=200 $ROOTCMD dpkg --get-selections > "${LOGDIR}"/dpkg.selections
19    # store list of packages sorted by size:
20    if [ -x $target/usr/bin/dpkg-query ] ; then
21       $ROOTCMD dpkg-query -W --showformat='${Package}\t${Installed-Size}\n' > \
22       "${LOGDIR}"/packages.size
23    fi
24    # store a list of non-free packages and their licenses
25    if $ROOTCMD test -x /usr/bin/aptitude ; then
26       echo "The following packages from the Debian non-free section are included in this release" \
27          > "${LOGDIR}"/nonfree-licenses.txt
28       echo >> "${LOGDIR}"/nonfree-licenses.txt
29       for pkg in `$ROOTCMD aptitude search '~i ~snon-free' -F '%p'` ; do
30          echo "Package: ${pkg}" >> "${LOGDIR}"/nonfree-licenses.txt
31          echo "========================================================================" \
32             >> "${LOGDIR}"/nonfree-licenses.txt
33          if $ROOTCMD test -r "/usr/share/doc/${pkg}/copyright" ; then
34             $ROOTCMD cat "/usr/share/doc/${pkg}/copyright" >> "${LOGDIR}"/nonfree-licenses.txt
35          else
36             echo "${pkg} does not provide a copyright file" >> "${LOGDIR}"/nonfree-licenses.txt
37          fi
38          echo >> "${LOGDIR}"/nonfree-licenses.txt
39       done
40    fi
41 fi
42
43 ## END OF FILE #################################################################
44 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2