# Copyright 1999-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 inherit cmake pam xdg-utils java-pkg-2 java-ant-2 pax-utils qmake-utils vcs-clean PLUS_PV="$(ver_rs 3 '+')" MINUS_PV="$(ver_rs 3 '-')" COMMIT="e7373ef832b49b2a9b88162cfe7eac5f22c40b34" # TODO # * use dict from tree, linguas # * do src_test (use junit from tree?) GIN_VER=2.1.2 # grep 'PANDOC_VERSION=' dependencies/common/install-pandoc PANDOC_VER=2.18 # grep -5 QT_CANDIDATES src/cpp/desktop/CMakeLists.txt QT_VER=5.12.6 QT_SLOT=5 DESCRIPTION="IDE for the R language" HOMEPAGE=" https://www.rstudio.org https://github.com/rstudio/rstudio/" SRC_URI=" https://github.com/rstudio/rstudio/archive/v${PLUS_PV}.tar.gz -> ${P}.tar.gz https://s3.amazonaws.com/rstudio-dictionaries/core-dictionaries.zip -> ${PN}-core-dictionaries.zip https://src.fedoraproject.org/repo/pkgs/rstudio/panmirror-0.1.0-nm.tgz/sha512/41b48d05ec27571eadbb628f3a0526d1c27c92d9267600fce41915b457aa8fa313cece9b61cfbefb6676074e7713f68b51322321948dbb167757441f3016a080/panmirror-0.1.0-nm.tgz " LICENSE="AGPL-3" SLOT="0" KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux" IUSE="headless server test" REQUIRED_USE="headless? ( server )" # The test require an R package to be installed called `testthat`. # To install using R: # ```sh # $ R # > install.packages("testthat") # // select a CRAN mirror # ``` # Using this locally installed "testthat", ezzieyguywuf got the following results # from the test suite. It's unclear to ezzieyguywuf if the failures are from # upstream or due to the gentoo packaging. # [ FAIL 7 | WARN 6 | SKIP 2 | PASS 980 ] RESTRICT="test" RDEPEND=" dev-cpp/websocketpp:= dev-cpp/yaml-cpp:= dev-db/postgresql:* dev-db/sqlite dev-java/aopalliance:1 dev-java/gin:2.1 dev-java/javax-inject =dev-java/validation-api-1.0*:1.0[source] dev-lang/R dev-libs/boost:= >=dev-libs/libfmt-8.1.1:= >=dev-libs/mathjax-2.7.4 dev-libs/soci:=[postgres] net-libs/nodejs sys-apps/util-linux sys-devel/clang:* sys-libs/zlib sys-process/lsof >=virtual/jre-1.8:= x11-libs/pango !headless? ( >=dev-qt/qtcore-${QT_VER}:${QT_SLOT} >=dev-qt/qtdeclarative-${QT_VER}:${QT_SLOT} >=dev-qt/qtdbus-${QT_VER}:${QT_SLOT} >=dev-qt/qtgui-${QT_VER}:${QT_SLOT} >=dev-qt/qtnetwork-${QT_VER}:${QT_SLOT} >=dev-qt/qtopengl-${QT_VER}:${QT_SLOT} >=dev-qt/qtpositioning-${QT_VER}:${QT_SLOT} >=dev-qt/qtprintsupport-${QT_VER}:${QT_SLOT} >=dev-qt/qtsingleapplication-2.6.1_p20150629[X,qt5(+)] >=dev-qt/qtsensors-${QT_VER}:${QT_SLOT} >=dev-qt/qtsql-${QT_VER}:${QT_SLOT} >=dev-qt/qtsvg-${QT_VER}:${QT_SLOT} >=dev-qt/qtwebchannel-${QT_VER}:${QT_SLOT} >=dev-qt/qtwebengine-${QT_VER}:${QT_SLOT}[widgets] >=dev-qt/qtwidgets-${QT_VER}:${QT_SLOT} >=dev-qt/qtxml-${QT_VER}:${QT_SLOT} >=dev-qt/qtxmlpatterns-${QT_VER}:${QT_SLOT} server? ( sys-libs/pam ) ) headless? ( sys-libs/pam ) headless? ( sys-libs/pam acct-user/rstudio-server acct-group/rstudio-server ) server? ( acct-user/rstudio-server acct-group/rstudio-server ) dev-libs/openssl:0= virtual/pandoc " DEPEND="${RDEPEND}" BDEPEND="app-arch/unzip dev-java/ant-core || ( =virtual/jdk-1.8*:* =virtual/jdk-11*:* ) || ( =virtual/jre-1.8*:* =virtual/jre-11*:* ) virtual/pkgconfig" PATCHES=( "${FILESDIR}"/${PN}-2022.07.2.576-resource-paths.patch "${FILESDIR}/"${PN}-2022.07.2.576-ant-system-node.patch "${FILESDIR}"/${PN}-2022.07.2.576-cmake-bundled-dependencies.patch "${FILESDIR}"/${PN}-1.2.1335-linker_flags.patch "${FILESDIR}"/${PN}-2022.07.2.576-qtsingleapplication.patch "${FILESDIR}"/${PN}-2022.07.2.576-fmt.patch "${FILESDIR}"/${PN}-2022.07.2.576-systemd.patch "${FILESDIR}"/${PN}-2022.07.2.576-soci-cmake-find_library.patch ) S="${WORKDIR}"/${PN}-${MINUS_PV} rstudio_env() { export RSTUDIO_VERSION_MAJOR=$(ver_cut 1) export RSTUDIO_VERSION_MINOR=$(ver_cut 2) export RSTUDIO_VERSION_PATCH=$(ver_cut 3) export RSTUDIO_VERSION_SUFFIX=+$(ver_cut 4) export RSTUDIO_GIT_REVISION_HASH=${COMMIT} export GIT_COMMIT=${COMMIT} export PACKAGE_OS=$(cat /etc/gentoo-release) } pkg_pretend() { if $(java-pkg_is-vm-version-ge 17); then eerror "rstudio requires the system-vm to be set to either 1.8 or 11" eerror "during emerge sci-mathematics/rstudio. See:" eerror "https://wiki.gentoo.org/wiki/Java#Configuring_the_Java_Virtual_Machine" eerror "Supporting building GWT with newer JDKs (e.g. 18) #11242" eerror "https://github.com/rstudio/rstudio/issues/11242" die fi } src_unpack() { local dict_archive_name="${PN}-core-dictionaries.zip" local ARCHIVE="" # rstudio's build-system expects these dictionary files to exist, but does # not ship them in the release tarball. Therefore, they are fetched in # `SRC_URI`, and here we unpack and move them to the correct place. for ARCHIVE in ${A} do if [[ ${ARCHIVE:-${#dict_archive_name}} == "${dict_archive_name}" ]]; then # unpack unzips the files as-is, and the zip from upstream isn't in # a sub-directory. We'll create a subdirectory and then unpack in # there in order to keep track of where these are. mkdir "${WORKDIR}/dictionaries" || die pushd "${WORKDIR}/dictionaries" > /dev/null || die unpack ${ARCHIVE} popd > /dev/null || die else unpack ${ARCHIVE} fi done } src_prepare() { cmake_src_prepare java-pkg-2_src_prepare egit_clean mkdir -p "${S}"/src/gwt/panmirror/src/editor/node_modules \ || die "Could not create dir src/gwt/panmirror/src/editor/node_modules" cp -r "${WORKDIR}"/node_modules_dev/* "${S}"/src/gwt/panmirror/src/editor/node_modules \ || die "Could not create copy node_modules_dev/* to src/gwt/panmirror/src/editor/node_modules" cp -r "${WORKDIR}"/node_modules_prod/* "${S}"/src/gwt/panmirror/src/editor/node_modules \ || die "Could not create copy node_modules_prod/* to src/gwt/panmirror/src/editor/node_modules" # Removed bundled libfmt and websocketpp rm -rf src/cpp/{fmt,websocketpp} \ || die "Could not removed bundled libfmt and websocketpp" # move the dictionary files to the expected place mkdir -p "${S}/dependencies" || die mv "${WORKDIR}/dictionaries" "${S}/dependencies" || die # Enable CMake to install our .service file for systemd usage mkdir -vp "${S}/src/cpp/server/lib/systemd/system" || die cp -v "${FILESDIR}/rstudio-server.service.in" "${S}/src/cpp/server/lib/systemd/system/" || die # use mathjax from system ln -sf "${EPREFIX}"/usr/share/mathjax dependencies/common/mathjax-27 || die # dev-qt/qtsingleapplication-2.6.1_p20150629 does not provide a cmake module. # It provides a library that has its version number appended to the end, # which is difficult to handle in cmake, as find_library does not support # searching for wildcard library names. So I find the library name from the # qmake spec, and then sed this into the patched src/cpp/desktop/CMakeLists.txt. rm -rf "${S}"/src/cpp/desktop/3rdparty || die local s=$(grep '\-lQt$${QT_MAJOR_VERSION}Solutions_SingleApplication' \ $(qt5_get_mkspecsdir)/features/qtsingleapplication.prf \ | sed -e 's@\$\${QT_MAJOR_VERSION}@5@' \ -e 's@LIBS \*= -l@@') sed -e "s@Qt5Solutions_SingleApplication-2.6@${s}@g" \ -i "${S}"/src/cpp/desktop/CMakeLists.txt \ || die # The git commit for tag: git rev-list -n 1 v${PV} sed -e "s@git rev-parse HEAD@echo ${COMMIT}@"\ -i "${S}"/CMakeLists.txt \ "${S}"/CMakeGlobals.txt \ || die # dev-cpp/yaml-cpp-0.7.0-r1 /usr/lib64/cmake/yaml-cpp/yaml-cpp-config.cmake # does not set these variables. Workaround error: # CMake Error at src/cpp/CMakeLists.txt:222 (message): # yaml-cpp not found (re-run dependencies script to install) sed -e "s@find_package(yaml-cpp REQUIRED)@set(YAML_CPP_INCLUDE_DIR \"${EPREFIX}/usr/include/yaml-cpp\")\n set(YAML_CPP_LIBRARIES \"${EPREFIX}/usr/$(get_libdir)/libyaml-cpp.so\")@" \ -i src/cpp/CMakeLists.txt \ || die "Could not set YAML_CPP_INCLUDE_DIR and YAML_CPP_LIBRARIES in src/cpp/CMakeLists.txt" } src_configure() { rstudio_env local mycmakeargs=( -DRSTUDIO_INSTALL_SUPPORTING="${EPREFIX}"/usr/share/${PN} -DCMAKE_INSTALL_PREFIX="${EPREFIX}"/usr/$(get_libdir)/${PN} -DRSTUDIO_TARGET=$(usex headless "Server" "$(usex server "Development" "Desktop")") -DRSTUDIO_DESKTOP=TRUE -DCMAKE_BUILD_TYPE=Release -DRSTUDIO_UNIT_TESTS_DISABLED=$(usex test OFF ON) -DRSTUDIO_VERIFY_R_VERSION=OFF -DRSTUDIO_USE_SYSTEM_BOOST=ON -DRSTUDIO_USE_SYSTEM_FMT=ON -DRSTUDIO_USE_SYSTEM_SOCI=ON -DRSTUDIO_USE_SYSTEM_YAML_CPP=ON -DRSTUDIO_BUNDLE_QT=OFF -DGWT_BUILD=OFF -DGWT_COPY=ON -DQUARTO_ENABLED=OFF ) if use !headless; then mycmakeargs+=( -DRSTUDIO_INSTALL_FREEDESKTOP="$(usex !headless "ON" "OFF")" -DQT_QMAKE_EXECUTABLE=$(qt5_get_bindir)/qmake ) fi cmake_src_configure } src_compile() { rstudio_env export EANT_BUILD_XML="src/gwt/build.xml" export EANT_BUILD_TARGET="build" # Avoid the rest of the oracle-jdk-bin-1.8.0.60 sandbox violations F: mkdir S: deny # P: /root/.oracle_jre_usage. export ANT_OPTS="-Duser.home=${T} -Djava.util.prefs.userRoot=${T}" # Avoid: [exec] Error: You must provide the URL of lib/mappings.wasm by calling SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) before using SourceMapConsumer export NODE_OPTIONS="--no-experimental-fetch" # FIXME: isn't there a variable we can use in one of the java eclasses that # will take care of some of the dependency and path stuff for us? local eant_extra_args=( # These are from src/gwt/CMakeLists.txt, grep if(GWT_BUILD) -Dbuild.dir="bin" -Dwww.dir="www" -Dextras.dir="extras" -Dlib.dir="lib" -Dgwt.main.module="org.rstudio.studio.RStudio" -Dnode.bin="${EPREFIX}/usr/bin/node" -Daopalliance.sdk="${EPREFIX}/usr/share/aopalliance-1/lib" -Dgin.sdk="${EPREFIX}/usr/share/gin-2.1/lib" -Djavax.inject="${EPREFIX}/usr/share/javax-inject/lib" -Dvalidation.api="${EPREFIX}/usr/share/validation-api-1.0/lib" -Dvalidation.api.sources="${EPREFIX}/usr/share/validation-api-1.0/sources" -DlocalWorkers=$(makeopts_jobs) ) local EANT_EXTRA_ARGS="${eant_extra_args[@]}" [[ $(java-pkg_is-vm-version-ge 11) ]] && local JAVA_PKG_WANT_SOURCE="11" || local JAVA_PKG_WANT_SOURCE="8" local JAVA_PKG_WANT_TARGET=${JAVA_PKG_WANT_SOURCE} java-pkg-2_src_compile cmake_src_compile } src_install() { rstudio_env export ANT_OPTS="-Duser.home=${T} -Djava.util.prefs.userRoot=${T}" cmake_src_install dosym ../$(get_libdir)/${PN}/bin/rstudio /usr/bin/rstudio dosym ../../../share/rstudio/resources /usr/$(get_libdir)/${PN}/bin/resources use headless || pax-mark m "${ED}/usr/$(get_libdir)/${PN}/rstudio" doconfd "${FILESDIR}"/rstudio-server.conf insinto /etc/rstudio doins "${FILESDIR}"/rsession.conf dosym ../conf.d/rstudio-server.conf /etc/rstudio/rserver.conf if use headless || use server; then dopamd src/cpp/server/extras/pam/rstudio newinitd "${FILESDIR}"/rstudio-server.initd rstudio-server fi } src_test() { # There is a gwt test suite, but it seems to require network access # export EANT_TEST_TARGET="unittest" # java-pkg-2_src_test mkdir -p ${HOME}/.local/share/rstudio || die cd "${BUILD_DIR}"/src/cpp || die ./rstudio-tests || die } pkg_preinst() { java-pkg-2_pkg_preinst } pkg_postinst() { use headless || { xdg_desktop_database_update xdg_mimeinfo_database_update xdg_icon_cache_update ;} } pkg_postrm() { use headless || { xdg_desktop_database_update xdg_mimeinfo_database_update xdg_icon_cache_update ;} }