pkgr 1.0.5 → 1.1.0

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.
@@ -121,6 +121,8 @@ module Pkgr
121
121
  @procfile_entries ||= begin
122
122
  default_process_types = YAML.load_file(release_file)["default_process_types"]
123
123
 
124
+ default_process_types = {} unless default_process_types
125
+
124
126
  entries = if File.exist?(procfile)
125
127
  File.read(procfile).gsub("\r\n","\n").split("\n").map do |line|
126
128
  if line =~ /^([A-Za-z0-9_]+):\s*(.+)$/
@@ -180,14 +182,14 @@ module Pkgr
180
182
 
181
183
  # List of available buildpacks for the current distribution.
182
184
  def buildpacks
183
- distribution.buildpacks
185
+ distribution.buildpacks(config.buildpack)
184
186
  end
185
187
 
186
188
  # Buildpack detected for the app, if any.
187
189
  def buildpack_for_app
188
190
  raise "#{source_dir} does not exist" unless File.directory?(source_dir)
189
191
  @buildpack_for_app ||= buildpacks.find do |buildpack|
190
- buildpack.setup
192
+ buildpack.setup(config.edge, config.home)
191
193
  buildpack.detect(source_dir)
192
194
  end
193
195
  end
@@ -1,4 +1,5 @@
1
1
  require 'fileutils'
2
+ require 'digest/sha1'
2
3
 
3
4
  module Pkgr
4
5
  class Buildpack
@@ -12,14 +13,17 @@ module Pkgr
12
13
  end
13
14
  end
14
15
 
15
- attr_reader :url, :banner
16
+ attr_reader :url, :banner, :type, :uuid, :branch
16
17
 
17
- def initialize(url)
18
- @url = url
18
+ def initialize(url, type = :builtin)
19
+ @uuid = Digest::SHA1.hexdigest(url)
20
+ @url, @branch = url.split("#")
21
+ @branch ||= "master"
22
+ @type = type
19
23
  end
20
24
 
21
25
  def buildpack_cache_dir
22
- self.class.buildpack_cache_dir
26
+ File.join(self.class.buildpack_cache_dir, type.to_s, uuid)
23
27
  end
24
28
 
25
29
  def detect(path)
@@ -57,24 +61,35 @@ module Pkgr
57
61
  File.directory?(dir)
58
62
  end
59
63
 
60
- def setup
61
- exists? ? refresh : install
64
+ def setup(edge, app_home)
65
+ exists? ? refresh(edge) : install
66
+ replace_app_with_app_home(app_home)
62
67
  end
63
68
 
64
- def refresh
69
+ def refresh(edge = true)
70
+ return if !edge
65
71
  Dir.chdir(dir) do
66
- buildpack_refresh = Mixlib::ShellOut.new("git fetch origin && git reset --hard origin/master")
72
+ buildpack_refresh = Mixlib::ShellOut.new("git fetch origin && git reset --hard origin/#{branch}")
67
73
  buildpack_refresh.run_command
68
74
  buildpack_refresh.error!
69
75
  end
70
76
  end
71
77
 
72
78
  def install
79
+ FileUtils.mkdir_p(buildpack_cache_dir)
73
80
  Dir.chdir(buildpack_cache_dir) do
74
81
  buildpack_install = Mixlib::ShellOut.new("git clone \"#{url}\"")
75
82
  buildpack_install.run_command
76
83
  buildpack_install.error!
77
84
  end
78
85
  end
86
+
87
+ def replace_app_with_app_home(app_home)
88
+ Dir.chdir(dir) do
89
+ buildpack_replace = Mixlib::ShellOut.new("find . -type f -print0 | xargs -0 sed -i 's/\\/app/#{app_home.gsub("/", "\\/")}/g'")
90
+ buildpack_replace.run_command
91
+ buildpack_replace.error!
92
+ end
93
+ end
79
94
  end
80
95
  end
@@ -25,6 +25,8 @@ module Pkgr
25
25
  method_option :host, :type => :string, :desc => "Remote host to build on (default: local machine)"
26
26
  method_option :auto, :type => :boolean, :default => false, :desc => "Automatically attempt to install missing dependencies"
