Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
v0.9.9.9
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyentumine committed Sep 5, 2020
1 parent 10220a4 commit dbc9b6b
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 54 deletions.
Binary file modified AIO/Tools/AIOCreator_x64.exe
Binary file not shown.
Binary file added AIO/Tools/DATA.IMG/Debian.data.7z
Binary file not shown.
Binary file added AIO/Tools/DATA.IMG/Ubuntu.data.7z
Binary file not shown.
4 changes: 4 additions & 0 deletions AIO/Tools/Win10PESE.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# GRUB Environment Block
# WARNING: Do not edit this file by tools other than grub-editenv!!!
[IsoInfo]
########################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
6 changes: 6 additions & 0 deletions AIO/grub/AliasCmds.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function linuxefi {
linux $@
}
function initrdefi {
initrd $@
}
2 changes: 1 addition & 1 deletion AIO/grub/Main.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ submenu "[${hotkey}] ${settings}" --hotkey=${hotkey} {
configfile ${prefix}/grub.cfg
}
GetHotkey
menuentry "[${hotkey}] Timeout" --hotkey=${hotkey} {
menuentry "[${hotkey}] ${timeoutmenu}" --hotkey=${hotkey} {
echo "${timeoutmsg}:"
read time_out
if regexp '^[0-9]+([0-9]+)?$' "$time_out"; then
Expand Down
182 changes: 138 additions & 44 deletions AIO/grub/functions.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ function helpmenu {
set pager=0
}

#function linuxefi {
# linux $@
#}

#function initrdefi {
# initrd $@
#}
if [ -n "$pc" ]; then
source ${prefix}/AliasCmds.cfg
fi

function strcontains {
set str="$1"
Expand All @@ -64,9 +60,10 @@ function GetDiskPartNum {

function Grub4dosRoot {
GetDiskPartNum
regexp -s g4dpartnum " ${partnum} ([0-9]+)" "31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0"
set g4droot="(hd${disknum},${g4dpartnum})"
set g4dpartnum="${partnum}"
decrement g4dpartnum
export g4dpartnum
set g4droot="(hd${disknum},${g4dpartnum})"
}

function WinLegacy {
Expand Down Expand Up @@ -536,8 +533,15 @@ function PartitionImageMapper {
echo "${frag1msg}"
stat --set=frag_partimg -c -q "/AIO/Files/PartIMG_ROOT.img"
stat --set=frag_file -c -q "$file"
if [ "${frag_partimg}" != "1" ] -o [ "${frag_file}" != "1" ];
then

unset datafile
set frag_datafile="1"
if [ -e "${file}.data" ]; then
set datafile="${file}.data"
stat --set=frag_datafile -c -q "$datafile"
fi

if [ "${frag_partimg}" != "1" ] -o [ "${frag_file}" != "1" ] -o [ "${frag_datafile}" != "1" ]; then
echo "${errormsg}: Code 0x0001"
echo "${frag2msg}"
if [ "${frag_partimg}" != "1" ];
Expand All @@ -548,10 +552,15 @@ function PartitionImageMapper {
then
esc 1 "${file} (${frag_file} fragments)"
fi
if [ "${frag_datafile}" != "1" ];
then
esc 1 "${datafile} (${frag_datafile} fragments)"
fi
return 1
fi
unset frag_file
unset frag_partimg
unset frag_datafile
echo "${donemsg}"

Grub4dosRoot
Expand All @@ -563,27 +572,28 @@ function PartitionImageMapper {
echo "${donemsg}"

echo "${filefs1msg}"
loopback -l filefs "$file"
loopback fileloop "$file"
unset _fstype
unset _filefs
probe -f -s _filefs filefs
probe -f -s _filefs fileloop

if [ -z "$_filefs" ]; then
for _filepart in (filefs,*); do
for _filepart in (fileloop,*); do
if ! probe -f -s _filefs $_filepart; then
continue
else
set filepart=${_filepart}
unset _filepart
break
fi
done
fi

set maptype="FD"
if [ "$_filefs" == "iso9660" ] -o [ "$_filefs" == "udf" ]; then
if [ -e ${filepart}/netbsd ]; then
if [ -e (fileloop)/netbsd ] -o [ -e ${filepart}/netbsd ]; then
set _fstype=0xA9
elif [ -e ${filepart}/*/*/bsd.rd ]; then
elif [ -e (fileloop)/*/*/bsd.rd ] -o [ -e ${filepart}/*/*/bsd.rd ]; then
set _fstype=0xA6
else
set _fstype=0xA8
Expand All @@ -594,8 +604,13 @@ function PartitionImageMapper {
elif [ "$_filefs" == "ntfs" ] -o [ "$_filefs" == "exfat" ]; then
set _fstype=0x07
elif [ "$_filefs" == "ufs1" ] -o [ "$_filefs" == "ufs2" ]; then
if [ -e ${filepart}/netbsd ]; then
if [ -e ${filepart}/netbsd ] -o [ -e (fileloop)/netbsd ]; then
set _fstype=0xA9
elif regexp -s 1:_disk -s 2:_part '^\(([a-z0-9]+)\,([a-z0-9]+)\,dfly' "$filepart"; then
set filepart="(${_disk},${_part})"
unset _disk
unset _part
set _fstype=0x6C
else
set _fstype=0xA5
fi
Expand All @@ -609,21 +624,44 @@ function PartitionImageMapper {
esc 1 "${filefs2msg}"
return 1
fi

if [ -n "$datafile" ]; then
loopback dataloop "$datafile"
unset _datafs
probe -f -s _datafs dataloop
if [ "$_datafs" == "ext2" ]; then
set _datafs=0x83
elif [ "$_datafs" == "fat" ]; then
set _datafs=0x0C
elif [ "$_datafs" == "ntfs" ] -o [ "$_datafs" == "exfat" ]; then
set _datafs=0x07
elif [ "$_datafs" == "ufs1" ] -o [ "$_datafs" == "ufs2" ]; then
set _datafs=0xA5
elif [ "$_datafs" == "hfsplus" ] -o [ "$_datafs" == "hfs" ]; then
set _datafs=0xAF
elif [ "$_datafs" == "sfs" ]; then
set _datafs=0xBF
else
set _datafs=0x00
fi
loopback -d dataloop
fi
echo "${donemsg}"

blocklist --disk --set=fileblocklist "${file}"
blocklist --disk --set=imgblocklist "/AIO/Files/PartIMG_ROOT.img"

if [ -n "$filepart" ]; then
regexp -s 1:fileoffset -s 2:filesectors '(.*)\+(.*)' "$fileblocklist"
stat -s partsectors -z $filepart
stat -s partoffset -o $filepart
stat -q -s partsectors -z $filepart
stat -q -s partoffset -o $filepart
expr -s partsectors $partsectors/512
expr -s partoffset ${fileoffset}+${partoffset}
set file=(hd${disknum})${partoffset}+${partsectors}
set maptype="HD"
fi
loopback -d filefs
loopback -d fileloop

if [ "$_filefs" == "fat" ] -o [ "$_filefs" == "ntfs" ] -o [ "$_filefs" == "exfat" ]; then
for partfile in 1 2 3 4; do
if [ "$partnum" != "$partfile" ]; then
Expand All @@ -647,9 +685,16 @@ function PartitionImageMapper {
fi
done
fi
if [ -n "$datafile" ]; then
for partdata in 1 2 3 4; do
if [ "$partnum" != "$partdata" ] -a [ "$partpartimg" != "$partdata" ] -a [ "$partfile" != "$partdata" ]; then
break;
fi
done
fi

echo "${file} --> hd${disknum},${scheme}${partfile}"
if ! partnew --type=${_fstype} --file="${file}" hd${disknum} ${partfile}; then
if ! partnew --type=${_fstype} --active --file="${file}" hd${disknum} ${partfile}; then
esc 1 "${errormsg}: Code 0x0003"
return 1
fi
Expand All @@ -658,7 +703,6 @@ function PartitionImageMapper {
dd --if=(hd${disknum})1+1 --of=(hd${disknum},${scheme}${partfile})/AIO/aioboot_img.mbr --bs=512 --count=1
fi


echo "/AIO/Files/PartIMG_ROOT.img --> hd${disknum},${scheme}${partpartimg}"
if ! partnew --type=0xEF --file="/AIO/Files/PartIMG_ROOT.img" hd${disknum} ${partpartimg}; then
esc 1 "${errormsg}: Code 0x0004"
Expand All @@ -668,7 +712,27 @@ function PartitionImageMapper {
if [ -e (hd${disknum},${scheme}${partpartimg})/AIO/aioboot.mbr ]; then
dd --if=(hd${disknum})1+1 --of=(hd${disknum},${scheme}${partpartimg})/AIO/aioboot.mbr --bs=512 --count=1
fi


if [ -n "$datafile" ]; then
echo "${datafile} --> hd${disknum},${scheme}${partdata}"
if ! partnew --type=${_datafs} --file="${datafile}" hd${disknum} ${partdata}; then
esc 1 "${errormsg}: Code 0x0005"
return 1
fi
echo "${donemsg}"
fi

if [ -e "${file}.cfg" ]; then
mount (hd${disknum},${scheme}${partpartimg}) 9
cp "${file}.cfg" "9:/grub2cfg.cfg"
umount 9
parttool hd${disknum},${scheme}${partnum} type=0x00
set root=hd${disknum},${scheme}${partfile}
terminal_output console
configfile "(hd${disknum},${scheme}${partpartimg})/grub2cfg.cfg"
return 0
fi

parttool hd${disknum},${scheme}${partnum} type=0x00
if [ -n "$efi" ]; then
map -x vd0
Expand All @@ -677,39 +741,54 @@ function PartitionImageMapper {
fi
if map (hd${disknum})${fileblocklist} -t ${maptype} vd0; then
if [ -n "$filepart" ]; then
regexp -s _part '\(filefs(.*)\)' "$filepart"
regexp -s _part '\(fileloop(.*)\)' "$filepart"
unset filepart

set root=vd0${_part}
if [ -e /efi/microsoft/boot/bcd ]; then
for _grub_path in /*/*/grub.cfg; do
regexp -s _grub_path '^(.*)\/grub\.cfg$' "$_grub_path"
set prefix=${_grub_path}
rmmod progress
terminal_output console
configfile ${_grub_path}/grub.cfg
return 0
done
fi
else
set root=vd0
fi

if [ -e /efi/microsoft/boot/bcd ]; then
for _grub_path in /*/*/grub.cfg; do
regexp -s _grub_path '^(.*)\/grub\.cfg$' "$_grub_path"
set prefix=${_grub_path}
rmmod progress
terminal_output console
configfile ${_grub_path}/grub.cfg
return 0
done
fi
if [ -e /FreeNAS ]; then
for _efifile in (vd0,*)/efi/boot/bootx64.efi; do
chainloader -b $_efifile
return 0
if chainloader -b $_efifile; then
return 0
fi
done
elif [ -e /boot/loader.efi ]; then
chainloader -b /boot/loader.efi
return 0
fi
if [ -e /boot/loader.efi ]; then
if chainloader -b /boot/loader.efi; then
return 0
fi
fi
if [ -e /boot/boot1.efi ]; then
if chainloader -b /boot/boot1.efi; then
return 0
fi
fi

if [ -e /efi/boot/grub${_SPEC_UEFI_ARCH}.efi ]; then
chainloader -b /efi/boot/grub${_SPEC_UEFI_ARCH}.efi
fi
boot
else
set root=vd0
if [ -n "$filepart" ]; then
regexp -s _part '\(fileloop(.*)\)' "$filepart"
unset filepart
set root=vd0${_part}
else
set root=vd0
fi

if [ -e /efi/boot/boot${_SPEC_UEFI_ARCH}.efi ]; then
chainloader -b /efi/boot/boot${_SPEC_UEFI_ARCH}.efi
fi
Expand Down Expand Up @@ -753,7 +832,6 @@ function FileProcessing {
filename="$2"
file_ext="$3"

tr -D -s file_ext "$file_ext"
regexp -s 1:loopdev -s 2:path '\((.*)\)(.*)' "$file"

if [ "$file_ext" == "iso" ]; then
Expand Down Expand Up @@ -802,6 +880,8 @@ function FileProcessing {
initrd16 ${g4d_path}/winvblk.img;
fi
}
elif test -e (isoloop)/CdUsb.Y -o -e (isoloop)/Win10PE.cd -o -e (isoloop)/Win8PE.cd; then
WinBuilderISO "${path}" "${loopdev}"
elif test -e (isoloop)/boot/grub/loopback.cfg -o -e (isoloop)/efi/boot/loopback.cfg -o -e (isoloop)/boot/grub/loopback.cfg; then
for cfg in /boot/grub/loopback.cfg /efi/boot/loopback.cfg /EFI/BOOT/loopback.cfg; do
if ! test -e (isoloop)$cfg; then continue; fi
Expand Down Expand Up @@ -1067,6 +1147,8 @@ function FileProcessing {
elif regexp "tinycore.gz" "$cfgtext"; then
set root=isoloop
if regexp 'linux' "$cfg"; then syslinux_configfile $cfg; else configfile $cfg; fi
else
map_and_boot "${path}" "${loopdev}"
fi
done
else
Expand Down Expand Up @@ -1154,6 +1236,7 @@ function FileManager {
}
elif test -f "$file"; then
if ! regexp -s file_ext '\.([^!/.]+)$' "$file"; then continue; fi
tr -D -s file_ext "$file_ext"
if [ -n "$file_ext_args" ]; then
set _ok="0"
for _file_ext in $file_ext_args; do
Expand Down Expand Up @@ -1220,7 +1303,7 @@ function memdiskcmd {

loopback _loop "${1}"
if probe -s _fs -f _loop; then
if [ "$_fs" == "iso9660" ]; then
if [ "$_fs" == "iso9660" ] -o [ "$_fs" == "udf" ]; then
set param="iso raw"
else
set param="fd raw"
Expand All @@ -1246,7 +1329,7 @@ function map_and_boot {

loopback _loop "${_file}"
if probe -s _fs -f _loop; then
if [ "$_fs" == "iso9660" ]; then
if [ "$_fs" == "iso9660" ] -o [ "$_fs" == "udf" ]; then
set param="CD"
else
set param="FD"
Expand All @@ -1268,4 +1351,15 @@ function map_and_boot {
esc 1 "${nobootablemsg}"
fi
boot
}

function WinBuilderISO {
regexp -s IsoName '^.(.*)$' "${1}"
for _ini in Win10PESE.ini Win8PESE.ini Win7PESE.ini; do
if [ -e /${_ini} ]; then
save_env -f /${_ini} IsoName
fi
done
unset IsoName
map_and_boot "${1}" "${2}"
}
Loading

0 comments on commit dbc9b6b

Please sign in to comment.