Skip to content

Commit

Permalink
1.0.08beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
ventoy committed Apr 26, 2020
1 parent d5b829f commit ad9a031
Show file tree
Hide file tree
Showing 17 changed files with 187 additions and 71 deletions.
20 changes: 18 additions & 2 deletions IMG/cpio/ventoy/hook/debian/default-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,21 @@
#
#************************************************************************************

ventoy_systemd_udevd_work_around
ventoy_add_udev_rule "$VTOY_PATH/hook/debian/udev_disk_hook.sh %k"
if [ -e /init ] && $GREP -q '^mountroot$' /init; then
echo "Here before mountroot ..." >> $VTLOG

$SED "/^mountroot$/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/disk_mount_hook.sh" -i /init
$SED "/^mountroot$/i\\export LIVEMEDIA=/dev/mapper/ventoy" -i /init
$SED "/^mountroot$/i\\export LIVE_MEDIA=/dev/mapper/ventoy" -i /init

elif [ -e /init ] && $GREP -q '/start-udev$' /init; then
echo "Here use notify ..." >> $VTLOG

ventoy_set_inotify_script debian/ventoy-inotifyd-hook.sh
$SED "/start-udev$/i\\mount -n -o mode=0755 -t devtmpfs devtmpfs /dev" -i /init
$SED "/start-udev$/i\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/ventoy-inotifyd-start.sh" -i /init
else
echo "Here use udev hook ..." >> $VTLOG
ventoy_systemd_udevd_work_around
ventoy_add_udev_rule "$VTOY_PATH/hook/debian/udev_disk_hook.sh %k"
fi
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@

. /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
Expand All @@ -36,9 +32,4 @@ if [ "$vtdiskname" = "unknown" ]; then
exit 0
fi

ventoy_udev_disk_common_hook "${vtdiskname#/dev/}2"

PATH=$VTPATH_OLD

set_ventoy_hook_finish

$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/udev_disk_hook.sh "${vtdiskname#/dev/}2"
13 changes: 12 additions & 1 deletion IMG/cpio/ventoy/hook/debian/udev_disk_hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ if [ -z "$dmsetup_path" ]; then
ventoy_os_install_dmsetup "/dev/${1:0:-1}"
fi

if ! $GREP -q 'device-mapper' /proc/devices; then
ventoy_os_install_dmsetup "/dev/${1:0:-1}"
fi

ventoy_udev_disk_common_hook $*

#
Expand All @@ -103,7 +107,14 @@ else
else
vtlog "No boot param, need to mount"
$BUSYBOX_PATH/mkdir /cdrom
$BUSYBOX_PATH/mount -t iso9660 $VTOY_DM_PATH /cdrom

if [ -b $VTOY_DM_PATH ]; then
vtlog "mount $VTOY_DM_PATH ..."
$BUSYBOX_PATH/mount -t iso9660 $VTOY_DM_PATH /cdrom
else
vtlog "mount /dev/$1 ..."
$BUSYBOX_PATH/mount -t iso9660 /dev/$1 /cdrom
fi
fi
fi

