summaryrefslogtreecommitdiff
path: root/vkraus/packages/disfluid.scm
blob: 08668b24b4017de91371cb33bde7685c5b86e8dd (plain)
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
;; This file has been automatically generated.
(define-module
  (vkraus packages disfluid)
  #:use-module
  (gnu packages base)
  #:use-module
  (gnu packages bash)
  #:use-module
  (gnu packages gettext)
  #:use-module
  (gnu packages glib)
  #:use-module
  (gnu packages gnupg)
  #:use-module
  (gnu packages gtk)
  #:use-module
  (gnu packages tls)
  #:use-module
  (guix git-download)
  #:use-module
  (guix monads)
  #:use-module
  (guix store)
  #:use-module
  (guix derivations)
  #:use-module
  (guix profiles)
  #:use-module
  (guix scripts pack)
  #:use-module
  (guix gexp)
  #:use-module
  (guix modules)
  #:use-module
  (guix utils)
  #:use-module
  (ice-9 match)
  #:use-module
  (guix packages)
  #:use-module
  ((guix licenses) #:prefix license:)
  #:use-module
  (guix download)
  #:use-module
  (guix build-system gnu)
  #:use-module
  (gnu packages)
  #:use-module
  (gnu packages autotools)
  #:use-module
  (gnu packages guile)
  #:use-module
  (gnu packages guile-xyz)
  #:use-module
  (gnu packages pkg-config)
  #:use-module
  (gnu packages texinfo))

(define gtk-minimal
  (package
    (inherit gtk)
    (arguments
      (substitute-keyword-arguments
        (package-arguments gtk)
        ((#:configure-flags configure-flags (gexp list))
         (gexp (append
                 (ungexp configure-flags)
                 (list "-Dmedia-gstreamer=disabled"
                       "-Dtracker=disabled"))))))
    (inputs
      (filter
        (match-lambda
          (("gst-plugins-bad" . _) #f)
          (("gst-plugins-base" . _) #f)
          (("tracker" . _) #f)
          (else #t))
        (package-inputs gtk)))))

(define-public disfluid
  (package
    (name "disfluid")
    (version "0.0.4-121-g0ce9761")
    (source
      (computed-file
        "source-with-translations"
        (with-imported-modules
          (source-module-closure '((guix build utils)))
          (gexp (begin
                  (use-modules (guix build utils))
                  (copy-recursively
                    (ungexp
                      (directory-union
                        "source-with-translations-linked"
                        (list (origin
                                (method git-fetch)
                                (uri (git-reference
                                       (url "https://labo.planete-kraus.eu/disfluid.git")
                                       (commit
                                         "0ce9761dc8febae3c710e0a006376b217017c01b")))
                                (sha256
                                  (base32
                                    "0ilj6jbx61kzvmmkxjri2pqpxj6lmmagdpf7ghiqb4ckr8fmvhn1")))
                              (origin
                                (method git-fetch)
                                (uri (git-reference
                                       (url "https://labo.planete-kraus.eu/disfluid.git")
                                       (commit
                                         "fb01e8bfc8740b3ccb4314a233a7fb993703b4f4")))
                                (sha256
                                  (base32
                                    "0v12vmdh1dg7jl6gyb6h0ai6gy9qchv62zgb944vgx6azdfn5p52"))))))
                    (ungexp output)
                    #:follow-symlinks?
                    #t))))))
    (build-system gnu-build-system)
    (arguments
      `(#:phases
        (modify-phases
          %standard-phases
          (add-after
            'unpack
            'fix-mtime
            (lambda _
              (let ((disfluid-mtimes
                      '(("doc/disfluid.texi" . 1668331245)
                        ("po/disfluid.pot" . 1670095886))))
                (for-each
                  ((@ (ice-9 match) match-lambda)
                   ((file . mtime) (utime file mtime mtime)))
                  disfluid-mtimes))))
          (add-before
            'bootstrap
            'fix-hall.scm
            (lambda _
              (let ((disfluid-version "0.0.4-121-g0ce9761"))
                (substitute*
                  "hall.scm"
                  (("SNAPSHOT") disfluid-version)))))
          (add-after
            'fix-hall.scm
            'hall-scan
            (lambda _
              (setenv "HOME" (getcwd))
              (call-with-output-file
                "disfluid/config.scm"
                (lambda (port)
                  (write `(define-module (disfluid config)) port)))
              (invoke "hall" "scan" "-x")
              (delete-file "disfluid/config.scm")))
          (add-after
            'hall-scan
            'hall-build-system
            (lambda _
              (invoke "hall" "build-system" "-x")
              (substitute*
                "Makefile.am"
                (("EXTRA_DIST =")
                 "EXTRA_DIST = guix.scm channels.scm"))))
          (add-after
            'hall-build-system
            'support-config.scm
            (lambda _
              (let ((expanded-variables
                      '(("prefix" . "PREFIX")
                        ("bindir" . "BINDIR")
                        ("exec_prefix" . "EXEC_PREFIX")
                        ("guilemoduledir" . "GUILEMODULEDIR")
                        ("guileobjectdir" . "GUILEOBJECTDIR")
                        ("localedir" . "LOCALEDIR"))))
                (let ((subst (string-join
                               (map ((@ (ice-9 match) match-lambda)
                                     ((var . expanded)
                                      (format
                                        #f
                                        "AX_RECURSIVE_EVAL([$~a], EXPANDED_~a)\nAC_SUBST([EXPANDED_~a])"
                                        var
                                        expanded
                                        expanded)))
                                    expanded-variables)
                               "\n")))
                  (substitute*
                    "configure.ac"
                    (("AC_OUTPUT")
                     (string-append
                       subst
                       "\nAC_CONFIG_FILES([disfluid/config.scm])\nAC_OUTPUT")))))
              (rename-file "Makefile.am" "hall.mk")
              (call-with-output-file
                "Makefile.am"
                (lambda (port)
                  (format
                    port
                    "include %reldir%/hall.mk\n\ndist-hook:\n\trm -rf $(distdir)/disfluid/config.scm\n")))
              (call-with-output-file
                "disfluid/config.scm.in"
                (lambda (port)
                  (for-each
                    (lambda (code)
                      ((@ (ice-9 pretty-print) pretty-print) code port)
                      (newline port))
                    '((define-module
                        (disfluid config)
                        #:export
                        (package
                          package-bugreport
                          version
                          localedir
                          guilemoduledir
                          prefix
                          exec-prefix
                          pkg-config))
                      (define package "@PACKAGE@")
                      (define package-bugreport "@PACKAGE_BUGREPORT@")
                      (define version "@VERSION@")
                      (define prefix "@EXPANDED_PREFIX@")
                      (define exec-prefix "@EXPANDED_EXEC_PREFIX@")
                      (define localedir "@EXPANDED_LOCALEDIR@")
                      (define guilemoduledir
                        "@EXPANDED_GUILEMODULEDIR@")
                      (define pkg-config "@PKG_CONFIG@")))))))
          (add-after
            'support-config.scm
            'gettextize
            (lambda _
              (substitute*
                "configure.ac"
                (("AC_OUTPUT")
                 "\nAM_GNU_GETTEXT([external])\nAM_GNU_GETTEXT_VERSION([0.21])\nAC_OUTPUT\n")
                (("AC_CONFIG_FILES\\(\\[Makefile")
                 "AC_CONFIG_FILES([Makefile po/Makefile.in"))
              (substitute*
                "hall.mk"
                (("EXTRA_DIST =")
                 "EXTRA_DIST = guix.scm channels.scm"))
              (rename-file "Makefile.am" "withconfig.mk")
              (call-with-output-file
                "Makefile.am"
                (lambda (port)
                  (format
                    port
                    "SUBDIRS = po\ninclude withconfig.mk\n")))
              (mkdir-p "po")
              (call-with-output-file
                "po/Makevars"
                (lambda (port)
                  (format
                    port
                    "DOMAIN = $(PACKAGE)\nsubdir = po\ntop_builddir = ..\nXGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --keyword=G_\nCOPYRIGHT_HOLDER = Viven Kraus\nPACKAGE_GNU =\nMSGID_BUGS_ADDRESS = vivien@planete-kraus.eu\nEXTRA_LOCALE_CATEGORIES =\nUSE_MSGCTXT = no\nMSGMERGE_OPTIONS =\nMSGINIT_OPTIONS =\nPO_DEPENDS_ON_POT = yes\nDIST_DEPENDS_ON_UPDATE_PO = yes\n")))
              (call-with-output-file
                "collect-potfiles.sh"
                (lambda (port)
                  (format
                    port
                    "\n(for pattern in '*.scm' ;\n do find . -name \"$pattern\" ;\n done) > po/POTFILES.in\n")
                  (chmod port 493)))
              (call-with-output-file
                "collect-linguas.sh"
                (lambda (port)
                  (format
                    port
                    "\n(for pofile in po/*.po ;\n do echo \"$pofile\" | cut -d '/' -f 2 | cut -d '.' -f 1 ;\n done) > po/LINGUAS\n")
                  (chmod port 493)))
              (invoke "bash" "collect-potfiles.sh")
              (invoke "bash" "collect-linguas.sh")))
          (add-after
            'hall-build-system
            'define-package-bugreport
            (lambda _
              (substitute*
                "configure.ac"
                (("AC_INIT")
                 (format
                   #f
                   "AC_INIT([disfluid], [~a], [vivien@planete-kraus.eu])\ndnl AC_INIT"
                   "0.0.4-121-g0ce9761")))))
          (add-after
            'unpack
            'fix-gnutls-location
            (lambda* (#:key inputs #:allow-other-keys)
              (let ((gnutls
                      (search-input-file inputs "/lib/libgnutls.so")))
                (substitute*
                  '("disfluid/gnutls/datum.scm"
                    "disfluid/gnutls/global.scm"
                    "disfluid/gnutls/pubkey.scm"
                    "disfluid/gnutls/privkey.scm"
                    "disfluid/gnutls/x509/privkey.scm")
                  (("\"libgnutls\"") (format #f "~s" gnutls))))))
          (add-after
            'bootstrap
            'fix-po-makefile-shell
            (lambda _
              (substitute*
                "po/Makefile.in.in"
                (("SHELL = /bin/sh") "SHELL = @SHELL@"))))
          (add-after
            'check
            'distcheck
            (lambda* (#:key make-flags inputs #:allow-other-keys)
              (apply invoke
                     "make"
                     `(,@make-flags
                       "distcheck"
                       ,(format
                          #f
                          "DISTCHECK_CONFIGURE_FLAGS=SHELL=~a"
                          (search-input-file inputs "/bin/bash"))))
              (copy-file
                "disfluid-0.0.4-121-g0ce9761.tar.gz"
                "/tmp/disfluid-0.0.4-121-g0ce9761.tar.gz")
              (with-directory-excursion
                "/tmp"
                (invoke
                  "tar"
                  "xf"
                  "disfluid-0.0.4-121-g0ce9761.tar.gz")
                (delete-file
                  "disfluid-0.0.4-121-g0ce9761.tar.gz")
                (invoke
                  "tar"
                  "--sort=name"
                  "--mtime=2022-01-01 00:00Z"
                  "--owner=0"
                  "--group=0"
                  "--numeric-owner"
                  "--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime"
                  "-cf"
                  "disfluid-0.0.4-121-g0ce9761.tar.gz"
                  "disfluid-0.0.4-121-g0ce9761"))
              (copy-file
                "/tmp/disfluid-0.0.4-121-g0ce9761.tar.gz"
                "disfluid-0.0.4-121-g0ce9761.tar.gz")))
          (add-after
            'build
            'html
            (lambda* (#:key make-flags #:allow-other-keys)
              (apply invoke "make" "html" make-flags)))
          (add-before
            'check
            'set-tz
            (lambda* (#:key inputs #:allow-other-keys)
              (setenv "TZ" "CET")
              (setenv
                "TZDIR"
                (search-input-directory inputs "share/zoneinfo"))))
          (add-after
            'install
            'install-complete-corresponding-source
            (lambda* (#:key outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out")))
                (mkdir-p (string-append out "/share/disfluid"))
                (copy-file
                  "disfluid-0.0.4-121-g0ce9761.tar.gz"
                  (string-append
                    out
                    "/share/disfluid/complete-corresponding-source.tar.gz")))))
          (add-after
            'install
            'install-html
            (lambda* (#:key make-flags #:allow-other-keys)
              (apply invoke "make" "install-html" make-flags)))
          (add-after
            'install
            'wrap-disfluid
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out")))
                (wrap-program
                  (string-append out "/bin/disfluid")
                  `("GUILE_LOAD_PATH"
                    prefix
                    ,(search-path-as-list
                       '("share/guile/site/3.0")
                       (map cdr inputs)))
                  `("GUILE_COMPILED_LOAD_PATH"
                    prefix
                    ,(search-path-as-list
                       '("lib/guile/3.0/site-ccache")
                       (map cdr inputs)))
                  `("GUILE_EXTENSIONS_PATH"
                    prefix
                    ,(search-path-as-list '("lib") (map cdr inputs))))))))))
    (native-inputs
      `(,autoconf
        ,automake
        ,pkg-config
        ,texinfo
        ,guile-hall
        ,gnu-gettext
        ,autoconf-archive
        ,findutils
        ,tzdata-for-tests))
    (inputs
      `(,guile-3.0
        ,glib
        ,gtk-minimal
        ,bash-minimal
        ,gnutls))
    (propagated-inputs
      `(,guile-gcrypt
        ,guile-json-4
        ,guile-rdf
        ,guile-jsonld
        ,guile-gi))
    (synopsis "Solid stack implementation")
    (description
      "This package provides a Solid implementation, client and server.")
    (home-page "https://disfluid.planete-kraus.eu")
    (license license:agpl3+)))

disfluid