ventoy_pack.sh 6.59 KB
Newer Older
1
2
#!/bin/sh

longpanda's avatar
longpanda committed
3
if [ "$1" = "CI" ]; then
longpanda's avatar
longpanda committed
4
    OPT='-dR'
longpanda's avatar
longpanda committed
5
6
7
8
else
    OPT='-a'
fi

longpanda's avatar
longpanda committed
9
dos2unix -q ./tool/ventoy_lib.sh
longpanda's avatar
longpanda committed
10
dos2unix -q ./tool/VentoyWorker.sh
11
dos2unix -q ./tool/VentoyGTK.glade
longpanda's avatar
longpanda committed
12
dos2unix -q ./tool/distro_gui_type.json
longpanda's avatar
longpanda committed
13

14
15
16
17
18
19
20
21
22
23
24
25
26
. ./tool/ventoy_lib.sh

GRUB_DIR=../GRUB2/INSTALL
LANG_DIR=../LANGUAGES

if ! [ -d $GRUB_DIR ]; then
    echo "$GRUB_DIR not exist"
    exit 1
fi


cd ../IMG
sh mkcpio.sh
longpanda's avatar
longpanda committed
27
sh mkloopex.sh
28
29
cd -

30
31
32
33
cd ../Unix
sh pack_unix.sh
cd -

34
35
36
37
38
cd ../LinuxGUI
sh language.sh || exit 1
sh build.sh
cd -

39
40
41
42
43
cd ../Plugson
sh build.sh
sh pack.sh
cd -

longpanda's avatar
longpanda committed
44
45
46
47
48
cd ../Vlnk
sh build.sh
sh pack.sh
cd -

49
50
51
52
53
54
55
56
57
58
59
60
61

LOOP=$(losetup -f)

rm -f img.bin
dd if=/dev/zero of=img.bin bs=1M count=256 status=none

losetup -P $LOOP img.bin 

while ! grep -q 524288 /sys/block/${LOOP#/dev/}/size 2>/dev/null; do
    echo "wait $LOOP ..."
    sleep 1
done

longpanda's avatar
longpanda committed
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
67
68
69
70
71
72
73
74
75
76
77
78

curver=$(get_ventoy_version_from_cfg ./grub/grub.cfg)

tmpmnt=./ventoy-${curver}-mnt
tmpdir=./ventoy-${curver}

rm -rf $tmpmnt
mkdir -p $tmpmnt

mount ${LOOP}p2  $tmpmnt 

mkdir -p $tmpmnt/grub

# First copy grub.cfg file, to make it locate at front of the part2
longpanda's avatar
longpanda committed
79
cp $OPT ./grub/grub.cfg     $tmpmnt/grub/
80
81

ls -1 ./grub/ | grep -v 'grub\.cfg' | while read line; do
longpanda's avatar
longpanda committed
82
    cp $OPT ./grub/$line $tmpmnt/grub/
83
84
done

longpanda's avatar
longpanda committed
85
86
87
88
89
90
#tar help txt
cd $tmpmnt/grub/
tar czf help.tar.gz ./help/
rm -rf ./help
cd ../../

91
92
93
#tar menu txt & update menulang.cfg
cd $tmpmnt/grub/

94
vtlangtitle=$(grep VTLANG_LANGUAGE_NAME menu/zh_CN.json | awk -F\" '{print $4}')
longpanda's avatar
longpanda committed
95
echo "menuentry \"zh_CN  -  $vtlangtitle\" --class=menu_lang_item --class=debug_menu_lang --class=F5tool {" >> menulang.cfg
longpanda's avatar
longpanda committed
96
97
98
99
echo "    vt_load_menu_lang zh_CN"  >> menulang.cfg
echo "}"  >> menulang.cfg

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}')
longpanda's avatar
longpanda committed
102
    echo "menuentry \"$vtlangname  -  $vtlangtitle\" --class=menu_lang_item --class=debug_menu_lang --class=F5tool {" >> menulang.cfg
103
104
105
    echo "    vt_load_menu_lang $vtlangname"  >> menulang.cfg
    echo "}"  >> menulang.cfg
done
106
echo "menuentry \"\$VTLANG_RETURN_PREVIOUS\" --class=vtoyret VTOY_RET {" >> menulang.cfg
107
echo "        echo \"Return ...\"" >> menulang.cfg
108
109
110
111
112
113
114
echo "}" >> menulang.cfg

tar czf menu.tar.gz ./menu/
rm -rf ./menu
cd ../../


longpanda's avatar
longpanda committed
115

longpanda's avatar
longpanda committed
116
117
118
cp $OPT ./ventoy   $tmpmnt/
cp $OPT ./EFI   $tmpmnt/
cp $OPT ./tool/ENROLL_THIS_KEY_IN_MOKMANAGER.cer $tmpmnt/
119
120
121


mkdir -p $tmpmnt/tool
longpanda's avatar
longpanda committed
122
123
124
125
# cp $OPT ./tool/i386/mount.exfat-fuse     $tmpmnt/tool/mount.exfat-fuse_i386
# cp $OPT ./tool/x86_64/mount.exfat-fuse   $tmpmnt/tool/mount.exfat-fuse_x86_64
# cp $OPT ./tool/aarch64/mount.exfat-fuse  $tmpmnt/tool/mount.exfat-fuse_aarch64
# to save space
longpanda's avatar
longpanda committed
126
127
128
dd status=none bs=1024 count=16  if=./tool/i386/vtoycli    of=$tmpmnt/tool/mount.exfat-fuse_i386
dd status=none bs=1024 count=16  if=./tool/x86_64/vtoycli  of=$tmpmnt/tool/mount.exfat-fuse_x86_64
dd status=none bs=1024 count=16  if=./tool/aarch64/vtoycli of=$tmpmnt/tool/mount.exfat-fuse_aarch64
129

longpanda's avatar
longpanda committed
130

longpanda's avatar
longpanda committed
131
rm -f $tmpmnt/grub/i386-pc/*.img
132
133
134
135
136
137
138
139
140
141
142
143
144


umount $tmpmnt && rm -rf $tmpmnt


rm -rf $tmpdir
mkdir -p $tmpdir/boot
mkdir -p $tmpdir/ventoy
echo $curver > $tmpdir/ventoy/version
dd if=$LOOP of=$tmpdir/boot/boot.img bs=1 count=512  status=none
dd if=$LOOP of=$tmpdir/boot/core.img bs=512 count=2047 skip=1 status=none
xz --check=crc32 $tmpdir/boot/core.img

longpanda's avatar
longpanda committed
145
cp $OPT ./tool $tmpdir/
longpanda's avatar
longpanda committed
146
rm -f $tmpdir/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
longpanda's avatar
longpanda committed
147
cp $OPT Ventoy2Disk.sh $tmpdir/
148
cp $OPT VentoyWeb.sh $tmpdir/
149
cp $OPT VentoyPlugson.sh $tmpdir/
longpanda's avatar
longpanda committed
150
cp $OPT VentoyVlnk.sh $tmpdir/
151
cp $OPT VentoyGUI* $tmpdir/
longpanda's avatar
longpanda committed
152

longpanda's avatar
longpanda committed
153

longpanda's avatar
longpanda committed
154
155
156
cp $OPT README $tmpdir/
cp $OPT plugin $tmpdir/
cp $OPT CreatePersistentImg.sh $tmpdir/
longpanda's avatar
longpanda committed
157
cp $OPT ExtendPersistentImg.sh $tmpdir/
longpanda's avatar
longpanda committed
158
dos2unix -q $tmpdir/Ventoy2Disk.sh
159
dos2unix -q $tmpdir/VentoyWeb.sh
160
dos2unix -q $tmpdir/VentoyPlugson.sh
longpanda's avatar
longpanda committed
161
dos2unix -q $tmpdir/VentoyVlnk.sh
longpanda's avatar
longpanda committed
162

longpanda's avatar
longpanda committed
163

longpanda's avatar
longpanda committed
164
dos2unix -q $tmpdir/CreatePersistentImg.sh
longpanda's avatar
longpanda committed
165
dos2unix -q $tmpdir/ExtendPersistentImg.sh
166

167
168
169
cp $OPT ../LinuxGUI/WebUI $tmpdir/
sed 's/.*SCRIPT_DEL_THIS \(.*\)/\1/g' -i $tmpdir/WebUI/index.html

170
171
#32MB disk img
dd status=none if=$LOOP of=$tmpdir/ventoy/ventoy.disk.img bs=512 count=$VENTOY_SECTOR_NUM skip=$part2_start_sector
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188


#4k image
# echo "make 4K img ..."
# dd status=none if=/dev/zero of=$tmpdir/ventoy/ventoy_4k.disk.img bs=1M count=32
# mkfs.vfat -F 16 -n VTOYEFI -s 1 -S 4096 $tmpdir/ventoy/ventoy_4k.disk.img
# vDIR1=$(mktemp -d)
# vDIR2=$(mktemp -d)
# mount $tmpdir/ventoy/ventoy.disk.img $vDIR1
# mount $tmpdir/ventoy/ventoy_4k.disk.img $vDIR2
# cp -a $vDIR1/* $vDIR2/
# umount $vDIR1
# umount $vDIR2
# rm -rf $vDIR1 $vDIR2

# xz --check=crc32 $tmpdir/ventoy/ventoy_4k.disk.img

189
190
xz --check=crc32 $tmpdir/ventoy/ventoy.disk.img

191
192


193
194
195
196
197
198
199
losetup -d $LOOP && rm -f img.bin

rm -f ventoy-${curver}-linux.tar.gz


CurDir=$PWD

200
for d in i386 x86_64 aarch64 mips64el; do
longpanda's avatar
longpanda committed
201
202
203
    cd $tmpdir/tool/$d
    for file in $(ls); do
        if [ "$file" != "xzcat" ]; then
204
205
206
207
208
            if echo "$file" | grep -q '^Ventoy2Disk'; then
                chmod +x $file
            else
                xz --check=crc32 $file
            fi
longpanda's avatar
longpanda committed
209
210
211
        fi
    done
    cd $CurDir
212
213
done

longpanda's avatar
longpanda committed
214
215
216
217
#chmod 
find $tmpdir/ -type d -exec chmod 755 "{}" +
find $tmpdir/ -type f -exec chmod 644 "{}" +
chmod +x $tmpdir/Ventoy2Disk.sh
218
chmod +x $tmpdir/VentoyWeb.sh
219
chmod +x $tmpdir/VentoyPlugson.sh
longpanda's avatar
longpanda committed
220
chmod +x $tmpdir/VentoyVlnk.sh
221
chmod +x $tmpdir/VentoyGUI*
222
223
224
225
226
227
228
chmod +x $tmpdir/tool/*.sh

for d in i386 x86_64 aarch64 mips64el; do
    chmod +x $tmpdir/tool/$d/xzcat
    chmod +x $tmpdir/tool/$d/Ventoy2Disk.*
done

229
230

cp $OPT $LANG_DIR/languages.json $tmpdir/tool/
longpanda's avatar
longpanda committed
231

longpanda's avatar
longpanda committed
232

longpanda's avatar
longpanda committed
233
chmod +x $tmpdir/CreatePersistentImg.sh
234
chmod +x $tmpdir/ExtendPersistentImg.sh
longpanda's avatar
longpanda committed
235

236
237
tar -czvf ventoy-${curver}-linux.tar.gz $tmpdir

longpanda's avatar
longpanda committed
238
239


240
rm -f ventoy-${curver}-windows.zip
longpanda's avatar
longpanda committed
241
242

cp $OPT Ventoy2Disk.exe $tmpdir/
243
cp $OPT VentoyPlugson.exe $tmpdir/
longpanda's avatar
longpanda committed
244
cp $OPT VentoyVlnk.exe $tmpdir/
longpanda's avatar
longpanda committed
245
246
247
cp $OPT FOR_X64_ARM.txt $tmpdir/
mkdir -p $tmpdir/altexe
cp $OPT Ventoy2Disk_*.exe $tmpdir/altexe/
248
cp $OPT VentoyPlugson_*.exe $tmpdir/altexe/
longpanda's avatar
longpanda committed
249
250
251



longpanda's avatar
longpanda committed
252
cp $OPT $tmpdir/tool/plugson.tar.xz $tmpdir/ventoy/
253
cp $OPT $LANG_DIR/languages.json $tmpdir/ventoy/
254
255
rm -rf $tmpdir/tool
rm -f $tmpdir/*.sh
longpanda's avatar
longpanda committed
256
rm -f $tmpdir/VentoyGUI.*
257
rm -rf $tmpdir/WebUI
longpanda's avatar
longpanda committed
258
rm -f $tmpdir/README
259
260
261
262
263
264


zip -r ventoy-${curver}-windows.zip $tmpdir/

rm -rf $tmpdir

longpanda's avatar
longpanda committed
265
echo "=============== run livecd.sh ==============="
longpanda's avatar
longpanda committed
266
cd ../LiveCDGUI
longpanda's avatar
longpanda committed
267
sh livecd.sh $1
longpanda's avatar
update  
longpanda committed
268
269
cd $CurDir

longpanda's avatar
longpanda committed
270
mv ../LiveCDGUI/ventoy*.iso ./
longpanda's avatar
update  
longpanda committed
271

272
273
274
275
276
277
278
if [ -e ventoy-${curver}-windows.zip ] && [ -e ventoy-${curver}-linux.tar.gz ]; then
    echo -e "\n ============= SUCCESS =================\n"
else
    echo -e "\n ============= FAILED =================\n"
    exit 1
fi

longpanda's avatar
longpanda committed
279
rm -f log.txt
longpanda's avatar
longpanda committed
280
281
rm -f sha256.txt
sha256sum ventoy-${curver}-* > sha256.txt
282