Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Extract drivers to temporary folder #803

Merged
merged 5 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 34 additions & 30 deletions src/define.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,31 @@ validVersion() {
return 1
}

addFolder() {

local src="$1"
local folder="/oem"

[ ! -d "$folder" ] && folder="/OEM"
[ ! -d "$folder" ] && folder="$STORAGE/oem"
[ ! -d "$folder" ] && folder="$STORAGE/OEM"
[ ! -d "$folder" ] && return 0

local msg="Adding OEM folder to image..."
info "$msg" && html "$msg"

local dest="$src/\$OEM\$/\$1/OEM"
mkdir -p "$dest"

! cp -Lr "$folder/." "$dest" && return 1

local file
file=$(find "$dest" -maxdepth 1 -type f -iname install.bat | head -n 1)
[ -f "$file" ] && unix2dos -q "$file"

return 0
}

migrateFiles() {

local base="$1"
Expand Down Expand Up @@ -1665,7 +1690,7 @@ prepareInstall() {
local arch="$4"
local key="$5"
local driver="$6"
local drivers="/run/shm/drivers"
local drivers="/tmp/drivers"

rm -rf "$drivers"
mkdir -p "$drivers"
Expand Down Expand Up @@ -1723,8 +1748,8 @@ prepareInstall() {
fi

mkdir -p "$dir/\$OEM\$/\$1/Drivers/sata"
cp -a "$drivers/sata/xp/$arch/." "$dir/\$OEM\$/\$1/Drivers/sata"
cp -a "$drivers/sata/xp/$arch/." "$target"
cp -Lr "$drivers/sata/xp/$arch/." "$dir/\$OEM\$/\$1/Drivers/sata"
cp -Lr "$drivers/sata/xp/$arch/." "$target"

sed -i '/^\[SCSI.Load\]/s/$/\niaStor=iaStor.sys,4/' "$target/TXTSETUP.SIF"
sed -i '/^\[FileFlags\]/s/$/\niaStor.sys = 16/' "$target/TXTSETUP.SIF"
Expand All @@ -1749,23 +1774,14 @@ prepareInstall() {
warn "this version of $desc requires a volume license key (VLK), it will ask for one during installation."
fi

local oem=""
local folder="/oem"

[ ! -d "$folder" ] && folder="/OEM"
[ ! -d "$folder" ] && folder="$STORAGE/oem"
[ ! -d "$folder" ] && folder="$STORAGE/OEM"

if [ -d "$folder" ]; then

file=$(find "$folder" -maxdepth 1 -type f -iname install.bat | head -n 1)

if [ -f "$file" ]; then
unix2dos -q "$file"
oem="\"Script\"=\"cmd /C start \\\"Install\\\" \\\"cmd /C C:\\\\OEM\\\\install.bat\\\"\""
fi
if ! addFolder "$dir"; then
error "Failed to add OEM folder to image!" && return 1
fi

local oem=""
local install="$dir/\$OEM\$/\$1/OEM/install.bat"
[ -f "$install" ] && oem="\"Script\"=\"cmd /C start \\\"Install\\\" \\\"cmd /C C:\\\\OEM\\\\install.bat\\\"\""

[ -z "$YRES" ] && YRES="720"
[ -z "$XRES" ] && XRES="1280"

Expand Down Expand Up @@ -1958,18 +1974,6 @@ prepareInstall() {
echo ""
} | unix2dos > "$dir/\$OEM\$/cmdlines.txt"

[ ! -d "$folder" ] && return 0

msg="Adding OEM folder to image..."
info "$msg" && html "$msg"

local dest="$dir/\$OEM\$/\$1/"
mkdir -p "$dest"

if ! cp -r "$folder" "$dest"; then
error "Failed to copy OEM folder!" && return 1
fi

return 0
}

Expand Down
32 changes: 4 additions & 28 deletions src/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,9 @@ addDriver() {
esac

local dest="$path/$target/$driver"
mv "$path/$driver/$folder" "$dest"
mkdir -p "$dest"

cp -Lr "$path/$driver/$folder/." "$dest"
return 0
}

Expand Down Expand Up @@ -756,7 +757,7 @@ addDrivers() {
# Workaround Virtio GPU driver bug
local dst="$src/\$OEM\$/\$\$/Drivers"
mkdir -p "$dst"
! cp -a "$dest/." "$dst" && return 1
! cp -Lr "$dest/." "$dst" && return 1
rm -rf "$dest/viogpudo"
;;
esac
Expand All @@ -769,37 +770,12 @@ addDrivers() {
return 0
}

addFolder() {

local src="$1"
local folder="/oem"

[ ! -d "$folder" ] && folder="/OEM"
[ ! -d "$folder" ] && folder="$STORAGE/oem"
[ ! -d "$folder" ] && folder="$STORAGE/OEM"
[ ! -d "$folder" ] && return 0

local msg="Adding OEM folder to image..."
info "$msg" && html "$msg"

local dest="$src/\$OEM\$/\$1/OEM"
mkdir -p "$dest"

! cp -a "$folder/." "$dest" && return 1

local file
file=$(find "$dest" -maxdepth 1 -type f -iname install.bat | head -n 1)
[ -f "$file" ] && unix2dos -q "$file"

return 0
}

updateImage() {

local dir="$1"
local asset="$2"
local language="$3"
local tmp="/run/shm/img"
local tmp="/tmp/install"
local file="autounattend.xml"
local org="${file//.xml/.org}"
local dat="${file//.xml/.dat}"
Expand Down