From 248525742446d58f38c3ef9a5c3186fdc9d17cd9 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Mon, 1 Aug 2016 00:30:29 +0000 Subject: [PATCH 1/8] Add a test to confirm the prefix doesn't work fine with `/bin/ruby` --- test/prefix.bats | 9 +++++++++ test/test_helper.bash | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/test/prefix.bats b/test/prefix.bats index 3fb94086..b78b8f94 100644 --- a/test/prefix.bats +++ b/test/prefix.bats @@ -24,6 +24,15 @@ load test_helper assert_success "$RBENV_TEST_DIR" } +@test "prefix for system in /" { + mkdir -p "${RBENV_TEST_DIR}/bin" + touch "${RBENV_TEST_DIR}/bin/rbenv-which" + echo "echo /bin/ruby" >"${RBENV_TEST_DIR}/bin/rbenv-which" + chmod +x "${RBENV_TEST_DIR}/bin/rbenv-which" + RBENV_VERSION="system" run rbenv-prefix + assert_success "/" +} + @test "prefix for invalid system" { PATH="$(path_without ruby)" run rbenv-prefix system assert_failure "rbenv: system version not found in PATH" diff --git a/test/test_helper.bash b/test/test_helper.bash index aef883a4..a6cbb74e 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -20,10 +20,10 @@ if [ -z "$RBENV_TEST_DIR" ]; then export RBENV_HOOK_PATH="${RBENV_ROOT}/rbenv.d" PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin - PATH="${RBENV_TEST_DIR}/bin:$PATH" PATH="${BATS_TEST_DIRNAME}/../libexec:$PATH" PATH="${BATS_TEST_DIRNAME}/libexec:$PATH" PATH="${RBENV_ROOT}/shims:$PATH" + PATH="${RBENV_TEST_DIR}/bin:$PATH" export PATH for xdg_var in `env 2>/dev/null | grep ^XDG_ | cut -d= -f1`; do unset "$xdg_var"; done From 6030ea51e4e4bdefa188529ed7bca8e45b1b078e Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Mon, 1 Aug 2016 00:32:50 +0000 Subject: [PATCH 2/8] Add a workaround for system executables in `/bin` --- libexec/rbenv-prefix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libexec/rbenv-prefix b/libexec/rbenv-prefix index 5376cf5d..e65be834 100755 --- a/libexec/rbenv-prefix +++ b/libexec/rbenv-prefix @@ -24,7 +24,8 @@ fi if [ "$RBENV_VERSION" = "system" ]; then if RUBY_PATH="$(rbenv-which ruby 2>/dev/null)"; then RUBY_PATH="${RUBY_PATH%/*}" - echo "${RUBY_PATH%/bin}" + RBENV_PREFIX_PATH="${RUBY_PATH%/bin}" + echo "${RBENV_PREFIX_PATH:-/}" exit else echo "rbenv: system version not found in PATH" >&2 From a456528be82cc76e9a851b781426ad3fffe40b90 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Tue, 2 Aug 2016 00:21:28 +0000 Subject: [PATCH 3/8] Keep original ordering of PATH configuration --- test/prefix.bats | 9 +++++---- test/test_helper.bash | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/prefix.bats b/test/prefix.bats index b78b8f94..0376954a 100644 --- a/test/prefix.bats +++ b/test/prefix.bats @@ -25,12 +25,13 @@ load test_helper } @test "prefix for system in /" { - mkdir -p "${RBENV_TEST_DIR}/bin" - touch "${RBENV_TEST_DIR}/bin/rbenv-which" - echo "echo /bin/ruby" >"${RBENV_TEST_DIR}/bin/rbenv-which" - chmod +x "${RBENV_TEST_DIR}/bin/rbenv-which" + mkdir -p "${BATS_TEST_DIRNAME}/libexec" + touch "${BATS_TEST_DIRNAME}/libexec/rbenv-which" + echo "echo /bin/ruby" >"${BATS_TEST_DIRNAME}/libexec/rbenv-which" + chmod +x "${BATS_TEST_DIRNAME}/libexec/rbenv-which" RBENV_VERSION="system" run rbenv-prefix assert_success "/" + rm -f "${BATS_TEST_DIRNAME}/libexec/rbenv-which" } @test "prefix for invalid system" { diff --git a/test/test_helper.bash b/test/test_helper.bash index a6cbb74e..aef883a4 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -20,10 +20,10 @@ if [ -z "$RBENV_TEST_DIR" ]; then export RBENV_HOOK_PATH="${RBENV_ROOT}/rbenv.d" PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin + PATH="${RBENV_TEST_DIR}/bin:$PATH" PATH="${BATS_TEST_DIRNAME}/../libexec:$PATH" PATH="${BATS_TEST_DIRNAME}/libexec:$PATH" PATH="${RBENV_ROOT}/shims:$PATH" - PATH="${RBENV_TEST_DIR}/bin:$PATH" export PATH for xdg_var in `env 2>/dev/null | grep ^XDG_ | cut -d= -f1`; do unset "$xdg_var"; done From 07fd1ae66b34439ed88659d01b87b2f76928c069 Mon Sep 17 00:00:00 2001 From: Jose Luis Duran Date: Tue, 2 Aug 2016 11:36:37 -0300 Subject: [PATCH 4/8] Update `shobj-conf` Update the `shobj-conf` script imported from bash to support new OSs. --- src/shobj-conf | 176 +++++++++++++++++++++++++++++-------------------- 1 file changed, 106 insertions(+), 70 deletions(-) diff --git a/src/shobj-conf b/src/shobj-conf index 593867ee..1f64433d 100755 --- a/src/shobj-conf +++ b/src/shobj-conf @@ -10,21 +10,23 @@ # Chet Ramey # chet@po.cwru.edu -# Copyright (C) 1996-2002 Free Software Foundation, Inc. +# Copyright (C) 1996-2014 Free Software Foundation, Inc. # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. +# This file is part of GNU Bash, the Bourne Again SHell. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. # # defaults @@ -62,7 +64,21 @@ while [ $# -gt 0 ]; do esac done -case "${host_os}-${SHOBJ_CC}" in +case "${host_os}-${SHOBJ_CC}-${host_vendor}" in +nsk-cc-tandem) + SHOBJ_CFLAGS=-Wglobalized + case `uname -m` in + NSR*) + SHOBJ_CFLAGS="${SHOBJ_CFLAGS} -Wcall_shared" # default on TNS/E, needed on TNS/R + SHOBJ_LD=/usr/bin/ld # for TNS/R + ;; + NSE*|NEO*) + SHOBJ_LD=/usr/bin/eld + ;; + esac + SHOBJ_LDFLAGS='-shared -bglobalized -unres_symbols ignore' + ;; + sunos4*-*gcc*) SHOBJ_CFLAGS=-fpic SHOBJ_LD=/usr/bin/ld @@ -80,15 +96,17 @@ sunos4*) ;; sunos5*-*gcc*|solaris2*-*gcc*) - SHOBJ_CFLAGS=-fpic SHOBJ_LD='${CC}' ld_used=`gcc -print-prog-name=ld` if ${ld_used} -V 2>&1 | grep GNU >/dev/null 2>&1; then # This line works for the GNU ld SHOBJ_LDFLAGS='-shared -Wl,-h,$@' + # http://sourceware.org/ml/binutils/2001-08/msg00361.html + SHOBJ_CFLAGS=-fPIC else # This line works for the Solaris linker in /usr/ccs/bin/ld SHOBJ_LDFLAGS='-shared -Wl,-i -Wl,-h,$@' + SHOBJ_CFLAGS=-fpic fi # SHLIB_XLDFLAGS='-R $(libdir)' @@ -104,8 +122,8 @@ sunos5*|solaris2*) SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; -# All versions of Linux or the semi-mythical GNU Hurd. -linux*-*|gnu*-*|k*bsd*-gnu-*) +# All versions of Linux (including Gentoo/FreeBSD) or the semi-mythical GNU Hurd. +linux*-*|gnu*-*|k*bsd*-gnu-*|freebsd*-gentoo) SHOBJ_CFLAGS=-fPIC SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared -Wl,-soname,$@' @@ -114,7 +132,7 @@ linux*-*|gnu*-*|k*bsd*-gnu-*) SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)' ;; -freebsd2* | netbsd*) +freebsd2*) SHOBJ_CFLAGS=-fpic SHOBJ_LD=ld SHOBJ_LDFLAGS='-x -Bshareable' @@ -124,8 +142,8 @@ freebsd2* | netbsd*) ;; # FreeBSD-3.x ELF -freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*|dragonfly*) - SHOBJ_CFLAGS=-fpic +freebsd3*|freebsdaout*) + SHOBJ_CFLAGS=-fPIC SHOBJ_LD='${CC}' if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then @@ -141,39 +159,20 @@ freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*|dragonfly*) fi ;; +# FreeBSD-4.x and later have only ELF +freebsd[4-9]*|freebsd1[0-9]*|freebsdelf*|dragonfly*) + SHOBJ_CFLAGS=-fPIC + SHOBJ_LD='${CC}' + + SHOBJ_LDFLAGS='-shared -Wl,-soname,$@' + SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)' + + SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' + ;; + # Darwin/MacOS X -darwin1*) - SHOBJ_STATUS=supported - SHLIB_STATUS=supported - - SHOBJ_CFLAGS='' - SHLIB_LIBSUFF='dylib' - - SHOBJ_LD='${CC}' - SHOBJ_LDFLAGS='-dynamiclib' - ;; - -darwin8*) - SHOBJ_STATUS=supported - SHLIB_STATUS=supported - - SHOBJ_CFLAGS='-fno-common' - - SHOBJ_LD='MACOSX_DEPLOYMENT_TARGET=10.3 ${CC}' - - SHLIB_LIBVERSION='$(SHLIB_MAJOR)$(SHLIB_MINOR).$(SHLIB_LIBSUFF)' - SHLIB_LIBSUFF='dylib' - - SHOBJ_LDFLAGS='-undefined dynamic_lookup' - SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v' - - SHLIB_LIBS='-lncurses' # see if -lcurses works on MacOS X 10.1 - ;; - -darwin*|macosx*) - SHOBJ_STATUS=unsupported - SHLIB_STATUS=supported - +darwin*) + # Common definitions for all darwin/mac os x versions SHOBJ_CFLAGS='-fno-common' SHOBJ_LD='${CC}' @@ -181,19 +180,39 @@ darwin*|macosx*) SHLIB_LIBVERSION='$(SHLIB_MAJOR)$(SHLIB_MINOR).$(SHLIB_LIBSUFF)' SHLIB_LIBSUFF='dylib' + # unused at this time + SHLIB_SONAME='$(libdir)/`echo $@ | sed "s:\\..*::"`.$(SHLIB_MAJOR).$(SHLIB_LIBSUFF)' + case "${host_os}" in - darwin[78]*) SHOBJ_LDFLAGS='' - SHLIB_XLDFLAGS='-dynamiclib -arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v' + # Darwin versions 1, 5, 6, 7 correspond to Mac OS X 10.0, 10.1, 10.2, + # and 10.3, respectively. + darwin[1-7].*) + SHOBJ_STATUS=unsupported + SHOBJ_LDFLAGS='-dynamic' + SHLIB_XLDFLAGS='-arch_only `/usr/bin/arch` -install_name $(libdir)/`echo $@ | sed "s:\\..*::"`.$(SHLIB_MAJOR).$(SHLIB_LIBSUFF) -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v' + ;; + # Darwin 8 == Mac OS X 10.4; Mac OS X 10.N == Darwin N+4 + *) + case "${host_os}" in + darwin[89]*|darwin1[012]*) + SHOBJ_ARCHFLAGS='-arch_only `/usr/bin/arch`' ;; - *) SHOBJ_LDFLAGS='-dynamic' - SHLIB_XLDFLAGS='-arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v' + *) # Mac OS X 10.9 (Mavericks) and later + SHOBJ_ARCHFLAGS= + # for 32 and 64bit universal library + #SHOBJ_ARCHFLAGS='-arch i386 -arch x86_64' + #SHOBJ_CFLAGS=${SHOBJ_CFLAGS}' -arch i386 -arch x86_64' ;; + esac + SHOBJ_LDFLAGS="-dynamiclib -dynamic -undefined dynamic_lookup ${SHOBJ_ARCHFLAGS}" + SHLIB_XLDFLAGS="-dynamiclib ${SHOBJ_ARCHFLAGS}"' -install_name $(libdir)/`echo $@ | sed "s:\\..*::"`.$(SHLIB_MAJOR).$(SHLIB_LIBSUFF) -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v' + ;; esac SHLIB_LIBS='-lncurses' # see if -lcurses works on MacOS X 10.1 ;; -openbsd*) +openbsd*|netbsd*|mirbsd*) SHOBJ_CFLAGS=-fPIC SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared' @@ -258,7 +277,7 @@ osf*) SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; -aix4.[2-9]*-*gcc*) # lightly tested by jik@cisco.com +aix4.[2-9]*-*gcc*|aix[5-9].*-*gcc*) # lightly tested by jik@cisco.com SHOBJ_CFLAGS=-fpic SHOBJ_LD='ld' SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall' @@ -269,7 +288,7 @@ aix4.[2-9]*-*gcc*) # lightly tested by jik@cisco.com SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' ;; -aix4.[2-9]*) +aix4.[2-9]*|aix[5-9].*) SHOBJ_CFLAGS=-K SHOBJ_LD='ld' SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall' @@ -340,7 +359,7 @@ hpux10*-*gcc*) SHOBJ_LD='${CC}' # if you have problems linking here, moving the `-Wl,+h,$@' from # SHLIB_XLDFLAGS to SHOBJ_LDFLAGS has been reported to work - SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,+s' + SHOBJ_LDFLAGS='-shared -fpic -Wl,-b -Wl,+s' SHLIB_XLDFLAGS='-Wl,+h,$@ -Wl,+b,$(libdir)' SHLIB_LIBSUFF='sl' @@ -500,20 +519,37 @@ msdos*) cygwin*) SHOBJ_LD='$(CC)' - SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a' - SHLIB_LIBPREF='cyg' - SHLIB_LIBSUFF='dll' - SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)' - SHLIB_LIBS='$(TERMCAP_LIB)' + SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a' + SHLIB_LIBPREF='cyg' + SHLIB_LIBSUFF='dll' + SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)' + SHLIB_LIBS='$(TERMCAP_LIB)' SHLIB_DOT= - # For official cygwin releases, DLLVERSION will be defined in the - # environment of configure, and will be incremented any time the API - # changes in a non-backwards compatible manner. Otherwise, it is just - # SHLIB_MAJOR. - if [ -n "$DLLVERSION" ] ; then + # For official cygwin releases, DLLVERSION will be defined in the + # environment of configure, and will be incremented any time the API + # changes in a non-backwards compatible manner. Otherwise, it is just + # SHLIB_MAJOR. + if [ -n "$DLLVERSION" ] ; then SHLIB_DLLVERSION="$DLLVERSION" - fi + fi + ;; + +mingw*) + SHOBJ_LD='$(CC)' + SHOBJ_LDFLAGS='-shared -Wl,--enable-auto-import -Wl,--enable-auto-image-base -Wl,--export-all -Wl,--out-implib=$(@).a' + SHLIB_LIBSUFF='dll' + SHLIB_LIBVERSION='$(SHLIB_DLLVERSION).$(SHLIB_LIBSUFF)' + SHLIB_LIBS='$(TERMCAP_LIB)' + + SHLIB_DOT= + # For official cygwin releases, DLLVERSION will be defined in the + # environment of configure, and will be incremented any time the API + # changes in a non-backwards compatible manner. Otherwise, it is just + # SHLIB_MAJOR. + if [ -n "$DLLVERSION" ] ; then + SHLIB_DLLVERSION="$DLLVERSION" + fi ;; # From 8eefa41a4d4f00628423e87c11b24ef374fc3af0 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Wed, 3 Aug 2016 00:58:05 +0000 Subject: [PATCH 5/8] Remove useless `touch` line --- test/prefix.bats | 1 - 1 file changed, 1 deletion(-) diff --git a/test/prefix.bats b/test/prefix.bats index 0376954a..87ab9864 100644 --- a/test/prefix.bats +++ b/test/prefix.bats @@ -26,7 +26,6 @@ load test_helper @test "prefix for system in /" { mkdir -p "${BATS_TEST_DIRNAME}/libexec" - touch "${BATS_TEST_DIRNAME}/libexec/rbenv-which" echo "echo /bin/ruby" >"${BATS_TEST_DIRNAME}/libexec/rbenv-which" chmod +x "${BATS_TEST_DIRNAME}/libexec/rbenv-which" RBENV_VERSION="system" run rbenv-prefix From 83e874a165a9aae7a174308765ed64013e62d0d3 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Wed, 3 Aug 2016 01:33:35 +0000 Subject: [PATCH 6/8] Add explicit shebang to executable for testing --- test/prefix.bats | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/prefix.bats b/test/prefix.bats index 87ab9864..47541e2a 100644 --- a/test/prefix.bats +++ b/test/prefix.bats @@ -26,7 +26,9 @@ load test_helper @test "prefix for system in /" { mkdir -p "${BATS_TEST_DIRNAME}/libexec" - echo "echo /bin/ruby" >"${BATS_TEST_DIRNAME}/libexec/rbenv-which" + { echo "#!/bin/sh" + echo "echo /bin/ruby" + } >"${BATS_TEST_DIRNAME}/libexec/rbenv-which" chmod +x "${BATS_TEST_DIRNAME}/libexec/rbenv-which" RBENV_VERSION="system" run rbenv-prefix assert_success "/" From 36138f4901e201bfe5c7ac858bfcb3f0d3bf762a Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Wed, 3 Aug 2016 06:29:59 +0000 Subject: [PATCH 7/8] Rewrite with using here document syntax --- test/prefix.bats | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/prefix.bats b/test/prefix.bats index 47541e2a..bdee6f06 100644 --- a/test/prefix.bats +++ b/test/prefix.bats @@ -26,9 +26,10 @@ load test_helper @test "prefix for system in /" { mkdir -p "${BATS_TEST_DIRNAME}/libexec" - { echo "#!/bin/sh" - echo "echo /bin/ruby" - } >"${BATS_TEST_DIRNAME}/libexec/rbenv-which" + cat >"${BATS_TEST_DIRNAME}/libexec/rbenv-which" < Date: Mon, 15 Aug 2016 05:22:59 +0000 Subject: [PATCH 8/8] s/rbenv/pyenv/g --- test/prefix.bats | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/prefix.bats b/test/prefix.bats index ae54b197..a1b2dcc6 100644 --- a/test/prefix.bats +++ b/test/prefix.bats @@ -38,14 +38,14 @@ OUT @test "prefix for system in /" { mkdir -p "${BATS_TEST_DIRNAME}/libexec" - cat >"${BATS_TEST_DIRNAME}/libexec/rbenv-which" <"${BATS_TEST_DIRNAME}/libexec/pyenv-which" <