Compiling UE4, I'm not certain how to manage/create installation packages

Hi,

I’ve installed Unreal Engine via the process of…

Downloading the Source

Then from…

https://wiki.archlinux.org/title/Unreal_Engine_4#Compile_manually_from_source_code

Install via

$ ./Setup.sh
Generate project files:

$ ./GenerateProjectFiles.sh
Then compile:

$ make -j6

This installed Unreal Engine and placed a shortcut in the menu.

Unfortunately the shortcut is broken because the drive I compiled it on is labelled with spaces in it, i.e Project Resources 1. My bad, I should have renamed them to use underscores or periods, these are Windows NTFS drives.

I think it might be sensible to remove the install and start again, but I don’t know how to uninstall this now :frowning:

What I want to do is compile and install UE 4.6, 4.7 and 5 and have them as three separate icons on my desktop linking to the three separate builds in three separate folders, in a manner that will allow me to uninstall them easily if I want to.

From doing some reading up on this I get the impression that I could write a PKGBUILD, i.e a shell script containing the build information required by Arch Linux packages. This will allow me to use pacman to easily install and uninstall packages.

I’m struggling to grasp how I can go from the compilation/installation process above to one that uses a PKGBUILD file.

From Creating a PKGBUILD to Make Packages for Arch Linux - It's FOSS and PKGBUILD - ArchWiki

  1. Write a PKGBUILD within which you write exactly how you installed the program inside the build() function.

Go into the UE4.6 source code folder and create two files

touch PKGBUILD UE4.26.sh
 
Edit PKGBUILD
 
pkgname="UnrealEngine4.26"
pkgver="4.26.0"
pkgdesc="Unreal Engine 4.26"
arch=("x86_64")
license=("custom")

Fine so far, but after this bit in the guide though I’m getting confused with the next bit that’s meant to go in the PKGBUILD so would really appreciate some guidance. I was hoping to get some guidance from looking at the PKGBUILD in the AUR for 4.26 but that looks extremely confusing. Would anyone be able to tell me what the paragraph below should look like?

PKGBUILD
file.txt
src/file.sh
 
