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