Commit 204b4caa authored by Natanael Copa's avatar Natanael Copa
Browse files

main/apk-tools: misc apk-tools improvements

fixes #1122
(cherry picked from commit 2de02519)
parent 56f1ed4d
From 38c1e65afbb334af0107c6bdd5362303473d866f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Tue, 1 May 2012 14:30:06 +0300
Subject: [PATCH 1/2] db: strip leading and trailing slashes from protected
Subject: [PATCH 1/5] db: strip leading and trailing slashes from protected
path spec
---
......
From c9a43a14697fa955f31e495a8b03a523975ad285 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
Date: Tue, 1 May 2012 15:40:31 +0300
Subject: [PATCH 2/2] audit: apply protected_paths.d masks to individual files
Subject: [PATCH 2/5] audit: apply protected_paths.d masks to individual files
---
src/audit.c | 21 ++++++++++++++++++---
......
From 9154b8b5e44859ce0a1fd0ba292b26bf8dc8d046 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Mon, 7 May 2012 08:51:02 +0200
Subject: [PATCH 3/5] ver: print '?' when package is not available in any repo
This makes it possible to differ between downgradable packages (-l '<')
and unavailable in repos (-l '?').
---
src/apk_version.h | 1 +
src/ver.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/apk_version.h b/src/apk_version.h
index dcbf20f..4275343 100644
--- a/src/apk_version.h
+++ b/src/apk_version.h
@@ -14,6 +14,7 @@
#include "apk_blob.h"
+#define APK_VERSION_UNKNOWN 0
#define APK_VERSION_EQUAL 1
#define APK_VERSION_LESS 2
#define APK_VERSION_GREATER 4
diff --git a/src/ver.c b/src/ver.c
index 4bfd607..90b6cd6 100644
--- a/src/ver.c
+++ b/src/ver.c
@@ -125,7 +125,8 @@ static void ver_print_package_status(struct ver_ctx *ictx, struct apk_database *
break;
}
}
- r = apk_version_compare_blob(*pkg->version, *latest);
+ r = latest->len ? apk_version_compare_blob(*pkg->version, *latest)
+ : APK_VERSION_UNKNOWN;
opstr = apk_version_op_string(r);
if ((ictx->limchars != NULL) && (strchr(ictx->limchars, *opstr) == NULL))
return;
--
1.7.10
From 08595072ae2156a399253d34b41748da99e84bfc Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Mon, 7 May 2012 08:54:41 +0200
Subject: [PATCH 4/5] ver: make --quiet output suitable for scripting/piping
Do not print version numbers or compare result char when in quiet
mode. This makes the output suitable for be used in scripts or pipes.
For example:
# Upgrade all packages that matches a given regexp
apk version --limit '<' --quiet | grep $regexp | apk fix --reinstall
# Delete all packages that are removed from repository
apk version --limit '?' --quiet | xargs apk del
---
src/ver.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/ver.c b/src/ver.c
index 90b6cd6..05ffce9 100644
--- a/src/ver.c
+++ b/src/ver.c
@@ -130,6 +130,10 @@ static void ver_print_package_status(struct ver_ctx *ictx, struct apk_database *
opstr = apk_version_op_string(r);
if ((ictx->limchars != NULL) && (strchr(ictx->limchars, *opstr) == NULL))
return;
+ if (apk_verbosity <= 0) {
+ printf("%s\n", pkg->name->name);
+ return;
+ }
snprintf(pkgname, sizeof(pkgname), PKG_VER_FMT,
PKG_VER_PRINTF(pkg));
printf("%-40s%s " BLOB_FMT, pkgname, opstr, BLOB_PRINTF(*latest));
--
1.7.10
From a6b28beef055c9c454fba49d02995765e6f3aeab Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Mon, 7 May 2012 10:53:45 +0200
Subject: [PATCH 5/5] ver: show all packages with -v
ref #1122
---
src/ver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ver.c b/src/ver.c
index 05ffce9..c20547a 100644
--- a/src/ver.c
+++ b/src/ver.c
@@ -161,7 +161,7 @@ static int ver_main(void *ctx, struct apk_database *db, int argc, char **argv)
if (ictx->limchars) {
if (strlen(ictx->limchars) == 0)
ictx->limchars = NULL;
- } else if (argc == 0) {
+ } else if (argc == 0 && apk_verbosity == 1) {
ictx->limchars = "<";
}
--
1.7.10
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=apk-tools
pkgver=2.3.1
pkgrel=1
pkgrel=2
pkgdesc="Alpine Package Keeper - package manager for alpine"
subpackages="$pkgname-static lua-apk:luaapk"
depends=
......@@ -9,6 +9,9 @@ makedepends="zlib-dev openssl-dev lua-dev"
source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.bz2
0001-db-strip-leading-and-trailing-slashes-from-protected.patch
0002-audit-apply-protected_paths.d-masks-to-individual-fi.patch
0003-ver-print-when-package-is-not-available-in-any-repo.patch
0004-ver-make-quiet-output-suitable-for-scripting-piping.patch
0005-ver-show-all-packages-with-v.patch
"
url="http://git.alpinelinux.org/cgit/apk-tools/"
......@@ -61,5 +64,8 @@ luaapk() {
}
md5sums="e343935cc2680a42f3da0f442045f046 apk-tools-2.3.1.tar.bz2
cc7c61312f403280dcb4c04eca53df81 0001-db-strip-leading-and-trailing-slashes-from-protected.patch
1156d61cd9ea475ebac209e1dec1175f 0002-audit-apply-protected_paths.d-masks-to-individual-fi.patch"
e88cc45d942821dc7f222f1f4c1e6292 0001-db-strip-leading-and-trailing-slashes-from-protected.patch
ad846965eb7826818d27c083fda6cc60 0002-audit-apply-protected_paths.d-masks-to-individual-fi.patch
e4f00e434f66770cb28bbd4b1e97eb40 0003-ver-print-when-package-is-not-available-in-any-repo.patch
3474af2f6db2794a4a2075a9d9b5af64 0004-ver-make-quiet-output-suitable-for-scripting-piping.patch
be6b5f7298d625876ae0f4ae3a117d7c 0005-ver-show-all-packages-with-v.patch"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment