ramips: mt7620: fix missplaced line in 01_leds
[openwrt/openwrt.git] / scripts / gen_image_generic.sh
1 #!/usr/bin/env bash
2 # Copyright (C) 2006-2012 OpenWrt.org
3 set -e -x
4 [ $# == 5 -o $# == 6 ] || {
5 echo "SYNTAX: $0 <file> <kernel size> <kernel directory> <rootfs size> <rootfs image> [<align>]"
6 exit 1
7 }
8
9 OUTPUT="$1"
10 KERNELSIZE="$2"
11 KERNELDIR="$3"
12 ROOTFSSIZE="$4"
13 ROOTFSIMAGE="$5"
14 ALIGN="$6"
15
16 rm -f "$OUTPUT"
17
18 head=16
19 sect=63
20 cyl=$(( (KERNELSIZE + ROOTFSSIZE) * 1024 * 1024 / (head * sect * 512)))
21
22 # create partition table
23 set $(ptgen -o "$OUTPUT" -h $head -s $sect ${GUID:+-g} -p ${KERNELSIZE}m -p ${ROOTFSSIZE}m ${ALIGN:+-l $ALIGN} ${SIGNATURE:+-S 0x$SIGNATURE} ${GUID:+-G $GUID})
24
25 KERNELOFFSET="$(($1 / 512))"
26 KERNELSIZE="$2"
27 ROOTFSOFFSET="$(($3 / 512))"
28 ROOTFSSIZE="$(($4 / 512))"
29
30 [ -n "$PADDING" ] && dd if=/dev/zero of="$OUTPUT" bs=512 seek="$ROOTFSOFFSET" conv=notrunc count="$ROOTFSSIZE"
31 dd if="$ROOTFSIMAGE" of="$OUTPUT" bs=512 seek="$ROOTFSOFFSET" conv=notrunc
32
33 if [ -n "$GUID" ]; then
34 [ -n "$PADDING" ] && dd if=/dev/zero of="$OUTPUT" bs=512 seek="$(($ROOTFSOFFSET + $ROOTFSSIZE))" conv=notrunc count="$sect"
35 mkfs.fat -n kernel -C "$OUTPUT.kernel" -S 512 "$(($KERNELSIZE / 1024))"
36 mcopy -s -i "$OUTPUT.kernel" "$KERNELDIR"/* ::/
37 else
38 make_ext4fs -J -L kernel -l "$KERNELSIZE" "$OUTPUT.kernel" "$KERNELDIR"
39 fi
40 dd if="$OUTPUT.kernel" of="$OUTPUT" bs=512 seek="$KERNELOFFSET" conv=notrunc
41 rm -f "$OUTPUT.kernel"