Index: files/lion.patch
===================================================================
--- files/lion.patch	(revision 86535)
+++ files/lion.patch	(working copy)
@@ -1,20 +0,0 @@
---- util/processinfo_darwin.cpp.orig
-+++ util/processinfo_darwin.cpp
-@@ -19,7 +19,7 @@
- #include "processinfo.h"
- #include "log.h"
- 
--
-+#include <mach/vm_statistics.h>
- #include <mach/task_info.h>
- 
- #include <mach/mach_init.h>
-@@ -27,7 +27,7 @@
- #include <mach/mach_traps.h>
- #include <mach/task.h>
- #include <mach/vm_map.h>
--#include <mach/shared_memory_server.h>
-+#include <mach/shared_region.h>
- #include <iostream>
- 
- #include <sys/types.h>
Index: files/patch-distsrc-client-SConstruct.diff
===================================================================
--- files/patch-distsrc-client-SConstruct.diff	(revision 0)
+++ files/patch-distsrc-client-SConstruct.diff	(revision 0)
@@ -0,0 +1,11 @@
+--- distsrc/client/SConstruct.orig	2011-09-11 09:09:34.000000000 -0500
++++ distsrc/client/SConstruct	2011-09-13 03:50:05.000000000 -0500
+@@ -39,7 +39,7 @@
+ linux = False
+ 
+ if "darwin" == os.sys.platform:
+-    addExtraLibs( "/opt/local/" )
++    addExtraLibs( "@@PREFIX@@/" )
+     nix = True
+ elif "linux2" == os.sys.platform or "linux3" == os.sys.platform:
+     nix = True
Index: files/patch-SConstruct.diff
===================================================================
--- files/patch-SConstruct.diff	(revision 86535)
+++ files/patch-SConstruct.diff	(working copy)
@@ -1,6 +1,6 @@
---- SConstruct.orig	2011-03-16 10:33:30.000000000 -0500
-+++ SConstruct	2011-03-27 03:30:06.000000000 -0500
-@@ -447,21 +447,14 @@
+--- SConstruct.orig	2011-10-21 19:52:16.000000000 -0500
++++ SConstruct	2011-10-27 20:35:05.000000000 -0500
+@@ -473,21 +473,15 @@
      darwin = True
      platform = "osx" # prettier than darwin
  
@@ -20,33 +20,52 @@
 -        env.Append( CPPPATH=filterExists(["/sw/include" , "/opt/local/include"]) )
 -        env.Append( LIBPATH=filterExists(["/sw/lib/", "/opt/local/lib"]) )
 +    env.Append( CPPPATH=["@@PREFIX@@/include"] )
-+    env.Append( LIBPATH=["@@PREFIX@@/lib/"] )
++    env.Append( LIBPATH=["@@PREFIX@@/lib"] )
 +    env["CFLAGS"] = os.getenv("CFLAGS")
++    env["CPPFLAGS"] = os.getenv("CPPFLAGS")
 +    env["CXXFLAGS"] = os.getenv("CXXFLAGS")
 +    env["LINKFLAGS"] = os.getenv("LINKFLAGS")
 +
  
- elif "linux2" == os.sys.platform:
+ elif "linux2" == os.sys.platform or "linux3" == os.sys.platform:
      linux = True
-@@ -931,11 +924,7 @@
-         haveReadLine = False
-         if darwin:
-             myenv.Append( CPPDEFINES=[ "USE_READLINE" ] )
--            if force64:
--                myCheckLib( "readline" , True )
--                myCheckLib( "ncurses" , True )
--            else:
--                myenv.Append( LINKFLAGS=" /usr/lib/libreadline.dylib " )
-+            myenv.Append( LINKFLAGS=" @@PREFIX@@/lib/libreadline.dylib " )
-         elif openbsd:
-             myenv.Append( CPPDEFINES=[ "USE_READLINE" ] )
-             myCheckLib( "termcap" , True )
-@@ -1176,8 +1165,6 @@
-         shellEnv["LINKFLAGS"].remove("-m64")
-         shellEnv["CPPPATH"].remove( "/usr/64/include" )
-         shellEnv["LIBPATH"].remove( "/usr/64/lib" )
--        shellEnv.Append( CPPPATH=filterExists(["/sw/include" , "/opt/local/include"]) )
--        shellEnv.Append( LIBPATH=filterExists(["/sw/lib/", "/opt/local/lib" , "/usr/lib", "/usr/local/lib" ]) )
+@@ -670,7 +664,7 @@
+         env["CXX"] = "distcc " + env["CXX"]
+         
+     # -Winvalid-pch Warn if a precompiled header (see Precompiled Headers) is found in the search path but can't be used. 
+-    env.Append( CPPFLAGS="-fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch" )
++    env.Append( CPPFLAGS=" -fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch " )
+     # env.Append( " -Wconversion" ) TODO: this doesn't really work yet
+     if linux:
+         env.Append( CPPFLAGS=" -Werror " )
+@@ -757,21 +751,6 @@
+         keyfile = "jstests/libs/key%s" % keysuffix
+         os.chmod( keyfile , stat.S_IWUSR|stat.S_IRUSR )
  
