userinstall

Annotated uml-linux-build

75:36a3b8a630a4
2015-01-15 Paul Boddie Added notes on filesystem resizing and uml-net invocation.
paul@31 1
#!/bin/sh
paul@31 2
paul@63 3
# Copyright (C) 2011, 2012, 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@31 18
# Configuration:
paul@31 19
if [ -e userinstall-defaults-uml ]; then
paul@31 20
        . "$PWD/userinstall-defaults-uml"
paul@31 21
elif [ -e /etc/default/userinstall-uml ]; then
paul@31 22
        . /etc/default/userinstall-uml
paul@31 23
else
paul@31 24
        echo "No defaults found for userinstall (UML)." 1>&2
paul@31 25
        exit 1
paul@31 26
fi
paul@31 27
paul@31 28
if [ ! -e "$PACKAGEROOT" ]; then
paul@31 29
	echo "A package root must first be made using user-setup." 1>&2
paul@31 30
	exit 1
paul@31 31
fi
paul@31 32
paul@35 33
if [ "$1" = '--root' ]; then
paul@35 34
        AS_USER="sudo"
paul@35 35
fi
paul@35 36
paul@31 37
THISDIR=`dirname "$0"`
paul@31 38
paul@31 39
if [ ! -e linux ]; then
paul@31 40
	if [ ! -e "$LINUXDIRNAME" ]; then
paul@31 41
		if [ ! -e "$LINUXARCHIVE" ]; then
paul@31 42
			echo "Getting the Linux kernel archive..." 1>&2
paul@31 43
			wget -O "$LINUXARCHIVE" "$LINUXADDRESS"
paul@31 44
		fi
paul@31 45
paul@31 46
		echo "Unpacking the archive..." 1>&2
paul@31 47
		tar jxf "$LINUXARCHIVE"
paul@31 48
	fi
paul@31 49
	if [ ! -e "$LINUXDIRNAME/linux" ]; then
paul@31 50
paul@31 51
		# Copy our configuration into the unpacked directory.
paul@31 52
		# Normally we would do this:
paul@31 53
		# make defconfig ARCH=um
paul@31 54
		# make menuconfig ARCH=um
paul@31 55
		# In "File systems", "CD-ROM/DVD Filesystems", press Y for "ISO 9660...".
paul@31 56
		# The supplied configuration file should include this information.
paul@31 57
		echo "Adding configuration..." 1>&2
paul@31 58
		if [ -e "$LINUXDIRNAME/.config" ]; then
paul@31 59
			if [ ! -e "$LINUXDIRNAME/.config.original" ]; then
paul@31 60
				echo "$LINUXDIRNAME/.config -> $LINUXDIRNAME/.config.original" 1>&2
paul@31 61
				mv "$LINUXDIRNAME/.config" "$LINUXDIRNAME/.config.original"
paul@31 62
			fi
paul@31 63
		fi
paul@31 64
paul@31 65
		echo "uml-linux-build.config -> $LINUXDIRNAME/.config"
paul@31 66
		cp "$THISDIR/uml-linux-build.config" "$LINUXDIRNAME/.config"
paul@31 67
	fi
paul@31 68
paul@31 69
	# Enter the unpacked directory and build.
paul@31 70
	cd "$LINUXDIRNAME"
paul@31 71
paul@31 72
	#echo "Patching hostaudio for SDL..."
paul@31 73
	#patch -p0 < ../patches/hostaudio_kern.c.diff
paul@31 74
paul@31 75
	echo "Building..." 1>&2
paul@31 76
	make ARCH=um
paul@31 77
paul@35 78
        echo "Making the modules..." 1>&2
paul@35 79
        make modules ARCH=um
paul@31 80
paul@31 81
	cd ..
paul@31 82
fi
paul@31 83
paul@35 84
echo "Installing the modules..." 1>&2
paul@59 85
"$THISDIR/uml-access-image" $AS_USER make -C "$LINUXDIRNAME" modules_install INSTALL_MOD_PATH="$IMAGEDIR" ARCH=um
paul@35 86
paul@31 87
# Now get the executable and remove the build directory.
paul@31 88
if [ ! -e linux ]; then
paul@31 89
	mv "$LINUXDIRNAME/linux" .
paul@31 90
fi
paul@31 91
paul@31 92
if [ -e linux ]; then
paul@31 93
	echo "To remove the Linux kernel sources, do this:" 1>&2
paul@31 94
	echo "rm -rf '$LINUXDIRNAME'" 1>&2
paul@31 95
fi