root/current/host/trunk/emdebian-tools/trunk/pbuilder/emsecondstage

Revision 4532, 3.6 kB (checked in by codehelp, 6 months ago)

ensure root directory has correct permissions

  • Property svn:executable set to *
Line 
1#!/bin/sh
2
3set -e
4#  emsandbox : emdebian rootfs installer
5#
6#  Copyright (C) 2007-2008  Neil Williams <codehelp@debian.org>
7#
8#  This package is free software; you can redistribute it and/or modify
9#  it under the terms of the GNU General Public License as published by
10#  the Free Software Foundation; either version 3 of the License, or
11#  (at your option) any later version.
12#
13#  This program is distributed in the hope that it will be useful,
14#  but WITHOUT ANY WARRANTY; without even the implied warranty of
15#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16#  GNU General Public License for more details.
17#
18#  You should have received a copy of the GNU General Public License
19#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
21# simple wrapper to aid installation of the rootfs
22# Provides a space for pre-installation custom commands as well as simplifying
23# the command line.
24
25TARGET=`pwd`
26
27PROG=emsecondstage
28
29usagehelp () {
30    # print out help message
31    cat <<EOF
32$PROG - emdebian roots installer
33
34Syntax: sudo $PROG
35        sudo $PROG [COMMAND]
36
37Commands:
38-?|-h|--help|-version:      print this help message and exit
39
40Although based on debootstrap, $PROG cannot support the full range of
41debootstrap commands or options.
42
43The standard Emdebian rootfs uses the 'busybox' package with 'dpkg' and
44'apt'. Replacement scripts need to be full debootstrap suite shell
45scripts that specify how to complete the first and second stage
46installations. If the script uses 'busybox', the second-stage install
47function must be compatible with the shell applet in busybox - avoid
48bashisms!
49
50Machine specific customisation hooks need to be shell scripts
51(not bash) located in /debootstrap/machine/config.sh in the top level
52directory of the rootfs. If you used 'emsandbox --machine ...' to
53create the rootfs, the config.sh script for your machine and variant
54has already been installed and will be executed by $PROG.
55
56If the root filesystem used the 'unpack' method, $PROG only has to
57apply the machine specific customisation hooks.
58
59EOF
60}
61
62while [ -n "$1" ]; do
63case "$1" in
64        --help|-h|-?|--version)
65                usagehelp
66                exit;
67        ;;
68        *)
69                echo "Unrecognised command: $1"
70        exit;
71        ;;
72esac
73done
74
75# debootstrap directory removed if successful so avoid running twice.
76if [ -d "$TARGET/debootstrap/" ]; then
77        chmod 0755 $TARGET
78        chroot $TARGET mount proc -t proc /proc || true
79        if [ -f datestring ]; then
80                TIME=`cat datestring`
81                echo "Setting approximate time of $TIME"
82                chroot $TARGET date -s $TIME || true
83        fi
84        echo "Running ldconfig in $TARGET ..."
85        chroot $TARGET /sbin/ldconfig
86        # in_target depmod # can only be run under the installed kernel, not the unpacking one.
87        export DEBCONF_USE_CDEBCONF=true
88        DEBIAN_FRONTEND=noninteractive
89        DEBCONF_NONINTERACTIVE_SEEN=true
90        export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN
91        # bug: See #451130
92        echo "Configuring cdebconf"
93        chroot $TARGET /usr/lib/cdebconf/debconf-loadtemplate /usr/share/debconf/demo /usr/share/debconf/demo.templates
94        echo "Configuring ..."
95        chroot $TARGET dpkg --configure -a
96        echo "Emdebian base system installed successfully in $TARGET."
97fi
98
99if [ -f $TARGET/machine/config.sh ]; then
100        echo "  -> Running second stage config.sh script for this machine variant"
101        sh $TARGET/machine/config.sh
102        rm -r $TARGET/machine/
103fi
104
105if [ -d $TARGET/debootstrap ]; then
106        rm -rf $TARGET/debootstrap
107fi
108
109if [ -d $TARGET/machine ]; then
110        rm -rf $TARGET/machine
111fi
112
113if [ -f $TARGET/0x97BB3B58.txt ]; then
114        rm $TARGET/0x97BB3B58.txt
115fi
116
117if [ -d $TARGET/tmp/buildd ]; then
118        rm -rf $TARGET/tmp/buildd
119fi
120
121# finally, remove self
122if [ -f $TARGET/emsecondstage ]; then
123        rm $TARGET/emsecondstage
124fi
125
126echo "Emdebian base system installed successfully."
Note: See TracBrowser for help on using the browser.