aboutsummaryrefslogtreecommitdiffstats
path: root/main/apk-tools
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2012-10-01 19:02:48 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2012-10-01 19:06:31 +0000
commit8d6945855c1fb5aa2871b33504c2a715c4d54e35 (patch)
tree4549d9e1448b4f09b175fc1bae81b5439f08ebd4 /main/apk-tools
parente6629e41d03fb04563ddbcd1bf7506c88e5efa29 (diff)
downloadaports-8d6945855c1fb5aa2871b33504c2a715c4d54e35.tar.bz2
aports-8d6945855c1fb5aa2871b33504c2a715c4d54e35.tar.xz
main/apk-tools: fix apk info --provides, add --progress-fd
ref #1396
Diffstat (limited to 'main/apk-tools')
-rw-r--r--main/apk-tools/0002-apk-implement-progress-fd-to-write-progress-to-a-spe.patch176
-rw-r--r--main/apk-tools/0003-info-provides-alias-p-is-reserved-for-root-use-P.patch35
-rw-r--r--main/apk-tools/APKBUILD8
3 files changed, 217 insertions, 2 deletions
diff --git a/main/apk-tools/0002-apk-implement-progress-fd-to-write-progress-to-a-spe.patch b/main/apk-tools/0002-apk-implement-progress-fd-to-write-progress-to-a-spe.patch
new file mode 100644
index 0000000000..7f57ac78d0
--- /dev/null
+++ b/main/apk-tools/0002-apk-implement-progress-fd-to-write-progress-to-a-spe.patch
@@ -0,0 +1,176 @@
+From 43850a126b94690302bc2564905141b077b490e7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
+Date: Thu, 20 Sep 2012 15:12:15 +0300
+Subject: [PATCH] apk: implement --progress-fd to write progress to a
+ specified fd
+
+---
+ src/apk.c | 5 +++++
+ src/apk_database.h | 4 ++--
+ src/database.c | 1 +
+ src/solver.c | 44 +++++++++++++++++++++++++++-----------------
+ 4 files changed, 35 insertions(+), 19 deletions(-)
+
+diff --git a/src/apk.c b/src/apk.c
+index 3bf1154..0404831 100644
+--- a/src/apk.c
++++ b/src/apk.c
+@@ -48,6 +48,7 @@ static struct apk_option generic_options[] = {
+ { 'f', "force", "Do what was asked even if it looks dangerous" },
+ { 'U', "update-cache", "Update the repository cache" },
+ { 0x101, "progress", "Show a progress bar" },
++ { 0x10f, "progress-fd", "Write progress to fd", required_argument, "FD" },
+ { 0x110, "no-progress", "Disable progress bar even for TTYs" },
+ { 0x102, "clean-protected", "Do not create .apk-new files to "
+ "configuration dirs" },
+@@ -265,6 +266,7 @@ static void setup_terminal(void)
+ {
+ setvbuf(stderr, NULL, _IOLBF, BUFSIZ);
+ signal(SIGWINCH, on_sigwinch);
++ signal(SIGPIPE, SIG_IGN);
+ }
+
+ static void setup_automatic_flags(void)
+@@ -383,6 +385,9 @@ int main(int argc, char **argv)
+ case 0x110:
+ apk_flags &= ~APK_PROGRESS;
+ break;
++ case 0x10f:
++ dbopts.progress_fd = atoi(optarg);
++ break;
+ case 0x102:
+ apk_flags |= APK_CLEAN_PROTECTED;
+ break;
+diff --git a/src/apk_database.h b/src/apk_database.h
+index 235030c..4628c23 100644
+--- a/src/apk_database.h
++++ b/src/apk_database.h
+@@ -108,7 +108,7 @@ struct apk_repository_list {
+ };
+
+ struct apk_db_options {
+- int lock_wait;
++ int lock_wait, progress_fd;
+ unsigned long open_flags;
+ char *root;
+ char *arch;
+@@ -127,7 +127,7 @@ struct apk_repository_tag {
+
+ struct apk_database {
+ char *root;
+- int root_fd, lock_fd, cache_fd, cachetmp_fd, keys_fd;
++ int root_fd, lock_fd, cache_fd, cachetmp_fd, keys_fd, progress_fd;
+ unsigned num_repos, num_repo_tags;
+ const char *cache_dir;
+ char *cache_remount_dir;
+diff --git a/src/database.c b/src/database.c
+index d1a8f1a..e130f0b 100644
+--- a/src/database.c
++++ b/src/database.c
+@@ -1359,6 +1359,7 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
+ int r, fd, write_arch = FALSE;
+
+ memset(db, 0, sizeof(*db));
++ db->progress_fd = dbopts->progress_fd;
+ if (apk_flags & APK_SIMULATE) {
+ dbopts->open_flags &= ~(APK_OPENF_CREATE | APK_OPENF_WRITE);
+ dbopts->open_flags |= APK_OPENF_READ;
+diff --git a/src/solver.c b/src/solver.c
+index 457d5ff..ec44958 100644
+--- a/src/solver.c
++++ b/src/solver.c
+@@ -10,6 +10,7 @@
+ */
+
+ #include <stdint.h>
++#include <unistd.h>
+ #include "apk_defines.h"
+ #include "apk_database.h"
+ #include "apk_package.h"
+@@ -1650,23 +1651,34 @@ struct progress {
+ struct apk_stats done;
+ struct apk_stats total;
+ struct apk_package *pkg;
+- size_t count;
++ size_t percent;
++ int progress_fd;
+ };
+
+-static void progress_cb(void *ctx, size_t progress)
++static void update_progress(struct progress *prog, size_t percent)
++{
++ if (prog->percent == percent)
++ return;
++ prog->percent = percent;
++ if (apk_flags & APK_PROGRESS)
++ draw_progress(percent);
++ if (prog->progress_fd != 0) {
++ char buf[8];
++ size_t n = snprintf(buf, sizeof(buf), "%d\n", percent);
++ write(prog->progress_fd, buf, n);
++ }
++}
++
++static void progress_cb(void *ctx, size_t pkg_percent)
+ {
+ struct progress *prog = (struct progress *) ctx;
+- size_t partial = 0, count;
++ size_t partial = 0, percent;
+
+ if (prog->pkg != NULL)
+- partial = muldiv(progress, prog->pkg->installed_size, APK_PROGRESS_SCALE);
+-
+- count = muldiv(100, prog->done.bytes + prog->done.packages + partial,
+- prog->total.bytes + prog->total.packages);
+-
+- if (prog->count != count)
+- draw_progress(count);
+- prog->count = count;
++ partial = muldiv(pkg_percent, prog->pkg->installed_size, APK_PROGRESS_SCALE);
++ percent = muldiv(100, prog->done.bytes + prog->done.packages + partial,
++ prog->total.bytes + prog->total.packages);
++ update_progress(prog, percent);
+ }
+
+ static int dump_packages(struct apk_changeset *changeset,
+@@ -1784,6 +1796,7 @@ int apk_solver_commit_changeset(struct apk_database *db,
+
+ /* Count what needs to be done */
+ memset(&prog, 0, sizeof(prog));
++ prog.progress_fd = db->progress_fd;
+ for (i = 0; i < changeset->changes->num; i++) {
+ change = &changeset->changes->item[i];
+ count_change(change, &prog.total);
+@@ -1831,17 +1844,15 @@ int apk_solver_commit_changeset(struct apk_database *db,
+ change = &changeset->changes->item[i];
+
+ print_change(db, change, i, changeset->changes->num);
+- if (apk_flags & APK_PROGRESS)
+- draw_progress(prog.count);
+ prog.pkg = change->newpkg;
++ progress_cb(&prog, 0);
+
+ if (!(apk_flags & APK_SIMULATE)) {
+ if (change->oldpkg != change->newpkg ||
+ (change->reinstall && pkg_available(db, change->newpkg)))
+ r = apk_db_install_pkg(db,
+ change->oldpkg, change->newpkg,
+- (apk_flags & APK_PROGRESS) ? progress_cb : NULL,
+- &prog);
++ progress_cb, &prog);
+ if (r != 0)
+ break;
+ if (change->newpkg)
+@@ -1850,8 +1861,7 @@ int apk_solver_commit_changeset(struct apk_database *db,
+
+ count_change(change, &prog.done);
+ }
+- if (apk_flags & APK_PROGRESS)
+- draw_progress(100);
++ update_progress(&prog, 100);
+
+ run_triggers(db);
+
+--
+1.7.12.2
+
diff --git a/main/apk-tools/0003-info-provides-alias-p-is-reserved-for-root-use-P.patch b/main/apk-tools/0003-info-provides-alias-p-is-reserved-for-root-use-P.patch
new file mode 100644
index 0000000000..f8b806e1a7
--- /dev/null
+++ b/main/apk-tools/0003-info-provides-alias-p-is-reserved-for-root-use-P.patch
@@ -0,0 +1,35 @@
+From 4b7b5d4668865b1026c7050c8872f256bc773605 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Fri, 28 Sep 2012 10:24:27 +0300
+Subject: [PATCH] info: --provides alias -p is reserved for --root, use -P
+
+fixes #1396
+---
+ src/info.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/info.c b/src/info.c
+index e9f1b59..9b37f38 100644
+--- a/src/info.c
++++ b/src/info.c
+@@ -427,7 +427,7 @@ static int info_parse(void *ctx, struct apk_db_options *dbopts,
+ case 'R':
+ ictx->subaction_mask |= APK_INFO_DEPENDS;
+ break;
+- case 'p':
++ case 'P':
+ ictx->subaction_mask |= APK_INFO_PROVIDES;
+ break;
+ case 'r':
+@@ -489,7 +489,7 @@ static struct apk_option info_options[] = {
+ { 'e', "installed", "Check if PACKAGE is installed" },
+ { 'W', "who-owns", "Print the package owning the specified file" },
+ { 'R', "depends", "List packages that the PACKAGE depends on" },
+- { 'p', "provides", "List virtual packages provided by PACKAGE" },
++ { 'P', "provides", "List virtual packages provided by PACKAGE" },
+ { 'r', "rdepends", "List all packages depending on PACKAGE" },
+ { 0x10000, "replaces", "List packages whom files PACKAGE might replace" },
+ { 'i', "install-if", "List the PACKAGE's install-if rule" },
+--
+1.7.12.2
+
diff --git a/main/apk-tools/APKBUILD b/main/apk-tools/APKBUILD
index 0bd514fe6d..85946fcbe3 100644
--- a/main/apk-tools/APKBUILD
+++ b/main/apk-tools/APKBUILD
@@ -1,13 +1,15 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=apk-tools
pkgver=2.3.2
-pkgrel=1
+pkgrel=2
pkgdesc="Alpine Package Keeper - package manager for alpine"
subpackages="$pkgname-static lua-apk:luaapk"
depends=
makedepends="zlib-dev openssl-dev lua-dev"
source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2
0001-db-remove-AT_SYMLINK_NOFOLLOW-for-directory-permissi.patch
+ 0002-apk-implement-progress-fd-to-write-progress-to-a-spe.patch
+ 0003-info-provides-alias-p-is-reserved-for-root-use-P.patch
"
url="http://git.alpinelinux.org/cgit/apk-tools/"
@@ -60,4 +62,6 @@ luaapk() {
}
md5sums="813b7c9fd7f6159972dc4fa5dfcc97c5 apk-tools-2.3.2.tar.bz2
-a5a635f510e6f69b1e2f6cadb45efe04 0001-db-remove-AT_SYMLINK_NOFOLLOW-for-directory-permissi.patch"
+a5a635f510e6f69b1e2f6cadb45efe04 0001-db-remove-AT_SYMLINK_NOFOLLOW-for-directory-permissi.patch
+0a96443650fec545667b6eccc5d9ef1e 0002-apk-implement-progress-fd-to-write-progress-to-a-spe.patch
+6718b405982c5bfeed3761a9d57cfce8 0003-info-provides-alias-p-is-reserved-for-root-use-P.patch"