summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/tex4ebook/exec_mobi.lua
blob: ce10b6da760a6a68202f97013fc564e722350bb9 (plain)
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
module(...,package.seeall)
local eb = require("exec_epub")
local ebookutils = require("mkutils")
local log = logging.new "exec_mobi"

function prepare(params)
	return eb.prepare(params)
end

function run(out,params)
	return eb.run(out, params)
end

function writeContainer()
	local ret =  eb.writeContainer()
  -- convert the epub file to mobi
  local epubpath = eb.basedir .. "/" .. eb.outputfile
	log:info("Pack mobi "..os.execute("kindlegen " .. epubpath))
  -- find the mobi filename 
  local mobifile = epubpath:gsub("epub$", "mobi")
  local mobidist = eb.destdir ..  eb.outputfile:gsub("epub$", "mobi")
  -- copy the mobi file to the destination directory
  -- the destination directory will be created by the epub writer, so it is possible to use
  -- the cp function which doesn't try to create directory
  ebookutils.cp(mobifile, mobidist)

	return ret
end

function clean()
	return eb.clean()
end