Skip to content

Commit

Permalink
Improve reproducibility if SOURCE_DATE_EPOCH if set (GH pull/89).
Browse files Browse the repository at this point in the history
configure.ac: Define SOURCE_DATE_EPOCH in CPPFLAGS.
utility.cpp: Print SOURCE_DATE_EPOCH value if specified.
Don't include configure arguments then.
cppcheck.sh: Silence related 'ConfigurationNotChecked' message.

git-svn-id: http://svn.code.sf.net/p/smartmontools/code/trunk@5201 4ea69e1a-61f1-4043-bf83-b5c94c648137
  • Loading branch information
chrfranke committed Feb 7, 2021
1 parent 5279a70 commit 2483891
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions smartmontools/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ $Id$

2021-02-07 Christian Franke <franke@computer.org>

Improve reproducibility if SOURCE_DATE_EPOCH if set (GH pull/89).
configure.ac: Define SOURCE_DATE_EPOCH in CPPFLAGS.
utility.cpp: Print SOURCE_DATE_EPOCH value if specified.
Don't include configure arguments then.
cppcheck.sh: Silence related 'ConfigurationNotChecked' message.

Always add timestamp to JSON output (#1436).
Move non-JSON timestamp output to common function.

Expand Down
12 changes: 12 additions & 0 deletions smartmontools/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ case "${host}" in
;;
esac

AC_MSG_CHECKING([whether reproducible build is selected (SOURCE_DATE_EPOCH)])
res=no
if test -n "$SOURCE_DATE_EPOCH"; then
res=yes
test -z "`echo "$SOURCE_DATE_EPOCH" | sed 's,[[0-9]]*,,'`" || res=error
fi
AC_MSG_RESULT([$res])
case $res in
error) AC_MSG_ERROR([Malformed SOURCE_DATE_EPOCH]) ;;
yes) CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-DSOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH" ;;
esac

# Check for SVN.
AC_MSG_CHECKING([whether this is a build from SVN])
is_svn_build=no
Expand Down
1 change: 1 addition & 0 deletions smartmontools/cppcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ defs="\
-DSMARTMONTOOLS_ATTRIBUTELOG=\"/file\"
-DSMARTMONTOOLS_SAVESTATES=\"/file\"
-DSMARTMONTOOLS_DRIVEDBDIR=\"/dir\"
-DSOURCE_DATE_EPOCH=1665402854
-Umakedev
-Ustricmp"

Expand Down
10 changes: 10 additions & 0 deletions smartmontools/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,19 @@ std::string format_version_info(const char * prog_name, bool full /*= false*/)
#endif
"\n"
"smartmontools configure arguments:"
#ifdef SOURCE_DATE_EPOCH
" [hidden in reproducible builds]\n"
"reproducible build SOURCE_DATE_EPOCH: "
#endif
;
#ifdef SOURCE_DATE_EPOCH
char ts[32]; struct tm tmbuf;
strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S", time_to_tm_local(&tmbuf, SOURCE_DATE_EPOCH));
info += strprintf("%u (%s)", (unsigned)SOURCE_DATE_EPOCH, ts);
#else
info += (sizeof(SMARTMONTOOLS_CONFIGURE_ARGS) > 1 ?
SMARTMONTOOLS_CONFIGURE_ARGS : " [no arguments given]");
#endif
info += '\n';

return info;
Expand Down

0 comments on commit 2483891

Please sign in to comment.