1.0.45 release

This commit is contained in:
longpanda 2021-05-29 19:42:16 +08:00
parent c42a8c6d93
commit ac3ab97686
13 changed files with 304 additions and 13 deletions

View File

@ -4573,6 +4573,7 @@ static cmd_para ventoy_cmds[] =
{ "vt_is_pe64", ventoy_cmd_is_pe64, 0, NULL, "", "", NULL },
{ "vt_sel_wimboot", ventoy_cmd_sel_wimboot, 0, NULL, "", "", NULL },
{ "vt_set_wim_load_prompt", ventoy_cmd_set_wim_prompt, 0, NULL, "", "", NULL },
{ "vt_set_theme", ventoy_cmd_set_theme, 0, NULL, "", "", NULL },
};

View File

@ -778,6 +778,12 @@ typedef struct file_fullpath
char path[256];
}file_fullpath;
typedef struct theme_list
{
file_fullpath theme;
struct theme_list *next;
}theme_list;
#define auto_install_type_file 0
#define auto_install_type_parent 1
typedef struct install_template
@ -999,6 +1005,7 @@ int ventoy_plugin_load_dud(dud *node, const char *isopart);
int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
int ventoy_check_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, grub_disk_addr_t start);
void ventoy_plugin_dump_persistence(void);
grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_plugin_check_json(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_check_password(grub_extcmd_context_t ctxt, int argc, char **args);
grub_err_t ventoy_cmd_linux_get_main_initrd_index(grub_extcmd_context_t ctxt, int argc, char **args);
@ -1036,5 +1043,9 @@ int ventoy_chain_file_read(const char *path, int offset, int len, void *buf);
#define VTOY_CMD_CHECK(a) if (33554432 != g_ventoy_disk_part_size[a]) ventoy_syscall0(exit)
#define vtoy_theme_random_boot_second 0
#define vtoy_theme_random_boot_day 1
#define vtoy_theme_random_boot_month 2
#endif /* __VENTOY_DEF_H__ */

View File

@ -56,6 +56,11 @@ static auto_memdisk *g_auto_memdisk_head = NULL;
static image_list *g_image_list_head = NULL;
static conf_replace *g_conf_replace_head = NULL;
static int g_theme_num = 0;
static theme_list *g_theme_head = NULL;
static int g_theme_random = vtoy_theme_random_boot_second;
static char g_theme_single_file[256];
static int ventoy_plugin_is_parent(const char *pat, int patlen, const char *isopath)
{
if (patlen > 1)
@ -177,6 +182,38 @@ static int ventoy_plugin_theme_check(VTOY_JSON *json, const char *isodisk)
return 1;
}
}
else
{
node = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "file");
if (node)
{
for (node = node->pstChild; node; node = node->pstNext)
{
value = node->unData.pcStrVal;
grub_printf("file: %s\n", value);
if (value[0] == '/')
{
exist = ventoy_is_file_exist("%s%s", isodisk, value);
}
else
{
exist = ventoy_is_file_exist("%s/ventoy/%s", isodisk, value);
}
if (exist == 0)
{
grub_printf("Theme file %s does NOT exist\n", value);
return 1;
}
}
value = vtoy_json_get_string_ex(json->pstChild, "random");
if (value)
{
grub_printf("random: %s\n", value);
}
}
}
value = vtoy_json_get_string_ex(json->pstChild, "gfxmode");
if (value)
@ -244,8 +281,10 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
{
const char *value;
char filepath[256];
VTOY_JSON *node;
VTOY_JSON *node = NULL;
theme_list *tail = NULL;
theme_list *themenode = NULL;
value = vtoy_json_get_string_ex(json->pstChild, "file");
if (value)
{
@ -258,7 +297,7 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
grub_snprintf(filepath, sizeof(filepath), "%s/ventoy/%s", isodisk, value);
}
if (ventoy_is_file_exist(filepath) == 0)
if (ventoy_check_file_exist(filepath) == 0)
{
debug("Theme file %s does not exist\n", filepath);
return 0;
@ -266,6 +305,65 @@ static int ventoy_plugin_theme_entry(VTOY_JSON *json, const char *isodisk)
debug("vtoy_theme %s\n", filepath);
grub_env_set("vtoy_theme", filepath);
grub_snprintf(g_theme_single_file, sizeof(g_theme_single_file), "%s", filepath);
}
else
{
node = vtoy_json_find_item(json->pstChild, JSON_TYPE_ARRAY, "file");
if (node)
{
for (node = node->pstChild; node; node = node->pstNext)
{
value = node->unData.pcStrVal;
if (value[0] == '/')
{
grub_snprintf(filepath, sizeof(filepath), "%s%s", isodisk, value);
}
else
{
grub_snprintf(filepath, sizeof(filepath), "%s/ventoy/%s", isodisk, value);
}
if (ventoy_check_file_exist(filepath) == 0)
{
continue;
}
themenode = grub_zalloc(sizeof(theme_list));
if (themenode)
{
grub_snprintf(themenode->theme.path, sizeof(themenode->theme.path), "%s", filepath);
if (g_theme_head)
{
tail->next = themenode;
}
else
{
g_theme_head = themenode;
}
tail = themenode;
g_theme_num++;
}
}
grub_env_set("vtoy_theme", "random");
value = vtoy_json_get_string_ex(json->pstChild, "random");
if (value)
{
if (grub_strcmp(value, "boot_second") == 0)
{
g_theme_random = vtoy_theme_random_boot_second;
}
else if (grub_strcmp(value, "boot_day") == 0)
{
g_theme_random = vtoy_theme_random_boot_day;
}
else if (grub_strcmp(value, "boot_month") == 0)
{
g_theme_random = vtoy_theme_random_boot_month;
}
}
}
}
value = vtoy_json_get_string_ex(json->pstChild, "gfxmode");
@ -2816,3 +2914,62 @@ end:
return 0;
}
grub_err_t ventoy_cmd_set_theme(grub_extcmd_context_t ctxt, int argc, char **args)
{
grub_uint32_t i = 0;
grub_uint32_t mod = 0;
theme_list *node = g_theme_head;
struct grub_datetime datetime;
(void)argc;
(void)args;
(void)ctxt;
if (g_theme_single_file[0])
{
debug("single theme %s\n", g_theme_single_file);
grub_env_set("theme", g_theme_single_file);
goto end;
}
debug("g_theme_num = %d\n", g_theme_num);
if (g_theme_num == 0)
{
goto end;
}
grub_memset(&datetime, 0, sizeof(datetime));
grub_get_datetime(&datetime);
if (g_theme_random == vtoy_theme_random_boot_second)
{
grub_divmod32((grub_uint32_t)datetime.second, (grub_uint32_t)g_theme_num, &mod);
}
else if (g_theme_random == vtoy_theme_random_boot_day)
{
grub_divmod32((grub_uint32_t)datetime.day, (grub_uint32_t)g_theme_num, &mod);
}
else if (g_theme_random == vtoy_theme_random_boot_month)
{
grub_divmod32((grub_uint32_t)datetime.month, (grub_uint32_t)g_theme_num, &mod);
}
debug("%04d/%02d/%02d %02d:%02d:%02d radom:%d mod:%d\n",
datetime.year, datetime.month, datetime.day,
datetime.hour, datetime.minute, datetime.second,
g_theme_random, mod);
for (i = 0; i < mod && node; i++)
{
node = node->next;
}
debug("random theme %s\n", node->theme.path);
grub_env_set("theme", node->theme.path);
end:
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}

