ONOS-4344 Fixes to onos_stage.py to fix Buck onos-package

Change-Id: I807a3cf66f15c60adb5790bdb54d4b68ea7f953d
diff --git a/tools/package/BUCK b/tools/package/BUCK
index 19c7db1..27c0274 100644
--- a/tools/package/BUCK
+++ b/tools/package/BUCK
@@ -99,7 +99,7 @@
 
 genrule(
   name = 'onos-package',
-  out = 'onos.zip',
+  out = 'onos.tar.gz',
   bash = 'cp $(location :onos-karaf) $OUT && $(exe //buck-tools:onos-stage) $OUT ' + ' '.join(sources),
   visibility = [ 'PUBLIC' ],
 )
\ No newline at end of file
diff --git a/tools/package/onos-prep-karaf b/tools/package/onos-prep-karaf
index c592648..afda1c2 100755
--- a/tools/package/onos-prep-karaf
+++ b/tools/package/onos-prep-karaf
@@ -9,6 +9,10 @@
 KARAF_TAR=$2
 ONOS_VERSION=$3
 BRANDING=$4
+#FIXME karaf version
+KARAF_VERSION="3.0.5"
+
+PREFIX="onos-1.6.0"
 
 # Unroll the Apache Karaf bits, prune them and make ONOS top-level directories.
 tar xf $KARAF_TAR
@@ -27,27 +31,32 @@
 mv bin/onos-client bin/onos
 chmod a+x bin/onos-service bin/onos
 
-# Stage the ONOS admin scripts and patch in Karaf service wrapper extras
-cp -r bin $KARAF_DIR
-cp -r init $KARAF_DIR
-cp -r etc $KARAF_DIR
-
-export BOOT_FEATURES="webconsole,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui"
+export BOOT_FEATURES="standard,ssh,scr,war,webconsole,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui"
 #FIXME
 #[ "$ONOS_SECURITY_MODE" = true ] && enable_security_mode
 
 # Patch the Apache Karaf distribution file to add ONOS features repository
-perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onosproject/onos-features/$ONOS_VERSION/xml/features|" \
+perl -pi.old -e "s|^(featuresRepositories=).*|\1mvn:org.apache.karaf.features/standard/$KARAF_VERSION/xml/features,mvn:org.onosproject/onos-features/$ONOS_VERSION/xml/features|" \
     $KARAF_DIR/etc/org.apache.karaf.features.cfg
 
 # Patch the Apache Karaf distribution file to load default ONOS boot features
-perl -pi.old -e "s|^(featuresBoot=.*)|\1,$BOOT_FEATURES|" \
+perl -pi.old -e "s|^(featuresBoot=).*|\1$BOOT_FEATURES|" \
     $KARAF_DIR/etc/org.apache.karaf.features.cfg
 
+
 # Patch the Apache Karaf distribution with ONOS branding bundle
 cp $BRANDING $KARAF_DIR/lib
 
-zip -q -0 -r $OUT $KARAF_DIR
+# **** Moving karaf to subdirectory ****
+mkdir $PREFIX
+mv $KARAF_DIR $PREFIX
+
+# Stage the ONOS admin scripts and patch in Karaf service wrapper extras
+cp -r bin $PREFIX
+cp -r init $PREFIX
+cp -r etc $PREFIX/$KARAF_DIR/etc/
+
+tar czf $OUT $PREFIX
 
 #FIXME
 # Stage all builtin ONOS apps for factory install