Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

The disk image opens on a window that shows where Peel goes

Țugui Dragoș915191c873b0
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index 168c4f92..7ff45da6 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -221,7 +221,9 @@ refuses it.
## Releases
-`Scripts/release.sh` builds a Release copy, signs it with a Developer ID, has Apple notarize it, staples the
-ticket, checks the result with Gatekeeper, and prints the path and SHA-256 of `Peel-<version>.dmg`, for people,
-and of `Peel-<version>.zip`, for Homebrew. The disk image is signed, notarized, and stapled too. It refuses a build
-in which any of the four programs can be debugged, or in which a language is missing.
+`Scripts/release.sh` builds a Release copy, signs it with a Developer ID, has Apple notarize it, staples the ticket,
+checks the result with Gatekeeper, and prints the path and SHA-256 of `Peel-<version>.dmg`, for people, and of
+`Peel-<version>.zip`, for Homebrew. The disk image is signed, notarized, and stapled too. It opens on a window of
+the album's paper with an arc from Peel to Applications, which `Scripts/make_dmg.sh` lays out with dmgbuild, run by
+uv, so nothing drives Finder; the background carries no words, since Finder writes the names in each Mac's language.
+It refuses a build in which any of the four programs can be debugged, or in which a language is missing.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 74f44b05..065ce730 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -94,8 +94,9 @@ xcodebuild test -project Peel.xcodeproj -scheme PeelUITests -derivedDataPath bui
- `Logo/`: the only source of the logo: the app icon (`Peel.icon`), the menu bar glyph, and `export.sh`, which
renders the PNGs the README shows.
- `Scripts/`: `sync_localizations.py`, which keeps the catalogs in step with the code, `generate_manual.py`,
- which keeps the manual page in step with `peel`, and `release.sh`, which builds, signs, notarizes, and checks a
- release.
+ which keeps the manual page in step with `peel`, `release.sh`, which builds, signs, notarizes, and checks a
+ release, and `make_dmg.sh`, which lays out the disk image's window with dmgbuild (run by uv) over the background
+ `dmg_background.swift` draws.
- `readme-assets/`: the screenshots the README shows.
- `.github/`: the test workflow, the issue forms, and the pull request template.
diff --git a/Scripts/dmg_background.swift b/Scripts/dmg_background.swift
new file mode 100644
index 00000000..d57f7f87
--- /dev/null
+++ b/Scripts/dmg_background.swift
@@ -0,0 +1,77 @@
+// Draws the background of Peel's disk image window at 1x and 2x: the album's paper, an arc of dots from Peel to
+// Applications, and a warm light where Peel is dropped. Finder draws the icons and their names on top.
+//
+// Usage: swift Scripts/dmg_background.swift <folder> <width> <height> <peel x> <applications x> <icons y>
+// Positions are the icons' centers in points from the window's top left corner, as Finder places them.
+import AppKit
+
+let arguments = Array(CommandLine.arguments.dropFirst())
+let numbers = arguments.dropFirst().compactMap(Double.init)
+guard arguments.count == 6, numbers.count == 5 else {
+ print("usage: swift dmg_background.swift <folder> <width> <height> <peel x> <applications x> <icons y>")
+ exit(64)
+}
+let folder = URL(filePath: arguments[0], directoryHint: .isDirectory)
+let width = CGFloat(numbers[0]), height = CGFloat(numbers[1])
+let peel = NSPoint(x: numbers[2], y: height - numbers[4]), applications = NSPoint(x: numbers[3], y: height - numbers[4])
+
+// The album's Sheet and PeelOrange, from the app's asset catalog.
+let paper = NSColor(srgbRed: 0.962, green: 0.952, blue: 0.930, alpha: 1)
+let orange = NSColor(srgbRed: 1, green: 0.55, blue: 0.13, alpha: 1)
+
+func point(_ a: NSPoint, _ c: NSPoint, _ b: NSPoint, _ t: CGFloat) -> NSPoint {
+ let u = 1 - t
+ return NSPoint(x: u * u * a.x + 2 * u * t * c.x + t * t * b.x, y: u * u * a.y + 2 * u * t * c.y + t * t * b.y)
+}
+
+func draw() {
+ let bounds = NSRect(x: 0, y: 0, width: width, height: height)
+ paper.setFill()
+ bounds.fill()
+ let middle = NSPoint(x: width / 2, y: height * 0.55)
+ NSGradient(colors: [NSColor.white.withAlphaComponent(0.55), NSColor.white.withAlphaComponent(0)])!
+ .draw(fromCenter: middle, radius: 0, toCenter: middle, radius: width * 0.62, options: [])
+ let edge = NSColor(srgbRed: 0.45, green: 0.35, blue: 0.2, alpha: 0.07)
+ NSGradient(colors: [edge.withAlphaComponent(0), edge])!
+ .draw(fromCenter: NSPoint(x: width / 2, y: height / 2), radius: width * 0.45,
+ toCenter: NSPoint(x: width / 2, y: height / 2), radius: width * 0.8, options: [])
+ NSGradient(colors: [orange.withAlphaComponent(0.16), orange.withAlphaComponent(0)])!
+ .draw(fromCenter: applications, radius: 0, toCenter: applications, radius: 118, options: [])
+
+ // The arc runs a little above the icons' centers, from beside one icon to beside the other.
+ let start = NSPoint(x: peel.x + 80, y: peel.y + 12), end = NSPoint(x: applications.x - 78, y: applications.y + 12)
+ let control = NSPoint(x: (start.x + end.x) / 2, y: start.y + 40)
+ let dots = 14
+ for index in 0..<dots {
+ let t = CGFloat(index) / CGFloat(dots) * 0.93
+ let center = point(start, control, end, t)
+ let radius = 2.2 + 1.6 * t
+ orange.withAlphaComponent(0.45 + 0.55 * t).setFill()
+ let dot = NSRect(x: center.x - radius, y: center.y - radius, width: 2 * radius, height: 2 * radius)
+ NSBezierPath(ovalIn: dot).fill()
+ }
+ let before = point(start, control, end, 0.97)
+ let angle = atan2(end.y - before.y, end.x - before.x), length: CGFloat = 15
+ let head = NSBezierPath()
+ head.move(to: NSPoint(x: end.x - length * cos(angle - 0.62), y: end.y - length * sin(angle - 0.62)))
+ head.line(to: end)
+ head.line(to: NSPoint(x: end.x - length * cos(angle + 0.62), y: end.y - length * sin(angle + 0.62)))
+ head.lineWidth = 4.5
+ head.lineCapStyle = .round
+ head.lineJoinStyle = .round
+ orange.setStroke()
+ head.stroke()
+}
+
+for (scale, name) in [(1, "background.png"), (2, "[email protected]")] {
+ let rep = NSBitmapImageRep(
+ bitmapDataPlanes: nil, pixelsWide: Int(width) * scale, pixelsHigh: Int(height) * scale, bitsPerSample: 8,
+ samplesPerPixel: 4, hasAlpha: true, isPlanar: false, colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0
+ )!
+ rep.size = NSSize(width: width, height: height)
+ NSGraphicsContext.saveGraphicsState()
+ NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: rep)
+ draw()
+ NSGraphicsContext.restoreGraphicsState()
+ try rep.representation(using: .png, properties: [:])!.write(to: folder.appending(path: name))
+}
diff --git a/Scripts/dmg_settings.py b/Scripts/dmg_settings.py
new file mode 100644
index 00000000..66256beb
--- /dev/null
+++ b/Scripts/dmg_settings.py
@@ -0,0 +1,22 @@
+# The settings dmgbuild reads for Peel's disk image. Scripts/make_dmg.sh passes every value with -D.
+import os.path
+
+app = defines["app"]
+width, height = int(defines["width"]), int(defines["height"])
+icons_y = int(defines["icons_y"])
+
+format = "ULFO"
+files = [app]
+symlinks = {"Applications": "/Applications"}
+icon = os.path.join(app, "Contents", "Resources", "Peel.icns")
+hide_extensions = [os.path.basename(app)]
+background = defines["background"]
+window_rect = ((200, 200), (width, height))
+default_view = "icon-view"
+show_icon_preview = False
+icon_size = 128
+text_size = 13
+icon_locations = {
+ os.path.basename(app): (int(defines["peel_x"]), icons_y),
+ "Applications": (int(defines["applications_x"]), icons_y),
+}
diff --git a/Scripts/make_dmg.sh b/Scripts/make_dmg.sh
new file mode 100755
index 00000000..49c3c4ba
--- /dev/null
+++ b/Scripts/make_dmg.sh
@@ -0,0 +1,27 @@
+#!/bin/zsh
+# Makes Peel's disk image: the app, a link to Applications, and a window that shows where to drag the app.
+# dmgbuild writes the window's layout without opening Finder, run by uv in an environment of its own.
+#
+# Usage: zsh Scripts/make_dmg.sh <Peel.app> <image.dmg>
+set -euo pipefail
+cd "$(dirname "$0")/.."
+
+[ $# -eq 2 ] || { echo "usage: zsh Scripts/make_dmg.sh <Peel.app> <image.dmg>"; exit 64; }
+app="$1"
+image="$2"
+command -v uvx > /dev/null || { echo "REFUSED: uv is not installed. Install it with: brew install uv"; exit 1; }
+
+# The window, and each icon's center in points from its top left corner. The background is drawn for these.
+width=640
+height=400
+peel_x=170
+applications_x=470
+icons_y=190
+
+background="$(dirname "$image")/disk-image-background"
+mkdir -p "$background"
+swift Scripts/dmg_background.swift "$background" $width $height $peel_x $applications_x $icons_y
+uvx --from dmgbuild==1.6.7 dmgbuild -s Scripts/dmg_settings.py \
+ -D app="$app" -D background="$background/background.png" \
+ -D width=$width -D height=$height -D peel_x=$peel_x -D applications_x=$applications_x -D icons_y=$icons_y \
+ Peel "$image"
diff --git a/Scripts/release.sh b/Scripts/release.sh
index bc74abaf..e66e4130 100755
--- a/Scripts/release.sh
+++ b/Scripts/release.sh
@@ -8,7 +8,8 @@
#
# Requires a Developer ID Application certificate in the keychain and a notary profile, stored once with
# xcrun notarytool store-credentials Peel --apple-id <you> --team-id 6R6J264YA2
-# which prompts for the app-specific password, so the password stays out of the shell history.
+# which prompts for the app-specific password, so the password stays out of the shell history, and uv
+# (`brew install uv`), which runs dmgbuild for the disk image's window.
#
# Usage: zsh Scripts/release.sh [notary-profile] (default profile: Peel)
set -euo pipefail
@@ -20,6 +21,11 @@ archive="$build/Peel.xcarchive"
export_directory="$build/export"
app="$export_directory/Peel.app"
+if ! command -v uvx > /dev/null; then
+ echo "REFUSED: uv is not installed, and the disk image needs it. Install it with: brew install uv"
+ exit 1
+fi
+
echo "== The tree"
if [ -n "$(git status --porcelain)" ]; then
git status --short
@@ -142,12 +148,8 @@ echo "== Disk image"
# Signed with the identity that signed the app, then notarized and stapled itself, so it opens without a warning.
identity="$(codesign -d --verbose=2 "$app" 2>&1 | sed -n 's/^Authority=\(Developer ID Application: .*\)$/\1/p' | head -1)"
[ -n "$identity" ] || { echo "REFUSED: the app's Developer ID identity could not be read"; exit 1; }
-staging="$build/disk-image"
-mkdir -p "$staging"
-ditto "$app" "$staging/Peel.app"
-ln -s /Applications "$staging/Applications"
image="$build/Peel-$version.dmg"
-hdiutil create -volname Peel -srcfolder "$staging" -format ULFO -ov "$image"
+zsh Scripts/make_dmg.sh "$app" "$image"
codesign --sign "$identity" --timestamp "$image"
xcrun notarytool submit "$image" --keychain-profile "$profile" --wait
xcrun stapler staple "$image"