The R Project SVN R

Rev

Rev 29864 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 29864 Rev 30691
Line 24... Line 24...
24
use File::Basename;
24
use File::Basename;
25
use File::Copy;
25
use File::Copy;
26
use File::Find;
26
use File::Find;
27
use File::Path;
27
use File::Path;
28
use Getopt::Long;
28
use Getopt::Long;
-
 
29
use IO::File;
29
use R::Dcf;
30
use R::Dcf;
30
use R::Logfile;
31
use R::Logfile;
31
use R::Rdtools;
32
use R::Rdtools;
32
use R::Utils;
33
use R::Utils;
33
use R::Vars;
34
use R::Vars;
Line 35... Line 36...
35
use Text::Wrap;
36
use Text::Wrap;
36
 
37
 
37
## Don't buffer output.
38
## Don't buffer output.
38
$| = 1;
39
$| = 1;
39
 
40
 
40
my $revision = ' $Revision: 1.188 $ ';
41
my $revision = ' $Revision: 1.193 $ ';
41
my $version;
42
my $version;
42
my $name;
43
my $name;
43
$revision =~ / ([\d\.]*) /;
44
$revision =~ / ([\d\.]*) /;
44
$version = $1;
45
$version = $1;
45
($name = $0) =~ s|.*/||;
46
($name = $0) =~ s|.*/||;
Line 54... Line 55...
54
my $opt_install = 1;
55
my $opt_install = 1;
55
my $opt_vignettes = 1;
56
my $opt_vignettes = 1;
56
 
57
 
57
my $WINDOWS = ($R::Vars::OSTYPE eq "windows");
58
my $WINDOWS = ($R::Vars::OSTYPE eq "windows");
58
 
59
 
59
R::Vars::error("R_HOME", "R_CMD", "R_EXE");
60
R::Vars::error("R_HOME", "R_EXE");
60
 
61
 
61
my @known_options = ("help|h", "version|v", "outdir|o:s", "library|l:s",
62
my @known_options = ("help|h", "version|v", "outdir|o:s", "library|l:s",
62
		    "no-clean", "no-examples", "no-tests", "no-latex",
63
		    "no-clean", "no-examples", "no-tests", "no-latex",
63
		    "use-gct" => \$opt_use_gct, "no-codoc",
64
		    "use-gct" => \$opt_use_gct, "no-codoc",
64
		    "install=s" => \$opt_install, "no-install",
65
		    "install=s" => \$opt_install, "no-install",
Line 133... Line 134...
133
    unlink(<Rtextest$$.*>);
134
    unlink(<Rtextest$$.*>);
134
    chdir($startdir);
135
    chdir($startdir);
135
    $log->close();
136
    $log->close();
136
}
137
}
137
 
138
 
138
## Get the valid keywords for later.
-
 
139
my %standard_keywords = ();
-
 
140
open(KEYWORDS,
-
 
141
     "< " . &file_path(${R::Vars::R_HOME}, "doc", "KEYWORDS.db"))
-
 
142
  or die "Error: cannot open file 'doc/KEYWORDS.db' for reading\n";
-
 
143
while(<KEYWORDS>) {
-
 
144
    if(/^.*\|([^:]*):.*/) {
-
 
145
	$standard_keywords{$1} = 1;
-
 
146
    }
-
 
147
}
-
 
148
close(KEYWORDS);
-
 
149
 
-
 
150
## Get the names of base and recommended packages and stubs for later.
-
 
151
my @R_pkgs_base = ();
-
 
152
my @R_pkgs_recommended = ();
-
 
153
my @R_pkgs_stubs = ();
-
 
154
open(MAKEVARS,
-
 
155
     "< " . &file_path(${R::Vars::R_HOME}, "share", "make", "vars.mk"))
-
 
156
  or die "Error: cannot open file 'share/make/vars.mk' for reading\n";
-
 
157
while(<MAKEVARS>) {
-
 
158
    @R_pkgs_base =
-
 
159
	split(/ +/, $2) if(/^(R_PKGS_BASE *=)(.*)/);
-
 
160
    @R_pkgs_recommended =
-
 
161
	split(/ +/, $2) if(/^(R_PKGS_RECOMMENDED *=)(.*)/);
-
 
162
    @R_pkgs_stubs =
-
 
163
	split(/ +/, $2) if(/^(R_PKGS_STUBS *=)(.*)/);
-
 
164
}
-
 
165
 
-
 
