Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ homepage = "https://hack.ink/rsnap"
license = "GPL-3.0"
readme = "README.md"
repository = "https://github.com/hack-ink/rsnap"
version = "0.2.5"
version = "0.2.6"

[workspace.dependencies]
arboard = { version = "3.6" }
Expand Down Expand Up @@ -54,9 +54,9 @@ wgpu = { version = "29.0" }
winit = { version = "0.30", features = ["rwh_06"] }
xcap = { version = "0.9" }

rsnap-capture-core = { version = "0.2.5", path = "packages/rsnap-capture-core" }
rsnap-host-ffi = { version = "0.2.5", path = "packages/rsnap-host-ffi" }
rsnap-overlay = { version = "0.2.5", path = "packages/rsnap-overlay" }
rsnap-capture-core = { version = "0.2.6", path = "packages/rsnap-capture-core" }
rsnap-host-ffi = { version = "0.2.6", path = "packages/rsnap-host-ffi" }
rsnap-overlay = { version = "0.2.6", path = "packages/rsnap-overlay" }

[profile.final-release]
inherits = "release"
Expand Down
6 changes: 6 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,12 @@ test -f "$APP_PATH/Contents/Resources/AppIcon.icns"
test -d "$APP_PATH/Contents/Frameworks/Sparkle.framework"
otool -L "$APP_PATH/Contents/MacOS/RsnapNativeHost" | grep -q '@rpath/Sparkle.framework'
otool -l "$APP_PATH/Contents/MacOS/RsnapNativeHost" | grep -q '@executable_path/../Frameworks'
if otool -l "$APP_PATH/Contents/MacOS/RsnapNativeHost" \
| awk '$1 == "cmd" && $2 == "LC_RPATH" { in_rpath = 1; next } in_rpath && $1 == "path" { sub(/^[[:space:]]*path /, ""); sub(/[[:space:]]+\(offset [0-9]+\)$/, ""); print; in_rpath = 0 }' \
| grep -E '^(/Applications/.*\.app/Contents/Developer/Toolchains/.*/usr/lib/swift[^/]*/macosx|/Library/Developer/CommandLineTools/usr/lib/swift[^/]*/macosx|/Users/.*/Applications/.*\.app/Contents/Developer/Toolchains/.*/usr/lib/swift[^/]*/macosx)$'; then
echo "RsnapNativeHost must not ship local Swift toolchain rpaths" >&2
exit 1
fi
plutil -extract CFBundleName raw "$APP_PATH/Contents/Info.plist" | grep -qx 'Rsnap'
plutil -extract CFBundleDisplayName raw "$APP_PATH/Contents/Info.plist" | grep -qx 'Rsnap'
plutil -extract CFBundleIdentifier raw "$APP_PATH/Contents/Info.plist" | grep -qx 'ink.hack.rsnap'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ final class NativeHostSoftwareUpdater {
isConfigured: true,
canCheckForUpdates: updater.canCheckForUpdates,
allowsAutomaticUpdates: updater.allowsAutomaticUpdates,
mode: Self.mode(
mode: SoftwareUpdateModeResolution.mode(
automaticallyChecksForUpdates: updater.automaticallyChecksForUpdates,
automaticallyDownloadsUpdates: updater.automaticallyDownloadsUpdates),
currentVersion: Self.currentAppVersionLabel,
Expand Down Expand Up @@ -158,19 +158,6 @@ final class NativeHostSoftwareUpdater {
&& nonEmptyInfoValue(forKey: "SUPublicEDKey") != nil
}

private static func mode(
automaticallyChecksForUpdates: Bool,
automaticallyDownloadsUpdates: Bool
) -> Mode {
if automaticallyDownloadsUpdates {
return .install
}
if automaticallyChecksForUpdates {
return .check
}
return .off
}

private static var currentAppVersionLabel: String {
nonEmptyInfoValue(forKey: "CFBundleShortVersionString") ?? "Development Build"
}
Expand Down Expand Up @@ -202,6 +189,32 @@ final class NativeHostSoftwareUpdater {
}
}

package enum SoftwareUpdateModeResolution {
fileprivate static func mode(
automaticallyChecksForUpdates: Bool,
automaticallyDownloadsUpdates: Bool
) -> NativeHostSoftwareUpdater.Mode {
guard automaticallyChecksForUpdates else {
return .off
}
if automaticallyDownloadsUpdates {
return .install
}
return .check
}

package static func modeRawValue(
automaticallyChecksForUpdates: Bool,
automaticallyDownloadsUpdates: Bool
) -> String {
mode(
automaticallyChecksForUpdates: automaticallyChecksForUpdates,
automaticallyDownloadsUpdates: automaticallyDownloadsUpdates
)
.rawValue
}
}

package enum SoftwareUpdateManualCheckAvailability {
package static func isEnabled(sparkleCanCheckForUpdates: Bool) -> Bool {
// Sparkle flips canCheckForUpdates off while a session is active, but Rsnap's
Expand Down
20 changes: 20 additions & 0 deletions native/macos-host/Sources/RsnapNativeHostKitProbe/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum RsnapNativeHostKitProbe {
assertCaptureFrameEffectExpandsExportCanvas()
assertScrollCaptureViewportPointAcceptsFlippedGlobalMouseCoordinates()
assertScrollCaptureObservedInputAcceptsSourceWindowGutter()
assertSoftwareUpdateModeResolution()
assertManualUpdateCheckRemainsAvailable()
let minimapExportSize = CGSize(width: 100, height: 200)
guard
Expand Down Expand Up @@ -68,6 +69,25 @@ enum RsnapNativeHostKitProbe {
assertLaunchAtLoginStateMapping()
}

private static func assertSoftwareUpdateModeResolution() {
guard
SoftwareUpdateModeResolution.modeRawValue(
automaticallyChecksForUpdates: false,
automaticallyDownloadsUpdates: false) == "off",
SoftwareUpdateModeResolution.modeRawValue(
automaticallyChecksForUpdates: false,
automaticallyDownloadsUpdates: true) == "off",
SoftwareUpdateModeResolution.modeRawValue(
automaticallyChecksForUpdates: true,
automaticallyDownloadsUpdates: false) == "check",
SoftwareUpdateModeResolution.modeRawValue(
automaticallyChecksForUpdates: true,
automaticallyDownloadsUpdates: true) == "install"
else {
fatalError("software update mode should treat disabled checks as off")
}
}

private static func assertManualUpdateCheckRemainsAvailable() {
guard
SoftwareUpdateManualCheckAvailability.isEnabled(sparkleCanCheckForUpdates: true),
Expand Down
40 changes: 40 additions & 0 deletions scripts/build_and_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,45 @@ stage_sparkle_framework() {
fi
}

staged_app_rpaths() {
otool -l "$APP_BINARY" | awk '
$1 == "cmd" && $2 == "LC_RPATH" {
in_rpath = 1
next
}
in_rpath && $1 == "path" {
sub(/^[[:space:]]*path /, "")
sub(/[[:space:]]+\(offset [0-9]+\)$/, "")
print
in_rpath = 0
}
'
}

is_local_toolchain_rpath() {
case "$1" in
/Applications/*.app/Contents/Developer/Toolchains/*/usr/lib/swift*/macosx | \
/Library/Developer/CommandLineTools/usr/lib/swift*/macosx | \
/Users/*/Applications/*.app/Contents/Developer/Toolchains/*/usr/lib/swift*/macosx)
return 0
;;
*)
return 1
;;
esac
}

sanitize_staged_app_rpaths() {
local rpath
while IFS= read -r rpath; do
[[ -n "$rpath" ]] || continue
if is_local_toolchain_rpath "$rpath"; then
install_name_tool -delete_rpath "$rpath" "$APP_BINARY"
STAGED_APP_DIRTY=1
fi
done < <(staged_app_rpaths)
}

write_if_changed() {
local destination="$1"
local contents="$2"
Expand Down Expand Up @@ -273,6 +312,7 @@ stage_app_bundle() {
install_name_tool -add_rpath '@executable_path/../Frameworks' "$APP_BINARY"
STAGED_APP_DIRTY=1
fi
sanitize_staged_app_rpaths

if [[ -f "$APP_ICON_SOURCE" ]]; then
if copy_if_changed "$APP_ICON_SOURCE" "$APP_RESOURCES/$APP_ICON_NAME"; then
Expand Down