#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
exit(EXIT_FAILURE);
}
+static time_t source_date_epoch = -1;
+static void set_source_date_epoch() {
+ char *env = getenv("SOURCE_DATE_EPOCH");
+ char *endptr = env;
+ errno = 0;
+ if (env && *env) {
+ source_date_epoch = strtoull(env, &endptr, 10);
+ if (errno || (endptr && *endptr != '\0')) {
+ fprintf(stderr, "Invalid SOURCE_DATE_EPOCH");
+ exit(1);
+ }
+ }
+}
+
struct board_info *find_board(char *id)
{
struct board_info *board;
usage();
}
- if (time(&t) == (time_t)(-1)) {
+ set_source_date_epoch();
+ if (source_date_epoch != -1) {
+ t = source_date_epoch;
+ } else if ((time(&t) == (time_t)(-1))) {
fprintf(stderr, "time call failed\n");
return EXIT_FAILURE;
}
#include <string.h>
#include <getopt.h>
#include <unistd.h>
-#include <sys/time.h>
+#include <errno.h>
+#include <time.h>
#include <sys/stat.h>
#include <libgen.h>
#include "bcmalgo.h"
printf ( "\n" );
}
+static time_t source_date_epoch = -1;
+static void set_source_date_epoch() {
+ char *env = getenv("SOURCE_DATE_EPOCH");
+ char *endptr = env;
+ errno = 0;
+ if (env && *env) {
+ source_date_epoch = strtoull(env, &endptr, 10);
+ if (errno || (endptr && *endptr != '\0')) {
+ fprintf(stderr, "Invalid SOURCE_DATE_EPOCH");
+ exit(1);
+ }
+ }
+}
int main ( int argc, char** argv )
{
{
fname = filename;
}
- struct timeval tm;
- gettimeofday ( &tm,NULL );
+
+ time_t t = -1;
+ set_source_date_epoch();
+ if (source_date_epoch != -1) {
+ t = source_date_epoch;
+ } else if ((time(&t) == (time_t)(-1))) {
+ fprintf(stderr, "time call failed\n");
+ return EXIT_FAILURE;
+ }
+
struct stat buf;
stat ( input,&buf );
- ldr_header_t* head = construct_header ( magicnum, (uint16_t) majrev, (uint16_t) minrev, ( uint32_t ) tm.tv_sec, ( uint32_t ) buf.st_size, ldaddress, fname, get_file_crc ( input ) );
+ ldr_header_t* head = construct_header ( magicnum, (uint16_t) majrev, (uint16_t) minrev, ( uint32_t ) t, ( uint32_t ) buf.st_size, ldaddress, fname, get_file_crc ( input ) );
free(dupe);
//uint32_t magic, uint16_t rev_maj,uint16_t rev_min, uint32_t build_date, uint32_t filelen, uint32_t ldaddress, const char* filename, uint32_t crc
//FILE* fd = fopen ("/tftpboot/haxorware11rev32.bin","r");
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
-#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
#include <netinet/in.h>
return fd;
}
+static time_t source_date_epoch = -1;
+static void set_source_date_epoch() {
+ char *env = getenv("SOURCE_DATE_EPOCH");
+ char *endptr = env;
+ errno = 0;
+ if (env && *env) {
+ source_date_epoch = strtoull(env, &endptr, 10);
+ if (errno || (endptr && *endptr != '\0')) {
+ fprintf(stderr, "Invalid SOURCE_DATE_EPOCH");
+ exit(1);
+ }
+ }
+}
+
/*
* Write the JCG header
*/
uLong crc;
uint16_t major = 0, minor = 0;
void *payload = (void *)h + sizeof(*h);
+ time_t t;
+
+ if (source_date_epoch != -1) {
+ t = source_date_epoch;
+ } else if ((time(&t) == (time_t)(-1))) {
+ err(1, "time call failed");
+ }
if (version != NULL) {
if (sscanf(version, "%hu.%hu", &major, &minor) != 2) {
memset(h, 0, sizeof(*h));
h->jh_magic = htonl(JH_MAGIC);
h->jh_type = htonl(1);
- h->jh_time = htonl(time(NULL));
+ h->jh_time = htonl(t);
h->jh_major = htons(major);
h->jh_minor = htons(minor);
/* Make sure the headers have the right size */
assert(sizeof(struct jcg_header) == 512);
assert(sizeof(struct uimage_header) == 64);
+ set_source_date_epoch();
while ((c = getopt(argc, argv, "o:k:f:u:v:h")) != -1) {
switch (c) {
#include <netinet/in.h>
#include <sys/mman.h>
#include <sys/stat.h>
-#include <time.h>
#include <unistd.h>
#include <zlib.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
-#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
free(entry.data);
}
+static time_t source_date_epoch = -1;
+static void set_source_date_epoch() {
+ char *env = getenv("SOURCE_DATE_EPOCH");
+ char *endptr = env;
+ errno = 0;
+ if (env && *env) {
+ source_date_epoch = strtoull(env, &endptr, 10);
+ if (errno || (endptr && *endptr != '\0')) {
+ fprintf(stderr, "Invalid SOURCE_DATE_EPOCH");
+ exit(1);
+ }
+ }
+}
+
/** Generates the partition-table partition */
static struct image_partition_entry make_partition_table(const struct flash_partition_entry *p) {
struct image_partition_entry entry = alloc_image_partition("partition-table", 0x800);
time_t t;
- if (time(&t) == (time_t)(-1))
+ if (source_date_epoch != -1)
+ t = source_date_epoch;
+ else if (time(&t) == (time_t)(-1))
error(1, errno, "time");
struct tm *tm = localtime(&t);
bool add_jffs2_eof = false, sysupgrade = false;
unsigned rev = 0;
const struct device_info *info;
+ set_source_date_epoch();
while (true) {
int c;
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
-#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
-#include <time.h>
#include <unistd.h>
#include <sys/stat.h>