View File

@ -0,0 +1,97 @@
#!/bin/sh
print_usage() {
echo 'Usage: ExtendPersistentImg.sh file size'
echo ' file persistent dat file'
echo ' size extend size in MB'
echo 'Example:'
echo ' sh ExtendPersistentImg.sh ubuntu.dat 2048'
echo ''
}
if [ -z "$1" -o "$1" = "-h" ]; then
print_usage
exit 1
fi
if [ -z "$2" ]; then
print_usage
exit 1
fi
file=$1
size=$2
if [ ! -f "$file" ]; then
echo "$file not exist."
exit 1
fi
if echo $size | grep -q "[^0-9]"; then
print_usage
exit 1
fi
fsize=$(stat -c '%s' $file)
fsmod=$(expr $fsize % 1024)
if [ $fsmod -ne 0 ]; then
echo "File size of $file is not aligned by 1MB, please check."
exit 1
fi
fsMB=$(expr $fsize / 1024 / 1024)
total=$(expr $fsMB + $size)
magic=$(hexdump -n3 -e '3/1 "%02X"' $file)
if [ "$magic" = "584653" ]; then
if which xfs_growfs >/dev/null 2>&1; then
cmd=xfs_growfs
else
echo 'xfs_growfs not found, please install xfsprogs first'
exit 1
fi
else
if which resize2fs >/dev/null 2>&1; then
cmd=resize2fs
else
echo 'resize2fs not found, please install e2fsprogs first'
exit 1
fi
fi
echo "Extend dat file... (current is ${fsMB}MB, append ${size}MB, total ${total}MB)"
dd if=/dev/zero bs=1M count=$size status=none >> "$file"
sync
freeloop=$(losetup -f)
losetup $freeloop "$file"
if [ "$cmd" = "resize2fs" ]; then
echo "Extend ext filesystem by resize2fs ..."
echo "resize2fs $freeloop ${total}M"
e2fsck -f $freeloop
resize2fs $freeloop ${total}M
ret=$?
else
echo "Extend xfs filesystem by xfs_growfs ..."
tmpdir=$(mktemp -d)
mount $freeloop $tmpdir
xfs_growfs $freeloop
ret=$?
umount $tmpdir && rm -rf $tmpdir
fi
losetup -d $freeloop
echo ""
if [ $ret -eq 0 ]; then
echo "======= SUCCESS ========="
else
echo "======= FAILED ========="
fi
echo ""

View File

@ -38,5 +38,12 @@ Please refer https://www.ventoy.net/en/plugin_persistence.html for details.
========== ExtendPersistentImg.sh ===============
sudo sh ExtendPersistentImg.sh file size
For example:
sh ExtendPersistentImg.sh persistence.dat 2048 ----> Extend persistence.dat by 2048MB
That is to say, persistence.dat file will grow to 3GB size (assume that it is 1GB size before extend)
Please refer https://www.ventoy.net/en/plugin_persistence.html for details.

View File

@ -68,7 +68,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
search_fs_uuid:
gcry_dsa: pgp mpi
keystatus: extcmd
linux: verifiers boot fdt
linux: ventoy verifiers boot fdt
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
cmdline_cat_test: font functional_test normal procfs video_fb
part_sun:
@ -93,7 +93,7 @@ terminal:
div:
crypto:
part_bsd: part_msdos
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd datetime div normal video gcry_sha1 iso9660
gcry_sha512: crypto
password: crypto normal
fshelp:

View File

@ -1796,7 +1796,7 @@ function img_unsupport_menuentry {
#############################################################
#############################################################
set VENTOY_VERSION="1.0.44"
set VENTOY_VERSION="1.0.45"
#ACPI not compatible with Window7/8, so disable by default
set VTOY_PARAM_NO_ACPI=1
@ -1932,7 +1932,7 @@ elif [ "$vtoy_display_mode" = "serial_console" ]; then
terminal_output serial console
else
if [ -n "$vtoy_theme" ]; then
set theme=$vtoy_theme
vt_set_theme
else
set theme=$prefix/themes/ventoy/theme.txt
fi

View File

@ -82,7 +82,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
search_fs_uuid:
gcry_dsa: pgp mpi
keystatus: extcmd
linux: verifiers video boot relocator mmap
linux: ventoy verifiers video boot relocator mmap
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
cmdline_cat_test: font functional_test normal procfs video_fb
rdmsr: extcmd
@ -120,7 +120,7 @@ ehci: cs5536 usb boot
crypto:
part_bsd: part_msdos
cs5536:
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd datetime div normal video gcry_sha1 iso9660
gcry_sha512: crypto
password: crypto normal
fshelp:

View File

@ -82,7 +82,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
search_fs_uuid:
gcry_dsa: pgp mpi
keystatus: extcmd
linux: verifiers normal vbe video boot relocator mmap
linux: ventoy verifiers normal vbe video boot relocator mmap
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
cmdline_cat_test: font functional_test normal procfs video_fb
rdmsr: extcmd
@ -123,7 +123,7 @@ crypto:
part_bsd: part_msdos
cs5536: pci
biosdisk:
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660 acpi
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf datetime div extcmd normal video gcry_sha1 iso9660 acpi
lsapm:
gcry_sha512: crypto
password: crypto normal

Binary file not shown.

View File

@ -81,7 +81,7 @@ gfxterm_background: video_colors bitmap_scale gfxterm extcmd video bitmap
search_fs_uuid:
gcry_dsa: pgp mpi
keystatus: extcmd
linux: verifiers video boot relocator mmap
linux: ventoy verifiers video boot relocator mmap
geli: cryptodisk crypto gcry_sha512 pbkdf2 gcry_sha256
cmdline_cat_test: font functional_test normal procfs video_fb
rdmsr: extcmd
@ -120,7 +120,7 @@ ehci: cs5536 usb boot
crypto:
part_bsd: part_msdos
cs5536:
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd normal video gcry_sha1 iso9660
ventoy: elf fshelp ext2 btrfs font crypto gcry_md5 exfat udf extcmd datetime div normal video gcry_sha1 iso9660
gcry_sha512: crypto
password: crypto normal
fshelp:

View File

@ -70,6 +70,22 @@ terminal-box: "terminal_box_*.png"
}
+ hbox{
left = 30%+200
top = 95%-50
width = 10%
height = 25
+ label {text = "@VTOY_GRUB2_MODE@" color = "red" align = "left"}
}
+ hbox{
left = 30%+200
top = 95%-25
width = 10%
height = 25
+ label {text = "@VTOY_WIMBOOT_MODE@" color = "red" align = "left"}
}
+ hbox{
left = 90%
top = 55

View File

@ -106,11 +106,13 @@ cp $OPT VentoyWebDeepin.sh $tmpdir/
cp $OPT README $tmpdir/
cp $OPT plugin $tmpdir/
cp $OPT CreatePersistentImg.sh $tmpdir/
cp $OPT ExtendPersistentImg.sh $tmpdir/
dos2unix -q $tmpdir/Ventoy2Disk.sh
dos2unix -q $tmpdir/VentoyWeb.sh
dos2unix -q $tmpdir/VentoyWebDeepin.sh
#dos2unix -q $tmpdir/Ventoy.desktop
dos2unix -q $tmpdir/CreatePersistentImg.sh
dos2unix -q $tmpdir/ExtendPersistentImg.sh
cp $OPT ../LinuxGUI/WebUI $tmpdir/
sed 's/.*SCRIPT_DEL_THIS \(.*\)/\1/g' -i $tmpdir/WebUI/index.html