termux-packages/packages/apt/0004-no-hardcoded-paths.patch

230 lines
9.3 KiB
Diff

diff -uNr apt-2.1.11/apt-pkg/aptconfiguration.cc apt-2.1.11.mod/apt-pkg/aptconfiguration.cc
--- apt-2.1.11/apt-pkg/aptconfiguration.cc 2020-10-21 12:53:18.000000000 +0300
+++ apt-2.1.11.mod/apt-pkg/aptconfiguration.cc 2020-11-05 15:33:57.243575020 +0200
@@ -35,11 +35,11 @@
// 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::zstd", "/usr/bin/zstd");
+ _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");
+ _config->CndSet("Dir::Bin::zstd", "@TERMUX_PREFIX@/bin/zstd");
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");
@@ -52,7 +52,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-2.1.11/apt-pkg/contrib/cdromutl.cc apt-2.1.11.mod/apt-pkg/contrib/cdromutl.cc
--- apt-2.1.11/apt-pkg/contrib/cdromutl.cc 2020-10-21 12:53:18.000000000 +0300
+++ apt-2.1.11.mod/apt-pkg/contrib/cdromutl.cc 2020-11-05 15:39:34.309826732 +0200
@@ -262,7 +262,7 @@
string FindMountPointForDevice(const char *devnode)
{
// this is the order that mount uses as well
- std::vector<std::string> const mounts = _config->FindVector("Dir::state::MountPoints", "/etc/mtab,/proc/mount");
+ std::vector<std::string> const mounts = _config->FindVector("Dir::state::MountPoints", "/proc/mount");
for (std::vector<std::string>::const_iterator m = mounts.begin(); m != mounts.end(); ++m)
if (FileExists(*m) == true)
diff -uNr apt-2.1.11/apt-pkg/contrib/fileutl.cc apt-2.1.11.mod/apt-pkg/contrib/fileutl.cc
--- apt-2.1.11/apt-pkg/contrib/fileutl.cc 2020-10-21 12:53:18.000000000 +0300
+++ apt-2.1.11.mod/apt-pkg/contrib/fileutl.cc 2020-11-05 15:40:49.418311615 +0200
@@ -112,7 +112,7 @@
_exit(100);
}
- if (chdir("/tmp/") != 0)
+ if (chdir("@TERMUX_PREFIX@/tmp/") != 0)
_exit(100);
unsigned int Count = 1;
@@ -3105,10 +3105,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);
}
@@ -3408,7 +3408,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-2.1.11/apt-pkg/deb/dpkgpm.cc apt-2.1.11.mod/apt-pkg/deb/dpkgpm.cc
--- apt-2.1.11/apt-pkg/deb/dpkgpm.cc 2020-10-21 12:53:18.000000000 +0300
+++ apt-2.1.11.mod/apt-pkg/deb/dpkgpm.cc 2020-11-05 15:37:39.289084595 +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;
@@ -482,7 +482,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;
@@ -2456,10 +2456,10 @@
}
// 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];
@@ -2470,11 +2470,11 @@
}
// attach df -l log (to learn about filesystem status)
- if (FileExists("/bin/df"))
+ if (FileExists("@TERMUX_PREFIX@/bin/df"))
{
fprintf(report, "Df:\n");
- FILE *log = popen("/bin/df -l -x squashfs","r");
+ FILE *log = popen("@TERMUX_PREFIX@/bin/df","r");
if(log != NULL)
{
char buf[1024];
diff -uNr apt-2.1.11/apt-pkg/init.cc apt-2.1.11.mod/apt-pkg/init.cc
--- apt-2.1.11/apt-pkg/init.cc 2020-10-21 12:53:18.000000000 +0300
+++ apt-2.1.11.mod/apt-pkg/init.cc 2020-11-05 15:33:08.863245537 +0200
@@ -210,7 +210,7 @@
Cnf.CndSet("Acquire::Changelogs::AlwaysOnline::Origin::Ubuntu", true);
- Cnf.CndSet("DPkg::Path", "/usr/sbin:/usr/bin:/sbin:/bin");
+ Cnf.CndSet("DPkg::Path", "@TERMUX_PREFIX@/bin");
// Read an alternate config file
_error->PushToStack();
diff -uNr apt-2.1.11/apt-private/private-json-hooks.cc apt-2.1.11.mod/apt-private/private-json-hooks.cc
--- apt-2.1.11/apt-private/private-json-hooks.cc 2020-10-21 12:53:18.000000000 +0300
+++ apt-2.1.11.mod/apt-private/private-json-hooks.cc 2020-11-05 15:36:12.936497984 +0200
@@ -364,7 +364,7 @@
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;
diff -uNr apt-2.1.11/cmdline/apt-dump-solver.cc apt-2.1.11.mod/cmdline/apt-dump-solver.cc
--- apt-2.1.11/cmdline/apt-dump-solver.cc 2020-10-21 12:53:18.000000000 +0300
+++ apt-2.1.11.mod/cmdline/apt-dump-solver.cc 2020-11-05 15:40:23.190141970 +0200
@@ -76,7 +76,7 @@
{
EDSP::WriteError("ERR_NO_FILENAME", "You have to set the environment variable APT_EDSP_DUMP_FILENAME\n"
"to a valid filename to store the dump of EDSP solver input in.\n"
- "For example with: export APT_EDSP_DUMP_FILENAME=/tmp/dump.edsp", stdoutfd);
+ "For example with: export APT_EDSP_DUMP_FILENAME=@TERMUX_PREFIX@/tmp/dump.edsp", stdoutfd);
return 0;
}
}
diff -uNr apt-2.1.11/cmdline/apt-key.in apt-2.1.11.mod/cmdline/apt-key.in
--- apt-2.1.11/cmdline/apt-key.in 2020-10-21 12:53:18.000000000 +0300
+++ apt-2.1.11.mod/cmdline/apt-key.in 2020-11-05 15:43:52.271502576 +0200
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!@TERMUX_PREFIX@/bin/sh
set -e
unset GREP_OPTIONS GPGHOMEDIR CURRENTTRAP
@@ -356,7 +356,7 @@
if accessible_file_exists "$TRUSTEDFILE" && is_supported_keyring "$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")"
@@ -535,7 +535,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
@@ -547,13 +547,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
@@ -653,7 +653,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
@@ -697,7 +697,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"