Created
May 27, 2010 16:38
-
-
Save ptone/416028 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
untitled.py | |
Created by Preston Holmes on 2009-07-14. | |
Copyright (c) 2009 __MyCompanyName__. All rights reserved. | |
The script below emulates these steps: | |
1) Use relative transcripts (you can convert them easily with sed if | |
you don't already have them) | |
2) Create a command file containing the loadset(s) you want and assign | |
it to your client | |
3) make a package_root directory on the client | |
4) cd to the package_root directory and use fsdiff/lapply to install | |
the loadset (you might need to do lapply -C unless you have all your | |
intermediate directories in the command file) | |
5) cd out of the package_root directory and do something like: | |
/Developer/usr/bin/packagemaker --id my.new.package --root | |
package_root --title"My Great Package" --target 10.4 --out | |
MyGreatPackage.pkg | |
""" | |
import sys | |
import os | |
from subprocess import Popen, call, STDOUT, PIPE | |
import shutil | |
def sh(cmd): | |
return Popen(cmd,shell=True,stdout=PIPE,stderr=PIPE).communicate()[0] | |
def pkg_from_transcript(transcript): | |
pkg_root = '/tmp/package_root' | |
pkg_maker_cmd = '/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker' | |
if not os.path.exists(pkg_root): os.makedirs(pkg_root) | |
os.chdir('/') | |
for line in open(transcript): | |
fields = line.split() | |
abs_path = os.path.abspath(fields[1]) | |
if os.path.isfile(abs_path): | |
dest = os.path.join (pkg_root,os.path.dirname(abs_path)[1:] + '/') | |
call(['ditto',abs_path,dest]) | |
pkg_id = os.path.basename(transcript) | |
call([pkg_maker_cmd,'--root',pkg_root,'--id',pkg_id,'--title',pkg_id,'--target','10.4','--out',pkg_id + '.pkg']) | |
shutil.rmtree(pkg_root) | |
def main(): | |
pkg_from_transcript('/Users/preston/AppleIntermediateCodec.T') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment