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