]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Add new iso support
authorlongpanda <admin@ventoy.net>
Sat, 18 Jul 2020 14:06:59 +0000 (22:06 +0800)
committerlongpanda <admin@ventoy.net>
Sat, 18 Jul 2020 14:07:06 +0000 (22:07 +0800)
19 files changed:
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.c
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/Ventoy.h
EDK2/edk2_mod/edk2-edk2-stable201911/MdeModulePkg/Application/Ventoy/VentoyProtocol.c
GRUB2/MOD_SRC/grub-2.04/grub-core/ventoy/ventoy.c
IMG/cpio/ventoy/hook/cdlinux/ventoy-hook.sh
IMG/cpio/ventoy/hook/cucumber/disk-hook.sh [new file with mode: 0644]
IMG/cpio/ventoy/hook/cucumber/ventoy-hook.sh [new file with mode: 0644]
IMG/cpio/ventoy/hook/fatdog/disk-hook.sh [new file with mode: 0644]
IMG/cpio/ventoy/hook/fatdog/ventoy-hook.sh [new file with mode: 0644]
IMG/cpio/ventoy/hook/kwort/disk-hook.sh [new file with mode: 0644]
IMG/cpio/ventoy/hook/kwort/ventoy-hook.sh [new file with mode: 0644]
IMG/cpio/ventoy/hook/parabola/ventoy-disk.sh [new file with mode: 0644]
IMG/cpio/ventoy/hook/parabola/ventoy-hook.sh [new file with mode: 0644]
IMG/cpio/ventoy/hook/parabola/ventoy-timeout.sh [new file with mode: 0644]
IMG/cpio/ventoy/hook/rhel7/ventoy-hook.sh
IMG/cpio/ventoy/hook/rhel7/ventoy-make-link.sh [new file with mode: 0644]
IMG/cpio/ventoy/ventoy.sh
INSTALL/grub/grub.cfg
INSTALL/ventoy_pack.sh

index 968049afa72e0cae5f2f39d56154a2faa6c2c699..2eeaa7a29589f0987fb17d04f2ac2e0180f40ee2 100644 (file)
@@ -37,6 +37,7 @@
 #include <Ventoy.h>
 
 BOOLEAN gDebugPrint = FALSE;
+BOOLEAN gLoadIsoEfi = FALSE;
 ventoy_ram_disk g_ramdisk_param;
 ventoy_chain_head *g_chain;
 ventoy_img_chunk *g_chunk;
@@ -52,6 +53,8 @@ static grub_env_get_pf grub_env_get = NULL;
 ventoy_grub_param_file_replace *g_file_replace_list = NULL;
 ventoy_efi_file_replace g_efi_file_replace;
 
+CONST CHAR16 gIso9660EfiDriverPath[] = ISO9660_EFI_DRIVER_PATH;
+
 BOOLEAN g_fix_windows_1st_cdrom_issue = FALSE;
 
 STATIC BOOLEAN g_hook_keyboard = FALSE;
@@ -67,7 +70,7 @@ CONST CHAR16 *gEfiBootFileName[] =
     L"\\EFI\\BOOT\\GRUBX64.EFI",
     L"\\EFI\\BOOT\\BOOTx64.EFI",
     L"\\EFI\\BOOT\\bootx64.efi",
-    L"\\efi\\boot\\bootx64.efi",
+    L"\\efi\\boot\\bootx64.efi"
 };
 
 VOID EFIAPI VtoyDebug(IN CONST CHAR8  *Format, ...)
@@ -484,6 +487,93 @@ STATIC EFI_STATUS EFIAPI ventoy_find_iso_disk(IN EFI_HANDLE ImageHandle)
     }
 }
 
