<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#-*- perl -*-
# Copyright (C) 2001-6 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., 51 Franklin Street,
# Fifth Floor, Boston, MA 02110-1301  USA.

# Send any bug reports to r-bugs@r-project.org

use Cwd;
use File::Find;
use Win32;

my $fn, $component, $path;
my $startdir=cwd();
my $RVER, $RVER0;
my $RW=$ARGV[0];
my $SRCDIR=$ARGV[1];

$SRCDIR =~ s+/+\\+g; # need DOS-style paths

## add to the target command line in the CmdParms function below

open ver, "&lt; ../../../VERSION";
$RVER = &lt;ver&gt;;
close ver;
$RVER =~ s/\n.*$//;
$RVER =~ s/Under .*$/Pre-release/;
$RVER0 = $RVER;
$RVER0 =~ s/ .*$//;

my $sRW = Win32::GetShortPathName($SRCDIR);

my %uuids;

## we could use Win32::Guidgen, but it is not normally installed
## so it is easier to use C code.

my $nc = 900;
open guidfile, "&lt;uuids" or die "Cannot open uuids\n";
while (&lt;guidfile&gt;) {
    chomp;
    $uuids{$nc++} = $_;
}
close guidfile;
$nc = 920;

open insfile, "&gt; R.wxs" or die "Cannot open R.wxs\n";
print insfile &lt;&lt;END;
&lt;?xml version="1.0" encoding="windows-1252"?&gt;
&lt;Wix xmlns="http://schemas.microsoft.com/wix/2003/01/wi"&gt;
  &lt;Product Manufacturer="R Development Core Team" 
   Id="3AF9DA8E-B4DB-49B2-802D-A279667F44E5"
   Language="1033"
   Name="R $RVER for Windows"
   Version="$RVER" 
   UpgradeCode="309E663C-CA7A-40B9-8822-5D466F1E2AF9"&gt;
    &lt;Package Id="????????-????-????-????-????????????" 
     Keywords="R $RVER for Windows Installer" 
     Description="R $RVER for Windows Installer" 
     Comments="R Language and Environment" 
     Manufacturer="R Development Core Team" 
     InstallerVersion="100" 
     Languages="1033" 
     Compressed="yes" 
     SummaryCodepage="1252" /&gt;
    &lt;Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" /&gt;
    &lt;Property Id='DiskPrompt' Value="R for Windows Installation [1]" /&gt;

    &lt;Directory Id='TARGETDIR' Name='SourceDir'&gt;

      &lt;Directory Id='ProgramFilesFolder' Name='PFiles'&gt;
        &lt;Directory Id='R' Name='R'&gt;
          &lt;Directory Id='INSTALLDIR' Name = '$sRW' LongName='$RW'&gt;
END

my $rgui, $rhelp;
my %comp;
open tfile, "&lt;files.wxs" or die "Cannot open files.wxs\n";
while(&lt;tfile&gt;) {
    next unless /^        /;
    if(/&lt;Component Id=\"([^\"]*)\"/) {
	$id = $1;
    }
    if(/&lt;File Id=\"([^\"]*).* src=\"([^\"]*)\"/) {
	$fn = $1;
	$src = $2;
	$src =~ s+.*\\$SRCDIR\\++;
	$src =~ s+\\+/+g;
	$comp{$src} = $id;
	$rgui = "$fn" if $src eq "bin/Rgui.exe";
	$rhelp = "$fn" if $src eq "doc/html/index.html";
    }
    if(/PUT-GUID-HERE/) {
	s/PUT-GUID-HERE/$uuids{$nc++}/;
    }
    print insfile "    ", $_;
}
close tfile;


my %develfiles=("doc\\html\\logo.jpg" =&gt; 1,
		"README.packages" =&gt; 1,
		"COPYING.LIB" =&gt; 1,
		"bin\\INSTALL" =&gt; 1,
		"bin\\REMOVE" =&gt; 1,
		"bin\\SHLIB" =&gt; 1,
		"bin\\build" =&gt; 1,
		"bin\\check" =&gt; 1,
		"bin\\massage-Examples" =&gt; 1,
		"bin\\Rd2dvi.sh" =&gt; 1,
		"bin\\Rd2txt" =&gt; 1,
		"bin\\Rdconv" =&gt; 1,
		"bin\\Rdiff.sh" =&gt; 1,
		"bin\\Sd2Rd" =&gt; 1);
		
