[26467] users/pipping/merge.rb

source_changes at macosforge.org source_changes at macosforge.org
Sun Jun 24 20:41:55 PDT 2007


Revision: 26467
          http://trac.macosforge.org/projects/macports/changeset/26467
Author:   pipping at macports.org
Date:     2007-06-24 20:41:54 -0700 (Sun, 24 Jun 2007)

Log Message:
-----------
check for symlinks (no action taken yet)
use more fine grained cases (none-some-all rather than none-any)
emit a warning (for the time being) if not action was taken on a non-symlink file

Modified Paths:
--------------
    users/pipping/merge.rb

Modified: users/pipping/merge.rb
===================================================================
--- users/pipping/merge.rb	2007-06-25 00:58:14 UTC (rev 26466)
+++ users/pipping/merge.rb	2007-06-25 03:41:54 UTC (rev 26467)
@@ -138,6 +138,8 @@
         unless processed.include? path
           my_dir=File.dirname(File.join(arguments[:output], path))
           # TODO: what if ppc/foo is a dir and i386/foo is a file (symlink)? (1)
+          # TODO: maybe mkdir should only be called *after* we've decided what
+          #       needs to be done with the file
           unless File.exist? my_dir
             FileUtils.mkdir_p(
               my_dir,
@@ -145,62 +147,76 @@
               :noop => arguments[:dry_run]
             )
           end
-          if true_for_all?(path, arguments) {|dir,filename,arch|
-            File.exist?(File.join(dir, filename))
+          if true_for_all?(path,arguments) {|dir,filename,arch|
+            !FileTest.symlink?(File.join(dir,filename))
           }
-            unless true_for_all?(path, arguments) {|dir,filename,arch|
-              File.directory?(File.join(dir, filename))
+            if true_for_all?(path, arguments) {|dir,filename,arch|
+              File.exist?(File.join(dir, filename))
             }
-
               if true_for_all?(path, arguments) {|dir,filename,arch|
-                FileUtils.identical?(
-                  File.join(dir, path),
-                  File.join(arguments[:root], ARGS[0], path)
-                )
+                !File.directory?(File.join(dir, filename))
               }
-                copytarget=File.join(arguments[:output],path)
-                if !File.exist?(copytarget) or arguments[:force]
-                  FileUtils.cp(
-                    File.join(arguments[:root],ARGS[0],path),
-                    copytarget,
-                    :preserve => !arguments[:force],
-                    :verbose => arguments[:verbose],
-                    :noop => arguments [:dry_run]
+                if true_for_all?(path, arguments) {|dir,filename,arch|
+                  FileUtils.identical?(
+                    File.join(dir, path),
+                    File.join(arguments[:root], ARGS[0], path)
                   )
-                end
-              else
-                # TODO: make this not-blindly lipo but check filetypes / archs
-                # TODO: beware of symlinks!
-                case File.basename path
-                when /\.dylib(\.\d*)*/, /\.so(\.\d*)*/, /\.a$/
-                  lipo(path,ARGS,arguments)
-                when /\.h$/, /\.hpp$/
-                  # TODO: handle header files
-                when /\.pc$/
-                  # TODO: handle pkgconfig files
-                when /\.sh$/
-                  # TODO: handle shell scripts
+                }
+                  copytarget=File.join(arguments[:output],path)
+                  if !File.exist?(copytarget) or arguments[:force]
+                    FileUtils.cp(
+                      File.join(arguments[:root],ARGS[0],path),
+                      copytarget,
+                      :preserve => !arguments[:force],
+                      :verbose => arguments[:verbose],
+                      :noop => arguments [:dry_run]
+                    )
+                  end
                 else
-                  case %x{#{FILE} -b "#{File.join(arguments[:root],ARGS[0],path)}"}
-                  when sprintf("Mach-O executable %s\n", ARGS[0])
-                    if true_for_all?(path, arguments) {|dir,filename,arch|
-                      %x{#{FILE} -b "#{File.join(dir,path)}"} == sprintf("Mach-O executable %s\n", arch)
-                    }
-                      lipo(path,ARGS,arguments)
+                  # TODO: make this non-blindly lipo but check filetypes / archs
+                  # TODO: beware of symlinks!
+                  case File.basename path
+                  when /\.dylib(\.\d*)*/, /\.so(\.\d*)*/, /\.a$/
+                    lipo(path,ARGS,arguments)
+                # when /\.h$/, /\.hpp$/
+                #   # TODO: handle header files
+                # when /\.pc$/
+                #   # TODO: handle pkgconfig files
+                # when /\.sh$/
+                #   # TODO: handle shell scripts
+                  else
+                    case %x{#{FILE} -b "#{File.join(arguments[:root],ARGS[0],path)}"}
+                    when sprintf("Mach-O executable %s\n", ARGS[0])
+                      if true_for_all?(path, arguments) {|dir,filename,arch|
+                        %x{#{FILE} -b "#{File.join(dir,path)}"} == sprintf("Mach-O executable %s\n", arch)
+                      }
+                        lipo(path,ARGS,arguments)
+                      else
+                        # one of the files is a mach-o file that matches its
+                        # desired architecture but one of the others doesn't
+                      end
                     else
-                      # one of the files is a mach-o file that matches its
-                      # desired architecture but one of the others doesn't
+                      printf "file not handled: %s\n", path
+                      # TODO: deal with whatever else can differ
                     end
-                  # else
-                    # TODO: deal with whatever else can differ
                   end
                 end
+              elsif !true_for_all?(path, arguments) {|dir,filename,arch|
+                File.directory?(File.join(dir, filename))
+              }
+                # TODO: we have a mix of at least one directory and items that
+                # are not directories
               end
             else
-              # TODO: at least one of the files is a directory (1)
+              # TODO: a file is not present in all trees. what's wrong?
             end
+          elsif true_for_all?(path,arguments) {|dir,filename,arch|
+            FileTest.symlink?(File.join(dir,filename))
+          }
+            # TODO: dealing with symlinks
           else
-            # TODO: a file is not present in all trees. what's wrong?
+            # TODO: dealing with a mix of at least on symlink and items that
+            # are not symlinks
           end
           processed << path
         end

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070624/98e89354/attachment.html


More information about the macports-changes mailing list