aboutsummaryrefslogtreecommitdiffstats
path: root/main/apk-tools/0001-apk-new-option-print-arch.patch
blob: 095c96f8d22b577612e884316eff2499e79ea9c6 (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
42
43
44
45
46
47
48
49
From b06a43a465f596289c73be8dc7eb6cd732a27114 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Mon, 6 Jan 2014 10:51:17 +0100
Subject: [PATCH] apk: new option --print-arch

Simply print the default arch and exit.
This is so scripts don't need to parse the output of -V.
---
 src/apk.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/apk.c b/src/apk.c
index 8a3c7ef..6cd01de 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -70,6 +70,7 @@ static struct apk_option generic_options[] = {
 	{ 0x111, "overlay-from-stdin", "Read list of overlay files from stdin" },
 	{ 0x112, "arch",	"Use architecture with --root",
 				required_argument, "ARCH" },
+	{ 0x114, "print-arch",	"Print default arch and exit" },
 #ifdef TEST_MODE
 	{ 0x200, "test-repo",	"Repository", required_argument, "REPO" },
 	{ 0x201, "test-instdb",	"Installed db", required_argument, "INSTALLED" },
@@ -86,6 +87,12 @@ static int version(void)
 	return 0;
 }
 
+static int show_arch(void)
+{
+	puts(APK_DEFAULT_ARCH);
+	return 0;
+}
+
 static int format_option(char *buf, size_t len, struct apk_option *o,
 			 const char *separator)
 {
@@ -418,6 +425,9 @@ int main(int argc, char **argv)
 		case 0x112:
 			dbopts.arch = optarg;
 			break;
+		case 0x114:
+			r = show_arch();
+			goto err;
 #ifdef TEST_MODE
 		case 0x200:
 			*apk_string_array_add(&test_repos) = (char*) optarg;
-- 
1.8.5.2