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