]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/ventoy_pack.sh
1.0.65 release
[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
45 LOOP=$(losetup -f)
46
47 rm -f img.bin
48 dd if=/dev/zero of=img.bin bs=1M count=256 status=none
49
50 losetup -P $LOOP img.bin
51
52 while ! grep -q 524288 /sys/block/${LOOP#/dev/}/size 2>/dev/null; do
53 echo "wait $LOOP ..."
54 sleep 1
55 done
56
57 format_ventoy_disk_mbr 0 $LOOP fdisk
58
59 $GRUB_DIR/sbin/grub-bios-setup --skip-fs-probe --directory="./grub/i386-pc" $LOOP
60
61 curver=$(get_ventoy_version_from_cfg ./grub/grub.cfg)
62
63 tmpmnt=./ventoy-${curver}-mnt
64 tmpdir=./ventoy-${curver}
65
66 rm -rf $tmpmnt
67 mkdir -p $tmpmnt
68
69 mount ${LOOP}p2 $tmpmnt
70
71 mkdir -p $tmpmnt/grub
72
73 # First copy grub.cfg file, to make it locate at front of the part2
74 cp $OPT ./grub/grub.cfg $tmpmnt/grub/
75
76 ls -1 ./grub/ | grep -v 'grub\.cfg' | while read line; do
77 cp $OPT ./grub/$line $tmpmnt/grub/
78 done
79
80 #tar help txt
81 cd $tmpmnt/grub/
82 tar czf help.tar.gz ./help/
83 rm -rf ./help
84 cd ../../
85
86
87 cp $OPT ./ventoy $tmpmnt/
88 cp $OPT ./EFI $tmpmnt/
89 cp $OPT ./tool/ENROLL_THIS_KEY_IN_MOKMANAGER.cer $tmpmnt/
90
91
92 mkdir -p $tmpmnt/tool
93 # cp $OPT ./tool/i386/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_i386
94 # cp $OPT ./tool/x86_64/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_x86_64
95 # cp $OPT ./tool/aarch64/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_aarch64
96 # to save space
97 dd status=none bs=1024 count=16 if=./tool/i386/vtoycli of=$tmpmnt/tool/mount.exfat-fuse_i386
98 dd status=none bs=1024 count=16 if=./tool/x86_64/vtoycli of=$tmpmnt/tool/mount.exfat-fuse_x86_64
99 dd status=none bs=1024 count=16 if=./tool/aarch64/vtoycli of=$tmpmnt/tool/mount.exfat-fuse_aarch64
100
101
102 rm -f $tmpmnt/grub/i386-pc/*.img
103
104
105 umount $tmpmnt && rm -rf $tmpmnt
106
107
108 rm -rf $tmpdir
109 mkdir -p $tmpdir/boot
110 mkdir -p $tmpdir/ventoy
111 echo $curver > $tmpdir/ventoy/version
112 dd if=$LOOP of=$tmpdir/boot/boot.img bs=1 count=512 status=none
113 dd if=$LOOP of=$tmpdir/boot/core.img bs=512 count=2047 skip=1 status=none
114 xz --check=crc32 $tmpdir/boot/core.img
115
116 cp $OPT ./tool $tmpdir/
117 rm -f $tmpdir/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
118 cp $OPT Ventoy2Disk.sh $tmpdir/
119 cp $OPT VentoyWeb.sh $tmpdir/
120 cp $OPT VentoyPlugson.sh $tmpdir/
121 cp $OPT VentoyGUI* $tmpdir/
122
123
124 cp $OPT README $tmpdir/
125 cp $OPT plugin $tmpdir/
126 cp $OPT CreatePersistentImg.sh $tmpdir/
127 cp $OPT ExtendPersistentImg.sh $tmpdir/
128 dos2unix -q $tmpdir/Ventoy2Disk.sh
129 dos2unix -q $tmpdir/VentoyWeb.sh
130 dos2unix -q $tmpdir/VentoyPlugson.sh
131
132
133 dos2unix -q $tmpdir/CreatePersistentImg.sh
134 dos2unix -q $tmpdir/ExtendPersistentImg.sh
135
136 cp $OPT ../LinuxGUI/WebUI $tmpdir/
137 sed 's/.*SCRIPT_DEL_THIS \(.*\)/\1/g' -i $tmpdir/WebUI/index.html
138
139 #32MB disk img
140 dd status=none if=$LOOP of=$tmpdir/ventoy/ventoy.disk.img bs=512 count=$VENTOY_SECTOR_NUM skip=$part2_start_sector
141 xz --check=crc32 $tmpdir/ventoy/ventoy.disk.img
142
143 losetup -d $LOOP && rm -f img.bin
144
145 rm -f ventoy-${curver}-linux.tar.gz
146
147
148 CurDir=$PWD
149
150 for d in i386 x86_64 aarch64 mips64el; do
151 cd $tmpdir/tool/$d
152 for file in $(ls); do
153 if [ "$file" != "xzcat" ]; then
154 if echo "$file" | grep -q '^Ventoy2Disk'; then
155 chmod +x $file
156 else
157 xz --check=crc32 $file
158 fi
159 fi
160 done
161 cd $CurDir
162 done
163
164 #chmod
165 find $tmpdir/ -type d -exec chmod 755 "{}" +
166 find $tmpdir/ -type f -exec chmod 644 "{}" +
167 chmod +x $tmpdir/Ventoy2Disk.sh
168 chmod +x $tmpdir/VentoyWeb.sh
169 chmod +x $tmpdir/VentoyPlugson.sh
170 chmod +x $tmpdir/VentoyGUI*
171
172 cp $OPT $LANG_DIR/languages.json $tmpdir/tool/
173
174
175 chmod +x $tmpdir/CreatePersistentImg.sh
176 chmod +x $tmpdir/ExtendPersistentImg.sh
177
178 tar -czvf ventoy-${curver}-linux.tar.gz $tmpdir
179
180
181
182 rm -f ventoy-${curver}-windows.zip
183
184 cp $OPT Ventoy2Disk.exe $tmpdir/
185 cp $OPT VentoyPlugson.exe $tmpdir/
186 cp $OPT FOR_X64_ARM.txt $tmpdir/
187 mkdir -p $tmpdir/altexe
188 cp $OPT Ventoy2Disk_*.exe $tmpdir/altexe/
189
190
191
192 cp $OPT $tmpdir/tool/plugson.tar.xz $tmpdir/ventoy/
193 cp $OPT $LANG_DIR/languages.json $tmpdir/ventoy/
194 rm -rf $tmpdir/tool
195 rm -f $tmpdir/*.sh
196 rm -f $tmpdir/VentoyGUI.*
197 rm -rf $tmpdir/WebUI
198 rm -f $tmpdir/README
199
200
201 zip -r ventoy-${curver}-windows.zip $tmpdir/
202
203 rm -rf $tmpdir
204
205 echo "=============== run livecd.sh ==============="
206 cd ../LiveCDGUI
207 sh livecd.sh $1
208 cd $CurDir
209
210 mv ../LiveCDGUI/ventoy*.iso ./
211
212 if [ -e ventoy-${curver}-windows.zip ] && [ -e ventoy-${curver}-linux.tar.gz ]; then
213 echo -e "\n ============= SUCCESS =================\n"
214 else
215 echo -e "\n ============= FAILED =================\n"
216 exit 1
217 fi
218
219 rm -f log.txt
220 rm -f sha256.txt
221 sha256sum ventoy-${curver}-* > sha256.txt
222