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

longpanda's avatar
longpanda committed
3
dos2unix -q ./tool/ventoy_lib.sh
longpanda's avatar
longpanda committed
4
dos2unix -q ./tool/VentoyWorker.sh
longpanda's avatar
longpanda committed
5

6
7
8
9
10
11
12
13
14
15
16
17
18
. ./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
19
sh mkloopex.sh
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
cd -


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
35
format_ventoy_disk_mbr 0 $LOOP fdisk
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

$GRUB_DIR/sbin/grub-bios-setup  --skip-fs-probe  --directory="./grub/i386-pc"  $LOOP

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
cp -a ./grub/grub.cfg     $tmpmnt/grub/

ls -1 ./grub/ | grep -v 'grub\.cfg' | while read line; do
    cp -a ./grub/$line $tmpmnt/grub/
done

cp -a ./ventoy   $tmpmnt/
cp -a ./EFI   $tmpmnt/
cp -a ./tool/ENROLL_THIS_KEY_IN_MOKMANAGER.cer $tmpmnt/


mkdir -p $tmpmnt/tool
cp -a ./tool/mount*     $tmpmnt/tool/

longpanda's avatar
longpanda committed
66
rm -f $tmpmnt/grub/i386-pc/*.img
67
68
69
70
71
72
73
74
75
76
77
78
79
80


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

cp -a ./tool $tmpdir/
longpanda's avatar
longpanda committed
81
rm -f $tmpdir/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
82
cp -a Ventoy2Disk.sh $tmpdir/
longpanda's avatar
longpanda committed
83
cp -a README $tmpdir/
longpanda's avatar
longpanda committed
84
cp -a plugin $tmpdir/
longpanda's avatar
longpanda committed
85
cp -a CreatePersistentImg.sh $tmpdir/
longpanda's avatar
longpanda committed
86
dos2unix -q $tmpdir/Ventoy2Disk.sh
longpanda's avatar
longpanda committed
87
dos2unix -q $tmpdir/CreatePersistentImg.sh
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

#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
cd $tmpdir/tool

for file in $(ls); do
    if [ "$file" != "xzcat" ] && [ "$file" != "ventoy_lib.sh" ]; then
        xz --check=crc32 $file
    fi
done

longpanda's avatar
longpanda committed
107
#chmod 
108
cd $CurDir
longpanda's avatar
longpanda committed
109
110
111
112
113
find $tmpdir/ -type d -exec chmod 755 "{}" +
find $tmpdir/ -type f -exec chmod 644 "{}" +
chmod +x $tmpdir/Ventoy2Disk.sh
chmod +x $tmpdir/CreatePersistentImg.sh

114
115
tar -czvf ventoy-${curver}-linux.tar.gz $tmpdir

longpanda's avatar
longpanda committed
116
117


118
rm -f ventoy-${curver}-windows.zip
longpanda's avatar
update  
longpanda committed
119
cp -a Ventoy2Disk*.exe $tmpdir/
120
121
122
cp -a $LANG_DIR/languages.ini $tmpdir/ventoy/
rm -rf $tmpdir/tool
rm -f $tmpdir/*.sh
longpanda's avatar
longpanda committed
123
rm -f $tmpdir/README
124
125
126
127
128
129


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

rm -rf $tmpdir

longpanda's avatar
update  
longpanda committed
130
131
132
133
134
135
cd ../LiveCD
sh livecd.sh
cd $CurDir

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

136
137
138
139
140
141
142
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
143
rm -f log.txt
144