Skip to content

Commit

Permalink
Hardcode the Ruby version in the y2start script (bsc#1068863)
Browse files Browse the repository at this point in the history
to always use the Ruby version used at the build time

- 4.0.1
  • Loading branch information
lslezak committed Nov 23, 2017
1 parent c855363 commit 8f0a4e8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
8 changes: 6 additions & 2 deletions cmake/modules/FindRuby.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if(RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
set(RUBY_FIND_QUIETLY TRUE)
endif (RUBY_LIBRARY AND RUBY_INCLUDE_PATH)

FIND_PROGRAM(RUBY_EXECUTABLE NAMES ruby ruby1.9 ruby19 ruby1.9.1 ruby2.1)
FIND_PROGRAM(RUBY_EXECUTABLE NAMES ruby ruby2.4 ruby.ruby2.4 ruy2.5 ruby.ruby2.5)

EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['archdir']"
OUTPUT_VARIABLE RUBY_ARCH_DIR)
Expand Down Expand Up @@ -46,6 +46,10 @@ EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFI
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['arch']"
OUTPUT_VARIABLE RUBY_ARCH)

# RUBY_BIN_PATH contains the full path including the version suffix,
# e.g. /usr/bin/ruby.ruby2.4
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig.ruby"
OUTPUT_VARIABLE RUBY_BIN_PATH)

FIND_PATH(RUBY_INCLUDE_PATH
NAMES ruby.h
Expand All @@ -54,7 +58,7 @@ FIND_PATH(RUBY_INCLUDE_PATH
)

FIND_LIBRARY(RUBY_LIBRARY
NAMES ruby ruby1.9 ruby-1.9.1 ruby2.1 ruby-2.1
NAMES ruby ruby2.4 ruby2.5
PATHS ${RUBY_POSSIBLE_LIB_PATH}
)

Expand Down
7 changes: 7 additions & 0 deletions package/yast2-ruby-bindings.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Nov 23 09:45:04 UTC 2017 - lslezak@suse.cz

- Hardcode the Ruby version in the y2start script to always use
the Ruby version used at the build time (bsc#1068863)
- 4.0.1

-------------------------------------------------------------------
Tue Sep 26 13:20:14 UTC 2017 - jreidinger@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-ruby-bindings.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-ruby-bindings
Version: 4.0.0
Version: 4.0.1
Url: https://github.com/yast/yast-ruby-bindings
Release: 0
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
8 changes: 6 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
add_subdirectory(ruby)
add_subdirectory(binary)



install(PROGRAMS y2start/y2start DESTINATION lib/YaST2/bin)

# hardcode the ruby version in the y2start script (bsc#1068863)
install(CODE "MESSAGE(\"Updating $ENV{DESTDIR}/${CMAKE_INSTALL_PREFIX}/lib/YaST2/bin/y2start hashbang:\")")
# replace the first line in y2start with a new hashbang
install(CODE "execute_process(COMMAND sed -i \"1 s@^.*$@\\#! ${RUBY_BIN_PATH}@\" $ENV{DESTDIR}/${CMAKE_INSTALL_PREFIX}/lib/YaST2/bin/y2start)")
install(CODE "execute_process(COMMAND head -n1 $ENV{DESTDIR}/${CMAKE_INSTALL_PREFIX}/lib/YaST2/bin/y2start)")
2 changes: 2 additions & 0 deletions src/y2start/y2start
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#! /usr/bin/ruby
# Note: The ruby interpreter path above is replaced at the installation
# to use a hardcoded versioned path.

# set env as first part, otherwise dummy UI will be created.
# for insts-sys it will be overwritten later
Expand Down

0 comments on commit 8f0a4e8

Please sign in to comment.