+
+STATIC EFI_STATUS EFIAPI ventoy_find_iso_disk_fs(IN EFI_HANDLE ImageHandle)
+{
+    UINTN i = 0;
+    UINTN Count = 0;
+    EFI_HANDLE Parent = NULL;
+    EFI_HANDLE *Handles = NULL;
+    EFI_STATUS Status = EFI_SUCCESS;
+    EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *pFile = NULL;
+    EFI_DEVICE_PATH_PROTOCOL *pDevPath = NULL;
+
+    Status = gBS->LocateHandleBuffer(ByProtocol, &gEfiSimpleFileSystemProtocolGuid, 
+                                     NULL, &Count, &Handles);
+    if (EFI_ERROR(Status))
+    {
+        return Status;
+    }
+
+    debug("ventoy_find_iso_disk_fs fs count:%u", Count);
+
+    for (i = 0; i < Count; i++)
+    {
+        Status = gBS->HandleProtocol(Handles[i], &gEfiSimpleFileSystemProtocolGuid, (VOID **)&pFile);
+        if (EFI_ERROR(Status))
+        {
+            continue;
+        }
+
+        Status = gBS->OpenProtocol(Handles[i], &gEfiDevicePathProtocolGuid, 
+                                   (VOID **)&pDevPath,
+                                   ImageHandle,
+                                   Handles[i],
+                                   EFI_OPEN_PROTOCOL_GET_PROTOCOL);
+        if (EFI_ERROR(Status))
+        {
+            debug("Failed to open device path protocol %r", Status);
+            continue;
+        }
+
+        debug("Handle:%p FS DP: <%s>", Handles[i], ConvertDevicePathToText(pDevPath, FALSE, FALSE));
+        Parent = ventoy_get_parent_handle(pDevPath);
+
+        if (Parent == gBlockData.RawBlockIoHandle)
+        {
+            debug("Find ventoy disk fs");
+            gBlockData.DiskFsHandle = Handles[i];
+            gBlockData.pDiskFs = pFile;
+            gBlockData.pDiskFsDevPath = pDevPath;
+            break;
+        }
+    }
+
+    FreePool(Handles);
+
+    return EFI_SUCCESS;
+}
+
+STATIC EFI_STATUS EFIAPI ventoy_load_isoefi_driver(IN EFI_HANDLE ImageHandle)
+{
+    EFI_HANDLE Image = NULL;
+    EFI_STATUS Status = EFI_SUCCESS;
+    CHAR16 LogVar[4] = L"5";
+            
+    Status = ventoy_load_image(ImageHandle, gBlockData.pDiskFsDevPath, 
+                               gIso9660EfiDriverPath, 
+                               sizeof(gIso9660EfiDriverPath), 
+                               &Image);
+    debug("load iso efi driver status:%r", Status);
+
+    if (gDebugPrint)
+    {
+        gRT->SetVariable(L"FS_LOGGING", &gShellVariableGuid, 
+                         EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+                         sizeof(LogVar), LogVar);
+    }
+
+    gRT->SetVariable(L"FS_NAME_NOCASE", &gShellVariableGuid, 
+                     EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+                     sizeof(LogVar), LogVar);
+
+    gBlockData.IsoDriverImage = Image;
+    Status = gBS->StartImage(Image, NULL, NULL);
+    debug("Start iso efi driver status:%r", Status);
+
+    return EFI_SUCCESS;
+}
+
 STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
 {   
     UINT32 i = 0;
@@ -513,6 +603,11 @@ STATIC EFI_STATUS EFIAPI ventoy_parse_cmdline(IN EFI_HANDLE ImageHandle)
         gDebugPrint = TRUE;
     }
 
