]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/ventoy_pack.sh
Update vtoytool
[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 vtlangtitle=$(grep VTLANG_LANGUAGE_NAME menu/zh_CN.json | awk -F\" '{print $4}')
95 echo "menuentry \"zh_CN - $vtlangtitle\" --class=menu_lang_item --class=debug_menu_lang --class=F5tool {" >> menulang.cfg
96 echo " vt_load_menu_lang zh_CN" >> menulang.cfg
97 echo "}" >> menulang.cfg
98
99 ls -1 menu/ | grep -v 'zh_CN' | sort | while read vtlang; do
100 vtlangname=${vtlang%.*}
101 vtlangtitle=$(grep VTLANG_LANGUAGE_NAME menu/$vtlang | awk -F\" '{print $4}')
102 echo "menuentry \"$vtlangname - $vtlangtitle\" --class=menu_lang_item --class=debug_menu_lang --class=F5tool {" >> menulang.cfg
103 echo " vt_load_menu_lang $vtlangname" >> menulang.cfg
104 echo "}" >> menulang.cfg
105 done
106 echo "menuentry \"\$VTLANG_RETURN_PREVIOUS\" --class=vtoyret VTOY_RET {" >> menulang.cfg
107 echo " echo \"Return ...\"" >> menulang.cfg
108 echo "}" >> menulang.cfg
109
110 tar czf menu.tar.gz ./menu/
111 rm -rf ./menu
112 cd ../../
113
114
115
116 cp $OPT ./ventoy $tmpmnt/
117 cp $OPT ./EFI $tmpmnt/
118 cp $OPT ./tool/ENROLL_THIS_KEY_IN_MOKMANAGER.cer $tmpmnt/
119
120
121 mkdir -p $tmpmnt/tool
122 # cp $OPT ./tool/i386/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_i386
123 # cp $OPT ./tool/x86_64/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_x86_64
124 # cp $OPT ./tool/aarch64/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_aarch64
125 # to save space
126 dd status=none bs=1024 count=16 if=./tool/i386/vtoycli of=$tmpmnt/tool/mount.exfat-fuse_i386
127 dd status=none bs=1024 count=16 if=./tool/x86_64/vtoycli of=$tmpmnt/tool/mount.exfat-fuse_x86_64
128 dd status=none bs=1024 count=16 if=./tool/aarch64/vtoycli of=$tmpmnt/tool/mount.exfat-fuse_aarch64
129
130
131 rm -f $tmpmnt/grub/i386-pc/*.img
132
133
134 umount $tmpmnt && rm -rf $tmpmnt
135
136
137 rm -rf $tmpdir
138 mkdir -p $tmpdir/boot
139 mkdir -p $tmpdir/ventoy
140 echo $curver > $tmpdir/ventoy/version
141 dd if=$LOOP of=$tmpdir/boot/boot.img bs=1 count=512 status=none
142 dd if=$LOOP of=$tmpdir/boot/core.img bs=512 count=2047 skip=1 status=none
143 xz --check=crc32 $tmpdir/boot/core.img
144
145 cp $OPT ./tool $tmpdir/
146 rm -f $tmpdir/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
147 cp $OPT Ventoy2Disk.sh $tmpdir/
148 cp $OPT VentoyWeb.sh $tmpdir/
149 cp $OPT VentoyPlugson.sh $tmpdir/
150 cp $OPT VentoyVlnk.sh $tmpdir/
151 cp $OPT VentoyGUI* $tmpdir/
152
153
154 cp $OPT README $tmpdir/
155 cp $OPT plugin $tmpdir/
156 cp $OPT CreatePersistentImg.sh $tmpdir/
157 cp $OPT ExtendPersistentImg.sh $tmpdir/
158 dos2unix -q $tmpdir/Ventoy2Disk.sh
159 dos2unix -q $tmpdir/VentoyWeb.sh
160 dos2unix -q $tmpdir/VentoyPlugson.sh
161 dos2unix -q $tmpdir/VentoyVlnk.sh
162
163
164 dos2unix -q $tmpdir/CreatePersistentImg.sh
165 dos2unix -q $tmpdir/ExtendPersistentImg.sh
166
167 cp $OPT ../LinuxGUI/WebUI $tmpdir/
168 sed 's/.*SCRIPT_DEL_THIS \(.*\)/\1/g' -i $tmpdir/WebUI/index.html
169
170 #32MB disk img
171 dd status=none if=$LOOP of=$tmpdir/ventoy/ventoy.disk.img bs=512 count=$VENTOY_SECTOR_NUM skip=$part2_start_sector
172
173
174 #4k image
175 # echo "make 4K img ..."
176 # dd status=none if=/dev/zero of=$tmpdir/ventoy/ventoy_4k.disk.img bs=1M count=32
177 # mkfs.vfat -F 16 -n VTOYEFI -s 1 -S 4096 $tmpdir/ventoy/ventoy_4k.disk.img
178 # vDIR1=$(mktemp -d)
179 # vDIR2=$(mktemp -d)
180 # mount $tmpdir/ventoy/ventoy.disk.img $vDIR1
181 # mount $tmpdir/ventoy/ventoy_4k.disk.img $vDIR2
182 # cp -a $vDIR1/* $vDIR2/
183 # umount $vDIR1
184 # umount $vDIR2
185 # rm -rf $vDIR1 $vDIR2
186
187 # xz --check=crc32 $tmpdir/ventoy/ventoy_4k.disk.img
188
189 xz --check=crc32 $tmpdir/ventoy/ventoy.disk.img
190
191
192
193 losetup -d $LOOP && rm -f img.bin
194
195 rm -f ventoy-${curver}-linux.tar.gz
196
197
198 CurDir=$PWD
199
200 for d in i386 x86_64 aarch64 mips64el; do
201 cd $tmpdir/tool/$d
202 for file in $(ls); do
203 if [ "$file" != "xzcat" ]; then
204 if echo "$file" | grep -q '^Ventoy2Disk'; then
205 chmod +x $file
206 else
207 xz --check=crc32 $file
208 fi
209 fi
210 done
211 cd $CurDir
212 done
213
214 #chmod
215 find $tmpdir/ -type d -exec chmod 755 "{}" +
216 find $tmpdir/ -type f -exec chmod 644 "{}" +
217 chmod +x $tmpdir/Ventoy2Disk.sh
218 chmod +x $tmpdir/VentoyWeb.sh
219 chmod +x $tmpdir/VentoyPlugson.sh
220 chmod +x $tmpdir/VentoyVlnk.sh
221 chmod +x $tmpdir/VentoyGUI*
222 chmod +x $tmpdir/tool/*.sh
223
224 for d in i386 x86_64 aarch64 mips64el; do
225 chmod +x $tmpdir/tool/$d/xzcat
226 chmod +x $tmpdir/tool/$d/Ventoy2Disk.*
227 done
228
229
230 cp $OPT $LANG_DIR/languages.json $tmpdir/tool/
231
232
233 chmod +x $tmpdir/CreatePersistentImg.sh
234 chmod +x $tmpdir/ExtendPersistentImg.sh
235
236 tar -czvf ventoy-${curver}-linux.tar.gz $tmpdir
237
238
239
240 rm -f ventoy-${curver}-windows.zip
241
242 cp $OPT Ventoy2Disk.exe $tmpdir/
243 cp $OPT VentoyPlugson.exe $tmpdir/
244 cp $OPT VentoyVlnk.exe $tmpdir/
245 cp $OPT FOR_X64_ARM.txt $tmpdir/
246 mkdir -p $tmpdir/altexe
247 cp $OPT Ventoy2Disk_*.exe $tmpdir/altexe/
248 cp $OPT VentoyPlugson_*.exe $tmpdir/altexe/
249
250
251
252 cp $OPT $tmpdir/tool/plugson.tar.xz $tmpdir/ventoy/
253 cp $OPT $LANG_DIR/languages.json $tmpdir/ventoy/
254 rm -rf $tmpdir/tool
255 rm -f $tmpdir/*.sh
256 rm -f $tmpdir/VentoyGUI.*
257 rm -rf $tmpdir/WebUI
258 rm -f $tmpdir/README
259
260
261 zip -r ventoy-${curver}-windows.zip $tmpdir/
262
263 rm -rf $tmpdir
264
265 echo "=============== run livecd.sh ==============="
266 cd ../LiveCDGUI
267 sh livecd.sh $1
268 cd $CurDir
269
270 mv ../LiveCDGUI/ventoy*.iso ./
271
272 if [ -e ventoy-${curver}-windows.zip ] && [ -e ventoy-${curver}-linux.tar.gz ]; then
273 echo -e "\n ============= SUCCESS =================\n"
274 else
275 echo -e "\n ============= FAILED =================\n"
276 exit 1
277 fi
278
279 rm -f log.txt
280 rm -f sha256.txt
281 sha256sum ventoy-${curver}-* > sha256.txt
282