packo 0.0.1.alpha.1 → 0.0.1.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/bin/packo +13 -2
  2. data/lib/packo.rb +16 -52
  3. data/lib/packo/cli.rb +9 -3
  4. data/lib/packo/cli/base.rb +65 -66
  5. data/lib/packo/cli/build.rb +124 -128
  6. data/lib/packo/cli/files.rb +7 -7
  7. data/lib/packo/cli/repository.rb +40 -26
  8. data/lib/packo/do.rb +106 -73
  9. data/lib/packo/environment.rb +2 -2
  10. data/lib/packo/extensions.rb +20 -6
  11. data/lib/packo/host.rb +10 -0
  12. data/lib/packo/models.rb +8 -2
  13. data/lib/packo/models/repository.rb +17 -14
  14. data/lib/packo/package.rb +9 -3
  15. data/lib/packo/profile.rb +2 -2
  16. data/lib/packo/rbuild.rb +0 -2
  17. data/lib/packo/rbuild/behaviors/default.rb +3 -2
  18. data/lib/packo/rbuild/{modules/misc/fetching.rb → behaviors/python.rb} +8 -3
  19. data/lib/packo/rbuild/modules.rb +2 -3
  20. data/lib/packo/rbuild/modules/building.rb +5 -2
  21. data/lib/packo/rbuild/modules/building/autotools.rb +11 -11
  22. data/lib/packo/rbuild/modules/building/rake.rb +71 -7
  23. data/lib/packo/rbuild/modules/building/scons.rb +128 -0
  24. data/lib/packo/rbuild/modules/{misc/fetcher.rb → fetcher.rb} +5 -5
  25. data/lib/packo/rbuild/modules/fetching.rb +29 -0
  26. data/lib/packo/rbuild/modules/{misc/fetching → fetching}/git.rb +15 -9
  27. data/lib/packo/rbuild/modules/{misc/fetching → fetching}/github.rb +1 -1
  28. data/lib/packo/rbuild/modules/{misc/fetching → fetching}/gnu.rb +1 -1
  29. data/lib/packo/rbuild/modules/{misc/fetching → fetching}/mercurial.rb +11 -7
  30. data/lib/packo/rbuild/modules/{misc/fetching → fetching}/sourceforge.rb +1 -1
  31. data/lib/packo/rbuild/modules/{misc/fetching → fetching}/subversion.rb +23 -5
  32. data/lib/packo/rbuild/modules/misc.rb +0 -8
  33. data/lib/packo/rbuild/modules/packager.rb +63 -0
  34. data/lib/packo/rbuild/modules/packaging.rb +2 -0
  35. data/lib/packo/rbuild/modules/packaging/pko.rb +24 -44
  36. data/lib/packo/rbuild/modules/{misc/unpacker.rb → unpacker.rb} +2 -2
  37. data/lib/packo/rbuild/modules/{misc/unpacking.rb → unpacking.rb} +6 -4
  38. data/lib/packo/rbuild/modules/{misc/unpacking → unpacking}/lzma.rb +1 -1
  39. data/lib/packo/rbuild/modules/{misc/unpacking → unpacking}/tar.rb +1 -1
  40. data/lib/packo/rbuild/modules/{misc/unpacking → unpacking}/xz.rb +1 -1
  41. data/lib/packo/rbuild/modules/{misc/unpacking → unpacking}/zip.rb +1 -1
  42. data/lib/packo/rbuild/package.rb +17 -8
  43. data/lib/packo/repository.rb +1 -1
  44. data/lib/packo/repository/virtual.rb +16 -0
  45. data/lib/packo/utils.rb +106 -0
  46. data/lib/packo/version.rb +1 -1
  47. metadata +39 -25
  48. data/lib/packo/rbuild/modules/misc/fetching/wget.rb +0 -57
@@ -238,7 +238,7 @@ class Environment < Hash
238
238
  if key.to_s.end_with?('FLAGS')
239
239
  self[key] = Flags.parse(value.to_s)
240
240
  elsif key.to_s.end_with?('PATH')
241
- self[key] = Pathname.new(value.to_s)
241
+ self[key] = Path.new(value.to_s)
242
242
  end
243
243
  }
244
244
  end
@@ -253,7 +253,7 @@ class Environment < Hash
253
253
  if name.to_s.end_with?('FLAGS')
254
254
  value = Flags.parse(value.to_s)
255
255
  elsif name.to_s.end_with?('PATH')
256
- value = Pathname.new(value.to_s)
256
+ value = Path.new(value.to_s)
257
257
  end
258
258
 
259
259
  super(name.to_sym, value)
@@ -18,11 +18,31 @@
18
18
  #++
19
19
 
20
20
  require 'ostruct'
21
+ require 'memoized'
22
+ require 'pathname'
23
+
24
+ Path = Pathname
25
+
26
+ class Pathname
27
+ def self.clean (path)
28
+ Pathname.new(path).cleanpath.to_s
29
+ end
30
+ end
21
31
 
22
32
  class Object
23
33
  def numeric?
24
34
  true if Float(self) rescue false
25
35
  end
36
+
37
+ def refine_method (meth, &block)
38
+ return unless block_given?
39
+
40
+ old = self.instance_method(meth) rescue Proc.new {}
41
+
42
+ define_method(meth) {|*args|
43
+ self.instance_exec((old.is_a?(Proc) ? old : old.bind(self)), *args, &block)
44
+ }
45
+ end
26
46
  end
27
47
 
28
48
  module Kernel
@@ -57,12 +77,6 @@ class String
57
77
  def interpolate (on)
58
78
  on.instance_eval("%{#{self}}") rescue self
59
79
  end
60
-
61
- def === (value)
62
- value.is_a?(Packo::Host) ?
63
- value == self :
64
- super(value)
65
- end
66
80
  end
67
81
 
68
82
  class OpenStruct
@@ -119,3 +119,13 @@ class Host
119
119
  end
120
120
 
121
121
  end
122
+
123
+ class String
124
+ refine_method(:==) do |old, value|
125
+ value.is_a?(Packo::Host) ? value == self : old.call(value)
126
+ end
127
+
128
+ refine_method(:===) do |old, value|
129
+ value.is_a?(Packo::Host) ? value === self : old.call(value)
130
+ end
131
+ end
@@ -78,11 +78,17 @@ class Property
78
78
  end
79
79
 
80
80
  def load (value)
81
- Versionomy.parse(value.to_s) unless value.to_s.empty?
81
+ return if value.to_s.empty?
82
+
83
+ whole, version, format = value.to_s.match(/^(.+?):([^:]+)$/).to_a
84
+
85
+ Versionomy.parse(version, format)
82
86
  end
83
87
 
84
88
  def dump (value)
85
- value.to_s unless value.nil?
89
+ return unless value
90
+
91
+ "#{value}:#{Versionomy::Format.canonical_name_for(value.format)}"
86
92
  end
87
93
 
88
94
  def typecast_to_primitive (value)
@@ -97,16 +97,9 @@ class Repository
97
97
  }
98
98
  end
99
99
  else
100
- if matches = expression.match(/^([<>]?=?)/)
101
- validity = ((matches[1] && !matches[1].empty?) ? matches[1] : nil)
102
- expression = expression.sub(/^([<>]?=?)/, '')
100
+ whole, validity, package, expression = expression.match(/^([<>]?=?)?(.+?)\s*(?:\[(.*)\])?$/).to_a
103
101
 
104
- validity = nil if validity == '='
105
- else
106
- validity = nil
107
- end
108
-
109
- package = Packo::Package.parse(expression)
102
+ package = Packo::Package.parse(package || '')
110
103
 
111
104
  conditions = { order: [:name.asc] }
112
105
 
@@ -128,16 +121,26 @@ class Repository
128
121
  }
129
122
  end
130
123
 
131
- if validity
124
+ if validity && !validity.empty?
132
125
  result = result.select {|pkg|
133
126
  case validity
134
- when '>'; pkg.version > package.version
135
- when '>='; pkg.version >= package.version
136
- when '<'; pkg.version < package.version
137
- when '<='; pkg.version <= package.version
127
+ when '~', '~=' then true
128
+ when '>' then pkg.version > package.version
129
+ when '>=' then pkg.version >= package.version
130
+ when '<' then pkg.version < package.version
131
+ when '<=' then pkg.version <= package.version
132
+ else pkg.version == package.version
138
133
  end
139
134
  }
140
135
  end
136
+
137
+ if expression && !expression.empty?
138
+ expression = Packo::Package::Tags::Expression.parse(expression)
139
+
140
+ result = result.select {|pkg|
141
+ expression.evaluate(Packo::Package.wrap(pkg))
142
+ }
143
+ end
141
144
  end
142
145
 
143
146
  return result
@@ -27,6 +27,8 @@ module Packo
27
27
 
28
28
  class Package
29
29
  def self.parse (text, type=:standard)
30
+ return text if text.is_a?(Package)
31
+
30
32
  data = {}
31
33
 
32
34
  case type
@@ -36,7 +38,7 @@ class Package
36
38
  data[:features] = matches[3]
37
39
  data[:flavor] = matches[5]
38
40
 
39
- matches = matches[1].match(/^(.*?)(-(\d.*?))?(%(.*?))?$/)
41
+ matches = matches[1].match(/^(.*?)(?:-(\d.*?))?(?:%(.*?))?(?:@(.*?))?$/)
40
42
 
41
43
  data[:tags] = matches[1].split('/')
42
44
 
@@ -44,8 +46,12 @@ class Package
44
46
  data[:name] = data[:tags].pop
45
47
  end
46
48
 
47
- data[:version] = matches[3]
48
- data[:slot] = matches[5]
49
+ data[:version] = matches[2]
50
+ data[:slot] = matches[3]
51
+
52
+ if matches[4]
53
+ data[:repository] = Repository.parse(matches[4])
54
+ end
49
55
  end
50
56
 
51
57
  Package.new(data)
@@ -47,7 +47,7 @@ class Profile
47
47
  }
48
48
 
49
49
  @paths.dup.each {|name, path|
50
- @paths[name] = Pathname.new(path)
50
+ @paths[name] = Path.new(path)
51
51
  }
52
52
  end
53
53
 
@@ -60,7 +60,7 @@ class Profile
60
60
  if respond_to? "#{id}="
61
61
  send "#{id}=", *args
62
62
  else
63
- @paths[id] = Pathname.new(args.first)
63
+ @paths[id] = Path.new(args.first)
64
64
  end
65
65
  end
66
66
  end
@@ -18,5 +18,3 @@
18
18
  #++
19
19
 
20
20
  require 'packo/rbuild/package'
21
- require 'packo/rbuild/modules'
22
- require 'packo/rbuild/behaviors'
@@ -20,8 +20,9 @@
20
20
  module Packo; module RBuild; module Behaviors
21
21
 
22
22
  Default = [
23
- Modules::Misc::Fetcher, Modules::Misc::Unpacker,
24
- Modules::Building::Patch, Modules::Building::Autotools, Modules::Building::Strip
23
+ Modules::Building::Patch,
24
+ Modules::Building::Autotools,
25
+ Modules::Building::Strip
25
26
  ]
26
27
 
27
28
  end; end; end
@@ -17,6 +17,11 @@
17
17
  # along with packo. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
 
20
- require 'packo/rbuild/modules/misc/fetching/gnu'
21
- require 'packo/rbuild/modules/misc/fetching/sourceforge'
22
- require 'packo/rbuild/modules/misc/fetching/github'
20
+ module Packo; module RBuild; module Behaviors
21
+
22
+ Python = [
23
+ Modules::Building::Patch,
24
+ Modules::Building::PythonSetup
25
+ ]
26
+
27
+ end; end; end
@@ -19,9 +19,8 @@
19
19
 
20
20
  require 'packo/rbuild/module'
21
21
 
22
+ require 'packo/rbuild/modules/fetching'
23
+ require 'packo/rbuild/modules/unpacking'
22
24
  require 'packo/rbuild/modules/building'
23
25
  require 'packo/rbuild/modules/packaging'
24
26
  require 'packo/rbuild/modules/misc'
25
-
26
- require 'packo/rbuild/modules/misc/fetching'
27
- require 'packo/rbuild/modules/misc/unpacking'
@@ -17,8 +17,11 @@
17
17
  # along with packo. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
 
20
- require 'packo/rbuild/modules/building/autotools'
20
+ require 'packo/rbuild/modules/building/patch'
21
21
  require 'packo/rbuild/modules/building/cmake'
22
+
23
+ require 'packo/rbuild/modules/building/autotools'
22
24
  require 'packo/rbuild/modules/building/rake'
23
- require 'packo/rbuild/modules/building/patch'
25
+ require 'packo/rbuild/modules/building/scons'
26
+
24
27
  require 'packo/rbuild/modules/building/strip'
