Browse Source
Setting db->root to $PREFIX breaks package installation if package was configured with '--prefix=$PREFIX'.android-5
Leonid Plyushch
6 years ago
committed by
Fredrik Fornwall
6 changed files with 178 additions and 17 deletions
@ -0,0 +1,30 @@ |
|||||
|
diff -uNr apk-tools-2.10.3/src/commit.c apk-tools-2.10.3.mod/src/commit.c
|
||||
|
--- apk-tools-2.10.3/src/commit.c 2018-11-15 15:09:07.000000000 +0200
|
||||
|
+++ apk-tools-2.10.3.mod/src/commit.c 2018-11-19 17:44:44.799596053 +0200
|
||||
|
@@ -19,6 +19,8 @@
|
||||
|
|
||||
|
#include "apk_print.h" |
||||
|
|
||||
|
+#include "termux_prefix.h"
|
||||
|
+
|
||||
|
static inline int pkg_available(struct apk_database *db, struct apk_package *pkg) |
||||
|
{ |
||||
|
if (pkg->repos & db->available_repos) |
||||
|
@@ -235,7 +237,7 @@
|
||||
|
if (file[0] == '.') return 0; |
||||
|
if ((apk_flags & (APK_NO_SCRIPTS | APK_SIMULATE)) != 0) return 0; |
||||
|
|
||||
|
- snprintf(fn, sizeof(fn), "etc/apk/commit_hooks.d" "/%s", file);
|
||||
|
+ snprintf(fn, sizeof(fn), TERMUX_PREFIX_RELATIVE"etc/apk/commit_hooks.d" "/%s", file);
|
||||
|
if ((apk_flags & APK_NO_COMMIT_HOOKS) != 0) { |
||||
|
apk_message("Skipping: %s %s", fn, commit_hook_str[hook->type]); |
||||
|
return 0; |
||||
|
@@ -251,7 +253,7 @@
|
||||
|
static int run_commit_hooks(struct apk_database *db, int type) |
||||
|
{ |
||||
|
struct apk_commit_hook hook = { .db = db, .type = type }; |
||||
|
- return apk_dir_foreach_file(openat(db->root_fd, "etc/apk/commit_hooks.d", O_RDONLY | O_CLOEXEC),
|
||||
|
+ return apk_dir_foreach_file(openat(db->root_fd, TERMUX_PREFIX_RELATIVE"etc/apk/commit_hooks.d", O_RDONLY | O_CLOEXEC),
|
||||
|
run_commit_hook, &hook); |
||||
|
} |
||||
|
|
@ -0,0 +1,30 @@ |
|||||
|
diff -uNr apk-tools-2.10.3/src/package.c apk-tools-2.10.3.mod/src/package.c
|
||||
|
--- apk-tools-2.10.3/src/package.c 2018-11-15 15:09:07.000000000 +0200
|
||||
|
+++ apk-tools-2.10.3.mod/src/package.c 2018-11-19 17:44:51.566313390 +0200
|
||||
|
@@ -30,6 +30,8 @@
|
||||
|
#include "apk_database.h" |
||||
|
#include "apk_print.h" |
||||
|
|
||||
|
+#include "termux_prefix.h"
|
||||
|
+
|
||||
|
static const apk_spn_match_def apk_spn_dependency_comparer = { |
||||
|
[7] = (1<<4) /*<*/ | (1<<5) /*=*/ | (1<<6) /*<*/, |
||||
|
[15] = (1<<6) /*~*/ |
||||
|
@@ -1008,7 +1010,7 @@
|
||||
|
argv[0] = (char *) apk_script_types[type]; |
||||
|
|
||||
|
/* Avoid /tmp as it can be mounted noexec */ |
||||
|
- snprintf(fn, sizeof(fn), "var/cache/misc/" PKG_VER_FMT ".%s",
|
||||
|
+ snprintf(fn, sizeof(fn), TERMUX_PREFIX_RELATIVE"var/cache/misc/" PKG_VER_FMT ".%s",
|
||||
|
PKG_VER_PRINTF(pkg), |
||||
|
apk_script_types[type]); |
||||
|
|
||||
|
@@ -1018,7 +1020,7 @@
|
||||
|
apk_message("Executing %s", &fn[15]); |
||||
|
fd = openat(root_fd, fn, O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC, 0755); |
||||
|
if (fd < 0) { |
||||
|
- mkdirat(root_fd, "var/cache/misc", 0755);
|
||||
|
+ mkdirat(root_fd, TERMUX_PREFIX_RELATIVE"var/cache/misc", 0755);
|
||||
|
fd = openat(root_fd, fn, O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC, 0755); |
||||
|
if (fd < 0) goto err_log; |
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
diff -uNr apk-tools-2.10.3/src/termux_prefix.h apk-tools-2.10.3.mod/src/termux_prefix.h
|
||||
|
--- apk-tools-2.10.3/src/termux_prefix.h 1970-01-01 03:00:00.000000000 +0300
|
||||
|
+++ apk-tools-2.10.3.mod/src/termux_prefix.h 2018-11-19 17:42:52.188760273 +0200
|
||||
|
@@ -0,0 +1,6 @@
|
||||
|
+#ifndef __TERMUX_PREFIX_H
|
||||
|
+#define __TERMUX_PREFIX_H
|
||||
|
+
|
||||
|
+#define TERMUX_PREFIX_RELATIVE "data/data/com.termux/files/usr/"
|
||||
|
+
|
||||
|
+#endif
|
Loading…
Reference in new issue