]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
support for tails.img
authorlongpanda <admin@ventoy.net>
Tue, 9 Mar 2021 09:17:46 +0000 (17:17 +0800)
committerlongpanda <admin@ventoy.net>
Tue, 9 Mar 2021 09:17:46 +0000 (17:17 +0800)
13 files changed:
GRUB2/MOD_SRC/grub-2.04/grub-core/loader/arm64/linux.c
GRUB2/MOD_SRC/grub-2.04/grub-core/loader/i386/linux.c
GRUB2/MOD_SRC/grub-2.04/grub-core/loader/mips64/linux.c
IMG/cpio/ventoy/loop/tails/ventoy-disk.sh [new file with mode: 0644]
IMG/cpio/ventoy/loop/tails/ventoy-hook.sh [new file with mode: 0644]
INSTALL/VentoyWebDeepin.sh
INSTALL/grub/grub.cfg
INSTALL/tool/aarch64/V2DServer
INSTALL/tool/i386/V2DServer
INSTALL/tool/mips64el/V2DServer
INSTALL/tool/x86_64/V2DServer
LANGUAGES/languages.ini
LinuxGUI/Ventoy2Disk/Core/ventoy_disk.c

index c5f82927ad0ba82075dc5948438334ab62e523af..f8dfec6444505cb12008f1fcca3be1b00ec6bec0 100644 (file)
@@ -304,6 +304,7 @@ static int ventoy_boot_opt_filter(char *opt)
 static int ventoy_bootopt_hook(int argc, char *argv[])
 {
     int i;
+    int TmpIdx;
     int count = 0;
     const char *env;
     char c;
@@ -317,10 +318,20 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
         return 0;
     }
 
-    /* the 1st parameter is BOOT_IMAGE=xxxx */
-    if (argc > 0 && 0 == ventoy_boot_opt_filter(argv[0]))
+    /* To avoid --- parameter, we split two parts */
+    for (TmpIdx = 0; TmpIdx < argc; TmpIdx++)
     {
-        ventoy_linux_args[count++] = grub_strdup(argv[0]);
+        if (ventoy_boot_opt_filter(argv[TmpIdx]))
+        {
+            continue;
+        }
+
+        if (grub_strncmp(argv[TmpIdx], "--", 2) == 0)
+        {
+            break;
+        }
+
+        ventoy_linux_args[count++] = grub_strdup(argv[TmpIdx]);
     }
 
     for (i = 0; i < ventoy_linux_argc; i++)
@@ -392,15 +403,15 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
         }
     }
 
-    /* We have processed the 1st parameter before, so start from 1 */
-    for (i = 1; i < argc; i++)
+    while (TmpIdx < argc)
     {
-        if (ventoy_boot_opt_filter(argv[i]))
+        if (ventoy_boot_opt_filter(argv[TmpIdx]))
         {
             continue;
         }
 
-        ventoy_linux_args[count++] = grub_strdup(argv[i]);
+        ventoy_linux_args[count++] = grub_strdup(argv[TmpIdx]);
+        TmpIdx++;
     }
 
     if (ventoy_debug)
index 2d453e369b51c9afee6127252b7bd79314cd0ba3..f6c879f54e94168e14f46ce66faf0ad1728da120 100644 (file)
@@ -530,6 +530,7 @@ static int ventoy_boot_opt_filter(char *opt)
 static int ventoy_bootopt_hook(int argc, char *argv[])
 {
     int i;
+    int TmpIdx;
     int count = 0;
     const char *env;
     char c;
@@ -543,10 +544,20 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
         return 0;
     }
 
-    /* the 1st parameter is BOOT_IMAGE=xxxx */
-    if (argc > 0 && 0 == ventoy_boot_opt_filter(argv[0]))
+    /* To avoid --- parameter, we split two parts */
+    for (TmpIdx = 0; TmpIdx < argc; TmpIdx++)
     {
-        ventoy_linux_args[count++] = grub_strdup(argv[0]);
+        if (ventoy_boot_opt_filter(argv[TmpIdx]))
+        {
+            continue;
+        }
+
+        if (grub_strncmp(argv[TmpIdx], "--", 2) == 0)
+        {
+            break;
+        }
+
+        ventoy_linux_args[count++] = grub_strdup(argv[TmpIdx]);
     }
 
     for (i = 0; i < ventoy_linux_argc; i++)
@@ -618,15 +629,15 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
         }
     }
 
-    /* We have processed the 1st parameter before, so start from 1 */
-    for (i = 1; i < argc; i++)
+    while (TmpIdx < argc)
     {
-        if (ventoy_boot_opt_filter(argv[i]))
+        if (ventoy_boot_opt_filter(argv[TmpIdx]))
         {
             continue;
         }
 
-        ventoy_linux_args[count++] = grub_strdup(argv[i]);
+        ventoy_linux_args[count++] = grub_strdup(argv[TmpIdx]);
+        TmpIdx++;
     }
 
     if (ventoy_debug)