$path="${SRCDIR}";chdir($path);
my %main;

find(\&amp;listFiles, ".");

print insfile &lt;&lt;END;
          &lt;/Directory&gt;
        &lt;/Directory&gt;
      &lt;/Directory&gt;

      &lt;Directory Id="StartMenuFolder" Name="SMenu"&gt;
        &lt;Directory Id="ProgramMenuFolder" Name="Programs"&gt;
          &lt;Directory Id="RMENU" Name="R"&gt;
            &lt;Component Id="shortcut0" 
             Guid="$uuids{910}" KeyPath="yes"&gt;
              &lt;Shortcut Id="RguiStartMenuShortcut" Directory="RMENU" Name="R" 
               LongName="R $RVER" Target="[!$rgui]" 
               WorkingDirectory="INSTALLDIR" /&gt;
            &lt;/Component&gt;
            &lt;Component Id="shortcut1" 
             Guid="$uuids{911}" KeyPath="yes"&gt;
              &lt;Shortcut Id="HelpStartMenuShortcut" Directory="RMENU" 
               Name="RHelp" LongName="R $RVER Help" Target="[!$rhelp]" 
               WorkingDirectory="INSTALLDIR" /&gt;
            &lt;/Component&gt;
            &lt;Component Id="shortcut2" 
             Guid="$uuids{912}" KeyPath="yes"&gt;
              &lt;Shortcut Id="UninstallStartMenuShortcut" Directory="RMENU" 
               Name="RUninst" LongName="Uninstall R $RVER" 
               Target="[SystemFolder]\msiexec.exe" 
               Arguments="/x [ProductCode]" Icon="shell32.dll" 
               IconIndex="32" WorkingDirectory="INSTALLDIR" /&gt;
            &lt;/Component&gt;
          &lt;/Directory&gt;
        &lt;/Directory&gt;
      &lt;/Directory&gt;
      &lt;Directory Id="DesktopFolder" Name="Desktop"&gt;
        &lt;Component Id="desktopshortcut0" DiskId="1" Guid="$uuids{907}"&gt;
          &lt;Shortcut Id="RguiDesktopShortcut" Directory="DesktopFolder" Name="R" LongName="R $RVER"
           WorkingDirectory="INSTALLDIR" Target="[!$rgui]" /&gt;
        &lt;/Component&gt;
      &lt;/Directory&gt;

      &lt;Directory Id="AppDataFolder" Name="AppData"&gt;
        &lt;Directory Id="Microsoft" Name="MS" LongName="Microsoft"&gt;
          &lt;Directory Id="InternetExplorer" Name="IE" LongName="Internet Explorer"&gt;
            &lt;Directory Id="QuickLaunch" Name="QLaunch" LongName="Quick Launch"&gt;
              &lt;Component Id="quickshortcut0" DiskId="1" Guid="$uuids{908}"&gt;
                &lt;Shortcut Id="RguiQuickShortcut" Directory="QuickLaunch" Name="R" LongName="R $RVER"
                 WorkingDirectory="INSTALLDIR" Target="[!$rgui]" /&gt;
              &lt;/Component&gt;
            &lt;/Directory&gt;
          &lt;/Directory&gt;
        &lt;/Directory&gt;
      &lt;/Directory&gt;


      &lt;Component Id="registry0" Guid="$uuids{900}"&gt;
        &lt;Registry Id="RInstallPath" Root="HKMU" Key="Software\\R-core\\R" 
         Name="InstallPath" Type="string" KeyPath="yes" Value="[INSTALLDIR]" /&gt;
      &lt;/Component&gt;
      &lt;Component Id="registry1" Guid="$uuids{901}"&gt;
        &lt;Registry Id="RCurrentVersion" Root="HKMU" Key="Software\\R-core\\R" 
         Name="Current Version" Type="string" KeyPath="yes" 
         Value="[ProductVersion]" /&gt;
      &lt;/Component&gt;
      &lt;Component Id="registry2" Guid="$uuids{902}"&gt;
        &lt;Registry Id="RVerInstallPath" Root="HKMU" 
         Key="Software\\R-core\\R\\[ProductVersion]" Name="InstallPath"
         Type="string" KeyPath="yes" Value="[INSTALLDIR]" /&gt;
      &lt;/Component&gt;
      &lt;Component Id="registry3" Guid="$uuids{903}"&gt;
        &lt;Registry Id="RData" Root="HKCR" Key=".RData" Type="string"
         KeyPath="yes" Value="RWorkspace" /&gt;
      &lt;/Component&gt;
      &lt;Component Id="registry4" Guid="$uuids{904}"&gt;
        &lt;Registry Id="RWorkspace" Root="HKCR" Key="RWorkspace" Type="string" 
         KeyPath="yes" Value="R Workspace" /&gt;
      &lt;/Component&gt;
      &lt;Component Id="registry5" Guid="$uuids{905}"&gt;
        &lt;Registry Id="RDataCommand" Root="HKCR" 
         Key="RWorkspace\\shell\\open\\command" Type="string" KeyPath="yes" 
         Value="&amp;quot;[!$rgui]&amp;quot; &amp;quot;%1&amp;quot;" /&gt;
      &lt;/Component&gt;
      &lt;Component Id="registry6" Guid="$uuids{906}"&gt;
        &lt;Registry Id="RDataDefaultIcon" Root="HKCR" 
         Key="RWorkspace\\DefaultIcon" Type="string" KeyPath="yes" 
         Value="[!$rgui],0" /&gt;
      &lt;/Component&gt;
    &lt;/Directory&gt;

    &lt;Feature Id="main" Title="Main Files" Description="Main Files" Level="1" 
     ConfigurableDirectory="INSTALLDIR"
     Display="expand" InstallDefault="local" AllowAdvertise="no" 
     Absent="disallow"&gt;
      &lt;ComponentRef Id='registry0' /&gt;
      &lt;ComponentRef Id='registry3' /&gt;
      &lt;ComponentRef Id='registry4' /&gt;
      &lt;ComponentRef Id='registry5' /&gt;
      &lt;ComponentRef Id='registry6' /&gt;
END
    
foreach $n (sort values %main) {
    print insfile "      &lt;ComponentRef Id='$n' /&gt;\n";
}

print insfile &lt;&lt;END;
    &lt;/Feature&gt;
    &lt;Feature Id="chtml" Title="Compiled HTML Help Files" Description="Compiled HTML Help Files" Level="1" InstallDefault="local" AllowAdvertise="no"&gt;
END

foreach $n (sort values %chtml) {
    print insfile "      &lt;ComponentRef Id='$n' /&gt;\n";
}

print insfile &lt;&lt;END;
    &lt;/Feature&gt;
    &lt;Feature Id="html" Title="HTML Help Files" Description="HTML Help Files" Level="1" InstallDefault="local" AllowAdvertise="no"&gt;
END

foreach $n (sort values %html) {
    print insfile "      &lt;ComponentRef Id='$n' /&gt;\n";
}

print insfile &lt;&lt;END;
    &lt;/Feature&gt;

    &lt;Feature Id="manuals" Title="On-line (PDF) Manuals" 
     Description="On-line (PDF) Manual" Level="1"
     InstallDefault="local" AllowAdvertise="no"&gt;
END

foreach $n (sort values %manuals) {
    print insfile "      &lt;ComponentRef Id='$n' /&gt;\n";
}

print insfile &lt;&lt;END;
    &lt;/Feature&gt;

    &lt;Feature Id="refman" Title="PDF Reference Manual" 
     Description="PDF Reference Manual" Level="1000"
     InstallDefault="local" AllowAdvertise="no"&gt;
END