166
## This is the main loop over all packages to be checked.
139
## This is the main loop over all packages to be checked.
167
(scalar(@ARGV) > 0) or die "Error: no packages were specified\n";
140
(scalar(@ARGV) > 0) or die "Error: no packages were specified\n";
168
foreach my $pkg (@ARGV) {
141
foreach my $pkg (@ARGV) {
169
    ## $pkg should be the path to the package (bundle) root source
142
    ## $pkg should be the path to the package (bundle) root source
170
    ## directory, either absolute or relative to $startdir.
143
    ## directory, either absolute or relative to $startdir.
Line 262... Line 235...
262
	    else {
235
	    else {
263
		my $use_install_log =
236
		my $use_install_log =
264
		    (($opt_install =~ /^check/) ||
237
		    (($opt_install =~ /^check/) ||
265
		     $ENV{"R_CHECK_USE_INSTALL_LOG"} ||
238
		     $ENV{"R_CHECK_USE_INSTALL_LOG"} ||
266
		     !(-t STDIN && -t STDOUT));
239
		     !(-t STDIN && -t STDOUT));
-
 
240
		my $INSTALL_opts = "";
-
 
241
		$INSTALL_opts = "--fake" if($opt_install eq "fake");
-
 
242
		my $cmd;
-
 
243
		if($WINDOWS) {
-
 
244
		    $cmd = join(" ",
267
		my $cmd = "${R::Vars::R_CMD} INSTALL -l";
245
				("Rcmd.exe INSTALL -l",
268
		$cmd .= " " . &shell_quote_file_path($library);
246
				 &shell_quote_file_path($library),
-
 
247
				 "$INSTALL_opts",
-
 
248
				 &shell_quote_file_path($pkgdir)));
-
 
249
		} else {
-
 
250
		    $cmd = join(" ",
269
		$cmd .= " --fake" if($opt_install eq "fake");
251
				(&shell_quote_file_path(${R::Vars::R_EXE}),
-
 
252
				 "CMD INSTALL -l",
-
 
253
				 &shell_quote_file_path($library),
-
 
254
				 "$INSTALL_opts",
270
		$cmd .= " " . &shell_quote_file_path($pkgdir);
255
				 &shell_quote_file_path($pkgdir)));
-
 
256
		}
271
		if(!$use_install_log) {
257
		if(!$use_install_log) {
272
		    ## Case A: No redirection of stdout/stderr from
258
		    ## Case A: No redirection of stdout/stderr from
273
		    ## installation.
259
		    ## installation.
274
		    print("\n");
260
		    print("\n");
275
		    if(R_system($cmd)) {
261
		    if(R_system($cmd)) {
Line 491... Line 477...
491
    else {
477
    else {
492
	find(\&find_wrong_names, ".");
478
	find(\&find_wrong_names, ".");
493
    }
479
    }
494
    if(scalar(@bad_files) > 0) {
480
    if(scalar(@bad_files) > 0) {
495
	$log->error();
481
	$log->error();
496
	$log->print("Found the following files with " .
482
	$log->print("Found the following file(s) with " .
497
		    "non-portable file names:\n");
483
		    "non-portable file names:\n");
498
	$log->print("  " . join("\n  ", @bad_files) . "\n");
484
	$log->print("  " . join("\n  ", @bad_files) . "\n");
499
	$log->print(wrap("", "",
485
	$log->print(wrap("", "",
500
			 ("These are not valid file names",
486
			 ("These are not valid file names",
501
			  "on all R platforms.\n",
487
			  "on all R platforms.\n",
Line 503... Line 489...
503
			  "See section 'Package structure'",
489
			  "See section 'Package structure'",
504
			  "in manual 'Writing R Extensions'.\n")));
490
			  "in manual 'Writing R Extensions'.\n")));
505
	exit(1);
491
	exit(1);
506
    }
492
    }
507
 
493
 
-
 
494
    ## next check for name clashes on case-insensitive file systems
-
 
495
    ## (that is on Windows).
-
 
496
    %seen = (); 
-
 
497
    my @duplicated = ();
-
 
498
    sub check_case_names {
-
 
499
	my $file_path = lc($File::Find::name);
-
 
500
	if($seen{$file_path}) {push(@duplicated, $file_path);}
-
 
501
	$seen{$file_path}  = 1;
-
 
502
    }
-
 
503
    if($in_bundle) {
-
 
504
	chdir(dirname($pkgdir)); # more portable than '..'?
-
 
505
	find(\&check_case_names, $pkgname);
-
 
506
	chdir($pkgname);
-
 
507
    }
-
 
508
    else {
-
 
509
	find(\&check_case_names, ".");
-
 
510
    }
-
 
511
    if(scalar(@duplicated) > 0) {
-
 
512
	$log->error();
-
 
513
	$log->print("Found the following file(s) with " .
-
 
514
		    "duplicate lower-cased file names:\n");
-
 
515
	$log->print("  " . join("\n  ", @duplicated) . "\n");
-
 
516
	$log->print(wrap("", "",
-
 
517
			 ("File names must not differ just by case",
-
 
518
			  "to be usable on all R platforms.\n",
-
 
519
			  "Please rename the files and try again.\n",
-
 
520
			  "See section 'Package structure'",
-
 
521
			  "in manual 'Writing R Extensions'.\n")));
-
 
522
	exit(1);
-
 
523
    }
-
 
524
 
508
    $log->result("OK");
525
    $log->result("OK");
509
 
526
 
510
    ## Check for sufficient file permissions (Unix only).
527
    ## Check for sufficient file permissions (Unix only).
511
 
528
 
512
    ## This used to be much more 'aggressive', requiring that dirs and
529
    ## This used to be much more 'aggressive', requiring that dirs and
Line 593... Line 610...
593
	}
610
	}
594
    }
611
    }
595
 
612
 
596
    ## Check DESCRIPTION meta-information.
613
    ## Check DESCRIPTION meta-information.
597
 
614
 
598
    if($in_bundle) {		# join DESCRIPTION and DESCRIPTION.in
-
 
599
	$log->checking("for file 'DESCRIPTION.in'");
-
 
600
        if(-r "DESCRIPTION.in") {
-
 
601
	    my $description_in = new R::Dcf("DESCRIPTION.in");
-
 
602
	    foreach my $key (keys(%$description)) {
-
 
603
		$description_in->{$key} = $description->{$key};
-
 
604
	    }
-
 
605
	    ## From now on use $description_in instead of $description
-
 
606
	    ## in this subroutine.
-
 
607
	    $description = $description_in;
-
 
608
	    $log->result("OK");
-
 
609
	    $log->message("joining DESCRIPTION and DESCRIPTION.in");
-
 
610
	}
-
 
611
	else {
-
 
612
	    $log->result("NO");
-
 
613
	    exit(1);
-
 
614
	}
-
 
615
    }
-
 
616
 
-
 
617
    my @msg_DESCRIPTION
-
 
618
      = ("See the information on DESCRIPTION files",
615
    ## If we just installed the package (via R CMD INSTALL), we already
619
	 "in section 'Creating R packages'",
-
 
620
	 "of the 'Writing R Extensions' manual.\n");
-
 
621
 
-
 
622
    $log->checking("DESCRIPTION meta-information");
616
    ## validated the package DESCRIPTION metadata.  Otherwise, let us be
623
 
-
 
624
    ## Mandatory entries in DESCRIPTION:
-
 
625
    ##   Package, Version, License, Description, Title, Author,
-
 
626
    ##   Maintainer.
617
    ## defensive about this ...
627
 
618
 
628
    foreach my $field (qw(Package Version License Description Title
619
    if(!$opt_install || ($opt_install eq "skip") || $is_base_pkg) {
629
			  Author Maintainer)) {
620
	my ($dfile, $dir);
630
	if(!$description->{$field}) {
621
	if($is_base_pkg) {
631
	    $log->error();
-
 
632
	    $log->print("No DESCRIPTION $field field found.\n");
-
 
633
	    $log->print(wrap("", "", @msg_DESCRIPTION));
622
	    $dfile = "DESCRIPTION.in";
634
	    exit(1);
-
 
635
	}
623
	}
636
    }
-
 
637
 
-
 
638
    if($description->{"Package"} !~ /^[a-z][a-z\d\.]*$/i) {
-
 
639
	$log->error();
624
	elsif(!$in_bundle) {
640
	$log->print("Malformed package name.\n");
-
 
641
	$log->print(wrap("", "", @msg_DESCRIPTION));
625
	    $dfile = "DESCRIPTION";
642
	exit(1);
-
 
643
    }
626
	}
644
    if($description->{"Package"} ne $pkgname) {
-
 
645
	$log->error();
-
 
646
	$log->print("DESCRIPTION Package field differs from dir	name.\n");
-
 
647
	$log->print(wrap("", "", @msg_DESCRIPTION));
-
 
648
	exit(1);
627
	else {
649
    }
-
 
650
    ## check if this is a name clash with an existing or past base package.
628
	    ## Bundles are a bit tricky, as their package (DESCRIPTION)
651
    ## The stub packages are handled specially in library()
629
	    ## metadata come from merging the bundle DESCRIPTION file
652
    if(!$is_base_pkg) {
-
 
653
        my $found = 0;
-
 
654
        foreach my $p (@R_pkgs_base) {
630
	    ## with the package DESCRIPTION.in one.  Hence, we
655
	    if($description->{"Package"} eq $p) {
631
	    ## concatenate these files to a temporary one.
656
		$found = 1;
-
 
657
		break;
-
 
658
	    }
-
 
659
	}
-
 
660
	if($found != 0) {
-
 
661
	    $log->error();
-
 
662
	    $log->print("Invalid package name.\n");
632
	    $log->checking("for file 'DESCRIPTION.in'");
663
	    $log->print("This is the name of a base package.\n");
-
 
664
	    exit(1);
-
 
665
	}
-
 
666
        $found = 0;
-
 
667
        foreach my $p (@R_pkgs_stubs) {
-
 
668
	    if($description->{"Package"} eq $p) {
633
	    if(-r "DESCRIPTION.in") {
669
		$found = 1;
634
		$log->result("OK");
670
		break;
-
 
671
	    }
635
	    }
672
	}
-
 
673
	if($found != 0) {
-
 
674
	    $log->error();
-
 
675
	    $log->print("Invalid package name.\n");
-
 
676
	    $log->print(wrap("", "",
-
 
677
			     ("This name was used for a base package",
-
 
678
			      "and is remapped by library().\n")));
-
 
679
	    exit(1);
636
	    else {
680
	}
-
 
681
    }
-
 
682
 
-
 
683
    if(($description->{"Version"} !~ /^\d+([.-]\d+)+$/)
-
 
684
       && !$is_base_pkg) {
-
 
685
	## Package sources from the R distribution have '@VERSION@' in
-
 
686
	## their 'DESCRIPTION.in' files ...
-
 
687
	$log->error();
-
 
688
	$log->print("Malformed package version.\n");
-
 
689
	$log->print(wrap("", "", @msg_DESCRIPTION));
-
 
690
	exit(1);
-
 
691
    }
-
 
692
 
-
 
693
    if(($description->{"Maintainer"} !~ /^[^<>]*<[^<>@]+@[^<>@]+> *$/) &&
-
 
694
       ($description->{"Maintainer"} !~ /ORPHANED/)) {
-
 
695
	$log->error();
637
		$log->result("NO");
696
	$log->print("Malformed Maintainer field.\n");
-
 
697
	$log->print(wrap("", "", @msg_DESCRIPTION));
-
 
698
	exit(1);
638
		exit(1);
699
    }
-
 
700
 
-
 
701
    ## Optional entries in DESCRIPTION:
-
 
702
    ##   Depends/Suggests, Namespace, Priority.
-
 
703
    ## These must be correct if present.
-
 
704
 
-
 
705
    if($description->{"Depends"} || $description->{"Suggests"}) {
-
 
706
	my @dependencies = split(/\,\s*/, ($description->{"Depends"},
-
 
707
					   $description->{"Suggests"}));
-
 
708
	my @matches;
-
 
709
	my ($is_bad_dep_op, $is_bad_dep_version);
-
 
710
	my ($bad_dep_value, @bad_dep_error);
-
 
711
	foreach my $dep (@dependencies) {
-
 
712
	    @matches =
-
 
713
	      ($dep =~ /^\s*([\w\.]+)(\s*\(([^) ]+)\s+([^) ]+)\))?\s*$/);
-
 
714
            ## The entry is malformed if there is no match, or there is
-
 
715
            ## a match but the dep_op is different from '<=' or '>', or
-
 
716
	    ## the dep_version does not only consist of digits, '.' or
-
 
717
	    ## '-'.
-
 
718
	    $is_bad_dep_op =
-
 
719
	      (($matches[2] ne "<=") && ($matches[2] ne ">="));
-
 
720
	    $is_bad_dep_version = ($matches[3] =~ /[^\d\.\-]/);
-
 
721
	    if(!($matches[0])
-
 
722
	       || ($matches[1]
-
 
723
		   && ($is_bad_dep_op || $is_bad_dep_version))) {
-
 
724
		$bad_dep_entry = $dep;
-
 
725
		if(!($matches[0])) {
-
 
726
		    @bad_dep_error =
-
 
727
		      ("Entries must be names of packages, optionally",
-
 
728
		       "followed by '<=' or '>=', white space, and a",
-
 
729
		       "valid version number in parentheses.\n");
-
 
730
		}
-
 
731
		elsif($is_bad_dep_op) {
-
 
732
		    @bad_dep_error =
-
 
733
			("Infeasible comparison operator '$matches[2]'.\n",
-
 
734
			 "Only operators '<=' and '>=' are possible.\n");
-
 
735
		}
-
 
736
		elsif($is_bad_dep_version) {
-
 
737
		    @bad_dep_error =
-
 
738
			("Infeasible version number '$matches[3]'.\n",
-
 
739
			 "Version numbers must only contain digits,",
-
 
740
			 "'.' or '-'.\n");
-
 
741
		}
-
 
742
		break;
-
 
743
	    }
639
	    }
744
	}
-
 
-
 
640
	    ## Checking metadata currently also includes verifying that
-
 
641
	    ## the package name and "directory name" are the same.
-
 
642
	    $dir = &file_path(${R::Vars::TMPDIR}, "check$$");
745
	if($bad_dep_entry) {
643
	    mkdir($dir, 0755)
-
 
644
		or die ("Error: cannot create directory '$dir'\n");
-
 
645
	    $dir = &file_path($dir, $pkgname);
746
	    $log->error();
646
	    mkdir($dir, 0755)
747
	    $log->print("Malformed Depends or Suggests field.\n");
647
		or die ("Error: cannot create directory '$dir'\n");
-
 
648
	    $dfile = &file_path($dir, "DESCRIPTION");
-
 
649
	    my $fh = new IO::File($dfile, "w")
748
	    $log->print("Offending entry is: '$bad_dep_entry'.\n");
650
		or die "Error: cannot open file '$dpath' for writing\n";
749
	    $log->print(wrap("", "", @bad_dep_error));
651
	    my @lines = (&read_lines(&file_path(dirname($pkgdir),
-
 
652
						"DESCRIPTION")),
-
 
653
			 &read_lines("DESCRIPTION.in"));
-
 
654
	    @lines = grep(!/^\s*$/, @lines); # Remove blank lines.
750
	    $log->print(wrap("", "", @msg_DESCRIPTION));
655
	    $fh->print(join("\n", @lines), "\n");
751
	    exit(1);
656
	    $fh->close();
752
	}
657
	}
753
    }
-
 
754
 
658
 
755
    if($description->{"Namespace"}) {
659
	$log->checking("DESCRIPTION meta-information");
-
 
660
    
756
	if($description->{"Namespace"} ne $description->{"Package"}) {
661
	my $Rcmd = "tools:::.check_package_description(\"$dfile\")";
-
 
662
	my @out = R_runR($Rcmd, "${R_opts} --quiet",
-
 
663
			 "R_DEFAULT_PACKAGES='tools'");
-
 
664
	rmtree(dirname($dir)) if($in_bundle);
-
 
665
	@out = grep(!/^\>/, @out);
-
 
666
	if(scalar(@out) > 0) {
757
	    $log->error();
667
	    $log->error();
758
	    $log->print("Namespace and Package fields differ.\n");
-
 
759
	    $log->print(wrap("", "", @msg_DESCRIPTION));
668
	    $log->print(join("\n", @out) . "\n");
760
	    exit(1);
669
	    exit(1);
761
	}
670
	}
-
 
671
	
-
 
672
	$log->result("OK");
762
    }
673
    }
763
 
-
 
764
    if($description->{"Priority"}) {
-
 
765
	if($description->{"Priority"}
-
 
766
	   =~ /^(base|recommended|defunct-base)/i) {
-
 
767
	    ## Simplify matters by treating high priority packages and
-
 
768
	    ## base stubs together.
-
 
769
	    my $found = 0;
-
 
770
	    foreach my $p (@R_pkgs_base,
-
 
771
			   @R_pkgs_recommended,
-
 
772
			   @R_pkgs_stubs) {
-
 
773
		if($description->{"Package"} eq $p) {
-
 
774
		    $found = 1;
-
 
775
		    break;
-
 
776
		}
-
 
777
	    }
-
 
778
	    if(!$found) {
-
 
779
		$log->error();
-
 
780
		$log->print("Invalid Priority field.\n");
-
 
781
		$log->print(wrap("", "",
-
 
782
				 ("Packages with priorities 'base' or",
-
 
783
				  "'recommended' or 'defunct-base'",
-
 
784
				  "must already be known to R.\n")));
-
 
785
		$log->print(wrap("", "", @msg_DESCRIPTION));
-
 
786
		exit(1);
-
 
787
	    }
-
 
788
	}
-
 
789
    }
674
    
790
 
-
 
791
    $log->result("OK");
-
 
792
 
-
 
793
    ## Check package dependencies.
675
    ## Check package dependencies.
794
 
676
 
795
    ## Try figuring out whether the package dependencies can be resolved
677
    ## Try figuring out whether the package dependencies can be resolved
796
    ## at run time.  Ideally, the installation mechanism would do this,
678
    ## at run time.  Ideally, the installation mechanism would do this,
797
    ## and we also do not check versions ... also see whether vignette
679
    ## and we also do not check versions ... also see whether vignette
Line 864... Line 746...
864
	    $any++;
746
	    $any++;
865
	    $log->print("Empty or missing file '$index'.\n");
747
	    $log->print("Empty or missing file '$index'.\n");
866
	}
748
	}
