>From 47d5ad30c1e1e2a24b950236590e10bbf72c277e Mon Sep 17 00:00:00 2001
From: Roel Janssen <r...@gnu.org>
Date: Thu, 17 Mar 2016 16:06:40 +0100
Subject: [PATCH] gnu: Add mongodb.

* gnu/packages/databases.scm (mongodb): New variable.
* gnu/packages/patches/mongodb-add-version-file.patch: New file.
* gnu-system.am (dist_patch_DATA): Add patch file.
---
 gnu-system.am                                      |  1 +
 gnu/packages/databases.scm                         | 51 +++++++++++++++++++++-
 .../patches/mongodb-add-version-file.patch         | 10 +++++
 3 files changed, 60 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/mongodb-add-version-file.patch

diff --git a/gnu-system.am b/gnu-system.am
index 634093a..7517cc0 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -633,6 +633,7 @@ dist_patch_DATA =						\
   gnu/packages/patches/mpc123-initialize-ao.patch		\
   gnu/packages/patches/mplayer2-theora-fix.patch		\
   gnu/packages/patches/module-init-tools-moduledir.patch	\
+  gnu/packages/patches/mongodb-add-version-file.patch		\
   gnu/packages/patches/mumps-build-parallelism.patch		\
   gnu/packages/patches/mupen64plus-ui-console-notice.patch	\
   gnu/packages/patches/mutt-store-references.patch		\
diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
index 755bf4f..a3a3744 100644
--- a/gnu/packages/databases.scm
+++ b/gnu/packages/databases.scm
@@ -9,6 +9,7 @@
 ;;; Copyright © 2015 Leo Famulari <l...@famulari.name>
 ;;; Copyright © 2016 Efraim Flashner <efr...@flashner.co.il>
 ;;; Copyright © 2016 Nils Gillmann <niaster...@grrlz.net>
+;;; Copyright © 2016 Roel Janssen <r...@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -46,8 +47,8 @@
   #:use-module (gnu packages bison)
   #:use-module (gnu packages jemalloc)
   #:use-module ((guix licenses)
-                #:select (gpl2 gpl3+ lgpl2.1+ lgpl3+ x11-style non-copyleft
-                          bsd-2 bsd-3 public-domain))
+                #:select (asl2.0 agpl3 gpl2 gpl3+ lgpl2.1+ lgpl3+ x11-style
+                          non-copyleft bsd-2 bsd-3 public-domain))
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix build-system gnu)
@@ -271,6 +272,52 @@ Language.")
 as a drop-in replacement of MySQL.")
     (license gpl2)))
 
+(define-public mongodb
+  (package
+    (name "mongodb")
+    (version "3.3.3")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://github.com/mongodb/mongo/archive/r";
+                                  version ".tar.gz"))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32 "01v16j8xbry7m7apwlhiqhgx3zyyk2kadyk2sr9m6k20wnh5j24y"))
+              (patches (list (search-patch "mongodb-add-version-file.patch")))))
+    (build-system gnu-build-system)
+    (native-inputs
+     `(("scons" ,scons)
+       ("python" ,python-2)
+       ("perl" ,perl)))
+    (arguments
+     `(#:tests? #f ; There is no 'check' target.
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure) ; There is no configure phase
+         (add-after 'unpack 'scons-propagate-environment
+           (lambda _
+             ;; Modify the SConstruct file to arrange for
+             ;; environment variables to be propagated.
+             (substitute* "SConstruct"
+               (("^env = Environment\\(")
+                "env = Environment(ENV=os.environ, "))))
+         (replace 'build
+           (lambda _
+             (zero? (system* "scons" "mongod" "mongo" "mongos"))))
+         (replace 'install
+           (lambda _
+             (let ((bin  (string-append (assoc-ref %outputs "out") "/bin")))
+               (install-file "mongod" bin)
+               (install-file "mongos" bin)
+               (install-file "mongo" bin)))))))
+    (home-page "https://www.mongodb.org/";)
+    (synopsis "High performance and high availability document database")
+    (description "Mongo is a high-performance, high availability,
+schema-free document-oriented database.  A key goal of MongoDB is to bridge
+the gap between key/value stores (which are fast and highly scalable) and
+traditional RDBMS systems (which are deep in functionality).")
+    (license (list agpl3 asl2.0))))
+
 (define-public postgresql
   (package
     (name "postgresql")
diff --git a/gnu/packages/patches/mongodb-add-version-file.patch b/gnu/packages/patches/mongodb-add-version-file.patch
new file mode 100644
index 0000000..ffcb70e
--- /dev/null
+++ b/gnu/packages/patches/mongodb-add-version-file.patch
@@ -0,0 +1,10 @@
+This patch is used to replace the need for git.  It's a work-around
+for a problem described here: https://jira.mongodb.org/browse/SERVER-21317
+
+Patch by Roel Janssen <r...@gnu.org>
+--- a/version.json	1970-01-01 01:00:00.000000000 +0100
++++ b/version.json	2016-03-16 15:10:23.933578071 +0100
+@@ -0,0 +1,3 @@
++{
++    "version": "3.3.3-guix-"
++}
-- 
2.5.0

Dear Guix,

This is a patch to add MongoDB (server and client) tools.  I used a
three-line patch to fix the build process's reliance on Git and the
.git/ directory.

Kind regards,
Roel Janssen

Reply via email to