11#! /usr/bin/env bash
2- # 2026053001
2+ # 2025021702
33
44# This script can run in a container (absolute paths) or in a Windows-VM.
55
66set -e -x
77
88if uname -a | grep -q " _NT" ; then
99 # We are on Windows.
10- IS_WINDOWS=' yes'
1110 REPO_DIR=" $LFMP_DIR_REPOS "
12- COMPILE_DIR=" $LFMP_DIR_COMPILED "
1311else
1412 # We are in a container.
15- IS_WINDOWS=' no'
1613 REPO_DIR=" /repos"
17- COMPILE_DIR=" /compiled"
1814fi
1915
20- if [ " $IS_WINDOWS " = ' no ' ] ; then
16+ if ! uname -a | grep -q " _NT " ; then
2117 # We are in a container.
2218 source /opt/venv/bin/activate
2319 PY_TAG=" py$( python3 -c ' import sys; print(f"{sys.version_info.major}{sys.version_info.minor}")' ) "
@@ -30,23 +26,10 @@ if [ "$IS_WINDOWS" = 'no' ]; then
3026fi
3127python3 --version
3228
33- SCRIPT_DIR=" $( dirname " $0 " ) "
34- COMPILE_ONE=" $SCRIPT_DIR /compile-one.sh"
35-
36- # Number of plugins to compile concurrently. Defaults to 4 (the GitHub Windows
37- # runner has 4 vCPUs). Override with LFMP_COMPILE_JOBS.
38- JOBS=" ${LFMP_COMPILE_JOBS:- 4} "
39-
40- # Capture the optional user-provided plugin list once. The per-group logic
41- # below mirrors the original behaviour: when a list is given it applies to
42- # check-plugins only; event-plugins and notification-plugins are skipped.
43- USER_PLUGIN_LIST=" $LFMP_COMPILE_PLUGINS "
44-
45- # Build a flat list of "<group> <plugin>" tasks to compile.
46- TASKS=()
29+ # Loop through each plugin in the list.
4730for PLUGINS in event-plugins notification-plugins check-plugins ; do
48- if [[ -n " $USER_PLUGIN_LIST " && " $PLUGINS " != " check-plugins" ]]; then
49- # if a check-plugin list is given, skip event-plugins and notification-plugins to save time
31+ if [[ ! -z " $LFMP_COMPILE_PLUGINS " && " $PLUGINS " != " check-plugins" ]]; then
32+ # if check-plugin list is given, skip event-plugins and notification-plugins to save time
5033 echo " ✅ Skipping $REPO_DIR /monitoring-plugins/$PLUGINS ..."
5134 continue
5235 fi
@@ -56,68 +39,30 @@ for PLUGINS in event-plugins notification-plugins check-plugins ; do
5639 fi
5740 echo " ✅ Processing $PLUGINS ..."
5841
59- if [[ -z " $USER_PLUGIN_LIST " ]]; then
42+ # If $LFMP_COMPILE_PLUGINS is empty, find all plugin directories under
43+ # $REPO_DIR/monitoring-plugins/$PLUGINS/ and create a space-separated list.
44+ if [[ -z " $LFMP_COMPILE_PLUGINS " ]]; then
6045 echo " ✅ No plugin list provided. Discovering all plugins..."
61- # List the directories immediately under $PLUGINS/ by basename.
62- # avoid using `find` as this is sometimes problematic in Github runners
63- GROUP_PLUGINS=$(
46+ # Find directories immediately under $PLUGINS/, extract their basenames, and join them with commas.
47+ LFMP_COMPILE_PLUGINS=$(
6448 for d in " $REPO_DIR /monitoring-plugins/$PLUGINS " /* ; do
6549 [ -d " $d " ] && basename " $d "
6650 done | sort
67- )
68- echo " ✅ Found '$GROUP_PLUGINS '"
69- else
70- GROUP_PLUGINS=" $USER_PLUGIN_LIST "
51+ ) # avoid using `find` as this is sometimes problematic in Github runners
52+ echo " ✅ Found '$LFMP_COMPILE_PLUGINS '"
7153 fi
7254
73- for PLUGIN in $GROUP_PLUGINS ; do
55+ for PLUGIN in $LFMP_COMPILE_PLUGINS ; do
7456 if [ " $PLUGIN " == " example" ]; then
7557 continue
7658 fi
77- if [[ ! -d " $REPO_DIR /monitoring-plugins/$PLUGINS /$PLUGIN " ]]; then
59+ if [[ -d " $REPO_DIR /monitoring-plugins/$PLUGINS /$PLUGIN " ]]; then
60+ bash $( dirname " $0 " ) /compile-one.sh $PLUGINS $PLUGIN
61+ else
7862 echo " ✅ Directory $REPO_DIR /$PLUGINS /$PLUGIN does not exist. Ignoring..."
79- continue
80- fi
81- # On Windows only plugins carrying a `.windows` marker get compiled
82- # (compile-one.sh enforces this too). Filter them out here so the
83- # parallel pool below is not filled with immediate no-op invocations.
84- if [[ " $IS_WINDOWS " = ' yes' && ! -f " $REPO_DIR /monitoring-plugins/$PLUGINS /$PLUGIN /.windows" ]]; then
85- echo " ✅ Ignoring '$PLUGIN ' on Windows (no .windows marker)"
86- continue
87- fi
88- TASKS+=(" $PLUGINS $PLUGIN " )
89- done
90- done
91-
92- # Compile. The first plugin runs alone to warm up Nuitka's download/cache dir
93- # (depends.exe, ccache, ...), so the parallel batch that follows does not race
94- # on first-time downloads. The rest run up to $JOBS at a time. xargs returns
95- # non-zero if any invocation fails, so `set -e` aborts the whole build.
96- if (( ${# TASKS[@]} > 0 )) ; then
97- echo " ✅ Compiling ${# TASKS[@]} plugin(s), up to $JOBS in parallel..."
98- read -r WARM_GROUP WARM_PLUGIN <<< " ${TASKS[0]}"
99- bash " $COMPILE_ONE " " $WARM_GROUP " " $WARM_PLUGIN "
100- if (( ${# TASKS[@]} > 1 )) ; then
101- printf ' %s\n' " ${TASKS[@]: 1} " | xargs -P " $JOBS " -L 1 bash " $COMPILE_ONE "
102- fi
103- fi
104-
105- # Merge each plugin's standalone `*.dist` directory into the shared, flattened
106- # group directory to save disk space (important on Github runners). Done here,
107- # serially, after all parallel compiles finished, so the shared runtime files
108- # the plugins all carry (python3xx.dll etc.) are never written concurrently.
109- # The special `/.` suffix copies only the *contents* of each dist directory.
110- for PLUGINS in event-plugins notification-plugins check-plugins ; do
111- GROUP_DIR=" $COMPILE_DIR /$PLUGINS "
112- [ -d " $GROUP_DIR " ] || continue
113- for DIST in " $GROUP_DIR " /* .dist ; do
114- [ -d " $DIST " ] || continue
115- if [ -n " $( ls --almost-all " $DIST " ) " ]; then
116- echo " ✅ cp --archive $DIST /. $GROUP_DIR /"
117- \c p --archive " $DIST " /. " $GROUP_DIR " /
11863 fi
119- rm -rf " $DIST "
12064 done
65+ LFMP_COMPILE_PLUGINS=" "
12166done
12267
12368# On RHEL? Then also compile the Linuxfabrik Type Enforcement Policy
0 commit comments