From 986d5fd041ce1002d2b37727f0e80db4cea34f73 Mon Sep 17 00:00:00 2001 From: Buck Evan Date: Wed, 21 Feb 2018 14:46:09 -0800 Subject: [PATCH 1/3] my older fixes for android, documented at https://docs.google.com/document/d/1FNMnPTKIrXkloFFoHtTXZl2yAgvXm4G-0hHAd0RbLVY --- Library/Homebrew/cmd/install.rb | 2 +- Library/Homebrew/development_tools.rb | 3 +++ Library/Homebrew/extend/ENV/shared.rb | 2 +- Library/Homebrew/extend/os/linux/extend/ENV/super.rb | 9 +++++++-- Library/Homebrew/os/linux/glibc.rb | 2 +- bin/brew | 3 ++- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index 5e4751969e4..c6da32053b5 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -324,7 +324,7 @@ def check_cellar def symlink_ld_so ld_so = HOMEBREW_PREFIX/"lib/ld.so" return if ld_so.readable? - sys_interpreter = ["/lib64/ld-linux-x86-64.so.2", "/lib/ld-linux.so.3", "/lib/ld-linux.so.2", "/lib/ld-linux-armhf.so.3"].find do |s| + sys_interpreter = ["/lib64/ld-linux-x86-64.so.2", "/lib/ld-linux.so.3", "/lib/ld-linux.so.2", "/lib/ld-linux-armhf.so.3", "/system/bin/linker"].find do |s| Pathname.new(s).executable? end raise "Unable to locate the system's ld.so" unless sys_interpreter diff --git a/Library/Homebrew/development_tools.rb b/Library/Homebrew/development_tools.rb index ad972a0584a..b21722c6e77 100644 --- a/Library/Homebrew/development_tools.rb +++ b/Library/Homebrew/development_tools.rb @@ -79,6 +79,9 @@ def clang_build_version if (path = locate("clang")) && build_version = `#{path} --version`[/clang-(\d{2,})/, 1] Version.new build_version + elsif (path = locate("clang")) && + build_version = `#{path} --version`[/clang version (\d\.\d\.\d)/, 1] + Version.new build_version else Version::NULL end diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb index 3e0513396cf..83a2c757d1d 100644 --- a/Library/Homebrew/extend/ENV/shared.rb +++ b/Library/Homebrew/extend/ENV/shared.rb @@ -25,7 +25,7 @@ module SharedEnvExtension MACOSX_DEPLOYMENT_TARGET SDKROOT DEVELOPER_DIR CMAKE_PREFIX_PATH CMAKE_INCLUDE_PATH CMAKE_FRAMEWORK_PATH GOBIN GOPATH GOROOT PERL_MB_OPT PERL_MM_OPT - LIBRARY_PATH LD_LIBRARY_PATH LD_PRELOAD LD_RUN_PATH + LIBRARY_PATH LD_PRELOAD LD_RUN_PATH ].freeze def inherit? diff --git a/Library/Homebrew/extend/os/linux/extend/ENV/super.rb b/Library/Homebrew/extend/os/linux/extend/ENV/super.rb index 3720f06273c..5bb3760ed3e 100644 --- a/Library/Homebrew/extend/os/linux/extend/ENV/super.rb +++ b/Library/Homebrew/extend/os/linux/extend/ENV/super.rb @@ -15,6 +15,8 @@ def xorg_recursive_deps def homebrew_extra_paths paths = [] + # IF ANDROID + paths += ["/data/data/com.termux/files/usr/bin", "/data/data/com.termux/files/usr/bin/applets"] paths += %w[binutils make].map do |f| begin @@ -39,7 +41,8 @@ def homebrew_extra_paths end def determine_extra_rpath_paths - paths = ["#{HOMEBREW_PREFIX}/lib"] + paths = ["/data/data/com.termux/files/usr/lib"] + paths += ["#{HOMEBREW_PREFIX}/lib"] paths += run_time_deps.map { |d| d.opt_lib.to_s } paths += homebrew_extra_library_paths paths @@ -47,7 +50,7 @@ def determine_extra_rpath_paths def determine_dynamic_linker_path(formula) return "" if formula&.name == "glibc" - "#{HOMEBREW_PREFIX}/lib/ld.so" + "/system/bin/linker" end # @private @@ -93,12 +96,14 @@ def homebrew_extra_isystem_paths def homebrew_extra_library_paths paths = [] + paths += ["/data/data/com.termux/files/usr/lib"] paths += xorg_lib_paths if x11? paths end def homebrew_extra_cmake_include_paths paths = [] + paths += ["/data/data/com.termux/files/usr/include"] paths += xorg_include_paths if x11? paths end diff --git a/Library/Homebrew/os/linux/glibc.rb b/Library/Homebrew/os/linux/glibc.rb index 710946bbc12..64aeb891e4b 100644 --- a/Library/Homebrew/os/linux/glibc.rb +++ b/Library/Homebrew/os/linux/glibc.rb @@ -5,7 +5,7 @@ module Glibc def system_version return @system_version if @system_version - version = Utils.popen_read("/usr/bin/ldd", "--version")[/ (\d+\.\d+)/, 1] + version = Utils.popen_read("/usr/bin/objdump", "--version")[/ (\d+\.\d+)/, 1] return Version::NULL unless version @system_version = Version.new version end diff --git a/bin/brew b/bin/brew index 791182c43a7..835a0892825 100755 --- a/bin/brew +++ b/bin/brew @@ -66,11 +66,12 @@ done # test-bot does environment filtering itself if [[ -z "$HOMEBREW_NO_ENV_FILTERING" && "$1" != "test-bot" ]] then - PATH="/usr/bin:/bin:/usr/sbin:/sbin" + PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/bin/applets" FILTERED_ENV=() # Filter all but the specific variables. for VAR in HOME SHELL PATH TERM LOGNAME USER CI CIRCLECI TRAVIS SSH_AUTH_SOCK SUDO_ASKPASS \ + LD_LIBRARY_PATH ANDROID_ROOT ANDROID_DATA \ http_proxy https_proxy ftp_proxy no_proxy all_proxy HTTPS_PROXY FTP_PROXY ALL_PROXY \ "${!HOMEBREW_@}" "${!TRAVIS_@}" "${!JENKINS_@}" do From eede2be9e66e703223ec68a0d94199266a2c2499 Mon Sep 17 00:00:00 2001 From: Buck Evan Date: Wed, 21 Feb 2018 14:48:30 -0800 Subject: [PATCH 2/3] toying with gettings things working without termux-chroot --- Library/Homebrew/brew.sh | 2 +- Library/Homebrew/config.rb | 3 ++- Library/Homebrew/development_tools.rb | 3 +++ Library/Homebrew/shims/scm/git | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 9c128bd4408..f9f6c72101d 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -32,7 +32,7 @@ onoe() { fi if [[ $# -eq 0 ]] then - /bin/cat >&2 + cat >&2 else echo "$*" >&2 fi diff --git a/Library/Homebrew/config.rb b/Library/Homebrew/config.rb index 0b36c5c5395..0dadb588730 100644 --- a/Library/Homebrew/config.rb +++ b/Library/Homebrew/config.rb @@ -42,7 +42,8 @@ (OS.mac? ? "~/Library/Logs/Homebrew/" : "~/.cache/Homebrew/Logs")).expand_path # Must use /tmp instead of $TMPDIR because long paths break Unix domain sockets -HOMEBREW_TEMP = Pathname.new(ENV.fetch("HOMEBREW_TEMP", "/tmp")) +# IF ANDROID +HOMEBREW_TEMP = Pathname.new(ENV.fetch("HOMEBREW_TEMP", "/data/data/com.termux/files/usr/tmp")) unless defined? HOMEBREW_LIBRARY_PATH # Root of the Homebrew code base diff --git a/Library/Homebrew/development_tools.rb b/Library/Homebrew/development_tools.rb index b21722c6e77..689139dfc51 100644 --- a/Library/Homebrew/development_tools.rb +++ b/Library/Homebrew/development_tools.rb @@ -10,6 +10,9 @@ def locate(tool) path elsif File.executable?(path = "/usr/bin/#{tool}") Pathname.new path + # IF ANDROID + elsif File.executable?(path = "/data/data/com.termux/files/usr/bin/#{tool}") + Pathname.new path # Homebrew GCCs most frequently; much faster to check this before xcrun elsif (path = HOMEBREW_PREFIX/"bin/#{tool}").executable? path diff --git a/Library/Homebrew/shims/scm/git b/Library/Homebrew/shims/scm/git index f826e1b608e..2b8df16b186 100755 --- a/Library/Homebrew/shims/scm/git +++ b/Library/Homebrew/shims/scm/git @@ -99,7 +99,7 @@ brew_repo_version="$(quiet_safe_cd "$SCM_DIR/../../../../bin" && pwd -P)/$SCM_FI safe_exec "$brew_repo_version" "$@" IFS=$'\n' -for path in $(/usr/bin/which -a "$SCM_FILE" 2>/dev/null) +for path in $(command -v "$SCM_FILE" 2>/dev/null) do if [[ "$path" != "/usr/bin/$SCM_FILE" ]] then From 15b7225a0fbd20a50874f1d1830190a418b55517 Mon Sep 17 00:00:00 2001 From: Buck Evan Date: Wed, 21 Feb 2018 15:20:48 -0800 Subject: [PATCH 3/3] enable-new-dtags, for Android linker --- Library/Homebrew/shims/linux/super/cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/shims/linux/super/cc b/Library/Homebrew/shims/linux/super/cc index 52786b9379e..9918e31e0cf 100755 --- a/Library/Homebrew/shims/linux/super/cc +++ b/Library/Homebrew/shims/linux/super/cc @@ -192,7 +192,10 @@ class Cmd # -R is not the correct way to pass rpaths to the linker path = chuzzle($1) || enum.next wl = "-Wl," unless mode == :ld - args << "#{wl}-rpath=" if keep?(path) + if keep?(path) + args << "#{wl}--enable-new-dtags" + args << "#{wl}-rpath=" + end else args << arg end @@ -255,6 +258,7 @@ class Cmd args += ["#{wl}--dynamic-linker=#{dynamic_linker_path}"] if dynamic_linker_path args << "-B#{@opt}/glibc/lib" unless mode == :ld args += path_flags("-L", library_paths) + args << "#{wl}--enable-new-dtags" args += rpath_flags("#{wl}-rpath=", rpath_paths) end