This commit is contained in:
longpanda
2020-08-13 20:20:20 +08:00
parent 062f816020
commit 9962775296
33 changed files with 1016 additions and 39 deletions

View File

@@ -43,6 +43,12 @@ ventoy_os_install_dmsetup() {
# install md-modules
LINE=$($GREP ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list)
if [ $? -eq 0 ]; then
LINTCNT=$($GREP -c ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list)
if [ $LINTCNT -gt 1 ]; then
vtlog "more than one pkgs, need to filter..."
VER=$($BUSYBOX_PATH/uname -r)
LINE=$($GREP ' md-modules.*\.udeb' $VTOY_PATH/iso_file_list | $GREP $VER)
fi
install_udeb_from_line "$LINE" ${vt_usb_disk}
fi
@@ -83,6 +89,8 @@ if is_ventoy_hook_finished || not_ventoy_disk "${1:0:-1}"; then
exit 0
fi
vtlog "==== $0 $* ===="
dmsetup_path=$(ventoy_find_bin_path dmsetup)
if [ -z "$dmsetup_path" ]; then
ventoy_os_install_dmsetup "/dev/${1:0:-1}"

View File

@@ -64,6 +64,10 @@ ventoy_get_debian_distro() {
echo 'linuxconsole'; return
fi
if $GREP -q 'vyos' /proc/version; then
echo 'vyos'; return
fi
echo 'default'
}

View File

@@ -0,0 +1,49 @@
#!/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
mkdir -p /live/vtoyfuse /live/vtoyiso
modprobe fuse
vtoydm -p -f $VTOY_PATH/ventoy_image_map -d $vtdiskname > $VTOY_PATH/ventoy_dm_table
vtoy_fuse_iso -f $VTOY_PATH/ventoy_dm_table -m /live/vtoyfuse
mount -t iso9660 /live/vtoyfuse/ventoy.iso /live/vtoyiso
PATH=$VTPATH_OLD
set_ventoy_hook_finish

View File

@@ -0,0 +1,25 @@
#!/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/>.
#
#************************************************************************************
if [ -e /init ] && $GREP -q '^mountroot$' /init; then
echo "Here before mountroot ..." >> $VTLOG
$SED "/^mountroot$/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/vyos-disk.sh" -i /init
$SED "/^mountroot$/i\\export LIVE_MEDIA=/live/vtoyiso" -i /init
#$SED "/^mountroot$/i\\exec /ventoy/busybox/sh" -i /init
fi

View File

@@ -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

View File

@@ -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/hyperbola/ventoy-disk.sh \"\$hyperisodevice\"" -i /init
if [ -f /hooks/parabolaiso ]; then
$SED '/while ! poll_device "${dev}"/a\ if /ventoy/busybox/sh /ventoy/hook/hyperbola/ventoy-timeout.sh ${dev}; then break; fi' -i /hooks/hyperiso
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

View File

@@ -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

View File

@@ -436,8 +436,14 @@ ventoy_udev_disk_common_hook() {
VTDISK="${1:0:-1}"
if [ -e /vtoy/vtoy ]; then
VTRWMOD=""
else
VTRWMOD="--readonly"
fi
# create device mapper for iso image file
if create_ventoy_device_mapper "/dev/$VTDISK" --readonly; then
if create_ventoy_device_mapper "/dev/$VTDISK" $VTRWMOD; then
vtlog "==== create ventoy device mapper success ===="
else
vtlog "==== create ventoy device mapper failed ===="
@@ -453,7 +459,7 @@ ventoy_udev_disk_common_hook() {
done
fi
if create_ventoy_device_mapper "/dev/$VTDISK" --readonly; then
if create_ventoy_device_mapper "/dev/$VTDISK" $VTRWMOD; then
vtlog "==== create ventoy device mapper success after retry ===="
else
vtlog "==== create ventoy device mapper failed after retry ===="
@@ -473,6 +479,24 @@ ventoy_udev_disk_common_hook() {
fi
}
ventoy_create_dev_ventoy_part() {
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
$BUSYBOX_PATH/mknod -m 0666 /dev/ventoy b $blkdev_num
if [ -e /vtoy_dm_table ]; then
vtPartid=1
$CAT /vtoy_dm_table | while read vtline; do
echo $vtline > /ventoy/dm_table_part${vtPartid}
$VTOY_PATH/tool/dmsetup create ventoy${vtPartid} /ventoy/dm_table_part${vtPartid}
blkdev_num=$($VTOY_PATH/tool/dmsetup ls | $GREP ventoy${vtPartid} | $SED 's/.*(\([0-9][0-9]*\),.*\([0-9][0-9]*\).*/\1 \2/')
$BUSYBOX_PATH/mknod -m 0666 /dev/ventoy${vtPartid} b $blkdev_num
vtPartid=$(expr $vtPartid + 1)
done
fi
}
is_inotify_ventoy_part() {
if echo $1 | $GREP -q "2$"; then

View File

@@ -0,0 +1,53 @@
#!/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
$BUSYBOX_PATH/insmod $VTOY_PATH/modules/dax.ko
$BUSYBOX_PATH/insmod $VTOY_PATH/modules/dm-mod.ko
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=$($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})
echo -n $vtDM > /ventoy/vtDM
ventoy_create_dev_ventoy_part
mdev -s
PATH=$VTPATH_OLD
set_ventoy_hook_finish

View File

@@ -0,0 +1,32 @@
#!/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 drives/i $BUSYBOX_PATH/sh $VTOY_PATH/loop/easyos/ventoy-disk.sh; vtDM=\$(cat /ventoy/vtDM)" -i /init
$SED "1a boot_dev=ventoy1;wkg_dev=ventoy2" -i /init
#check for ssd will read /sys/block/ventoy, will no exist, need a workaround
$SED "s#/sys/block/\${WKG_DRV}/#/sys/block/\$vtDM/#g" -i /init
#skip the resizing process, can't resizing partition
$SED "s#640M#0M#g" -i /init

View File

@@ -0,0 +1,50 @@
#!/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=$($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})
echo -n $vtDM > /ventoy/vtDM
ventoy_create_dev_ventoy_part
mdev -s
PATH=$VTPATH_OLD
set_ventoy_hook_finish

View File

@@ -0,0 +1,30 @@
#!/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
$BUSYBOX_PATH/mkdir /sys
$BUSYBOX_PATH/mount -t proc proc /proc
$BUSYBOX_PATH/mount -t sysfs sys /sys
$BUSYBOX_PATH/mdev -s
#$BUSYBOX_PATH/sh $VTOY_PATH/loop/openwrt/ventoy-disk.sh
exec $BUSYBOX_PATH/sh

View File

@@ -0,0 +1,46 @@
#!/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"
ventoy_create_dev_ventoy_part
mdev -s
PATH=$VTPATH_OLD
set_ventoy_hook_finish

View File

@@ -0,0 +1,28 @@
#!/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 "/^CMDLINE=/i $BUSYBOX_PATH/sh $VTOY_PATH/loop/volumio/ventoy-disk.sh" -i /init
#skip the resizing process
$SED "/^FREESIZE=/a FREESIZE=0" -i /init
$SED "/exec.*switch_root/i $SED 's@\\\\(.*/boot \\\\)@#\\\\1@' -i /mnt/ext/union/etc/fstab" -i /init

View File

@@ -227,6 +227,10 @@ ventoy_get_os_type() {
echo 'vine'; return
fi
if $GREP -q 'hyperbola' /proc/cmdline; then
echo 'hyperbola'; return
fi
echo "default"
}

View File

@@ -37,10 +37,30 @@ for i in $vtcmdline; do
fi
done
####################################################################
# #
# Step 2 : Process ko #
# #
####################################################################
$BUSYBOX_PATH/mkdir -p /ventoy/modules
$BUSYBOX_PATH/ls -1a / | $EGREP '\.ko$|\.ko.[gx]z$' | while read vtline; do
if [ "${vtline:0:1}" = "." ]; then
$BUSYBOX_PATH/mv /${vtline} /ventoy/modules/${vtline:1}
else
$BUSYBOX_PATH/mv /${vtline} /ventoy/modules/
fi
done
if [ -e /vtloopex.tar.xz ]; then
echo "extract vtloopex ..." >> $VTLOG
$BUSYBOX_PATH/tar -xJf /vtloopex.tar.xz -C $VTOY_PATH/
$BUSYBOX_PATH/rm -f /vtloopex.tar.xz
fi
####################################################################
# #
# Step 2 : Do OS specific hook #
# Step 3 : Do OS specific hook #
# #
####################################################################
ventoy_get_os_type() {
@@ -56,6 +76,22 @@ ventoy_get_os_type() {
echo 'endless'; return
fi
if $GREP -q 'OpenWrt' /proc/version; then
echo 'openwrt'; return
fi
if [ -e /BOOT_SPECS ]; then
if $GREP -q 'easyos' /BOOT_SPECS; then
echo 'easyos'; return
fi
fi
if [ -e /etc/os-release ]; then
if $GREP -q 'volumio' /etc/os-release; then
echo 'volumio'; return
fi
fi
echo "default"
}
@@ -68,7 +104,7 @@ fi
####################################################################
# #
# Step 3 : Check for debug break #
# Step 4 : Check for debug break #
# #
####################################################################
if [ "$VTOY_BREAK_LEVEL" = "03" ] || [ "$VTOY_BREAK_LEVEL" = "13" ]; then
@@ -85,7 +121,7 @@ fi
####################################################################
# #
# Step 3 : Hand over to real init #
# Step 5 : Hand over to real init #
# #
####################################################################
$BUSYBOX_PATH/umount /proc