index 85ea20e02ef764ecb891eb2f91678c4822331290..2822187d4029ebca704462a2cb9fdeb9541a474b 100644 (file)
@@ -252,6 +252,7 @@ static int ventoy_boot_opt_filter(char *opt)
 static int ventoy_bootopt_hook(int argc, char *argv[])
 {
     int i;
+    int TmpIdx;
     int count = 0;
     const char *env;
     char c;
@@ -265,10 +266,20 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
         return 0;
     }
 
-    /* the 1st parameter is BOOT_IMAGE=xxxx */
-    if (argc > 0 && 0 == ventoy_boot_opt_filter(argv[0]))
+    /* To avoid --- parameter, we split two parts */
+    for (TmpIdx = 0; TmpIdx < argc; TmpIdx++)
     {
-        ventoy_linux_args[count++] = grub_strdup(argv[0]);
+        if (ventoy_boot_opt_filter(argv[TmpIdx]))
+        {
+            continue;
+        }
+
+        if (grub_strncmp(argv[TmpIdx], "--", 2) == 0)
+        {
+            break;
+        }
+
+        ventoy_linux_args[count++] = grub_strdup(argv[TmpIdx]);
     }
 
     for (i = 0; i < ventoy_linux_argc; i++)
@@ -340,15 +351,15 @@ static int ventoy_bootopt_hook(int argc, char *argv[])
         }
     }
 
-    /* We have processed the 1st parameter before, so start from 1 */
-    for (i = 1; i < argc; i++)
+    while (TmpIdx < argc)
     {
-        if (ventoy_boot_opt_filter(argv[i]))
+        if (ventoy_boot_opt_filter(argv[TmpIdx]))
         {
             continue;
         }
 
-        ventoy_linux_args[count++] = grub_strdup(argv[i]);
+        ventoy_linux_args[count++] = grub_strdup(argv[TmpIdx]);
+        TmpIdx++;
     }
 
     if (ventoy_debug)
diff --git a/IMG/cpio/ventoy/loop/tails/ventoy-disk.sh b/IMG/cpio/ventoy/loop/tails/ventoy-disk.sh
new file mode 100644 (file)
index 0000000..a4e4706
--- /dev/null
@@ -0,0 +1,61 @@
+#!/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
+
+modprobe dm-mod
+
+ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2" "noreplace"
+
+ventoy_create_dev_ventoy_part
+
+if [ -n "${FSUUID}" ]; then
+    vtPartid=0
+    MaxPart=$(cat /vtoy_dm_table|wc -l)
+    
+    while [ $vtPartid -le $MaxPart ]; do
+        if blkid /dev/dm-${vtPartid} | grep -q "${FSUUID}"; then
+            ln -s ../../dm-${vtPartid} "/dev/disk/by-uuid/${FSUUID}"
+            break
+        fi
+        vtPartid=$(expr $vtPartid + 1)
+    done
+fi
+
+
+PATH=$VTPATH_OLD
+
+set_ventoy_hook_finish
diff --git a/IMG/cpio/ventoy/loop/tails/ventoy-hook.sh b/IMG/cpio/ventoy/loop/tails/ventoy-hook.sh
new file mode 100644 (file)
index 0000000..4eec2ae
--- /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
+
+$SED  "/^mount_premount$/i\\$BUSYBOX_PATH/sh $VTOY_PATH/loop/tails/ventoy-disk.sh"  -i /init
+
+if [ -f /scripts/init-premount/partitioning ]; then
+    $SED  "1a exit 0"  -i /scripts/init-premount/partitioning
+fi
index c17607e68eb232fcfc1250bea5c72d7fe2f6a7b5..37c15d8ea4fd6a5958bf2c097721b423b0963662 100644 (file)
@@ -28,6 +28,13 @@ get_user() {
     fi
 }
 
+get_browser_cmd() {
+    if uos-browser --version > /dev/null 2>&1; then
+        echo "uos-browser"; return
+    else
+        echo "browser"
+    fi    
+}
 
 uid=$(id -u)
 if [ $uid -ne 0 ]; then
@@ -101,7 +108,11 @@ VUSER=$(get_user)
 
 LOGFILE=log.txt
 if [ -e $LOGFILE ]; then
-    chown $VUSER $LOGFILE
+    LogGroup=$(stat -c '%G' $LOGFILE)
+    if [ "$LogGroup" = "root" ]; then
+        rm -f $LOGFILE
+        su $VUSER -c "touch $LOGFILE"
+    fi
 else
     su $VUSER -c "touch $LOGFILE"
 fi
