This commit is contained in:
longpanda 2020-08-08 19:39:31 +08:00
parent be50ea69aa
commit 1186caba41
34 changed files with 3002 additions and 166 deletions

1166
BUSYBOX/64h.config Normal file

File diff suppressed because it is too large Load Diff

18
BUSYBOX/chmod/build.sh Normal file
View File

@ -0,0 +1,18 @@
#!/bin/sh
DSTDIR=../../IMG/cpio/ventoy/busybox
rm -f vtchmod32 vtchmod64
rm -f $DSTDIR/vtchmod32 $DSTDIR/vtchmod64
/opt/diet32/bin/diet gcc -Os -m32 vtchmod.c -o vtchmod32
/opt/diet64/bin/diet gcc -Os vtchmod.c -o vtchmod64
chmod 777 vtchmod32
chmod 777 vtchmod64
cp -a vtchmod32 $DSTDIR/
cp -a vtchmod64 $DSTDIR/

13
BUSYBOX/chmod/vtchmod.c Normal file
View File

@ -0,0 +1,13 @@
#include <sys/types.h>
#include <sys/stat.h>
int main(int argc, char **argv)
{
if (argc != 2)
{
return 1;
}
return chmod(argv[1], 0777);
}

BIN
BUSYBOX/chmod/vtchmod32 Normal file

Binary file not shown.

BIN
BUSYBOX/chmod/vtchmod64 Normal file

Binary file not shown.

View File

@ -28,4 +28,22 @@ build for 32bit, static linked with dietlibc
4. make
5. strip dmsetup/dmsetup
5. get dmsetup/dmsetup as the binary file
6. get dmsetup/dmsetup as the dmsetup32 binary file
======================== Build for 64bit dmsetup =========================
https://www.uclibc.org/downloads/binaries/0.9.30.1/mini-native-x86_64.tar.bz2
1. extract device mapper source code
2. extract mini-native-x86_64.tar.bz2
3. chroot to mini-native-x86_64
3. ./configure --disable-nls --disable-selinux --disable-shared --enable-static_link
4. make
5. strip dmsetup/dmsetup.static
6. get dmsetup/dmsetup.static as the dmsetup64 binary file

BIN
DMSETUP/dmsetup64 Normal file

Binary file not shown.

View File

@ -127,15 +127,24 @@
cd /home/Ventoy-master/GenUUID
sh build.sh
4.15 == Build xzminidec ==
cd /home/Ventoy-master/xz-embedded-20130513/userspace
4.15 == Build xzminidec32 ==
cd /home/Ventoy-master/Ventoy2Disk/Ventoy2Disk/xz-embedded-20130513/userspace
make -f ventoy_makefile
strip --strip-all xzminidec
4.16 == Build iso9660_x64.efi ==
4.16 == Build xzminidec64 ==
cd /home/Ventoy-master/Ventoy2Disk/Ventoy2Disk/xz-embedded-20130513/userspace
make -f ventoy_makefile64
strip --strip-all xzminidec
4.17 == Build iso9660_x64.efi ==
This efi driver is from https://github.com/pbatard/efifs
Follow all the build instructions in this project. I modified 3 files (the original and modified source are at /home/Ventoy-master/EDK2/efiffs)
4.18 IMG/cpio/ventoy/busybox/64h
https://www.uclibc.org/downloads/binaries/0.9.30.1/mini-native-x86_64.tar.bz2
https://busybox.net/downloads/busybox-1.32.0.tar.bz2
use BUSYBOX/64h.config and uclibc to build busybox-1.32
==========================================
@ -156,7 +165,7 @@
https://busybox.net/downloads/binaries/1.30.0-i686 busybox_INOTIFYD
SHA-256: 3532162a8695e91a1ed9ddea28b2cb22259a90e93d5d9c4a517b6c36842c686f
5.4 IMG/cpio/ventoy/busybox/tmpsh
5.4 IMG/cpio/ventoy/busybox/ash
https://busybox.net/downloads/binaries/1.27.1-i686 busybox_ASH
SHA-256: 44a6274bca580c2758ffc173fc76d18bb855b1fe8dcf70efd9ee75cbd57dee97

File diff suppressed because it is too large Load Diff

View File

