From 048f2ca0636292a82fc070faa09e99a2e8c87614 Mon Sep 17 00:00:00 2001 From: Greg Lin Date: Wed, 29 Apr 2020 14:44:16 -0500 Subject: [PATCH] Remove unnecessary PCRE2 dependency on R 3.x For more details on PCRE2 usage in R 3.x, see: https://github.com/wch/r-source/blob/7d25524f8b83d63979cc18f0914a321bfbe9a819/m4/R.m4#L3056-L3058 https://github.com/wch/r-source/blob/7d25524f8b83d63979cc18f0914a321bfbe9a819/m4/R.m4#L3139-L3155 --- builder/build.sh | 14 ++++++++++++++ builder/package.centos-6 | 9 +++++++-- builder/package.centos-7 | 9 +++++++-- builder/package.centos-8 | 9 +++++++-- builder/package.debian-10 | 9 +++++++-- builder/package.debian-9 | 9 +++++++-- builder/package.opensuse-15 | 9 +++++++-- builder/package.opensuse-42 | 9 +++++++-- builder/package.ubuntu-1604 | 9 +++++++-- builder/package.ubuntu-1804 | 9 +++++++-- builder/package.ubuntu-2004 | 9 +++++++-- 11 files changed, 84 insertions(+), 20 deletions(-) diff --git a/builder/build.sh b/builder/build.sh index aac683a..01461ef 100755 --- a/builder/build.sh +++ b/builder/build.sh @@ -65,6 +65,20 @@ compile_r() { build_flag='' fi + # Avoid a PCRE2 dependency for R 3.5 and 3.6. R 3.x uses PCRE1, but R 3.5+ + # will link against PCRE2 if present, although it is not actually used. + # Since there's no way to disable this in the configure script, and we need + # PCRE2 for R 4.x, we hide PCRE2 from the configure script by temporarily + # removing the pkg-config file and pcre2-config script. + if [[ "${1}" =~ ^3 ]] && pkg-config --exists libpcre2-8; then + mkdir -p /tmp/pcre2 + pc_dir=$(pkg-config --variable pcfiledir libpcre2-8) + mv ${pc_dir}/libpcre2-8.pc /tmp/pcre2 + config_bin=$(which pcre2-config) + mv ${config_bin} /tmp/pcre2 + trap "{ mv /tmp/pcre2/libpcre2-8.pc ${pc_dir}; mv /tmp/pcre2/pcre2-config ${config_bin}; }" EXIT + fi + # Default configure options. Some Dockerfiles override this with an ENV directive. default_configure_options="\ --enable-R-shlib \ diff --git a/builder/package.centos-6 b/builder/package.centos-6 index 93fadd8..a855002 100644 --- a/builder/package.centos-6 +++ b/builder/package.centos-6 @@ -4,6 +4,12 @@ if [[ ! -d /tmp/output/centos-6 ]]; then mkdir -p /tmp/output/centos-6 fi +# R 3.x requires PCRE1 +pcre_lib='pcre2-devel' +if [[ "${R_VERSION}" =~ ^3 ]]; then + pcre_lib='pcre-devel' +fi + # create post-install script required for openblas cat <> /post-install.sh mv /opt/R/${R_VERSION}/lib/R/lib/libRblas.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so.keep @@ -60,8 +66,7 @@ fpm \ -d make \ -d openblas-devel \ -d pango \ - -d pcre-devel \ - -d pcre2-devel \ + -d ${pcre_lib} \ -d tcl \ -d tk \ -d unzip \ diff --git a/builder/package.centos-7 b/builder/package.centos-7 index e927d8f..1623d6a 100644 --- a/builder/package.centos-7 +++ b/builder/package.centos-7 @@ -4,6 +4,12 @@ if [[ ! -d /tmp/output/centos-7 ]]; then mkdir -p /tmp/output/centos-7 fi +# R 3.x requires PCRE1 +pcre_lib='pcre2-devel' +if [[ "${R_VERSION}" =~ ^3 ]]; then + pcre_lib='pcre-devel' +fi + # create post-install script required for openblas cat <> /post-install.sh mv /opt/R/${R_VERSION}/lib/R/lib/libRblas.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so.keep @@ -45,8 +51,7 @@ fpm \ -d make \ -d openblas-devel \ -d pango \ - -d pcre-devel \ - -d pcre2-devel \ + -d ${pcre_lib} \ -d tcl \ -d tk \ -d unzip \ diff --git a/builder/package.centos-8 b/builder/package.centos-8 index a873d1d..4568261 100644 --- a/builder/package.centos-8 +++ b/builder/package.centos-8 @@ -2,6 +2,12 @@ if [[ ! -d /tmp/output/centos-8 ]]; then mkdir -p /tmp/output/centos-8 fi +# R 3.x requires PCRE1 +pcre_lib='pcre2-devel' +if [[ "${R_VERSION}" =~ ^3 ]]; then + pcre_lib='pcre-devel' +fi + # create post-install script required for openblas cat <> /post-install.sh mv /opt/R/${R_VERSION}/lib/R/lib/libRblas.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so.keep @@ -43,8 +49,7 @@ fpm \ -d make \ -d openblas-threads \ -d pango \ - -d pcre-devel \ - -d pcre2-devel \ + -d ${pcre_lib} \ -d tcl \ -d tk \ -d unzip \ diff --git a/builder/package.debian-10 b/builder/package.debian-10 index afacab5..5d9dfc9 100644 --- a/builder/package.debian-10 +++ b/builder/package.debian-10 @@ -4,6 +4,12 @@ if [[ ! -d /tmp/output/debian-10 ]]; then mkdir -p /tmp/output/debian-10 fi +# R 3.x requires PCRE1 +pcre_lib='libpcre2-8-0' +if [[ "${R_VERSION}" =~ ^3 ]]; then + pcre_lib='libpcre3' +fi + fpm \ -s dir \ -t deb \ @@ -33,8 +39,7 @@ fpm \ -d libpango-1.0-0 \ -d libpangocairo-1.0-0 \ -d libpaper-utils \ - -d libpcre2-8-0 \ - -d libpcre3 \ + -d ${pcre_lib} \ -d libpng16-16 \ -d libreadline7 \ -d libtcl8.6 \ diff --git a/builder/package.debian-9 b/builder/package.debian-9 index ee90933..b60d330 100644 --- a/builder/package.debian-9 +++ b/builder/package.debian-9 @@ -4,6 +4,12 @@ if [[ ! -d /tmp/output/debian-9 ]]; then mkdir -p /tmp/output/debian-9 fi +# R 3.x requires PCRE1 +pcre_lib='libpcre2-8-0' +if [[ "${R_VERSION}" =~ ^3 ]]; then + pcre_lib='libpcre3' +fi + fpm \ -s dir \ -t deb \ @@ -33,8 +39,7 @@ fpm \ -d libpango-1.0-0 \ -d libpangocairo-1.0-0 \ -d libpaper-utils \ - -d libpcre2-8-0 \ - -d libpcre3 \ + -d ${pcre_lib} \ -d libpng16-16 \ -d libreadline7 \ -d libtcl8.6 \ diff --git a/builder/package.opensuse-15 b/builder/package.opensuse-15 index 834a8a9..25b7f24 100644 --- a/builder/package.opensuse-15 +++ b/builder/package.opensuse-15 @@ -4,6 +4,12 @@ if [[ ! -d /tmp/output/opensuse-15 ]]; then mkdir -p /tmp/output/opensuse-15 fi +# R 3.x requires PCRE1 +pcre_lib='pcre2-devel' +if [[ "${R_VERSION}" =~ ^3 ]]; then + pcre_lib='pcre-devel' +fi + # create post-install script required for openblas cat <> /post-install.sh mv /opt/R/${R_VERSION}/lib/R/lib/libRblas.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so.keep @@ -50,8 +56,7 @@ fpm \ -d libtiff5 \ -d make \ -d openblas-devel \ - -d pcre-devel \ - -d pcre2-devel \ + -d ${pcre_lib} \ -d tar \ -d tcl \ -d tk \ diff --git a/builder/package.opensuse-42 b/builder/package.opensuse-42 index 4ee631d..5bb72c9 100644 --- a/builder/package.opensuse-42 +++ b/builder/package.opensuse-42 @@ -4,6 +4,12 @@ if [[ ! -d /tmp/output/opensuse-42 ]]; then mkdir -p /tmp/output/opensuse-42 fi +# R 3.x requires PCRE1 +pcre_lib='pcre2-devel' +if [[ "${R_VERSION}" =~ ^3 ]]; then + pcre_lib='pcre-devel' +fi + # create post-install script required for openblas cat <> /post-install.sh mv /opt/R/${R_VERSION}/lib/R/lib/libRblas.so /opt/R/${R_VERSION}/lib/R/lib/libRblas.so.keep @@ -48,8 +54,7 @@ fpm \ -d libtiff5 \ -d make \ -d openblas-devel \ - -d pcre-devel \ - -d pcre2-devel \ + -d ${pcre_lib} \ -d tar \ -d tcl \ -d tk \ diff --git a/builder/package.ubuntu-1604 b/builder/package.ubuntu-1604 index 27b797b..e9c9034 100644 --- a/builder/package.ubuntu-1604 +++ b/builder/package.ubuntu-1604 @@ -4,6 +4,12 @@ if [[ ! -d /tmp/output/ubuntu-1604 ]]; then mkdir -p /tmp/output/ubuntu-1604 fi +# R 3.x requires PCRE1 +pcre_lib='libpcre2-8-0' +if [[ "${R_VERSION}" =~ ^3 ]]; then + pcre_lib='libpcre3' +fi + fpm \ -s dir \ -t deb \ @@ -33,8 +39,7 @@ fpm \ -d libpango-1.0-0 \ -d libpangocairo-1.0-0 \ -d libpaper-utils \ - -d libpcre2-8-0 \ - -d libpcre3 \ + -d ${pcre_lib} \ -d libpng16-16 \ -d libreadline6 \ -d libtcl8.6 \ diff --git a/builder/package.ubuntu-1804 b/builder/package.ubuntu-1804 index e858c1f..2d9d8d5 100644 --- a/builder/package.ubuntu-1804 +++ b/builder/package.ubuntu-1804 @@ -4,6 +4,12 @@ if [[ ! -d /tmp/output/ubuntu-1804 ]]; then mkdir -p /tmp/output/ubuntu-1804 fi +# R 3.x requires PCRE1 +pcre_lib='libpcre2-8-0' +if [[ "${R_VERSION}" =~ ^3 ]]; then + pcre_lib='libpcre3' +fi + fpm \ -s dir \ -t deb \ @@ -33,8 +39,7 @@ fpm \ -d libpango-1.0-0 \ -d libpangocairo-1.0-0 \ -d libpaper-utils \ - -d libpcre2-8-0 \ - -d libpcre3 \ + -d ${pcre_lib} \ -d libpng16-16 \ -d libreadline7 \ -d libtcl8.6 \ diff --git a/builder/package.ubuntu-2004 b/builder/package.ubuntu-2004 index 60f8f28..f615651 100644 --- a/builder/package.ubuntu-2004 +++ b/builder/package.ubuntu-2004 @@ -4,6 +4,12 @@ if [[ ! -d /tmp/output/ubuntu-2004 ]]; then mkdir -p /tmp/output/ubuntu-2004 fi +# R 3.x requires PCRE1 +pcre_lib='libpcre2-8-0' +if [[ "${R_VERSION}" =~ ^3 ]]; then + pcre_lib='libpcre3' +fi + fpm \ -s dir \ -t deb \ @@ -34,8 +40,7 @@ fpm \ -d libpango-1.0-0 \ -d libpangocairo-1.0-0 \ -d libpaper-utils \ - -d libpcre2-8-0 \ - -d libpcre3 \ + -d ${pcre_lib} \ -d libpng16-16 \ -d libreadline8 \ -d libtcl8.6 \