diff -uNr ruby-3.0.0/addr2line.c ruby-3.0.0.mod/addr2line.c --- ruby-3.0.0/addr2line.c 2020-12-25 05:33:01.000000000 +0200 +++ ruby-3.0.0.mod/addr2line.c 2021-02-09 17:44:23.586601868 +0200 @@ -545,7 +545,7 @@ follow_debuglink(const char *debuglink, int num_traces, void **traces, obj_info_t **objp, line_info_t *lines, int offset) { - static const char global_debug_dir[] = "/usr/lib/debug"; + static const char global_debug_dir[] = "@TERMUX_PREFIX@/lib/debug"; const size_t global_debug_dir_len = sizeof(global_debug_dir) - 1; char *p; obj_info_t *o1 = *objp, *o2; @@ -577,7 +577,7 @@ follow_debuglink_build_id(const char *build_id, size_t build_id_size, int num_traces, void **traces, obj_info_t **objp, line_info_t *lines, int offset) { - static const char global_debug_dir[] = "/usr/lib/debug/.build-id/"; + static const char global_debug_dir[] = "@TERMUX_PREFIX@/lib/debug/.build-id/"; const size_t global_debug_dir_len = sizeof(global_debug_dir) - 1; char *p; obj_info_t *o1 = *objp, *o2; diff -uNr ruby-3.0.0/dln_find.c ruby-3.0.0.mod/dln_find.c --- ruby-3.0.0/dln_find.c 2020-12-25 05:33:01.000000000 +0200 +++ ruby-3.0.0.mod/dln_find.c 2021-02-09 17:35:46.039359196 +0200 @@ -72,10 +72,7 @@ if (!path) { path = - "/usr/local/bin" PATH_SEP - "/usr/ucb" PATH_SEP - "/usr/bin" PATH_SEP - "/bin" PATH_SEP + "@TERMUX_PREFIX@/bin" PATH_SEP "."; } buf = dln_find_1(fname, path, buf, size, 1 DLN_FIND_EXTRA_ARG); diff -uNr ruby-3.0.0/ext/etc/etc.c ruby-3.0.0.mod/ext/etc/etc.c --- ruby-3.0.0/ext/etc/etc.c 2020-12-25 05:33:01.000000000 +0200 +++ ruby-3.0.0.mod/ext/etc/etc.c 2021-02-09 17:41:07.618382244 +0200 @@ -672,7 +672,7 @@ if (!len) return Qnil; tmpdir = rb_w32_conv_from_wchar(path, rb_filesystem_encoding()); #else - const char default_tmp[] = "/tmp"; + const char default_tmp[] = "@TERMUX_PREFIX@/tmp"; const char *tmpstr = default_tmp; size_t tmplen = strlen(default_tmp); # if defined _CS_DARWIN_USER_TEMP_DIR diff -uNr ruby-3.0.0/ext/pty/pty.c ruby-3.0.0.mod/ext/pty/pty.c --- ruby-3.0.0/ext/pty/pty.c 2020-12-25 05:33:01.000000000 +0200 +++ ruby-3.0.0.mod/ext/pty/pty.c 2021-02-09 17:45:16.473977053 +0200 @@ -176,7 +176,7 @@ char errbuf[32]; if (argc == 0) { - const char *shellname = "/bin/sh"; + const char *shellname = "@TERMUX_PREFIX@/bin/sh"; if ((p = getenv("SHELL")) != NULL) { shellname = p; diff -uNr ruby-3.0.0/hash.c ruby-3.0.0.mod/hash.c --- ruby-3.0.0/hash.c 2020-12-25 05:33:01.000000000 +0200 +++ ruby-3.0.0.mod/hash.c 2021-02-09 17:43:01.683876134 +0200 @@ -717,11 +717,11 @@ else { #if 0 static int pid; - static char fname[256]; + static char fname[sizeof("@TERMUX_PREFIX@/tmp")+256]; static FILE *fp; if (pid != getpid()) { - snprintf(fname, sizeof(fname), "/tmp/ruby-armiss.%d", pid = getpid()); + snprintf(fname, sizeof(fname), "@TERMUX_PREFIX@/tmp/ruby-armiss.%d", pid = getpid()); if ((fp = fopen(fname, "w")) == NULL) rb_bug("fopen"); } diff -uNr ruby-3.0.0/lib/mkmf.rb ruby-3.0.0.mod/lib/mkmf.rb --- ruby-3.0.0/lib/mkmf.rb 2020-12-25 05:33:01.000000000 +0200 +++ ruby-3.0.0.mod/lib/mkmf.rb 2021-02-09 17:35:46.039359196 +0200 @@ -1580,7 +1580,7 @@ if path ||= ENV['PATH'] path = path.split(File::PATH_SEPARATOR) else - path = %w[/usr/local/bin /usr/ucb /usr/bin /bin] + path = "@TERMUX_PREFIX@/bin" end file = nil path.each do |dir| diff -uNr ruby-3.0.0/lib/resolv.rb ruby-3.0.0.mod/lib/resolv.rb --- ruby-3.0.0/lib/resolv.rb 2020-12-25 05:33:01.000000000 +0200 +++ ruby-3.0.0.mod/lib/resolv.rb 2021-02-09 17:35:46.043359300 +0200 @@ -173,7 +173,7 @@ rescue LoadError end end - DefaultFileName ||= '/etc/hosts' + DefaultFileName ||= '@TERMUX_PREFIX@/etc/hosts' ## # Creates a new Resolv::Hosts, using +filename+ for its data source. @@ -985,7 +985,7 @@ return { :nameserver => nameserver, :search => search, :ndots => ndots } end - def Config.default_config_hash(filename="/etc/resolv.conf") + def Config.default_config_hash(filename="@TERMUX_PREFIX@/etc/resolv.conf") if File.exist? filename config_hash = Config.parse_resolv_conf(filename) else diff -uNr ruby-3.0.0/process.c ruby-3.0.0.mod/process.c --- ruby-3.0.0/process.c 2020-12-25 05:33:01.000000000 +0200 +++ ruby-3.0.0.mod/process.c 2021-02-09 17:49:30.716668413 +0200 @@ -1810,9 +1810,9 @@ *argv = (char *)prog; *--argv = (char *)"sh"; if (envp) - execve("/bin/sh", argv, envp); /* async-signal-safe */ + execve("@TERMUX_PREFIX@/bin/sh", argv, envp); /* async-signal-safe */ else - execv("/bin/sh", argv); /* async-signal-safe (since SUSv4) */ + execv("@TERMUX_PREFIX@/bin/sh", argv); /* async-signal-safe (since SUSv4) */ } #else @@ -1880,9 +1880,9 @@ } #else if (envp_str) - execle("/bin/sh", "sh", "-c", str, (char *)NULL, RB_IMEMO_TMPBUF_PTR(envp_str)); /* async-signal-safe */ + execle("@TERMUX_PREFIX@/bin/sh", "sh", "-c", str, (char *)NULL, RB_IMEMO_TMPBUF_PTR(envp_str)); /* async-signal-safe */ else - execl("/bin/sh", "sh", "-c", str, (char *)NULL); /* async-signal-safe (since SUSv4) */ + execl("@TERMUX_PREFIX@/bin/sh", "sh", "-c", str, (char *)NULL); /* async-signal-safe (since SUSv4) */ #endif /* _WIN32 */ return errno; } diff -uNr ruby-3.1.0/ruby.c ruby-3.1.0.mod/ruby.c --- ruby-3.1.0/ruby.c +++ ruby-3.1.0.mod/ruby.c @@ -684,7 +684,7 @@ RUBY_ARCH_PATH; const ptrdiff_t libdir_len = (ptrdiff_t)sizeof(libdir) - rb_strlen_lit(RUBY_ARCH_PATH) - 1; - static const char bindir[] = "/bin"; + static const char bindir[] = "@TERMUX_PREFIX@/bin"; const ptrdiff_t bindir_len = (ptrdiff_t)sizeof(bindir) - 1; const char *p2 = NULL; diff -uNr ruby-3.0.0/spec/ruby/core/dir/shared/pwd.rb ruby-3.0.0.mod/spec/ruby/core/dir/shared/pwd.rb --- ruby-3.0.0/spec/ruby/core/dir/shared/pwd.rb 2020-12-25 05:33:01.000000000 +0200 +++ ruby-3.0.0.mod/spec/ruby/core/dir/shared/pwd.rb 2021-02-09 17:50:07.720664849 +0200 @@ -14,7 +14,7 @@ # The following uses inode rather than file names to account for # case insensitive file systems like default OS/X file systems platform_is_not :windows do - File.stat(pwd).ino.should == File.stat(`/bin/sh -c "pwd -P"`.chomp).ino + File.stat(pwd).ino.should == File.stat(`@TERMUX_PREFIX@/bin/sh -c "pwd -P"`.chomp).ino end platform_is :windows do File.stat(pwd).ino.should == File.stat(File.expand_path(`cd`.chomp)).ino diff -uNr ruby-3.0.0/spec/ruby/core/process/spawn_spec.rb ruby-3.0.0.mod/spec/ruby/core/process/spawn_spec.rb --- ruby-3.0.0/spec/ruby/core/process/spawn_spec.rb 2020-12-25 05:33:01.000000000 +0200 +++ ruby-3.0.0.mod/spec/ruby/core/process/spawn_spec.rb 2021-02-09 17:50:41.692695143 +0200 @@ -133,7 +133,7 @@ describe "with a command array" do it "uses the first element as the command name and the second as the argv[0] value" do platform_is_not :windows do - -> { Process.wait Process.spawn(["/bin/sh", "argv_zero"], "-c", "echo $0") }.should output_to_fd("argv_zero\n") + -> { Process.wait Process.spawn(["@TERMUX_PREFIX@/bin/sh", "argv_zero"], "-c", "echo $0") }.should output_to_fd("argv_zero\n") end platform_is :windows do -> { Process.wait Process.spawn(["cmd.exe", "/C"], "/C", "echo", "argv_zero") }.should output_to_fd("argv_zero\n") @@ -156,7 +156,7 @@ it "calls #to_ary to convert the argument to an Array" do o = mock("to_ary") platform_is_not :windows do - o.should_receive(:to_ary).and_return(["/bin/sh", "argv_zero"]) + o.should_receive(:to_ary).and_return(["@TERMUX_PREFIX@/bin/sh", "argv_zero"]) -> { Process.wait Process.spawn(o, "-c", "echo $0") }.should output_to_fd("argv_zero\n") end platform_is :windows do diff -uNr ruby-3.0.0/st.c ruby-3.0.0.mod/st.c --- ruby-3.0.0/st.c 2020-12-25 05:33:01.000000000 +0200 +++ ruby-3.0.0.mod/st.c 2021-02-09 17:39:08.594113373 +0200 @@ -496,10 +496,10 @@ static void stat_col(void) { - char fname[10+sizeof(long)*3]; + char fname[sizeof("@TERMUX_PREFIX@/tmp/col")+sizeof(long)*3]; FILE *f; if (!collision.total) return; - f = fopen((snprintf(fname, sizeof(fname), "/tmp/col%ld", (long)getpid()), fname), "w"); + f = fopen((snprintf(fname, sizeof(fname), "@TERMUX_PREFIX@/tmp/col%ld", (long)getpid()), fname), "w"); if (f == NULL) return; fprintf(f, "collision: %d / %d (%6.2f)\n", collision.all, collision.total,