# 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")
{
## The layout of 64-bit Intel builds is different so that it matches
## previous versions of R which supported sub-architectures (32-bit and
## 64-bit Intel) and installing files for both at the same time.
havex64 <- file_test("-d", file.path(srcdir, "bin", "x64"))
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}
aarch64 <- FALSE
if (!havex64) {
fout <- system(
paste("file", shQuote(file.path(srcdir, "bin", "R.exe"))),
intern=TRUE)
if (grepl("Aarch64", fout, fixed = TRUE))
aarch64 <- TRUE
}
if (aarch64) {
# To distinguish aarch64 version from x86_64 version installed on
# Windows/aarch64 in ARP entries and in shortcuts
RverA <- paste0("aarch64 ", Rver)
dsuffix <- "-aarch64"
} else {
if (havex64)
RverA <- paste0("x64 ", Rver)
else
RverA <- Rver
dsuffix <- ""
}
con <- file("R.wxs", "w")
cat(file = con, sep = "\n",
'',
'',
' ',
' ',
' ',
' ',
if(personal)' '
else ' 1',
sprintf(' %s', Rver),
' ',
' ',
'')
if (havex64) {
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="")
}
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(" ", dsuffix),
sprintf(" ", srcdir),
" ",
" ",
" ")
cat(file = con, sep="\n",
' ',
' ')
cat(file = con, sep="\n",
sprintf(' ', guuids()),
sprintf(' ', rgui),
' ',
' ')
cat(file = con, sep="\n",
' ',
'',
' ',
' ',
' ',
' ',
sprintf(' ', guuids()),
sprintf(' ', rgui),
' ',
' ',
' ',
' ',
' ',
' ',
'',
''
)
## registry
cat(file = con, sep="\n",
sprintf(' ', guuids()),
' ',
' ',
' ',
' ',
' ',
' ',
' ',
'')
if (havex64)
cat(file = con, sep="\n",
' ',
' ',
' ',
' ',
' ',
' ',
' ',
'')
cat(file = con, sep="\n",
' ',
'')
## 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')
if (havex64) {
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",
'',
' ',
" ",
" ",
" ",
" ",
" ",
" ",
" ",
' ',
" ",
" ",
" ")
cat(file = con, sep="\n",
' ',
" ",
" ",
' ',
" ",
" ")
cat(file = con, sep="\n",
"",
' ',
' ',
' ',
'',
# ' ',
'',
" ",
"")
close(con)
}
args <- commandArgs(TRUE)
do.call(".make_R.wxs", as.list(args))