paul@32 | 1 | #!/bin/sh |
paul@32 | 2 | |
paul@63 | 3 | # Copyright (C) 2011, 2013 Paul Boddie <paul@boddie.org.uk> |
paul@63 | 4 | # |
paul@63 | 5 | # This program is free software; you can redistribute it and/or modify it under |
paul@63 | 6 | # the terms of the GNU General Public License as published by the Free Software |
paul@63 | 7 | # Foundation; either version 3 of the License, or (at your option) any later |
paul@63 | 8 | # version. |
paul@63 | 9 | # |
paul@63 | 10 | # This program is distributed in the hope that it will be useful, but WITHOUT |
paul@63 | 11 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@63 | 12 | # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@63 | 13 | # details. |
paul@63 | 14 | # |
paul@63 | 15 | # You should have received a copy of the GNU General Public License along with |
paul@63 | 16 | # this program. If not, see <http://www.gnu.org/licenses/>. |
paul@63 | 17 | |
paul@32 | 18 | # Configuration: |
paul@32 | 19 | if [ -e userinstall-defaults-uml ]; then |
paul@32 | 20 | . "$PWD/userinstall-defaults-uml" |
paul@32 | 21 | elif [ -e /etc/default/userinstall-uml ]; then |
paul@32 | 22 | . /etc/default/userinstall-uml |
paul@32 | 23 | else |
paul@32 | 24 | echo "No defaults found for userinstall (UML)." 1>&2 |
paul@32 | 25 | exit 1 |
paul@32 | 26 | fi |
paul@32 | 27 | |
paul@32 | 28 | if [ ! -e "$PACKAGEROOT" ]; then |
paul@32 | 29 | echo "A package root must first be made using user-setup." 1>&2 |
paul@32 | 30 | exit 1 |
paul@32 | 31 | fi |
paul@32 | 32 | |
paul@32 | 33 | if [ ! "$IMAGEDIR" ]; then |
paul@32 | 34 | echo "An image directory must be defined." 1>&2 |
paul@32 | 35 | exit 1 |
paul@32 | 36 | fi |
paul@32 | 37 | |
paul@32 | 38 | THISDIR=`dirname "$0"` |
paul@32 | 39 | |
paul@32 | 40 | echo "Installing the package root..." 1>&2 |
paul@69 | 41 | if ! touch "$PACKAGEROOT/root/tmp-uml-make-image" ; then |
paul@69 | 42 | echo "The permissions for copying files from the package root into the image appear to be wrong." 1>&2 |
paul@69 | 43 | echo "You may be accessing a root-owned package root and thus need to specify --root as an option." 1>&2 |
paul@69 | 44 | exit 1 |
paul@69 | 45 | else |
paul@69 | 46 | rm "$PACKAGEROOT/root/tmp-uml-make-image" |
paul@69 | 47 | fi |
paul@69 | 48 | |
paul@32 | 49 | cp -a "$PACKAGEROOT/"* "$IMAGEDIR"/ |
paul@32 | 50 | |
paul@32 | 51 | if [ -h "$IMAGEDIR/dev" ]; then |
paul@34 | 52 | echo "Removing linked /dev entry..." 1>&2 |
paul@32 | 53 | rm "$IMAGEDIR/dev" |
paul@32 | 54 | fi |
paul@32 | 55 | |
paul@34 | 56 | if [ -e "$IMAGEDIR/dev" ]; then |
paul@34 | 57 | echo "Moving existing /dev directory..." 1>&2 |
paul@34 | 58 | mv "$IMAGEDIR/dev" "$IMAGEDIR/dev.old" |
paul@34 | 59 | fi |
paul@34 | 60 | |
paul@32 | 61 | if [ ! -e "$IMAGEDIR/dev" ]; then |
paul@34 | 62 | echo "Making /dev directory..." 1>&2 |
paul@32 | 63 | mkdir "$IMAGEDIR/dev" |
paul@32 | 64 | fi |
paul@32 | 65 | |
paul@32 | 66 | cp "/dev/MAKEDEV" "$IMAGEDIR/dev" |
paul@32 | 67 | |
paul@32 | 68 | if [ -h "$IMAGEDIR/proc" ]; then |
paul@34 | 69 | echo "Removing any linked /proc entry..." 1>&2 |
paul@32 | 70 | rm "$IMAGEDIR/proc" |
paul@32 | 71 | fi |
paul@32 | 72 | |
paul@34 | 73 | if [ -e "$IMAGEDIR/proc" ]; then |
paul@34 | 74 | echo "Moving existing /proc directory..." 1>&2 |
paul@34 | 75 | mv "$IMAGEDIR/proc" "$IMAGEDIR/proc.old" |
paul@34 | 76 | fi |
paul@34 | 77 | |
paul@32 | 78 | if [ ! -e "$IMAGEDIR/proc" ]; then |
paul@34 | 79 | echo "Making /proc directory..." 1>&2 |
paul@32 | 80 | mkdir "$IMAGEDIR/proc" |
paul@32 | 81 | fi |
paul@32 | 82 | |
paul@32 | 83 | echo "Using a special fstab..." 1>&2 |
paul@32 | 84 | if [ -e "$IMAGEDIR/etc/fstab" ]; then |
paul@32 | 85 | if [ ! -e "$IMAGEDIR/etc/fstab.orig" ]; then |
paul@32 | 86 | mv "$IMAGEDIR/etc/fstab" "$IMAGEDIR/etc/fstab.orig" |
paul@32 | 87 | fi |
paul@32 | 88 | fi |
paul@32 | 89 | cp "$THISDIR/UML/fstab" "$IMAGEDIR/etc/fstab" |
paul@32 | 90 | |
paul@32 | 91 | # Tweak the inittab to only use tty0 and add it to securetty. |
paul@32 | 92 | echo "Reconfiguring the console settings..." 1>&2 |
paul@32 | 93 | if [ ! -e "$IMAGEDIR/etc/inittab.orig" ]; then |
paul@32 | 94 | if [ -e "$IMAGEDIR/etc/inittab" ]; then |
paul@32 | 95 | cp "$IMAGEDIR/etc/inittab" "$IMAGEDIR/etc/inittab.orig" |
paul@32 | 96 | grep -v "getty" "$IMAGEDIR/etc/inittab.orig" > "$IMAGEDIR/etc/inittab" |
paul@32 | 97 | fi |
paul@35 | 98 | cat >> "$IMAGEDIR/etc/inittab" <<EOF |
paul@35 | 99 | # We launch just one console for UML: |
paul@35 | 100 | c0:1235:respawn:/sbin/getty 38400 tty0 linux |
paul@35 | 101 | EOF |
paul@32 | 102 | |
paul@35 | 103 | cat >> "$IMAGEDIR/etc/securetty" <<EOF |
paul@35 | 104 | # UML modification: use tty0 or vc/0 |
paul@35 | 105 | tty0 |
paul@35 | 106 | vc/0 |
paul@35 | 107 | EOF |
paul@32 | 108 | fi |
paul@32 | 109 | |
paul@32 | 110 | sudo "$THISDIR/uml-make-devices" "$IMAGEDIR" |