Use offline version of karaf 4.2.1

Change-Id: Ie3e42bd5768702c1d38df70f9c6fdf65a697635d
diff --git a/lib/deps.json b/lib/deps.json
index 3faad6b..b3ea3e8 100644
--- a/lib/deps.json
+++ b/lib/deps.json
@@ -292,7 +292,7 @@
     "typesafe-config": "mvn:com.typesafe:config:1.3.2",
     "validation-api": "mvn:javax.validation:validation-api:1.1.0.Final",
     "checkstyle": "mvn:com.puppycrawl.tools:checkstyle:8.10",
-    "apache-karaf": "http://repo1.maven.org/maven2/org/onosproject/apache-karaf-offline/4.2.1-20181024/apache-karaf-offline-4.2.1-20181024.tar.gz",
+    "apache-karaf": "http://repo1.maven.org/maven2/org/onosproject/apache-karaf-offline/4.2.1-offline-20181102/apache-karaf-offline-4.2.1-offline-20181102.tar.gz",
     "bndlib": "mvn:biz.aQute.bnd:biz.aQute.bndlib:jar:4.0.0",
     "bndexe": "mvn:biz.aQute.bnd:biz.aQute.bnd:4.0.0",
     "libthrift": "mvn:org.apache.thrift:libthrift:0.11.0",
diff --git a/tools/build/bazel/generate_workspace.bzl b/tools/build/bazel/generate_workspace.bzl
index 057ab80..2252a6e 100644
--- a/tools/build/bazel/generate_workspace.bzl
+++ b/tools/build/bazel/generate_workspace.bzl
@@ -1,4 +1,4 @@
-# ***** This file was auto-generated at Wed, 24 Oct 2018 19:26:57 GMT. Do not edit this file manually. *****
+# ***** This file was auto-generated at Thu, 1 Nov 2018 23:13:54 GMT. Do not edit this file manually. *****
 # ***** Use onos-lib-gen *****
 
 load("//tools/build/bazel:variables.bzl", "ONOS_GROUP_ID", "ONOS_VERSION")
@@ -1015,9 +1015,9 @@
     if "apache_karaf" not in native.existing_rules():
         java_import_external(
             name = "apache_karaf",
-            jar_sha256 = "2c43a844046ea7accbe4e673838b855d438c3f9077e6a900875b267c8c1cd92c",
+            jar_sha256 = "a9fc3883d4922d8a03c177e1696407a83b2e8af6b698c70a23d628b6ed1fffbf",
             licenses = ["notice"],
-            jar_urls = ["http://repo1.maven.org/maven2/org/onosproject/apache-karaf-offline/4.2.1-20181024/apache-karaf-offline-4.2.1-20181024.tar.gz"],        )
+            jar_urls = ["http://repo1.maven.org/maven2/org/onosproject/apache-karaf-offline/4.2.1-offline-20181102/apache-karaf-offline-4.2.1-offline-20181102.tar.gz"],        )
     if "bndlib" not in native.existing_rules():
         java_import_external(
             name = "bndlib",
@@ -1566,7 +1566,7 @@
 artifact_map["@typesafe_config//:typesafe_config"] = "mvn:com.typesafe:config:jar:1.3.2"
 artifact_map["@validation_api//:validation_api"] = "mvn:javax.validation:validation-api:jar:1.1.0.Final"
 artifact_map["@checkstyle//:checkstyle"] = "mvn:com.puppycrawl.tools:checkstyle:jar:NON-OSGI:8.10"
-artifact_map["@apache_karaf//:apache_karaf"] = "http://repo1.maven.org/maven2/org/onosproject/apache-karaf-offline/4.2.1-20181024/apache-karaf-offline-4.2.1-20181024.tar.gz"
+artifact_map["@apache_karaf//:apache_karaf"] = "http://repo1.maven.org/maven2/org/onosproject/apache-karaf-offline/4.2.1-offline-20181102/apache-karaf-offline-4.2.1-offline-20181102.tar.gz"
 artifact_map["@bndlib//:bndlib"] = "mvn:biz.aQute.bnd:biz.aQute.bndlib:jar:4.0.0"
 artifact_map["@bndexe//:bndexe"] = "mvn:biz.aQute.bnd:biz.aQute.bnd:jar:4.0.0"
 artifact_map["@libthrift//:libthrift"] = "mvn:org.apache.thrift:libthrift:jar:0.11.0"
diff --git a/tools/build/build-offline-karaf b/tools/build/build-offline-karaf
index baaec33..24d5821 100755
--- a/tools/build/build-offline-karaf
+++ b/tools/build/build-offline-karaf
@@ -1,12 +1,13 @@
 #!/bin/bash
  
 KARAF_VERSION="4.2.1"
+KARAF_BASE_PACKAGE_VERSION="4.2.1-20181024"
 KARAF_TARFILE_NAME="apache-karaf-${KARAF_VERSION}.tar"
-BOOT_FEATURES="standard,ssh,scr,war,webconsole"
+ADDED_BOOT_FEATURES="kar/${KARAF_VERSION},webconsole/${KARAF_VERSION},scr/${KARAF_VERSION},war/${KARAF_VERSION}"
 
 # fetch the standard karaf bits
 rm -f /tmp/${KARAF_TARFILE_NAME}
-curl -o /tmp/${KARAF_TARFILE_NAME}.gz http://onlab.vicci.org/onos/third-party/${KARAF_TARFILE_NAME}.gz
+curl -o /tmp/${KARAF_TARFILE_NAME}.gz http://repo1.maven.org/maven2/org/onosproject/apache-karaf-offline/${KARAF_BASE_PACKAGE_VERSION}/apache-karaf-offline-${KARAF_BASE_PACKAGE_VERSION}.tar.gz
 
 # get a small cell
 source ${ONOS_ROOT}/tools/dev/bash_profile
@@ -21,13 +22,13 @@
     cd karaf
     tar xf /tmp/${KARAF_TARFILE_NAME}.gz
 
-    # set the ONOS default boot features
-    perl -pi.old -e 's|^(featuresBoot=).*|\1${BOOT_FEATURES}|' apache-karaf-${KARAF_VERSION}/etc/org.apache.karaf.features.cfg
+    # add the extra ONOS default boot features
+    sed -i.old -e 's|kar/${KARAF_VERSION}.*$|${ADDED_BOOT_FEATURES}|' apache-karaf-${KARAF_VERSION}/etc/org.apache.karaf.features.cfg
 
     # run karaf to fill the maven repo with required artifacts
     apache-karaf-${KARAF_VERSION}/bin/karaf server 1>/tmp/onos.out 2>/tmp/onos.err &
 
-    sleep 15
+    sleep 30
 
     # stop karaf and capture the artifacts that were downloaded into the maven repo
     apache-karaf-${KARAF_VERSION}/bin/karaf stop 1>/tmp/onos.out 2>/tmp/onos.err &
@@ -51,7 +52,7 @@
 "
 
 # fetch the new offline karaf tar ball
-BUILD_NUMBER="apache-karaf-${KARAF_VERSION}-offline-$(date +'%Y%m%d')"
+BUILD_NUMBER="${KARAF_VERSION}-offline-$(date +'%Y%m%d')"
 scp sdn@[${OC1}]:karaf-offline.tar.gz /tmp/${BUILD_NUMBER}.tar.gz
 
 cell return