Package: imagemagick Version: 7:6.5.5.3-1 Severity: important Tags: patch User: debian-h...@lists.debian.org Usertags: hurd
Hi, as shown in [1], currently imagemagick does not build on GNU/Hurd. The reason is in magick/utility.c, in the implementation of GetExecutionPath(): Hurd has both getpid() and readlink(), so the #if defined(MAGICKCORE_HAVE_GETPID) && defined(MAGICKCORE_HAVE_READLINK) [...] #endif code block is used. Although, this block has two problems for Hurd: - inconditional usage of PATH_MAX (which is not a problem, as it could be fixed) - use of /proc/$PID/{exe,file}; Hurd's proc have none of those two, so the code there would be unuseful anyway The solution I chose was to exclude that block for Hurd, and add a new Hurd-specific block which makes use of the GNU-specific program_invocation_name extern variable (see /usr/include/errno.h) - and cwd if program_invocation_name is relative - to get the absolute path of the execution application. [1] http://buildd.debian-ports.org/fetch.php?&pkg=imagemagick&ver=7:6.5.5.3-1&arch=hurd-i386&stamp=1251687730&file=log&as=raw Thanks, -- Pino
--- imagemagick-6.5.5.3.orig/magick/utility.c +++ imagemagick-6.5.5.3/magick/utility.c @@ -904,7 +904,7 @@ *path='\0'; cwd=getcwd(path,(unsigned long) extent); -#if defined(MAGICKCORE_HAVE_GETPID) && defined(MAGICKCORE_HAVE_READLINK) +#if defined(MAGICKCORE_HAVE_GETPID) && defined(MAGICKCORE_HAVE_READLINK) && !defined(__GNU__) { char link_path[MaxTextExtent], @@ -961,6 +961,46 @@ #if defined(__WINDOWS__) NTGetExecutionPath(path,extent); #endif +#if defined(__GNU__) + { + char + *buffer, + *exec_path; + + MagickBooleanType + free_buffer; + + size_t + buffer_length; + + long + count; + + free_buffer = MagickFalse; + count = 0; + exec_path = NULL; + if (program_invocation_name[0] == '/') + { + buffer = program_invocation_name; + } + else + { + buffer_length = strlen(cwd) + 1 + strlen(program_invocation_name) + 1; + buffer = malloc(buffer_length); + free_buffer = MagickTrue; + count = FormatMagickString(buffer,buffer_length,"%s/%s",cwd,program_invocation_name); + } + if (count != -1) + { + exec_path = realpath(buffer,NULL); + if (exec_path) + CopyMagickString(path,exec_path,extent); + } + if (free_buffer) + free(buffer); + free(exec_path); + } +#endif return(IsPathAccessible(path)); }