- Add support for _buildhost macro (#1309367)

This commit is contained in:
Florian Festi 2016-06-02 16:02:52 +02:00
parent b1ea7e94ff
commit ae2bf135f8
2 changed files with 57 additions and 1 deletions

View File

@ -0,0 +1,52 @@
From 22588250baa1bfa5c00f57d39329d0c144fc8112 Mon Sep 17 00:00:00 2001
From: Florian Festi <ffesti@redhat.com>
Date: Thu, 2 Jun 2016 15:54:01 +0200
Subject: [PATCH] Add support for _buildhost macro for setting the build host
manually.
This is useful for reproducible builds. See rhbz#1309367.
---
build/pack.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/build/pack.c b/build/pack.c
index f9fb3a0..82c1262 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -179,16 +179,25 @@ static const char * buildHost(void)
static char hostname[1024];
static int oneshot = 0;
struct hostent *hbn;
+ char *bhMacro;
if (! oneshot) {
- (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);
- oneshot = 1;
+ 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);
}
--
2.5.5

View File

@ -29,7 +29,7 @@
Summary: The RPM package management system Summary: The RPM package management system
Name: rpm Name: rpm
Version: %{rpmver} Version: %{rpmver}
Release: %{?snapver:0.%{snapver}.}36%{?dist} Release: %{?snapver:0.%{snapver}.}37%{?dist}
Group: System Environment/Base Group: System Environment/Base
Url: http://www.rpm.org/ Url: http://www.rpm.org/
Source0: http://rpm.org/releases/rpm-4.12.x/%{name}-%{srcver}.tar.bz2 Source0: http://rpm.org/releases/rpm-4.12.x/%{name}-%{srcver}.tar.bz2
@ -84,6 +84,7 @@ Patch128: rpm-4.13.0-stringFormat-sigsegv.patch
Patch129: rpm-4.13.0-filter-unversioned.patch Patch129: rpm-4.13.0-filter-unversioned.patch
Patch130: rpm-4.13.0-armv7hl-isa.patch Patch130: rpm-4.13.0-armv7hl-isa.patch
Patch131: rpm-4.13.0-non-ASCII-keys.patch Patch131: rpm-4.13.0-non-ASCII-keys.patch
Patch132: rpm-4.13.0-_buildhost-macro.diff
# These are not yet upstream # These are not yet upstream
Patch302: rpm-4.7.1-geode-i686.patch Patch302: rpm-4.7.1-geode-i686.patch
@ -595,6 +596,9 @@ exit 0
%doc doc/librpm/html/* %doc doc/librpm/html/*
%changelog %changelog
* Thu Jun 02 2016 Florian Festi <ffesti@rpm.org> - 4.4.13.0-0.rc1.37
- Add support for _buildhost macro (#1309367)
* Mon May 23 2016 Lubos Kardos <lkardos@redhat.com> 4.13.0-0.rc1.36 * Mon May 23 2016 Lubos Kardos <lkardos@redhat.com> 4.13.0-0.rc1.36
- Fix signing with non-ASCII uid keys (#1243963) - Fix signing with non-ASCII uid keys (#1243963)