forked from a1ive/grub2-filemanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·124 lines (118 loc) · 3.22 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env sh
echo -n "checking for gettext ... "
if [ -e "$(which msgfmt)" ]
then
echo "ok"
else
echo "not found\nPlease install gettext."
exit
fi
echo -n "checking for mkisofs ... "
if [ -e "$(which mkisofs)" ]
then
echo "ok"
geniso=$(which mkisofs)
else
echo -n "not found\nchecking for genisoimage ... "
if [ -e "$(which genisoimage)" ]
then
echo "ok"
geniso=$(which genisoimage)
else
echo "not found\nPlease install mkisofs or genisoimage."
exit
fi
fi
echo -n "checking for grub ... "
if [ -e "$(which grub-mkimage)" ]
then
mkimage=grub-mkimage
echo "ok"
else
echo "not found"
case "$( uname -m )" in
i?86) mkimage="./bin/grub-mkimage32"
;;
x86_64) mkimage="./bin/grub-mkimage64"
;;
esac
fi
if [ -d "build" ]
then
rm -r build
fi
mkdir build
echo "common files"
cp -r boot build/
echo "Language / 语言 / 語言"
echo "1. Simplified Chinese / 简体中文"
echo "2. Traditional Chinese / 正體中文"
echo "3. English (United States)"
read -p "Please make a choice: " choice
case "$choice" in
2)
echo "zh_TW"
msgfmt grub/locale/zh_TW.po -o build/boot/grub/locale/zh_TW.mo
msgfmt lang/zh_TW/fm.po -o build/boot/grub/locale/fm/zh_TW.mo
cp lang/zh_TW/lang.sh build/boot/grub/
;;
3)
echo "en_US"
;;
*)
echo "zh_CN"
msgfmt grub/locale/zh_CN.po -o build/boot/grub/locale/zh_CN.mo
msgfmt lang/zh_CN/fm.po -o build/boot/grub/locale/fm/zh_CN.mo
cp lang/zh_CN/lang.sh build/boot/grub/
;;
esac
echo "x86_64-efi"
cp arch/x64/CrScreenshotDxe.efi build/boot/grub
cp arch/x64/Shell.efi build/boot/grub
cd build
find ./boot | cpio -o -H newc > ./memdisk.cpio
cd ..
rm build/boot/grub/*.efi
modules=$(cat arch/x64/builtin.lst)
$mkimage -m ./build/memdisk.cpio -d ./grub/x86_64-efi -p "(memdisk)/boot/grub" -c arch/x64/config.cfg -o grubfmx64.efi -O x86_64-efi $modules
echo "i386-efi"
cp arch/ia32/CrScreenshotDxe.efi build/boot/grub
cp arch/x64/Shell.efi build/boot/grub
cd build
find ./boot | cpio -o -H newc > ./memdisk.cpio
cd ..
rm build/boot/grub/*.efi
modules=$(cat arch/ia32/builtin.lst)
$mkimage -m ./build/memdisk.cpio -d ./grub/i386-efi -p "(memdisk)/boot/grub" -c arch/ia32/config.cfg -o grubfmia32.efi -O i386-efi $modules
rm build/memdisk.cpio
echo "i386-pc"
builtin=$(cat arch/legacy/builtin.lst)
mkdir build/boot/grub/i386-pc
for modules in $(cat arch/legacy/insmod.lst)
do
echo "copying ${modules}.mod"
cp grub/i386-pc/${modules}.mod build/boot/grub/i386-pc/
done
cp arch/legacy/insmod.lst build/boot/grub/
cp arch/legacy/grub.exe build/boot/grub/
cp arch/legacy/memdisk build/boot/grub/
cp arch/legacy/ipxe.lkrn build/boot/grub/
cd build
find ./boot | cpio -o -H newc | gzip -9 > ./fm.loop
cd ..
rm -r build/boot
$mkimage -d ./grub/i386-pc -p "(memdisk)/boot/grub" -c arch/legacy/config.cfg -o ./build/core.img -O i386-pc $builtin
cat grub/i386-pc/cdboot.img build/core.img > build/fmldr
rm build/core.img
cp arch/legacy/MAP build/
if [ -e "legacy/ntboot/NTBOOT.MOD/NTBOOT.NT6" -o -e "legacy/ntboot/NTBOOT.MOD/NTBOOT.PE1" ]
then
cp -r arch/legacy/ntboot/* build/
echo "WARNING: Non-GPL module(s) enabled!"
fi
if [ -e "legacy/wimboot" ]
then
cp arch/legacy/wimboot build/
fi
$geniso -R -hide-joliet boot.catalog -b fmldr -no-emul-boot -allow-lowercase -boot-load-size 4 -boot-info-table -o grubfm.iso build
rm -r build