diff --git a/ue4docker/build.py b/ue4docker/build.py index 0bfb527d..adde62d7 100644 --- a/ue4docker/build.py +++ b/ue4docker/build.py @@ -138,13 +138,8 @@ def build(): logger.error('https://unrealcontainers.com/docs/concepts/windows-containers', False) sys.exit(1) - # Verify that the user is not attempting to build images with a newer kernel version than the host OS - if WindowsUtils.isNewerBaseTag(config.hostBasetag, config.basetag): - logger.error('Error: cannot build container images with a newer kernel version than that of the host OS!') - sys.exit(1) - # Check if the user is building a different kernel version to the host OS but is still copying DLLs from System32 - differentKernels = WindowsUtils.isInsiderPreview() or config.basetag != config.hostBasetag + differentKernels = config.basetag != config.hostBasetag if config.pullPrerequisites == False and differentKernels == True and config.dlldir == config.defaultDllDir: logger.error('Error: building images with a different kernel version than the host,', False) logger.error('but a custom DLL directory has not specified via the `-dlldir=DIR` arg.', False) diff --git a/ue4docker/diagnostics/base.py b/ue4docker/diagnostics/base.py index d974118f..bd726f2a 100644 --- a/ue4docker/diagnostics/base.py +++ b/ue4docker/diagnostics/base.py @@ -60,8 +60,7 @@ def _generateWindowsBuildArgs(self, logger, basetagOverride=None, isolationOverr ''' # Determine the appropriate container image base tag for the host system release unless the user specified a base tag - buildArgs = [] - defaultBaseTag = WindowsUtils.getReleaseBaseTag(WindowsUtils.getWindowsRelease()) + defaultBaseTag = WindowsUtils.getWindowsRelease() baseTag = basetagOverride if basetagOverride is not None else defaultBaseTag buildArgs = ['--build-arg', 'BASETAG={}'.format(baseTag)] diff --git a/ue4docker/infrastructure/BuildConfiguration.py b/ue4docker/infrastructure/BuildConfiguration.py index 247f82a7..23df47aa 100644 --- a/ue4docker/infrastructure/BuildConfiguration.py +++ b/ue4docker/infrastructure/BuildConfiguration.py @@ -228,29 +228,20 @@ def _generateWindowsConfig(self): self.dlldir = self.args.dlldir if self.args.dlldir is not None else self.defaultDllDir # Determine base tag for the Windows release of the host system - self.hostRelease = WindowsUtils.getWindowsRelease() - self.hostBasetag = WindowsUtils.getReleaseBaseTag(self.hostRelease) + self.hostBasetag = WindowsUtils.getWindowsRelease() # Store the tag for the base Windows Server Core image self.basetag = self.args.basetag if self.args.basetag is not None else self.hostBasetag self.baseImage = 'mcr.microsoft.com/windows/servercore:' + self.basetag self.prereqsTag = self.basetag - # Verify that any user-specified base tag is valid - if WindowsUtils.isValidBaseTag(self.basetag) == False: - raise RuntimeError('unrecognised Windows Server Core base image tag "{}", supported tags are {}'.format(self.basetag, WindowsUtils.getValidBaseTags())) - - # Verify that any user-specified tag suffix does not collide with our base tags - if WindowsUtils.isValidBaseTag(self.suffix) == True: - raise RuntimeError('tag suffix cannot be any of the Windows Server Core base image tags: {}'.format(WindowsUtils.getValidBaseTags())) - # If the user has explicitly specified an isolation mode then use it, otherwise auto-detect if self.args.isolation is not None: self.isolation = self.args.isolation else: # If we are able to use process isolation mode then use it, otherwise fallback to the Docker daemon's default isolation mode - differentKernels = WindowsUtils.isInsiderPreview() or self.basetag != self.hostBasetag + differentKernels = self.basetag != self.hostBasetag hostSupportsProcess = WindowsUtils.supportsProcessIsolation() dockerSupportsProcess = parse_version(DockerUtils.version()['Version']) >= parse_version('18.09.0') if not differentKernels and hostSupportsProcess and dockerSupportsProcess: diff --git a/ue4docker/infrastructure/WindowsUtils.py b/ue4docker/infrastructure/WindowsUtils.py index 33d73006..812efab5 100644 --- a/ue4docker/infrastructure/WindowsUtils.py +++ b/ue4docker/infrastructure/WindowsUtils.py @@ -7,12 +7,6 @@ class WindowsUtils(object): - # The latest Windows build version we recognise as a non-Insider build - _latestReleaseBuild = 19042 - - # The list of Windows Server Core base image tags that we recognise, in ascending version number order - _validTags = ['ltsc2016', '1709', '1803', 'ltsc2019', '1903', '1909', '2004', '20H2'] - # The list of Windows Server and Windows 10 host OS releases that are blacklisted due to critical bugs # (See: ) _blacklistedReleases = ['1903', '1909'] @@ -76,7 +70,13 @@ def getWindowsRelease() -> str: ''' Determines the Windows 10 / Windows Server release (1607, 1709, 1803, etc.) of the Windows host system ''' - return WindowsUtils._getVersionRegKey('ReleaseId') + try: + # Starting with Windows 20H2 (also known as 2009), Microsoft stopped updating ReleaseId + # and instead updates DisplayVersion + return WindowsUtils._getVersionRegKey('DisplayVersion') + except FileNotFoundError: + # Fallback to ReleaseId for pre-20H2 releases that didn't have DisplayVersion + return WindowsUtils._getVersionRegKey('ReleaseId') @staticmethod def getWindowsBuild() -> int: @@ -112,56 +112,6 @@ def isWindowsServer() -> bool: # TODO: Replace this with something more reliable return 'Windows Server' in WindowsUtils._getVersionRegKey('ProductName') - @staticmethod - def isInsiderPreview() -> bool: - ''' - Determines if the Windows host system is a Windows Insider preview build - ''' - return WindowsUtils.getWindowsBuild() > WindowsUtils._latestReleaseBuild - - @staticmethod - def getReleaseBaseTag(release: str) -> str: - ''' - Retrieves the tag for the Windows Server Core base image matching the specified Windows 10 / Windows Server release - ''' - - # For Windows Insider preview builds, build the latest release tag - if WindowsUtils.isInsiderPreview(): - return WindowsUtils._validTags[-1] - - # This lookup table is based on the list of valid tags from - return { - '1709': '1709', - '1803': '1803', - '1809': 'ltsc2019', - '1903': '1903', - '1909': '1909', - '2004': '2004', - '2009': '20H2', - '20H2': '20H2' - }.get(release, 'ltsc2016') - - @staticmethod - def getValidBaseTags() -> [str]: - ''' - Returns the list of valid tags for the Windows Server Core base image, in ascending chronological release order - ''' - return WindowsUtils._validTags - - @staticmethod - def isValidBaseTag(tag: str) -> bool: - ''' - Determines if the specified tag is a valid Windows Server Core base image tag - ''' - return tag in WindowsUtils._validTags - - @staticmethod - def isNewerBaseTag(older: str, newer: str) -> bool: - ''' - Determines if the base tag `newer` is chronologically newer than the base tag `older` - ''' - return WindowsUtils._validTags.index(newer) > WindowsUtils._validTags.index(older) - @staticmethod def supportsProcessIsolation() -> bool: '''