Skip to content

Commit

Permalink
Merge pull request #171 from mr-c/reproducible
Browse files Browse the repository at this point in the history
Enable reproducible build
  • Loading branch information
gmarcais committed Oct 5, 2021
2 parents 358b7f7 + b6315b8 commit b9dff7d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/jellyfish/generic_file_header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,17 @@ class generic_file_header {

protected:
std::string get_hostname() const {
if(std::getenv("SOURCE_DATE_EPOCH"))
return "hostname";
struct utsname buf;
if(uname(&buf) == -1)
return "";
return buf.nodename;
}

std::string get_pwd() const {
if(std::getenv("SOURCE_DATE_EPOCH"))
return ".";
#ifdef PATH_MAX
size_t len = PATH_MAX;
#else
Expand All @@ -194,6 +198,16 @@ class generic_file_header {
std::string get_localtime() const {
time_t t = time(0);
std::string res(ctime(&t));
char *source_date_epoch = std::getenv("SOURCE_DATE_EPOCH");
if(source_date_epoch) {
std::istringstream iss(source_date_epoch);
iss >> t;
if(iss.fail() || !iss.eof()) {
std::cerr << "Error: Cannot parse SOURCE_DATE_EPOCH as integer\n";
exit(27);
}
res = asctime(gmtime(&t));
}
chomp(res);
return res;
}
Expand Down

0 comments on commit b9dff7d

Please sign in to comment.