Committed by
Gerrit Code Review
onos-package updates for sm-onos
Change-Id: I14e83645361b3ec12cb8b065f10e7db45008bd43
Showing
1 changed file
with
80 additions
and
28 deletions
... | @@ -72,12 +72,15 @@ function build_stage_dir() { | ... | @@ -72,12 +72,15 @@ function build_stage_dir() { |
72 | 72 | ||
73 | # ONOS Patching ---------------------------------------------------------------- | 73 | # ONOS Patching ---------------------------------------------------------------- |
74 | 74 | ||
75 | + export BOOT_FEATURES="webconsole,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui" | ||
76 | + | ||
77 | + [ "$ONOS_SECURITY_MODE" = true ] && enable_security_mode | ||
78 | + | ||
75 | # Patch the Apache Karaf distribution file to add ONOS features repository | 79 | # Patch the Apache Karaf distribution file to add ONOS features repository |
76 | perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onosproject/onos-features/$ONOS_POM_VERSION/xml/features|" \ | 80 | perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onosproject/onos-features/$ONOS_POM_VERSION/xml/features|" \ |
77 | $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg | 81 | $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg |
78 | 82 | ||
79 | # Patch the Apache Karaf distribution file to load default ONOS boot features | 83 | # Patch the Apache Karaf distribution file to load default ONOS boot features |
80 | - export BOOT_FEATURES="webconsole,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui" | ||
81 | perl -pi.old -e "s|^(featuresBoot=.*)|\1,$BOOT_FEATURES|" \ | 84 | perl -pi.old -e "s|^(featuresBoot=.*)|\1,$BOOT_FEATURES|" \ |
82 | $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg | 85 | $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg |
83 | 86 | ||
... | @@ -89,19 +92,49 @@ function build_stage_dir() { | ... | @@ -89,19 +92,49 @@ function build_stage_dir() { |
89 | echo $ONOS_VERSION > $ONOS_STAGE/VERSION | 92 | echo $ONOS_VERSION > $ONOS_STAGE/VERSION |
90 | } | 93 | } |
91 | 94 | ||
92 | -function build_compressed_package() { | 95 | +function clean_stage_dir() { |
93 | - # Package up the ONOS tar file | 96 | + [ -d "$ONOS_STAGE" ] && rm -r $ONOS_STAGE || : |
94 | - cd $ONOS_STAGE_ROOT | 97 | +} |
95 | - rm -f $ONOS_TAR $ONOS_ZIP | 98 | + |
96 | - COPYFILE_DISABLE=1 tar zcf $ONOS_TAR $ONOS_BITS | 99 | +function enable_security_mode() { |
100 | + echo "Enabling security mode ONOS..." | ||
101 | + | ||
102 | + # SM-ONOS step 1: downgrade felix config admin | ||
103 | + FELIX_CFG_ADMIN=${FELIX_CFG_ADMIN:-~/Downloads/org.apache.felix.configadmin-1.6.0.jar} | ||
104 | + if [ ! -f $FELIX_CFG_ADMIN ]; then | ||
105 | + echo "Downloading $FELIX_CFG_ADMIN..." | ||
106 | + curl -sL http://archive.apache.org/dist/felix/org.apache.felix.configadmin-1.6.0.jar > $FELIX_CFG_ADMIN | ||
107 | + fi | ||
108 | + [ ! -f $FELIX_CFG_ADMIN ] && \ | ||
109 | + echo "Felix config admin not found: $FELIX_CFG_ADMIN" && exit 1 | ||
110 | + | ||
111 | + mkdir -p $ONOS_STAGE/$KARAF_DIST/system/org/apache/felix/org.apache.felix.configadmin/1.6.0 | ||
112 | + cp $FELIX_CFG_ADMIN $ONOS_STAGE/$KARAF_DIST/system/org/apache/felix/org.apache.felix.configadmin/1.6.0 | ||
113 | + perl -pi.old -e "s|org.apache.felix.configadmin/1.8.0|org.apache.felix.configadmin/1.6.0|g" \ | ||
114 | + $ONOS_STAGE/$KARAF_DIST/etc/startup.properties | ||
115 | + | ||
116 | + # SM-ONOS step 2: stage ONOS Felix framework security (this is already done by karaf assembly); end | ||
117 | + | ||
118 | + # SM-ONOS step 3.1: configure karaf | ||
119 | + perl -pi.old -e "s|#java.security.policy|java.security.policy|" \ | ||
120 | + $ONOS_STAGE/$KARAF_DIST/etc/system.properties | ||
121 | + perl -pi.old -e "s|#org.osgi.framework.security|org.osgi.framework.security|" \ | ||
122 | + $ONOS_STAGE/$KARAF_DIST/etc/system.properties | ||
97 | 123 | ||
98 | - # Figure out whether we should build ONOS zip file and if so, build it. | 124 | + # SM-ONOS step 3.2: update featuresBoot |
99 | - which zip >/dev/null && [ -z "$ONOS_TAR_ONLY" ] && buildZip=true || unset buildZip | 125 | + export BOOT_FEATURES="onos-security,$BOOT_FEATURES" |
100 | - [ -n "$buildZip" ] && zip -rq $ONOS_ZIP $ONOS_BITS | 126 | +} |
101 | 127 | ||
102 | - # Report on the archives that were built and clean-up | 128 | +function build_compressed_zip() { |
103 | - [ -n "$buildZip" ] && ls -lh $ONOS_TAR $ONOS_ZIP || ls -lh $ONOS_TAR | 129 | + cd $ONOS_STAGE_ROOT |
104 | - rm -r $ONOS_STAGE | 130 | + rm -f $ONOS_ZIP |
131 | + which zip >/dev/null && zip -rq $ONOS_ZIP $ONOS_BITS && ls -lh $ONOS_ZIP | ||
132 | +} | ||
133 | + | ||
134 | +function build_compressed_tar() { | ||
135 | + cd $ONOS_STAGE_ROOT | ||
136 | + rm -f $ONOS_TAR | ||
137 | + COPYFILE_DISABLE=1 tar zcf $ONOS_TAR $ONOS_BITS && ls -lh $ONOS_TAR | ||
105 | } | 138 | } |
106 | 139 | ||
107 | # Build a DEB package | 140 | # Build a DEB package |
... | @@ -162,25 +195,44 @@ function build_rpm() { | ... | @@ -162,25 +195,44 @@ function build_rpm() { |
162 | # Bail on any errors | 195 | # Bail on any errors |
163 | set -e | 196 | set -e |
164 | 197 | ||
198 | +[[ $# == 0 ]] && ONOS_PACKAGE_TAR_arg=true | ||
199 | +while [[ $# > 0 ]]; do | ||
200 | +case $1 in | ||
201 | + -t|--tar) | ||
202 | + ONOS_PACKAGE_TAR_arg=true | ||
203 | + ;; | ||
204 | + -z|--zip) | ||
205 | + ONOS_PACKAGE_ZIP_arg=true | ||
206 | + ;; | ||
207 | + -d|--deb) | ||
208 | + ONOS_PACKAGE_DEB_arg=true | ||
209 | + ;; | ||
210 | + -r|--rpm) | ||
211 | + ONOS_PACKAGE_RPM_arg=true | ||
212 | + ;; | ||
213 | + -s|--secure) | ||
214 | + ONOS_SECURITY_MODE=true | ||
215 | + ;; | ||
216 | + *) | ||
217 | + # unknown option | ||
218 | + echo "Unknown options: $1" | ||
219 | + echo "usage: $(basename $0) [--tar] [--zip] [--deb] [--rpm] [--secure]" >&2 && exit 1 | ||
220 | + ;; | ||
221 | +esac | ||
222 | +shift | ||
223 | +done | ||
224 | + | ||
165 | # Run karaf assembly to collect artifacts for off-line installations. | 225 | # Run karaf assembly to collect artifacts for off-line installations. |
166 | aux=/tmp/assembly-$$.log | 226 | aux=/tmp/assembly-$$.log |
167 | trap "rm -f $aux 2>/dev/null" EXIT | 227 | trap "rm -f $aux 2>/dev/null" EXIT |
168 | cd $ONOS_ROOT/tools/package/karaf-assembly && mvn clean install > $aux 2>&1 | 228 | cd $ONOS_ROOT/tools/package/karaf-assembly && mvn clean install > $aux 2>&1 |
169 | 229 | ||
170 | # Before starting make sure the environment is clan - delete onos staging folder | 230 | # Before starting make sure the environment is clan - delete onos staging folder |
171 | -rm -fr $ONOS_STAGE | 231 | +clean_stage_dir |
172 | - | 232 | + |
173 | -# If there are parameters check if we want to build a deb - otherwise build tar.gz | 233 | +build_stage_dir |
174 | -case ${1:---tar} in | 234 | +[ "$ONOS_PACKAGE_TAR_arg" = true ] && build_compressed_tar |
175 | - "--tar" | "-T") build_stage_dir | 235 | +[ "$ONOS_PACKAGE_ZIP_arg" = true ] && build_compressed_zip |
176 | - build_compressed_package | 236 | +[ "$ONOS_PACKAGE_DEB_arg" = true ] && build_deb |
177 | - ;; | 237 | +[ "$ONOS_PACKAGE_RPM_arg" = true ] && build_rpm |
178 | - "--deb" | "-D") build_stage_dir | 238 | +clean_stage_dir |
179 | - build_deb | ||
180 | - ;; | ||
181 | - "--rpm" | "-R") build_stage_dir | ||
182 | - build_rpm | ||
183 | - ;; | ||
184 | - *) echo "usage: $(basename $0) [--tar|--deb|--rpm]" >&2 && exit 1 | ||
185 | - ;; | ||
186 | -esac | ... | ... |
-
Please register or login to post a comment