add support to freebsd

This commit is contained in:
longpanda
2020-07-31 23:08:17 +08:00
parent 036e9cc167
commit d80a008c04
24 changed files with 2662 additions and 15 deletions

Binary file not shown.

View File

@@ -39,12 +39,17 @@ if ! [ -f ./tool/ash ]; then
if ! [ -f ./tool/ash ]; then
echo 'Failed to decompress tools ...'
cd $OLDDIR
if [ -n "$OLDDIR" ]; then
cd $OLDDIR
fi
exit 1
fi
fi
./tool/ash ./tool/VentoyWorker.sh $*
cd $OLDDIR
if [ -n "$OLDDIR" ]; then
cd $OLDDIR
fi

View File

@@ -89,6 +89,14 @@ function get_os_type {
fi
done
if [ "$vtoy_os" = "Linux" ]; then
if vt_strstr "$vt_system_id" "FreeBSD"; then
set vtoy_os=Unix
elif [ -e (loop)/bin/freebsd-version ]; then
set vtoy_os=Unix
fi
fi
if [ -n "${vtdebug_flag}" ]; then
echo ISO is $vtoy_os
fi
@@ -211,6 +219,70 @@ function distro_specify_initrd_file_phase2 {
fi
}
function ventoy_freebsd_proc {
if regexp "^12_[0-9]" $vt_volume_id; then
set vt_freebsd_ver=12.x
elif regexp "^11_[0-9]" $vt_volume_id; then
set vt_freebsd_ver=11.x
elif regexp "^10_[0-9]" $vt_volume_id; then
set vt_freebsd_ver=10.x
elif [ -e (loop)/bin/freebsd-version ]; then
vt_unix_parse_freebsd_ver (loop)/bin/freebsd-version vt_userland_ver
if regexp "\"12\.[0-9]-" $vt_userland_ver; then
set vt_freebsd_ver=12.x
elif regexp "\"11\.[0-9]-" $vt_userland_ver; then
set vt_freebsd_ver=11.x
elif regexp "\"10\.[0-9]-" $vt_userland_ver; then
set vt_freebsd_ver=10.x
fi
else
set vt_freebsd_ver=12.x
fi
if file --is-i386-kfreebsd (loop)/boot/kernel/kernel; then
set vt_freebsd_bit=32
else
set vt_freebsd_bit=64
fi
if [ -n "${vtdebug_flag}" ]; then
echo "This is FreeBSD $vt_freebsd_ver ${vt_freebsd_bit}bit"
fi
for file in "geom_nop" "ipmi"; do
if [ -e (loop)/boot/kernel/${file}.ko ]; then
set vt_unix_ko=$file
break
fi
done
vt_unix_replace_ko $vt_unix_ko (vtunix)/ventoy_unix/FreeBSD/geom_ventoy_ko/$vt_freebsd_ver/$vt_freebsd_bit/geom_ventoy.ko.xz
vt_unix_replace_conf FreeBSD ${1}${chosen_path}
}
function ventoy_unix_comm_proc {
vt_unix_reset
if [ "$ventoy_compatible" = "NO" ]; then
loopback vtunix $vtoy_efi_part/ventoy/ventoy_unix.cpio
set vt_unix_type=unknown
if vt_strstr "$vt_system_id" "FreeBSD"; then
ventoy_freebsd_proc $1 ${chosen_path}
elif [ -e (loop)/bin/freebsd-version ]; then
ventoy_freebsd_proc $1 ${chosen_path}
else
if [ -n "${vtdebug_flag}" ]; then
echo "Unknown unix type"
fi
fi
fi
vt_unix_chain_data ${1}${chosen_path}
ventoy_debug_pause
}
function uefi_windows_menu_func {
vt_windows_reset
@@ -330,6 +402,18 @@ function uefi_linux_menu_func {
fi
}
function uefi_unix_menu_func {
ventoy_unix_comm_proc $1 ${chosen_path}
if [ -n "$vtoy_chain_mem_addr" ]; then
ventoy_cli_console
chainloader ${vtoy_path}/ventoy_x64.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot
else
echo "chain empty failed"
ventoy_pause
fi
}
function uefi_iso_menu_func {
@@ -358,6 +442,7 @@ function uefi_iso_menu_func {
fi
loopback loop ${1}${chosen_path}
vt_parse_iso_volume ${1}${chosen_path} vt_system_id vt_volume_id
get_os_type (loop)
if [ -d (loop)/EFI ]; then
@@ -382,6 +467,8 @@ function uefi_iso_menu_func {
if [ "$vtoy_os" = "Windows" ]; then
vt_check_compatible_pe (loop)
uefi_windows_menu_func $1 ${chosen_path}
elif [ "$vtoy_os" = "Unix" ]; then
uefi_unix_menu_func $1 ${chosen_path}
else
uefi_linux_menu_func $1 ${chosen_path}
fi
@@ -501,6 +588,20 @@ function legacy_linux_menu_func {
fi
}
function legacy_unix_menu_func {
ventoy_unix_comm_proc $1 ${chosen_path}
if [ -n "$vtoy_chain_mem_addr" ]; then
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot
else
echo "chain empty failed"
ventoy_pause
fi
}
function legacy_iso_menu_func {
if [ -d (loop)/ ]; then
@@ -519,6 +620,7 @@ function legacy_iso_menu_func {
fi
loopback loop ${1}${chosen_path}
vt_parse_iso_volume ${1}${chosen_path} vt_system_id vt_volume_id
get_os_type (loop)
if [ -n "$vtcompat" ]; then
@@ -535,6 +637,8 @@ function legacy_iso_menu_func {
if [ "$vtoy_os" = "Windows" ]; then
vt_check_compatible_pe (loop)
legacy_windows_menu_func $1 ${chosen_path}
elif [ "$vtoy_os" = "Unix" ]; then
legacy_unix_menu_func $1 ${chosen_path}
else
legacy_linux_menu_func $1 ${chosen_path}
fi
@@ -550,6 +654,9 @@ function legacy_iso_memdisk {
}
function iso_common_menuentry {
unset vt_system_id
unset vt_volume_id
if [ "$grub_platform" = "pc" ]; then
if vt_check_mode 0; then
legacy_iso_memdisk $vtoy_iso_part

View File

@@ -129,13 +129,13 @@ is_disk_contains_ventoy() {
PART1_TYPE=$(dd if=$DISK bs=1 count=1 skip=450 status=none | ./tool/hexdump -n1 -e '1/1 "%02X"')
PART2_TYPE=$(dd if=$DISK bs=1 count=1 skip=466 status=none | ./tool/hexdump -n1 -e '1/1 "%02X"')
if [ "$PART1_TYPE" != "EE" ]; then
if [ "$PART2_TYPE" != "EF" ]; then
vtdebug "part2 type is $PART2_TYPE not EF"
ventoy_false
return
fi
fi
# if [ "$PART1_TYPE" != "EE" ]; then
# if [ "$PART2_TYPE" != "EF" ]; then
# vtdebug "part2 type is $PART2_TYPE not EF"
# ventoy_false
# return
# fi
# fi
# PART1_TYPE=$(dd if=$DISK bs=1 count=1 skip=450 status=none | ./tool/hexdump -n1 -e '1/1 "%02X"')
# if [ "$PART1_TYPE" != "07" ]; then

Binary file not shown.