]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/ventoy_pack.sh
Support escaped quotes (\") in ventoy.json. (#1062)
[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
12
13 . ./tool/ventoy_lib.sh
14
15 GRUB_DIR=../GRUB2/INSTALL
16 LANG_DIR=../LANGUAGES
17
18 if ! [ -d $GRUB_DIR ]; then
19 echo "$GRUB_DIR not exist"
20 exit 1
21 fi
22
23
24 cd ../IMG
25 sh mkcpio.sh
26 sh mkloopex.sh
27 cd -
28
29 cd ../Unix
30 sh pack_unix.sh
31 cd -
32
33 cd ../LinuxGUI
34 sh language.sh || exit 1
35 sh build.sh
36 cd -
37
38
39 LOOP=$(losetup -f)
40
41 rm -f img.bin
42 dd if=/dev/zero of=img.bin bs=1M count=256 status=none
43
44 losetup -P $LOOP img.bin
45
46 while ! grep -q 524288 /sys/block/${LOOP#/dev/}/size 2>/dev/null; do
47 echo "wait $LOOP ..."
48 sleep 1
49 done
50
51 format_ventoy_disk_mbr 0 $LOOP fdisk
52
53 $GRUB_DIR/sbin/grub-bios-setup --skip-fs-probe --directory="./grub/i386-pc" $LOOP
54
55 curver=$(get_ventoy_version_from_cfg ./grub/grub.cfg)
56
57 tmpmnt=./ventoy-${curver}-mnt
58 tmpdir=./ventoy-${curver}
59
60 rm -rf $tmpmnt
61 mkdir -p $tmpmnt
62
63 mount ${LOOP}p2 $tmpmnt
64
65 mkdir -p $tmpmnt/grub
66
67 # First copy grub.cfg file, to make it locate at front of the part2
68 cp $OPT ./grub/grub.cfg $tmpmnt/grub/
69
70 ls -1 ./grub/ | grep -v 'grub\.cfg' | while read line; do
71 cp $OPT ./grub/$line $tmpmnt/grub/
72 done
73
74 cp $OPT ./ventoy $tmpmnt/
75 cp $OPT ./EFI $tmpmnt/
76 cp $OPT ./tool/ENROLL_THIS_KEY_IN_MOKMANAGER.cer $tmpmnt/
77
78
79 mkdir -p $tmpmnt/tool
80 cp $OPT ./tool/i386/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_i386
81 cp $OPT ./tool/x86_64/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_x86_64
82 cp $OPT ./tool/aarch64/mount.exfat-fuse $tmpmnt/tool/mount.exfat-fuse_aarch64
83
84
85 rm -f $tmpmnt/grub/i386-pc/*.img
86
87
88 umount $tmpmnt && rm -rf $tmpmnt
89
90
91 rm -rf $tmpdir
92 mkdir -p $tmpdir/boot
93 mkdir -p $tmpdir/ventoy
94 echo $curver > $tmpdir/ventoy/version
95 dd if=$LOOP of=$tmpdir/boot/boot.img bs=1 count=512 status=none
96 dd if=$LOOP of=$tmpdir/boot/core.img bs=512 count=2047 skip=1 status=none
97 xz --check=crc32 $tmpdir/boot/core.img
98
99 cp $OPT ./tool $tmpdir/
100 rm -f $tmpdir/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
101 cp $OPT Ventoy2Disk.sh $tmpdir/
102 cp $OPT VentoyWeb.sh $tmpdir/
103
104 #cp $OPT Ventoy.desktop $tmpdir/
105 cp $OPT README $tmpdir/
106 cp $OPT plugin $tmpdir/
107 cp $OPT CreatePersistentImg.sh $tmpdir/
108 cp $OPT ExtendPersistentImg.sh $tmpdir/
109 dos2unix -q $tmpdir/Ventoy2Disk.sh
110 dos2unix -q $tmpdir/VentoyWeb.sh
111
112 #dos2unix -q $tmpdir/Ventoy.desktop
113 dos2unix -q $tmpdir/CreatePersistentImg.sh
114 dos2unix -q $tmpdir/ExtendPersistentImg.sh
115
116 cp $OPT ../LinuxGUI/WebUI $tmpdir/
117 sed 's/.*SCRIPT_DEL_THIS \(.*\)/\1/g' -i $tmpdir/WebUI/index.html
118
119 #32MB disk img
120 dd status=none if=$LOOP of=$tmpdir/ventoy/ventoy.disk.img bs=512 count=$VENTOY_SECTOR_NUM skip=$part2_start_sector
121 xz --check=crc32 $tmpdir/ventoy/ventoy.disk.img
122
123 losetup -d $LOOP && rm -f img.bin
124
125 rm -f ventoy-${curver}-linux.tar.gz
126
127
128 CurDir=$PWD
129
130 for d in i386 x86_64 aarch64; do
131 cd $tmpdir/tool/$d
132 for file in $(ls); do
133 if [ "$file" != "xzcat" ]; then
134 xz --check=crc32 $file
135 fi
136 done
137 cd $CurDir
138 done
139
140 #chmod
141 find $tmpdir/ -type d -exec chmod 755 "{}" +
142 find $tmpdir/ -type f -exec chmod 644 "{}" +
143 chmod +x $tmpdir/Ventoy2Disk.sh
144 chmod +x $tmpdir/VentoyWeb.sh
145
146 #chmod +x $tmpdir/Ventoy.desktop
147 chmod +x $tmpdir/CreatePersistentImg.sh
148 chmod +x $tmpdir/ExtendPersistentImg.sh
149
150 tar -czvf ventoy-${curver}-linux.tar.gz $tmpdir
151
152
153
154 rm -f ventoy-${curver}-windows.zip
155 cp $OPT Ventoy2Disk*.exe $tmpdir/
156 cp $OPT $LANG_DIR/languages.json $tmpdir/ventoy/
157 rm -rf $tmpdir/tool
158 rm -f $tmpdir/*.sh
159 rm -rf $tmpdir/WebUI
160 rm -f $tmpdir/README
161
162
163 zip -r ventoy-${curver}-windows.zip $tmpdir/
164
165 rm -rf $tmpdir
166
167 echo "=============== run livecd.sh ==============="
168 cd ../LiveCD
169 sh livecd.sh $1
170 cd $CurDir
171
172 mv ../LiveCD/ventoy*.iso ./
173
174 if [ -e ventoy-${curver}-windows.zip ] && [ -e ventoy-${curver}-linux.tar.gz ]; then
175 echo -e "\n ============= SUCCESS =================\n"
176 else
177 echo -e "\n ============= FAILED =================\n"
178 exit 1
179 fi
180
181 rm -f log.txt
182