From 3b0ec0d72b6fb368dc1bc8446d4101ef1627e389 Mon Sep 17 00:00:00 2001 From: jyelon Date: Mon, 8 Sep 2025 16:42:16 -0400 Subject: [PATCH] Modify build system to properly handle unreal version upgrades --- README.md | 18 +------- ...gine.zip => UnrealEngine-5.5.4-release.zip | 0 build.py | 44 ++++++++++++++----- 3 files changed, 34 insertions(+), 28 deletions(-) rename UnrealEngine.zip => UnrealEngine-5.5.4-release.zip (100%) diff --git a/README.md b/README.md index 072594cc..2675453f 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,7 @@ SOFTWARE YOU WILL NEED Before attempting anything, install the following software: - apt-get install git-lfs - apt-get install code - apt-get install dotnet6 - apt-get install clangd-15 or better. + apt-get install git-lfs code dotnet6 clangd-15 Everything else you need should be included in PopOS. If that's not the case, let me know. @@ -22,22 +19,11 @@ not the case, let me know. GETTING THE CODE -You will need to clone two git repositories: +You will need to clone our repository: cd $HOME - git clone https://github.com/EpicGames/UnrealEngine.git git clone https://www.gnaut.com/team/integration.git -The two clone commands above are a simplification. In reality, -cloning these two repositories will require you to jump through -some hoops to get access from Epic Games. Follow the steps to -get access from Epic's website, but only go as far as cloning -the repository. Once the repository is cloned, we will take it -from there with our own "build.py". - -It is important that these two repositories be located -at $HOME/UnrealEngine and $HOME/integration. - HOW TO BUILD THE FIRST TIME diff --git a/UnrealEngine.zip b/UnrealEngine-5.5.4-release.zip similarity index 100% rename from UnrealEngine.zip rename to UnrealEngine-5.5.4-release.zip diff --git a/build.py b/build.py index b1ac8361..c3aee301 100755 --- a/build.py +++ b/build.py @@ -51,6 +51,20 @@ def read_if_exists(fn): try: return Path(fn).read_text() except: return "" +# +# Fix a chmod bug in the Zipfile module. +# + +class JZipFile(zipfile.ZipFile): + def _extract_member(self, member, targetpath, pwd): + if not isinstance(member, zipfile.ZipInfo): + member = self.getinfo(member) + targetpath = super()._extract_member(member, targetpath, pwd) + attr = member.external_attr >> 16 + if attr != 0: + os.chmod(targetpath, attr) + return targetpath + # # A JSON preprocessor. # @@ -191,20 +205,26 @@ def unzip_unreal_engine_and_apply_patch(): """ Unzip the unreal engine source, then apply a patch. """ - if not Path(UNREALENGINE).is_dir(): - zipfn = f"{INTEGRATION}/UnrealEngine.zip"; - with zipfile.ZipFile(zipfn, 'r') as z: - version = z.namelist()[0].split('/')[0] - if not fnmatch.fnmatch(version, 'UnrealEngine-*-release'): - sys.exit("UnrealEngine.zip does not contain UnrealEngine-*-release") - unrealversion = os.path.join(INTEGRATION, version) + zips = list(Path(INTEGRATION).glob("UnrealEngine-*-release.zip")) + if len(zips) == 0: + sys.exit("Cannot find UnrealEngine-*-release.zip") + if len(zips) > 1: + sys.exit("Found multiple files matching UnrealEngine-*-release.zip") + print("Unreal version: ", zips[0].stem) + zipfn = os.path.join(INTEGRATION, zips[0].name) + extracted = os.path.join(INTEGRATION, zips[0].stem) + touchfile = os.path.join(UNREALENGINE, zips[0].stem) + if not Path(touchfile).is_file(): + print("Removing old version of unreal engine source...") shutil.rmtree(UNREALENGINE, ignore_errors=True) - shutil.rmtree(unrealversion, ignore_errors=True) - print("Unzipping UnrealEngine.zip...") - shell(INTEGRATION, "unzip -q UnrealEngine.zip") + shutil.rmtree(extracted, ignore_errors=True) + print(f"Unzipping {zipfn}...") + with JZipFile(zipfn) as zf: + zf.extractall(INTEGRATION) patchfile = f"{INTEGRATION}/EnginePatches/EnginePatch" - shell(unrealversion, f"patch -p1 < {patchfile}") - Path(unrealversion).rename(UNREALENGINE) + shell(extracted, f"patch -p1 < {patchfile}") + Path(extracted).rename(UNREALENGINE) + Path(touchfile).touch() def generate_buildconfiguration_xml():