Use strings instead of --help to detect support of safe-upgrade inside aptitude
[grml-live.git] / etc / grml / fai / config / hooks / instsoft.GRMLBASE
1 #!/bin/sh
2 # Filename:      /etc/grml/fai/config/hooks/instsoft.GRML
3 # Purpose:       grml specific Debian installation in the chroot
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: Sun Nov 04 14:37:26 CET 2007 [mika]
8 ################################################################################
9
10 set -u
11 set -e
12
13 # visualize chroot inside zsh:
14 echo grml_chroot > $target/etc/debian_chroot
15
16 if [ "$FAI_ACTION" = "softupdate" ] ; then
17    echo "Softupdate of FAI via grml-live running"
18
19    if [ -r /etc/resolv.conf ] ; then
20      if [ -r $target/etc/resolvconf/run/resolv.conf ] ; then
21         cat /etc/resolv.conf >> $target/etc/resolvconf/run/resolv.conf
22      else
23         cat /etc/resolv.conf >> $target/etc/resolv.conf
24      fi
25    fi
26
27    if [ -r $target/etc/policy-rc.d.conf ] ; then
28       sed -i "s/EXITSTATUS=.*/EXITSTATUS='101'/" $target/etc/policy-rc.d.conf
29    fi
30
31    # make sure we prefer grml repository:
32    if [ -r /etc/grml/fai/apt/preferences ] ; then
33       cp /etc/grml/fai/apt/preferences $target/etc/apt/preferences
34    fi
35
36    if [ -r /etc/grml/fai/apt/sources.list ] ; then
37       if [ -L $target/etc/apt/sources.list ] ; then
38          rm $target/etc/apt/sources.list
39       fi
40       cp /etc/grml/fai/apt/sources.list $target/etc/apt/sources.list
41    fi
42
43    # FAI softupdate does not execute upgrade, so let's do it on our own:
44    $ROOTCMD apt-get update
45    if [ -x $target/usr/bin/aptitude ] ; then
46       if strings $target/usr/bin/aptitude | grep safe-upgrade 1>/dev/null ; then
47          $ROOTCMD aptitude safe-upgrade
48       else
49          $ROOTCMD aptitude upgrade
50       fi
51    else
52       $ROOTCMD apt-get upgrade
53    fi
54
55 else # no softupdate but fresh installation
56
57 # work around http://trac.lighttpd.net/trac/ticket/657
58 # should be removed later on:
59 echo "Acquire::http::Pipeline-Depth "0"; // added by grml-live" >> $target/etc/apt/apt.conf
60
61 # Recommends just pull in way tooooo much packages, so disable it:
62 echo "APT::Install-Recommends "false"; // added by grml-live"   >> $target/etc/apt/apt.conf
63
64 # install grml keys:
65 gpg --keyserver subkeys.pgp.net      --recv-keys F61E2E7CECDEA787 || \
66 gpg --keyserver blackhole.pca.dfn.de --recv-keys F61E2E7CECDEA787
67 gpg --export F61E2E7CECDEA787 > $target/etc/apt/grml.key
68 $ROOTCMD apt-key add /etc/apt/grml.key
69
70 # make sure we prefer grml repository:
71 if [ -r /etc/grml/fai/files/etc/apt/preferences ] ; then
72    cp /etc/grml/fai/apt/preferences $target/etc/apt/preferences
73 fi
74
75 # make sure we have file-rc available before
76 # package_config/GRML is being executed:
77 $ROOTCMD apt-get update
78 $ROOTCMD aptitude -f -y install file-rc
79
80 # Workaround #443481 of snort for Debian/etch:
81 mkdir -p $target/etc/snort
82 echo 'LOGDIR=/var/log/snort' >> $target/etc/snort/snort.common.parameters
83
84 # we definitely don't want to fail running fai dirinstall just
85 # because of some well known bugs:
86 [ -d $target/etc/apt/apt.conf.d ] || mkdir $target/etc/apt/apt.conf.d
87 cat > $target/etc/apt/apt.conf.d/10apt-listbugs << EOF
88 // Check all packages whether they has critical bugs before they are installed.
89 // If you don't like it, comment it out.
90 //DPkg::Pre-Install-Pkgs {"/usr/sbin/apt-listbugs apt || exit 10"};
91 //DPkg::Tools::Options::/usr/sbin/apt-listbugs "";
92 //DPkg::Tools::Options::/usr/sbin/apt-listbugs::Version "2";
93 EOF
94
95 # make sure /dev/MAKEDEV is available:
96 if [ -x "$target"/sbin/MAKEDEV ] && ! [ -r "$target"/dev/MAKEDEV ] ; then
97    ln -s /sbin/MAKEDEV "$target"/dev/MAKEDEV
98 fi
99
100 # we don't need the invoke-rc.d.d diversion (we have grml-policyrcd :)):
101 if [ -L "$target"/usr/sbin/invoke-rc.d ] ; then
102    rm -f "$target"/usr/sbin/invoke-rc.d
103    $ROOTCMD dpkg-divert --package fai --rename --remove /usr/sbin/invoke-rc.d
104 fi
105
106 fi # end of FAI_ACTION = softupdate
107
108 ## END OF FILE #################################################################
109 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=3