Source: afterstep
Version: 2.2.12-5
Severity: wishlist
Tags: patch
User: reproducible-builds@lists.alioth.debian.org
Usertags: timestamps

Hi!

While working on the "reproducible builds" effort [1], we have noticed
that afterstep could not be built reproducibly.

The three attached patches removes extra timestamps from the build system:

* 47-Add-build-date-to-AsDocGen.patch: modifies ASDocGen binary to add the
  --build-date flag that expects an unix time (integer) and use it for
  timestamps in generated files (documentation).

* 48-Make-build-reproducible.patch: modifies Makefile.in adding the
  variable ASDOCGENOPTS to the command line of ASDocGen.

* debian-rules.patch: modifies the debian/rules file to get the unix
  time from the changelog file and set the variable ASDOCGENOPTS.

Once applied, afterstep can be built reproducibly in our current experimental
framework.

 [1]: https://wiki.debian.org/ReproducibleBuilds


-- System Information:
Debian Release: stretch/sid
  APT prefers testing-updates
  APT policy: (500, 'testing-updates'), (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.16.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Description: Add build-date flag
 Add build-date flag for use the given unix time instead current time in
 timestamps.
Author: Juan Picca <jumap...@gmail.com>
Last-Update: 2015-05-18
---
--- a/src/ASDocGen/ASDocGen.c
+++ b/src/ASDocGen/ASDocGen.c
@@ -195,14 +195,15 @@ asdocgen_usage (void)
 	printf ("Usage:\n"
 			"%s\t\t[-t |--target plain|text|html|php|xml|nroff|source] [-s | -css stylesheets_file]\n"
 			"\t\t\t[--faq-css stylesheets_file] [--html-data-back background] [-d | --data]\n"
-			"\t\t\t[-S | --source source_dir] [-D | --dst destination_dir]\n"
+			"\t\t\t[-S | --source source_dir] [-D | --dst destination_dir] [--build-date unixtime]\n"
 			"-t | --target 		- selects oputput file format\n"
 			"-s | --css 		- selects which file to get HTML style sheets from\n"
 			"     --faq-css    	- selects which file to get HTML style sheets from for FAQs\n"
 			"	  --html-data-back - which image file to use as HTML background ( default background.jpg )\n"
 			"-d | --data        - generate HTML catalogue of image/data files\n"
 			"-S | --source      - specifies dir to read XML source or data source from\n"
-			"-D | --dst         - specifies destination directory - where to wriote stuff to\n",
+			"-D | --dst         - specifies destination directory - where to wriote stuff to\n"
+			"     --build-date  - uses the given unix time instead current time\n",
 			MyName);
 	exit (0);
 }
@@ -215,6 +216,8 @@ main (int argc, char **argv)
 	char *source_dir = NULL ;
 	const char *destination_dir = NULL ;
 	Bool do_data = False;
+	Bool use_build_date = False;
+	time_t build_date;
 	ASDocType target_type = DocType_Source ;
 	/* Save our program name - for error messages */
 	set_DeadPipe_handler(DeadPipe);
@@ -269,6 +272,17 @@ main (int argc, char **argv)
 			{
 				++i ;				
 				destination_dir = argv[i] ;
+			}else if( strcmp( argv[i], "--build-date" ) == 0 && i+1 < argc && argv[i+1] != NULL )
+			{
+				++i ;
+				struct tm tm;
+				if( strptime(argv[i], "%s", &tm) == NULL)
+					show_error( "invalid unix time \"%s\"", argv[i] );
+				else
+				{
+					build_date = mktime(&tm);
+					use_build_date = True;
+				}
 			}
 		}
 	}		  
@@ -295,7 +309,6 @@ main (int argc, char **argv)
 	TopicIndexName = UserTopicIndexName ; 
 
 	if( target_type < DocType_Source ) {	
-		time_t curtime;
    	struct tm *loctime;
 		ASHashData hashd;
 		
@@ -306,9 +319,15 @@ main (int argc, char **argv)
 		}
 		
 		/* Get the current time. */
-		curtime = time (NULL);
-     	/* Convert it to local time representation. */
-		loctime = localtime (&curtime);
+		if( use_build_date )
+			loctime = gmtime (&build_date);
+		else
+		{
+			time_t curtime = time (NULL);
+			/* Convert it to local time representation. */
+			loctime = localtime (&curtime);
+		}
+
 		strftime(CurrentDateLong, DATE_SIZE, "%b %e %Y", loctime);
 		strftime(CurrentDateShort, DATE_SIZE, "%m/%d/%Y", loctime);
 	}
Description: Add variable for ASDocGen options in Makefile.in
 Add variable ASDOCGENOPTS in Makefile.in to pass extra options to ASDocGen
 when build the documentation.
Author: Juan Picca <jumap...@gmail.com>
Last-Update: 2015-05-19
---
--- a/src/ASDocGen/Makefile.in
+++ b/src/ASDocGen/Makefile.in
@@ -1,3 +1,6 @@
+# You can set these variables from the command line.
+ASDOCGENOPTS	=
+
 OBJS		= ASDocGen.o datadoc.o docfile.o robodoc.o xmlproc.o
 
 PROG		= ASDocGen
@@ -18,18 +21,18 @@ do_compile:    $(OBJS) $(LIBS_DEPEND) Ma
 		@touch do_compile
 
 doc_man:	do_compile
