--- Portfile.org	2014-06-25 23:57:41.000000000 -0700
+++ Portfile	2014-06-26 04:04:18.000000000 -0700
@@ -4,7 +4,7 @@
 PortSystem          1.0
 
 name                bacula
-version             5.2.13
+version             7.0.4
 categories          sysutils
 platforms           darwin
 license             {AGPL-3 OpenSSLException}
@@ -18,8 +18,8 @@
 homepage            http://www.bacula.org/
 master_sites        sourceforge
 
-checksums           rmd160  bcc168143c0eec5cb5e983f765935534379f4fcf \
-                    sha256  a4bed458bf001889bd06bf31671b5d9908055a1d1e8113fd750ae4d326607ad8
+checksums           rmd160  09d033f4ea3431f57d8018647af41c1ae417652d \
+                    sha256  ebf802b843a95f6526e82dd181dff7cd7dc7d1fdc55cec8636e0fe3af69acf7e
 
 depends_build       port:pkgconfig
 depends_lib         port:gawk \
@@ -28,7 +28,8 @@
                     port:ncurses \
                     port:openssl \
                     port:tcp_wrappers \
-                    port:zlib
+                    port:zlib \
+                    port:lzo2
 
 configure.ccache    no
 configure.args      --mandir=${prefix}/share/man \
@@ -40,19 +41,15 @@
                     --with-libintl-prefix=${prefix} \
                     --with-openssl=${prefix} \
                     --with-libiconv-prefix=${prefix} \
-                    --with-readline=${prefix} \
                     --with-archivedir=/var/tmp \
                     --with-working-dir=${prefix}/var/bacula/working \
                     --with-included-gettext=${prefix} \
                     --enable-smartalloc \
                     --enable-largefile \
-                    --without-sqlite \
+                    --enable-conio \
                     --without-sqlite3 \
                     --without-postgresql \
                     --without-mysql \
-                    --disable-gnome \
-                    --disable-wx-console \
-                    --disable-tray-monitor \
                     --with-tcp-wrappers
 
 configure.cppflags-append   -I${prefix}/ncurses
@@ -73,7 +70,7 @@
 startupitem.start   "\[ -x \${BIN} \] && \${BIN} -c ${prefix}/etc/bacula/bacula-fd.conf"
 startupitem.stop    "\[ -r \${PID} \] && /bin/kill \$(cat \${PID})"
 
-variant client_only conflicts mysql55 postgresql83 postgresql84 sqlite2 sqlite3 description "Install bacula client (bacula-fd) only" {
+variant client_only conflicts mysql51 mysql55 postgresql83 postgresql84 sqlite3 description "Install bacula client (bacula-fd) only" {
     configure.args-append --enable-client-only
 }
 
@@ -95,10 +92,23 @@
     notes "To use the Bacula BAT GUI, you'll need to configure \"${prefix}/etc/bacula/bat.conf\"."
 }
 
-variant mysql55 conflicts client_only postgresql83 postgresql84 sqlite2 sqlite3 description "Install bacula client and server with mysql 5 backend" {
+variant mysql51 conflicts client_only mysql55 postgresql83 postgresql84 sqlite3 description "Install bacula client and server with mysql 5.1 backend" {
+    depends_lib-append    port:mysql51
+    configure.args-append --with-mysql=${prefix}/include/mysql51/mysql
+    configure.args-delete --without-mysql
+    configure.args-append --enable-batch-insert
+    configure.cppflags-append   -I${prefix}/include/mysql51/mysql
+
+    patchfiles          patch-configure-mysql.diff
+    post-patch {
+                     reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/configure
+    }
+}
+variant mysql55 conflicts client_only mysql51 postgresql83 postgresql84 sqlite3 description "Install bacula client and server with mysql 5.5 backend" {
     depends_lib-append    port:mysql55
     configure.args-append --with-mysql=${prefix}/include/mysql55/mysql
     configure.args-delete --without-mysql
+    configure.args-append --enable-batch-insert
     configure.cppflags-append   -I${prefix}/include/mysql55/mysql
 
     patchfiles          patch-configure-mysql.diff
@@ -107,27 +117,23 @@
     }
 }
 
-variant postgresql83 conflicts mysql55 postgresql84 sqlite2 sqlite3 client_only description "Install bacula client and server with postgresql 8.3 backend" {
+variant postgresql83 conflicts mysql51 mysql55 postgresql84 sqlite3 client_only description "Install bacula client and server with postgresql 8.3 backend" {
     depends_lib-append    port:postgresql83
     configure.args-append --with-postgresql
     configure.args-delete --without-postgresql
+    configure.args-append --enable-batch-insert
     configure.env-append  PATH=${prefix}/lib/postgresql83/bin:$env(PATH)
 }
 
-variant postgresql84 conflicts mysql55 postgresql83 sqlite2 sqlite3 client_only description "Install bacula client and server with postgresql 8.4 backend" {
+variant postgresql84 conflicts mysql51 mysql55 postgresql83 sqlite3 client_only description "Install bacula client and server with postgresql 8.4 backend" {
     depends_lib-append    port:postgresql84
     configure.args-append --with-postgresql
     configure.args-delete --without-postgresql
+    configure.args-append --enable-batch-insert
     configure.env-append  PATH=${prefix}/lib/postgresql84/bin:$env(PATH)
 }
 
-variant sqlite2 conflicts client_only sqlite3 mysql55 postgresql83 postgresql84 description "Install bacula client and server with sqlite 2 backend" {
-    depends_lib-append    port:sqlite2
-    configure.args-append --with-sqlite=${prefix}
-    configure.args-delete --without-sqlite
-}
-
-variant sqlite3 conflicts client_only sqlite2 mysql55 postgresql83 postgresql84 description "Install bacula client and server with sqlite 3 backend" {
+variant sqlite3 conflicts client_only mysql51 mysql55 postgresql83 postgresql84 description "Install bacula client and server with sqlite 3 backend" {
     depends_lib-append    port:sqlite3
     configure.args-append --with-sqlite3=${prefix}
     configure.args-delete --without-sqlite3
@@ -135,7 +141,7 @@
 
 default_variants +console_bat
 
-if {![variant_isset mysql55] && ![variant_isset postgresql83] && ![variant_isset postgresql84] && ![variant_isset sqlite2] && ![variant_isset sqlite3]} {
+if {![variant_isset mysql51] && ![variant_isset mysql55] && ![variant_isset postgresql83] && ![variant_isset postgresql84] && ![variant_isset sqlite3]} {
     default_variants-append +client_only
 }
