Closed dhwanivora14 closed 3 years ago
From the README at https://github.com/munki/munki-pkg#build-info:
YAML is supported if you also install the Python PyYAML module.
Re-reading this, I'm now re-opening...
Adding the PyYAML module is intended to be optional, but there's a coding error.
You have an invalid build_info file, and when it's trying to tell you this, it hits the undefined yaml global:
https://github.com/munki/munki-pkg/blob/main/munkipkg#L148-L150
So, yes, there's an issue in the munkipkg code that should be fixed, but its being triggered by the fact your build_info file is invalid.
How can I verify if build-info.plist is valid?
I did the following steps:
1) munkipkg --create Foo
2) Updated build-info.plist file
3) Added scripts/postinstall
4) Ran munkipkg /path/to/project
One way would be plutil /path/to/build-info.plist
.
Another way would be to show us your build-info.plist file!
Changed some fields:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>distribution_style</key>
<false/>
<key>identifier</key>
<string>com.abc.xyz</string>
<key>install_location</key>
<string>/usr/local/bin/xyz</string>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>900</integer>
<key>WorkingDirectory</key>
<string>/Library/Application Support/abc/xyz</string>
<string>xyz-${version}.pkg</string>
<key>ownership</key>
<string>recommended</string>
<key>postinstall_action</key>
<string>none</string>
<key>preserve_xattr</key>
<false/>
<key>suppress_bundle_relocation</key>
<true/>
<key>version</key>
<string>1.0</string>
</dict>
</plist>
Removing line 17 fixes the validation issue:
<string>xyz-${version}.pkg</string>
To install pyyaml, I followed this:
sudo easy_install pip
sudo pip install -r requirements.txt
However, I get the following stacktrace:
Traceback (most recent call last):
File "/Users/vdhwani/Projects/munki-pkg/munkipkg", line 1053, in <module>
main()
File "/Users/vdhwani/Projects/munki-pkg/munkipkg", line 1049, in main
result = build(arguments[0], options)
File "/Users/vdhwani/Projects/munki-pkg/munkipkg", line 630, in build
build_info = get_build_info(project_dir, options)
File "/Users/vdhwani/Projects/munki-pkg/munkipkg", line 257, in get_build_info
file_info = read_build_info(build_file + '.' + file_type)
File "/Users/vdhwani/Projects/munki-pkg/munkipkg", line 147, in read_build_info
build_info = readPlist(path)
File "/Users/vdhwani/Projects/munki-pkg/munkipkg", line 86, in readPlist
return plistlib.readPlist(filepath)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 78, in readPlist
rootObject = p.parse(pathOrFile)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 406, in parse
parser.ParseFile(fileobj)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 418, in handleEndElement
handler()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 470, in end_string
self.addObject(self.getData())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 431, in addObject
self.stack[-1].append(value)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 301, in __getattr__
raise AttributeError, attr
AttributeError: append
Its using python 2.7 for some reason. Instead of python 3. Not sure why.
Issue addressed here: https://github.com/munki/munki-pkg/commit/cd84d82efad6146b956b56c5f5d582636d9877c0
As for your build-info.plist, you appear to have pasted in keys and values completely unrelated to munki-pkg build-info plists, namely:
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>900</integer>
<key>WorkingDirectory</key>
<string>/Library/Application Support/abc/xyz</string>
and have ended up with an invalid plist.
It's using Python 2.7 because the shebang is #!/usr/local/python
, which on macOS is the Python 2.7 install Apple includes.
Oh got it. I need to use the keys exactly as listed for munki-pkg build-info plists.
How can I use python3 then?
python3 munkipkg whatever
Thanks so much!
Hi, I am getting the following error while trying to build package