host-build: add HOST_MAKE_FLAGS similar to package MAKE_FLAGS
[openwrt/svn-archive/archive.git] / target / linux / x86 / image / gen_image_x86.sh
1 #!/usr/bin/env bash
2 # Copyright (C) 2006-2010 OpenWrt.org
3 set -x
4 [ $# == 5 ] || {
5 echo "SYNTAX: $0 <file> <kernel size> <kernel directory> <rootfs size> <rootfs image>"
6 exit 1
7 }
8
9 OUTPUT="$1"
10 KERNELSIZE="$2"
11 KERNELDIR="$3"
12 ROOTFSSIZE="$4"
13 ROOTFSIMAGE="$5"
14
15 rm -f "$OUTPUT"
16
17 head=16
18 sect=63
19 cyl=$(( ($KERNELSIZE + $ROOTFSSIZE) * 1024 * 1024 / ($head * $sect * 512)))
20
21 # create partition table
22 set `ptgen -o "$OUTPUT" -h $head -s $sect -p ${KERNELSIZE}m -p ${ROOTFSSIZE}m`
23
24 KERNELOFFSET="$(($1 / 512))"
25 KERNELSIZE="$(($2 / 512))"
26 ROOTFSOFFSET="$(($3 / 512))"
27 ROOTFSSIZE="$(($4 / 512))"
28
29 BLOCKS="$((($KERNELSIZE / 2) - 1))"
30
31 [ -n "$PADDING" ] && dd if=/dev/zero of="$OUTPUT" bs=512 seek="$ROOTFSOFFSET" conv=notrunc count="$ROOTFSSIZE"
32 dd if="$ROOTFSIMAGE" of="$OUTPUT" bs=512 seek="$ROOTFSOFFSET" conv=notrunc
33
34 [ -n "$NOGRUB" ] && exit 0
35
36 genext2fs -d "$KERNELDIR" -b "$BLOCKS" "$OUTPUT.kernel"
37 dd if="$OUTPUT.kernel" of="$OUTPUT" bs=512 seek="$KERNELOFFSET" conv=notrunc
38 rm -f "$OUTPUT.kernel"
39
40 which chpax >/dev/null && chpax -zp $(which grub)
41 grub --batch --no-curses --no-floppy --device-map=/dev/null <<EOF
42 device (hd0) $OUTPUT
43 geometry (hd0) $cyl $head $sect
44 root (hd0,0)
45 setup (hd0)
46 quit
47 EOF
48