summaryrefslogtreecommitdiffstats
path: root/main/apk-tools/0003-ver-print-when-package-is-not-available-in-any-repo.patch
blob: 6d589c61aea273c33a589123d6b5be405cafc79b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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