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