Skip to content

Commit

Permalink
update for new release
Browse files Browse the repository at this point in the history
  • Loading branch information
ventoy committed Jul 22, 2020
1 parent a6d3ecc commit 0f8478f
Show file tree
Hide file tree
Showing 433 changed files with 2,597 additions and 620 deletions.
7 changes: 7 additions & 0 deletions DOC/BuildVentoyFromSource.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,10 @@
https://busybox.net/downloads/binaries/1.31.0-i686-uclibc/ busybox_ASH
SHA-256: 2943f02f85fee0c9551aec47110a558a73f919c032b3c51e56d6f197b5ec4d7b

5.12 7za.exe
download from https://www.7-zip.org/a/7z1900-extra.7z
ISNTALL/ventoy/7z/64/7za.exe SHA-256: 8117e40ee7f824f63373a4f5625bb62749f69159d0c449b3ce2f35aad3b83549
ISNTALL/ventoy/7z/32/7za.exe SHA-256: ea308c76a2f927b160a143d94072b0dce232e04b751f0c6432a94e05164e716d



2 changes: 1 addition & 1 deletion GRUB2/MOD_SRC/grub-2.04/grub-core/normal/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ grub_env_new_context (int export_all)
grub_err_t
grub_env_context_open (void)
{
return grub_env_new_context (1);
return grub_env_new_context (grub_env_get("ventoy_new_context") ? 0 : 1);
}

