Add support for _buildhost macro for setting the build host manually.
This is useful for reproducible builds. See rhbz#1309367.
This commit is contained in:
parent
7a7c31f551
commit
22588250ba
25
build/pack.c
25
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue