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
|
From 721a660a507d6d062e7aecafad886c643970a5d5 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Thu, 25 May 2017 18:15:27 +0300
Subject: [PATCH 1/4] Split binary package building into a separate function
So that it can be run as a thread pool task.
Upstream-Status: Submitted [https://github.com/rpm-software-management/rpm/pull/226]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
build/pack.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/build/pack.c b/build/pack.c
index 518f4e92a..ccfd614cc 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -546,18 +546,13 @@ static rpmRC checkPackages(char *pkgcheck)
return RPMRC_OK;
}
-rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating)
+static rpmRC packageBinary(rpmSpec spec, Package pkg, const char *cookie, int cheating, char** filename)
{
- rpmRC rc;
- const char *errorString;
- Package pkg;
- char *pkglist = NULL;
-
- for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
- char *fn;
+ const char *errorString;
+ rpmRC rc = RPMRC_OK;
if (pkg->fileList == NULL)
- continue;
+ return rc;
if ((rc = processScriptFiles(spec, pkg)))
return rc;
@@ -587,7 +582,7 @@ rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating)
headerGetString(pkg->header, RPMTAG_NAME), errorString);
return RPMRC_FAIL;
}
- fn = rpmGetPath("%{_rpmdir}/", binRpm, NULL);
+ *filename = rpmGetPath("%{_rpmdir}/", binRpm, NULL);
if ((binDir = strchr(binRpm, '/')) != NULL) {
struct stat st;
char *dn;
@@ -609,14 +604,28 @@ rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating)
free(binRpm);
}
- rc = writeRPM(pkg, NULL, fn, NULL);
+ rc = writeRPM(pkg, NULL, *filename, NULL);
if (rc == RPMRC_OK) {
/* Do check each written package if enabled */
- char *pkgcheck = rpmExpand("%{?_build_pkgcheck} ", fn, NULL);
+ char *pkgcheck = rpmExpand("%{?_build_pkgcheck} ", *filename, NULL);
if (pkgcheck[0] != ' ') {
rc = checkPackages(pkgcheck);
}
free(pkgcheck);
+ }
+ return rc;
+}
+
+rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating)
+{
+ rpmRC rc;
+ Package pkg;
+ char *pkglist = NULL;
+
+ for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
+ char *fn = NULL;
+ rc = packageBinary(spec, pkg, cookie, cheating, &fn);
+ if (rc == RPMRC_OK) {
rstrcat(&pkglist, fn);
rstrcat(&pkglist, " ");
}
--
2.11.0
|