]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/ventoy_pack.sh
Update languages.json (Turkish) (#1077)
[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 # to save space
84 cp $OPT ./tool/i386/vtoygpt $tmpmnt/tool/mount.exfat-fuse_i386
85 cp $OPT ./tool/x86_64/vtoygpt $tmpmnt/tool/mount.exfat-fuse_x86_64
86 cp $OPT ./tool/aarch64/vtoygpt $tmpmnt/tool/mount.exfat-fuse_aarch64
87
88
89 rm -f $tmpmnt/grub/i386-pc/*.img
90
91
92 umount $tmpmnt && rm -rf $tmpmnt
93
94
95 rm -rf $tmpdir
96 mkdir -p $tmpdir/boot
97 mkdir -p $tmpdir/ventoy
98 echo $curver > $tmpdir/ventoy/version
99 dd if=$LOOP of=$tmpdir/boot/boot.img bs=1 count=512 status=none
100 dd if=$LOOP of=$tmpdir/boot/core.img bs=512 count=2047 skip=1 status=none
101 xz --check=crc32 $tmpdir/boot/core.img
102
103 cp $OPT ./tool $tmpdir/
104 rm -f $tmpdir/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
105 cp $OPT Ventoy2Disk.sh $tmpdir/
106 cp $OPT VentoyWeb.sh $tmpdir/
107
108 #cp $OPT Ventoy.desktop $tmpdir/
109 cp $OPT README $tmpdir/
110 cp $OPT plugin $tmpdir/
111 cp $OPT CreatePersistentImg.sh $tmpdir/
112 cp $OPT ExtendPersistentImg.sh $tmpdir/
113 dos2unix -q $tmpdir/Ventoy2Disk.sh
114 dos2unix -q $tmpdir/VentoyWeb.sh
115
116 #dos2unix -q $tmpdir/Ventoy.desktop
117 dos2unix -q $tmpdir/CreatePersistentImg.sh
118 dos2unix -q $tmpdir/ExtendPersistentImg.sh
119
120 cp $OPT ../LinuxGUI/WebUI $tmpdir/
121 sed 's/.*SCRIPT_DEL_THIS \(.*\)/\1/g' -i $tmpdir/WebUI/index.html
122
123 #32MB disk img
124 dd status=none if=$LOOP of=$tmpdir/ventoy/ventoy.disk.img bs=512 count=$VENTOY_SECTOR_NUM skip=$part2_start_sector
125 xz --check=crc32 $tmpdir/ventoy/ventoy.disk.img
126
127 losetup -d $LOOP && rm -f img.bin
128
129 rm -f ventoy-${curver}-linux.tar.gz
130
131
132 CurDir=$PWD
133
134 for d in i386 x86_64 aarch64; do
135 cd $tmpdir/tool/$d
136 for file in $(ls); do
137 if [ "$file" != "xzcat" ]; then
138 xz --check=crc32 $file
139 fi
140 done
141 cd $CurDir
142 done
143
144 #chmod
145 find $tmpdir/ -type d -exec chmod 755 "{}" +
146 find $tmpdir/ -type f -exec chmod 644 "{}" +
147 chmod +x $tmpdir/Ventoy2Disk.sh
148 chmod +x $tmpdir/VentoyWeb.sh
149
150 #chmod +x $tmpdir/Ventoy.desktop
151 chmod +x $tmpdir/CreatePersistentImg.sh
152 chmod +x $tmpdir/ExtendPersistentImg.sh
153
154 tar -czvf ventoy-${curver}-linux.tar.gz $tmpdir
155
156
157
158 rm -f ventoy-${curver}-windows.zip
159 cp $OPT Ventoy2Disk*.exe $tmpdir/
160 cp $OPT $LANG_DIR/languages.json $tmpdir/ventoy/
161 rm -rf $tmpdir/tool
162 rm -f $tmpdir/*.sh
163 rm -rf $tmpdir/WebUI
164 rm -f $tmpdir/README
165
166
167 zip -r ventoy-${curver}-windows.zip $tmpdir/
168
169 rm -rf $tmpdir
170
171 echo "=============== run livecd.sh ==============="
172 cd ../LiveCD
173 sh livecd.sh $1
174 cd $CurDir
175
176 mv ../LiveCD/ventoy*.iso ./
177
178 if [ -e ventoy-${curver}-windows.zip ] && [ -e ventoy-${curver}-linux.tar.gz ]; then
179 echo -e "\n ============= SUCCESS =================\n"
180 else
181 echo -e "\n ============= FAILED =================\n"
182 exit 1
183 fi
184
185 rm -f log.txt
186