[tyndur-devel] [PATCH] + Maketarget image-* erkennt automatisch ob grub legacy oder grub2 installiert ist
Jörg Pfähler ·
Signed-off-by: Jörg Pfähler <bluecoder at gmx.de> --- Makefile | 17 ++--- build/scripts/grub2_cdrom | 45 ----------- build/scripts/grub2_hd | 154 -------------------------------------- build/scripts/image_cdrom | 135 --------------------------------- build/scripts/image_cdrom_grub1 | 135 +++++++++++++++++++++++++++++++++ build/scripts/image_cdrom_grub2 | 52 +++++++++++++ build/scripts/image_floppy | 86 --------------------- build/scripts/image_floppy_grub1 | 86 +++++++++++++++++++++ build/scripts/image_hd | 121 ------------------------------ build/scripts/image_hd_grub1 | 121 ++++++++++++++++++++++++++++++ build/scripts/image_hd_grub2 | 154 ++++++++++++++++++++++++++++++++++++++ buildmk.sh | 24 ++++--- 12 files changed, 569 insertions(+), 561 deletions(-) delete mode 100755 build/scripts/grub2_cdrom delete mode 100755 build/scripts/grub2_hd delete mode 100755 build/scripts/image_cdrom create mode 100755 build/scripts/image_cdrom_grub1 create mode 100755 build/scripts/image_cdrom_grub2 delete mode 100755 build/scripts/image_floppy create mode 100755 build/scripts/image_floppy_grub1 delete mode 100755 build/scripts/image_hd create mode 100755 build/scripts/image_hd_grub1 create mode 100755 build/scripts/image_hd_grub2 diff --git a/Makefile b/Makefile index adf7df3..4238fc9 100644 --- a/Makefile +++ b/Makefile @@ -61,26 +61,23 @@ updateroot: subdirs build/scripts/updateroot image-floppy: updateroot - build/scripts/image_floppy + build/scripts/image_floppy_$(GRUB_VERSION) image-hd: updateroot - build/scripts/image_hd + build/scripts/image_hd_$(GRUB_VERSION) image-cdrom: updateroot - build/scripts/image_cdrom + build/scripts/image_cdrom_$(GRUB_VERSION) -grub2-hd: updateroot - build/scripts/grub2_hd - -grub2-cdrom: updateroot - build/scripts/grub2_cdrom - -test-qemu: image-floppy +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 test-qemu-hd: image-hd qemu -serial stdio -hda build/images/hd.img -net user -net nic,model=rtl8139 | tee qemu-serial.log +test-qemu-cdrom: image-cdrom + qemu -serial stdio -cdrom build/images/cdrom.img -boot d -net user -net nic,model=rtl8139 | tee qemu-serial.log + test-bochs: image-floppy bochs -f bochs.config diff --git a/build/scripts/grub2_cdrom b/build/scripts/grub2_cdrom deleted file mode 100755 index 406b603..0000000 --- a/build/scripts/grub2_cdrom +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (c) 20010 The tyndur Project. All rights reserved. -# -# This code is derived from software contributed to the tyndur Project -# by Johannes Pfeiffer. -# -# 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. - -#Konfigurationsdateien kopieren -cp build/config/grub2_cdrom.cfg build/root/boot/grub/grub.cfg -cp -r build/root-cdrom/config build/root/ -cp -r build/root-common/config build/root/ - -#CD Image erstellen -grub-mkrescue --output=build/images/grub2-cdrom-tyndur.iso build/root/ - -#Konfigurationsdateien wieder löschen -rm -r build/root/config -#Nachricht für den Fall, dass xorriso nicht installiert ist -echo "Falls es zu Error 127 während der Erstellung des CD-Images kommt, hilft es das Paket XORRISO zu installieren." diff --git a/build/scripts/grub2_hd b/build/scripts/grub2_hd deleted file mode 100755 index 9c0f5a8..0000000 --- a/build/scripts/grub2_hd +++ /dev/null @@ -1,154 +0,0 @@ -#!/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_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 -} - -convert_menu_lst() -{ - sed -ie 's/^title \(.*\)$/menuentry "\1" {/' "$1" - sed -ie 's/^kernel \([^ ]\+\)\(.*\)$/ multiboot \1 \1 \2/' "$1" - sed -ie 's/^module \([^ ]\+\)\(.*\)$/ module \1 \1 \2/' "$1" - sed -ie 's/^boot$/}/' "$1" - sed -ie 's/|/\\|/' "$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 -R $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/ - -# GRUB-Konfiguration kopieren -mkdir -p $MOUNT/boot/grub -rm -f $MOUNT/boot/grub/grub.cfg -echo "insmod multiboot" >> $MOUNT/boot/grub/grub.cfg -if [ -e $MOUNT/boot/tyndur2 ]; then - cat build/config/grub_hd_kernel2.cfg >> $MOUNT/boot/grub/grub.cfg -fi -if [ -e $MOUNT/boot/tyndur ]; then - cat build/config/grub_hd.cfg >> $MOUNT/boot/grub/grub.cfg -fi - -convert_menu_lst $MOUNT/boot/grub/grub.cfg - -# Grub kopieren -if [ $NEW -ne 0 ]; then - xargs -isrc cp src $MOUNT/boot/grub <<-EOF - $LOST_GRUB2_MODULESDIR/boot.mod - $LOST_GRUB2_MODULESDIR/cat.mod - $LOST_GRUB2_MODULESDIR/configfile.mod - $LOST_GRUB2_MODULESDIR/crypto.mod - $LOST_GRUB2_MODULESDIR/extcmd.mod - $LOST_GRUB2_MODULESDIR/gzio.mod - $LOST_GRUB2_MODULESDIR/ls.mod - $LOST_GRUB2_MODULESDIR/mmap.mod - $LOST_GRUB2_MODULESDIR/multiboot.mod - $LOST_GRUB2_MODULESDIR/normal.mod - $LOST_GRUB2_MODULESDIR/relocator.mod - $LOST_GRUB2_MODULESDIR/terminal.mod - $LOST_GRUB2_MODULESDIR/video.mod -EOF -fi - -# Partition unmounten und loopback-Device freigeben -$SUDO umount $MOUNT -rmdir $MOUNT - - -# Grub installieren -if [ $NEW -ne 0 ]; then - LOOP_DEV=`$SUDO losetup -f $IMAGE_PATH --show` - if [ $? -ne 0 ]; then - die "Loop Device konnte nicht angelegt werden" - fi - - mkdir -p build/grub2 - echo "(img) $LOOP_DEV" > build/grub2/device.map - - cp $LOST_GRUB2_MODULESDIR/boot.img build/grub2/ - grub-mkimage -O i386-pc -o build/grub2/core.img ext2 biosdisk part_msdos minicmd - - $SUDO grub-setup -m build/grub2/device.map -d build/grub2 -r "(img,1)" "(img)" - - $SUDO losetup -d $LOOP_DEV -fi diff --git a/build/scripts/image_cdrom b/build/scripts/image_cdrom deleted file mode 100755 index e7233f2..0000000 --- a/build/scripts/image_cdrom +++ /dev/null @@ -1,135 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2008-2009 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_CDROM=build/root-cdrom -ROOT_LOCAL=build/root-local - -STAGE2_ELTORITO=/usr/lib/grub/i386-pc/stage2_eltorito - -export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin - -source build/config/image_cdrom.sh -export LOST_BUILDMK_ROOT="`pwd`" -source config.sh - - -export MTOOLSRC=lostmtools.conf - -# Festplattenpartition kopieren -if [ ! -f $HD_IMAGE_PATH ]; then - echo "Benoetige ein Festplattenimage" - exit 1 -fi - - -PARTITIONS="`build/scripts/get_partition $HD_IMAGE_PATH`" -PART_START=`echo $PARTITIONS | awk '{print $1}'` - -dd if=$HD_IMAGE_PATH of=$ROOT_CDROM/hd.img skip=$PART_START - - -# CD bauen - -if [ -f $STAGE2_ELTORITO ]; then # Eltorito - - mkdir -p $ROOT/boot/grub - cp $STAGE2_ELTORITO $ROOT/boot/grub/stage2_eltorito - cp build/config/grub_cdrom_eltorito.cfg $ROOT/boot/grub/menu.lst - - # Fix für uppercase-Pfade in ISO9660-Dateisystemen. - # Ohne wird grub die menu.lst nicht finden. - sed -i "s/boot\/grub\/menu.lst/BOOT\/GRUB\/MENU.LST/g" $ROOT/boot/grub/stage2_eltorito - - mkisofs -b boot/grub/stage2_eltorito -no-emul-boot \ - -boot-load-size 4 -boot-info-table -m .svn -o $IMAGE_PATH \ - $ROOT $ROOT_COMMON $ROOT_CDROM - - echo "CD-Image erfolgreich erstellt!" - echo "Verwendete Methode: Eltorito" - exit -fi - -# Floppy-Emulation - -# Konfigurationsdatei fuer mtools generieren -cat << EOF > $MTOOLSRC -drive l: - file="$FLOPPY_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 $FLOPPY_IMAGE_PATH ]; then - # Leeres Image erstellen und formatieren - dd of=$FLOPPY_IMAGE_PATH bs=1024 seek=1440 count=0 - mformat l: - NEW=1 -fi - - -if [ $NEW -ne 0 ]; then - # Grub kopieren und installieren - mmd -D s l:/boot - mmd -D s l:/boot/grub - mcopy -D o $LOST_GRUB_STAGESDIR/stage? l:/boot/grub/ - - $LOST_TOOLS_GRUB --batch <<EOF - device (fd0) $FLOPPY_IMAGE_PATH - root (fd0) - setup (fd0) -EOF -fi - -# Grub-Konfiguration kopieren -mcopy -D o build/config/grub_cdrom.cfg l:/boot/grub/menu.lst - -# Die noetigsten Treiber auf das Floppy-Image packen -mcopy -D o $ROOT/boot/tyndur $ROOT/modules/init $ROOT/modules/console l:/ -mcopy -D o $ROOT/modules/ata $ROOT/modules/iso9660 $ROOT/modules/servmgr l:/ -mcopy -D o $ROOT/modules/ext2 $ROOT/modules/ramoverlay $ROOT/modules/pci l:/ - -# Konfigurationsdatei fuer mtools wieder loeschen -rm -f $MTOOLSRC - -# CD-Image bauen -cp $FLOPPY_IMAGE_PATH $ROOT_CDROM -mkisofs -b $(basename $FLOPPY_IMAGE_PATH) -m .svn -o $IMAGE_PATH $ROOT $ROOT_COMMON $ROOT_CDROM $ROOT_LOCAL -rm $ROOT_CDROM/$(basename $FLOPPY_IMAGE_PATH) - -echo "CD-Image erfolgreich erstellt!" -echo "Verwendete Methode: Floppy-Emulation" diff --git a/build/scripts/image_cdrom_grub1 b/build/scripts/image_cdrom_grub1 new file mode 100755 index 0000000..e7233f2 --- /dev/null +++ b/build/scripts/image_cdrom_grub1 @@ -0,0 +1,135 @@ +#!/bin/bash + +# Copyright (c) 2008-2009 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_CDROM=build/root-cdrom +ROOT_LOCAL=build/root-local + +STAGE2_ELTORITO=/usr/lib/grub/i386-pc/stage2_eltorito + +export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin + +source build/config/image_cdrom.sh +export LOST_BUILDMK_ROOT="`pwd`" +source config.sh + + +export MTOOLSRC=lostmtools.conf + +# Festplattenpartition kopieren +if [ ! -f $HD_IMAGE_PATH ]; then + echo "Benoetige ein Festplattenimage" + exit 1 +fi + + +PARTITIONS="`build/scripts/get_partition $HD_IMAGE_PATH`" +PART_START=`echo $PARTITIONS | awk '{print $1}'` + +dd if=$HD_IMAGE_PATH of=$ROOT_CDROM/hd.img skip=$PART_START + + +# CD bauen + +if [ -f $STAGE2_ELTORITO ]; then # Eltorito + + mkdir -p $ROOT/boot/grub + cp $STAGE2_ELTORITO $ROOT/boot/grub/stage2_eltorito + cp build/config/grub_cdrom_eltorito.cfg $ROOT/boot/grub/menu.lst + + # Fix für uppercase-Pfade in ISO9660-Dateisystemen. + # Ohne wird grub die menu.lst nicht finden. + sed -i "s/boot\/grub\/menu.lst/BOOT\/GRUB\/MENU.LST/g" $ROOT/boot/grub/stage2_eltorito + + mkisofs -b boot/grub/stage2_eltorito -no-emul-boot \ + -boot-load-size 4 -boot-info-table -m .svn -o $IMAGE_PATH \ + $ROOT $ROOT_COMMON $ROOT_CDROM + + echo "CD-Image erfolgreich erstellt!" + echo "Verwendete Methode: Eltorito" + exit +fi + +# Floppy-Emulation + +# Konfigurationsdatei fuer mtools generieren +cat << EOF > $MTOOLSRC +drive l: + file="$FLOPPY_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 $FLOPPY_IMAGE_PATH ]; then + # Leeres Image erstellen und formatieren + dd of=$FLOPPY_IMAGE_PATH bs=1024 seek=1440 count=0 + mformat l: + NEW=1 +fi + + +if [ $NEW -ne 0 ]; then + # Grub kopieren und installieren + mmd -D s l:/boot + mmd -D s l:/boot/grub + mcopy -D o $LOST_GRUB_STAGESDIR/stage? l:/boot/grub/ + + $LOST_TOOLS_GRUB --batch <<EOF + device (fd0) $FLOPPY_IMAGE_PATH + root (fd0) + setup (fd0) +EOF +fi + +# Grub-Konfiguration kopieren +mcopy -D o build/config/grub_cdrom.cfg l:/boot/grub/menu.lst + +# Die noetigsten Treiber auf das Floppy-Image packen +mcopy -D o $ROOT/boot/tyndur $ROOT/modules/init $ROOT/modules/console l:/ +mcopy -D o $ROOT/modules/ata $ROOT/modules/iso9660 $ROOT/modules/servmgr l:/ +mcopy -D o $ROOT/modules/ext2 $ROOT/modules/ramoverlay $ROOT/modules/pci l:/ + +# Konfigurationsdatei fuer mtools wieder loeschen +rm -f $MTOOLSRC + +# CD-Image bauen +cp $FLOPPY_IMAGE_PATH $ROOT_CDROM +mkisofs -b $(basename $FLOPPY_IMAGE_PATH) -m .svn -o $IMAGE_PATH $ROOT $ROOT_COMMON $ROOT_CDROM $ROOT_LOCAL +rm $ROOT_CDROM/$(basename $FLOPPY_IMAGE_PATH) + +echo "CD-Image erfolgreich erstellt!" +echo "Verwendete Methode: Floppy-Emulation" diff --git a/build/scripts/image_cdrom_grub2 b/build/scripts/image_cdrom_grub2 new file mode 100755 index 0000000..f32ef4f --- /dev/null +++ b/build/scripts/image_cdrom_grub2 @@ -0,0 +1,52 @@ +#!/bin/bash + +# Copyright (c) 2010 The tyndur Project. All rights reserved. +# +# This code is derived from software contributed to the tyndur Project +# by Johannes Pfeiffer. +# +# 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. + +#Überprüfen ob Xorriso installiert ist + +if [ -z `which xorriso` ]; then + echo "Fehler: Bitte Paket XORRISO installieren" + exit 1 +fi + +#Konfigurationsdateien kopieren +cp build/config/grub2_cdrom.cfg build/root/boot/grub/grub.cfg +cp -r build/root-cdrom/config build/root/ +cp -r build/root-common/config build/root/ + +#CD Image erstellen +grub-mkrescue --output=build/images/cdrom.img build/root/ + +#Konfigurationsdateien wieder löschen +rm -r build/root/config diff --git a/build/scripts/image_floppy b/build/scripts/image_floppy deleted file mode 100755 index 463b117..0000000 --- a/build/scripts/image_floppy +++ /dev/null @@ -1,86 +0,0 @@ -#!/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_floppy.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 of=$IMAGE_PATH bs=1024 seek=1440 count=0 - 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_floppy.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/build/scripts/image_floppy_grub1 b/build/scripts/image_floppy_grub1 new file mode 100755 index 0000000..463b117 --- /dev/null +++ b/build/scripts/image_floppy_grub1 @@ -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_floppy.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 of=$IMAGE_PATH bs=1024 seek=1440 count=0 + 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_floppy.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/build/scripts/image_hd b/build/scripts/image_hd deleted file mode 100755 index 70ce748..0000000 --- a/build/scripts/image_hd +++ /dev/null @@ -1,121 +0,0 @@ -#!/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_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 -R $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/ - -# GRUB-Konfiguration kopieren -mkdir -p $MOUNT/boot/grub -rm -f $MOUNT/boot/grub/menu.lst -if [ -e $MOUNT/boot/tyndur2 ]; then - cat build/config/grub_hd_kernel2.cfg >> $MOUNT/boot/grub/menu.lst -fi -if [ -e $MOUNT/boot/tyndur ]; then - cat build/config/grub_hd.cfg >> $MOUNT/boot/grub/menu.lst -fi - - -# Grub kopieren -if [ $NEW -ne 0 ]; then - cp $LOST_GRUB_STAGESDIR/stage? $MOUNT/boot/grub/ -fi - -# Partition unmounten und loopback-Device freigeben -$SUDO umount $MOUNT -rmdir $MOUNT - - -# Grub installieren -if [ $NEW -ne 0 ]; then - $LOST_TOOLS_GRUB --no-floppy --batch > /dev/null <<EOF - device (hd0) $IMAGE_PATH - root (hd0,0) - install /boot/grub/stage1 (hd0) /boot/grub/stage2 p /boot/grub/menu.lst -EOF -fi - diff --git a/build/scripts/image_hd_grub1 b/build/scripts/image_hd_grub1 new file mode 100755 index 0000000..70ce748 --- /dev/null +++ b/build/scripts/image_hd_grub1 @@ -0,0 +1,121 @@ +#!/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_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 -R $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/ + +# GRUB-Konfiguration kopieren +mkdir -p $MOUNT/boot/grub +rm -f $MOUNT/boot/grub/menu.lst +if [ -e $MOUNT/boot/tyndur2 ]; then + cat build/config/grub_hd_kernel2.cfg >> $MOUNT/boot/grub/menu.lst +fi +if [ -e $MOUNT/boot/tyndur ]; then + cat build/config/grub_hd.cfg >> $MOUNT/boot/grub/menu.lst +fi + + +# Grub kopieren +if [ $NEW -ne 0 ]; then + cp $LOST_GRUB_STAGESDIR/stage? $MOUNT/boot/grub/ +fi + +# Partition unmounten und loopback-Device freigeben +$SUDO umount $MOUNT +rmdir $MOUNT + + +# Grub installieren +if [ $NEW -ne 0 ]; then + $LOST_TOOLS_GRUB --no-floppy --batch > /dev/null <<EOF + device (hd0) $IMAGE_PATH + root (hd0,0) + install /boot/grub/stage1 (hd0) /boot/grub/stage2 p /boot/grub/menu.lst +EOF +fi + diff --git a/build/scripts/image_hd_grub2 b/build/scripts/image_hd_grub2 new file mode 100755 index 0000000..9c0f5a8 --- /dev/null +++ b/build/scripts/image_hd_grub2 @@ -0,0 +1,154 @@ +#!/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_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 +} + +convert_menu_lst() +{ + sed -ie 's/^title \(.*\)$/menuentry "\1" {/' "$1" + sed -ie 's/^kernel \([^ ]\+\)\(.*\)$/ multiboot \1 \1 \2/' "$1" + sed -ie 's/^module \([^ ]\+\)\(.*\)$/ module \1 \1 \2/' "$1" + sed -ie 's/^boot$/}/' "$1" + sed -ie 's/|/\\|/' "$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 -R $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/ + +# GRUB-Konfiguration kopieren +mkdir -p $MOUNT/boot/grub +rm -f $MOUNT/boot/grub/grub.cfg +echo "insmod multiboot" >> $MOUNT/boot/grub/grub.cfg +if [ -e $MOUNT/boot/tyndur2 ]; then + cat build/config/grub_hd_kernel2.cfg >> $MOUNT/boot/grub/grub.cfg +fi +if [ -e $MOUNT/boot/tyndur ]; then + cat build/config/grub_hd.cfg >> $MOUNT/boot/grub/grub.cfg +fi + +convert_menu_lst $MOUNT/boot/grub/grub.cfg + +# Grub kopieren +if [ $NEW -ne 0 ]; then + xargs -isrc cp src $MOUNT/boot/grub <<-EOF + $LOST_GRUB2_MODULESDIR/boot.mod + $LOST_GRUB2_MODULESDIR/cat.mod + $LOST_GRUB2_MODULESDIR/configfile.mod + $LOST_GRUB2_MODULESDIR/crypto.mod + $LOST_GRUB2_MODULESDIR/extcmd.mod + $LOST_GRUB2_MODULESDIR/gzio.mod + $LOST_GRUB2_MODULESDIR/ls.mod + $LOST_GRUB2_MODULESDIR/mmap.mod + $LOST_GRUB2_MODULESDIR/multiboot.mod + $LOST_GRUB2_MODULESDIR/normal.mod + $LOST_GRUB2_MODULESDIR/relocator.mod + $LOST_GRUB2_MODULESDIR/terminal.mod + $LOST_GRUB2_MODULESDIR/video.mod +EOF +fi + +# Partition unmounten und loopback-Device freigeben +$SUDO umount $MOUNT +rmdir $MOUNT + + +# Grub installieren +if [ $NEW -ne 0 ]; then + LOOP_DEV=`$SUDO losetup -f $IMAGE_PATH --show` + if [ $? -ne 0 ]; then + die "Loop Device konnte nicht angelegt werden" + fi + + mkdir -p build/grub2 + echo "(img) $LOOP_DEV" > build/grub2/device.map + + cp $LOST_GRUB2_MODULESDIR/boot.img build/grub2/ + grub-mkimage -O i386-pc -o build/grub2/core.img ext2 biosdisk part_msdos minicmd + + $SUDO grub-setup -m build/grub2/device.map -d build/grub2 -r "(img,1)" "(img)" + + $SUDO losetup -d $LOOP_DEV +fi diff --git a/buildmk.sh b/buildmk.sh index c8950d3..8f390e4 100644 --- a/buildmk.sh +++ b/buildmk.sh @@ -87,6 +87,13 @@ BUILD_ROOT=$LOST_BUILDMK_ROOT/build/output PPC_BINARY=$LOST_TOOLS_PPC EOF +# Ist grub legacy installiert? +if [ -f $GRUB_STAGEDIR/stage1 ]; then + echo GRUB_VERSION=grub1 >> Makefile.local +else + echo GRUB_VERSION=grub2 >> Makefile.local +fi + cat <<EOF > Makefile -include Makefile.local @@ -274,26 +281,23 @@ updateroot: subdirs build/scripts/updateroot image-floppy: updateroot - build/scripts/image_floppy + build/scripts/image_floppy_\$(GRUB_VERSION) image-hd: updateroot - build/scripts/image_hd + build/scripts/image_hd_\$(GRUB_VERSION) image-cdrom: updateroot - build/scripts/image_cdrom + build/scripts/image_cdrom_\$(GRUB_VERSION) -grub2-hd: updateroot - build/scripts/grub2_hd - -grub2-cdrom: updateroot - build/scripts/grub2_cdrom - -test-qemu: image-floppy +test-qemu-floppy: image-floppy $LOST_TOOLS_QEMU -serial stdio -fda build/images/floppy.img -boot a -net user -net nic,model=rtl8139 | tee qemu-serial.log test-qemu-hd: image-hd $LOST_TOOLS_QEMU -serial stdio -hda build/images/hd.img -net user -net nic,model=rtl8139 | tee qemu-serial.log +test-qemu-cdrom: image-cdrom + $LOST_TOOLS_QEMU -serial stdio -cdrom build/images/cdrom.img -boot d -net user -net nic,model=rtl8139 | tee qemu-serial.log + test-bochs: image-floppy bochs -f bochs.config -- 1.7.1