]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/ventoy_pack.sh
Hotkey change:
[Ventoy.git] / INSTALL / ventoy_pack.sh
1 #!/bin/sh
2
3 if [ "$1" = "CI" ]; then
4 OPT='-dR'
5 else
6 OPT='-a'
7 fi
8
9 dos2unix -q ./tool/ventoy_lib.sh
10 dos2unix -q ./tool/VentoyWorker.sh
11 dos2unix -q ./tool/VentoyGTK.glade
12 dos2unix -q ./tool/distro_gui_type.json
13
14 . ./tool/ventoy_lib.sh
15
16 GRUB_DIR=../GRUB2/INSTALL
17 LANG_DIR=../LANGUAGES
18
19 if ! [ -d $GRUB_DIR ]; then
20 echo "$GRUB_DIR not exist"
21 exit 1
22 fi
23
24
25 cd ../IMG
26 sh mkcpio.sh
27 sh mkloopex.sh
28 cd -
29
30 cd ../Unix
31 sh pack_unix.sh
32 cd -
33
34 cd ../LinuxGUI
35 sh language.sh || exit 1
36 sh build.sh
37 cd -
38
39 cd ../Plugson
40 sh build.sh
41 sh pack.sh
42 cd -
43
44 cd ../Vlnk
45 sh build.sh
46 sh pack.sh
47 cd -
48
49
50 LOOP=$(losetup -f)
51
52 rm -f img.bin
53 dd if=/dev/zero of=img.bin bs=1M count=256 status=none
54
55 losetup -P $LOOP img.bin
56
57 while ! grep -q 524288 /sys/block/${LOOP#/dev/}/size 2>/dev/null; do
58 echo "wait $LOOP ..."
59 sleep 1
60 done
61
62 format_ventoy_disk_mbr 0 $LOOP fdisk
63
64 $GRUB_DIR/sbin/grub-bios-setup --skip-fs-probe --directory="./grub/i386-pc" $LOOP
65
66 curver=$(get_ventoy_version_from_cfg ./grub/grub.cfg)
67
68 tmpmnt=./ventoy-${curver}-mnt
69 tmpdir=./ventoy-${curver}
70
71 rm -rf $tmpmnt
72 mkdir -p $tmpmnt
73
74 mount ${LOOP}p2 $tmpmnt
75
76 mkdir -p $tmpmnt/grub
77
78 # First copy grub.cfg file, to make it locate at front of the part2
79 cp $OPT ./grub/grub.cfg $tmpmnt/grub/
80
81 ls -1 ./grub/ | grep -v 'grub\.cfg' | while read line; do
82 cp $OPT ./grub/$line $tmpmnt/grub/
83 done
84
85 #tar help txt
86 cd $tmpmnt/grub/
87 tar czf help.tar.gz ./help/
88 rm -rf ./help
89 cd ../../
90
91 #tar menu txt & update menulang.cfg
92 cd $tmpmnt/grub/
93
94 for vtlang in $(ls menu/); do
95 vtlangname=${vtlang%.*}
96 vtlangtitle=$(grep VTMENU_LANGUAGE_NAME menu/$vtlang | awk -F\" '{print $4}')
97 echo "menuentry \"$vtlangtitle\" --class=menu_lang_item --class=debug_menu_lang --class=F5tool {" >> menulang.cfg
98 echo " vt_load_menu_lang $vtlangname" >> menulang.cfg
99 echo "}" >> menulang.cfg
100 done
101 echo "menuentry '@VTMENU_RETURN_PREVIOUS' --class=vtoyret VTOY_RET {" >> menulang.cfg
102 echo " echo 'Return ...'" >> menulang.cfg
103 echo "}" >> menulang.cfg
104
105 tar czf menu.tar.gz ./menu/
106 rm -rf ./menu
107 cd ../../
108
109
110
111 cp $OPT ./ventoy $tmpmnt/
112 cp $OPT ./EFI $tmpmnt/
113 cp $OPT ./tool/ENROLL_THIS_KEY_IN_MOKMANAGER.cer $tmpmnt/
114
115
116 mkdir -p $tmpmnt/tool
117 # cp $OPT ./tool/i386/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_i386
118 # cp $OPT ./tool/x86_64/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_x86_64
119 # cp $OPT ./tool/aarch64/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_aarch64
120 # to save space
121 dd status=none bs=1024 count=16 if=./tool/i386/vtoycli of=$tmpmnt/tool/mount.exfat-fuse_i386
122 dd status=none bs=1024 count=16 if=./tool/x86_64/vtoycli of=$tmpmnt/tool/mount.exfat-fuse_x86_64
123 dd status=none bs=1024 count=16 if=./tool/aarch64/vtoycli of=$tmpmnt/tool/mount.exfat-fuse_aarch64
124
125
126 rm -f $tmpmnt/grub/i386-pc/*.img
127
128
129 umount $tmpmnt && rm -rf $tmpmnt
130
131
132 rm -rf $tmpdir
133 mkdir -p $tmpdir/boot
134 mkdir -p $tmpdir/ventoy
135 echo $curver > $tmpdir/ventoy/version
136 dd if=$LOOP of=$tmpdir/boot/boot.img bs=1 count=512 status=none
137 dd if=$LOOP of=$tmpdir/boot/core.img bs=512 count=2047 skip=1 status=none
138 xz --check=crc32 $tmpdir/boot/core.img
139
140 cp $OPT ./tool $tmpdir/
141 rm -f $tmpdir/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
142 cp $OPT Ventoy2Disk.sh $tmpdir/
143 cp $OPT VentoyWeb.sh $tmpdir/
144 cp $OPT VentoyPlugson.sh $tmpdir/
145 cp $OPT VentoyVlnk.sh $tmpdir/
146 cp $OPT VentoyGUI* $tmpdir/
147
148
149 cp $OPT README $tmpdir/
150 cp $OPT plugin $tmpdir/
151 cp $OPT CreatePersistentImg.sh $tmpdir/
152 cp $OPT ExtendPersistentImg.sh $tmpdir/
153 dos2unix -q $tmpdir/Ventoy2Disk.sh
154 dos2unix -q $tmpdir/VentoyWeb.sh
155 dos2unix -q $tmpdir/VentoyPlugson.sh
156 dos2unix -q $tmpdir/VentoyVlnk.sh
157
158
159 dos2unix -q $tmpdir/CreatePersistentImg.sh
160 dos2unix -q $tmpdir/ExtendPersistentImg.sh
161
162 cp $OPT ../LinuxGUI/WebUI $tmpdir/
163 sed 's/.*SCRIPT_DEL_THIS \(.*\)/\1/g' -i $tmpdir/WebUI/index.html
164
165 #32MB disk img
166 dd status=none if=$LOOP of=$tmpdir/ventoy/ventoy.disk.img bs=512 count=$VENTOY_SECTOR_NUM skip=$part2_start_sector
167 xz --check=crc32 $tmpdir/ventoy/ventoy.disk.img
168
169 losetup -d $LOOP && rm -f img.bin
170
171 rm -f ventoy-${curver}-linux.tar.gz
172
173
174 CurDir=$PWD
175
176 for d in i386 x86_64 aarch64 mips64el; do
177 cd $tmpdir/tool/$d
178 for file in $(ls); do
179 if [ "$file" != "xzcat" ]; then
180 if echo "$file" | grep -q '^Ventoy2Disk'; then
181 chmod +x $file
182 else
183 xz --check=crc32 $file
184 fi
185 fi
186 done
187 cd $CurDir
188 done
189
190 #chmod
191 find $tmpdir/ -type d -exec chmod 755 "{}" +
192 find $tmpdir/ -type f -exec chmod 644 "{}" +
193 chmod +x $tmpdir/Ventoy2Disk.sh
194 chmod +x $tmpdir/VentoyWeb.sh
195 chmod +x $tmpdir/VentoyPlugson.sh
196 chmod +x $tmpdir/VentoyVlnk.sh
197 chmod +x $tmpdir/VentoyGUI*
198 chmod +x $tmpdir/tool/*.sh
199
200 for d in i386 x86_64 aarch64 mips64el; do
201 chmod +x $tmpdir/tool/$d/xzcat
202 chmod +x $tmpdir/tool/$d/Ventoy2Disk.*
203 done
204
205
206 cp $OPT $LANG_DIR/languages.json $tmpdir/tool/
207
208
209 chmod +x $tmpdir/CreatePersistentImg.sh
210 chmod +x $tmpdir/ExtendPersistentImg.sh
211
212 tar -czvf ventoy-${curver}-linux.tar.gz $tmpdir
213
214
215
216 rm -f ventoy-${curver}-windows.zip
217
218 cp $OPT Ventoy2Disk.exe $tmpdir/
219 cp $OPT VentoyPlugson.exe $tmpdir/
220 cp $OPT VentoyVlnk.exe $tmpdir/
221 cp $OPT FOR_X64_ARM.txt $tmpdir/
222 mkdir -p $tmpdir/altexe
223 cp $OPT Ventoy2Disk_*.exe $tmpdir/altexe/
224
225
226
227 cp $OPT $tmpdir/tool/plugson.tar.xz $tmpdir/ventoy/
228 cp $OPT $LANG_DIR/languages.json $tmpdir/ventoy/
229 rm -rf $tmpdir/tool
230 rm -f $tmpdir/*.sh
231 rm -f $tmpdir/VentoyGUI.*
232 rm -rf $tmpdir/WebUI
233 rm -f $tmpdir/README
234
235
236 zip -r ventoy-${curver}-windows.zip $tmpdir/
237
238 rm -rf $tmpdir
239
240 echo "=============== run livecd.sh ==============="
241 cd ../LiveCDGUI
242 sh livecd.sh $1
243 cd $CurDir
244
245 mv ../LiveCDGUI/ventoy*.iso ./
246
247 if [ -e ventoy-${curver}-windows.zip ] && [ -e ventoy-${curver}-linux.tar.gz ]; then
248 echo -e "\n ============= SUCCESS =================\n"
249 else
250 echo -e "\n ============= FAILED =================\n"
251 exit 1
252 fi
253
254 rm -f log.txt
255 rm -f sha256.txt
256 sha256sum ventoy-${curver}-* > sha256.txt
257