1 #!/bin/sh 2 3 # Copyright (C) 2011, 2012, 2013, 2014 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 [ "$1" = '--root' ]; then 34 AS_USER="sudo" 35 fi 36 37 THISDIR=`dirname "$0"` 38 39 if [ ! -e linux ]; then 40 if [ ! -e "$LINUXDIRNAME" ]; then 41 if [ ! -e "$LINUXARCHIVE" ]; then 42 echo "Getting the Linux kernel archive..." 1>&2 43 if ! wget -O "$LINUXARCHIVE" "$LINUXADDRESS" ; then 44 echo "Unable to download from URL: $LINUXADDRESS" 1>&2 45 exit 1 46 fi 47 fi 48 49 echo "Unpacking the archive..." 1>&2 50 if [ `basename "$LINUXARCHIVE" .bz2` != "$LINUXARCHIVE" ]; then 51 tar jxf "$LINUXARCHIVE" 52 elif [ `basename "$LINUXARCHIVE" .gz` != "$LINUXARCHIVE" ]; then 53 tar zxf "$LINUXARCHIVE" 54 else 55 echo "Don't know how to unpack the downloaded file: $LINUXARCHIVE" 1>&2 56 fi 57 fi 58 if [ ! -e "$LINUXDIRNAME/linux" ]; then 59 60 # Copy our configuration into the unpacked directory. 61 # Normally we would do this: 62 # make defconfig ARCH=um 63 # make menuconfig ARCH=um 64 # In "File systems", "CD-ROM/DVD Filesystems", press Y for "ISO 9660...". 65 # The supplied configuration file should include this information. 66 echo "Adding configuration..." 1>&2 67 if [ -e "$LINUXDIRNAME/.config" ]; then 68 if [ ! -e "$LINUXDIRNAME/.config.original" ]; then 69 echo "$LINUXDIRNAME/.config -> $LINUXDIRNAME/.config.original" 1>&2 70 mv "$LINUXDIRNAME/.config" "$LINUXDIRNAME/.config.original" 71 fi 72 fi 73 74 echo "uml-linux-build.config -> $LINUXDIRNAME/.config" 75 cp "$THISDIR/uml-linux-build.config" "$LINUXDIRNAME/.config" 76 fi 77 78 # Enter the unpacked directory and build. 79 cd "$LINUXDIRNAME" 80 81 #echo "Patching hostaudio for SDL..." 82 #patch -p0 < ../patches/hostaudio_kern.c.diff 83 84 echo "Building..." 1>&2 85 make ARCH=um 86 87 echo "Making the modules..." 1>&2 88 make modules ARCH=um 89 90 cd .. 91 fi 92 93 echo "Installing the modules..." 1>&2 94 "$THISDIR/uml-access-image" $AS_USER make -C "$LINUXDIRNAME" modules_install INSTALL_MOD_PATH="$IMAGEDIR" ARCH=um 95 96 # Now get the executable and remove the build directory. 97 if [ ! -e linux ]; then 98 mv "$LINUXDIRNAME/linux" . 99 fi 100 101 if [ -e linux ]; then 102 echo "To remove the Linux kernel sources, do this:" 1>&2 103 echo "rm -rf '$LINUXDIRNAME'" 1>&2 104 fi