From 8247b645e7593597fce67c1d13d51ab8bbff828d Mon Sep 17 00:00:00 2001 From: Dakota Paasman <122491662+dpaasman00@users.noreply.github.com> Date: Mon, 26 Aug 2024 08:23:03 -0400 Subject: [PATCH] feat: Windows installation and packaging (#1775) * wip * initial testing * add goreleaser logging * install tools * simplify manual msi build action * fix supervisor binary * polish * change back service name * remove goreleaser logs * update supervisor labels field * add supervisor_storage, rename cfg to supervisor.yaml, try removing supervisor storage on uninstall * cleanup logging and use -r flag when removing supervisor_storage * include supervisor_storage dir --- .github/workflows/manual_msi_build.yml | 24 +++---- .github/workflows/release.yml | 7 +- .gitignore | 1 - buildscripts/download-dependencies.sh | 3 +- windows/Makefile | 21 ------ windows/README.md | 12 ---- windows/Vagrantfile | 18 ----- windows/install/generate-manager-yaml.bat | 35 ---------- windows/install/generate-supervisor-yaml.bat | 71 ++++++++++++++++++++ windows/scripts/build-msi.sh | 28 -------- windows/scripts/fetch-dependencies.sh | 36 ---------- windows/scripts/test-install-msi.sh | 21 ------ windows/scripts/test-uninstall-msi.sh | 21 ------ windows/scripts/vagrant-prep.sh | 19 ------ windows/supervisor_storage/.include | 0 windows/templates/ConfigureManagementDlg.wxs | 2 +- windows/templates/SecretKeyRequiredDlg.wxs | 16 +++++ windows/templates/WixUI_HK.wxs | 6 +- windows/templates/product.wxs | 43 ++++++++---- windows/test/install.rb | 30 --------- windows/test/uninstall.rb | 5 -- windows/wix.json | 16 ++--- 22 files changed, 146 insertions(+), 289 deletions(-) delete mode 100644 windows/Vagrantfile delete mode 100644 windows/install/generate-manager-yaml.bat create mode 100644 windows/install/generate-supervisor-yaml.bat delete mode 100755 windows/scripts/build-msi.sh delete mode 100755 windows/scripts/fetch-dependencies.sh delete mode 100755 windows/scripts/test-install-msi.sh delete mode 100755 windows/scripts/test-uninstall-msi.sh delete mode 100755 windows/scripts/vagrant-prep.sh create mode 100644 windows/supervisor_storage/.include create mode 100644 windows/templates/SecretKeyRequiredDlg.wxs delete mode 100644 windows/test/install.rb delete mode 100644 windows/test/uninstall.rb diff --git a/.github/workflows/manual_msi_build.yml b/.github/workflows/manual_msi_build.yml index c3947e0b6..b7d58111a 100644 --- a/.github/workflows/manual_msi_build.yml +++ b/.github/workflows/manual_msi_build.yml @@ -18,26 +18,22 @@ jobs: with: go-version: "1.21" check-latest: true - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v5 - with: - # either 'goreleaser' (default) or 'goreleaser-pro' - distribution: goreleaser-pro - version: "v2.1.0" - args: build --single-target --skip=validate --clean --snapshot - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} + - name: Install tools + run: make install-tools + - name: Release Prep + run: make release-prep + - name: Build Binaries + run: make build-binaries - name: Copy Windows Collector Binary - run: cp dist/windows_amd64/collector_windows_amd64_v1/observiq-otel-collector.exe windows/observiq-otel-collector.exe + run: cp dist/collector_windows_amd64.exe windows/observiq-otel-collector.exe - name: Copy Windows Updater Binary - run: cp dist/windows_amd64/updater_windows_amd64_v1/updater.exe windows/updater.exe + run: cp dist/updater_windows_amd64.exe windows/updater.exe + - name: Copy Supervisor Binary + run: cp release_deps/supervisor_bin/opampsupervisor_windows_amd64.exe windows/opampsupervisor.exe - name: Copy Plugins to MSI Build Directory run: cp -r release_deps/plugins windows/ - name: Copy Example Config run: cp config/example.yaml windows/config.yaml - - name: Copy Logging Config - run: cp config/logging.yaml windows/logging.yaml - name: Copy JMX Receiver Jar run: cp release_deps/opentelemetry-java-contrib-jmx-metrics.jar windows/opentelemetry-java-contrib-jmx-metrics.jar - name: Copy LICENSE diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 873eab8e0..28070f66a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,18 +15,21 @@ jobs: with: go-version: "1.21" check-latest: true + # Needed until supervisor binary is released + - name: Build Supervisor Binary + run: make release-prep - name: Build Windows Binaries run: make build-binaries - name: Copy Windows Collector Binary run: cp dist/collector_windows_amd64.exe windows/observiq-otel-collector.exe - name: Copy Windows Updater Binary run: cp dist/updater_windows_amd64.exe windows/updater.exe + - name: Copy Supervisor Binary + run: cp release_deps/supervisor_bin/opampsupervisor_windows_amd64.exe windows/opampsupervisor.exe - name: Copy Plugins to MSI Build Directory run: cp -r release_deps/plugins windows/ - name: Copy Example Config run: cp config/example.yaml windows/config.yaml - - name: Copy Logging Config - run: cp config/logging.yaml windows/logging.yaml - name: Copy JMX Receiver Jar run: cp release_deps/opentelemetry-java-contrib-jmx-metrics.jar windows/opentelemetry-java-contrib-jmx-metrics.jar - name: Copy LICENSE diff --git a/.gitignore b/.gitignore index bb24bd752..eeccb1a55 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ windows/*.zip windows/**/wix.dynamic.json windows/**/wix windows/config.yaml -windows/logging.yaml windows/LICENSE windows/plugins opentelemetry-java-contrib-jmx-metrics.jar diff --git a/buildscripts/download-dependencies.sh b/buildscripts/download-dependencies.sh index 36c586473..aa74647e2 100755 --- a/buildscripts/download-dependencies.sh +++ b/buildscripts/download-dependencies.sh @@ -48,6 +48,7 @@ for PLATFORM in "${PLATFORMS[@]}"; do fi echo "Building supervisor for $GOOS/$GOARCH" GOOS="$GOOS" GOARCH="$GOARCH" go build main.go - cp main $PROJECT_BASE/$DOWNLOAD_DIR/supervisor_bin/opampsupervisor_${GOOS}_${GOARCH}${EXT} + cp main${EXT} $PROJECT_BASE/$DOWNLOAD_DIR/supervisor_bin/opampsupervisor_${GOOS}_${GOARCH}${EXT} + rm main${EXT} done $(cd $PROJECT_BASE/$DOWNLOAD_DIR && rm -rf opentelemetry-collector-contrib) diff --git a/windows/Makefile b/windows/Makefile index e04fafb79..7c4a5292f 100644 --- a/windows/Makefile +++ b/windows/Makefile @@ -1,24 +1,3 @@ -.PHONY: vagrant-prep -vagrant-prep: - ./scripts/vagrant-prep.sh - -.PHONY: fetch-dependencies -fetch-dependencies: - ./scripts/fetch-dependencies.sh - -.PHONY: build-msi -build-msi: fetch-dependencies - cd ..; $(MAKE) build-windows - ./scripts/build-msi.sh - -.PHONY: test-install-msi -test-install-msi: - ./scripts/test-install-msi.sh - -.PHONY: test-uninstall-msi -test-uninstall-msi: - ./scripts/test-uninstall-msi.sh - .PHONY: clean clean: rm -rf go-msi.exe config.yaml cinc-auditor.msi observiq-otel-collector.exe observiq-otel-collector.msi \ diff --git a/windows/README.md b/windows/README.md index f2b423d27..8fb60791d 100644 --- a/windows/README.md +++ b/windows/README.md @@ -1,15 +1,3 @@ # Windows MSI building This directory contains sources for building the Windows MSI using [go-msi](https://github.com/observIQ/go-msi/) and the [Wix toolset](https://wixtoolset.org/). - -## Building Locally with Vagrant - -A local build may be performed with [vagrant](https://www.vagrantup.com/). - -The following make targets are available for local development: -* `vagrant-prep`: Starts up the vagrant box and prepares it for building and testing. The vagrant box must be up in order for building or testing to work. **PLEASE NOTE** that valid Windows licensing is your responsibility. -* `fetch-dependencies`: Fetches dependencies for building the MSI. -* `build-msi`: Builds the MSI. Depends on the `fetch-dependencies` target (`fetch-dependencies` will be run every time this is run). -* `test-install-msi`: Test installing the MSI. `build-msi` should be run before this is run. **NOTE** This target is flaky, it seems like the installers just don't run sometimes, so you may need to run this a couple of times, or manually install the msi's (cinc + observiq-otel-collector). -* `test-uninstall-msi`: Test uninstalling the MSI. `build-msi` should be run before this is run, and the MSI should be installed (e.g. by running `test-install-msi`) -* `clean`: Cleans this directory of dependencies from `fetch-dependencies`, as well as of build artifacts. diff --git a/windows/Vagrantfile b/windows/Vagrantfile deleted file mode 100644 index 60d323d57..000000000 --- a/windows/Vagrantfile +++ /dev/null @@ -1,18 +0,0 @@ -Vagrant.configure("2") do |config| - config.vm.define :win2012 do |win| - win.vm.box = "devopsgroup-io/windows_server-2012r2-standard-amd64-nocm" - win.vm.boot_timeout = 500 - win.vm.communicator = :winrm - win.vm.provider "virtualbox" do |vb| - # first setup requires gui to be enabled so scripts can be executed in virtualbox guest screen - vb.gui = false - vb.gui = true - vb.customize ["modifyvm", :id, "--memory", "4096"] - vb.customize ["modifyvm", :id, "--vram", "128"] - vb.customize ["modifyvm", :id, "--cpus", "2"] - vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] - vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] - vb.customize ["guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000] - end - end -end diff --git a/windows/install/generate-manager-yaml.bat b/windows/install/generate-manager-yaml.bat deleted file mode 100644 index 5c80cb277..000000000 --- a/windows/install/generate-manager-yaml.bat +++ /dev/null @@ -1,35 +0,0 @@ -@echo off -setlocal - -set "install_dir=%~1" -set "endpoint=%~2" -set "secret_key=%~3" -set "labels=%~4" - -echo %install_dir% -echo %endpoint% -echo %secret_key% -echo %labels% - -if "%endpoint%"=="" ( - echo Endpoint not specified; Not writing output yaml - exit /b 0 -) - -set "managerfile=%install_dir%manager.yaml" - -echo Writing manager yaml -set "endpointField=endpoint: "%endpoint%"" -set "secretField=secret_key: "%secret_key%"" -set "labelsField=labels: "%labels%"" - -echo %endpointField% >"%managerfile%" -if not "%secret_key%"=="" ( - echo %secretField% >>"%managerfile%" -) -if not "%labels%"=="" ( - echo %labelsField% >>"%managerfile%" -) - - -endlocal diff --git a/windows/install/generate-supervisor-yaml.bat b/windows/install/generate-supervisor-yaml.bat new file mode 100644 index 000000000..e1d6e19aa --- /dev/null +++ b/windows/install/generate-supervisor-yaml.bat @@ -0,0 +1,71 @@ +@echo off +setlocal + +set "install_dir=%~1" +set "endpoint=%~2" +set "secret_key=%~3" +set "labels=%~4" + +echo %install_dir% +echo %endpoint% +echo %secret_key% +echo %labels% + +if "%endpoint%"=="" ( + echo Endpoint not specified; Not writing output yaml + exit /b 0 +) + +if "%secret_key%"=="" ( + echo Secret Key not specified; Not writing output yaml + exit /b 0 +) + +set "supervisorFile=%install_dir%supervisor.yaml" +set "agentBinary=%install_dir%observiq-otel-collector.exe" + +echo Writing manager yaml + +set "serverField=server:" +set "endpointField= endpoint: "%endpoint%"" +set "headersField= headers:" +set "authorizationField= Authorization: "Secret-Key %secret_key%"" +set "tlsField= tls:" +set "insecureField= insecure: true" +set "insecureSkipField= insecure_skip_verify: true" + +set "capabilitiesField=capabilities:" +set "acceptsRemoteCfgField= accepts_remote_config: true" +set "reportsRemoteCfgField= reports_remote_config: true" + +set "agentField=agent:" +set "executablePathField= executable: '%agentBinary%'" +set "descriptionField= description:" +set "nonIdentifyingAttributesField= non_identifying_attributes:" +set "serviceLabelsField= service.labels: "%labels%"" + +set "storageField=storage:" +set "directoryField= directory: '%install_dir%supervisor_storage'" + +echo %serverField% >"%supervisorFile%" +echo %endpointField% >>"%supervisorFile%" +echo %headersField% >>"%supervisorFile%" +echo %authorizationField% >>"%supervisorFile%" +echo %tlsField% >>"%supervisorFile%" +echo %insecureField% >>"%supervisorFile%" +echo %insecureSkipField% >>"%supervisorFile%" + +echo %capabilitiesField% >>"%supervisorFile%" +echo %acceptsRemoteCfgField% >>"%supervisorFile%" +echo %reportsRemoteCfgField% >>"%supervisorFile%" + +echo %agentField% >>"%supervisorFile%" +echo %executablePathField% >>"%supervisorFile%" +echo %descriptionField% >>"%supervisorFile%" +echo %nonIdentifyingAttributesField% >>"%supervisorFile%" +echo %serviceLabelsField% >>"%supervisorFile%" + +echo %storageField% >>"%supervisorFile%" +echo %directoryField% >>"%supervisorFile%" + +endlocal diff --git a/windows/scripts/build-msi.sh b/windows/scripts/build-msi.sh deleted file mode 100755 index a6d1c7fe1..000000000 --- a/windows/scripts/build-msi.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# Copyright observIQ, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e -BASEDIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" -PROJECT_BASE="$BASEDIR/../.." - -# Empty storage directory required by wix.json -mkdir -p storage -touch storage/.include - -cp "$PROJECT_BASE/dist/collector_windows_amd64.exe" "observiq-otel-collector.exe" -cp "$PROJECT_BASE/dist/updater_windows_amd64.exe" "updater.exe" - -vagrant winrm -c \ - "cd C:/vagrant; go-msi.exe make -m observiq-otel-collector.msi --version v0.0.1 --arch amd64" diff --git a/windows/scripts/fetch-dependencies.sh b/windows/scripts/fetch-dependencies.sh deleted file mode 100755 index 798520c63..000000000 --- a/windows/scripts/fetch-dependencies.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Copyright observIQ, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e -BASEDIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" -PROJECT_BASE="$BASEDIR/../.." - -[ -f go-msi.exe ] || curl -f -L -o go-msi.exe https://github.com/observIQ/go-msi/releases/download/v2.2.0/go-msi.exe -[ -f ./cinc-auditor.msi ] || curl -f -L -o cinc-auditor.msi http://downloads.cinc.sh/files/stable/cinc-auditor/4.17.7/windows/2012r2/cinc-auditor-4.17.7-1-x64.msi - -[ -f ./wix-binaries.zip ] || curl -f -L -o wix-binaries.zip https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip - -mkdir -p wix -[ -d wix/sdk ] || unzip -o wix-binaries.zip -d wix - -make -C "$PROJECT_BASE" release-prep - -cp -r "$PROJECT_BASE/release_deps/plugins" "$BASEDIR/.." -cp "$PROJECT_BASE/release_deps/opentelemetry-java-contrib-jmx-metrics.jar" "$BASEDIR/.." -cp "$PROJECT_BASE/release_deps/config.yaml" "$BASEDIR/.." -cp "$PROJECT_BASE/release_deps/VERSION.txt" "$BASEDIR/.." -cp "$PROJECT_BASE/release_deps/logging.yaml" "$BASEDIR/.." - -cp "$PROJECT_BASE/LICENSE" "$BASEDIR/.." diff --git a/windows/scripts/test-install-msi.sh b/windows/scripts/test-install-msi.sh deleted file mode 100755 index 7d18c119f..000000000 --- a/windows/scripts/test-install-msi.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# Copyright observIQ, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -vagrant winrm -c "cd C:/vagrant; msiexec.exe /i cinc-auditor.msi /passive" -vagrant winrm -c "cd C:/vagrant; msiexec.exe /i observiq-otel-collector.msi /passive" -sleep 10 -vagrant winrm -c "cinc-auditor exec C:\vagrant\test\install.rb" diff --git a/windows/scripts/test-uninstall-msi.sh b/windows/scripts/test-uninstall-msi.sh deleted file mode 100755 index 271f85bca..000000000 --- a/windows/scripts/test-uninstall-msi.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# Copyright observIQ, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -vagrant winrm -c "cd C:\vagrant; msiexec.exe /i cinc-auditor.msi /passive" -vagrant winrm -c "cd C:\vagrant; msiexec.exe /x observiq-otel-collector.msi /passive" -sleep 10 -vagrant winrm -c "cinc-auditor exec C:\vagrant\test\uninstall.rb" diff --git a/windows/scripts/vagrant-prep.sh b/windows/scripts/vagrant-prep.sh deleted file mode 100755 index dbd7304c1..000000000 --- a/windows/scripts/vagrant-prep.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# Copyright observIQ, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -e - -vagrant up --provider virtualbox -vagrant winrm -c "setx PATH \"%PATH%;C:/vagrant/wix\;C:/vagrant\"" diff --git a/windows/supervisor_storage/.include b/windows/supervisor_storage/.include new file mode 100644 index 000000000..e69de29bb diff --git a/windows/templates/ConfigureManagementDlg.wxs b/windows/templates/ConfigureManagementDlg.wxs index b70bb2a9f..403085631 100644 --- a/windows/templates/ConfigureManagementDlg.wxs +++ b/windows/templates/ConfigureManagementDlg.wxs @@ -24,7 +24,7 @@ -