867
	else {
749
	else {
868
	    my $dir = "demo";
750
	    my $dir = "demo";
869
	    my $Rcmd = "tools:::.check_demo_index(\"$dir\")\n";
751
	    my $Rcmd = "options(warn=1)\ntools:::.check_demo_index(\"$dir\")\n";
870
	    my @out = R_runR($Rcmd, "${R_opts} --quiet",
752
	    my @out = R_runR($Rcmd, "${R_opts} --quiet",
871
			     "R_DEFAULT_PACKAGES=tools");
753
			     "R_DEFAULT_PACKAGES=tools");
872
	    @out = grep(!/^\>/, @out);
754
	    @out = grep(!/^\>/, @out);
873
	    if(scalar(@out) > 0) {
755
	    if(scalar(@out) > 0) {
874
		$log->warning() unless($any);
756
		$log->warning() unless($any);
Line 879... Line 761...
879
    }
761
    }
880
    if((-d &file_path("inst", "doc"))
762
    if((-d &file_path("inst", "doc"))
881
       && &list_files_with_type(&file_path("inst", "doc"),
763
       && &list_files_with_type(&file_path("inst", "doc"),
882
				"vignette")) {
764
				"vignette")) {
883
	my $dir = &file_path("inst", "doc");
765
	my $dir = &file_path("inst", "doc");
884
	my $Rcmd = "tools:::.check_vignette_index(\"$dir\")\n";
766
	my $Rcmd = "options(warn=1)\ntools:::.check_vignette_index(\"$dir\")\n";
885
	my @out = R_runR($Rcmd, "${R_opts} --quiet",
767
	my @out = R_runR($Rcmd, "${R_opts} --quiet",
886
			 "R_DEFAULT_PACKAGES=tools");
768
			 "R_DEFAULT_PACKAGES=tools");
887
	@out = grep(!/^\>/, @out);
769
	@out = grep(!/^\>/, @out);
888
	if(scalar(@out) > 0) {
770
	if(scalar(@out) > 0) {
889
	    $log->warning() unless($any);
771
	    $log->warning() unless($any);
Line 1057... Line 939...
1057
 
939
 
1058
	my @msg_S3_methods =
940
	my @msg_S3_methods =
1059
	  ("See section 'Generic functions and methods'",
941
	  ("See section 'Generic functions and methods'",
1060
	   "of the 'Writing R Extensions' manual.\n");
942
	   "of the 'Writing R Extensions' manual.\n");
1061
 
943
 
1062
	my $Rcmd;
944
	my $Rcmd = "options(warn=1)\n";
1063
	if($opt_install) {
945
	if($opt_install) {
1064
	    $Rcmd .= "checkS3methods(package = \"${pkgname}\")\n";
946
	    $Rcmd .= "checkS3methods(package = \"${pkgname}\")\n";
1065
	}
947
	}
1066
        else {
948
        else {
1067
	    $Rcmd .= "checkS3methods(dir = \"${pkgdir}\")\n";
949
	    $Rcmd .= "checkS3methods(dir = \"${pkgdir}\")\n";
Line 1082... Line 964...
1082
 
964
 
1083
    ## Check whether replacement functions have their final argument
965
    ## Check whether replacement functions have their final argument
1084
    ## named 'value'.
966
    ## named 'value'.
1085
 
967
 
1086
    if(-d "R") {
968
    if(-d "R") {
1087
	$log->checking("for replacement functions with final arg not " .
969
	$log->checking("replacement functions");
1088
		       "named 'value'");
-
 
1089
 
970
 
1090
	my @msg_replace_funs =
971
	my @msg_replace_funs =
1091
	  ("In R, the argument of a replacement function",
972
	  ("In R, the argument of a replacement function",
1092
	   "which corresponds to the right hand side",
973
	   "which corresponds to the right hand side",
1093
	   "must be named 'value'.");
974
	   "must be named 'value'.\n");
1094
 
975
 
1095
	my $Rcmd;
976
	my $Rcmd = "options(warn=1)\n";
1096
	if($opt_install) {
977
	if($opt_install) {
1097
	    $Rcmd .= "checkReplaceFuns(package = \"${pkgname}\")\n";
978
	    $Rcmd .= "checkReplaceFuns(package = \"${pkgname}\")\n";
1098
	}
979
	}
1099
	else {
980
	else {
1100
	    $Rcmd .= "checkReplaceFuns(dir = \"${pkgdir}\")\n";
981
	    $Rcmd .= "checkReplaceFuns(dir = \"${pkgdir}\")\n";
Line 1125... Line 1006...
1125
 
1006
 
1126
	my @msg_ff_calls =
1007
	my @msg_ff_calls =
1127
	  ("See section 'System and foreign language interfaces'",
1008
	  ("See section 'System and foreign language interfaces'",
1128
	   "of the 'Writing R Extensions' manual.\n");
1009
	   "of the 'Writing R Extensions' manual.\n");
1129
 
1010
 
1130
	my $Rcmd;
1011
	my $Rcmd = "options(warn=1)\n";
1131
	if($opt_install) {
1012
	if($opt_install) {
1132
	    $Rcmd .= "checkFF(package = \"${pkgname}\")\n";
1013
	    $Rcmd .= "checkFF(package = \"${pkgname}\")\n";
1133
	}
1014
	}
1134
        else {
1015
        else {
1135
	    $Rcmd .= "checkFF(dir = \"${pkgdir}\")\n";
1016
	    $Rcmd .= "checkFF(dir = \"${pkgdir}\")\n";
Line 1155... Line 1036...
1155
	 "in manual 'Writing R Extensions'.\n");
1036
	 "in manual 'Writing R Extensions'.\n");
1156
 
1037
 
1157
    if(-d "man") {
1038
    if(-d "man") {
1158
	$log->checking("Rd files");
1039
	$log->checking("Rd files");
1159
 
1040
 
1160
	my $Rcmd = "tools:::check_Rd_files_in_man_dir(\"man\")\n";
1041
	my $Rcmd = "options(warn=1)\ntools:::check_Rd_files_in_man_dir(\"man\")\n";
1161
	my @out = R_runR($Rcmd, "${R_opts} --quiet",
1042
	my @out = R_runR($Rcmd, "${R_opts} --quiet",
1162
			 "R_DEFAULT_PACKAGES=tools");
1043
			 "R_DEFAULT_PACKAGES=tools");
1163
	@out = grep(!/^\>/, @out);
1044
	@out = grep(!/^\>/, @out);
1164
	if(scalar(@out) > 0) {
1045
	if(scalar(@out) > 0) {
1165
	    ## Output may indicate warnings or errors ...
1046
	    ## Output may indicate warnings or errors ...
Line 1184... Line 1065...
1184
    ## Check for missing documentation entries.
1065
    ## Check for missing documentation entries.
1185
 
1066
 
1186
    if(((-d "R") || (-d "data")) && (-d "man")) {
1067
    if(((-d "R") || (-d "data")) && (-d "man")) {
1187
	$log->checking("for missing documentation entries");
1068
	$log->checking("for missing documentation entries");
1188
 
1069
 
1189
	my $Rcmd;
1070
	my $Rcmd= "options(warn=1)\n";
1190
	if($opt_install) {
1071
	if($opt_install) {
1191
	    $Rcmd .= "undoc(package = \"${pkgname}\")\n";
1072
	    $Rcmd .= "undoc(package = \"${pkgname}\")\n";
1192
	}
1073
	}
1193
	else {
1074
	else {
1194
	    $Rcmd .= "undoc(dir = \"${pkgdir}\")\n";
1075
	    $Rcmd .= "undoc(dir = \"${pkgdir}\")\n";
Line 1227... Line 1108...
1227
 
1108
 
1228
	my $any = 0;
1109
	my $any = 0;
1229
 
1110
 
1230
	## Check for code/documentation mismatches in functions.
1111
	## Check for code/documentation mismatches in functions.
1231
	if(-d "R") {
1112
	if(-d "R") {
1232
	    my $Rcmd;
1113
	    my $Rcmd = "options(warn=1)\n";
1233
	    if($opt_install) {
1114
	    if($opt_install) {
1234
		$Rcmd .= "codoc(package = \"${pkgname}\")\n";
1115
		$Rcmd .= "codoc(package = \"${pkgname}\")\n";
1235
	    }
1116
	    }
1236
	    else {
1117
	    else {
1237
		$Rcmd .= "codoc(dir = \"${pkgdir}\")\n";
1118
		$Rcmd .= "codoc(dir = \"${pkgdir}\")\n";
Line 1247... Line 1128...
1247
	    }
1128
	    }
1248
	}
1129
	}
1249
 
1130
 
1250
	## Check for code/documentation mismatches in data sets.
1131
	## Check for code/documentation mismatches in data sets.
1251
	if($opt_install) {
1132
	if($opt_install) {
1252
	    my $Rcmd = "codocData(package = \"${pkgname}\")\n";
1133
	    my $Rcmd = "options(warn=1)\ncodocData(package = \"${pkgname}\")\n";
1253
	    my @out = R_runR($Rcmd, "${R_opts} --quiet",
1134
	    my @out = R_runR($Rcmd, "${R_opts} --quiet",
1254
			     "R_DEFAULT_PACKAGES='utils,graphics,stats,tools'");
1135
			     "R_DEFAULT_PACKAGES='utils,graphics,stats,tools'");
1255
	    @out = grep(!/^\>/, @out);
1136
	    @out = grep(!/^\>/, @out);
1256
	    if(scalar(@out) > 0) {
1137
	    if(scalar(@out) > 0) {
1257
		$log->warning() unless($any);
1138
		$log->warning() unless($any);
Line 1260... Line 1141...
1260
	    }
1141
	    }
1261
	}
1142
	}
1262
 
1143
 
1263
	## Check for code/documentation mismatches in S4 classes.
1144
	## Check for code/documentation mismatches in S4 classes.
1264
	if($opt_install && (-d "R")) {
1145
	if($opt_install && (-d "R")) {
1265
	    my $Rcmd = "codocClasses(package = \"${pkgname}\")\n";
1146
	    my $Rcmd = "options(warn=1)\ncodocClasses(package = \"${pkgname}\")\n";
1266
	    my @out = R_runR($Rcmd, "${R_opts} --quiet",
1147
	    my @out = R_runR($Rcmd, "${R_opts} --quiet",
1267
			     "R_DEFAULT_PACKAGES='utils,graphics,stats,tools'");
1148
			     "R_DEFAULT_PACKAGES='utils,graphics,stats,tools'");
1268
	    @out = grep(!/^\>/, @out);
1149
	    @out = grep(!/^\>/, @out);
1269
	    if(scalar(@out) > 0) {
1150
	    if(scalar(@out) > 0) {
1270
		$log->warning() unless($any);
1151
		$log->warning() unless($any);
Line 1285... Line 1166...
1285
	$log->checking("Rd \\usage sections");
1166
	$log->checking("Rd \\usage sections");
1286
 
1167
 
1287
	my @msg_doc_files =
1168
	my @msg_doc_files =
1288
	  ("Functions with \\usage entries",
1169
	  ("Functions with \\usage entries",
1289
	   "need to have the appropriate \\alias entries,",
1170
	   "need to have the appropriate \\alias entries,",
1290
	   "and all their arguments documented.");
1171
	   "and all their arguments documented.\n");
1291
 
1172
 
1292
	my $Rcmd;
1173
	my $Rcmd = "options(warn=1)\n";
1293
	if($opt_install) {
1174
	if($opt_install) {
1294
	    $Rcmd .= "checkDocFiles(package = \"${pkgname}\")\n";
1175
	    $Rcmd .= "checkDocFiles(package = \"${pkgname}\")\n";
1295
	}
1176
	}
1296
	else {
1177
	else {
1297
	    $Rcmd .= "checkDocFiles(dir = \"${pkgdir}\")\n";
1178
	    $Rcmd .= "checkDocFiles(dir = \"${pkgdir}\")\n";
Line 1380... Line 1261...
1380
            ## We've forced R_HOME and Rexdir to have no spaces already.
1261
            ## We've forced R_HOME and Rexdir to have no spaces already.
1381
            $cmd = "perl ${R::Vars::R_HOME}/bin/massage-Examples ".
1262
            $cmd = "perl ${R::Vars::R_HOME}/bin/massage-Examples ".
1382
  		     "${pkgname} ${Rexdir} ".
1263
  		     "${pkgname} ${Rexdir} ".
1383
  		     "> ${pkgname}-Ex.R";
1264
  		     "> ${pkgname}-Ex.R";
1384
        } else {
1265
        } else {
1385
	    $cmd = join(" ",
1266
	    $cmd =
-
 
1267
		join(" ",
-
 
1268
		     (&shell_quote_file_path(${R::Vars::R_EXE}),
1386
			("${R::Vars::R_CMD} perl",
1269
		      "CMD perl",
1387
			 &file_path(${R::Vars::R_HOME}, "share", "perl",
1270
		      &shell_quote_file_path(&file_path(${R::Vars::R_HOME},
-
 
1271
							"share", "perl",
1388
				    "massage-Examples.pl"),
1272
							"massage-Examples.pl")),
1389
			 "${pkgname}",
1273
		      "${pkgname}",
1390
			 &shell_quote_file_path(${Rexdir}),
1274
		      &shell_quote_file_path(${Rexdir}),
1391
			 "> ${pkgname}-Ex.R"));
1275
		      "> ${pkgname}-Ex.R"));
1392
        }
1276
        }
1393
 
1277
 
1394
 	if(R_system($cmd)) {
1278
 	if(R_system($cmd)) {
1395
  	    $log->error();
1279
  	    $log->error();
1396
	    $log->print("Running massage-Examples to create " .
1280
	    $log->print("Running massage-Examples to create " .
Line 1403... Line 1287...
1403
 
1287
 
1404
	$log->result("OK");
1288
	$log->result("OK");
1405
	$log->checking("examples");
1289
	$log->checking("examples");
1406
 
1290
 
1407
	if($opt_use_gct) {
1291
	if($opt_use_gct) {
-
 
1292
            $cmd = join(" ",
1408
            $cmd = "(echo 'gctorture(TRUE)'; cat ${pkgname}-Ex.R) " .
1293
			("(echo 'gctorture(TRUE)';",
-
 
1294
			 "cat ${pkgname}-Ex.R) |",
-
 
1295
			 &shell_quote_file_path(${R::Vars::R_EXE}),
-
 
1296
			 "${R_opts}",
1409
	      "| ${R::Vars::R_EXE} ${R_opts} > ${pkgname}-Ex.Rout 2>&1";
1297
			 "> ${pkgname}-Ex.Rout 2>&1"));
1410
	}
1298
	}
1411
	else {
1299
	else {
1412
            $cmd = "${R::Vars::R_EXE} ${R_opts} " .
1300
            $cmd = join(" ",
-
 
1301
			(&shell_quote_file_path(${R::Vars::R_EXE}),
-
 
1302
			 "${R_opts}",
-
 
1303
			 "< ${pkgname}-Ex.R",
1413
	      "< ${pkgname}-Ex.R > ${pkgname}-Ex.Rout 2>&1";
1304
			 "> ${pkgname}-Ex.Rout 2>&1"));
1414
	}
1305
	}
1415
	if(R_system($cmd)) {
1306
	if(R_system($cmd)) {
1416
	    $log->error();
1307
	    $log->error();
1417
	    $log->print("Running examples in ${pkgname}-Ex.R failed.\n");
1308
	    $log->print("Running examples in ${pkgname}-Ex.R failed.\n");
1418
	    ## Try to spot the offending example right away.
1309
	    ## Try to spot the offending example right away.
Line 1468... Line 1359...
1468
        }
1359
        }
1469
        chdir($testdir);
1360
        chdir($testdir);
1470
	foreach my $file (&list_files($testsrcdir)) {
1361
	foreach my $file (&list_files($testsrcdir)) {
1471
	    copy($file, basename($file));
1362
	    copy($file, basename($file));
1472
	}
1363
	}
-
 
1364
        my $makefiles = "-f " .
1473
        my $makefiles = "-f " . &file_path(${R::Vars::R_HOME},
1365
	    &shell_quote_file_path(&file_path(${R::Vars::R_HOME},
1474
					   "share", "make",
1366
					      "share", "make",
1475
					   "tests.mk");
1367
					      "tests.mk"));
1476
        if($WINDOWS) {
1368
        if($WINDOWS) {
1477
            $makefiles = "-f ${R::Vars::R_HOME}/share/make/wintests.mk";}
1369
            $makefiles = "-f ${R::Vars::R_HOME}/share/make/wintests.mk";}
1478
        my $makevars = "";
1370
        my $makevars = "";
1479
        if($WINDOWS && (-r "$testsrcdir/Makefile.win")) {
1371
        if($WINDOWS && (-r "$testsrcdir/Makefile.win")) {
1480
            $makefiles .= " -f $testsrcdir/Makefile.win";
1372
            $makefiles .= " -f $testsrcdir/Makefile.win";
Line 1553... Line 1445...
1553
 
1445
 
1554
	## Can we run the code in the vignettes?
1446
	## Can we run the code in the vignettes?
1555
	if($opt_vignettes) {
1447
	if($opt_vignettes) {
1556
	    ## Should checking the vignettes assume the system default
1448
	    ## Should checking the vignettes assume the system default
1557
	    ## packages, or just base?
1449
	    ## packages, or just base?
1558
	    my $Rcmd = "library(tools)\n";
1450
	    my $Rcmd = "options(warn=1)\nlibrary(tools)\n";
1559
            ## A base package does not get installed during check.
1451
            ## A base package does not get installed during check.
1560
	    if(!$is_base_pkg && $opt_install) {
1452
	    if(!$is_base_pkg && $opt_install) {
1561
		$Rcmd .= "checkVignettes(package = \"${pkgname}\", " .
1453
		$Rcmd .= "checkVignettes(package = \"${pkgname}\", " .
1562
		         "lib.loc = \"${library}\", " .
1454
		         "lib.loc = \"${library}\", " .
1563
		         "workdir = \"src\")\n";
1455
		         "workdir = \"src\")\n";
Line 1647... Line 1539...
1647
	    }
1539
	    }
1648
	}
1540
	}
1649
	else {
1541
	else {
1650
	    if($HAVE_LATEX) {
1542
	    if($HAVE_LATEX) {
1651
		$log->checking("DVI version of manual");
1543
		$log->checking("DVI version of manual");
-
 
1544
		my $cmd;
-
 
1545
		if($WINDOWS) {
-
 
1546
		    $cmd = join(" ",
-
 
1547
				("Rcmd.exe Rd2dvi --batch --no-preview",
-
 
1548
				 "-o ${pkgname}-manual.dvi >/dev/null 2>&1",
-
 
1549
				 "$pkgdir"));
-
 
1550
		} else {
-
 
1551
		    $cmd = join(" ",
-
 
1552
				(&shell_quote_file_path("${R::Vars::R_EXE}"),
1652
		my $cmd = "${R::Vars::R_CMD} Rd2dvi --batch --no-preview";
1553
				 "CMD Rd2dvi --batch --no-preview",
1653
		$cmd .= " -o ${pkgname}-manual.dvi >/dev/null 2>&1";
1554
				 "-o ${pkgname}-manual.dvi >/dev/null 2>&1",
1654
		$cmd .= " $pkgdir";
1555
				 "$pkgdir"));
-
 
1556
		}
1655
		if(R_system($cmd)) {
1557
		if(R_system($cmd)) {
1656
		    $log->error();
1558
		    $log->error();
1657
		    $log->print("LaTeX errors when creating DVI version.\n");
1559
		    $log->print("LaTeX errors when creating DVI version.\n");
1658
		    $log->print("This typically indicates Rd problems.\n");
1560
		    $log->print("This typically indicates Rd problems.\n");
1659
		    exit(1);
1561
		    exit(1);
Line 1672... Line 1574...
1672
Check R packages from package sources in the directories specified by
1574
Check R packages from package sources in the directories specified by
1673
pkgdirs.  A variety of diagnostic checks on directory structure, index
1575
pkgdirs.  A variety of diagnostic checks on directory structure, index
1674
and control files are performed.  The package is installed into the log
1576
and control files are performed.  The package is installed into the log
1675
directory (which includes the translation of all Rd files into several
1577
directory (which includes the translation of all Rd files into several
1676
formats), and the Rd files are tested by LaTeX (if available).  All
1578
formats), and the Rd files are tested by LaTeX (if available).  All
1677
examples and tests provided by the package are tested if they run
1579
examples and tests provided by the package are tested to see if they run
1678
successfully.
1580
successfully.
1679
 
1581
 
1680
Options:
1582
Options:
1681
  -h, --help            print short help message and exit
1583
  -h, --help            print short help message and exit
1682
  -v, --version         print version info and exit
1584
  -v, --version         print version info and exit