Browse Source

apk-tools: don't set db->root to $PREFIX

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
parent
commit
bd4319d001
  1. 2
      disabled-packages/apk-tools/src-archive.c.patch
  2. 30
      disabled-packages/apk-tools/src-commit.c.patch
  3. 121
      disabled-packages/apk-tools/src-database.c.patch
  4. 2
      disabled-packages/apk-tools/src-io.c.patch
  5. 30
      disabled-packages/apk-tools/src-package.c.patch
  6. 10
      disabled-packages/apk-tools/src-termux_prefix.h.patch

2
disabled-packages/apk-tools/src-archive.c.patch

@ -1,6 +1,6 @@
diff -uNr apk-tools-2.10.3/src/archive.c apk-tools-2.10.3.mod/src/archive.c diff -uNr apk-tools-2.10.3/src/archive.c apk-tools-2.10.3.mod/src/archive.c
--- apk-tools-2.10.3/src/archive.c 2018-11-15 15:09:07.000000000 +0200 --- apk-tools-2.10.3/src/archive.c 2018-11-15 15:09:07.000000000 +0200
+++ apk-tools-2.10.3.mod/src/archive.c 2018-11-18 14:39:33.811301837 +0200 +++ apk-tools-2.10.3.mod/src/archive.c 2018-11-19 17:36:03.835900565 +0200
@@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
#include <sysexits.h> #include <sysexits.h>
#include <sys/wait.h> #include <sys/wait.h>

30
disabled-packages/apk-tools/src-commit.c.patch

@ -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);
}

121
disabled-packages/apk-tools/src-database.c.patch

@ -1,29 +1,120 @@
diff -uNr apk-tools-2.10.3/src/database.c apk-tools-2.10.3.mod/src/database.c diff -uNr apk-tools-2.10.3/src/database.c apk-tools-2.10.3.mod/src/database.c
--- apk-tools-2.10.3/src/database.c 2018-11-15 15:09:07.000000000 +0200 --- apk-tools-2.10.3/src/database.c 2018-11-15 15:09:07.000000000 +0200
+++ apk-tools-2.10.3.mod/src/database.c 2018-11-18 19:16:02.755222559 +0200 +++ apk-tools-2.10.3.mod/src/database.c 2018-11-19 17:45:05.469750983 +0200
@@ -1332,10 +1332,11 @@ @@ -37,6 +37,8 @@
#include "apk_print.h"
#include "apk_openssl.h"
+#include "termux_prefix.h"
+
static const apk_spn_match_def apk_spn_repo_separators = {
[4] = (1<<0) /* */,
[7] = (1<<2) /*:*/,
@@ -54,22 +56,22 @@
static const char * const apkindex_tar_gz = "APKINDEX.tar.gz";
-static const char * const apk_static_cache_dir = "var/cache/apk";
+static const char * const apk_static_cache_dir = TERMUX_PREFIX_RELATIVE"var/cache/apk";
-static const char * const apk_world_file = "etc/apk/world";
-static const char * const apk_world_file_tmp = "etc/apk/world.new";
-static const char * const apk_arch_file = "etc/apk/arch";
+static const char * const apk_world_file = TERMUX_PREFIX_RELATIVE"etc/apk/world";
+static const char * const apk_world_file_tmp = TERMUX_PREFIX_RELATIVE"etc/apk/world.new";
+static const char * const apk_arch_file = TERMUX_PREFIX_RELATIVE"etc/apk/arch";
-static const char * const apk_lock_file = "lib/apk/db/lock";
+static const char * const apk_lock_file = TERMUX_PREFIX_RELATIVE"lib/apk/db/lock";
-static const char * const apk_scripts_file = "lib/apk/db/scripts.tar";
-static const char * const apk_scripts_file_tmp = "lib/apk/db/scripts.tar.new";
+static const char * const apk_scripts_file = TERMUX_PREFIX_RELATIVE"lib/apk/db/scripts.tar";
+static const char * const apk_scripts_file_tmp = TERMUX_PREFIX_RELATIVE"lib/apk/db/scripts.tar.new";
-static const char * const apk_triggers_file = "lib/apk/db/triggers";
-static const char * const apk_triggers_file_tmp = "lib/apk/db/triggers.new";
+static const char * const apk_triggers_file = TERMUX_PREFIX_RELATIVE"lib/apk/db/triggers";
+static const char * const apk_triggers_file_tmp = TERMUX_PREFIX_RELATIVE"lib/apk/db/triggers.new";
-const char * const apk_installed_file = "lib/apk/db/installed";
-static const char * const apk_installed_file_tmp = "lib/apk/db/installed.new";
+const char * const apk_installed_file = TERMUX_PREFIX_RELATIVE"lib/apk/db/installed";
+static const char * const apk_installed_file_tmp = TERMUX_PREFIX_RELATIVE"lib/apk/db/installed.new";
static struct apk_db_acl *apk_default_acl_dir, *apk_default_acl_file;
@@ -1332,19 +1334,20 @@
static int apk_db_create(struct apk_database *db) static int apk_db_create(struct apk_database *db)
{ {
int fd; int fd;
- -
mkdirat(db->root_fd, "tmp", 01777); - mkdirat(db->root_fd, "tmp", 01777);
+ mkdirat(db->root_fd, TERMUX_PREFIX_RELATIVE"tmp", 01777);
mkdirat(db->root_fd, "dev", 0755); mkdirat(db->root_fd, "dev", 0755);
+#ifndef __ANDROID__ +#ifndef __ANDROID__
mknodat(db->root_fd, "dev/null", S_IFCHR | 0666, makedev(1, 3)); mknodat(db->root_fd, "dev/null", S_IFCHR | 0666, makedev(1, 3));
- mkdirat(db->root_fd, "etc", 0755);
- mkdirat(db->root_fd, "etc/apk", 0755);
- mkdirat(db->root_fd, "lib", 0755);
- mkdirat(db->root_fd, "lib/apk", 0755);
- mkdirat(db->root_fd, "lib/apk/db", 0755);
- mkdirat(db->root_fd, "var", 0755);
- mkdirat(db->root_fd, "var/cache", 0755);
- mkdirat(db->root_fd, "var/cache/apk", 0755);
- mkdirat(db->root_fd, "var/cache/misc", 0755);
+#endif +#endif
mkdirat(db->root_fd, "etc", 0755); + mkdirat(db->root_fd, TERMUX_PREFIX_RELATIVE"etc", 0755);
mkdirat(db->root_fd, "etc/apk", 0755); + mkdirat(db->root_fd, TERMUX_PREFIX_RELATIVE"etc/apk", 0755);
mkdirat(db->root_fd, "lib", 0755); + mkdirat(db->root_fd, TERMUX_PREFIX_RELATIVE"lib", 0755);
@@ -1538,7 +1539,7 @@ + mkdirat(db->root_fd, TERMUX_PREFIX_RELATIVE"lib/apk", 0755);
+ mkdirat(db->root_fd, TERMUX_PREFIX_RELATIVE"lib/apk/db", 0755);
+ mkdirat(db->root_fd, TERMUX_PREFIX_RELATIVE"var", 0755);
+ mkdirat(db->root_fd, TERMUX_PREFIX_RELATIVE"var/cache", 0755);
+ mkdirat(db->root_fd, TERMUX_PREFIX_RELATIVE"var/cache/apk", 0755);
+ mkdirat(db->root_fd, TERMUX_PREFIX_RELATIVE"var/cache/misc", 0755);
fd = openat(db->root_fd, apk_world_file, O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC, 0644);
if (fd < 0)
@@ -1533,7 +1536,7 @@
!(dbopts->open_flags & APK_OPENF_NO_AUTOUPDATE) &&
!(apk_flags & APK_NO_NETWORK))
db->autoupdate = 1;
- if (!dbopts->cache_dir) dbopts->cache_dir = "etc/apk/cache";
+ if (!dbopts->cache_dir) dbopts->cache_dir = TERMUX_PREFIX_RELATIVE"etc/apk/cache";
apk_db_setup_repositories(db, dbopts->cache_dir); apk_db_setup_repositories(db, dbopts->cache_dir);
db->cache_max_age = dbopts->cache_max_age ?: 4*60*60; /* 4 hours default */ @@ -1625,7 +1628,7 @@
- db->root = strdup(dbopts->root ?: "/"); blob = APK_BLOB_STR("+etc\n" "@etc/init.d\n" "!etc/apk\n");
+ db->root = strdup(dbopts->root ?: "/data/data/com.termux/files/usr"); apk_blob_for_each_segment(blob, "\n", add_protected_path, db);
db->root_fd = openat(AT_FDCWD, db->root, O_RDONLY | O_CLOEXEC);
if (db->root_fd < 0 && (dbopts->open_flags & APK_OPENF_CREATE)) { - apk_dir_foreach_file(openat(db->root_fd, "etc/apk/protected_paths.d", O_RDONLY | O_CLOEXEC),
mkdirat(AT_FDCWD, db->root, 0755); + apk_dir_foreach_file(openat(db->root_fd, TERMUX_PREFIX_RELATIVE"etc/apk/protected_paths.d", O_RDONLY | O_CLOEXEC),
@@ -1931,7 +1932,7 @@ add_protected_paths_from_file, db);
/* figure out where to have the cache */
@@ -1655,7 +1658,7 @@
}
db->keys_fd = openat(db->root_fd,
- dbopts->keys_dir ?: "etc/apk/keys",
+ dbopts->keys_dir ?: TERMUX_PREFIX_RELATIVE"etc/apk/keys",
O_RDONLY | O_CLOEXEC);
if (apk_flags & APK_OVERLAY_FROM_STDIN) {
@@ -1693,8 +1696,8 @@
apk_db_add_repository(db, APK_BLOB_STR(repo->url));
if (dbopts->repositories_file == NULL) {
- add_repos_from_file(db, db->root_fd, "etc/apk/repositories");
- apk_dir_foreach_file(openat(db->root_fd, "etc/apk/repositories.d", O_RDONLY | O_CLOEXEC),
+ add_repos_from_file(db, db->root_fd, TERMUX_PREFIX_RELATIVE"etc/apk/repositories");
+ apk_dir_foreach_file(openat(db->root_fd, TERMUX_PREFIX_RELATIVE"etc/apk/repositories.d", O_RDONLY | O_CLOEXEC),
add_repos_from_file, db);
} else {
add_repos_from_file(db, db->root_fd, dbopts->repositories_file);
@@ -1931,7 +1934,7 @@
int status; int status;
pid_t pid; pid_t pid;
static char * const environment[] = { static char * const environment[] = {
@ -32,7 +123,7 @@ diff -uNr apk-tools-2.10.3/src/database.c apk-tools-2.10.3.mod/src/database.c
NULL NULL
}; };
@@ -1968,9 +1969,10 @@ @@ -1968,9 +1971,10 @@
r = fstatat(db->root_fd, dir->name, &st, AT_SYMLINK_NOFOLLOW); r = fstatat(db->root_fd, dir->name, &st, AT_SYMLINK_NOFOLLOW);
if (r < 0 || (st.st_mode & 07777) != (dir->mode & 07777)) if (r < 0 || (st.st_mode & 07777) != (dir->mode & 07777))
fchmodat(db->root_fd, dir->name, dir->mode, 0); fchmodat(db->root_fd, dir->name, dir->mode, 0);

2
disabled-packages/apk-tools/src-io.c.patch

@ -1,6 +1,6 @@
diff -uNr apk-tools-2.10.3/src/io.c apk-tools-2.10.3.mod/src/io.c diff -uNr apk-tools-2.10.3/src/io.c apk-tools-2.10.3.mod/src/io.c
--- apk-tools-2.10.3/src/io.c 2018-11-15 15:09:07.000000000 +0200 --- apk-tools-2.10.3/src/io.c 2018-11-15 15:09:07.000000000 +0200
+++ apk-tools-2.10.3.mod/src/io.c 2018-11-18 19:15:25.081674847 +0200 +++ apk-tools-2.10.3.mod/src/io.c 2018-11-19 17:36:03.842567276 +0200
@@ -1012,6 +1012,7 @@ @@ -1012,6 +1012,7 @@
.delete_item = (apk_hash_delete_f) free, .delete_item = (apk_hash_delete_f) free,
}; };

30
disabled-packages/apk-tools/src-package.c.patch

@ -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;
}

10
disabled-packages/apk-tools/src-termux_prefix.h.patch

@ -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…
Cancel
Save