From 27b1f0a6f214fa232090c436affcb09f77fb3366 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Tue, 11 Sep 2018 00:46:45 +0200 Subject: [PATCH] apk-tools: Add as disabled package --- disabled-packages/apk-tools/Make.rules.patch | 16 ++++++ disabled-packages/apk-tools/Makefile.patch | 20 ++++++++ disabled-packages/apk-tools/build.sh | 17 +++++++ disabled-packages/apk-tools/src-apk.c.patch | 12 +++++ .../apk-tools/src-archive.c.patch | 11 ++++ .../apk-tools/src-database.c.patch | 29 +++++++++++ disabled-packages/apk-tools/src-io.c.patch | 50 +++++++++++++++++++ 7 files changed, 155 insertions(+) create mode 100644 disabled-packages/apk-tools/Make.rules.patch create mode 100644 disabled-packages/apk-tools/Makefile.patch create mode 100644 disabled-packages/apk-tools/build.sh create mode 100644 disabled-packages/apk-tools/src-apk.c.patch create mode 100644 disabled-packages/apk-tools/src-archive.c.patch create mode 100644 disabled-packages/apk-tools/src-database.c.patch create mode 100644 disabled-packages/apk-tools/src-io.c.patch diff --git a/disabled-packages/apk-tools/Make.rules.patch b/disabled-packages/apk-tools/Make.rules.patch new file mode 100644 index 000000000..6ed01fbaf --- /dev/null +++ b/disabled-packages/apk-tools/Make.rules.patch @@ -0,0 +1,16 @@ +diff -u -r ../apk-tools-2.10.1/Make.rules ./Make.rules +--- ../apk-tools-2.10.1/Make.rules 2018-09-10 08:04:03.000000000 +0000 ++++ ./Make.rules 2018-09-10 21:36:27.914805239 +0000 +@@ -64,9 +64,9 @@ + # Utilities and default flags for them. + + CROSS_COMPILE ?= +-CC := $(CROSS_COMPILE)gcc +-AR := $(CROSS_COMPILE)ar +-LD := $(CROSS_COMPILE)ld ++CC ?= $(CROSS_COMPILE)gcc ++AR ?= $(CROSS_COMPILE)ar ++LD ?= $(CROSS_COMPILE)ld + INSTALL := install + INSTALLDIR := $(INSTALL) -d + diff --git a/disabled-packages/apk-tools/Makefile.patch b/disabled-packages/apk-tools/Makefile.patch new file mode 100644 index 000000000..b26edc7e4 --- /dev/null +++ b/disabled-packages/apk-tools/Makefile.patch @@ -0,0 +1,20 @@ +diff -u -r ../apk-tools-2.10.1/Makefile ./Makefile +--- ../apk-tools-2.10.1/Makefile 2018-09-10 08:04:03.000000000 +0000 ++++ ./Makefile 2018-09-10 21:58:19.631911343 +0000 +@@ -10,11 +10,11 @@ + # Default directories + + DESTDIR := +-SBINDIR := /sbin +-LIBDIR := /lib +-CONFDIR := /etc/apk +-MANDIR := /usr/share/man +-DOCDIR := /usr/share/doc/apk ++SBINDIR := @TERMUX_PREFIX@/bin ++LIBDIR := @TERMUX_PREFIX@/lib ++CONFDIR := @TERMUX_PREFIX@/etc/apk ++MANDIR := @TERMUX_PREFIX@/share/man ++DOCDIR := @TERMUX_PREFIX@/share/doc/apk + + export DESTDIR SBINDIR LIBDIR CONFDIR MANDIR DOCDIR + diff --git a/disabled-packages/apk-tools/build.sh b/disabled-packages/apk-tools/build.sh new file mode 100644 index 000000000..a14255375 --- /dev/null +++ b/disabled-packages/apk-tools/build.sh @@ -0,0 +1,17 @@ +TERMUX_PKG_HOMEPAGE=https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management +TERMUX_PKG_DESCRIPTION="Alpine Linux package management tools" +TERMUX_PKG_VERSION=2.10.1 +TERMUX_PKG_SHA256=278854c4ee21ed4ddb7605ef09190385106c6fdfc10526e32e0108ad0f12509a +TERMUX_PKG_SRCURL=https://github.com/alpinelinux/apk-tools/archive/v${TERMUX_PKG_VERSION}.tar.gz +TERMUX_PKG_DEPENDS="openssl" +TERMUX_PKG_BUILD_IN_SRC=yes +TERMUX_PKG_EXTRA_MAKE_ARGS="LUAAPK=" + +termux_step_post_make_install() { + mkdir -p $TERMUX_PREFIX/etc/apk/ + echo $TERMUX_ARCH > $TERMUX_PREFIX/etc/apk/arch + + mkdir -p $TERMUX_PREFIX/lib/apk/db/ + echo "Needed by the apk tool." > $TERMUX_PREFIX/lib/apk/db/README +} + diff --git a/disabled-packages/apk-tools/src-apk.c.patch b/disabled-packages/apk-tools/src-apk.c.patch new file mode 100644 index 000000000..97c947f5d --- /dev/null +++ b/disabled-packages/apk-tools/src-apk.c.patch @@ -0,0 +1,12 @@ +diff -u -r ../apk-tools-2.10.1/src/apk.c ./src/apk.c +--- ../apk-tools-2.10.1/src/apk.c 2018-09-10 08:04:03.000000000 +0000 ++++ ./src/apk.c 2018-09-10 22:02:50.668809543 +0000 +@@ -486,7 +486,7 @@ + + apk_flags |= APK_PROGRESS; + if (!(apk_flags & APK_SIMULATE) && +- access("/etc/apk/interactive", F_OK) == 0) ++ access("@TERMUX_PREFIX@/etc/apk/interactive", F_OK) == 0) + apk_flags |= APK_INTERACTIVE; + } + diff --git a/disabled-packages/apk-tools/src-archive.c.patch b/disabled-packages/apk-tools/src-archive.c.patch new file mode 100644 index 000000000..14653bb25 --- /dev/null +++ b/disabled-packages/apk-tools/src-archive.c.patch @@ -0,0 +1,11 @@ +diff -u -r ../apk-tools-2.10.1/src/archive.c ./src/archive.c +--- ../apk-tools-2.10.1/src/archive.c 2018-09-10 08:04:03.000000000 +0000 ++++ ./src/archive.c 2018-09-10 21:48:51.234399333 +0000 +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + #include + #include + #include diff --git a/disabled-packages/apk-tools/src-database.c.patch b/disabled-packages/apk-tools/src-database.c.patch new file mode 100644 index 000000000..ee733bb62 --- /dev/null +++ b/disabled-packages/apk-tools/src-database.c.patch @@ -0,0 +1,29 @@ +diff -u -r ../apk-tools-2.10.1/src/database.c ./src/database.c +--- ../apk-tools-2.10.1/src/database.c 2018-09-10 08:04:03.000000000 +0000 ++++ ./src/database.c 2018-09-10 22:06:19.510417812 +0000 +@@ -1331,7 +1331,7 @@ + static int apk_db_create(struct apk_database *db) + { + int fd; +- ++#ifndef __ANDROID__ + mkdirat(db->root_fd, "tmp", 01777); + mkdirat(db->root_fd, "dev", 0755); + mknodat(db->root_fd, "dev/null", S_IFCHR | 0666, makedev(1, 3)); +@@ -1344,6 +1344,7 @@ + mkdirat(db->root_fd, "var/cache", 0755); + mkdirat(db->root_fd, "var/cache/apk", 0755); + mkdirat(db->root_fd, "var/cache/misc", 0755); ++#endif + + fd = openat(db->root_fd, apk_world_file, O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC, 0644); + if (fd < 0) +@@ -1529,7 +1530,7 @@ + apk_db_setup_repositories(db, dbopts->cache_dir); + + db->cache_max_age = dbopts->cache_max_age ?: 4*60*60; /* 4 hours default */ +- db->root = strdup(dbopts->root ?: "/"); ++ db->root = strdup(dbopts->root ?: "@TERMUX_PREFIX@"); + db->root_fd = openat(AT_FDCWD, db->root, O_RDONLY | O_CLOEXEC); + if (db->root_fd < 0 && (dbopts->open_flags & APK_OPENF_CREATE)) { + mkdirat(AT_FDCWD, db->root, 0755); diff --git a/disabled-packages/apk-tools/src-io.c.patch b/disabled-packages/apk-tools/src-io.c.patch new file mode 100644 index 000000000..c51eaf75c --- /dev/null +++ b/disabled-packages/apk-tools/src-io.c.patch @@ -0,0 +1,50 @@ +diff -u -r ../apk-tools-2.10.1/src/io.c ./src/io.c +--- ../apk-tools-2.10.1/src/io.c 2018-09-10 08:04:03.000000000 +0000 ++++ ./src/io.c 2018-09-10 21:56:03.349469566 +0000 +@@ -1005,6 +1005,7 @@ + .delete_item = (apk_hash_delete_f) free, + }; + ++#ifndef __ANDROID__ + static struct cache_item *resolve_cache_item(struct apk_hash *hash, apk_blob_t name) + { + struct cache_item *ci; +@@ -1025,6 +1026,7 @@ + + return ci; + } ++#endif + + void apk_id_cache_init(struct apk_id_cache *idc, int root_fd) + { +@@ -1049,6 +1051,9 @@ + + uid_t apk_resolve_uid(struct apk_id_cache *idc, const char *username, uid_t default_uid) + { ++#ifdef __ANDROID__ ++ return getuid(); ++#else + #ifdef HAVE_FGETPWENT_R + char buf[1024]; + struct passwd pwent; +@@ -1088,10 +1093,14 @@ + return ci->uid; + + return default_uid; ++#endif + } + + uid_t apk_resolve_gid(struct apk_id_cache *idc, const char *groupname, uid_t default_gid) + { ++#ifdef __ANDROID__ ++ return getgid(); ++#else + #ifdef HAVE_FGETGRENT_R + char buf[1024]; + struct group grent; +@@ -1131,4 +1140,5 @@ + return ci->gid; + + return default_gid; ++#endif + }