Skip to content

Commit

Permalink
Make the build reproducible if SOURCE_DATE_EPOCH is set.
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen M. Cameron <stephenmcameron@gmail.com>
  • Loading branch information
lamby authored and smcameron committed Jan 18, 2017
1 parent 9d77b4c commit c890eb3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions stamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ int main(int argc, char *argv[])
{
struct timeval tv;
int uid;
char *source_date_epoch;

gettimeofday(&tv, NULL);
uid = getuid();

source_date_epoch = getenv("SOURCE_DATE_EPOCH");
if (source_date_epoch) {
printf("static int builder = 0;\n");
printf("static uint64_t builtat = %s;\n", source_date_epoch);
exit(0);
}

printf("static int builder = %d;\n", uid);
printf("static uint64_t builtat = %d;\n", tv.tv_sec);

Expand Down

0 comments on commit c890eb3

Please sign in to comment.