summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/build.c49
-rw-r--r--build/spec.c50
2 files changed, 49 insertions, 50 deletions
diff --git a/build/build.c b/build/build.c
index d6f418793..e50c3784e 100644
--- a/build/build.c
+++ b/build/build.c
@@ -7,6 +7,8 @@
#include <errno.h>
#include <sys/wait.h>
+#include <netdb.h>
+#include <time.h>
#include <rpm/rpmlog.h>
#include <rpm/rpmfileutil.h>
@@ -16,6 +18,50 @@
#include "debug.h"
+static rpm_time_t getBuildTime(void)
+{
+ rpm_time_t buildTime = 0;
+ char *srcdate;
+ time_t epoch;
+ char *endptr;
+
+ srcdate = getenv("SOURCE_DATE_EPOCH");
+ if (srcdate && rpmExpandNumeric("%{?use_source_date_epoch_as_buildtime}")) {
+ errno = 0;
+ epoch = strtol(srcdate, &endptr, 10);
+ if (srcdate == endptr || *endptr || errno != 0)
+ rpmlog(RPMLOG_ERR, _("unable to parse SOURCE_DATE_EPOCH\n"));
+ else
+ buildTime = (int32_t) epoch;
+ } else
+ buildTime = (int32_t) time(NULL);
+
+ return buildTime;
+}
+
+static char * buildHost(void)
+{
+ char* hostname;
+ struct hostent *hbn;
+ char *bhMacro;
+
+ bhMacro = rpmExpand("%{?_buildhost}", NULL);
+ if (strcmp(bhMacro, "") != 0) {
+ rasprintf(&hostname, "%s", bhMacro);
+ } else {
+ hostname = rcalloc(1024, sizeof(*hostname));
+ (void) gethostname(hostname, 1024);
+ hbn = gethostbyname(hostname);
+ if (hbn)
+ strcpy(hostname, hbn->h_name);
+ else
+ rpmlog(RPMLOG_WARNING,
+ _("Could not canonicalize hostname: %s\n"), hostname);
+ }
+ free(bhMacro);
+ return(hostname);
+}
+
/**
*/
static rpmRC doRmSource(rpmSpec spec)
@@ -260,6 +306,9 @@ static rpmRC buildSpec(rpmts ts, BTA_t buildArgs, rpmSpec spec, int what)
}
}
+ spec->buildTime = getBuildTime();
+ spec->buildHost = buildHost();
+
/* XXX TODO: rootDir is only relevant during build, eliminate from spec */
spec->rootDir = buildArgs->rootdir;
if (!spec->recursing && spec->BACount) {
diff --git a/build/spec.c b/build/spec.c
index bf09c5a5c..6d402319f 100644
--- a/build/spec.c
+++ b/build/spec.c
@@ -5,8 +5,6 @@
#include "system.h"
#include <errno.h>
-#include <netdb.h>
-#include <time.h>
#include <rpm/header.h>
#include <rpm/rpmds.h>
@@ -199,60 +197,12 @@ rpmds * packageDependencies(Package pkg, rpmTagVal tag)
return NULL;
}
-static rpm_time_t getBuildTime(void)
-{
- rpm_time_t buildTime = 0;
- char *srcdate;
- time_t epoch;
- char *endptr;
-
- srcdate = getenv("SOURCE_DATE_EPOCH");
- if (srcdate && rpmExpandNumeric("%{?use_source_date_epoch_as_buildtime}")) {
- errno = 0;
- epoch = strtol(srcdate, &endptr, 10);
- if (srcdate == endptr || *endptr || errno != 0)
- rpmlog(RPMLOG_ERR, _("unable to parse SOURCE_DATE_EPOCH\n"));
- else
- buildTime = (int32_t) epoch;
- } else
- buildTime = (int32_t) time(NULL);
-
- return buildTime;
-}
-
-static char * buildHost(void)
-{
- char* hostname;
- struct hostent *hbn;
- char *bhMacro;
-
- bhMacro = rpmExpand("%{?_buildhost}", NULL);
- if (strcmp(bhMacro, "") != 0) {
- rasprintf(&hostname, "%s", bhMacro);
- } else {
- hostname = rcalloc(1024, sizeof(*hostname));
- (void) gethostname(hostname, 1024);
- hbn = gethostbyname(hostname);
- if (hbn)
- strcpy(hostname, hbn->h_name);
- else
- rpmlog(RPMLOG_WARNING,
- _("Could not canonicalize hostname: %s\n"), hostname);
- }
- free(bhMacro);
- return(hostname);
-}
-
-
rpmSpec newSpec(void)
{
rpmSpec spec = xcalloc(1, sizeof(*spec));
spec->specFile = NULL;
- spec->buildHost = buildHost();
- spec->buildTime = getBuildTime();
-
spec->fileStack = NULL;
spec->lbufSize = BUFSIZ * 10;
spec->lbuf = xmalloc(spec->lbufSize);