Skip to content

Commit

Permalink
feat: Autogenerate config.ini before framework startup (#5351)
Browse files Browse the repository at this point in the history
* feat: Autogenerate config.ini before framework startup

Signed-off-by: Nicola Timeus <[email protected]>

* fixed typos

---------

Signed-off-by: Nicola Timeus <[email protected]>
  • Loading branch information
nicolatimeus authored Sep 20, 2024
1 parent 1dec568 commit 651dd03
Show file tree
Hide file tree
Showing 7 changed files with 1,390 additions and 1,344 deletions.
2,590 changes: 1,278 additions & 1,312 deletions kura/distrib/src/main/ant/build_equinox_distrib.xml

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions kura/distrib/src/main/resources/common/gen_config_ini.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/sh

TEMPLATE=$1
ROOT=$2

usage() {
>&2 echo "Usage: gen_config_ini.sh <config.ini template> <plugin root directory>"
}

abspath() {
cd "${1}" || exit 1
RESULT="${PWD}"
cd "${OLDPWD}" || exit 1
echo "${RESULT}"
}

if ! [ -e "${TEMPLATE}" ]
then
>&2 echo "config.ini template not found"
usage
exit 1
fi

if ! [ -d "${ROOT}" ]
then
>&2 echo "plugin root directory not found"
usage
exit 1
fi

ROOT=$(abspath "${ROOT}")

OSGI_BUNDLES=

for DIR_PATH in "${ROOT}"/*
do
DIR_NAME=$(basename -- "${DIR_PATH}")

if [ "${#DIR_NAME}" = 0 ] || [ "${#DIR_NAME}" -gt 2 ] || ! [ -d "${DIR_PATH}" ]
then
continue
fi

if ! expr "${DIR_NAME}" : '^[0-9]\{1,\}s\{0,1\}$' > /dev/null
then
continue
fi

START_LEVEL="${DIR_NAME%s}"

if [ "${#DIR_NAME}" = "${#START_LEVEL}" ]
then
START=
else
START="\:start"
fi

for JAR in "${DIR_PATH}"/*.jar
do
if [ -n "${OSGI_BUNDLES}" ]
then
OSGI_BUNDLES="${OSGI_BUNDLES},"
fi

OSGI_BUNDLES="${OSGI_BUNDLES}reference\:file\:${JAR}@${START_LEVEL}${START}"
done

done

cat "${TEMPLATE}"
echo
echo "osgi.bundles=${OSGI_BUNDLES}"
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
set -e

for i in $*; do
echo >> "${KURA_DIR}/framework/config.ini"
echo "$i" >> "${KURA_DIR}/framework/config.ini"
done
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [ $JAVA_VERSION_NUM -gt 001008 ] ; then
fi

mkdir -p /tmp/.kura/configuration
cp "${KURA_DIR}/framework/config.ini" /tmp/.kura/configuration/
"${KURA_DIR}/bin/gen_config_ini.sh" "${KURA_DIR}"/framework/config.ini "${KURA_DIR}"/plugins > /tmp/.kura/configuration/config.ini

JAVA_INT_OPTS="$JAVA_INT_OPTS -XX:+IgnoreUnrecognizedVMOptions"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
set -e

for i in $*; do
echo >> "${KURA_DIR}/framework/config.ini"
echo "$i" >> "${KURA_DIR}/framework/config.ini"
done
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if [ $JAVA_VERSION_NUM -gt 001008 ] ; then
fi

mkdir -p /tmp/.kura/configuration
cp "${KURA_DIR}/framework/config.ini" /tmp/.kura/configuration/
"${KURA_DIR}/bin/gen_config_ini.sh" "${KURA_DIR}"/framework/config.ini "${KURA_DIR}"/plugins > /tmp/.kura/configuration/config.ini

JAVA_INT_OPTS="$JAVA_INT_OPTS -XX:+IgnoreUnrecognizedVMOptions"

Expand Down
66 changes: 36 additions & 30 deletions target-platform/p2-repo-common/pom.xml

Large diffs are not rendered by default.

0 comments on commit 651dd03

Please sign in to comment.