Rework apt.conf handling in instsoft/updatebase (provide /etc/apt/apt.conf.d/15grml...
[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    ## taken from FAI's lib/updatebase:
28    # some packages must access /proc even in chroot environment
29    mount -t proc proc $FAI_ROOT/proc
30    # some packages must access /sys even in chroot environment
31    mount -t sysfs sysfs $FAI_ROOT/sys
32    # if we are using udev, also mount it into $FAI_ROOT
33    [ -f /etc/init.d/udev ] && mount --bind /dev $FAI_ROOT/dev
34    mount -t devpts devpts $FAI_ROOT/dev/pts
35
36    ## make sure we don't start any daemons - removed
37    ## later on via /etc/grml/fai/config/scripts/GRMLBASE/98-clean-chroot
38    if ! [ -r $target/usr/sbin/policy-rc.d ] ; then
39       cat > $target/usr/sbin/policy-rc.d << EOF
40 #!/bin/sh
41 # FAI_ACTION=updatebase
42 exit 101
43 EOF
44       chmod 755 $target/usr/sbin/policy-rc.d
45    fi
46
47    # skip the task if we want to build a new ISO only:
48    [ -n "$BUILD_ONLY" ] && skiptask instsoft || /bin/true
49
50    exit # make sure we don't continue behind the following "fi"
51 fi
52
53 # no softupdate but updating chroot e.g. based on /etc/grml/fai/config/basefiles/*
54 echo "Action $FAI_ACTION of FAI (hooks/updatebase.GRMLBASE) via grml-live running"
55
56 # install all apt related files
57 fcopy -r /etc/apt
58
59 # remove grml-live's notice file from chroot:
60 if [ -r $target/etc/apt/important_note.txt ] ; then
61    grep -q GRML_LIVE_SOURCES $target/etc/apt/important_note.txt && rm $target/etc/apt/important_note.txt
62 fi
63
64 # install grml gpg key:
65 fcopy /etc/apt/grml.key
66 $ROOTCMD apt-key add /etc/apt/grml.key
67
68 ## END OF FILE #################################################################
69 # vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=3