gnu: Fix and improve the mongo-tools package.

The hash of the source for this package is wrong. Most probably because the
source was changed from a tarball to a git repository without updating the
hash. Fixing this seems to break the check phase, so I rewrote that as well,
making changes to the build and install phases as needed.

* gnu/packages/databases.scm (mongo-tools)[source]: Update the hash value.
  [arguments]: Remove the different unpack path, as this isn't necessary when
  using the git repository as a source. Move the list of tools to make it
  accessible from multiple phases. Rewrite the build phase, getting it to
  install the tools in to the location the tests seem to expect to find
  them. Replace the check phase to run the tests for each tool
  individually. Add an install phase to install the tools, now that go install
  is not being run in the build phase.
  [native-inputs]: Add go-github.com-smartystreets-goconvey as a native-input
  as this is required for running the tests.
This commit is contained in:
Christopher Baines 2018-01-31 13:45:34 +00:00
parent 8d54ace78e
commit 9b32bf6e6c
No known key found for this signature in database
GPG Key ID: 5E28A33B0B84F577
1 changed files with 50 additions and 30 deletions

View File

@ -2617,51 +2617,71 @@ transforms idiomatic python function calls to well-formed SQL queries.")
(file-name (git-file-name name version)) (file-name (git-file-name name version))
(sha256 (sha256
(base32 (base32
"095nc57k4m4iyim0x3fgpw681qba123iyl4qz7xysbv5ngbr19mc")))) "1bcsz5cvj39a7nsxsfqmz9igrw33j6yli9kffigqyscs52amw7x1"))))
(build-system go-build-system) (build-system go-build-system)
(arguments (arguments
`(#:unpack-path "github.com/mongodb" `(#:import-path "github.com/mongodb/mongo-tools"
#:import-path "github.com/mongodb/mongo-tools" #:modules ((srfi srfi-1)
(guix build go-build-system)
(guix build utils))
#:phases #:phases
(modify-phases %standard-phases (let ((all-tools
(add-after 'unpack 'delete-bundled-source-code '("bsondump" "mongodump" "mongoexport" "mongofiles"
(lambda _ "mongoimport" "mongooplog" "mongorestore"
(delete-file-recursively "mongostat" "mongotop")))
"src/github.com/mongodb/mongo-tools/vendor") (modify-phases %standard-phases
#t)) (add-after 'unpack 'delete-bundled-source-code
(lambda _
;; We don't need to install the source code for end-user application (delete-file-recursively
(delete 'install-source) "src/github.com/mongodb/mongo-tools/vendor")
#t))
(replace 'build ;; We don't need to install the source code for end-user applications
(lambda* (#:key inputs outputs #:allow-other-keys) (delete 'install-source)
(let build ((tools (replace 'build
'("bsondump" "mongodump" "mongoexport" "mongofiles" (lambda _
"mongoimport" "mongooplog" "mongorestore" (every (lambda (tool)
"mongostat" "mongotop"))) (let ((command
(if (null? tools) `("go" "build"
#t ;; This is where the tests expect to find the
(if (let* ((tool (car tools)) ;; executables
(command "-o" ,(string-append
`("go" "install" "-v" "src/github.com/mongodb/mongo-tools/bin/"
tool)
"-v"
"-tags=\"ssl sasl\"" "-tags=\"ssl sasl\""
"-ldflags" "-ldflags"
"-extldflags=-Wl,-z,now,-z,relro" "-extldflags=-Wl,-z,now,-z,relro"
,(string-append ,(string-append
"src/github.com/mongodb/mongo-tools/" "src/github.com/mongodb/mongo-tools/"
tool "/main/" tool ".go")))) tool "/main/" tool ".go"))))
(simple-format #t "build: running ~A\n" (simple-format #t "build: running ~A\n"
(string-join command)) (string-join command))
(zero? (apply system* command))) (apply invoke command)))
(build (cdr tools)) all-tools)))
#f)))))))) (replace 'check
(lambda _
(with-directory-excursion "src"
(every (lambda (tool)
(invoke
"go" "test" "-v"
(string-append "github.com/mongodb/mongo-tools/" tool)))
all-tools))))
(replace 'install
(lambda* (#:key outputs #:allow-other-keys)
(for-each (lambda (tool)
(install-file
(string-append "src/github.com/mongodb/mongo-tools/bin/" tool)
(string-append (assoc-ref outputs "out")
"/bin")))
all-tools)))))))
(native-inputs (native-inputs
`(("go-github.com-howeyc-gopass" ,go-github.com-howeyc-gopass) `(("go-github.com-howeyc-gopass" ,go-github.com-howeyc-gopass)
("go-github.com-jessevdk-go-flags" ,go-github.com-jessevdk-go-flags) ("go-github.com-jessevdk-go-flags" ,go-github.com-jessevdk-go-flags)
("go-golang.org-x-crypto-ssh-terminal" ,go-golang.org-x-crypto-ssh-terminal) ("go-golang.org-x-crypto-ssh-terminal" ,go-golang.org-x-crypto-ssh-terminal)
("go-gopkg.in-mgo.v2" ,go-gopkg.in-mgo.v2) ("go-gopkg.in-mgo.v2" ,go-gopkg.in-mgo.v2)
("go-gopkg.in-tomb.v2" ,go-gopkg.in-tomb.v2) ("go-gopkg.in-tomb.v2" ,go-gopkg.in-tomb.v2)
("go-github.com-nsf-termbox-go" ,go-github.com-nsf-termbox-go))) ("go-github.com-nsf-termbox-go" ,go-github.com-nsf-termbox-go)
("go-github.com-smartystreets-goconvey" ,go-github.com-smartystreets-goconvey)))
(home-page "https://github.com/mongodb/mongo-tools") (home-page "https://github.com/mongodb/mongo-tools")
(synopsis "Various tools for interacting with MongoDB and BSON") (synopsis "Various tools for interacting with MongoDB and BSON")
(description (description