Add rpm2 recipe to build python2-rpm

Hacking the install task to release python2-rpm only
Issue-ID: 31
Signed-off-by: Bin Yang <bin.yang@windriver.com>
This commit is contained in:
Bin Yang 2019-12-24 11:11:56 +08:00 committed by Sar Ashki, Babak
parent 8100180ac2
commit e8c21e171c
17 changed files with 1430 additions and 0 deletions

View File

@ -200,6 +200,7 @@ RDEPENDS_packagegroup-stx-ceph = "\
python3-netaddr \
python3-keyring \
python3-rpm \
python2-rpm \
python-oslo.messaging \
python-keyring \
python-cephclient \

View File

@ -0,0 +1,40 @@
From e3eff024826550aec4a6a5baef7210a29faf299d Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Thu, 9 Mar 2017 18:54:02 +0200
Subject: [PATCH] Add a color setting for mips64_n32 binaries
Upstream-Status: Inappropriate [oe-core specific]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
build/rpmfc.c | 1 +
rpmrc.in | 2 ++
2 files changed, 3 insertions(+)
diff --git a/build/rpmfc.c b/build/rpmfc.c
index d38a10916..c8e2f876a 100644
--- a/build/rpmfc.c
+++ b/build/rpmfc.c
@@ -622,6 +622,7 @@ exit:
static const struct rpmfcTokens_s rpmfcTokens[] = {
{ "directory", RPMFC_INCLUDE },
+ { "N32 MIPS64", RPMFC_ELFMIPSN32|RPMFC_INCLUDE },
{ "ELF 32-bit", RPMFC_ELF32|RPMFC_INCLUDE },
{ "ELF 64-bit", RPMFC_ELF64|RPMFC_INCLUDE },
diff --git a/rpmrc.in b/rpmrc.in
index abc08fc31..f5bc820d8 100644
--- a/rpmrc.in
+++ b/rpmrc.in
@@ -133,6 +133,8 @@ archcolor: mipsr6el 1
archcolor: mips64r6 2
archcolor: mips64r6el 2
+archcolor: mips64_n32 4
+
archcolor: m68k 1
archcolor: m68kmint 1
--
2.11.0

View File

@ -0,0 +1,33 @@
From 87cfc0db1ed6fe381a5ed5f0016d8c3344a31a11 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Mon, 9 Jan 2017 18:52:11 +0200
Subject: [PATCH] Do not add an unsatisfiable dependency when building rpms in
a short-circuited way.
Upstream permits short-circuiting only for local testing; Yocto on the other
hand produces rpms that way by design.
Upstream-Status: Inappropriate [oe-core specific]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
build/pack.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/build/pack.c b/build/pack.c
index 1261cdbba..bb2d6f4f6 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -595,10 +595,6 @@ rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating)
headerPutBin(pkg->header, RPMTAG_SOURCEPKGID, spec->sourcePkgId,16);
}
- if (cheating) {
- (void) rpmlibNeedsFeature(pkg, "ShortCircuited", "4.9.0-1");
- }
-
{ char *binFormat = rpmGetPath("%{_rpmfilename}", NULL);
char *binRpm, *binDir;
binRpm = headerFormat(pkg->header, binFormat, &errorString);
--
2.11.0

View File

@ -0,0 +1,58 @@
From bd08eb0ae1312f347f49949481daa7c923752df2 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Mon, 27 Feb 2017 09:43:30 +0200
Subject: [PATCH] Do not hardcode "lib/rpm" as the installation path for
default configuration and macros.
Upstream-Status: Denied [https://github.com/rpm-software-management/rpm/pull/263]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
configure.ac | 2 +-
macros.in | 2 +-
rpm.am | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index 09af7c4..9bd6903 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1055,7 +1055,7 @@ else
usrprefix=$prefix
fi
-RPMCONFIGDIR="`echo ${usrprefix}/lib/rpm`"
+RPMCONFIGDIR="`echo ${libdir}/rpm`"
AC_SUBST(RPMCONFIGDIR)
AC_SUBST(OBJDUMP)
diff --git a/macros.in b/macros.in
index a3aa7a9..62cee5c 100644
--- a/macros.in
+++ b/macros.in
@@ -970,7 +970,7 @@ package or when debugging this package.\
%_sharedstatedir %{_prefix}/com
%_localstatedir %{_prefix}/var
%_lib lib
-%_libdir %{_exec_prefix}/%{_lib}
+%_libdir @libdir@
%_includedir %{_prefix}/include
%_infodir %{_datadir}/info
%_mandir %{_datadir}/man
diff --git a/rpm.am b/rpm.am
index 82c2d7c..6341b51 100644
--- a/rpm.am
+++ b/rpm.am
@@ -1,10 +1,10 @@
# Internal binaries
## HACK: It probably should be $(libexecdir)/rpm or $(libdir)/rpm
-rpmlibexecdir = $(prefix)/lib/rpm
+rpmlibexecdir = $(libdir)/rpm
# Host independent config files
## HACK: it probably should be $(datadir)/rpm
-rpmconfigdir = $(prefix)/lib/rpm
+rpmconfigdir = $(libdir)/rpm
# Libtool version (current-revision-age) for all our libraries
rpm_version_info = 9:0:1

View File

@ -0,0 +1,38 @@
From 35381b6cd6c1b571bf7e6b0640de0f54dbf94386 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Tue, 10 Jan 2017 14:11:30 +0200
Subject: [PATCH] Do not read config files from $HOME
Upstream-Status: Inappropriate [oe-core specific]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
lib/rpmrc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/lib/rpmrc.c b/lib/rpmrc.c
index 4ed991321..19fe80f98 100644
--- a/lib/rpmrc.c
+++ b/lib/rpmrc.c
@@ -458,8 +458,7 @@ static void setDefaults(void)
if (!defrcfiles) {
defrcfiles = rstrscat(NULL, confdir, "/rpmrc", ":",
confdir, "/" RPMCANONVENDOR "/rpmrc", ":",
- SYSCONFDIR "/rpmrc", ":",
- "~/.rpmrc", NULL);
+ SYSCONFDIR "/rpmrc", ":");
}
#ifndef MACROFILES
@@ -471,8 +470,7 @@ static void setDefaults(void)
confdir, "/" RPMCANONVENDOR "/macros", ":",
SYSCONFDIR "/rpm/macros.*", ":",
SYSCONFDIR "/rpm/macros", ":",
- SYSCONFDIR "/rpm/%{_target}/macros", ":",
- "~/.rpmmacros", NULL);
+ SYSCONFDIR "/rpm/%{_target}/macros", ":");
}
#else
macrofiles = MACROFILES;
--
2.11.0

View File

