metarake 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,21 @@
1
+ # -*- ruby -*-
2
+
3
+ # Use Rake inside subproject directories to build .deb packages, and
4
+ # freight (https://github.com/rcrowley/freight/) to publish them as an
5
+ # apt repository.
6
+
7
+ require 'metarake'
8
+ require 'metarake/publisher/freight'
9
+
10
+ class PackagesMetaTask < MetaRake::Task
11
+ include MetaRake::Builder::Rake
12
+ include MetaRake::Publisher::Freight
13
+
14
+ self.target_filter = /\.deb$/
15
+ self.rake_command = 'fakeroot bundle exec rake'
16
+ self.freight_distro = ENV['FREIGHT_DISTRO'] || 'squeeze'
17
+ self.freight_conf_path = ENV['FREIGHT_CONF'] || 'freight.conf'
18
+ self.freight_command = ENV['FREIGHT_COMMAND'] || 'freight'
19
+ end
20
+
21
+ task :default => PackagesMetaTask.discover!
@@ -11,9 +11,13 @@ module MetaRake::Builder::Rake
11
11
  # @see Metarake::Builder::Rake#project_target?
12
12
  attr_accessor :target_filter
13
13
 
14
+ # Glob to find projects' Rakefiles (default: `['*/Rakefile']`)
15
+ attr_accessor :rakefile_glob
16
+
14
17
  # Projects are subdirectories that have a Rakefile.
15
18
  def projects
16
- Dir['*/Rakefile'].map { |rakefile| File.dirname(rakefile) }
19
+ glob = rakefile_glob || ['*/Rakefile']
20
+ Dir[*glob].map { |rakefile| File.dirname(rakefile) }
17
21
  end
18
22
  end
19
23
 
@@ -43,9 +47,9 @@ module MetaRake::Builder::Rake
43
47
  def project_target?(target_name)
44
48
  case self.class.target_filter
45
49
  when nil ; true
46
- when Regexp ; dir_targets_filter =~ target
47
- when Proc ; dir_targets_filter.call(target)
48
- when String ; target.include?(dir_targets_filter)
50
+ when Regexp ; self.class.target_filter =~ target_name
51
+ when Proc ; self.class.target_filter.call(target_name)
52
+ when String ; target_name.include?(self.class.target_filter)
49
53
  end
50
54
  end
51
55
 
@@ -2,7 +2,7 @@ require 'mixlib/shellout'
2
2
 
3
3
  # Metarake publisher that pushes `.deb` Debian packages to a Freight
4
4
  # apt repository (https://github.com/rcrowley/freight).
5
- module MetaRake::Publisher::Directory
5
+ module MetaRake::Publisher::Freight
6
6
  extend MetaRake::Magic
7
7
 
8
8
  module ClassMethods
@@ -16,38 +16,39 @@ module MetaRake::Publisher::Directory
16
16
  attr_accessor :freight_command
17
17
 
18
18
  # @return [Hash] freight config, plus some random shell environment.
19
- def freight_conf
20
- @freight_conf ||=
19
+ def freight_varlib
20
+ @freight_varlib ||=
21
21
  begin
22
- raise ValueError, "#{self}.freight_conf_path is not set" unless freight_conf_path
23
- conf = Mixlib::ShellOut.new('env', '-i', '/bin/sh', '-c', ". #{freight_conf_path} ; set")
22
+ raise "#{self}.freight_conf_path is not set" unless freight_conf_path
23
+ conf = Mixlib::ShellOut.new('env', '-i', '/bin/sh', '-c', ". #{freight_conf_path} ; echo $VARLIB")
24
24
  conf.run_command.error!
25
- Hash[ conf.stdout.lines.map { |ln| ln.strip.split('=', 2) } ]
25
+ conf.stdout.strip
26
26
  end
27
27
  end
28
28
  end
29
29
 
30
30
  # True if all project targets are added to the repository
31
31
  def published?
32
- raise ValueError, "#{self.class}.freight_distro is not set" unless self.class.freight_distro
32
+ raise "#{self.class}.freight_distro is not set" unless self.class.freight_distro
33
33
  self.targets.map { |tgt| File.exist?(File.join(
34
- self.class.freight_conf['VARLIB'], self.class.freight_distro, tgt)) }.all?
34
+ self.class.freight_varlib, 'apt', self.class.freight_distro,
35
+ tgt)) }.all?
35
36
  end
36
37
 
37
38
  # Add files to the freight repo and publish them
38
39
  def publish!
39
40
  self.targets.each do |tgt|
40
- sh *(self.freight_command('add') + [
41
+ sh *(freight_command('add') + [
41
42
  File.join(self.to_s, tgt),
42
43
  "apt/#{self.class.freight_distro}" ])
43
44
  end
44
- sh *(self.freight_command('cache'))
45
+ sh *(freight_command('cache'))
45
46
  end
46
47
 
47
48
  private
48
- def freight_command(cmd)
49
+ def freight_command(subcmd)
49
50
  cmd = self.class.freight_command || 'freight'
50
51
  cmd = cmd.split if cmd.respond_to?(:split)
51
- cmd + [ cmd, '-c' self.class.freight_conf_path ]
52
+ cmd + [ subcmd, '-c', self.class.freight_conf_path ]
52
53
  end
53
54
  end
@@ -1,3 +1,3 @@
1
1
  module MetaRake
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metarake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-23 00:00:00.000000000 Z
12
+ date: 2013-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -90,6 +90,7 @@ files:
90
90
  - README.md
91
91
  - Rakefile
92
92
  - examples/Rakefile.basic
93
+ - examples/Rakefile.fpm_and_freight
93
94
  - features/basic.feature
94
95
  - features/files/Rakefile.one_two_three
95
96
  - features/step_definitions/basic.rb
@@ -113,21 +114,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
114
  - - ! '>='
114
115
  - !ruby/object:Gem::Version
115
116
  version: '0'
116
- segments:
117
- - 0
118
- hash: 2320268432724083561
119
117
  required_rubygems_version: !ruby/object:Gem::Requirement
120
118
  none: false
121
119
  requirements:
122
120
  - - ! '>='
123
121
  - !ruby/object:Gem::Version
124
122
  version: '0'
125
- segments:
126
- - 0
127
- hash: 2320268432724083561
128
123
  requirements: []
129
124
  rubyforge_project:
130
- rubygems_version: 1.8.24
125
+ rubygems_version: 1.8.25
131
126
  signing_key:
132
127
  specification_version: 3
133
128
  summary: Rake extension to manage multiple builds
@@ -136,4 +131,3 @@ test_files:
136
131
  - features/files/Rakefile.one_two_three
137
132
  - features/step_definitions/basic.rb
138
133
  - features/support/env.rb
139
- has_rdoc: