Commit 99627752 authored by longpanda's avatar longpanda
Browse files

update

parent 062f8160
#!/ventoy/busybox/sh
#************************************************************************************
# 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/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
if is_ventoy_hook_finished; then
exit 0
fi
vtlog "####### $0 $* ########"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
PATH=$VTPATH_OLD
exit 0
fi
ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
ventoy_create_dev_ventoy_part
mdev -s
PATH=$VTPATH_OLD
set_ventoy_hook_finish
#!/ventoy/busybox/sh
#************************************************************************************
# 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/>.
#
#************************************************************************************
. $VTOY_PATH/hook/ventoy-os-lib.sh
$SED "/^CMDLINE=/i $BUSYBOX_PATH/sh $VTOY_PATH/loop/volumio/ventoy-disk.sh" -i /init
#skip the resizing process
$SED "/^FREESIZE=/a FREESIZE=0" -i /init
$SED "/exec.*switch_root/i $SED 's@\\\\(.*/boot \\\\)@#\\\\1@' -i /mnt/ext/union/etc/fstab" -i /init
...@@ -227,6 +227,10 @@ ventoy_get_os_type() { ...@@ -227,6 +227,10 @@ ventoy_get_os_type() {
echo 'vine'; return echo 'vine'; return
fi fi
if $GREP -q 'hyperbola' /proc/cmdline; then
echo 'hyperbola'; return
fi
echo "default" echo "default"
} }
......
...@@ -37,10 +37,30 @@ for i in $vtcmdline; do ...@@ -37,10 +37,30 @@ for i in $vtcmdline; do
fi fi
done done
####################################################################
# #
# Step 2 : Process ko #
# #
####################################################################
$BUSYBOX_PATH/mkdir -p /ventoy/modules
$BUSYBOX_PATH/ls -1a / | $EGREP '\.ko$|\.ko.[gx]z$' | while read vtline; do
if [ "${vtline:0:1}" = "." ]; then
$BUSYBOX_PATH/mv /${vtline} /ventoy/modules/${vtline:1}
else
$BUSYBOX_PATH/mv /${vtline} /ventoy/modules/
fi
done
if [ -e /vtloopex.tar.xz ]; then
echo "extract vtloopex ..." >> $VTLOG
$BUSYBOX_PATH/tar -xJf /vtloopex.tar.xz -C $VTOY_PATH/
$BUSYBOX_PATH/rm -f /vtloopex.tar.xz
fi
#################################################################### ####################################################################
# # # #
# Step 2 : Do OS specific hook # # Step 3 : Do OS specific hook #
# # # #
#################################################################### ####################################################################
ventoy_get_os_type() { ventoy_get_os_type() {
...@@ -56,6 +76,22 @@ ventoy_get_os_type() { ...@@ -56,6 +76,22 @@ ventoy_get_os_type() {
echo 'endless'; return echo 'endless'; return
fi fi
if $GREP -q 'OpenWrt' /proc/version; then
echo 'openwrt'; return
fi
if [ -e /BOOT_SPECS ]; then
if $GREP -q 'easyos' /BOOT_SPECS; then
echo 'easyos'; return
fi
fi
if [ -e /etc/os-release ]; then
if $GREP -q 'volumio' /etc/os-release; then
echo 'volumio'; return
fi
fi
echo "default" echo "default"
} }
...@@ -68,7 +104,7 @@ fi ...@@ -68,7 +104,7 @@ fi
#################################################################### ####################################################################
# # # #
# Step 3 : Check for debug break # # Step 4 : Check for debug break #
# # # #
#################################################################### ####################################################################
if [ "$VTOY_BREAK_LEVEL" = "03" ] || [ "$VTOY_BREAK_LEVEL" = "13" ]; then if [ "$VTOY_BREAK_LEVEL" = "03" ] || [ "$VTOY_BREAK_LEVEL" = "13" ]; then
...@@ -85,7 +121,7 @@ fi ...@@ -85,7 +121,7 @@ fi
#################################################################### ####################################################################
# # # #
# Step 3 : Hand over to real init # # Step 5 : Hand over to real init #
# # # #
#################################################################### ####################################################################
$BUSYBOX_PATH/umount /proc $BUSYBOX_PATH/umount /proc
......
#!/bin/bash
VENTOY_PATH=$PWD/../
rm -f vtloopex.cpio
cp -a vtloopex vtloopex_tmp
cd vtloopex_tmp
for dir in $(ls); do
cd $dir
tar -cJf vtloopex.tar.xz vtloopex
rm -rf vtloopex
cd ..
done
find . | cpio -o -H newc>../vtloopex.cpio
cd ..
rm -rf vtloopex_tmp
rm -f $VENTOY_PATH/INSTALL/ventoy/vtloopex.cpio
cp -a vtloopex.cpio $VENTOY_PATH/INSTALL/ventoy/
echo '======== SUCCESS ============='
...@@ -206,6 +206,11 @@ function distro_specify_initrd_file_phase2 { ...@@ -206,6 +206,11 @@ function distro_specify_initrd_file_phase2 {
if [ -f (loop)/parabola/boot/i686/parabolaiso.img ]; then if [ -f (loop)/parabola/boot/i686/parabolaiso.img ]; then
vt_linux_specify_initrd_file /parabola/boot/i686/parabolaiso.img vt_linux_specify_initrd_file /parabola/boot/i686/parabolaiso.img
fi fi
elif [ -f (loop)/hyperbola/boot/x86_64/hyperiso.img ]; then
vt_linux_specify_initrd_file /hyperbola/boot/x86_64/hyperiso.img
if [ -f (loop)/hyperbola/boot/i686/hyperiso.img ]; then
vt_linux_specify_initrd_file /hyperbola/boot/i686/hyperiso.img
fi
elif [ -f (loop)/EFI/BOOT/initrd.img ]; then elif [ -f (loop)/EFI/BOOT/initrd.img ]; then
#Qubes #Qubes
vt_linux_specify_initrd_file /EFI/BOOT/initrd.img vt_linux_specify_initrd_file /EFI/BOOT/initrd.img
...@@ -230,6 +235,14 @@ function ventoy_get_ghostbsd_ver { ...@@ -230,6 +235,14 @@ function ventoy_get_ghostbsd_ver {
set vt_freebsd_ver=12.x set vt_freebsd_ver=12.x
} }
function ventoy_get_furybsd_ver {
if regexp "13\.[0-9]" "$2"; then
set vt_freebsd_ver=13.x
else
set vt_freebsd_ver=12.x
fi
}
function ventoy_get_freenas_ver { function ventoy_get_freenas_ver {
set vt_freebsd_ver=11.x set vt_freebsd_ver=11.x
...@@ -250,6 +263,8 @@ function ventoy_freebsd_proc { ...@@ -250,6 +263,8 @@ function ventoy_freebsd_proc {
ventoy_get_ghostbsd_ver $1 ${chosen_path} ventoy_get_ghostbsd_ver $1 ${chosen_path}
elif vt_strstr "$vt_volume_id" "FREENAS"; then elif vt_strstr "$vt_volume_id" "FREENAS"; then
ventoy_get_freenas_ver $1 ${chosen_path} ventoy_get_freenas_ver $1 ${chosen_path}
elif vt_strstr "$vt_volume_id" "FURYBSD"; then
ventoy_get_furybsd_ver $1 ${chosen_path}
elif regexp "^13_[0-9]" "$vt_volume_id"; then elif regexp "^13_[0-9]" "$vt_volume_id"; then
set vt_freebsd_ver=13.x set vt_freebsd_ver=13.x
elif regexp "^12_[0-9]" "$vt_volume_id"; then elif regexp "^12_[0-9]" "$vt_volume_id"; then
...@@ -307,7 +322,7 @@ function ventoy_freebsd_proc { ...@@ -307,7 +322,7 @@ function ventoy_freebsd_proc {
fi fi
unset vt_unix_mod_path unset vt_unix_mod_path
for file in "/COPYRIGHT" "/FreeNAS-MANIFEST" "/version"; do for file in "/COPYRIGHT" "/FreeNAS-MANIFEST" "/version" "/etc/fstab"; do
if [ -e (loop)${file} ]; then if [ -e (loop)${file} ]; then
set vt_unix_mod_path=${file} set vt_unix_mod_path=${file}
break break
...@@ -442,6 +457,8 @@ function uefi_linux_menu_func { ...@@ -442,6 +457,8 @@ function uefi_linux_menu_func {
elif [ -d (loop)/EFI/boot/entries ]; then elif [ -d (loop)/EFI/boot/entries ]; then
if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img" vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
elif [ -f (loop)/hyperbola/boot/x86_64/hyperiso.img ]; then
vt_add_replace_file 0 "EFI\\hyperiso\\hyperiso.img"
fi fi
elif [ -e (loop)/syslinux/alt0/full.cz ]; then elif [ -e (loop)/syslinux/alt0/full.cz ]; then
vt_add_replace_file 0 "EFI\\BOOT\\full.cz" vt_add_replace_file 0 "EFI\\BOOT\\full.cz"
...@@ -833,20 +850,125 @@ function efi_unsupport_menuentry { ...@@ -833,20 +850,125 @@ function efi_unsupport_menuentry {
common_unsupport_menuentry common_unsupport_menuentry
} }
#
#============================================================#
# IMG file boot process #
#============================================================#
#
function ventoy_img_busybox_ver {
set ventoy_busybox_ver=32 function ventoy_img_easyos {
vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
if [ -e (vtimghd,2)/etc/openwrt_release ]; then loopback easysfs (vtimghd,1)/easy.sfs
if vt_file_strstr (vtimghd,2)/etc/openwrt_release x86_64; then vt_get_lib_module_ver (easysfs) /lib/modules/ vt_module_ver
set ventoy_busybox_ver=64
fi if [ -n "$vt_module_ver" ]; then
fi for mod in "kernel/drivers/md/dm-mod.ko" "kernel/drivers/dax/dax.ko"; do
vt_img_extra_initrd_append (easysfs)/lib/modules/$vt_module_ver/$mod
done
fi
ventoy_debug_pause
#boot image file
vt_set_boot_opt rdinit=/vtoy/vtoy
vt_img_hook_root
syslinux_configfile (vtimghd,1)/syslinux.cfg
vt_img_unhook_root
vt_unset_boot_opt
loopback -d easysfs
} }
function ventoy_img_volumio {
vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
ventoy_debug_pause
#boot image file
vt_set_boot_opt rdinit=/vtoy/vtoy imgpart=/dev/ventoy2 bootpart=/dev/ventoy1
vt_img_hook_root
syslinux_configfile (vtimghd,1)/syslinux.cfg
vt_img_unhook_root
vt_unset_boot_opt
}
function ventoy_img_fydeos {
set ventoy_busybox_ver=64
vt_load_cpio $vtoy_path/ventoy.cpio ${vt_chosen_path} ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
vt_trailer_cpio ${vtoy_iso_part} ${vt_chosen_path} noinit
# loopback easysfs (vtimghd,1)/easy.sfs
# vt_get_lib_module_ver (easysfs) /lib/modules/ vt_module_ver
# if [ -n "$vt_module_ver" ]; then
# for mod in "kernel/drivers/md/dm-mod.ko" "kernel/drivers/dax/dax.ko"; do
# vt_img_extra_initrd_append (easysfs)/lib/modules/$vt_module_ver/$mod
# done
# fi
ventoy_debug_pause
#boot image file
vt_set_boot_opt rdinit=/vtoy/vtoy
vt_img_hook_root
set root=(vtimghd,12)
configfile (vtimghd,12)/efi/boot/grub.cfg
#syslinux_configfile (vtimghd,12)/syslinux/syslinux.cfg
vt_img_unhook_root
vt_unset_boot_opt
}
function img_common_menuentry { function img_common_menuentry {
set ventoy_busybox_ver=32
vt_chosen_img_path vt_chosen_path vt_chosen_size
if [ -d (vtimghd)/ ]; then
loopback -d vtimghd
fi
loopback vtimghd ${vtoy_iso_part}${vt_chosen_path}
vt_img_sector ${vtoy_iso_part}${vt_chosen_path}
vt_img_part_info (vtimghd)
set vtback_root=$root
ventoy_cli_console
vt_push_last_entry
echo "To be implement" vt_img_extra_initrd_reset
if [ -e (vtimghd,1)/easy.sfs ]; then
ventoy_img_easyos
elif [ -e (vtimghd,1)/volumio.initrd ]; then
ventoy_img_volumio
elif [ -e (vtimghd,3)/etc/os-release ]; then
if vt_file_strstr (vtimghd,3)/etc/os-release FydeOS; then
ventoy_img_fydeos
fi
else
echo -e "\n This IMG file is NOT supported now. \n"
echo -e " 当前不支持启动此 IMG 文件 \n"
echo -e "\npress ENTER to exit (请按 回车 键返回) ..."
read vtInputKey
fi
set root=$vtback_root
vt_pop_last_entry
ventoy_gui_console
} }
function img_unsupport_menuentry { function img_unsupport_menuentry {
......
...@@ -116,7 +116,7 @@ if [ "$MODE" = "install" ]; then ...@@ -116,7 +116,7 @@ if [ "$MODE" = "install" ]; then
if parted -v > /dev/null 2>&1; then if parted -v > /dev/null 2>&1; then
PARTTOOL='parted' PARTTOOL='parted'
else else
vterr "parted is not found in the sysstem, Ventoy can't create new partition." vterr "parted is not found in the system, Ventoy can't create new partition."
exit 1 exit 1
fi fi
else else
...@@ -125,7 +125,7 @@ if [ "$MODE" = "install" ]; then ...@@ -125,7 +125,7 @@ if [ "$MODE" = "install" ]; then
elif fdisk -v >/dev/null 2>&1; then elif fdisk -v >/dev/null 2>&1; then
PARTTOOL='fdisk' PARTTOOL='fdisk'
else else
vterr "Both parted and fdisk are not found in the sysstem, Ventoy can't create new partition." vterr "Both parted and fdisk are not found in the system, Ventoy can't create new partition."
exit 1 exit 1
fi fi
fi fi
...@@ -144,7 +144,7 @@ if [ "$MODE" = "install" ]; then ...@@ -144,7 +144,7 @@ if [ "$MODE" = "install" ]; then
disk_sector_num=$(cat /sys/block/${DISK#/dev/}/size) disk_sector_num=$(cat /sys/block/${DISK#/dev/}/size)
disk_size_gb=$(expr $disk_sector_num / 2097152) disk_size_gb=$(expr $disk_sector_num / 2097152)
if [ $disk_sector_num -gt 4294967296 ] && [ -z $VTGPT ]; then if [ $disk_sector_num -gt 4294967296 ] && [ -z "$VTGPT" ]; then
vterr "$DISK is over 2TB size, MBR will not work on it." vterr "$DISK is over 2TB size, MBR will not work on it."
exit 1 exit 1
fi fi
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -486,8 +486,8 @@ static int vtoydm_print_linear_table(const char *img_map_file, const char *diskn ...@@ -486,8 +486,8 @@ static int vtoydm_print_linear_table(const char *img_map_file, const char *diskn
{ {
int i; int i;
int len; int len;
uint32_t disk_sector_num;
uint32_t sector_start; uint32_t sector_start;
uint32_t sector_num;
ventoy_img_chunk *chunk = NULL; ventoy_img_chunk *chunk = NULL;
chunk = vtoydm_get_img_map_data(img_map_file, &len); chunk = vtoydm_get_img_map_data(img_map_file, &len);
...@@ -499,16 +499,16 @@ static int vtoydm_print_linear_table(const char *img_map_file, const char *diskn ...@@ -499,16 +499,16 @@ static int vtoydm_print_linear_table(const char *img_map_file, const char *diskn
for (i = 0; i < len / sizeof(ventoy_img_chunk); i++) for (i = 0; i < len / sizeof(ventoy_img_chunk); i++)
{ {
sector_start = chunk[i].img_start_sector; sector_start = chunk[i].img_start_sector;
sector_num = chunk[i].img_end_sector - chunk[i].img_start_sector + 1; disk_sector_num = (uint32_t)(chunk[i].disk_end_sector + 1 - chunk[i].disk_start_sector);
/* TBD: to be more flexible */ /* TBD: to be more flexible */
#if 0 #if 0
printf("%u %u linear %s %llu\n", printf("%u %u linear %s %llu\n",
(sector_start << 2), (sector_num << 2), (sector_start << 2), disk_sector_num,
diskname, (unsigned long long)chunk[i].disk_start_sector); diskname, (unsigned long long)chunk[i].disk_start_sector);
#else #else
printf("%u %u linear %s1 %llu\n", printf("%u %u linear %s1 %llu\n",
(sector_start << 2), (sector_num << 2), (sector_start << 2), disk_sector_num,
diskname, (unsigned long long)chunk[i].disk_start_sector - 2048); diskname, (unsigned long long)chunk[i].disk_start_sector - 2048);
#endif #endif
} }
......
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