1616
1717set -euo pipefail
1818
19- SCRIPT_DIR=" $( cd " $( dirname ${BASH_SOURCE[0]} ) " && pwd ) "
20- REPO_DIR=" $( cd $SCRIPT_DIR /../../../../ && pwd ) "
21-
22- IMAGE_NAME=" felfert/wix:latest"
23- WXS_PATH=" ./internal/buildscripts/packaging/msi/splunk-otel-collector.wxs"
24- OTELCOL=" ./bin/otelcol_windows_amd64.exe"
25- CONFIG=" ./cmd/otelcol/config/collector/agent_config.yaml"
26- FLUENTD_CONFIG=" ./internal/buildscripts/packaging/fpm/etc/otel/collector/fluentd/fluent.conf"
27- FLUENTD_CONFD=" ./internal/buildscripts/packaging/msi/fluentd/conf.d"
28- OUTPUT_DIR=" ./dist"
19+ WXS_PATH=" /project/internal/buildscripts/packaging/msi/splunk-otel-collector.wxs"
20+ OTELCOL=" /project/bin/otelcol_windows_amd64.exe"
21+ CONFIG=" /project/cmd/otelcol/config/collector/agent_config.yaml"
22+ FLUENTD_CONFIG=" /project/internal/buildscripts/packaging/fpm/etc/otel/collector/fluentd/fluent.conf"
23+ FLUENTD_CONFD=" /project/internal/buildscripts/packaging/msi/fluentd/conf.d"
24+ SPLUNK_ICON=" /project/internal/buildscripts/packaging/msi/splunk.ico"
25+ OUTPUT_DIR=" /project/dist"
2926
3027usage () {
3128 cat << EOH >&2
3229usage: ${BASH_SOURCE[0]} [OPTIONS] VERSION
3330
3431Description:
35- Build the MSI with the ' $IMAGE_NAME ' docker image .
32+ Build the Splunk OpenTelemetry MSI from the project available at /project .
3633 By default, the MSI is saved as '${OUTPUT_DIR} /splunk-otel-collector-VERSION-amd64.msi'.
3734
38- Required Arguments:
39- VERSION: The version for the MSI. The version should be in the form "N.N.N" or "N.N.N.N".
40-
4135OPTIONS:
42- --otelcol PATH: Relative path from the repo base directory to the otelcol exe.
43- Defaults to '$OTELCOL '.
44- --config PATH: Relative path from the repo base directory to the agent config.
45- Defaults to '$CONFIG '.
46- --fluentd PATH: Relative path from the repo base directory to the fluentd config.
47- Defaults to '$FLUENTD_CONFIG '.
48- --eventlog PATH: Relative path from the repo base directory to the eventlog config.
49- Defaults to '$EVENTLOG_CONFIG '.
50- --output DIR: Directory to save the MSI.
51- Defaults to '$OUTPUT_DIR '.
36+ --otelcol PATH: Absolute path to the otelcol exe.
37+ Defaults to '$OTELCOL '.
38+ --config PATH: Absolute path to the agent config.
39+ Defaults to '$CONFIG '.
40+ --fluentd PATH: Absolute path to the fluentd config.
41+ Defaults to '$FLUENTD_CONFIG '.
42+ --fluentd-confd PATH: Absolute path to the conf.d.
43+ Defaults to '$FLUENTD_CONFD '.
44+ --splunk-icon PATH: Absolute path to the splunk.ico.
45+ Defaults to '$SPLUNK_ICON '.
46+ --output DIR: Directory to save the MSI.
47+ Defaults to '$OUTPUT_DIR '.
5248
5349EOH
5450}
@@ -59,6 +55,7 @@ parse_args_and_build() {
5955 local fluentd_config=" $FLUENTD_CONFIG "
6056 local fluentd_confd=" $FLUENTD_CONFD "
6157 local output=" $OUTPUT_DIR "
58+ local splunk_icon=" $SPLUNK_ICON "
6259 local version=
6360
6461 while [ -n " ${1-} " ]; do
@@ -79,6 +76,10 @@ parse_args_and_build() {
7976 fluentd_confd=" $2 "
8077 shift 1
8178 ;;
79+ --splunk-icon)
80+ splunk_icon=" $2 "
81+ shift 1
82+ ;;
8283 --output)
8384 output=" $2 "
8485 shift 1
@@ -107,8 +108,8 @@ parse_args_and_build() {
107108 exit 1
108109 fi
109110
110- docker_run= " docker run --rm -v ${REPO_DIR} :/work -w /work $IMAGE_NAME "
111- build_dir=" ${output} /build"
111+ set -x
112+ build_dir=" /work /build"
112113 files_dir=" ${build_dir} /msi"
113114 msi_name=" splunk-otel-collector-${version} -amd64.msi"
114115
@@ -121,10 +122,27 @@ parse_args_and_build() {
121122 cp " $fluentd_config " " ${files_dir} /fluentd/td-agent.conf"
122123 cp " ${fluentd_confd} " /* .conf " ${files_dir} /fluentd/conf.d/"
123124
124- $docker_run heat dir " $files_dir " -srd -sreg -gg -template fragment -cg ConfigFiles -dr INSTALLDIR -out " ${build_dir} /configfiles.wsx"
125- $docker_run candle -arch x64 -out " ${build_dir} /configfiles.wixobj" " ${build_dir} /configfiles.wsx"
126- $docker_run candle -arch x64 -out " ${build_dir} /splunk-otel-collector.wixobj" -dVersion=" $version " -dOtelcol=" $otelcol " " $WXS_PATH "
127- $docker_run light -ext WixUtilExtension.dll -sval -out " ${output} /${msi_name} " -b " ${files_dir} " " ${build_dir} /splunk-otel-collector.wixobj" " ${build_dir} /configfiles.wixobj"
125+ # kludge to satisfy relative path in splunk-otel-collector.wxs
126+ mkdir -p /work/internal/buildscripts/packaging/msi
127+ cp " ${splunk_icon} " " /work/internal/buildscripts/packaging/msi/splunk.ico"
128+
129+ cd /work
130+ configFilesWsx=" ${build_dir} /configfiles.wsx"
131+ heat dir " $files_dir " -srd -sreg -gg -template fragment -cg ConfigFiles -dr INSTALLDIR -out " ${configFilesWsx// \/ / \\ } "
132+
133+ configFilesWixObj=" ${build_dir} /configfiles.wixobj"
134+ candle -arch x64 -out " ${configFilesWixObj// \/ / \\ } " " ${configFilesWsx// \/ / \\ } "
135+
136+ collectorWixObj=" ${build_dir} /splunk-otel-collector.wixobj"
137+ candle -arch x64 -out " ${collectorWixObj// \/ / \\ } " -dVersion=" $version " -dOtelcol=" $otelcol " " ${WXS_PATH// \/ / \\ } "
138+
139+ msi=" ${build_dir} /${msi_name} "
140+ light -ext WixUtilExtension.dll -sval -out " ${msi// \/ / \\ } " -b " ${files_dir// \/ / \\ } " " ${collectorWixObj// \/ / \\ } " " ${configFilesWixObj// \/ / \\ } "
141+
142+ mkdir -p $output
143+ cp " ${msi} " " ${output} /${msi_name} "
144+ { set +x; } 2> /dev/null
145+
128146 echo " MSI saved to ${output} /${msi_name} "
129147}
130148
0 commit comments