]>
Commit | Line | Data |
---|---|---|
4366d57a CD |
1 | #!/bin/sh |
2 | # | |
3 | # This file is subject to the terms and conditions of the GNU General Public | |
4 | # License. See the file "COPYING" in the main directory of this archive | |
5 | # for more details. | |
6 | # | |
7 | # Copyright (C) 2017 by Changbin Du <changbin.du@intel.com> | |
8 | # | |
9 | # Adapted from code in arch/x86/boot/Makefile by H. Peter Anvin and others | |
10 | # | |
11 | # "make fdimage/fdimage144/fdimage288/isoimage" script for x86 architecture | |
12 | # | |
13 | # Arguments: | |
14 | # $1 - fdimage format | |
15 | # $2 - target image file | |
16 | # $3 - kernel bzImage file | |
17 | # $4 - mtool configuration file | |
18 | # $5 - kernel cmdline | |
19 | # $6 - inird image file | |
20 | # | |
21 | ||
7980f029 CD |
22 | # Use "make V=1" to debug this script |
23 | case "${KBUILD_VERBOSE}" in | |
24 | *1*) | |
25 | set -x | |
26 | ;; | |
27 | esac | |
28 | ||
4366d57a CD |
29 | verify () { |
30 | if [ ! -f "$1" ]; then | |
31 | echo "" 1>&2 | |
32 | echo " *** Missing file: $1" 1>&2 | |
33 | echo "" 1>&2 | |
34 | exit 1 | |
35 | fi | |
36 | } | |
37 | ||
38 | ||
39 | export MTOOLSRC=$4 | |
40 | FIMAGE=$2 | |
41 | FBZIMAGE=$3 | |
42 | KCMDLINE=$5 | |
43 | FDINITRD=$6 | |
44 | ||
45 | # Make sure the files actually exist | |
46 | verify "$FBZIMAGE" | |
4366d57a CD |
47 | |
48 | genbzdisk() { | |
f79ce87f | 49 | verify "$MTOOLSRC" |
4366d57a CD |
50 | mformat a: |
51 | syslinux $FIMAGE | |
52 | echo "$KCMDLINE" | mcopy - a:syslinux.cfg | |
53 | if [ -f "$FDINITRD" ] ; then | |
54 | mcopy "$FDINITRD" a:initrd.img | |
55 | fi | |
56 | mcopy $FBZIMAGE a:linux | |
57 | } | |
58 | ||
59 | genfdimage144() { | |
f79ce87f | 60 | verify "$MTOOLSRC" |
7980f029 | 61 | dd if=/dev/zero of=$FIMAGE bs=1024 count=1440 2> /dev/null |
4366d57a CD |
62 | mformat v: |
63 | syslinux $FIMAGE | |
64 | echo "$KCMDLINE" | mcopy - v:syslinux.cfg | |
65 | if [ -f "$FDINITRD" ] ; then | |
66 | mcopy "$FDINITRD" v:initrd.img | |
67 | fi | |
68 | mcopy $FBZIMAGE v:linux | |
69 | } | |
70 | ||
71 | genfdimage288() { | |
f79ce87f | 72 | verify "$MTOOLSRC" |
7980f029 | 73 | dd if=/dev/zero of=$FIMAGE bs=1024 count=2880 2> /dev/null |
4366d57a CD |
74 | mformat w: |
75 | syslinux $FIMAGE | |
76 | echo "$KCMDLINE" | mcopy - W:syslinux.cfg | |
77 | if [ -f "$FDINITRD" ] ; then | |
78 | mcopy "$FDINITRD" w:initrd.img | |
79 | fi | |
80 | mcopy $FBZIMAGE w:linux | |
81 | } | |
82 | ||
83 | genisoimage() { | |
84 | tmp_dir=`dirname $FIMAGE`/isoimage | |
85 | rm -rf $tmp_dir | |
86 | mkdir $tmp_dir | |
87 | for i in lib lib64 share end ; do | |
8a7546a0 CD |
88 | for j in syslinux ISOLINUX ; do |
89 | if [ -f /usr/$i/$j/isolinux.bin ] ; then | |
90 | isolinux=/usr/$i/$j/isolinux.bin | |
8a7546a0 | 91 | cp $isolinux $tmp_dir |
4366d57a | 92 | fi |
8a7546a0 CD |
93 | done |
94 | for j in syslinux syslinux/modules/bios ; do | |
95 | if [ -f /usr/$i/$j/ldlinux.c32 ]; then | |
96 | ldlinux=/usr/$i/$j/ldlinux.c32 | |
8a7546a0 CD |
97 | cp $ldlinux $tmp_dir |
98 | fi | |
99 | done | |
100 | if [ -n "$isolinux" -a -n "$ldlinux" ] ; then | |
4366d57a CD |
101 | break |
102 | fi | |
8a7546a0 CD |
103 | if [ $i = end -a -z "$isolinux" ] ; then |
104 | echo 'Need an isolinux.bin file, please install syslinux/isolinux.' | |
105 | exit 1 | |
106 | fi | |
4366d57a CD |
107 | done |
108 | cp $FBZIMAGE $tmp_dir/linux | |
109 | echo "$KCMDLINE" > $tmp_dir/isolinux.cfg | |
110 | if [ -f "$FDINITRD" ] ; then | |
111 | cp "$FDINITRD" $tmp_dir/initrd.img | |
112 | fi | |
7980f029 | 113 | mkisofs -J -r -input-charset=utf-8 -quiet -o $FIMAGE -b isolinux.bin \ |
c306ba7b CD |
114 | -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table \ |
115 | $tmp_dir | |
4366d57a CD |
116 | isohybrid $FIMAGE 2>/dev/null || true |
117 | rm -rf $tmp_dir | |
118 | } | |
119 | ||
120 | case $1 in | |
121 | bzdisk) genbzdisk;; | |
122 | fdimage144) genfdimage144;; | |
123 | fdimage288) genfdimage288;; | |
124 | isoimage) genisoimage;; | |
125 | *) echo 'Unknown image format'; exit 1; | |
126 | esac |