Commit 5d0fe69b authored by longpanda's avatar longpanda
Browse files

1. change some directory structure for the build script

2. add build script and document
   see DOC/BuildVentoyFromSource.txt for detail
parent 96541797
========== About Source Code =============
Ventoy use grub-2.04, so I only put the added and modified source code here.
You can download grub-2.04 source code from this site:
https://ftp.gnu.org/gnu/grub/
Just merge the code here with the original code of grub-2.04
========== Build =============
./autogen.sh
./configure
make
#!/bin/bash
VT_GRUB_DIR=$PWD
rm -rf INSTALL
rm -rf SRC
rm -rf NBP
rm -rf PXE
mkdir SRC
mkdir NBP
mkdir PXE
tar -xvf grub-2.04.tar.xz -C ./SRC/
/bin/cp -a ./MOD_SRC/grub-2.04 ./SRC/
cd ./SRC/grub-2.04
# build for Legacy BIOS
./autogen.sh
./configure --prefix=$VT_GRUB_DIR/INSTALL/
make -j 16
sh install.sh
# build for UEFI
make distclean
./autogen.sh
./configure --with-platform=efi --prefix=$VT_GRUB_DIR/INSTALL/
make -j 16
sh install.sh uefi
cd ../../
#!/bin/bash
/opt/diet32/bin/diet gcc -Os -m32 vtoy_gen_uuid.c -o vtoy_gen_uuid
if [ -e vtoy_gen_uuid ]; then
echo -e '\n############### SUCCESS ###############\n'
rm -f ../INSTALL/tool/vtoy_gen_uuid
cp -a vtoy_gen_uuid ../INSTALL/tool/vtoy_gen_uuid
else
echo -e '\n############### FAILED ################\n'
exit 1
fi
/******************************************************************************
* vtoy_gen_uuid.c
*
* Copyright (c) 2020, longpanda <admin@ventoy.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
int main()
{
int i;
int fd;
unsigned char uuid[16];
fd = open("/dev/random", O_RDONLY);
if (fd < 0)
{
srand(time(NULL));
for (i = 0; i < 16; i++)
{
uuid[i] = (unsigned char)(rand());
}
}
else
{
read(fd, uuid, 16);
}
fwrite(uuid, 1, 16, stdout);
return 0;
}
...@@ -2,12 +2,6 @@ ...@@ -2,12 +2,6 @@
VENTOY_PATH=$PWD/../ VENTOY_PATH=$PWD/../
if [ -e check.sh ]; then
if ! sh check.sh; then
exit 1
fi
fi
rm -f ventoy.cpio rm -f ventoy.cpio
chmod -R 777 cpio chmod -R 777 cpio
...@@ -22,6 +16,13 @@ ln -s sbin/init linuxrc ...@@ -22,6 +16,13 @@ ln -s sbin/init linuxrc
cd ventoy cd ventoy
cp -a $VENTOY_PATH/DMSETUP/dmsetup tool/
cp -a $VENTOY_PATH/SQUASHFS/unsquashfs_* tool/
cp -a $VENTOY_PATH/FUSEISO/vtoy_fuse_iso_* tool/
cp -a $VENTOY_PATH/VtoyTool/vtoytool tool/
cp -a $VENTOY_PATH/VBLADE/vblade-master/vblade_* tool/
chmod -R 777 ./tool
find ./tool | cpio -o -H newc>tool.cpio find ./tool | cpio -o -H newc>tool.cpio
xz tool.cpio xz tool.cpio
......
#!/bin/sh
VTOY_PATH=$PWD/..
cd $VTOY_PATH/DOC
sh installdietlibc.sh
cd $VTOY_PATH/GRUB2
sh buildgrub.sh || exit 1
cd $VTOY_PATH/IPXE
sh buildipxe.sh || exit 1
cd $VTOY_PATH/EDK2
sh buildedk.sh || exit 1
cd $VTOY_PATH/VtoyTool
sh build.sh || exit 1
cd $VTOY_PATH/vtoyfat/fat_io_lib
sh buildlib.sh
cd $VTOY_PATH/vtoyfat
sh build.sh || exit 1
cd $VTOY_PATH/ExFAT
sh buidlibfuse.sh || exit 1
sh buidexfat.sh || exit 1
/bin/cp -a EXFAT/shared/mkexfatfs $VTOY_PATH/INSTALL/tool/mkexfatfs_64
/bin/cp -a EXFAT/shared/mount.exfat-fuse $VTOY_PATH/INSTALL/tool/mount.exfat-fuse_64
cd $VTOY_PATH/FUSEISO
sh build_libfuse.sh
sh build.sh
cd $VTOY_PATH/SQUASHFS/SRC
sh build_lz4.sh
sh build_lzma.sh
sh build_lzo.sh
sh build_zstd.sh
cd $VTOY_PATH/SQUASHFS/squashfs-tools-4.4/squashfs-tools
sh build.sh
cd $VTOY_PATH/VBLADE/vblade-master
sh build.sh
cd $VTOY_PATH/Ventoy2Disk/Ventoy2Disk/xz-embedded-20130513/userspace
make -f ventoy_makefile
strip --strip-all xzminidec
rm -f $VTOY_PATH/IMG/cpio/ventoy/tool/xzminidec
cp -a xzminidec $VTOY_PATH/IMG/cpio/ventoy/tool/xzminidec
make clean; rm -f *.o
cd $VTOY_PATH/INSTALL
sh ventoy_pack.sh || exit 1
echo -e '\n============== SUCCESS ==================\n'
...@@ -38,7 +38,7 @@ function ventoy_power { ...@@ -38,7 +38,7 @@ function ventoy_power {
function get_os_type { function get_os_type {
set vtoy_os=Linux set vtoy_os=Linux
for file in "efi/microsoft" "sources/boot.wim" "boot/bcd" "bootmgr.efi" "boot/etfsboot.com"; do for file in "efi/microsoft" "sources/boot.wim" "boot/bcd" "bootmgr.efi" "boot/etfsboot.com" "BOOT/etfsboot.com"; do
if [ -e $1/$file ]; then if [ -e $1/$file ]; then
set vtoy_os=Windows set vtoy_os=Windows
break break
...@@ -453,8 +453,7 @@ function common_menuentry { ...@@ -453,8 +453,7 @@ function common_menuentry {
############################################################# #############################################################
############################################################# #############################################################
set VENTOY_VERSION="1.0.9Y" set VENTOY_VERSION="1.0.10"
# Default menu display mode, you can change it as you want. # Default menu display mode, you can change it as you want.
# 0: List mode # 0: List mode
...@@ -470,14 +469,6 @@ set VTOY_ISO_UEFI_DRV_STR="UEFI FS" ...@@ -470,14 +469,6 @@ set VTOY_ISO_UEFI_DRV_STR="UEFI FS"
set VTOY_F2_CMD="ventoy_power" set VTOY_F2_CMD="ventoy_power"
if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
set VTOY_F3_CMD="vt_dynamic_menu 1 1"
set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:TreeView"
else
set VTOY_F3_CMD="vt_dynamic_menu 1 0"
set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:ListView"
fi
if [ "$grub_platform" = "pc" ]; then if [ "$grub_platform" = "pc" ]; then
set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION BIOS www.ventoy.net" set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION BIOS www.ventoy.net"
else else
...@@ -501,10 +492,21 @@ fi ...@@ -501,10 +492,21 @@ fi
loadfont ascii loadfont ascii
#Load Plugin
if [ -f $iso_path/ventoy/ventoy.json ]; then if [ -f $iso_path/ventoy/ventoy.json ]; then
vt_load_plugin $iso_path vt_load_plugin $iso_path
fi fi
if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
set VTOY_F3_CMD="vt_dynamic_menu 1 1"
set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:TreeView"
else
set VTOY_F3_CMD="vt_dynamic_menu 1 0"
set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:ListView"
fi
if [ -n "$vtoy_gfxmode" ]; then if [ -n "$vtoy_gfxmode" ]; then
set gfxmode=$vtoy_gfxmode set gfxmode=$vtoy_gfxmode
else else
......
#!/bin/sh
. ./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
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
format_ventoy_disk $LOOP
$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/
rm -f $tmpmnt/grub/i386-pc/*
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/
cp -a Ventoy2Disk.sh $tmpdir/
#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
cd $CurDir
tar -czvf ventoy-${curver}-linux.tar.gz $tmpdir
rm -f ventoy-${curver}-windows.zip
cp -a Ventoy2Disk.exe $tmpdir/
cp -a $LANG_DIR/languages.ini $tmpdir/ventoy/
rm -rf $tmpdir/tool
rm -f $tmpdir/*.sh
zip -r ventoy-${curver}-windows.zip $tmpdir/
rm -rf $tmpdir
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
========== About Source Code =============
1. unpack ipxe_org_code/ipxe-3fe683e.tar.bz2
2. After decompressing, delete ipxe-3fe683e/src/drivers (whole directory)
3. Merge left source code with the ipxe-3fe683e directory here
========== Build =============
make bin/ipxe.iso
#!/bin/bash
rm -rf ipxe-3fe683e
tar -xvf ipxe_org_code/ipxe-3fe683e.tar.bz2 -C ./
rm -rf ./ipxe-3fe683e/src/bin
rm -rf ./ipxe-3fe683e/src/drivers
/bin/cp -a ipxe_mod_code/ipxe-3fe683e ./
cd ipxe-3fe683e/src
sh build.sh
cd ../../
...@@ -1374,6 +1374,25 @@ static int int13_load_eltorito ( unsigned int drive, struct segoff *address ) { ...@@ -1374,6 +1374,25 @@ static int int13_load_eltorito ( unsigned int drive, struct segoff *address ) {
return -EIO; return -EIO;
} }
if (catalog.boot.length > 4)
{
isolinux_boot_info *bootinfo = NULL;
bootinfo = (isolinux_boot_info *)(real_to_user(address->segment, address->offset));
if (0x7C6CEAFA == bootinfo->isolinux0 && 0x90900000 == bootinfo->isolinux1)
{
if (bootinfo->BootFileLocation == 0 && bootinfo->PvdLocation == 16 &&
(bootinfo->BootFileLen / 2048) < catalog.boot.length && bootinfo->BootFileChecksum > 0)
{
if (g_debug)
{
printf("isolinux file location is 0, now fix it to %u ...\n", catalog.boot.start);
ventoy_debug_pause();
}
bootinfo->BootFileLocation = catalog.boot.start;
}
}
}
return 0; return 0;
} }
......
#!/bin/bash
build_bios() {
rm -f bin/ipxe.iso
make -e -k -j 8 bin/ipxe.iso BIOS_MODE=BIOS
if ! [ -e bin/ipxe.iso ]; then
echo "Failed"
exit 1
fi
mkdir -p ./mnt
mount bin/ipxe.iso ./mnt
rm -f ../../../INSTALL/ventoy/ipxe.krn
cp -a ./mnt/ipxe.krn ../../../INSTALL/ventoy/ipxe.krn
umount ./mnt > /dev/null 2>&1
umount ./mnt > /dev/null 2>&1
umount ./mnt > /dev/null 2>&1
rm -rf ./mnt
echo -e "\n===============SUCCESS===============\n"
}
build_bios
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment