@@ -13,6 +13,67 @@ supported_extensions = ['dmg', 'app']
1313
1414# modeled after munkiimport but to build a pkg
1515
16+
17+ def logger (log , v = 0 ):
18+ if args .verbosity >= v :
19+ print log
20+
21+ def cmdexec (command ):
22+ """Execute a command."""
23+ # if 'command' is a string, split the string into components
24+ if isinstance (command , str ):
25+ command = command .split ()
26+
27+ proc = subprocess .Popen (command , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
28+ (stdout , stderr ) = proc .communicate ()
29+
30+ logger ("cmdexec: %s, result: %s, error: %s" % (command , stdout , stderr ), 3 )
31+
32+ # strip trailing whitespace, which would mess with string comparisons
33+ return {"return_code" : proc .returncode , "stderr" : stderr .rstrip (), "stdout" : stdout .rstrip ()}
34+
35+ def attachdmg (dmgpath ):
36+
37+ #command to run
38+ #hdiutil attach ~/Downloads/BBEdit_11.1.4.dmg -mountrandom /tmp -plist -nobrowse
39+
40+ # returns
41+ #<?xml version="1.0" encoding="UTF-8"?>
42+ #<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
43+ #<plist version="1.0">
44+ #<dict>
45+ # <key>system-entities</key>
46+ # <array>
47+ # <dict>
48+ # <key>content-hint</key>
49+ # <string>Apple_HFS</string>
50+ # <key>dev-entry</key>
51+ # <string>/dev/disk4s1</string>
52+ # <key>mount-point</key>
53+ # <string>/private/tmp/dmg.6fzBvH</string>
54+ # <key>potentially-mountable</key>
55+ # <true/>
56+ # <key>unmapped-content-hint</key>
57+ # <string>48465300-0000-11AA-AA11-00306543ECAC</string>
58+ # <key>volume-kind</key>
59+ # <string>hfs</string>
60+ # </dict>
61+ # <dict>
62+ # <key>content-hint</key>
63+ # <string>GUID_partition_scheme</string>
64+ # <key>dev-entry</key>
65+ # <string>/dev/disk4</string>
66+ # <key>potentially-mountable</key>
67+ # <false/>
68+ # <key>unmapped-content-hint</key>
69+ # <string>GUID_partition_scheme</string>
70+ # </dict>
71+ # </array>
72+ #</dict>
73+ #</plist>
74+
75+
76+
1677if __name__ == "__main__" :
1778 # for convenience link to argparse tutorial:
1879 # https://docs.python.org/2/howto/argparse.html#id1
@@ -27,6 +88,8 @@ if __name__ == "__main__":
2788 # takes a path as input
2889 parser .add_argument ('item_path' , help = "path to the installer item" )
2990
91+ parser .add_argument ("-v" , "--verbosity" , action = "count" , default = 0 , help = "controls amount of logging output (max -vvv)" )
92+
3093 args = parser .parse_args ()
3194
3295 # remove trailing '/' from path
0 commit comments