summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b17058f800e936250e4e6b3a4052086b261b8ecb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Maintainer: Yann Büchau <nobodyinperson at posteo de>
# Previous Maintainer: Stephen Martin <stephenSRMMartin at gmail dot com>
#
# Note: Apache ant and java must be on the path for make to succeed.
#       If either was installed as a dependency during the build, you
#       will need to log out and then log back in for the changes to
#       your path and JAVA_HOME environment variable to take effect.
#
pkgname=rstudio-server-git
_gitname="rstudio"
pkgver=v2022.02.3+492.r1692.g7faaa81408
_gwtver=2.8.2
_ginver=2.1.2
_nodever=16.14.0
pkgrel=1
pkgdesc="A new integrated development environment (IDE) for R programming language"
arch=('i686' 'x86_64')
url="http://www.rstudio.org/"
license=('AGPL3')
depends=('r>=3.0.1' 'boost-libs>=1.69' 'openssl' 'mathjax2' 'pandoc' 'clang' 'postgresql-libs' 'sqlite3' 'soci' 'yaml-cpp' 'hunspell-en_US')
makedepends=('git' 'quarto-cli-bin' 'cmake>=3.4.3' 'boost>=1.69' 'jdk8-openjdk' 'apache-ant' 'unzip' 'bzip2' 'pango' 'pam' 'zlib' 'wget' 'yarn')
install="${pkgname}.install"
conflicts=('rstudio-server')
source=('git+https://github.com/rstudio/rstudio.git'
	'rstudio-server.service'
	"https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/google-gin/gin-${_ginver}.zip"
        "https://storage.googleapis.com/gwt-releases/gwt-${_gwtver}.zip"
	"https://nodejs.org/dist/v${_nodever}/node-v${_nodever}-linux-x64.tar.gz"
)
md5sums=('SKIP'
         'eea28f7865720f6c8d5de12f3f631880'
         'e2617189fe5c138945b8cc95f26bd476'
         'c295406d68c5ef364e445068599aa6d4'
         'a46e501a201be6c3c05c0f770c375372')
         

pkgver() {
  cd "$srcdir/$_gitname"
  git describe --long --tags | sed -r 's/([^-]*-g)/r\1/;s/-/./g'
}

prepare () {
    if test "`archlinux-java get`" != "java-8-openjdk";then
        cat<<EOT
    Your default Java version is set to `archlinux-java get`, not java-8-openjdk!

    Fix it with:

        archlinux-java set java-8-openjdk

EOT
        exit 1
    fi

    _rstudio_node_version=$(perl -ne 'print "$1" if(m/RSTUDIO_NODE_VERSION\s*"([^"]+)/)' "$srcdir"/rstudio/src/node/CMakeNodeTools.txt)
    if test "$_nodever" != "$_rstudio_node_version";then
        cat<<EOT
    node version in PKGBUILD ($_nodever) does not match what RStudio server expects ($_rstudio_node_version).

    Fix it by updating the \$_nodever variable in the PKGBUILD:

    ...
    \$_nodever="$_rstudio_node_version"
    ...

    Then clean the PKGBUILD repo (git clean -ffdx), update the pkgsums (updpkgsums) and rebuild (makepkg -sf)

EOT
        exit 1
    fi

	cd ${srcdir}/$_gitname
	# Patching SOCI
	# patch -p1 < ${srcdir}/soci.patch
	# patch -p1 < ${srcdir}/rstudio_boost.patch

	msg "Extracting dependencies..."
	    cd "${srcdir}/${_gitname}/src/gwt"
	    install -d lib/{gin,gwt}
	    install -d lib/gin/${_ginver}
	    install -d lib/gwt/${_gwtver}
	    unzip -qo "${srcdir}/gin-${_ginver}.zip" -d lib/gin/${_ginver}
	    cp -r "${srcdir}/gwt-${_gwtver}/"* lib/gwt/${_gwtver}

	    cd "${srcdir}/${_gitname}/dependencies/common"
	    _pandocver=$(grep -oP "(?<=PANDOC_VERSION=\").*(?=\"$)" install-pandoc)
	    install -d pandoc/${_pandocver}

	    ln -sfT "/usr/share/myspell/dicts" dictionaries
	    ln -sfT "/usr/share/mathjax2" mathjax-27
   	    ln -sfT /opt/quarto quarto
	    ln -sfT "/usr/bin/pandoc" pandoc/${_pandocver}/pandoc
	    ln -sfT "/usr/bin/pandoc-citeproc" pandoc/${_pandocvec}/pandoc-citeproc

	    # Nodejs
	    install -d node/${_nodever}
	    cp -r ${srcdir}/node-v${_nodever}-linux-x64/* node/${_nodever}
	    cd ${srcdir}/${_gitname}/src/gwt/panmirror/src/editor
	    yarn config set ignore-engines true
	    yarn install

	    # Fix links for src/cpp/session/CMakeLists.txt
	    cd "${srcdir}/${_gitname}/dependencies"
	    ln -sfT common/dictionaries dictionaries
   	    ln -sfT common/quarto quarto
	    ln -sfT common/mathjax-27 mathjax-27
	    ln -sfT common/pandoc pandoc

	    cd ${srcdir}/${_gitname}/dependencies/common
	    # ./install-dictionaries
	    msg "Downloading and installing R packages..."
	    ./install-packages
}


build() {
  # Small hack
  # unset user Rprofile.r variable for building
  if [ -n $R_PROFILE_USER ]; then
	  unset R_PROFILE_USER
  fi

  # Configure with cmake in a new build directory as recommended in the rstudio INSTALL file
  rm -rf ${srcdir}/$_gitname/build
  mkdir "${srcdir}/$_gitname/build"
  cd "${srcdir}/$_gitname/build"

  # Configure cmake 
  cmake -DRSTUDIO_TARGET=Server \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=/usr/lib/rstudio-server \
	-DRSTUDIO_USE_SYSTEM_BOOST=yes \
	-DRSTUDIO_USE_SYSTEM_YAML_CPP=yes \
	-DBoost_NO_BOOST_CMAKE=ON \
	-DRSTUDIO_USE_SYSTEM_SOCI=yes ..

}


package() {
# Install
  msg "Installing to pkgdir"
  cd "${srcdir}/$_gitname/build"
  make DESTDIR="$pkgdir" install
# Extras (pam, var)
  msg "Install additional files..."
  install -d "${pkgdir}/etc/pam.d"
  install -Dm 644 "${pkgdir}/usr/lib/rstudio-server/extras/pam/rstudio" "${pkgdir}/etc/pam.d/rstudio"
  # rstudio home directory
  install -d "${pkgdir}/srv/rstudio-server"
  install -d "${pkgdir}/usr/lib//systemd/system"
  install -Dm 644 "${srcdir}/rstudio-server.service" "${pkgdir}/usr/lib//systemd/system/rstudio-server.service"
  install -d "${pkgdir}/etc/rstudio"

  # vars
  mkdir -p ${pkgdir}/run/rstudio-server ${pkgdir}/lock/rstudio-server ${pkgdir}/var/log/rstudio-server ${pkgdir}/var/lib/rstudio-server

  # lns
  mkdir -p $pkgdir/usr/bin
  ln -s /usr/lib/rstudio-server/bin/rserver $pkgdir/usr/bin/rserver
  ln -s /usr/lib/rstudio-server/bin/rstudio-server $pkgdir/usr/bin/rstudio-server
}