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