Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

Commit

Permalink
Update build for R 4.0.0 (#38)
Browse files Browse the repository at this point in the history
* Re-tool README

* Re-write welcome splash

* Bump copyright and versioning

* Remove outdated configuration manipulations

* Switch to removing existing Makevars

* Switch to removing existing R_ENVIRON

* Switch to a different way of detecting macOS minor version (10.x)

* Pin to Mojave the rest.

* Bring out the label step a bit.

* Add a download function for the gfortran dmg

* Update the install gfortran component

* Add a backup and remove file function. Remove download gfortran

* Port over the configuration checks to use the backup and remove function

* Implement a new gfortran download and installation technique

* Upgrade installer accepted macos versions

* Add changelog details

* Remove dangling installer

* Update splash screen of installer for readme
  • Loading branch information
coatless authored May 27, 2020
1 parent 3041ac8 commit 27308c5
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 228 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## ChangeLog

### __v4.0.0__ - 2020-05-27

- Re-wrote the installer package to focus on R 4.0.0 requirements.
- Downloads and installs Xcode CLI
- Downloads and installs appropriate gfortran binary
- Backup and remove existing ~/.R/Makevars and ~/.Renviron configuration files.

### __v3.2.2__ - 2019-12-30

- Xcode CLI headless installation for macOS Catalina was made more robust ([#33](https://github.com/rmacoslib/r-macos-rtools/issues/33)).
Expand Down
45 changes: 18 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@

# Installer Package for macOS _R_ toolchain [![License](https://img.shields.io/badge/license-GPL%20%28%3E=%202%29-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html)

The repository contains the scripts used to create an installer package (.pkg)
The repository contains the scripts used to create an installer package (`.pkg`)
that contains binaries used to create the CRAN official macOS _R_ binary.

Specifically, the installer will try to download and install:

- Xcode command line tools (XCode CLI) from Apple
- `clang7` from <https://cran.r-project.org/bin/macosx/tools/>
- `gfortran6.1` from <https://cran.r-project.org/bin/macosx/tools/>
- `gfortran6.3` or `gfortran8.2` from <https://github.com/fxcoudert/gfortran-for-macOS/releases>

Aftwards, it will attempt to configure the necessary `~/.R/Makevars` and `~/.Renviron` files.
If either file is pre-existing, then a backup will be made prior to setting up the new versions.
Moreover, the installer will attempt to clean up previous installations by
removing configuration files `~/.R/Makevars` and `~/.Renviron` that are no longer used.
Backups for each file will be presented with `.bck` appended to the end.

For those interested, the installer can be obtained
on either the project's [**release page**](https://github.com/rmacoslib/r-macos-rtools/releases/latest)
or through <http://go.illinois.edu/r-macos-rtools-pkg>. The pre-built binaries this
installer encloses can be found at <https://developer.apple.com/download/more/>,
<https://cran.r-project.org/bin/macosx/tools/>, and <https://gcc.gnu.org/wiki/GFortranBinaries#MacOS-1>.
installer encloses can be found at <https://developer.apple.com/download/more/> and
<https://github.com/fxcoudert/gfortran-for-macOS/releases>.

**Note** The installer package was developed by [James Joseph Balamuta](https://thecoatlessprofessor.com)
and has no connection with the R project’s macOS CRAN maintainers.
Expand All @@ -33,8 +34,7 @@ of the [University of Edinburgh](http://www.ed.ac.uk/).

**That's it.**

Once installed, you can start using compiled code
in _R_ like normal with the added benefit of `OpenMP`.
Once installed, you can start using compiled code in _R_ like normal.

If you want to see behind the curtain, continue reading...

Expand All @@ -44,15 +44,12 @@ The macOS _R_ toolchain installer performs four actions that require
the user's password to accomplish. These actions are:

1. download and install XCode CLI via secure Apple product update
1. download, verify, and install the `clang7` pre-made binary
files into the `/usr/local/clang7` directory
1. download, verify, and install `gfortran6.1`
1. establish the proper header files in `CFLAGS`, `CPPFLAGS`, and `CXXFLAGS` in the `~/.R/Makevars` file
1. add to the `PATH` variable where the `clang7` binary is by using `~/.Renviron`
1. remove any existing `~/.R/Makevars` or `~/.Renviron` (backups available with `.bck`)s
1. determine which `gfortran` version to use
1. download, verify, and install the appropriate `gfortran` version

**Note:** The installer will replace existing `~/.R/Makevars` and `~/.Renviron` files.
**Note:** The installer will remove any existing `~/.R/Makevars` and `~/.Renviron` files.
The existing files will be copied to a backup file, e.g. `~/.R/Makevars.bck` and `~/.Renvion.bck`.
Re-running the installer _will_ result in the old backup files being wiped.

Verify steps are conducted using embedded md5 hashes of the files.
If the hash is not identical to what was embedded, the installer will
Expand Down Expand Up @@ -83,22 +80,16 @@ With this being said, the code used to generate the installer has been made publ
Below is an abridged version of the actions of each file provided.

- `scripts/postinstall`
- Downloads and Installs Xcode CLI, `clang7`, and `gfortran6.1`
- Downloads and Installs Xcode CLI and the appropriate `gfortran` version
- Detects the appropriate `Command Line Tools` dmg installer
by using a [headless cli check](https://github.com/timsutton/osx-vm-templates/blob/ce8df8a7468faa7c5312444ece1b977c1b2f77a4/scripts/xcode-cli-tools.sh#L8-L14),
downloads the installer from <https://developer.apple.com/download/more/>,
and installs it using `softwareupdate`.
- Downloads the `clang-7.0.0.pkg` from
<https://cran.r-project.org/bin/macosx/tools/> and installs it into `/` directory
so that it is installed on `/usr/local/clang7`
- Downloads the gfortran binary 6.1 from
<https://cran.r-project.org/bin/macosx/tools/gfortran-6.1.pkg>, and
- Downloads the gfortran binary from
<https://github.com/fxcoudert/gfortran-for-macOS/releases>, and
and installs it into `/usr/local/gfortran`.
- Create the `~/.R/Makevars` file with the necessary implicit variables
to compile using the new header location.
- `CFLAGS`, `CPPFLAGS`, `CXXFLAGS` for `clang7`
- Make the `~/.Renviron` file with a modified `PATH` variable to the location of `clang7`.
- **Note:** Pre-existing `~/.R/Makevars` and `~/.Renviron` files will be backed up prior to being overridden.
- Removes the `~/.R/Makevars` and `~/.Renviron` files
- **Note:** Pre-existing `~/.R/Makevars` and `~/.Renviron` files will be backed up prior to being removed.
- `make_installer.sh`
- Create the installer package R binary installer `.pkg`
- Builds the package from the extracted tar using `pkgbuild`
Expand Down
12 changes: 5 additions & 7 deletions build_files/WELCOME_DISPLAY.rtf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{\rtf1\ansi\ansicpg1252\cocoartf2511
{\rtf1\ansi\ansicpg1252\cocoartf2512
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fmodern\fcharset0 Courier;\f1\fmodern\fcharset0 Courier-Bold;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
Expand All @@ -11,18 +11,16 @@
\f0\fs24 \cf0 \expnd0\expndtw0\kerning0
Welcome to the
\f1\b macOS R toolchain
\f0\b0 package. For this installer to work, please ensure a stable connection to the internet is available to download ~.6 GB of files. The installer will try to:\
\f0\b0 package. For this installer to work, please ensure a stable connection to the internet is available to download ~.5 GB of files. The installer will try to:\
\
\pard\tx220\tx720\pardeftab720\li720\fi-720\sl280\partightenfactor0
\ls1\ilvl0\cf0 \kerning1\expnd0\expndtw0 {\listtext 1. }Install the {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/library/content/technotes/tn2339/_index.html#//apple_ref/doc/uid/DTS40014588-CH1-WHAT_IS_THE_COMMAND_LINE_TOOLS_PACKAGE_"}}{\fldrslt Xcode Command Line Tools}} provided by {\field{\*\fldinst{HYPERLINK "https://developer.apple.com/download/more/"}}{\fldrslt Apple}}.\
{\listtext 2. }\expnd0\expndtw0\kerning0
Install the {\field{\*\fldinst{HYPERLINK "https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#macOS"}}{\fldrslt clang7 binaries}} provided by {\field{\*\fldinst{HYPERLINK "https://r.research.att.com/libs"}}{\fldrslt CRAN}}.\
\ls1\ilvl0\kerning1\expnd0\expndtw0 {\listtext 3. }Install {\field{\*\fldinst{HYPERLINK "https://gcc.gnu.org/wiki/GFortranBinaries#MacOS-1"}}{\fldrslt gfortran6.1 binaries}} provided by {\field{\*\fldinst{HYPERLINK "https://gcc.gnu.org/wiki/HomePage"}}{\fldrslt GNU\'92s GCC Project}}.\expnd0\expndtw0\kerning0
{\listtext 3. }Install OS-specific {\field{\*\fldinst{HYPERLINK "https://github.com/fxcoudert/gfortran-for-macOS/releases"}}{\fldrslt gfortran binaries}} provided by {\field{\*\fldinst{HYPERLINK "https://gcc.gnu.org/wiki/HomePage"}}{\fldrslt GNU\'92s GCC Project}}.\expnd0\expndtw0\kerning0
\
\ls1\ilvl0\kerning1\expnd0\expndtw0 {\listtext 4. }\expnd0\expndtw0\kerning0
Create and populate {\field{\*\fldinst{HYPERLINK "https://cran.r-project.org/doc/manuals/R-exts.html#Using-Makevars"}}{\fldrslt ~/.R/Makevars}} and ~/.Renviron with the appropriate paths.\
Remove any existing {\field{\*\fldinst{HYPERLINK "https://cran.r-project.org/doc/manuals/R-exts.html#Using-Makevars"}}{\fldrslt ~/.R/Makevars}} and ~/.Renviron files.\
\pard\tx940\tx1440\pardeftab720\li1440\fi-1440\sl280\partightenfactor0
\ls1\ilvl1\cf0 \kerning1\expnd0\expndtw0 {\listtext \uc0\u8259 }If any file is pre-existing, they will be copied with `.bck` extension. \expnd0\expndtw0\kerning0
\ls1\ilvl1\cf0 \kerning1\expnd0\expndtw0 {\listtext \uc0\u8259 }Backups of each file will be made available with `.bck` extension. \expnd0\expndtw0\kerning0
\
\pard\tx720\pardeftab720\sl280\partightenfactor0
\cf0 \
Expand Down
4 changes: 2 additions & 2 deletions distribution.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<choice id="com.rbinaries.rtools" visible="false">
<pkg-ref id="com.rbinaries.rtools"/>
</choice>
<pkg-ref id="com.rbinaries.rtools" version="3.2.2" onConclusion="none">macos-rtools-temp.pkg</pkg-ref>
<pkg-ref id="com.rbinaries.rtools" version="4.0.0" onConclusion="none">macos-rtools-temp.pkg</pkg-ref>
<title>macOS R toolchain</title>
<background file="Rlogo.png" mime-type="image/png" />
<welcome file="WELCOME_DISPLAY.rtf"/>
<license file="LICENSE.rtf"/>
<allowed-os-versions>
<os-version min="10.11.0" />
<os-version min="10.13.0" />
</allowed-os-versions>
</installer-gui-script>
10 changes: 5 additions & 5 deletions make_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#
# make_installer.sh
#
# Copyright (C) 2018 - 2019 James Joseph Balamuta <[email protected]>
# Copyright (C) 2018 - 2020 James Joseph Balamuta <[email protected]>
#
# Version 3.2.2 -- 2019-12-30
# Version 4.0.0 -- 2020-05-27
#
# 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
Expand All @@ -30,7 +30,7 @@ echo "[setup] Creating an environment for the installer..."
chmod a+x scripts/*

# Version of installer
INSTALLER_VERSION=3.2.2
INSTALLER_VERSION=4.0.0

# Previously, we created a payload-free package due to downloading
# components as needed. We used a read receipt trick of including an empty
Expand Down Expand Up @@ -82,11 +82,11 @@ add_line_1before_last '<welcome file="WELCOME_DISPLAY.rtf"/>' distribution.xml
add_line_1before_last '<license file="LICENSE.rtf"/>' distribution.xml

# Enforce a minimum standard for the installer.
# R CRAN Binaries use OS X Mavericks 10.11
# R CRAN Binaries use macOS High Sierra 10.13
# Docs: https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html#//apple_ref/doc/uid/TP40005370-CH100-SW33
MINVERSION=$(cat <<-END
<allowed-os-versions>
<os-version min="10.11.0" />
<os-version min="10.13.0" />
</allowed-os-versions>
END
)
Expand Down
Binary file modified readme_img/lock_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified readme_img/signed_certificate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 27308c5

Please sign in to comment.