2 # Filename: ${GRML_FAI_CONFIG}/hooks/instsoft.GRMLBASE
3 # Purpose: Grml specific software installation in the chroot, executed after updatebase
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 ################################################################################
10 if ifclass FILE_RC ; then
17 # if hooks/updatebase.GRMLBASE fails for whatever reason
18 # and can't skip instsoft.GRMLBASE we have to make sure
19 # we exit here as well
20 if [ -n "$BUILD_ONLY" ] ; then
21 "Exiting hooks/instsoft.GRMLBASE as BUILD_ONLY environment is set."
25 if [ "$FAI_ACTION" = "softupdate" ] ; then
26 echo "Action $FAI_ACTION of FAI (hooks/instsoft.GRMLBASE) via grml-live running"
28 # /etc/resolv.conf is usually a symlink, pointing out of the chroot.
29 # Make it a file with known contents.
30 rm -f "${target}"/etc/resolv.conf
31 cat /etc/resolv.conf >> "$target"/etc/resolv.conf
33 if [ -r $target/etc/policy-rc.d.conf ] ; then
34 sed -i "s/EXITSTATUS=.*/EXITSTATUS='101'/" $target/etc/policy-rc.d.conf
37 # we definitely don't want to fail running fai sofupdate just
38 # because of some well known bugs:
39 [ -d $target/etc/apt/apt.conf.d ] || mkdir $target/etc/apt/apt.conf.d
40 cat > $target/etc/apt/apt.conf.d/10apt-listbugs << EOF
41 // Check all packages whether they has critical bugs before they are installed.
42 // If you don't like it, comment it out.
43 //DPkg::Pre-Install-Pkgs {"/usr/sbin/apt-listbugs apt || exit 10"};
44 //DPkg::Tools::Options::/usr/sbin/apt-listbugs "";
45 //DPkg::Tools::Options::/usr/sbin/apt-listbugs::Version "2";
48 # work around /etc/kernel/postinst.d/zz-update-grub failing
49 # inside openvz environment, see #597084
50 if ! $ROOTCMD dpkg-divert --list | grep -q '/usr/sbin/update-grub' ; then
51 echo "Diverting update-grub executable"
52 $ROOTCMD dpkg-divert --rename --add /usr/sbin/update-grub
53 $ROOTCMD ln -s /bin/true /usr/sbin/update-grub
56 # work around a bug which causes openvz to freeze when grub-probe is invoked
57 if ! $ROOTCMD dpkg-divert --list | grep -q '/usr/sbin/grub-probe' ; then
58 echo "Diverting grub-probe executable"
59 $ROOTCMD dpkg-divert --rename --add /usr/sbin/grub-probe
60 $ROOTCMD ln -s /bin/true /usr/sbin/grub-probe
63 # Update package lists (so they exist at all), so we can install
64 # software; if /var/lib/dpkg/available is empty, it was was probably
65 # cleaned by GRMLBASE/98-clean-chroot, so we need to rebuild it
67 $ROOTCMD /usr/lib/dpkg/methods/apt/update /var/lib/dpkg/ apt apt
70 echo "Installing file-rc as FILE_RC class is enabled."
71 # newer aptitude versions won't remove essential packages using
72 # 'aptitude -f -y install file-rc' anymore, therefore force it:
73 $ROOTCMD aptitude -o Aptitude::ProblemResolver::Keep-All-Tier=60000 -f -y install file-rc systemd-sysv-
76 if ! $ROOTCMD test -x /usr/bin/aptitude ; then
77 $ROOTCMD apt-get -y install aptitude
80 # make sure we can upgrade automatically,
81 # even with unsigned repos, but only if user wants it
82 if [ "${FAI_ALLOW_UNSIGNED:-}" = "1" ] ; then
83 APTGET_OPTS="${APTGET_OPTS:-} --allow-unauthenticated"
84 APTITUDE_OPTS="${APTITUDE_OPTS:-} --allow-untrusted"
87 # make sure we don't fail when configuration files changed
88 APTGET_OPTS="${APTGET_OPTS:-} -o DPkg::Options::=--force-confdef -o DPkg::Options::=--force-confmiss -o DPkg::Options::=--force-confnew"
89 APTITUDE_OPTS="${APTITUDE_OPTS:-} -o DPkg::Options::=--force-confdef -o DPkg::Options::=--force-confmiss -o DPkg::Options::=--force-confnew"
91 if $ROOTCMD test -x /usr/bin/aptitude ; then
92 if $ROOTCMD aptitude --help | grep -q safe-upgrade ; then
93 APT_LISTCHANGES_FRONTEND=none APT_LISTBUGS_FRONTEND=none $ROOTCMD aptitude -y $APTITUDE_OPTS safe-upgrade
95 APT_LISTCHANGES_FRONTEND=none APT_LISTBUGS_FRONTEND=none $ROOTCMD aptitude -y $APTITUDE_OPTS upgrade
98 APT_LISTCHANGES_FRONTEND=none APT_LISTBUGS_FRONTEND=none $ROOTCMD apt-get -y $APTGET_OPTS --force-yes upgrade
101 exit # make sure we don't continue behind the following "fi"
104 # no softupdate but fresh installation
105 echo "Action $FAI_ACTION of FAI (hooks/instsoft.GRMLBASE) via grml-live running"
107 # work around /etc/kernel/postinst.d/zz-update-grub failing
108 # inside openvz environment, see #597084
109 if ! $ROOTCMD dpkg-divert --list | grep -q '/usr/sbin/update-grub' ; then
110 echo "Diverting update-grub executable"
111 $ROOTCMD dpkg-divert --rename --add /usr/sbin/update-grub
112 $ROOTCMD ln -s /bin/true /usr/sbin/update-grub
115 # work around a bug which causes openvz to freeze when grub-probe is invoked
116 if ! $ROOTCMD dpkg-divert --list | grep -q '/usr/sbin/grub-probe' ; then
117 echo "Diverting grub-probe executable"
118 $ROOTCMD dpkg-divert --rename --add /usr/sbin/grub-probe
119 $ROOTCMD ln -s /bin/true /usr/sbin/grub-probe
122 # make sure we have file-rc available before package_config/GRML* is being executed {{{
123 # the apt-get update might return an error if there's for example
124 # a hashsum mismatch on Debian mirror sources, we might want to continue
125 # but should warn the user
126 if ! $ROOTCMD apt-get update ; then
127 echo "Warning: there was an error executing apt-get update, continuing anyway."
128 echo "Warning: there was an error executing apt-get update, continuing anyway." >&2
132 echo "Installing file-rc as FILE_RC class is enabled."
133 # newer aptitude versions won't remove essential packages using
134 # 'aptitude -f -y install file-rc' anymore, therefore force it via:
135 $ROOTCMD aptitude -o Aptitude::ProblemResolver::Keep-All-Tier=60000 -f -y install file-rc systemd-sysv-
139 # we definitely don't want to fail running fai dirinstall just
140 # because of some well known bugs:
141 [ -d $target/etc/apt/apt.conf.d ] || mkdir $target/etc/apt/apt.conf.d
142 cat > $target/etc/apt/apt.conf.d/10apt-listbugs << EOF
143 // Check all packages whether they has critical bugs before they are installed.
144 // If you don't like it, comment it out.
145 //DPkg::Pre-Install-Pkgs {"/usr/sbin/apt-listbugs apt || exit 10"};
146 //DPkg::Tools::Options::/usr/sbin/apt-listbugs "";
147 //DPkg::Tools::Options::/usr/sbin/apt-listbugs::Version "2";
150 # make sure /dev/MAKEDEV is available:
151 if [ -x "$target"/sbin/MAKEDEV ] && ! [ -r "$target"/dev/MAKEDEV ] ; then
152 ln -s /sbin/MAKEDEV "$target"/dev/MAKEDEV
155 # we don't need the invoke-rc.d.d diversion (we have grml-policyrcd :)):
156 if [ -L "$target"/usr/sbin/invoke-rc.d ] ; then
157 rm -f "$target"/usr/sbin/invoke-rc.d
158 $ROOTCMD dpkg-divert --package fai --rename --remove /usr/sbin/invoke-rc.d
161 ## END OF FILE #################################################################
162 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2