From f3027f3b121a7ae188dfd617c83e336274d14d70 Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 13 Nov 2024 09:23:34 +0100 Subject: [PATCH] rstudio-server: bug fixes in launcher script, rebuild needed --- rstudio-server-2024.09.0-375-1.build.sh | 131 ++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100755 rstudio-server-2024.09.0-375-1.build.sh diff --git a/rstudio-server-2024.09.0-375-1.build.sh b/rstudio-server-2024.09.0-375-1.build.sh new file mode 100755 index 0000000..0af210a --- /dev/null +++ b/rstudio-server-2024.09.0-375-1.build.sh @@ -0,0 +1,131 @@ +#! /usr/bin/bash + +# COOKIE=$(mcookie|cut -c-8); grep -v V_GREP_ME $0 > /dev/shm/runme-$COOKIE.sh ; sleep 0.3; exec bash /dev/shm/runme-$COOKIE.sh +# TESTING=1 + +PKG=rstudio-server +VERSION=2024.09.0-375 +BUILD=1 + +CONTAINER_NAME=$PKG-$VERSION-$BUILD-container +CONTAINER_TYPE=sandbox # otherwise a sif is created, but here there is still trouble + +PREFIX=/pkg/$PKG-$VERSION-$BUILD +if [ -n "$TESTING" ]; then PREFIX=/scratch/local2/$PKG-$VERSION-$BUILD ; fi + +set -xe +umask 022 + +BUILD_TMPDIR=/scratch/local2/$PKG-$VERSION-$BUILD.$USER.build.tmp +test -d $BUILD_TMPDIR && ( chmod -R u+rwx $BUILD_TMPDIR || true ; rm -rf $BUILD_TMPDIR ) +mkdir -p $BUILD_TMPDIR/home +export TMPDIR=$BUILD_TMPDIR +export HOME=$BUILD_TMPDIR/home + +mkdir -p $PREFIX +cat >$PREFIX/profile <<-EOF + PATH=$PREFIX/bin:\$PATH:/usr/local/package/bin + if [ -d $PREFIX/.compatlibs ]; then export LD_LIBRARY_PATH=$PREFIX/.compatlibs\${LD_LIBRARY_PATH:+:}\$LD_LIBRARY_PATH ; fi +EOF +. $PREFIX/profile + +BUILD=$PREFIX/build + +mkdir -p $BUILD +cd $BUILD + +mkdir -p rstudio-server +cd rstudio-server + +# orig: https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2024.09.0-375-amd64.deb +BEEHIVE=https://beehive.molgen.mpg.de/048f99f73ce9442ef2efca9b92c14a31/rstudio-server-2024.09.0-375-amd64.deb + +test -e rstudio-server-$VERSION-amd64.deb || wget -nv $BEEHIVE +test -d rstudio-server || ar p rstudio-server-$VERSION-amd64.deb data.tar.xz | unxz | tar -x --strip-components=3 -f - + +cd $BUILD + +mkdir -p apptainer +cd apptainer + +echo 'root:x:0:0:root:/root:/bin/bash' > passwd +echo 'root:x:0:' > group +echo '# this is just a stub file, needed to keep /usr/sbin/hostconfig happy (almost).' > hostconfig + +cat > apptainer.def <<-EOF + # our build mode + Bootstrap: scratch + +# %environment +# export PATH='' + + # what goes into the container ... + %files + $BUILD/rstudio-server/rstudio-server /apps/rstudio-server + $BUILD/apptainer/group /etc/group + $BUILD/apptainer/hostconfig /etc/hostconfig + $BUILD/apptainer/passwd /etc/passwd + /etc/services /etc/services + + + + # This is a scriptlet that will be executed on the host, not in the container + %setup + ln -s usr/bin \$APPTAINER_ROOTFS/bin + ln -s usr/sbin \$APPTAINER_ROOTFS/sbin + ln -s usr/lib \$APPTAINER_ROOTFS/lib + ln -s usr/lib \$APPTAINER_ROOTFS/lib64 + + # %runscript + # echo "This is what happens when you run the container..." + + # %post + # echo "Hello from inside the container" + +EOF + +if [ "$CONTAINER_TYPE" = "sandbox" ]; then + CONTAINER=$CONTAINER_NAME-sandbox + test -d $CONTAINER && rm -r $CONTAINER + apptainer build --sandbox $CONTAINER apptainer.def +else + CONTAINER=$CONTAINER_NAME.sif + rm -vf $CONTAINER + apptainer build $CONTAINER apptainer.def +fi + +cd $BUILD + +mkdir -p launcher +cd launcher + +# Need a proper startup for rstudio-server (search: 'rstudio-server docker singularity/apptainer') +# see e.g. https://github.com/oist/BioinfoUgrp/blob/master/RStudio/launch_rserver.sh + +GITCOMMIT_PAM_HELPER=a4d695b +GITCOMMIT_LAUNCHER=3f3fc19 + +wget https://github.molgen.mpg.de/thomas/utilities_for_rstudio_server/raw/$GITCOMMIT_PAM_HELPER/rstudio-server.pam-helper.sh +sed -i \ + -e "/^# @ID@ #/ s,@ID@,source: github.molgen.mpg.de/thomas/utilities_for_rstudio_server rstudio-server.pam-helper.sh $GITCOMMIT_PAM_HELPER," \ + rstudio-server.pam-helper.sh + +chmod -c +x rstudio-server.pam-helper.sh + +wget https://github.molgen.mpg.de/thomas/utilities_for_rstudio_server/raw/$GITCOMMIT_LAUNCHER/rstudio-server.launcher.sh +sed -i \ + -e "/^# @ID@ #/ s,@ID@,source: github.molgen.mpg.de/thomas/utilities_for_rstudio_server rstudio-server.launcher.sh $GITCOMMIT_LAUNCHER," \ + -e "/^PREFIX=/ s,@PREFIX@,$PREFIX," \ + -e "/^CONTAINER=/ s,@CONTAINER@,$CONTAINER," \ + rstudio-server.launcher.sh + +mv rstudio-server.launcher.sh rstudio-server +chmod -c +x rstudio-server + +cd $BUILD + +# now 'install' +mkdir -vp $PREFIX/bin $PREFIX/libexec +cp -vp launcher/rstudio-server $PREFIX/bin +cp -vp launcher/rstudio-server.pam-helper.sh $PREFIX/bin +mv -v apptainer/$CONTAINER $PREFIX/libexec