updatebase.GRMLBASE: run recursive fcopy with -B to avoid backup files
[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 [ -n "${APT_PROXY:-}" ] ; then
22   cat > $target/etc/apt/apt.conf.d/90grml-apt-proxy.conf <<EOF
23 Acquire::http { Proxy "$APT_PROXY"; };
24 EOF
25 fi
26
27 if [ "$FAI_ACTION" = "softupdate" ] ; then
28    echo "Action $FAI_ACTION of FAI (hooks/updatebase.GRMLBASE) via grml-live running"
29
30    ## we want to use our own sources.list:
31    skiptask updatebase
32
33    ## based on FAI's lib/updatebase:
34    # some packages must access /proc even in chroot environment
35    if ! [ -d $FAI_ROOT/proc/1 ] ; then
36       mount -t proc proc $FAI_ROOT/proc || true
37    fi
38    # some packages must access /sys even in chroot environment
39    if ! [ -d $FAI_ROOT/sys/kernel ] ; then
40       mount -t sysfs sysfs $FAI_ROOT/sys
41    fi
42    # if we are using udev, also mount it into $FAI_ROOT
43    if [ -f /etc/init.d/udev ] ; then
44       mount --bind /dev $FAI_ROOT/dev || true
45    fi
46
47    mount -t devpts devpts $FAI_ROOT/dev/pts || true
48
49    # skip the task if we want to build a new ISO only,
50    # this means we do NOT update any packages
51    if [ -n "$BUILD_ONLY" ] ; then
52       skiptask instsoft || true
53    fi
54
55    exit # make sure we don't continue behind the following "fi"
56 fi
57
58 if [ -n "$BOOTSTRAP_ONLY" ] ; then
59   echo "Skipping task configure in hooks/updatebase.GRMLBASE as BOOTSTRAP_ONLY environment is set."
60   skiptask configure
61 fi
62
63 # no softupdate but updating chroot e.g. based on ${GRML_FAI_CONFIG}/basefiles/*
64 echo "Action $FAI_ACTION of FAI (hooks/updatebase.GRMLBASE) via grml-live running"
65
66 # work around #632624: udev fails to install on systems with old kernel versions
67 if ! [ -e ${target}/etc/udev/kernel-upgrade ] ; then
68   echo "Working around udev package bug, creating /etc/udev/kernel-upgrade"
69   echo "# installed via updatebase.GRMLBASE" > ${target}/etc/udev/kernel-upgrade
70 fi
71
72 # install all apt related files
73 fcopy -B -v -r /etc/apt
74
75 # install Grml gpg key:
76 $ROOTCMD apt-key add /etc/apt/grml.key
77
78 ## END OF FILE #################################################################
79 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2