summaryrefslogtreecommitdiff
path: root/sci-mathematics/rstudio/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /sci-mathematics/rstudio/files
reinit the tree, so we can have metadata
Diffstat (limited to 'sci-mathematics/rstudio/files')
-rw-r--r--sci-mathematics/rstudio/files/rsession.conf26
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.97.336-boost-1.53.patch64
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.97.336-linker_flags.patch18
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.97.336-paths.patch112
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.97.336-prefs.patch24
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.97.551-boost-1.53.patch64
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.97.551-linker_flags.patch18
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.97.551-paths.patch112
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.97.551-prefs.patch24
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.98.1091-boost-1.57.patch60
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.98.1091-pandoc.patch26
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.98.490-linker_flags.patch18
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.98.490-paths.patch120
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.98.490-prefs.patch24
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.98.932-pandoc.patch25
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.98.932-paths.patch140
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.99.473-clang-pandoc.patch77
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.99.473-paths.patch130
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.99.473-qtsingleapplication.patch60
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.99.486-systemd.patch22
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.99.879-clang-pandoc.patch77
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.99.879-paths.patch130
-rw-r--r--sci-mathematics/rstudio/files/rstudio-0.99.879-prefs.patch45
-rw-r--r--sci-mathematics/rstudio/files/rstudio-1.0.44-clang-pandoc.patch71
-rw-r--r--sci-mathematics/rstudio/files/rstudio-1.0.44-paths.patch130
-rw-r--r--sci-mathematics/rstudio/files/rstudio-1.0.44-systemd.patch21
-rw-r--r--sci-mathematics/rstudio/files/rstudio-server.conf35
-rw-r--r--sci-mathematics/rstudio/files/rstudio-server.initd15
-rw-r--r--sci-mathematics/rstudio/files/rstudio-server.service.in10
29 files changed, 1698 insertions, 0 deletions
diff --git a/sci-mathematics/rstudio/files/rsession.conf b/sci-mathematics/rstudio/files/rsession.conf
new file mode 100644
index 000000000000..645bfa46b208
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rsession.conf
@@ -0,0 +1,26 @@
+######rsession.conf############
+# Session Timeouts
+# By default if a user hasn't issued a command for 2 hours
+# RStudio will suspend that user's R session to disk so
+# they are no longer consuming server resources (the next
+# time the user attempts to access the server their session
+# will be restored). You can change the timeout (including
+# disabling it by specifying a value of 0) using the
+# session-timeout-minutes setting
+#session-timeout-minutes=30
+
+# By default RStudio sets the R_LIBS_USER environment
+# variable to ~/R/library. This ensures that packages
+# installed by end users do not have R version numbers
+# encoded in the path (which is the default behavior).
+# This in turn enables administrators to upgrade the version
+# of R on the server without reseting users installed packages
+# (which would occur if the installed packages were in an
+# R-version derived directory).
+# If you wish to override this behavior you can do so using
+# the r-libs-user settings
+#r-libs-user=~/R/packages
+
+# You can set the default CRAN repository for the server
+# using the r-cran-repos setting
+#r-cran-repos=http://cran.case.edu/
diff --git a/sci-mathematics/rstudio/files/rstudio-0.97.336-boost-1.53.patch b/sci-mathematics/rstudio/files/rstudio-0.97.336-boost-1.53.patch
new file mode 100644
index 000000000000..38bb63a8ab61
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.97.336-boost-1.53.patch
@@ -0,0 +1,64 @@
+=== modified file 'src/cpp/core/include/core/http/AsyncServer.hpp'
+--- src/cpp/core/include/core/http/AsyncServer.hpp 2013-07-09 12:02:58 +0000
++++ src/cpp/core/include/core/http/AsyncServer.hpp 2013-07-09 12:03:34 +0000
+@@ -264,7 +264,7 @@
+
+ // convert to cannonical HttpConnection
+ boost::shared_ptr<AsyncConnection> pAsyncConnection =
+- boost::shared_static_cast<AsyncConnection>(pConnection);
++ boost::static_pointer_cast<AsyncConnection>(pConnection);
+
+ // call the appropriate handler to generate a response
+ std::string uri = pRequest->uri();
+
+=== modified file 'src/cpp/core/include/core/http/LocalStreamAsyncClient.hpp'
+--- src/cpp/core/include/core/http/LocalStreamAsyncClient.hpp 2013-07-09 12:02:58 +0000
++++ src/cpp/core/include/core/http/LocalStreamAsyncClient.hpp 2013-07-09 12:03:36 +0000
+@@ -87,7 +87,7 @@
+ boost::shared_ptr<AsyncClient<boost::asio::local::stream_protocol::socket> >
+ ptrShared = shared_from_this();
+
+- return boost::shared_static_cast<LocalStreamAsyncClient>(ptrShared);
++ return boost::static_pointer_cast<LocalStreamAsyncClient>(ptrShared);
+ }
+
+ private:
+
+=== modified file 'src/cpp/core/include/core/http/TcpIpAsyncClient.hpp'
+--- src/cpp/core/include/core/http/TcpIpAsyncClient.hpp 2013-07-09 12:02:58 +0000
++++ src/cpp/core/include/core/http/TcpIpAsyncClient.hpp 2013-07-09 12:03:32 +0000
+@@ -74,7 +74,7 @@
+ boost::shared_ptr<AsyncClient<boost::asio::ip::tcp::socket> > ptrShared
+ = shared_from_this();
+
+- return boost::shared_static_cast<TcpIpAsyncClient>(ptrShared);
++ return boost::static_pointer_cast<TcpIpAsyncClient>(ptrShared);
+ }
+
+ private:
+
+=== modified file 'src/cpp/core/include/core/http/TcpIpAsyncClientSsl.hpp'
+--- src/cpp/core/include/core/http/TcpIpAsyncClientSsl.hpp 2013-07-09 12:02:58 +0000
++++ src/cpp/core/include/core/http/TcpIpAsyncClientSsl.hpp 2013-07-09 12:03:39 +0000
+@@ -109,7 +109,7 @@
+ boost::shared_ptr<AsyncClient<boost::asio::ssl::stream<boost::asio::ip::tcp::socket> > > ptrShared
+ = shared_from_this();
+
+- return boost::shared_static_cast<TcpIpAsyncClientSsl>(ptrShared);
++ return boost::static_pointer_cast<TcpIpAsyncClientSsl>(ptrShared);
+ }
+
+ virtual bool isShutdownError(const boost::system::error_code& ec)
+
+=== modified file 'src/cpp/session/http/SessionHttpConnectionListenerImpl.hpp'
+--- src/cpp/session/http/SessionHttpConnectionListenerImpl.hpp 2013-07-09 12:02:58 +0000
++++ src/cpp/session/http/SessionHttpConnectionListenerImpl.hpp 2013-07-09 12:03:29 +0000
+@@ -256,7 +256,7 @@
+ {
+ // convert to cannonical HttpConnection
+ boost::shared_ptr<HttpConnection> ptrHttpConnection =
+- boost::shared_static_cast<HttpConnection>(ptrConnection);
++ boost::static_pointer_cast<HttpConnection>(ptrConnection);
+
+ if (!authenticate(ptrHttpConnection))
+ {
diff --git a/sci-mathematics/rstudio/files/rstudio-0.97.336-linker_flags.patch b/sci-mathematics/rstudio/files/rstudio-0.97.336-linker_flags.patch
new file mode 100644
index 000000000000..a336fccbc981
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.97.336-linker_flags.patch
@@ -0,0 +1,18 @@
+Some gcc hardening options were added, however since we add
+"-Wl,--as-needed" we end up with "-Wl,--as-needed;-Wl,-z,relro" which
+leads to linker errors about unknown options, if we make it so the
+as-needed option is the last option on the line, everything is fine.
+
+diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt
+index 0589ca0..fe5bd5f 100644
+--- a/src/cpp/CMakeLists.txt
++++ b/src/cpp/CMakeLists.txt
+@@ -57,7 +57,7 @@ if(UNIX)
+ add_definitions(-D_FORTIFY_SOURCE=2)
+ add_definitions(-fstack-protector --param ssp-buffer-size=4)
+ add_definitions(-pie -fPIE)
+- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro,-z,now")
++ set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,relro,-z,now ${CMAKE_EXE_LINKER_FLAGS}")
+ endif()
+
+ # Win32 specific global directives
diff --git a/sci-mathematics/rstudio/files/rstudio-0.97.336-paths.patch b/sci-mathematics/rstudio/files/rstudio-0.97.336-paths.patch
new file mode 100644
index 000000000000..7b44374a72d2
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.97.336-paths.patch
@@ -0,0 +1,112 @@
+change the install path, as by default everything is dumped right under
+the prefix. After fixing install paths, now fix the source so the
+program can find the moved resources.
+
+diff --git a/CMakeGlobals.txt b/CMakeGlobals.txt
+index da74970..1537bff 100644
+--- a/CMakeGlobals.txt
++++ b/CMakeGlobals.txt
+@@ -103,7 +103,7 @@ else()
+ else()
+ set(RSTUDIO_INSTALL_BIN bin)
+ endif()
+- set(RSTUDIO_INSTALL_SUPPORTING .)
++ set(RSTUDIO_INSTALL_SUPPORTING ${DISTRO_SHARE})
+ endif()
+
+ # if the install prefix is /usr/local then tweak as appropriate
+diff --git a/src/cpp/server/CMakeLists.txt b/src/cpp/server/CMakeLists.txt
+index af4db1c..96b767e 100644
+--- a/src/cpp/server/CMakeLists.txt
++++ b/src/cpp/server/CMakeLists.txt
+@@ -142,7 +142,7 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT}
+- DESTINATION ${RSERVER_INITD_DEBIAN_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_DEBIAN_DIR})
+
+ # install configured redhat init.d script
+ set(RSERVER_INITD_REDHAT_DIR "extras/init.d/redhat")
+@@ -150,7 +150,7 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_REDHAT_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_REDHAT_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_REDHAT_SCRIPT}
+- DESTINATION ${RSERVER_INITD_REDHAT_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_REDHAT_DIR})
+
+ # install configured suse init.d script
+ set(RSERVER_INITD_SUSE_DIR "extras/init.d/suse")
+@@ -158,13 +158,13 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_SUSE_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_SUSE_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_SUSE_SCRIPT}
+- DESTINATION ${RSERVER_INITD_SUSE_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_SUSE_DIR})
+
+ # install pam profile
+ set(RSERVER_PAM_DIR "extras/pam")
+ set(RSERVER_PAM_PROFILE "${RSERVER_PAM_DIR}/rstudio")
+ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_PAM_PROFILE}
+- DESTINATION ${RSERVER_PAM_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_PAM_DIR})
+
+ # install configured apparmor profile
+ set(RSERVER_APPARMOR_DIR "extras/apparmor")
+@@ -172,9 +172,9 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_APPARMOR_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_APPARMOR_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_APPARMOR_PROFILE}
+- DESTINATION ${RSERVER_APPARMOR_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_APPARMOR_DIR})
+ install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_APPARMOR_DIR}/apparmor-profile-load
+- DESTINATION ${RSERVER_APPARMOR_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_APPARMOR_DIR})
+
+ # install configured upstart profile
+ set(RSERVER_UPSTART_DIR "extras/upstart")
+@@ -182,6 +182,6 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_UPSTART_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE}
+- DESTINATION ${RSERVER_UPSTART_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_UPSTART_DIR})
+
+ endif()
+diff --git a/src/cpp/server/ServerOptions.cpp b/src/cpp/server/ServerOptions.cpp
+index 77a63f1..f0d25f0 100644
+--- a/src/cpp/server/ServerOptions.cpp
++++ b/src/cpp/server/ServerOptions.cpp
+@@ -201,7 +201,7 @@ ProgramStatus Options::read(int argc, char * const argv[])
+
+ // convert relative paths by completing from the system installation
+ // path (this allows us to be relocatable)
+- resolvePath(installPath, &wwwLocalPath_);
++ resolvePath(installPath.childPath(DISTRO_SHARE), &wwwLocalPath_);
+ resolvePath(installPath, &authPamHelperPath_);
+ resolvePath(installPath, &rsessionPath_);
+ resolvePath(installPath, &rldpathPath_);
+diff --git a/src/cpp/session/SessionOptions.cpp b/src/cpp/session/SessionOptions.cpp
+index 0df1081..777cc6a 100644
+--- a/src/cpp/session/SessionOptions.cpp
++++ b/src/cpp/session/SessionOptions.cpp
+@@ -333,12 +333,12 @@ core::ProgramStatus Options::read(int argc, char * const argv[])
+
+ // convert relative paths by completing from the app resource path
+- resolvePath(resourcePath, &rResourcesPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &rResourcesPath_);
+ resolvePath(resourcePath, &agreementFilePath_);
+- resolvePath(resourcePath, &wwwLocalPath_);
+- resolvePath(resourcePath, &coreRSourcePath_);
+- resolvePath(resourcePath, &modulesRSourcePath_);
+- resolvePath(resourcePath, &sessionLibraryPath_);
+- resolvePath(resourcePath, &sessionPackagesPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwLocalPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &coreRSourcePath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &modulesRSourcePath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &sessionLibraryPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &sessionPackagesPath_);
+ resolvePostbackPath(resourcePath, &rpostbackPath_);
+ #ifdef _WIN32
+ resolvePath(resourcePath, &consoleIoPath_);
+
diff --git a/sci-mathematics/rstudio/files/rstudio-0.97.336-prefs.patch b/sci-mathematics/rstudio/files/rstudio-0.97.336-prefs.patch
new file mode 100644
index 000000000000..3175d47235ab
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.97.336-prefs.patch
@@ -0,0 +1,24 @@
+And now we fix src/gwt/build.xml since java's user preference class is
+braindead and insists on writing where it is not allowed.
+much thanks to http://www.allaboutbalance.com/articles/disableprefs/
+
+diff --git a/src/gwt/build.xml b/src/gwt/build.xml
+index e7d2418..ae3a331 100644
+--- a/src/gwt/build.xml
++++ b/src/gwt/build.xml
+@@ -25,6 +25,7 @@
+ <property name="gwt.extra.args" value=""/>
+ <property name="gwt.main.module" value="org.rstudio.studio.RStudio"/>
+ <property name="ace.bin" value="src/org/rstudio/studio/client/workbench/views/source/editors/text/ace"/>
++ <property environment="env"/>
+
+ <path id="project.class.path">
+ <pathelement location="bin"/>
+@@ -109,6 +110,7 @@
+ </classpath>
+ <!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
+ <jvmarg value="-Xmx1024M"/>
++ <jvmarg value="-Djava.util.prefs.userRoot=${env.T}"/>
+ <arg value="-war"/>
+ <arg value="www"/>
+ <arg value="-localWorkers"/>
diff --git a/sci-mathematics/rstudio/files/rstudio-0.97.551-boost-1.53.patch b/sci-mathematics/rstudio/files/rstudio-0.97.551-boost-1.53.patch
new file mode 100644
index 000000000000..38bb63a8ab61
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.97.551-boost-1.53.patch
@@ -0,0 +1,64 @@
+=== modified file 'src/cpp/core/include/core/http/AsyncServer.hpp'
+--- src/cpp/core/include/core/http/AsyncServer.hpp 2013-07-09 12:02:58 +0000
++++ src/cpp/core/include/core/http/AsyncServer.hpp 2013-07-09 12:03:34 +0000
+@@ -264,7 +264,7 @@
+
+ // convert to cannonical HttpConnection
+ boost::shared_ptr<AsyncConnection> pAsyncConnection =
+- boost::shared_static_cast<AsyncConnection>(pConnection);
++ boost::static_pointer_cast<AsyncConnection>(pConnection);
+
+ // call the appropriate handler to generate a response
+ std::string uri = pRequest->uri();
+
+=== modified file 'src/cpp/core/include/core/http/LocalStreamAsyncClient.hpp'
+--- src/cpp/core/include/core/http/LocalStreamAsyncClient.hpp 2013-07-09 12:02:58 +0000
++++ src/cpp/core/include/core/http/LocalStreamAsyncClient.hpp 2013-07-09 12:03:36 +0000
+@@ -87,7 +87,7 @@
+ boost::shared_ptr<AsyncClient<boost::asio::local::stream_protocol::socket> >
+ ptrShared = shared_from_this();
+
+- return boost::shared_static_cast<LocalStreamAsyncClient>(ptrShared);
++ return boost::static_pointer_cast<LocalStreamAsyncClient>(ptrShared);
+ }
+
+ private:
+
+=== modified file 'src/cpp/core/include/core/http/TcpIpAsyncClient.hpp'
+--- src/cpp/core/include/core/http/TcpIpAsyncClient.hpp 2013-07-09 12:02:58 +0000
++++ src/cpp/core/include/core/http/TcpIpAsyncClient.hpp 2013-07-09 12:03:32 +0000
+@@ -74,7 +74,7 @@
+ boost::shared_ptr<AsyncClient<boost::asio::ip::tcp::socket> > ptrShared
+ = shared_from_this();
+
+- return boost::shared_static_cast<TcpIpAsyncClient>(ptrShared);
++ return boost::static_pointer_cast<TcpIpAsyncClient>(ptrShared);
+ }
+
+ private:
+
+=== modified file 'src/cpp/core/include/core/http/TcpIpAsyncClientSsl.hpp'
+--- src/cpp/core/include/core/http/TcpIpAsyncClientSsl.hpp 2013-07-09 12:02:58 +0000
++++ src/cpp/core/include/core/http/TcpIpAsyncClientSsl.hpp 2013-07-09 12:03:39 +0000
+@@ -109,7 +109,7 @@
+ boost::shared_ptr<AsyncClient<boost::asio::ssl::stream<boost::asio::ip::tcp::socket> > > ptrShared
+ = shared_from_this();
+
+- return boost::shared_static_cast<TcpIpAsyncClientSsl>(ptrShared);
++ return boost::static_pointer_cast<TcpIpAsyncClientSsl>(ptrShared);
+ }
+
+ virtual bool isShutdownError(const boost::system::error_code& ec)
+
+=== modified file 'src/cpp/session/http/SessionHttpConnectionListenerImpl.hpp'
+--- src/cpp/session/http/SessionHttpConnectionListenerImpl.hpp 2013-07-09 12:02:58 +0000
++++ src/cpp/session/http/SessionHttpConnectionListenerImpl.hpp 2013-07-09 12:03:29 +0000
+@@ -256,7 +256,7 @@
+ {
+ // convert to cannonical HttpConnection
+ boost::shared_ptr<HttpConnection> ptrHttpConnection =
+- boost::shared_static_cast<HttpConnection>(ptrConnection);
++ boost::static_pointer_cast<HttpConnection>(ptrConnection);
+
+ if (!authenticate(ptrHttpConnection))
+ {
diff --git a/sci-mathematics/rstudio/files/rstudio-0.97.551-linker_flags.patch b/sci-mathematics/rstudio/files/rstudio-0.97.551-linker_flags.patch
new file mode 100644
index 000000000000..a336fccbc981
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.97.551-linker_flags.patch
@@ -0,0 +1,18 @@
+Some gcc hardening options were added, however since we add
+"-Wl,--as-needed" we end up with "-Wl,--as-needed;-Wl,-z,relro" which
+leads to linker errors about unknown options, if we make it so the
+as-needed option is the last option on the line, everything is fine.
+
+diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt
+index 0589ca0..fe5bd5f 100644
+--- a/src/cpp/CMakeLists.txt
++++ b/src/cpp/CMakeLists.txt
+@@ -57,7 +57,7 @@ if(UNIX)
+ add_definitions(-D_FORTIFY_SOURCE=2)
+ add_definitions(-fstack-protector --param ssp-buffer-size=4)
+ add_definitions(-pie -fPIE)
+- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro,-z,now")
++ set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,relro,-z,now ${CMAKE_EXE_LINKER_FLAGS}")
+ endif()
+
+ # Win32 specific global directives
diff --git a/sci-mathematics/rstudio/files/rstudio-0.97.551-paths.patch b/sci-mathematics/rstudio/files/rstudio-0.97.551-paths.patch
new file mode 100644
index 000000000000..7b44374a72d2
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.97.551-paths.patch
@@ -0,0 +1,112 @@
+change the install path, as by default everything is dumped right under
+the prefix. After fixing install paths, now fix the source so the
+program can find the moved resources.
+
+diff --git a/CMakeGlobals.txt b/CMakeGlobals.txt
+index da74970..1537bff 100644
+--- a/CMakeGlobals.txt
++++ b/CMakeGlobals.txt
+@@ -103,7 +103,7 @@ else()
+ else()
+ set(RSTUDIO_INSTALL_BIN bin)
+ endif()
+- set(RSTUDIO_INSTALL_SUPPORTING .)
++ set(RSTUDIO_INSTALL_SUPPORTING ${DISTRO_SHARE})
+ endif()
+
+ # if the install prefix is /usr/local then tweak as appropriate
+diff --git a/src/cpp/server/CMakeLists.txt b/src/cpp/server/CMakeLists.txt
+index af4db1c..96b767e 100644
+--- a/src/cpp/server/CMakeLists.txt
++++ b/src/cpp/server/CMakeLists.txt
+@@ -142,7 +142,7 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT}
+- DESTINATION ${RSERVER_INITD_DEBIAN_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_DEBIAN_DIR})
+
+ # install configured redhat init.d script
+ set(RSERVER_INITD_REDHAT_DIR "extras/init.d/redhat")
+@@ -150,7 +150,7 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_REDHAT_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_REDHAT_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_REDHAT_SCRIPT}
+- DESTINATION ${RSERVER_INITD_REDHAT_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_REDHAT_DIR})
+
+ # install configured suse init.d script
+ set(RSERVER_INITD_SUSE_DIR "extras/init.d/suse")
+@@ -158,13 +158,13 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_SUSE_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_SUSE_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_SUSE_SCRIPT}
+- DESTINATION ${RSERVER_INITD_SUSE_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_SUSE_DIR})
+
+ # install pam profile
+ set(RSERVER_PAM_DIR "extras/pam")
+ set(RSERVER_PAM_PROFILE "${RSERVER_PAM_DIR}/rstudio")
+ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_PAM_PROFILE}
+- DESTINATION ${RSERVER_PAM_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_PAM_DIR})
+
+ # install configured apparmor profile
+ set(RSERVER_APPARMOR_DIR "extras/apparmor")
+@@ -172,9 +172,9 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_APPARMOR_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_APPARMOR_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_APPARMOR_PROFILE}
+- DESTINATION ${RSERVER_APPARMOR_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_APPARMOR_DIR})
+ install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_APPARMOR_DIR}/apparmor-profile-load
+- DESTINATION ${RSERVER_APPARMOR_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_APPARMOR_DIR})
+
+ # install configured upstart profile
+ set(RSERVER_UPSTART_DIR "extras/upstart")
+@@ -182,6 +182,6 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_UPSTART_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE}
+- DESTINATION ${RSERVER_UPSTART_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_UPSTART_DIR})
+
+ endif()
+diff --git a/src/cpp/server/ServerOptions.cpp b/src/cpp/server/ServerOptions.cpp
+index 77a63f1..f0d25f0 100644
+--- a/src/cpp/server/ServerOptions.cpp
++++ b/src/cpp/server/ServerOptions.cpp
+@@ -201,7 +201,7 @@ ProgramStatus Options::read(int argc, char * const argv[])
+
+ // convert relative paths by completing from the system installation
+ // path (this allows us to be relocatable)
+- resolvePath(installPath, &wwwLocalPath_);
++ resolvePath(installPath.childPath(DISTRO_SHARE), &wwwLocalPath_);
+ resolvePath(installPath, &authPamHelperPath_);
+ resolvePath(installPath, &rsessionPath_);
+ resolvePath(installPath, &rldpathPath_);
+diff --git a/src/cpp/session/SessionOptions.cpp b/src/cpp/session/SessionOptions.cpp
+index 0df1081..777cc6a 100644
+--- a/src/cpp/session/SessionOptions.cpp
++++ b/src/cpp/session/SessionOptions.cpp
+@@ -333,12 +333,12 @@ core::ProgramStatus Options::read(int argc, char * const argv[])
+
+ // convert relative paths by completing from the app resource path
+- resolvePath(resourcePath, &rResourcesPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &rResourcesPath_);
+ resolvePath(resourcePath, &agreementFilePath_);
+- resolvePath(resourcePath, &wwwLocalPath_);
+- resolvePath(resourcePath, &coreRSourcePath_);
+- resolvePath(resourcePath, &modulesRSourcePath_);
+- resolvePath(resourcePath, &sessionLibraryPath_);
+- resolvePath(resourcePath, &sessionPackagesPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwLocalPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &coreRSourcePath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &modulesRSourcePath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &sessionLibraryPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &sessionPackagesPath_);
+ resolvePostbackPath(resourcePath, &rpostbackPath_);
+ #ifdef _WIN32
+ resolvePath(resourcePath, &consoleIoPath_);
+
diff --git a/sci-mathematics/rstudio/files/rstudio-0.97.551-prefs.patch b/sci-mathematics/rstudio/files/rstudio-0.97.551-prefs.patch
new file mode 100644
index 000000000000..3175d47235ab
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.97.551-prefs.patch
@@ -0,0 +1,24 @@
+And now we fix src/gwt/build.xml since java's user preference class is
+braindead and insists on writing where it is not allowed.
+much thanks to http://www.allaboutbalance.com/articles/disableprefs/
+
+diff --git a/src/gwt/build.xml b/src/gwt/build.xml
+index e7d2418..ae3a331 100644
+--- a/src/gwt/build.xml
++++ b/src/gwt/build.xml
+@@ -25,6 +25,7 @@
+ <property name="gwt.extra.args" value=""/>
+ <property name="gwt.main.module" value="org.rstudio.studio.RStudio"/>
+ <property name="ace.bin" value="src/org/rstudio/studio/client/workbench/views/source/editors/text/ace"/>
++ <property environment="env"/>
+
+ <path id="project.class.path">
+ <pathelement location="bin"/>
+@@ -109,6 +110,7 @@
+ </classpath>
+ <!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
+ <jvmarg value="-Xmx1024M"/>
++ <jvmarg value="-Djava.util.prefs.userRoot=${env.T}"/>
+ <arg value="-war"/>
+ <arg value="www"/>
+ <arg value="-localWorkers"/>
diff --git a/sci-mathematics/rstudio/files/rstudio-0.98.1091-boost-1.57.patch b/sci-mathematics/rstudio/files/rstudio-0.98.1091-boost-1.57.patch
new file mode 100644
index 000000000000..3a157183c22c
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.98.1091-boost-1.57.patch
@@ -0,0 +1,60 @@
+--- rstudio-0.98.1091-orig/src/cpp/desktop/DesktopApplicationLaunch.hpp 2014-11-06 23:15:47.000000000 +1100
++++ rstudio-0.98.1091/src/cpp/desktop/DesktopApplicationLaunch.hpp 2015-02-28 14:01:51.970672316 +1100
+@@ -19,7 +19,10 @@
+ #include <QObject>
+ #include <QWidget>
+ #include <QApplication>
++// see https://bugreports.qt-project.org/browse/QTBUG-22829
++#ifndef Q_MOC_RUN
+ #include <boost/scoped_ptr.hpp>
++#endif
+
+ namespace desktop {
+
+--- rstudio-0.98.1091-orig/src/cpp/desktop/DesktopSessionLauncher.hpp 2014-11-06 23:15:47.000000000 +1100
++++ rstudio-0.98.1091/src/cpp/desktop/DesktopSessionLauncher.hpp 2015-02-28 14:01:51.972672316 +1100
+@@ -18,7 +18,10 @@
+
+ #include <string>
+
++// see https://bugreports.qt-project.org/browse/QTBUG-22829
++#ifndef Q_MOC_RUN
+ #include <boost/utility.hpp>
++#endif
+
+ #include <core/Error.hpp>
+ #include <core/FilePath.hpp>
+--- rstudio-0.98.1091-orig/src/cpp/core/include/core/FilePath.hpp 2014-11-06 23:15:47.000000000 +1100
++++ rstudio-0.98.1091/src/cpp/core/include/core/FilePath.hpp 2015-02-28 14:01:51.984672314 +1100
+@@ -23,11 +23,14 @@
+ #include <vector>
+ #include <iosfwd>
+
++// see https://bugreports.qt-project.org/browse/QTBUG-22829
++#ifndef Q_MOC_RUN
+ #include <boost/shared_ptr.hpp>
+ #include <boost/scoped_ptr.hpp>
+ #include <boost/function.hpp>
+
+ #include <boost/utility.hpp>
++#endif
+
+ #include <core/Error.hpp>
+ #include <core/Log.hpp>
+--- rstudio-0.98.1091-orig/src/cpp/core/include/core/Error.hpp 2014-11-06 23:15:47.000000000 +1100
++++ rstudio-0.98.1091/src/cpp/core/include/core/Error.hpp 2015-02-28 14:01:51.977672315 +1100
+@@ -20,11 +20,14 @@
+ #include <string>
+ #include <vector>
+
++// see https://bugreports.qt-project.org/browse/QTBUG-22829
++#ifndef Q_MOC_RUN
+ #include <boost/shared_ptr.hpp>
+
+ #include <boost/system/error_code.hpp>
+
+ #include <boost/current_function.hpp>
++#endif
+
+ namespace core {
+
diff --git a/sci-mathematics/rstudio/files/rstudio-0.98.1091-pandoc.patch b/sci-mathematics/rstudio/files/rstudio-0.98.1091-pandoc.patch
new file mode 100644
index 000000000000..3df8d1a986a3
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.98.1091-pandoc.patch
@@ -0,0 +1,26 @@
+--- rstudio-0.98.1091-orig/src/cpp/session/CMakeLists.txt 2014-11-06 23:15:47.000000000 +1100
++++ rstudio-0.98.1091/src/cpp/session/CMakeLists.txt 2014-11-26 17:12:42.699712510 +1100
+@@ -25,9 +25,6 @@
+ if(NOT EXISTS "${RSTUDIO_DEPENDENCIES_DIR}/common/mathjax-23")
+ message(FATAL_ERROR "Mathjax 2.3 not found (re-run install-dependencies script to install)")
+ endif()
+-if(NOT EXISTS "${RSTUDIO_DEPENDENCIES_DIR}/common/pandoc")
+- message(FATAL_ERROR "pandoc not found (re-run install-dependencies script to install)")
+-endif()
+ if(NOT EXISTS "${RSTUDIO_DEPENDENCIES_DIR}/common/rmarkdown")
+ message(FATAL_ERROR "rmarkdown package not found (re-run install-dependencies script to install)")
+ endif()
+@@ -343,13 +340,6 @@
+ install(DIRECTORY "${RSTUDIO_DEPENDENCIES_DIR}/common/mathjax-23"
+ DESTINATION "${RSTUDIO_INSTALL_SUPPORTING}/resources")
+
+- # install pandoc
+- set(PANDOC_BIN "${RSTUDIO_DEPENDENCIES_DIR}/common/pandoc/1.12.4.2")
+- file(GLOB PANDOC_FILES "${PANDOC_BIN}/pandoc*")
+- install(FILES ${PANDOC_FILES}
+- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+- DESTINATION ${RSTUDIO_INSTALL_BIN}/pandoc)
+-
+ # install rmarkdown package
+ file(GLOB RMARKDOWN_PACKAGE "${RSTUDIO_DEPENDENCIES_DIR}/common/rmarkdown*.tar.gz")
+ install(FILES ${RMARKDOWN_PACKAGE}
diff --git a/sci-mathematics/rstudio/files/rstudio-0.98.490-linker_flags.patch b/sci-mathematics/rstudio/files/rstudio-0.98.490-linker_flags.patch
new file mode 100644
index 000000000000..a336fccbc981
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.98.490-linker_flags.patch
@@ -0,0 +1,18 @@
+Some gcc hardening options were added, however since we add
+"-Wl,--as-needed" we end up with "-Wl,--as-needed;-Wl,-z,relro" which
+leads to linker errors about unknown options, if we make it so the
+as-needed option is the last option on the line, everything is fine.
+
+diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt
+index 0589ca0..fe5bd5f 100644
+--- a/src/cpp/CMakeLists.txt
++++ b/src/cpp/CMakeLists.txt
+@@ -57,7 +57,7 @@ if(UNIX)
+ add_definitions(-D_FORTIFY_SOURCE=2)
+ add_definitions(-fstack-protector --param ssp-buffer-size=4)
+ add_definitions(-pie -fPIE)
+- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro,-z,now")
++ set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,relro,-z,now ${CMAKE_EXE_LINKER_FLAGS}")
+ endif()
+
+ # Win32 specific global directives
diff --git a/sci-mathematics/rstudio/files/rstudio-0.98.490-paths.patch b/sci-mathematics/rstudio/files/rstudio-0.98.490-paths.patch
new file mode 100644
index 000000000000..d28ad5cb0752
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.98.490-paths.patch
@@ -0,0 +1,120 @@
+diff --git a/CMakeGlobals.txt b/CMakeGlobals.txt
+index cc10191..f75b85a 100644
+--- a/CMakeGlobals.txt
++++ b/CMakeGlobals.txt
+@@ -105,7 +105,7 @@ else()
+ else()
+ set(RSTUDIO_INSTALL_BIN bin)
+ endif()
+- set(RSTUDIO_INSTALL_SUPPORTING .)
++ set(RSTUDIO_INSTALL_SUPPORTING ${DISTRO_SHARE})
+ endif()
+
+ # if the install prefix is /usr/local then tweak as appropriate
+diff --git a/src/cpp/server/CMakeLists.txt b/src/cpp/server/CMakeLists.txt
+index 184e514..d09aac5 100644
+--- a/src/cpp/server/CMakeLists.txt
++++ b/src/cpp/server/CMakeLists.txt
+@@ -145,7 +145,7 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT}
+- DESTINATION ${RSERVER_INITD_DEBIAN_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_DEBIAN_DIR})
+
+ # install configured redhat init.d script
+ set(RSERVER_INITD_REDHAT_DIR "extras/init.d/redhat")
+@@ -153,7 +153,7 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_REDHAT_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_REDHAT_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_REDHAT_SCRIPT}
+- DESTINATION ${RSERVER_INITD_REDHAT_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_REDHAT_DIR})
+
+ # install configured suse init.d script
+ set(RSERVER_INITD_SUSE_DIR "extras/init.d/suse")
+@@ -161,13 +161,13 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_SUSE_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_SUSE_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_SUSE_SCRIPT}
+- DESTINATION ${RSERVER_INITD_SUSE_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_SUSE_DIR})
+
+ # install pam profile
+ set(RSERVER_PAM_DIR "extras/pam")
+ set(RSERVER_PAM_PROFILE "${RSERVER_PAM_DIR}/rstudio")
+ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_PAM_PROFILE}
+- DESTINATION ${RSERVER_PAM_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_PAM_DIR})
+
+ # install configured apparmor profile
+ set(RSERVER_APPARMOR_DIR "extras/apparmor")
+@@ -175,9 +175,9 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_APPARMOR_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_APPARMOR_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_APPARMOR_PROFILE}
+- DESTINATION ${RSERVER_APPARMOR_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_APPARMOR_DIR})
+ install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_APPARMOR_DIR}/apparmor-profile-load
+- DESTINATION ${RSERVER_APPARMOR_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_APPARMOR_DIR})
+
+ # install configured upstart profile
+ set(RSERVER_UPSTART_DIR "extras/upstart")
+@@ -185,12 +185,12 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_UPSTART_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE}
+- DESTINATION ${RSERVER_UPSTART_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_UPSTART_DIR})
+ set(RSERVER_UPSTART_PROFILE_REDHAT "${RSERVER_UPSTART_DIR}/rstudio-server.redhat.conf")
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_UPSTART_PROFILE_REDHAT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE_REDHAT})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE_REDHAT}
+- DESTINATION ${RSERVER_UPSTART_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_UPSTART_DIR})
+
+ endif()
+
+diff --git a/src/cpp/server/ServerOptions.cpp b/src/cpp/server/ServerOptions.cpp
+index 1eaf7c0..4b25fa1 100644
+--- a/src/cpp/server/ServerOptions.cpp
++++ b/src/cpp/server/ServerOptions.cpp
+@@ -307,8 +307,8 @@ ProgramStatus Options::read(int argc,
+
+ // convert relative paths by completing from the system installation
+ // path (this allows us to be relocatable)
+- resolvePath(resourcePath, &wwwLocalPath_);
+- resolvePath(resourcePath, &wwwSymbolMapsPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwLocalPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwSymbolMapsPath_);
+ resolvePath(binaryPath, &authPamHelperPath_);
+ resolvePath(binaryPath, &rsessionPath_);
+ resolvePath(binaryPath, &rldpathPath_);
+diff --git a/src/cpp/session/SessionOptions.cpp b/src/cpp/session/SessionOptions.cpp
+index 44b3d55..a48cdb6 100644
+--- a/src/cpp/session/SessionOptions.cpp
++++ b/src/cpp/session/SessionOptions.cpp
+@@ -357,14 +357,14 @@ core::ProgramStatus Options::read(int argc, char * const argv[])
+ timeoutMinutes_ = 0;
+
+ // convert relative paths by completing from the app resource path
+- resolvePath(resourcePath, &rResourcesPath_);
+- resolvePath(resourcePath, &agreementFilePath_);
+- resolvePath(resourcePath, &wwwLocalPath_);
+- resolvePath(resourcePath, &wwwSymbolMapsPath_);
+- resolvePath(resourcePath, &coreRSourcePath_);
+- resolvePath(resourcePath, &modulesRSourcePath_);
+- resolvePath(resourcePath, &sessionLibraryPath_);
+- resolvePath(resourcePath, &sessionPackagesPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &rResourcesPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &agreementFilePath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwLocalPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &coreRSourcePath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &modulesRSourcePath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &sessionLibraryPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &sessionPackagesPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwSymbolMapsPath_);
+ resolvePostbackPath(resourcePath, &rpostbackPath_);
+ #ifdef _WIN32
+ resolvePath(resourcePath, &consoleIoPath_);
diff --git a/sci-mathematics/rstudio/files/rstudio-0.98.490-prefs.patch b/sci-mathematics/rstudio/files/rstudio-0.98.490-prefs.patch
new file mode 100644
index 000000000000..3175d47235ab
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.98.490-prefs.patch
@@ -0,0 +1,24 @@
+And now we fix src/gwt/build.xml since java's user preference class is
+braindead and insists on writing where it is not allowed.
+much thanks to http://www.allaboutbalance.com/articles/disableprefs/
+
+diff --git a/src/gwt/build.xml b/src/gwt/build.xml
+index e7d2418..ae3a331 100644
+--- a/src/gwt/build.xml
++++ b/src/gwt/build.xml
+@@ -25,6 +25,7 @@
+ <property name="gwt.extra.args" value=""/>
+ <property name="gwt.main.module" value="org.rstudio.studio.RStudio"/>
+ <property name="ace.bin" value="src/org/rstudio/studio/client/workbench/views/source/editors/text/ace"/>
++ <property environment="env"/>
+
+ <path id="project.class.path">
+ <pathelement location="bin"/>
+@@ -109,6 +110,7 @@
+ </classpath>
+ <!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
+ <jvmarg value="-Xmx1024M"/>
++ <jvmarg value="-Djava.util.prefs.userRoot=${env.T}"/>
+ <arg value="-war"/>
+ <arg value="www"/>
+ <arg value="-localWorkers"/>
diff --git a/sci-mathematics/rstudio/files/rstudio-0.98.932-pandoc.patch b/sci-mathematics/rstudio/files/rstudio-0.98.932-pandoc.patch
new file mode 100644
index 000000000000..d2b6911eabb8
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.98.932-pandoc.patch
@@ -0,0 +1,25 @@
+--- a/src/cpp/session/CMakeLists.txt
++++ b/src/cpp/session/CMakeLists.txt
+@@ -25,9 +25,6 @@
+ if(NOT EXISTS "${RSTUDIO_DEPENDENCIES_DIR}/common/mathjax")
+ message(FATAL_ERROR "Mathjax not found (re-run install-dependencies script to install)")
+ endif()
+-if(NOT EXISTS "${RSTUDIO_DEPENDENCIES_DIR}/common/pandoc")
+- message(FATAL_ERROR "pandoc not found (re-run install-dependencies script to install)")
+-endif()
+ if(NOT EXISTS "${RSTUDIO_DEPENDENCIES_DIR}/common/rmarkdown")
+ message(FATAL_ERROR "rmarkdown package not found (re-run install-dependencies script to install)")
+ endif()
+@@ -337,12 +334,6 @@
+ install(DIRECTORY "${RSTUDIO_DEPENDENCIES_DIR}/common/mathjax"
+ DESTINATION "${RSTUDIO_INSTALL_SUPPORTING}/resources")
+
+- # install pandoc
+- set(PANDOC_BIN "${RSTUDIO_DEPENDENCIES_DIR}/common/pandoc/1.12.3")
+- file(GLOB PANDOC_FILES "${PANDOC_BIN}/pandoc*")
+- install(PROGRAMS ${PANDOC_FILES}
+- DESTINATION ${RSTUDIO_INSTALL_BIN}/pandoc)
+-
+ # install rmarkdown package
+ file(GLOB RMARKDOWN_PACKAGE "${RSTUDIO_DEPENDENCIES_DIR}/common/rmarkdown*.tar.gz")
+ install(FILES ${RMARKDOWN_PACKAGE}
diff --git a/sci-mathematics/rstudio/files/rstudio-0.98.932-paths.patch b/sci-mathematics/rstudio/files/rstudio-0.98.932-paths.patch
new file mode 100644
index 000000000000..d4bb4249f1a6
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.98.932-paths.patch
@@ -0,0 +1,140 @@
+diff --git a/CMakeGlobals.txt b/CMakeGlobals.txt
+index cc10191..f75b85a 100644
+--- a/CMakeGlobals.txt
++++ b/CMakeGlobals.txt
+@@ -105,7 +105,7 @@ else()
+ else()
+ set(RSTUDIO_INSTALL_BIN bin)
+ endif()
+- set(RSTUDIO_INSTALL_SUPPORTING .)
++ set(RSTUDIO_INSTALL_SUPPORTING ${DISTRO_SHARE})
+ endif()
+
+ # if the install prefix is /usr/local then tweak as appropriate
+diff --git a/src/cpp/server/CMakeLists.txt b/src/cpp/server/CMakeLists.txt
+index 184e514..d09aac5 100644
+--- a/src/cpp/server/CMakeLists.txt
++++ b/src/cpp/server/CMakeLists.txt
+@@ -145,7 +145,7 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT}
+- DESTINATION ${RSERVER_INITD_DEBIAN_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_DEBIAN_DIR})
+
+ # install configured redhat init.d script
+ set(RSERVER_INITD_REDHAT_DIR "extras/init.d/redhat")
+@@ -153,7 +153,7 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_REDHAT_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_REDHAT_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_REDHAT_SCRIPT}
+- DESTINATION ${RSERVER_INITD_REDHAT_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_REDHAT_DIR})
+
+ # install configured suse init.d script
+ set(RSERVER_INITD_SUSE_DIR "extras/init.d/suse")
+@@ -161,13 +161,13 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_SUSE_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_SUSE_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_SUSE_SCRIPT}
+- DESTINATION ${RSERVER_INITD_SUSE_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_SUSE_DIR})
+
+ # install pam profile
+ set(RSERVER_PAM_DIR "extras/pam")
+ set(RSERVER_PAM_PROFILE "${RSERVER_PAM_DIR}/rstudio")
+ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_PAM_PROFILE}
+- DESTINATION ${RSERVER_PAM_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_PAM_DIR})
+
+ # install configured apparmor profile
+ set(RSERVER_APPARMOR_DIR "extras/apparmor")
+@@ -175,9 +175,9 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_APPARMOR_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_APPARMOR_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_APPARMOR_PROFILE}
+- DESTINATION ${RSERVER_APPARMOR_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_APPARMOR_DIR})
+ install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_APPARMOR_DIR}/apparmor-profile-load
+- DESTINATION ${RSERVER_APPARMOR_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_APPARMOR_DIR})
+
+ # install configured upstart profile
+ set(RSERVER_UPSTART_DIR "extras/upstart")
+@@ -185,12 +185,12 @@ if (UNIX AND NOT APPLE)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_UPSTART_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE}
+- DESTINATION ${RSERVER_UPSTART_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_UPSTART_DIR})
+ set(RSERVER_UPSTART_PROFILE_REDHAT "${RSERVER_UPSTART_DIR}/rstudio-server.redhat.conf")
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_UPSTART_PROFILE_REDHAT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE_REDHAT})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE_REDHAT}
+- DESTINATION ${RSERVER_UPSTART_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_UPSTART_DIR})
+
+ endif()
+
+diff --git a/src/cpp/server/ServerOptions.cpp b/src/cpp/server/ServerOptions.cpp
+index 1eaf7c0..4b25fa1 100644
+--- a/src/cpp/server/ServerOptions.cpp
++++ b/src/cpp/server/ServerOptions.cpp
+@@ -307,8 +307,8 @@ ProgramStatus Options::read(int argc,
+
+ // convert relative paths by completing from the system installation
+ // path (this allows us to be relocatable)
+- resolvePath(resourcePath, &wwwLocalPath_);
+- resolvePath(resourcePath, &wwwSymbolMapsPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwLocalPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwSymbolMapsPath_);
+ resolvePath(binaryPath, &authPamHelperPath_);
+ resolvePath(binaryPath, &rsessionPath_);
+ resolvePath(binaryPath, &rldpathPath_);
+diff --git a/src/cpp/session/SessionOptions.cpp b/src/cpp/session/SessionOptions.cpp
+index 44b3d55..a48cdb6 100644
+--- a/src/cpp/session/SessionOptions.cpp
++++ b/src/cpp/session/SessionOptions.cpp
+@@ -40,7 +40,7 @@
+ namespace session {
+
+ namespace {
+-const char* const kDefaultPandocPath = "bin/pandoc";
++const char* const kDefaultPandocPath = "bin";
+ const char* const kDefaultPostbackPath = "bin/postback/rpostback";
+ } // anonymous namespace
+
+@@ -392,15 +392,15 @@
+ }
+
+ // convert relative paths by completing from the app resource path
+- resolvePath(resourcePath, &rResourcesPath_);
+- resolvePath(resourcePath, &agreementFilePath_);
+- resolvePath(resourcePath, &wwwLocalPath_);
+- resolvePath(resourcePath, &wwwSymbolMapsPath_);
+- resolvePath(resourcePath, &coreRSourcePath_);
+- resolvePath(resourcePath, &modulesRSourcePath_);
+- resolvePath(resourcePath, &sessionLibraryPath_);
+- resolvePath(resourcePath, &sessionPackagesPath_);
+- resolvePath(resourcePath, &sessionPackageArchivesPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &rResourcesPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &agreementFilePath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwLocalPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &coreRSourcePath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &modulesRSourcePath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &sessionLibraryPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &sessionPackagesPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &sessionPackageArchivesPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwSymbolMapsPath_);
+ resolvePostbackPath(resourcePath, &rpostbackPath_);
+ #ifdef _WIN32
+ resolvePath(resourcePath, &consoleIoPath_);
+@@ -409,7 +409,7 @@
+ resolvePath(resourcePath, &msysSshPath_);
+ resolvePath(resourcePath, &sumatraPath_);
+ #endif
+- resolvePath(resourcePath, &hunspellDictionariesPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &hunspellDictionariesPath_);
+ resolvePath(resourcePath, &mathjaxPath_);
+ resolvePandocPath(resourcePath, &pandocPath_);
+
diff --git a/sci-mathematics/rstudio/files/rstudio-0.99.473-clang-pandoc.patch b/sci-mathematics/rstudio/files/rstudio-0.99.473-clang-pandoc.patch
new file mode 100644
index 000000000000..b37a91929574
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.99.473-clang-pandoc.patch
@@ -0,0 +1,77 @@
+--- rstudio-0.99.473-orig/src/cpp/session/CMakeLists.txt 2015-08-12 09:58:43.000000000 +1000
++++ rstudio-0.99.473/src/cpp/session/CMakeLists.txt 2015-08-27 00:51:48.395751378 +1000
+@@ -25,30 +25,11 @@
+ if(NOT EXISTS "${RSTUDIO_DEPENDENCIES_DIR}/common/mathjax-23")
+ message(FATAL_ERROR "Mathjax 2.3 not found (re-run install-dependencies script to install)")
+ endif()
+-if(NOT EXISTS "${RSTUDIO_DEPENDENCIES_DIR}/common/pandoc")
+- message(FATAL_ERROR "pandoc not found (re-run install-dependencies script to install)")
+-endif()
+ if(NOT EXISTS "${RSTUDIO_DEPENDENCIES_DIR}/common/rsconnect")
+ message(FATAL_ERROR "rsconnect package not found (re-run install-dependencies script to install)")
+ endif()
+
+
+-# verify libclang is installed
+-if(WIN32)
+- set(LIBCLANG_VERSION "3.4")
+-else()
+- set(LIBCLANG_VERSION "3.5")
+-endif()
+-set(LIBCLANG_DIR "${RSTUDIO_DEPENDENCIES_DIR}/common/libclang/${LIBCLANG_VERSION}")
+-if(NOT EXISTS "${LIBCLANG_DIR}")
+- message(FATAL_ERROR "libclang ${LIBCLANG_VERSION} not found (re-run install-dependencies script to install)")
+-endif()
+-set(LIBCLANG_HEADERS_DIR "${RSTUDIO_DEPENDENCIES_DIR}/common/libclang/builtin-headers")
+-if(NOT EXISTS "${LIBCLANG_HEADERS_DIR}")
+- message(FATAL_ERROR "libclang builtin-headers not found (re-run install-dependencies script to install)")
+-endif()
+-
+-
+ # include files
+ file(GLOB_RECURSE SESSION_HEADER_FILES "*.h*")
+
+@@ -391,18 +372,6 @@
+ install(DIRECTORY "${RSTUDIO_DEPENDENCIES_DIR}/common/mathjax-23"
+ DESTINATION "${RSTUDIO_INSTALL_SUPPORTING}/resources")
+
+- # install pandoc
+- if(RSTUDIO_PACKAGE_BUILD_SLES)
+- # when producing a SUSE Linux Enterpise build, we want to install the
+- # static Pandoc binaries (see dependencies/common/install-pandoc)
+- set(PANDOC_EXTENSION_DIR "/static")
+- endif()
+- set(PANDOC_BIN "${RSTUDIO_DEPENDENCIES_DIR}/common/pandoc/1.13.1${PANDOC_EXTENSION_DIR}")
+- file(GLOB PANDOC_FILES "${PANDOC_BIN}/pandoc*")
+- install(FILES ${PANDOC_FILES}
+- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+- DESTINATION ${RSTUDIO_INSTALL_BIN}/pandoc)
+-
+ # install rsconnect package
+ file(GLOB RSCONNECT_PACKAGE "${RSTUDIO_DEPENDENCIES_DIR}/common/rsconnect*.tar.gz")
+ install(FILES ${RSCONNECT_PACKAGE}
+@@ -420,24 +389,6 @@
+ install(DIRECTORY "resources/help_resources"
+ DESTINATION ${RSTUDIO_INSTALL_SUPPORTING}/resources)
+
+- # install libclang
+- if(WIN32)
+- file(GLOB LIBCLANG_32_FILES "${LIBCLANG_DIR}/x86/libclang.*")
+- install(PROGRAMS ${LIBCLANG_32_FILES}
+- DESTINATION ${RSTUDIO_INSTALL_BIN}/rsclang/x86)
+- file(GLOB LIBCLANG_64_FILES "${LIBCLANG_DIR}/x86_64/libclang.*")
+- install(PROGRAMS ${LIBCLANG_64_FILES}
+- DESTINATION ${RSTUDIO_INSTALL_BIN}/rsclang/x86_64)
+- else()
+- file(GLOB_RECURSE LIBCLANG_FILES "${LIBCLANG_DIR}/libclang.*")
+- install(PROGRAMS ${LIBCLANG_FILES}
+- DESTINATION ${RSTUDIO_INSTALL_BIN}/rsclang)
+- endif()
+-
+- # install libclang builtin-headers
+- install(DIRECTORY "${RSTUDIO_DEPENDENCIES_DIR}/common/libclang/builtin-headers"
+- DESTINATION "${RSTUDIO_INSTALL_SUPPORTING}/resources/libclang")
+-
+ # install 64 bit binaries if we are on win64
+ if(WIN32)
+ if(NOT ("$ENV{PROGRAMW6432}" STREQUAL ""))
diff --git a/sci-mathematics/rstudio/files/rstudio-0.99.473-paths.patch b/sci-mathematics/rstudio/files/rstudio-0.99.473-paths.patch
new file mode 100644
index 000000000000..6b8d8886e21e
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.99.473-paths.patch
@@ -0,0 +1,130 @@
+--- rstudio-0.99.473-orig/CMakeGlobals.txt 2015-08-12 09:58:43.000000000 +1000
++++ rstudio-0.99.473/CMakeGlobals.txt 2015-08-26 22:12:43.614346285 +1000
+@@ -111,7 +111,7 @@
+ else()
+ set(RSTUDIO_INSTALL_BIN bin)
+ endif()
+- set(RSTUDIO_INSTALL_SUPPORTING .)
++ set(RSTUDIO_INSTALL_SUPPORTING ${DISTRO_SHARE})
+ endif()
+
+ # if the install prefix is /usr/local then tweak as appropriate
+--- rstudio-0.99.473-orig/src/cpp/server/CMakeLists.txt 2015-08-12 09:58:43.000000000 +1000
++++ rstudio-0.99.473/src/cpp/server/CMakeLists.txt 2015-08-26 22:15:30.988353389 +1000
+@@ -160,7 +160,7 @@
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT}
+- DESTINATION ${RSERVER_INITD_DEBIAN_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_DEBIAN_DIR})
+
+ # install configured redhat init.d script
+ set(RSERVER_INITD_REDHAT_DIR "extras/init.d/redhat")
+@@ -168,7 +168,7 @@
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_REDHAT_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_REDHAT_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_REDHAT_SCRIPT}
+- DESTINATION ${RSERVER_INITD_REDHAT_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_REDHAT_DIR})
+
+ # install configured suse init.d script
+ set(RSERVER_INITD_SUSE_DIR "extras/init.d/suse")
+@@ -176,13 +176,13 @@
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_SUSE_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_SUSE_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_SUSE_SCRIPT}
+- DESTINATION ${RSERVER_INITD_SUSE_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_SUSE_DIR})
+
+ # install pam profile
+ set(RSERVER_PAM_DIR "extras/pam")
+ set(RSERVER_PAM_PROFILE "${RSERVER_PAM_DIR}/rstudio")
+ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_PAM_PROFILE}
+- DESTINATION ${RSERVER_PAM_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_PAM_DIR})
+
+ # install configured apparmor profile
+ set(RSERVER_APPARMOR_DIR "extras/apparmor")
+@@ -190,9 +190,9 @@
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_APPARMOR_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_APPARMOR_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_APPARMOR_PROFILE}
+- DESTINATION ${RSERVER_APPARMOR_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_APPARMOR_DIR})
+ install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_APPARMOR_DIR}/apparmor-profile-load
+- DESTINATION ${RSERVER_APPARMOR_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_APPARMOR_DIR})
+
+ # install configured upstart profile
+ set(RSERVER_UPSTART_DIR "extras/upstart")
+@@ -200,12 +200,12 @@
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_UPSTART_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE}
+- DESTINATION ${RSERVER_UPSTART_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_UPSTART_DIR})
+ set(RSERVER_UPSTART_PROFILE_REDHAT "${RSERVER_UPSTART_DIR}/rstudio-server.redhat.conf")
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_UPSTART_PROFILE_REDHAT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE_REDHAT})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE_REDHAT}
+- DESTINATION ${RSERVER_UPSTART_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_UPSTART_DIR})
+
+ # install configured systemd profile
+ set(RSERVER_SYSTEMD_DIR "extras/systemd")
+--- rstudio-0.99.473-orig/src/cpp/server/ServerOptions.cpp 2015-08-12 09:58:43.000000000 +1000
++++ rstudio-0.99.473/src/cpp/server/ServerOptions.cpp 2015-08-26 22:12:43.615346286 +1000
+@@ -314,8 +314,8 @@
+
+ // convert relative paths by completing from the system installation
+ // path (this allows us to be relocatable)
+- resolvePath(resourcePath, &wwwLocalPath_);
+- resolvePath(resourcePath, &wwwSymbolMapsPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwLocalPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwSymbolMapsPath_);
+ resolvePath(binaryPath, &authPamHelperPath_);
+ resolvePath(binaryPath, &rsessionPath_);
+ resolvePath(binaryPath, &rldpathPath_);
+--- rstudio-0.99.473-orig/src/cpp/session/SessionOptions.cpp 2015-08-12 09:58:43.000000000 +1000
++++ rstudio-0.99.473/src/cpp/session/SessionOptions.cpp 2015-08-26 22:17:40.594358890 +1000
+@@ -43,7 +43,7 @@
+ namespace session {
+
+ namespace {
+-const char* const kDefaultPandocPath = "bin/pandoc";
++const char* const kDefaultPandocPath = "bin";
+ const char* const kDefaultPostbackPath = "bin/postback/rpostback";
+ const char* const kDefaultRsclangPath = "bin/rsclang";
+ } // anonymous namespace
+@@ -431,14 +431,14 @@
+ }
+
+ // convert relative paths by completing from the app resource path
+- resolvePath(resourcePath, &rResourcesPath_);
+- resolvePath(resourcePath, &agreementFilePath_);
+- resolvePath(resourcePath, &wwwLocalPath_);
+- resolvePath(resourcePath, &wwwSymbolMapsPath_);
+- resolvePath(resourcePath, &coreRSourcePath_);
+- resolvePath(resourcePath, &modulesRSourcePath_);
+- resolvePath(resourcePath, &sessionLibraryPath_);
+- resolvePath(resourcePath, &sessionPackageArchivesPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &rResourcesPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &agreementFilePath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwLocalPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwSymbolMapsPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &coreRSourcePath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &modulesRSourcePath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &sessionLibraryPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &sessionPackageArchivesPath_);
+ resolvePostbackPath(resourcePath, &rpostbackPath_);
+ #ifdef _WIN32
+ resolvePath(resourcePath, &consoleIoPath_);
+@@ -447,7 +447,7 @@
+ resolvePath(resourcePath, &msysSshPath_);
+ resolvePath(resourcePath, &sumatraPath_);
+ #endif
+- resolvePath(resourcePath, &hunspellDictionariesPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &hunspellDictionariesPath_);
+ resolvePath(resourcePath, &mathjaxPath_);
+ resolvePath(resourcePath, &libclangHeadersPath_);
+ resolvePandocPath(resourcePath, &pandocPath_);
diff --git a/sci-mathematics/rstudio/files/rstudio-0.99.473-qtsingleapplication.patch b/sci-mathematics/rstudio/files/rstudio-0.99.473-qtsingleapplication.patch
new file mode 100644
index 000000000000..bf66bd236788
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.99.473-qtsingleapplication.patch
@@ -0,0 +1,60 @@
+--- rstudio-0.99.473-orig/src/cpp/desktop/CMakeLists.txt 2015-08-12 09:58:43.000000000 +1000
++++ rstudio-0.99.473/src/cpp/desktop/CMakeLists.txt 2015-08-30 23:16:11.396175587 +1000
+@@ -93,7 +93,12 @@
+ find_package(Qt5DBus REQUIRED)
+ endif()
+
+-
++find_path(QTSINGLEAPPLIB_INCLUDE_DIR NAMES QtSingleApplication
++ PATH_SUFFIXES QtSolutions
++ PATHS
++ /usr/include/qt5)
++find_library(QTSINGLEAPPLIB Qt5Solutions_SingleApplication-2.6
++ libQt5Solutions_SingleApplication-2.6)
+
+ # disable clang warnings for qt sources
+ if(APPLE)
+@@ -113,7 +118,6 @@
+
+ set(MOC_DESKTOP_HEADER_FILES ${DESKTOP_HEADER_FILES})
+ list(REMOVE_ITEM MOC_DESKTOP_HEADER_FILES
+- ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/qtsingleapplication/qtlockedfile.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/DesktopDetectRHome.hpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/DesktopOptions.hpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/DesktopRVersion.hpp
+@@ -175,8 +179,6 @@
+ DesktopSubMenu.cpp
+ DesktopSynctex.cpp
+ DesktopNetworkAccessManager.cpp
+- 3rdparty/qtsingleapplication/qtsingleapplication.cpp
+- 3rdparty/qtsingleapplication/qtlocalpeer.cpp
+ )
+
+ if(WIN32)
+@@ -219,6 +221,7 @@
+ ${CORE_SOURCE_DIR}/include
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
++ ${QTSINGLEAPPLIB_INCLUDE_DIR}
+ ${TESTS_INCLUDE_DIR}
+ )
+
+@@ -332,6 +335,7 @@
+
+ # set link dependencies
+ target_link_libraries(rstudio
++ ${QTSINGLEAPPLIB}
+ ${QT_LIBRARIES}
+ rstudio-core
+ ${LINK_FLAGS}
+--- rstudio-0.99.473-orig/src/cpp/desktop/DesktopPosixApplication.hpp 2015-08-12 09:58:43.000000000 +1000
++++ rstudio-0.99.473/src/cpp/desktop/DesktopPosixApplication.hpp 2015-08-30 21:41:21.616934106 +1000
+@@ -16,7 +16,7 @@
+ #ifndef DESKTOP_POSIX_APPLICATION_HPP
+ #define DESKTOP_POSIX_APPLICATION_HPP
+
+-#include "3rdparty/qtsingleapplication/QtSingleApplication"
++#include <QtSingleApplication>
+
+ namespace rstudio {
+ namespace desktop {
diff --git a/sci-mathematics/rstudio/files/rstudio-0.99.486-systemd.patch b/sci-mathematics/rstudio/files/rstudio-0.99.486-systemd.patch
new file mode 100644
index 000000000000..4c7eda39cc29
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.99.486-systemd.patch
@@ -0,0 +1,22 @@
+diff -Naur /tmp/rstudio.org/work/rstudio-0.99.486/src/cpp/server/CMakeLists.txt ./work/rstudio-0.99.486/src/cpp/server/CMakeLists.txt
+--- /tmp/rstudio.org/work/rstudio-0.99.486/src/cpp/server/CMakeLists.txt 2015-12-10 19:29:24.408267862 +0100
++++ ./work/rstudio-0.99.486/src/cpp/server/CMakeLists.txt 2015-12-10 19:35:24.660194216 +0100
+@@ -208,17 +208,12 @@
+ DESTINATION ${DISTRO_SHARE}/${RSERVER_UPSTART_DIR})
+
+ # install configured systemd profile
+- set(RSERVER_SYSTEMD_DIR "extras/systemd")
++ set(RSERVER_SYSTEMD_DIR "lib/systemd/system")
+ set(RSERVER_SYSTEMD_PROFILE "${RSERVER_SYSTEMD_DIR}/rstudio-server.service")
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_SYSTEMD_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_SYSTEMD_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_SYSTEMD_PROFILE}
+ DESTINATION ${RSERVER_SYSTEMD_DIR})
+- set(RSERVER_SYSTEMD_PROFILE_REDHAT "${RSERVER_SYSTEMD_DIR}/rstudio-server.redhat.service")
+- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_SYSTEMD_PROFILE_REDHAT}.in
+- ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_SYSTEMD_PROFILE_REDHAT})
+- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_SYSTEMD_PROFILE_REDHAT}
+- DESTINATION ${RSERVER_SYSTEMD_DIR})
+
+ endif()
+
diff --git a/sci-mathematics/rstudio/files/rstudio-0.99.879-clang-pandoc.patch b/sci-mathematics/rstudio/files/rstudio-0.99.879-clang-pandoc.patch
new file mode 100644
index 000000000000..c3af2b7a6f56
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.99.879-clang-pandoc.patch
@@ -0,0 +1,77 @@
+--- rstudio-0.99.879-orig/src/cpp/session/CMakeLists.txt 2016-02-12 09:24:39.000000000 +1100
++++ rstudio-0.99.879/src/cpp/session/CMakeLists.txt 2016-02-19 23:04:57.266186448 +1100
+@@ -25,30 +25,11 @@
+ if(NOT EXISTS "${RSTUDIO_DEPENDENCIES_DIR}/common/mathjax-23")
+ message(FATAL_ERROR "Mathjax 2.3 not found (re-run install-dependencies script to install)")
+ endif()
+-if(NOT EXISTS "${RSTUDIO_DEPENDENCIES_DIR}/common/pandoc")
+- message(FATAL_ERROR "pandoc not found (re-run install-dependencies script to install)")
+-endif()
+ if(NOT EXISTS "${RSTUDIO_DEPENDENCIES_DIR}/common/rsconnect")
+ message(FATAL_ERROR "rsconnect package not found (re-run install-dependencies script to install)")
+ endif()
+
+
+-# verify libclang is installed
+-if(WIN32)
+- set(LIBCLANG_VERSION "3.4")
+-else()
+- set(LIBCLANG_VERSION "3.5")
+-endif()
+-set(LIBCLANG_DIR "${RSTUDIO_DEPENDENCIES_DIR}/common/libclang/${LIBCLANG_VERSION}")
+-if(NOT EXISTS "${LIBCLANG_DIR}")
+- message(FATAL_ERROR "libclang ${LIBCLANG_VERSION} not found (re-run install-dependencies script to install)")
+-endif()
+-set(LIBCLANG_HEADERS_DIR "${RSTUDIO_DEPENDENCIES_DIR}/common/libclang/builtin-headers")
+-if(NOT EXISTS "${LIBCLANG_HEADERS_DIR}")
+- message(FATAL_ERROR "libclang builtin-headers not found (re-run install-dependencies script to install)")
+-endif()
+-
+-
+ # include files
+ file(GLOB_RECURSE SESSION_HEADER_FILES "*.h*")
+
+@@ -399,18 +380,6 @@
+ install(DIRECTORY "${RSTUDIO_DEPENDENCIES_DIR}/common/mathjax-23"
+ DESTINATION "${RSTUDIO_INSTALL_SUPPORTING}/resources")
+
+- # install pandoc
+- if(RSTUDIO_PACKAGE_BUILD_SLES)
+- # when producing a SUSE Linux Enterpise build, we want to install the
+- # static Pandoc binaries (see dependencies/common/install-pandoc)
+- set(PANDOC_EXTENSION_DIR "/static")
+- endif()
+- set(PANDOC_BIN "${RSTUDIO_DEPENDENCIES_DIR}/common/pandoc/1.15.2${PANDOC_EXTENSION_DIR}")
+- file(GLOB PANDOC_FILES "${PANDOC_BIN}/pandoc*")
+- install(FILES ${PANDOC_FILES}
+- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+- DESTINATION ${RSTUDIO_INSTALL_BIN}/pandoc)
+-
+ # install rsconnect package
+ file(GLOB RSCONNECT_PACKAGE "${RSTUDIO_DEPENDENCIES_DIR}/common/rsconnect*.tar.gz")
+ install(FILES ${RSCONNECT_PACKAGE}
+@@ -428,24 +397,6 @@
+ install(DIRECTORY "resources/help_resources"
+ DESTINATION ${RSTUDIO_INSTALL_SUPPORTING}/resources)
+
+- # install libclang
+- if(WIN32)
+- file(GLOB LIBCLANG_32_FILES "${LIBCLANG_DIR}/x86/libclang.*")
+- install(PROGRAMS ${LIBCLANG_32_FILES}
+- DESTINATION ${RSTUDIO_INSTALL_BIN}/rsclang/x86)
+- file(GLOB LIBCLANG_64_FILES "${LIBCLANG_DIR}/x86_64/libclang.*")
+- install(PROGRAMS ${LIBCLANG_64_FILES}
+- DESTINATION ${RSTUDIO_INSTALL_BIN}/rsclang/x86_64)
+- else()
+- file(GLOB_RECURSE LIBCLANG_FILES "${LIBCLANG_DIR}/libclang.*")
+- install(PROGRAMS ${LIBCLANG_FILES}
+- DESTINATION ${RSTUDIO_INSTALL_BIN}/rsclang)
+- endif()
+-
+- # install libclang builtin-headers
+- install(DIRECTORY "${RSTUDIO_DEPENDENCIES_DIR}/common/libclang/builtin-headers"
+- DESTINATION "${RSTUDIO_INSTALL_SUPPORTING}/resources/libclang")
+-
+ # install 64 bit binaries if we are on win64
+ if(WIN32)
+ if(NOT ("$ENV{PROGRAMW6432}" STREQUAL ""))
diff --git a/sci-mathematics/rstudio/files/rstudio-0.99.879-paths.patch b/sci-mathematics/rstudio/files/rstudio-0.99.879-paths.patch
new file mode 100644
index 000000000000..a8b48f24968c
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.99.879-paths.patch
@@ -0,0 +1,130 @@
+--- rstudio-0.99.879-orig/CMakeGlobals.txt 2016-02-12 09:24:39.000000000 +1100
++++ rstudio-0.99.879/CMakeGlobals.txt 2016-02-19 22:58:41.396818474 +1100
+@@ -120,7 +120,7 @@
+ else()
+ set(RSTUDIO_INSTALL_BIN bin)
+ endif()
+- set(RSTUDIO_INSTALL_SUPPORTING .)
++ set(RSTUDIO_INSTALL_SUPPORTING ${DISTRO_SHARE})
+ endif()
+
+ # if the install prefix is /usr/local then tweak as appropriate
+--- rstudio-0.99.879-orig/src/cpp/server/CMakeLists.txt 2016-02-12 09:24:39.000000000 +1100
++++ rstudio-0.99.879/src/cpp/server/CMakeLists.txt 2016-02-19 22:58:41.397818478 +1100
+@@ -155,7 +155,7 @@
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT}
+- DESTINATION ${RSERVER_INITD_DEBIAN_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_DEBIAN_DIR})
+
+ # install configured redhat init.d script
+ set(RSERVER_INITD_REDHAT_DIR "extras/init.d/redhat")
+@@ -163,7 +163,7 @@
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_REDHAT_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_REDHAT_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_REDHAT_SCRIPT}
+- DESTINATION ${RSERVER_INITD_REDHAT_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_REDHAT_DIR})
+
+ # install configured suse init.d script
+ set(RSERVER_INITD_SUSE_DIR "extras/init.d/suse")
+@@ -171,13 +171,13 @@
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_SUSE_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_SUSE_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_SUSE_SCRIPT}
+- DESTINATION ${RSERVER_INITD_SUSE_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_SUSE_DIR})
+
+ # install pam profile
+ set(RSERVER_PAM_DIR "extras/pam")
+ set(RSERVER_PAM_PROFILE "${RSERVER_PAM_DIR}/rstudio")
+ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_PAM_PROFILE}
+- DESTINATION ${RSERVER_PAM_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_PAM_DIR})
+
+ # install configured apparmor profile
+ set(RSERVER_APPARMOR_DIR "extras/apparmor")
+@@ -185,9 +185,9 @@
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_APPARMOR_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_APPARMOR_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_APPARMOR_PROFILE}
+- DESTINATION ${RSERVER_APPARMOR_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_APPARMOR_DIR})
+ install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_APPARMOR_DIR}/apparmor-profile-load
+- DESTINATION ${RSERVER_APPARMOR_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_APPARMOR_DIR})
+
+ # install configured upstart profile
+ set(RSERVER_UPSTART_DIR "extras/upstart")
+@@ -195,12 +195,12 @@
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_UPSTART_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE}
+- DESTINATION ${RSERVER_UPSTART_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_UPSTART_DIR})
+ set(RSERVER_UPSTART_PROFILE_REDHAT "${RSERVER_UPSTART_DIR}/rstudio-server.redhat.conf")
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_UPSTART_PROFILE_REDHAT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE_REDHAT})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE_REDHAT}
+- DESTINATION ${RSERVER_UPSTART_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_UPSTART_DIR})
+
+ # install configured systemd profile
+ set(RSERVER_SYSTEMD_DIR "extras/systemd")
+--- rstudio-0.99.879-orig/src/cpp/server/ServerOptions.cpp 2016-02-12 09:24:39.000000000 +1100
++++ rstudio-0.99.879/src/cpp/server/ServerOptions.cpp 2016-02-19 22:58:41.397818478 +1100
+@@ -382,8 +382,8 @@
+
+ // convert relative paths by completing from the system installation
+ // path (this allows us to be relocatable)
+- resolvePath(resourcePath, &wwwLocalPath_);
+- resolvePath(resourcePath, &wwwSymbolMapsPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwLocalPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwSymbolMapsPath_);
+ resolvePath(binaryPath, &authPamHelperPath_);
+ resolvePath(binaryPath, &rsessionPath_);
+ resolvePath(binaryPath, &rldpathPath_);
+--- rstudio-0.99.879-orig/src/cpp/session/SessionOptions.cpp 2016-02-12 09:24:39.000000000 +1100
++++ rstudio-0.99.879/src/cpp/session/SessionOptions.cpp 2016-02-20 18:13:34.807771539 +1100
+@@ -49,7 +49,7 @@
+ namespace session {
+
+ namespace {
+-const char* const kDefaultPandocPath = "bin/pandoc";
++const char* const kDefaultPandocPath = "bin";
+ const char* const kDefaultPostbackPath = "bin/postback/rpostback";
+ const char* const kDefaultRsclangPath = "bin/rsclang";
+ } // anonymous namespace
+@@ -451,14 +451,14 @@
+ }
+
+ // convert relative paths by completing from the app resource path
+- resolvePath(resourcePath_, &rResourcesPath_);
+- resolvePath(resourcePath_, &agreementFilePath_);
+- resolvePath(resourcePath_, &wwwLocalPath_);
+- resolvePath(resourcePath_, &wwwSymbolMapsPath_);
+- resolvePath(resourcePath_, &coreRSourcePath_);
+- resolvePath(resourcePath_, &modulesRSourcePath_);
+- resolvePath(resourcePath_, &sessionLibraryPath_);
+- resolvePath(resourcePath_, &sessionPackageArchivesPath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &rResourcesPath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &agreementFilePath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &wwwLocalPath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &wwwSymbolMapsPath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &coreRSourcePath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &modulesRSourcePath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &sessionLibraryPath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &sessionPackageArchivesPath_);
+ resolvePostbackPath(resourcePath_, &rpostbackPath_);
+ #ifdef _WIN32
+ resolvePath(resourcePath_, &consoleIoPath_);
+@@ -467,7 +467,7 @@
+ resolvePath(resourcePath_, &msysSshPath_);
+ resolvePath(resourcePath_, &sumatraPath_);
+ #endif
+- resolvePath(resourcePath_, &hunspellDictionariesPath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &hunspellDictionariesPath_);
+ resolvePath(resourcePath_, &mathjaxPath_);
+ resolvePath(resourcePath_, &libclangHeadersPath_);
+ resolvePandocPath(resourcePath_, &pandocPath_);
diff --git a/sci-mathematics/rstudio/files/rstudio-0.99.879-prefs.patch b/sci-mathematics/rstudio/files/rstudio-0.99.879-prefs.patch
new file mode 100644
index 000000000000..483613cc5c09
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-0.99.879-prefs.patch
@@ -0,0 +1,45 @@
+--- rstudio-0.99.879-orig/src/gwt/build.xml 2016-02-12 09:24:39.000000000 +1100
++++ rstudio-0.99.879/src/gwt/build.xml 2016-02-20 00:25:39.458756693 +1100
+@@ -25,6 +25,7 @@
+ <property name="gwt.extra.args" value=""/>
+ <property name="gwt.main.module" value="org.rstudio.studio.RStudio"/>
+ <property name="ace.bin" value="src/org/rstudio/studio/client/workbench/views/source/editors/text/ace"/>
++ <property environment="env"/>
+
+ <path id="project.class.path">
+ <pathelement location="bin"/>
+@@ -101,8 +102,10 @@
+ <pathelement location="src"/>
+ <path refid="project.class.path"/>
+ </classpath>
++ <jvmarg value="-Duser.home=${env.T}"/>
+ <!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
+ <jvmarg value="-Xmx1536M"/>
++ <jvmarg value="-Djava.util.prefs.userRoot=${env.T}"/>
+ <arg value="-war"/>
+ <arg value="www"/>
+ <arg value="-localWorkers"/>
+@@ -142,6 +145,7 @@
+ <pathelement location="src"/>
+ <path refid="project.class.path"/>
+ </classpath>
++ <jvmarg value="-Duser.home=${env.T}"/>
+ <jvmarg value="-Xmx2048M"/>
+ <arg value="-war"/>
+ <arg value="www"/>
+@@ -163,6 +167,7 @@
+ <pathelement location="src"/>
+ <path refid="project.class.path"/>
+ </classpath>
++ <jvmarg value="-Duser.home=${env.T}"/>
+ <jvmarg value="-Xmx2048M"/>
+ <arg value="-src"/>
+ <arg value = "src"/>
+@@ -194,6 +199,7 @@
+ <pathelement location="src"/>
+ <path refid="test.class.path"/>
+ </classpath>
++ <jvmarg value="-Duser.home=${env.T}"/>
+ <arg value="org.rstudio.studio.selenium.RStudioTestSuite"/>
+ </java>
+ </sequential>
diff --git a/sci-mathematics/rstudio/files/rstudio-1.0.44-clang-pandoc.patch b/sci-mathematics/rstudio/files/rstudio-1.0.44-clang-pandoc.patch
new file mode 100644
index 000000000000..ed0fc8ebce4b
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-1.0.44-clang-pandoc.patch
@@ -0,0 +1,71 @@
+--- rstudio-1.0.44-orig/src/cpp/session/CMakeLists.txt 2016-10-19 08:32:41.000000000 +1100
++++ rstudio-1.0.44/src/cpp/session/CMakeLists.txt 2016-12-01 23:44:30.130725331 +1100
+@@ -25,24 +25,6 @@
+ if(NOT EXISTS "${RSTUDIO_DEPENDENCIES_DIR}/common/mathjax-26")
+ message(FATAL_ERROR "Mathjax 2.6 not found (re-run install-dependencies script to install)")
+ endif()
+-if(NOT EXISTS "${RSTUDIO_DEPENDENCIES_DIR}/common/pandoc")
+- message(FATAL_ERROR "pandoc not found (re-run install-dependencies script to install)")
+-endif()
+-
+-# verify libclang is installed
+-if(WIN32)
+- set(LIBCLANG_VERSION "3.4")
+-else()
+- set(LIBCLANG_VERSION "3.5")
+-endif()
+-set(LIBCLANG_DIR "${RSTUDIO_DEPENDENCIES_DIR}/common/libclang/${LIBCLANG_VERSION}")
+-if(NOT EXISTS "${LIBCLANG_DIR}")
+- message(FATAL_ERROR "libclang ${LIBCLANG_VERSION} not found (re-run install-dependencies script to install)")
+-endif()
+-set(LIBCLANG_HEADERS_DIR "${RSTUDIO_DEPENDENCIES_DIR}/common/libclang/builtin-headers")
+-if(NOT EXISTS "${LIBCLANG_HEADERS_DIR}")
+- message(FATAL_ERROR "libclang builtin-headers not found (re-run install-dependencies script to install)")
+-endif()
+
+
+ # include files
+@@ -420,18 +402,6 @@
+ install(DIRECTORY "${RSTUDIO_DEPENDENCIES_DIR}/common/mathjax-26"
+ DESTINATION "${RSTUDIO_INSTALL_SUPPORTING}/resources")
+
+- # install pandoc
+- if(RSTUDIO_PACKAGE_BUILD_SLES)
+- # when producing a SUSE Linux Enterpise build, we want to install the
+- # static Pandoc binaries (see dependencies/common/install-pandoc)
+- set(PANDOC_EXTENSION_DIR "/static")
+- endif()
+- set(PANDOC_BIN "${RSTUDIO_DEPENDENCIES_DIR}/common/pandoc/1.17.2${PANDOC_EXTENSION_DIR}")
+- file(GLOB PANDOC_FILES "${PANDOC_BIN}/pandoc*")
+- install(FILES ${PANDOC_FILES}
+- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+- DESTINATION ${RSTUDIO_INSTALL_BIN}/pandoc)
+-
+ # install PDF.js
+ install(DIRECTORY "resources/pdfjs"
+ DESTINATION ${RSTUDIO_INSTALL_SUPPORTING}/resources)
+@@ -452,24 +422,6 @@
+ install(DIRECTORY "resources/pagedtable"
+ DESTINATION ${RSTUDIO_INSTALL_SUPPORTING}/resources)
+
+- # install libclang
+- if(WIN32)
+- file(GLOB LIBCLANG_32_FILES "${LIBCLANG_DIR}/x86/libclang.*")
+- install(PROGRAMS ${LIBCLANG_32_FILES}
+- DESTINATION ${RSTUDIO_INSTALL_BIN}/rsclang/x86)
+- file(GLOB LIBCLANG_64_FILES "${LIBCLANG_DIR}/x86_64/libclang.*")
+- install(PROGRAMS ${LIBCLANG_64_FILES}
+- DESTINATION ${RSTUDIO_INSTALL_BIN}/rsclang/x86_64)
+- else()
+- file(GLOB_RECURSE LIBCLANG_FILES "${LIBCLANG_DIR}/libclang.*")
+- install(PROGRAMS ${LIBCLANG_FILES}
+- DESTINATION ${RSTUDIO_INSTALL_BIN}/rsclang)
+- endif()
+-
+- # install libclang builtin-headers
+- install(DIRECTORY "${RSTUDIO_DEPENDENCIES_DIR}/common/libclang/builtin-headers"
+- DESTINATION "${RSTUDIO_INSTALL_SUPPORTING}/resources/libclang")
+-
+ # install 64 bit binaries if we are on win64
+ if(WIN32)
+ if(NOT ("$ENV{PROGRAMW6432}" STREQUAL ""))
diff --git a/sci-mathematics/rstudio/files/rstudio-1.0.44-paths.patch b/sci-mathematics/rstudio/files/rstudio-1.0.44-paths.patch
new file mode 100644
index 000000000000..b2a1a33b44c2
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-1.0.44-paths.patch
@@ -0,0 +1,130 @@
+--- rstudio-1.0.44-orig/CMakeGlobals.txt 2016-10-19 08:32:41.000000000 +1100
++++ rstudio-1.0.44/CMakeGlobals.txt 2016-12-01 23:33:04.149326324 +1100
+@@ -123,7 +123,7 @@
+ else()
+ set(RSTUDIO_INSTALL_BIN bin)
+ endif()
+- set(RSTUDIO_INSTALL_SUPPORTING .)
++ set(RSTUDIO_INSTALL_SUPPORTING ${DISTRO_SHARE})
+ endif()
+
+ # if the install prefix is /usr/local then tweak as appropriate
+--- rstudio-1.0.44-orig/src/cpp/server/CMakeLists.txt 2016-10-19 08:32:41.000000000 +1100
++++ rstudio-1.0.44/src/cpp/server/CMakeLists.txt 2016-12-01 23:35:51.634862018 +1100
+@@ -155,7 +155,7 @@
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_DEBIAN_SCRIPT}
+- DESTINATION ${RSERVER_INITD_DEBIAN_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_DEBIAN_DIR})
+
+ # install configured redhat init.d script
+ set(RSERVER_INITD_REDHAT_DIR "extras/init.d/redhat")
+@@ -163,7 +163,7 @@
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_REDHAT_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_REDHAT_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_REDHAT_SCRIPT}
+- DESTINATION ${RSERVER_INITD_REDHAT_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_REDHAT_DIR})
+
+ # install configured suse init.d script
+ set(RSERVER_INITD_SUSE_DIR "extras/init.d/suse")
+@@ -171,13 +171,13 @@
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_INITD_SUSE_SCRIPT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_SUSE_SCRIPT})
+ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_INITD_SUSE_SCRIPT}
+- DESTINATION ${RSERVER_INITD_SUSE_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_INITD_SUSE_DIR})
+
+ # install pam profile
+ set(RSERVER_PAM_DIR "extras/pam")
+ set(RSERVER_PAM_PROFILE "${RSERVER_PAM_DIR}/rstudio")
+ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_PAM_PROFILE}
+- DESTINATION ${RSERVER_PAM_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_PAM_DIR})
+
+ # install configured apparmor profile
+ set(RSERVER_APPARMOR_DIR "extras/apparmor")
+@@ -185,9 +185,9 @@
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_APPARMOR_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_APPARMOR_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_APPARMOR_PROFILE}
+- DESTINATION ${RSERVER_APPARMOR_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_APPARMOR_DIR})
+ install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_APPARMOR_DIR}/apparmor-profile-load
+- DESTINATION ${RSERVER_APPARMOR_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_APPARMOR_DIR})
+
+ # install configured upstart profile
+ set(RSERVER_UPSTART_DIR "extras/upstart")
+@@ -195,12 +195,12 @@
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_UPSTART_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE}
+- DESTINATION ${RSERVER_UPSTART_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_UPSTART_DIR})
+ set(RSERVER_UPSTART_PROFILE_REDHAT "${RSERVER_UPSTART_DIR}/rstudio-server.redhat.conf")
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_UPSTART_PROFILE_REDHAT}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE_REDHAT})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_UPSTART_PROFILE_REDHAT}
+- DESTINATION ${RSERVER_UPSTART_DIR})
++ DESTINATION ${DISTRO_SHARE}/${RSERVER_UPSTART_DIR})
+
+ # install configured systemd profile
+ set(RSERVER_SYSTEMD_DIR "extras/systemd")
+--- rstudio-1.0.44-orig/src/cpp/server/ServerOptions.cpp 2016-10-19 08:32:41.000000000 +1100
++++ rstudio-1.0.44/src/cpp/server/ServerOptions.cpp 2016-12-01 23:33:04.151326331 +1100
+@@ -386,8 +386,8 @@
+
+ // convert relative paths by completing from the system installation
+ // path (this allows us to be relocatable)
+- resolvePath(resourcePath, &wwwLocalPath_);
+- resolvePath(resourcePath, &wwwSymbolMapsPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwLocalPath_);
++ resolvePath(resourcePath.childPath(DISTRO_SHARE), &wwwSymbolMapsPath_);
+ resolvePath(binaryPath, &authPamHelperPath_);
+ resolvePath(binaryPath, &rsessionPath_);
+ resolvePath(binaryPath, &rldpathPath_);
+--- rstudio-1.0.44-orig/src/cpp/session/SessionOptions.cpp 2016-10-19 08:32:41.000000000 +1100
++++ rstudio-1.0.44/src/cpp/session/SessionOptions.cpp 2016-12-01 23:33:04.151326331 +1100
+@@ -49,7 +49,7 @@
+ namespace session {
+
+ namespace {
+-const char* const kDefaultPandocPath = "bin/pandoc";
++const char* const kDefaultPandocPath = "bin";
+ const char* const kDefaultPostbackPath = "bin/postback/rpostback";
+ const char* const kDefaultRsclangPath = "bin/rsclang";
+
+@@ -481,14 +481,14 @@
+ }
+
+ // convert relative paths by completing from the app resource path
+- resolvePath(resourcePath_, &rResourcesPath_);
+- resolvePath(resourcePath_, &agreementFilePath_);
+- resolvePath(resourcePath_, &wwwLocalPath_);
+- resolvePath(resourcePath_, &wwwSymbolMapsPath_);
+- resolvePath(resourcePath_, &coreRSourcePath_);
+- resolvePath(resourcePath_, &modulesRSourcePath_);
+- resolvePath(resourcePath_, &sessionLibraryPath_);
+- resolvePath(resourcePath_, &sessionPackageArchivesPath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &rResourcesPath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &agreementFilePath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &wwwLocalPath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &wwwSymbolMapsPath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &coreRSourcePath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &modulesRSourcePath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &sessionLibraryPath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &sessionPackageArchivesPath_);
+ resolvePostbackPath(resourcePath_, &rpostbackPath_);
+ #ifdef _WIN32
+ resolvePath(resourcePath_, &consoleIoPath_);
+@@ -498,7 +498,7 @@
+ resolvePath(resourcePath_, &sumatraPath_);
+ resolvePath(resourcePath_, &winutilsPath_);
+ #endif
+- resolvePath(resourcePath_, &hunspellDictionariesPath_);
++ resolvePath(resourcePath_.childPath(DISTRO_SHARE), &hunspellDictionariesPath_);
+ resolvePath(resourcePath_, &mathjaxPath_);
+ resolvePath(resourcePath_, &libclangHeadersPath_);
+ resolvePandocPath(resourcePath_, &pandocPath_);
diff --git a/sci-mathematics/rstudio/files/rstudio-1.0.44-systemd.patch b/sci-mathematics/rstudio/files/rstudio-1.0.44-systemd.patch
new file mode 100644
index 000000000000..7eafd4386abd
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-1.0.44-systemd.patch
@@ -0,0 +1,21 @@
+--- rstudio-1.0.44-orig/src/cpp/server/CMakeLists.txt 2016-10-19 08:32:41.000000000 +1100
++++ rstudio-1.0.44/src/cpp/server/CMakeLists.txt 2016-12-02 11:11:45.259050839 +1100
+@@ -203,17 +203,12 @@
+ DESTINATION ${RSERVER_UPSTART_DIR})
+
+ # install configured systemd profile
+- set(RSERVER_SYSTEMD_DIR "extras/systemd")
++ set(RSERVER_SYSTEMD_DIR "lib/systemd/system")
+ set(RSERVER_SYSTEMD_PROFILE "${RSERVER_SYSTEMD_DIR}/rstudio-server.service")
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_SYSTEMD_PROFILE}.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_SYSTEMD_PROFILE})
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_SYSTEMD_PROFILE}
+ DESTINATION ${RSERVER_SYSTEMD_DIR})
+- set(RSERVER_SYSTEMD_PROFILE_REDHAT "${RSERVER_SYSTEMD_DIR}/rstudio-server.redhat.service")
+- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${RSERVER_SYSTEMD_PROFILE_REDHAT}.in
+- ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_SYSTEMD_PROFILE_REDHAT})
+- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${RSERVER_SYSTEMD_PROFILE_REDHAT}
+- DESTINATION ${RSERVER_SYSTEMD_DIR})
+
+ elseif(APPLE)
+
diff --git a/sci-mathematics/rstudio/files/rstudio-server.conf b/sci-mathematics/rstudio/files/rstudio-server.conf
new file mode 100644
index 000000000000..34e93e9fab0b
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-server.conf
@@ -0,0 +1,35 @@
+###########rstudio-server.conf#############
+
+# www-port entry corresponding to the port you want RStudio to listen on
+#www-port=80
+
+
+# By default RStudio binds to address 0.0.0.0 (accepting connections
+# from any remote IP). You can modify this behavior using the
+# www-address entry.
+#www-address=127.0.0.1
+
+
+# You can add elements to the default LD_LIBRARY_PATH for R
+# sessions (as determined by the R ldpaths script) by adding
+# an rsession-ld-library-path entry to the server config file.
+# This might be useful for ensuring that packages can
+# locate external library dependencies that aren't installed
+# in the system standard library paths
+#rsession-ld-library-path=/opt/local/lib:/opt/local/someapp/lib
+
+
+#By default RStudio Server runs against the version of R which
+# is found on the system PATH (using which R). You can override
+# which version of R is used via the rsession-which-r setting
+# in the server config file. For example, if you have two
+# versions of R installed on the server and want to make sure
+# the one at /usr/local/bin/R is used by RStudio then you would use:
+rsession-which-r=/usr/bin/R
+
+########ADDITIONALAL#########
+
+# To limit the users who can login to RStudio to the members
+# of a specific group, you use the auth-required-user-group
+# setting
+auth-required-user-group=rstudio-server
diff --git a/sci-mathematics/rstudio/files/rstudio-server.initd b/sci-mathematics/rstudio/files/rstudio-server.initd
new file mode 100644
index 000000000000..caa7e46d5df8
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-server.initd
@@ -0,0 +1,15 @@
+#!/sbin/openrc-run
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+start() {
+ ebegin "Starting RStudio Server"
+ start-stop-daemon --start --quiet --exec /usr/bin/rserver
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping RStudio Server"
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --name /usr/bin/rserver
+ eend $?
+}
diff --git a/sci-mathematics/rstudio/files/rstudio-server.service.in b/sci-mathematics/rstudio/files/rstudio-server.service.in
new file mode 100644
index 000000000000..fb3e37305e00
--- /dev/null
+++ b/sci-mathematics/rstudio/files/rstudio-server.service.in
@@ -0,0 +1,10 @@
+[Unit]
+Description=RStudio Server
+
+[Service]
+Type=forking
+ExecStart=${CMAKE_INSTALL_PREFIX}/bin/rserver
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target