-		@echo -n "Generating man pages ..." ; ./ASDocGen -l log.man -t nroff ; echo "Done" ; touch doc_man
+		@echo -n "Generating man pages ..." ; ./ASDocGen -l log.man -t nroff $(ASDOCGENOPTS) ; echo "Done" ; touch doc_man
 
 doc_html:    	do_compile
-		@echo -n "Generating HTML docs ..." ; ./ASDocGen -l log.html -t html ; echo "Done" ; \
+		@echo -n "Generating HTML docs ..." ; ./ASDocGen -l log.html -t html $(ASDOCGENOPTS) ; echo "Done" ; \
 		echo -n "Extracting Visualselect HTML ..." ; tar xf visualselect4html.tar -C html ; echo "Done" ; \
 		touch doc_html
 
 doc_xml:	do_compile
-		@echo -n "Generating XML docs ..." ; ./ASDocGen -l log.xml -t xml ; echo "Done" ; touch doc_xml
+		@echo -n "Generating XML docs ..." ; ./ASDocGen -l log.xml -t xml $(ASDOCGENOPTS) ; echo "Done" ; touch doc_xml
 
 doc_text:    	do_compile
-		@echo -n "Generating Plain Text docs ..." ; ./ASDocGen -l log.text -t plain ; echo "Done" ; touch doc_text
+		@echo -n "Generating Plain Text docs ..." ; ./ASDocGen -l log.text -t plain $(ASDOCGENOPTS) ; echo "Done" ; touch doc_text
 
 data_php:  	do_compile
 		@echo "Generating PHP catalogue of installed data files ..." ; \
@@ -37,7 +40,7 @@ data_php:  	do_compile
 		FONT_PATH="$HOME/.afterstep/desktop/fonts/:/usr/local/share/afterstep/desktop/fonts/:/usr/share/fonts/default/TrueType/:/usr/X11R6/lib/X11/fonts/TTF"; \
 		IMAGE_PATH="$HOME/.afterstep/desktop/icons/:/usr/local/share/afterstep/desktop/icons/:$HOME/.afterstep/desktop/:/usr/local/share/afterstep/desktop/:$HOME/.afterstep/desktop/buttons/:/usr/local/share/afterstep/desktop/buttons/:$HOME/.afterstep/backgrounds/:/usr/local/share/afterstep/backgrounds/:/usr/X11R6/include/X11/pixmaps/"; \
 		export IMAGE_PATH; export FONT_PATH; \
-		./ASDocGen -t php --data --css data_html_styles.css -S $(AFTER_SHAREDIR) -D data/php -l /log.data.php.log  ; \
+		./ASDocGen -t php --data --css data_html_styles.css -S $(AFTER_SHAREDIR) -D data/php -l /log.data.php.log $(ASDOCGENOPTS) ; \
 		IMAGE_PATH=$(old_IMAGE_PATH); FONT_PATH=$(old_FONT_PATH); \
 		export IMAGE_PATH; export FONT_PATH; \
 		echo "Done"
@@ -86,7 +89,7 @@ install.data_html:  do_compile
 			FONT_PATH="@with_afterdir@/desktop/fonts/:@datarootdir@/afterstep/desktop/fonts/:/usr/share/fonts/default/TrueType/:@x_libraries@/X11/fonts/TTF"; \
 			IMAGE_PATH="@with_afterdir@/desktop/icons/:@datarootdir@/afterstep/desktop/icons/:@with_afterdir@/desktop/:@datarootdir@/afterstep/desktop/:@with_afterdir@/desktop/buttons/:@datarootdir@/afterstep/desktop/buttons/:@with_afterdir@/backgrounds/:@datarootdir@/afterstep/backgrounds/:@x_includes@/X11/pixmaps/"; \
 			export IMAGE_PATH; export FONT_PATH; \
-			./ASDocGen -t html --data --css data_html_styles.css -S $(AFTER_SHAREDIR) -D $(AFTER_DOC_DIR)/html/data -l /dev/null  ; \
+			./ASDocGen -t html --data --css data_html_styles.css -S $(AFTER_SHAREDIR) -D $(AFTER_DOC_DIR)/html/data -l /dev/null $(ASDOCGENOPTS) ; \
 			IMAGE_PATH=$(old_IMAGE_PATH); FONT_PATH=$(old_FONT_PATH); \
 			export IMAGE_PATH; export FONT_PATH; \
 			echo "Done"; \
diff -rupN afterstep-2.2.12.old/debian/rules afterstep-2.2.12/debian/rules
--- afterstep-2.2.12.old/debian/rules	2015-05-17 10:03:13.000000000 +0000
+++ afterstep-2.2.12/debian/rules	2015-05-19 17:51:04.811928049 +0000
@@ -1,6 +1,8 @@
 #!/usr/bin/make -f
 # Uncomment this to turn on verbose mode.
 # export DH_VERBOSE=1
+LAST_CHANGE=$(shell dpkg-parsechangelog -S Date)
+BUILD_DATE=$(shell date +%s -d "$(LAST_CHANGE)")
 
 SHELL                   := /bin/sh
 DH_AUTO_OPTIONS         := -v -Sautoconf
@@ -71,7 +73,7 @@ endef
 # Usage: call(common-build,additional make args)
 define common-build
    dh_auto_build $(DH_AUTO_OPTIONS) --parallel -- \
-   SHELL="$(SHELL) -e" \
+   SHELL="$(SHELL) -e" ASDOCGENOPTS="--build-date $(BUILD_DATE)" \
    $1
 endef
 
_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to