[med-svn] [augustus] 03/03: avoid use of PATH_MAX

Sascha Steinbiss satta at debian.org
Sun Sep 25 12:03:19 UTC 2016


This is an automated email from the git hooks/post-receive script.

satta pushed a commit to branch master
in repository augustus.

commit d659a1835f6e64a991ce5dc5a4b318eade2cce69
Author: Sascha Steinbiss <satta at debian.org>
Date:   Sun Sep 25 12:00:31 2016 +0000

    avoid use of PATH_MAX
---
 debian/changelog                    |  1 +
 debian/patches/avoid_PATH_MAX.patch | 74 +++++++++++++++++++++++++++++++++++++
 debian/patches/series               |  1 +
 3 files changed, 76 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 396d296..e46e20c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ augustus (3.2.2+dfsg-2) UNRELEASED; urgency=medium
 
   * Update uploader email address.
   * Fix manpage option entry.
+  * Avoid use of PATH_MAX. This enables building on Hurd.
 
  -- Sascha Steinbiss <satta at debian.org>  Sun, 25 Sep 2016 11:56:22 +0000
 
diff --git a/debian/patches/avoid_PATH_MAX.patch b/debian/patches/avoid_PATH_MAX.patch
new file mode 100644
index 0000000..48d3f3d
--- /dev/null
+++ b/debian/patches/avoid_PATH_MAX.patch
@@ -0,0 +1,74 @@
+Description: avoid use of PATH_MAX
+ Some platforms, e.g. Hurd, do not define PATH_MAX, however, Augustus
+ assumes it's present. This patch replaces the code using it by an
+ iterative approach growing a string to allow for arbitrarily long paths.
+Author: Sascha Steinbiss <satta at debian.org>
+--- a/src/properties.cc
++++ b/src/properties.cc
+@@ -677,6 +677,30 @@
+ 	    properties[name] = value;
+ }
+ 
++static char* get_self(void)
++{
++  char *path = NULL;
++  size_t allocated = 256;
++
++  while (1) {
++    ssize_t pos = 0;
++    if (!(path = (char*) malloc(allocated)))
++			abort();
++    if ((pos = readlink( "/proc/self/exe", path, allocated - 1 )) != -1)
++			path[pos] = '\0';
++    else {
++			free(path);
++			return NULL;
++    }
++    if (pos < allocated - 1)
++			break;
++    free(path);
++    allocated *= 2;
++  }
++	return path;
++}
++
++
+ string findLocationOfSelfBinary(){
+     string self;
+ 
+@@ -690,18 +714,23 @@
+ 	// need to program workaround with new/free.\n";
+     }
+ #else // LINUX
+-    char path[PATH_MAX];
+-    ssize_t pos = readlink( "/proc/self/exe", path, PATH_MAX-1 );
+-    if (pos > 0){
+-        self = string(path);
+-	pos = self.find_last_of("/");
+-	if (pos>0)
+-	    pos = self.find_last_of("/", pos-1);
+-	if (pos >= 0)
+-	    self.resize(pos);
+-	self += "/config";
+-    } else 
+-	throw ProjectError("/proc/self/exe not found.\nPlease specify environment variable or parameter " CFGPATH_KEY ".");
++		char *path = get_self();
++		ssize_t pos = 0;
++		if (path)
++			pos = strlen(path);
++		if (pos > 0){
++				self = string(path);
++				free(path);
++				pos = self.find_last_of("/");
++				if (pos>0)
++				    pos = self.find_last_of("/", pos-1);
++				if (pos >= 0)
++				    self.resize(pos);
++				self += "/config";
++		} else {
++			free(path);
++	    throw ProjectError("/proc/self/exe not found.\nPlease specify environment variable or parameter " CFGPATH_KEY ".");
++		}
+ #endif // WINDOWS not supported
+     return self;
+ }
diff --git a/debian/patches/series b/debian/patches/series
index 8e23e91..79716c2 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,3 +2,4 @@ search_config_path
 set_installdir
 keep_cflags
 buildflags.patch
+avoid_PATH_MAX.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/augustus.git



More information about the debian-med-commit mailing list