Bug 1062

Summary: rescale-pdf not working
Product: ns-3 Reporter: Nicola Baldo <nicola>
Component: documentationAssignee: Tom Henderson <tomh>
Status: RESOLVED FIXED    
Severity: major CC: jpelkey, ns-bugs
Priority: P5    
Version: ns-3-dev   
Hardware: All   
OS: All   

Description Nicola Baldo 2011-02-24 08:38:03 EST
I am trying to build the manual with latest ns-3-dev (r6828)
The build stops at the first time rescale-pdf.sh is to be executed:

nicola@pcnbaldo:~/locale/ns-3-dev/doc/manual$ make html
dia -t eps figures/internet-node-send.dia -e figures/internet-node-send.eps
figures/internet-node-send.dia --> figures/internet-node-send.eps
[snip]
dia -t png figures/auvmobility-classes.dia -e figures/auvmobility-classes.png
figures/auvmobility-classes.dia --> figures/auvmobility-classes.png
epstopdf figures/internet-node-send.eps -o=figures/internet-node-send.pdf; if test x5in != x; then TMPFILE=`mktemp`; ./rescale-pdf.sh 5in figures/internet-node-send.pdf ${TMPFILE} && mv ${TMPFILE} figures/internet-node-send.pdf; fi

I can make the build continue if I disable rescale-pdf in this way:

diff -r 26b3f160b071 doc/manual/Makefile
--- a/doc/manual/Makefile	Wed Feb 23 23:05:02 2011 +0000
+++ b/doc/manual/Makefile	Thu Feb 24 14:23:23 2011 +0100
@@ -46,7 +46,9 @@
 
 %.eps : %.dia; $(DIA) -t eps $< -e $@
 %.png : %.dia; $(DIA) -t png $< -e $@
-%.pdf : %.eps; $(EPSTOPDF) $< -o=$@; if test x$($@_width) != x; then TMPFILE=`mktemp`; ./rescale-pdf.sh $($@_width) $@ $${TMPFILE} && mv $${TMPFILE} $@; fi
+%.pdf : %.eps; $(EPSTOPDF) $< -o=$@
+
+#; if test x$($@_width) != x; then TMPFILE=`mktemp`; ./rescale-pdf.sh $($@_width) $@ $${TMPFILE} && mv $${TMPFILE} $@; fi
 
 
Besides, I think there is an error in rescale-pdf.sh:

diff -r 26b3f160b071 doc/manual/rescale-pdf.sh
--- a/doc/manual/rescale-pdf.sh	Wed Feb 23 23:05:02 2011 +0000
+++ b/doc/manual/rescale-pdf.sh	Thu Feb 24 14:23:23 2011 +0100
@@ -4,7 +4,7 @@
 
 echo "\documentclass{book}
 \usepackage{pdfpages}
-\\begin{document}
+\begin{document}
 \includepdf[width=${1},fitpaper]{${2}}
 \end{document}" >${TMPFILE}.tex
 pdflatex -output-directory /tmp ${TMPFILE}.tex >/dev/null 2>/dev/null
Comment 1 Josh Pelkey 2011-02-24 09:37:46 EST
I am not doubting your problems, but this seems to go ok on the code server. I just updated the manual "manually" and the logfile showed everything completing. There were quite a few warnings however.
Comment 2 Nicola Baldo 2011-02-24 09:54:51 EST
(In reply to comment #1)
> I am not doubting your problems, but this seems to go ok on the code server. I
> just updated the manual "manually" and the logfile showed everything
> completing. There were quite a few warnings however.

I understand that the build works on the code server, but if it fails on other platforms I consider it a bug. I am using Ubuntu 10.04 LTS.

If there is any additional test that might help, I'd be happy to do it.
Comment 3 Josh Pelkey 2011-02-24 10:04:00 EST
I am inclined to agree. The problems are likely due to version differences in other programs like dia, latex, sphinx, etc. For example, it looks like you are using sphinx v0.6.4, while on the server, we have v1.0.7. I don't doubt we should take a look at this. I just wanted to point out that it works on some machines.

(In reply to comment #2)
> (In reply to comment #1)
> > I am not doubting your problems, but this seems to go ok on the code server. I
> > just updated the manual "manually" and the logfile showed everything
> > completing. There were quite a few warnings however.
> 
> I understand that the build works on the code server, but if it fails on other
> platforms I consider it a bug. I am using Ubuntu 10.04 LTS.
> 
> If there is any additional test that might help, I'd be happy to do it.
Comment 4 Josh Pelkey 2011-02-24 11:15:51 EST
FYI, this happened on my Ubuntu machine too. Checking the logs, it looks like this is an escaping issue in rescale-pdf. Changing \\begin{document} to \\\begin{document} fixed it for me.

After checking the revisions of rescale-pdf.sh on the code server (http://code.nsnam.org/ns-3-dev/log/f1f595e0ea3c/doc/manual/rescale-pdf.sh) it looks like Tom noticed this, but reverted it. Not sure why, maybe it works on the code server with only one escape character.
Comment 5 Josh Pelkey 2011-02-24 13:05:05 EST
(In reply to comment #4)
> FYI, this happened on my Ubuntu machine too. Checking the logs, it looks like
> this is an escaping issue in rescale-pdf. Changing \\begin{document} to
> \\\begin{document} fixed it for me.
> 
> After checking the revisions of rescale-pdf.sh on the code server
> (http://code.nsnam.org/ns-3-dev/log/f1f595e0ea3c/doc/manual/rescale-pdf.sh) it
> looks like Tom noticed this, but reverted it. Not sure why, maybe it works on
> the code server with only one escape character.

And another thing to note: If I use the full path to echo (/bin/echo) in the rescale-pdf script, it works fine without having to modify that backspace escape character. Something is strange with the built-in echo I guess.
Comment 6 Tom Henderson 2011-02-24 13:10:00 EST
(In reply to comment #4)
> FYI, this happened on my Ubuntu machine too. Checking the logs, it looks like
> this is an escaping issue in rescale-pdf. Changing \\begin{document} to
> \\\begin{document} fixed it for me.
> 
> After checking the revisions of rescale-pdf.sh on the code server
> (http://code.nsnam.org/ns-3-dev/log/f1f595e0ea3c/doc/manual/rescale-pdf.sh) it
> looks like Tom noticed this, but reverted it. Not sure why, maybe it works on
> the code server with only one escape character.

I made the change back during the release process to make it work on the server. I did not look into the portability problem at the time.

Looking at it today, I believe the issue is that Ubuntu symlinks "sh" to "dash" by default.  Since bash is fairly ubiquitous nowadays, I think that changing it to bash is the way to go.  

pushed in changeset 58c12aeae0c0  (tested on the Fedora web server and on Ubuntu 10.04 LTS)