int grub_extractor_level = 0;
Expand Down
16 changes: 10 additions & 6 deletions GRUB2/MOD_SRC/grub-2.04/grub-core/normal/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,12 +853,16 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
}
break;
case GRUB_TERM_KEY_F6:
cmdstr = grub_env_get("VTOY_F6_CMD");
if (cmdstr)
{
menu_fini ();
grub_script_execute_sourcecode(cmdstr);
goto refresh;
if (0 == g_ventoy_fn_mutex) {
cmdstr = grub_env_get("VTOY_F6_CMD");
if (cmdstr)
{
menu_fini ();
g_ventoy_fn_mutex = 1;
grub_script_execute_sourcecode(cmdstr);
g_ventoy_fn_mutex = 0;
goto refresh;
}
}
break;
case GRUB_TERM_KEY_F7:
Expand Down
5 changes: 1 addition & 4 deletions GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2167,7 +2167,7 @@ static grub_err_t ventoy_cmd_find_bootable_hdd(grub_extcmd_context_t ctxt, int a
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s variable\n", cmd_raw_name);
}

isopath = grub_env_get("iso_path");
isopath = grub_env_get("vtoy_iso_part");
if (!isopath)
{
debug("isopath is null %p\n", isopath);
Expand Down Expand Up @@ -2321,9 +2321,6 @@ static int ventoy_env_init(void)
char buf[64];

grub_env_set("vtdebug_flag", "");
grub_env_export("vtdebug_flag");



g_tree_script_buf = grub_malloc(VTOY_MAX_SCRIPT_BUF);
g_list_script_buf = grub_malloc(VTOY_MAX_SCRIPT_BUF);
Expand Down
10 changes: 10 additions & 0 deletions GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,15 @@ typedef struct menu_class
struct menu_class *next;
}menu_class;

typedef struct injection_config
{
int pathlen;
char isopath[256];
char archive[256];

struct injection_config *next;
}injection_config;

extern int g_ventoy_menu_esc;
extern int g_ventoy_suppress_esc;
extern int g_ventoy_last_entry;
Expand All @@ -666,6 +675,7 @@ persistence_config * ventoy_plugin_find_persistent(const char *isopath);
void ventoy_plugin_dump_auto_install(void);
int ventoy_fill_windows_rtdata(void *buf, char *isopath);
int ventoy_plugin_get_persistent_chunklist(const char *isopath, int index, ventoy_img_chunk_list *chunk_list);
const char * ventoy_plugin_get_injection(const char *isopath);
const char * ventoy_plugin_get_menu_alias(int type, const char *isopath);
const char * ventoy_plugin_get_menu_class(int type, const char *name);
int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
Expand Down
55 changes: 47 additions & 8 deletions GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,8 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
char *template_file = NULL;
char *template_buf = NULL;
char *persistent_buf = NULL;
char *injection_buf = NULL;
const char *injection_file = NULL;
grub_uint8_t *buf = NULL;
grub_uint32_t mod;
grub_uint32_t headlen;
Expand All @@ -917,8 +919,9 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
grub_uint32_t img_chunk_size;
grub_uint32_t template_size = 0;
grub_uint32_t persistent_size = 0;
grub_uint32_t injection_size = 0;
grub_file_t file;
grub_file_t scriptfile;
grub_file_t tmpfile;
ventoy_img_chunk_list chunk_list;

(void)ctxt;
Expand Down Expand Up @@ -960,18 +963,18 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
if (template_file)
{
debug("auto install template: <%s>\n", template_file);
scriptfile = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s%s", args[2], template_file);
if (scriptfile)
tmpfile = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s%s", args[2], template_file);
if (tmpfile)
{
debug("auto install script size %d\n", (int)scriptfile->size);
template_size = scriptfile->size;
debug("auto install script size %d\n", (int)tmpfile->size);
template_size = tmpfile->size;
template_buf = grub_malloc(template_size);
if (template_buf)
{
grub_file_read(scriptfile, template_buf, template_size);
grub_file_read(tmpfile, template_buf, template_size);
}

grub_file_close(scriptfile);
grub_file_close(tmpfile);
}
else
{
Expand All @@ -983,7 +986,34 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
debug("auto install script skipped or not configed %s\n", args[1]);
}

g_ventoy_cpio_buf = grub_malloc(file->size + 4096 + template_size + persistent_size + img_chunk_size);
injection_file = ventoy_plugin_get_injection(args[1]);
if (injection_file)
{
debug("injection archive: <%s>\n", injection_file);
tmpfile = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s%s", args[2], injection_file);
if (tmpfile)
{
debug("injection archive size:%d\n", (int)tmpfile->size);
injection_size = tmpfile->size;
injection_buf = grub_malloc(injection_size);
if (injection_buf)
{
grub_file_read(tmpfile, injection_buf, injection_size);
}

grub_file_close(tmpfile);
}
else
{
debug("Failed to open injection archive %s%s\n", args[2], injection_file);
}
}
else
{
debug("injection not configed %s\n", args[1]);
}

g_ventoy_cpio_buf = grub_malloc(file->size + 4096 + template_size + persistent_size + injection_size + img_chunk_size);
if (NULL == g_ventoy_cpio_buf)
{
grub_file_close(file);
Expand Down Expand Up @@ -1020,6 +1050,15 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
persistent_buf = NULL;
}

if (injection_size > 0 && injection_buf)
{
headlen = ventoy_cpio_newc_fill_head(buf, injection_size, injection_buf, "ventoy/ventoy_injection");
buf += headlen + ventoy_align(injection_size, 4);

grub_free(injection_buf);
injection_buf = NULL;
}

/* step2: insert os param to cpio */
headlen = ventoy_cpio_newc_fill_head(buf, 0, NULL, "ventoy/ventoy_os_param");
padlen = sizeof(ventoy_os_param);
Expand Down
108 changes: 108 additions & 0 deletions GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static install_template *g_install_template_head = NULL;
static persistence_config *g_persistence_head = NULL;
static menu_alias *g_menu_alias_head = NULL;
static menu_class *g_menu_class_head = NULL;
static injection_config *g_injection_head = NULL;

static int ventoy_plugin_control_check(VTOY_JSON *json, const char *isodisk)
{
Expand Down Expand Up @@ -805,6 +806,96 @@ static int ventoy_plugin_menualias_entry(VTOY_JSON *json, const char *isodisk)
return 0;
}


static int ventoy_plugin_injection_check(VTOY_JSON *json, const char *isodisk)
{
const char *path = NULL;
const char *archive = NULL;
VTOY_JSON *pNode = NULL;

(void)isodisk;

if (json->enDataType != JSON_TYPE_ARRAY)
{
grub_printf("Not array %d\n", json->enDataType);
return 0;
}

for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
{
path = vtoy_json_get_string_ex(pNode->pstChild, "image");
if (!path)
{
grub_printf("image not found\n");
continue;
}

archive = vtoy_json_get_string_ex(pNode->pstChild, "archive");
if (!archive)
{
grub_printf("archive not found\n");
continue;
}

grub_printf("image: <%s> [%s]\n", path, ventoy_check_file_exist("%s%s", isodisk, path) ? "OK" : "NOT EXIST");
grub_printf("archive: <%s> [%s]\n\n", archive, ventoy_check_file_exist("%s%s", isodisk, archive) ? "OK" : "NOT EXIST");
}

return 0;
}

static int ventoy_plugin_injection_entry(VTOY_JSON *json, const char *isodisk)
{
const char *path = NULL;
const char *archive = NULL;
VTOY_JSON *pNode = NULL;
injection_config *node = NULL;
injection_config *next = NULL;

(void)isodisk;

if (json->enDataType != JSON_TYPE_ARRAY)
{
debug("Not array %d\n", json->enDataType);
return 0;
}

if (g_injection_head)
{
for (node = g_injection_head; node; node = next)
{
next = node->next;
grub_free(node);
}

g_injection_head = NULL;
}

for (pNode = json->pstChild; pNode; pNode = pNode->pstNext)
{
path = vtoy_json_get_string_ex(pNode->pstChild, "image");
archive = vtoy_json_get_string_ex(pNode->pstChild, "archive");
if (path && path[0] == '/' && archive && archive[0] == '/')
{
node = grub_zalloc(sizeof(injection_config));
if (node)
{
node->pathlen = grub_snprintf(node->isopath, sizeof(node->isopath), "%s", path);
grub_snprintf(node->archive, sizeof(node->archive), "%s", archive);

if (g_injection_head)
{
node->next = g_injection_head;
}

g_injection_head = node;
}
}
}

return 0;
}

static int ventoy_plugin_menuclass_entry(VTOY_JSON *json, const char *isodisk)
{
int type;
Expand Down Expand Up @@ -914,6 +1005,7 @@ static plugin_entry g_plugin_entries[] =
{ "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check },
{ "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check },
{ "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check },
{ "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check },
};

static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk)
Expand Down Expand Up @@ -1151,6 +1243,22 @@ int ventoy_plugin_get_persistent_chunklist(const char *isopath, int index, vento
return rc;
}

const char * ventoy_plugin_get_injection(const char *isopath)
{
injection_config *node = NULL;
int len = (int)grub_strlen(isopath);

for (node = g_injection_head; node; node = node->next)
{
if (node->pathlen == len && grub_strcmp(node->isopath, isopath) == 0)
{
return node->archive;
}
}

return NULL;
}

const char * ventoy_plugin_get_menu_alias(int type, const char *isopath)
{
menu_alias *node = NULL;
Expand Down
11 changes: 11 additions & 0 deletions GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,17 @@ int ventoy_fill_windows_rtdata(void *buf, char *isopath)
{
debug("auto install script skipped or not configed %s\n", pos);
}

script = (char *)ventoy_plugin_get_injection(pos);
if (script)
{
debug("injection archive <%s>\n", script);
grub_snprintf(data->injection_archive, sizeof(data->injection_archive) - 1, "%s", script);
}
else
{
debug("injection archive not configed %s\n", pos);
}

return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion GRUB2/MOD_SRC/grub-2.04/include/grub/ventoy.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ typedef struct ventoy_os_param
typedef struct ventoy_windows_data
{
char auto_install_script[384];
grub_uint8_t reserved[128];
char injection_archive[384];
grub_uint8_t reserved[256];
}ventoy_windows_data;


Expand Down
29 changes: 21 additions & 8 deletions GRUB2/MOD_SRC/grub-2.04/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ all_modules_uefi="blocklist ventoy test search at_keyboard usb_keyboard gcry_md
all_extra_modules="elf macho offsetio regexp file"

if [ "$1" = "uefi" ]; then
all_modules="$net_modules_uefi $all_modules_uefi $all_extra_modules"
all_modules="$net_modules_uefi $all_modules_uefi $all_extra_modules "
grub-mkimage -v --directory "$VT_DIR/GRUB2/INSTALL/lib/grub/x86_64-efi" --prefix '(,2)/grub' --output "$VT_DIR/INSTALL/EFI/BOOT/grubx64_real.efi" --format 'x86_64-efi' --compression 'auto' $all_modules_uefi 'fat' 'part_msdos'
else
all_modules="$net_modules_legacy $all_modules_legacy"
all_modules="$net_modules_legacy $all_modules_legacy "
grub-mkimage -v --directory "$VT_DIR/GRUB2/INSTALL/lib/grub/i386-pc" --prefix '(,2)/grub' --output "$VT_DIR/INSTALL/grub/i386-pc/core.img" --format 'i386-pc' --compression 'auto' $all_modules_legacy 'fat' 'part_msdos' 'biosdisk'
fi

Expand All @@ -34,16 +34,29 @@ if [ "$1" = "uefi" ]; then
cp -a $VT_DIR/GRUB2/PXE/grub2/x86_64-efi/core.efi $VT_DIR/GRUB2/NBP/core.efi || exit 1

rm -f $VT_DIR/INSTALL/grub/x86_64-efi/normal.mod
cp -a $VT_DIR/GRUB2/PXE/grub2/x86_64-efi/normal.mod $VT_DIR/INSTALL/grub/x86_64-efi/normal.mod || exit 1
cp -a $VT_DIR/GRUB2/PXE/grub2/x86_64-efi/normal.mod $VT_DIR/INSTALL/grub/x86_64-efi/normal.mod || exit 1

#copy other modules
ls -1 $VT_DIR/GRUB2/INSTALL/lib/grub/x86_64-efi/ | egrep '\.(lst|mod)$' | while read line; do
if ! echo $all_modules | grep -q "${line%.mod} "; then
echo "Copy $line ..."
rm -f $VT_DIR/INSTALL/grub/x86_64-efi/$line
cp -a $VT_DIR/GRUB2/INSTALL/lib/grub/x86_64-efi/$line $VT_DIR/INSTALL/grub/x86_64-efi/
fi
done
else
rm -f $VT_DIR/GRUB2/NBP/core.0
cp -a $VT_DIR/GRUB2/PXE/grub2/i386-pc/core.0 $VT_DIR/GRUB2/NBP/core.0 || exit 1

for md in $all_extra_modules; do
rm -f $VT_DIR/INSTALL/grub/i386-pc/${md}.mod
cp -a $VT_DIR/GRUB2/INSTALL/lib/grub/i386-pc/${md}.mod $VT_DIR/INSTALL/grub/i386-pc/
done

rm -f $VT_DIR/INSTALL/grub/i386-pc/boot.img
cp -a $VT_DIR/GRUB2/INSTALL/lib/grub/i386-pc/boot.img $VT_DIR/INSTALL/grub/i386-pc/boot.img || exit 1

#copy other modules
ls -1 $VT_DIR/GRUB2/INSTALL/lib/grub/i386-pc/ | egrep '\.(lst|mod)$' | while read line; do
if ! echo $all_modules | grep -q "${line%.mod} "; then
echo "Copy $line ..."
rm -f $VT_DIR/INSTALL/grub/i386-pc/$line
cp -a $VT_DIR/GRUB2/INSTALL/lib/grub/i386-pc/$line $VT_DIR/INSTALL/grub/i386-pc/
fi
done
fi
Loading

0 comments on commit 0f8478f

Please sign in to comment.