Skip to content

Commit 4d7fcc2

Browse files
committed
Add support for AerynOS. (#3433)
1 parent 3597f15 commit 4d7fcc2

5 files changed

Lines changed: 53 additions & 2 deletions

File tree

GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_cmd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7039,6 +7039,7 @@ static cmd_para ventoy_cmds[] =
70397039
{ "vt_cmp_checksum", ventoy_cmd_cmp_checksum, 0, NULL, "", "", NULL },
70407040
{ "vt_push_menu_lang", ventoy_cmd_push_menulang, 0, NULL, "", "", NULL },
70417041
{ "vt_pop_menu_lang", ventoy_cmd_pop_menulang, 0, NULL, "", "", NULL },
7042+
{ "vt_linux_initrd", ventoy_cmd_linux_initrd, 0, NULL, "", "", NULL },
70427043

70437044
};
70447045

GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_def.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#define VTOY_SIZE_4MB (4 * 1024 * 1024)
3838
#define VTOY_SIZE_512KB (512 * 1024)
3939
#define VTOY_SIZE_1KB 1024
40+
#define VTOY_SIZE_4KB 4096
4041
#define VTOY_SIZE_32KB (32 * 1024)
4142
#define VTOY_SIZE_128KB (128 * 1024)
4243

@@ -662,6 +663,7 @@ grub_uint32_t ventoy_get_iso_boot_catlog(grub_file_t file);
662663
int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector);
663664
grub_err_t ventoy_cmd_linux_chain_data(grub_extcmd_context_t ctxt, int argc, char **args);
664665
grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args);
666+
grub_err_t ventoy_cmd_linux_initrd(grub_extcmd_context_t ctxt, int argc, char **args);
665667
grub_err_t ventoy_cmd_linux_limine_menu(grub_extcmd_context_t ctxt, int argc, char **args);
666668
grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc, char **args);
667669
grub_err_t ventoy_cmd_initrd_count(grub_extcmd_context_t ctxt, int argc, char **args);
@@ -1279,6 +1281,7 @@ typedef struct systemd_menu_ctx
12791281
{
12801282
char *dev;
12811283
char *buf;
1284+
const char *initrd_cmd;
12821285
int pos;
12831286
int len;
12841287
}systemd_menu_ctx;

GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy_linux.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,7 +1867,7 @@ static int ventoy_systemd_conf_hook(const char *filename, const struct grub_dirh
18671867
ctx->pos = oldpos;
18681868
goto out;
18691869
}
1870-
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Downloading kernel ...\"\n linux %s ", tag);
1870+
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Loading kernel ...\"\n linux %s ", tag);
18711871

18721872
/* kernel options */
18731873
grub_memcpy(filebuf, bkbuf, file->size);
@@ -1876,7 +1876,7 @@ static int ventoy_systemd_conf_hook(const char *filename, const struct grub_dirh
18761876

18771877

18781878
/* initrd xxx xxx xxx */
1879-
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Downloading initrd ...\"\n initrd ");
1879+
vtoy_len_ssprintf(ctx->buf, ctx->pos, ctx->len, " echo \"Loading initrd ...\"\n %s ", ctx->initrd_cmd);
18801880
grub_memcpy(filebuf, bkbuf, file->size);
18811881
tag = ventoy_systemd_conf_tag(filebuf, "initrd", 1);
18821882
while (tag)
@@ -1893,6 +1893,34 @@ static int ventoy_systemd_conf_hook(const char *filename, const struct grub_dirh
18931893
return 0;
18941894
}
18951895

1896+
grub_err_t ventoy_cmd_linux_initrd(grub_extcmd_context_t ctxt, int argc, char **args)
1897+
{
1898+
int i;
1899+
int pos = 0;
1900+
char *buf = NULL;
1901+
1902+
(void)ctxt;
1903+
1904+
buf = (char *)grub_malloc(VTOY_SIZE_4KB);
1905+
if (!buf)
1906+
{
1907+
return 1;
1908+
}
1909+
1910+
pos += grub_snprintf(buf + pos, VTOY_SIZE_4KB - pos, "initrd mem:%s:size:%s",
1911+
grub_env_get("ventoy_cpio_addr"), grub_env_get("ventoy_cpio_size"));
1912+
1913+
for (i = 0; i < argc; i++)
1914+
{
1915+
pos += grub_snprintf(buf + pos, VTOY_SIZE_4KB - pos, " newc:initrd%03d:%s", i + 1, args[i]);
1916+
}
1917+
1918+
grub_script_execute_sourcecode(buf);
1919+
grub_free(buf);
1920+
1921+
return 0;
1922+
}
1923+
18961924
grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, char **args)
18971925
{
18981926
static char *buf = NULL;
@@ -1936,6 +1964,7 @@ grub_err_t ventoy_cmd_linux_systemd_menu(grub_extcmd_context_t ctxt, int argc, c
19361964

19371965
ctx.dev = args[0];
19381966
ctx.buf = buf;
1967+
ctx.initrd_cmd = args[2] ? args[2] : "initrd";
19391968
ctx.pos = 0;
19401969
ctx.len = VTOY_LINUX_SYSTEMD_MENU_MAX_BUF;
19411970
fs->fs_dir(dev, "/loader/entries", ventoy_systemd_conf_hook, &ctx);

IMG/cpio/ventoy/ventoy_chain.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ ventoy_get_os_type() {
177177
echo 'deepin'; return
178178
elif $GREP -q 'chinauos' /etc/os-release; then
179179
echo 'deepin'; return
180+
elif $GREP -qi 'aerynos' /etc/os-release; then
181+
echo 'rhel7'; return
180182
fi
181183
fi
182184

INSTALL/grub/grub.cfg

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ function ventoy_acpi_param {
7070
fi
7171
}
7272

73+
function vt_vcfg_pre_proc {
74+
vt_img_sector "${vtoy_iso_part}${vt_chosen_path}"
75+
vt_load_cpio $vtoy_path "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
76+
vt_trailer_cpio $vtoy_iso_part "$vt_chosen_path"
77+
}
78+
7379
function ventoy_vcfg_proc {
7480
if vt_check_custom_boot "${1}" vt_vcfg; then
7581
set vtoy_chosen_path="${1}"
@@ -422,6 +428,16 @@ function distro_specify_initrd_file_phase2 {
422428
vt_linux_specify_initrd_file /initramfs-linux.img
423429
elif [ -f (loop)/boot/isolinux/initrd.gz ]; then
424430
vt_linux_specify_initrd_file /boot/isolinux/initrd.gz
431+
elif vt_str_begin "$vt_volume_id" "AERYNOS"; then
432+
vt_vcfg_pre_proc
433+
434+
loopback va "${vtoy_iso_part}${vt_chosen_path}"
435+
loopback vb (va)/EFI/Boot/efiboot.img
436+
437+
set root=(vb)
438+
vt_systemd_menu (vb) vt_sys_menu_mem vt_linux_initrd
439+
configfile "mem:${vt_sys_menu_mem_addr}:size:${vt_sys_menu_mem_size}"
440+
425441
fi
426442
}
427443

0 commit comments

Comments
 (0)