# HG changeset patch
# User J. H. Palmieri
# Date 1351285561 25200
# Node ID 46935f1ecd7687bea94d0b8362479c0fc6600aab
# Parent 0c1731b225dc33e6ced60a82740f3ad36e30beb6
#9668: make R relocatable by using $SAGE_ROOT instead of hard-coded path.
diff --git a/SPKG.txt b/SPKG.txt
--- a/SPKG.txt
+++ b/SPKG.txt
@@ -41,6 +41,9 @@ much code written for S runs unaltered u
== Changelog ==
+=== r-2.14.0.p7 (John Palmieri, 25 October 2012) ===
+ * #9668: make R relocatable by using $SAGE_ROOT instead of hard-coded path.
+
=== r-2.14.0.p6 (Jeroen Demeyer, 10 September 2012) ===
* #13443: some clean up of spkg-install.
* Compile R with optimization (at -O2 level).
diff --git a/spkg-install b/spkg-install
--- a/spkg-install
+++ b/spkg-install
@@ -146,6 +146,20 @@ if [ $? -ne 0 ]; then
exit 1
fi
+# Make R relocatable by using "$SAGE_ROOT" instead of the hardcoded path.
+for f in "$SAGE_LOCAL/bin/R" "$SAGE_LOCAL/lib/R/bin/R" \
+ "$SAGE_LOCAL/lib/R/bin/libtool" "$SAGE_LOCAL/lib/R/etc/Makeconf" \
+ "$SAGE_LOCAL/lib/R/etc/Renviron"
+do
+ # Add quotes in lines like 'blah=$SAGE_ROOT/...'
+ # and replace any remaining occurrences of SAGE_ROOT.
+ sed -e "s|=$SAGE_ROOT|=\"\$SAGE_ROOT\"|g" -e "s|$SAGE_ROOT|\$SAGE_ROOT|g" "$f" > "$f.tmp"
+ mv "$f.tmp" "$f"
+done
+
+# Make scripts executable.
+chmod a+x "$SAGE_LOCAL/bin/R" "$SAGE_LOCAL/lib/R/bin/R" "$SAGE_LOCAL/lib/R/bin/libtool"
+
if [ "$UNAME" = "Darwin" ]; then
echo "Removing fake java and javac compiler"
rm -f "$SAGE_LOCAL"/bin/java