[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tyndur-devel] [PATCH v2] USB-Image
From: Max Reitz <max@xxxxxxxxxx>
+ Möglichkeit zur Erstellung eines Diskettenimages, das dann
(unter QEMU) per USB gebootet werden kann
Signed-off-by: Max Reitz <max@xxxxxxxxxx>
---
Makefile | 3 ++
build/config/grub_usb.cfg | 9 +++++
build/config/image_usb.sh | 1 +
build/scripts/image_usb | 86 +++++++++++++++++++++++++++++++++++++++++++++
buildmk.sh | 3 ++
5 files changed, 102 insertions(+), 0 deletions(-)
create mode 100644 build/config/grub_usb.cfg
create mode 100644 build/config/image_usb.sh
create mode 100755 build/scripts/image_usb
diff --git a/Makefile b/Makefile
index 9b63409..9272f47 100644
--- a/Makefile
+++ b/Makefile
@@ -49,6 +49,9 @@ image-hd: updateroot
image-cdrom: updateroot
build/scripts/image_cdrom
+image-usb: updateroot
+ build/scripts/image_usb
+
test-qemu: image-floppy
qemu -serial stdio -fda build/images/floppy.img -boot a -net user -net nic,model=rtl8139 | tee qemu-serial.log
diff --git a/build/config/grub_usb.cfg b/build/config/grub_usb.cfg
new file mode 100644
index 0000000..0b2adcb
--- /dev/null
+++ b/build/config/grub_usb.cfg
@@ -0,0 +1,9 @@
+title tyndur
+kernel /boot/tyndur debug=s
+module /modules/init boot=file:/
+module /modules/pci
+module /modules/usb
+module /modules/fat
+module /modules/console servmgr:/term servmgr:/term
+module /modules/servmgr usb-msc:/msd0|fat:/ vterm:/vterm8/out pci usb-msc fat console
+boot
diff --git a/build/config/image_usb.sh b/build/config/image_usb.sh
new file mode 100644
index 0000000..984dac2
--- /dev/null
+++ b/build/config/image_usb.sh
@@ -0,0 +1 @@
+IMAGE_PATH="build/images/usb-floppy.img"
diff --git a/build/scripts/image_usb b/build/scripts/image_usb
new file mode 100755
index 0000000..8ad3725
--- /dev/null
+++ b/build/scripts/image_usb
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+# Copyright (c) 2008 The tyndur Project. All rights reserved.
+#
+# This code is derived from software contributed to the tyndur Project
+# by Antoine Kaufmann.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the tyndur Project
+# and its contributors.
+# 4. Neither the name of the tyndur Project nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ROOT=build/root
+ROOT_COMMON=build/root-common
+ROOT_FLOPPY=build/root-floppy
+ROOT_LOCAL=build/root-local
+
+export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
+
+source build/config/image_usb.sh
+export LOST_BUILDMK_ROOT="`pwd`"
+source config.sh
+
+
+export MTOOLSRC=lostmtools.conf
+
+# Konfigurationsdatei fuer mtools generieren
+cat << EOF > $MTOOLSRC
+drive l:
+ file="$IMAGE_PATH" cylinders=80 heads=2 sectors=18 filter
+EOF
+
+# Wenn das Image neu erstellt werden muss, kommen noch ein paar schritte mehr
+# dazu.
+NEW=0
+if ! [ -f $IMAGE_PATH ]; then
+ # Leeres Image erstellen und formatieren
+ dd if=/dev/zero of=$IMAGE_PATH bs=1024 count=1440
+ mformat l:
+ NEW=1
+fi
+
+
+mcopy -D o -s $ROOT/* $ROOT_COMMON/* $ROOT_FLOPPY/* l:/
+mcopy -D o -s $ROOT_LOCAL/* l:/
+
+# Grub-Konfiguration kopieren
+mcopy -D o build/config/grub_usb.cfg l:/boot/grub/menu.lst
+
+if [ $NEW -ne 0 ]; then
+ # Grub kopieren und installieren
+ mmd -D s l:/boot/grub
+ mcopy -D o $LOST_GRUB_STAGESDIR/stage? l:/boot/grub/
+
+ $LOST_TOOLS_GRUB --batch <<EOF
+ device (fd0) $IMAGE_PATH
+ root (fd0)
+ setup (fd0)
+EOF
+fi
+
+# Konfigurationsdatei fuer mtools wieder loeschen
+rm -f $MTOOLSRC
diff --git a/buildmk.sh b/buildmk.sh
index 4e3cd85..0315c12 100644
--- a/buildmk.sh
+++ b/buildmk.sh
@@ -249,6 +249,9 @@ image-hd: updateroot
image-cdrom: updateroot
build/scripts/image_cdrom
+image-usb: updateroot
+ build/scripts/image_usb
+
test-qemu: image-floppy
$LOST_TOOLS_QEMU -serial stdio -fda build/images/floppy.img -boot a -net user -net nic,model=rtl8139 | tee qemu-serial.log
--
1.6.5