@@ -5,9 +5,9 @@ public enum SystemCommand {}
5
5
6
6
// This file contains a set of system commands that's used by Swiftly and its related tests and tooling
7
7
8
- // Directory Service command line utility for macOS
9
- // See dscl(1) for details
10
8
extension SystemCommand {
9
+ // Directory Service command line utility for macOS
10
+ // See dscl(1) for details
11
11
public static func dscl( executable: Executable = DsclCommand . defaultExecutable, datasource: String ? = nil ) -> DsclCommand {
12
12
DsclCommand ( executable: executable, datasource: datasource)
13
13
}
@@ -93,13 +93,15 @@ extension SystemCommand.DsclCommand.ReadCommand: Output {
93
93
}
94
94
}
95
95
96
- // Create or operate on universal files
97
- // See lipo(1) for details
98
96
extension SystemCommand {
97
+ // Create or operate on universal files
98
+ // See lipo(1) for details
99
99
public static func lipo( executable: Executable = LipoCommand . defaultExecutable, inputFiles: FilePath ... ) -> LipoCommand {
100
100
Self . lipo ( executable: executable, inputFiles: inputFiles)
101
101
}
102
102
103
+ // Create or operate on universal files
104
+ // See lipo(1) for details
103
105
public static func lipo( executable: Executable = LipoCommand . defaultExecutable, inputFiles: [ FilePath ] ) -> LipoCommand {
104
106
LipoCommand ( executable: executable, inputFiles: inputFiles)
105
107
}
@@ -155,13 +157,15 @@ extension SystemCommand {
155
157
156
158
extension SystemCommand . LipoCommand . CreateCommand : Runnable { }
157
159
158
- // Build a macOS Installer component package from on-disk files
159
- // See pkgbuild(1) for more details
160
160
extension SystemCommand {
161
+ // Build a macOS Installer component package from on-disk files
162
+ // See pkgbuild(1) for more details
161
163
public static func pkgbuild( executable: Executable = PkgbuildCommand . defaultExecutable, _ options: PkgbuildCommand . Option ... , root: FilePath , packageOutputPath: FilePath ) -> PkgbuildCommand {
162
164
Self . pkgbuild ( executable: executable, options: options, root: root, packageOutputPath: packageOutputPath)
163
165
}
164
166
167
+ // Build a macOS Installer component package from on-disk files
168
+ // See pkgbuild(1) for more details
165
169
public static func pkgbuild( executable: Executable = PkgbuildCommand . defaultExecutable, options: [ PkgbuildCommand . Option ] , root: FilePath , packageOutputPath: FilePath ) -> PkgbuildCommand {
166
170
PkgbuildCommand ( executable: executable, options, root: root, packageOutputPath: packageOutputPath)
167
171
}
@@ -224,13 +228,15 @@ extension SystemCommand {
224
228
225
229
extension SystemCommand . PkgbuildCommand : Runnable { }
226
230
227
- // get entries from Name Service Switch libraries
228
- // See getent(1) for more details
229
231
extension SystemCommand {
232
+ // get entries from Name Service Switch libraries
233
+ // See getent(1) for more details
230
234
public static func getent( executable: Executable = GetentCommand . defaultExecutable, database: String , keys: String ... ) -> GetentCommand {
231
235
Self . getent ( executable: executable, database: database, keys: keys)
232
236
}
233
237
238
+ // get entries from Name Service Switch libraries
239
+ // See getent(1) for more details
234
240
public static func getent( executable: Executable = GetentCommand . defaultExecutable, database: String , keys: [ String ] ) -> GetentCommand {
235
241
GetentCommand ( executable: executable, database: database, keys: keys)
236
242
}
@@ -283,6 +289,8 @@ extension SystemCommand.GetentCommand: Output {
283
289
}
284
290
285
291
extension SystemCommand {
292
+ // the stupid content tracker
293
+ // See git(1) for more information.
286
294
public static func git( executable: Executable = GitCommand . defaultExecutable, workingDir: FilePath ? = nil ) -> GitCommand {
287
295
GitCommand ( executable: executable, workingDir: workingDir)
288
296
}
@@ -486,13 +494,15 @@ extension SystemCommand.GitCommand.DiffIndexCommand: Runnable {}
486
494
extension SystemCommand . GitCommand . InitCommand : Runnable { }
487
495
extension SystemCommand . GitCommand . CommitCommand : Runnable { }
488
496
489
- // manipulate tape archives
490
- // See tar(1) for more details
491
497
extension SystemCommand {
498
+ // manipulate tape archives
499
+ // See tar(1) for more details
492
500
public static func tar( executable: Executable = TarCommand . defaultExecutable, _ options: TarCommand . Option ... ) -> TarCommand {
493
501
Self . tar ( executable: executable, options)
494
502
}
495
503
504
+ // manipulate tape archives
505
+ // See tar(1) for more details
496
506
public static func tar( executable: Executable = TarCommand . defaultExecutable, _ options: [ TarCommand . Option ] ) -> TarCommand {
497
507
TarCommand ( executable: executable, options)
498
508
}
@@ -948,6 +958,8 @@ extension SystemCommand.SwiftCommand.SdkCommand.RemoveCommand: Runnable {}
948
958
extension SystemCommand . SwiftCommand . BuildCommand : Runnable { }
949
959
950
960
extension SystemCommand {
961
+ // make utility to maintain groups of programs
962
+ // See make(1) for more information.
951
963
public static func make( executable: Executable = MakeCommand . defaultExecutable) -> MakeCommand {
952
964
MakeCommand ( executable: executable)
953
965
}
@@ -1001,10 +1013,14 @@ extension SystemCommand.MakeCommand: Runnable {}
1001
1013
extension SystemCommand . MakeCommand . InstallCommand : Runnable { }
1002
1014
1003
1015
extension SystemCommand {
1016
+ // remove symbols
1017
+ // See strip(1) for more information.
1004
1018
public static func strip( executable: Executable = StripCommand . defaultExecutable, names: FilePath ... ) -> StripCommand {
1005
1019
self . strip ( executable: executable, names: names)
1006
1020
}
1007
1021
1022
+ // remove symbols
1023
+ // See strip(1) for more information.
1008
1024
public static func strip( executable: Executable = StripCommand . defaultExecutable, names: [ FilePath ] ) -> StripCommand {
1009
1025
StripCommand ( executable: executable, names: names)
1010
1026
}
@@ -1038,10 +1054,14 @@ extension SystemCommand {
1038
1054
extension SystemCommand . StripCommand : Runnable { }
1039
1055
1040
1056
extension SystemCommand {
1057
+ // calculate a message-digest fingerprint (checksum) for a file
1058
+ // See sha256sum(1) for more information.
1041
1059
public static func sha256sum( executable: Executable = Sha256SumCommand . defaultExecutable, files: FilePath ... ) -> Sha256SumCommand {
1042
1060
self . sha256sum ( executable: executable, files: files)
1043
1061
}
1044
1062
1063
+ // calculate a message-digest fingerprint (checksum) for a file
1064
+ // See sha256sum(1) for more information.
1045
1065
public static func sha256sum( executable: Executable , files: [ FilePath ] ) -> Sha256SumCommand {
1046
1066
Sha256SumCommand ( executable: executable, files: files)
1047
1067
}
@@ -1073,3 +1093,126 @@ extension SystemCommand {
1073
1093
}
1074
1094
1075
1095
extension SystemCommand . Sha256SumCommand : Output { }
1096
+
1097
+ extension SystemCommand {
1098
+ // Build a product archive for the macOS Installer or the Mac App Store.
1099
+ // See productbuild(1) for more information.
1100
+ public static func productbuild( executable: Executable = ProductBuildCommand . defaultExecutable) -> ProductBuildCommand {
1101
+ ProductBuildCommand ( executable: executable)
1102
+ }
1103
+
1104
+ public struct ProductBuildCommand {
1105
+ public static var defaultExecutable : Executable { . name( " productbuild " ) }
1106
+
1107
+ public var executable : Executable
1108
+
1109
+ public init ( executable: Executable ) {
1110
+ self . executable = executable
1111
+ }
1112
+
1113
+ public func config( ) -> Configuration {
1114
+ var args : [ String ] = [ ]
1115
+
1116
+ return Configuration (
1117
+ executable: self . executable,
1118
+ arguments: Arguments ( args) ,
1119
+ environment: . inherit
1120
+ )
1121
+ }
1122
+
1123
+ public func synthesize( package : FilePath , distributionOutputPath: FilePath ) -> SynthesizeCommand {
1124
+ SynthesizeCommand ( self , package : package , distributionOutputPath: distributionOutputPath)
1125
+ }
1126
+
1127
+ public struct SynthesizeCommand {
1128
+ public var productBuildCommand : ProductBuildCommand
1129
+
1130
+ public var package : FilePath
1131
+
1132
+ public var distributionOutputPath : FilePath
1133
+
1134
+ public init ( _ productBuildCommand: ProductBuildCommand , package : FilePath , distributionOutputPath: FilePath ) {
1135
+ self . productBuildCommand = productBuildCommand
1136
+ self . package = package
1137
+ self . distributionOutputPath = distributionOutputPath
1138
+ }
1139
+
1140
+ public func config( ) -> Configuration {
1141
+ var c = self . productBuildCommand. config ( )
1142
+
1143
+ var args = c. arguments. storage. map ( \. description)
1144
+
1145
+ args. append ( " --synthesize " )
1146
+
1147
+ args. append ( contentsOf: [ " --package " , " \( self . package ) " ] )
1148
+ args. append ( " \( self . distributionOutputPath) " )
1149
+
1150
+ c. arguments = . init( args)
1151
+
1152
+ return c
1153
+ }
1154
+ }
1155
+
1156
+ public func distribution( _ options: DistributionCommand . Option ... , distPath: FilePath , productOutputPath: FilePath ) -> DistributionCommand {
1157
+ self . distribution ( options, distPath: distPath, productOutputPath: productOutputPath)
1158
+ }
1159
+
1160
+ public func distribution( _ options: [ DistributionCommand . Option ] , distPath: FilePath , productOutputPath: FilePath ) -> DistributionCommand {
1161
+ DistributionCommand ( self , options, distPath: distPath, productOutputPath: productOutputPath)
1162
+ }
1163
+
1164
+ public struct DistributionCommand {
1165
+ public var productBuildCommand : ProductBuildCommand
1166
+
1167
+ public var options : [ Option ]
1168
+
1169
+ public var distPath : FilePath
1170
+
1171
+ public var productOutputPath : FilePath
1172
+
1173
+ public enum Option {
1174
+ case packagePath( FilePath )
1175
+ case sign( String )
1176
+
1177
+ public func args( ) -> [ String ] {
1178
+ switch self {
1179
+ case let . packagePath( packagePath) :
1180
+ [ " --package-path " , " \( packagePath) " ]
1181
+ case let . sign( sign) :
1182
+ [ " --sign " , " \( sign) " ]
1183
+ }
1184
+ }
1185
+ }
1186
+
1187
+ public init ( _ productBuildCommand: ProductBuildCommand , _ options: [ Option ] , distPath: FilePath , productOutputPath: FilePath ) {
1188
+ self . productBuildCommand = productBuildCommand
1189
+ self . options = options
1190
+ self . distPath = distPath
1191
+ self . productOutputPath = productOutputPath
1192
+ }
1193
+
1194
+ public func config( ) -> Configuration {
1195
+ var c = self . productBuildCommand. config ( )
1196
+
1197
+ var args = c. arguments. storage. map ( \. description)
1198
+
1199
+ args. append ( " --distribution " )
1200
+
1201
+ args. append ( " \( self . distPath) " )
1202
+
1203
+ for opt in self . options {
1204
+ args. append ( contentsOf: opt. args ( ) )
1205
+ }
1206
+
1207
+ args. append ( " \( self . productOutputPath) " )
1208
+
1209
+ c. arguments = . init( args)
1210
+
1211
+ return c
1212
+ }
1213
+ }
1214
+ }
1215
+ }
1216
+
1217
+ extension SystemCommand . ProductBuildCommand . SynthesizeCommand : Runnable { }
1218
+ extension SystemCommand . ProductBuildCommand . DistributionCommand : Runnable { }
0 commit comments