diff options
Diffstat (limited to 'src/tools/build.sh')
-rwxr-xr-x | src/tools/build.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/tools/build.sh b/src/tools/build.sh new file mode 100755 index 0000000..d542a8f --- /dev/null +++ b/src/tools/build.sh | |||
@@ -0,0 +1,40 @@ | |||
1 | #!/bin/bash | ||
2 | # build.sh -- a shell version of build.c for the new bootsect.s & setup.s | ||
3 | # author: falcon <wuzhangjin@gmail.com> | ||
4 | # update: 2008-10-10 | ||
5 | |||
6 | bootsect=$1 | ||
7 | setup=$2 | ||
8 | system=$3 | ||
9 | IMAGE=$4 | ||
10 | root_dev=$5 | ||
11 | |||
12 | # Set the biggest sys_size | ||
13 | # Changes from 0x20000 to 0x30000 by tigercn to avoid oversized code. | ||
14 | SYS_SIZE=$((0x3000*16)) | ||
15 | |||
16 | # set the default "device" file for root image file | ||
17 | if [ -z "$root_dev" ]; then | ||
18 | DEFAULT_MAJOR_ROOT=3 | ||
19 | DEFAULT_MINOR_ROOT=1 | ||
20 | else | ||
21 | DEFAULT_MAJOR_ROOT=${root_dev:0:2} | ||
22 | DEFAULT_MINOR_ROOT=${root_dev:2:3} | ||
23 | fi | ||
24 | |||
25 | # Write bootsect (512 bytes, one sector) to stdout | ||
26 | [ ! -f "$bootsect" ] && echo "there is no bootsect binary file there" && exit -1 | ||
27 | dd if=$bootsect bs=512 count=1 of=$IMAGE 2>&1 >/dev/null | ||
28 | |||
29 | # Write setup(4 * 512bytes, four sectors) to stdout | ||
30 | [ ! -f "$setup" ] && echo "there is no setup binary file there" && exit -1 | ||
31 | dd if=$setup seek=1 bs=512 count=4 of=$IMAGE 2>&1 >/dev/null | ||
32 | |||
33 | # Write system(< SYS_SIZE) to stdout | ||
34 | [ ! -f "$system" ] && echo "there is no system binary file there" && exit -1 | ||
35 | system_size=`wc -c $system |cut -d" " -f1` | ||
36 | [ $system_size -gt $SYS_SIZE ] && echo "the system binary is too big" && exit -1 | ||
37 | dd if=$system seek=5 bs=512 count=$((2888-1-4)) of=$IMAGE 2>&1 >/dev/null | ||
38 | |||
39 | # Set "device" for the root image file | ||
40 | echo -ne "\x$DEFAULT_MINOR_ROOT\x$DEFAULT_MAJOR_ROOT" | dd ibs=1 obs=1 count=2 seek=508 of=$IMAGE conv=notrunc 2>&1 >/dev/null | ||