diff --git a/.gitignore b/.gitignore index d64770ac3c..0059f2561c 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,7 @@ desktop.app.tar.gz osqueryd.app.tar.gz desktop.tar.gz nudge.app.tar.gz +swiftDialog.app.tar.gz # residual files when running the cpe command cmd/cpe/etagenv diff --git a/Makefile b/Makefile index bc636adf3e..df46760cfe 100644 --- a/Makefile +++ b/Makefile @@ -360,6 +360,24 @@ endif tar czf $(out-path)/nudge.app.tar.gz -C $(TMP_DIR)/nudge_pkg_payload_expanded/ Nudge.app rm -r $(TMP_DIR) +# Generate swiftDialog.app.tar.gz bundle from the swiftDialog repo. +# +# Usage: +# make swift-dialog-app-tar-gz version=2.1.0 build=4148 out-path=. +swift-dialog-app-tar-gz: +ifneq ($(shell uname), Darwin) + @echo "Makefile target swift-dialog-app-tar-gz is only supported on macOS" + @exit 1 +endif + $(eval TMP_DIR := $(shell mktemp -d)) + curl -L https://github.com/bartreardon/swiftDialog/releases/download/v$(version)/dialog-$(version)-$(build).pkg --output $(TMP_DIR)/swiftDialog-$(version).pkg + pkgutil --expand $(TMP_DIR)/swiftDialog-$(version).pkg $(TMP_DIR)/swiftDialog_pkg_expanded + mkdir -p $(TMP_DIR)/swiftDialog_pkg_payload_expanded + tar xvf $(TMP_DIR)/swiftDialog_pkg_expanded/Payload --directory $(TMP_DIR)/swiftDialog_pkg_payload_expanded + $(TMP_DIR)/swiftDialog_pkg_payload_expanded/usr/local/bin/dialog --version + tar czf $(out-path)/swiftDialog.app.tar.gz -C $(TMP_DIR)/swiftDialog_pkg_payload_expanded/usr/local bin + rm -rf $(TMP_DIR) + # Build and generate desktop.app.tar.gz bundle. # # Usage: diff --git a/orbit/pkg/update/notifications.go b/orbit/pkg/update/notifications.go index ce6a514ca9..9d15c76c05 100644 --- a/orbit/pkg/update/notifications.go +++ b/orbit/pkg/update/notifications.go @@ -44,6 +44,18 @@ func ApplyRenewEnrollmentProfileConfigFetcherMiddleware(fetcher OrbitConfigFetch // to renew the enrollment profile. func (h *RenewEnrollmentProfileConfigFetcher) GetConfig() (*fleet.OrbitConfig, error) { cfg, err := h.Fetcher.GetConfig() + + // TODO: download and use swiftDialog following the same patterns we + // use for Nudge. + // + // updaterHasTarget := h.UpdateRunner.HasRunnerOptTarget("swiftDialog") + // runnerHasLocalHash := h.UpdateRunner.HasLocalHash("swiftDialog") + // if !updaterHasTarget || !runnerHasLocalHash { + // log.Info().Msg("refreshing the update runner config with swiftDialog targets and hashes") + // log.Debug().Msgf("updater has target: %t, runner has local hash: %t", updaterHasTarget, runnerHasLocalHash) + // return cfg, h.setTargetsAndHashes() + // } + if err == nil && cfg.Notifications.RenewEnrollmentProfile { if h.cmdMu.TryLock() { defer h.cmdMu.Unlock() diff --git a/orbit/pkg/update/options.go b/orbit/pkg/update/options.go index f93fbb40bd..c02a33f31f 100644 --- a/orbit/pkg/update/options.go +++ b/orbit/pkg/update/options.go @@ -88,4 +88,11 @@ var ( TargetFile: "nudge.app.tar.gz", ExtractedExecSubPath: []string{"Nudge.app", "Contents", "MacOS", "Nudge"}, } + + SwiftDialogTarget = TargetInfo{ + Platform: "macos", + Channel: "stable", + TargetFile: "swiftDialog.app.tar.gz", + ExtractedExecSubPath: []string{"bin", "dialog"}, + } ) diff --git a/tools/tuf/test/create_repository.sh b/tools/tuf/test/create_repository.sh index 7fb1fe8667..e9ac7aab0e 100755 --- a/tools/tuf/test/create_repository.sh +++ b/tools/tuf/test/create_repository.sh @@ -25,6 +25,8 @@ fi SYSTEMS=${SYSTEMS:-macos linux windows} NUDGE_VERSION=stable +SWIFT_DIALOG_MACOS_APP_VERSION=2.1.0 +SWIFT_DIALOG_MACOS_APP_BUILD_VERSION=4148 if [[ -z "$OSQUERY_VERSION" ]]; then OSQUERY_VERSION=5.8.1 @@ -111,6 +113,20 @@ for system in $SYSTEMS; do rm nudge.app.tar.gz fi + # Add swiftDialog on macos (if enabled). + if [[ $system == "macos" && -n "$SWIFT_DIALOG" ]]; then + # For now we always make swiftDialog (until it's uploaded to our TUF repo) + make swift-dialog-app-tar-gz version=$SWIFT_DIALOG_MACOS_APP_VERSION build=$SWIFT_DIALOG_MACOS_APP_BUILD_VERSION out-path=. + + ./build/fleetctl updates add \ + --path $TUF_PATH \ + --target swiftDialog.app.tar.gz \ + --platform macos \ + --name swiftDialog \ + --version 42.0.0 -t 42.0 -t 42 -t stable + rm swiftDialog.app.tar.gz + fi + # Add Fleet Desktop application on windows (if enabled). if [[ $system == "windows" && -n "$FLEET_DESKTOP" ]]; then FLEET_DESKTOP_VERSION=42.0.0 \