stowm 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +8 -0
- data/bin/stowm +110 -0
- data/lib/stowm/env.nnd +61 -0
- data/lib/stowm/env.nndc +863 -0
- data/lib/stowm/listutil.nnd +40 -0
- data/lib/stowm/listutil.nndc +469 -0
- data/lib/stowm/main.nnd +340 -0
- data/lib/stowm/main.nndc +3848 -0
- data/lib/stowm/parseutil.nnd +121 -0
- data/lib/stowm/parseutil.nndc +1826 -0
- data/lib/stowm/specfile.nnd +113 -0
- data/lib/stowm/specfile.nndc +1166 -0
- data/lib/stowm/util.nnd +39 -0
- data/lib/stowm/util.nndc +395 -0
- data/lib/stowm/version.rb +5 -0
- data/lib/stowm.rb +35 -0
- metadata +75 -0
@@ -0,0 +1,113 @@
|
|
1
|
+
;; #-*- mode: nendo; syntax: scheme -*-;;
|
2
|
+
;; specfile util functions
|
3
|
+
|
4
|
+
(use rfc.yaml)
|
5
|
+
|
6
|
+
;; create specfile as yaml.
|
7
|
+
;; stow-home: stow home path.
|
8
|
+
;; url: url arg must be validated.
|
9
|
+
;; return
|
10
|
+
;; ("yamlfile image"
|
11
|
+
;; (( "filename of shellscript" . "shellscript image"))
|
12
|
+
;; )
|
13
|
+
(define (create-specfile stow-home url)
|
14
|
+
(let* ([parsed (stowm-parse-url url)]
|
15
|
+
[fetchable (not (eq? 'empty (scheme-type parsed)))]
|
16
|
+
[tree
|
17
|
+
`(
|
18
|
+
("fetch" . ,(if fetchable
|
19
|
+
(sprintf "wget %s -O %s" url (filename parsed))
|
20
|
+
#f))
|
21
|
+
("configure" . ,(sprintf "bash configure --prefix=%s/%s"
|
22
|
+
stow-home
|
23
|
+
(package parsed)))
|
24
|
+
("make" . "make")
|
25
|
+
("install" . "make install")
|
26
|
+
("url" . ,url)
|
27
|
+
("filename" . ,(filename parsed))
|
28
|
+
("projname" . ,(package parsed)))])
|
29
|
+
|
30
|
+
(construct-yaml-string tree)))
|
31
|
+
|
32
|
+
;; load specfile
|
33
|
+
;; path : full path of specfile.yml
|
34
|
+
(define (load-specfile path)
|
35
|
+
(with-open
|
36
|
+
path
|
37
|
+
(lambda (f)
|
38
|
+
(parse-yaml f))))
|
39
|
+
|
40
|
+
|
41
|
+
;; return
|
42
|
+
;; "tar zxf aaaa-1.2.3.tar.gz"
|
43
|
+
;; or
|
44
|
+
;; "bzcat aaaa-1.2.3.tar.bz2 | tar xf -"
|
45
|
+
(define (create-extract-tarball-command url)
|
46
|
+
(let* ([parsed (stowm-parse-url url)]
|
47
|
+
[_filename (filename parsed)])
|
48
|
+
(cond
|
49
|
+
((or (eq? 'gz (arc-type parsed))
|
50
|
+
(eq? 'z (arc-type parsed)))
|
51
|
+
(sprintf "tar zxf %s" _filename))
|
52
|
+
((eq? 'bz2 (arc-type parsed))
|
53
|
+
(sprintf "bzcat %s | tar xf -" _filename))
|
54
|
+
((eq? 'xz (arc-type parsed))
|
55
|
+
(sprintf "xzcat %s | tar xf -" _filename))
|
56
|
+
(else
|
57
|
+
(sprintf "echo \"Error: unsupported archive format. (%s) ; exit 1 ; \"" _filename)))))
|
58
|
+
|
59
|
+
|
60
|
+
;; create command line string
|
61
|
+
;; like " cd ./ruby-2.2.0 && configure --prefix=XXXX && make && make install"
|
62
|
+
(define (create-build-cmdline cd cf mk ins)
|
63
|
+
(let ([cf (if (stowm-regex-match "^[ \t]*$" cf)
|
64
|
+
#f
|
65
|
+
cf)]
|
66
|
+
[mk (if (stowm-regex-match "^[ \t]*$" mk)
|
67
|
+
#f
|
68
|
+
mk)]
|
69
|
+
[ins (if (stowm-regex-match "^[ \t]*$" ins)
|
70
|
+
#f
|
71
|
+
ins)])
|
72
|
+
(string-join
|
73
|
+
(filter-map
|
74
|
+
(lambda (x) x)
|
75
|
+
(list cd cf mk ins))
|
76
|
+
" && ")))
|
77
|
+
|
78
|
+
;; spec object to Makefile string
|
79
|
+
;; spec-obj : loaded data of specfile.yml
|
80
|
+
(define (create-makefile spec-obj home-repos)
|
81
|
+
(let* ([fetch (assv-ref "fetch" spec-obj)]
|
82
|
+
[filename (assv-ref "filename" spec-obj)]
|
83
|
+
[projname (assv-ref "projname" spec-obj)]
|
84
|
+
[strings
|
85
|
+
(list
|
86
|
+
(sprintf "all: %s/configure\n %s"
|
87
|
+
projname
|
88
|
+
(create-build-cmdline
|
89
|
+
(sprintf "cd ./%s" projname)
|
90
|
+
(assv-ref "configure" spec-obj)
|
91
|
+
(assv-ref "make" spec-obj)
|
92
|
+
(assv-ref "install" spec-obj)))
|
93
|
+
(sprintf "%s/configure : %s\n %s\n touch %s/configure"
|
94
|
+
projname
|
95
|
+
filename
|
96
|
+
(create-extract-tarball-command (assv-ref "url" spec-obj))
|
97
|
+
projname)
|
98
|
+
(if fetch
|
99
|
+
(sprintf "%s :\n %s"
|
100
|
+
filename
|
101
|
+
fetch)
|
102
|
+
(sprintf "%s :\n /bin/cp %s/%s/%s %s"
|
103
|
+
filename
|
104
|
+
home-repos
|
105
|
+
projname
|
106
|
+
filename
|
107
|
+
filename))
|
108
|
+
(sprintf "clean:\n /bin/rm -rf ./%s\n"
|
109
|
+
projname))])
|
110
|
+
(string-join
|
111
|
+
strings
|
112
|
+
"\n\n")))
|
113
|
+
|