-     l = shellEnv["LIBS"]
+-for x in os.listdir( "third_party" ):
+-    if not x.endswith( ".py" ) or x.find( "#" ) >= 0:
+-        continue
+-         
+-    shortName = x.rpartition( "." )[0]
+-    path = "third_party/%s" % x
+-
+-
+-    myModule = imp.load_module( "third_party_%s" % shortName , open( path , "r" ) , path , ( ".py" , "r" , imp.PY_SOURCE ) )
+-    fileLists = { "commonFiles" : commonFiles , "serverOnlyFiles" : serverOnlyFiles , "scriptingFiles" : scriptingFiles }
+-    
+-    options_topass["windows"] = windows
+-    options_topass["nix"] = nix
+-    
+-    myModule.configure( env , fileLists , options_topass )
  
+ coreServerFiles += scriptingFiles
+ 
+@@ -963,7 +942,7 @@
+ 
+         myCheckLib( "tcmalloc" , True );  # if successful, appedded 'tcmalloc' to myenv[ LIBS ]
+         myenv.Append( CPPDEFINES=[ "HEAP_CHECKING" ] )
+-        myenv.Append( CPPFLAGS="-fno-omit-frame-pointer" )
++        myenv.Append( CPPFLAGS=" -fno-omit-frame-pointer " )
+ 
+     # FIXME doConfigure() is being called twice, in the case of the shell. So if it is called 
+     # with shell==True, it'd be on its second call and it would need to rearrange the libraries'
Index: files/patch-util-compress.cpp.diff
===================================================================
--- files/patch-util-compress.cpp.diff	(revision 0)
+++ files/patch-util-compress.cpp.diff	(revision 0)
@@ -0,0 +1,10 @@
+--- util/compress.cpp.orig	2011-10-21 19:52:16.000000000 -0500
++++ util/compress.cpp	2011-10-27 19:30:16.000000000 -0500
+@@ -1,6 +1,6 @@
+ // @file compress.cpp
+ 
+-#include "../third_party/snappy/snappy.h"
++#include <snappy.h>
+ #include "compress.h"
+ #include <string>
+ #include <string.h>
Index: Portfile
===================================================================
--- Portfile	(revision 86535)
+++ Portfile	(working copy)
@@ -4,7 +4,7 @@
 
 name                mongodb
 epoch               1
-version             1.8.3
+version             2.0.1
 license             AGPL-3.0
 categories          databases
 maintainers         nomaintainer
@@ -18,8 +18,8 @@
 master_sites        http://downloads.mongodb.org/src/
 distname            ${name}-src-r${version}
 
-checksums           rmd160  9662b6963e7e6a4b5adcbea3faa36dd50a794457 \
-                    sha256  ee121c9698a48b819f1c5b5ba10a98d565bd732d527743f1475f54f697dd63e2
+checksums           rmd160  e98af1398a9eb0ce0b5a6eae28dc93963cac4630 \
+                    sha256  4acbf4186b03fffabd6ea36f8312b173ea0f34b919833675b5f7330ef0470749
 
 depends_build       port:scons
 
@@ -27,12 +27,24 @@
                     port:pcre \
                     port:spidermonkey \
                     port:libpcap \
-                    port:readline
+                    port:snappy
 
-patchfiles          patch-SConstruct.diff
+patchfiles          patch-SConstruct.diff \
+                    patch-distsrc-client-SConstruct.diff \
+                    patch-util-compress.cpp.diff
 
 post-patch {
-    reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/SConstruct
+    # Delete all included third-party libraries, except linenoise for which
+    # we don't have a port yet (there doesn't seem to be a stable release).
+    foreach x [glob ${worksrcpath}/third_party/*] {
+        if {"linenoise" != [file tail ${x}]} {
+            delete ${x}
+        }
+    }
+    
+    reinplace "s|@@PREFIX@@|${prefix}|g" \
+        ${worksrcpath}/SConstruct \
+        ${worksrcpath}/distsrc/client/SConstruct
 }
 
 use_configure       no
@@ -41,8 +53,9 @@
 
 build.env           TERM=xterm \
                     CFLAGS="[get_canonical_archflags]" \
+                    CPPFLAGS="-I${prefix}/include/js -DXP_UNIX" \
                     CXXFLAGS="[get_canonical_archflags]" \
-                    LINKFLAGS="[get_canonical_archflags]"
+                    LINKFLAGS="[get_canonical_archflags] -ljs -lpcre -lpcrecpp -lsnappy"
 build.cmd           scons
 build.args          --usesm --cxx=${configure.cxx} --full
 build.target        all mongobridge mongosniff
@@ -74,9 +87,5 @@
 startupitem.create      yes
 startupitem.executable  sudo -u ${mongouser} ${prefix}/bin/mongod --dbpath ${dbdir} --logpath ${logdir}/mongodb.log --logappend
 
-platform darwin 11 {
-    patchfiles-append lion.patch
-}
-
 livecheck.url       ${homepage}downloads
 livecheck.regex     {mongodb-src-r(\d+\.\d*[02468]\.\d+)\.}
