@@ -25,7 +25,7 @@ import PackageCollectionsSigning
25
25
import Utilities
26
26
27
27
@main
28
- public struct PackageCollectionSign : ParsableCommand {
28
+ public struct PackageCollectionSign : AsyncParsableCommand {
29
29
public static let configuration = CommandConfiguration (
30
30
abstract: " Sign a package collection. "
31
31
)
@@ -49,11 +49,11 @@ public struct PackageCollectionSign: ParsableCommand {
49
49
50
50
public init ( ) { }
51
51
52
- public func run( ) throws {
53
- try self . _run ( signer: nil )
52
+ public func run( ) async throws {
53
+ try await self . _run ( signer: nil )
54
54
}
55
55
56
- internal func _run( signer: PackageCollectionSigner ? ) throws {
56
+ internal func _run( signer: PackageCollectionSigner ? ) async throws {
57
57
Backtrace . install ( )
58
58
59
59
guard !self . certChainPaths. isEmpty else {
@@ -69,7 +69,7 @@ public struct PackageCollectionSign: ParsableCommand {
69
69
let privateKeyURL = URL ( fileURLWithPath: self . privateKeyPath)
70
70
let certChainURLs : [ URL ] = try self . certChainPaths. map { try ensureAbsolute ( path: $0) . asURL }
71
71
72
- try withTemporaryDirectory ( removeTreeOnDeinit: true ) { tmpDir in
72
+ try await withTemporaryDirectory ( removeTreeOnDeinit: true ) { tmpDir in
73
73
// The last item in the array is the root certificate and we want to trust it, so here we
74
74
// create a temp directory, copy the root certificate to it, and make it the trustedRootCertsDir.
75
75
let rootCertPath = try AbsolutePath ( validating: certChainURLs. last!. path) // !-safe since certChain cannot be empty at this point
@@ -78,11 +78,13 @@ public struct PackageCollectionSign: ParsableCommand {
78
78
79
79
// Sign the collection
80
80
let signer = signer ?? PackageCollectionSigning ( trustedRootCertsDir: tmpDir. asURL,
81
- observabilityScope: ObservabilitySystem { _, diagnostic in print ( diagnostic) } . topScope,
82
- callbackQueue: DispatchQueue . global ( ) )
83
- let signedCollection = try temp_await { callback in
84
- signer. sign ( collection: collection, certChainPaths: certChainURLs, certPrivateKeyPath: privateKeyURL, certPolicyKey: . default, callback: callback)
85
- }
81
+ observabilityScope: ObservabilitySystem { _, diagnostic in print ( diagnostic) } . topScope)
82
+ let signedCollection = try await signer. sign (
83
+ collection: collection,
84
+ certChainPaths: certChainURLs,
85
+ certPrivateKeyPath: privateKeyURL,
86
+ certPolicyKey: . default
87
+ )
86
88
87
89
// Make sure the output directory exists
88
90
let outputAbsolutePath = try ensureAbsolute ( path: self . outputPath)
0 commit comments