Subject: [bug#59716] [PATCH] Add tes3mp

From: Michal Atlas <[email-masked]>
Date: Wed, 30 Nov 2022 23:31:44 +0000

* gnu/packages/game-development.scm (set-openmw-commit-version): New private-variable
* gnu/packages/game-development.scm (set-commit-version): New phase in tes3mp and tes3mp-server

---

Sorry,
I didn't notice that the official release tarball was from
tag `tes3mp-0.8.1` and not `0.8.1`.

On that note, I forced in version information to be able to
connect to standard 0.8.1 server instances from the binary release.
They'd refuse connection due to "version mismatch" otherwise.

Hardcoding the COMMITHASH is certainly ugly,
but the TAGHASH probably needs to be as well anyways, since
cmake normally generates it by running `git rev-list --tags --max-count=1` on the repo,
which I'm not sure if we want to do or can do in the build itself,
this at least ensures that the correct tag is always chosen.

Cheers.

---
 gnu/packages/game-development.scm | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/game-development.scm b/gnu/packages/game-development.scm
index 8136b22b3e..d1de36f93d 100644
--- a/gnu/packages/game-development.scm
+++ b/gnu/packages/game-development.scm
@@ -2914,6 +2914,16 @@ (define tes3mp-common-arguments
            #$(file-append crabnet "/build/lib/libRakNetLibStatic.a"))
           "-DOPENMW_USE_SYSTEM_RECASTNAVIGATION=ON"))
 
+(define set-openmw-commit-version
+  #~(substitute* "CMakeLists.txt"
+      ;; Used for version compatibility checks
+      ;; Commit the project was built with
+      (("set\\(OPENMW_VERSION_COMMITHASH \"\"\\)")
+       "set(OPENMW_VERSION_COMMITHASH \"68954091c54d0596037c4fb54d2812313b7582a1\")")
+      ;; points to 0.8.0 in 0.8.1 Release
+      (("set\\(OPENMW_VERSION_TAGHASH \"\"\\)")
+       "set(OPENMW_VERSION_TAGHASH \"000e8724cacaf0176f6220de111ca45098807e78\")")))
+
 (define-public tes3mp-server
   (package
     (name "tes3mp-server")
@@ -2935,16 +2945,18 @@ (define-public tes3mp-server
               (method git-fetch)
               (uri (git-reference
                     (url "https://github.com/TES3MP/TES3MP")
-                    (commit version)))
+                    (commit (string-append "tes3mp-" version))))
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "09gd1zia27fa5phz0xx375y89rdsvf9pgfmw4n38pp108gh6002c"))))
+                "16k3l2ky0wciy0xaxxm1kvl1z3725l6ikirldiycjhrvrkidbxpk"))))
     (arguments
      (list
       #:tests? #f
       #:phases
       #~(modify-phases %standard-phases
+          (add-before 'configure 'set-commit-version
+            (lambda _ #$set-openmw-commit-version))
           (add-before 'configure 'set-default-server-home
             (lambda _
                                         ; This lets the server always at least start up
@@ -2997,6 +3009,8 @@ (define-public tes3mp
       (list
        #:phases
        #~(modify-phases %standard-phases
+           (add-before 'configure 'set-commit-version
+             (lambda _ #$set-openmw-commit-version))
            ;; The check always fails and reports
            ;; version too old
            (add-before 'configure 'remove-ffmpeg-version-check

base-commit: b4be83b6ac7e2139bec5d3eaafcf8af6cbe50856
prerequisite-patch-id: d05b134d12be8b8184cd42f0d7cd435b0718894f
-- 
2.38.1