foreach $n (sort values %refman) {
    print insfile "      &lt;ComponentRef Id='$n' /&gt;\n";
}
print insfile &lt;&lt;END;
    &lt;/Feature&gt;

    &lt;Feature Id="latex" Title="Latex Help Files"
     Description="Latex Help Files" Level="1000" 
     InstallDefault="local" AllowAdvertise="no"&gt;
END

foreach $n (sort values %latex) {
    print insfile "      &lt;ComponentRef Id='$n' /&gt;\n";
}

print insfile &lt;&lt;END;
    &lt;/Feature&gt;

    &lt;Feature Id="devel" Title="Source Package Installation Files"
     Description="Source Package Installation Files" Level="1"
     InstallDefault="local" AllowAdvertise="no" Display="expand"&gt;
END

foreach $n (sort values %devel) {
    print insfile "      &lt;ComponentRef Id='$n' /&gt;\n";
}

print insfile &lt;&lt;END;
    &lt;/Feature&gt;

    &lt;Feature Id="Rd" Title="Source Files for Help Pages"
     Description="Source Files for Help Pages" Level="1"
     InstallDefault="local" AllowAdvertise="no" Display="expand"&gt;
END

foreach $n (sort values %Rd) {
    print insfile "        &lt;ComponentRef Id='$n' /&gt;\n";
}

print insfile &lt;&lt;END;
    &lt;/Feature&gt;

    &lt;Feature Id="libdocs" Title="Support Files for Package tcltk" Description="Support Files for Package tcltk" Level="1"
     InstallDefault="local" AllowAdvertise="no"&gt;
END

foreach $n (sort values %libdocs) {
    print insfile "      &lt;ComponentRef Id='$n' /&gt;\n";
}

print insfile &lt;&lt;END;
    &lt;/Feature&gt;

    &lt;Feature Id="tcl" Title="Support Files for Package tcltk" Description="Support Files for Package tcltk" Level="1"
     InstallDefault="local" AllowAdvertise="no"&gt;
END

foreach $n (sort values %tcl) {
    print insfile "      &lt;ComponentRef Id='$n' /&gt;\n";
}

print insfile &lt;&lt;END;
    &lt;/Feature&gt;

    &lt;Feature Id="trans" Title="Message Translations" Description="Messages translated to other languages" Level="1"
     InstallDefault="local" AllowAdvertise="no"&gt;
END

foreach $n (sort values %trans) {
    print insfile "      &lt;ComponentRef Id='$n' /&gt;\n";
}

## look up local Windows system32 directory
my $WINDOWS = Win32::GetFolderPath(Win32::CSIDL_SYSTEM);

print insfile &lt;&lt;END;
    &lt;/Feature&gt;

    &lt;Feature Id="shortcuts" Title="Shortcuts" Description="Shortcut install options" Level="1" InstallDefault="local"
     AllowAdvertise='no' Display="expand"&gt;
      &lt;Feature Id='sshortcuts' Title='Start Menu Shortcuts' Description='Install Start menu shortcuts' Level='1'
       ConfigurableDirectory='RMENU' InstallDefault='local' AllowAdvertise='no'&gt;
        &lt;ComponentRef Id='shortcut0' /&gt;
        &lt;ComponentRef Id='shortcut1' /&gt;
        &lt;ComponentRef Id='shortcut2' /&gt;
      &lt;/Feature&gt;
      &lt;Feature Id='dshortcut' Title='Desktop Shortcut' Description='Install Desktop shortcut' Level='1'
       InstallDefault='local' AllowAdvertise='no'&gt;
        &lt;ComponentRef Id='desktopshortcut0' /&gt;
      &lt;/Feature&gt;
      &lt;Feature Id="qshortcut" Title="Quicklaunch Shortcut" Description="Install Quick Launch shortcut" Level="1000"
       InstallDefault="local" AllowAdvertise="no"&gt;
        &lt;ComponentRef Id='quickshortcut0' /&gt;
      &lt;/Feature&gt;
    &lt;/Feature&gt;
    &lt;Feature Id="registryversion" Title="Save Version in Registry"
     Description="Save the product version in the Registry" Level="1" InstallDefault="local" AllowAdvertise="no"&gt;
      &lt;ComponentRef Id='registry1' /&gt;
      &lt;ComponentRef Id='registry2' /&gt;
    &lt;/Feature&gt;

    &lt;UIRef Id="WixUI_Mondo" /&gt;
    &lt;UIRef Id="WixUI_ErrorProgressText" /&gt;

    &lt;Icon Id="shell32.dll" SourceFile="$WINDOWS\\shell32.dll" /&gt;

  &lt;/Product&gt;
