Patching Apache Karaf with a shell console fix to avoid thread leak.

Change-Id: I27e8fbaf443391a51b40c35639a39a5f38aecf31
diff --git a/lib/BUCK b/lib/BUCK
index c37f470..3ae6307 100644
--- a/lib/BUCK
+++ b/lib/BUCK
@@ -1,4 +1,4 @@
-# ***** This file was auto-generated at Thu, 12 Apr 2018 17:32:52 GMT. Do not edit this file manually. *****
+# ***** This file was auto-generated at Sat, 21 Apr 2018 05:05:33 GMT. Do not edit this file manually. *****
 # ***** Use onos-lib-gen *****
 
 pass_thru_pom(
@@ -1185,6 +1185,14 @@
   visibility = [ 'PUBLIC' ],
 )
 
+remote_file (
+  name = 'apache-karaf-patches',
+  out = 'onos-apache-karaf-patches-3.0.8.tar.gz',
+  url = 'mvn:org.onosproject:onos-apache-karaf-patches:tar.gz:3.0.8',
+  sha1 = 'be5d620a2c4f4c5faa520d2c1b949ad0cc29c84f',
+  visibility = [ 'PUBLIC' ],
+)
+
 remote_jar (
   name = 'bndlib',
   out = 'biz.aQute.bndlib-3.1.0.jar',
diff --git a/lib/deps.json b/lib/deps.json
index ccf648d..46d6d30 100644
--- a/lib/deps.json
+++ b/lib/deps.json
@@ -225,6 +225,7 @@
     "validation-api": "mvn:javax.validation:validation-api:1.1.0.Final",
     "checkstyle": "mvn:com.puppycrawl.tools:checkstyle:6.19",
     "apache-karaf": "mvn:org.onosproject:apache-karaf-offline:tar.gz:3.0.8",
+    "apache-karaf-patches": "mvn:org.onosproject:onos-apache-karaf-patches:tar.gz:3.0.8",
     "bndlib": "mvn:biz.aQute.bnd:biz.aQute.bndlib:jar:3.1.0",
     "bndexe": "mvn:biz.aQute.bnd:biz.aQute.bnd:3.1.0",
     "libthrift": "mvn:org.apache.thrift:libthrift:0.9.3",
diff --git a/tools/package/BUCK b/tools/package/BUCK
index 05fefcb..a317983 100644
--- a/tools/package/BUCK
+++ b/tools/package/BUCK
@@ -1,5 +1,6 @@
 KARAF = '//lib:apache-karaf'
 BRANDING = '//tools/package/branding:onos-tools-package-branding'
+PATCHES = '//lib:apache-karaf-patches'
 
 FEATURES = [
   '//features:onos-thirdparty-base',
@@ -21,8 +22,8 @@
 genrule(
   name = 'onos-karaf',
   srcs = glob(['bin/*', 'etc/*', 'init/*', 'runtime/bin/*']),
-  bash = '$(location :onos-prep-karaf) $OUT $(location %s) %s $(location %s)'\
-            % (KARAF, ONOS_VERSION, BRANDING),
+  bash = '$(location :onos-prep-karaf) $OUT $(location %s) %s $(location %s) $(location %s)'\
+            % (KARAF, ONOS_VERSION, BRANDING, PATCHES),
   out = 'karaf.zip',
 )
 
diff --git a/tools/package/onos-prep-karaf b/tools/package/onos-prep-karaf
index 718630c..a466858 100755
--- a/tools/package/onos-prep-karaf
+++ b/tools/package/onos-prep-karaf
@@ -9,6 +9,7 @@
 KARAF_TAR=$2
 ONOS_VERSION=$3
 BRANDING=$4
+KARAF_PATCHES=$5
 #FIXME karaf version
 KARAF_VERSION="3.0.8"
 ONOS_SECURITY_MODE="false"
@@ -21,6 +22,8 @@
 # rename path name to match what was distributed with vicci
 mv "$(ls -d apache*)" "apache-karaf-$KARAF_VERSION" || true
 
+tar xf $KARAF_PATCHES
+
 # Unroll the Apache Karaf bits, prune them and make ONOS top-level directories.
 KARAF_DIR=$(ls -d apache*)
 rm -rf $KARAF_DIR/demos