Commit e98f835b authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Check the OSFAMILY correctness in InstallUnattend

If the OSFAMILY is 'windows', the NT Version must be at least 6.0. If
the OSFAMILY is 'windows-legacy', the NT Version must be less than 6.0.
parent aac04183
......@@ -829,9 +829,28 @@ get_windows_architecture() {
| tr [A-Z] [a-z]
}
get_windows_nt_version() {
local target hive current_version
target="$1"
hive="$target/windows/system32/config/software"
if [ ! -f "$hive" ]; then
log_error "File: \`$hive' does not exist"
fi
current_version=$($HIVEXGET "$hive" 'Microsoft\Windows NT\CurrentVersion' \
| grep ^'"CurrentVersion"=')
if [[ "$current_version" =~ \"CurrentVersion\"=\"([0-9]+)\.([0-9]+)\" ]]; then
echo ${BASH_REMATCH[1]} ${BASH_REMATCH[2]}
else
log_error "Can't decode CurrentVersion registry key: $current_version"
fi
}
check_if_root() {
local os fd device is_root args windows_fs linux_fs freebsd_fs netbsd_fs \
openbsd_fs supported_fs current_version hive major minor
openbsd_fs supported_fs major minor
osfamily="$1"
fs="$2"
......@@ -876,21 +895,12 @@ check_if_root() {
fi
;;
windows)
hive="$SNF_IMAGE_TARGET/windows/system32/config/software"
if [ -f "$hive" ]; then
is_root=yes
current_version=$($HIVEXGET "$hive" 'Microsoft\Windows NT\CurrentVersion' \
| grep ^'"CurrentVersion"=')
if [[ "$current_version" =~ \"CurrentVersion\"=\"([0-9]+)\.([0-9]+)\" ]]; then
major=${BASH_REMATCH[1]}
minor=${BASH_REMATCH[2]}
if [ -d "$SNF_IMAGE_TARGET/windows/system32" ]; then
read major minor <<<$(get_windows_nt_version "$SNF_IMAGE_TARGET")
if [ $major -lt 6 ]; then
# This windows version is older than Vista
osfamily='windows-legacy'
fi
else
warn "Can't decode windows version: $current_version"
osfamily="windows-legacy"
fi
is_root=yes
fi
;;
esac
......
......@@ -120,12 +120,12 @@ if ! check_yes_no SNF_IMAGE_PROPERTY_EXCLUDE_ALL_TASKS; then
detect_image_properties "$SNF_IMAGE_DEV"
if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = "" ]; then
echo "Detected OSFAMILY: $DETECTED_OSFAMILY"
warn "Detected OSFAMILY: $DETECTED_OSFAMILY"
export SNF_IMAGE_PROPERTY_OSFAMILY="$DETECTED_OSFAMILY"
fi
if [ "$SNF_IMAGE_PROPERTY_ROOT_PARTITION" = "" ]; then
echo "Detected ROOT_PARTITION: $DETECTED_ROOT_PARTITION"
warn "Detected ROOT_PARTITION: $DETECTED_ROOT_PARTITION"
export SNF_IMAGE_PROPERTY_ROOT_PARTITION="$DETECTED_ROOT_PARTITION"
fi
fi
......
......@@ -74,8 +74,13 @@ echo "del /Q /F C:\Windows\SnfScripts\ChangeAdminPassword.cmd" >> \
echo "rmdir C:\Windows\SnfScripts" >> \
"$target/Windows/Setup/Scripts/SetupComplete.cmd"
read nt_version_major nt_version_minor <<<$(get_windows_nt_version "$target")
if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = windows ]; then
if [ $nt_version_major -lt 6 ]; then
log_error "Windows image seems older than Vista. Use 'windows-legacy' as OSFAMILY"
fi
unattend=$(get_unattend "$target")
if test -n "$unattend" && ! check_yes_no SNF_IMAGE_PROPERTY_IGNORE_UNATTEND; then
warn "Using the Unattend.xml file found in the image"
......@@ -132,6 +137,10 @@ if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = windows ]; then
fi
elif [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = "windows-legacy" ]; then
if [ $nt_version_major -ge 6 ]; then
log_error "Windows image is not legacy. Use 'windows' as OSFAMILY"
fi
# If using an old-style (XP / Server 2003) SYSPREP.INF answer file,
# ensure C:\SnfScripts\SetupComplete.cmd is executed via CmdLines.txt
# which must be installed in the InstalledfilesPath from SYSPREP.INF.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment