diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 08f82cdd..c7822790 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -56,6 +56,7 @@ run_tools_test: artifacts: when: always paths: + - debug.log - out/datamodel_default.xml - out/datamodel_hdm.xml - out/datamodel.xls diff --git a/gitlab-ci/install-dependencies-ms.sh b/gitlab-ci/install-dependencies-ms.sh index edcc89c2..cbfa455d 100755 --- a/gitlab-ci/install-dependencies-ms.sh +++ b/gitlab-ci/install-dependencies-ms.sh @@ -14,108 +14,129 @@ mkdir -p /etc/bbfdm/dmmap [ ! -d "${BBFDM_MS_DIR}" ] && mkdir -p "${BBFDM_MS_DIR}" # Clean up generated files -rm -rf ${BBFDM_MS_DIR}/* -rm -f ${BBFDM_MS_CONF}/* -rm -f ${BBFDM_DMMAP_DIR}/* +rm -rf "${BBFDM_MS_DIR:?}"/* +rm -f "${BBFDM_MS_CONF}"/* +rm -f "${BBFDM_DMMAP_DIR}"/* install_libeasy # compile and install Core Data Model as a micro-service -install_libbbf ${1} +install_libbbf "${1}" + +# Install datamodel plugins/micro-service only when pipeline trigger for bbfdm +if [ -z "${1}" ]; then + echo "Skip installation of micro-services ...." + exit 0 +fi if [ "$1" == "bbfdm" ]; then #compile and install libbbf_test dynamic extension library install_libbbf_test fi -# Install datamodel plugins/micro-service only when pipeline trigger for bbfdm -if [ -z "${1}" ]; then - echo "Skip installation of micro-services ...." -else - JSON_FILE=$BBFDM_TOOLS_INPUT_FILE - JSON_DESC_PATH="/tmp/desc_files" - plugin_count=$(jq '.plugins | length' "$JSON_FILE") +JSON_FILE=$BBFDM_TOOLS_INPUT_FILE +JSON_DESC_PATH="/tmp/desc_files" +plugin_count=$(jq '.plugins | length' "$JSON_FILE") - # Create desc_files directory - [ -d "${JSON_DESC_PATH}" ] && rm -f ${JSON_DESC_PATH} - mkdir -p ${JSON_DESC_PATH} +# Create desc_files directory +[ -d "${JSON_DESC_PATH}" ] && rm -f ${JSON_DESC_PATH} +mkdir -p ${JSON_DESC_PATH} - for i in $(seq 0 $((plugin_count - 1))); do - echo "==== Processing plugin [$i] ====" +ret=0 +for i in $(seq 0 $((plugin_count - 1))); do + echo "==== Processing plugin [$i] ====" - repo=$(jq -r ".plugins[$i].repo" "$JSON_FILE") - version=$(jq -r ".plugins[$i].version // empty" "$JSON_FILE") - if [ -z "${version}" ]; then - version=${BRANCH:-devel} - fi + repo=$(jq -r ".plugins[$i].repo" "$JSON_FILE") + version=$(jq -r ".plugins[$i].version // empty" "$JSON_FILE") + if [ -z "${version}" ]; then + version=${BRANCH:-devel} + fi - plugin_name=$(basename "$repo" .git) - dest="$BBFDM_PLUGIN_DEST/$plugin_name" + plugin_name=$(basename "$repo" .git) + dest="$BBFDM_PLUGIN_DEST/$plugin_name" - # Adjust repo URL based on ~/.netrc existence - NETRC_PATH="$HOME/.netrc" - if [ ! -f "$NETRC_PATH" ]; then - repo=${repo/https:\/\/dev.iopsys.eu\//git@dev.iopsys.eu:} - fi + # Adjust repo URL based on ~/.netrc existence + NETRC_PATH="$HOME/.netrc" + if [ ! -f "$NETRC_PATH" ]; then + repo=${repo/https:\/\/dev.iopsys.eu\//git@dev.iopsys.eu:} + fi - echo "Repo path: $repo" - echo "Plugin name: $plugin_name" - echo "Destination: $dest" - echo "Version: $version" + echo "Repo path: $repo" + echo "Plugin name: $plugin_name" + echo "Destination: $dest" + echo "Version: $version" - # Install dependencies - if [ "$plugin_name" == "ethmngr" ]; then - install_libethernet - install_libqos - fi + # Install dependencies + if [ "$plugin_name" == "ethmngr" ]; then + install_libethernet + install_libqos + fi - if [ "$plugin_name" == "parental-control" ]; then - install_cmph - fi + if [ "$plugin_name" == "parental-control" ]; then + install_cmph + fi - if [ -d "$dest" ]; then - echo "Directory $dest already exists, skipping clone." - else - echo "Cloning $repo into $dest, branch ${version} ..." - git clone -b "$version" "$repo" "$dest" || { echo "❌ Git clone failed"; exit -1; } - fi + if [ -d "$dest" ]; then + echo "Directory $dest already exists, checkout $version" + (cd "$dest" && git checkout . && git checkout "$version") + else + echo "Cloning $repo into $dest, branch ${version} ..." + exec_cmd git clone -b "$version" "$repo" "$dest" + fi - cd $dest + cd "$dest" || exit 5 - # Compilation - compile="$(jq -r ".plugins[$i].compile[]" "$JSON_FILE" 2>/dev/null)" - if [ -n "${compile}" ]; then - echo "Starting compilation..." - jq -r ".plugins[$i].compile[]" "$JSON_FILE" 2>/dev/null| while read -r cmd; do - echo "Executing: $cmd" - eval "$cmd" || { echo "❌ Compilation command failed"; exit -1; } - done - fi - - # Post-install - post_install="$(jq -r ".plugins[$i].post_install[]" "$JSON_FILE" 2>/dev/null)" - if [ -n "${post_install}" ]; then - echo "Running post-install steps..." - jq -r ".plugins[$i].post_install[]" "$JSON_FILE" 2>/dev/null| while read -r post_cmd; do - echo "Executing: $post_cmd" - eval "$post_cmd" || { echo "❌ Post-install command failed"; exit -1; } - done - fi - - # Save dm_info_file if defined - dm_info_file=$(jq -r ".plugins[$i].dm_info_file // empty" "$JSON_FILE") - if [ -n "$dm_info_file" ]; then - src_file="$dest/$dm_info_file" - out_file="/tmp/desc_files/${i}_${plugin_name}.json" - if [ -f "$src_file" ]; then - echo "Saving dm_info_file to $out_file" - cp -f "$src_file" "$out_file" - else - echo "❌ dm_info_file not found: $src_file" + # Compilation + compile="$(jq -r ".plugins[$i].compile[]" "$JSON_FILE" 2>/dev/null)" + if [ -n "${compile}" ]; then + echo "Starting compilation..." + while read -r cmd; do + echo "Executing: $cmd" + if ! eval "$cmd" > debug.log 2>&1; then + echo "❌ Compilation command [$cmd] failed" + ret=1 + break fi + done <<< ${compile} + [ $ret -eq 1 ] && break + fi + + # Post-install + post_install="$(jq -r ".plugins[$i].post_install[]" "$JSON_FILE" 2>/dev/null)" + if [ -n "${post_install}" ]; then + echo "Running post-install steps..." + while read -r post_cmd; do + echo "Executing: $post_cmd" + if ! eval "$post_cmd" > debug.log 2>&1; then + ret=1 + echo "❌ Post-install command [$post_cmd] failed" + break + fi + done <<< ${post_install} + [ $ret -eq "1" ] && break + fi + + # Save dm_info_file if defined + dm_info_file=$(jq -r ".plugins[$i].dm_info_file // empty" "$JSON_FILE") + if [ -n "$dm_info_file" ]; then + src_file="$dest/$dm_info_file" + out_file="/tmp/desc_files/${i}_${plugin_name}.json" + if [ -f "$src_file" ]; then + echo "Saving dm_info_file to $out_file" + cp -f "$src_file" "$out_file" + else + echo "❌ dm_info_file not found: $src_file" + ret=1 fi + fi - cd $(pwd) + cd .. || exit 7 + if [ ${ret} -eq 0 ]; then echo "✅ Plugin [$plugin_name] build complete." - done -fi + else + echo "❌ Plugin [$plugin_name] build failed" + break + fi +done + +exit $ret diff --git a/tools/tools_input.json b/tools/tools_input.json index 9ee91ec6..50bf689a 100644 --- a/tools/tools_input.json +++ b/tools/tools_input.json @@ -402,7 +402,8 @@ "export CFLAGS=\"-I/usr/include/libbbfdm-api -Wall\"", "cmake -DBBF_VENDOR_PREFIX:String=X_IOWRT_EU_ -DTR104_EXTENSION_DIR:String=iowrt -DRUNAS_BBFDM_MICROSERVICE:BOOL=ON", "cd libdm", - "make" + "make", + "cd -" ], "post_install": [ "cp -f libdm/tr104/libtr104.so /usr/share/bbfdm/micro_services/tr104.so", @@ -583,10 +584,10 @@ { "repo": "https://dev.iopsys.eu/feed/gnx.git", "proto": "git", - "dm_info_file": "package/gnx-files-ftth/bbf_plugin/link_forwarding.json", + "dm_info_file": "genexis-packages/link-state-forwarding/bbf_plugin/link_forwarding.json", "post_install": [ "mkdir -p /usr/share/bbfdm/micro_services/ethmngr", - "sed 's/{BBF_VENDOR_PREFIX}/X_GENEXIS_EU_/g' package/gnx-files-ftth/bbf_plugin/link_forwarding.json > /usr/share/bbfdm/micro_services/ethmngr/link_forwarding.json" + "sed 's/{BBF_VENDOR_PREFIX}/X_GENEXIS_EU_/g' genexis-packages/link-state-forwarding/bbf_plugin/link_forwarding.json > /usr/share/bbfdm/micro_services/ethmngr/link_forwarding.json" ] }, { @@ -597,7 +598,8 @@ "compile": [ "cd genexis-packages/gnx-ux-manager", "cmake src/bbf_plugin -DCMAKE_INSTALL_PREFIX=/", - "make" + "make", + "cd -" ], "post_install": [ "cp -f genexis-packages/gnx-ux-manager/libleddm.so /usr/share/bbfdm/micro_services/gnx-ux-manager.so", @@ -612,7 +614,8 @@ "dm_info_file": "genexis-packages/gnx-catv/datamodel/datamodel_description.json", "compile": [ "cd genexis-packages/gnx-catv", - "make -C datamodel CFLAGS+='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'" + "make -C datamodel CFLAGS+='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'", + "cd -" ], "post_install": [ "cp -f genexis-packages/gnx-catv/datamodel/libgnx-bbf-catv.so /usr/share/bbfdm/micro_services/gnx-catv.so", @@ -636,7 +639,8 @@ "dm_info_file": "genexis-packages/dhcp-on-boarding/src/datamodel_description.json", "compile": [ "cd genexis-packages/dhcp-on-boarding", - "make -C src CFLAGS+='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'" + "make -C src CFLAGS+='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'", + "cd -" ], "post_install": [ "cp -f genexis-packages/dhcp-on-boarding/src/lib_dhcp_onboarding.so /usr/share/bbfdm/micro_services/dhcp-on-boarding.so", @@ -651,7 +655,8 @@ "dm_info_file": "genexis-packages/gnx-loop-detector/datamodel/datamodel_description.json", "compile": [ "cd genexis-packages/gnx-loop-detector", - "make -C datamodel CFLAGS+='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'" + "make -C datamodel CFLAGS+='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'", + "cd -" ], "post_install": [ "cp -f genexis-packages/gnx-loop-detector/datamodel/libloopdetection.so /usr/share/bbfdm/micro_services/gnx-loop-detector.so", @@ -667,7 +672,8 @@ "compile": [ "cd genexis-packages/gnx-sfp", "cmake src/bbf_plugin -DCMAKE_INSTALL_PREFIX=/ -DCMAKE_C_FLAGS='-DBBF_VENDOR_PREFIX=\\\"X_GENEXIS_EU_\\\"'", - "make" + "make", + "cd -" ], "post_install": [ "cp -f genexis-packages/gnx-sfp/libopticaldm.so /usr/share/bbfdm/micro_services/gnx-sfp.so",