Skip to content

Add scripts for Mac Bundle#7987

Open
errodriguez wants to merge 4 commits intosleuthkit:developfrom
errodriguez:fix-arm64-missing-lib
Open

Add scripts for Mac Bundle#7987
errodriguez wants to merge 4 commits intosleuthkit:developfrom
errodriguez:fix-arm64-missing-lib

Conversation

@errodriguez
Copy link
Copy Markdown

@errodriguez errodriguez commented Nov 21, 2025

Summary by CodeRabbit

  • New Features
    • Added macOS application bundling capability to install the application as a native .app bundle in the Applications folder. The bundling process automatically configures Java 17 runtime settings, generates application icons, applies code signing, and removes quarantine attributes for a smooth user experience.

@bcarrier
Copy link
Copy Markdown
Member

bcarrier commented Apr 6, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 6, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

A new Bash script is introduced that builds a macOS application bundle at $HOME/Applications/Autopsy.app. The script creates directory structure, generates an Info.plist configuration file, writes a launcher script, copies application files, generates app icons, and performs code signing.

Changes

Cohort / File(s) Summary
macOS Bundle Build Script
macos-bundle.sh
New Bash script that orchestrates macOS .app bundle creation, including Contents directory structure setup, Info.plist metadata configuration, executable launcher script generation with Java runtime resolution, application file synchronization via rsync, PNG-to-ICNS icon conversion using sips and iconutil, and code signing with quarantine attribute removal.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A bundle we build with care and delight,
Apps wrapped in macOS, coded just right,
From icons to signing, each piece in its place,
No quarantine troubles within this safe space! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Add scripts for Mac Bundle' is vague and generic. It uses non-descriptive language ('scripts', 'Mac Bundle') without conveying what the actual change accomplishes or which script is being added. Revise the title to be more specific and descriptive, such as 'Add macos-bundle.sh for building macOS application bundle' to clearly convey the main purpose of the change.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@macos-bundle.sh`:
- Around line 74-77: The echo message has a typo ("Copyng") and the rsync source
uses invalid parameter expansion `${autopsy,bin,etc}` which should be a
brace-expanded list; update the echo to "Copying application..." and change the
rsync source to explicitly list the three directories (or use brace expansion)
so rsync copies "$SRC/autopsy" "$SRC/bin" "$SRC/etc" (or
"$SRC/{autopsy,bin,etc}") into "$APP/Contents/Resources/app/"; ensure variables
SRC and APP are used as in the original rsync command.
- Around line 1-2: Add strict mode to the top of macos-bundle.sh by enabling set
-euo pipefail and IFS handling, and update the icon generation block (the
section that references autopsy.png, sips and iconutil) to stop suppressing
stdout/stderr, validate that autopsy.png exists and that sips and iconutil are
available (use which/command -v checks), and abort with a clear error message if
any dependency or file is missing; ensure the icon generation commands
themselves return non-zero on failure so the script exits under strict mode.
- Around line 53-66: The copied etc/autopsy.conf contains a stale jdkhome="jre"
that will override the JAVA_HOME chosen by the launcher (JAVA_HOME logic and
exec "$APP_ROOT/bin/autopsy"); after the rsync/copy step in macos-bundle.sh but
before exec "$APP_ROOT/bin/autopsy", remove any existing jdkhome entries from
"$APP_ROOT/etc/autopsy.conf" (e.g. use sed -i or grep -v to delete lines
matching ^jdkhome=) so the launcher’s JAVA_HOME selection is not overridden;
ensure the removal targets the same file referenced by APP_ROOT and is done on
macOS-compatible sed/commands.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b41d9aff-2385-4f95-bd0a-f7fbf14df8c0

📥 Commits

Reviewing files that changed from the base of the PR and between 1775aa0 and 451fa4f.

⛔ Files ignored due to path filters (1)
  • autopsy.png is excluded by !**/*.png
📒 Files selected for processing (1)
  • macos-bundle.sh

Comment thread macos-bundle.sh
Comment on lines +1 to +2
#! /usr/bin/env bash

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n 'set -euo pipefail|sips|iconutil|> /dev/null 2>&1' macos-bundle.sh

Repository: sleuthkit/autopsy

Length of output: 874


🏁 Script executed:

head -50 macos-bundle.sh | cat -n

Repository: sleuthkit/autopsy

Length of output: 1664


🏁 Script executed:

sed -n '80,100p' macos-bundle.sh | cat -n

Repository: sleuthkit/autopsy

Length of output: 1106


Top-level script lacks strict mode, and the icon block suppresses all tool output.

The macos-bundle.sh script has no set -euo pipefail at the top level, allowing silent failures. The icon generation block (lines 83–98) silently suppresses all output with > /dev/null 2>&1 and has no checks for required dependencies (autopsy.png, sips, iconutil). A missing source file or unavailable tool will produce a broken bundle without any error indication.

Proposed fix
 #! /usr/bin/env bash
+set -euo pipefail
+

For lines 83–98:

 echo "Creating icon set..."
+[ -f "autopsy.png" ] || { echo "autopsy.png not found" >&2; exit 1; }
+command -v sips >/dev/null || { echo "sips is required" >&2; exit 1; }
+command -v iconutil >/dev/null || { echo "iconutil is required" >&2; exit 1; }
 mkdir -p tmp/autopsy.iconset
 ( 
 sips -z 16 16     autopsy.png --out tmp/autopsy.iconset/icon_16x16.png
@@ -94,7 +94,7 @@
 sips -z 512 512   autopsy.png --out tmp/autopsy.iconset/icon_512x512.png 
-) > /dev/null 2>&1
+)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#! /usr/bin/env bash
#! /usr/bin/env bash
set -euo pipefail
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@macos-bundle.sh` around lines 1 - 2, Add strict mode to the top of
macos-bundle.sh by enabling set -euo pipefail and IFS handling, and update the
icon generation block (the section that references autopsy.png, sips and
iconutil) to stop suppressing stdout/stderr, validate that autopsy.png exists
and that sips and iconutil are available (use which/command -v checks), and
abort with a clear error message if any dependency or file is missing; ensure
the icon generation commands themselves return non-zero on failure so the script
exits under strict mode.

Comment thread macos-bundle.sh
Comment on lines +53 to +66
# Prefer a JDK 17 if present; fall back to default
if [ -z "${JAVA_HOME:-}" ]; then
if /usr/libexec/java_home -v 17 >/dev/null 2>&1; then
export JAVA_HOME="$("/usr/libexec/java_home" -v 17)"
else
export JAVA_HOME="$("/usr/libexec/java_home" 2>/dev/null || true)"
fi
[ -n "${JAVA_HOME:-}" ] && export PATH="\$JAVA_HOME/bin:\$PATH"
fi

# Start from the app's root so relative paths work
cd "\$APP_ROOT"
exec "\$APP_ROOT/bin/autopsy"
EOT
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C3 'jdkhome|--jdkhome|JAVA_HOME' \
  macos-bundle.sh \
  netbeans-plat/15/harness/launchers/app.sh \
  unix_setup.sh

rg -n '^[[:space:]]*#?[[:space:]]*jdkhome=' etc/autopsy.conf || true

Repository: sleuthkit/autopsy

Length of output: 3799


🏁 Script executed:

cat -n macos-bundle.sh | sed -n '1,90p'

Repository: sleuthkit/autopsy

Length of output: 3120


🏁 Script executed:

# Check the full context of how jdkhome is handled in app.sh
cat -n netbeans-plat/15/harness/launchers/app.sh | sed -n '80,110p'

Repository: sleuthkit/autopsy

Length of output: 873


🏁 Script executed:

# Search for any nbexec or java launcher documentation
fd -type f \( -name "*.md" -o -name "*.txt" -o -name "README*" \) | head -20

Repository: sleuthkit/autopsy

Length of output: 231


🏁 Script executed:

# Check if there's a default autopsy.conf to see typical jdkhome entries
fd -type f -name "autopsy.conf*"

Repository: sleuthkit/autopsy

Length of output: 231


🏁 Script executed:

# Search for autopsy.conf files
find . -name "*autopsy.conf*" -type f 2>/dev/null | head -20

Repository: sleuthkit/autopsy

Length of output: 97


🏁 Script executed:

# Check what bin/autopsy actually is
cat -n bin/autopsy | head -30

Repository: sleuthkit/autopsy

Length of output: 104


🏁 Script executed:

# Search for any netbeans nbexec documentation or comments about --jdkhome
rg -A2 -B2 'jdkhome' netbeans-plat/15/harness/launchers/ --type sh

Repository: sleuthkit/autopsy

Length of output: 1386


🏁 Script executed:

# Check the default autopsy.conf
cat installer_autopsy/etc/autopsy.conf

Repository: sleuthkit/autopsy

Length of output: 3517


🏁 Script executed:

# Search for where bin/autopsy gets created - it's likely from netbeans-plat
find . -path "*/bin/*" -type f | grep -E "(autopsy|launcher)" | head -20

Repository: sleuthkit/autopsy

Length of output: 229


🏁 Script executed:

# Check if app.sh actually uses JAVA_HOME or only jdkhome
rg -n 'JAVA_HOME|jdkhome' netbeans-plat/15/harness/launchers/app.sh | head -20

Repository: sleuthkit/autopsy

Length of output: 328


🏁 Script executed:

# Verify the rsync command at lines 76-77
cat -n macos-bundle.sh | sed -n '73,80p'

Repository: sleuthkit/autopsy

Length of output: 312


🏁 Script executed:

# Check if there's a template or mechanism to customize jdkhome in macos-bundle.sh
rg -n 'jdkhome|autopsy.conf' macos-bundle.sh

Repository: sleuthkit/autopsy

Length of output: 43


Remove stale jdkhome from config after bundle assembly.

The launcher carefully selects JAVA_HOME (preferring JDK 17), but bin/autopsy (which is the netbeans app.sh launcher) reads jdkhome from etc/autopsy.conf and passes --jdkhome to nbexec, overriding the launcher's selection. The copied config file contains jdkhome="jre", which will override the JAVA_HOME set at lines 54-61.

This mirrors the pattern in unix_setup.sh (lines 55-57), which removes jdkhome before setting a new value (though the comment notes this only works on Linux). The same cleanup is needed here after rsync copies the stale config.

Proposed fix
 rsync -a --delete --exclude=".git" --exclude="target" \
   "$SRC/${autopsy,bin,etc}" "$APP/Contents/Resources/app/"
+
+# Prevent stale jdkhome from overriding launcher JAVA_HOME selection
+CONF="$APP/Contents/Resources/app/etc/autopsy.conf"
+if [ -f "$CONF" ]; then
+  awk '!/^[[:space:]]*jdkhome=/' "$CONF" > "$CONF.tmp"
+  mv "$CONF.tmp" "$CONF"
+fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@macos-bundle.sh` around lines 53 - 66, The copied etc/autopsy.conf contains a
stale jdkhome="jre" that will override the JAVA_HOME chosen by the launcher
(JAVA_HOME logic and exec "$APP_ROOT/bin/autopsy"); after the rsync/copy step in
macos-bundle.sh but before exec "$APP_ROOT/bin/autopsy", remove any existing
jdkhome entries from "$APP_ROOT/etc/autopsy.conf" (e.g. use sed -i or grep -v to
delete lines matching ^jdkhome=) so the launcher’s JAVA_HOME selection is not
overridden; ensure the removal targets the same file referenced by APP_ROOT and
is done on macOS-compatible sed/commands.

Comment thread macos-bundle.sh
Comment on lines +74 to +77
echo "Copyng application..."
SRC="$PWD" # Change if necessary
rsync -a --delete --exclude=".git" --exclude="target" \
"$SRC/${autopsy,bin,etc}" "$APP/Contents/Resources/app/"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n '\$\{autopsy,bin,etc\}' macos-bundle.sh

bash -lc 'unset autopsy; SRC=/tmp/src; printf "current=[%s]\n" "$SRC/${autopsy,bin,etc}"'
bash -lc 'SRC=/tmp/src; printf "expected=[%s]\n" "$SRC"/{autopsy,bin,etc}'

Repository: sleuthkit/autopsy

Length of output: 433


Fix invalid Bash expansion in the rsync source list and typo on line 74.

Line 77 uses ${autopsy,bin,etc} (parameter expansion), not brace expansion. When the autopsy variable is unset, this resolves to an empty value, causing rsync to sync only $SRC/ instead of the three required directories. Additionally, line 74 contains a typo: "Copyng" should be "Copying".

Proposed fix
-echo "Copyng application..."
+echo "Copying application..."
 SRC="$PWD"  # Change if necessary
-rsync -a --delete   --exclude=".git"  --exclude="target" \
-  "$SRC/${autopsy,bin,etc}" "$APP/Contents/Resources/app/"
+for d in autopsy bin etc; do
+  [ -d "$SRC/$d" ] || { echo "Missing required directory: $SRC/$d" >&2; exit 1; }
+done
+rsync -a --delete --exclude=".git" --exclude="target" \
+  "$SRC/autopsy/" "$SRC/bin/" "$SRC/etc/" "$APP/Contents/Resources/app/"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
echo "Copyng application..."
SRC="$PWD" # Change if necessary
rsync -a --delete --exclude=".git" --exclude="target" \
"$SRC/${autopsy,bin,etc}" "$APP/Contents/Resources/app/"
echo "Copying application..."
SRC="$PWD" # Change if necessary
for d in autopsy bin etc; do
[ -d "$SRC/$d" ] || { echo "Missing required directory: $SRC/$d" >&2; exit 1; }
done
rsync -a --delete --exclude=".git" --exclude="target" \
"$SRC/autopsy/" "$SRC/bin/" "$SRC/etc/" "$APP/Contents/Resources/app/"
🧰 Tools
🪛 Shellcheck (0.11.0)

[warning] 77-77: autopsy is referenced but not assigned.

(SC2154)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@macos-bundle.sh` around lines 74 - 77, The echo message has a typo ("Copyng")
and the rsync source uses invalid parameter expansion `${autopsy,bin,etc}` which
should be a brace-expanded list; update the echo to "Copying application..." and
change the rsync source to explicitly list the three directories (or use brace
expansion) so rsync copies "$SRC/autopsy" "$SRC/bin" "$SRC/etc" (or
"$SRC/{autopsy,bin,etc}") into "$APP/Contents/Resources/app/"; ensure variables
SRC and APP are used as in the original rsync command.

@bcarrier
Copy link
Copy Markdown
Member

bcarrier commented Apr 6, 2026

Notes on this:

  • We should move it into linux_macos_install_scripts/ and address the comments from CodeRabbit.
  • It can not be run from the current Windows build process and needs to happen on a Mac.

@bcarrier bcarrier changed the title Fix arm64 missing lib Add scripts for Mac Bundle Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants