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
@@ -17,7 +17,7 @@
17
17
  # along with packo. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
 
20
- module Packo; module RBuild; module Modules; module Misc
20
+ module Packo; module RBuild; module Modules; module Unpacking
21
21
 
22
22
  Unpacker.register /\.lzma$/ do |path, to|
23
23
  Packo.sh 'lzma', '-dfk', path
@@ -17,7 +17,7 @@
17
17
  # along with packo. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
 
20
- module Packo; module RBuild; module Modules; module Misc
20
+ module Packo; module RBuild; module Modules; module Unpacking
21
21
 
22
22
  Unpacker.register /\.((tar\.(bz2|gz|xz|lzma))|tgz)$/ do |path, to|
23
23
  options = [case File.extname(path)
@@ -17,7 +17,7 @@
17
17
  # along with packo. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
 
20
- module Packo; module RBuild; module Modules; module Misc
20
+ module Packo; module RBuild; module Modules; module Unpacking
21
21
 
22
22
  Unpacker.register /\.xz$/ do |path, to|
23
23
  Packo.sh 'xz', '-dfk', path
@@ -17,7 +17,7 @@
17
17
  # along with packo. If not, see <http://www.gnu.org/licenses/>.
18
18
  #++
19
19
 
20
- module Packo; module RBuild; module Modules; module Misc
20
+ module Packo; module RBuild; module Modules; module Unpacking
21
21
 
22
22
  Unpacker.register /\.zip$/ do |path, to|
23
23
  Packo.sh 'unzip', '-qq', *(to ? ['-d', to] : []), path
@@ -29,6 +29,9 @@ require 'packo/rbuild/features'
29
29
  require 'packo/rbuild/flavor'
30
30
  require 'packo/rbuild/package/manifest'
31
31
 
32
+ require 'packo/rbuild/modules'
33
+ require 'packo/rbuild/behaviors'
34
+
32
35
  module Packo; module RBuild
33
36
 
34
37
  class Package < Packo::Package
@@ -75,8 +78,8 @@ class Package < Packo::Package
75
78
  @stages.add :dependencies, self.method(:dependencies_check), at: :beginning
76
79
  @stages.add :blockers, self.method(:blockers_check), at: :beginning
77
80
 
81
+ use Modules::Fetcher, Modules::Unpacker, Modules::Packager
78
82
  behavior Behaviors::Default
79
- use Modules::Packaging::PKO
80
83
 
81
84
  if (@parent = Package.last)
82
85
  self.instance_exec(self, &@parent.instance_eval('@block'))
@@ -126,7 +129,7 @@ class Package < Packo::Package
126
129
  }
127
130
  }
128
131
 
129
- self.directory = Pathname.new("#{package.env[:TMP]}/#{tags.to_s(true)}/#{name}/#{slot}/#{version}").cleanpath.to_s
132
+ self.directory = Path.clean("#{package.env[:TMP]}/#{tags.to_s(true)}/#{name}/#{slot}/#{version}")
130
133
  self.workdir = "#{package.directory}/work"
131
134
  self.distdir = "#{package.directory}/dist"
132
135
  self.tempdir = "#{package.directory}/temp"
@@ -235,20 +238,26 @@ class Package < Packo::Package
235
238
  ] if @build_start_at
236
239
  end
237
240
 
238
- def use (klass)
239
- @modules << klass.new(self)
241
+ def use (*modules)
242
+ modules.flatten.compact.each {|klass|
243
+ @modules << klass.new(self)
244
+ }
240
245
  end
241
246
 
