Author: wade
Date: 2008-01-24 18:24:01 -0500 (Thu, 24 Jan 2008)
New Revision: 93859

Modified:
   trunk/release/macosx/universal_merge
   trunk/release/packaging/do-install-zip-pkgs
   trunk/release/pyutils/utils.py
Log:
utils.py:
-Share code to find out which files are mach-o
 ignore .a files for do-install-zip-pkgs

universal_merge:
-use this code

do-install-zip-pkgs:
-add /tmp/build_deps to paths to look for to replace (for monodevelop)
-use this code



Modified: trunk/release/macosx/universal_merge
===================================================================
--- trunk/release/macosx/universal_merge        2008-01-24 23:23:26 UTC (rev 
93858)
+++ trunk/release/macosx/universal_merge        2008-01-24 23:24:01 UTC (rev 
93859)
@@ -8,7 +8,7 @@
 import distutils.dir_util
 import distutils.file_util
 
-import pdb
+import utils
 
 try:
        (script, distro1, distro2, dest_dir) = sys.argv
@@ -22,30 +22,9 @@
 
 os.chdir('PKGROOT_' + distro1)
 
-candidate_filelist = []
-full_filelist = []
-print "Gathering filelist..."
-# Get a list of all files (which are not symlinks)
-for root, dirs, files in os.walk('.'):
-        for file in files:
-               full_path = root + os.sep + file
-               full_filelist.append(full_path)
-               if os.path.isfile(full_path) and not os.path.islink(full_path):
-                       candidate_filelist.append(full_path)
+print "Gathering filelists..."
+full_filelist, native_files = utils.get_mac_filelists()
 
-# Get report from 'file' as to file types
-(code, output) = commands.getstatusoutput('file ' + ' 
'.join(candidate_filelist))
-
-# Find which files are native
-print "Determining native files..."
-native_reg = re.compile('(.*):.*(Mach-O|ar archive)')
-native_files = []
-for match in native_reg.finditer(output):
-       native_files.append(match.group(1))
-
-native_files.sort()
-print "\n".join(native_files)
-
 os.chdir('..')
 
 # Could auto detect these by diffing...

Modified: trunk/release/packaging/do-install-zip-pkgs
===================================================================
--- trunk/release/packaging/do-install-zip-pkgs 2008-01-24 23:23:26 UTC (rev 
93858)
+++ trunk/release/packaging/do-install-zip-pkgs 2008-01-24 23:24:01 UTC (rev 
93859)
@@ -79,6 +79,8 @@
 # This is for macos
 # NOTE: This shouldn't be used... generally using this var on macos is a bad 
idea
 #env.write('DYLD_LIBRARY_PATH=%s/lib\n' % (reloc) )
+# man dyld
+#  DYLD_FALLBACK_LIBRARY_PATH (will avoid conflicts)
 
 # Use this method for older shells
 env.write('export PKG_CONFIG_PATH PATH LDFLAGS CPPFLAGS LD_LIBRARY_PATH 
MANPATH\n')
@@ -103,6 +105,8 @@
 env.close()
 os.chmod('env.csh', 0755)
 
+mac_prefix_regex = "/Library/Frameworks/Mono.framework/Versions/.*?"
+
 # Fake out .la files (for solaris, win32 doesn't seem to need this
 parameter_map = {}
 parameter_map[re.compile("^libdir=.*", re.M)] = "libdir='" + reloc + "/lib'"
@@ -110,6 +114,8 @@
 parameter_map[re.compile("/opt/csw")] = reloc
 parameter_map[re.compile("/tmp/install")] = reloc
 parameter_map[re.compile("/tmp/build_deps")] = reloc
+parameter_map[re.compile("/tmp/build_deps")] = reloc
+parameter_map[re.compile(mac_prefix_regex + "/")] = reloc + "/"
 
 for root, dirs, files in os.walk('.'):
        for file in files:
@@ -137,17 +143,19 @@
 # For packages we build
 parameter_map[re.compile("/tmp/install")] = reloc
 # For mac builds
-mac_prefix_regex = "/Library/Frameworks/Mono.framework/Versions/.*?"
 parameter_map[re.compile(mac_prefix_regex + "/")] = reloc + "/"
 # For solaris builds
 parameter_map[re.compile("/opt/mono")] = reloc
 # For packages we consume (noarch rpms)
 parameter_map[re.compile("/usr")] = reloc
 
+# Monodevelop on Mac references the mono it was built with.  Replace it.
+parameter_map[re.compile("/tmp/build_deps")] = reloc
+
 for root, dirs, files in os.walk('bin'):
        for file in files:
                # Search and replace in all files containing #!/bin/sh and 
/tmp/install
-               utils.substitute_parameters_in_file(os.path.join(root, file), 
parameter_map, 
qualifier=re.compile('#!/bin/sh.*(/tmp/install|/usr|/Library/Framework|/opt/mono)',
 re.M | re.DOTALL))
+               utils.substitute_parameters_in_file(os.path.join(root, file), 
parameter_map, 
qualifier=re.compile('#!/bin/(ba)?sh.*(/tmp/install|/usr|/Library/Framework|/opt/mono)',
 re.M | re.DOTALL))
 
 # Relocate any .config files with our custom prefix
 #  (This was done so that the swf and sd .config files on mac could be used 
both in testing sd/swf inside monobuild as well as in the installer)
@@ -173,7 +181,7 @@
                        utils.substitute_parameters_in_file(os.path.join(root, 
file), parameter_map)
 
 # Relocate files on macos
-print "Relocating dylib files..."
+print "Relocating mach-o files (mac)..."
 # for all of the .dylib files
 # Notes from 
http://www.opendarwin.org/pipermail/darwinports/2004-August/021704.html
 #  So, each dylib needs to change the reference to itself using:
@@ -182,23 +190,16 @@
 # And then each reference to a symbol that was in /tmp/install needs to be 
updated using
 #  install_name_tool -change <old> <new> <file>
 
-for root, dirs, files in os.walk('.'):
-       for file in files:
-               path_on_disk = root + os.sep + file
-               # Do this on dylib files as well as the files in bin
-               if ( re.compile('\.dylib$').search(file) or root == "./bin" ) 
and not os.path.islink(path_on_disk):
+full_filelist, native_filelist = 
utils.get_mac_filelists(include_ar_files=False)
 
+# Only look at mach-o files
+for path_on_disk in native_filelist:
+
                        utils.debug=0
 
-                       old_filename = os.path.abspath('/tmp/install/%s/%s' % 
(root, file) )
+                       old_filename = os.path.abspath('/tmp/install/%s' % 
(path_on_disk) )
                        new_filename = os.path.abspath( re.sub('/tmp/install', 
reloc, old_filename) )
 
-                       (code, output) = utils.launch_process('otool -L %s' % 
path_on_disk, print_output=0)
-
-                       # Skip non object files or if otool failed (doesn't 
exist)
-                       if re.compile('is not an object file', 
re.M).search(output) or code:
-                               continue
-
                        print 'Relocating %s' % path_on_disk
                        utils.launch_process('install_name_tool -id %s %s' % 
(new_filename, path_on_disk ) )
 

