unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob 241bfdb0cc7470d6486a34e377f0a366123bd5db 14766 bytes (raw)
name: gnu/packages/golang.scm 	 # note: path name is non-authoritative(*)

  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
 
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015, 2016 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2016 Matthew Jordan <matthewjordandevops@yandex.com>
;;;
;;; This file is an addendum GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages golang)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix utils)
  #:use-module (guix download)
  #:use-module (guix packages)
  #:use-module (guix build-system gnu)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages rc)
  #:use-module (gnu packages gcc)
  #:use-module (gnu packages base)
  #:use-module (gnu packages perl)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages pcre)
  #:use-module (gnu packages bash)
  #:use-module (srfi srfi-1))

;; According to https://golang.org/doc/install/gccgo, gccgo-4.8.2 includes a
;; complete go-1.1.2 implementation, gccgo-4.9 includes a complete go-1.2
;; implementation, and gccgo-5 a complete implementation of go-1.4.  Ultimately
;; we hope to build go-1.5+ with a bootstrap process using gccgo-5.  As of
;; go-1.5, go cannot be bootstrapped without go-1.4, so we need to use go-1.4 or
;; gccgo-5.  Mips is not officially supported, but it should work if it is
;; bootstrapped.

(define-public go-1.4
  (package
    (name "go")
    (version "1.4.3")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://storage.googleapis.com/golang/"
                           name version ".src.tar.gz"))
       (sha256
        (base32
         "0na9yqilzpvq0bjndbibfp07wr796gf252y471cip10bbdqgqiwr"))))
    (build-system gnu-build-system)
    (outputs '("out"
               "doc"
               "src"))
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (delete 'configure)
         (delete 'validate-runpath)
         (add-after 'patch-generated-file-shebangs 'chdir
           (lambda _ (chdir "src")))
         (add-before 'build 'prebuild
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let* ((gccgo  (assoc-ref inputs "gccgo"))
                    (gcclib (string-append (assoc-ref inputs "gcc:lib") "/lib"))
                    (ld (string-append
                         (assoc-ref inputs "glibc") "/lib"))
                    (loader (car (find-files ld "^ld-linux.+")))
                    (libgcc (string-append (assoc-ref inputs "gcc:lib") "/lib"))
                    (net-base (assoc-ref inputs "net-base"))
                    (tzdata-path
                     (string-append (assoc-ref inputs "tzdata") "/share/zoneinfo"))
                    (output (assoc-ref outputs "out")))
               ;; Removing net/ tests
               (for-each
                (lambda (srcfile)
                  (let ((srcfile (string-append "net/" srcfile)))
                  (if (file-exists? srcfile)
                      (delete-file srcfile))))
                '("multicast_test.go" "parse_test.go" "port_test.go"))
               (substitute* "os/os_test.go"
                 (("/usr/bin") (getcwd))
                 (("/bin/pwd") (which "pwd")))
               ;; Disable failing tests
               (for-each
                (lambda (srcfile)
                  (substitute* (car srcfile)
                    (((cdr srcfile) all) (string-append all "return\n"))))
                (list
                 '("net/net_test.go" . ".+TestShutdownUnix.+")
                 '("net/dial_test.go" . ".+TestDialTimeout.+")
                 '("os/os_test.go" . ".+TestHostname.+")
                 '("time/format_test.go" . ".+TestParseInSydney.+")
                 '("os/exec/exec_test.go" . ".+TestEcho.+")
                 '("os/exec/exec_test.go" . ".+TestCommandRelativeName.+")
                 '("os/exec/exec_test.go" . ".+TestCatStdin.+")
                 '("os/exec/exec_test.go" . ".+TestCatGoodAndBadFile.+")
                 '("os/exec/exec_test.go" . ".+TestExitStatus.+")
                 '("os/exec/exec_test.go" . ".+TestPipes.+")
                 '("os/exec/exec_test.go" . ".+TestStdinClose.+")
                 '("syscall/syscall_unix_test.go" . ".+TestPassFD\\(.+")
                 '("os/exec/exec_test.go" . ".+TestExtraFiles.+")))
               (substitute* "net/lookup_unix.go"
                 (("/etc/protocols") (string-append net-base "/etc/protocols")))
               (substitute* "time/zoneinfo_unix.go"
                 (("/usr/share/zoneinfo/") tzdata-path))
               (substitute*
                   (find-files "cmd" "asm.c")
                 (("/lib/ld-linux.*\\.so\\.[0-9]") loader)))))
         (replace 'build
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let* ((gccgo  (assoc-ref inputs "gccgo"))
                    (output (assoc-ref outputs "out")))
               (setenv "CC" (which "gcc"))
               (setenv "GOOS" "linux")
               (setenv "GOROOT" (dirname (getcwd)))
               (setenv "GOROOT_BOOTSTRAP" gccgo)
               (setenv "GOROOT_FINAL" output)
               (setenv "LD_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
               (setenv "CGO_ENABLED" "1")
               (zero? (system* "sh" "all.bash")))))
         (replace 'install
           (lambda* (#:key outputs inputs #:allow-other-keys)
             (let* ((output (assoc-ref outputs "out"))
                    (doc_out (assoc-ref outputs "doc"))
                    (bash (string-append (assoc-ref inputs "bash") "bin/bash"))
                    (docs (string-append doc_out "/share/doc/" ,name "-" ,version))
                    (src (string-append
                            (assoc-ref outputs "src") "/share/" ,name "-" ,version)))
               (mkdir-p src)
               (copy-recursively "../test" (string-append src "/test"))
               (delete-file-recursively "../test")
               (mkdir-p docs)
               (copy-recursively "../api" (string-append docs "/api"))
               (delete-file-recursively "../api")
               (copy-recursively "../doc" (string-append docs "/doc"))
               (delete-file-recursively "../doc")

               (for-each
                (lambda (file)
                  (let* ((filein (string-append "../" file))
                         (fileout (string-append docs "/" file)))
                  (copy-file filein fileout)
                  (delete-file filein)))
                '("README" "CONTRIBUTORS" "AUTHORS" "PATENTS"
                  "LICENSE" "VERSION" "robots.txt"))
               (rename-file "../bin/go" (string-append "../bin/go-" ,version))

               ;; Create a wrapper script for go command
               (call-with-output-file (string-append "../bin/go")
                 (lambda (port)
                   (format port (string-append "#!" bash "\n"))
                   (format port "\nexport LD_LIBRARY_PATH=$LIBRARY_PATH\n")
                   (format port (string-append "go-" ,version " \"$@\""))
                   (chmod port #o555)))
               (copy-recursively "../" output)))))
       #:tests? #f))
    (inputs
     `(("which" ,which)
       ("tzdata" ,tzdata)
       ("pkg-config" ,%pkg-config)
       ("pcre" ,pcre)))
    (native-inputs
     `(("gccgo" ,gccgo-4.9)
       ("gcc:out" ,gcc-4.9 "out")
       ("net-base" ,net-base)
       ("rc" ,rc)
       ("perl" ,perl)))
    (propagated-inputs
     `(("gcc:lib" ,gcc-4.9 "lib")
       ("bash" ,bash)
       ("glibc" ,glibc)))
    (home-page "https://golang.org/")
    (synopsis "Compiled, statically typed language developed by Google")
    (description "Go, also commonly referred to as golang, is a programming
 language developed at Google.  Designed primarily for systems programming, it
 is a compiled, statically typed language in the tradition of C and C++, with
garbage collection, various safety features and in the style of communicating
sequential processes (CSP) concurrent programming features added.")
    (license license:bsd-3)))

(define-public go-1.5
  (package
    (inherit go-1.4)
    (name "go")
    (version "1.5.4")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "https://storage.googleapis.com/golang/"
                           name version ".src.tar.gz"))
       (sha256
        (base32
         "14xwn2pr3g4i1h8qpyrjjdmq1pgvzkagk4aqsp841hfxwyyclah0"))))
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (delete 'configure)
         (delete 'validate-runpath)
         (add-after 'patch-generated-file-shebangs 'chdir
           (lambda _ (chdir "src")))
         (add-before 'build 'prebuild
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let* ((gcclib (string-append (assoc-ref inputs "gcc:lib") "/lib"))
                    (ld (string-append
                         (assoc-ref inputs "glibc") "/lib"))
                    (loader (car (find-files ld "^ld-linux.+")))
                    (libgcc (string-append (assoc-ref inputs "gcc:lib") "/lib"))
                    (net-base (assoc-ref inputs "net-base"))
                    (tzdata-path
                     (string-append (assoc-ref inputs "tzdata") "/share/zoneinfo"))
                    (output (assoc-ref outputs "out")))
               ;; Removing net/ tests
               (for-each
                (lambda (srcfile)
                  (let ((srcfile (string-append "net/" srcfile)))
                    (if (file-exists? srcfile)
                        (delete-file srcfile))))
                '("multicast_test.go" "parse_test.go" "port_test.go"))
               (substitute* "os/os_test.go"
                 (("/usr/bin") (getcwd))
                 (("/bin/pwd") (which "pwd")))
               ;; Disable failing tests
               (for-each
                (lambda (srcfile)
                  (substitute* (car srcfile)
                    (((cdr srcfile) all) (string-append all "return\n"))))
                (list
                 '("net/net_test.go" . ".+TestShutdownUnix.+")
                 '("net/dial_test.go" . ".+TestDialTimeout.+")
                 '("os/os_test.go" . ".+TestHostname.+")
                 '("time/format_test.go" . ".+TestParseInSydney.+")
                 '("os/exec/exec_test.go" . ".+TestEcho.+")
                 '("os/exec/exec_test.go" . ".+TestCommandRelativeName.+")
                 '("os/exec/exec_test.go" . ".+TestCatStdin.+")
                 '("os/exec/exec_test.go" . ".+TestCatGoodAndBadFile.+")
                 '("os/exec/exec_test.go" . ".+TestExitStatus.+")
                 '("os/exec/exec_test.go" . ".+TestPipes.+")
                 '("os/exec/exec_test.go" . ".+TestStdinClose.+")
                 '("os/exec/exec_test.go" . ".+TestIgnorePipeErrorOnSuccess.+")
                 '("syscall/syscall_unix_test.go" . ".+TestPassFD\\(.+")
                 '("os/exec/exec_test.go" . ".+TestExtraFiles.+")
                 '("net/listen_test.go" . ".+TestIPv4MulticastListener\\(.+")
                 '("syscall/exec_linux_test.go" .
                   ".+TestCloneNEWUSERAndRemapNoRootDisableSetgroups.+")))
               (substitute* "net/lookup_unix.go"
                 (("/etc/protocols") (string-append net-base "/etc/protocols")))
               (substitute* "time/zoneinfo_unix.go"
                 (("/usr/share/zoneinfo/") tzdata-path))
               (substitute*
                   (find-files "cmd" "asm.c")
                 (("/lib/ld-linux.*\\.so\\.[0-9]") loader)))))
         (replace 'build
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let* ((go  (assoc-ref inputs "go"))
                    (output (assoc-ref outputs "out")))
               (setenv "CC" (which "gcc"))
               (setenv "GOOS" "linux")
               (setenv "GOROOT" (dirname (getcwd)))
               (setenv "GOROOT_BOOTSTRAP" go)
               (setenv "GOROOT_FINAL" output)
               (setenv "GOGC" "400")
               (setenv "LD_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
               (setenv "CGO_ENABLED" "1")
               (zero? (system* "sh" "all.bash")))))
         (replace 'install
           (lambda* (#:key inputs outputs #:allow-other-keys)
             (let* ((output (assoc-ref outputs "out"))
                    (doc_out (assoc-ref outputs "doc"))
                    (bash (string-append (assoc-ref inputs "bash") "bin/bash"))
                    (docs (string-append doc_out "/share/doc/" ,name "-" ,version))
                    (src (string-append
                          (assoc-ref outputs "src") "/share/" ,name "-" ,version)))
               (mkdir-p src)
               (copy-recursively "../test" (string-append src "/test"))
               (delete-file-recursively "../test")
               (mkdir-p docs)
               (copy-recursively "../api" (string-append docs "/api"))
               (delete-file-recursively "../api")
               (copy-recursively "../doc" (string-append docs "/doc"))
               (delete-file-recursively "../doc")

               (for-each
                (lambda (file)
                  (let* ((filein (string-append "../" file))
                         (fileout (string-append docs "/" file)))
                  (copy-file filein fileout)
                  (delete-file filein)))
                '("README.md" "CONTRIBUTORS" "AUTHORS" "PATENTS"
                  "LICENSE" "VERSION" "CONTRIBUTING.md" "robots.txt"))
               (rename-file "../bin/go" (string-append "../bin/go-" ,version))

               ;; Create a wrapper script for go command
               (call-with-output-file (string-append "../bin/go")
                 (lambda (port)
                   (format port (string-append "#!" bash "\n"))
                   (format port "\nexport LD_LIBRARY_PATH=$LIBRARY_PATH\n")
                   (format port (string-append "go-" ,version " \"$@\""))
                   (chmod port #o555)))

               (copy-recursively "../" output)))))
       #:tests? #f))
    (inputs
     `(,@(package-inputs go-1.4)))
    (native-inputs
     `(("go" ,go-1.4)
       ,@(alist-delete "gccgo" (package-native-inputs go-1.4))))
    (propagated-inputs
     `(,@(package-propagated-inputs go-1.4)))))

debug log:

solving 241bfdb ...
found 241bfdb in https://yhetil.org/guix-devel/871t4mynom.fsf@mailerver.i-did-not-set--mail-host-address--so-tickle-me/
found 77d4b0e in https://yhetil.org/guix-devel/8737p2ynsx.fsf@mailerver.i-did-not-set--mail-host-address--so-tickle-me/

applying [1/2] https://yhetil.org/guix-devel/8737p2ynsx.fsf@mailerver.i-did-not-set--mail-host-address--so-tickle-me/
diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
new file mode 100644
index 0000000..77d4b0e


applying [2/2] https://yhetil.org/guix-devel/871t4mynom.fsf@mailerver.i-did-not-set--mail-host-address--so-tickle-me/
diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 77d4b0e..241bfdb 100644

Checking patch gnu/packages/golang.scm...
Applied patch gnu/packages/golang.scm cleanly.
Checking patch gnu/packages/golang.scm...
Applied patch gnu/packages/golang.scm cleanly.

index at:
100644 241bfdb0cc7470d6486a34e377f0a366123bd5db	gnu/packages/golang.scm

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).