242
- def avoid (klass)
243
- [klass].flatten.compact.each {|klass|
247
+ def avoid (*modules)
248
+ modules.flatten.compact.each {|klass|
244
249
  @modules.delete(@modules.find {|mod|
245
250
  mod.class == klass
246
251
  }).finalize rescue nil
247
252
  }
248
253
  end
249
254
 
250
- def behavior (uses)
251
- uses.each {|use|
255
+ def behavior (behavior)
256
+ if @behavior
257
+ avoid @behavior
258
+ end
259
+
260
+ (@behavior = behavior).each {|use|
252
261
  self.use(use)
253
262
  }
254
263
  end
@@ -40,7 +40,7 @@ class Repository
40
40
  end
41
41
 
42
42
  def self.wrap (model)
43
- Repository.new(
43
+ Repository.const_get(model.type.capitalize).new(
44
44
  type: model.type,
45
45
  name: model.name,
46
46
 
@@ -61,6 +61,22 @@ class Virtual < Repository
61
61
  def packages (*args)
62
62
  Enumerator.new(self, :each_package, *args)
63
63
  end
64
+
65
+ def dependencies (*args)
66
+ Enumerator.new(self, :each_dependency, *args)
67
+ end
68
+
69
+ def has? (package)
70
+ false
71
+ end
72
+
73
+ def install (package)
74
+ false
75
+ end
76
+
77
+ def uninstall (package)
78
+ true
79
+ end
64
80
  end
65
81
 
66
82
  end; end
@@ -0,0 +1,106 @@
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/extensions'
21
+ require 'digest/sha1'
22
+ require 'fileutils'
23
+ require 'shellwords'
24
+ require 'memoized'
25
+
26
+ module Packo
27
+ def self.protected?
28
+ !!(ENV['SANDBOX_ACTIVE'] || ENV['FAKED_MODE'])
29
+ end
30
+
31
+ def self.sh (*cmd, &block)
32
+ options = (Hash === cmd.last) ? cmd.pop : {}
33
+ cmd = cmd.flatten.compact.map {|c| c.to_s}
34
+
35
+ if !block_given?
36
+ show_command = cmd.join(' ')
37
+ show_command = show_command[0, 42] + '...' unless $trace
38
+
39
+ block = lambda {|ok, status|
40
+ ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}] in {#{Dir.pwd}}"
41
+ }
42
+ end
43
+
44
+ if options[:silent]
45
+ options[:out] = '/dev/null'
46
+ options[:err] = '/dev/null'
47
+ else
48
+ print "#{cmd.first} "
49
+ cmd[1 .. cmd.length].each {|cmd|
50
+ if cmd.match(/[ \$'`]/)
51
+ print %Q{"#{cmd}" }
52
+ else
53
+ print "#{cmd} "
54
+ end
55
+ }
56
+ print "\n"
57
+ end
58
+
59
+ options.delete :silent
60
+
61
+ result = Kernel.system(options[:env] || {}, *cmd, options)
62
+ status = $?
63
+
64
+ block.call(result, status)
65
+ end
66
+
67
+ def self.load (path, options={})
68
+ if !File.readable? path
69
+ raise LoadError.new("no such file to load -- #{path}")
70
+ end
71
+
72
+ eval("#{options[:before]}#{File.read(path, encoding: 'utf-8').split(/^__END__$/).first}#{options[:after]}", options[:binding] || binding, path, 1)
73
+ end
74
+
75
+ def self.digest (path)
76
+ Digest::SHA1.hexdigest(File.read(path))
77
+ end
78
+
79
+ def self.contents (obj, &block)
80
+ Enumerator.new do |e|
81
+ obj.each {|file|
82
+ next unless File.directory?(file) || File.symlink?(file) || File.file?(file)
83
+
84
+ data = {}
85
+ data.merge!(block.call(file) || {}) if block
86
+
87
+ next if data[:next]
88
+
89
+ data[:source] ||= file
90
+ data[:path] ||= file
91
+
92
+ if File.directory?(file)
93
+ data[:type] ||= :dir
94
+ elsif File.symlink?(file)
95
+ data[:type] ||= :sym
96
+ data[:meta] ||= File.readlink(file)
97
+ elsif File.file?(file)
98
+ data[:type] ||= :obj
99
+ data[:meta] ||= Packo.digest(file)
100
+ end
101
+
102
+ e << OpenStruct.new(data)
103
+ }
104
+ end
105
+ end
106
+ end
@@ -20,7 +20,7 @@
20
20
  module Packo
21
21
 
22
22
  def self.version
23
- '0.0.1.alpha.1'
23
+ '0.0.1.alpha.2'
24
24
  end
25
25
 
26
26
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: packo
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 0.0.1.alpha.1
5
+ version: 0.0.1.alpha.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - meh.
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-25 00:00:00 Z
13
+ date: 2011-05-03 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -46,7 +46,7 @@ dependencies:
46
46
  type: :runtime
47
47
  version_requirements: *id003
48
48
  - !ruby/object:Gem::Dependency
49
- name: datamapper
49
+ name: memoized
50
50
  prerelease: false
51
51
  requirement: &id004 !ruby/object:Gem::Requirement
52
52
  none: false
@@ -57,7 +57,7 @@ dependencies:
57
57
  type: :runtime
58
58
  version_requirements: *id004
59
59
  - !ruby/object:Gem::Dependency
60
- name: dm-transactions
60
+ name: datamapper
61
61
  prerelease: false
62
62
  requirement: &id005 !ruby/object:Gem::Requirement
63
63
  none: false
@@ -68,7 +68,7 @@ dependencies:
68
68
  type: :runtime
69
69
  version_requirements: *id005
70
70
  - !ruby/object:Gem::Dependency
71
- name: dm-timestamps
71
+ name: dm-transactions
72
72
  prerelease: false
73
73
  requirement: &id006 !ruby/object:Gem::Requirement
74
74
  none: false
@@ -79,7 +79,7 @@ dependencies:
79
79
  type: :runtime
80
80
  version_requirements: *id006
81
81
  - !ruby/object:Gem::Dependency
82
- name: dm-types
82
+ name: dm-timestamps
83
83
  prerelease: false
84
84
  requirement: &id007 !ruby/object:Gem::Requirement
85
85
  none: false
@@ -90,7 +90,7 @@ dependencies:
90
90
  type: :runtime
91
91
  version_requirements: *id007
92
92
  - !ruby/object:Gem::Dependency
93
- name: dm-constraints
93
+ name: dm-types
94
94
  prerelease: false
95
95
  requirement: &id008 !ruby/object:Gem::Requirement
96
96
  none: false
@@ -101,7 +101,7 @@ dependencies:
101
101
  type: :runtime
102
102
  version_requirements: *id008
103
103
  - !ruby/object:Gem::Dependency
104
- name: versionomy
104
+ name: dm-constraints
105
105
  prerelease: false
106
106
  requirement: &id009 !ruby/object:Gem::Requirement
107
107
  none: false
@@ -112,16 +112,27 @@ dependencies:
112
112
  type: :runtime
113
113
  version_requirements: *id009
114
114
  - !ruby/object:Gem::Dependency
115
- name: fffs
115
+ name: versionomy
116
116
  prerelease: false
117
117
  requirement: &id010 !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements:
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
- version: "0"
122
+ version: 0.4.1
123
123
  type: :runtime
124
124
  version_requirements: *id010
125
+ - !ruby/object:Gem::Dependency
126
+ name: fffs
127
+ prerelease: false
128
+ requirement: &id011 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: 0.0.7
134
+ type: :runtime
135
+ version_requirements: *id011
125
136
  description: A really flexible package manager, inspired by portage and pacman.
126
137
  email: meh@paranoici.org
127
138
  executables:
@@ -141,22 +152,21 @@ extra_rdoc_files: []
141
152
  files:
142
153
  - lib/packo.rb
143
154
  - lib/packo/rbuild/stages.rb
155
+ - lib/packo/rbuild/modules/unpacking/lzma.rb
156
+ - lib/packo/rbuild/modules/unpacking/zip.rb
157
+ - lib/packo/rbuild/modules/unpacking/xz.rb
158
+ - lib/packo/rbuild/modules/unpacking/tar.rb
159
+ - lib/packo/rbuild/modules/packager.rb
144
160
  - lib/packo/rbuild/modules/packaging.rb
145
- - lib/packo/rbuild/modules/misc/unpacking/lzma.rb
146
- - lib/packo/rbuild/modules/misc/unpacking/zip.rb
147
- - lib/packo/rbuild/modules/misc/unpacking/xz.rb
148
- - lib/packo/rbuild/modules/misc/unpacking/tar.rb
149
- - lib/packo/rbuild/modules/misc/fetcher.rb
150
- - lib/packo/rbuild/modules/misc/fetching/gnu.rb
151
- - lib/packo/rbuild/modules/misc/fetching/sourceforge.rb
152
- - lib/packo/rbuild/modules/misc/fetching/subversion.rb
153
- - lib/packo/rbuild/modules/misc/fetching/git.rb
154
- - lib/packo/rbuild/modules/misc/fetching/github.rb
155
- - lib/packo/rbuild/modules/misc/fetching/mercurial.rb
156
- - lib/packo/rbuild/modules/misc/fetching/wget.rb
157
- - lib/packo/rbuild/modules/misc/unpacker.rb
158
- - lib/packo/rbuild/modules/misc/fetching.rb
159
- - lib/packo/rbuild/modules/misc/unpacking.rb
161
+ - lib/packo/rbuild/modules/fetcher.rb
162
+ - lib/packo/rbuild/modules/fetching/gnu.rb
163
+ - lib/packo/rbuild/modules/fetching/sourceforge.rb
164
+ - lib/packo/rbuild/modules/fetching/subversion.rb
165
+ - lib/packo/rbuild/modules/fetching/git.rb
166
+ - lib/packo/rbuild/modules/fetching/github.rb
167
+ - lib/packo/rbuild/modules/fetching/mercurial.rb
168
+ - lib/packo/rbuild/modules/unpacker.rb
169
+ - lib/packo/rbuild/modules/fetching.rb
160
170
  - lib/packo/rbuild/modules/misc.rb
161
171
  - lib/packo/rbuild/modules/packaging/pko.rb
162
172
  - lib/packo/rbuild/modules/building.rb
@@ -165,11 +175,14 @@ files:
165
175
  - lib/packo/rbuild/modules/building/strip.rb
166
176
  - lib/packo/rbuild/modules/building/cmake.rb
167
177
  - lib/packo/rbuild/modules/building/autotools.rb
178
+ - lib/packo/rbuild/modules/building/scons.rb
179
+ - lib/packo/rbuild/modules/unpacking.rb
168
180
  - lib/packo/rbuild/package.rb
169
181
  - lib/packo/rbuild/package/manifest.rb
170
182
  - lib/packo/rbuild/feature.rb
171
183
  - lib/packo/rbuild/behaviors.rb
172
184
  - lib/packo/rbuild/flavor.rb
185
+ - lib/packo/rbuild/behaviors/python.rb
173
186
  - lib/packo/rbuild/behaviors/default.rb
174
187
  - lib/packo/rbuild/features.rb
175
188
  - lib/packo/rbuild/modules.rb
@@ -215,6 +228,7 @@ files:
215
228
  - lib/packo/package/features.rb
216
229
  - lib/packo/package/blocker.rb
217
230
  - lib/packo/package/blockers.rb
231
+ - lib/packo/utils.rb
218
232
  - lib/packo/repository.rb
219
233
  - lib/packo/cli/base.rb
220
234
  - lib/packo/cli/environment.rb
@@ -1,57 +0,0 @@
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 Fetching
21
-
22
- class Wget < Module
23
- def self.fetch (path, to, package={})
24
- Packo.sh 'wget', '-c', '-O', to, path
25
- end
26
-
27
- def self.url (url, package={})
28
- Packo.interpolate(url, package)
29
- end
30
-
31
- def initialize (package)
32
- super(package)
33
-
34
- package.stages.add :fetch, self.method(:fetch), after: :beginning
35
- end
36
-
37
- def fetch
38
- version = package.version
39
-
40
- distfiles = []
41
- sources = [package.source].flatten.compact.map {|s|
42
- Wget.url(s, package)
43
- }
44
-
45
- package.stages.callbacks(:fetch).do(sources) {
46
- sources.each {|source|
47
- distfiles << "#{package.fetchdir || '/tmp'}/#{File.basename(source)}"
48
-
49
- Wget.fetch source, distfiles.last, package
50
- }
51
- }
52
-
53
- package.distfiles distfiles
54
- end
55
- end
56
-
57
- end; end; end; end