summaryrefslogtreecommitdiff
blob: 3336a455794f4faeda69d0647fad74be35e2af26 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
https://github.com/pkgconf/pkgconf/issues/335
https://github.com/pkgconf/pkgconf/issues/332
https://github.com/pkgconf/pkgconf/issues/317
https://github.com/pkgconf/pkgconf/pull/336

https://github.com/pkgconf/pkgconf/commit/125af82dbe93eddadb7ec10eebac5087e9fbc451
https://github.com/pkgconf/pkgconf/commit/b2f8386c32d1cb4dfa8f51c619c0c2a56a3544d6
https://github.com/pkgconf/pkgconf/commit/5825e2c6d608ef74a97349e81d750ab95c53cf50

From 9a5c9be4ccef66a80df7533e00e525f87ff2fb01 Mon Sep 17 00:00:00 2001
From: Kai Pastor <dg0yt@darc.de>
Date: Fri, 1 Dec 2023 21:20:39 +0100
Subject: [PATCH 1/3] Test --modversion with constraint

--- a/tests/regress.sh
+++ b/tests/regress.sh
@@ -27,6 +27,9 @@ tests_init \
 	modversion_fullpath \
 	modversion_provides \
 	modversion_uninstalled \
+	modversion_one_word_expression \
+	modversion_two_word_expression \
+	modversion_three_word_expression \
 	pcpath \
 	virtual_variable \
 	fragment_collision \
@@ -301,3 +304,21 @@ modversion_uninstalled_body()
 	atf_check -o inline:"1.2.3\n" \
 		pkgconf --with-path="${selfdir}/lib1" --modversion omg
 }
+
+modversion_one_word_expression_body()
+{
+	atf_check -o inline:"1.2.3\n" \
+		pkgconf --with-path="${selfdir}/lib1" --modversion "foo > 1.0"
+}
+
+modversion_two_word_expression_body()
+{
+	atf_check -o inline:"1.2.3\n" \
+		pkgconf --with-path="${selfdir}/lib1" --modversion foo "> 1.0"
+}
+
+modversion_three_word_expression_body()
+{
+	atf_check -o inline:"1.2.3\n" \
+		pkgconf --with-path="${selfdir}/lib1" --modversion foo ">" 1.0
+}

From 0d4e6fa01074f5e540a7d89731edf44751bd17fc Mon Sep 17 00:00:00 2001
From: Kai Pastor <dg0yt@darc.de>
Date: Fri, 1 Dec 2023 21:50:46 +0100
Subject: [PATCH 2/3] Fix --modversion output

--- a/cli/main.c
+++ b/cli/main.c
@@ -333,7 +333,12 @@ apply_modversion(pkgconf_client_t *client, pkgconf_pkg_t *world, void *data, int
 			pkgconf_dependency_t *dep = world_iter->data;
 			pkgconf_pkg_t *pkg = dep->match;
 
-			if (strcmp(pkg->why, queue_node->package))
+			const size_t name_len = strlen(pkg->why);
+			if (name_len > strlen(queue_node->package) ||
+			    strncmp(pkg->why, queue_node->package, name_len) ||
+			    (queue_node->package[name_len] != 0 &&
+			     !isspace(queue_node->package[name_len]) &&
+			     !PKGCONF_IS_OPERATOR_CHAR(queue_node->package[name_len])))
 				continue;
 
 			if (pkg->version != NULL) {

From ace73a690437488baea28130c98f0b1eaab4689e Mon Sep 17 00:00:00 2001
From: Kai Pastor <dg0yt@darc.de>
Date: Fri, 1 Dec 2023 22:12:20 +0100
Subject: [PATCH 3/3] Fix crash on two-word expressions

--- a/cli/main.c
+++ b/cli/main.c
@@ -1405,6 +1405,15 @@ main(int argc, char *argv[])
 			pkgconf_queue_push(&pkgq, package);
 			pkg_optind++;
 		}
+		else if (argv[pkg_optind + 2] == NULL)
+		{
+			char packagebuf[PKGCONF_BUFSIZE];
+
+			snprintf(packagebuf, sizeof packagebuf, "%s %s", package, argv[pkg_optind + 1]);
+			pkg_optind += 2;
+
+			pkgconf_queue_push(&pkgq, packagebuf);
+		}
 		else
 		{
 			char packagebuf[PKGCONF_BUFSIZE];