]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Support LibreELEC 11.0+ (#2281)
authorlongpanda <admin@ventoy.net>
Thu, 9 Mar 2023 15:59:12 +0000 (23:59 +0800)
committerlongpanda <admin@ventoy.net>
Thu, 9 Mar 2023 15:59:12 +0000 (23:59 +0800)
GRUB2/MOD_SRC/grub-2.04/grub-core/Makefile.core.def
GRUB2/MOD_SRC/grub-2.04/grub-core/fs/squash4.c
IMG/cpio/ventoy/loop/LibreELEC/ventoy-disk.sh
INSTALL/grub/grub.cfg

index 2853b8e573498be9b4a36820da7eb0b3b2e979c8..c76386f66af0a98da8daf1d9b0df55a9c5c10a93 100644 (file)
@@ -1533,7 +1533,7 @@ module = {
   name = squash4;
   common = fs/squash4.c;
   cflags = '$(CFLAGS_POSIX) -Wno-undef';
   name = squash4;
   common = fs/squash4.c;
   cflags = '$(CFLAGS_POSIX) -Wno-undef';
-  cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -I$(srcdir)/lib/minilzo -DMINILZO_HAVE_CONFIG_H';
+  cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -I$(srcdir)/lib/minilzo -I$(srcdir)/lib/zstd -DMINILZO_HAVE_CONFIG_H';
 };
 
 module = {
 };
 
 module = {
index afeea66818f599593d911cca1c4c15e3040127dc..5dbad6e1425788b8ab9e7589baf4412fd41f45b5 100644 (file)
@@ -27,6 +27,7 @@
 #include <grub/fshelp.h>
 #include <grub/deflate.h>
 #include <minilzo.h>
 #include <grub/fshelp.h>
 #include <grub/deflate.h>
 #include <minilzo.h>
+#include <zstd.h>
 
 #include "xz.h"
 #include "xz_stream.h"
 
 #include "xz.h"
 #include "xz_stream.h"
@@ -184,6 +185,7 @@ enum
     COMPRESSION_LZO = 3,
     COMPRESSION_XZ = 4,
     COMPRESSION_LZ4 = 5,
     COMPRESSION_LZO = 3,
     COMPRESSION_XZ = 4,
     COMPRESSION_LZ4 = 5,
+    COMPRESSION_ZSTD = 6,
   };
 
 
   };
 
 
@@ -398,6 +400,33 @@ static grub_ssize_t lz4_decompress_wrap(char *inbuf, grub_size_t insize, grub_of
   return len;
 }
 
   return len;
 }
 
+static grub_ssize_t zstd_decompress_wrap(char *inbuf, grub_size_t insize, grub_off_t off, 
+    char *outbuf, grub_size_t len, struct grub_squash_data *data)
+{
+  char *udata = NULL;
+  int usize = data->blksz;
+
+  if (off == 0)
+  {
+    ZSTD_decompress(outbuf, len, inbuf, insize);      
+  }
+  else
+  {
+    if (usize < 8192)
+      usize = 8192;
+
+    udata = grub_malloc (usize);
+    if (!udata)
+      return -1;
+  
+    ZSTD_decompress(udata, usize, inbuf, insize);      
+    grub_memcpy(outbuf, udata + off, len);
+    grub_free(udata);
+  }
+  
+  return len;
+}
+
 static struct grub_squash_data *
 squash_mount (grub_disk_t disk)
 {
 static struct grub_squash_data *
 squash_mount (grub_disk_t disk)
 {
@@ -447,6 +476,9 @@ squash_mount (grub_disk_t disk)
     case grub_cpu_to_le16_compile_time (COMPRESSION_LZ4):
       data->decompress = lz4_decompress_wrap;
       break;
     case grub_cpu_to_le16_compile_time (COMPRESSION_LZ4):
       data->decompress = lz4_decompress_wrap;
       break;
+    case grub_cpu_to_le16_compile_time (COMPRESSION_ZSTD):
+      data->decompress = zstd_decompress_wrap;
+      break;
     case grub_cpu_to_le16_compile_time (COMPRESSION_XZ):
       data->decompress = xz_decompress;
       data->xzbuf = grub_malloc (XZBUFSIZ);
     case grub_cpu_to_le16_compile_time (COMPRESSION_XZ):
       data->decompress = xz_decompress;
       data->xzbuf = grub_malloc (XZBUFSIZ);
index 027a4c64c80f600fe28e5de04079702ac1f62b14..8acbb36fc69f36c6b71350ecb490ac4473c7b525 100644 (file)
@@ -34,9 +34,12 @@ else
     vtBit=32
 fi
 
     vtBit=32
 fi
 
-xz -d $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko.xz
-insmod $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko
-
+if [ -f $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko.xz ]; then
+    xz -d $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko.xz
+    insmod $VTOY_PATH/vtloopex/dm-mod/$vtKerVer/$vtBit/dm-mod.ko
+elif [ -f $VTOY_PATH/modules/dm-mod.ko ]; then
+    insmod $VTOY_PATH/modules/dm-mod.ko
+fi
 
 wait_for_usb_disk_ready
 
 
 wait_for_usb_disk_ready
 
index 496959d5222b3fd241f76dd90eeef6d21fbcc504..8389ab1cbcd1e8657b013d3bccdfaf338a3ad8be 100644 (file)
@@ -1926,6 +1926,20 @@ function ventoy_img_openelec {
     loopback vtloopex $vtoy_efi_part/ventoy/vtloopex.cpio    
     vt_img_extra_initrd_append  (vtloopex)/$elec_ver/vtloopex.tar.xz
 
     loopback vtloopex $vtoy_efi_part/ventoy/vtloopex.cpio    
     vt_img_extra_initrd_append  (vtloopex)/$elec_ver/vtloopex.tar.xz
 
+    if [ "$elec_ver" = "LibreELEC" ]; then
+        if [ -f (vtimghd,1)/system ]; then
+            loopback elecsfs (vtimghd,1)/system
+            vt_get_lib_module_ver (elecsfs) /usr/lib/kernel-overlays/base/lib/modules/  vt_module_ver
+            if [ -n "$vt_module_ver" ]; then        
+                for mod in "kernel/drivers/md/dm-mod.ko"; do
+                    if [ -e (elecsfs)/usr/lib/kernel-overlays/base/lib/modules/$vt_module_ver/$mod ]; then
+                        vt_img_extra_initrd_append  (elecsfs)/usr/lib/kernel-overlays/base/lib/modules/$vt_module_ver/$mod
+                    fi
+                done
+            fi
+        fi
+    fi
+
     ventoy_debug_pause
 
     #boot image file
     ventoy_debug_pause
 
     #boot image file
@@ -1938,6 +1952,7 @@ function ventoy_img_openelec {
     vt_img_unhook_root
     vt_unset_boot_opt
     loopback -d vtloopex
     vt_img_unhook_root
     vt_unset_boot_opt
     loopback -d vtloopex
+    loopback -d elecsfs
 }
 
 
 }