[R-SIG-Mac] Generating R .pkg file for Mac Distribution
Balamuta, James Joseph
b@l@mut2 @ending from illinoi@@edu
Fri May 25 04:07:45 CEST 2018
Greetings and Salutations Nigel,
You’re welcome!
Just a word of advice regarding 3.4.x and 3.5.x, make sure the installer includes packages from the desired version. ALTREP was added in 3.5.x and that has caused issues with users who opt to copy over the previous installation of r binaries to the new install location.
Lastly, you may wish to just maintain an R package install script, c.f.
https://github.com/coatless/toad/blob/master/install-r-packages.R
Sincerely,
JJB
From: Nigel Delaney <nigelfdelaney using gmail.com>
Date: Thursday, May 24, 2018 at 2:14 AM
To: "Balamuta, James Joseph" <balamut2 using illinois.edu>
Cc: "r-sig-mac using r-project.org" <r-sig-mac using r-project.org>
Subject: Re: [R-SIG-Mac] Generating R .pkg file for Mac Distribution
James,
Thank you for the wonderful response and for making your packaging code available (and producing this!). Very much appreciated.
I wound up taking an approach where I just modified the CRAN R installer to include a few more packages (specifically all I had installed). I couldn't find advice about this on the internet, so am attaching a subset of the script I used below in case a future individual also wants some advice on this.
Cheers,
Nigel
# Script to modify the R bundle to add more packages from the users library
wget https://cloud.r-project.org/bin/macosx/R-3.5.0.pkg
BUILD_DIR=build
mkdir $BUILD_DIR
# Unpack the CRAN R distribution
pkgutil --expand R-3.5.0.pkg $BUILD_DIR/tmp_pkg
# Now to add more default packages to the R package payload
# First extract the payload
pushd $BUILD_DIR/tmp_pkg/r.pkg/
cat Payload | gzip -d | cpio -id
# Copy all of the users R packages into this
# folder for distribution
R_LIB_DIR=$(sed -e 's/\[1\] \"//' -e 's/\"//' <<< $(RScript -e '.libPaths()'))
R_PAYLOAD_DIR="R.framework/Resources/library"
for dirname in $R_LIB_DIR/*
do
pkg_name=$(basename $dirname)
if [ ! -d $R_PAYLOAD_DIR/$pkg_name ]
then
echo "Moving package:" $pkg_name
cp -r $dirname $R_PAYLOAD_DIR/$pkg_name
fi
done
# Let's remove the debug symbols and their associated plists for compiled code in R
# packages, as they bloat the installation
find $R_PAYLOAD_DIR -name '*so.dSYM' -prune -exec rm -rf {} \;
# Now build a new r.pkg
pkgbuild --component R.framework --scripts Scripts/ \
--identifier org.r-project.R.el-capitan.fw.pkg \
--version 30574626 \ # You may want to change this
--install-location /Library/Frameworks \
../../r.pkg
popd
# Remove original one we've replaced
rm -rf $BUILD_DIR/tmp_pkg/r.pkg
# Flatten remaining components distributed with R
# (necessary to repackage it all).
for fname in $BUILD_DIR/tmp_pkg/*.pkg
do
bname=$(basename $fname)
pkgutil --flatten $fname $BUILD_DIR/$bname
done
mv $BUILD_DIR/tmp_pkg/Resources $BUILD_DIR/
mv $BUILD_DIR/tmp_pkg/Distribution $BUILD_DIR/
(cd $BUILD_DIR; productbuild --distribution Distribution --resources Resources ../R-With-Your-Stuff.pkg)
[[alternative HTML version deleted]]
More information about the R-SIG-Mac
mailing list