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