packo 0.0.1.alpha.1
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.
- data/bin/packo +78 -0
- data/bin/packo-base +24 -0
- data/bin/packo-build +24 -0
- data/bin/packo-db +24 -0
- data/bin/packo-env +24 -0
- data/bin/packo-files +24 -0
- data/bin/packo-profile +24 -0
- data/bin/packo-repository +24 -0
- data/bin/packo-select +24 -0
- data/lib/packo.rb +186 -0
- data/lib/packo/cli.rb +79 -0
- data/lib/packo/cli/base.rb +554 -0
- data/lib/packo/cli/build.rb +488 -0
- data/lib/packo/cli/database.rb +55 -0
- data/lib/packo/cli/database/definition.rb +65 -0
- data/lib/packo/cli/database/helpers.rb +20 -0
- data/lib/packo/cli/environment.rb +45 -0
- data/lib/packo/cli/files.rb +153 -0
- data/lib/packo/cli/profile.rb +31 -0
- data/lib/packo/cli/repository.rb +561 -0
- data/lib/packo/cli/repository/binary.rb +74 -0
- data/lib/packo/cli/repository/helpers.rb +20 -0
- data/lib/packo/cli/repository/repository.rb +48 -0
- data/lib/packo/cli/repository/source.rb +91 -0
- data/lib/packo/cli/repository/virtual.rb +53 -0
- data/lib/packo/cli/select.rb +61 -0
- data/lib/packo/do.rb +249 -0
- data/lib/packo/environment.rb +269 -0
- data/lib/packo/extensions.rb +70 -0
- data/lib/packo/flags.rb +64 -0
- data/lib/packo/host.rb +121 -0
- data/lib/packo/models.rb +171 -0
- data/lib/packo/models/installed_package.rb +190 -0
- data/lib/packo/models/installed_package/content.rb +50 -0
- data/lib/packo/models/installed_package/dependency.rb +39 -0
- data/lib/packo/models/repository.rb +209 -0
- data/lib/packo/models/repository/binary.rb +32 -0
- data/lib/packo/models/repository/binary/mirror.rb +35 -0
- data/lib/packo/models/repository/package.rb +73 -0
- data/lib/packo/models/repository/package/binary.rb +34 -0
- data/lib/packo/models/repository/package/binary/build.rb +36 -0
- data/lib/packo/models/repository/package/source.rb +36 -0
- data/lib/packo/models/repository/package/source/feature.rb +36 -0
- data/lib/packo/models/repository/package/source/flavor.rb +36 -0
- data/lib/packo/models/repository/package/virtual.rb +32 -0
- data/lib/packo/models/repository/source.rb +30 -0
- data/lib/packo/models/repository/virtual.rb +30 -0
- data/lib/packo/models/selector.rb +34 -0
- data/lib/packo/models/tag.rb +30 -0
- data/lib/packo/package.rb +239 -0
- data/lib/packo/package/blocker.rb +100 -0
- data/lib/packo/package/blockers.rb +40 -0
- data/lib/packo/package/dependencies.rb +40 -0
- data/lib/packo/package/dependency.rb +100 -0
- data/lib/packo/package/feature.rb +55 -0
- data/lib/packo/package/features.rb +105 -0
- data/lib/packo/package/flavor.rb +101 -0
- data/lib/packo/package/tags.rb +60 -0
- data/lib/packo/package/tags/expression.rb +130 -0
- data/lib/packo/package/tags/expression/group.rb +28 -0
- data/lib/packo/package/tags/expression/logic.rb +48 -0
- data/lib/packo/package/tags/expression/name.rb +28 -0
- data/lib/packo/profile.rb +174 -0
- data/lib/packo/rbuild.rb +22 -0
- data/lib/packo/rbuild/behaviors.rb +20 -0
- data/lib/packo/rbuild/behaviors/default.rb +27 -0
- data/lib/packo/rbuild/feature.rb +64 -0
- data/lib/packo/rbuild/features.rb +65 -0
- data/lib/packo/rbuild/flavor.rb +67 -0
- data/lib/packo/rbuild/module.rb +40 -0
- data/lib/packo/rbuild/modules.rb +27 -0
- data/lib/packo/rbuild/modules/building.rb +24 -0
- data/lib/packo/rbuild/modules/building/autotools.rb +315 -0
- data/lib/packo/rbuild/modules/building/cmake.rb +38 -0
- data/lib/packo/rbuild/modules/building/patch.rb +84 -0
- data/lib/packo/rbuild/modules/building/rake.rb +74 -0
- data/lib/packo/rbuild/modules/building/strip.rb +41 -0
- data/lib/packo/rbuild/modules/misc.rb +26 -0
- data/lib/packo/rbuild/modules/misc/fetcher.rb +177 -0
- data/lib/packo/rbuild/modules/misc/fetching.rb +22 -0
- data/lib/packo/rbuild/modules/misc/fetching/git.rb +57 -0
- data/lib/packo/rbuild/modules/misc/fetching/github.rb +31 -0
- data/lib/packo/rbuild/modules/misc/fetching/gnu.rb +59 -0
- data/lib/packo/rbuild/modules/misc/fetching/mercurial.rb +51 -0
- data/lib/packo/rbuild/modules/misc/fetching/sourceforge.rb +47 -0
- data/lib/packo/rbuild/modules/misc/fetching/subversion.rb +51 -0
- data/lib/packo/rbuild/modules/misc/fetching/wget.rb +57 -0
- data/lib/packo/rbuild/modules/misc/unpacker.rb +70 -0
- data/lib/packo/rbuild/modules/misc/unpacking.rb +23 -0
- data/lib/packo/rbuild/modules/misc/unpacking/lzma.rb +34 -0
- data/lib/packo/rbuild/modules/misc/unpacking/tar.rb +35 -0
- data/lib/packo/rbuild/modules/misc/unpacking/xz.rb +34 -0
- data/lib/packo/rbuild/modules/misc/unpacking/zip.rb +26 -0
- data/lib/packo/rbuild/modules/packaging.rb +20 -0
- data/lib/packo/rbuild/modules/packaging/pko.rb +78 -0
- data/lib/packo/rbuild/package.rb +281 -0
- data/lib/packo/rbuild/package/manifest.rb +169 -0
- data/lib/packo/rbuild/stages.rb +171 -0
- data/lib/packo/rbuild/stages/callbacks.rb +96 -0
- data/lib/packo/rbuild/stages/stage.rb +50 -0
- data/lib/packo/repository.rb +95 -0
- data/lib/packo/repository/binary.rb +116 -0
- data/lib/packo/repository/source.rb +77 -0
- data/lib/packo/repository/virtual.rb +66 -0
- data/lib/packo/system.rb +53 -0
- data/lib/packo/version.rb +26 -0
- metadata +276 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
|
|
3
|
+
#
|
|
4
|
+
# This file is part of packo.
|
|
5
|
+
#
|
|
6
|
+
# packo is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU Affero General Public License as published
|
|
8
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# packo is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
# along with packo. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
#++
|
|
19
|
+
|
|
20
|
+
require 'packo/package/feature'
|
|
21
|
+
|
|
22
|
+
module Packo; class Package
|
|
23
|
+
|
|
24
|
+
class Flavor
|
|
25
|
+
def self.parse (text)
|
|
26
|
+
data = []
|
|
27
|
+
|
|
28
|
+
text.split(/\s+/).each {|part|
|
|
29
|
+
data << Feature.parse(part)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Flavor.new(data)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def initialize (values={})
|
|
36
|
+
@values = {}
|
|
37
|
+
|
|
38
|
+
if values.is_a?(Array)
|
|
39
|
+
values.dup.each {|feature|
|
|
40
|
+
@values[feature.name] = feature
|
|
41
|
+
}
|
|
42
|
+
elsif values.is_a?(Hash)
|
|
43
|
+
values.dup.each {|name, value|
|
|
44
|
+
@values[name.to_sym] = Feature.new(name, value || false)
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def each
|
|
50
|
+
@values.dup.each_value {|feature|
|
|
51
|
+
yield feature
|
|
52
|
+
}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def empty?
|
|
56
|
+
@values.empty?
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def set (name, value)
|
|
60
|
+
@values[name.to_sym] = Feature.new(name, value)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def get (name)
|
|
64
|
+
@values[name.to_sym] ||= Feature.new(name, false)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def delete (name)
|
|
68
|
+
@values.delete(name.to_sym)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def has? (name)
|
|
72
|
+
@values.key? name.to_sym
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def to_hash
|
|
76
|
+
Hash[*@values.map {|(name, element)|
|
|
77
|
+
[name, element.value]
|
|
78
|
+
}]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def to_a
|
|
82
|
+
@values.map {|(name, element)|
|
|
83
|
+
element
|
|
84
|
+
}
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def to_s (type=:normal)
|
|
88
|
+
values = @values.map {|(name, value)|
|
|
89
|
+
next unless name != :binary && value.enabled?
|
|
90
|
+
|
|
91
|
+
name.to_s
|
|
92
|
+
}.compact
|
|
93
|
+
|
|
94
|
+
case type
|
|
95
|
+
when :normal; values.join(' ')
|
|
96
|
+
when :package; values.join('.')
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
end; end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
|
|
3
|
+
#
|
|
4
|
+
# This file is part of packo.
|
|
5
|
+
#
|
|
6
|
+
# packo is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU Affero General Public License as published
|
|
8
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# packo is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
# along with packo. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
#++
|
|
19
|
+
|
|
20
|
+
require 'digest/sha1'
|
|
21
|
+
|
|
22
|
+
require 'packo/package/tags/expression'
|
|
23
|
+
|
|
24
|
+
module Packo; class Package
|
|
25
|
+
|
|
26
|
+
class Tags < Array
|
|
27
|
+
def self.parse (value)
|
|
28
|
+
Tags.new(value.is_a?(Array) ? value : Tags.new(value.to_s.split(%r{/|\s+})))
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def initialize (*tags)
|
|
32
|
+
tags.flatten.compact.each {|tag|
|
|
33
|
+
self << tag.to_s.strip.downcase
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
reject! {|tag|
|
|
37
|
+
tag.empty?
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def == (tags)
|
|
42
|
+
self.to_a.sort == Tags.parse(tags).to_a.sort
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def hashed
|
|
46
|
+
Digest::SHA1.hexdigest(self.sort.join('/'))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def hash
|
|
50
|
+
self.sort.join('/').hash
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def to_s (minimized=false)
|
|
54
|
+
minimized ?
|
|
55
|
+
self.sort.map {|t| t[0]}.join :
|
|
56
|
+
self.join('/')
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end; end
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
|
|
3
|
+
#
|
|
4
|
+
# This file is part of packo.
|
|
5
|
+
#
|
|
6
|
+
# packo is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU Affero General Public License as published
|
|
8
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# packo is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
# along with packo. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
#++
|
|
19
|
+
|
|
20
|
+
require 'packo/package/tags/expression/name'
|
|
21
|
+
require 'packo/package/tags/expression/logic'
|
|
22
|
+
require 'packo/package/tags/expression/group'
|
|
23
|
+
|
|
24
|
+
require 'stringio'
|
|
25
|
+
|
|
26
|
+
module Packo; class Package; class Tags < Array
|
|
27
|
+
|
|
28
|
+
class Expression
|
|
29
|
+
def self.parse (text)
|
|
30
|
+
base = Group.new
|
|
31
|
+
name = nil
|
|
32
|
+
stack = [base]
|
|
33
|
+
logic = nil
|
|
34
|
+
|
|
35
|
+
text.to_s.each_char.to_a.each_with_index {|char, index|
|
|
36
|
+
begin
|
|
37
|
+
if char == ')' && stack.length == 1
|
|
38
|
+
raise SyntaxError.new('Closing an unopened parenthesis')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
if char.match(/\s|\(|\)/) || (!logic && ['|', '&', '!'].member?(char))
|
|
42
|
+
if logic || (name && name.match(/(and|or|not)/i))
|
|
43
|
+
stack.last << Logic.new(logic || name)
|
|
44
|
+
logic = nil
|
|
45
|
+
name = nil
|
|
46
|
+
elsif name
|
|
47
|
+
stack.last << Name.new(name)
|
|
48
|
+
name = nil
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
if name || logic
|
|
53
|
+
name << char if name
|
|
54
|
+
logic << char if logic
|
|
55
|
+
else
|
|
56
|
+
case char
|
|
57
|
+
when '('; stack.push Group.new
|
|
58
|
+
when ')'; stack[-2] << stack.pop
|
|
59
|
+
when '|'; logic = '|'
|
|
60
|
+
when '&'; logic = '&'
|
|
61
|
+
when '!'; stack.last << Logic.new('!')
|
|
62
|
+
else; name = char if !char.match(/\s/)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
rescue SyntaxError => e
|
|
66
|
+
raise "#{e.message} near `#{text[index - 4, 8]}` at character #{index}"
|
|
67
|
+
end
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if stack.length != 1
|
|
71
|
+
raise SyntaxError.new('Not all parenthesis are closed')
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
if logic
|
|
75
|
+
raise SyntaxError.new('The expression cannot end with a logic operator')
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
base << Name.new(name) if name
|
|
79
|
+
|
|
80
|
+
Expression.new(base)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
attr_reader :base
|
|
84
|
+
|
|
85
|
+
def initialize (base=Group.new)
|
|
86
|
+
@base = base
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def evaluate (package)
|
|
90
|
+
_evaluate(@base, package.is_a?(Array) ? package : package.tags.to_a)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
private
|
|
94
|
+
|
|
95
|
+
def _evaluate (group, tags)
|
|
96
|
+
values = []
|
|
97
|
+
|
|
98
|
+
group.each {|thing|
|
|
99
|
+
case thing
|
|
100
|
+
when Logic; values << thing
|
|
101
|
+
when Group; values << _evaluate(thing, tags)
|
|
102
|
+
when Name; values << tags.member?(thing)
|
|
103
|
+
end
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
at = 0
|
|
107
|
+
while at < values.length
|
|
108
|
+
if values[at].is_a?(Logic) && values[at].type == :not
|
|
109
|
+
values.delete_at(at)
|
|
110
|
+
values[at] = !values[at]
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
at += 1
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
while values.length > 1
|
|
117
|
+
if values.first.is_a?(Logic) && values.first.type == :not
|
|
118
|
+
values.shift
|
|
119
|
+
values.first = !values.first
|
|
120
|
+
else
|
|
121
|
+
a, logic, b = values.shift(3)
|
|
122
|
+
values.unshift(logic.evaluate(a, b))
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
return values.pop
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
end; end; end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
|
|
3
|
+
#
|
|
4
|
+
# This file is part of packo.
|
|
5
|
+
#
|
|
6
|
+
# packo is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU Affero General Public License as published
|
|
8
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# packo is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
# along with packo. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
#++
|
|
19
|
+
|
|
20
|
+
module Packo; class Package; class Tags < Array; class Expression
|
|
21
|
+
|
|
22
|
+
class Group < Array
|
|
23
|
+
def inspect
|
|
24
|
+
'(' + self.map {|e| e.inspect}.join(' ') + ')'
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end; end; end; end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
|
|
3
|
+
#
|
|
4
|
+
# This file is part of packo.
|
|
5
|
+
#
|
|
6
|
+
# packo is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU Affero General Public License as published
|
|
8
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# packo is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
# along with packo. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
#++
|
|
19
|
+
|
|
20
|
+
module Packo; class Package; class Tags < Array; class Expression
|
|
21
|
+
|
|
22
|
+
class Logic
|
|
23
|
+
attr_reader :type
|
|
24
|
+
|
|
25
|
+
def initialize (what)
|
|
26
|
+
@type = case what
|
|
27
|
+
when '!', /not/i then :not
|
|
28
|
+
when '&&', /and/i then :and
|
|
29
|
+
when '||', /or/i then :or
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
raise SyntaxError.new('Invalid logical operator') unless @type
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def evaluate (a, b=nil)
|
|
36
|
+
case @type
|
|
37
|
+
when :not; !a
|
|
38
|
+
when :and; !!(a && b)
|
|
39
|
+
when :or; !!(a || b)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def inspect
|
|
44
|
+
self.type.to_s.upcase
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end; end; end; end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
|
|
3
|
+
#
|
|
4
|
+
# This file is part of packo.
|
|
5
|
+
#
|
|
6
|
+
# packo is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU Affero General Public License as published
|
|
8
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# packo is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
# along with packo. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
#++
|
|
19
|
+
|
|
20
|
+
module Packo; class Package; class Tags < Array; class Expression
|
|
21
|
+
|
|
22
|
+
class Name < String
|
|
23
|
+
def inspect
|
|
24
|
+
self.to_s.downcase
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end; end; end; end
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# Copyleft meh. [http://meh.doesntexist.org | meh@paranoici.org]
|
|
3
|
+
#
|
|
4
|
+
# This file is part of packo.
|
|
5
|
+
#
|
|
6
|
+
# packo is free software: you can redistribute it and/or modify
|
|
7
|
+
# it under the terms of the GNU Affero General Public License as published
|
|
8
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
# (at your option) any later version.
|
|
10
|
+
#
|
|
11
|
+
# packo is distributed in the hope that it will be useful,
|
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
# GNU Affero General Public License for more details.
|
|
15
|
+
#
|
|
16
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
# along with packo. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
+
#++
|
|
19
|
+
|
|
20
|
+
module Packo
|
|
21
|
+
|
|
22
|
+
class Profile
|
|
23
|
+
def self.path (path)
|
|
24
|
+
return unless File.directory?(path)
|
|
25
|
+
|
|
26
|
+
Profile.new(
|
|
27
|
+
config: "#{path}/config",
|
|
28
|
+
tags: "#{path}/tags",
|
|
29
|
+
packages: "#{path}/packages",
|
|
30
|
+
modules: "#{path}/modules",
|
|
31
|
+
mask: "#{path}/mask",
|
|
32
|
+
unmask: "#{path}/unmask",
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
attr_reader :paths
|
|
37
|
+
|
|
38
|
+
def initialize (paths={})
|
|
39
|
+
@paths = paths
|
|
40
|
+
|
|
41
|
+
if !@paths.is_a?(Hash)
|
|
42
|
+
@paths = @paths.to_hash rescue {}
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
@paths.delete_if {|_, path|
|
|
46
|
+
!File.file?(path) || !File.readable?(path)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@paths.dup.each {|name, path|
|
|
50
|
+
@paths[name] = Pathname.new(path)
|
|
51
|
+
}
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def method_missing (id, *args)
|
|
55
|
+
id = id.to_s.sub(/[=?]$/, '').to_sym
|
|
56
|
+
|
|
57
|
+
if args.length == 0
|
|
58
|
+
return @paths[id]
|
|
59
|
+
else
|
|
60
|
+
if respond_to? "#{id}="
|
|
61
|
+
send "#{id}=", *args
|
|
62
|
+
else
|
|
63
|
+
@paths[id] = Pathname.new(args.first)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def apply! (environment, package=nil)
|
|
69
|
+
mod = ::Module.new
|
|
70
|
+
|
|
71
|
+
begin
|
|
72
|
+
suppress_warnings {
|
|
73
|
+
mod.module_eval File.read(config)
|
|
74
|
+
} if File.readable?(config.to_s)
|
|
75
|
+
rescue Exception => e
|
|
76
|
+
Packo.debug e
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
if package
|
|
80
|
+
if File.directory?(modules.to_s)
|
|
81
|
+
Dir.glob("#{modules}/*").each {|script|
|
|
82
|
+
package.instance_exec(package, File.read(script)) if File.readable?(script)
|
|
83
|
+
}
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
if File.readable?(tags.to_s)
|
|
87
|
+
file = File.read(tags)
|
|
88
|
+
tags = {}
|
|
89
|
+
values = file.split(/^\s*\[.*?\]\s*$/); values.shift
|
|
90
|
+
|
|
91
|
+
file.scan(/^\s*\[(.*?)\]\s*$/).flatten.each_with_index {|name, index|
|
|
92
|
+
tags[name] = values[index]
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
tags.each {|expr, value|
|
|
96
|
+
next unless Packo::Package::Tags::Expression.parse(expr).evaluate(package) rescue false
|
|
97
|
+
|
|
98
|
+
begin
|
|
99
|
+
suppress_warnings {
|
|
100
|
+
mod.module_eval value
|
|
101
|
+
}
|
|
102
|
+
rescue Exception => e
|
|
103
|
+
Packo.debug e
|
|
104
|
+
end
|
|
105
|
+
}
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
if File.readable?(packages.to_s)
|
|
109
|
+
file = File.read(packages)
|
|
110
|
+
packages = {}
|
|
111
|
+
values = file.split(/^\s*\[.*?\]\s*$/); values.shift
|
|
112
|
+
|
|
113
|
+
file.scan(/^\s*\[(.*?)\]\s*$/).flatten.each_with_index {|name, index|
|
|
114
|
+
packages[name] = values[index]
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
packages.each {|name, value|
|
|
118
|
+
next unless Packo::Package::Dependency.parse(name).in?(package) rescue false
|
|
119
|
+
|
|
120
|
+
begin
|
|
121
|
+
suppress_warnings {
|
|
122
|
+
mod.module_eval value
|
|
123
|
+
}
|
|
124
|
+
rescue Exception => e
|
|
125
|
+
Packo.debug e
|
|
126
|
+
end
|
|
127
|
+
}
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
if File.readable?(mask.to_s)
|
|
131
|
+
File.read(mask).lines.each {|line|
|
|
132
|
+
line.strip!
|
|
133
|
+
|
|
134
|
+
if line.start_with?('[') && line.end_with?(']')
|
|
135
|
+
if Packo::Package::Tags::Expression.parse(line[1, line.length - 2]).evaluate(package)
|
|
136
|
+
package.mask!
|
|
137
|
+
end
|
|
138
|
+
else
|
|
139
|
+
if Packo::Package::Dependency.parse(line).in?(package)
|
|
140
|
+
package.mask!
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
}
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
if File.readable?(unmask.to_s)
|
|
147
|
+
File.read(unmask).lines.each {|line|
|
|
148
|
+
line.strip!
|
|
149
|
+
|
|
150
|
+
if line.start_with?('[') && line.end_with?(']')
|
|
151
|
+
if Packo::Package::Tags::Expression.parse(line[1, line.length - 2]).evaluate(package)
|
|
152
|
+
package.unmask!
|
|
153
|
+
end
|
|
154
|
+
else
|
|
155
|
+
if Packo::Package::Dependency.parse(line).in?(package)
|
|
156
|
+
package.unmask!
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
}
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
mod.constants.each {|const|
|
|
165
|
+
environment[const] = mod.const_get const
|
|
166
|
+
}
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def hash
|
|
170
|
+
@paths.hash
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
end
|