Browse Source

apt: fix hardcoded paths

android-5
Leonid Plyushch 7 years ago
committed by Fredrik Fornwall
parent
commit
24cdcc7829
  1. 27
      packages/apt/apt-pkg-aptconfiguration.cc.patch
  2. 12
      packages/apt/apt-pkg-contrib-cdromutl.cc.patch
  3. 24
      packages/apt/apt-pkg-contrib-fileutl.cc.patch
  4. 76
      packages/apt/apt-pkg-deb-dpkgpm.cc.patch
  5. 2
      packages/apt/build.sh
  6. 40
      packages/apt/cmdline-apt-key.in.patch
  7. 12
      packages/apt/methods-rsh.cc.patch

27
packages/apt/apt-pkg-aptconfiguration.cc.patch

@ -0,0 +1,27 @@
diff -uNr apt-1.4.8/apt-pkg/aptconfiguration.cc apt-1.4.8.mod/apt-pkg/aptconfiguration.cc
--- apt-1.4.8/apt-pkg/aptconfiguration.cc 2017-09-13 19:47:33.000000000 +0300
+++ apt-1.4.8.mod/apt-pkg/aptconfiguration.cc 2018-06-19 13:51:30.203757806 +0300
@@ -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");

12
packages/apt/apt-pkg-contrib-cdromutl.cc.patch

@ -0,0 +1,12 @@
diff -uNr apt-1.4.8/apt-pkg/contrib/cdromutl.cc apt-1.4.8.mod/apt-pkg/contrib/cdromutl.cc
--- apt-1.4.8/apt-pkg/contrib/cdromutl.cc 2017-09-13 19:47:33.000000000 +0300
+++ apt-1.4.8.mod/apt-pkg/contrib/cdromutl.cc 2018-06-19 13:55:06.720435620 +0300
@@ -268,7 +268,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", "@TERMUX_PREFIX@/etc/mtab,/proc/mount");
for (std::vector<std::string>::const_iterator m = mounts.begin(); m != mounts.end(); ++m)
if (FileExists(*m) == true)

24
packages/apt/apt-pkg-contrib-fileutl.cc.patch

@ -0,0 +1,24 @@
diff -uNr apt-1.4.8/apt-pkg/contrib/fileutl.cc apt-1.4.8.mod/apt-pkg/contrib/fileutl.cc
--- apt-1.4.8/apt-pkg/contrib/fileutl.cc 2018-06-19 13:55:47.313771042 +0300
+++ apt-1.4.8.mod/apt-pkg/contrib/fileutl.cc 2018-06-19 13:41:41.387060822 +0300
@@ -3068,7 +3068,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.8/apt-pkg/contrib/fileutl.cc apt-1.4.8.mod/apt-pkg/contrib/fileutl.cc
--- apt-1.4.8/apt-pkg/contrib/fileutl.cc 2018-06-19 16:51:22.570980141 +0300
+++ apt-1.4.8.mod/apt-pkg/contrib/fileutl.cc 2018-06-19 16:52:20.507649790 +0300
@@ -108,7 +108,7 @@
_exit(100);
}
- if (chdir("/tmp/") != 0)
+ if (chdir("@TERMUX_PREFIX@/tmp/") != 0)
_exit(100);
unsigned int Count = 1;

76
packages/apt/apt-pkg-deb-dpkgpm.cc.patch

@ -29,3 +29,79 @@ diff -u -r ../apt-1.4.8/apt-pkg/deb/dpkgpm.cc ./apt-pkg/deb/dpkgpm.cc
close(d->master);
d->master = -1;
}
diff -uNr apt-1.4.8/apt-pkg/deb/dpkgpm.cc apt-1.4.8.mod/apt-pkg/deb/dpkgpm.cc
--- apt-1.4.8/apt-pkg/deb/dpkgpm.cc 2018-06-19 13:55:47.330437710 +0300
+++ apt-1.4.8.mod/apt-pkg/deb/dpkgpm.cc 2018-06-19 13:54:21.810433307 +0300
@@ -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;
@@ -2413,11 +2413,14 @@
fprintf(report, " %s: %s\n", pkgname.c_str(), opstr);
}
+// In latest versions of Android, we can't 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];
@@ -2426,13 +2429,18 @@
pclose(log);
}
}
+#endif
+// Current Termux implementation of 'df' is just a wrapper
+// for /system/bin/df which may don't understand additional
+// parameters such as '-l'.
+#ifndef __ANDROID__
// 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","r");
+ FILE *log = popen("@TERMUX_PREFIX@/bin/df -l","r");
if(log != NULL)
{
char buf[1024];
@@ -2441,6 +2449,7 @@
pclose(log);
}
}
+#endif
fclose(report);

2
packages/apt/build.sh

@ -2,7 +2,7 @@ TERMUX_PKG_HOMEPAGE=https://packages.debian.org/apt
TERMUX_PKG_DESCRIPTION="Front-end for the dpkg package manager"
TERMUX_PKG_DEPENDS="libcurl, liblzma, dpkg, gpgv, libc++, termux-exec"
TERMUX_PKG_VERSION=1.4.8
TERMUX_PKG_REVISION=3
TERMUX_PKG_REVISION=4
TERMUX_PKG_SHA256=767ad7d6efb64cde52faececb7d3c0bf49800b9fe06f3a5b0132ab4c01a5b8f8
TERMUX_PKG_SRCURL=http://ftp.debian.org/debian/pool/main/a/apt/apt_${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="

40
packages/apt/cmdline-apt-key.in.patch

@ -1,6 +1,6 @@
diff -u -r ../apt-1.4.7/cmdline/apt-key.in ./cmdline/apt-key.in
--- ../apt-1.4.7/cmdline/apt-key.in 2017-07-13 23:45:39.000000000 +0200
+++ ./cmdline/apt-key.in 2017-07-26 12:18:17.424086422 +0200
diff -uNr apt-1.4.8/cmdline/apt-key.in apt-1.4.8.mod/cmdline/apt-key.in
--- apt-1.4.8/cmdline/apt-key.in 2017-09-13 19:47:33.000000000 +0300
+++ apt-1.4.8.mod/cmdline/apt-key.in 2018-06-19 18:18:43.024583291 +0300
@@ -16,10 +16,7 @@
aptkey_echo() { echo "$@"; }
@ -22,6 +22,31 @@ diff -u -r ../apt-1.4.7/cmdline/apt-key.in ./cmdline/apt-key.in
eval "$(apt-config shell TRUSTEDPARTS Dir::Etc::TrustedParts/d)"
if [ -d "$TRUSTEDPARTS" ]; then
TRUSTEDPARTS="$(readlink -f "$TRUSTEDPARTS")"
@@ -439,7 +436,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 +448,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 +539,7 @@
done
@ -41,3 +66,12 @@ diff -u -r ../apt-1.4.7/cmdline/apt-key.in ./cmdline/apt-key.in
CURRENTTRAP="${CURRENTTRAP} cleanup_gpg_home;"
trap "${CURRENTTRAP}" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
if [ -z "$GPGHOMEDIR" ]; then
@@ -654,7 +652,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"

12
packages/apt/methods-rsh.cc.patch

@ -0,0 +1,12 @@
diff -uNr apt-1.4.8/methods/rsh.cc apt-1.4.8.mod/methods/rsh.cc
--- apt-1.4.8/methods/rsh.cc 2017-09-13 19:47:33.000000000 +0300
+++ apt-1.4.8.mod/methods/rsh.cc 2018-06-19 13:41:50.497061290 +0300
@@ -152,7 +152,7 @@
if (Host.empty() == false) {
Args[i++] = Host.c_str();
}
- Args[i++] = "/bin/sh";
+ Args[i++] = "@TERMUX_PREFIX@/bin/sh";
Args[i] = 0;
execvp(Args[0],(char **)Args);
exit(100);
Loading…
Cancel
Save