gnu: Add widelands.

* gnu/local.mk (widelands): New variable.
* gnu/packages/patches/widelands-system-wide_minizip.patch: New file.
(dist_patch_DATA): Register file above.

Co-authored-by: Nicolas Goaziou <mail@nicolasgoaziou.fr>
This commit is contained in:
Alberto Eleuterio Flores Guerrero 2020-06-17 11:45:17 +02:00 committed by Nicolas Goaziou
parent db23a54875
commit 9299da1362
No known key found for this signature in database
GPG key ID: DA00B4F048E92F2D
3 changed files with 262 additions and 0 deletions

View file

@ -1604,6 +1604,7 @@ dist_patch_DATA = \
%D%/packages/patches/wicd-get-selected-profile-fix.patch \ %D%/packages/patches/wicd-get-selected-profile-fix.patch \
%D%/packages/patches/wicd-urwid-1.3.patch \ %D%/packages/patches/wicd-urwid-1.3.patch \
%D%/packages/patches/wicd-wpa2-ttls.patch \ %D%/packages/patches/wicd-wpa2-ttls.patch \
%D%/packages/patches/widelands-system-wide_minizip.patch \
%D%/packages/patches/wmctrl-64-fix.patch \ %D%/packages/patches/wmctrl-64-fix.patch \
%D%/packages/patches/wmfire-update-for-new-gdk-versions.patch \ %D%/packages/patches/wmfire-update-for-new-gdk-versions.patch \
%D%/packages/patches/wordnet-CVE-2008-2149.patch \ %D%/packages/patches/wordnet-CVE-2008-2149.patch \

View file

