|
Florian Festi |
ae2bf1 |
From 22588250baa1bfa5c00f57d39329d0c144fc8112 Mon Sep 17 00:00:00 2001
|
|
Florian Festi |
ae2bf1 |
From: Florian Festi <ffesti@redhat.com>
|
|
Florian Festi |
ae2bf1 |
Date: Thu, 2 Jun 2016 15:54:01 +0200
|
|
Florian Festi |
ae2bf1 |
Subject: [PATCH] Add support for _buildhost macro for setting the build host
|
|
Florian Festi |
ae2bf1 |
manually.
|
|
Florian Festi |
ae2bf1 |
|
|
Florian Festi |
ae2bf1 |
This is useful for reproducible builds. See rhbz#1309367.
|
|
Florian Festi |
ae2bf1 |
---
|
|
Florian Festi |
ae2bf1 |
build/pack.c | 25 +++++++++++++++++--------
|
|
Florian Festi |
ae2bf1 |
1 file changed, 17 insertions(+), 8 deletions(-)
|
|
Florian Festi |
ae2bf1 |
|
|
Florian Festi |
ae2bf1 |
diff --git a/build/pack.c b/build/pack.c
|
|
Florian Festi |
ae2bf1 |
index f9fb3a0..82c1262 100644
|
|
Florian Festi |
ae2bf1 |
--- a/build/pack.c
|
|
Florian Festi |
ae2bf1 |
+++ b/build/pack.c
|
|
Florian Festi |
ae2bf1 |
@@ -179,16 +179,25 @@ static const char * buildHost(void)
|
|
Florian Festi |
ae2bf1 |
static char hostname[1024];
|
|
Florian Festi |
ae2bf1 |
static int oneshot = 0;
|
|
Florian Festi |
ae2bf1 |
struct hostent *hbn;
|
|
Florian Festi |
ae2bf1 |
+ char *bhMacro;
|
|
Florian Festi |
ae2bf1 |
|
|
Florian Festi |
ae2bf1 |
if (! oneshot) {
|
|
Florian Festi |
ae2bf1 |
- (void) gethostname(hostname, sizeof(hostname));
|
|
Florian Festi |
ae2bf1 |
- hbn = gethostbyname(hostname);
|
|
Florian Festi |
ae2bf1 |
- if (hbn)
|
|
Florian Festi |
ae2bf1 |
- strcpy(hostname, hbn->h_name);
|
|
Florian Festi |
ae2bf1 |
- else
|
|
Florian Festi |
ae2bf1 |
- rpmlog(RPMLOG_WARNING,
|
|
Florian Festi |
ae2bf1 |
- _("Could not canonicalize hostname: %s\n"), hostname);
|
|
Florian Festi |
ae2bf1 |
- oneshot = 1;
|
|
Florian Festi |
ae2bf1 |
+ bhMacro = rpmExpand("%{?_buildhost}", NULL);
|
|
Florian Festi |
ae2bf1 |
+ if (strcmp(bhMacro, "") != 0 && strlen(bhMacro) < 1024) {
|
|
Florian Festi |
ae2bf1 |
+ strcpy(hostname, bhMacro);
|
|
Florian Festi |
ae2bf1 |
+ } else {
|
|
Florian Festi |
ae2bf1 |
+ if (strcmp(bhMacro, "") != 0)
|
|
Florian Festi |
ae2bf1 |
+ rpmlog(RPMLOG_WARNING, _("The _buildhost macro is too long\n"));
|
|
Florian Festi |
ae2bf1 |
+ (void) gethostname(hostname, sizeof(hostname));
|
|
Florian Festi |
ae2bf1 |
+ hbn = gethostbyname(hostname);
|
|
Florian Festi |
ae2bf1 |
+ if (hbn)
|
|
Florian Festi |
ae2bf1 |
+ strcpy(hostname, hbn->h_name);
|
|
Florian Festi |
ae2bf1 |
+ else
|
|
Florian Festi |
ae2bf1 |
+ rpmlog(RPMLOG_WARNING,
|
|
Florian Festi |
ae2bf1 |
+ _("Could not canonicalize hostname: %s\n"), hostname);
|
|
Florian Festi |
ae2bf1 |
+ }
|
|
Florian Festi |
ae2bf1 |
+ free(bhMacro);
|
|
Florian Festi |
ae2bf1 |
+ oneshot = 1;
|
|
Florian Festi |
ae2bf1 |
}
|
|
Florian Festi |
ae2bf1 |
return(hostname);
|
|
Florian Festi |
ae2bf1 |
}
|
|
Florian Festi |
ae2bf1 |
--
|
|
Florian Festi |
ae2bf1 |
2.5.5
|
|
Florian Festi |
ae2bf1 |
|