diff options
author | Felix Fietkau <nbd@openwrt.org> | 2006-10-13 22:51:49 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2016-03-20 17:29:15 +0100 |
commit | 60c1f0f64d23003a19a07d6b9638542130f6641d (patch) | |
tree | 8fb2787f4c49baded97cd55e0c371fe1cffce2b6 /target/image/x86/gen_image.sh | |
parent | d58a09110ccfa95f06c983fe796806f2e035c9d2 (diff) | |
parent | b3ce218b51746d3a576221ea542facf3a1703ab2 (diff) | |
download | upstream-60c1f0f64d23003a19a07d6b9638542130f6641d.tar.gz upstream-60c1f0f64d23003a19a07d6b9638542130f6641d.tar.bz2 upstream-60c1f0f64d23003a19a07d6b9638542130f6641d.zip |
finally move buildroot-ng to trunk
Diffstat (limited to 'target/image/x86/gen_image.sh')
-rwxr-xr-x | target/image/x86/gen_image.sh | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/target/image/x86/gen_image.sh b/target/image/x86/gen_image.sh new file mode 100755 index 0000000000..95be6cc8ef --- /dev/null +++ b/target/image/x86/gen_image.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env bash +# Copyright (C) 2006 OpenWrt.org + +[ $# == 5 ] || { + echo "SYNTAX: $0 <file> <kernel size> <kernel directory> <rootfs size> <rootfs image>" + exit 1 +} + +file="$1" +part1s="$2" +part1d="$3" +part2s="$4" +part2f="$5" + +head=16 +sect=63 +cyl=$(( ($part1s + $part2s) * 1024 * 1024 / ($head * $sect * 512))) + +dd if=/dev/zero of="$file" bs=1M count=$(($part1s + $part2s)) 2>/dev/null || exit +fdisk -u -C $cyl -H $head -S $sect "$file" > /dev/null 2>/dev/null <<EOF +n +p +1 + ++${part1s}M +n +p +2 + ++${part2s}M +w +q +EOF + +block() { + echo -e 'p\nq' | fdisk -u -C $cyl -H $head -S $sect "$file" | awk -v file="$file$1" -v n="$(($2 + 2))" ' +$1 == file { + print $n * 512 +}' +} + +start="$(block 1 0)" +end="$(block 1 1)" +blocks="$(( ($end - $start) / 1024 ))" + +genext2fs -d "$part1d" -b "$blocks" "$file.kernel" +dd if="$file.kernel" of="$file" bs=512 seek="$(($start / 512))" conv=notrunc +rm -f "$file.kernel" + +start="$(block 2 0)" +dd if="$part2f" of="$file" bs=512 seek="$(($start / 512))" conv=notrunc + +which chpax >/dev/null && chpax -zp $(which grub) +grub --device-map=/dev/null <<EOF +device (hd0) $file +geometry (hd0) $cyl $head $sect +root (hd0,0) +setup (hd0) +EOF + |