Dwarf-Therapist icon indicating copy to clipboard operation
Dwarf-Therapist copied to clipboard

Add option to disable building manual

Open anders-larsson opened this issue 11 years ago • 12 comments

Hi,

Since the manual as a part of Dwarf Therapist a lot of new dependencies has been added for Dwarf Therapist to build correctly. It might exist cases where the user do not want to install the LaTeX suite to use Dwarf Therapist.

Would it be possible to add some flag to enable/disable building the manual?

anders-larsson avatar Sep 15 '14 15:09 anders-larsson

Yeah I was going to make a note of this myself after being forced to install some ~1GB of dependencies...

splintermind avatar Sep 15 '14 15:09 splintermind

So. I installed the dependencies needed to build the manual and I've checked the log and it's actually built. However it's not actually installed when "make install" is used.

Also when clicking on the Manual entry in Dwarf Therapist it points to "file:///share:doc/Therapist%20Manual.pdf" which does not at all seem to be adapted for a "installed" version (make install) of Dwarf Therapist.

anders-larsson avatar Sep 15 '14 16:09 anders-larsson

Regarding my latest post. Moving a few lines of code further up in dwarftherapist.pro seems to solve the issue with the manual not being installed into /usr/share/dwaftherapist. I can't understand though why vim is unable to understand if the file has dos or unix line endings though so every line ends with "^M". Perhaps there's a better way to solve it though.

Here's the patch:

diff --git a/dwarftherapist.pro b/dwarftherapist.pro
index 1189558..ee536af 100644
--- a/dwarftherapist.pro
+++ b/dwarftherapist.pro
@@ -96,6 +96,15 @@ build_pass {
         doc.path = /usr/share/doc/dwarftherapist
         doc.files += LICENSE.txt
         doc.files += README.rst
+        system("printf 'Checking for pdflatex... '; if ! command -v pdflatex; then r=$?; echo 'not found'; exit $?; fi") {^M
+            manual.depends = "$$PWD/doc/Dwarf Therapist.tex" $$PWD/doc/images/*^M
+            manual.commands = [ -d doc ] || mkdir doc;^M
+            manual.commands += TEXINPUTS=".:$$PWD/doc/images:" pdflatex -output-directory=doc \"$<\"^M
+            manual.target = "doc/Dwarf Therapist.pdf"^M
+            QMAKE_EXTRA_TARGETS += manual^M
+            POST_TARGETDEPS += "$$manual.target"^M
+            doc.files += "$$manual.target"^M
+        }^M
         INSTALLS += doc

         icon.path = /usr/share/pixmaps
@@ -107,15 +116,6 @@ build_pass {
         memory_layouts.files += share/memory_layouts/linux/*
         INSTALLS += memory_layouts

-        system("printf 'Checking for pdflatex... '; if ! command -v pdflatex; then r=$?; echo 'not found'; exit $?; fi") {
-            manual.depends = "$$PWD/doc/Dwarf Therapist.tex" $$PWD/doc/images/*
-            manual.commands = [ -d doc ] || mkdir doc;
-            manual.commands += TEXINPUTS=".:$$PWD/doc/images:" pdflatex -output-directory=doc \"$<\"
-            manual.target = "doc/Dwarf Therapist.pdf"
-            QMAKE_EXTRA_TARGETS += manual
-            POST_TARGETDEPS += "$$manual.target"
-            doc.files += "$$manual.target"
-        }
     }
 }

anders-larsson avatar Sep 15 '14 18:09 anders-larsson

Since the manual as a part of Dwarf Therapist a lot of new dependencies has been added for Dwarf Therapist to build correctly. It might exist cases where the user do not want to install the LaTeX suite to use Dwarf Therapist.

latex is intentionally not required to build, thus the use of system scope instead of unconditional target addition.

Yeah I was going to make a note of this myself after being forced to install some ~1GB of dependencies...

$ du -sh /usr/share/texmf-dist
253M    /usr/share/texmf-dist
$ du -h --total /usr/portage/distfiles/texlive*2012* | tail -n 1
241M total

if your distro requires you to install all texlive packages, get a new distro. (or more likely, learn to use your existing one)

Also when clicking on the Manual entry in Dwarf Therapist it points to "file:///share:doc/Therapist%20Manual.pdf" which does not at all seem to be adapted for a "installed" version (make install) of Dwarf Therapist.

oops. made a logic error when converting from if() to ternary form. will make pull request later.

Regarding my latest post. Moving a few lines of code further up in dwarftherapist.pro seems to solve the issue with the manual not being installed into /usr/share/dwaftherapist.

i hate qmake.

Hello71 avatar Sep 15 '14 18:09 Hello71

latex is intentionally not required to build, thus the use of system scope instead of unconditional target addition.

Is there any option that should be send into qmake for it not to try to build the manual? Because currently it tries to build it automatically when running make.

if your distro requires you to install all texlive packages, get a new distro. (or more likely, learn to use your existing one)

Yes. I did resolve the issue. Only two packages is neccessary on Gentoo:

  • dev-texlive/texlive-latex
  • dev-texlive/texlive-latexextra

anders-larsson avatar Sep 15 '14 18:09 anders-larsson

bleh. I did exit $? instead of exit $r by accident. shell scripting is hard.

Hello71 avatar Sep 17 '14 00:09 Hello71

I would like to re-open this issue.

Dwarf Therapist is still unable to find the manual correctly on GNU/Linux (and probably other operating systems). It attempts to open Therapist.pdf instead of Dwarf Therapist.pdf. I've managed to solve this part of the issue. Looking at strace now it sucessfully finds Dwarf Therapist.pdf. File found:

stat("/usr/share/doc/dwarftherapist/Dwarf Therapist.pdf", {st_mode=S_IFREG|0644, st_size=2128671, ...}) = 0

However next problem is that it attempts to open the file with the following call

execve("/usr/local/bin/xdg-open", ["/usr/local/bin/xdg-open", "file:share:Dwarf%20Therapist.pdf"], [/* 73 vars */] <unfinished ...>

It seems to fail because "share" is not translated into the correct path when "QDesktopServices::openUrl(url);" is executed. Sadly here ends my knowledge on how to solve it.

Below is the changes I made to get it this far:

diff --git a/src/dwarftherapist.cpp b/src/dwarftherapist.cpp
index c8c8516..28f9bea 100644
--- a/src/dwarftherapist.cpp
+++ b/src/dwarftherapist.cpp
@@ -115,6 +115,8 @@ void DwarfTherapist::setup_search_paths() {
     paths << QString("%1/../share").arg(appdir);
     // /usr/bin/../share/dwarftherapist/game_data.ini
     paths << QString("%1/../share/dwarftherapist").arg(appdir);
+    // /usr/bin/../share/doc/dwarftherapist/Dwarf Therapist.pdf
+    paths << QString("%1/../share/doc/dwarftherapist").arg(appdir);
     // cwd/game_data.ini
     paths << QString("%1").arg(working_dir);
     // cwd/share/game_data.ini
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 9e345a5..bdf2002 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -869,7 +869,7 @@ void MainWindow::go_to_new_issue() {
 }

 void MainWindow::open_help(){
-    const QString local_manual = "share:doc/Therapist Manual.pdf";
+    const QString local_manual = "share:Dwarf Therapist.pdf";
     QUrl url = QFile::exists(local_manual) ? QUrl::fromLocalFile(local_manual)
                                            : QUrl("http://dffd.wimbli.com/file.php?id=7889");
     QDesktopServices::openUrl(url);

anders-larsson avatar Sep 17 '14 15:09 anders-larsson

Perhaps this issue should be closed since issue #160 is regarding this exact thing. My fault for making it about the path to the manual as well.

anders-larsson avatar Sep 17 '14 16:09 anders-larsson

I think #194 fixes this.

Hello71 avatar Sep 23 '14 14:09 Hello71

I did some testing and Dwarf Therapist is unable to find the pdf-file because its installed into /usr/share/doc/dwarftherapist/Dwarf Therapist.pdf. However the program itself looks for the pdf-file as /usr/share/dwarftherapist/doc/Dwarf Therapist.pdf. Copying the pdf into the correct location (or creating a link) solves the issue.

anders-larsson avatar Sep 23 '14 18:09 anders-larsson

/me grumbles

Hello71 avatar Sep 23 '14 18:09 Hello71

I'm sorry to say it but it does not seem like it helped. Commit: cb17b2bdd4cebe6dca7114ee2fa8e817e177f81c

Steps: qmake (tried both qt4 and qt5) make make install

PDF file installed into: /usr/share/doc/dwarftherapist

Strace:

19420 stat("/usr/bin/doc/Dwarf Therapist.pdf", 0x7fff5e91b3e0) = -1 ENOENT (No such file or directory)
19420 stat("/usr/bin/../doc/Dwarf Therapist.pdf", 0x7fff5e91b3e0) = -1 ENOENT (No such file or directory)
19420 stat("/usr/bin/../share/dwarftherapist/Dwarf Therapist.pdf", 0x7fff5e91b3e0) = -1 ENOENT (No such file or directory)

anders-larsson avatar Sep 26 '14 08:09 anders-larsson