source=("UE4.26.sh"
sha512sums=("SKIP")
 
package() {
  echo 'Hello to you!' > "${srcdir}/hello-world.sh"
  mkdir -p "${pkgdir}/usr/bin"
  cp "${srcdir}/hello-world.sh" "${pkgdir}/usr/bin/hello-world"
  chmod +x "${pkgdir}/usr/bin/hello-world"
}

Stage 2 seems pretty straightforward to follow.

  1. makepkg

This will create a pkgname.pkg.tar.zst file that can then be installed with pacman.

(Install a ‘local’ package that is not from a remote repository (e.g. the package is from the AUR):slight_smile:

pacman -Uf <pkg.tar.gz>

To remove a single package, leaving all of its dependencies installed

pacman -R <pkgname>

To remove a package and its dependencies which are not required by any other installed package:

pacman -Rs package_name

Sorry if this is long winded. I’ve just started with Manjaro, and my first attempt at compiling anything was a couple of weeks ago on Ubuntu, so I’m still learning.

Thanks :slight_smile:

Hello,

You can build it from http://aur.archlinux.org/packages/unreal-engine
pamac build unreal-engine

Hi,

This is for 4.26.2-6. I want 4.26.2-6, 4.7 and 5 Preview 2 also. I ran into security issues trying to clone via git, and have had better success just downloading the source and compiling it myself. My issue is managing the install to make it easy to install/uninstall.

No problem, you can do that. Use the existing PKGBUILD from AUR to make your own.

1 Like

Hi bogdancovaciu, based upon the PKGBUILD on AUR it should look something like this with the git related cloning content removed?

pkgname=unreal-engine4.26
pkgver=4.26.2
pkgrel=6
pkgdesc='Unreal Engine 4.26'
arch=(x86_64)
depends=(icu sdl2 python lld xdg-user-dirs dos2unix)
optdepends=('qt5-base: qmake build system for projects'
            'cmake: build system for projects'
            'qtcreator: IDE for projects'
            'codelite: IDE for projects'
            'kdevelop: IDE for projects'
            'clion: IDE for projects')
license=(custom:UnrealEngine)
source=(com.unrealengine.UE4Editor.desktop
        ccache_executor.patch
        stop_mono_clone.patch
        clang_path_fix.patch)
sha256sums=('SKIP')
options=(!strip staticlibs) # Package is 3 Gib smaller with "strip" but it takes a long time and generates many warnings

_ccache_support=false # Patches for ccache. More optimizations might be needed.
_system_mono=false # Uses System mono for unreal. Must set UE_USE_SYSTEM_MONO in your environment for it to work after install.
_install_dir="opt/$pkgname" # Default engine installation directory. Can be useful if you do not have a lot of space in /opt directory.

if [[ $_ccache_support == true ]]
then
  depends+=(ccache)
fi

if [[ $_system_mono == true ]]
then
  depends+=(mono mono-msbuild)
fi

prepare() {

  # Apply custom patches
  patch -p1 -i "$srcdir/clang_path_fix.patch" # Replace Windows specific search with the correct path (used for -mode=GenerateClangDatabase in UBT)
  if [[ $_system_mono == true ]]
  then
    export UE_USE_SYSTEM_MONO=1
    patch -p1 -i "$srcdir/stop_mono_clone.patch"
  fi
  if [[ $_ccache_support == true ]]
  then
    patch -p1 -i "$srcdir/ccache_executor.patch"
  fi

  ./Setup.sh
}

build() {
  cd $pkgname
  Engine/Build/BatchFiles/RunUAT.sh BuildGraph -target="Make Installed Build Linux" -script=Engine/Build/InstalledEngineBuild.xml -set:WithDDC=false -set:HostPlatformOnly=true
}

package() {
  # Desktop entry
  if [[ "$_install_dir" != "opt/$pkgname" ]] # Set new path if dir changed
  then
    sed -i "5c\Path=/$_install_dir/Engine/Binaries/Linux/" com.unrealengine.UE4Editor4.26.desktop
    sed -i "6c\Exec=/$_install_dir/Engine/Binaries/Linux/UE4Editor %F" com.unrealengine.UE4Editor4.26.desktop
  fi
  install -Dm775 com.unrealengine.UE4Editor4.26.desktop "$pkgdir/usr/share/applications/com.unrealengine.UE4Editor4.26.desktop"
  
  cd $pkgname
  
  # Icon for Desktop entry
  install -Dm770 Engine/Source/Programs/UnrealVS/Resources/Preview.png "$pkgdir/usr/share/pixmaps/ue4editor.png"

  # License
  install -Dm770 LICENSE.md "$pkgdir/usr/share/licenses/UnrealEngine/LICENSE.md"
  
  # Engine
  install -dm770 "$pkgdir/$_install_dir/Engine"
  mv LocalBuilds/Engine/Linux/* "$pkgdir/$_install_dir"
}

I did a
sudo pacman -S base-devel
to install the perquisite packages and then
makepkg -si
to make the package
this errors with

com.unrealengine.UE4Editor.desktop was not found in the build directory and is not a URL.

so I will do some reading up and see if I can understand what is going off here.

Well, from what I’ve read so far it looks like PKGBUILD is for use for remote packages, so AUR examples are no good to me.

PKGBUILDS are just not-so-but-a-little-fancy install scripts. Not very different from a MAKEFILE.
They can source things locally or remotely … and be for personal or public use.
Its just that the most obvious way they are used is in the AUR - usually providing an arch-specific recipe for compiling something on your system that will be recognized/indexed/updated/managed by your package manager.
In order for you to have a ‘ready-to-install’ package like a .deb (in our case ‘some-package-666-x86_64.pkg.tar.zst’) someone, somewhere, needed to create and use a PKGBUILD.

I believe I have been able to cobble together the correct process from some trial and error and solutions to various PKGBUILD related issues on forums.

pkgname=UnrealEngine-4.26.2-release
pkgver=4.26.2
pkgrel=6
pkgdesc='Unreal Engine 4.26'
arch=(x86_64)
depends=(icu sdl2 python lld xdg-user-dirs dos2unix)
optdepends=('qt5-base: qmake build system for projects'
            'cmake: build system for projects'
            'qtcreator: IDE for projects'
            'codelite: IDE for projects'
            'kdevelop: IDE for projects'
            'clion: IDE for projects')
license=(custom:UnrealEngine)
#source=(com.unrealengine.UE4Editor.desktop
#        ccache_executor.patch
 #       stop_mono_clone.patch
 #       clang_path_fix.patch)
source=(UnrealEngine-4.26.2-release.tar.gz)
#sha256sums=('SKIP')
options=(!strip staticlibs) # Package is 3 Gib smaller with "strip" but it takes a long time and generates many warnings

_ccache_support=false # Patches for ccache. More optimizations might be needed.
_system_mono=false # Uses System mono for unreal. Must set UE_USE_SYSTEM_MONO in your environment for it to work after install.
_install_dir="opt/$pkgname" # Default engine installation directory. Can be useful if you do not have a lot of space in /opt directory.

if [[ $_ccache_support == true ]]
then
  depends+=(ccache)
fi

if [[ $_system_mono == true ]]
then
  depends+=(mono mono-msbuild)
fi

prepare() {

  # Apply custom patches
#  patch -p1 -i "$srcdir/clang_path_fix.patch" # Replace Windows specific search with the correct path (used for -mode=GenerateClangDatabase in UBT)
#  if [[ $_system_mono == true ]]
#  then
#    export UE_USE_SYSTEM_MONO=1
#    patch -p1 -i "$srcdir/stop_mono_clone.patch"
#  fi
#  if [[ $_ccache_support == true ]]
#  then
#    patch -p1 -i "$srcdir/ccache_executor.patch"
#  fi

./Setup.sh
}

build() {
  cd $pkgname
  Engine/Build/BatchFiles/RunUAT.sh BuildGraph -target="Make Installed Build Linux" -script=Engine/Build/InstalledEngineBuild.xml -set:WithDDC=false -set:HostPlatformOnly=true
}

package() {
  # Desktop entry
  if [[ "$_install_dir" != "opt/$pkgname" ]] # Set new path if dir changed
  then
    sed -i "5c\Path=/$_install_dir/Engine/Binaries/Linux/" com.unrealengine.UE4Editor.desktop
    sed -i "6c\Exec=/$_install_dir/Engine/Binaries/Linux/UE4Editor %F" com.unrealengine.UE4Editor.desktop
  fi
  install -Dm775 com.unrealengine.UE4Editor4.26.desktop "$pkgdir/usr/share/applications/com.unrealengine.UE4Editor.desktop"
  
  cd $pkgname
  
  # Icon for Desktop entry
  install -Dm770 Engine/Source/Programs/UnrealVS/Resources/Preview.png "$pkgdir/usr/share/pixmaps/ue4editor.png"

  # License
  install -Dm770 LICENSE.md "$pkgdir/usr/share/licenses/UnrealEngine/LICENSE.md"
  
  # Engine
  install -dm770 "$pkgdir/$_install_dir/Engine"
  mv LocalBuilds/Engine/Linux/* "$pkgdir/$_install_dir"
}

Looks like it went well up until the desktop entry where I’d made a typo and it failed. Now my Add/Remove software opens and closes straight away. Rebooted, no joy. tried flatpak update from terminal no joy. Not sure how what I’ve done would have broken flatpack management :-/

 $ pamac-manager %U
** Message: 12:25:00.041: flatpak_plugin.vala:330: refreshing flathub appstream data
**
flatpak:ERROR:common/flatpak-variant-impl-private.h:1197:var_summary_get_metadata: assertion failed: (start <= end)
Bail out! flatpak:ERROR:common/flatpak-variant-impl-private.h:1197:var_summary_get_metadata: assertion failed: (start <= end)
Aborted (core dumped)

What fixed that was deleting .cache/flatpak/system-cache/summaries folder.

Anyway, after adding

source=(UnrealEngine-4.26.2-release.tar.gz
                com.UnrealEngineEditor4.26.desktop)
sha256sums=('SKIP')

and placing the com.UnrealEngineEditor4.26.desktop shortcut in the same directory I can’t seem to get it to skip the sha check.

==> ERROR: Integrity checks (sha256) differ in size from the source array

The addition of com.UnrealEngineEditor4.26.desktop to the source list seems be be what is causing the sha error issue.

You have 2 source and only 1 hash check, run updpkgsums for calculating the checksum automatically

Which security issue?

Thanks Lolix, I’ll give that a go.

The security issue was just me struggling to get git to authenticate to the Unreal Engine repository. I went through a guide, but couldn’t get it to authenticate. No doubt something I did wrong.

As I was happy enough to download the source directly and compile, I didn’t pursue it. I thought I’d just have a go at making a package for each main version so that I can easily install/uninstall them.