@@ -1218,6 +1218,8 @@ extension SystemCommand.ProductBuildCommand.SynthesizeCommand: Runnable {}
12181218extension SystemCommand . ProductBuildCommand . DistributionCommand : Runnable { }
12191219
12201220extension SystemCommand {
1221+ // OpenPGP encryption and signing tool
1222+ // See gpg(1) for more information.
12211223 public static func gpg( executable: Executable = GpgCommand . defaultExecutable) -> GpgCommand {
12221224 GpgCommand ( executable: executable)
12231225 }
@@ -1313,3 +1315,154 @@ extension SystemCommand {
13131315
13141316extension SystemCommand . GpgCommand . ImportCommand : Runnable { }
13151317extension SystemCommand . GpgCommand . VerifyCommand : Runnable { }
1318+
1319+ extension SystemCommand {
1320+ // Query and manipulate macOS Installer packages and receipts.
1321+ // See pkgutil(1) for more information.
1322+ public static func pkgutil( executable: Executable = PkgutilCommand . defaultExecutable, _ options: PkgutilCommand . Option ... ) -> PkgutilCommand {
1323+ Self . pkgutil ( executable: executable, options)
1324+ }
1325+
1326+ // Query and manipulate macOS Installer packages and receipts.
1327+ // See pkgutil(1) for more information.
1328+ public static func pkgutil( executable: Executable = PkgutilCommand . defaultExecutable, _ options: [ PkgutilCommand . Option ] ) -> PkgutilCommand {
1329+ PkgutilCommand ( executable: executable, options)
1330+ }
1331+
1332+ public struct PkgutilCommand {
1333+ public static var defaultExecutable : Executable { . name( " pkgutil " ) }
1334+
1335+ public var executable : Executable
1336+
1337+ public var options : [ Option ]
1338+
1339+ public enum Option {
1340+ case verbose
1341+ case volume( FilePath )
1342+
1343+ public func args( ) -> [ String ] {
1344+ switch self {
1345+ case . verbose:
1346+ [ " --verbose " ]
1347+ case let . volume( volume) :
1348+ [ " --volume " , " \( volume) " ]
1349+ }
1350+ }
1351+ }
1352+
1353+ public init ( executable: Executable , _ options: [ Option ] ) {
1354+ self . executable = executable
1355+ self . options = options
1356+ }
1357+
1358+ public func config( ) -> Configuration {
1359+ var args : [ String ] = [ ]
1360+
1361+ for opt in self . options {
1362+ args. append ( contentsOf: opt. args ( ) )
1363+ }
1364+
1365+ return Configuration (
1366+ executable: self . executable,
1367+ arguments: Arguments ( args) ,
1368+ environment: . inherit
1369+ )
1370+ }
1371+
1372+ public func checkSignature( pkgPath: FilePath ) -> CheckSignatureCommand {
1373+ CheckSignatureCommand ( self , pkgPath: pkgPath)
1374+ }
1375+
1376+ public struct CheckSignatureCommand {
1377+ public var pkgutil : PkgutilCommand
1378+
1379+ public var pkgPath : FilePath
1380+
1381+ public init ( _ pkgutil: PkgutilCommand , pkgPath: FilePath ) {
1382+ self . pkgutil = pkgutil
1383+ self . pkgPath = pkgPath
1384+ }
1385+
1386+ public func config( ) -> Configuration {
1387+ var c : Configuration = self . pkgutil. config ( )
1388+
1389+ var args = c. arguments. storage. map ( \. description)
1390+
1391+ args. append ( " --check-signature " )
1392+
1393+ args. append ( " \( self . pkgPath) " )
1394+
1395+ c. arguments = . init( args)
1396+
1397+ return c
1398+ }
1399+ }
1400+
1401+ public func expand( pkgPath: FilePath , dirPath: FilePath ) -> ExpandCommand {
1402+ ExpandCommand ( self , pkgPath: pkgPath, dirPath: dirPath)
1403+ }
1404+
1405+ public struct ExpandCommand {
1406+ public var pkgutil : PkgutilCommand
1407+
1408+ public var pkgPath : FilePath
1409+
1410+ public var dirPath : FilePath
1411+
1412+ public init ( _ pkgutil: PkgutilCommand , pkgPath: FilePath , dirPath: FilePath ) {
1413+ self . pkgutil = pkgutil
1414+ self . pkgPath = pkgPath
1415+ self . dirPath = dirPath
1416+ }
1417+
1418+ public func config( ) -> Configuration {
1419+ var c : Configuration = self . pkgutil. config ( )
1420+
1421+ var args = c. arguments. storage. map ( \. description)
1422+
1423+ args. append ( " --expand " )
1424+
1425+ args. append ( " \( self . pkgPath) " )
1426+
1427+ args. append ( " \( self . dirPath) " )
1428+
1429+ c. arguments = . init( args)
1430+
1431+ return c
1432+ }
1433+ }
1434+
1435+ public func forget( packageId: String ) -> ForgetCommand {
1436+ ForgetCommand ( self , packageId: packageId)
1437+ }
1438+
1439+ public struct ForgetCommand {
1440+ public var pkgutil : PkgutilCommand
1441+
1442+ public var packageId : String
1443+
1444+ public init ( _ pkgutil: PkgutilCommand , packageId: String ) {
1445+ self . pkgutil = pkgutil
1446+ self . packageId = packageId
1447+ }
1448+
1449+ public func config( ) -> Configuration {
1450+ var c : Configuration = self . pkgutil. config ( )
1451+
1452+ var args = c. arguments. storage. map ( \. description)
1453+
1454+ args. append ( " --forget " )
1455+
1456+ args. append ( " \( self . packageId) " )
1457+
1458+ c. arguments = . init( args)
1459+
1460+ return c
1461+ }
1462+ }
1463+ }
1464+ }
1465+
1466+ extension SystemCommand . PkgutilCommand . CheckSignatureCommand : Runnable { }
1467+ extension SystemCommand . PkgutilCommand . ExpandCommand : Runnable { }
1468+ extension SystemCommand . PkgutilCommand . ForgetCommand : Runnable { }
0 commit comments