diff --git a/debian_specs/passenger/passenger_free_ruby.c b/debian_specs/passenger/passenger_free_ruby.c index aba70df..fd20a9a 100644 --- a/debian_specs/passenger/passenger_free_ruby.c +++ b/debian_specs/passenger/passenger_free_ruby.c @@ -15,22 +15,15 @@ int main(int argc, const char *argv[]) { try_exec("ruby", argc, argv); - try_exec("/usr/bin/ruby3.4", argc, argv); - try_exec("/usr/bin/ruby3.3", argc, argv); - try_exec("/usr/bin/ruby3.2", argc, argv); - try_exec("/usr/bin/ruby3.1", argc, argv); - try_exec("/usr/bin/ruby3.0", argc, argv); - try_exec("/usr/bin/ruby2.7", argc, argv); - try_exec("/usr/bin/ruby2.6", argc, argv); - try_exec("/usr/bin/ruby2.5", argc, argv); - try_exec("/usr/bin/ruby2.4", argc, argv); - try_exec("/usr/bin/ruby2.3", argc, argv); - try_exec("/usr/bin/ruby2.2", argc, argv); - try_exec("/usr/bin/ruby2.1", argc, argv); - try_exec("/usr/bin/ruby2.0", argc, argv); + char* exe = "/usr/bin/rubyX.XX"; + for(int m = 4; m > 0; m--) { + for(int n = 10; n > -1; n--) { + snprintf(exe, 18, "/usr/bin/ruby%i.%i", m, n); + try_exec(exe, argc, argv); + } + } try_exec("/usr/bin/ruby1.9.1", argc, argv); - try_exec("/usr/bin/ruby1.8", argc, argv); - fprintf(stderr, "passenger_free_ruby: cannot find suitable Ruby interpreter\n"); + fprintf(stderr, PROGRAM_NAME ": cannot find suitable Ruby interpreter\n"); return 1; } diff --git a/debian_specs/passenger/passenger_system_ruby.c.erb b/debian_specs/passenger/passenger_system_ruby.c.erb index 26c7133..b8f70d2 100644 --- a/debian_specs/passenger/passenger_system_ruby.c.erb +++ b/debian_specs/passenger/passenger_system_ruby.c.erb @@ -1,9 +1,7 @@ <% require File.dirname(File.absolute_path(__FILE__)) + '/helpers' all_ruby_versions_to_try = distro_ruby_versions.reverse + - ['3.4', '3.3', '3.2', '3.1', '3.0', - '2.7', '2.6', '2.5', '2.4', '2.3', - '2.2', '2.1', '2.0', '1.9.1', '1.8'] + (1..4).to_a.product((0..10).to_a).map{|x,y|"#{x}.#{y}"}.reverse.push('1.9.1') all_ruby_versions_to_try.uniq! -%> /* @@ -27,8 +25,27 @@ all_ruby_versions_to_try.uniq! #define PROGRAM_NAME "passenger_system_ruby" #include "passenger_ruby_utils.c" +static void +try_unset(const char* s){ + if (0 != unsetenv(s)) { + int e = errno; + fprintf(stderr, PROGRAM_NAME ": cannot unset '%s': %s\n",s, strerror(e)); + exit(1); + } +} + +static void +reset_env() { + try_unset("GEM_HOME"); + try_unset("GEM_PATH"); + try_unset("RUBYOPT"); + try_unset("RUBYPATH"); + try_unset("RUBYLIB"); +} + int main(int argc, const char *argv[]) { + reset_env(); <% for ruby_version in all_ruby_versions_to_try.reverse -%> try_exec("/usr/bin/ruby<%= ruby_version %>", argc, argv); <% end -%>