27
27
  method_option :clean, :type => :boolean, :default => true, :desc => "Automatically clean up temporary dirs"
28
+ method_option :buildpack, :type => :string, :desc => "Custom buildpack to use"
29
+ method_option :edge, :type => :boolean, :default => true, :desc => "Always use the latest version of the buildpack if already installed"
28
30
 
29
31
  def package(tarball)
30
32
  Pkgr.level = Logger::INFO if options[:verbose]
@@ -60,10 +60,12 @@ module Pkgr
60
60
  args.push "--build-dependencies #{build_dependencies.map{|d| "\"#{d}\""}.join("")}" unless build_dependencies.nil? || build_dependencies.empty?
61
61
  args.push "--compile-cache-dir \"#{compile_cache_dir}\"" unless compile_cache_dir.nil? || compile_cache_dir.empty?
62
62
  args.push "--before-precompile \"#{before_precompile}\"" unless compile_cache_dir.nil? || compile_cache_dir.empty?
63
+ args.push "--buildpack \"#{buildpack}\"" unless buildpack.nil? || buildpack.empty?
63
64
  args.push "--auto" if auto
64
65
  args.push "--verbose" if verbose
65
66
  args.push "--debug" if debug
66
- args.push "--clean" if clean
67
+ args.push "--no-clean" if !clean
68
+ args.push "--no-edge" if !edge
67
69
  args
68
70
  end
69
71
  end
@@ -91,24 +91,29 @@ module Pkgr
91
91
  }
92
92
  end
93
93
 
94
- def buildpacks
95
- case version
96
- when "wheezy"
97
- %w{
98
- https://github.com/heroku/heroku-buildpack-ruby.git
99
- https://github.com/heroku/heroku-buildpack-nodejs.git
100
- https://github.com/heroku/heroku-buildpack-java.git
101
- https://github.com/heroku/heroku-buildpack-play.git
102
- https://github.com/heroku/heroku-buildpack-python.git
103
- https://github.com/heroku/heroku-buildpack-php.git
104
- https://github.com/heroku/heroku-buildpack-clojure.git
105
- https://github.com/kr/heroku-buildpack-go.git
106
- https://github.com/miyagawa/heroku-buildpack-perl.git
107
- https://github.com/heroku/heroku-buildpack-scala
108
- https://github.com/igrigorik/heroku-buildpack-dart.git
109
- https://github.com/rhy-jot/buildpack-nginx.git
110
- https://github.com/Kloadut/heroku-buildpack-static-apache.git
111
- }.map{|url| Buildpack.new(url)}
94
+ def buildpacks(custom_buildpack_uri = nil)
95
+ if custom_buildpack_uri
96
+ uuid = Digest::SHA1.hexdigest(custom_buildpack_uri)
97
+ [Buildpack.new(custom_buildpack_uri, :custom)]
98
+ else
99
+ case version
100
+ when "wheezy"
101
+ %w{
102
+ https://github.com/heroku/heroku-buildpack-ruby.git
103
+ https://github.com/heroku/heroku-buildpack-nodejs.git
104
+ https://github.com/heroku/heroku-buildpack-java.git
105
+ https://github.com/heroku/heroku-buildpack-play.git
106
+ https://github.com/heroku/heroku-buildpack-python.git
107
+ https://github.com/heroku/heroku-buildpack-php.git
108
+ https://github.com/heroku/heroku-buildpack-clojure.git
109
+ https://github.com/kr/heroku-buildpack-go.git
110
+ https://github.com/miyagawa/heroku-buildpack-perl.git
111
+ https://github.com/heroku/heroku-buildpack-scala
112
+ https://github.com/igrigorik/heroku-buildpack-dart.git
113
+ https://github.com/rhy-jot/buildpack-nginx.git
114
+ https://github.com/Kloadut/heroku-buildpack-static-apache.git
115
+ }.map{|url| Buildpack.new(url)}
116
+ end
112
117
  end
113
118
  end
114
119
 
@@ -1,3 +1,3 @@
1
1
  module Pkgr
2
- VERSION = "1.0.5"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pkgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.1.0
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: 2013-10-09 00:00:00.000000000 Z
12
+ date: 2013-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake