schroot 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/schroot.rb +20 -18
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2fe498cb8c7197740cfcf89abc824d08a6a6e8eb
|
|
4
|
+
data.tar.gz: e34b0f70154cb55974043756d421a3783c0fbaab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d71a3b23c47c8df968d346a1a73d5afa7062ad7f0a63ce067cecbb5fb249a3e34d51ea5655d0efeef9d11e424ab45a94dd9142a9922f190ed134b1c28e54b33e
|
|
7
|
+
data.tar.gz: eaa6d98672e65ad6ae07925ce0712e67d0bdaf3cc6073f1171f5a2d3736346147bd65b70cffd4254879b809d4b125ec5148e034e1ec973a8969f0c4bdd66cdfa
|
data/README.md
CHANGED
|
@@ -35,7 +35,8 @@ $ gem install ./*.gem
|
|
|
35
35
|
or just
|
|
36
36
|
```bash
|
|
37
37
|
$ rake install
|
|
38
|
-
```
|
|
38
|
+
```
|
|
39
|
+
|
|
39
40
|
Examples
|
|
40
41
|
------
|
|
41
42
|
|
|
@@ -52,6 +53,7 @@ Simple example:
|
|
|
52
53
|
=> "Hello, World!\n"
|
|
53
54
|
```
|
|
54
55
|
Using logger:
|
|
56
|
+
|
|
55
57
|
```ruby
|
|
56
58
|
irb(main):001:0> require 'schroot'
|
|
57
59
|
=> true
|
data/lib/schroot.rb
CHANGED
|
@@ -2,8 +2,9 @@ require 'open3'
|
|
|
2
2
|
require 'logger'
|
|
3
3
|
|
|
4
4
|
SCHROOT_BASE="/var/lib/schroot"
|
|
5
|
-
BASE_CONF
|
|
6
|
-
CONF_D
|
|
5
|
+
BASE_CONF="/etc/schroot/schroot.conf"
|
|
6
|
+
CONF_D="/etc/schroot/chroot.d/"
|
|
7
|
+
CONF_D_PREFIX="99ruby-"
|
|
7
8
|
|
|
8
9
|
class SchrootError < StandardError
|
|
9
10
|
end
|
|
@@ -15,39 +16,40 @@ class SchrootConfig
|
|
|
15
16
|
chroots = {}
|
|
16
17
|
files = [BASE_CONF]
|
|
17
18
|
Dir.entries(CONF_D).each do |file|
|
|
18
|
-
files << (CONF_D+file) unless ['.','..'].include? file
|
|
19
|
+
files << (CONF_D+CONF_D_PREFIX+file) unless ['.','..'].include? file
|
|
19
20
|
end
|
|
20
21
|
files.each do |file|
|
|
21
22
|
stream = File.open(file,"r")
|
|
22
23
|
current = nil
|
|
23
24
|
while (line = stream.gets)
|
|
24
|
-
if
|
|
25
|
-
current =
|
|
25
|
+
if match_name(line)
|
|
26
|
+
current = match_name(line)[1]
|
|
26
27
|
chroots[current.strip] = {"source" => file}
|
|
27
|
-
elsif current and
|
|
28
|
-
param, value =
|
|
28
|
+
elsif current and match_param(line)
|
|
29
|
+
param, value = match_param(line)[1],match_param(line)[2]
|
|
29
30
|
chroots[current][param.strip] = value.strip if current
|
|
30
31
|
end
|
|
31
32
|
end
|
|
33
|
+
stream.close
|
|
32
34
|
end
|
|
33
35
|
return chroots
|
|
34
36
|
end
|
|
35
37
|
|
|
36
|
-
def
|
|
38
|
+
def self.match_name(name)
|
|
37
39
|
return /^\s*\[([a-z0-9A-Z\-\_]+)\]/.match(name)
|
|
38
40
|
end
|
|
39
41
|
|
|
40
|
-
def
|
|
42
|
+
def self.match_param(param)
|
|
41
43
|
return /^\s*([a-z0-9A-Z\-\_]+)\=(.*)$/.match(param)
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
# Adds new chroot configuration to .../chroot.d/ directory
|
|
45
47
|
#
|
|
46
48
|
# @example
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
#
|
|
49
|
+
# SchrootConfig.add("testing", {"description" => "Debian testing",
|
|
50
|
+
# "file" => "/srv/chroot/testing.tgz",
|
|
51
|
+
# "location" => "/testing",
|
|
52
|
+
# "groups" => "sbuild"})
|
|
51
53
|
# => true
|
|
52
54
|
# @param name [String] name of chroot
|
|
53
55
|
# @param kwargs [Hash] options
|
|
@@ -55,7 +57,7 @@ class SchrootConfig
|
|
|
55
57
|
# @return [Bool] true if operation has completed successfully
|
|
56
58
|
def self.add(name, kwargs = {}, force=false)
|
|
57
59
|
chroots = readconf()
|
|
58
|
-
filename = CONF_D+name
|
|
60
|
+
filename = CONF_D+CONF_D_PREFIX+name
|
|
59
61
|
if (chroots[name] or File.exists?(filename)) and !force
|
|
60
62
|
return false
|
|
61
63
|
else
|
|
@@ -77,15 +79,15 @@ class SchrootConfig
|
|
|
77
79
|
# Removes chroot from .../chroot.d/ directory
|
|
78
80
|
#
|
|
79
81
|
# @example
|
|
80
|
-
#
|
|
81
|
-
#
|
|
82
|
+
# SchrootConfig.remove("testing", true)
|
|
83
|
+
# => true
|
|
82
84
|
# @param name [String] name of chroot
|
|
83
85
|
# @param kwargs [Hash] options
|
|
84
86
|
# @param force [Bool] should we override existing config
|
|
85
87
|
# @return [Bool] true if operation has completed successfully
|
|
86
88
|
def self.remove(name, force=false)
|
|
87
89
|
chroots = readconf()
|
|
88
|
-
filename = CONF_D+name
|
|
90
|
+
filename = CONF_D+CONF_D_PREFIX+name
|
|
89
91
|
if (File.exists?(filename) and chroots[name]) or force
|
|
90
92
|
File.delete(filename)
|
|
91
93
|
return true
|
|
@@ -200,4 +202,4 @@ class Schroot
|
|
|
200
202
|
|
|
201
203
|
private :safe_run, :command
|
|
202
204
|
attr_reader :session, :location, :chroot, :logger
|
|
203
|
-
end
|
|
205
|
+
end
|