ventoy_pack.sh 3.83 KB
Newer Older
1
2
#!/bin/sh

longpanda's avatar
longpanda committed
3
if [ "$1" = "CI" ]; then
longpanda's avatar
longpanda committed
4
    OPT='-dR'
longpanda's avatar
longpanda committed
5
6
7
8
else
    OPT='-a'
fi

longpanda's avatar
longpanda committed
9
dos2unix -q ./tool/ventoy_lib.sh
longpanda's avatar
longpanda committed
10
dos2unix -q ./tool/VentoyWorker.sh
longpanda's avatar
longpanda committed
11
12
dos2unix -q ./tool/WebDeepin.sh
dos2unix -q ./tool/WebUos.sh
longpanda's avatar
longpanda committed
13

14
15
16
17
18
19
20
21
22
23
24
25
26
. ./tool/ventoy_lib.sh

GRUB_DIR=../GRUB2/INSTALL
LANG_DIR=../LANGUAGES

if ! [ -d $GRUB_DIR ]; then
    echo "$GRUB_DIR not exist"
    exit 1
fi


cd ../IMG
sh mkcpio.sh
longpanda's avatar
longpanda committed
27
sh mkloopex.sh
28
29
cd -

30
31
32
33
34
cd ../LinuxGUI
sh language.sh || exit 1
sh build.sh
cd -

35
36
37
38
39
40
41
42
43
44
45
46
47

LOOP=$(losetup -f)

rm -f img.bin
dd if=/dev/zero of=img.bin bs=1M count=256 status=none

losetup -P $LOOP img.bin 

