aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Geerinckx-Rice <me@tobias.gr>2022-08-07 02:00:00 +0200
committerTobias Geerinckx-Rice <me@tobias.gr>2022-08-07 02:00:01 +0200
commit5dee2fdae70aec405722dc2a7399e1871253efc5 (patch)
tree9c0682d2ed8dfdf471abb45a5fc620ce15f3975c
parent642a3e3d7abd3f53987c49edf5ec0f50dbbff30d (diff)
downloadguix-5dee2fdae70aec405722dc2a7399e1871253efc5.tar
guix-5dee2fdae70aec405722dc2a7399e1871253efc5.tar.gz
gnu: xonotic: Further explore the concept of iteration.
* gnu/packages/games.scm (xonotic)[arguments]: Use FOR-EACH in the 'install-binaries and renamed 'install-desktop-entries phases. Use FIND-FILES in the 'install-icons phase. Use both in 'wrap-binaries for brevity (and SRFI-26 for fun). Symlink ‘xonotic’ after wrapping, so we don't double-wrap it.
-rw-r--r--gnu/packages/games.scm142
1 files changed, 53 insertions, 89 deletions
diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index b55fe92d9b..37274781db 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -7810,6 +7810,9 @@ quotation from a collection of quotes.")
(list #:configure-flags
#~(list (string-append "--prefix=" #$output)
"--disable-rijndael")
+ #:modules '((guix build gnu-build-system)
+ (guix build utils)
+ (srfi srfi-26))
#:phases
#~(modify-phases %standard-phases
(add-before 'configure 'build-darkplaces
@@ -7841,105 +7844,66 @@ quotation from a collection of quotes.")
(data (assoc-ref inputs "xonotic-data")))
(symlink (string-append data "/share/xonotic")
(string-append out "/share/xonotic")))))
- (add-after 'install 'install-desktop-entry
+ (add-after 'install 'install-desktop-entries
(lambda* (#:key outputs #:allow-other-keys)
- ;; Add .desktop files for the 2 variants and the symlink.
- (let* ((output (assoc-ref outputs "out"))
- (apps (string-append output "/share/applications")))
- (mkdir-p apps)
- (with-output-to-file
- (string-append apps "/xonotic-glx.desktop")
- (lambda _
- (format #t
- "[Desktop Entry]~@
- Name=xonotic-glx~@
- Comment=Xonotic glx~@
- Exec=~a/bin/xonotic-glx~@
- TryExec=~@*~a/bin/xonotic-glx~@
- Icon=xonotic~@
- Categories=Game~@
- Type=Application~%"
- output)))
- (with-output-to-file
- (string-append apps "/xonotic-sdl.desktop")
- (lambda _
- (format #t
- "[Desktop Entry]~@
- Name=xonotic-sdl~@
- Comment=Xonotic sdl~@
- Exec=~a/bin/xonotic-sdl~@
- TryExec=~@*~a/bin/xonotic-sdl~@
- Icon=xonotic~@
- Categories=Game~@
- Type=Application~%"
- output)))
- (with-output-to-file
- (string-append apps "/xonotic.desktop")
- (lambda _
- (format #t
- "[Desktop Entry]~@
- Name=xonotic~@
- Comment=Xonotic~@
- Exec=~a/bin/xonotic-glx~@
- TryExec=~@*~a/bin/xonotic~@
- Icon=xonotic~@
- Categories=Game~@
- Type=Application~%"
- output))))))
+ (let* ((out (assoc-ref outputs "out"))
+ (app (string-append out "/share/applications")))
+ ;; Add .desktop files for the 2 variants and the symlink.
+ (for-each
+ (lambda (variant)
+ (let* ((file (if variant
+ (format #f "xonotic-~(~a~)" variant)
+ "xonotic"))
+ (name (if variant
+ (format #f "Xonotic (~a)" variant)
+ "Xonotic"))
+ (exec (string-append out "/bin/" file)))
+ (make-desktop-entry-file
+ (string-append app "/" file ".desktop")
+ #:name name
+ #:comment `((#f #$(package-synopsis this-package)))
+ #:exec exec
+ #:try-exec exec
+ #:icon "xonotic"
+ #:categories '("Game"))))
+ (list #f "GLX" "SDL")))))
(add-after 'install 'install-icons
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
- (with-directory-excursion "../../misc/logos/icons_png/"
- (for-each
- (lambda (file)
- (let* ((size (string-filter char-numeric? file))
- (icons (string-append out "/share/icons/hicolor/"
- size "x" size "/apps")))
- (mkdir-p icons)
- (copy-file file (string-append icons "/xonotic.png"))))
- '("xonotic_16.png" "xonotic_22.png" "xonotic_24.png"
- "xonotic_32.png" "xonotic_48.png" "xonotic_64.png"
- "xonotic_128.png" "xonotic_256.png" "xonotic_512.png"))))))
+ (for-each
+ (lambda (file)
+ (let* ((size (string-filter char-numeric? file))
+ (icons (string-append out "/share/icons/hicolor/"
+ size "x" size "/apps")))
+ (mkdir-p icons)
+ (copy-file file (string-append icons "/xonotic.png"))))
+ (find-files "../../misc/logos/icons_png"
+ "^xonotic_[0-9]+\\.png$")))))
(add-after 'install 'install-binaries
(lambda* (#:key outputs #:allow-other-keys)
- (let ((out (assoc-ref outputs "out")))
- (define (install src dst)
- (let ((dst (string-append out dst)))
- (mkdir-p (dirname dst))
- (copy-file src dst)))
- (mkdir-p (string-append out "/bin"))
- (install "../darkplaces/darkplaces-dedicated"
- "/bin/xonotic-dedicated")
- (install "../darkplaces/darkplaces-glx"
- "/bin/xonotic-glx")
- (install "../darkplaces/darkplaces-sdl"
- "/bin/xonotic-sdl")
- ;; Provide a default xonotic executable, defaulting to SDL.
- (symlink (string-append out "/bin/xonotic-sdl")
- (string-append out "/bin/xonotic")))))
- (add-after 'install-binaries 'wrap
+ (let* ((out (assoc-ref outputs "out"))
+ (bin (string-append out "/bin")))
+ (for-each
+ (lambda (variant)
+ (copy-file
+ (string-append "../darkplaces/darkplaces-" variant)
+ (string-append bin "/xonotic-" variant)))
+ (list "dedicated" "glx" "sdl")))))
+ (add-after 'install-binaries 'wrap-binaries
(lambda* (#:key outputs inputs #:allow-other-keys)
- ;; Curl and libvorbis need to be wrapped so that we get
- ;; sound and networking.
+ ;; All games must be wrapped to get sound and networking.
(let* ((out (assoc-ref outputs "out"))
- (bin (string-append out "/bin/xonotic"))
- (bin-sdl (string-append out "/bin/xonotic-sdl"))
- (bin-glx (string-append out "/bin/xonotic-glx"))
- (bin-dedicated (string-append out "/bin/xonotic-dedicated"))
+ (bin (string-append out "/bin"))
(curl (assoc-ref inputs "curl"))
(vorbis (assoc-ref inputs "libvorbis")))
- (wrap-program bin
- `("LD_LIBRARY_PATH" ":" prefix
- (,(string-append curl "/lib:" vorbis "/lib"))))
- (wrap-program bin-sdl
- `("LD_LIBRARY_PATH" ":" prefix
- (,(string-append curl "/lib:" vorbis "/lib"))))
- (wrap-program bin-glx
- `("LD_LIBRARY_PATH" ":" prefix
- (,(string-append curl "/lib:" vorbis "/lib"))))
- (wrap-program bin-dedicated
- `("LD_LIBRARY_PATH" ":" prefix
- (,(string-append curl "/lib:" vorbis "/lib"))))))))))
+ (for-each (cut wrap-program <>
+ `("LD_LIBRARY_PATH" ":" prefix
+ (,(string-append curl "/lib:"
+ vorbis "/lib"))))
+ (find-files bin "^xonotic"))
+
+ ;; Provide a default xonotic executable, defaulting to SDL.
+ (symlink "xonotic-sdl" (string-append bin "/xonotic"))))))))
(native-inputs
(list autoconf
automake