linuxrc: just added a comment regarding booting via pcmcia (which is not available...
[grml-live.git] / scripts / 02_chroot.sh
1 # Filename:      02_chroot.sh
2 # Purpose:       build script for creating grml live-cd
3 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
4 # Bug-Reports:   see http://grml.org/bugs/
5 # License:       This file is licensed under the GPL v2.
6 # Latest change: Tue Feb 13 00:37:19 CET 2007
7 ################################################################################
8
9 chroot_shell() {
10   chroot "$TARGET" /bin/bash
11 }
12
13 chroot_exec() {
14   chroot "$TARGET" /usr/bin/env -i HOME="/root" PATH="/usr/sbin:/usr/bin:/sbin:/bin" TERM="${TERM}" \
15   DEBIAN_FRONTEND="${DEBCONF_FRONTEND}" DEBIAN_PRIORITY="${DEBCONF_PRIORITY}" ${1}
16   return $?
17 }
18
19 patch_chroot() {
20   case "${1}" in
21
22        apply)
23           debug "executing patch_chroot in apply mode"
24           echo "grml-live" > "${TARGET}"/etc/debian_chroot
25           [ -f "${TARGET}"/etc/hosts ] && cp "${TARGET}"/etc/hosts "$TARGET"/etc/hosts.orig
26           [ -f /etc/hosts ]            && cp /etc/hosts "$TARGET"/etc/hosts
27           [ -f "${TARGET}"/etc/resolv.conf ] && cp "${TARGET}"/etc/resolv.conf "$TARGET"/etc/resolv.conf.orig
28           [ -f /etc/resolv.conf ]            && cp /etc/resolv.conf "$TARGET"/etc/resolv.conf
29           # TODO: make sure to fix setup of grml-policy.rc.d
30           cat > "${TARGET}"/usr/sbin/policy-rc.d <<EOF
31 #!/bin/sh
32 echo
33 echo "Information: policy-rc.d in action."
34 exit 101
35 EOF
36           chmod 755 "${TARGET}"/usr/sbin/policy-rc.d
37           ;;
38
39        deapply)
40           debug "executing patch_chroot in deapply mode"
41           rm -f "${TARGET}"/etc/debian_chroot
42
43           if [ -f "${TARGET}"/etc/hosts.orig ] ; then
44              mv "${TARGET}"/etc/hosts.orig "$TARGET"/etc/hosts
45           else
46              rm -f "$TARGET"/etc/hosts
47           fi
48
49           # TODO: adjust for grml-policy.rc.d
50           if [ -f "${TARGET}"/etc/resolv.conf.orig ] ; then
51              mv "${TARGET}"/etc/resolv.conf.orig "$TARGET"/etc/resolv.conf
52           else
53              rm -f "$TARGET"/etc/resolv.conf
54           fi
55
56           rm -f "${TARGET}"/usr/sbin/policy-rc.d
57           ;;
58   esac
59 }
60
61 chroot_live_prepare() {
62   debug "preparing grml-live directory in chroot"
63   if [ -n "$SOURCES_LIST" ] ; then
64      echo $SOURCES_LIST > "${TARGET}"/grml-live/files/sources.list
65   fi
66
67   cat > "${TARGET}"/grml-live/scripts/install_packages.sh << EOF
68 #!/bin/sh
69
70 if ! [ -f /etc/apt/grml.key ] ; then
71    gpg --keyserver subkeys.pgp.net --recv-keys F61E2E7CECDEA787
72    gpg --export F61E2E7CECDEA787 > /etc/apt/grml.key
73    apt-key add /etc/apt/grml.key
74 fi
75
76 apt-get update
77 apt-get upgrade
78
79 EOF
80
81   chmod 755 "${TARGET}"/grml-live/scripts/install_packages.sh
82 }
83
84 chroot_live_execute() {
85   debug "executing grml-live script in chroot"
86   chroot_exec /grml-live/scripts/install_packages.sh
87 }
88
89 ## END OF FILE #################################################################
90 # vim: ai tw=80 ft=sh expandtab