Modified: trunk/release/pyutils/utils.py
===================================================================
--- trunk/release/pyutils/utils.py      2008-01-24 23:23:26 UTC (rev 93858)
+++ trunk/release/pyutils/utils.py      2008-01-24 23:24:01 UTC (rev 93859)
@@ -700,4 +700,49 @@
        if dict_hash.has_key(key):
                return_val = dict_hash[key]
        return return_val
+
+def get_mac_filelists(include_ar_files=True):
+       """Return 2 lists: full filelist (excluding directories), mach-o 
filelist.  Each from current dir"""
+
+       # Used both in do-install-zip-pkg and universal merge.  Consolidate 
here.
+
+       full_filelist = []
+       native_filelist = []
+
+       candidate_filelist = []
+
+       # Max files to pass on the command line (croaks if it's too long)
+       max_num_files = 1000
+
+       # Get a list of all files (which are not symlinks)
+       for root, dirs, files in os.walk('.'):
+               for file in files:
+                       full_path = root + os.sep + file
+                       full_filelist.append(full_path)
+                       if os.path.isfile(full_path) and not 
os.path.islink(full_path):
+                               candidate_filelist.append(full_path)
+
+       # Get report from 'file' as to file types
+       filelist_string = ""
+       final_output = ""
+       while len(candidate_filelist):
+               (code, output) = launch_process('file ' + ' 
'.join(candidate_filelist[:max_num_files]), print_output=0)
+               final_output += "\n" + output
+
+               # Remove them from the list
+               candidate_filelist = candidate_filelist[max_num_files:]
+
+       # Find which files are native
+       if include_ar_files:
+               native_reg = re.compile('(.*):.*(Mach-O|ar archive)')
+       else:   
+               native_reg = re.compile('(.*):.*Mach-O')
+       for match in native_reg.finditer(final_output):
+               native_filelist.append(match.group(1))
+
+       full_filelist.sort()
+       native_filelist.sort()
+
+       return full_filelist, native_filelist
+
  

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to