diff --git a/windows/Makefile b/windows/Makefile index 4869a1ac..35b681bc 100644 --- a/windows/Makefile +++ b/windows/Makefile @@ -22,15 +22,24 @@ else EDIT ?= SERVERSTANDARD endif +ifeq ($(wildcard /usr/share/OVMF/OVMF_CODE.fd),) + OVMF_SFX ?= _4M +else + OVMF_SFX ?= +endif + .PHONY: all clean all: windows $(eval $(call check_packages_deps,cloud-image-utils ovmf,cloud-image-utils ovmf)) +OVMF_VARS.fd: /usr/share/OVMF/OVMF_VARS*.fd + cp -v $< $@ + http/Autounattend.xml: http/Autounattend.xml.${BOOT}.template sed s#@VERSION@#"${TYPE} ${VERSION} ${EDIT}"#g $< > $@ -ifneq ($(strip $(PKEY)),) +ifneq ($(strip $(PKEY1)),) sed -i s#@PKEY@#${PKEY}#g $@ sed -i 's//<\/ProductKey>/' $@ endif @@ -40,10 +49,17 @@ else ifeq ($(strip $(VERSION)),11) sed -i 's//<\/LocalAccounts>/' $@ endif -.INTERMEDIATE: http/Autounattend.xml +extra_drivers: + mkisofs -o drivers.iso -V 'Extra Drivers' -input-charset utf-8 drivers + +.INTERMEDIATE: extra_drivers http/Autounattend.xml -windows: check-deps clean http/Autounattend.xml - ${PACKER} init . && ${PACKER} build -var iso_path=${ISO} -var headless=${HEADLESS} windows.pkr.hcl +windows: check-deps clean extra_drivers http/Autounattend.xml OVMF_VARS.fd + ${PACKER} init . && ${PACKER} build -var iso_path=${ISO} \ + -var headless=${HEADLESS} \ + -var ovmf_suffix=${OVMF_SFX} \ + windows.pkr.hcl clean: - ${RM} -rf output-* windows.dd.gz http/Autounattend.xml + ${RM} -rf output-* windows.tar.gz http/Autounattend.xml \ + drivers.iso OVMF_VARS.fd diff --git a/windows/drivers/README.md b/windows/drivers/README.md new file mode 100644 index 00000000..b474103d --- /dev/null +++ b/windows/drivers/README.md @@ -0,0 +1,14 @@ +#### Extra Windows drivers +Place all extra Windows drivers under infs directory. + +Please note that these drivers will be installed using +dpinst.exe which does not support scanning sub directories. + +This requires all drivers to be present directly under the +infs directory. + +These can include custom Windows drivers needed by certain +hardware components to function, either becuase the drivers +are not natively availble in Windows or would require extra +optimization. + diff --git a/windows/drivers/infs/.gitignore b/windows/drivers/infs/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/windows/drivers/infs/.gitkeep b/windows/drivers/infs/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/windows/http/logon.ps1 b/windows/http/logon.ps1 index 89d47291..02e5a7ec 100644 --- a/windows/http/logon.ps1 +++ b/windows/http/logon.ps1 @@ -63,7 +63,7 @@ try # Download the WDK installer. $Host.UI.RawUI.WindowTitle = "Downloading Windows Driver Kit..." [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - Invoke-WebRequest "http://download.microsoft.com/download/0/8/C/08C7497F-8551-4054-97DE-60C0E510D97A/wdk/wdksetup.exe" -Outfile "c:\wdksetup.exe" + Invoke-WebRequest "https://download.microsoft.com/download/8/6/9/86925F0F-D57A-4BA4-8278-861B6876D78E/wdk/wdksetup.exe" -Outfile "c:\wdksetup.exe" # Run the installer. $Host.UI.RawUI.WindowTitle = "Installing Windows Driver Kit..." @@ -75,7 +75,7 @@ try # Run dpinst.exe with the path to the drivers. $Host.UI.RawUI.WindowTitle = "Injecting Windows drivers..." - $dpinst = "$programFilesDir\Windows Kits\8.1\redist\DIFx\dpinst\EngMui\$archDir\dpinst.exe" + $dpinst = "$ENV:ProgramFiles (x86)\Windows Kits\8.1\redist\DIFx\dpinst\EngMui\x64\dpinst.exe" Start-Process -Wait -FilePath "$dpinst" -ArgumentList "/S /C /F /SA /Path E:\infs" # Uninstall the WDK diff --git a/windows/windows.pkr.hcl b/windows/windows.pkr.hcl index 5c7acbeb..4241e060 100644 --- a/windows/windows.pkr.hcl +++ b/windows/windows.pkr.hcl @@ -1,8 +1,3 @@ -variable "iso_path" { - type = string - default = "" -} - packer { required_version = ">= 1.7.0" required_plugins { @@ -19,6 +14,22 @@ variable "headless" { description = "Whether VNC viewer should not be launched." } +variable "iso_path" { + type = string + default = "" +} + +variable "ovmf_suffix" { + type = string + default = "_4M" +} + +variable "filename" { + type = string + default = "windows.dd.gz" + description = "The filename of the tarball to produce" +} + source "qemu" "windows_builder" { accelerator = "kvm" boot_command = [""] @@ -38,7 +49,13 @@ source "qemu" "windows_builder" { cpus = "2" net_device = "e1000" qemuargs = [ - ["-serial", "stdio"], ["-bios", "/usr/share/OVMF/OVMF_CODE.fd"] + ["-serial", "stdio"], + ["-drive", "if=pflash,format=raw,id=ovmf_code,readonly=on,file=/usr/share/OVMF/OVMF_CODE${var.ovmf_suffix}.fd"], + ["-drive", "if=pflash,format=raw,id=ovmf_vars,file=OVMF_VARS.fd"], + ["-drive", "file=output-windows_builder/packer-windows_builder,format=raw"], + ["-cdrom", "${var.iso_path}"], + ["-drive", "file=drivers.iso,media=cdrom,index=3"], + ["-boot", "d"] ] shutdown_timeout = "45m" vnc_bind_address = "0.0.0.0" @@ -66,6 +83,6 @@ build { inline_shebang = "/bin/bash -e" } post-processor "compress" { - output = "windows.dd.gz" + output = "${var.filename}" } }