98-clean-chroot: remove packages via dpkg instead of apt-get
[grml-live.git] / etc / grml / fai / config / scripts / GRMLBASE / 98-clean-chroot
1 #!/bin/sh
2 # Filename:      /etc/grml/fai/config/scripts/GRMLBASE/98-clean-chroot
3 # Purpose:       clean up 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 # Latest change: Mon Jän 07 11:33:41 CET 2008 [mika]
8 ################################################################################
9
10 set -e
11
12 # remove some big directories when using class LATEX_CLEANUP:
13 if ifclass LATEX_CLEANUP ; then
14    cp /etc/grml/fai/grml/grml_cleanup_chroot.latex_cleanup $target/root/
15    $ROOTCMD  /root/grml_cleanup_chroot.latex_cleanup
16    rm $target/root/grml_cleanup_chroot.latex_cleanup
17 fi
18
19 # skip tasks which require only when using class NO_ONLINE:
20 if ! ifclass NO_ONLINE ; then
21    cp /etc/grml/fai/grml/grml_cleanup_chroot.online $target/root/
22    $ROOTCMD  /root/grml_cleanup_chroot.online
23    rm $target/root/grml_cleanup_chroot.online
24 fi
25
26 # drop unnecessary software:
27 if ifclass GRML_SMALL || ifclass DEBORPHAN ; then
28    if [ -f /etc/grml/fai/grml/grml_cleanup_chroot.deborphan ] ; then
29       cp /etc/grml/fai/grml/grml_cleanup_chroot.deborphan $target/root/
30       $ROOTCMD  /root/grml_cleanup_chroot.deborphan
31       rm $target/root/grml_cleanup_chroot.deborphan
32    fi
33 fi
34
35 # make sure to drop from grml-small what's unnecessary:
36 if ifclass GRML_SMALL ; then
37    $ROOTCMD dpkg --purge groff-base info locales man-db manpages nano
38 fi
39
40 # remove /usr/share/doc, /usr/share/info,... only in class REMOVE_DOCS:
41 # (important: remove them *after* deinstalling packages, otherwise
42 # removing packages might fail due to lack of /usr/share/man/...)
43 if ifclass REMOVE_DOCS ; then
44    cp /etc/grml/fai/grml/grml_cleanup_chroot.remove_docs $target/root/
45    $ROOTCMD  /root/grml_cleanup_chroot.remove_docs
46    rm $target/root/grml_cleanup_chroot.remove_docs
47 fi
48 # misc cleanup:
49 if [ -f /etc/grml/fai/grml/grml_cleanup_chroot ] ; then
50    cp /etc/grml/fai/grml/grml_cleanup_chroot $target/root/
51    $ROOTCMD  /root/grml_cleanup_chroot
52    rm $target/root/grml_cleanup_chroot
53 fi
54
55 # make sure GRML_SMALL uses the appropriate configuration:
56 if ifclass GRML_SMALL ; then
57    cp $target/etc/inittab.small $target/etc/inittab
58    cp $target/etc/runlevel.conf.livecd.small $target/etc/runlevel.conf
59 fi
60
61 if ifclass RELEASE ; then
62    # Remove all FAI logs from chroot via grml-live later then:
63    touch $target/etc/grml_fai_release
64    # Remove all files inside /root/ of chroot:
65    rm -rf $target/root && mkdir -m 0755 $target/root
66 fi
67
68 ## END OF FILE #################################################################
69 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=3