@@ -104,22 +104,22 @@ class Autotools < Module
104
104
 
105
105
  @enable.each {|name, value|
106
106
  case value
107
- when true; result += "--enable-#{name} "
108
- when false; result += "--disable-#{name} "
109
- else; result += "--enable-#{name}='#{value}' "
107
+ when true; result += "--enable-#{name.shellescape} "
108
+ when false; result += "--disable-#{name.shellescape} "
109
+ else; result += "--enable-#{name.shellescape}=#{value.shellescape} "
110
110
  end
111
111
  }
112
112
 
113
113
  @with.each {|name, value|
114
114
  case value
115
- when true; result += "--with-#{name} "
116
- when false; result += "--without-#{name} "
117
- else; result += "--with-#{name}='#{value}' "
115
+ when true; result += "--with-#{name.shellescape} "
116
+ when false; result += "--without-#{name.shellescape} "
117
+ else; result += "--with-#{name.shellescape}=#{value.shellescape} "
118
118
  end
119
119
  }
120
120
 
121
121
  @other.each {|name, value|
122
- result += "--#{name}='#{value}' "
122
+ result += "--#{name.shellescape}=#{value.shellescape} "
123
123
  }
124
124
 
125
125
  return result
@@ -268,10 +268,10 @@ class Autotools < Module
268
268
  def configure
269
269
  @configuration = Configuration.new(self)
270
270
 
271
- @configuration.set 'prefix', (System.env[:INSTALL_PATH] + '/usr').cleanpath
272
- @configuration.set 'sysconfdir', (System.env[:INSTALL_PATH] + '/etc').cleanpath
273
- @configuration.set 'sharedstatedir', (System.env[:INSTALL_PATH] + '/com').cleanpath
274
- @configuration.set 'localstatedir', (System.env[:INSTALL_PATH] + '/var').cleanpath
271
+ @configuration.set 'prefix', Path.clean(System.env[:INSTALL_PATH] + '/usr')
272
+ @configuration.set 'sysconfdir', Path.clean(System.env[:INSTALL_PATH] + '/etc')
273
+ @configuration.set 'sharedstatedir', Path.clean(System.env[:INSTALL_PATH] + '/com')
274
+ @configuration.set 'localstatedir', Path.clean(System.env[:INSTALL_PATH] + '/var')
275
275
 
276
276
  @configuration.set 'host', package.host
277
277
  @configuration.set 'build', package.host
@@ -20,14 +20,71 @@
20
20
  module Packo; module RBuild; module Modules; module Building
21
21
 
22
22
  class Rake < Module
23
+ class Configuration
24
+ attr_reader :module
25
+
26
+ def initialize (mod=nil)
27
+ @module = mod
28
+
29
+ @options = {}
30
+ end
31
+
32
+ def clear
33
+ @options.clear
34
+ end
35
+
36
+ def enable (*names)
37
+ names.flatten.compact.each {|name|
38
+ @options[name] = true
39
+ }
40
+ end
41
+
42
+ def disable (*names)
43
+ names.flatten.compact.each {|name|
44
+ @options[name] = false
45
+ }
46
+ end
47
+
48
+ def set (name, value)
49
+ @options[name.to_s] = value.to_s
50
+ end
51
+
52
+ def get (name)
53
+ @options[name.to_s]
54
+ end
55
+
56
+ def delete (*names)
57
+ names.flatten.each {|name|
58
+ @options.delete(name.to_s)
59
+ }
60
+ end
61
+
62
+ def to_s
63
+ result = ''
64
+
65
+ @options.each {|name, value|
66
+ case value
67
+ when true; result += "#{name.shellescape}=on "
68
+ when false; result += "#{name.shellescape}=off "
69
+ else; result += "#{name.shellescape}=#{value.shellescape} "
70
+ end
71
+ }
72
+
73
+ return result
74
+ end
75
+ end
76
+
23
77
  def initialize (package)
24
78
  super(package)
25
79
 
26
- package.stages.add :compile, self.method(:compile), after: :fetch
27
- package.stages.add :install, self.method(:install), after: :compile
80
+ package.stages.add :configure, self.method(:configure), after: :fetch
81
+ package.stages.add :compile, self.method(:compile), after: :configure
82
+ package.stages.add :install, self.method(:install), after: :compile
28
83
 
29
- package.before :build do
84
+ package.after :initialize do
30
85
  package.environment[:RUBYOPT] = ''
86
+
87
+ package.dependencies << 'interpreter/ruby!'
31
88
  end
32
89
 
33
90
  package.rake = Class.new(Module::Helper) {
@@ -54,19 +111,26 @@ class Rake < Module
54
111
  end
55
112
 
56
113
  def finalize
57
- package.stages.delete :compile, self.method(:compile)
58
- package.stages.delete :install, self.method(:install)
114
+ package.stages.delete :configure, self.method(:configure)
115
+ package.stages.delete :compile, self.method(:compile)
116
+ package.stages.delete :install, self.method(:install)
117
+ end
118
+
119
+ def configure
120
+ @configuration = Configuration.new(self)
121
+
122
+ package.stages.callbacks(:configure).do(@configuration)
59
123
  end
60
124
 
61
125
  def compile
62
126
  package.stages.callbacks(:compile).do(@configuration) {
63
- package.rake.do
127
+ package.rake.do @configuration.to_s.shellsplit
64
128
  }
65
129
  end
66
130
 
67
131
  def install
68
132
  package.stages.callbacks(:install).do(@configuration) {
69
- package.rake.install
133
+ package.rake.install @configuration.to_s.shellsplit
70
134
  }
71
135
  end
72
136
  end
@@ -0,0 +1,128 @@
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 RBuild; module Modules; module Building
21
+
22
+ class Scons < Module
23
+ class Configuration
24
+ attr_reader :module
25
+
26
+ def initialize (mod=nil)
27
+ @module = mod
28
+
29
+ @options = {}
30
+ end
31
+
32
+ def clear
33
+ @options.clear
34
+ end
35
+
36
+ def enable (*names)
37
+ names.flatten.compact.each {|name|
38
+ @options[name] = true
39
+ }
40
+ end
41
+
42
+ def disable (*names)
43
+ names.flatten.compact.each {|name|
44
+ @options[name] = false
45
+ }
46
+ end
47
+
48
+ def set (name, value)
49
+ @options[name.to_s] = value.to_s
50
+ end
51
+
52
+ def get (name)
53
+ @options[name.to_s]
54
+ end
55
+
56
+ def delete (*names)
57
+ names.flatten.each {|name|
58
+ @options.delete(name.to_s)
59
+ }
60
+ end
61
+
62
+ def to_s
63
+ result = ''
64
+
65
+ @options.each {|name, value|
66
+ case value
67
+ when true; result += "#{name.shellescape}=on "
68
+ when false; result += "#{name.shellescape}=off "
69
+ else; result += "#{name.shellescape}=#{value.shellescape} "
70
+ end
71
+ }
72
+
73
+ return result
74
+ end
75
+ end
76
+
77
+ def initialize (package)
78
+ super(package)
79
+
80
+ package.stages.add :configure, self.method(:configure), after: :fetch
81
+ package.stages.add :compile, self.method(:compile), after: :configure
82
+ package.stages.add :install, self.method(:install), after: :compile
83
+
84
+ package.before :initialize do
85
+ package.dependencies << 'development/utility/scons!'
86
+ end
87
+
88
+ package.scons = Class.new(Module::Helper) {
89
+ def initialize (package)
90
+ super(package)
91
+ end
92
+
93
+ def do (*args)
94
+ package.environment.sandbox {
95
+ Packo.sh 'scons', *args
96
+ }
97
+ end
98
+
99
+ def version (name, slot=nil)
100
+ slot ? @versions[name.to_sym] = slot : @versions[name.to_sym]
101
+ end
102
+ }.new(package)
103
+ end
104
+
105
+ def finalize
106
+ package.stages.delete :configure, self.method(:configure)
107
+ package.stages.delete :compile, self.method(:compile)
108
+ package.stages.delete :install, self.method(:install)
109
+ end
110
+
111
+ def configure
112
+ @configuration = Configuration.new(self)
113
+
114
+ package.stages.callbacks(:configure).do(@configuration)
115
+ end
116
+
117
+ def compile
118
+ package.stages.callbacks(:compile).do(@configuration) {
119
+ package.scons.do @configuration.to_s.shellsplit
120
+ }
121
+ end
122
+
123
+ def install
124
+ package.stages.callbacks(:install).do(@configuration)
125
+ end
126
+ end
127
+
128
+ end; end; end; end