├── .gitignore ├── .gitattributes ├── .github └── workflows │ ├── quick-build.yml │ └── full-build.yml ├── create-tcltk-bundle-ucrt.sh ├── MkRules.local.in ├── shortcut.diff ├── readme.md └── scripts.ps1 /.gitignore: -------------------------------------------------------------------------------- 1 | R-devel 2 | R-devel.tar.gz 3 | 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | PKGBUILD eol=lf 2 | *.patch eol=lf 3 | *.diff eol=lf 4 | *.sh eol=lf 5 | -------------------------------------------------------------------------------- /.github/workflows/quick-build.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | pull_request: 4 | workflow_dispatch: 5 | 6 | name: Test quick-build 7 | 8 | jobs: 9 | build: 10 | runs-on: windows-2022 11 | steps: 12 | - uses: actions/checkout@v2 13 | - name: Run quick-build script 14 | run: $(cygpath ${GITHUB_WORKSPACE})/build.sh 15 | shell: c:\rtools40\usr\bin\bash.exe --login {0} 16 | -------------------------------------------------------------------------------- /create-tcltk-bundle-ucrt.sh: -------------------------------------------------------------------------------- 1 | #/bin/sh 2 | set -e 3 | OUTPUT=$(mktemp -d) 4 | FILES=$(pacman -Sp mingw-w64-ucrt-x86_64-{tcl,tk,bwidget,tktable} --cache=".") 5 | for FILE in $FILES 6 | do 7 | curl -OLs $FILE 8 | echo " Extracting: $(basename $FILE)" 9 | tar xf $(basename $FILE) -C ${OUTPUT} 10 | unlink $(basename $FILE) 11 | done 12 | rm -f $(find ${OUTPUT} -name *.a) 13 | 14 | # Copy to 'Tcl' directory 15 | rm -Rf Tcl 16 | mkdir -p Tcl/bin 17 | cp ${OUTPUT}/ucrt64/bin/*.dll Tcl/bin/ 18 | cp -r ${OUTPUT}/ucrt64/lib Tcl/ 19 | 20 | # Cleanup 21 | rm -Rf ${OUTPUT} 22 | -------------------------------------------------------------------------------- /MkRules.local.in: -------------------------------------------------------------------------------- 1 | #-*- Makefile -*- 2 | 3 | ## Toolchain config 4 | WIN = 64 5 | 6 | ## Produce a debug build 7 | # DEBUG = 1 8 | 9 | ## Add custom compile flags here 10 | # EOPTS = -mtune=generic 11 | 12 | # Enable features 13 | USE_ICU = YES 14 | USE_LIBCURL = YES 15 | BUILD_HTML = YES 16 | USE_ATLAS = NO 17 | MIKTEX = TRUE 18 | OPENMP = -fopenmp 19 | 20 | ## Curl / ICU flags 21 | CURL_LIBS = -lcurl -lssh2 -lz -lssl -lcrypto -lgdi32 -lws2_32 -lcrypt32 -lwldap32 22 | ICU_LIBS = -licuin -licuuc -licudt -lstdc++ 23 | 24 | # Cairo flags 25 | USE_CAIRO = YES 26 | CAIRO_LIBS = "-lcairo -lfreetype -lpng -lpixman-1 -lz -liconv -lgdi32 -lmsimg32" 27 | CAIRO_CPPFLAGS = -I/ucrt64/include/cairo 28 | 29 | ## For building docs/installer 30 | ISDIR = C:/Program Files (x86)/Inno Setup 6 31 | MAKEINFO = texi2any 32 | TEXI2ANY = texi2any 33 | 34 | ## Fix for MiKTeX removing texi2dvi 35 | TEXI2DVI = TEXINDEX=@texindex@ texify 36 | -------------------------------------------------------------------------------- /shortcut.diff: -------------------------------------------------------------------------------- 1 | diff --git a/src/gnuwin32/installer/header1.iss b/src/gnuwin32/installer/header1.iss 2 | index 52f11986747..9516db51c60 100644 3 | --- a/src/gnuwin32/installer/header1.iss 4 | +++ b/src/gnuwin32/installer/header1.iss 5 | @@ -44,7 +44,7 @@ Name: ko; MessagesFile: "Korean.isl" 6 | #include "CustomMsg.iss" 7 | 8 | [Tasks] 9 | -Name: "desktopicon"; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; MinVersion: 0,6.0 10 | +Name: "desktopicon"; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; MinVersion: 0,6.0; Flags: unchecked 11 | Name: "quicklaunchicon"; Description: {cm:CreateQuickLaunchIcon}; GroupDescription: {cm:AdditionalIcons}; MinVersion: 0,6.0; Flags: unchecked 12 | Name: "recordversion"; Description: {cm:recordversion}; GroupDescription: {cm:regentries}; MinVersion: 0,6.0 13 | Name: "associate"; Description: {cm:associate}; GroupDescription: {cm:regentries}; MinVersion: 0,6.0; Check: IsAdmin 14 | -------------------------------------------------------------------------------- /.github/workflows/full-build.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | pull_request: 4 | workflow_dispatch: 5 | 6 | name: Build installers 7 | 8 | jobs: 9 | build: 10 | runs-on: windows-2022 11 | name: Build r-${{ matrix.src }} installer 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | src: [ 'devel', 'patched' ] 16 | steps: 17 | - name: checkout 18 | uses: actions/checkout@v2 19 | 20 | - name: Install Miktex 21 | run: | 22 | Import-Module .\scripts.ps1 23 | SetTimezone 24 | InstallMiktex 25 | 26 | - name: Download and build r-${{ matrix.src }} 27 | run: $(cygpath ${GITHUB_WORKSPACE})/build.sh 28 | shell: c:\rtools40\usr\bin\bash.exe --login {0} 29 | id: build 30 | env: 31 | version: ${{matrix.src}} 32 | build_installer: true 33 | 34 | - name: Sign installer 35 | run: | 36 | Import-Module .\scripts.ps1 37 | SignFiles ${{steps.build.outputs.installer}} 38 | env: 39 | PfxUri: ${{ secrets.PFXURI }} 40 | CertPassword: ${{ secrets.CERTPASSWORD }} 41 | SignTool: 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64\signtool.exe' 42 | if: always() 43 | 44 | - name: "Upload artifacts" 45 | uses: actions/upload-artifact@v3 46 | with: 47 | name: r-${{matrix.src}} 48 | path: | 49 | *.log 50 | *.exe 51 | if: always() 52 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Base R Installer ![GHA Build Status](https://github.com/r-windows/r-base/actions/workflows/full-build.yml/badge.svg) 2 | 3 | > Scripts to build R for Windows (ucrt64) using [Rtools40](https://github.com/r-windows/rtools-installer) toolchains. 4 | 5 | This repository was used to build dailies and official releases for R 4.0.0 - 4.1.3. Sadly as of R 4.2.0, R-core has decided to go back to building the releases privately by an R-core member. Yet the current scripts and CI still work, and can be used for testing and understanding the build process. 6 | 7 | ## Downloads 8 | 9 | Signed builds can be found under [releases](https://github.com/r-windows/r-base/releases). These installers are signed with a certified developer certificate, trusted by all Windows systems. 10 | 11 | For the very latest svn builds, or testing patches, also checkout the r-contributor [svn-dashboard](https://contributor.r-project.org/svn-dashboard/)! 12 | 13 | ## Build requirements 14 | 15 | To build R for Windows, you need: 16 | 17 | - [rtools40](https://cran.r-project.org/bin/windows/Rtools/) 18 | - [InnoSetup 6](https://www.jrsoftware.org/isdl.php) (only required for installer) 19 | - [MikTex](https://miktex.org/download) (only required for installer) 20 | 21 | Rtools40 provides perl and all required system libraries. 22 | 23 | ## How to build yourself 24 | 25 | Clone or [download](https://github.com/r-windows/r-base/archive/master.zip) this repository. Optionally edit [`MkRules.local.in`](MkRules.local.in) to adjust compiler flags. Now open any rtools msys2 shell from the Windows start menu. 26 | 27 | ![win10](https://user-images.githubusercontent.com/216319/73364595-1fe28080-42ab-11ea-9858-ac8c660757d6.png) 28 | 29 | To build the latest R-devel from source, run the [`./build.sh`](build.sh) script inside the rtools40 bash shell. This will download and build a complete ucrt64 version of R-devel, but no manuals or the installer. 30 | 31 | This is useful if you want to test a patch for base R. You can adjust the [`./build.sh`](build.sh) script to add patches. 32 | 33 | ### Building the full installer 34 | 35 | Alternatively to build the complete installer as it would appear on CRAN, set an environment variable `build_installer` when running the build script: 36 | 37 | ```sh 38 | # Run in rtools40 shell 39 | export build_installer=1 40 | ./build.sh 41 | ``` 42 | 43 | This requires you have innosetup and latex installed on your machine (in addition to rtools40). The process involves building R as well as pdf manuals and finally the installer program. 44 | -------------------------------------------------------------------------------- /scripts.ps1: -------------------------------------------------------------------------------- 1 | ### Global variables 2 | $RTOOLS_ARCH = ${env:RTOOLS_ARCH} 3 | $RTOOLS_ZIP = "rtools40-${RTOOLS_ARCH}.7z" 4 | $RTOOLS_EXE = "rtools40-${RTOOLS_ARCH}.exe" 5 | 6 | ### Use for bootstrapping installation 7 | $RTOOLS_MIRROR = "https://ftp.opencpu.org/rtools/installer/" 8 | # $RTOOLS_MIRROR = "https://cloud.r-project.org/bin/windows/Rtools/" 9 | # $RTOOLS_MIRROR = "https://ftp.opencpu.org/archive/rtools/4.0/" 10 | 11 | ### InnoSetup Mirror 12 | # $INNO_MIRROR = "http://www.jrsoftware.org/download.php/is.exe?site=2" 13 | ### Latest InnoSetup does not support Vista anymore 14 | $INNO_MIRROR = "http://files.jrsoftware.org/is/6/innosetup-6.0.4.exe" 15 | 16 | ### MikTex Mirror 17 | $MIKTEX_MIRROR = "https://miktex.org/download/win/basic-miktex-x64.exe" 18 | #$MIKTEX_MIRROR = "https://cloud.r-project.org/bin/windows/Rtools/basic-miktex-2.9.7152-x64.exe" 19 | 20 | function CheckExitCode($msg) { 21 | if ($LastExitCode -ne 0) { 22 | Throw $msg 23 | } 24 | } 25 | 26 | # Unzip and Initiate Rtools dump 27 | Function InstallRtoolsZip { 28 | Write-Host "Installing ${RTOOLS_ZIP}..." -ForegroundColor Cyan 29 | $tmp = "$($env:USERPROFILE)\${RTOOLS_ZIP}" 30 | (New-Object Net.WebClient).DownloadFile($RTOOLS_MIRROR + $RTOOLS_ZIP, $tmp) 31 | 7z x $tmp -y -oC:\ | Out-Null 32 | CheckExitCode "Failed to extract ${RTOOLS_ZIP}" 33 | C:\rtools40\usr\bin\bash.exe --login -c exit 2>$null 34 | Write-Host "Installation of ${RTOOLS_ZIP} done!" -ForegroundColor Green 35 | } 36 | 37 | # Don't use installer when: (1) architecture doesn't match host (2) Dir C:/rtools40 already exists 38 | Function InstallRtoolsExe { 39 | Write-Host "Installing ${RTOOLS_EXE}..." -ForegroundColor Cyan 40 | $tmp = "$($env:USERPROFILE)\${RTOOLS_EXE}" 41 | (New-Object Net.WebClient).DownloadFile($RTOOLS_MIRROR + $RTOOLS_EXE, $tmp) 42 | Start-Process -FilePath $tmp -ArgumentList /VERYSILENT -NoNewWindow -Wait 43 | Write-Host "Installation of ${RTOOLS_EXE} done!" -ForegroundColor Green 44 | } 45 | 46 | function bash($command) { 47 | Write-Host $command -NoNewline 48 | cmd /c start /wait C:\rtools40\usr\bin\sh.exe --login -c $command 49 | Write-Host " - OK" -ForegroundColor Green 50 | } 51 | 52 | function InstallRtools { 53 | InstallRtoolsZip 54 | bash 'pacman -Sy --noconfirm pacman pacman-mirrors' 55 | bash 'pacman -Syyu --noconfirm --ask 20' 56 | } 57 | 58 | Function InstallInno { 59 | Write-Host "Downloading InnoSetup from: " + $INNO_MIRROR 60 | & "C:\Program Files\Git\mingw64\bin\curl.exe" -s -o ../innosetup.exe -L $INNO_MIRROR 61 | CheckExitCode "Failed to download $INNO_MIRROR" 62 | 63 | Write-Host "Installig InnoSetup..." 64 | Start-Process -FilePath ..\innosetup.exe -ArgumentList "/ALLUSERS /SILENT" -NoNewWindow -Wait 65 | CheckExitCode "Failed to install InnoSetup" 66 | 67 | Write-Host "InnoSetup installation: Done" -ForegroundColor Green 68 | Get-ItemProperty "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" 69 | } 70 | 71 | function InnoBuild($iss){ 72 | Write-Host "Creating installer..." -NoNewline 73 | & "C:\Program Files (x86)\Inno Setup 5\iscc.exe" "${env:RTOOLS_NAME}.iss" | Out-File output.log 74 | Write-Host "OK!" -ForegroundColor Green 75 | } 76 | 77 | function SignFiles($files) { 78 | (New-Object Net.WebClient).DownloadFile(${env:PfxUri}, 'C:\jeroen.pfx') 79 | & $env:SignTool sign /f C:\jeroen.pfx /p "$env:CertPassword" /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp /td sha256 /fd sha256 $files 80 | CheckExitCode "Failed to sign files." 81 | Remove-Item 'C:\jeroen.pfx' 82 | } 83 | 84 | Function InstallMiktex { 85 | $miktexinstall = "--unattended --auto-install=yes --shared --package-set=basic" 86 | 87 | Write-Host "Downloading " + $MIKTEX_MIRROR 88 | & "C:\Program Files\Git\mingw64\bin\curl.exe" -s -o ../basic-miktex-x64.exe -L $MIKTEX_MIRROR 89 | 90 | Write-Host "Installing MiKTeX: " + $miktexinstall 91 | Start-Process -FilePath ..\basic-miktex-x64.exe -ArgumentList $miktexinstall -NoNewWindow -Wait 92 | 93 | Write-Host "Setting PATH variable for current process" 94 | $env:PATH = 'C:\Program Files\MiKTeX\miktex\bin\x64;' + $env:PATH 95 | 96 | Write-Host "Installing CTAN packages" 97 | mpm --admin --set-repository=https://ctan.math.illinois.edu/systems/win32/miktex/tm/packages/ 98 | mpm --admin --verbose --update-db 99 | mpm --admin --verbose --update 100 | mpm --admin --install=inconsolata 101 | 102 | # Enable auto-install, just in case 103 | initexmf --admin --enable-installer 104 | initexmf --admin --set-config-value "[MPM]AutoInstall=1" 105 | 106 | # See https://tex.stackexchange.com/a/129523/12890 107 | $conffile = "C:\Program Files\MiKTeX\miktex\config\updmap.cfg" 108 | Write-Host "Adding zi4.map" 109 | initexmf --admin --update-fndb 110 | Add-Content $conffile "`nMap zi4.map`n" 111 | initexmf --admin --mkmaps 112 | 113 | # First time running 'pdflatex' always fails with some inite 114 | Write-Host "Trying pdflatex..." 115 | # pdflatex.exe --version 116 | Write-Host "MiKTeX installation: Done" -ForegroundColor Green 117 | } 118 | 119 | ########### OLD CODE ########### 120 | 121 | Function InstallMSYS32 { 122 | Write-Host "Installing MSYS2 32-bit..." -ForegroundColor Cyan 123 | 124 | # download installer 125 | $zipPath = "$($env:USERPROFILE)\msys2-i686-latest.tar.xz" 126 | $tarPath = "$($env:USERPROFILE)\msys2-i686-latest.tar" 127 | Write-Host "Downloading MSYS installation package..." 128 | (New-Object Net.WebClient).DownloadFile('http://repo.msys2.org/distrib/msys2-i686-latest.tar.xz', $zipPath) 129 | 130 | Write-Host "Untaring installation package..." 131 | 7z x $zipPath -y -o"$env:USERPROFILE" | Out-Null 132 | 133 | Write-Host "Unzipping installation package..." 134 | 7z x $tarPath -y -oC:\ | Out-Null 135 | del $zipPath 136 | del $tarPath 137 | } 138 | 139 | function rtools_bootstrap { 140 | # AppVeyor only has msys64 preinstalled 141 | if($env:MSYS_VERSION -eq 'msys32') { 142 | InstallMSYS32 143 | bash 'pacman -Sy --noconfirm pacman pacman-mirrors' 144 | 145 | # May upgrade runtime, need to exit afterwards 146 | bash 'pacman -Syyuu --noconfirm --ask 20' 147 | } 148 | bash 'pacman --version' 149 | bash 'pacman --noconfirm -Rcsu mingw-w64-x86_64-toolchain mingw-w64-i686-toolchain' 150 | bash 'repman add rtools "https://dl.bintray.com/rtools/${MSYSTEM_CARCH}"' 151 | bash 'pacman --noconfirm --sync rtools/pacman-mirrors rtools/pacman rtools/tar' 152 | bash 'mv /etc/pacman.conf /etc/pacman.conf.old' 153 | bash 'mv /etc/pacman.conf.pacnew /etc/pacman.conf' 154 | bash 'pacman --noconfirm -Scc' 155 | bash 'pacman --noconfirm --ask 20 -Syyu' 156 | } 157 | 158 | 159 | Function SetTimezone { 160 | tzutil /g 161 | tzutil /s "GMT Standard Time" 162 | tzutil /g 163 | } 164 | --------------------------------------------------------------------------------