Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | From 721a660a507d6d062e7aecafad886c643970a5d5 Mon Sep 17 00:00:00 2001 |
| 2 | From: Alexander Kanavin <alex.kanavin@gmail.com> |
| 3 | Date: Thu, 25 May 2017 18:15:27 +0300 |
| 4 | Subject: [PATCH 1/4] Split binary package building into a separate function |
| 5 | |
| 6 | So that it can be run as a thread pool task. |
| 7 | |
| 8 | Upstream-Status: Submitted [https://github.com/rpm-software-management/rpm/pull/226] |
| 9 | Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> |
| 10 | |
| 11 | --- |
| 12 | build/pack.c | 33 +++++++++++++++++++++------------ |
| 13 | 1 file changed, 21 insertions(+), 12 deletions(-) |
| 14 | |
| 15 | diff --git a/build/pack.c b/build/pack.c |
| 16 | index 518f4e92a..ccfd614cc 100644 |
| 17 | --- a/build/pack.c |
| 18 | +++ b/build/pack.c |
| 19 | @@ -546,18 +546,13 @@ static rpmRC checkPackages(char *pkgcheck) |
| 20 | return RPMRC_OK; |
| 21 | } |
| 22 | |
| 23 | -rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating) |
| 24 | +static rpmRC packageBinary(rpmSpec spec, Package pkg, const char *cookie, int cheating, char** filename) |
| 25 | { |
| 26 | - rpmRC rc; |
| 27 | - const char *errorString; |
| 28 | - Package pkg; |
| 29 | - char *pkglist = NULL; |
| 30 | - |
| 31 | - for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) { |
| 32 | - char *fn; |
| 33 | + const char *errorString; |
| 34 | + rpmRC rc = RPMRC_OK; |
| 35 | |
| 36 | if (pkg->fileList == NULL) |
| 37 | - continue; |
| 38 | + return rc; |
| 39 | |
| 40 | if ((rc = processScriptFiles(spec, pkg))) |
| 41 | return rc; |
| 42 | @@ -587,7 +582,7 @@ rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating) |
| 43 | headerGetString(pkg->header, RPMTAG_NAME), errorString); |
| 44 | return RPMRC_FAIL; |
| 45 | } |
| 46 | - fn = rpmGetPath("%{_rpmdir}/", binRpm, NULL); |
| 47 | + *filename = rpmGetPath("%{_rpmdir}/", binRpm, NULL); |
| 48 | if ((binDir = strchr(binRpm, '/')) != NULL) { |
| 49 | struct stat st; |
| 50 | char *dn; |
| 51 | @@ -609,14 +604,28 @@ rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating) |
| 52 | free(binRpm); |
| 53 | } |
| 54 | |
| 55 | - rc = writeRPM(pkg, NULL, fn, NULL); |
| 56 | + rc = writeRPM(pkg, NULL, *filename, NULL); |
| 57 | if (rc == RPMRC_OK) { |
| 58 | /* Do check each written package if enabled */ |
| 59 | - char *pkgcheck = rpmExpand("%{?_build_pkgcheck} ", fn, NULL); |
| 60 | + char *pkgcheck = rpmExpand("%{?_build_pkgcheck} ", *filename, NULL); |
| 61 | if (pkgcheck[0] != ' ') { |
| 62 | rc = checkPackages(pkgcheck); |
| 63 | } |
| 64 | free(pkgcheck); |
| 65 | + } |
| 66 | + return rc; |
| 67 | +} |
| 68 | + |
| 69 | +rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating) |
| 70 | +{ |
| 71 | + rpmRC rc; |
| 72 | + Package pkg; |
| 73 | + char *pkglist = NULL; |
| 74 | + |
| 75 | + for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) { |
| 76 | + char *fn = NULL; |
| 77 | + rc = packageBinary(spec, pkg, cookie, cheating, &fn); |
| 78 | + if (rc == RPMRC_OK) { |
| 79 | rstrcat(&pkglist, fn); |
| 80 | rstrcat(&pkglist, " "); |
| 81 | } |
| 82 | -- |
| 83 | 2.11.0 |
| 84 | |