Last active
April 8, 2017 13:10
-
-
Save jankatins/3d5d25c1326c1fcc60ba1222a10a6259 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Generate a RStudio*.AppImage (either stable or one of the dailies) file which can be used by | |
# marking it as axecuteable and simply running it | |
# | |
# ./rstudio 1.1.90 # version downloads a daily | |
# chmod +x RStudio*.AppImage | |
# ./RStudio*.AppImage | |
# It uses the provided deb for an older ubuntu and adds the required packages from debian oldstable | |
set -e | |
APP=RStudio | |
LOWERAPP=rstudio # ${APP,,} | |
mkdir -p ./$APP/$APP.AppDir/usr/lib | |
cd ./$APP/ | |
wget -q https://github.com/probonopd/AppImages/raw/master/functions.sh -O ./functions.sh | |
. ./functions.sh | |
# We get this app and almost all its dependencies via apt-get | |
# but not using the host system's information about what is | |
# installed on the system but our own assumptions instead | |
generate_status | |
echo "deb http://ftp.de.debian.org/debian/ oldstable main contrib non-free | |
" > sources.list | |
if [[ "x$1x" == "xx" ]] ; then | |
wget -c "https://download1.rstudio.org/rstudio-1.0.136-amd64.deb" | |
else | |
wget -c "https://s3.amazonaws.com/rstudio-dailybuilds/rstudio-$1-amd64.deb" | |
fi | |
# Add local repository so that we can install deb files | |
# that were downloaded outside of a repository | |
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz | |
echo "deb file:$(readlink -e $PWD) ./" >> sources.list | |
apt-get $OPTIONS update | |
# running rstudio in the appimage runtime expects libxml2 in some special place, so move it there later on | |
URLS=$(apt-get $OPTIONS -y install --print-uris $LOWERAPP libxml2 | cut -d "'" -f 2 | grep -e "^http") | |
wget -c $URLS | |
cd ./$APP.AppDir/ | |
find ../*.deb -exec dpkg -x {} . \; || true | |
cp ./usr/share/applications/$LOWERAPP.desktop . | |
rm -rf ./usr/share/icons/48x48/apps || true | |
find ./usr/share/icons -path *256* -name $LOWERAPP.png -exec cp {} . \; || true | |
find ./usr/share/icons -path *512* -name $LOWERAPP.png -exec cp {} . \; || true | |
get_apprun | |
# Copy in the indirect dependencies | |
# copy_deps # not needed here due to the way we use apt to download everything | |
move_lib | |
# mv doesn't really work due to non-empty directories... | |
cp -r ./usr/lib/x86_64-linux-gnu/* ./usr/lib/ && rm -R ./usr/lib/x86_64-linux-gnu/* | |
mkdir ./lib | |
# No idea why, but now it works... | |
mv ./usr/lib/libxml2.so.2 ./lib | |
delete_blacklisted | |
rm -rf ./etc/ ./home/ || true | |
# rstudio has a nonstandard naming :-/ | |
VER1=$(find ../*.deb -name "${LOWERAPP}-*" | head -n 1 | cut -d "-" -f 2 ) | |
GLIBC_NEEDED=$(glibc_needed) | |
VERSION=$VER1.glibc$GLIBC_NEEDED | |
echo $VERSION | |
# the get_desktopintegration function usually installs the wrapper + desktop file, but this doesn't work here | |
# because of the directory layout of rstudio | |
mkdir -p ./usr/bin | |
wget -O ./usr/bin/rstudio.wrapper https://raw.githubusercontent.com/probonopd/AppImageKit/master/desktopintegration | |
chmod +x ./usr/bin/rstudio.wrapper | |
# the wrapper expects a /usr/bin/<NAME> binary, so create one... | |
(cd ./usr/bin ; rm -rvf rstudio; ln -s ../lib/rstudio/bin/rstudio .) | |
# rstudio ships with a full path to /usr/lib/rstudio/bin/rstudio, but we want to use a wrapper | |
sed -i -e "s|^Exec=.*|Exec=$LOWERAPP.wrapper|g" *.desktop | |
# Go out of AppImage | |
cd .. | |
generate_appimage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment