f88f0fb988677163b81ec9833b20041613220929
[grml-live.git] / etc / grml / fai / config / hooks / updatebase.GRMLBASE
1 #!/bin/bash
2 # Filename:      ${GRML_FAI_CONFIG}/hooks/updatebase.GRMLBASE
3 # Purpose:       Updates the base packages of the system, prepare chroot for instsoft
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 # visualize chroot inside zsh:
13 echo grml_chroot > $target/etc/debian_chroot
14
15 HOSTNAME=''
16 [ -r /etc/grml/grml-live.conf ]  && . /etc/grml/grml-live.conf
17 [ -r /etc/grml/grml-live.local ] && . /etc/grml/grml-live.local
18 [ -n "$HOSTNAME" ] || HOSTNAME=grml
19 echo "$HOSTNAME" > $target/etc/hostname
20
21 if [ "$FAI_ACTION" = "softupdate" ] ; then
22    echo "Action $FAI_ACTION of FAI (hooks/updatebase.GRMLBASE) via grml-live running"
23
24    ## we want to use our own sources.list:
25    skiptask updatebase
26
27    ## based on FAI's lib/updatebase:
28    # some packages must access /proc even in chroot environment
29    if ! [ -d $FAI_ROOT/proc/1 ] ; then
30       mount -t proc proc $FAI_ROOT/proc || true
31    fi
32    # some packages must access /sys even in chroot environment
33    if ! [ -d $FAI_ROOT/sys/kernel ] ; then
34       mount -t sysfs sysfs $FAI_ROOT/sys
35    fi
36    # if we are using udev, also mount it into $FAI_ROOT
37    if [ -f /etc/init.d/udev ] ; then
38       mount --bind /dev $FAI_ROOT/dev || true
39    fi
40
41    mount -t devpts devpts $FAI_ROOT/dev/pts || true
42
43    # skip the task if we want to build a new ISO only,
44    # this means we do NOT update any packages
45    if [ -n "$BUILD_ONLY" ] ; then
46       skiptask instsoft || true
47    fi
48
49    exit # make sure we don't continue behind the following "fi"
50 fi
51
52 if [ -n "$BOOTSTRAP_ONLY" ] ; then
53   echo "Skipping task configure in hooks/updatebase.GRMLBASE as BOOTSTRAP_ONLY environment is set."
54   skiptask configure
55 fi
56
57 # no softupdate but updating chroot e.g. based on ${GRML_FAI_CONFIG}/basefiles/*
58 echo "Action $FAI_ACTION of FAI (hooks/updatebase.GRMLBASE) via grml-live running"
59
60 # work around #632624: udev fails to install on systems with old kernel versions
61 if ! [ -e ${target}/etc/udev/kernel-upgrade ] ; then
62   echo "Working around udev package bug, creating /etc/udev/kernel-upgrade"
63   echo "# installed via updatebase.GRMLBASE" > ${target}/etc/udev/kernel-upgrade
64 fi
65
66 # install all apt related files
67 fcopy -v /etc/apt/grml.key
68 fcopy -v /etc/apt/preferences
69 fcopy -v /etc/apt/apt.conf.d/20pdiffs
70 fcopy -v /etc/apt/apt.conf.d/15grml-live
71
72 # this is the auto-generated sources.list file by grml-live,
73 # will be overriden by $GRML_FAI_CONFIG/scripts/GRMLBASE/33-aptsetup
74 fcopy -v -c GRML_LIVE_SOURCES_LIST /etc/apt/sources.list
75
76 # install Grml gpg key:
77 $ROOTCMD apt-key add /etc/apt/grml.key
78
79 ## END OF FILE #################################################################
80 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2