@ -2498,6 +2498,49 @@ end:
return 0;
}
static grub_err_t ventoy_cmd_file_strstr(grub_extcmd_context_t ctxt, int argc, char **args)
{
int rc = 1;
grub_file_t file;
char *buf = NULL;
(void)ctxt;
(void)argc;
if (argc != 2)
{
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s file str \n", cmd_raw_name);
}
file = ventoy_grub_file_open(VENTOY_FILE_TYPE, "%s", args[0]);
if (!file)
{
debug("failed to open file %s\n", args[0]);
return 1;
}
buf = grub_malloc(file->size + 1);
if (!buf)
{
goto end;
}
buf[file->size] = 0;
grub_file_read(file, buf, file->size);
if (grub_strstr(buf, args[1]))
{
rc = 0;
}
end:
grub_check_free(buf);
grub_file_close(file);
return rc;
}
static grub_err_t ventoy_cmd_parse_volume(grub_extcmd_context_t ctxt, int argc, char **args)
{
int len;
@ -2790,6 +2833,9 @@ static cmd_para ventoy_cmds[] =
{ "vt_check_plugin_json", ventoy_cmd_plugin_check_json, 0, NULL, "", "", NULL },
{ "vt_1st_line", ventoy_cmd_read_1st_line, 0, NULL, "", "", NULL },
{ "vt_file_strstr", ventoy_cmd_file_strstr, 0, NULL, "", "", NULL },
{ "vt_parse_iso_volume", ventoy_cmd_parse_volume, 0, NULL, "", "", NULL },
{ "vt_parse_iso_create_date", ventoy_cmd_parse_create_date, 0, NULL, "", "", NULL },
{ "vt_parse_freenas_ver", ventoy_cmd_parse_freenas_ver, 0, NULL, "", "", NULL },

View File

@ -910,6 +910,40 @@ grub_err_t ventoy_cmd_linux_locate_initrd(grub_extcmd_context_t ctxt, int argc,
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}
static int ventoy_cpio_busybox64(cpio_newc_header *head)
{
char *name;
int namelen;
int offset;
int count = 0;
name = (char *)(head + 1);
while (name[0] && count < 2)
{
if (grub_strcmp(name, "ventoy/busybox/ash") == 0)
{
grub_memcpy(name, "ventoy/busybox/32h", 18);
count++;
}
else if (grub_strcmp(name, "ventoy/busybox/64h") == 0)
{
grub_memcpy(name, "ventoy/busybox/ash", 18);
count++;
}
namelen = ventoy_cpio_newc_get_int(head->c_namesize);
offset = sizeof(cpio_newc_header) + namelen;
offset = ventoy_align(offset, 4);
offset += ventoy_cpio_newc_get_int(head->c_filesize);
offset = ventoy_align(offset, 4);
head = (cpio_newc_header *)((char *)head + offset);
name = (char *)(head + 1);
}
return 0;
}
grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **args)
{
int rc;
@ -934,7 +968,7 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
(void)ctxt;
(void)argc;
if (argc != 3)
if (argc != 4)
{
return grub_error(GRUB_ERR_BAD_ARGUMENT, "Usage: %s cpiofile\n", cmd_raw_name);
}
@ -1087,6 +1121,12 @@ grub_err_t ventoy_cmd_load_cpio(grub_extcmd_context_t ctxt, int argc, char **arg
grub_file_close(file);
if (grub_strcmp(args[3], "busybox=64") == 0)
{
debug("cpio busybox proc %s\n", args[3]);
ventoy_cpio_busybox64((cpio_newc_header *)g_ventoy_cpio_buf);
}
VENTOY_CMD_RETURN(GRUB_ERR_NONE);
}

View File

@ -1,4 +1,4 @@
#!/ventoy/busybox/tmpsh
#!/ventoy/busybox/ash
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
@ -36,7 +36,14 @@ export SED=$BUSYBOX_PATH/sed
export SLEEP=$BUSYBOX_PATH/sleep
export HEAD=$BUSYBOX_PATH/head
$BUSYBOX_PATH/tmpxz -d $BUSYBOX_PATH/busybox.xz
if [ -e $BUSYBOX_PATH/64h ]; then
$BUSYBOX_PATH/xzminidec32 < $BUSYBOX_PATH/busybox32.xz > $BUSYBOX_PATH/busybox
$BUSYBOX_PATH/vtchmod32 $BUSYBOX_PATH/busybox
else
$BUSYBOX_PATH/xzminidec64 < $BUSYBOX_PATH/busybox64.xz > $BUSYBOX_PATH/busybox
$BUSYBOX_PATH/vtchmod64 $BUSYBOX_PATH/busybox
fi
$BUSYBOX_PATH/busybox --install $BUSYBOX_PATH
export PATH=$BUSYBOX_PATH/:$VTOY_PATH/tool
@ -60,9 +67,21 @@ xz -d ventoy_loop.sh.xz
if [ -n "$VTOY_REDT_BUG" ]; then
xz -d -c hook.cpio.xz | cpio -idm
xz -d -c tool.cpio.xz | cpio -idm
xz -d -c loop.cpio.xz | cpio -idm
else
xz -d -c hook.cpio.xz | cpio -idm 2>>$VTLOG
xz -d -c tool.cpio.xz | cpio -idm 2>>$VTLOG
xz -d -c loop.cpio.xz | cpio -idm 2>>$VTLOG
fi
if [ -e $BUSYBOX_PATH/64h ]; then
echo "Use busybox32 toolkit ..." >>$VTLOG
ln -s $BUSYBOX_PATH/xzminidec32 $BUSYBOX_PATH/xzminidec
ln -s $VTOY_PATH/tool/dmsetup32 $VTOY_PATH/tool/dmsetup
else
echo "Use busybox64 toolkit ..." >>$VTLOG
ln -s $BUSYBOX_PATH/xzminidec64 $BUSYBOX_PATH/xzminidec
ln -s $VTOY_PATH/tool/dmsetup64 $VTOY_PATH/tool/dmsetup
fi
rm -f *.xz

BIN
IMG/cpio/ventoy/busybox/64h Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -23,11 +23,38 @@
# Step 1 : parse kernel debug parameter #
# #
####################################################################
[ -d /proc ] || mkdir /proc; mount -t proc proc /proc
vtoy_cmdline=$(cat /proc/cmdline)
umount /proc; rm -rf /proc
if echo $vtoy_cmdline | grep -q 'rdinit=/vtoy/vtoy'; then
if ! [ -d /proc ]; then
mkdir /proc
vtrmproc='Y'
fi
mount -t proc proc /proc
export vtcmdline=$(cat /proc/cmdline)
export vtkerver=$(cat /proc/version)
umount /proc;
if [ "$vtrmproc" = "Y" ]; then
rm -rf /proc
fi
echo "kenel version=$vtkerver" >>$VTLOG
echo "kenel cmdline=$vtcmdline" >>$VTLOG
#break here for debug
if [ "$VTOY_BREAK_LEVEL" = "01" ] || [ "$VTOY_BREAK_LEVEL" = "11" ]; then
sleep 5
echo -e "\n\n\033[32m ################################################# \033[0m"
echo -e "\033[32m ################ VENTOY DEBUG ################### \033[0m"
echo -e "\033[32m ################################################# \033[0m \n"
if [ "$VTOY_BREAK_LEVEL" = "11" ]; then
cat $VTLOG
fi
exec $BUSYBOX_PATH/sh
fi
if echo $vtcmdline | grep -q 'rdinit=/vtoy/vtoy'; then
echo "handover to init_loop" >>$VTLOG
rm -f /xxxx /vtoyxrc
exec $BUSYBOX_PATH/sh $VTOY_PATH/init_loop

View File

@ -18,36 +18,9 @@
#************************************************************************************
###################################################################
# #
# Step 1 : parse kernel debug parameter #
# #
####################################################################
[ -d /proc ] || mkdir /proc; mount -t proc proc /proc
vtcmdline=$(cat /proc/cmdline)
vtkerver=$(cat /proc/version)
umount /proc; rm -rf /proc
echo "kenel version=$vtkerver" >>$VTLOG
echo "kenel cmdline=$vtcmdline" >>$VTLOG
#break here for debug
if [ "$VTOY_BREAK_LEVEL" = "01" ] || [ "$VTOY_BREAK_LEVEL" = "11" ]; then
sleep 5
echo -e "\n\n\033[32m ################################################# \033[0m"
echo -e "\033[32m ################ VENTOY DEBUG ################### \033[0m"
echo -e "\033[32m ################################################# \033[0m \n"
if [ "$VTOY_BREAK_LEVEL" = "11" ]; then
cat $VTLOG
fi
exec $BUSYBOX_PATH/sh
fi
####################################################################
# #
# Step 2 : extract real initramfs to / #
# Step 1 : extract real initramfs to / #
# #
####################################################################
cd /

View File

@ -18,36 +18,9 @@
#************************************************************************************
###################################################################
# #
# Step 1 : parse kernel debug parameter #
# #
####################################################################
[ -d /proc ] || mkdir /proc; mount -t proc proc /proc
vtcmdline=$(cat /proc/cmdline)
vtkerver=$(cat /proc/version)
umount /proc; rm -rf /proc
echo "kenel version=$vtkerver" >>$VTLOG
echo "kenel cmdline=$vtcmdline" >>$VTLOG
#break here for debug
if [ "$VTOY_BREAK_LEVEL" = "01" ] || [ "$VTOY_BREAK_LEVEL" = "11" ]; then
sleep 5
echo -e "\n\n\033[32m ################################################# \033[0m"
echo -e "\033[32m ################ VENTOY DEBUG ################### \033[0m"
echo -e "\033[32m ################################################# \033[0m \n"
if [ "$VTOY_BREAK_LEVEL" = "11" ]; then
cat $VTLOG
fi
exec $BUSYBOX_PATH/sh
fi
####################################################################
# #
# Step 2 : Extract injection archive #
# Step 1 : Extract injection archive #
# #
####################################################################
ventoy_unpack_injection() {

View File

@ -1,36 +0,0 @@
#!/bin/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/>.
#
#************************************************************************************
cd /ventoy
xzcat tool.cpio.xz | cpio -idmu
/ventoy/tool/vtoytool/00/vtoytool_64 --install
while [ -n "Y" ]; do
line=$(/ventoy/tool/vtoydump -f /ventoy/ventoy_os_param)
if [ $? -eq 0 ]; then
vtdiskname=${line%%#*}
break
else
sleep 1
fi
done
echo "ventoy disk is $vtdiskname" >> /ventoy/log
/ventoy/tool/vtoydm -p -f /ventoy/ventoy_image_map -d $vtdiskname > /ventoy/ventoy_dm_table
dmsetup create ventoy /ventoy/ventoy_dm_table --readonly

View File

@ -1,21 +0,0 @@
#!/bin/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/>.
#
#************************************************************************************
sed "/^mountroot$/i\\sh /ventoy/loop/deepin/ventoy-disk.sh" -i /init
exec /init

View File

@ -97,7 +97,7 @@ cd /
unset VTLOG FIND GREP EGREP CAT AWK SED SLEEP HEAD
for vtinit in $user_rdinit /sbin/init /init /linuxrc; do
for vtinit in $user_rdinit /init /sbin/init /linuxrc; do
if [ -d /ventoy_rdroot ]; then
if [ -e "/ventoy_rdroot$vtinit" ]; then
# switch_root will check /init file, this is a cheat code

View File

@ -16,7 +16,7 @@ ln -s sbin/init linuxrc
cd ventoy
cp -a $VENTOY_PATH/DMSETUP/dmsetup tool/
cp -a $VENTOY_PATH/DMSETUP/dmsetup* tool/
cp -a $VENTOY_PATH/SQUASHFS/unsquashfs_* tool/
cp -a $VENTOY_PATH/FUSEISO/vtoy_fuse_iso_* tool/
cp -a $VENTOY_PATH/VtoyTool/vtoytool tool/
@ -28,6 +28,10 @@ find ./tool | cpio -o -H newc>tool.cpio
xz tool.cpio
rm -rf tool
find ./loop | cpio -o -H newc>loop.cpio
xz loop.cpio
rm -rf loop
xz ventoy_chain.sh
xz ventoy_loop.sh

View File

@ -389,7 +389,7 @@ function uefi_linux_menu_func {
loopback loop $1$2
fi
vt_load_cpio ${vtoy_path}/ventoy.cpio $2 $1
vt_load_cpio ${vtoy_path}/ventoy.cpio $2 $1 "busybox=$ventoy_busybox_ver"
vt_linux_clear_initrd
@ -594,7 +594,7 @@ function legacy_linux_menu_func {
loopback loop $1$2
fi
vt_load_cpio $vtoy_path/ventoy.cpio $2 $1
vt_load_cpio $vtoy_path/ventoy.cpio $2 $1 "busybox=$ventoy_busybox_ver"
vt_linux_clear_initrd
@ -709,32 +709,6 @@ function legacy_iso_memdisk {
boot
}
function iso_deepin_live_proc {
if [ -d (loop)/ ]; then
loopback -d loop
fi
loopback loop ${1}${2}
vt_img_sector ${1}${2}
vt_load_cpio $vtoy_path/ventoy.cpio $2 $1
vt_trailer_cpio $1 $2 noinit
ventoy_debug_pause
vt_set_boot_opt rdinit=/ventoy/loop/deepin/ventoy-init.sh live-media=/dev/mapper/ventoy
set ventoy_loading_tip="Loading files ......"
linux (loop)/live/vmlinuz boot=live components locales=zh_CN.UTF-8 splash quiet
initrd (loop)/live/initrd.img
boot
unset ventoy_loading_tip
vt_unset_boot_opt
}
function iso_endless_os_proc {
if [ -d (loop)/ ]; then
@ -744,7 +718,7 @@ function iso_endless_os_proc {
loopback loop ${1}${2}
vt_img_sector ${1}${2}
vt_load_cpio $vtoy_path/ventoy.cpio $2 $1
vt_load_cpio $vtoy_path/ventoy.cpio $2 $1 "busybox=$ventoy_busybox_ver"
vt_trailer_cpio $1 $2 noinit
ventoy_debug_pause
@ -765,6 +739,18 @@ function iso_endless_os_proc {
vt_unset_boot_opt
}
function ventoy_iso_busybox_ver {
set ventoy_busybox_ver=32
#special process for deepin-live iso
if [ "$vt_chosen_size" = "403701760" ]; then
if vt_str_begin $vt_chosen_path "/deepin-live"; then
set ventoy_busybox_ver=64
fi
fi
}
function iso_common_menuentry {
unset vt_system_id
unset vt_volume_id
@ -772,13 +758,8 @@ function iso_common_menuentry {
vt_chosen_img_path vt_chosen_path vt_chosen_size
vt_parse_iso_volume ${vtoy_iso_part}${vt_chosen_path} vt_system_id vt_volume_id
#special process for deepin-live iso
if [ "$vt_chosen_size" = "403701760" ]; then
if vt_str_begin $vt_chosen_path "/deepin-live"; then
iso_deepin_live_proc $vtoy_iso_part $vt_chosen_path
fi
fi
ventoy_iso_busybox_ver
#special process for Endless OS
if vt_str_begin $vt_volume_id "Endless-OS"; then
iso_endless_os_proc $vtoy_iso_part $vt_chosen_path
@ -853,8 +834,15 @@ function efi_unsupport_menuentry {
}
function ventoy_img_busybox_ver {
set ventoy_busybox_ver=32
if [ -e (vtimghd,2)/etc/openwrt_release ]; then
if vt_file_strstr (vtimghd,2)/etc/openwrt_release x86_64; then
set ventoy_busybox_ver=64
fi
fi
}
function img_common_menuentry {

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,48 @@
#
# Makefile
#
# Author: Lasse Collin <lasse.collin@tukaani.org>
#
# This file has been put into the public domain.
# You can do whatever you want with this file.
#
CC = /opt/diet64/bin/diet gcc -Os -std=gnu89
BCJ_CPPFLAGS = -DXZ_DEC_X86 -DXZ_DEC_POWERPC -DXZ_DEC_IA64 \
-DXZ_DEC_ARM -DXZ_DEC_ARMTHUMB -DXZ_DEC_SPARC
CPPFLAGS = -DXZ_USE_CRC64 -DXZ_DEC_ANY_CHECK
CFLAGS = -ggdb3 -O2 -pedantic -Wall -Wextra
RM = rm -f
VPATH = ../linux/include/linux ../linux/lib/xz
COMMON_SRCS = xz_crc32.c xz_crc64.c xz_dec_stream.c xz_dec_lzma2.c xz_dec_bcj.c
COMMON_OBJS = $(COMMON_SRCS:.c=.o)
XZMINIDEC_OBJS = xzminidec.o
BYTETEST_OBJS = bytetest.o
BUFTEST_OBJS = buftest.o
BOOTTEST_OBJS = boottest.o
XZ_HEADERS = xz.h xz_private.h xz_stream.h xz_lzma2.h xz_config.h
PROGRAMS = xzminidec bytetest buftest boottest
ALL_CPPFLAGS = -I../linux/include/linux -I. $(BCJ_CPPFLAGS) $(CPPFLAGS)
all: $(PROGRAMS)
%.o: %.c $(XZ_HEADERS)
$(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c -o $@ $<
xzminidec: $(COMMON_OBJS) $(XZMINIDEC_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(XZMINIDEC_OBJS)
bytetest: $(COMMON_OBJS) $(BYTETEST_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BYTETEST_OBJS)
buftest: $(COMMON_OBJS) $(BUFTEST_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(COMMON_OBJS) $(BUFTEST_OBJS)
boottest: $(BOOTTEST_OBJS) $(COMMON_SRCS)
$(CC) $(ALL_CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(BOOTTEST_OBJS)
.PHONY: clean
clean:
-$(RM) $(COMMON_OBJS) $(XZMINIDEC_OBJS) $(BUFTEST_OBJS) \
$(BOOTTEST_OBJS) $(PROGRAMS)