]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/ventoy_pack.sh
Support for new MidnightBSD 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 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 ../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
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 cp $OPT VentoyWebDeepin.sh $tmpdir/
104 #cp $OPT Ventoy.desktop $tmpdir/
105 cp $OPT README $tmpdir/
106 cp $OPT plugin $tmpdir/
107 cp $OPT CreatePersistentImg.sh $tmpdir/
108 dos2unix -q $tmpdir/Ventoy2Disk.sh
109 dos2unix -q $tmpdir/VentoyWeb.sh
110 dos2unix -q $tmpdir/VentoyWebDeepin.sh
111 #dos2unix -q $tmpdir/Ventoy.desktop
112 dos2unix -q $tmpdir/CreatePersistentImg.sh
113
114 cp $OPT ../LinuxGUI/WebUI $tmpdir/
115 sed 's/.*SCRIPT_DEL_THIS \(.*\)/\1/g' -i $tmpdir/WebUI/index.html
116
117 #32MB disk img
118 dd status=none if=$LOOP of=$tmpdir/ventoy/ventoy.disk.img bs=512 count=$VENTOY_SECTOR_NUM skip=$part2_start_sector
119 xz --check=crc32 $tmpdir/ventoy/ventoy.disk.img
120
121 losetup -d $LOOP && rm -f img.bin
122
123 rm -f ventoy-${curver}-linux.tar.gz
124
125
126 CurDir=$PWD
127
128 for d in i386 x86_64 aarch64; do
129 cd $tmpdir/tool/$d
130 for file in $(ls); do
131 if [ "$file" != "xzcat" ]; then
132 xz --check=crc32 $file
133 fi
134 done
135 cd $CurDir
136 done
137
138 #chmod
139 find $tmpdir/ -type d -exec chmod 755 "{}" +
140 find $tmpdir/ -type f -exec chmod 644 "{}" +
141 chmod +x $tmpdir/Ventoy2Disk.sh
142 chmod +x $tmpdir/VentoyWeb.sh
143 chmod +x $tmpdir/VentoyWebDeepin.sh
144 #chmod +x $tmpdir/Ventoy.desktop
145 chmod +x $tmpdir/CreatePersistentImg.sh
146
147 tar -czvf ventoy-${curver}-linux.tar.gz $tmpdir
148
149
150
151 rm -f ventoy-${curver}-windows.zip
152 cp $OPT Ventoy2Disk*.exe $tmpdir/
153 cp $OPT $LANG_DIR/languages.ini $tmpdir/ventoy/
154 rm -rf $tmpdir/tool
155 rm -f $tmpdir/*.sh
156 rm -rf $tmpdir/WebUI
157 rm -f $tmpdir/README
158
159
160 zip -r ventoy-${curver}-windows.zip $tmpdir/
161
162 rm -rf $tmpdir
163
164 echo "=============== run livecd.sh ==============="
165 cd ../LiveCD
166 sh livecd.sh $1
167 cd $CurDir
168
169 mv ../LiveCD/ventoy*.iso ./
170
171 if [ -e ventoy-${curver}-windows.zip ] && [ -e ventoy-${curver}-linux.tar.gz ]; then
172 echo -e "\n ============= SUCCESS =================\n"
173 else
174 echo -e "\n ============= FAILED =================\n"
175 exit 1
176 fi
177
178 rm -f log.txt
179