source: branches/backfire/target/linux/x86/image/gen_image_x86.sh @ 21326

Last change on this file since 21326 was 21326, checked in by nico, 7 years ago

[backfire] merge r21243

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