From mboxrd@z Thu Jan 1 00:00:00 1970 From: Leo Famulari Subject: Go build system Date: Mon, 11 Jul 2016 17:36:21 -0400 Message-ID: <20160711213621.GA22573@jasmine> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="DocE+STaALJfprDB" Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMisk-0005bi-2O for guix-devel@gnu.org; Mon, 11 Jul 2016 17:36:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMisg-0006Qp-I6 for guix-devel@gnu.org; Mon, 11 Jul 2016 17:36:50 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:58434) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMise-0006Oo-5N for guix-devel@gnu.org; Mon, 11 Jul 2016 17:36:46 -0400 Received: from localhost (c-68-81-58-201.hsd1.pa.comcast.net [68.81.58.201]) by mail.messagingengine.com (Postfix) with ESMTPA id 4EF2DF29FE for ; Mon, 11 Jul 2016 17:36:29 -0400 (EDT) Content-Disposition: inline List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org --DocE+STaALJfprDB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Now that we have go-1.4 and (almost) go-1.5, we should start thinking about a go-build-system. I just wrote my first package using Go, the crude Syncthing package that is attached. It still needs a lot of work, especially since it builds Syncthing's dependencies from bundled copies instead of external packages. But, it does illustrate some of the assumptions that Go makes when building. It seems that Go is very particular about directory structures; it would be better if we could avoid these contortions by setting some environment variables. Should Go packages refer to the compiler? This Syncthing package does retain a reference. I hope to get some replies from some people who have been building Go software for longer than 1 day ;) This is the guide that I used to create this package: https://docs.syncthing.net/dev/building.html --DocE+STaALJfprDB Content-Type: text/x-diff; charset=iso-8859-1 Content-Disposition: attachment; filename="0001-WIP-Add-syncthing.patch" Content-Transfer-Encoding: 8bit >From 24fad181e128d987cc4066265bbd6e34ff4f5461 Mon Sep 17 00:00:00 2001 From: Leo Famulari Date: Mon, 11 Jul 2016 16:37:17 -0400 Subject: [PATCH] WIP: Add syncthing. * gnu/packages/syncthing.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. --- gnu/local.mk | 1 + gnu/packages/syncthing.scm | 123 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 gnu/packages/syncthing.scm diff --git a/gnu/local.mk b/gnu/local.mk index d011844..fe3b1d2 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -322,6 +322,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/suckless.scm \ %D%/packages/swig.scm \ %D%/packages/sxiv.scm \ + %D%/packages/syncthing.scm \ %D%/packages/synergy.scm \ %D%/packages/task-management.scm \ %D%/packages/tbb.scm \ diff --git a/gnu/packages/syncthing.scm b/gnu/packages/syncthing.scm new file mode 100644 index 0000000..97ca8ec --- /dev/null +++ b/gnu/packages/syncthing.scm @@ -0,0 +1,123 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2016 Leo Famulari +;;; +;;; This file is part of 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 . + +(define-module (gnu packages syncthing) + #:use-module (guix build-system gnu) + #:use-module (guix download) + #:use-module (guix git-download) + #:use-module (guix licenses) + #:use-module (guix packages) + #:use-module (gnu packages golang)) + +(define-public syncthing + (package + (name "syncthing") + (version "v0.13.10") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/syncthing/syncthing.git") + (commit version))) + (file-name (string-append name "-" version)) + (sha256 + (base32 + "07q3j6mnrza719rnvbkdsmvlkyr2pch5sj2l204m5iy5mxaghpx7")))) + + ;; TODO Make go-build-system. + (build-system gnu-build-system) + (arguments + `(#:phases + (modify-phases %standard-phases + (delete 'configure) ; No ./configure script. + + ;; This is the directory structure recommended by Syncthings "guide to + ;; building": https://docs.syncthing.net/dev/building.html + ;; Can we simplify this step? + (replace 'unpack + (lambda* (#:key source #:allow-other-keys) + (let ((tree "src/github.com/syncthing/syncthing")) + (copy-recursively source tree)))) + + (add-after 'unpack 'set-env + (lambda* (#:key inputs outputs #:allow-other-keys) + (let ((source (assoc-ref inputs "source"))) + (setenv "GOPATH" (getcwd)) + + ;; This should control where `go run build.go install` installs + ;; things, but it seems to have no effect in this case. + (setenv "GOBIN" (assoc-ref outputs "out")) + + ;; Enable use of bundled dependencies. This is a stop-gap + ;; until the dependencies are packaged properly. + (setenv "GO15VENDOREXPERIMENT" "1")))) + + ;; This is related to the unpack phase. Can it be avoided? + (add-before 'build 'chdir + (lambda _ (chdir "src/github.com/syncthing/syncthing"))) + + (replace 'build + (lambda _ + (zero? (system* "go" "run" "build.go" + ;; Disable Syncthing's built-in updater. + "-no-upgrade" + ;; This might not be necessary if building from a + ;; tarball. + "-version" ,version)))) + (replace 'check + (lambda _ + (zero? (system* "go" "run" "build.go" "test")))) + + ;; TODO Make this use `go run build.go install`. + (replace 'install + (lambda _ + (copy-recursively "bin" (string-append (assoc-ref %outputs "out") + "/bin")))) + ;; TODO These man pages are generated from a different Git + ;; repo, https://github.com/syncthing/docs. + (add-after 'install 'install-doc + (lambda* (#:key outputs source #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (man1 (string-append out "/share/man/man1")) + (man5 (string-append out "/share/man/man5")) + (man7 (string-append out "/share/man/man7")) + (src (string-append source "/man/"))) + (install-file (string-append src "syncthing.1") man1) + (install-file (string-append src "syncthing-config.5") man5) + (install-file (string-append src "syncthing-stignore.5") man5) + (install-file (string-append src "syncthing-bep.7") man7) + (install-file (string-append src "syncthing-device-ids.7") man7) + (install-file (string-append src "syncthing-event-api.7") man7) + (install-file (string-append src "syncthing-faq.7") man7) + (install-file (string-append src "syncthing-globaldisco.7") man7) + (install-file (string-append src "syncthing-localdisco.7") man7) + (install-file (string-append src "syncthing-networking.7") man7) + (install-file (string-append src "syncthing-relay.7") man7) + (install-file (string-append src "syncthing-rest-api.7") man7) + (install-file (string-append src "syncthing-security.7") man7) + (install-file (string-append src "syncthing-versioning.7") man7) + (install-file (string-append src "syncthing.1") man7) + #t)))))) + (native-inputs + `(("go" ,go-1.5))) + (synopsis "Decentralized filesystem synchronization") + (description "Syncthing is a peer-to-peer file synchronization tool that +supports a wide variety of computing platforms. It uses the Block Exchange +Protocol.") + (home-page "https://syncthing.net") + ;; TODO Either delete the bundled dependencies or list their licenses here. + (license mpl2.0))) -- 2.9.0 --DocE+STaALJfprDB--