#-*- perl -*- # Copyright (C) 2000 R Development Core Team # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # A copy of the GNU General Public License is available via WWW at # http://www.gnu.org/copyleft/gpl.html. You can also obtain it by # writing to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA. # Send any bug reports to R-bugs@lists.r-project.org use Cwd; use File::Basename; use File::Path; use Getopt::Long; use R::Dcf; use R::Utils; my $revision = ' $Revision: 1.4.2.1 $ '; my $version; my $name; $revision =~ / ([\d\.]*) /; $version = $1; ($name = $0) =~ s|.*/||; my @knownoptions = ("help|h", "version|v", "debug|d", "library|l:s", "clean|c", "docs:s", "use-zip", "use-zip-data", "use-zip-help"); GetOptions (@knownoptions) || usage(); R_version($name, $version) if $opt_version; usage() if $opt_help; my $R_HOME = $ENV{'R_HOME'} || die "Error: Environment variable R_HOME not found\n"; my $startdir = getcwd(); if($opt_library){ chdir($opt_library) || die "Error: cannot change to directory \`$opt_library'\n"; $library = getcwd(); chdir($startdir); } else { $library = $R_HOME . "/library"; } my $helpflags = "HELP=YES WINHELP=CHM"; if($opt_docs) { $helpflags = "HELP=NO" if $opt_docs == "no"; $helpflags = "HELP=YES WINHELP=NO" if $opt_docs == "normal"; $helpflags = "HELP=YES WINHELP=CHM" if $opt_docs == "chm"; $helpflags = "HELP=YES WINHELP=BOTH" if $opt_docs == "winhlp"; $helpflags = "HELP=YES WINHELP=BOTH" if $opt_docs == "all"; } ## this is the main loop over all packages to be installed my $pkg; foreach $pkg (@ARGV){ $pkg =~ s/\/$//; my $pkgname = basename($pkg); chdir($pkg)|| die "Error: cannot change to directory \`$pkg'\n";; chdir(".."); my $pkgdir = getcwd(); chdir($startdir); my $pkgoutdir="$library/$pkgname"; rmtree($pkgoutdir) if (-d $pkgoutdir); my $makecmd = "pkg"; if(-r "$pkg/DESCRIPTION"){ $description = new R::Dcf("$pkg/DESCRIPTION"); } if($description->{"Contains"}){ print "\nLooks like \`${pkg}' is a package bundle\n"; $makecmd = "bundle" } print "\n"; if(system("make -C $R_HOME/src/gnuwin32 PKGDIR=$pkgdir RLIB=$library $helpflags $makecmd-$pkgname")){ printf "Installation of $pkgname failed\n"; } else { if($opt_use_zip || $opt_use_zip_data) { system("make -C $R_HOME/src/gnuwin32 PKGDIR=$pkgdir RLIB=$library zipdata-$pkgname") if -d "$library/$pkgname/data"; } if($opt_use_zip || $opt_use_zip_help) { system("make -C $R_HOME/src/gnuwin32 PKGDIR=$pkgdir RLIB=$library ziponly-$pkgname") } } system("make -C $R_HOME/src/gnuwin32 PKGDIR=$pkgdir RLIB=$library pkgclean-$pkgname") if ($opt_clean && $makecmd == "pkg"); if($opt_clean && $makecmd == "bundle") { my @bundlepkgs = split(/\s+/, $description->{"Contains"}); foreach $ppkg (@bundlepkgs){ system("make -C $R_HOME/src/gnuwin32 PKGDIR=$pkgdir/$pkg RLIB=$library pkgclean-$ppkg") } } print("\n"); } if(!(-d "$library/R.css")) { system("cp $R_HOME/doc/html/R.css $library/R.css"); } sub usage { print STDERR <. END exit 0; }