Chris Lamb wrote:
> […]
Updated patch attached - I left a debug "printf" call in there by
accident.
Regards,
--
,''`.
: :' : Chris Lamb
`. `'` [email protected] / chris-lamb.co.uk
`-
diff --git a/misc.c b/misc.c
index 6adf33b..3321dc8 100644
--- a/misc.c
+++ b/misc.c
@@ -109,7 +109,8 @@ FILE *open_mcwd(const char *mode)
* Ignore the info, if the file is more than 6 hours old
*/
getTimeNow(&now);
- if (now - sbuf.st_mtime > 6 * 60 * 60) {
+ if (now - sbuf.st_mtime > 6 * 60 * 60
+ && getenv("SOURCE_DATE_EPOCH") == NULL) {
fprintf(stderr,
"Warning: \"%s\" is out of date, removing it\n",
file);
@@ -159,11 +160,33 @@ void print_sector(const char *message, unsigned char
*data, int size)
time_t getTimeNow(time_t *now)
{
+ char *endptr;
+ char *source_date_epoch;
+ unsigned long long epoch;
static int haveTime = 0;
static time_t sharedNow;
if(!haveTime) {
- time(&sharedNow);
+ source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+ if (source_date_epoch) {
+ epoch = strtoull(source_date_epoch, &endptr, 10);
+
+ if (endptr == source_date_epoch)
+ fprintf(stderr, "SOURCE_DATE_EPOCH invalid\n");
+ else if ((errno == ERANGE && (epoch == ULLONG_MAX ||
epoch == 0))
+ || (errno != 0 && epoch == 0))
+ fprintf(stderr, "SOURCE_DATE_EPOCH: strtoull:
%s: %llu\n",
+ strerror(errno), epoch);
+ else if (*endptr != '\0')
+ fprintf(stderr, "SOURCE_DATE_EPOCHh has
trailing garbage\n");
+ else if (epoch > ULONG_MAX)
+ fprintf(stderr, "SOURCE_DATE_EPOCH must be <=
%lu but saw: %llu\n", ULONG_MAX, epoch);
+ else {
+ sharedNow = epoch;
+ }
+ } else {
+ time(&sharedNow);
+ }
haveTime = 1;
}
if(now)