&lt;/Wix&gt;
END

close insfile;

sub listFiles {
    $fn = $File::Find::name;
    if (!(-d $_)) {
	$_ = $dir = $fn;
	s+^./++;
	s+/+\\+g;
	$fn =~ s+.*/++g;

	if ($_ eq "bin\\Rchtml.dll" 
	    || m/^library\\[^\\]*\\chtml/) {
	    $component = "chtml";
	#} elsif ($_ eq "doc\\html\\logo.jpg") {
	#    $component = "html devel";
	} elsif ($_ eq "doc\\manual\\R-FAQ.html"
		 || $_ eq "doc\\html\\rw-FAQ.html"
		 || $_ eq "share\\texmf\\Sweave.sty") {
	    $component = "main";
	} elsif (m/^doc\\html/
		 || m/^doc\\manual\\[^\\]*\.html/
		 || m/^library\\[^\\]*\\html/
		 || m/^library\\[^\\]*\\CONTENTS/
		 || $_ eq "library\\R.css") {
	    $component = "html";
	} elsif ($_ eq "doc\\manual\\refman.pdf") {
	    $component = "refman";
	} elsif (m/^doc\\manual/ &amp;&amp; $_ ne "doc\\manual\\R-FAQ.pdf") {
	    $component = "manuals";
	} elsif (m/^library\\[^\\]*\\latex/) {
	    	$component = "latex";
	} elsif (m/^library\\[^\\]*\\man/) {
	    	$component = "Rd";
	} elsif (m/^Tcl/) {
	    $component = "tcl";
	} elsif (exists($develfiles{$_})
		 || m/^doc\\KEYWORDS/
		 || m/^src\\gnuwin32/
		 || m/^include/
		 || m/^src\\library\\windlgs/
		 || m/^share\\make/
		 || m/^share\\perl/
		 || m/^share\\R/
		 || m/^share\\texmf/
		 || m/^bin\\build/
		 || m/^bin\\check/
		 || m/^bin\\INSTALL/
		 || m/^bin\\massage-Examples/
		 || m/^bin\\Rd2dvi.sh/
		 || m/^bin\\Rd2txt/
		 || m/^bin\\Rdconv/
		 || m/^bin\\Rdiff.sh/
		 || m/^bin\\REMOVE/
		 || m/^bin\\Rprof/
		 || m/^bin\\Sd2Rd/
		 || m/^bin\\SHLIB/
		 || m/^lib\\/) {
	    $component = "devel";
	} elsif (m/^library\\grid\\doc/
		 || $_ eq "library\\survival\\survival.ps.gz") {
	    $component = "libdocs";
	} elsif ($_ eq "modules\\iconv.dll") {
	    $component = "main";
	} elsif (m/^share\\locale/ 
		 || m/^library\\[^\\]*\\po/) { # needs iconv
	    $component = "trans";
	} else {
	    $component = "main";
	}

	s+\\+/+g;
	$ncomp = $comp{$_};
	$main{$_} = $ncomp if $component eq "main";
	$devel{$_} = $ncomp if $component eq "devel";
	$chtml{$_} = $ncomp if $component eq "chtml";
	$html{$_} = $ncomp if $component eq "html";
	$latex{$_} = $ncomp if $component eq "latex";
	$manuals{$_} = $ncomp if $component eq "manuals";
	$refman{$_} = $ncomp if $component eq "refman";
	$Rd{$_} = $ncomp if $component eq "Rd";
	$libdocs{$_} = $ncomp if $component eq "libdocs";
	$tcl{$_} = $ncomp if $component eq "tcl";
	$trans{$_} = $ncomp if $component eq "trans";
    }
}
</pre></body></html>