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