diff -uNr apt-1.4.9/apt-pkg/aptconfiguration.cc apt-1.4.9.mod/apt-pkg/aptconfiguration.cc --- apt-1.4.9/apt-pkg/aptconfiguration.cc 2019-01-18 12:42:07.000000000 +0200 +++ apt-1.4.9.mod/apt-pkg/aptconfiguration.cc 2019-11-12 22:10:28.531994919 +0200 @@ -35,10 +35,10 @@ // setDefaultConfigurationForCompressors /*{{{*/ static void setDefaultConfigurationForCompressors() { // Set default application paths to check for optional compression types - _config->CndSet("Dir::Bin::gzip", "/bin/gzip"); - _config->CndSet("Dir::Bin::bzip2", "/bin/bzip2"); - _config->CndSet("Dir::Bin::xz", "/usr/bin/xz"); - _config->CndSet("Dir::Bin::lz4", "/usr/bin/lz4"); + _config->CndSet("Dir::Bin::gzip", "@TERMUX_PREFIX@/bin/gzip"); + _config->CndSet("Dir::Bin::bzip2", "@TERMUX_PREFIX@/bin/bzip2"); + _config->CndSet("Dir::Bin::xz", "@TERMUX_PREFIX@/bin/xz"); + _config->CndSet("Dir::Bin::lz4", "@TERMUX_PREFIX@/bin/lz4"); if (FileExists(_config->Find("Dir::Bin::xz")) == true) { _config->Set("Dir::Bin::lzma", _config->Find("Dir::Bin::xz")); _config->Set("APT::Compressor::lzma::Binary", "xz"); @@ -51,7 +51,7 @@ _config->Set("APT::Compressor::lzma::UncompressArg::", "-d"); } } else { - _config->CndSet("Dir::Bin::lzma", "/usr/bin/lzma"); + _config->CndSet("Dir::Bin::lzma", "@TERMUX_PREFIX@/bin/lzma"); if (_config->Exists("APT::Compressor::lzma::CompressArg") == false) { _config->Set("APT::Compressor::lzma::CompressArg::", "--suffix="); _config->Set("APT::Compressor::lzma::CompressArg::", "-6"); diff -uNr apt-1.4.9/apt-pkg/contrib/cdromutl.cc apt-1.4.9.mod/apt-pkg/contrib/cdromutl.cc --- apt-1.4.9/apt-pkg/contrib/cdromutl.cc 2019-01-18 12:42:07.000000000 +0200 +++ apt-1.4.9.mod/apt-pkg/contrib/cdromutl.cc 2019-11-12 22:10:38.788703372 +0200 @@ -268,7 +268,7 @@ string FindMountPointForDevice(const char *devnode) { // this is the order that mount uses as well - std::vector const mounts = _config->FindVector("Dir::state::MountPoints", "/etc/mtab,/proc/mount"); + std::vector const mounts = _config->FindVector("Dir::state::MountPoints", "@TERMUX_PREFIX@/etc/mtab,/proc/mount"); for (std::vector::const_iterator m = mounts.begin(); m != mounts.end(); ++m) if (FileExists(*m) == true) diff -uNr apt-1.4.9/apt-pkg/contrib/fileutl.cc apt-1.4.9.mod/apt-pkg/contrib/fileutl.cc --- apt-1.4.9/apt-pkg/contrib/fileutl.cc 2019-01-18 12:42:07.000000000 +0200 +++ apt-1.4.9.mod/apt-pkg/contrib/fileutl.cc 2019-11-12 22:12:25.625803839 +0200 @@ -106,7 +106,7 @@ _exit(100); } - if (chdir("/tmp/") != 0) + if (chdir("@TERMUX_PREFIX@/tmp/") != 0) _exit(100); unsigned int Count = 1; @@ -2790,10 +2790,10 @@ struct stat st; if (!tmpdir || strlen(tmpdir) == 0 || // tmpdir is set stat(tmpdir, &st) != 0 || (st.st_mode & S_IFDIR) == 0) // exists and is directory - tmpdir = "/tmp"; + tmpdir = "@TERMUX_PREFIX@/tmp"; else if (geteuid() != 0 && // root can do everything anyway faccessat(AT_FDCWD, tmpdir, R_OK | W_OK | X_OK, AT_EACCESS) != 0) // current user has rwx access to directory - tmpdir = "/tmp"; + tmpdir = "@TERMUX_PREFIX@/tmp"; return string(tmpdir); } @@ -3064,7 +3064,7 @@ setenv("LOGNAME", pw->pw_name, 1); auto const shell = flNotDir(pw->pw_shell); if (shell == "false" || shell == "nologin") - setenv("SHELL", "/bin/sh", 1); + setenv("SHELL", "@TERMUX_PREFIX@/bin/sh", 1); else setenv("SHELL", pw->pw_shell, 1); auto const apt_setenv_tmp = [](char const * const env) { diff -uNr apt-1.4.9/apt-pkg/deb/dpkgpm.cc apt-1.4.9.mod/apt-pkg/deb/dpkgpm.cc --- apt-1.4.9/apt-pkg/deb/dpkgpm.cc 2019-01-18 12:42:07.000000000 +0200 +++ apt-1.4.9.mod/apt-pkg/deb/dpkgpm.cc 2019-11-12 22:18:36.777295457 +0200 @@ -179,7 +179,7 @@ so we use the binary from util-linux */ static bool ionice(int PID) { - if (!FileExists("/usr/bin/ionice")) + if (!FileExists("@TERMUX_PREFIX@/bin/ionice")) return false; pid_t Process = ExecFork(); if (Process == 0) @@ -187,7 +187,7 @@ char buf[32]; snprintf(buf, sizeof(buf), "-p%d", PID); const char *Args[4]; - Args[0] = "/usr/bin/ionice"; + Args[0] = "@TERMUX_PREFIX@/bin/ionice"; Args[1] = "-c3"; Args[2] = buf; Args[3] = 0; @@ -483,7 +483,7 @@ debSystem::DpkgChrootDirectory(); const char *Args[4]; - Args[0] = "/bin/sh"; + Args[0] = "@TERMUX_PREFIX@/bin/sh"; Args[1] = "-c"; Args[2] = Opts->Value.c_str(); Args[3] = 0; @@ -2403,11 +2403,13 @@ fprintf(report, " %s: %s\n", pkgname.c_str(), opstr); } +// Android doesn't allow to use dmesg without root. +#ifndef __ANDROID__ // attach dmesg log (to learn about segfaults) - if (FileExists("/bin/dmesg")) + if (FileExists("@TERMUX_PREFIX@/bin/dmesg")) { fprintf(report, "Dmesg:\n"); - FILE *log = popen("/bin/dmesg","r"); + FILE *log = popen("@TERMUX_PREFIX@/bin/dmesg","r"); if(log != NULL) { char buf[1024]; @@ -2416,13 +2418,13 @@ pclose(log); } } +#endif - // attach df -l log (to learn about filesystem status) - if (FileExists("/bin/df")) + // attach df log (to learn about filesystem status) + if (FileExists("@TERMUX_PREFIX@/bin/df")) { - fprintf(report, "Df:\n"); - FILE *log = popen("/bin/df -l","r"); + FILE *log = popen("@TERMUX_PREFIX@/bin/df","r"); if(log != NULL) { char buf[1024]; diff -uNr apt-1.4.9/cmdline/apt-key.in apt-1.4.9.mod/cmdline/apt-key.in --- apt-1.4.9/cmdline/apt-key.in 2019-01-18 12:42:07.000000000 +0200 +++ apt-1.4.9.mod/cmdline/apt-key.in 2019-11-12 22:27:00.015963736 +0200 @@ -260,7 +260,7 @@ if accessible_file_exists "$TRUSTEDFILE"; then $ACTION "$TRUSTEDFILE" "$@" fi - local TRUSTEDPARTS="/etc/apt/trusted.gpg.d" + local TRUSTEDPARTS="@TERMUX_PREFIX@/etc/apt/trusted.gpg.d" eval "$(apt-config shell TRUSTEDPARTS Dir::Etc::TrustedParts/d)" if [ -d "$TRUSTEDPARTS" ]; then TRUSTEDPARTS="$(readlink -f "$TRUSTEDPARTS")" @@ -439,7 +439,7 @@ merge_all_trusted_keyrings_into_pubring FORCED_KEYRING="${GPGHOMEDIR}/forcedkeyid.gpg" TRUSTEDFILE="${FORCED_KEYRING}" - echo "#!/bin/sh + echo "#!@TERMUX_PREFIX@/bin/sh exec sh '($(escape_shell "${GPG}")' --keyring '$(escape_shell "${TRUSTEDFILE}")' \"\$@\"" > "${GPGHOMEDIR}/gpg.1.sh" GPG="${GPGHOMEDIR}/gpg.1.sh" # ignore error as this "just" means we haven't found the forced keyid and the keyring will be empty @@ -451,13 +451,13 @@ else touch "${GPGHOMEDIR}/pubring.gpg" "${GPGHOMEDIR}/pubring.orig.gpg" fi - echo "#!/bin/sh + echo "#!@TERMUX_PREFIX@/bin/sh exec sh '$(escape_shell "${GPG}")' --keyring '$(escape_shell "${GPGHOMEDIR}/pubring.gpg")' \"\$@\"" > "${GPGHOMEDIR}/gpg.1.sh" GPG="${GPGHOMEDIR}/gpg.1.sh" else TRUSTEDFILE="$(dearmor_filename "$FORCED_KEYRING")" create_new_keyring "$TRUSTEDFILE" - echo "#!/bin/sh + echo "#!@TERMUX_PREFIX@/bin/sh exec sh '$(escape_shell "${GPG}")' --keyring '$(escape_shell "${TRUSTEDFILE}")' \"\$@\"" > "${GPGHOMEDIR}/gpg.1.sh" GPG="${GPGHOMEDIR}/gpg.1.sh" fi @@ -542,7 +542,7 @@ done if [ -z "$TRUSTEDFILE" ]; then - TRUSTEDFILE="/etc/apt/trusted.gpg" + TRUSTEDFILE="@TERMUX_PREFIX@/etc/apt/trusted.gpg" eval $(apt-config shell TRUSTEDFILE Apt::GPGV::TrustedKeyring) eval $(apt-config shell TRUSTEDFILE Dir::Etc::Trusted/f) fi @@ -612,7 +612,7 @@ unset TMPDIR fi fi - GPGHOMEDIR="$(mktemp --directory --tmpdir 'apt-key-gpghome.XXXXXXXXXX')" + GPGHOMEDIR="$(mktemp -d -t 'apt-key-gpghome.XXXXXXXXXX')" CURRENTTRAP="${CURRENTTRAP} cleanup_gpg_home;" trap "${CURRENTTRAP}" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM if [ -z "$GPGHOMEDIR" ]; then @@ -654,7 +654,7 @@ create_gpg_home # now tell gpg that it shouldn't try to maintain this trustdb file - echo "#!/bin/sh + echo "#!@TERMUX_PREFIX@/bin/sh exec '$(escape_shell "${GPG_EXE}")' --ignore-time-conflict --no-options --no-default-keyring \\ --homedir '$(escape_shell "${GPGHOMEDIR}")' --no-auto-check-trustdb --trust-model always \"\$@\"" > "${GPGHOMEDIR}/gpg.0.sh" GPG_SH="${GPGHOMEDIR}/gpg.0.sh"