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