diff options
author | Florian Festi <ffesti@redhat.com> | 2016-06-02 15:54:01 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2016-10-20 15:32:35 +0300 |
commit | 8683332c410e55880393631521f3256a339855a3 (patch) | |
tree | e895aea2bf30b1b27bcfef4c825883e7648580fd | |
parent | ad623bb4754d8af9a2a38b8a1e1473b8a13ae109 (diff) | |
download | rpm-8683332c410e55880393631521f3256a339855a3.tar.gz |
Add support for _buildhost macro for setting the build host manually.
This is useful for reproducible builds. See rhbz#1309367.
(cherry picked from commit 22588250baa1bfa5c00f57d39329d0c144fc8112)
-rw-r--r-- | build/pack.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/build/pack.c b/build/pack.c index bfb4c73bb..96724143e 100644 --- a/build/pack.c +++ b/build/pack.c @@ -165,16 +165,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); } |