diff --git a/builder/Dockerfile.ubuntu-1804 b/builder/Dockerfile.ubuntu-1804 index 67a271b..df5f3ec 100644 --- a/builder/Dockerfile.ubuntu-1804 +++ b/builder/Dockerfile.ubuntu-1804 @@ -6,15 +6,18 @@ RUN set -x \ && sed -i "s|# deb-src|deb-src|g" /etc/apt/sources.list \ && export DEBIAN_FRONTEND=noninteractive \ && apt-get update \ - && apt-get install -y libcurl4-openssl-dev libicu-dev libopenblas-base wget python-pip \ + && apt-get install -y libcurl4-openssl-dev libicu-dev libopenblas-base wget python-pip ruby ruby-dev \ && apt-get build-dep -y r-base RUN pip install awscli +RUN gem install fpm + RUN chmod 0777 /opt # Override the default pager used by R ENV PAGER /usr/bin/pager +COPY package.ubuntu-1804 /package.sh COPY build.sh . ENTRYPOINT ./build.sh diff --git a/builder/build.sh b/builder/build.sh index 123d6e5..56d1754 100755 --- a/builder/build.sh +++ b/builder/build.sh @@ -19,6 +19,12 @@ upload_r() { if [ -n "$S3_BUCKET" ] && [ "$S3_BUCKET" != "" ]; then echo "Storing artifact on s3: ${S3_BUCKET}, tarball: ${TARBALL_NAME}" aws s3 cp /tmp/${TARBALL_NAME} s3://${S3_BUCKET}/${S3_BUCKET_PREFIX}${baseName}/${TARBALL_NAME} + # check if PKG_FILE has been set by a packager script and act accordingly + if [ -n "$PKG_FILE" ] && [ "$PKG_FILE" != "" ]; then + if [ -f "$PKG_FILE" ]; then + aws s3 cp ${PKG_FILE} s3://${S3_BUCKET}/${S3_BUCKET_PREFIX}${baseName}/pkgs/$(basename ${PKG_FILE}) + fi + fi fi if [ -n "$LOCAL_STORE" ] && [ "$LOCAL_STORE" != '' ]; then echo "Storing artifact locally: ${LOCAL_STORE}, tarball: ${TARBALL_NAME}" @@ -89,6 +95,16 @@ compile_r() { make install } +# check for packager script +## If it exists this build is ready for packaging with fpm, so run the script +## else do nothing +package_r() { + if [[ -f /package.sh ]]; then + export R_VERSION=${1} + source /package.sh + fi +} + set_up_environment() { mkdir -p /opt/R } @@ -102,5 +118,6 @@ set_up_environment fetch_r_source $R_VERSION compile_r $R_VERSION clean_r +package_r $R_VERSION archive_r $R_VERSION upload_r $R_VERSION diff --git a/builder/package.ubuntu-1804 b/builder/package.ubuntu-1804 new file mode 100644 index 0000000..52d5028 --- /dev/null +++ b/builder/package.ubuntu-1804 @@ -0,0 +1,51 @@ +if [[ ! -d /tmp/output/ubuntu-1804 ]]; then + mkdir -p /tmp/output/ubuntu-1804 +fi + +fpm \ + -s dir \ + -t deb \ + -v 1 \ + -n R-${R_VERSION} \ + --deb-priority "optional" \ + --deb-field 'Bugs: https://github.com/rstudio/r-builds/issues' \ + --url "http://www.r-project.org/" \ + --description "GNU R statistical computation and graphics system" \ + --maintainer "RStudio Inc https://github.com/rstudio/r-builds" \ + --license "GPL-2" \ + -p /tmp/output/ubuntu-1804/ \ + -d g++ \ + -d gcc \ + -d gfortran \ + -d libbz2-1.0 \ + -d libc6 \ + -d libcairo2 \ + -d libcurl4 \ + -d libglib2.0-0 \ + -d libgomp1 \ + -d libicu60 \ + -d libjpeg8 \ + -d liblzma5 \ + -d libopenblas-dev \ + -d libpango-1.0-0 \ + -d libpangocairo-1.0-0 \ + -d libpaper-utils \ + -d libpcre3 \ + -d libpng16-16 \ + -d libreadline7 \ + -d libtcl8.6 \ + -d libtiff5 \ + -d libtk8.6 \ + -d libx11-6 \ + -d libxt6 \ + -d make \ + -d ucf \ + -d unzip \ + -d xdg-utils \ + -d zip \ + -d zlib1g \ + /opt/R/${R_VERSION} + +shopt -s extglob +export PKG_FILE=$(ls /tmp/output/ubuntu-1804/[rR]-${R_VERSION}*.@(deb|rpm) | head -1) +