Expand Down
8 changes: 0 additions & 8 deletions IMG/cpio/ventoy/hook/debian/ventoy-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ ventoy_get_debian_distro() {
echo 'pve'; return
fi

if $GREP -q '[Dd]eepin' /proc/version; then
echo 'deepin'; return
fi

if $GREP -q '[Uu][Oo][Ss] ' /proc/version; then
echo 'deepin'; return
fi

if [ -d /porteus ]; then
echo 'porteus'; return
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,17 @@

. /ventoy/hook/ventoy-hook-lib.sh

vtlog "####### $0 $* ########"

VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH

vtmountpoint=$1

if is_ventoy_hook_finished; then
PATH=$VTPATH_OLD
exit 0
fi

wait_for_usb_disk_ready
vtlog "##### INOTIFYD: $2/$3 is created ..."

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"
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH

$BUSYBOX_PATH/mount -t iso9660 $VTOY_DM_PATH $vtmountpoint
if is_inotify_ventoy_part $3; then
vtlog "find ventoy partition $3 ..."
$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/udev_disk_hook.sh "$3"
fi

# OK finish
set_ventoy_hook_finish
PATH=$VTPATH_OLD
25 changes: 25 additions & 0 deletions IMG/cpio/ventoy/hook/default/ventoy-inotifyd-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <[email protected]>
#
# 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

vtHook=$($CAT $VTOY_PATH/inotifyd-hook-script.txt)

vtlog "... start inotifyd listen $vtHook ..."
$BUSYBOX_PATH/nohup $VTOY_PATH/tool/inotifyd $vtHook /dev:n 2>&- &
11 changes: 9 additions & 2 deletions IMG/cpio/ventoy/hook/manjaro/ventoy-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ else
$CAT $VTOY_PATH/hook/default/13-dm-disk.rules > "$DISTRO_UDEV_DIR/13-dm-disk.rules"
fi

ventoy_systemd_udevd_work_around

ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
if $GREP -q '^mount_setup$' init; then
echo "Here use notify ..." >> $VTLOG

ventoy_set_inotify_script manjaro/ventoy-inotifyd-hook.sh
$SED "/^mount_setup$/a\\$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/ventoy-inotifyd-start.sh" -i /init
else
ventoy_systemd_udevd_work_around
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k"
fi
46 changes: 46 additions & 0 deletions IMG/cpio/ventoy/hook/manjaro/ventoy-inotifyd-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <[email protected]>
#
# 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 "##### INOTIFYD: $2/$3 is created ..."

VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH

if is_inotify_ventoy_part $3; then
vtlog "find ventoy partition $3 ..."
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh "$3"

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})
vtLABEL=$($BUSYBOX_PATH/blkid /dev/$vtDM | $AWK '{print $2}' | $SED 's/.*"\(.*\)".*/\1/')

vtlog "blkdev_num=$blkdev_num vtDM=$vtDM label $vtLABEL ..."

if ! [ -d /dev/disk/by-label ]; then
mkdir -p /dev/disk/by-label
fi
$BUSYBOX_PATH/cp -a /dev/$vtDM /dev/disk/by-label/$vtLABEL
fi

PATH=$VTPATH_OLD
9 changes: 6 additions & 3 deletions IMG/cpio/ventoy/hook/rhel7/ventoy-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@

. $VTOY_PATH/hook/ventoy-os-lib.sh

ventoy_systemd_udevd_work_around
ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace"
#ventoy_systemd_udevd_work_around
#ventoy_add_udev_rule "$VTOY_PATH/hook/default/udev_disk_hook.sh %k noreplace"

#$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/rhel7/ventoy-disk.sh /lib/dracut/hooks/initqueue/01-ventoy-disk.sh
$SED "s#printf\(.*\)\$CMDLINE#printf\1\$CMDLINE inst.stage2=hd:/dev/dm-0#" -i /lib/dracut-lib.sh
ventoy_set_inotify_script rhel7/ventoy-inotifyd-hook.sh

$BUSYBOX_PATH/cp -a $VTOY_PATH/hook/default/ventoy-inotifyd-start.sh /lib/dracut/hooks/pre-udev/01-ventoy-inotifyd-start.sh

# suppress write protected mount warning
if [ -e /usr/sbin/anaconda-diskroot ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,31 @@
#
#************************************************************************************

drop_initramfs_workaround() {
mainfilelist=$($FIND / -name 9990-main.sh)

echo "mainfilelist=$mainfilelist" >> $VTLOG

if [ -z "$mainfilelist" ]; then
return
fi
. /ventoy/hook/ventoy-hook-lib.sh

for vtfile in $mainfilelist; do
vtcnt=$($GREP -c 'panic.*Unable to find a medium' $vtfile)
if [ $vtcnt -ne 1 ]; then
return
fi
done

echo "direct_hook insert ..." >> $VTLOG

for vtfile in $mainfilelist; do
$SED "s#panic.*Unable to find a medium.*#$BUSYBOX_PATH/sh $VTOY_PATH/hook/debian/deepin-disk.sh \$mountpoint; livefs_root=\$mountpoint#" -i $vtfile
done
}
if is_ventoy_hook_finished; then
exit 0
fi

ventoy_systemd_udevd_work_around
ventoy_add_udev_rule "$VTOY_PATH/hook/debian/udev_disk_hook.sh %k"
vtlog "##### INOTIFYD: $2/$3 is created ..."

drop_initramfs_workaround
VTPATH_OLD=$PATH; PATH=$BUSYBOX_PATH:$VTOY_PATH/tool:$PATH

if is_inotify_ventoy_part $3; then
vtlog "find ventoy partition ..."
$BUSYBOX_PATH/sh $VTOY_PATH/hook/default/udev_disk_hook.sh $3 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})

if [ "$vtDM" = "dm-0" ]; then
vtlog "This is dm-0, OK ..."
else
vtlog "####### This is $vtDM ####### this is abnormal ..."
ventoy_swap_device /dev/dm-0 /dev/$vtDM
fi

set_ventoy_hook_finish
fi

PATH=$VTPATH_OLD
33 changes: 33 additions & 0 deletions IMG/cpio/ventoy/hook/ventoy-hook-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -421,4 +421,37 @@ ventoy_udev_disk_common_hook() {
fi
}

is_inotify_ventoy_part() {
if echo $1 | grep -q "2$"; then
if ! [ -e /sys/block/$1 ]; then
if [ -e /sys/class/block/$1 ]; then
if [ -e /dev/${1:0:-1} ]; then
$VTOY_PATH/tool/vtoydump -f $VTOY_PATH/ventoy_os_param -c ${1:0:-1}
return
fi
fi
fi
fi

[ "1" = "0" ]
}

ventoy_find_dm_id() {
for vt in $($BUSYBOX_PATH/ls /sys/block/); do
if [ "${vt:0:3}" = "dm-" ]; then
vtMajorMinor=$($CAT /sys/block/$vt/dev)
if [ "$vtMajorMinor" = "$1" ]; then
echo ${vt}
return
fi
fi
done
echo 'xx'
}

ventoy_swap_device() {
mv $1 $VTOY_PATH/swap_tmp_dev
mv $2 $1
mv $VTOY_PATH/swap_tmp_dev $2
}

4 changes: 4 additions & 0 deletions IMG/cpio/ventoy/hook/ventoy-os-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,7 @@ ventoy_print_yum_repo() {
echo "gpgcheck=0"
echo "priority=0"
}

ventoy_set_inotify_script() {
echo $VTOY_PATH/hook/$1 > $VTOY_PATH/inotifyd-hook-script.txt
}
Binary file modified INSTALL/Ventoy2Disk.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion INSTALL/grub/grub.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ function legacy_iso_memdisk {
#############################################################
#############################################################

set VENTOY_VERSION="1.0.07"
set VENTOY_VERSION="1.0.08b1"

#disable timeout
unset timeout
Expand Down
Binary file modified INSTALL/ventoy/ventoy.cpio
Binary file not shown.
Binary file modified Ventoy2Disk/Ventoy2Disk/Ventoy2Disk.rc
Binary file not shown.
2 changes: 1 addition & 1 deletion VtoyTool/vtoydump.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ static int vtoy_check_device(ventoy_os_param *param, const char *device)
debug("param->vtoy_disk_size=%llu size=%llu\n",
(unsigned long long)param->vtoy_disk_size, (unsigned long long)size);

if (param->vtoy_disk_size == size &&
if ((param->vtoy_disk_size == size || param->vtoy_disk_size == size + 512) &&
memcmp(vtguid, param->vtoy_disk_guid, 16) == 0)
{
debug("<%s> is right ventoy disk\n", device);
Expand Down

0 comments on commit ad9a031

Please sign in to comment.