[csw-devel] SF.net SVN: gar:[19637] csw/mgar/gar/v2/bin/pathfilter

dmichelsen at users.sourceforge.net dmichelsen at users.sourceforge.net
Sun Nov 11 01:00:47 CET 2012


Revision: 19637
          http://gar.svn.sourceforge.net/gar/?rev=19637&view=rev
Author:   dmichelsen
Date:     2012-11-11 00:00:46 +0000 (Sun, 11 Nov 2012)
Log Message:
-----------
mGAR v2: Fix isaexec hardlinks

Modified Paths:
--------------
    csw/mgar/gar/v2/bin/pathfilter

Modified: csw/mgar/gar/v2/bin/pathfilter
===================================================================
--- csw/mgar/gar/v2/bin/pathfilter	2012-11-10 23:47:50 UTC (rev 19636)
+++ csw/mgar/gar/v2/bin/pathfilter	2012-11-11 00:00:46 UTC (rev 19637)
@@ -114,20 +114,50 @@
 }
 
 # Process isaexec substitutions
-# Usage: -e /opt/csw/bin/mytool=/opt/csw/bin/sparcv8/mytool
-#   f none /opt/csw/bin/mytool 0755 root bin
+# -e /opt/csw/bin/foo=/opt/csw/bin/sparcv8/foo
+#   f none /opt/csw/bin/foo 0755 root bin
 # ->
-#   l none /opt/csw/bin/mytool=/opt/csw/bin/isaexec
-#   f none /opt/csw/bin/sparcv8/mytool=/opt/csw/bin/mytool
+#   l none /opt/csw/bin/foo=/opt/csw/bin/isaexec
+#   f none /opt/csw/bin/sparcv8/foo=/opt/csw/bin/foo
+#
+# --
+#
+# -e /opt/csw/bin/foo=/opt/csw/bin/sparcv8/foo
+# -e /opt/csw/bin/bar=/opt/csw/bin/sparcv8/bar
+#   f none /opt/csw/bin/foo 0755 root bin			SAME
+#   l none /opt/csw/bin/bar=/opt/csw/bin/foo 0755 root bin
+# ->
+#   l none /opt/csw/bin/foo=/opt/csw/bin/isaexec		SAME
+#   f none /opt/csw/bin/sparcv8/foo=/opt/csw/bin/foo		SAME
+#   l none /opt/csw/bin/bar=/opt/csw/bin/isaexec
+#   l none /opt/csw/bin/sparcv8/bar=/opt/csw/bin/sparcv8/foo
+#
+
+my %isaexec_map;
 foreach my $e (@isaexec) {
   my ($isaexec_path, $new_path) = split( /=/, $e );
+  $isaexec_map{$isaexec_path} = $new_path;
+}
 
+foreach my $e (@isaexec) {
+  my ($isaexec_path, $new_path) = split( /=/, $e );
+
   # Don't do isaexec replacement if the path has not been selected.
   next if( !exists $p{$isaexec_path} );
 
   $p{$new_path} = [ @{$p{$isaexec_path}} ];
-  $p{$new_path}->[2] = $new_path . '=' . $isaexec_path;
-  $p{$isaexec_path}->[0] = 'l';
+
+  # If the thing we try to isaexec is a symlink itself we need to replace the target also
+  if( $p{$isaexec_path}->[0] eq 'l' ) {
+    # The file to replaced by isaexec is already a hardlink, remove the target
+    my ($target) = ($p{$isaexec_path}->[2] =~ /=(.*)/);
+    $p{$isaexec_path}->[2] =~ s/=.*//;
+    $p{$new_path}->[2] = $new_path . '=' . (exists $isaexec_map{$target} ? $isaexec_map{$target} : $isaexec_path);
+  } else {
+    # Make it a hardlink
+    $p{$isaexec_path}->[0] = 'l';
+    $p{$new_path}->[2] = $new_path . '=' . $isaexec_path;
+  }
   $p{$isaexec_path}->[2] .= '=/opt/csw/bin/isaexec';
 }
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list