From 762527ece9e35319d6da3bef6c6e7a0b411dbafe Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Sun, 5 Feb 2023 18:11:47 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20Add=20quotes=20around=20paths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PHP Monitor.xcodeproj/project.pbxproj | 40 ++++++++----------- phpmon-updater/ReleaseManifest.swift | 14 ------- phpmon-updater/Updater.swift | 22 +++++----- phpmon-updater/{Alert.swift => Utility.swift} | 7 +++- phpmon-updater/main.swift | 2 +- 5 files changed, 35 insertions(+), 50 deletions(-) delete mode 100644 phpmon-updater/ReleaseManifest.swift rename phpmon-updater/{Alert.swift => Utility.swift} (88%) diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index d12de6e..b09885e 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -202,9 +202,6 @@ C469E700294CF7B200A82AB2 /* FakeValetProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C469E6FD294CF7B200A82AB2 /* FakeValetProxy.swift */; }; C469E701294CF7B200A82AB2 /* FakeValetProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C469E6FD294CF7B200A82AB2 /* FakeValetProxy.swift */; }; C469E706294CFDF700A82AB2 /* DomainsListTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C469E702294CFDF700A82AB2 /* DomainsListTest.swift */; }; - C46B2648298B324100084651 /* ReleaseManifest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46B2647298B324100084651 /* ReleaseManifest.swift */; }; - C46B2649298B324100084651 /* ReleaseManifest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46B2647298B324100084651 /* ReleaseManifest.swift */; }; - C46B2650298B3C2100084651 /* PHP Monitor Self-Updater.app in Resources */ = {isa = PBXBuildFile; fileRef = C46B264F298B3C2100084651 /* PHP Monitor Self-Updater.app */; }; C46E20702829D27F00D909D6 /* AppUpdaterCheckTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46E206F2829D27F00D909D6 /* AppUpdaterCheckTest.swift */; }; C46EBC4428DB95F0007ACC74 /* ShellProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46EBC4328DB95F0007ACC74 /* ShellProtocol.swift */; }; C46EBC4528DB95F0007ACC74 /* ShellProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C46EBC4328DB95F0007ACC74 /* ShellProtocol.swift */; }; @@ -530,6 +527,7 @@ C48D6C70279CD2AC00F26D7E /* VersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */; }; C48D6C71279CD2AC00F26D7E /* VersionNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */; }; C48D6C75279CD3E400F26D7E /* PhpVersionNumberTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48D6C73279CD3E400F26D7E /* PhpVersionNumberTest.swift */; }; + C491997029901AF6001F3A21 /* PHP Monitor Self-Updater.app in Resources */ = {isa = PBXBuildFile; fileRef = C491996F29901AF5001F3A21 /* PHP Monitor Self-Updater.app */; }; C4927F0B27B2DFC200C55AFD /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4927F0A27B2DFC200C55AFD /* Errors.swift */; }; C4927F0C27B2DFC200C55AFD /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4927F0A27B2DFC200C55AFD /* Errors.swift */; }; C493084A279F331F009C240B /* AddSiteVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4930849279F331F009C240B /* AddSiteVC.swift */; }; @@ -588,7 +586,7 @@ C4C3ED412783497000AB15D8 /* MainMenu+Startup.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C3ED402783497000AB15D8 /* MainMenu+Startup.swift */; }; C4C3ED4327834C5200AB15D8 /* CustomPrefs.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C3ED4227834C5200AB15D8 /* CustomPrefs.swift */; }; C4C75F5A298C2D5700DFD82E /* LaunchControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C75F59298C2D5700DFD82E /* LaunchControl.swift */; }; - C4C75F5C298C31C000DFD82E /* Alert.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C75F5B298C31C000DFD82E /* Alert.swift */; }; + C4C75F5C298C31C000DFD82E /* Utility.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C75F5B298C31C000DFD82E /* Utility.swift */; }; C4C8900328F0E28800CE5E97 /* FileSystemProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C8900228F0E28800CE5E97 /* FileSystemProtocol.swift */; }; C4C8900528F0E3D100CE5E97 /* RealFileSystem.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C8900428F0E3D100CE5E97 /* RealFileSystem.swift */; }; C4C8900728F0E3EF00CE5E97 /* ActiveFileSystem.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4C8900628F0E3EF00CE5E97 /* ActiveFileSystem.swift */; }; @@ -864,8 +862,6 @@ C464ADB1275A87CA003FCD53 /* DomainListCellProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainListCellProtocol.swift; sourceTree = ""; }; C469E6FD294CF7B200A82AB2 /* FakeValetProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FakeValetProxy.swift; sourceTree = ""; }; C469E702294CFDF700A82AB2 /* DomainsListTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DomainsListTest.swift; sourceTree = ""; }; - C46B2647298B324100084651 /* ReleaseManifest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReleaseManifest.swift; sourceTree = ""; }; - C46B264F298B3C2100084651 /* PHP Monitor Self-Updater.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; path = "PHP Monitor Self-Updater.app"; sourceTree = ""; }; C46E206F2829D27F00D909D6 /* AppUpdaterCheckTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppUpdaterCheckTest.swift; sourceTree = ""; }; C46EBC4328DB95F0007ACC74 /* ShellProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShellProtocol.swift; sourceTree = ""; }; C46EBC4628DB9644007ACC74 /* RealShell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RealShell.swift; sourceTree = ""; }; @@ -890,6 +886,7 @@ C48D0C9225CC804200CC7490 /* XibLoadable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = XibLoadable.swift; sourceTree = ""; }; C48D6C6F279CD2AC00F26D7E /* VersionNumber.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionNumber.swift; sourceTree = ""; }; C48D6C73279CD3E400F26D7E /* PhpVersionNumberTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhpVersionNumberTest.swift; sourceTree = ""; }; + C491996F29901AF5001F3A21 /* PHP Monitor Self-Updater.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; path = "PHP Monitor Self-Updater.app"; sourceTree = ""; }; C4927F0A27B2DFC200C55AFD /* Errors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = ""; }; C4930849279F331F009C240B /* AddSiteVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddSiteVC.swift; sourceTree = ""; }; C495F5AE28A42E080087F70A /* EnvironmentCheck.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnvironmentCheck.swift; sourceTree = ""; }; @@ -922,7 +919,7 @@ C4C3ED402783497000AB15D8 /* MainMenu+Startup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MainMenu+Startup.swift"; sourceTree = ""; }; C4C3ED4227834C5200AB15D8 /* CustomPrefs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomPrefs.swift; sourceTree = ""; }; C4C75F59298C2D5700DFD82E /* LaunchControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchControl.swift; sourceTree = ""; }; - C4C75F5B298C31C000DFD82E /* Alert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Alert.swift; sourceTree = ""; }; + C4C75F5B298C31C000DFD82E /* Utility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utility.swift; sourceTree = ""; }; C4C8900228F0E28800CE5E97 /* FileSystemProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileSystemProtocol.swift; sourceTree = ""; }; C4C8900428F0E3D100CE5E97 /* RealFileSystem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RealFileSystem.swift; sourceTree = ""; }; C4C8900628F0E3EF00CE5E97 /* ActiveFileSystem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActiveFileSystem.swift; sourceTree = ""; }; @@ -1121,13 +1118,12 @@ isa = PBXGroup; children = ( C406A5F2298AD2CE00B5B85A /* main.swift */, - C4C75F5B298C31C000DFD82E /* Alert.swift */, - C4C75F59298C2D5700DFD82E /* LaunchControl.swift */, - C46B2647298B324100084651 /* ReleaseManifest.swift */, C406A601298AD50D00B5B85A /* Updater.swift */, + C4C75F5B298C31C000DFD82E /* Utility.swift */, + C4C75F59298C2D5700DFD82E /* LaunchControl.swift */, C406A5F6298AD2CF00B5B85A /* Assets.xcassets */, C406A5FB298AD2CF00B5B85A /* phpmon-updater.entitlements */, - C46B264F298B3C2100084651 /* PHP Monitor Self-Updater.app */, + C491996F29901AF5001F3A21 /* PHP Monitor Self-Updater.app */, ); path = "phpmon-updater"; sourceTree = ""; @@ -1994,7 +1990,7 @@ C41C1B3B22B0098000E7CF16 /* Assets.xcassets in Resources */, C41C1B3E22B0098000E7CF16 /* Main.storyboard in Resources */, C405A4D124B9B9140062FAFA /* InternetAccessPolicy.plist in Resources */, - C46B2650298B3C2100084651 /* PHP Monitor Self-Updater.app in Resources */, + C491997029901AF6001F3A21 /* PHP Monitor Self-Updater.app in Resources */, C44C1991276E44CB0072762D /* ProgressWindow.storyboard in Resources */, C4232EE52612526500158FC6 /* Credits.html in Resources */, 54FCFD26276C883F004CE748 /* SelectPreferenceView.xib in Resources */, @@ -2087,10 +2083,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - C4C75F5C298C31C000DFD82E /* Alert.swift in Sources */, + C4C75F5C298C31C000DFD82E /* Utility.swift in Sources */, C406A602298AD50D00B5B85A /* Updater.swift in Sources */, C4C75F5A298C2D5700DFD82E /* LaunchControl.swift in Sources */, - C46B2649298B324100084651 /* ReleaseManifest.swift in Sources */, C41F3D08298AED0D0042ACBF /* System.swift in Sources */, C406A5F3298AD2CE00B5B85A /* main.swift in Sources */, ); @@ -2236,7 +2231,6 @@ C4D9ADC8277611A0007277F4 /* InternalSwitcher.swift in Sources */, C4FACE83288F1F9700FC478F /* OnboardingWindowController.swift in Sources */, C4080FFA27BD956700BF2C6B /* BetterAlertVC.swift in Sources */, - C46B2648298B324100084651 /* ReleaseManifest.swift in Sources */, C4BF56AB2949381100379603 /* FakeValetInteractor.swift in Sources */, C4B5635E276AB09000F12CCB /* VersionExtractor.swift in Sources */, C451AFF62969E40F0078E617 /* HelpButton.swift in Sources */, @@ -2832,7 +2826,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 20; + CURRENT_PROJECT_VERSION = 25; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; GENERATE_INFOPLIST_FILE = YES; @@ -2864,7 +2858,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 20; + CURRENT_PROJECT_VERSION = 25; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; GENERATE_INFOPLIST_FILE = YES; @@ -2896,7 +2890,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 20; + CURRENT_PROJECT_VERSION = 25; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; GENERATE_INFOPLIST_FILE = YES; @@ -2928,7 +2922,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 20; + CURRENT_PROJECT_VERSION = 25; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; GENERATE_INFOPLIST_FILE = YES; @@ -3077,7 +3071,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1100; + CURRENT_PROJECT_VERSION = 1200; DEAD_CODE_STRIPPING = YES; DEBUG = YES; DEVELOPMENT_TEAM = 8M54J5J787; @@ -3106,7 +3100,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1100; + CURRENT_PROJECT_VERSION = 1200; DEAD_CODE_STRIPPING = YES; DEBUG = NO; DEVELOPMENT_TEAM = 8M54J5J787; @@ -3334,7 +3328,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1100; + CURRENT_PROJECT_VERSION = 1200; DEBUG = NO; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; @@ -3444,7 +3438,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1100; + CURRENT_PROJECT_VERSION = 1200; DEBUG = YES; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; diff --git a/phpmon-updater/ReleaseManifest.swift b/phpmon-updater/ReleaseManifest.swift deleted file mode 100644 index 117ba7c..0000000 --- a/phpmon-updater/ReleaseManifest.swift +++ /dev/null @@ -1,14 +0,0 @@ -// -// UpdateManifest.swift -// PHP Monitor -// -// Created by Nico Verbruggen on 02/02/2023. -// Copyright © 2023 Nico Verbruggen. All rights reserved. -// - -import Foundation - -struct ReleaseManifest: Codable { - let url: String - let sha256: String -} diff --git a/phpmon-updater/Updater.swift b/phpmon-updater/Updater.swift index 5d6e314..abbfa89 100644 --- a/phpmon-updater/Updater.swift +++ b/phpmon-updater/Updater.swift @@ -1,5 +1,5 @@ // -// AppDelegate.swift +// Updater.swift // PHP Monitor Updater // // Created by Nico Verbruggen on 01/02/2023. @@ -79,10 +79,10 @@ class Updater: NSObject, NSApplicationDelegate { system_quiet("rm -rf \(updaterDirectory)/*.zip") // Download the file (and follow redirects + no output on failure) - system_quiet("cd \(updaterDirectory) && curl \(manifest.url) -fLO --max-time 20") + system_quiet("cd \"\(updaterDirectory)\" && curl \(manifest.url) -fLO --max-time 20") // Identify the downloaded file - let filename = system("cd \(updaterDirectory) && ls | grep .zip") + let filename = system("cd \"\(updaterDirectory)\" && ls | grep .zip") .trimmingCharacters(in: .whitespacesAndNewlines) // Ensure the zip exists @@ -92,7 +92,7 @@ class Updater: NSObject, NSApplicationDelegate { } // Calculate the checksum for the downloaded file - let checksum = system("openssl dgst -sha256 \(updaterDirectory)/\(filename) | awk '{print $NF}'") + let checksum = system("openssl dgst -sha256 \"\(updaterDirectory)/\(filename)\" | awk '{print $NF}'") .trimmingCharacters(in: .whitespacesAndNewlines) // Compare the checksums @@ -114,10 +114,10 @@ class Updater: NSObject, NSApplicationDelegate { private func extractAndInstall(zipPath: String) async -> String { // Remove the directory that will contain the extracted update - system_quiet("rm -rf \(updaterDirectory)/extracted") + system_quiet("rm -rf \"\(updaterDirectory)/extracted\"") // Recreate the directory where we will unzip the .app file - system_quiet("mkdir -p \(updaterDirectory)/extracted") + system_quiet("mkdir -p \"\(updaterDirectory)/extracted\"") // Make sure the updater directory exists var isDirectory: ObjCBool = true @@ -126,10 +126,10 @@ class Updater: NSObject, NSApplicationDelegate { } // Unzip the file - system_quiet("unzip \(zipPath) -d \(updaterDirectory)/extracted") + system_quiet("unzip \"\(zipPath)\" -d \"\(updaterDirectory)/extracted\"") // Find the .app file - let app = system("ls \(updaterDirectory)/extracted | grep .app") + let app = system("ls \"\(updaterDirectory)/extracted\" | grep .app") .trimmingCharacters(in: .whitespacesAndNewlines) print("Finished extracting: \(updaterDirectory)/extracted/\(app)") @@ -147,13 +147,13 @@ class Updater: NSObject, NSApplicationDelegate { system_quiet("mv \"\(updaterDirectory)/extracted/\(app)\" \"/Applications/\(app)\"") // Remove the zip - system_quiet("rm \(zipPath)") + system_quiet("rm \"\(zipPath)\"") // Remove the manifest - system_quiet("rm \(manifestPath)") + system_quiet("rm \"\(manifestPath)\"") // Write a file that is only written when we upgraded successfully - system_quiet("touch \(updaterDirectory)/upgrade.success") + system_quiet("touch \"\(updaterDirectory)/upgrade.success\"") // Return the new location of the app return "/Applications/\(app)" diff --git a/phpmon-updater/Alert.swift b/phpmon-updater/Utility.swift similarity index 88% rename from phpmon-updater/Alert.swift rename to phpmon-updater/Utility.swift index 6619b44..e980ba6 100644 --- a/phpmon-updater/Alert.swift +++ b/phpmon-updater/Utility.swift @@ -1,5 +1,5 @@ // -// Alert.swift +// Utility.swift // PHP Monitor Self-Updater // // Created by Nico Verbruggen on 02/02/2023. @@ -27,3 +27,8 @@ class Alert { } } } + +public struct ReleaseManifest: Codable { + let url: String + let sha256: String +} diff --git a/phpmon-updater/main.swift b/phpmon-updater/main.swift index 46757f2..6008aa0 100644 --- a/phpmon-updater/main.swift +++ b/phpmon-updater/main.swift @@ -1,6 +1,6 @@ // // AppDelegate.swift -// PHP Monitor Updater +// PHP Monitor Self-Updater // // Created by Nico Verbruggen on 01/02/2023. // Copyright © 2023 Nico Verbruggen. All rights reserved.