File: 514030_debianize_dbtoepub.patch

package info (click to toggle)
dbtoepub 0%2Bsvn9904-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 196 kB
  • sloc: ruby: 237; sh: 15; xml: 7; makefile: 6
file content (70 lines) | stat: -rw-r--r-- 2,855 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Author: Daniel Leidert <daniel.leidert@wgdd.de>
Description: The dbtoepub script and its modules need to be debianized.
 - epub/bin/dbtoepub: The modules are installed into
   /usr/lib/ruby/vendor_ruby/dbtoepub.
 - epub/bin/lib/docbook.rb: Create temporary directory with Dir::tmpdir.
   Use local stylesheet path. Delete output directory.
 - epub/docbook.xsl: Use local stylesheet paths
Bug-Debian: http://bugs.debian.org/514030
Forwarded: no

--- a/bin/dbtoepub
+++ b/bin/dbtoepub
@@ -17,14 +17,11 @@
 #                                        layer (imports epub/docbook.xsl).
 #     -v, --verbose                    Make output verbose.
 
-lib = File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
-$LOAD_PATH.unshift(lib) if File.exist?(lib)
-
 require 'fileutils'
 require 'optparse'
 require 'tmpdir'
 
-require 'docbook'
+require 'dbtoepub/docbook'
 
 verbose = false
 debug = false
--- a/bin/lib/docbook.rb
+++ b/bin/lib/docbook.rb
@@ -1,17 +1,27 @@
 require 'fileutils'
 require 'rexml/parsers/pullparser'
+require 'tmpdir'
 
 module DocBook
 
   class Epub
     CHECKER = "epubcheck"
-    STYLESHEET = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', "docbook.xsl"))
+    STYLESHEET_PATH = File.join('usr/share/xml/docbook/stylesheet', 'docbook-xsl')
+    STYLESHEET_NS_PATH = File.join('usr/share/xml/docbook/stylesheet', 'docbook-xsl-ns')
+    if File.directory?(File.expand_path(File.join(File::Separator, STYLESHEET_PATH)))
+      STYLESHEET = File.expand_path(File.join(File::Separator, STYLESHEET_PATH, 'epub', "docbook.xsl"))
+    elsif File.directory?(File.expand_path(File.join(File::Separator, STYLESHEET_NS_PATH)))
+      STYLESHEET = File.expand_path(File.join(File::Separator, STYLESHEET_NS_PATH, 'epub', "docbook.xsl"))
+    else
+      fail "Stylesheet path not found. Use the -s switch."
+    end
+    fail "Stylesheet #{STYLESHEET} not found. Use the -s switch." unless File.exist?(STYLESHEET)
     CALLOUT_PATH = File.join('images', 'callouts')
-    CALLOUT_FULL_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', CALLOUT_PATH))
+    CALLOUT_FULL_PATH = File.expand_path(File.join(File::Separator, STYLESHEET_PATH, CALLOUT_PATH))
     CALLOUT_LIMIT = 15
     CALLOUT_EXT = ".png"
     XSLT_PROCESSOR = "xsltproc"
-    OUTPUT_DIR = ".epubtmp#{Time.now.to_f.to_s}"
+    OUTPUT_DIR = File.expand_path(File.join(Dir::tmpdir, ".epubtmp#{Time.now.to_f.to_s}"))
     MIMETYPE = "application/epub+zip"
     META_DIR = "META-INF"
     OEBPS_DIR = "OEBPS"
@@ -26,7 +36,7 @@
       @oebps_dir = File.join(@output_dir, OEBPS_DIR)
       @css_file = css_file ? File.expand_path(css_file) : css_file
       @embedded_fonts = embedded_fonts
-      @to_delete = []
+      @to_delete = [OUTPUT_DIR]
       
       if customization_layer
         @stylesheet = File.expand_path(customization_layer)