MacOS and Windows support TEST

This commit is contained in:
zenobit 2023-03-14 06:29:24 +01:00
parent 3f2bc926c4
commit 2c544e1a36
2 changed files with 604 additions and 8 deletions

View file

@ -8,13 +8,7 @@ Welcome to
quickly create and run VMs
As a base my FOSS fork of excellent [quickemu](https://github.com/quickemu-project/quickemu)
Removed:
Windows support (Currently not intended)
MacoOS support (Currently not intended)
As a base excellent [quickemu](https://github.com/quickemu-project/quickemu)
I added:
@ -180,6 +174,9 @@ with your preferred flavour.
- `xerolinux` (XeroLinux)
- `zorin` (Zorin OS)
- `macos` (MacOS)
- `windows` (Windows)
### Testing version!
# Without these amazing projects it wouldn't be posible:

601
quickget
View file

@ -61,6 +61,7 @@ function pretty_name() {
netboot) PRETTY_NAME="netboot.xyz";;
netbsd) PRETTY_NAME="NetBSD";;
nixos) PRETTY_NAME="NixOS";;
macos) PRETTY_NAME="macOS";;
openbsd) PRETTY_NAME="OpenBSD";;
opensuse) PRETTY_NAME="openSUSE";;
oraclelinux) PRETTY_NAME="Oracle Linux";;
@ -147,7 +148,9 @@ function list_csv() {
SVG="https://quickemu-project.github.io/quickemu-icons/svg/${FUNC}/${FUNC}-quickemu-white-pinkbg.svg"
for RELEASE in $("releases_${FUNC}"); do
if [ "${OS}" == "ubuntu" ] && [ "${RELEASE}" == "canary" ] && [ ${HAS_ZSYNC} -eq 1 ]; then
if [ "${OS}" == "macos" ]; then
DOWNLOADER="macrecovery"
elif [ "${OS}" == "ubuntu" ] && [ "${RELEASE}" == "canary" ] && [ ${HAS_ZSYNC} -eq 1 ]; then
DOWNLOADER="zsync"
elif [[ "${OS}" == *"ubuntu"* ]] && [ "${RELEASE}" == "devel" ] && [ ${HAS_ZSYNC} -eq 1 ]; then
DOWNLOADER="zsync"
@ -160,6 +163,10 @@ function list_csv() {
for OPTION in $(editions_"${OS}"); do
echo "${DISPLAY_NAME},${OS},${RELEASE},${OPTION},${DOWNLOADER},${PNG},${SVG}"
done
elif [ "${OS}" == "windows" ]; then
for OPTION in "${LANGS[@]}"; do
echo "${DISPLAY_NAME},${OS},${RELEASE},${OPTION},${DOWNLOADER},${PNG},${SVG}"
done
else
echo "${DISPLAY_NAME},${OS},${RELEASE},,${DOWNLOADER},${PNG},${SVG}"
fi
@ -211,6 +218,7 @@ function os_support() {
netbsd \
nixos \
lubuntu \
macos \
openbsd \
opensuse \
oraclelinux \
@ -235,6 +243,7 @@ function os_support() {
void \
voidpup \
vxlinux \
windows \
xerolinux \
xubuntu \
zorin
@ -465,6 +474,10 @@ function editions_mageia(){
echo Plasma GNOME Xfce
}
function releases_macos() {
echo high-sierra mojave catalina big-sur monterey ventura
}
function releases_manjaro() {
echo xfce \
gnome \
@ -679,6 +692,51 @@ function releases_vxlinux() {
echo 6.1.2 6.1 5.0 4.2 4.1 4.0.
}
function releases_windows() {
echo 8 10 11
}
function languages_windows() {
LANGS=(Arabic
"Brazilian Portuguese"
Bulgarian
"Chinese (Simplified)"
"Chinese (Traditional)"
Croatian
Czech
Danish
Dutch
English
"English International"
Estonian
Finnish
French
"French Canadian"
German
Greek
Hebrew
Hungarian
Italian
Japanese
Korean
Latvian
Lithuanian
Norwegian
Polish
Portuguese
Romanian
Russian
"Serbian Latin"
Slovak
Slovenian
Spanish
"Spanish (Mexico)"
Swedish
Thai
Turkish
Ukrainian)
}
function releases_xerolinux() {
echo kde
}
@ -815,6 +873,9 @@ function make_vm_config() {
kolibrios)
GUEST="kolibrios"
IMAGE_TYPE="iso";;
macos)
GUEST="macos"
IMAGE_TYPE="img";;
netbsd)
GUEST="netbsd"
IMAGE_TYPE="iso";;
@ -827,6 +888,9 @@ function make_vm_config() {
truenas*)
GUEST="truenas"
IMAGE_TYPE="iso";;
windows)
GUEST="windows"
IMAGE_TYPE="iso";;
*)
GUEST="linux"
IMAGE_TYPE="iso";;
@ -903,7 +967,26 @@ EOF
echo "disk_size=\"12G\"" >> "${CONF_FILE}"
echo "ram=\"2048M\"" >> "${CONF_FILE}"
;;
macos)
echo "macos_release=\"${RELEASE}\"" >> "${CONF_FILE}"
# https://github.com/quickemu-project/quickemu/issues/438
if [ "${RELEASE}" == "monterey" ]; then
echo "cpu_cores=2" >> "${CONF_FILE}"
fi
;;
esac
# Enable TPM for Windows 11
if [ "${OS}" == "windows" ] && [ "${RELEASE}" -ge 11 ]; then
echo "tpm=\"on\"" >> "${CONF_FILE}"
# Only force SecureBoot on for non-Debian/Ubuntu distros.
if [ -e "/usr/share/OVMF/OVMF_CODE_4M.fd" ] && [ -e "/usr/share/OVMF/OVMF_VARS_4M.fd" ]; then
SEC_BOOT="off"
else
SEC_BOOT="on"
fi
echo "secureboot=\"${SEC_BOOT}\"" >> "${CONF_FILE}"
fi
fi
echo
echo "To start your $(pretty_name "${OS}") virtual machine run:"
@ -1409,6 +1492,94 @@ function get_lmde() {
echo "${URL}/${ISO} ${HASH}"
}
function get_macos() {
local BOARD_ID=""
local CWD=""
local MACRECOVERY=""
local MLB="00000000000000000"
local OS_TYPE="default"
case ${RELEASE} in
lion) #10.7
BOARD_ID="Mac-2E6FAB96566FE58C"
MLB="00000000000F25Y00";;
mountainlion) #10.8
BOARD_ID="Mac-7DF2A3B5E5D671ED"
MLB="00000000000F65100";;
mavericks) #10.9
BOARD_ID="Mac-F60DEB81FF30ACF6"
MLB="00000000000FNN100";;
yosemite) #10.10
BOARD_ID="Mac-E43C1C25D4880AD6"
MLB="00000000000GDVW00";;
elcapitan) #10.11
BOARD_ID="Mac-FFE5EF870D7BA81A"
MLB="00000000000GQRX00";;
sierra) #10.12
BOARD_ID="Mac-77F17D7DA9285301"
MLB="00000000000J0DX00";;
high-sierra) #10.13
BOARD_ID="Mac-BE088AF8C5EB4FA2"
MLB="00000000000J80300";;
mojave) #10.14
BOARD_ID="Mac-7BA5B2DFE22DDD8C"
MLB="00000000000KXPG00";;
catalina) #10.15
BOARD_ID="Mac-00BE6ED71E35EB86";;
big-sur) #11
BOARD_ID="Mac-42FD25EABCABB274";;
monterey) #12
BOARD_ID="Mac-E43C1C25D4880AD6";;
ventura) #13
echo "ERROR! Not yet supported: ${RELEASE}"
exit 1;;
*) echo "ERROR! Unknown release: ${RELEASE}"
releases_macos
exit 1;;
esac
# Use a bundled macrecovery if possible
CWD="$(dirname "${0}")"
if [ -x "${CWD}/macrecovery" ]; then
MACRECOVERY="${CWD}/macrecovery"
elif [ -x /usr/bin/macrecovery ]; then
MACRECOVERY="/usr/bin/macrecovery"
else
web_get "https://raw.githubusercontent.com/wimpysworld/quickemu/master/macrecovery" "${HOME}/.quickemu"
MACRECOVERY="python3 ${HOME}/.quickemu/macrecovery"
fi
if [ -z "${MACRECOVERY}" ]; then
echo "ERROR! Can not find a usable macrecovery."
exit 1
fi
# Get firmware
web_get "https://github.com/kholia/OSX-KVM/raw/master/OpenCore/OpenCore.qcow2" "${VM_PATH}"
web_get "https://github.com/kholia/OSX-KVM/raw/master/OVMF_CODE.fd" "${VM_PATH}"
if [ ! -e "${VM_PATH}/OVMF_VARS-1024x768.fd" ]; then
web_get "https://github.com/kholia/OSX-KVM/raw/master/OVMF_VARS-1024x768.fd" "${VM_PATH}"
fi
if [ ! -e "${VM_PATH}/RecoveryImage.chunklist" ]; then
echo "Downloading ${RELEASE}..."
${MACRECOVERY} \
--board-id "${BOARD_ID}" \
--mlb "${MLB}" \
--os-type "${OS_TYPE}" \
--basename RecoveryImage \
--outdir "${VM_PATH}" \
download
fi
if [ -e "${VM_PATH}/RecoveryImage.dmg" ] && [ ! -e "${VM_PATH}/RecoveryImage.img" ]; then
echo "Converting RecoveryImage..."
qemu-img convert "${VM_PATH}/RecoveryImage.dmg" -O raw "${VM_PATH}/RecoveryImage.img" 2>/dev/null
fi
make_vm_config RecoveryImage.img
}
function get_mageia() {
local EDITION="${1:-}"
local ISO=$(wget -q https://www.mageia.org/en/downloads/get/?q="Mageia-${RELEASE}-Live-${EDITION}-x86_64.iso" -O- | grep 'click here'| grep -o 'href=.*\.iso'|cut -d\" -f2)
@ -1773,6 +1944,411 @@ function get_zorin() {
echo "${URL} ${HASH}"
}
function unattended_windows() {
cat << 'EOF' > "${1}"
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend"
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--
For documentation on components:
https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/
-->
<settings pass="offlineServicing">
<component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<EnableLUA>false</EnableLUA>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ComputerName>*</ComputerName>
</component>
</settings>
<settings pass="generalize">
<component name="Microsoft-Windows-PnPSysprep" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
<PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
</component>
<component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkipRearm>1</SkipRearm>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkipAutoActivation>true</SkipAutoActivation>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ComputerName>*</ComputerName>
<OEMInformation>
<Manufacturer>Quickemu Project</Manufacturer>
<Model>Quickemu</Model>
<SupportHours>24/7</SupportHours>
<SupportPhone></SupportPhone>
<SupportProvider>Quickemu Project</SupportProvider>
<SupportURL>https://github.com/quickemu-project/quickemu/issues</SupportURL>
</OEMInformation>
<OEMName>Quickemu Project</OEMName>
<ProductKey>W269N-WFGWX-YVC9B-4J6C9-T83GX</ProductKey>
</component>
<component name="Microsoft-Windows-SQMApi" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CEIPEnabled>0</CEIPEnabled>
</component>
</settings>
<settings pass="windowsPE">
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Diagnostics>
<OptIn>false</OptIn>
</Diagnostics>
<DiskConfiguration>
<Disk wcm:action="add">
<DiskID>0</DiskID>
<WillWipeDisk>true</WillWipeDisk>
<CreatePartitions>
<!-- Windows RE Tools partition -->
<CreatePartition wcm:action="add">
<Order>1</Order>
<Type>Primary</Type>
<Size>256</Size>
</CreatePartition>
<!-- System partition (ESP) -->
<CreatePartition wcm:action="add">
<Order>2</Order>
<Type>EFI</Type>
<Size>128</Size>
</CreatePartition>
<!-- Microsoft reserved partition (MSR) -->
<CreatePartition wcm:action="add">
<Order>3</Order>
<Type>MSR</Type>
<Size>128</Size>
</CreatePartition>
<!-- Windows partition -->
<CreatePartition wcm:action="add">
<Order>4</Order>
<Type>Primary</Type>
<Extend>true</Extend>
</CreatePartition>
</CreatePartitions>
<ModifyPartitions>
<!-- Windows RE Tools partition -->
<ModifyPartition wcm:action="add">
<Order>1</Order>
<PartitionID>1</PartitionID>
<Label>WINRE</Label>
<Format>NTFS</Format>
<TypeID>DE94BBA4-06D1-4D40-A16A-BFD50179D6AC</TypeID>
</ModifyPartition>
<!-- System partition (ESP) -->
<ModifyPartition wcm:action="add">
<Order>2</Order>
<PartitionID>2</PartitionID>
<Label>System</Label>
<Format>FAT32</Format>
</ModifyPartition>
<!-- MSR partition does not need to be modified -->
<ModifyPartition wcm:action="add">
<Order>3</Order>
<PartitionID>3</PartitionID>
</ModifyPartition>
<!-- Windows partition -->
<ModifyPartition wcm:action="add">
<Order>4</Order>
<PartitionID>4</PartitionID>
<Label>Windows</Label>
<Letter>C</Letter>
<Format>NTFS</Format>
</ModifyPartition>
</ModifyPartitions>
</Disk>
</DiskConfiguration>
<DynamicUpdate>
<Enable>true</Enable>
<WillShowUI>Never</WillShowUI>
</DynamicUpdate>
<ImageInstall>
<OSImage>
<InstallTo>
<DiskID>0</DiskID>
<PartitionID>4</PartitionID>
</InstallTo>
<InstallToAvailablePartition>false</InstallToAvailablePartition>
</OSImage>
</ImageInstall>
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">
<Order>1</Order>
<Path>reg add HKLM\System\Setup\LabConfig /v BypassCPUCheck /t REG_DWORD /d 0x00000001 /f</Path>
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">
<Order>2</Order>
<Path>reg add HKLM\System\Setup\LabConfig /v BypassRAMCheck /t REG_DWORD /d 0x00000001 /f</Path>
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">
<Order>3</Order>
<Path>reg add HKLM\System\Setup\LabConfig /v BypassSecureBootCheck /t REG_DWORD /d 0x00000001 /f</Path>
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">
<Order>4</Order>
<Path>reg add HKLM\System\Setup\LabConfig /v BypassTPMCheck /t REG_DWORD /d 0x00000001 /f</Path>
</RunSynchronousCommand>
</RunSynchronous>
<UpgradeData>
<Upgrade>false</Upgrade>
<WillShowUI>Never</WillShowUI>
</UpgradeData>
<UserData>
<AcceptEula>true</AcceptEula>
<FullName>Quickemu</FullName>
<Organization>Quickemu Project</Organization>
<!-- https://docs.microsoft.com/en-us/windows-server/get-started/kms-client-activation-keys -->
<ProductKey>
<Key>W269N-WFGWX-YVC9B-4J6C9-T83GX</Key>
<WillShowUI>Never</WillShowUI>
</ProductKey>
</UserData>
</component>
<component name="Microsoft-Windows-PnpCustomizationsWinPE" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="amd64" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--
This makes the VirtIO drivers available to Windows, assuming that
the VirtIO driver disk is available as drive E:
https://github.com/virtio-win/virtio-win-pkg-scripts/blob/master/README.md
-->
<DriverPaths>
<PathAndCredentials wcm:action="add" wcm:keyValue="1">
<Path>E:\qemufwcfg\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="2">
<Path>E:\vioinput\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="3">
<Path>E:\vioscsi\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="4">
<Path>E:\viostor\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="5">
<Path>E:\vioserial\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="6">
<Path>E:\qxldod\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="7">
<Path>E:\amd64\w10</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="8">
<Path>E:\viogpudo\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="9">
<Path>E:\viorng\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="10">
<Path>E:\NetKVM\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="11">
<Path>E:\viofs\w10\amd64</Path>
</PathAndCredentials>
<PathAndCredentials wcm:action="add" wcm:keyValue="12">
<Path>E:\Balloon\w10\amd64</Path>
</PathAndCredentials>
</DriverPaths>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AutoLogon>
<Password>
<Value>quickemu</Value>
<PlainText>true</PlainText>
</Password>
<Enabled>true</Enabled>
<Username>Quickemu</Username>
</AutoLogon>
<DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
<OOBE>
<HideEULAPage>true</HideEULAPage>
<HideLocalAccountScreen>true</HideLocalAccountScreen>
<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
<NetworkLocation>Home</NetworkLocation>
<ProtectYourPC>3</ProtectYourPC>
<SkipUserOOBE>true</SkipUserOOBE>
<SkipMachineOOBE>true</SkipMachineOOBE>
<VMModeOptimizations>
<SkipWinREInitialization>true</SkipWinREInitialization>
</VMModeOptimizations>
</OOBE>
<UserAccounts>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Password>
<Value>quickemu</Value>
<PlainText>true</PlainText>
</Password>
<Description>Quickemu</Description>
<DisplayName>Quickemu</DisplayName>
<Group>Administrators</Group>
<Name>Quickemu</Name>
</LocalAccount>
</LocalAccounts>
</UserAccounts>
<RegisteredOrganization>Quickemu Project</RegisteredOrganization>
<RegisteredOwner>Quickemu</RegisteredOwner>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<CommandLine>msiexec /i E:\guest-agent\qemu-ga-x86_64.msi /quiet /passive /qn</CommandLine>
<Description>Install Virtio Guest Agent</Description>
<Order>1</Order>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>msiexec /i F:\spice-webdavd-x64-latest.msi /quiet /passive /qn</CommandLine>
<Description>Install spice-webdavd file sharing agent</Description>
<Order>2</Order>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>msiexec /i F:\UsbDk_1.0.22_x64.msi /quiet /passive /qn</CommandLine>
<Description>Install usbdk USB sharing agent</Description>
<Order>3</Order>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>msiexec /i F:\spice-vdagent-x64-0.10.0.msi /quiet /passive /qn</CommandLine>
<Description>Install spice-vdagent SPICE agent</Description>
<Order>4</Order>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>Cmd /c POWERCFG -H OFF</CommandLine>
<Description>Disable Hibernation</Description>
<Order>5</Order>
</SynchronousCommand>
</FirstLogonCommands>
</component>
</settings>
</unattend>
EOF
}
function dbg_windows() {
local DEBUG=0
if [ ${DEBUG} -eq 1 ]; then
echo "${1}"
fi
}
# Adapted from https://gist.github.com/hongkongkiwi/15a5bf16437315df256c118c163607cb
function get_windows() {
# Use the API to automatically download a Windows .iso image
# The API we were using is unmaintained and not currently functional
# 0 : Prompt for a manual ISO download
# 1 : Use the API for automated download
local API_GUIDED_DOWNLOAD=0
local ARCH="x64"
local INDEX=0
local LANG_CODE="en"
local LANG_EDITION="${1}"
local LATEST_WINDOWS_VERSION=""
local WINDOWS_NAME=""
local WINDOWS_ISO_URL=""
local VERSION_ID=""
local EDITION_ID=""
local LANGUAGE_ID=""
local FILE_NAME=""
local ARCH_ID=""
local DOWNLOAD_INFO=""
local DOWNLOAD_ID=""
local DOWNLOAD_URL=""
if [ ${API_GUIDED_DOWNLOAD} -eq 1 ]; then
# Ignore the most recent Windows 10 release for now.
case ${RELEASE} in
10) INDEX=0;;
11) INDEX=0;;
esac
echo "Getting Windows ${RELEASE} URL..."
WINDOWS_VERSIONS=$(wget -4 -q -O- "https://tb.rg-adguard.net/php/get_version.php?type_id=1" | jq '.versions | sort_by(-(.version_id | tonumber))')
dbg_windows "${WINDOWS_VERSIONS}"
LATEST_WINDOWS_VERSION=$(echo "${WINDOWS_VERSIONS}" | jq -c 'map(select(.name | contains("Windows '"${RELEASE}"'")))['${INDEX}']')
dbg_windows "${LATEST_WINDOWS_VERSION}"
WINDOWS_NAME=$(echo "${LATEST_WINDOWS_VERSION}" | jq -r .name)
dbg_windows "${WINDOWS_NAME}"
VERSION_ID=$(echo "${LATEST_WINDOWS_VERSION}" | jq -r .version_id)
dbg_windows "${VERSION_ID}"
case ${RELEASE} in
8) EDITION_ID=$(wget -4 -q -O- "https://tb.rg-adguard.net/php/get_edition.php?version_id=${VERSION_ID}&lang=name_${LANG_CODE}" | jq -r '.editions[] | select(.name_'${LANG_CODE}'=="Windows 8.1 Pro + Core").edition_id');;
10|11) EDITION_ID=$(wget -4 -q -O- "https://tb.rg-adguard.net/php/get_edition.php?version_id=${VERSION_ID}&lang=name_${LANG_CODE}" | jq -r '.editions[] | select(.name_'${LANG_CODE}'=="Windows '"${RELEASE}"'").edition_id');;
esac
dbg_windows "${EDITION_ID}"
LANGUAGE_ID=$(wget -4 -q -O- "https://tb.rg-adguard.net/php/get_language.php?edition_id=${EDITION_ID}&lang=name_${LANG_CODE}" | jq -r '.languages[] | select(.name_'${LANG_CODE}'=="'"${LANG_EDITION}"'").language_id')
dbg_windows "${LANGUAGE_ID}"
ARCH_INFO=$(wget -4 -q -O- "https://tb.rg-adguard.net/php/get_arch.php?language_id=${LANGUAGE_ID}")
dbg_windows "${ARCH_INFO}"
FILE_NAME=$(echo "${ARCH_INFO}" | jq -r '.archs[] | select(.name | contains("'${ARCH}'")).name')
dbg_windows "${FILE_NAME}"
ARCH_ID=$(echo "${ARCH_INFO}" | jq -r '.archs[] | select(.name | contains("'${ARCH}'")).arch_id')
dbg_windows "${ARCH_ID}"
DOWNLOAD_INFO=$(wget -4 -q -O- "https://tb.rg-adguard.net/dl.php?fileName=${ARCH_ID}&lang=en")
dbg_windows "${DOWNLOAD_INFO}"
DOWNLOAD_SHA1=$(echo "${DOWNLOAD_INFO}" | sed -e 's/<[^>]*>//g' | grep -o -P '(?<=SHA1: ).*(?= expire)' | sed 's/Link//')
dbg_windows "${DOWNLOAD_SHA1}"
DOWNLOAD_ID=$(echo "${DOWNLOAD_INFO}" | grep -oP '(?<=https:\/\/tb\.rg-adguard\.net/dl\.php\?go=)[0-9a-z]+')
dbg_windows "${DOWNLOAD_ID}"
REDIRECT_URL="https://tb.rg-adguard.net/dl.php?go=${DOWNLOAD_ID}"
dbg_windows "${REDIRECT_URL}"
DOWNLOAD_URL=$(curl --head --silent --write-out "%{redirect_url}\n" --output /dev/null "${REDIRECT_URL}")
dbg_windows "${DOWNLOAD_URL}"
MS_BASE_URL="https://software.download.prss.microsoft.com/"
if [[ ! ${DOWNLOAD_URL} =~ ^${MS_BASE_URL} ]]; then
echo "Download URL not leading to Microsoft CDN"
exit 1
fi
echo "Downloading ${WINDOWS_NAME}..."
web_get "${DOWNLOAD_URL}" "${VM_PATH}" "${FILE_NAME}"
# Windows 10 doesn't include a SHA1, so only check the integrity if the SHA1 is available.
if [ -n "${DOWNLOAD_SHA1}" ]; then
check_hash "${FILE_NAME}" "${DOWNLOAD_SHA1}"
fi
else
case ${RELEASE} in
10) WINDOWS_ISO_URL="https://www.microsoft.com/software-download/windows10";;
11) WINDOWS_ISO_URL="https://www.microsoft.com/software-download/windows11";;
esac
echo "######################################################################"
echo "# Download a Windows ${RELEASE} .iso image from:"
echo "# - ${WINDOWS_ISO_URL}"
echo "# Put the .iso image in the ${VM_PATH} directory and rename"
echo "# it to windows-${RELEASE}.iso."
echo "######################################################################"
fi
web_get "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso" "${VM_PATH}"
rm -f "${VM_PATH}/unattended.iso"
case ${RELEASE} in
10|11)
echo "Making unattended.iso"
mkdir -p "${VM_PATH}/unattended" 2>/dev/null
web_get https://www.spice-space.org/download/windows/spice-webdavd/spice-webdavd-x64-latest.msi "${VM_PATH}/unattended"
web_get https://www.spice-space.org/download/windows/vdagent/vdagent-win-0.10.0/spice-vdagent-x64-0.10.0.msi "${VM_PATH}/unattended"
web_get https://www.spice-space.org/download/windows/usbdk/UsbDk_1.0.22_x64.msi "${VM_PATH}/unattended"
unattended_windows "${VM_PATH}/unattended/autounattend.xml"
mkisofs -quiet -l -o "${VM_PATH}/unattended.iso" "${VM_PATH}/unattended/"
;;
esac
case "${API_GUIDED_DOWNLOAD}" in
0) make_vm_config "windows-${RELEASE}.iso" "virtio-win.iso";;
1) make_vm_config "${FILE_NAME}" "virtio-win.iso";;
esac
}
create_vm() {
# shellcheck disable=SC2206
local URL_HASH=(${1// / })
@ -1817,6 +2393,10 @@ if ((BASH_VERSINFO[0] < 4)); then
echo "Sorry, you need bash 4.0 or newer to run this script."
exit 1
fi
LANGS=()
languages_windows
if [ -n "${1}" ]; then
OS="${1,,}"
if [ "${OS}" == "list" ] || [ "${OS}" == "list_csv" ]; then
@ -1940,6 +2520,10 @@ if [ -n "${2}" ]; then
VM_PATH="${OS}-${RELEASE}-${EDITION}"
validate_release "releases_${OS}"
create_vm "$("get_${OS}" "${EDITION}")"
elif [ "${OS}" == "macos" ]; then
# macOS doesn't use create_vm()
validate_release releases_macos
get_macos
elif [[ "${OS}" == *"ubuntu"* ]]; then
# Ubuntu doesn't use create_vm()
validate_release releases_ubuntu
@ -1948,6 +2532,21 @@ if [ -n "${2}" ]; then
# deepin doesn't use create_vm()
validate_release releases_deepin
get_deepin
elif [ "${OS}" == "windows" ]; then
LANG="English International"
if [ -n "${3}" ]; then
LANG="${3}"
if [[ ! ${LANGS[*]} =~ "${LANG}" ]]; then
echo -e "ERROR! ${LANG} is not a supported Windows language:\n"
for LANG in "${LANGS[@]}"; do
echo -n "${LANG} "
done
exit 1
fi
fi
# Windows doesn't use create_vm()
validate_release releases_windows
get_windows "${LANG}"
else
validate_release "releases_${OS}"
create_vm "$("get_${OS}")"