Ventoy/INSTALL/ventoy_pack.sh

264 lines
6.1 KiB
Bash
Raw Normal View History

#!/bin/sh
2021-01-29 09:54:04 +00:00
if [ "$1" = "CI" ]; then
2021-01-29 12:58:02 +00:00
OPT='-dR'
2021-01-29 09:54:04 +00:00
else
OPT='-a'
fi
2020-05-24 12:43:31 +00:00
dos2unix -q ./tool/ventoy_lib.sh
2020-05-30 12:13:04 +00:00
dos2unix -q ./tool/VentoyWorker.sh
dos2unix -q ./tool/VentoyGTK.glade
2021-09-13 08:41:51 +00:00
dos2unix -q ./tool/distro_gui_type.json
2020-05-24 12:43:31 +00:00
. ./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
2020-08-29 05:12:36 +00:00
sh mkloopex.sh
cd -
2021-04-21 09:00:40 +00:00
cd ../Unix
sh pack_unix.sh
cd -
cd ../LinuxGUI
sh language.sh || exit 1
sh build.sh
cd -
cd ../Plugson
sh build.sh
sh pack.sh
cd -
2022-02-13 09:00:39 +00:00
cd ../Vlnk
sh build.sh
sh pack.sh
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
2020-07-04 14:29:54 +00:00
format_ventoy_disk_mbr 0 $LOOP fdisk
$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
2021-01-29 09:54:04 +00:00
cp $OPT ./grub/grub.cfg $tmpmnt/grub/
ls -1 ./grub/ | grep -v 'grub\.cfg' | while read line; do
2021-01-29 09:54:04 +00:00
cp $OPT ./grub/$line $tmpmnt/grub/
done
2021-11-01 11:32:43 +00:00
#tar help txt
cd $tmpmnt/grub/
tar czf help.tar.gz ./help/
rm -rf ./help
cd ../../
#tar menu txt & update menulang.cfg
cd $tmpmnt/grub/
2022-12-04 05:15:18 +00:00
vtlangtitle=$(grep VTMENU_LANGUAGE_NAME menu/zh_CN.json | awk -F\" '{print $4}')
echo "menuentry \"zh_CN - $vtlangtitle\" --class=menu_lang_item --class=debug_menu_lang --class=F5tool {" >> menulang.cfg
2022-12-03 13:37:09 +00:00
echo " vt_load_menu_lang zh_CN" >> menulang.cfg
echo "}" >> menulang.cfg
ls -1 menu/ | grep -v 'zh_CN' | sort | while read vtlang; do
vtlangname=${vtlang%.*}
vtlangtitle=$(grep VTMENU_LANGUAGE_NAME menu/$vtlang | awk -F\" '{print $4}')
2022-12-03 13:37:09 +00:00
echo "menuentry \"$vtlangname - $vtlangtitle\" --class=menu_lang_item --class=debug_menu_lang --class=F5tool {" >> menulang.cfg
echo " vt_load_menu_lang $vtlangname" >> menulang.cfg
echo "}" >> menulang.cfg
done
echo "menuentry '@VTMENU_RETURN_PREVIOUS' --class=vtoyret VTOY_RET {" >> menulang.cfg
echo " echo 'Return ...'" >> menulang.cfg
echo "}" >> menulang.cfg
tar czf menu.tar.gz ./menu/
rm -rf ./menu
cd ../../
2021-11-01 11:32:43 +00:00
2021-01-29 09:54:04 +00:00
cp $OPT ./ventoy $tmpmnt/
cp $OPT ./EFI $tmpmnt/
cp $OPT ./tool/ENROLL_THIS_KEY_IN_MOKMANAGER.cer $tmpmnt/
mkdir -p $tmpmnt/tool
2021-08-18 15:00:11 +00:00
# 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
# to save space
2021-11-12 11:56:05 +00:00
dd status=none bs=1024 count=16 if=./tool/i386/vtoycli of=$tmpmnt/tool/mount.exfat-fuse_i386
dd status=none bs=1024 count=16 if=./tool/x86_64/vtoycli of=$tmpmnt/tool/mount.exfat-fuse_x86_64
dd status=none bs=1024 count=16 if=./tool/aarch64/vtoycli of=$tmpmnt/tool/mount.exfat-fuse_aarch64
2021-04-21 11:40:54 +00:00
2020-07-22 15:30:01 +00:00
rm -f $tmpmnt/grub/i386-pc/*.img
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
2021-01-29 09:54:04 +00:00
cp $OPT ./tool $tmpdir/
2020-07-18 14:06:59 +00:00
rm -f $tmpdir/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
2021-01-29 09:54:04 +00:00
cp $OPT Ventoy2Disk.sh $tmpdir/
cp $OPT VentoyWeb.sh $tmpdir/
cp $OPT VentoyPlugson.sh $tmpdir/
2022-02-13 09:00:39 +00:00
cp $OPT VentoyVlnk.sh $tmpdir/
cp $OPT VentoyGUI* $tmpdir/
2021-08-01 13:50:36 +00:00
2021-09-22 06:44:50 +00:00
2021-01-29 09:54:04 +00:00
cp $OPT README $tmpdir/
cp $OPT plugin $tmpdir/
cp $OPT CreatePersistentImg.sh $tmpdir/
2021-05-29 11:42:16 +00:00
cp $OPT ExtendPersistentImg.sh $tmpdir/
2020-05-24 12:43:31 +00:00
dos2unix -q $tmpdir/Ventoy2Disk.sh
dos2unix -q $tmpdir/VentoyWeb.sh
dos2unix -q $tmpdir/VentoyPlugson.sh
2022-02-13 09:00:39 +00:00
dos2unix -q $tmpdir/VentoyVlnk.sh
2021-08-01 13:50:36 +00:00
2021-09-22 06:44:50 +00:00
2020-05-30 12:13:04 +00:00
dos2unix -q $tmpdir/CreatePersistentImg.sh
2021-05-29 11:42:16 +00:00
dos2unix -q $tmpdir/ExtendPersistentImg.sh
cp $OPT ../LinuxGUI/WebUI $tmpdir/
sed 's/.*SCRIPT_DEL_THIS \(.*\)/\1/g' -i $tmpdir/WebUI/index.html
#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
for d in i386 x86_64 aarch64 mips64el; do
2020-12-11 23:56:52 +00:00
cd $tmpdir/tool/$d
for file in $(ls); do
if [ "$file" != "xzcat" ]; then
if echo "$file" | grep -q '^Ventoy2Disk'; then
chmod +x $file
else
xz --check=crc32 $file
fi
2020-12-11 23:56:52 +00:00
fi
done
cd $CurDir
done
2020-08-29 05:12:36 +00:00
#chmod
find $tmpdir/ -type d -exec chmod 755 "{}" +
find $tmpdir/ -type f -exec chmod 644 "{}" +
chmod +x $tmpdir/Ventoy2Disk.sh
chmod +x $tmpdir/VentoyWeb.sh
chmod +x $tmpdir/VentoyPlugson.sh
2022-02-13 09:00:39 +00:00
chmod +x $tmpdir/VentoyVlnk.sh
chmod +x $tmpdir/VentoyGUI*
chmod +x $tmpdir/tool/*.sh
for d in i386 x86_64 aarch64 mips64el; do
chmod +x $tmpdir/tool/$d/xzcat
chmod +x $tmpdir/tool/$d/Ventoy2Disk.*
done
cp $OPT $LANG_DIR/languages.json $tmpdir/tool/
2021-08-01 13:50:36 +00:00
2021-09-22 06:44:50 +00:00
2020-08-29 05:12:36 +00:00
chmod +x $tmpdir/CreatePersistentImg.sh
2021-07-15 17:03:01 +00:00
chmod +x $tmpdir/ExtendPersistentImg.sh
2020-08-29 05:12:36 +00:00
tar -czvf ventoy-${curver}-linux.tar.gz $tmpdir
2020-08-29 05:12:36 +00:00
rm -f ventoy-${curver}-windows.zip
2021-11-06 09:54:11 +00:00
cp $OPT Ventoy2Disk.exe $tmpdir/
cp $OPT VentoyPlugson.exe $tmpdir/
2022-02-13 09:00:39 +00:00
cp $OPT VentoyVlnk.exe $tmpdir/
2021-11-06 09:54:11 +00:00
cp $OPT FOR_X64_ARM.txt $tmpdir/
mkdir -p $tmpdir/altexe
cp $OPT Ventoy2Disk_*.exe $tmpdir/altexe/
cp $OPT VentoyPlugson_*.exe $tmpdir/altexe/
2021-11-06 09:54:11 +00:00
2021-12-02 02:55:37 +00:00
cp $OPT $tmpdir/tool/plugson.tar.xz $tmpdir/ventoy/
cp $OPT $LANG_DIR/languages.json $tmpdir/ventoy/
rm -rf $tmpdir/tool
rm -f $tmpdir/*.sh
2021-09-22 06:44:50 +00:00
rm -f $tmpdir/VentoyGUI.*
rm -rf $tmpdir/WebUI
2020-07-22 15:30:01 +00:00
rm -f $tmpdir/README
zip -r ventoy-${curver}-windows.zip $tmpdir/
rm -rf $tmpdir
2021-01-29 09:54:04 +00:00
echo "=============== run livecd.sh ==============="
2021-09-29 11:26:50 +00:00
cd ../LiveCDGUI
2021-01-29 12:58:02 +00:00
sh livecd.sh $1
2020-09-02 11:29:19 +00:00
cd $CurDir
2021-09-29 11:26:50 +00:00
mv ../LiveCDGUI/ventoy*.iso ./
2020-09-02 11:29:19 +00:00
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
2020-05-30 12:13:04 +00:00
rm -f log.txt
2022-02-04 09:05:14 +00:00
rm -f sha256.txt
sha256sum ventoy-${curver}-* > sha256.txt