Re: Bug#654767: transfig: FTBFS(kfreebsd): File `overlay-sample-0.pdf' not found.
tags 654767 + patch
thanks
Hi,
This was reproducible on my kfreebsd-i386 system; with ktrace I can see
that fig2dev does an improper chmod on the shell script it generates.
The problem code is supplied from debian/patches/14_fig2mpdf.patch
Short answer:
It just needs to include sys/stat.h
Long answer:
(Yes, I only realised the above after writing all this!)
fig2dev tries to does a shift-and-OR on a mode_t to try to make the
script executable only for users who could read it:
> fig2dev/dev/genpstex.c:173: fchmod (fileno(ptCreateFile), tStat.st_mode | ((tStat.st_mode & (S_IRUSR | S_IRGRP | S_IROTH)) >> 2));
This had me puzzled because, although a bit fancy, it looks like it
should work okay here. With kFreeBSD's macro definitions substituted:
> fchmod (fileno(ptCreateFile), tStat.st_mode | ((tStat.st_mode & (0400 | (0400 >> 3) | ((0400 >> 3) >> 3))) >> 2));
The original mode would appear to be 0644 in the ktrace below, the
bitwise AND should then produce 444, shift that to 111, and OR back in
to give 0755.
The actual calculated new mode_t is 0001 though.
The bitwise arithmetic is possibly converting to a signed int, and
doesn't have the fchmod function prototype time, but on BSD platforms
mode_t is an unsigned short int. With -Wall:
> genpstex.c:173:2: warning: implicit declaration of function ‘fchmod’ [-Wimplicit-function-declaration]
ktrace:
> 27796 100362 fig2dev CALL open(0x80e62c0,0x601<><invalid>1537,0x1b6<><invalid>438)
> 27796 100362 fig2dev NAMI "_fig2mpdfoverlay-sample-0_inp.create"
> 27796 100362 fig2dev RET open 4
> 27796 100362 fig2dev CALL fstat(0x4,0xbfbfe0e8)
> 27796 100362 fig2dev STRU struct stat {dev=2340379690, ino=586182, mode=-rw-r--r-- , nlink=1, uid=1000, gid=1000, rdev=4294967295, atime=1334148528.102033354, stime=133414852
> 8.102033354, ctime=1334148528.102033354, birthtime=1334148528.102033354, size=0, blksize=131072, blocks=1, flags=0x0 }
> 27796 100362 fig2dev RET fstat 0
> 27796 100362 fig2dev CALL fchmod(0x4,0x1<><invalid>1)
> 27796 100362 fig2dev RET fchmod 0
> 27796 100362 fig2dev CALL fstat(0x4,0xbfbfda20)
> 27796 100362 fig2dev STRU struct stat {dev=2340379690, ino=586182, mode=---------x , nlink=1, uid=1000, gid=1000, rdev=4294967295, atime=1334148528.102033354, stime=133414852
> 8.102033354, ctime=1334148528.102995492, birthtime=1334148528.102995492, size=0, blksize=131072, blocks=1, flags=0x0 }
> 27796 100362 fig2dev RET fstat 0
> 27796 100362 fig2dev CALL write(0x4,0x2858e000,0x21b)
> 27796 100362 fig2dev GIO fd 4 wrote 539 bytes
> "#!/bin/bash
>
> while getopts "r" Option
> do
> case $Option in
> r) iOptRemove=1;;
> *) echo "illegal option -$Option"
> esac
> done
> shift $(($OPTIND - 1))
> if [ "$iOptRemove" == "" ]; then
> echo "\\setlength\\pdfpagewidth{69.43pt}\\setlength\\pdfpageheight{159.22pt}" > _fig2mpdfoverlay-sample-0_inp.size
> else
> rm -f _fig2mpdfoverlay-sample-0_inp.size
> fi
> if [ "$iOptRemove" == "" ]; then
> fig2dev -L pstex -D +53:53 overlay-sample.lfig | epstopdf -f > _fig2mpdfoverlay-sample-0_inp000.pdf
> else
> rm -f _fig2mpdfoverlay-sample-0_inp000.pdf
> fi
> "
> 27796 100362 fig2dev RET write 539/0x21b
> 27796 100362 fig2dev CALL close(0x4)
Regards,
--
Steven Chamberlain
steven@pyro.eu.org
Index: transfig-3.2.5.d/fig2dev/dev/genpstex.c
===================================================================
--- transfig-3.2.5.d.orig/fig2dev/dev/genpstex.c 2012-04-11 13:29:16.000000000 +0100
+++ transfig-3.2.5.d/fig2dev/dev/genpstex.c 2012-04-11 15:18:12.622216281 +0100
@@ -37,6 +37,7 @@
* Jose Alberto.
*/
+#include <sys/stat.h>
#include "fig2dev.h"
#include "genps.h"
#include "genpdf.h"
Reply to: