Hi,

Debian tries to make binary packages build reproducible [1].

FFmpeg embeds date and time in the program and documentation, which makes it hard to have binary reproducible packages.

The attached patch allows to specify the build date and time to use with a configure option, solving this problem.

Best regards,
Andreas

1: https://wiki.debian.org/ReproducibleBuilds/About
>From 285003006eb2b9cd1a6e2dcd6351c7f8b3090366 Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
Date: Wed, 21 Jan 2015 22:31:04 +0100
Subject: [PATCH] configure: add --build-date and --build-time options

These allow to make the build binary reproducible by specifying the
date/time that should be used instead of the current date/time.

Signed-off-by: Andreas Cadhalpun <andreas.cadhal...@googlemail.com>
---
 cmdutils.c   |  2 +-
 configure    | 14 ++++++++++++++
 doc/Makefile |  9 +++++++++
 ffprobe.c    |  4 ++--
 4 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/cmdutils.c b/cmdutils.c
index 53268d8..2b467ea 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -1082,7 +1082,7 @@ static void print_program_info(int flags, int level)
                program_birth_year, CONFIG_THIS_YEAR);
     av_log(NULL, level, "\n");
     av_log(NULL, level, "%sbuilt on %s %s with %s\n",
-           indent, __DATE__, __TIME__, CC_IDENT);
+           indent, BUILD_DATE, BUILD_TIME, CC_IDENT);
 
     av_log(NULL, level, "%sconfiguration: " FFMPEG_CONFIGURATION "\n", indent);
 }
diff --git a/configure b/configure
index a0dbafb..4f44cea 100755
--- a/configure
+++ b/configure
@@ -108,6 +108,8 @@ Configuration options:
   --disable-all            disable building components, libraries and programs
   --enable-incompatible-libav-abi enable incompatible Libav fork ABI [no]
   --enable-raise-major     increase major version numbers in sonames [no]
+  --build-date=DATE        DATE is used instead of the build date
+  --build-time=TIME        TIME is used instead of the build time
 
 Program options:
   --disable-programs       do not build command line programs
@@ -1950,6 +1952,8 @@ CMDLINE_SET="
     optflags
     pkg_config
     pkg_config_flags
+    build_date
+    build_time
     progs_suffix
     random_seed
     ranlib
@@ -5712,6 +5716,16 @@ cat > $TMPH <<EOF
 #define SWS_MAX_FILTER_SIZE $sws_max_filter_size
 EOF
 
+if [ -n "$build_date" ] || [ -n "$build_time" ]; then
+    echo "#define BUILD_DATE \"${build_date}\"" >> $TMPH
+    echo "#define BUILD_TIME \"${build_time}\"" >> $TMPH
+    echo "BUILD_DATE=$build_date" >> config.mak
+    echo "BUILD_TIME=$build_time" >> config.mak
+else
+    echo "#define BUILD_DATE __DATE__" >> $TMPH
+    echo "#define BUILD_TIME __TIME__" >> $TMPH
+fi
+
 test -n "$assert_level" &&
     echo "#define ASSERT_LEVEL $assert_level" >>$TMPH
 
diff --git a/doc/Makefile b/doc/Makefile
index 2502922..cef09be 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -88,10 +88,16 @@ ifdef HAVE_MAKEINFO_HTML
 doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.pm $(GENTEXI)
 	$(Q)$(TEXIDEP)
 	$(M)makeinfo --html -I doc --no-split -D config-not-all --init-file=$(SRC_PATH)/doc/t2h.pm --output $@ $<
+ifdef BUILD_DATE
+	sed -i 's_This document was generated on <em>.*</em> using_This document was generated on <em>$(BUILD_DATE)</em> using_' $@
+endif
 
 doc/%-all.html: doc/%.texi $(SRC_PATH)/doc/t2h.pm $(GENTEXI)
 	$(Q)$(TEXIDEP)
 	$(M)makeinfo --html -I doc --no-split -D config-all --init-file=$(SRC_PATH)/doc/t2h.pm --output $@ $<
+ifdef BUILD_DATE
+	sed -i 's_This document was generated on <em>.*</em> using_This document was generated on <em>$(BUILD_DATE)</em> using_' $@
+endif
 else
 doc/%.html: doc/%.texi $(SRC_PATH)/doc/t2h.init $(GENTEXI)
 	$(Q)$(TEXIDEP)
@@ -127,6 +133,9 @@ DOXY_INPUT      = $(addprefix $(SRC_PATH)/, $(INSTHEADERS) $(DOC_EXAMPLES:%$(EXE
 doc/doxy/html: TAG = DOXY
 doc/doxy/html: $(SRC_PATH)/doc/Doxyfile $(SRC_PATH)/doc/doxy-wrapper.sh $(DOXY_INPUT)
 	$(M)$(SRC_PATH)/doc/doxy-wrapper.sh $(SRC_PATH) $< $(DOXYGEN) $(DOXY_INPUT)
+ifdef BUILD_DATE
+	for file in $(M)$(SRC_PATH)/doc/doxy/html/*.html; do sed -i 's/Generated on .* for FFmpeg by/Generated on $(BUILD_DATE) $(BUILD_TIME) for FFmpeg by/' "$$file"; done
+endif
 
 install-doc: install-html install-man
 
diff --git a/ffprobe.c b/ffprobe.c
index 38879f1..f27380d 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -2562,8 +2562,8 @@ static void ffprobe_show_program_version(WriterContext *w)
     print_str("version", FFMPEG_VERSION);
     print_fmt("copyright", "Copyright (c) %d-%d the FFmpeg developers",
               program_birth_year, CONFIG_THIS_YEAR);
-    print_str("build_date", __DATE__);
-    print_str("build_time", __TIME__);
+    print_str("build_date", BUILD_DATE);
+    print_str("build_time", BUILD_TIME);
     print_str("compiler_ident", CC_IDENT);
     print_str("configuration", FFMPEG_CONFIGURATION);
     writer_print_section_footer(w);
-- 
2.1.4

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to