summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/libs-imp-lzma.lmt
blob: 69762a54ca54e5c684b0c37267859ee4470e5448 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
if not modules then modules = { } end modules ['libs-imp-lzma'] = {
    version   = 1.001,
    comment   = "companion to luat-lib.mkxl",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

-- Instead of linking in libs like this we now do them optional. After all, once
-- we start adding more and more stuff statically we en dup with a mess.

local libname = "lzma"
local libfile = "liblzma"

local lzmalib = resolvers.libraries.validoptional(libname)

if not lzmalib then return end

local lzma_compress   = lzmalib.compress
local lzma_decompress = lzmalib.decompress

local function okay()
    if resolvers.libraries.optionalloaded(libname,libfile) then
        okay = function() return true end
    else
        okay = function() return false end
    end
    return okay()
end

local lzma = {
    compress   = function (...) return okay() and lzma_compress       (...) end,
    decompress = function (...) return okay() and lzma_decompress     (...) end,
}

package.loaded[libname] = lzma

-- local raw = io.loaddata("e:/luatex/luametatex-source.tar")
-- local old = io.loaddata("e:/luatex/luametatex-source.tar.xz")
-- local new = lzma.decompress(old)
-- local xz1 = lzma.compress(raw,9)
-- local xz2 = lzma.decompress(xz1)

-- print("raw",raw and #raw)
-- print("old",old and #old)
-- print("new",new and #new)
-- print("chk",new == raw)
-- print("xz1",xz1 and #xz1)
-- print("xz2",xz2 and #xz2)
-- print("chk",xz2 == raw)

return lzma