From cecf54f2feb409e87c9eb79786080c2ffd0a9dda Mon Sep 17 00:00:00 2001 From: Allen Houchins <32207388+allenhouchins@users.noreply.github.com> Date: Mon, 10 Nov 2025 15:49:52 -0600 Subject: [PATCH] Improve icon selection and resizing in generate-icons.sh (#35258) I ran into an app that only had a single 512 x 512 png icon resulting in the `generate-icons.sh` script failing. ``` % bash tools/software/icons/generate-icons.sh -a /Applications/logioptionsplus.app -s "logi-options+/darwin" Error: 128x128 icon not found. ``` This should add some additional flexibility. **Related issue:** Resolves # # Checklist for submitter If some of the following don't apply, delete the relevant line. - [ ] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. - [ ] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [ ] If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes ## Testing - [ ] Added/updated automated tests - [ ] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [ ] QA'd all new/changed functionality manually For unreleased bug fixes in a release candidate, one of: - [ ] Confirmed that the fix is not expected to adversely impact load test results - [ ] Alerted the release DRI if additional load testing is needed ## Database migrations - [ ] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [ ] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [ ] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). ## New Fleet configuration settings - [ ] Setting(s) is/are explicitly excluded from GitOps If you didn't check the box above, follow this checklist for GitOps-enabled settings: - [ ] Verified that the setting is exported via `fleetctl generate-gitops` - [ ] Verified the setting is documented in a separate PR to [the GitOps documentation](https://github.com/fleetdm/fleet/blob/main/docs/Configuration/yaml-files.md#L485) - [ ] Verified that the setting is cleared on the server if it is not supplied in a YAML file (or that it is documented as being optional) - [ ] Verified that any relevant UI is disabled when GitOps mode is enabled ## fleetd/orbit/Fleet Desktop - [ ] Verified compatibility with the latest released version of Fleet (see [Must rule](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/workflows/fleetd-development-and-release-strategy.md)) - [ ] If the change applies to only one platform, confirmed that `runtime.GOOS` is used as needed to isolate changes - [ ] Verified that fleetd runs on macOS, Linux and Windows - [ ] Verified auto-update works from the released version of component to the new version (see [tools/tuf/test](../tools/tuf/test/README.md)) --- tools/software/icons/generate-icons.sh | 42 ++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/tools/software/icons/generate-icons.sh b/tools/software/icons/generate-icons.sh index 24ad9dd8a3..31ea3c1a87 100755 --- a/tools/software/icons/generate-icons.sh +++ b/tools/software/icons/generate-icons.sh @@ -78,14 +78,50 @@ ICON_DIR="$TMP_DIR/icons.iconset" mkdir -p "$ICON_DIR" iconutil -c iconset "$ICNS_PATH" -o "$ICON_DIR" -# Find the 128x128 PNG -ICON_128=$(find "$ICON_DIR" -name "*128x128.png" | head -n 1) +# Debug: list all PNG files in iconset +echo "Available icon files in iconset:" +find "$ICON_DIR" -name "*.png" | sort || true + +# Find the 128x128 PNG (prefer exact 128x128, not @2x) +ICON_128=$(find "$ICON_DIR" -name "*128x128.png" ! -name "*@2x*" | head -n 1) if [[ -z "$ICON_128" ]]; then - echo "Error: 128x128 icon not found." + # Fallback: try 128x128@2x (which is 256x256) + ICON_128=$(find "$ICON_DIR" -name "*128x128@2x.png" | head -n 1) +fi +if [[ -z "$ICON_128" ]]; then + # Fallback: try any icon with 128 in the name + ICON_128=$(find "$ICON_DIR" -name "*128*.png" | head -n 1) +fi +if [[ -z "$ICON_128" ]]; then + # Last resort: find the largest PNG (prefer larger sizes) + ICON_128=$(find "$ICON_DIR" -name "*.png" | sort -V | tail -n 1) +fi + +if [[ -z "$ICON_128" ]]; then + echo "Error: No icon PNG files found in extracted iconset." + echo "ICON_DIR: $ICON_DIR" exit 1 fi + echo "Using icon for SVG and PNG: $ICON_128" +# Check dimensions and resize to 128x128 if larger +ICON_WIDTH=$(sips -g pixelWidth "$ICON_128" | grep pixelWidth | awk '{print $2}') +ICON_HEIGHT=$(sips -g pixelHeight "$ICON_128" | grep pixelHeight | awk '{print $2}') +echo "Icon dimensions: ${ICON_WIDTH}x${ICON_HEIGHT}" + +if [[ $ICON_WIDTH -gt 128 || $ICON_HEIGHT -gt 128 ]]; then + echo "Resizing icon from ${ICON_WIDTH}x${ICON_HEIGHT} to 128x128..." + RESIZED_ICON="$TMP_DIR/icon_128x128.png" + sips -z 128 128 "$ICON_128" --out "$RESIZED_ICON" > /dev/null 2>&1 + if [[ -f "$RESIZED_ICON" ]]; then + ICON_128="$RESIZED_ICON" + echo "Resized icon saved to: $ICON_128" + else + echo "Warning: Failed to resize icon, using original" + fi +fi + # Generate SVG from 128 PNG WIDTH=32 HEIGHT=32