# File src/gnuwin32/installer/WiXins.R
#
# Part of the R package, https://www.R-project.org
#
# 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 of the License, 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 at
# https://www.R-project.org/Licenses/
## Collection of notes about WiX usage
## for x64 add InstallerVersion="200" Platforms="x64"
## see http://blogs.msdn.com/astebner/archive/2007/08/09/4317654.aspx
## Or something like
##
## VersionNT64
##
## Actually seem to need both, and it is 'Platform' in WiX 3.0
## ALLUSERS = 1 for per-machine, blank for default.
## http://wix.mindcapers.com/wiki/Allusers_Install_vs._Per_User_Install
## For non-elevation see
## http://blogs.msdn.com/astebner/archive/2007/11/18/6385121.aspx
## Also
## http://msdn.microsoft.com/en-us/library/aa367559%28VS.85%29.aspx
## The standard folder names are listed at
## http://msdn.microsoft.com/en-us/library/aa372057.aspx
## http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/64-bit-and-32-bit-Registry-Keys-in-same-MSI-td4439679.html
.make_R.wxs <- function(RW, srcdir, personal = "0")
{
have64bit <- file_test("-d", file.path(srcdir, "bin", "x64"))
have32bit <- file_test("-d", file.path(srcdir, "bin", "i386")) # from R 4.2.0 always FALSE
personal <- personal == "1"
## need DOS-style paths
srcdir0 <- srcdir
srcdir <- gsub("/", "\\", srcdir, fixed = TRUE)
Rver <- readLines("../../../VERSION")[1L]
Rver <- sub("Under .*$", "Pre-release", Rver)
SVN <- sub("Revision: ", "", readLines("../../../SVN-REVISION"))[1L]
Rver0 <- paste(sub(" .*$", "", Rver), SVN, sep = ".")
uuids <- readLines("uuids")
nc <- 1
guuids <- function() {x <- uuids[nc]; nc <<- nc + 1L; x}
con <- file("R.wxs", "w")
cat(file = con, sep = "\n",
'',
'',
' ',
' ',
' ',
' ',
if(personal)' '
else ' 1',
sprintf(' %s', Rver),
' ',
' ',
'')
if (have64bit) {
cat(file = con, sep = "\n", "",
"",
" VersionNT64", "")
}
name0 <- paste('Name="', srcdir, '" />', sep = '')
ff <- readLines('files.wxs', warn = FALSE)
ff <- grep("^ ", ff, value = TRUE)
rx1 <- ' *", f, fixed = TRUE)
cat(" ", f, "\n", file=con, sep="")
}
if (rgui == "unknown") rgui <- rgui64
cat(file = con, sep = "\n", '',
' ',
'',
## empty components to work around bug in Windows Installer
## offering to install components with no features from the network
sprintf(' ', guuids()),
sprintf(' ', guuids()),
sprintf(' ', guuids()),
'',
if (have64bit)
' '
else
' ',
" ",
sprintf(" ", srcdir),
" ",
" ",
" ")
cat(file = con, sep="\n",
' ',
' ',
' ')
cat(file = con, sep="\n",
' ',
' ')
if (have32bit)
cat(file = con, sep="\n",
sprintf(' ', guuids()),
sprintf(' ', rgui),
' ',
' ')
if (have64bit)
cat(file = con, sep="\n",
sprintf(' ', guuids()),
sprintf(' ', rgui64),
' ',
' ')
cat(file = con, sep="\n",
' ',
'',
' ',
' ',
' ',
' ',
sprintf(' ', guuids()),
sprintf(' ', rgui),
' ',
' ',
' ',
' ',
' ',
' ',
'',
''
)
if(have32bit) { # go in 32-bit registry
cat(file = con, sep="\n",
sprintf(' ', guuids()),
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
'')
}
if(have64bit) { # go in 64-bit registry
cat(file = con, sep="\n",
sprintf(' ', guuids()),
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
' ',
'')
}
## file associations
cat(file = con, sep="\n",
sprintf(' ', guuids()),
" ",
" ",
sprintf(" ", rgui),
" ",
" ",
' ')
cat(file = con, sep="\n", ' ')
## the features.
cat(file = con, sep="\n",
'',
' ')
for(id in ids[comps == 'main'])
cat(file = con,
" \n", sep="")
cat(file = con, ' \n')
cat(file = con, sep="\n",
'',
' ',
' ',
' \n')
if (have64bit && have32bit) {
cat(file = con, sep="\n",
'',
' ')
for(id in ids[comps == 'i386'])
cat(file = con,
" \n", sep="")
cat(file = con, ' \n')
}
if (have64bit) {
cat(file = con, sep="\n",
'',
' ')
for(id in ids[comps == 'x64'])
cat(file = con,
" \n", sep="")
cat(file = con, ' \n')
}
cat(file = con, sep="\n",
'',
' ',
" ",
if (have32bit) " ",
if (have64bit) " ",
" ",
" ",
" ",
if (have32bit) " ",
if (have64bit) " ",
" ",
' ',
" ",
" ",
" ")
cat(file = con, sep="\n",
' ',
if (have32bit) " ",
if (have64bit) " ",
" ",
' ',
" ",
" ")
cat(file = con, sep="\n",
"",
' ',
' ',
' ',
'',
# ' ',
'',
" ",
"")
close(con)
}
args <- commandArgs(TRUE)
do.call(".make_R.wxs", as.list(args))