@ -0,0 +1,28 @@
From a674b9cc7af448d7c6748bc163bf37dc14a57f09 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Fri, 20 Jan 2017 13:32:06 +0200
Subject: [PATCH] Do not reset the PATH environment variable before running
scriptlets.
We add lots of native stuff into it and scriptlets rely on that.
Upstream-Status: Inappropriate [oe-core specific]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
lib/rpmscript.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/rpmscript.c b/lib/rpmscript.c
index 6a31e0d..2b0e438 100644
--- a/lib/rpmscript.c
+++ b/lib/rpmscript.c
@@ -184,7 +184,7 @@ static void doScriptExec(ARGV_const_t argv, ARGV_const_t prefixes,
if (ipath && ipath[5] != '%')
path = ipath;
- xx = setenv("PATH", path, 1);
+ //xx = setenv("PATH", path, 1);
free(ipath);
}

View File

@ -0,0 +1,48 @@
From d076de030deb9cafd9b2e82be5d506cebdefad0b Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Mon, 27 Feb 2017 14:43:21 +0200
Subject: [PATCH 1/9] Fix build with musl C library.
Upstream-Status: Pending
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
configure.ac | 3 ++-
rpmio/digest_nss.c | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index c04a2e8d1..c9d9ac16d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -255,6 +255,7 @@ AC_SEARCH_LIBS(dlopen, [dl])
# Check for libelf library. Prefer external, otherwise none.
WITH_LIBELF_LIB=
AC_CHECK_HEADER([libelf.h])
+AC_CHECK_HEADERS([error.h], [WITH_ERROR_H=yes])
AC_CHECK_HEADERS([gelf.h], [
AC_CHECK_LIB(elf, gelf_getvernaux, [
AC_DEFINE(HAVE_LIBELF, 1, [Define to 1 if you have the 'elf' library (-lelf).])
@@ -263,7 +264,7 @@ AC_CHECK_HEADERS([gelf.h], [
])
])
AC_SUBST(WITH_LIBELF_LIB)
-AM_CONDITIONAL(LIBELF,[test "$WITH_LIBELF" = yes])
+AM_CONDITIONAL(LIBELF,[test "$WITH_LIBELF" = yes && test "$WITH_ERROR_H" = yes])
AC_CHECK_HEADERS([dwarf.h], [
WITH_LIBDWARF=yes
diff --git a/rpmio/digest_nss.c b/rpmio/digest_nss.c
index 992d9acf6..e11920e3e 100644
--- a/rpmio/digest_nss.c
+++ b/rpmio/digest_nss.c
@@ -1,5 +1,6 @@
#include "system.h"
+#include <signal.h>
#include <pthread.h>
#include <nss.h>
#include <sechash.h>
--
2.14.2

View File

@ -0,0 +1,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

View File

@ -0,0 +1,62 @@
From a89daa75ac970d8e247edc762d1181e9a5b0c5d0 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Tue, 17 Jan 2017 14:07:17 +0200
Subject: [PATCH] When cross-installing, execute package scriptlets without
chrooting into destination rootfs
This is triggered only when RPM_NO_CHROOT_FOR_SCRIPTS environment variable is defined.
Otherwise they will trigger an explosion of failures, obviously.
Amended 2018-07-03 by Olof Johansson <olofjn@axis.com>:
Remove leaking temporary scriptlet files
Since we tell dnf to run rpm with debug output, this will result in rpm not
cleaning up written temporary scriptlet files (same flag controls both
behaviors). This wouldn't have been a problem since we normally would use the
target sysroot also for temporary files, but we need to chroot out to be able
to actually run the rpm scriptlets (purpose of this patch), so the temporary
files are written to the host's /var/tmp/ directory, causing a gradual
resource leakage on the host system for every RPM based do_rootfs task
executed.
Signed-off-by: Olof Johansson <olofjn@axis.com>
Upstream-Status: Inappropriate [oe-core specific]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
lib/rpmscript.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/rpmscript.c b/lib/rpmscript.c
index cc98c4885..f8bd3df04 100644
--- a/lib/rpmscript.c
+++ b/lib/rpmscript.c
@@ -394,8 +394,7 @@ exit:
Fclose(out); /* XXX dup'd STDOUT_FILENO */
if (fn) {
- if (!rpmIsDebug())
- unlink(fn);
+ unlink(fn);
free(fn);
}
free(mline);
@@ -428,7 +427,13 @@ rpmRC rpmScriptRun(rpmScript script, int arg1, int arg2, FD_t scriptFd,
if (rc != RPMRC_FAIL) {
if (script_type & RPMSCRIPTLET_EXEC) {
- rc = runExtScript(plugins, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2, &script->nextFileFunc);
+ if (getenv("RPM_NO_CHROOT_FOR_SCRIPTS") != NULL) {
+ rpmChrootOut();
+ rc = runExtScript(plugins, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2, &script->nextFileFunc);
+ rpmChrootIn();
+ } else {
+ rc = runExtScript(plugins, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2, &script->nextFileFunc);
+ }
} else {
rc = runLuaScript(plugins, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2, &script->nextFileFunc);
}
--
2.11.0

View File

@ -0,0 +1,32 @@
perl: disable auto requires
When generating automatic requirements, it's possible for perl scripts to
declare 'optional' dependencies. These seem to often be incorrect and will
cause installation failures in OE. Instead of fixing the perl scripts, it
was decided it is better to simply disable the automatic dependency
generation. This matches the behavior from the previous RPM5 implementation.
Upstream-Status: Inappropriate [OE specific configuration]
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Index: git/fileattrs/perl.attr
===================================================================
--- git.orig/fileattrs/perl.attr
+++ git/fileattrs/perl.attr
@@ -1,3 +1,3 @@
-%__perl_requires %{_rpmconfigdir}/perl.req
+#__perl_requires %{_rpmconfigdir}/perl.req
%__perl_magic ^.*[Pp]erl .*$
%__perl_flags exeonly
Index: git/fileattrs/perllib.attr
===================================================================
--- git.orig/fileattrs/perllib.attr
+++ git/fileattrs/perllib.attr
@@ -1,5 +1,5 @@
%__perllib_provides %{_rpmconfigdir}/perl.prov
-%__perllib_requires %{_rpmconfigdir}/perl.req
+#__perllib_requires %{_rpmconfigdir}/perl.req
%__perllib_magic ^Perl[[:digit:]] module source.*
%__perllib_path \\.pm$
%__perllib_flags magic_and_path

View File

@ -0,0 +1,65 @@
From 0066b862bb3a09f39295abd5d972a53ac8dc1555 Mon Sep 17 00:00:00 2001
From: Peter Bergin <peter@berginkonsult.se>
Date: Wed, 19 Sep 2018 15:12:31 +0200
Subject: [PATCH] rpm/rpmio.c: restrict virtual memory usage if limit set
A solution to avoid OOM situation when the virtual memory is restricted
for a user (ulimit -v). As the lzopen_internal function is run in parallel
one instance per CPU thread the available virtual memory is limited per
CPU thread.
Upstream-Status: Pending [merge of multithreading patches to upstream]
Signed-off-by: Peter Bergin <peter@berginkonsult.se>
---
rpmio/rpmio.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c
index e051c98..b3c56b6 100644
--- a/rpmio/rpmio.c
+++ b/rpmio/rpmio.c
@@ -845,6 +845,40 @@ static LZFILE *lzopen_internal(const char *mode, int fd, int xz)
}
#endif
+ struct rlimit virtual_memory;
+ getrlimit(RLIMIT_AS, &virtual_memory);
+ if (virtual_memory.rlim_cur != RLIM_INFINITY) {
+ const uint64_t virtual_memlimit = virtual_memory.rlim_cur;
+ const uint64_t virtual_memlimit_per_cpu_thread =
+ virtual_memlimit / lzma_cputhreads();
+ uint64_t memory_usage_virt;
+ rpmlog(RPMLOG_NOTICE, "XZ: virtual memory restricted to %lu and "
+ "per CPU thread %lu\n", virtual_memlimit, virtual_memlimit_per_cpu_thread);
+ /* keep reducing the number of compression threads until memory
+ usage falls below the limit per CPU thread*/
+ while ((memory_usage_virt = lzma_stream_encoder_mt_memusage(&mt_options)) >
+ virtual_memlimit_per_cpu_thread) {
+ /* If number of threads goes down to zero lzma_stream_encoder will
+ * will return UINT64_MAX. We must check here to avoid an infinite loop.
+ * If we get into situation that one thread requires more virtual memory
+ * than available we set one thread, print error message and try anyway. */
+ if (--mt_options.threads == 0) {
+ mt_options.threads = 1;
+ rpmlog(RPMLOG_WARNING,
+ "XZ: Could not adjust number of threads to get below "
+ "virtual memory limit %lu. usage %lu\n",
+ virtual_memlimit_per_cpu_thread, memory_usage_virt);
+ break;
+ }
+ }
+ if (threads != (int)mt_options.threads)
+ rpmlog(RPMLOG_NOTICE,
+ "XZ: Adjusted the number of threads from %d to %d to not "
+ "exceed the memory usage limit of %lu bytes\n",
+ threads, mt_options.threads, virtual_memlimit);
+
+ }
+
ret = lzma_stream_encoder_mt(&lzfile->strm, &mt_options);
}
#endif
--
2.7.4

View File

@ -0,0 +1,72 @@
From 383c0b097b7eba16801a9e3c4b8e36a4b6de74ab Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Fri, 20 Jan 2017 13:33:05 +0200
Subject: [PATCH 2/2] Add support for prefixing /etc from RPM_ETCCONFIGDIR
environment variable
This is needed so that rpm can pick up target-specific configuration
from target rootfs instead of its own native sysroot.
Upstream-Status: Inappropriate [oe-core specific]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
lib/rpmrc.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/lib/rpmrc.c b/lib/rpmrc.c
index 19fe80f98..6b27b3941 100644
--- a/lib/rpmrc.c
+++ b/lib/rpmrc.c
@@ -455,10 +455,14 @@ const char * lookupInDefaultTable(const char * name,
static void setDefaults(void)
{
const char *confdir = rpmConfigDir();
+ const char *etcconfdir = getenv("RPM_ETCCONFIGDIR");
+ if (etcconfdir == NULL)
+ etcconfdir = "";
+
if (!defrcfiles) {
defrcfiles = rstrscat(NULL, confdir, "/rpmrc", ":",
confdir, "/" RPMCANONVENDOR "/rpmrc", ":",
- SYSCONFDIR "/rpmrc", ":");
+ etcconfdir, SYSCONFDIR "/rpmrc", ":", NULL);
}
#ifndef MACROFILES
@@ -468,9 +472,9 @@ static void setDefaults(void)
confdir, "/platform/%{_target}/macros", ":",
confdir, "/fileattrs/*.attr", ":",
confdir, "/" RPMCANONVENDOR "/macros", ":",
- SYSCONFDIR "/rpm/macros.*", ":",
- SYSCONFDIR "/rpm/macros", ":",
- SYSCONFDIR "/rpm/%{_target}/macros", ":");
+ etcconfdir, SYSCONFDIR "/rpm/macros.*", ":",
+ etcconfdir, SYSCONFDIR "/rpm/macros", ":",
+ etcconfdir, SYSCONFDIR "/rpm/%{_target}/macros", ":", NULL);
}
#else
macrofiles = MACROFILES;
@@ -989,7 +993,11 @@ static void read_auxv(void)
*/
static void defaultMachine(rpmrcCtx ctx, const char ** arch, const char ** os)
{
- const char * const platform_path = SYSCONFDIR "/rpm/platform";
+ const char *etcconfdir = getenv("RPM_ETCCONFIGDIR");
+ if (etcconfdir == NULL)
+ etcconfdir = "";
+
+ const char * const platform_path = rstrscat(NULL, etcconfdir, SYSCONFDIR "/rpm/platform", NULL);
static struct utsname un;
char * chptr;
canonEntry canon;
@@ -1286,6 +1294,7 @@ static void defaultMachine(rpmrcCtx ctx, const char ** arch, const char ** os)
if (arch) *arch = un.machine;
if (os) *os = un.sysname;
+ free(platform_path);
}
static
--
2.11.0

View File

@ -0,0 +1,127 @@
From 513200cf76758de4668312c628d6362bdabfaf4b Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Thu, 25 May 2017 19:30:20 +0300
Subject: [PATCH 1/3] Run binary package creation via thread pools.
Upstream-Status: Submitted [https://github.com/rpm-software-management/rpm/pull/226]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
build/pack.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++-----------
configure.ac | 3 +++
2 files changed, 70 insertions(+), 14 deletions(-)
diff --git a/build/pack.c b/build/pack.c
index ccfd614cc..ed5b9ab4e 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -616,25 +616,78 @@ static rpmRC packageBinary(rpmSpec spec, Package pkg, const char *cookie, int ch
return rc;
}
-rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating)
+struct binaryPackageTaskData
{
- rpmRC rc;
Package pkg;
+ char *filename;
+ rpmRC result;
+ struct binaryPackageTaskData *next;
+};
+
+static struct binaryPackageTaskData* runBinaryPackageTasks(rpmSpec spec, const char *cookie, int cheating)
+{
+ struct binaryPackageTaskData *tasks = NULL;
+ struct binaryPackageTaskData *task = NULL;
+ struct binaryPackageTaskData *prev = NULL;
+
+ for (Package pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
+ task = rcalloc(1, sizeof(*task));
+ task->pkg = pkg;
+ if (pkg == spec->packages) {
+ // the first package needs to be processed ahead of others, as they copy
+ // changelog data from it, and so otherwise data races would happen
+ task->result = packageBinary(spec, pkg, cookie, cheating, &(task->filename));
+ rpmlog(RPMLOG_NOTICE, _("Finished binary package job, result %d, filename %s\n"), task->result, task->filename);
+ tasks = task;
+ }
+ if (prev != NULL) {
+ prev->next = task;
+ }
+ prev = task;
+ }
+
+ #pragma omp parallel
+ #pragma omp single
+ // re-declaring task variable is necessary, or older gcc versions will produce code that segfaults
+ for (struct binaryPackageTaskData *task = tasks; task != NULL; task = task->next) {
+ if (task != tasks)
+ #pragma omp task
+ {
+ task->result = packageBinary(spec, task->pkg, cookie, cheating, &(task->filename));
+ rpmlog(RPMLOG_NOTICE, _("Finished binary package job, result %d, filename %s\n"), task->result, task->filename);
+ }
+ }
+
+ return tasks;
+}
+
+static void freeBinaryPackageTasks(struct binaryPackageTaskData* tasks)
+{
+ while (tasks != NULL) {
+ struct binaryPackageTaskData* next = tasks->next;
+ rfree(tasks->filename);
+ rfree(tasks);
+ tasks = next;
+ }
+}
+
+rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating)
+{
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, " ");
- }
- free(fn);
- if (rc != RPMRC_OK) {
- pkglist = _free(pkglist);
- return rc;
- }
+ struct binaryPackageTaskData *tasks = runBinaryPackageTasks(spec, cookie, cheating);
+
+ for (struct binaryPackageTaskData *task = tasks; task != NULL; task = task->next) {
+ if (task->result == RPMRC_OK) {
+ rstrcat(&pkglist, task->filename);
+ rstrcat(&pkglist, " ");
+ } else {
+ _free(pkglist);
+ freeBinaryPackageTasks(tasks);
+ return RPMRC_FAIL;
+ }
}
+ freeBinaryPackageTasks(tasks);
/* Now check the package set if enabled */
if (pkglist != NULL) {
diff --git a/configure.ac b/configure.ac
index a506ec819..59fa0acaf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,6 +17,9 @@ AC_DISABLE_STATIC
PKG_PROG_PKG_CONFIG
+AC_OPENMP
+RPMCFLAGS="$OPENMP_CFLAGS $RPMCFLAGS"
+
dnl Checks for programs.
AC_PROG_CXX
AC_PROG_AWK
--
2.11.0

View File

@ -0,0 +1,207 @@
From c80892f17e44331206c8318d53b63bb6a99554d0 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Tue, 30 May 2017 13:58:30 +0300
Subject: [PATCH 3/4] rpmstrpool.c: make operations over string pools
thread-safe
Otherwise multithreaded rpm building explodes in various ways due
to data races.
Upstream-Status: Submitted [https://github.com/rpm-software-management/rpm/pull/226]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
rpmio/rpmstrpool.c | 56 +++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 47 insertions(+), 9 deletions(-)
diff --git a/rpmio/rpmstrpool.c b/rpmio/rpmstrpool.c
index 30a57eb10..58ba95a02 100644
--- a/rpmio/rpmstrpool.c
+++ b/rpmio/rpmstrpool.c
@@ -113,6 +113,8 @@ static poolHash poolHashCreate(int numBuckets)
return ht;
}
+static const char * rpmstrPoolStrNoLock(rpmstrPool pool, rpmsid sid);
+
static void poolHashResize(rpmstrPool pool, int numBuckets)
{
poolHash ht = pool->hash;
@@ -120,7 +122,7 @@ static void poolHashResize(rpmstrPool pool, int numBuckets)
for (int i=0; i<ht->numBuckets; i++) {
if (!ht->buckets[i].keyid) continue;
- unsigned int keyHash = rstrhash(rpmstrPoolStr(pool, ht->buckets[i].keyid));
+ unsigned int keyHash = rstrhash(rpmstrPoolStrNoLock(pool, ht->buckets[i].keyid));
for (unsigned int j=0;;j++) {
unsigned int hash = hashbucket(keyHash, j) % numBuckets;
if (!buckets[hash].keyid) {
@@ -149,7 +151,7 @@ static void poolHashAddHEntry(rpmstrPool pool, const char * key, unsigned int ke
ht->buckets[hash].keyid = keyid;
ht->keyCount++;
break;
- } else if (!strcmp(rpmstrPoolStr(pool, ht->buckets[hash].keyid), key)) {
+ } else if (!strcmp(rpmstrPoolStrNoLock(pool, ht->buckets[hash].keyid), key)) {
return;
}
}
@@ -191,7 +193,7 @@ static void poolHashPrintStats(rpmstrPool pool)
int maxcollisions = 0;
for (i=0; i<ht->numBuckets; i++) {
- unsigned int keyHash = rstrhash(rpmstrPoolStr(pool, ht->buckets[i].keyid));
+ unsigned int keyHash = rstrhash(rpmstrPoolStrNoLock(pool, ht->buckets[i].keyid));
for (unsigned int j=0;;j++) {
unsigned int hash = hashbucket(keyHash, i) % ht->numBuckets;
if (hash==i) {
@@ -221,7 +223,7 @@ static void rpmstrPoolRehash(rpmstrPool pool)
pool->hash = poolHashCreate(sizehint);
for (int i = 1; i <= pool->offs_size; i++)
- poolHashAddEntry(pool, rpmstrPoolStr(pool, i), i);
+ poolHashAddEntry(pool, rpmstrPoolStrNoLock(pool, i), i);
}
rpmstrPool rpmstrPoolCreate(void)
@@ -245,6 +247,8 @@ rpmstrPool rpmstrPoolCreate(void)
rpmstrPool rpmstrPoolFree(rpmstrPool pool)
{
+ #pragma omp critical(rpmstrpool)
+ {
if (pool) {
if (pool->nrefs > 1) {
pool->nrefs--;
@@ -260,18 +264,24 @@ rpmstrPool rpmstrPoolFree(rpmstrPool pool)
free(pool);
}
}
+ }
return NULL;
}
rpmstrPool rpmstrPoolLink(rpmstrPool pool)
{
+ #pragma omp critical(rpmstrpool)
+ {
if (pool)
pool->nrefs++;
+ }
return pool;
}
void rpmstrPoolFreeze(rpmstrPool pool, int keephash)
{
+ #pragma omp critical(rpmstrpool)
+ {
if (pool && !pool->frozen) {
if (!keephash) {
pool->hash = poolHashFree(pool->hash);
@@ -281,16 +291,20 @@ void rpmstrPoolFreeze(rpmstrPool pool, int keephash)
pool->offs_alloced * sizeof(*pool->offs));
pool->frozen = 1;
}
+ }
}
void rpmstrPoolUnfreeze(rpmstrPool pool)
{
+ #pragma omp critical(rpmstrpool)
+ {
if (pool) {
if (pool->hash == NULL) {
rpmstrPoolRehash(pool);
}
pool->frozen = 0;
}
+ }
}
static rpmsid rpmstrPoolPut(rpmstrPool pool, const char *s, size_t slen, unsigned int hash)
@@ -350,7 +364,7 @@ static rpmsid rpmstrPoolGet(rpmstrPool pool, const char * key, size_t keylen,
return 0;
}
- s = rpmstrPoolStr(pool, ht->buckets[hash].keyid);
+ s = rpmstrPoolStrNoLock(pool, ht->buckets[hash].keyid);
/* pool string could be longer than keylen, require exact matche */
if (strncmp(s, key, keylen) == 0 && s[keylen] == '\0')
return ht->buckets[hash].keyid;
@@ -373,27 +387,31 @@ static inline rpmsid strn2id(rpmstrPool pool, const char *s, size_t slen,
rpmsid rpmstrPoolIdn(rpmstrPool pool, const char *s, size_t slen, int create)
{
rpmsid sid = 0;
-
+ #pragma omp critical(rpmstrpool)
+ {
if (s != NULL) {
unsigned int hash = rstrnhash(s, slen);
sid = strn2id(pool, s, slen, hash, create);
}
+ }
return sid;
}
rpmsid rpmstrPoolId(rpmstrPool pool, const char *s, int create)
{
rpmsid sid = 0;
-
+ #pragma omp critical(rpmstrpool)
+ {
if (s != NULL) {
size_t slen;
unsigned int hash = rstrlenhash(s, &slen);
sid = strn2id(pool, s, slen, hash, create);
}
+ }
return sid;
}
-const char * rpmstrPoolStr(rpmstrPool pool, rpmsid sid)
+static const char * rpmstrPoolStrNoLock(rpmstrPool pool, rpmsid sid)
{
const char *s = NULL;
if (pool && sid > 0 && sid <= pool->offs_size)
@@ -401,12 +419,25 @@ const char * rpmstrPoolStr(rpmstrPool pool, rpmsid sid)
return s;
}
+const char * rpmstrPoolStr(rpmstrPool pool, rpmsid sid)
+{
+ const char *s = NULL;
+ #pragma omp critical(rpmstrpool)
+ {
+ s = rpmstrPoolStrNoLock(pool, sid);
+ }
+ return s;
+}
+
size_t rpmstrPoolStrlen(rpmstrPool pool, rpmsid sid)
{
size_t slen = 0;
+ #pragma omp critical(rpmstrpool)
+ {
if (pool && sid > 0 && sid <= pool->offs_size) {
slen = strlen(pool->offs[sid]);
}
+ }
return slen;
}
@@ -421,5 +452,12 @@ int rpmstrPoolStreq(rpmstrPool poolA, rpmsid sidA,
rpmsid rpmstrPoolNumStr(rpmstrPool pool)
{
- return (pool != NULL) ? pool->offs_size : 0;
+ rpmsid id = 0;
+ #pragma omp critical(rpmstrpool)
+ {
+ if (pool) {
+ id = pool->offs_size;
+ }
+ }
+ return id;
}
--
2.11.0

View File

@ -0,0 +1,336 @@
From 792693bb90768cfde4898e8dd31ee1b5de803d2f Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Thu, 8 Jun 2017 17:08:09 +0300
Subject: [PATCH] build/pack.c: remove static local variables from buildHost()
and getBuildTime()
Their use is causing difficult to diagnoze data races when building multiple
packages in parallel, and is a bad idea in general, as it also makes it more
difficult to reason about code.
Upstream-Status: Submitted [https://github.com/rpm-software-management/rpm/pull/226]
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
build/build.c | 54 ++++++++++++++++++++++++++++--
build/pack.c | 84 +++++++++--------------------------------------
build/rpmbuild_internal.h | 8 +++--
3 files changed, 74 insertions(+), 72 deletions(-)
diff --git a/build/build.c b/build/build.c
index 13c3df2..b154f08 100644
--- a/build/build.c
+++ b/build/build.c
@@ -6,6 +6,8 @@
#include "system.h"
#include <errno.h>
+#include <netdb.h>
+#include <time.h>
#include <sys/wait.h>
#include <rpm/rpmlog.h>
@@ -16,6 +18,50 @@
#include "debug.h"
+static rpm_time_t getBuildTime(void)
+{
+ rpm_time_t buildTime = 0;
+ char *srcdate;
+ time_t epoch;
+ char *endptr;
+
+ srcdate = getenv("SOURCE_DATE_EPOCH");
+ if (srcdate) {
+ errno = 0;
+ epoch = strtol(srcdate, &endptr, 10);
+ if (srcdate == endptr || *endptr || errno != 0)
+ rpmlog(RPMLOG_ERR, _("unable to parse SOURCE_DATE_EPOCH\n"));
+ else
+ buildTime = (int32_t) epoch;
+ } else
+ buildTime = (int32_t) time(NULL);
+
+ return buildTime;
+}
+
+static char * buildHost(void)
+{
+ char* hostname;
+ struct hostent *hbn;
+ char *bhMacro;
+
+ bhMacro = rpmExpand("%{?_buildhost}", NULL);
+ if (strcmp(bhMacro, "") != 0) {
+ rasprintf(&hostname, "%s", bhMacro);
+ } else {
+ hostname = rcalloc(1024, sizeof(*hostname));
+ (void) gethostname(hostname, 1024);
+ hbn = gethostbyname(hostname);
+ if (hbn)
+ strcpy(hostname, hbn->h_name);
+ else
+ rpmlog(RPMLOG_WARNING,
+ _("Could not canonicalize hostname: %s\n"), hostname);
+ }
+ free(bhMacro);
+ return(hostname);
+}
+
/**
*/
static rpmRC doRmSource(rpmSpec spec)
@@ -201,6 +247,9 @@ static rpmRC buildSpec(BTA_t buildArgs, rpmSpec spec, int what)
rpmRC rc = RPMRC_OK;
int test = (what & RPMBUILD_NOBUILD);
char *cookie = buildArgs->cookie ? xstrdup(buildArgs->cookie) : NULL;
+ const char* host = buildHost();
+ rpm_time_t buildTime = getBuildTime();
+
if (rpmExpandNumeric("%{?source_date_epoch_from_changelog}") &&
getenv("SOURCE_DATE_EPOCH") == NULL) {
@@ -269,11 +318,11 @@ static rpmRC buildSpec(BTA_t buildArgs, rpmSpec spec, int what)
goto exit;
if (((what & RPMBUILD_PACKAGESOURCE) && !test) &&
- (rc = packageSources(spec, &cookie)))
+ (rc = packageSources(spec, &cookie, buildTime, host)))
goto exit;
if (((what & RPMBUILD_PACKAGEBINARY) && !test) &&
- (rc = packageBinaries(spec, cookie, (didBuild == 0))))
+ (rc = packageBinaries(spec, cookie, (didBuild == 0), buildTime, host)))
goto exit;
if ((what & RPMBUILD_CLEAN) &&
@@ -293,6 +342,7 @@ static rpmRC buildSpec(BTA_t buildArgs, rpmSpec spec, int what)
(void) unlink(spec->specFile);
exit:
+ free(host);
free(cookie);
spec->rootDir = NULL;
if (rc != RPMRC_OK && rpmlogGetNrecs() > 0) {
diff --git a/build/pack.c b/build/pack.c
index df15876..17a4b09 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -6,8 +6,6 @@
#include "system.h"
#include <errno.h>
-#include <netdb.h>
-#include <time.h>
#include <sys/wait.h>
#include <rpm/rpmlib.h> /* RPMSIGTAG*, rpmReadPackageFile */
@@ -152,57 +150,6 @@ exit:
return rc;
}
-static rpm_time_t * getBuildTime(void)
-{
- static rpm_time_t buildTime[1];
- char *srcdate;
- time_t epoch;
- char *endptr;
-
- if (buildTime[0] == 0) {
- srcdate = getenv("SOURCE_DATE_EPOCH");
- if (srcdate) {
- errno = 0;
- epoch = strtol(srcdate, &endptr, 10);
- if (srcdate == endptr || *endptr || errno != 0)
- rpmlog(RPMLOG_ERR, _("unable to parse SOURCE_DATE_EPOCH\n"));
- else
- buildTime[0] = (int32_t) epoch;
- } else
- buildTime[0] = (int32_t) time(NULL);
- }
-
- return buildTime;
-}
-
-static const char * buildHost(void)
-{
- static char hostname[1024];
- static int oneshot = 0;
- struct hostent *hbn;
- char *bhMacro;
-
- if (! oneshot) {
- bhMacro = rpmExpand("%{?_buildhost}", NULL);
- if (strcmp(bhMacro, "") != 0 && strlen(bhMacro) < 1024) {
- strcpy(hostname, bhMacro);
- } else {
- if (strcmp(bhMacro, "") != 0)
- rpmlog(RPMLOG_WARNING, _("The _buildhost macro is too long\n"));
- (void) gethostname(hostname, sizeof(hostname));
- hbn = gethostbyname(hostname);
- if (hbn)
- strcpy(hostname, hbn->h_name);
- else
- rpmlog(RPMLOG_WARNING,
- _("Could not canonicalize hostname: %s\n"), hostname);
- }
- free(bhMacro);
- oneshot = 1;
- }
- return(hostname);
-}
-
static rpmRC processScriptFiles(rpmSpec spec, Package pkg)
{
struct TriggerFileEntry *p;
@@ -476,7 +423,8 @@ exit:
* order to how the RPM format is laid on disk.
*/
static rpmRC writeRPM(Package pkg, unsigned char ** pkgidp,
- const char *fileName, char **cookie)
+ const char *fileName, char **cookie,
+ rpm_time_t buildTime, const char* buildHost)
{
FD_t fd = NULL;
char * rpmio_flags = NULL;
@@ -500,7 +448,7 @@ static rpmRC writeRPM(Package pkg, unsigned char ** pkgidp,
/* Create and add the cookie */
if (cookie) {
- rasprintf(cookie, "%s %d", buildHost(), (int) (*getBuildTime()));
+ rasprintf(cookie, "%s %d", buildHost, buildTime);
headerPutString(pkg->header, RPMTAG_COOKIE, *cookie);
}
@@ -641,7 +589,7 @@ static rpmRC checkPackages(char *pkgcheck)
return RPMRC_OK;
}
-static rpmRC packageBinary(rpmSpec spec, Package pkg, const char *cookie, int cheating, char** filename)
+static rpmRC packageBinary(rpmSpec spec, Package pkg, const char *cookie, int cheating, char** filename, rpm_time_t buildTime, const char* buildHost)
{
const char *errorString;
rpmRC rc = RPMRC_OK;
@@ -660,8 +608,8 @@ static rpmRC packageBinary(rpmSpec spec, Package pkg, const char *cookie, int ch
headerCopyTags(spec->packages->header, pkg->header, copyTags);
headerPutString(pkg->header, RPMTAG_RPMVERSION, VERSION);
- headerPutString(pkg->header, RPMTAG_BUILDHOST, buildHost());
- headerPutUint32(pkg->header, RPMTAG_BUILDTIME, getBuildTime(), 1);
+ headerPutString(pkg->header, RPMTAG_BUILDHOST, buildHost);
+ headerPutUint32(pkg->header, RPMTAG_BUILDTIME, &buildTime, 1);
if (spec->sourcePkgId != NULL) {
headerPutBin(pkg->header, RPMTAG_SOURCEPKGID, spec->sourcePkgId,16);
@@ -699,7 +647,7 @@ static rpmRC packageBinary(rpmSpec spec, Package pkg, const char *cookie, int ch
free(binRpm);
}
- rc = writeRPM(pkg, NULL, *filename, NULL);
+ rc = writeRPM(pkg, NULL, *filename, NULL, buildTime, buildHost);
if (rc == RPMRC_OK) {
/* Do check each written package if enabled */
char *pkgcheck = rpmExpand("%{?_build_pkgcheck} ", *filename, NULL);
@@ -719,7 +667,7 @@ struct binaryPackageTaskData
struct binaryPackageTaskData *next;
};
-static struct binaryPackageTaskData* runBinaryPackageTasks(rpmSpec spec, const char *cookie, int cheating)
+static struct binaryPackageTaskData* runBinaryPackageTasks(rpmSpec spec, const char *cookie, int cheating, rpm_time_t buildTime, char* buildHost)
{
struct binaryPackageTaskData *tasks = NULL;
struct binaryPackageTaskData *task = NULL;
@@ -731,7 +679,7 @@ static struct binaryPackageTaskData* runBinaryPackageTasks(rpmSpec spec, const c
if (pkg == spec->packages) {
// the first package needs to be processed ahead of others, as they copy
// changelog data from it, and so otherwise data races would happen
- task->result = packageBinary(spec, pkg, cookie, cheating, &(task->filename));
+ task->result = packageBinary(spec, pkg, cookie, cheating, &(task->filename), buildTime, buildHost);
rpmlog(RPMLOG_NOTICE, _("Finished binary package job, result %d, filename %s\n"), task->result, task->filename);
tasks = task;
}
@@ -748,7 +696,7 @@ static struct binaryPackageTaskData* runBinaryPackageTasks(rpmSpec spec, const c
if (task != tasks)
#pragma omp task
{
- task->result = packageBinary(spec, task->pkg, cookie, cheating, &(task->filename));
+ task->result = packageBinary(spec, task->pkg, cookie, cheating, &(task->filename), buildTime, buildHost);
rpmlog(RPMLOG_NOTICE, _("Finished binary package job, result %d, filename %s\n"), task->result, task->filename);
}
}
@@ -766,11 +714,11 @@ static void freeBinaryPackageTasks(struct binaryPackageTaskData* tasks)
}
}
-rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating)
+rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating, rpm_time_t buildTime, char* buildHost)
{
char *pkglist = NULL;
- struct binaryPackageTaskData *tasks = runBinaryPackageTasks(spec, cookie, cheating);
+ struct binaryPackageTaskData *tasks = runBinaryPackageTasks(spec, cookie, cheating, buildTime, buildHost);
for (struct binaryPackageTaskData *task = tasks; task != NULL; task = task->next) {
if (task->result == RPMRC_OK) {
@@ -797,7 +745,7 @@ rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating)
return RPMRC_OK;
}
-rpmRC packageSources(rpmSpec spec, char **cookie)
+rpmRC packageSources(rpmSpec spec, char **cookie, rpm_time_t buildTime, char* buildHost)
{
Package sourcePkg = spec->sourcePackage;
rpmRC rc;
@@ -805,8 +753,8 @@ rpmRC packageSources(rpmSpec spec, char **cookie)
/* Add some cruft */
headerPutString(sourcePkg->header, RPMTAG_RPMVERSION, VERSION);
- headerPutString(sourcePkg->header, RPMTAG_BUILDHOST, buildHost());
- headerPutUint32(sourcePkg->header, RPMTAG_BUILDTIME, getBuildTime(), 1);
+ headerPutString(sourcePkg->header, RPMTAG_BUILDHOST, buildHost);
+ headerPutUint32(sourcePkg->header, RPMTAG_BUILDTIME, &buildTime, 1);
headerPutUint32(sourcePkg->header, RPMTAG_SOURCEPACKAGE, &one, 1);
/* XXX this should be %_srpmdir */
@@ -814,7 +762,7 @@ rpmRC packageSources(rpmSpec spec, char **cookie)
char *pkgcheck = rpmExpand("%{?_build_pkgcheck_srpm} ", fn, NULL);
spec->sourcePkgId = NULL;
- rc = writeRPM(sourcePkg, &spec->sourcePkgId, fn, cookie);
+ rc = writeRPM(sourcePkg, &spec->sourcePkgId, fn, cookie, buildTime, buildHost);
/* Do check SRPM package if enabled */
if (rc == RPMRC_OK && pkgcheck[0] != ' ') {
diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h
index 439b7d3..07e8338 100644
--- a/build/rpmbuild_internal.h
+++ b/build/rpmbuild_internal.h
@@ -427,19 +427,23 @@ rpmRC processSourceFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags);
* @param spec spec file control structure
* @param cookie build identifier "cookie" or NULL
* @param cheating was build shortcircuited?
+ * @param buildTime the build timestamp that goes into packages
+ * @param buildHost the hostname where the build is happening
* @return RPMRC_OK on success
*/
RPM_GNUC_INTERNAL
-rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating);
+rpmRC packageBinaries(rpmSpec spec, const char *cookie, int cheating, rpm_time_t buildTime, char* buildHost);
/** \ingroup rpmbuild
* Generate source package.
* @param spec spec file control structure
* @retval cookie build identifier "cookie" or NULL
+ * @param buildTime the build timestamp that goes into packages
+ * @param buildHost the hostname where the build is happening
* @return RPMRC_OK on success
*/
RPM_GNUC_INTERNAL
-rpmRC packageSources(rpmSpec spec, char **cookie);
+rpmRC packageSources(rpmSpec spec, char **cookie, rpm_time_t buildTime, char* buildHost);
RPM_GNUC_INTERNAL
int addLangTag(rpmSpec spec, Header h, rpmTagVal tag,

View File

@ -0,0 +1,33 @@
From 5141d50d7b3d3c209a22c53deedb4ceef014401d Mon Sep 17 00:00:00 2001
From: Peter Kjellerstedt <pkj@axis.com>
Date: Mon, 15 May 2017 10:21:08 +0200
Subject: [PATCH 09/15] Do not require that ELF binaries are executable to be
identifiable
There is nothing that requires, e.g., a DSO to be executable, but it
is still an ELF binary and should be identified as such.
Upstream probably expects all ELF binaries to be marked as executable,
but rather than imposing such a limitation for OE, allow any file to
be identified as an ELF binary regardless of whether it is executable
or not.
Upstream-Status: Inappropriate
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
fileattrs/elf.attr | 1 -
1 file changed, 1 deletion(-)
diff --git a/fileattrs/elf.attr b/fileattrs/elf.attr
index 5805dd0ee..3516f309d 100644
--- a/fileattrs/elf.attr
+++ b/fileattrs/elf.attr
@@ -1,4 +1,3 @@
%__elf_provides %{_rpmconfigdir}/elfdeps --provides %{?__filter_GLIBC_PRIVATE:--filter-private}
%__elf_requires %{_rpmconfigdir}/elfdeps --requires %{?__filter_GLIBC_PRIVATE:--filter-private}
%__elf_magic ^(setuid,? )?(setgid,? )?(sticky )?ELF (32|64)-bit.*$
-%__elf_flags exeonly
--
2.14.2

View File

@ -0,0 +1,166 @@
#SUMMARY = "The RPM package management system"
#DESCRIPTION = "The RPM Package Manager (RPM) is a powerful command line driven \
#package management system capable of installing, uninstalling, \
#verifying, querying, and updating software packages. Each software \
#package consists of an archive of files along with information about \
#the package like its version, a description, etc."
#SUMMARY_${PN}-dev = "Development files for manipulating RPM packages"
#DESCRIPTION_${PN}-dev = "This package contains the RPM C library and header files. These \
#development files will simplify the process of writing programs that \
#manipulate RPM packages and databases. These files are intended to \
#simplify the process of creating graphical package managers or any \
#other tools that need an intimate knowledge of RPM packages in order \
#to function."
SUMMARY_python2-rpm = "Python bindings for apps which will manupulate RPM packages"
DESCRIPTION_python2-rpm = "The python2-rpm package contains a module that permits applications \
written in the Python programming language to use the interface \
supplied by the RPM Package Manager libraries."
HOMEPAGE = "http://www.rpm.org"
# libraries are also LGPL - how to express this?
LICENSE = "GPL-2.0"
LIC_FILES_CHKSUM = "file://COPYING;md5=c0bf017c0fd1920e6158a333acabfd4a"
SRC_URI = "git://github.com/rpm-software-management/rpm;branch=rpm-4.14.x \
file://0001-Do-not-add-an-unsatisfiable-dependency-when-building.patch \
file://0001-Do-not-read-config-files-from-HOME.patch \
file://0001-When-cross-installing-execute-package-scriptlets-wit.patch \
file://0001-Do-not-reset-the-PATH-environment-variable-before-ru.patch \
file://0002-Add-support-for-prefixing-etc-from-RPM_ETCCONFIGDIR-.patch \
file://0001-Do-not-hardcode-lib-rpm-as-the-installation-path-for.patch \
file://0001-Fix-build-with-musl-C-library.patch \
file://0001-Add-a-color-setting-for-mips64_n32-binaries.patch \
file://0011-Do-not-require-that-ELF-binaries-are-executable-to-b.patch \
file://0001-Split-binary-package-building-into-a-separate-functi.patch \
file://0002-Run-binary-package-creation-via-thread-pools.patch \
file://0003-rpmstrpool.c-make-operations-over-string-pools-threa.patch \
file://0004-build-pack.c-remove-static-local-variables-from-buil.patch \
file://0001-perl-disable-auto-reqs.patch \
file://0001-rpm-rpmio.c-restrict-virtual-memory-usage-if-limit-s.patch \
"
PE = "1"
SRCREV = "753f6941dc32e94047b7cfe713ddd604a810b4db"
S = "${WORKDIR}/git"
DEPENDS = "nss libarchive db file popt xz bzip2 dbus elfutils python"
DEPENDS_append_class-native = " file-replacement-native bzip2-replacement-native"
inherit autotools gettext pkgconfig pythonnative
export PYTHON_ABI
# OE-core patches autoreconf to additionally run gnu-configize, which fails with this recipe
EXTRA_AUTORECONF_append = " --exclude=gnu-configize"
EXTRA_OECONF_append = " --without-lua --enable-python"
EXTRA_OECONF_append_libc-musl = " --disable-nls"
# --sysconfdir prevents rpm from attempting to access machine-specific configuration in sysroot/etc; we need to have it in rootfs
#
# --localstatedir prevents rpm from writing its database to native sysroot when building images
#
# Disable dbus for native, so that rpm doesn't attempt to inhibit shutdown via session dbus even when plugins support is enabled.
# Also disable plugins by default for native.
EXTRA_OECONF_append_class-native = " --sysconfdir=/etc --localstatedir=/var --disable-plugins"
EXTRA_OECONF_append_class-nativesdk = " --sysconfdir=/etc --localstatedir=/var --disable-plugins"
BBCLASSEXTEND = "native nativesdk"
PACKAGECONFIG ??= ""
PACKAGECONFIG[imaevm] = "--with-imaevm,,ima-evm-utils"
ASNEEDED = ""
# Direct rpm-native to read configuration from our sysroot, not the one it was compiled in
# libmagic also has sysroot path contamination, so override it
#WRAPPER_TOOLS = " \
# ${bindir}/rpm \
# ${bindir}/rpm2archive \
# ${bindir}/rpm2cpio \
# ${bindir}/rpmbuild \
# ${bindir}/rpmdb \
# ${bindir}/rpmgraph \
# ${bindir}/rpmkeys \
# ${bindir}/rpmsign \
# ${bindir}/rpmspec \
# ${libdir}/rpm/rpmdeps \
#"
#do_install_append_class-native() {
# for tool in ${WRAPPER_TOOLS}; do
# create_wrapper ${D}$tool \
# RPM_CONFIGDIR=${STAGING_LIBDIR_NATIVE}/rpm \
# RPM_ETCCONFIGDIR=${STAGING_DIR_NATIVE} \
# MAGIC=${STAGING_DIR_NATIVE}${datadir_native}/misc/magic.mgc \
# RPM_NO_CHROOT_FOR_SCRIPTS=1
# done
#}
#do_install_append_class-nativesdk() {
# for tool in ${WRAPPER_TOOLS}; do
# create_wrapper ${D}$tool \
# RPM_CONFIGDIR='`dirname $''realpath`'/${@os.path.relpath(d.getVar('libdir'), d.getVar('bindir'))}/rpm \
# RPM_ETCCONFIGDIR='$'{RPM_ETCCONFIGDIR-'`dirname $''realpath`'/${@os.path.relpath(d.getVar('sysconfdir'), d.getVar('bindir'))}/..} \
# MAGIC='`dirname $''realpath`'/${@os.path.relpath(d.getVar('datadir'), d.getVar('bindir'))}/misc/magic.mgc \
# RPM_NO_CHROOT_FOR_SCRIPTS=1
# done
#
# rm -rf ${D}/var
#}
# Rpm's make install creates var/tmp which clashes with base-files packaging
#do_install_append_class-target() {
# rm -rf ${D}/var
#}
do_install_append () {
sed -i -e 's:${HOSTTOOLS_DIR}/::g' \
${D}/${libdir}/rpm/macros
sed -i -e 's|/usr/bin/python|${USRBINPATH}/env ${PYTHON_PN}|' \
${D}${libdir}/rpm/pythondistdeps.py \
${D}${libdir}/rpm/python-macro-helper
# remove all contents except python2-rpm
rm -r ${D}/var
rm -r ${D}/usr/share
rm -r ${D}/usr/include
rm -r ${D}/usr/lib/librpm*
rm -r ${D}/usr/lib/pkgconfig
# rm -r ${D}/usr/src
rm -r ${D}/usr/lib/rpm
rm -r ${D}/usr/lib/rpm-plugins
# rm -r ${D}/usr/lib/.debug
rm -r ${D}/usr/bin
}
#FILES_${PN} += "${libdir}/rpm-plugins/*.so \
# ${libdir}/rpm \
# "
#FILES_${PN}-dev += "${libdir}/rpm-plugins/*.la \
# "
PACKAGES = "python2-rpm rpm2-dbg"
PROVIDES = "python2-rpm rpm2-dbg"
FILES_python2-rpm = "${PYTHON_SITEPACKAGES_DIR}/rpm/*"
# rpm 5.x was packaging the rpm build tools separately
#RPROVIDES_${PN} += "rpm-build"
RDEPENDS_${PN} = "bash perl python-core"
RDEPENDS_python2-rpm = "rpm"
DEPENDS_python2-rpm = "rpm"
# PACKAGE_PREPROCESS_FUNCS += "rpm_package_preprocess"
# Do not specify a sysroot when compiling on a target.
#rpm_package_preprocess () {
# sed -i -e 's:--sysroot[^ ]*::g' \
# ${PKGD}/${libdir}/rpm/macros
#}