X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?p=xodist;a=blobdiff_plain;f=mkext3.sh;h=08a1c41c165e2493a492c646a4f98db18ef5a67f;hp=4a53ab9506022c9f7d4287c9deb8dae015337a53;hb=4147cb5472e422ccff6c96040c303c4cc6e8a120;hpb=f11b5b3afd3f2e9c5e229287c89740e111d5ec89 diff --git a/mkext3.sh b/mkext3.sh index 4a53ab9..08a1c41 100755 --- a/mkext3.sh +++ b/mkext3.sh @@ -1,6 +1,6 @@ -#!/bin/sh -e +#!/bin/bash -e # -# Copyright © 2008 Andres Salomon +# Copyright © 2008-2009 Andres Salomon # # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -16,12 +16,13 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -ROOT_SIZE="2048" -IMG_LABEL="DebXO" IMG_NAME="" ROOT_DIR="" +SKIP_GRUB="n" -. functions.sh +. ./functions.sh + +CONFIG_TYPE=generic # @img - fs image to attach loop device to # @offset - if the image is partitioned, the offset to attach at @@ -47,41 +48,19 @@ detach_loop() losetup -d "$1" } -# @img - fs image to mount -# @type - fs type to mount -# @offset - if the image is partitioned, the offset to mount at -# -# sets $MOUNT_POINT with the path of the newly created (and mounted) dir -mk_mount() -{ - img="$1" - type="$2" - offset="$3" - - if [ "$offset" != "" ]; then - offset=",offset=$offset" - fi - - MOUNT_POINT=$(mktemp) - rm -f $MOUNT_POINT - mkdir $MOUNT_POINT - - mount "$img" "$MOUNT_POINT" -o loop$offset -t "$type" -} - -# @mntpt - directory to umount and delete -rm_mount() -{ - umount "$1" - rmdir "$1" -} - # @img - image name to create -# @size - image size create_bootable_img() { img="$1" - size="$2" + + # get the total size by summing all the partition sizes (listed in fstab comments) + partition_sizes=`grep '^LABEL=' configs/${CONFIG_TYPE}/fstab-ext3 | \ + sed 's/.*#[[:space:]]\+\([0-9]\+\)$/\1/' | xargs echo | tr ' ' +` + size=$(($partition_sizes)) + + # there's some partition overhead; pad the image so that parted doesn't whine + overhead=`echo | awk "{ printf(\"%d\n\", 0.014 * $size); }"` + size=$((size + overhead)) # first, create a sparse image minus_size=$(($size * 6 / 100)) @@ -90,7 +69,13 @@ create_bootable_img() # fill in the partition table parted -s "$img" "mklabel msdos" - parted -s "$img" "mkpart primary ext2 0 -1" + prior=0 + grep '^LABEL=' configs/${CONFIG_TYPE}/fstab-ext3 | \ + sed 's/.*#[[:space:]]\+\([0-9]\+\)$/\1/' | while read s; do + end=$((prior + s)) + parted -s "$img" "mkpart primary ext2 $prior $end" + prior=$end + done parted -s "$img" "set 1 boot on" } @@ -109,16 +94,42 @@ grub_install() default 0 timeout 5 color cyan/blue white/blue +EOF + installer_added=0 + label=`sed -ne 's/^LABEL=\(.\+\)[[:space:]]\+\/[[:space:]]\+.*/\1/p' configs/${CONFIG_TYPE}/fstab-ext3` + prefix= + grep -q ' ${mntpt}/boot ' /proc/mounts && prefix=/boot + for kern in ${mntpt}/boot/vmlinuz-*; do + v=$(basename $kern | sed 's/vmlinuz-//') + if [ "${v}" = '*' ]; then + echo "*** Error: no kernel images found in /boot!" 1>&2 + exit 1 + fi + cat >>${mntpt}/boot/grub/menu.lst<>${mntpt}/boot/grub/menu.lst<] " 1>&2 echo "" 1>&2 echo "Options:" 1>&2 - echo " -l