summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Festi <ffesti@redhat.com>2016-06-02 15:54:01 +0200
committerFlorian Festi <ffesti@redhat.com>2016-06-02 15:54:01 +0200
commit22588250baa1bfa5c00f57d39329d0c144fc8112 (patch)
tree32937ff6cc5ca1cf56a9db93e2c8e262ce124e3d
parent7a7c31f551ff167f8718aea6d5048f6288d60205 (diff)
downloadrpm-22588250baa1bfa5c00f57d39329d0c144fc8112.tar.gz
Add support for _buildhost macro for setting the build host manually.
This is useful for reproducible builds. See rhbz#1309367.
-rw-r--r--build/pack.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/build/pack.c b/build/pack.c
index f9fb3a05d..82c12624e 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);
}