| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | set -e |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | TARGET=`pwd` |
|---|
| 26 | |
|---|
| 27 | PROG=emsecondstage |
|---|
| 28 | |
|---|
| 29 | usagehelp () { |
|---|
| 30 | |
|---|
| 31 | cat <<EOF |
|---|
| 32 | $PROG - emdebian roots installer |
|---|
| 33 | |
|---|
| 34 | Syntax: sudo $PROG |
|---|
| 35 | sudo $PROG [COMMAND] |
|---|
| 36 | |
|---|
| 37 | Commands: |
|---|
| 38 | -?|-h|--help|-version: print this help message and exit |
|---|
| 39 | |
|---|
| 40 | Although based on debootstrap, $PROG cannot support the full range of |
|---|
| 41 | debootstrap commands or options. |
|---|
| 42 | |
|---|
| 43 | The standard Emdebian rootfs uses the 'busybox' package with 'dpkg' and |
|---|
| 44 | 'apt'. Replacement scripts need to be full debootstrap suite shell |
|---|
| 45 | scripts that specify how to complete the first and second stage |
|---|
| 46 | installations. If the script uses 'busybox', the second-stage install |
|---|
| 47 | function must be compatible with the shell applet in busybox - avoid |
|---|
| 48 | bashisms! |
|---|
| 49 | |
|---|
| 50 | Machine specific customisation hooks need to be shell scripts |
|---|
| 51 | (not bash) located in /debootstrap/machine/config.sh in the top level |
|---|
| 52 | directory of the rootfs. If you used 'emsandbox --machine ...' to |
|---|
| 53 | create the rootfs, the config.sh script for your machine and variant |
|---|
| 54 | has already been installed and will be executed by $PROG. |
|---|
| 55 | |
|---|
| 56 | If the root filesystem used the 'unpack' method, $PROG only has to |
|---|
| 57 | apply the machine specific customisation hooks. |
|---|
| 58 | |
|---|
| 59 | EOF |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | while [ -n "$1" ]; do |
|---|
| 63 | case "$1" in |
|---|
| 64 | --help|-h|-?|--version) |
|---|
| 65 | usagehelp |
|---|
| 66 | exit; |
|---|
| 67 | ;; |
|---|
| 68 | *) |
|---|
| 69 | echo "Unrecognised command: $1" |
|---|
| 70 | exit; |
|---|
| 71 | ;; |
|---|
| 72 | esac |
|---|
| 73 | done |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | if [ -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 | |
|---|
| 87 | export DEBCONF_USE_CDEBCONF=true |
|---|
| 88 | DEBIAN_FRONTEND=noninteractive |
|---|
| 89 | DEBCONF_NONINTERACTIVE_SEEN=true |
|---|
| 90 | export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN |
|---|
| 91 | |
|---|
| 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." |
|---|
| 97 | fi |
|---|
| 98 | |
|---|
| 99 | if [ -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/ |
|---|
| 103 | fi |
|---|
| 104 | |
|---|
| 105 | if [ -d $TARGET/debootstrap ]; then |
|---|
| 106 | rm -rf $TARGET/debootstrap |
|---|
| 107 | fi |
|---|
| 108 | |
|---|
| 109 | if [ -d $TARGET/machine ]; then |
|---|
| 110 | rm -rf $TARGET/machine |
|---|
| 111 | fi |
|---|
| 112 | |
|---|
| 113 | if [ -f $TARGET/0x97BB3B58.txt ]; then |
|---|
| 114 | rm $TARGET/0x97BB3B58.txt |
|---|
| 115 | fi |
|---|
| 116 | |
|---|
| 117 | if [ -d $TARGET/tmp/buildd ]; then |
|---|
| 118 | rm -rf $TARGET/tmp/buildd |
|---|
| 119 | fi |
|---|
| 120 | |
|---|
| 121 | |
|---|
| 122 | if [ -f $TARGET/emsecondstage ]; then |
|---|
| 123 | rm $TARGET/emsecondstage |
|---|
| 124 | fi |
|---|
| 125 | |
|---|
| 126 | echo "Emdebian base system installed successfully." |
|---|