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,100 @@
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
21
+
22
+ class Blocker < Package
23
+ def self.parse (text)
24
+ text = text.dup
25
+
26
+ if text.end_with? '!!'
27
+ text[-2, 2] = ''
28
+ type = :runtime
29
+ elsif text.end_with? '!'
30
+ text[-1] = ''
31
+ type = :build
32
+ else
33
+ type = :both
34
+ end
35
+
36
+ if matches = text.match(/^([<>~]?=?)/)
37
+ validity = ((matches[1] && !matches[1].empty?) ? matches[1] : nil)
38
+ text.sub!(/^([<>~]?=?)/, '')
39
+ else
40
+ validity = nil
41
+ end
42
+
43
+ parsed = Packo::Package.parse(text)
44
+
45
+ self.new(parsed.to_hash, validity, type)
46
+ end
47
+
48
+ attr_reader :type, :validity
49
+
50
+ def initialize (data, validity=nil, type=nil)
51
+ super(data)
52
+
53
+ @validity = validity
54
+ @type = type
55
+ end
56
+
57
+ def runtime?; [:runtime, :both].member?(@type) end
58
+ def build?; [:build, :both].member?(@type) end
59
+ def both?; @type == :both end
60
+
61
+ def in? (package)
62
+ return false if package.name != name || package.tags != tags
63
+
64
+ return true if !version
65
+
66
+ case validity
67
+ when '~', '~=' then !!package.version.to_s.match(/^#{Regexp.escape(version.to_s)}/)
68
+ when '>' then package.version > version
69
+ when '>=' then package.version >= version
70
+ when '<' then package.version < version
71
+ when '<=' then package.version <= version
72
+ else package.version == version
73
+ end
74
+ end
75
+
76
+ def to_s (type=:normal)
77
+ case type
78
+ when :short
79
+ "#{tags}/#{name}#{"-#{version}" if version}"
80
+
81
+ else
82
+ features = features.to_a.sort {|a, b|
83
+ if a.enabled? && b.enabled? ; 0
84
+ elsif a.enabled? && !b.enabled? ; -1
85
+ else ; 1
86
+ end
87
+ }.map {|feature|
88
+ (feature.enabled? ? '' : '-') + feature.name.to_s
89
+ }.join(',')
90
+
91
+ flavor = flavor.to_a.map {|f|
92
+ f.name.to_s
93
+ }.sort
94
+
95
+ "#{validity}#{tags}/#{name}#{"-#{version}" if version}#{"[#{features}]" if !features.empty?}#{"{#{flavor}}" if !flavor.empty?}"
96
+ end
97
+ end
98
+ end
99
+
100
+ end; end
@@ -0,0 +1,40 @@
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/blocker'
21
+
22
+ module Packo; class Package
23
+
24
+ class Blockers < Array
25
+ attr_reader :package
26
+
27
+ def initialize (package)
28
+ @package = package
29
+ end
30
+
31
+ def push (blocker)
32
+ super(blocker.is_a?(Blocker) ? blocker : Blocker.parse(blocker))
33
+ self.compact!
34
+ self
35
+ end
36
+
37
+ alias << push
38
+ end
39
+
40
+ end; end
@@ -0,0 +1,40 @@
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/dependency'
21
+
22
+ module Packo; class Package
23
+
24
+ class Dependencies < Array
25
+ attr_reader :package
26
+
27
+ def initialize (package)
28
+ @package = package
29
+ end
30
+
31
+ def push (dependency)
32
+ super(dependency.is_a?(Dependency) ? dependency : Dependency.parse(dependency))
33
+ self.compact!
34
+ self
35
+ end
36
+
37
+ alias << push
38
+ end
39
+
40
+ end; end
@@ -0,0 +1,100 @@
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
21
+
22
+ class Dependency < Package
23
+ def self.parse (text)
24
+ text = text.dup
25
+
26
+ if text.end_with? '!!'
27
+ text[-2, 2] = ''
28
+ type = :runtime
29
+ elsif text.end_with? '!'
30
+ text[-1] = ''
31
+ type = :build
32
+ else
33
+ type = :both
34
+ end
35
+
36
+ if matches = text.match(/^([<>~]?=?)/)
37
+ validity = ((matches[1] && !matches[1].empty?) ? matches[1] : nil)
38
+ text.sub!(/^([<>~]?=?)/, '')
39
+ else
40
+ validity = nil
41
+ end
42
+
43
+ parsed = Packo::Package.parse(text)
44
+
45
+ self.new(parsed.to_hash, validity, type)
46
+ end
47
+
48
+ attr_reader :type, :validity
49
+
50
+ def initialize (data, validity=nil, type=nil)
51
+ super(data)
52
+
53
+ @validity = validity
54
+ @type = type
55
+ end
56
+
57
+ def runtime?; [:runtime, :both].member?(@type) end
58
+ def build?; [:build, :both].member?(@type) end
59
+ def both?; @type == :both end
60
+
61
+ def in? (package)
62
+ return false if package.name != name || package.tags != tags
63
+
64
+ return true if !version
65
+
66
+ case validity
67
+ when '~', '~=' then !!package.version.to_s.match(/^#{Regexp.escape(version.to_s)}/)
68
+ when '>' then package.version > version
69
+ when '>=' then package.version >= version
70
+ when '<' then package.version < version
71
+ when '<=' then package.version <= version
72
+ else package.version == version
73
+ end
74
+ end
75
+
76
+ def to_s (type=:normal)
77
+ case type
78
+ when :short
79
+ "#{tags}/#{name}#{"-#{version}" if version}"
80
+
81
+ else
82
+ features = features.to_a.sort {|a, b|
83
+ if a.enabled? && b.enabled? ; 0
84
+ elsif a.enabled? && !b.enabled? ; -1
85
+ else ; 1
86
+ end
87
+ }.map {|feature|
88
+ (feature.enabled? ? '' : '-') + feature.name.to_s
89
+ }.join(',')
90
+
91
+ flavor = flavor.to_a.map {|f|
92
+ f.name.to_s
93
+ }.sort
94
+
95
+ "#{validity}#{tags}/#{name}#{"-#{version}" if version}#{"[#{features}]" if !features.empty?}#{"{#{flavor}}" if !flavor.empty?}"
96
+ end
97
+ end
98
+ end
99
+
100
+ end; end
@@ -0,0 +1,55 @@
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
21
+
22
+ class Feature
23
+ def self.parse (text)
24
+ Feature.new(text.match(/^[\+\-]?(.*)$/)[1], !text.start_with?('-'))
25
+ end
26
+
27
+ attr_reader :name
28
+
29
+ def initialize (name, enabled=false, description=nil)
30
+ @name = name.to_sym
31
+ @enabled = !!enabled
32
+ @description = description
33
+ end
34
+
35
+ def enabled?; @enabled end
36
+ def disabled?; !@enabled end
37
+ def enabled!; @enabled = true unless @forced end
38
+ def disabled!; @enabled = false unless @forced end
39
+ def enable!; @enabled = true unless @forced end
40
+ def disable!; @enabled = false unless @forced end
41
+
42
+ def forced?; @forced end
43
+ def force!; @forced = true end
44
+ def not_forced!; @forced = false end
45
+
46
+ def description (value=nil)
47
+ value ? @description = value : @description
48
+ end
49
+
50
+ def to_s
51
+ name.to_s
52
+ end
53
+ end
54
+
55
+ end; end
@@ -0,0 +1,105 @@
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 Features
25
+ def self.parse (text)
26
+ data = []
27
+
28
+ text.split(/\s+/).each {|part|
29
+ data << Feature.parse(part)
30
+ }
31
+
32
+ Features.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
+ case type
89
+ when :package
90
+ @values.select {|name, feature| feature.enabled?}.map {|item| item[0]}.join('-')
91
+
92
+ when :normal
93
+ self.to_a.sort {|a, b|
94
+ if a.enabled? && b.enabled? ; 0
95
+ elsif a.enabled? && !b.enabled? ; -1
96
+ else ; 1
97
+ end
98
+ }.map {|feature|
99
+ (feature.enabled? ? '' : '-') + feature.name.to_s
100
+ }.join(' ')
101
+ end
102
+ end
103
+ end
104
+
105
+ end; end