while ! grep -q 524288 /sys/block/${LOOP#/dev/}/size 2>/dev/null; do
    echo "wait $LOOP ..."
    sleep 1
done

longpanda's avatar
longpanda committed
48
format_ventoy_disk_mbr 0 $LOOP fdisk
49

50
$GRUB_DIR/sbin/grub-bios-setup  --skip-fs-probe  --directory="./grub/i386-pc"  $LOOP
51
52
53
54
55
56
57
58
59
60
61
62
63
64

curver=$(get_ventoy_version_from_cfg ./grub/grub.cfg)

tmpmnt=./ventoy-${curver}-mnt
tmpdir=./ventoy-${curver}

rm -rf $tmpmnt
mkdir -p $tmpmnt

mount ${LOOP}p2  $tmpmnt 

mkdir -p $tmpmnt/grub

# First copy grub.cfg file, to make it locate at front of the part2
longpanda's avatar
longpanda committed
65
cp $OPT ./grub/grub.cfg     $tmpmnt/grub/
66
67

ls -1 ./grub/ | grep -v 'grub\.cfg' | while read line; do
longpanda's avatar
longpanda committed
68
    cp $OPT ./grub/$line $tmpmnt/grub/
69
70
done

longpanda's avatar
longpanda committed
71
72
73
cp $OPT ./ventoy   $tmpmnt/
cp $OPT ./EFI   $tmpmnt/
cp $OPT ./tool/ENROLL_THIS_KEY_IN_MOKMANAGER.cer $tmpmnt/
74
75
76


mkdir -p $tmpmnt/tool
longpanda's avatar
longpanda committed
77
78
79
cp $OPT ./tool/i386/mount.exfat-fuse     $tmpmnt/tool/mount.exfat-fuse_i386
cp $OPT ./tool/x86_64/mount.exfat-fuse   $tmpmnt/tool/mount.exfat-fuse_x86_64
cp $OPT ./tool/aarch64/mount.exfat-fuse  $tmpmnt/tool/mount.exfat-fuse_aarch64
80

longpanda's avatar
longpanda committed
81
rm -f $tmpmnt/grub/i386-pc/*.img
82
83
84
85
86
87
88
89
90
91
92
93
94


umount $tmpmnt && rm -rf $tmpmnt


rm -rf $tmpdir
mkdir -p $tmpdir/boot
mkdir -p $tmpdir/ventoy
echo $curver > $tmpdir/ventoy/version
dd if=$LOOP of=$tmpdir/boot/boot.img bs=1 count=512  status=none
dd if=$LOOP of=$tmpdir/boot/core.img bs=512 count=2047 skip=1 status=none
xz --check=crc32 $tmpdir/boot/core.img

longpanda's avatar
longpanda committed
95
cp $OPT ./tool $tmpdir/
longpanda's avatar
longpanda committed
96
rm -f $tmpdir/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
longpanda's avatar
longpanda committed
97
cp $OPT Ventoy2Disk.sh $tmpdir/
98
cp $OPT VentoyWeb.sh $tmpdir/
longpanda's avatar
longpanda committed
99
100
cp $OPT VentoyWebDeepin.sh $tmpdir/
#cp $OPT Ventoy.desktop $tmpdir/
longpanda's avatar
longpanda committed
101
102
103
cp $OPT README $tmpdir/
cp $OPT plugin $tmpdir/
cp $OPT CreatePersistentImg.sh $tmpdir/
longpanda's avatar
longpanda committed
104
dos2unix -q $tmpdir/Ventoy2Disk.sh
105
dos2unix -q $tmpdir/VentoyWeb.sh
longpanda's avatar
longpanda committed
106
107
dos2unix -q $tmpdir/VentoyWebDeepin.sh
#dos2unix -q $tmpdir/Ventoy.desktop
longpanda's avatar
longpanda committed
108
dos2unix -q $tmpdir/CreatePersistentImg.sh
109

110
111
112
cp $OPT ../LinuxGUI/WebUI $tmpdir/
sed 's/.*SCRIPT_DEL_THIS \(.*\)/\1/g' -i $tmpdir/WebUI/index.html

113
114
115
116
117
118
119
120
121
122
123
#32MB disk img
dd status=none if=$LOOP of=$tmpdir/ventoy/ventoy.disk.img bs=512 count=$VENTOY_SECTOR_NUM skip=$part2_start_sector
xz --check=crc32 $tmpdir/ventoy/ventoy.disk.img

losetup -d $LOOP && rm -f img.bin

rm -f ventoy-${curver}-linux.tar.gz


CurDir=$PWD

longpanda's avatar
longpanda committed
124
125
126
127
128
129
130
131
for d in i386 x86_64 aarch64; do
    cd $tmpdir/tool/$d
    for file in $(ls); do
        if [ "$file" != "xzcat" ]; then
            xz --check=crc32 $file
        fi
    done
    cd $CurDir
132
133
done

longpanda's avatar
longpanda committed
134
135
136
137
#chmod 
find $tmpdir/ -type d -exec chmod 755 "{}" +
find $tmpdir/ -type f -exec chmod 644 "{}" +
chmod +x $tmpdir/Ventoy2Disk.sh
138
chmod +x $tmpdir/VentoyWeb.sh
longpanda's avatar
longpanda committed
139
140
chmod +x $tmpdir/VentoyWebDeepin.sh
#chmod +x $tmpdir/Ventoy.desktop
longpanda's avatar
longpanda committed
141
142
chmod +x $tmpdir/CreatePersistentImg.sh

143
144
tar -czvf ventoy-${curver}-linux.tar.gz $tmpdir

longpanda's avatar
longpanda committed
145
146


147
rm -f ventoy-${curver}-windows.zip
longpanda's avatar
longpanda committed
148
149
cp $OPT Ventoy2Disk*.exe $tmpdir/
cp $OPT $LANG_DIR/languages.ini $tmpdir/ventoy/
150
151
rm -rf $tmpdir/tool
rm -f $tmpdir/*.sh
152
rm -rf $tmpdir/WebUI
longpanda's avatar
longpanda committed
153
rm -f $tmpdir/README
154
155
156
157
158
159


zip -r ventoy-${curver}-windows.zip $tmpdir/

rm -rf $tmpdir

longpanda's avatar
longpanda committed
160
echo "=============== run livecd.sh ==============="
longpanda's avatar
longpanda committed
161
cd ../LiveCD
longpanda's avatar
longpanda committed
162
sh livecd.sh $1
longpanda's avatar
update  
longpanda committed
163
164
165
166
cd $CurDir

mv ../LiveCD/ventoy*.iso ./

167
168
169
170
171
172
173
if [ -e ventoy-${curver}-windows.zip ] && [ -e ventoy-${curver}-linux.tar.gz ]; then
    echo -e "\n ============= SUCCESS =================\n"
else
    echo -e "\n ============= FAILED =================\n"
    exit 1
fi

longpanda's avatar
longpanda committed
174
rm -f log.txt
175