[Rd] patch: allow R CMD build exclude patterns to match symlinks

From: Michael Lawrence <lawremi_at_iastate.edu>
Date: Tue, 2 Oct 2007 09:34:07 -0500


The following is a patch (svn diff) for the R CMD build script that calculates exclude patterns after the tar/untar step rather than before. The perl find() function, used in the calculation of the exclude patterns, ignores symlinks, which meant that directory symlinks were not considered for exclusion. Since the tar/untar step resolves (copies) symlinks, this works around that limitation.

Michael

Index: src/scripts/build.in


+ chdir(dirname($pkgdir));
+ my $filename = "${intname}_" . $description->{"Version"} . ".tar";
+ my $filepath = &file_path($startdir, $filename);
+ R_system(join(" ",
+ ("$tar chf",
+ &shell_quote_file_path($filepath),
+ "$pkgname")));
+ my $tmpdir = R_tempfile("Rbuild");
+ rmtree($tmpdir) if(-d $tmpdir);
+ mkdir("$tmpdir", 0755)
+ or die "Error: cannot create directory '$tmpdir'\n";
+ chdir($tmpdir);
+ ## was xhf, but there are no symbolic links here and that is invalid
+ ## on FreeBSD, see

http://www.freebsd.org/cgi/man.cgi?query=tar&apropos=0&sektion=0&manpath=FreeBSD+5.4-RELEASE+and+Ports&format=html
+ R_system(join(" ",
+ ("$tar xf",
+ &shell_quote_file_path($filepath))));
+

     my $exclude = R_tempfile("Rbuild-exclude");
     open(EXCLUDE, "> $exclude")
        or die "Error: cannot open file '$exclude' for writing\n";
@@ -226,27 +244,9 @@
            }
        }
     }
-    chdir(dirname($pkgdir));
     find(\&find_exclude_files, "$pkgname");
     close(EXCLUDE);

-    my $filename = "${intname}_" . $description->{"Version"} . ".tar";
-    my $filepath = &file_path($startdir, $filename);
-    R_system(join(" ",
-                 ("$tar chf",
-                  &shell_quote_file_path($filepath),
-                  "$pkgname")));
-    my $tmpdir = R_tempfile("Rbuild");
-    rmtree($tmpdir) if(-d $tmpdir);
-    mkdir("$tmpdir", 0755)
-       or die "Error: cannot create directory '$tmpdir'\n";
-    chdir($tmpdir);

- ## was xhf, but there are no symbolic links here and that is invalid - ## on FreeBSD, see
http://www.freebsd.org/cgi/man.cgi?query=tar&apropos=0&sektion=0&manpath=FreeBSD+5.4-RELEASE+and+Ports&format=html
-    R_system(join(" ",
-                 ("$tar xf",
-                  &shell_quote_file_path($filepath))));
-
     ## Remove exclude files.
     open(EXCLUDE, "< $exclude");
     while(<EXCLUDE>) {

	[[alternative HTML version deleted]]

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 02 Oct 2007 - 14:37:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 25 Oct 2007 - 11:37:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.