Support -N option to only bootstrap the grml_chroot and skip building of [files for...
[grml-live.git] / etc / grml / fai / config / hooks / updatebase.GRMLBASE
1 #!/bin/bash
2 # Filename:      /etc/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 /etc/grml/fai/config/basefiles/*
58 echo "Action $FAI_ACTION of FAI (hooks/updatebase.GRMLBASE) via grml-live running"
59
60 # install all apt related files
61 fcopy -r /etc/apt
62
63 # remove grml-live's notice file from chroot:
64 if [ -r $target/etc/apt/important_note.txt ] ; then
65    grep -q GRML_LIVE_SOURCES $target/etc/apt/important_note.txt && rm $target/etc/apt/important_note.txt
66 fi
67
68 # install grml gpg key:
69 fcopy /etc/apt/grml.key
70 $ROOTCMD apt-key add /etc/apt/grml.key
71
72 ## END OF FILE #################################################################
73 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=3