5 from shutil import copy, copytree
8 #print >>sys.stderr, cmdline
9 return os.system(cmdline)
13 head, tail = os.path.split(path)
14 path_list.insert(0, tail)
16 head, tail = os.path.split(head)
17 path_list.insert(0, tail)
19 for path_element in path_list:
20 created_path = os.path.join(created_path, path_element)
21 if not os.path.exists(created_path):
22 os.mkdir(created_path)
24 # useful information about building dmgs
25 # http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix
26 # http://developer.apple.com/documentation/developertools/Conceptual/SoftwareDistribution/Concepts/sd_disk_images.html
28 def makedmg(dirlist, volname):
29 # need to detect what the real volume name is
30 mussa_mount = '/Volumes/%s' %(volname)
31 mussarw_dmg = '%sw.dmg' %(volname)
32 mussa_dmg = '%s.dmg' %(volname)
33 system('hdiutil detach '+mussa_mount)
34 if os.path.exists(mussa_mount):
35 print >>sys.stderr, "Something is in", mussa_mount
37 if os.path.exists(mussarw_dmg):
38 os.unlink(mussarw_dmg)
39 if os.path.exists(mussa_dmg):
41 system('hdiutil create -size 64m -fs HFS+ -volname "%s" %s'%(volname, mussarw_dmg))
42 system('hdiutil attach '+mussarw_dmg)
45 copytree(d, os.path.join(mussa_mount, d))
47 system('hdiutil detach '+mussa_mount)
48 system('hdiutil convert '+mussarw_dmg +' -format UDZO -o '+mussa_dmg)
49 #system('hdiutil internet-enable -yes '+mussa_dmg)
52 framework_subpath = os.path.join("%(framework)s.framework", "Versions", "4.0", "%(framework)s")
53 frameworks = ['QtCore', 'QtGui', 'QtOpenGL']
55 qt_lib_dir="/usr/local/qt-4.1.1/lib"
56 qt_framework=os.path.join(qt_lib_dir, framework_subpath)
59 app_dir=app_name+".app"
60 app_binary=app_dir+"/Contents/MacOS/"+app_name
61 app_framework=os.path.join(app_dir, "Contents", "Frameworks", framework_subpath)
62 if not os.path.exists(app_dir):
63 print >>sys.stderr, "please build mussagl first"
66 # install frameworks and update binary
67 for frame in frameworks:
68 qtframe = qt_framework % ({'framework': frame})
69 appframe = app_framework % ({'framework': frame})
70 exe_path = "@executable_path/../Frameworks/" + framework_subpath
71 exe_path %= ({'framework': frame})
72 mkdir(os.path.split(appframe)[0])
74 copy(qtframe, appframe)
75 system("install_name_tool -id "+exe_path+" "+appframe)
76 system("install_name_tool -change "+qtframe+" "+exe_path+" "+app_binary)
77 # now that everything is in place change the frameworks
79 for frame2 in frameworks:
80 qtframe2 = qt_framework % ({'framework': frame2})
81 contents_exe_path = "@executable_path/../Frameworks/" + framework_subpath
82 contents_exe_path %= ({'framework': frame2})
83 system("install_name_tool -change "+qtframe2+" "+contents_exe_path+" "+
85 makedmg([app_dir], 'mussa')
87 if __name__ == "__main__":