packo 0.0.1.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/bin/packo +78 -0
  2. data/bin/packo-base +24 -0
  3. data/bin/packo-build +24 -0
  4. data/bin/packo-db +24 -0
  5. data/bin/packo-env +24 -0
  6. data/bin/packo-files +24 -0
  7. data/bin/packo-profile +24 -0
  8. data/bin/packo-repository +24 -0
  9. data/bin/packo-select +24 -0
  10. data/lib/packo.rb +186 -0
  11. data/lib/packo/cli.rb +79 -0
  12. data/lib/packo/cli/base.rb +554 -0
  13. data/lib/packo/cli/build.rb +488 -0
  14. data/lib/packo/cli/database.rb +55 -0
  15. data/lib/packo/cli/database/definition.rb +65 -0
  16. data/lib/packo/cli/database/helpers.rb +20 -0
  17. data/lib/packo/cli/environment.rb +45 -0
  18. data/lib/packo/cli/files.rb +153 -0
  19. data/lib/packo/cli/profile.rb +31 -0
  20. data/lib/packo/cli/repository.rb +561 -0
  21. data/lib/packo/cli/repository/binary.rb +74 -0
  22. data/lib/packo/cli/repository/helpers.rb +20 -0
  23. data/lib/packo/cli/repository/repository.rb +48 -0
  24. data/lib/packo/cli/repository/source.rb +91 -0
  25. data/lib/packo/cli/repository/virtual.rb +53 -0
  26. data/lib/packo/cli/select.rb +61 -0
  27. data/lib/packo/do.rb +249 -0
  28. data/lib/packo/environment.rb +269 -0
  29. data/lib/packo/extensions.rb +70 -0
  30. data/lib/packo/flags.rb +64 -0
  31. data/lib/packo/host.rb +121 -0
  32. data/lib/packo/models.rb +171 -0
  33. data/lib/packo/models/installed_package.rb +190 -0
  34. data/lib/packo/models/installed_package/content.rb +50 -0
  35. data/lib/packo/models/installed_package/dependency.rb +39 -0
  36. data/lib/packo/models/repository.rb +209 -0
  37. data/lib/packo/models/repository/binary.rb +32 -0
  38. data/lib/packo/models/repository/binary/mirror.rb +35 -0
  39. data/lib/packo/models/repository/package.rb +73 -0
  40. data/lib/packo/models/repository/package/binary.rb +34 -0
  41. data/lib/packo/models/repository/package/binary/build.rb +36 -0
  42. data/lib/packo/models/repository/package/source.rb +36 -0
  43. data/lib/packo/models/repository/package/source/feature.rb +36 -0
  44. data/lib/packo/models/repository/package/source/flavor.rb +36 -0
  45. data/lib/packo/models/repository/package/virtual.rb +32 -0
  46. data/lib/packo/models/repository/source.rb +30 -0
  47. data/lib/packo/models/repository/virtual.rb +30 -0
  48. data/lib/packo/models/selector.rb +34 -0
  49. data/lib/packo/models/tag.rb +30 -0
  50. data/lib/packo/package.rb +239 -0
  51. data/lib/packo/package/blocker.rb +100 -0
  52. data/lib/packo/package/blockers.rb +40 -0
  53. data/lib/packo/package/dependencies.rb +40 -0
  54. data/lib/packo/package/dependency.rb +100 -0
  55. data/lib/packo/package/feature.rb +55 -0
  56. data/lib/packo/package/features.rb +105 -0
  57. data/lib/packo/package/flavor.rb +101 -0
  58. data/lib/packo/package/tags.rb +60 -0
  59. data/lib/packo/package/tags/expression.rb +130 -0
  60. data/lib/packo/package/tags/expression/group.rb +28 -0
  61. data/lib/packo/package/tags/expression/logic.rb +48 -0
  62. data/lib/packo/package/tags/expression/name.rb +28 -0
  63. data/lib/packo/profile.rb +174 -0
  64. data/lib/packo/rbuild.rb +22 -0
  65. data/lib/packo/rbuild/behaviors.rb +20 -0
  66. data/lib/packo/rbuild/behaviors/default.rb +27 -0
  67. data/lib/packo/rbuild/feature.rb +64 -0
  68. data/lib/packo/rbuild/features.rb +65 -0
  69. data/lib/packo/rbuild/flavor.rb +67 -0
  70. data/lib/packo/rbuild/module.rb +40 -0
  71. data/lib/packo/rbuild/modules.rb +27 -0
  72. data/lib/packo/rbuild/modules/building.rb +24 -0
  73. data/lib/packo/rbuild/modules/building/autotools.rb +315 -0
  74. data/lib/packo/rbuild/modules/building/cmake.rb +38 -0
  75. data/lib/packo/rbuild/modules/building/patch.rb +84 -0
  76. data/lib/packo/rbuild/modules/building/rake.rb +74 -0
  77. data/lib/packo/rbuild/modules/building/strip.rb +41 -0
  78. data/lib/packo/rbuild/modules/misc.rb +26 -0
  79. data/lib/packo/rbuild/modules/misc/fetcher.rb +177 -0
  80. data/lib/packo/rbuild/modules/misc/fetching.rb +22 -0
  81. data/lib/packo/rbuild/modules/misc/fetching/git.rb +57 -0
  82. data/lib/packo/rbuild/modules/misc/fetching/github.rb +31 -0
  83. data/lib/packo/rbuild/modules/misc/fetching/gnu.rb +59 -0
  84. data/lib/packo/rbuild/modules/misc/fetching/mercurial.rb +51 -0
  85. data/lib/packo/rbuild/modules/misc/fetching/sourceforge.rb +47 -0
  86. data/lib/packo/rbuild/modules/misc/fetching/subversion.rb +51 -0
  87. data/lib/packo/rbuild/modules/misc/fetching/wget.rb +57 -0
  88. data/lib/packo/rbuild/modules/misc/unpacker.rb +70 -0
  89. data/lib/packo/rbuild/modules/misc/unpacking.rb +23 -0
  90. data/lib/packo/rbuild/modules/misc/unpacking/lzma.rb +34 -0
  91. data/lib/packo/rbuild/modules/misc/unpacking/tar.rb +35 -0
  92. data/lib/packo/rbuild/modules/misc/unpacking/xz.rb +34 -0
  93. data/lib/packo/rbuild/modules/misc/unpacking/zip.rb +26 -0
  94. data/lib/packo/rbuild/modules/packaging.rb +20 -0
  95. data/lib/packo/rbuild/modules/packaging/pko.rb +78 -0
  96. data/lib/packo/rbuild/package.rb +281 -0
  97. data/lib/packo/rbuild/package/manifest.rb +169 -0
  98. data/lib/packo/rbuild/stages.rb +171 -0
  99. data/lib/packo/rbuild/stages/callbacks.rb +96 -0
  100. data/lib/packo/rbuild/stages/stage.rb +50 -0
  101. data/lib/packo/repository.rb +95 -0
  102. data/lib/packo/repository/binary.rb +116 -0
  103. data/lib/packo/repository/source.rb +77 -0
  104. data/lib/packo/repository/virtual.rb +66 -0
  105. data/lib/packo/system.rb +53 -0
  106. data/lib/packo/version.rb +26 -0
  107. metadata +276 -0
@@ -0,0 +1,36 @@
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; module Models; class Repository; class Package; class Source
21
+
22
+ class Feature
23
+ include DataMapper::Resource
24
+
25
+ belongs_to :source
26
+
27
+ property :id, Serial
28
+
29
+ property :source_package_id, Integer, unique_index: :a
30
+ property :name, String, unique_index: :a
31
+
32
+ property :description, Text, default: ''
33
+ property :enabled, Boolean, default: false
34
+ end
35
+
36
+ end; end; end; end; end
@@ -0,0 +1,36 @@
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; module Models; class Repository; class Package; class Source
21
+
22
+ class Flavor
23
+ include DataMapper::Resource
24
+
25
+ belongs_to :source
26
+
27
+ property :id, Serial
28
+
29
+ property :source_package_id, Integer, unique_index: :a
30
+ property :name, String, unique_index: :a
31
+
32
+ property :description, Text, default: ''
33
+ property :enabled, Boolean, default: false
34
+ end
35
+
36
+ end; end; end; end; end
@@ -0,0 +1,32 @@
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; module Models; class Repository; class Package
21
+
22
+ class Virtual
23
+ include DataMapper::Resource
24
+
25
+ belongs_to :package, key: true
26
+
27
+ property :package_id, Integer, key: true
28
+
29
+ property :content, Object
30
+ end
31
+
32
+ end; end; end; end
@@ -0,0 +1,30 @@
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; module Models; class Repository
21
+
22
+ class Source
23
+ include DataMapper::Resource
24
+
25
+ belongs_to :repo, 'Repository', key: true
26
+
27
+ property :address, Text, default: '', required: false
28
+ end
29
+
30
+ end; end; end
@@ -0,0 +1,30 @@
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; module Models; class Repository
21
+
22
+ class Virtual
23
+ include DataMapper::Resource
24
+
25
+ belongs_to :repo, 'Repository', key: true
26
+
27
+ property :address, Text, required: false
28
+ end
29
+
30
+ end; end; end
@@ -0,0 +1,34 @@
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; module Models
21
+
22
+ class Selector
23
+ include DataMapper::Resource
24
+
25
+ property :id, Serial
26
+
27
+ property :name, String, unique: true
28
+ property :description, Text, default: ''
29
+ property :path, Text, default: ''
30
+
31
+ property :data, Object, required: false
32
+ end
33
+
34
+ end; end
@@ -0,0 +1,30 @@
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; module Models
21
+
22
+ class Tag
23
+ include DataMapper::Resource
24
+
25
+ property :id, Serial
26
+
27
+ property :name, Text, required: true
28
+ end
29
+
30
+ end; end
@@ -0,0 +1,239 @@
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 'versionomy'
21
+
22
+ require 'packo/package/tags'
23
+ require 'packo/package/flavor'
24
+ require 'packo/package/features'
25
+
26
+ module Packo
27
+
28
+ class Package
29
+ def self.parse (text, type=:standard)
30
+ data = {}
31
+
32
+ case type
33
+ when :standard
34
+ matches = text.match(/^(.*?)(\[(.*?)\])?(\{(.*?)\})?$/)
35
+
36
+ data[:features] = matches[3]
37
+ data[:flavor] = matches[5]
38
+
39
+ matches = matches[1].match(/^(.*?)(-(\d.*?))?(%(.*?))?$/)
40
+
41
+ data[:tags] = matches[1].split('/')
42
+
43
+ if matches[1][matches[1].length - 1] != '/'
44
+ data[:name] = data[:tags].pop
45
+ end
46
+
47
+ data[:version] = matches[3]
48
+ data[:slot] = matches[5]
49
+ end
50
+
51
+ Package.new(data)
52
+ end
53
+
54
+ def self.wrap (model)
55
+ case model
56
+ when Models::Repository::Package; Package.new(
57
+ tags: model.tags.map {|t| t.name},
58
+ name: model.name,
59
+ version: model.version,
60
+ slot: model.slot,
61
+ revision: model.revision,
62
+
63
+ features: (case model.repo.type
64
+ when :binary; model.data.features
65
+ when :source; model.data.features.map {|f| f.name}.join(' ')
66
+ end),
67
+
68
+ description: model.description,
69
+ homepage: model.homepage,
70
+ license: model.license,
71
+
72
+ repository: Repository.wrap(model.repo),
73
+ model: model
74
+ )
75
+
76
+ when Models::InstalledPackage; Package.new(
77
+ tags: model.tags.map {|t| t.name},
78
+ name: model.name,
79
+ version: model.version,
80
+ slot: model.slot,
81
+ revision: model.revision,
82
+
83
+ flavor: model.flavor,
84
+ features: model.features,
85
+
86
+ repository: model.repo ? Repository.parse(model.repo) : nil,
87
+ model: model
88
+ )
89
+
90
+ else; raise "I do not know #{model.class}."
91
+ end
92
+ end
93
+
94
+ attr_reader :model, :environment
95
+
96
+ def environment!; @environmentClean; end
97
+
98
+ alias env environment
99
+ alias env! environment!
100
+
101
+ def initialize (data)
102
+ @data = {}
103
+ @environment = Environment.new(self)
104
+ @environmentClean = Environment.new(self, true)
105
+ @export = []
106
+
107
+ data.each {|name, value|
108
+ self.send "#{name}=", value
109
+ }
110
+
111
+ self.tags = [] unless self.tags
112
+
113
+ @model = data[:model]
114
+ end
115
+
116
+ def method_missing (id, *args)
117
+ id = id.to_s.sub(/[=?]$/, '').to_sym
118
+
119
+ if args.length == 0
120
+ return @data[id]
121
+ else
122
+ if respond_to? "#{id}="
123
+ send "#{id}=", *args
124
+ else
125
+ @data[id] = (args.length > 1) ? args : args.first
126
+ end
127
+ end
128
+ end
129
+
130
+ def envify!
131
+ environment.apply!
132
+
133
+ environment[:FLAVOR].split(/\s+/).each {|element|
134
+ matches = element.match(/^([+-])?(.+)$/)
135
+
136
+ (matches[1] == '-') ?
137
+ self.flavor.send("not_#{matches[2]}!") :
138
+ self.flavor.send("#{matches[2]}!")
139
+ }
140
+
141
+ "#{environment[:FEATURES]} #{environment[:USE]}".split(/\s+/).each {|feature|
142
+ feature = Feature.parse(feature)
143
+
144
+ self.features {
145
+ next if !self.has?(feature.name)
146
+
147
+ if feature.enabled?
148
+ self.get(feature.name).enable!
149
+ else
150
+ self.get(feature.name).disable!
151
+ end
152
+ }
153
+ }
154
+ end
155
+
156
+ def export! (*names)
157
+ @export.insert(-1, *names)
158
+ @export.compact!
159
+ @export.uniq!
160
+ end
161
+
162
+ def exports
163
+ result = {}
164
+
165
+ @export.each {|export|
166
+ result[export] = @data[export]
167
+ }
168
+
169
+ result
170
+ end
171
+
172
+ def masked?; !!@masked end
173
+ def mask!; @masked = true if @masked != false end
174
+ def unmask!; @masked = false end
175
+
176
+ def tags= (*value)
177
+ @data[:tags] = Tags.parse(value.length > 1 ? value : value.first) unless value.empty? || !value.first
178
+ end
179
+
180
+ def version= (value)
181
+ @data[:version] = ((value.is_a?(Versionomy::Value)) ? value : Versionomy.parse(value.to_s)) if value
182
+ end
183
+
184
+ def slot= (value)
185
+ @data[:slot] = (value.to_s.empty?) ? nil : value.to_s
186
+ end
187
+
188
+ def revision= (value)
189
+ @data[:revision] = value.to_i rescue 0
190
+ end
191
+
192
+ def flavor= (value)
193
+ @data[:flavor] = ((value.is_a?(Flavor)) ? value : Flavor.parse(value.to_s))
194
+ end
195
+
196
+ def features= (value)
197
+ @data[:features] = ((value.is_a?(Features)) ? value : Features.parse(value.to_s))
198
+ end
199
+
200
+ def == (package)
201
+ name == package.name &&
202
+ tags == ((defined?(Packo::Models) && package.is_a?(Packo::Models::Repository::Package)) ? Package.wrap(package).tags : package.tags)
203
+ end
204
+
205
+ def === (package)
206
+ name == package.name &&
207
+ tags == ((defined?(Packo::Models) && package.is_a?(Packo::Models::Repository::Package)) ? Package.wrap(package).tags : package.tags) &&
208
+ version == package.version &&
209
+ slot == package.slot &&
210
+ revision == package.revision
211
+ end
212
+
213
+ alias eql? ===
214
+
215
+ def hash
216
+ "#{self.tags.hashed}/#{self.name}-#{self.version}%#{self.slot}".hash
217
+ end
218
+
219
+ def to_hash
220
+ result = {}
221
+
222
+ [:tags, :name, :version, :slot, :revision, :repository, :flavor, :features].each {|name|
223
+ if tmp = self.send(name)
224
+ result[name] = tmp
225
+ end
226
+ }
227
+
228
+ return result
229
+ end
230
+
231
+ def to_s (type=:whole)
232
+ case type
233
+ when :whole; "#{self.to_s(:name)}#{"-#{version}" if version}#{"%#{slot}" if slot}"
234
+ when :name; "#{tags}/#{name}"
235
+ end
236
+ end
237
+ end
238
+
239
+ end