SW: add f2fs-tools to GRML_SMALL + GRML_FULL
[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 . "$GRML_LIVE_CONFIG"
12
13 # visualize chroot inside zsh:
14 echo grml_chroot > $target/etc/debian_chroot
15
16 echo "$HOSTNAME" > $target/etc/hostname
17
18 if [ -n "${APT_PROXY:-}" ] ; then
19   cat > $target/etc/apt/apt.conf.d/90grml-apt-proxy.conf <<EOF
20 Acquire::http { Proxy "$APT_PROXY"; };
21 EOF
22 fi
23
24 if [ "$FAI_ACTION" = "softupdate" ] ; then
25    echo "Action $FAI_ACTION of FAI (hooks/updatebase.GRMLBASE) via grml-live running"
26
27    # otherwise we're running 'aptitude update' even on with -b option
28    skiptask updatebase
29
30    ## based on FAI's lib/updatebase:
31    # some packages must access /proc even in chroot environment
32    if ! [ -d $FAI_ROOT/proc/1 ] ; then
33       mount -t proc proc $FAI_ROOT/proc || true
34    fi
35    # some packages must access /sys even in chroot environment
36    if ! [ -d $FAI_ROOT/sys/kernel ] ; then
37       mount -t sysfs sysfs $FAI_ROOT/sys
38    fi
39    # if we are using udev, also mount it into $FAI_ROOT
40    if [ -f /etc/init.d/udev ] ; then
41       mount --bind /dev $FAI_ROOT/dev || true
42    fi
43
44    if [ -d $FAI_ROOT/run ] ; then
45       mount -t tmpfs tmpfs $FAI_ROOT/run
46       mkdir $FAI_ROOT/run/lock
47    fi
48
49    mount -t devpts devpts $FAI_ROOT/dev/pts || true
50
51    # skip the task if we want to build a new ISO only,
52    # this means we do NOT update any packages
53    if [ -n "$BUILD_ONLY" ] ; then
54       skiptask instsoft || true
55    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 # work around #632624: udev fails to install on systems with old kernel versions
64 if ! [ -e ${target}/etc/udev/kernel-upgrade ] ; then
65   echo "Working around udev package bug, creating /etc/udev/kernel-upgrade"
66   echo "# installed via updatebase.GRMLBASE" > ${target}/etc/udev/kernel-upgrade
67 fi
68
69 # install all apt related files
70 fcopy -i -B -v -r /etc/apt
71
72 # install packages from a repository of a specific date
73 if [ -n "${WAYBACK_DATE:-}" ] ; then
74   echo "Wayback date '$WAYBACK_DATE' identified, enabling for snapshot.debian.org usage."
75
76   perl -pi -e "s#^(\s+)(deb.* )(.*://ftp.debian.org.*?)\s+([a-z-]+)\s+(.*)\$#\$1\$2 [check-valid-until=no] http://snapshot.debian.org/archive/debian/$WAYBACK_DATE/ \$4 \$5#" \
77     "${target}/etc/apt/sources.list.d/debian.list"
78
79   perl -pi -e "s#^(\s+)(deb.* )(.*://security.debian.org.*?)\s+([a-z-/]+)\s+(.*)\$#\$1\$2 [check-valid-until=no] http://snapshot.debian.org/archive/debian-security/$WAYBACK_DATE/ \$4 \$5#" \
80     "${target}/etc/apt/sources.list.d/debian.list"
81 fi
82
83 ## END OF FILE #################################################################
84 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2