Skip to content

Commit

Permalink
Upgrade to Karaf 4.2.1 (#761)
Browse files Browse the repository at this point in the history
Signed-off-by: Wouter Born <eclipse@maindrain.net>
  • Loading branch information
wborn authored and kaikreuzer committed Sep 14, 2018
1 parent c321e9b commit e101923
Show file tree
Hide file tree
Showing 8 changed files with 209 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
# * 3. if not found looks for ${maven.home}/conf/settings.xml
# * 4. if not found looks for ${M2_HOME}/conf/settings.xml
#
# Properties prefixed with "org.ops4j.pax.url.mvn." have
# higher priority except <proxies> element. HTTP proxies should be configured in
# settings file
#org.ops4j.pax.url.mvn.settings=

#
Expand All @@ -28,17 +31,21 @@ org.ops4j.pax.url.mvn.localRepository=${openhab.userdata}/tmp/mvn

#
# Default this to false. It's just weird to use undocumented repos
# "false" means that http://repo1.maven.org/maven2@id=central won't be
# implicitly used as remote repository
#
org.ops4j.pax.url.mvn.useFallbackRepositories=false

#
# Uncomment if you don't wanna use the proxy settings
# from the Maven conf/settings.xml file
#
# org.ops4j.pax.url.mvn.proxySupport=false

#
# Comma separated list of repositories scanned when resolving an artifact.
# list of repositories searched in the first place, should contain
# ${runtime.home}/${karaf.default.repository}.
# if "org.ops4j.pax.url.mvn.localRepository" is defined and it's not
# ~/.m2/repository, it's recommended (at least for dev purposes) to add
# ~/.m2/repository to defaultRepositories
# each of these repositories is checked by aether as "local repository". if
# artifact isn't found, "repositories" are searched next
#
# Those repositories will be checked before iterating through the
# below list of repositories and even before the local repository
# A repository url can be appended with zero or more of the following flags:
Expand All @@ -48,31 +55,36 @@ org.ops4j.pax.url.mvn.useFallbackRepositories=false
# The following property value will add the system folder as a repo.
#
org.ops4j.pax.url.mvn.defaultRepositories=\
file:${karaf.home}/${karaf.default.repository}@id=system.repository@snapshots, \
file:${karaf.data}/tmp/kar@id=kar.repository@multi@snapshots, \
file:${karaf.base}/${karaf.default.repository}@id=child.system.repository@snapshots
${karaf.home.uri}${karaf.default.repository}@id=system.repository@snapshots, \
${karaf.data.uri}tmp/kar@id=kar.repository@multi@snapshots, \
${karaf.base.uri}${karaf.default.repository}@id=child.system.repository@snapshots

# Use the default local repo (e.g.~/.m2/repository) as a "remote" repo
#org.ops4j.pax.url.mvn.defaultLocalRepoAsRemote=false
#
# if "defaultLocalRepoAsRemote" is set to *any* value, localRepository will be
# added to the list of remote repositories being searched for artifacts
#
#org.ops4j.pax.url.mvn.defaultLocalRepoAsRemote = true

#
# Comma separated list of repositories scanned when resolving an artifact.
#
# Default repos:
#
# http://repo1.maven.org/maven2@id=central, \
# http://repository.springsource.com/maven/bundles/release@id=spring.ebr.release, \
# http://repository.springsource.com/maven/bundles/external@id=spring.ebr.external, \
# http://zodiac.springsource.com/maven/bundles/release@id=gemini, \
# http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases, \
# https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@noreleases, \
# https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases, \
# http://repository.springsource.com/maven/bundles/external@id=spring-ebr-repository@snapshots@noreleases, \
#
# list of repositories searched after resolution fails for "defaultRepositories"
# These are true remote repositories accessed using maven/aether/wagon
# mechanisms. If any repository contains required artifact, it is then written
# to "localRepository"
#
# if this list is _prepended_ with '+' sign, all repositories from active
# profiles defined in effective settings.xml file will be _appended_ to this
# list
# The default list includes the following repositories:
# http://repo1.maven.org/maven2@id=central
# http://repository.apache.org/content/groups/snapshots-group@id=apache@snapshots@noreleases
# https://oss.sonatype.org/content/repositories/snapshots@id=sonatype.snapshots.deploy@snapshots@noreleases
# https://oss.sonatype.org/content/repositories/ops4j-snapshots@id=ops4j.sonatype.snapshots.deploy@snapshots@noreleases
# A repository url can be appended with zero or more of the following flags:
# @snapshots : the repository contains snapshots
# @noreleases : the repository does not contain any released artifacts
# @id=repository.id : the id for the repository, just like in the settings.xml this is optional but recommended
# @id=repository.id : the id for the repository, just like in the
# settings.xml this is optional but recommended
#
# This contains the openhab, smart home and default repositories.
#
Expand Down
53 changes: 43 additions & 10 deletions distributions/openhab/src/main/resources/bin/karaf
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,25 @@
#

realpath() {
# Use in priority xpg4 awk or nawk on SunOS as standard awk is outdated
AWK=awk
if ${solaris}; then
if [ -x /usr/xpg4/bin/awk ]; then
AWK=/usr/xpg4/bin/awk
elif [ -x /usr/bin/nawk ]; then
AWK=/usr/bin/nawk
fi
fi

READLINK_EXISTS=$(command -v readlink &> /dev/null)
if [ -z $READLINK_EXISTS ]; then
if [ -z "$READLINK_EXISTS" ]; then
OURPWD=${PWD}
cd "$(dirname "${1}")" || exit 2
LINK=$(ls -l "$(basename "${1}")" | awk -F"-> " '{print $2}')
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
while [ "${LINK}" ]; do
echo "link: ${LINK}" >&2
cd "$(dirname "${LINK}")" || exit 2
LINK=$(ls -l "$(basename "${1}")" | awk -F"-> " '{print $2}')
LINK=$(ls -l "$(basename "${1}")" | ${AWK} -F"-> " '{print $2}')
done
REALPATH="${PWD}/$(basename "${1}")"
cd "${OURPWD}" || exit 2
Expand All @@ -48,6 +58,7 @@ realpath() {
REALNAME=$(realpath "$0")
DIRNAME=$(dirname "${REALNAME}")
PROGNAME=$(basename "${REALNAME}")
LOCAL_CLASSPATH=$CLASSPATH

#
# Load common functions
Expand Down Expand Up @@ -89,9 +100,14 @@ checkRootInstance() {
ROOT_INSTANCE_PID=$(sed -n -e '/item.0.pid/ s/.*\= *//p' "${KARAF_DATA}/tmp/instances/instance.properties")
ROOT_INSTANCE_NAME=$(sed -n -e '/item.0.name/ s/.*\= *//p' "${KARAF_DATA}/tmp/instances/instance.properties")
if [ "${ROOT_INSTANCE_PID}" -ne "0" ]; then
if ps p "${ROOT_INSTANCE_PID}" > /dev/null
if ps -p "${ROOT_INSTANCE_PID}" > /dev/null
then
ROOT_INSTANCE_RUNNING=true
MAIN=org.apache.karaf.main.Main
PID_COMMAND=$("${PS_PREFIX}"ps -p "${ROOT_INSTANCE_PID}" -o args | sed 1d)

if [ "${PID_COMMAND#*$MAIN}" != "$PID_COMMAND" ]; then
ROOT_INSTANCE_RUNNING=true
fi
fi
fi
fi
Expand Down Expand Up @@ -166,6 +182,7 @@ run() {
fi

debug=false
debugs=false
nodebug=false
while [ "${1}" != "" ]; do
case "${1}" in
Expand All @@ -177,6 +194,11 @@ run() {
debug=true
shift
;;
'debugs')
debug=true
debugs=true
shift
;;
'status')
MAIN=org.apache.karaf.main.Status
CHECK_ROOT_INSTANCE_RUNNING=false
Expand Down Expand Up @@ -228,7 +250,11 @@ run() {
fi
if ${debug}; then
if [ "x${JAVA_DEBUG_OPTS}" = "x" ]; then
JAVA_DEBUG_OPTS="${DEFAULT_JAVA_DEBUG_OPTS}"
if ${debugs}; then
JAVA_DEBUG_OPTS="${DEFAULT_JAVA_DEBUGS_OPTS}"
else
JAVA_DEBUG_OPTS="${DEFAULT_JAVA_DEBUG_OPTS}"
fi
fi
JAVA_OPTS="${JAVA_DEBUG_OPTS} ${JAVA_OPTS}"
fi
Expand All @@ -240,6 +266,10 @@ run() {
echo "Updating libs..."
rm -rf "${KARAF_HOME:?}/lib"
mv -f "${KARAF_HOME:?}/lib.next" "${KARAF_HOME}/lib"

echo "Updating classpath..."
CLASSPATH=$LOCAL_CLASSPATH
setupClassPath
fi

# Ensure the log directory exists
Expand All @@ -252,19 +282,22 @@ run() {
fi

if [ "${ROOT_INSTANCE_RUNNING}" = "false" ] || [ "${CHECK_ROOT_INSTANCE_RUNNING}" = "false" ] ; then
if [ "${VERSION}" -gt "80" ]; then
if [ "${VERSION}" -gt "8" ]; then
${KARAF_EXEC} "${JAVA}" ${JAVA_OPTS} \
--add-reads=java.xml=java.logging \
--patch-module java.base=lib/endorsed/org.apache.karaf.specs.locator-4.2.1.jar \
--patch-module java.xml=lib/endorsed/org.apache.karaf.specs.java.xml-4.2.1.jar \
--add-opens java.base/java.security=ALL-UNNAMED \
--add-opens java.base/java.net=ALL-UNNAMED \
--add-opens java.base/java.lang=ALL-UNNAMED \
--add-opens java.base/java.util=ALL-UNNAMED \
--add-opens java.naming/javax.naming.spi=ALL-UNNAMED \
--add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED \
--add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED \
--add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED \
--add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED \
--add-exports=java.xml.bind/com.sun.xml.internal.bind.v2.runtime=ALL-UNNAMED \
--add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED \
--add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED \
--add-modules java.xml.ws.annotation,java.corba,java.transaction,java.xml.bind,java.xml.ws \
-Dkaraf.instances="${KARAF_DATA}/tmp/instances" \
-Dkaraf.home="${KARAF_HOME}" \
-Dkaraf.base="${KARAF_BASE}" \
Expand Down Expand Up @@ -299,7 +332,7 @@ run() {
${MAIN} "$@"
fi
else
die "There is a Root instance already running with name ${ROOT_INSTANCE_NAME} and pid ${ROOT_INSTANCE_PID}"
die "There is a Root instance already running with name ${ROOT_INSTANCE_NAME} and pid ${ROOT_INSTANCE_PID}. If you know what you are doing and want to force the run anyway, export CHECK_ROOT_INSTANCE_RUNNING=false and re run the command."
fi

KARAF_RC=$?
Expand Down
Loading

0 comments on commit e101923

Please sign in to comment.