+    if (StrStr(pCmdLine, L"isoefi=on"))
+    {
+        gLoadIsoEfi = TRUE;
+    }
+
     pPos = StrStr(pCmdLine, L"FirstTry=@");
     if (pPos)
     {
@@ -639,6 +734,11 @@ EFI_STATUS EFIAPI ventoy_clean_env(VOID)
     FreePool(g_sector_flag);
     g_sector_flag_num = 0;
 
+    if (gLoadIsoEfi && gBlockData.IsoDriverImage)
+    {
+        gBS->UnloadImage(gBlockData.IsoDriverImage);
+    }
+
     gBS->DisconnectController(gBlockData.Handle, NULL, NULL);
 
     gBS->UninstallMultipleProtocolInterfaces(gBlockData.Handle,
@@ -857,6 +957,12 @@ EFI_STATUS EFIAPI VentoyEfiMain
         ventoy_save_variable();
         ventoy_find_iso_disk(ImageHandle);
 
+        if (gLoadIsoEfi)
+        {
+            ventoy_find_iso_disk_fs(ImageHandle);
+            ventoy_load_isoefi_driver(ImageHandle);
+        }
+
         ventoy_debug_pause();
         
         ventoy_install_blockio(ImageHandle, g_chain->virt_img_size_in_bytes);
index 1056f8cc6a648a05a3bfdf598999a106e0db146a..2e2ab031738116329c7b8378b37be92caa3d5e4c 100644 (file)
@@ -168,6 +168,8 @@ typedef struct ventoy_virt_chunk
 #define VTOY_BLOCK_DEVICE_PATH_GUID                                    \
        { 0x37b87ac6, 0xc180, 0x4583, { 0xa7, 0x05, 0x41, 0x4d, 0xa8, 0xf7, 0x7e, 0xd2 }}
 
+#define ISO9660_EFI_DRIVER_PATH  L"\\ventoy\\iso9660_x64.efi"
+
 #define VTOY_BLOCK_DEVICE_PATH_NAME  L"ventoy"
 
 #if   defined (MDE_CPU_IA32)
@@ -208,6 +210,7 @@ typedef struct vtoy_block_data
     EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *pDiskFs;
     EFI_DEVICE_PATH_PROTOCOL *pDiskFsDevPath;
 
+    EFI_HANDLE IsoDriverImage;
 }vtoy_block_data;
 
 
index ed595b9f1c7b635bdcc67e281dbd3bdc5ba1584d..004c83f9f8d374345b1fc808ee1221c49b791a58 100644 (file)
@@ -699,8 +699,16 @@ STATIC EFI_STATUS EFIAPI
 ventoy_wrapper_file_set_pos(EFI_FILE_HANDLE This, UINT64 Position)
 {
     (VOID)This;
+        
+    if (Position <= g_efi_file_replace.FileSizeBytes)
+    {
+        g_efi_file_replace.CurPos = Position;
+    }
+    else
+    {
+        g_efi_file_replace.CurPos = g_efi_file_replace.FileSizeBytes;
+    }
     
-    g_efi_file_replace.CurPos = Position;
     return EFI_SUCCESS;
 }
 
@@ -815,6 +823,8 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
     CHAR8 TmpName[256];
     ventoy_virt_chunk *virt = NULL;
 
+    debug("## ventoy_wrapper_file_open <%s> ", Name);
+
     Status = g_original_fopen(This, New, Name, Mode, Attributes);
     if (EFI_ERROR(Status))
     {
@@ -850,6 +860,11 @@ STATIC EFI_STATUS EFIAPI ventoy_wrapper_file_open
                 return Status;
             }
         }
+
+        if (StrCmp(Name, L"\\EFI\\BOOT") == 0)
+        {
+            (*New)->Open = ventoy_wrapper_file_open;
+        }
     }
 
     return Status;
index 708d4c1516b1a15acbd4bdb6aff788bfdcb78aac..2975bb2a2e96a251c4b7c3e72d2f35903dcc9e0b 100644 (file)
@@ -1459,6 +1459,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)
 {
     int i;
+    int x86count = 0;
     grub_uint8_t buf[512];
 
     grub_file_seek(file, sector * 2048);
@@ -1470,6 +1471,11 @@ int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector)
         return 1;
     }
 
+    if (buf[0] == 0x01 && buf[1] == 0x00)
+    {
+        x86count++;
+    }
+
     for (i = 64; i < (int)sizeof(buf); i += 32)
     {
         if ((buf[i] == 0x90 || buf[i] == 0x91) && buf[i + 1] == 0xEF)
@@ -1477,6 +1483,12 @@ int ventoy_has_efi_eltorito(grub_file_t file, grub_uint32_t sector)
             debug("%s efi eltorito offset %d 0x%02x\n", file->name, i, buf[i]);
             return 1;
         }
+
+        if (buf[i] == 0x91 && buf[i + 1] == 0x00 && x86count == 1)
+        {
+            debug("0x9100 assume %s efi eltorito offset %d 0x%02x\n", file->name, i, buf[i]);
+            return 1;
+        }
     }
 
     debug("%s does not contain efi eltorito\n", file->name);
index 32c0b09396b8f4109908d40a01caf785290d8b40..41ac545a3c0312a4b15943ef14a3e6960ae0a074 100644 (file)
@@ -36,8 +36,8 @@ done
 $BUSYBOX_PATH/umount /vtmnt && $BUSYBOX_PATH/rm -rf /vtmnt
 $BUSYBOX_PATH/cp -a /ventoy /ventoy_rdroot
 
-echo "CDL_DEV=/dev/mapper/ventoy" >> /ventoy_rdroot/etc/default/cdlinux
+echo 'echo "CDL_DEV=/dev/mapper/ventoy" >>"$VAR_FILE"' >> /ventoy_rdroot/etc/rc.d/rc.var
 
 ventoy_set_rule_dir_prefix /ventoy_rdroot
 ventoy_systemd_udevd_work_around
-ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
+ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace"
diff --git a/IMG/cpio/ventoy/hook/cucumber/disk-hook.sh b/IMG/cpio/ventoy/hook/cucumber/disk-hook.sh
new file mode 100644 (file)
index 0000000..a5b7b95
--- /dev/null
@@ -0,0 +1,52 @@
+#!/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"
+
+blkdev_num=$(dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
+vtDM=$(ventoy_find_dm_id ${blkdev_num})
+
+vtlog "mount media /dev/$vtDM ..."
+if ! [ -e /media/install ]; then
+    mkdir -p /media/install
+fi
+mount /dev/$vtDM /media/install
+
+PATH=$VTPATH_OLD
+
+set_ventoy_hook_finish
diff --git a/IMG/cpio/ventoy/hook/cucumber/ventoy-hook.sh b/IMG/cpio/ventoy/hook/cucumber/ventoy-hook.sh
new file mode 100644 (file)
index 0000000..4f0363c
--- /dev/null
@@ -0,0 +1,26 @@
+#!/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
+
+if [ -e /sbin/mount_installer ]; then
+    echo "hook at mount_installer ..." >> $VTLOG
+    $SED "1 a $BUSYBOX_PATH/sh $VTOY_PATH/hook/cucumber/disk-hook.sh" -i /sbin/mount_installer
+fi
+
diff --git a/IMG/cpio/ventoy/hook/fatdog/disk-hook.sh b/IMG/cpio/ventoy/hook/fatdog/disk-hook.sh
new file mode 100644 (file)
index 0000000..8ee0579
--- /dev/null
@@ -0,0 +1,43 @@
+#!/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"
+
+PATH=$VTPATH_OLD
+
+set_ventoy_hook_finish
diff --git a/IMG/cpio/ventoy/hook/fatdog/ventoy-hook.sh b/IMG/cpio/ventoy/hook/fatdog/ventoy-hook.sh
new file mode 100644 (file)
index 0000000..8b16432
--- /dev/null
@@ -0,0 +1,23 @@
+#!/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 "/find_local_device *(/a $BUSYBOX_PATH/sh $VTOY_PATH/hook/fatdog/disk-hook.sh" -i /init
+$SED "/find_and_choose_local_device *(/a $BUSYBOX_PATH/sh $VTOY_PATH/hook/fatdog/disk-hook.sh" -i /init
diff --git a/IMG/cpio/ventoy/hook/kwort/disk-hook.sh b/IMG/cpio/ventoy/hook/kwort/disk-hook.sh
new file mode 100644 (file)
index 0000000..8ee0579
--- /dev/null
@@ -0,0 +1,43 @@
+#!/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"
+
+PATH=$VTPATH_OLD
+
+set_ventoy_hook_finish
diff --git a/IMG/cpio/ventoy/hook/kwort/ventoy-hook.sh b/IMG/cpio/ventoy/hook/kwort/ventoy-hook.sh
new file mode 100644 (file)
index 0000000..78f5615
--- /dev/null
@@ -0,0 +1,22 @@
+#!/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 "1 a $BUSYBOX_PATH/sh $VTOY_PATH/hook/kwort/disk-hook.sh" -i /etc/rc.d/init/media
diff --git a/IMG/cpio/ventoy/hook/parabola/ventoy-disk.sh b/IMG/cpio/ventoy/hook/parabola/ventoy-disk.sh
new file mode 100644 (file)
index 0000000..356c77f
--- /dev/null
@@ -0,0 +1,48 @@
+#!/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
+
+vtlog "######### $0 $* ############"
+
+if is_ventoy_hook_finished; then
+    exit 0
+fi
+
+wait_for_usb_disk_ready
+
+vtdiskname=$(get_ventoy_disk_name)
+if [ "$vtdiskname" = "unknown" ]; then
+    vtlog "ventoy disk not found"
+    exit 0
+fi
+
+ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
+
+if [ -n "$1" ]; then
+    blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
+    vtDM=$(ventoy_find_dm_id ${blkdev_num})
+    
+    vtlog "ln -s /dev/$vtDM $1"
+    ln -s /dev/$vtDM "$1"
+fi 
+
+# OK finish
+set_ventoy_hook_finish
+
diff --git a/IMG/cpio/ventoy/hook/parabola/ventoy-hook.sh b/IMG/cpio/ventoy/hook/parabola/ventoy-hook.sh
new file mode 100644 (file)
index 0000000..b8b3a5d
--- /dev/null
@@ -0,0 +1,44 @@
+#!/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
+
+if $GREP -q '^"$mount_handler"' /init; then
+    echo 'use mount_handler ...' >> $VTLOG
+    $SED "/^\"\$mount_handler\"/i\ $BUSYBOX_PATH/sh $VTOY_PATH/hook/parabola/ventoy-disk.sh \"\$parabolaisodevice\"" -i /init
+    
+    if [ -f /hooks/parabolaiso ]; then
+        $SED  '/while ! poll_device "${dev}"/a\    if /ventoy/busybox/sh /ventoy/hook/parabola/ventoy-timeout.sh ${dev}; then break; fi'   -i /hooks/parabolaiso
+    fi
+    
+else
+    # some archlinux initramfs doesn't contain device-mapper udev rules file
+    ARCH_UDEV_DIR=$(ventoy_get_udev_conf_dir)
+    if [ -s "$ARCH_UDEV_DIR/13-dm-disk.rules" ]; then
+        echo 'dm-disk rule exist' >> $VTLOG
+    else
+        echo 'Copy dm-disk rule file' >> $VTLOG
+        $CAT $VTOY_PATH/hook/default/13-dm-disk.rules > "$ARCH_UDEV_DIR/13-dm-disk.rules"
+    fi
+
+    # use default proc
+    ventoy_systemd_udevd_work_around
+
+    ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
+fi
diff --git a/IMG/cpio/ventoy/hook/parabola/ventoy-timeout.sh b/IMG/cpio/ventoy/hook/parabola/ventoy-timeout.sh
new file mode 100644 (file)
index 0000000..fec9cc0
--- /dev/null
@@ -0,0 +1,36 @@
+#!/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
+
+vtlog "######### $0 $* ############"
+
+blkdev_num=$($VTOY_PATH/tool/dmsetup ls | grep ventoy | sed 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1:\2/')
+vtDM=$(ventoy_find_dm_id ${blkdev_num})
+
+if [ -b /dev/$vtDM ]; then
+    vtlog "ln -s /dev/$vtDM $1"
+    ln -s /dev/$vtDM "$1"
+    exit 0
+else
+    vtlog "Device-mapper not found"
+    exit 1
+fi
+
+
index 1bb6a6b18071028549078a248bd07deb4e4eed1d..ed53f4cad656f541d2ecf3eb6a1b51beae7b7806 100644 (file)
@@ -60,6 +60,11 @@ fi
 $BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/${vtPriority}-ventoy-inotifyd-start.sh
 $BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-timeout.sh /lib/dracut/hooks/initqueue/timeout/${vtPriority}-ventoy-timeout.sh
 
+if [ -e /sbin/dmsquash-live-root ]; then
+    echo "patch /sbin/dmsquash-live-root ..." >> $VTLOG
+    $SED "1 a $BUSYBOX_PATH/sh $VTOY_PATH/hook/rhel7/ventoy-make-link.sh" -i /sbin/dmsquash-live-root
+fi
+
 # suppress write protected mount warning
 if [ -e /usr/sbin/anaconda-diskroot ]; then
     $SED  's/^mount $dev $repodir/mount -oro $dev $repodir/' -i /usr/sbin/anaconda-diskroot
diff --git a/IMG/cpio/ventoy/hook/rhel7/ventoy-make-link.sh b/IMG/cpio/ventoy/hook/rhel7/ventoy-make-link.sh
new file mode 100644 (file)
index 0000000..22a3dd4
--- /dev/null
@@ -0,0 +1,35 @@
+#!/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 ! [ -e /dev/mapper/ventoy ]; then
+    vtlog "link to /dev/mapper/ventoy"
+    ln -s /dev/dm-0 /dev/mapper/ventoy
+fi
+
+VTLABEL=$($BUSYBOX_PATH/blkid /dev/dm-0 | $SED 's/.*LABEL="\([^"]*\)".*/\1/')
+vtlog "VTLABEL=$VTLABEL"
+
+if [ -n "$VTLABEL" ]; then
+    if ! [ -e "/dev/disk/by-label/$VTLABEL" ]; then
+        vtlog "link to /dev/disk/by-label/$VTLABEL"
+        ln -s /dev/dm-0 "/dev/disk/by-label/$VTLABEL"
+    fi
+fi
index 42efb2ec1c13dcdd4ff56850275159763f2a64c1..7242021afb1868367391ef8c5ba5e19326be6ddf 100644 (file)
@@ -133,8 +133,9 @@ ventoy_get_os_type() {
         if $GREP -q 'XenServer' /etc/os-release; then
             echo 'xen'; return
         elif $GREP -q 'SUSE ' /etc/os-release; then
-            echo 'suse'; return
-       
+            echo 'suse'; return        
+        elif $GREP -q 'uruk' /etc/os-release; then
+            echo 'debian'; return
         fi
     fi
     
@@ -204,6 +205,23 @@ ventoy_get_os_type() {
         echo 'cdlinux'; return
     fi
     
+    if $GREP -q 'parabola' /proc/version; then
+        echo 'parabola'; return
+    fi
+    
+    if $GREP -q 'cucumber' /proc/version; then
+        echo 'cucumber'; return
+    fi
+    
+    if $GREP -q 'fatdog' /proc/version; then
+        echo 'fatdog'; return
+    fi
+    
+    if $GREP -q 'KWORT' /proc/version; then
+        echo 'kwort'; return
+    fi
+    
+    
     echo "default"
 }
 
index c78473933a132acec0d857ca1a038e02d788f1a1..80279bd32f651d661e3c721ccf90e374ec8878f2 100644 (file)
@@ -180,7 +180,22 @@ function distro_specify_initrd_file_phase2 {
         vt_linux_specify_initrd_file /sysresccd/boot/x86_64/sysresccd.img
     elif [ -f (loop)/CDlinux/initrd ]; then 
         vt_linux_specify_initrd_file /CDlinux/initrd
-    
+    elif [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then 
+        vt_linux_specify_initrd_file /parabola/boot/x86_64/parabolaiso.img
+        if [ -f (loop)/parabola/boot/i686/parabolaiso.img ]; then 
+            vt_linux_specify_initrd_file /parabola/boot/i686/parabolaiso.img
+        fi
+    elif [ -f (loop)/EFI/BOOT/initrd.img ]; then 
+        #Qubes
+        vt_linux_specify_initrd_file /EFI/BOOT/initrd.img
+        if [ "$grub_platform" != "pc" ]; then
+            vt_add_replace_file 0 "initrd.img"    
+        fi
+    elif [ -f (loop)/initrd ]; then 
+        vt_linux_specify_initrd_file /initrd
+    elif [ -f (loop)/live/initrd1 ]; then 
+        vt_linux_specify_initrd_file /live/initrd1
+        
     fi
 }
 
@@ -278,6 +293,10 @@ function uefi_linux_menu_func {
             elif [ -f (loop)/EFI/BOOT/initrd.gz ]; then
                 vt_add_replace_file $vtindex "EFI\\BOOT\\initrd.gz"
             fi
+        elif [ -d (loop)/EFI/boot/entries ]; then
+            if [ -f (loop)/parabola/boot/x86_64/parabolaiso.img ]; then
+                vt_add_replace_file 0 "EFI\\parabolaiso\\parabolaiso.img"
+            fi
         elif [ -e (loop)/syslinux/alt0/full.cz ]; then
             vt_add_replace_file 0 "EFI\\BOOT\\full.cz"            
             set FirstTryBootFile='@EFI@BOOT@grubx64.efi'
index 9f21bbfab4f539c32b0f440b12b620e17ec56788..988d4e13d2ec972f4ebf25207b9d42421a5b0b30 100644 (file)
@@ -77,6 +77,7 @@ dd if=$LOOP of=$tmpdir/boot/core.img bs=512 count=2047 skip=1 status=none
 xz --check=crc32 $tmpdir/boot/core.img
 
 cp -a ./tool $tmpdir/
+rm -f $tmpdir/ENROLL_THIS_KEY_IN_MOKMANAGER.cer
 cp -a Ventoy2Disk.sh $tmpdir/
 cp -a CreatePersistentImg.sh $tmpdir/
 dos2unix -q $tmpdir/Ventoy2Disk.sh