root/sil.scm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
(define-module (hidamari-blue sil)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module (guix download)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system cmake)
  #:use-module ((guix licenses) #:renamer (symbol-prefix-proc 'license:))
  #:use-module (gnu packages)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages ncurses)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages xorg))

;;; status: its playable, but some cache files can't be in initalized, and the tutorial is not installed
;;; TODO: style with guix-devel mode

(define-public sil
  (package
   (name "sil")
   (version "1.30")
   (source
    (origin (method url-fetch/zipbomb)
            (uri (string-append "http://www.amirrorclear.net/flowers/game/sil/Sil-"
                                "130"
                                "-src.zip"))
            (sha256
             (base32
              "0gh9gp7y6bqv8vgykppghcqn6jq1fpmls0yc30v8alv02pqk2h07"))
            (modules '((guix build utils)))
            (snippet
             '(begin
                ;; delete sound files because of unclear licencing,
                ;; they only seem to be used in the osx builds anyway.
                ;; copying.txt says:
                ;; * the sounds are freeware, whatever that means.
                (delete-file-recursively "Sil/lib/xtra/sound/")

                ;; fixes tutorial when USE_PRIVATE_SAVE_PATH is used
                (substitute* "Sil/src/main.c"
                             ;; "Sil/src/main-crb.c"
                             ;; "Sil/src/main-coca-NMcC.m"
                             ;; "Sil/src/main-coca-win.c"
                             (("ANGBAND_DIR_APEX, \"tutorial\"")
                              "ANGBAND_DIR_XTRA, \"tutorial\""))
                (rename-file "Sil/lib/apex/tutorial" "Sil/lib/xtra/tutorial")

                ;; fixes data when installing to readonly directory
                (substitute* "Sil/src/init2.c"
                             (("path_build\\(buf, sizeof\\(buf\\), ANGBAND_DIR_USER, \"scores\"\\);")
                              "
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, \"data\");
ANGBAND_DIR_DATA = string_make(buf);

path_build(buf, sizeof(buf), ANGBAND_DIR_USER, \"scores\");"))
                (substitute* "Sil/src/main.c"
                             (("#ifdef USE_PRIVATE_SAVE_PATH")
                              "#ifdef USE_PRIVATE_SAVE_PATH
    path_build(dirpath, sizeof(dirpath), subdirpath, \"data\");
    mkdir(dirpath, 0700);"))

                (substitute* "Sil/src/config.h"
                             ;; TODO is this a bug?
                             (("# ifdef PRIVATE_USER_PATH")
                              "# ifndef PRIVATE_USER_PATH"))))))
   (build-system gnu-build-system)
   (arguments '(#:tests?
                #f
                #:make-flags (let* ((out (assoc-ref %outputs "out")))
                               ;; disable the default terminal mode, only pick x11
                               ;; GCU termnial mode uses the outdated libcurses
                               (list
                                (string-append "CFLAGS= -Wall -O1 -pipe -g -D\"USE_X11\" -DPRIVATE_USER_PATH=\\\"~/.sil\\\" -DDEFAULT_PATH=\\\"" out "/share/sil\\\" -DUSE_PRIVATE_SAVE_PATH=1")
                                "LIBS= -lX11"
                                "-Csrc"
                                "-f" "Makefile.std")
                               )
                #:phases
                (modify-phases %standard-phases
                               (add-after 'unpack 'move-to-right-dir
                                          (lambda* (#:key source #:allow-other-keys)
                                            ;; use fetch/zipbomb to avoid __MACOSX dir
                                            (chdir "Sil")))
                               (delete 'configure)
                               (replace 'install
                                        (lambda* (#:key outputs version name #:allow-other-keys)
                                          ;; TODO get actual name and version from package
                                          (define name "sil")
                                          (define version "1.30")
                                          (let ((out (assoc-ref outputs "out")))
                                            (mkdir-p (string-append out "/bin"))
                                            (mkdir-p (string-append out "/share/sil"))
                                            (mkdir-p (string-append out "/share/doc/sil"))

                                            (substitute* "silx"
                                                         (("/bin/sh")
                                                          (which "bash"))
                                                         (("./sil")
                                                          (string-append out "/bin/" name)))

                                            (copy-file "src/sil" (string-append out "/bin/" name))
                                            (copy-file "silx" (string-append out "/bin/" name "x"))
                                            (copy-recursively "lib" (string-append out "/share/sil"))
                                            (copy-file (string-append "Sil " "1.3" " Manual.pdf")
                                                       (string-append out "/share/doc/sil/Manual.pdf"))
                                            ))))))
   (inputs `(("libx11" ,libx11)))
   (native-inputs `(("unzip" ,unzip)))
   (synopsis "tactical roguelike adventure game")
   (description "Sil is a computer role-playing game with a strong emphasis on
discovery and tactical combat. It has a simple but rich combat system which
allows for a great variety of choice.")
   (home-page "http://www.amirrorclear.net/flowers/game/sil/")
   (license (list license:gpl2          ; src is dual licenced with the angband license
                  license:public-domain ; 16x16 graphics
                  license:cc-by-sa3.0   ; 32x32 graphics
                  license:x11-style     ; the fonts have various x11-style licenses
                  ))))

;; (define-public sil-q
;;   (let ((commit "398947f1ced65f1be1213b7e232bd6a2e2f78d28"))
;;     (package
;;      (name "sil-q")
;;      (version "1.3.2")
;;      (inherit sil)
;;      (origin (method git-fetch)
;;              (uri (url "https://github.com/sil-quirk/sil-q")
;;                   (commit commit)))
;;      (arguments (append
;;                  '(#:phases
;;                    (modify-phases (package-phases sil)
;;                                   (remove 'move-to-right-dir)))
;;                  (package-arguments sil))))))