]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Add support for easyOS easy-4.4.2-amd64.img. (#1926)
authorlongpanda <admin@ventoy.net>
Sat, 22 Oct 2022 07:28:16 +0000 (15:28 +0800)
committerlongpanda <admin@ventoy.net>
Sat, 22 Oct 2022 07:28:16 +0000 (15:28 +0800)
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_linux.c
IMG/cpio/ventoy/loop/easyos/ventoy-hook.sh
IMG/cpio/ventoy/ventoy_loop.sh
INSTALL/grub/grub.cfg

index 5dec9e297d38c39a79fead72dbf2c9f1416baffd..3f7b4a01dbc65806817116ed66e987bfb6ed0c2f 100644 (file)
@@ -6390,6 +6390,7 @@ static cmd_para ventoy_cmds[] =
     { "vt_show_secondary_menu", ventoy_cmd_show_secondary_menu, 0, NULL, "", "", NULL },
     { "vt_fs_ignore_case", ventoy_cmd_fs_ignore_case, 0, NULL, "", "", NULL },
     { "vt_systemd_menu", ventoy_cmd_linux_systemd_menu, 0, NULL, "", "", NULL },
     { "vt_show_secondary_menu", ventoy_cmd_show_secondary_menu, 0, NULL, "", "", NULL },
     { "vt_fs_ignore_case", ventoy_cmd_fs_ignore_case, 0, NULL, "", "", NULL },
     { "vt_systemd_menu", ventoy_cmd_linux_systemd_menu, 0, NULL, "", "", NULL },
+    { "vt_limine_menu", ventoy_cmd_linux_limine_menu, 0, NULL, "", "", NULL },
     { "vt_secondary_recover_mode", ventoy_cmd_secondary_recover_mode, 0, NULL, "", "", NULL },
 };
 
     { "vt_secondary_recover_mode", ventoy_cmd_secondary_recover_mode, 0, NULL, "", "", NULL },
 };
 
index 705f965a433988d11deea1ed29cae3513309dfdb..89119ac86656c416bbfbb124752c708ad1faad23 100644 (file)
@@ -623,6 +623,7 @@ grub_uint32_t ventoy_get_iso_boot_catlog(grub_file_t file);
 int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector);
 grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
 grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args);
 int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector);
 grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
 grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args);
+grub_err_t ventoy_cmd_linux_limine_menu(grub_extcmd_context_t ctxt, int argc, char **args);
 grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc, char **args);
 grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
 grub_err_t ventoy_cmd_valid_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
 grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc, char **args);
 grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
 grub_err_t ventoy_cmd_valid_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
index bfeb85893e08b916fb7fa5f0c3e7e783d5476d12..c70ba9a27c72375dbf6c36ea42476e198abbcb93 100644 (file)
@@ -1981,3 +1981,155 @@ end:
     VENTOY_CMD_RETURN(GRUB_ERR_NONE);
 }
 
     VENTOY_CMD_RETURN(GRUB_ERR_NONE);
 }
 
+static int ventoy_limine_path_convert(char *path)
+{
+    char newpath[256] = {0};
+
+    if (grub_strncmp(path, "boot://2/", 9) == 0)
+    {
+        grub_snprintf(newpath, sizeof(newpath), "(vtimghd,2)/%s", path + 9);
+    }
+    else if (grub_strncmp(path, "boot://1/", 9) == 0)
+    {
+        grub_snprintf(newpath, sizeof(newpath), "(vtimghd,1)/%s", path + 9);
+    }
+
+    if (newpath[0])
+    {
+        grub_snprintf(path, 1024, "%s", newpath);
+    }
+
+    return 0;
+}
+
+grub_err_t ventoy_cmd_linux_limine_menu(grub_extcmd_context_t ctxt, int argc, char **args)
+{
+    int pos = 0;
+    int sub = 0;
+    int len = VTOY_LINUX_SYSTEMD_MENU_MAX_BUF;
+    char *filebuf = NULL;
+    char *start = NULL;
+    char *nextline = NULL;
+    grub_file_t file = NULL;
+    char name[128];
+    char value[64];
+    char *title = NULL;
+    char *kernel = NULL;
+    char *initrd = NULL;
+    char *param = NULL;
+    static char *buf = NULL;
+    
+    (void)ctxt;
+    (void)argc;
+
+    if (!buf)
+    {
+        buf = grub_malloc(len + 4 * 1024);
+        if (!buf)
+        {
+            goto end;
+        }        
+    }
+
+    title = buf + len;
+    kernel = title + 1024;
+    initrd = kernel + 1024;
+    param = initrd + 1024;
+    
+    file = ventoy_grub_file_open(VENTOY_FILE_TYPE, args[0]);
+    if (!file)
+    {
+        return 0;
+    }
+
+    filebuf = grub_zalloc(file->size + 8);
+    if (!filebuf)
+    {
+        goto end;
+    }
+
+    grub_file_read(file, filebuf, file->size);
+    grub_file_close(file);
+
+    
+    title[0] = kernel[0] = initrd[0] = param[0] = 0;
+    for (start = filebuf; start; start = nextline)
+    {
+        nextline = ventoy_get_line(start);
+        while (ventoy_isspace(*start))
+        {
+            start++;
+        }
+
+        if (start[0] == ':')
+        {
+            if (start[1] == ':')
+            {
+                grub_snprintf(title, 1024, "%s", start + 2);
+            }
+            else
+            {
+                if (sub)
+                {
+                    vtoy_len_ssprintf(buf, pos, len, "}\n");
+                    sub = 0;
+                }
+
+                if (nextline && nextline[0] == ':' && nextline[1] == ':')
+                {
+                    vtoy_len_ssprintf(buf, pos, len, "submenu \"[+] %s\" {\n", start + 2);
+                    sub = 1;
+                    title[0] = 0;
+                }
+                else
+                {
+                    grub_snprintf(title, 1024, "%s", start + 1);                    
+                }
+            }
+        }
+        else if (grub_strncmp(start, "KERNEL_PATH=", 12) == 0)
+        {
+            grub_snprintf(kernel, 1024, "%s", start + 12);
+        }
+        else if (grub_strncmp(start, "MODULE_PATH=", 12) == 0)
+        {
+            grub_snprintf(initrd, 1024, "%s", start + 12);
+        }
+        else if (grub_strncmp(start, "KERNEL_CMDLINE=", 15) == 0)
+        {
+            grub_snprintf(param, 1024, "%s", start + 15);
+        }
+
+        if (title[0] && kernel[0] && initrd[0] && param[0])
+        {
+            ventoy_limine_path_convert(kernel);
+            ventoy_limine_path_convert(initrd);
+        
+            vtoy_len_ssprintf(buf, pos, len, "menuentry \"%s\" {\n", title);
+            vtoy_len_ssprintf(buf, pos, len, "  echo \"Downloading kernel ...\"\n  linux %s %s\n", kernel, param);
+            vtoy_len_ssprintf(buf, pos, len, "  echo \"Downloading initrd ...\"\n  initrd %s\n", initrd);
+            vtoy_len_ssprintf(buf, pos, len, "}\n");
+        
+            title[0] = kernel[0] = initrd[0] = param[0] = 0;
+        }
+    }
+
+    if (sub)
+    {
+        vtoy_len_ssprintf(buf, pos, len, "}\n");
+        sub = 0;
+    }
+
+    grub_snprintf(name, sizeof(name), "%s_addr", args[1]);
+    grub_snprintf(value, sizeof(value), "0x%llx", (ulonglong)(ulong)buf);
+    grub_env_set(name, value);
+    
+    grub_snprintf(name, sizeof(name), "%s_size", args[1]);
+    grub_snprintf(value, sizeof(value), "%d", pos);
+    grub_env_set(name, value);
+
+end:
+    grub_check_free(filebuf);
+    VENTOY_CMD_RETURN(GRUB_ERR_NONE);
+}
+
index a240dcb00f05d7ac9fe92da7cb2fbe68d6cb050c..75eabc67f79850baff0cce8a6a7b80e8252d2ac9 100644 (file)
@@ -23,6 +23,9 @@ $SED "/find drives/i $BUSYBOX_PATH/sh $VTOY_PATH/loop/easyos/ventoy-disk.sh; vtD
 
 $SED "1a boot_dev=ventoy1;wkg_dev=ventoy2" -i /init
 
 
 $SED "1a boot_dev=ventoy1;wkg_dev=ventoy2" -i /init
 
+$SED 's#\(dd *if=/dev/.*WKG_DRV.* *of=/dev/null.*skip\)=[0-9]*#\1=1048576#' -i /init
+$SED "s#WKG_DEV=\"\"#WKG_DEV=ventoy2#g" -i /init
+
 #check for ssd will read /sys/block/ventoy, will no exist, need a workaround
 $SED "s#/sys/block/\${WKG_DRV}/#/sys/block/\$vtDM/#g"  -i /init
 
 #check for ssd will read /sys/block/ventoy, will no exist, need a workaround
 $SED "s#/sys/block/\${WKG_DRV}/#/sys/block/\$vtDM/#g"  -i /init
 
index 0c69ec13ad8bd85e9d391ddbe60ed948a8dc0d01..38e60162c09c3f8253b53151890c84a97507b155 100644 (file)
@@ -75,6 +75,10 @@ ventoy_get_os_type() {
         echo 'openwrt'; return
     fi
     
         echo 'openwrt'; return
     fi
     
+    if $GREP -q 'easyos' /proc/cmdline; then
+        echo 'easyos'; return
+    fi
+    
     if [ -e /BOOT_SPECS ]; then
         if $GREP -q 'easyos' /BOOT_SPECS; then
             echo 'easyos'; return
     if [ -e /BOOT_SPECS ]; then
         if $GREP -q 'easyos' /BOOT_SPECS; then
             echo 'easyos'; return
index 3e000d9a391031f07e6a0dc278bb9ce82e6f2380..7190500a23c79b5e41294227aab23554e9a2a9d8 100644 (file)
@@ -1847,6 +1847,41 @@ function ventoy_img_easyos {
     loopback -d easysfs
 }
 
     loopback -d easysfs
 }
 
+function ventoy_img_easyos2 {
+    vt_load_cpio  $vtoy_path  "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
+    vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
+    
+    if [ -e (vtimghd,2)/easyos/easy.sfs ]; then
+        loopback easysfs (vtimghd,2)/easyos/easy.sfs
+    elif [ -d (vtimghd,2)/easyos/releases ]; then
+        vt_fs_enum_1st_dir (vtimghd,2) /easyos/releases/ vt_dir_name
+        loopback easysfs (vtimghd,2)/easyos/releases/$vt_dir_name/easy.sfs
+    fi
+    
+    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
+            if [ -e (easysfs)/lib/modules/$vt_module_ver/$mod ]; then
+                vt_img_extra_initrd_append  (easysfs)/lib/modules/$vt_module_ver/$mod
+            fi
+        done
+    fi
+
+    ventoy_debug_pause
+
+    #boot image file
+    vt_set_boot_opt rdinit=/vtoy/vtoy
+    vt_img_hook_root
+    
+    vt_limine_menu (vtimghd,1)/limine.cfg vt_sys_menu_mem
+    configfile "mem:${vt_sys_menu_mem_addr}:size:${vt_sys_menu_mem_size}"
+    
+    vt_img_unhook_root
+    vt_unset_boot_opt
+    loopback -d easysfs
+}
+
 function ventoy_img_volumio {
     vt_load_cpio  $vtoy_path  "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
     vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
 function ventoy_img_volumio {
     vt_load_cpio  $vtoy_path  "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
     vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
@@ -2262,6 +2297,8 @@ function img_common_menuentry {
         ventoy_img_esysrescue
     elif [ -e (vtimghd,1)/easy.sfs ]; then
         ventoy_img_easyos
         ventoy_img_esysrescue
     elif [ -e (vtimghd,1)/easy.sfs ]; then
         ventoy_img_easyos
+    elif [ -d (vtimghd,2)/easyos ]; then
+        ventoy_img_easyos2
     elif [ -e (vtimghd,1)/volumio.initrd ]; then
         ventoy_img_volumio
     elif [ -f (vtimghd,2)/loader/entries/ubos.conf ]; then
     elif [ -e (vtimghd,1)/volumio.initrd ]; then
         ventoy_img_volumio
     elif [ -f (vtimghd,2)/loader/entries/ubos.conf ]; then