A new user interface for you! Read more...

File reproducible.patch of Package bam

commit ca28a91991e1b2e4a579bc3f80a20b60cffa550d
Author: Bernhard M. Wiedemann <bwiedemann@suse.de>
Date:   Thu Jun 1 08:08:41 2017 +0200

    listdirectory: use scandir instead of readdir
    
    in order to have sorted directory entries
    to enable reproducible builds
    fix issue #111

diff --git a/src/support.c b/src/support.c
index dae01cc..7be6857 100644
--- a/src/support.c
+++ b/src/support.c
@@ -304,7 +304,8 @@
 
 	void file_listdirectory(const char *path, void (*callback)(const char *filename, int dir, void *user), void *user)
 	{
-		DIR *dir;
+		struct dirent **namelist;
+		int n;
 		struct dirent *entry;
 		struct stat info;
 		char buffer[1024];
@@ -324,14 +325,15 @@
 			*startpoint = 0;
 		}
 		
-		dir = opendir(buffer);
-		if(!dir)
+		n = scandir(buffer, &namelist, NULL, alphasort);
+		if(n == -1)
 			return;
 		
-		while((entry = readdir(dir)) != NULL)
+		while(n--)
 		{
 			int isdir;
 			int have_d_type = 0;
+			entry = namelist[n];
 			/* make the path absolute */
 			strcpy(startpoint, entry->d_name);
 #ifdef D_TYPE_HACK
@@ -346,11 +348,12 @@
 				stat(buffer, &info);
 				isdir = S_ISDIR(info.st_mode);
 			}
+			free(entry);
 			/* call the callback */
 			callback(buffer, isdir, user);
 		}
 		
-		closedir(dir);
+		free(namelist);
 	}
 
 	/* signals. should be moved to platform.c or similar? */