libphonenumber: fix reproducible builds patch

Now actually sorts the directory listings

Fixes https://github.com/NixOS/nixpkgs/issues/276443

Changed files
+20 -15
pkgs
development
libraries
+18 -14
pkgs/development/libraries/libphonenumber/build-reproducibility.patch
··· 1 - diff --git a/tools/cpp/src/cpp-build/generate_geocoding_data.cc b/tools/cpp/src/cpp-build/generate_geocoding_data.cc 2 - index 205947e831..1e628e2cd2 100644 3 - --- a/tools/cpp/src/cpp-build/generate_geocoding_data.cc 4 - +++ b/tools/cpp/src/cpp-build/generate_geocoding_data.cc 5 - @@ -97,7 +97,8 @@ class DirEntry { 1 + --- a/tools/cpp/src/cpp-build/generate_geocoding_data.cc.orig 1970-01-01 01:00:01.000000000 +0100 2 + +++ b/tools/cpp/src/cpp-build/generate_geocoding_data.cc 2024-01-16 19:03:45.409089423 +0100 3 + @@ -94,7 +94,8 @@ 6 4 DirEntryKinds kind_; 7 5 }; 8 6 ··· 12 10 // success. 13 11 bool ListDirectory(const string& path, vector<DirEntry>* entries) { 14 12 entries->clear(); 15 - @@ -135,6 +136,9 @@ bool ListDirectory(const string& path, vector<DirEntry>* entries) { 13 + @@ -114,8 +115,14 @@ 14 + // http://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html 15 + errno = 0; 16 + entry = readdir(dir); 17 + + if (errno != 0) { 18 + + return false; 19 + + } 20 + if (entry == NULL) { 21 + - return errno == 0; 22 + + std::sort( 23 + + entries->begin(), entries->end(), 24 + + [](const DirEntry& a, const DirEntry& b) { return a.name() < b.name(); }); 25 + + return true; 16 26 } 17 - entries->push_back(DirEntry(entry->d_name, kind)); 18 - } 19 - + std::sort( 20 - + entries->begin(), entries->end(), 21 - + [](const DirEntry& a, const DirEntry& b) { return a.name() < b.name(); }); 22 - } 23 - 24 - // Returns true if s ends with suffix. 27 + if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) { 28 + continue;
+2 -1
pkgs/development/libraries/libphonenumber/default.nix
··· 12 12 }; 13 13 14 14 patches = [ 15 - # Submitted upstream: https://github.com/google/libphonenumber/pull/2921 15 + # An earlier version of this patch was submitted upstream but did not get 16 + # any interest there - https://github.com/google/libphonenumber/pull/2921 16 17 ./build-reproducibility.patch 17 18 ]; 18 19