Bug#860731: viruskiller: please make the build reproducible

Chris Lamb lamby at debian.org
Wed Apr 19 13:35:02 UTC 2017


Source: viruskiller
Version: 1.03-1+dfsg1-1
Severity: wishlist
Tags: patch
User: reproducible-builds at lists.alioth.debian.org
Usertags: fileordering
X-Debbugs-Cc: reproducible-bugs at lists.alioth.debian.org

Hi,

Whilst working on the Reproducible Builds effort [0], we noticed
that viruskiller could not be built reproducibly.

This due to the build system assembling the .pak file by iterating
over the filesystem in a non-determinstic order.

Patch attached that uses scandir with the alphasort argument.

 [0] https://reproducible-builds.org/


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      lamby at debian.org / chris-lamb.co.uk
       `-
-------------- next part --------------
--- a/debian/patches/reproducible-build.patch	1970-01-01 01:00:00.000000000 +0100
--- b/debian/patches/reproducible-build.patch	2017-04-19 14:29:49.480885008 +0100
@@ -0,0 +1,72 @@
+--- viruskiller-1.03-1+dfsg1.orig/src/pak.cpp
++++ viruskiller-1.03-1+dfsg1/src/pak.cpp
+@@ -88,19 +88,19 @@ void countFiles(const char *dirName)
+ 
+ void recurseDirectory(const char *dirName)
+ {
+-	DIR *dirp, *dirp2;
+-	dirent *dfile;
++	int n;
++	DIR *dirp2;
+ 	gzFile fp;
+ 	FILE *infile;
+ 	char filename[1024];
++	struct dirent **namelist;
+ 
+ 	uLongf cSize = 0;
+ 	uLongf fSize = 0;
+ 
+-	dirp = opendir(dirName);
+ 
+-	if (dirp == NULL)
+-	{
++	n = scandir(dirName, &namelist, NULL, alphasort);
++	if (n == -1) {
+ 		printf("%s: Directory does not exist or is not accessible\n", dirName);
+ 		return;
+ 	}
+@@ -108,14 +108,14 @@ void recurseDirectory(const char *dirNam
+ 	float percentage;
+ 	long filesize;
+ 
+-	while ((dfile = readdir(dirp)))
++	while (n--)
+ 	{
+-		if (dfile->d_name[0] == '.')
++		if (namelist[n]->d_name[0] == '.')
+ 		{
+ 			continue;
+ 		}
+ 
+-		sprintf(filename, "%s/%s", dirName, dfile->d_name);
++		sprintf(filename, "%s/%s", dirName, namelist[n]->d_name);
+ 
+ 		dirp2 = opendir(filename);
+ 
+@@ -130,7 +130,7 @@ void recurseDirectory(const char *dirNam
+ 			if (!infile)
+ 			{
+ 				printf("Couldn't open %s for reading!\n", filename);
+-				closedir(dirp);
++				free(namelist);
+ 				fclose(pak);
+ 				exit(1);
+ 			}
+@@ -162,7 +162,7 @@ void recurseDirectory(const char *dirNam
+ 			if (!fp)
+ 			{
+ 				printf("Couldn't open %s for reading!\n", filename);
+-				closedir(dirp);
++				free(namelist);
+ 				fclose(pak);
+ 				exit(1);
+ 			}
+@@ -190,7 +190,7 @@ void recurseDirectory(const char *dirNam
+ 		}
+ 	}
+ 
+-	closedir(dirp);
++	free(namelist);
+ 
+ 	dirs++;
+ }
--- a/debian/patches/series	2017-04-19 14:22:26.530841180 +0100
--- b/debian/patches/series	2017-04-19 14:27:26.820224965 +0100
@@ -8,3 +8,4 @@
 0009-start-with-fewer-directories.patch
 0010-mismatched-delete.patch
 0011-remove-bad-gzclose.patch
+reproducible-build.patch


More information about the Pkg-games-devel mailing list