diff --git a/Makefile b/Makefile index b4f7bd5684..5419c8c24a 100644 --- a/Makefile +++ b/Makefile @@ -686,20 +686,39 @@ restore: $(SNAPSHOT_BINARY) # To generate an osquery bundle for a unreleased change in osquery in a pull request # (e.g. https://github.com/osquery/osquery/pull/8815): # make osqueryd-app-tar-gz pr=8815 out-path=. +# +# To generate an osquery bundle from a locally built osqueryd executable: +# make osqueryd-app-tar-gz osqueryd_path=/path/to/osqueryd out-path=. osqueryd-app-tar-gz: ifneq ($(shell uname), Darwin) @echo "Makefile target osqueryd-app-tar-gz is only supported on macOS" @exit 1 endif -ifdef pr +ifdef osqueryd_path + $(eval TMP_DIR := $(shell mktemp -d)) + @if [ ! -f "$(osqueryd_path)" ]; then \ + echo "Error: osqueryd executable not found at $(osqueryd_path)"; \ + rm -rf $(TMP_DIR); \ + exit 1; \ + fi + mkdir -p $(TMP_DIR)/osquery.app/Contents/MacOS + mkdir -p $(TMP_DIR)/osquery.app/Contents/Resources + cp "$(osqueryd_path)" $(TMP_DIR)/osquery.app/Contents/MacOS/osqueryd + chmod +x $(TMP_DIR)/osquery.app/Contents/MacOS/osqueryd + @OSQUERY_VERSION=$$("$(osqueryd_path)" --version | awk '{print $$NF}') && \ + printf '\n\n\n\n\tCFBundleIdentifier\n\tio.osquery.agent\n\tCFBundleName\n\tosquery\n\tCFBundleExecutable\n\tosqueryd\n\tCFBundleVersion\n\t%s\n\tCFBundleShortVersionString\n\t%s\n\tCFBundleInfoDictionaryVersion\n\t6.0\n\tCFBundlePackageType\n\tAPPL\n\tCFBundleSignature\n\t????\n\tLSMinimumSystemVersion\n\t10.14\n\n\n' "$$OSQUERY_VERSION" "$$OSQUERY_VERSION" > $(TMP_DIR)/osquery.app/Contents/Info.plist + $(TMP_DIR)/osquery.app/Contents/MacOS/osqueryd --version + tar czf $(out-path)/osqueryd.app.tar.gz -C $(TMP_DIR) osquery.app + rm -rf $(TMP_DIR) +else ifdef pr $(eval TMP_DIR := $(shell mktemp -d)) @echo "Fetching macos_unsigned_tgz_universal artifact from osquery/osquery PR $(pr)..." @PR_SHA=$$(gh pr view -R osquery/osquery $(pr) --json headRefOid -q .headRefOid) && \ echo "PR head SHA: $$PR_SHA" && \ RUN_IDS=$$(gh api "repos/osquery/osquery/actions/runs?head_sha=$$PR_SHA" \ - -q '[.workflow_runs[] | select(.conclusion == "success") | .id] | .[]') && \ + -q '[.workflow_runs[] | .id] | .[]') && \ if [ -z "$$RUN_IDS" ]; then \ - echo "Error: no successful workflow runs found for PR $(pr)"; \ + echo "Error: no workflow runs found for PR $(pr)"; \ rm -rf $(TMP_DIR); \ exit 1; \ fi && \ diff --git a/tools/tuf/test/README.md b/tools/tuf/test/README.md index 6e906379ce..ff214d486b 100644 --- a/tools/tuf/test/README.md +++ b/tools/tuf/test/README.md @@ -154,6 +154,15 @@ make osqueryd-app-tar-gz pr=8815 out-path=. ./tools/tuf/test/push_target.sh macos-app osqueryd osqueryd.app.tar.gz 5.23.0 ``` +E.g. to add a custom `osqueryd` version built locally: +```sh +# Generate osqueryd app bundle from a locally built osqueryd executable. +make osqueryd-app-tar-gz osqueryd_path=/path/to/osqueryd out-path=. + +# Push the osqueryd target as a new version. +./tools/tuf/test/push_target.sh macos-app osqueryd osqueryd.app.tar.gz 5.23.0 +``` + E.g. to add a new version of `desktop` for macOS: ```sh source ./tools/tuf/test/load_orbit_version_vars.sh