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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 96bb5eb5199a4847a2ded83334d4dbeb3745f6df
|
4
|
+
data.tar.gz: 6d7080bbfe7a749cbc8816ac38993db22535a25c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 32604bed16bc9ff1871ff82032e2756b03c06d0dc580229680a70b18d16e028cb1b978f51185a4c1d891f1d1990f79b7ed42ad94506e337272dbeec84545a801
|
7
|
+
data.tar.gz: 4666d514921ec493b8303d34d18271db2501492c7f45c4a6741f1185a3429cae3d2469f578d1d0c6c9b29d27375ef8324a5299fb4598feb45cf3111a1d6c6734
|
data/README.md
ADDED
data/bin/stowm
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- mode: nendo; syntax: scheme ; coding: utf-8 -*-
|
3
|
+
require 'nendo'
|
4
|
+
$LOAD_PATH.push( File.dirname(__FILE__) + "/../lib" )
|
5
|
+
core = Nendo::Core.new()
|
6
|
+
core.setArgv( ARGV )
|
7
|
+
core.loadInitFile
|
8
|
+
core.disableRuntimeCheck( )
|
9
|
+
core.evalStr( <<";;END-OF-SCRIPT" )
|
10
|
+
;;;
|
11
|
+
;;; stowm - a package management tool for GNU stow
|
12
|
+
;;;
|
13
|
+
;;; Copyright (c) 2014 Kiyoka Nishiyama <kiyoka@sumibi.org>
|
14
|
+
;;;
|
15
|
+
;;; Redistribution and use in source and binary forms, with or without
|
16
|
+
;;; modification, are permitted provided that the following conditions
|
17
|
+
;;; are met:
|
18
|
+
;;;
|
19
|
+
;;; 1. Redistributions of source code must retain the above copyright
|
20
|
+
;;; notice, this list of conditions and the following disclaimer.
|
21
|
+
;;;
|
22
|
+
;;; 2. Redistributions in binary form must reproduce the above copyright
|
23
|
+
;;; notice, this list of conditions and the following disclaimer in the
|
24
|
+
;;; documentation and/or other materials provided with the distribution.
|
25
|
+
;;;
|
26
|
+
;;; 3. Neither the name of the authors nor the names of its contributors
|
27
|
+
;;; may be used to endorse or promote products derived from this
|
28
|
+
;;; software without specific prior written permission.
|
29
|
+
;;;
|
30
|
+
;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
31
|
+
;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
32
|
+
;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
33
|
+
;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
34
|
+
;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
35
|
+
;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
36
|
+
;;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
37
|
+
;;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
38
|
+
;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
39
|
+
;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
40
|
+
;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
41
|
+
;;;
|
42
|
+
(use srfi-1)
|
43
|
+
(use srfi-9)
|
44
|
+
(use util.list)
|
45
|
+
(use stowm.env)
|
46
|
+
(use stowm.util)
|
47
|
+
(use stowm.parseutil)
|
48
|
+
(use stowm.listutil)
|
49
|
+
(use stowm.specfile)
|
50
|
+
(use stowm.main)
|
51
|
+
|
52
|
+
(define (main argv)
|
53
|
+
;; branch by argument
|
54
|
+
(let1 env (stowm-get-default-env)
|
55
|
+
|
56
|
+
;; check the stow program
|
57
|
+
(if (not (stow-program env))
|
58
|
+
(begin
|
59
|
+
(STDERR.puts "Error: not found the (stow or xstow) program binary.")
|
60
|
+
(exit 1)))
|
61
|
+
|
62
|
+
;; load dotfiles
|
63
|
+
(if (File.exist? (inifile-path env))
|
64
|
+
(load (inifile-path env)))
|
65
|
+
|
66
|
+
;; home-repos exist check
|
67
|
+
(if (not (Dir.exist? (home-repos env)))
|
68
|
+
(begin
|
69
|
+
(STDERR.printf "Error : repos dir [%s] nessesary to use stowm.\n" (home-repos env))
|
70
|
+
(exit 1)))
|
71
|
+
|
72
|
+
(let1 stowed-list (rebuild-installed-db env)
|
73
|
+
|
74
|
+
(case (length argv)
|
75
|
+
((0)
|
76
|
+
(display-help)
|
77
|
+
0)
|
78
|
+
(else
|
79
|
+
(cond
|
80
|
+
((stowm-regex-match #/^env/ (car argv))
|
81
|
+
(print (stowm-env-to-string env)))
|
82
|
+
((stowm-regex-match #/^ena?b?l?e?/ (car argv))
|
83
|
+
(cond
|
84
|
+
((stowm-regex-match #/^[0-9]+$/ (second argv))
|
85
|
+
(action-by-keyword-num env 'enable (to-i (second argv)) stowed-list))
|
86
|
+
(else
|
87
|
+
(action-by-keyword-name env 'enable (second argv) stowed-list))))
|
88
|
+
((stowm-regex-match #/^dis?a?b?l?e?/ (car argv))
|
89
|
+
(cond
|
90
|
+
((stowm-regex-match #/^[0-9]+$/ (second argv))
|
91
|
+
(action-by-keyword-num env 'disable (to-i (second argv)) stowed-list))
|
92
|
+
(else
|
93
|
+
(action-by-keyword-name env 'disable (second argv) stowed-list))))
|
94
|
+
((stowm-regex-match #/^reb?u?i?l?d?/ (car argv))
|
95
|
+
(rebuild-num env (to-i (second argv)) stowed-list))
|
96
|
+
((is-valid-url? (car argv))
|
97
|
+
(action-by-url env (car argv)))
|
98
|
+
((stowm-regex-match #/^li?s??t?$/ (car argv))
|
99
|
+
(cond
|
100
|
+
((< 1 (length argv))
|
101
|
+
(display-list stowed-list (second argv)))
|
102
|
+
(else
|
103
|
+
(display-list stowed-list #f))))
|
104
|
+
(else
|
105
|
+
(display-help)
|
106
|
+
0)))))))
|
107
|
+
|
108
|
+
|
109
|
+
(main *argv*)
|
110
|
+
;;END-OF-SCRIPT
|
data/lib/stowm/env.nnd
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
;; #-*- mode: nendo; syntax: scheme -*-;;
|
2
|
+
;; env record library
|
3
|
+
|
4
|
+
(use srfi-9)
|
5
|
+
|
6
|
+
(define-record-type <stowm-env>
|
7
|
+
(stowm-env pwd home home-repos stow-home local bin lib temp inifile-path db-path stow-program)
|
8
|
+
stowm-env?
|
9
|
+
(pwd pwd) ;; pwd
|
10
|
+
(home home) ;; "/home/xxxx/"
|
11
|
+
(home-repos home-repos) ;; "/home/xxxx/stowm"
|
12
|
+
(stow-home stow-home) ;; "/usr/local/stow"
|
13
|
+
(local local) ;; "/usr/local"
|
14
|
+
(bin bin) ;; "/usr/local/bin"
|
15
|
+
(lib lib) ;; "/usr/local/lib"
|
16
|
+
(temp temp) ;; "/tmp/stowm"
|
17
|
+
(inifile-path inifile-path) ;; ~/.stowm
|
18
|
+
(db-path db-path) ;; ~/.stowm.db
|
19
|
+
(stow-program stow-program) ;; "/usr/bin/stow"
|
20
|
+
)
|
21
|
+
|
22
|
+
(define (stowm-get-default-env)
|
23
|
+
(stowm-env
|
24
|
+
(ENV.fetch "PWD") ;; pwd
|
25
|
+
(ENV.fetch "HOME") ;; home
|
26
|
+
(File.expand_path "~/stowm") ;; "/home/xxxx/stowm"
|
27
|
+
"/usr/local/stow"
|
28
|
+
"/usr/local"
|
29
|
+
"/usr/local/bin"
|
30
|
+
"/usr/local/lib"
|
31
|
+
"/tmp/stowm"
|
32
|
+
(File.expand_path "~/.stowm") ;; ~/.stowm
|
33
|
+
(File.expand_path "~/.stowm.db") ;; ~/.stowm.db
|
34
|
+
(let1 lst ;; "/usr/bin/stow"
|
35
|
+
(filter-map
|
36
|
+
(lambda (x)
|
37
|
+
(let ((path1 (+ "/usr/bin/" (car x)))
|
38
|
+
(path2 (+ "/usr/local/bin/" (car x))))
|
39
|
+
(if (File.exist? path1)
|
40
|
+
(cons path1 (cdr x))
|
41
|
+
(if (File.exist? path2)
|
42
|
+
(cons path2 (cdr x))))))
|
43
|
+
'(("xstow" . "-f") ("stow" . "")))
|
44
|
+
(if (< 0 (length lst))
|
45
|
+
(caar lst)
|
46
|
+
#f
|
47
|
+
))))
|
48
|
+
|
49
|
+
(define (stowm-env-to-string env)
|
50
|
+
(string-join
|
51
|
+
(map
|
52
|
+
(lambda (x)
|
53
|
+
(sprintf " %-20s %-30s" (car x) (cdr x)))
|
54
|
+
`(
|
55
|
+
("stow home: " . ,(stow-home env))
|
56
|
+
("stow program: " . ,(stow-program env))
|
57
|
+
("stown repository: " . ,(home-repos env))
|
58
|
+
("stowm rcfile path: " . ,(inifile-path env))
|
59
|
+
("stowm db path: " . ,(db-path env))
|
60
|
+
("stowm tmp: " . ,(temp env))))
|
61
|
+
"\n"))
|