[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH] HD-Images mit Syslinux



+ Festplattenimages können auch mit Syslinux (bzw. Extlinux) statt mit
  GRUB erstellt werden.

Signed-off-by: Arne Hasselbring <arne.hasselbring@xxxxxxxxxxxxxx>
---
 Makefile                        |   6 +--
 build/config/syslinux_hd.cfg    |  19 +++++++
 build/scripts/image_hd_syslinux | 113 ++++++++++++++++++++++++++++++++++++++++
 buildmk.sh                      |   9 +++-
 config.sh                       |   1 +
 5 files changed, 143 insertions(+), 5 deletions(-)
 create mode 100644 build/config/syslinux_hd.cfg
 create mode 100755 build/scripts/image_hd_syslinux

diff --git a/Makefile b/Makefile
index 474b7c3..96a6b24 100644
--- a/Makefile
+++ b/Makefile
@@ -65,13 +65,13 @@ updateroot: subdirs
 	build/scripts/updateroot
 
 image-floppy: updateroot
-	build/scripts/image_floppy_$(GRUB_VERSION)
+	build/scripts/image_floppy_$(BOOTLOADER)
 
 image-hd: updateroot
-	build/scripts/image_hd_$(GRUB_VERSION)
+	build/scripts/image_hd_$(BOOTLOADER)
 
 image-cdrom: updateroot
-	build/scripts/image_cdrom_$(GRUB_VERSION)
+	build/scripts/image_cdrom_$(BOOTLOADER)
 
 test-qemu-floppy: 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/syslinux_hd.cfg b/build/config/syslinux_hd.cfg
new file mode 100644
index 0000000..9fcefb6
--- /dev/null
+++ b/build/config/syslinux_hd.cfg
@@ -0,0 +1,19 @@
+DEFAULT tyndurde
+PROMPT 0
+UI menu.c32
+MENU TITLE Tyndur 0.3.0
+MENU COLOR screen 37;40 #ffffff #000000 std
+MENU COLOR border 37;40 #ffffff #000000 std
+MENU COLOR title 37;40 #ffffff #000000 std
+MENU COLOR unsel 37;40 #ffffff #000000 std
+MENU COLOR sel 30;47 #000000 #ffffff std
+MENU COLOR tabmsg 37;40 #000000 #ffffff std
+
+LABEL tyndurde
+MENU LABEL Tyndur (Deutsch)
+KERNEL mboot.c32
+APPEND /boot/tyndur2 debug=s --- /modules/init boot=file:/ --- /modules/pci --- /modules/ata --- /modules/ext2 --- /modules/console servmgr:/term servmgr:/term --- /modules/servmgr ata:/ata00_p0|ext2:/ vterm:/vterm8/out ata ext2 console pci
+LABEL tynduren
+MENU LABEL Tyndur (English)
+KERNEL mboot.c32
+APPEND /boot/tyndur2 debug=s --- /modules/init boot=file:/ env.LANG=en --- /modules/pci --- /modules/ata --- /modules/ext2 --- /modules/console servmgr:/term servmgr:/term --- /modules/servmgr ata:/ata00_p0|ext2:/ vterm:/vterm8/out ata ext2 console pci
diff --git a/build/scripts/image_hd_syslinux b/build/scripts/image_hd_syslinux
new file mode 100755
index 0000000..a487920
--- /dev/null
+++ b/build/scripts/image_hd_syslinux
@@ -0,0 +1,113 @@
+#!/bin/bash
+
+# Copyright (c) 2012 The tyndur Project. All rights reserved.
+#
+# This code is derived from software contributed to the tyndur Project
+# by Arne Hasselbring.
+#
+# 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_HD=build/root-hd
+ROOT_LOCAL=build/root-local
+MOUNT=build/mnt
+SUDO=sudo
+
+export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
+
+export LOST_BUILDMK_ROOT="`pwd`"
+source build/config/image_hd.sh
+source config.sh
+
+die()
+{
+    echo $1
+    exit -1
+}
+
+# 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 of=$IMAGE_PATH bs=$((1024 * 1024)) seek=$IMAGE_SIZE count=0
+    build/scripts/create_partition $IMAGE_PATH
+    NEW=1
+fi
+
+
+# Start und Ende der Partition einlesen
+PARTITIONS="`build/scripts/get_partition $IMAGE_PATH`"
+PART_START=`echo $PARTITIONS | awk '{print $1}'`
+PART_SIZE=`echo $PARTITIONS | awk '{print $2}'`
+
+if [ $NEW -ne 0 ]; then
+    LOOP_DEV=`$SUDO losetup -f $IMAGE_PATH --sizelimit $(($PART_SIZE * 512)) -o $(($PART_START * 512)) --show`
+    if [ $? -ne 0 ]; then
+        die "Loop Device konnte nicht angelegt werden"
+    fi
+
+    # Dateisystem erstellen
+    $SUDO $LOST_TOOLS_MKE2FS -T ext2 -F -q $LOOP_DEV || die "Dateisystem konnte nicht erstellt werden"
+
+    $SUDO losetup -d $LOOP_DEV
+fi
+
+# Partition mounten
+mkdir -p $MOUNT
+$SUDO mount $IMAGE_PATH $MOUNT -t ext2 -o loop,offset=$((${PART_START} * 512))
+$SUDO chmod 777 -Rf $MOUNT
+
+# Daten Kopieren
+cp -rP --preserve=links,timestamps $ROOT/* $ROOT_COMMON/* $ROOT_HD/* $MOUNT/
+[ -d $ROOT_LOCAL ] && cp -rP --preserve=links,timestamps $ROOT_LOCAL/* $MOUNT/
+
+# Syslinux-Konfiguration kopieren
+mkdir -p $MOUNT/boot/syslinux
+rm -f $MOUNT/boot/syslinux/syslinux.cfg
+cat build/config/syslinux_hd.cfg >> $MOUNT/boot/syslinux/syslinux.cfg
+
+
+# Syslinux installieren und Dateien kopieren
+if [ $NEW -ne 0 ]; then
+    $SUDO extlinux --install $MOUNT/boot/syslinux
+    cp $LOST_SYSLINUX_DIR/mboot.c32 $MOUNT/boot/syslinux
+    cp $LOST_SYSLINUX_DIR/menu.c32 $MOUNT/boot/syslinux
+fi
+
+# Partition unmounten und loopback-Device freigeben
+while fuser -m $MOUNT; do true; done
+$SUDO umount $MOUNT
+rmdir $MOUNT
+
+# MBR installieren
+if [ $NEW -ne 0 ]; then
+    printf '\1' | cat $LOST_SYSLINUX_DIR/altmbr.bin - | dd bs=440 count=1 conv=notrunc iflag=fullblock of=$IMAGE_PATH
+fi
diff --git a/buildmk.sh b/buildmk.sh
index 083ea21..abbd359 100644
--- a/buildmk.sh
+++ b/buildmk.sh
@@ -95,9 +95,14 @@ EOF
 
   # Ist grub legacy installiert?
   if [ -f $LOST_GRUB_STAGESDIR/stage1 ]; then
-    echo GRUB_VERSION=grub1 >> Makefile.local
+    echo BOOTLOADER=grub1 >> Makefile.local
+  elif [ -d $LOST_GRUB2_MODULESDIR ]; then
+    echo BOOTLOADER=grub2 >> Makefile.local
+  elif [ -d $LOST_SYSLINUX_DIR ]; then
+    echo BOOTLOADER=syslinux >> Makefile.local
   else
-    echo GRUB_VERSION=grub2 >> Makefile.local
+    echo "Kein passender Bootloader gefunden"
+    exit -1
   fi
 
   for dir in doc src; do
diff --git a/config.sh b/config.sh
index 8693bcb..e102b4d 100644
--- a/config.sh
+++ b/config.sh
@@ -4,6 +4,7 @@ COMPILER_PREFIX_I386=
 LOST_TOOLS_PPC=$LOST_BUILDMK_ROOT/lbuilds/env/bin/fpc
 LOST_GRUB_STAGESDIR=/boot/grub
 LOST_GRUB2_MODULESDIR=/usr/lib/grub/i386-pc
+LOST_SYSLINUX_DIR=/usr/lib/syslinux
 LOST_TOOLS_GRUB=grub
 LOST_TOOLS_MKE2FS=/sbin/mke2fs
 LOST_TOOLS_QEMU=qemu
-- 
1.7.12.2