[26676] users/pipping/merge.rb

source_changes at macosforge.org source_changes at macosforge.org
Mon Jul 2 23:45:45 PDT 2007


Revision: 26676
          http://trac.macosforge.org/projects/macports/changeset/26676
Author:   pipping at macports.org
Date:     2007-07-02 23:45:44 -0700 (Mon, 02 Jul 2007)

Log Message:
-----------
require Pathname (from the Standard Library) to handle symlinks (*huge* performance boost)
minor changes to dryrun and force behavior

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

Modified: users/pipping/merge.rb
===================================================================
--- users/pipping/merge.rb	2007-07-03 05:29:13 UTC (rev 26675)
+++ users/pipping/merge.rb	2007-07-03 06:45:44 UTC (rev 26676)
@@ -23,6 +23,7 @@
 require 'fileutils'
 require 'find'
 require 'optparse'
+require 'pathname'
 require 'set'
 
 ###
@@ -122,9 +123,9 @@
     FileUtils.cp(
       origin,
       target,
-      :preserve => !args[:force],
-      :verbose => args[:verbose],
-      :noop => args [:dry_run]
+      :noop => args[:dry_run],
+      :preserve => true,
+      :verbose => args[:verbose]
     )
   end
 end
@@ -176,8 +177,8 @@
           unless File.exist? my_dir
             FileUtils.mkdir_p(
               my_dir,
-              :verbose => arguments[:verbose],
-              :noop => arguments[:dry_run]
+              :noop => arguments[:dry_run],
+              :verbose => arguments[:verbose]
             )
           end
           if true_for_all?(path,arguments,true) {|filepath,arch|
@@ -292,7 +293,7 @@
                           }
                           lipo(path,ARGS,arguments)
                         else
-                          # ERROR: processing universal binary or wrong arch
+                          raise 'processing universal binary or wrong architecture'
                         end
                       else
                         # ERROR: mixed filetypes
@@ -315,33 +316,23 @@
           elsif true_for_all?(path,arguments,true) {|filepath,arch|
             FileTest.symlink? filepath
           }
-            link_target=%x{
-              #{FILE} -b #{
-                File.join(
-                  arguments[:root],
-                  ARGS[0],path
-                )
-              }
-            }.gsub(
-              /^(broken )?symbolic link to `/, ''
-            ).gsub(
-              /'$/, ''
-            ).chomp
+            link_target = Pathname.new(
+              File.join( arguments[:root], ARGS[0],path)
+            ).readlink
             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 = Pathname.new(
+                File.join( arguments[:root], arch, path)
+              ).readlink
               my_link_target == link_target
             }
               link_output=File.join(arguments[:output],path)
-              if !File.exists? link_output
+              if !File.exists? link_output or arguments[:force]
                 FileUtils.symlink(
                   link_target,
-                  link_output
+                  link_output, 
+                  :force => arguments[:force],
+                  :verbose => arguments[:verbose],
+                  :noop => arguments [:dry_run]
                 )
               end
             else

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


More information about the macports-changes mailing list