Guest User

Untitled

a guest
May 26th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. """
  4. untitled.py
  5.  
  6. Created by Preston Holmes on 2009-07-14.
  7. Copyright (c) 2009 __MyCompanyName__. All rights reserved.
  8.  
  9. The script below emulates these steps:
  10. 1) Use relative transcripts (you can convert them easily with sed if
  11. you don't already have them)
  12. 2) Create a command file containing the loadset(s) you want and assign
  13. it to your client
  14. 3) make a package_root directory on the client
  15. 4) cd to the package_root directory and use fsdiff/lapply to install
  16. the loadset (you might need to do lapply -C unless you have all your
  17. intermediate directories in the command file)
  18. 5) cd out of the package_root directory and do something like:
  19.  
  20. /Developer/usr/bin/packagemaker --id my.new.package --root
  21. package_root --title"My Great Package" --target 10.4 --out
  22. MyGreatPackage.pkg
  23. """
  24.  
  25. import sys
  26. import os
  27. from subprocess import Popen, call, STDOUT, PIPE
  28. import shutil
  29.  
  30. def sh(cmd):
  31. return Popen(cmd,shell=True,stdout=PIPE,stderr=PIPE).communicate()[0]
  32.  
  33. def pkg_from_transcript(transcript):
  34. pkg_root = '/tmp/package_root'
  35. pkg_maker_cmd = '/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker'
  36. if not os.path.exists(pkg_root): os.makedirs(pkg_root)
  37. os.chdir('/')
  38. for line in open(transcript):
  39. fields = line.split()
  40. abs_path = os.path.abspath(fields[1])
  41. if os.path.isfile(abs_path):
  42. dest = os.path.join (pkg_root,os.path.dirname(abs_path)[1:] + '/')
  43. call(['ditto',abs_path,dest])
  44. pkg_id = os.path.basename(transcript)
  45. call([pkg_maker_cmd,'--root',pkg_root,'--id',pkg_id,'--title',pkg_id,'--target','10.4','--out',pkg_id + '.pkg'])
  46. shutil.rmtree(pkg_root)
  47.  
  48.  
  49.  
  50. def main():
  51. pkg_from_transcript('/Users/preston/AppleIntermediateCodec.T')
  52.  
  53.  
  54. if __name__ == '__main__':
  55. main()
Add Comment
Please, Sign In to add comment