@ -4401,6 +4401,114 @@ (define-public warzone2100
license:gpl2+ license:gpl2+
license:lgpl2.1+)))) license:lgpl2.1+))))
(define-public widelands
(package
(name "widelands")
(version "20")
(source
(origin
(method url-fetch)
(uri (string-append "https://launchpad.net/widelands/"
"build" version "/build" version "/+download/"
"widelands-build" version ".tar.bz2"))
(sha256
(base32 "1cmwfwk7j6yi2pwmm4rm57s23sdzasqf53nx6567sdagqyc4sn9q"))
(modules '((guix build utils)))
(snippet
'(begin
(delete-file-recursively "src/third_party/minizip")
#t))
(patches
;; Use system Minizip. Patch is provided by Debian, and discussed
;; upstream at <https://github.com/widelands/widelands/issues/399>.
(search-patches "widelands-system-wide_minizip.patch"))))
(build-system cmake-build-system)
(arguments
`(#:configure-flags
(let* ((out (assoc-ref %outputs "out"))
(share (string-append out "/share")))
(list (string-append "-DCMAKE_INSTALL_PREFIX=" out "/bin")
(string-append "-DWL_INSTALL_BASEDIR=" share "/widelands")
(string-append "-DWL_INSTALL_DATADIR=" share "/widelands")
"-DOPTION_BUILD_WEBSITE_TOOLS=OFF"
;; CMakeLists.txt does not handle properly RelWithDebInfo build
;; type. When used, no game data is installed!
"-DCMAKE_BUILD_TYPE=Release"))
#:phases
(modify-phases %standard-phases
(add-after 'unpack 'install-desktop-file-and-icons
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((share (string-append (assoc-ref outputs "out") "/share"))
(applications (string-append share "/applications"))
(icons (string-append share "/icons/hicolor")))
;; Move desktop entry.
(mkdir-p applications)
(copy-file "debian/org.widelands.widelands.desktop"
(string-append applications "/widelands.desktop"))
;; Install icons.
(for-each (lambda (size)
(let* ((dim (string-append size "x" size))
(apps (string-append icons "/" dim "/apps")))
(mkdir-p apps)
(copy-file (string-append "data/images/logos"
"/wl-ico-" size ".png")
(string-append apps "/widelands.png"))))
'("16" "32" "48" "64" "128"))
#t)))
(add-after 'unpack 'unbundle-fonts
;; Unbundle fonts already packaged in Guix. XXX: missing fonts are
;; amiri, Culmus, mmrCensus, Nakula, and Sinhala.
(lambda* (#:key inputs #:allow-other-keys)
(with-directory-excursion "data/i18n/fonts"
(for-each (lambda (font)
(delete-file-recursively font)
(symlink (string-append (assoc-ref inputs font)
"/share/fonts/truetype")
font))
'("DejaVu" "MicroHei")))
#t)))))
(native-inputs
`(("gettext" ,gettext-minimal)
("python" ,python-wrapper)))
(inputs
`(("boost" ,boost)
("glew" ,glew)
("icu4c" ,icu4c)
("libpng" ,libpng)
("minizip" ,minizip)
("sdl" ,(sdl-union (list sdl2 sdl2-image sdl2-mixer sdl2-ttf)))
("zlib" ,zlib)
;; Fonts for the unbundle-fonts phase. Case matters in name!
("DejaVu" ,font-dejavu)
("MicroHei" ,font-wqy-microhei)))
(home-page "https://www.widelands.org/")
(synopsis "Fantasy real-time strategy game")
(description
"In Widelands, you are the regent of a small clan. You start out with
nothing but your headquarters, where all your resources are stored.
In the course of the game, you will build an ever growing settlement. Every
member of your clan will do his or her part to produce more resources---wood,
food, iron, gold and more---to further this growth. The economic network is
complex and different in the four tribes (Barbarians, Empire, Atlanteans, and
Frisians).
As you are not alone in the world, you will meet other clans sooner or later.
Some of them may be friendly and you may eventually trade with them. However,
if you want to rule the world, you will have to train soldiers and fight.
Widelands offers single-player mode with different campaigns; the campaigns
all tell stories of tribes and their struggle in the Widelands universe!
However, settling really starts when you unite with friends over the Internet
or LAN to build up new empires together---or to crush each other in the dusts
of war. Widelands also offers an Artificial Intelligence to challenge you.")
;; Game is released as GPL2+. Some parts, e.g., art, are released under
;; different licenses.
(license (list license:gpl2+
license:expat ;src/third_party/eris
license:silofl1.1 ;Widelands.ttf
license:cc-by-sa3.0)))) ;some music files
(define-public starfighter (define-public starfighter
(package (package
(name "starfighter") (name "starfighter")

View file

@ -0,0 +1,153 @@
Description: use the system-wide minizip instead of the embeeded one if found.
Forwarded-Upstream: It was provided by upstream: http://bazaar.launchpad.net/~widelands-dev/widelands/b19-debian/revision/8147
.
Thanks to Fòram na Gàidhlig for the patch.
I just added this line to make its use easier:
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_HOME_DIRECTORY}/Modules)
=== modified file 'CMakeLists.txt'
---
CMakeLists.txt | 3 +++
Modules/FindMinizip.cmake | 37 +++++++++++++++++++++++++++++++++++++
cmake/WlFunctions.cmake | 7 +++++++
src/io/CMakeLists.txt | 2 +-
src/third_party/CMakeLists.txt | 20 +++++++++++---------
src/third_party/minizip/README.txt | 4 ++++
6 files changed, 63 insertions(+), 10 deletions(-)
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -43,6 +43,7 @@
endif(POLICY CMP0074)
include("${CMAKE_SOURCE_DIR}/cmake/WlFunctions.cmake")
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_HOME_DIRECTORY}/Modules)
option(OPTION_USE_GLBINDING "Use glbinding instead of GLEW" OFF)
option(OPTION_GLEW_STATIC "Use static GLEW Library" OFF)
@@ -105,6 +106,8 @@
find_package(SDL2_ttf REQUIRED)
find_package(ZLIB REQUIRED)
find_package(ICU REQUIRED)
+find_package(Minizip)
+
if(OPTION_USE_GLBINDING)
find_package(glbinding REQUIRED)
else()
--- /dev/null
+++ b/Modules/FindMinizip.cmake
@@ -0,0 +1,37 @@
+# - Try to find Minizip
+# Once done this will define
+#
+# MINIZIP_FOUND - system has MINIZIP
+# MINIZIP_INCLUDE_DIR - the MINIZIP include directory
+# MINIZIP_LIBRARY_DIR - where the libraries are
+# MINIZIP_LIBRARY - Link these to use MINIZIP
+#
+
+IF (MINIZIP_INCLUDE_DIR)
+ # Already in cache, be silent
+ SET(MINIZIP_FIND_QUIETLY TRUE)
+ENDIF (MINIZIP_INCLUDE_DIR)
+
+FIND_PATH( MINIZIP_INCLUDE_DIR
+ NAMES zip.h unzip.h ioapi.h
+ PATHS /usr/local/include /usr/include
+ PATH_SUFFIXES minizip/ )
+SET( MINIZIP_NAMES minizip MINIZIP )
+FIND_LIBRARY( MINIZIP_LIBRARY
+ NAMES ${MINIZIP_NAMES}
+ PATHS /usr/lib /usr/local/lib )
+
+GET_FILENAME_COMPONENT( MINIZIP_LIBRARY_DIR ${MINIZIP_LIBRARY} PATH )
+
+IF (MINIZIP_INCLUDE_DIR AND MINIZIP_LIBRARY)
+ SET(MINIZIP_FOUND TRUE)
+ SET(MINIZIP_LIBRARY_DIR ${MINIZIP_LIBRARY} )
+ IF (NOT MINIZIP_FIND_QUIETLY)
+ MESSAGE (STATUS "Found Minizip: ${MINIZIP_LIBRARY} ${MINIZIP_INCLUDE_DIR}")
+ ENDIF (NOT MINIZIP_FIND_QUIETLY)
+ELSE (MINIZIP_INCLUDE_DIR AND MINIZIP_LIBRARY)
+ SET( MINIZIP_FOUND FALSE )
+ SET( MINIZIP_LIBRARY_DIR )
+ SET( MINIZIP_EXTRA_DEFINITIONS )
+ENDIF (MINIZIP_INCLUDE_DIR AND MINIZIP_LIBRARY)
+
--- a/cmake/WlFunctions.cmake
+++ b/cmake/WlFunctions.cmake
@@ -81,6 +81,14 @@
if(ARG_USES_ZLIB)
wl_include_system_directories(${NAME} ${ZLIB_INCLUDE_DIRS})
target_link_libraries(${NAME} ${ZLIB_LIBRARY})
+ if (MINIZIP_FOUND)
+ wl_include_system_directories(${NAME} ${MINIZIP_INCLUDE_DIR})
+ target_link_libraries(${NAME} ${MINIZIP_LIBRARY})
+ target_compile_definitions(${NAME} PUBLIC -DHAVE_SYSTEM_MINIZIP)
+ else(MINIZIP_FOUND)
+ target_link_libraries(${NAME} third_party_minizip)
+ message(FATAL_ERROR "You are using widelands-bundled minizip sources. Please install your distribution's minizip dev library or urge your distribution maintainer to include the minizip library in your package repository. Thank you.")
+ endif(MINIZIP_FOUND)
endif()
# OpenGL and GLEW are one thing for us. If you use the one, you also use the
--- a/src/third_party/CMakeLists.txt
+++ b/src/third_party/CMakeLists.txt
@@ -1,12 +1,14 @@
-wl_library(third_party_minizip
- THIRD_PARTY
- SRCS
- minizip/ioapi.h
- minizip/unzip.cc
- minizip/unzip.h
- minizip/zip.h
- USES_ZLIB
-)
+if(NOT MINIZIP_FOUND)
+ wl_library(third_party_minizip
+ THIRD_PARTY
+ SRCS
+ ioapi.h
+ unzip.cc
+ unzip.h
+ zip.h
+ USES_ZLIB
+ )
+endif(NOT MINIZIP_FOUND)
wl_library(third_party_eris
THIRD_PARTY
--- a/src/io/filesystem/CMakeLists.txt
+++ b/src/io/filesystem/CMakeLists.txt
@@ -12,6 +12,7 @@
zip_exceptions.h
zip_filesystem.cc
zip_filesystem.h
+ USES_ZLIB
DEPENDS
base_exceptions
base_i18n
@@ -19,5 +20,4 @@
base_macros
graphic_text_layout
io_stream
- third_party_minizip
)
--- a/src/io/filesystem/zip_filesystem.h
+++ b/src/io/filesystem/zip_filesystem.h
@@ -28,8 +28,14 @@
#include "io/filesystem/filesystem.h"
#include "io/streamread.h"
#include "io/streamwrite.h"
+
+#ifndef HAVE_SYSTEM_MINIZIP
#include "third_party/minizip/unzip.h"
#include "third_party/minizip/zip.h"
+#else
+#include <minizip/unzip.h>
+#include <minizip/zip.h>
+#endif
class ZipFilesystem : public FileSystem {
public: