pkgr 1.1.3 → 1.1.4pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -19,11 +19,11 @@ Install `pkgr` on a Debian/Ubuntu machine (only `wheezy` flavour for now):
19
19
 
20
20
  To package your app, you can either execute `pkgr` locally if your app repository is on the same machine:
21
21
 
22
- pkgr path/to/app/repo
22
+ pkgr package path/to/app/repo
23
23
 
24
24
  Or, assuming your build machine is accessible via SSH by doing `ssh pkgr-build-machine` (set this in your `~/.ssh/config` file), you can do as follows:
25
25
 
26
- pkgr path/to/app/repo --host pkgr-build-machine
26
+ pkgr package path/to/app/repo --host pkgr-build-machine
27
27
 
28
28
  The resulting .deb package will be in your current working directory.
29
29
 
@@ -60,6 +60,7 @@ Full command line options are given below:
60
60
  [--verbose] # Run verbosely
61
61
  [--debug] # Run very verbosely
62
62
  [--name=NAME] # Application name (if directory given, it will default to the directory name)
63
+ [--env="RACK_ENV=staging" ] # Specify environment variables for buildpack
63
64
 
64
65
  ## Why?
65
66
 
@@ -195,7 +195,7 @@ module Pkgr
195
195
 
196
196
  # List of available buildpacks for the current distribution.
197
197
  def buildpacks
198
- distribution.buildpacks(config.buildpack)
198
+ distribution.buildpacks(config)
199
199
  end
200
200
 
201
201
  # Buildpack detected for the app, if any.
@@ -13,13 +13,14 @@ module Pkgr
13
13
  end
14
14
  end
15
15
 
16
- attr_reader :url, :banner, :type, :uuid, :branch
16
+ attr_reader :url, :banner, :type, :uuid, :branch, :env
17
17
 
18
- def initialize(url, type = :builtin)
18
+ def initialize(url, type = :builtin, env = nil)
19
19
  @uuid = Digest::SHA1.hexdigest(url)
20
20
  @url, @branch = url.split("#")
21
21
  @branch ||= "master"
22
22
  @type = type
23
+ @env = env
23
24
  end
24
25
 
25
26
  def buildpack_cache_dir
@@ -34,8 +35,10 @@ module Pkgr
34
35
  end
35
36
 
36
37
  def compile(path, compile_cache_dir)
38
+ cmd = %{env -i PATH="$PATH"#{env} #{dir}/bin/compile "#{path}" "#{compile_cache_dir}" }
39
+
37
40
  Dir.chdir(path) do
38
- IO.popen(%{ env -i PATH="$PATH" #{dir}/bin/compile "#{path}" "#{compile_cache_dir}" }) do |io|
41
+ IO.popen(cmd) do |io|
39
42
  until io.eof?
40
43
  data = io.gets
41
44
  print data
@@ -86,10 +89,10 @@ module Pkgr
86
89
 
87
90
  def replace_app_with_app_home(app_home)
88
91
  Dir.chdir(dir) do
89
- buildpack_replace = Mixlib::ShellOut.new("find . -type f -print0 | xargs -0 sed -i 's/\\/app/#{app_home.gsub("/", "\\/")}/g'")
92
+ buildpack_replace = Mixlib::ShellOut.new("find . -type f -print0 | xargs -0 perl -pi -e s,/app,#{app_home},g")
90
93
  buildpack_replace.run_command
91
94
  buildpack_replace.error!
92
95
  end
93
96
  end
94
97
  end
95
- end
98
+ end
@@ -1,6 +1,7 @@
1
1
  require "thor"
2
2
  require 'pkgr'
3
3
  require 'pkgr/buildpack'
4
+ require 'pkgr/env'
4
5
 
5
6
  module Pkgr
6
7
  class CLI < Thor
@@ -40,6 +41,7 @@ module Pkgr
40
41
  method_option :clean, :type => :boolean, :default => true, :desc => "Automatically clean up temporary dirs"
41
42
  method_option :buildpack, :type => :string, :desc => "Custom buildpack to use"
42
43
  method_option :edge, :type => :boolean, :default => true, :desc => "Always use the latest version of the buildpack if already installed"
44
+ method_option :env, :type => :array, default: [], :description => 'Specify environment variables for buildpack (--env "CURL_TIMEOUT=2" "BUNDLE_WITHOUT=development test")'
43
45
 
44
46
  def package(tarball)
45
47
  Pkgr.level = Logger::INFO if options[:verbose]
@@ -55,4 +57,4 @@ module Pkgr
55
57
  exit 1
56
58
  end
57
59
  end
58
- end
60
+ end
@@ -58,6 +58,10 @@ module Pkgr
58
58
  @table[:description] || "No description given"
59
59
  end
60
60
 
61
+ def env
62
+ Pkgr::Env.new(@table[:env])
63
+ end
64
+
61
65
  def valid?
62
66
  @errors = []
63
67
  @errors.push("name can't be blank") if name.nil? || name.empty?
@@ -84,11 +88,12 @@ module Pkgr
84
88
  "--target \"#{target}\"",
85
89
  "--description \"#{description}\"",
86
90
  ]
87
- args.push "--dependencies #{dependencies.map{|d| "\"#{d}\""}.join("")}" unless dependencies.nil? || dependencies.empty?
88
- args.push "--build-dependencies #{build_dependencies.map{|d| "\"#{d}\""}.join("")}" unless build_dependencies.nil? || build_dependencies.empty?
91
+ args.push "--dependencies #{dependencies.map{|d| "\"#{d}\""}.join}" unless dependencies.nil? || dependencies.empty?
92
+ args.push "--build-dependencies #{build_dependencies.map{|d| "\"#{d}\""}.join}" unless build_dependencies.nil? || build_dependencies.empty?
89
93
  args.push "--compile-cache-dir \"#{compile_cache_dir}\"" unless compile_cache_dir.nil? || compile_cache_dir.empty?
90
- args.push "--before-precompile \"#{before_precompile}\"" unless compile_cache_dir.nil? || compile_cache_dir.empty?
94
+ args.push "--before-precompile \"#{before_precompile}\"" unless before_precompile.nil? || before_precompile.empty?
91
95
  args.push "--buildpack \"#{buildpack}\"" unless buildpack.nil? || buildpack.empty?
96
+ args.push "--env #{env.variables.map{|v| "\"#{v}\""}.join(" ")}" if env.present?
92
97
  args.push "--auto" if auto
93
98
  args.push "--verbose" if verbose
94
99
  args.push "--debug" if debug
@@ -3,28 +3,31 @@ default:
3
3
  - mysql-common
4
4
  - libpq5
5
5
  - libsqlite3-0
6
- - libssl0.9.8
7
6
  - openssl
8
7
  - libxml2
9
8
  - libxslt1.1
10
9
  - libreadline5
11
10
  - libreadline6
12
11
  debian-squeeze:
12
+ - libssl0.9.8
13
13
  - libmysqlclient16
14
14
  - libevent-1.4-2
15
15
  - libevent-core-1.4-2
16
16
  - libevent-extra-1.4-2
17
17
  ubuntu-lucid:
18
+ - libssl0.9.8
18
19
  - libmysqlclient16
19
20
  - libevent-1.4-2
20
21
  - libevent-core-1.4-2
21
22
  - libevent-extra-1.4-2
22
23
  debian-wheezy:
24
+ - libssl1.0.0
23
25
  - libmysqlclient18
24
26
  - libevent-2.0-5
25
27
  - libevent-core-2.0-5
26
28
  - libevent-extra-2.0-5
27
29
  ubuntu-precise:
30
+ - libssl1.0.0
28
31
  - libmysqlclient18
29
32
  - libevent-2.0-5
30
33
  - libevent-core-2.0-5
@@ -91,10 +91,11 @@ module Pkgr
91
91
  }
92
92
  end
93
93
 
94
- def buildpacks(custom_buildpack_uri = nil)
94
+ def buildpacks(config)
95
+ custom_buildpack_uri = config.buildpack
95
96
  if custom_buildpack_uri
96
97
  uuid = Digest::SHA1.hexdigest(custom_buildpack_uri)
97
- [Buildpack.new(custom_buildpack_uri, :custom)]
98
+ [Buildpack.new(custom_buildpack_uri, :custom, config.env)]
98
99
  else
99
100
  case version
100
101
  when "ubuntu-precise", "debian-wheezy", "ubuntu-lucid", "debian-squeeze"
@@ -112,7 +113,7 @@ module Pkgr
112
113
  https://github.com/igrigorik/heroku-buildpack-dart.git
113
114
  https://github.com/rhy-jot/buildpack-nginx.git
114
115
  https://github.com/Kloadut/heroku-buildpack-static-apache.git
115
- }.map{|url| Buildpack.new(url)}
116
+ }.map{|url| Buildpack.new(url, :builtin, config.env)}
116
117
  else
117
118
  []
118
119
  end
@@ -162,4 +163,4 @@ module Pkgr
162
163
  end
163
164
  end
164
165
  end
165
- end
166
+ end
@@ -0,0 +1,33 @@
1
+ module Pkgr
2
+ class Env
3
+ attr_reader :variables
4
+
5
+ def initialize(variables)
6
+ @variables = variables || []
7
+ end
8
+
9
+ def to_s
10
+ to_hash.map {|k, v| " #{k}=#{v}" }.join
11
+ end
12
+
13
+ def present?
14
+ create_env_hash_from_string.length > 0
15
+ end
16
+
17
+ def to_hash
18
+ create_env_hash_from_string
19
+ end
20
+
21
+ private
22
+
23
+ def create_env_hash_from_string
24
+ return {} if variables == []
25
+
26
+ variables.inject({}) do |h, var|
27
+ name, value = var.split('=')
28
+ h[name.strip] = value.strip
29
+ h
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module Pkgr
2
- VERSION = "1.1.3"
2
+ VERSION = "1.1.4pre1"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pkgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
5
- prerelease:
4
+ version: 1.1.4pre1
5
+ prerelease: 5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Cyril Rohr
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-13 00:00:00.000000000 Z
12
+ date: 2014-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -155,6 +155,7 @@ files:
155
155
  - lib/pkgr/dispatcher.rb
156
156
  - lib/pkgr/distributions/debian.rb
157
157
  - lib/pkgr/distributions.rb
158
+ - lib/pkgr/env.rb
158
159
  - lib/pkgr/git.rb
159
160
  - lib/pkgr/process.rb
160
161
  - lib/pkgr/templates/dir_template.rb