diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2010-04-04 10:34:02 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2010-04-04 10:34:02 +0200 |
commit | 5042ac8e5927d0089d3902b1c37e5bcc1565d053 (patch) | |
tree | cd2be3085808c5ac59dd70f9c610c6a40bfe3ffd /scripts/create-image.sh | |
parent | 401dabf66529cfb5ab47b4c78d5e25fd493eef1f (diff) | |
parent | 4d569ed1a3305c7b7abe8fa4273cea3b559cc85a (diff) |
Merge branch 'master' of git+ssh://openadk.org/git/openadk
Conflicts:
BUGS
package/autoconf/Makefile
Diffstat (limited to 'scripts/create-image.sh')
-rwxr-xr-x | scripts/create-image.sh | 89 |
1 files changed, 28 insertions, 61 deletions
diff --git a/scripts/create-image.sh b/scripts/create-image.sh index bbebcf4d2..b4824aea7 100755 --- a/scripts/create-image.sh +++ b/scripts/create-image.sh @@ -1,19 +1,16 @@ #!/usr/bin/env bash -grubinstall=1 +filesystem=ext2 -while getopts ":tin" option +while getopts "f:i" option do case $option in - t) - emul=$OPTARG + f) + filesystem=$OPTARG ;; i) initramfs=1 ;; - n) - grubinstall=0 - ;; *) printf "Option not recognized\n" exit 1 @@ -27,10 +24,10 @@ if [ $(id -u) -ne 0 ];then exit 1 fi -printf "Checking if grub is installed" -grub=$(which grub) +printf "Checking if mkfs is installed" +mkfs=$(which mkfs.$filesystem) -if [ ! -z $grub -a -x $grub ];then +if [ ! -z $mkfs -a -x $mkfs ];then printf "...okay\n" else printf "...failed\n" @@ -75,27 +72,40 @@ else fi -printf "Generate qemu image\n" -$qimg create -f raw $1 300M +printf "Generate qemu image (512 MB)\n" +$qimg create -f raw $1 512M >/dev/null + +printf "Creating filesystem $filesystem\n" printf "Create partition and filesystem\n" $parted -s $1 mklabel msdos -$parted -s $1 mkpart primary ext2 0 300 +$parted -s $1 mkpart primary ext2 0 100% $parted -s $1 set 1 boot on -$parted -s $1 mkfs 1 ext2 + +dd if=$1 of=mbr bs=16384 count=1 2>/dev/null +dd if=$1 skip=16384 of=$1.new 2>/dev/null + +if [ "$filesystem" = "ext2" -o "$filesystem" = "ext3" -o "$filesystem" = "ext4" ];then + mkfsopts=-F +fi + +mkfs.$filesystem $mkfsopts ${1}.new >/dev/null if [ $? -eq 0 ];then printf "Successfully created partition\n" - $parted $1 print + #$parted $1 print else printf "Partition creation failed, Exiting.\n" exit 1 fi +cat mbr ${1}.new > $1 +rm ${1}.new +rm mbr tmp=$(mktemp -d) -mount -o loop,offset=16384 -t ext2 $1 $tmp +mount -o loop,offset=16384 -t $filesystem $1 $tmp if [ -z $initramfs ];then printf "Extracting install archive\n" @@ -110,59 +120,16 @@ else cp $2-initramfs $tmp/boot/initramfs fi -if [ $grubinstall -eq 1 ];then -printf "Copying grub files\n" -mkdir $tmp/boot/grub -cp /boot/grub/stage1 $tmp/boot/grub -cp /boot/grub/stage2 $tmp/boot/grub -cp /boot/grub/e2fs_stage1_5 $tmp/boot/grub - -if [ -z $initramfs ];then -cat << EOF > $tmp/boot/grub/menu.lst -serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 -terminal --timeout=2 serial console -timeout 2 -default 0 -hiddenmenu -title linux -root (hd0,0) -kernel /boot/kernel root=/dev/sda1 init=/init console=ttyS0,115200 console=tty0 panic=10 rw -EOF -else -cat << EOF > $tmp/boot/grub/menu.lst -serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 -terminal --timeout=2 serial console -timeout 4 -default 0 -hiddenmenu -title linux -root (hd0,0) -kernel /boot/kernel root=/dev/sda1 console=ttyS0,115200 console=tty0 rw -initrd /boot/initramfs -EOF -fi - -printf "Installing Grub bootloader\n" -$grub --batch --no-curses --no-floppy --device-map=/dev/null >/dev/null << EOF -device (hd0) $1 -root (hd0,0) -setup (hd0) -quit -EOF - -fi - -printf "Creating device nodes\n" +#printf "Creating device nodes\n" mknod -m 666 $tmp/dev/zero c 1 5 mknod -m 666 $tmp/dev/null c 1 3 mknod -m 622 $tmp/dev/console c 5 1 mknod -m 666 $tmp/dev/tty c 5 0 mknod -m 666 $tmp/dev/tty0 c 4 0 -mknod -m 660 $tmp/dev/hda b 3 0 -mknod -m 660 $tmp/dev/hda1 b 3 1 mknod -m 666 $tmp/dev/ttyS0 c 4 64 umount $tmp printf "Successfully installed.\n" +printf "Be sure $1 is writable for the user which use qemu\n" exit 0 |