Skip to content

Commit debaf6f

Browse files
committed
Change the default install path for macOS pkgs
Correct productbuild issue when creating a pkg
1 parent 400e6a9 commit debaf6f

File tree

4 files changed

+17
-31
lines changed

4 files changed

+17
-31
lines changed

Sources/Swiftly/Init.swift

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,6 @@ internal struct Init: SwiftlyCommand {
8989
}
9090
}
9191

92-
// Ensure swiftly doesn't overwrite any existing executables without getting confirmation first.
93-
let swiftlyBinDir = Swiftly.currentPlatform.swiftlyBinDir
94-
let swiftlyBinDirContents = (try? FileManager.default.contentsOfDirectory(atPath: swiftlyBinDir.path)) ?? [String]()
95-
let willBeOverwritten = Set(["swiftly"]).intersection(swiftlyBinDirContents)
96-
if !willBeOverwritten.isEmpty && !overwrite {
97-
SwiftlyCore.print("The following existing executables will be overwritten:")
98-
99-
for executable in willBeOverwritten {
100-
SwiftlyCore.print(" \(swiftlyBinDir.appendingPathComponent(executable).path)")
101-
}
102-
103-
guard SwiftlyCore.promptForConfirmation(defaultBehavior: false) else {
104-
throw SwiftlyError(message: "Swiftly installation has been cancelled")
105-
}
106-
}
107-
10892
let shell = if let s = ProcessInfo.processInfo.environment["SHELL"] {
10993
s
11094
} else {
@@ -239,14 +223,16 @@ internal struct Init: SwiftlyCommand {
239223
(postInstall, pathChanged) = try await Install.execute(version: latestVersion, &config, useInstalledToolchain: true, verifySignature: true, verbose: verbose, assumeYes: assumeYes)
240224
}
241225

242-
if addEnvToProfile && !quietShellFollowup {
226+
if addEnvToProfile {
243227
try Data(sourceLine.utf8).append(to: profileHome)
244228

245-
SwiftlyCore.print("""
246-
To begin using installed swiftly from your current shell, first run the following command:
247-
\(sourceLine)
229+
if !quietShellFollowup {
230+
SwiftlyCore.print("""
231+
To begin using installed swiftly from your current shell, first run the following command:
232+
\(sourceLine)
248233
249-
""")
234+
""")
235+
}
250236
}
251237

252238
// Fish doesn't have path caching, so this might only be needed for bash/zsh

Tests/SwiftlyTests/SwiftlyTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ public class MockToolchainDownloader: HTTPRequestExecutor {
729729
#elseif os(macOS)
730730
public func makeMockedSwiftly(from _: URL) throws -> Data {
731731
let tmp = FileManager.default.temporaryDirectory.appendingPathComponent("swiftly-\(UUID())")
732-
let swiftlyDir = tmp.appendingPathComponent("swiftly", isDirectory: true)
732+
let swiftlyDir = tmp.appendingPathComponent(".swiftly", isDirectory: true)
733733
let swiftlyBinDir = swiftlyDir.appendingPathComponent("bin")
734734

735735
try FileManager.default.createDirectory(
@@ -766,7 +766,7 @@ public class MockToolchainDownloader: HTTPRequestExecutor {
766766
"--root",
767767
swiftlyDir.path,
768768
"--install-location",
769-
"usr/local",
769+
".swiftly",
770770
"--version",
771771
"\(self.latestSwiftlyVersion)",
772772
"--identifier",

Tests/SwiftlyTests/UninstallTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,10 @@ final class UninstallTests: SwiftlyTests {
301301
func testUninstallNotInstalled() async throws {
302302
let toolchains = Set([Self.oldStable, Self.newStable, Self.newMainSnapshot, Self.oldReleaseSnapshot])
303303
try await self.withMockedHome(homeName: Self.homeName, toolchains: toolchains, inUse: Self.newMainSnapshot) {
304-
var config = try await Config.load()
304+
var config = try Config.load()
305305
config.inUse = Self.newMainSnapshot
306306
config.installedToolchains.remove(Self.newMainSnapshot)
307-
try await config.save()
307+
try config.save()
308308

309309
var uninstall = try self.parseCommand(Uninstall.self, ["uninstall", "-y", Self.newMainSnapshot.name])
310310
_ = try await uninstall.run()

Tools/build-swiftly-release/BuildSwiftlyRelease.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,12 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
399399
try runProgram(strip, ".build/\(arch)-apple-macosx/release/swiftly")
400400
}
401401

402-
let swiftlyBinDir = FileManager.default.currentDirectoryPath + "/.build/release/usr/local/bin"
402+
let swiftlyBinDir = FileManager.default.currentDirectoryPath + "/.build/release/.swiftly/bin"
403403
try? FileManager.default.createDirectory(atPath: swiftlyBinDir, withIntermediateDirectories: true)
404404

405405
try runProgram(lipo, ".build/x86_64-apple-macosx/release/swiftly", ".build/arm64-apple-macosx/release/swiftly", "-create", "-o", "\(swiftlyBinDir)/swiftly")
406406

407-
let swiftlyLicenseDir = FileManager.default.currentDirectoryPath + "/.build/release/usr/local/share/doc/swiftly/license"
407+
let swiftlyLicenseDir = FileManager.default.currentDirectoryPath + "/.build/release/.swiftly/license"
408408
try? FileManager.default.createDirectory(atPath: swiftlyLicenseDir, withIntermediateDirectories: true)
409409
try await self.collectLicenses(swiftlyLicenseDir)
410410

@@ -418,7 +418,7 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
418418
"--root",
419419
swiftlyBinDir + "/..",
420420
"--install-location",
421-
"usr/local",
421+
".swiftly",
422422
"--version",
423423
self.version,
424424
"--identifier",
@@ -433,7 +433,7 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
433433
"--root",
434434
swiftlyBinDir + "/..",
435435
"--install-location",
436-
"usr/local",
436+
".swiftly",
437437
"--version",
438438
self.version,
439439
"--identifier",
@@ -455,9 +455,9 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
455455
try distFileContents.write(to: distFile, atomically: true, encoding: .utf8)
456456

457457
if let cert = cert {
458-
try runProgram("productbuild", "--distribution", distFile.path, "--package-path", pkgFile.path, "--sign", cert, pkgFileReconfigured.path)
458+
try runProgram("productbuild", "--distribution", distFile.path, "--package-path", pkgFile.deletingLastPathComponent().path, "--sign", cert, pkgFileReconfigured.path)
459459
} else {
460-
try runProgram("productbuild", "--distribution", distFile.path, "--package-path", pkgFile.path, pkgFileReconfigured.path)
460+
try runProgram("productbuild", "--distribution", distFile.path, "--package-path", pkgFile.deletingLastPathComponent().path, pkgFileReconfigured.path)
461461
}
462462
try FileManager.default.removeItem(at: pkgFile)
463463
try FileManager.default.copyItem(atPath: pkgFileReconfigured.path, toPath: pkgFile.path)

0 commit comments

Comments
 (0)