[26652] users/pipping/merge.rb

source_changes at macosforge.org source_changes at macosforge.org
Sun Jul 1 08:24:35 PDT 2007


Revision: 26652
          http://trac.macosforge.org/projects/macports/changeset/26652
Author:   pipping at macports.org
Date:     2007-07-01 08:24:35 -0700 (Sun, 01 Jul 2007)

Log Message:
-----------
== sync with http://elias.svn.binera.de ==
make true_for_all? take another predicate to skip checks for the first element of ARGS
make FileUtils.cp(...) into a function
make FileUtils.cd always quiet
handle pkgconfig files (http://elias.binera.de/dokuwiki/doku.php#file_types)
handle symlinks (http://elias.binera.de/dokuwiki/doku.php#file_types)

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

Modified: users/pipping/merge.rb
===================================================================
--- users/pipping/merge.rb	2007-07-01 15:22:30 UTC (rev 26651)
+++ users/pipping/merge.rb	2007-07-01 15:24:35 UTC (rev 26652)
@@ -108,14 +108,27 @@
 # avoid duplicates and trailing slashes
 ARGS=ARGV.collect {|arg| arg.chomp('/')}.uniq
 
-def true_for_all? (path, args, &block)
+def true_for_all? (path, args, first_too, &block)
   result=true
-  ARGS.each {|arch|
+  iter_over = first_too ? ARGS : ARGS[1..-1]
+  iter_over.each {|arch|
     result=false unless yield(File.join(args[:root], arch, path), arch)
   }
   return result
 end
 
+def copy (origin, target, args)
+  if !File.exist?(target) or args[:force]
+    FileUtils.cp(
+      origin,
+      target,
+      :preserve => !args[:force],
+      :verbose => args[:verbose],
+      :noop => args [:dry_run]
+    )
+  end
+end
+
 def lipo (filepath,architectures,args)
   lipoargs = Array.new
   architectures.each {|arch|
@@ -149,7 +162,7 @@
     )
       FileUtils.cd(
         File.join(arguments[:root], architecture),
-        :verbose => arguments[:verbose]
+        :verbose => false
       )
       Find.find('.') {|path|
         arguments[:exclude].each {|exclude_me|
@@ -167,31 +180,26 @@
               :noop => arguments[:dry_run]
             )
           end
-          if true_for_all?(path,arguments) {|filepath,arch|
+          if true_for_all?(path,arguments,true) {|filepath,arch|
             !FileTest.symlink? filepath
           }
-            if true_for_all?(path, arguments) {|filepath,arch|
+            if true_for_all?(path, arguments,true) {|filepath,arch|
               File.exist? filepath
             }
-              if true_for_all?(path, arguments) {|filepath,arch|
+              if true_for_all?(path, arguments,true) {|filepath,arch|
                 !File.directory? filepath
               }
-                if true_for_all?(path, arguments) {|filepath,arch|
+                if true_for_all?(path, arguments,false) {|filepath,arch|
                   FileUtils.identical?(
                     filepath, 
                     File.join(arguments[:root], ARGS[0], path)
                   )
                 }
-                  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
+                  copy(
+                    File.join(arguments[:root],ARGS[0],path),
+                    File.join(arguments[:output],path),
+                    arguments
+                  )
                 else
                   case File.basename path
                   # TODO: more cases
@@ -205,6 +213,27 @@
                         }
                       }
                     end
+                  when /\.pc$/
+                    ARGS.each {|arch|
+                      copy_target=File.join(
+                        arguments[:output],
+                        File.dirname(path),
+                        arch,
+                        File.basename(path)
+                      )
+                      unless File.exists? File.dirname(copy_target)
+                        FileUtils.mkdir_p(
+                          File.dirname(copy_target),
+                          :verbose => arguments[:verbose],
+                          :noop => arguments[:dry_run]
+                        )
+                      end
+                      copy(
+                        File.join(arguments[:root],arch,path),
+                        copy_target,
+                        arguments
+                      )
+                    }
                   else
                     file_output = %x{
                       #{FILE} -b "#{
@@ -213,10 +242,10 @@
                     }.chomp
                     case file_output
                     when /^current ar archive/
-                      if true_for_all?(path, arguments) {|filepath,arch|
+                      if true_for_all?(path, arguments,false) {|filepath,arch|
                         %x{#{FILE} -b "#{filepath}"}.chomp =~ /^current ar archive/
                       }
-                        if true_for_all?(path, arguments) {|filepath,arch|
+                        if true_for_all?(path, arguments,true) {|filepath,arch|
                           %x{lipo -info "#{filepath}"}.chomp =~ /is architecture: #{arch}$/
                         }
                           lipo(path,ARGS,arguments)
@@ -227,10 +256,10 @@
                         # ERROR: mixed filetypes
                       end
                     when /^Mach-O/
-                      if true_for_all?(path, arguments) {|filepath,arch|
+                      if true_for_all?(path, arguments,false) {|filepath,arch|
                         %x{#{FILE} -b "#{filepath}"}.chomp =~ /^Mach-O/
                       }
-                        if true_for_all?(path, arguments) {|filepath,arch|
+                        if true_for_all?(path, arguments,true) {|filepath,arch|
                           %x{lipo -info "#{filepath}"}.chomp =~ /is architecture: #{arch}$/
                         }
                           links=Hash.new
@@ -274,7 +303,7 @@
                     end
                   end
                 end
-              elsif !true_for_all?(path, arguments) {|filepath,arch|
+              elsif !true_for_all?(path, arguments,true) {|filepath,arch|
                 File.directory? filepath
               }
                 # TODO: we have a mix of at least one directory and items that
@@ -283,10 +312,41 @@
             else
               # TODO: a file is not present in all trees. what's wrong?
             end
-          elsif true_for_all?(path,arguments) {|filepath,arch|
+          elsif true_for_all?(path,arguments,true) {|filepath,arch|
             FileTest.symlink? filepath
           }
-            # TODO: dealing with symlinks
+            link_target=%x{
+              #{FILE} -b #{
+                File.join(
+                  arguments[:root],
+                  ARGS[0],path
+                )
+              }
+            }.gsub(
+              /^(broken )?symbolic link to `/, ''
+            ).gsub(
+              /'$/, ''
+            ).chomp
+            if true_for_all?(path,arguments,false) {|filepath,arch|
+              my_link_target=%x{
+                #{FILE} -b #{filepath}
+              }.gsub(
+                /^(broken )?symbolic link to `/, ''
+              ).gsub(
+                /'$/, ''
+              ).chomp
+              my_link_target == link_target
+            }
+              link_output=File.join(arguments[:output],path)
+              if !File.exists? link_output
+                FileUtils.symlink(
+                  link_target,
+                  link_output
+                )
+              end
+            else
+              # ERROR: link targets differ
+            end
           else
             # TODO: dealing with a mix of at least one symlink and items that
             # are not symlinks

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


More information about the macports-changes mailing list