summaryrefslogtreecommitdiffstats
path: root/OSX-package/linktools/ingest.py
blob: 83a06204458a7581a3aba0f18876b094901d841a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/python

import os
import sys
import osxtools

def usage():
	print """
 Usage: ingest.py bundle [-x lib] [-s fw]
 
	Copies all dependent libraries and frameworks into the app bundle.
	System libraries (/usr/lib*, /System/Library) are not copied.
	Fixes the dependencies in all executabels contained in bundle.
	
	bundle:	the path to the *.app bundle
	-x lib:	dont move lib into the bundle. 
	-s fw:	only move the referenced libarry file from framework fw 
			into the bundle, not the complete framework
	"""


if len(sys.argv) <= 1 or sys.argv[1] == "-?" :
	usage()
	sys.exit(0)



exceptions = []
strippedfws = []
bundle = None

argp = 1

while argp < len(sys.argv) :
	if sys.argv[argp] == '-x' :
		exceptions.append(sys.argv[argp + 1])
		argp = argp + 2
	elif sys.argv[argp][0:2] == '-x' :
		exceptions.append(sys.argv[argp][2:])
		argp = argp + 1
	elif sys.argv[argp] == '-s' :
		strippedfws.append(sys.argv[argp + 1])
		argp = argp + 2
	elif  sys.argv[argp][0:2] == '-s' :
		strippedfws.append(sys.argv[argp][2:])
		argp = argp + 1
	elif  sys.argv[argp][0:1] == '-' :
		print "Error: unknown option: " + sys.argv[argp]
		usage()
		sys.exit(1)
	elif bundle == None:
		bundle = sys.argv[argp]
		argp = argp + 1
	else:
		print "Error: more than one bundle path specified!"
		usage()
		sys.exit(1)

if bundle == None:	
	print "Error: no bundle path specified!"
	usage()
	sys.exit(1)

if not os.path.isabs(bundle):
	bundle = os.path.join(os.getenv("PWD"), bundle)
	
if not os.path.isdir(bundle):
	print "Error: '" + bundle + "' is no bundle path!"
	usage()
	sys.exit(1)

osxtools.ingest(bundle, exceptions, strippedfws)