Install policy-rc.d via /etc/grml/fai/config/hooks/updatebase.GRMLBASE
[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 ################################################################################
8
9 set -e
10
11 # check for policy-rc.d workaround of
12 # /etc/grml/fai/config/hooks/updatebase.GRMLBASE
13 if [ -r $target/usr/sbin/policy-rc.d ] ; then
14    if grep -q 'FAI_ACTION=updatebase' $target/usr/sbin/policy-rc.d ; then
15       rm -f $target/usr/sbin/policy-rc.d
16    fi
17 fi
18
19 # remove some big directories when using class LATEX_CLEANUP:
20 if ifclass LATEX_CLEANUP ; then
21    cp /etc/grml/fai/grml/grml_cleanup_chroot.latex_cleanup $target/root/
22    $ROOTCMD  /root/grml_cleanup_chroot.latex_cleanup
23    rm $target/root/grml_cleanup_chroot.latex_cleanup
24 fi
25
26 # skip tasks which require only when using class NO_ONLINE:
27 if ! ifclass NO_ONLINE ; then
28    cp /etc/grml/fai/grml/grml_cleanup_chroot.online $target/root/
29    $ROOTCMD  /root/grml_cleanup_chroot.online
30    rm $target/root/grml_cleanup_chroot.online
31 fi
32
33 # make sure to drop from grml-small what's unnecessary:
34 if ifclass GRML_SMALL ; then
35    $ROOTCMD apt-get -y --purge remove aptitude
36    for pkg in groff-base info locales man-db manpages nano; do
37      $ROOTCMD apt-get --purge remove --yes $pkg || true
38    done
39 fi
40
41 # drop unnecessary software:
42 if ifclass GRML_SMALL || ifclass DEBORPHAN ; then
43    if [ -f /etc/grml/fai/grml/grml_cleanup_chroot.deborphan ] ; then
44       cp /etc/grml/fai/grml/grml_cleanup_chroot.deborphan $target/root/
45       $ROOTCMD  /root/grml_cleanup_chroot.deborphan
46       rm $target/root/grml_cleanup_chroot.deborphan
47    fi
48 fi
49
50 # remove /usr/share/doc, /usr/share/info,... only in class REMOVE_DOCS:
51 # (important: remove them *after* deinstalling packages, otherwise
52 # removing packages might fail due to lack of /usr/share/man/...)
53 if ifclass REMOVE_DOCS ; then
54    cp /etc/grml/fai/grml/grml_cleanup_chroot.remove_docs $target/root/
55    $ROOTCMD  /root/grml_cleanup_chroot.remove_docs
56    rm $target/root/grml_cleanup_chroot.remove_docs
57 fi
58 # misc cleanup:
59 if [ -f /etc/grml/fai/grml/grml_cleanup_chroot ] ; then
60    cp /etc/grml/fai/grml/grml_cleanup_chroot $target/root/
61    $ROOTCMD  /root/grml_cleanup_chroot
62    rm $target/root/grml_cleanup_chroot
63 fi
64
65 # make sure GRML_SMALL uses the appropriate configuration:
66 if ifclass GRML_SMALL ; then
67    cp $target/etc/inittab.small $target/etc/inittab
68    cp $target/etc/runlevel.conf.livecd.small $target/etc/runlevel.conf
69 fi
70
71 if ifclass RELEASE ; then
72    # Remove all FAI logs from chroot via grml-live later then:
73    touch $target/etc/grml_fai_release
74    # Remove all files inside /root/ of chroot:
75    rm -rf $target/root && mkdir -m 0755 $target/root
76 fi
77
78 ## END OF FILE #################################################################
79 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=3