-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-install.xql
76 lines (63 loc) · 3 KB
/
post-install.xql
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
71
72
73
74
75
xquery version "3.0";
import module namespace pmu="http://www.tei-c.org/tei-simple/xquery/util";
import module namespace odd="http://www.tei-c.org/tei-simple/odd2odd";
declare namespace repo="http://exist-db.org/xquery/repo";
(: The following external variables are set by the repo:deploy function :)
(: file path pointing to the exist installation directory :)
declare variable $home external;
(: path to the directory containing the unpacked .xar package :)
declare variable $dir external;
(: the target collection into which the app is deployed :)
declare variable $target external;
declare variable $repoxml :=
let $uri := doc($target || "/expath-pkg.xml")/*/@name
let $repo := util:binary-to-string(repo:get-resource($uri, "repo.xml"))
return
parse-xml($repo)
;
declare function local:generate-code($collection as xs:string) {
let $odd := xmldb:get-child-resources($collection || "/resources/odd")[ends-with(., ".odd")]
let $count := count($odd)
let $oddName :=
switch ($count)
case 2 return distinct-values($odd[not(.=("tei_simplePrint.odd"))])
case 1 return $odd
default return distinct-values($odd[not(.=("teipublisher.odd", "tei_simplePrint.odd"))])
(: TODO: cleanup
for $source in $collection || "/resources/odd" || $oddName
for $source in xmldb:get-child-resources($collection || "/resources/odd")[ends-with(., ".odd")]:)
for $module in ("web", "print", "latex", "epub")
for $file in pmu:process-odd (
(: $odd as document-node():)
odd:get-compiled($collection || "/resources/odd" , $oddName),
(: $output-root as xs:string :)
$collection || "/transform",
(: $mode as xs:string :)
$module,
(: $relPath as xs:string :)
"../transform",
(: $config as element(modules)? :)
doc($collection || "/resources/odd/configuration.xml")/*)?("module")
return
(),
let $permissions := $repoxml//repo:permissions[1]
return (
for $file in xmldb:get-child-resources($collection || "/transform")
let $path := xs:anyURI($collection || "/transform/" || $file)
return (
sm:chown($path, $permissions/@user),
sm:chgrp($path, $permissions/@group)
)
)
};
sm:chmod(xs:anyURI($target || "/modules/view.xql"), "rwsr-xr-x"),
(:sm:chmod(xs:anyURI($target || "/modules/transform.xql"), "rwsr-xr-x"),:)
sm:chmod(xs:anyURI($target || "/modules/lib/pdf.xql"), "rwsr-xr-x"),
sm:chmod(xs:anyURI($target || "/modules/lib/get-epub.xql"), "rwsr-xr-x"),
sm:chmod(xs:anyURI($target || "/modules/lib/ajax.xql"), "rwsr-xr-x"),
sm:chmod(xs:anyURI($target || "/modules/lib/regenerate.xql"), "rwsr-xr-x"),
sm:chmod(xs:anyURI($target || "/modules/lib/upload.xql"), "rwsr-xr-x"),
(: LaTeX requires dba permissions to execute shell process :)
sm:chmod(xs:anyURI($target || "/modules/lib/latex.xql"), "rwxr-Sr-x"),
sm:chgrp(xs:anyURI($target || "/modules/lib/latex.xql"), "dba"),
local:generate-code($target)