@@ -121,15 +132,14 @@ if [ -f ./tool/$TOOLDIR/V2DServer.xz ]; then
 fi
 
 rm -rf ./*_VTMPDIR
-vtWebTmpDir=$(mktemp -d -p ./ --suffix=_VTMPDIR)
-chown $VUSER $vtWebTmpDir
-
+vtWebTmpDir=$(su $VUSER -c "mktemp -d -p ./ --suffix=_VTMPDIR")
 
 V2DServer "$HOST" "$PORT" &
 V2DPid=$!
 sleep 1
 
-su $VUSER -c "browser --window-size=550,400 --app=\"http://${HOST}:${PORT}/index.html?chrome-app\"  --user-data-dir=$vtWebTmpDir >> $LOGFILE 2>&1" &
+browsercmd=$(get_browser_cmd)
+su $VUSER -c "$browsercmd --window-size=550,400 --app=\"http://${HOST}:${PORT}/index.html?chrome-app\"  --user-data-dir=$vtWebTmpDir >> $LOGFILE 2>&1" &
 WebPid=$!
 
 
index 85a630a18b0b59b9a5965f6f880853838840430d..08504fb49db9741007b60daa376f3dafb9d2cbad 100644 (file)
@@ -1480,6 +1480,23 @@ function ventoy_img_batocera {
     vt_unset_boot_opt
 }
 
+function ventoy_img_tails {
+    vt_load_cpio  $vtoy_path  "${vt_chosen_path}" ${vtoy_iso_part} "busybox=$ventoy_busybox_ver"
+    vt_trailer_cpio ${vtoy_iso_part} "${vt_chosen_path}" noinit
+
+    ventoy_debug_pause
+
+    #boot image file
+    vt_set_boot_opt rdinit=/vtoy/vtoy live-media=/dev/dm-1 ventoyos=tails
+    vt_img_hook_root
+    
+    set root=(vtimghd,1)
+    configfile (vtimghd,1)/efi/debian/grub.cfg
+
+    vt_img_unhook_root
+    vt_unset_boot_opt
+}
+
 function ventoy_img_memtest86 {      
     chainloader (vtimghd,1)/efi/boot/BOOTX64.efi
     boot
@@ -1518,6 +1535,8 @@ function img_common_menuentry {
     set vtback_root=$root
     ventoy_cli_console
     vt_push_last_entry
+    set vtback_theme=$theme
+    unset theme
 
     vt_img_extra_initrd_reset
 
@@ -1544,6 +1563,8 @@ function img_common_menuentry {
         ventoy_img_freedombox
     elif vt_str_begin "$vtImgHd1Label" "BATOCERA"; then
         ventoy_img_batocera
+    elif vt_str_begin "$vtImgHd1Label" "Tails"; then
+        ventoy_img_tails
     elif [ "$vtImgHd2Label" = "RECALBOX" ]; then
         ventoy_img_recalbox
     elif [ -f (vtimghd,2)/loader/entries/ubos.conf ]; then
@@ -1568,6 +1589,7 @@ function img_common_menuentry {
 
     set root=$vtback_root
     vt_pop_last_entry
+    set theme=$vtback_theme
     ventoy_gui_console
     set ventoy_compatible=NO
 }
index 66f408b077c12628ef10f862ea03067396cc0963..6663ab582895c6931b9a78569b1b92014f158fc3 100644 (file)
Binary files a/INSTALL/tool/aarch64/V2DServer and b/INSTALL/tool/aarch64/V2DServer differ
index d8fe1025ae0bc55327321a5b63bfa9409e5200b7..02f1e5efd50ff47700ddf67f54ab4281647638f6 100644 (file)
Binary files a/INSTALL/tool/i386/V2DServer and b/INSTALL/tool/i386/V2DServer differ
index 1018962e6778fb18fea026db594efc054f5ac638..bb9f481c36d1e218f9893a73f1ff619be79f0edf 100644 (file)
Binary files a/INSTALL/tool/mips64el/V2DServer and b/INSTALL/tool/mips64el/V2DServer differ
index f4d21e4754959e113a1836f9e4ab8ca269f6e732..9b9d8710219abc13cf0007bf48c05fdab258b8ba 100644 (file)
Binary files a/INSTALL/tool/x86_64/V2DServer and b/INSTALL/tool/x86_64/V2DServer differ
index fdf6949bba01f7a648eb637704909c1196665172..30493d44f898056dc4a19fbded851ce9fbb53bc1 100644 (file)
Binary files a/LANGUAGES/languages.ini and b/LANGUAGES/languages.ini differ
index 4df2040ec7ac96a777c657939f32c89f20aa2b8d..a4ac62b5acd9bec7e9d5befaef5b78904ef789ac 100644 (file)
@@ -232,6 +232,12 @@ static int ventoy_is_possible_blkdev(const char *name)
     {
         return 0;
     }
+    
+    /* /dev/zramX */
+    if (name[0] == 'z' && name[1] == 'r' && name[2] == 'a' && name[3] == 'm')
+    {
+        return 0;
+    }
 
     /* /dev/loopX */
     if (name[0] == 'l' && name[1] == 'o' && name[2] == 'o' && name[3] == 'p')