vulcan 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,7 +24,7 @@ if no COMMAND is specified, a sensible default will be chosen for you
24
24
  method_option :name, :aliases => "-n", :desc => "the name of the library (defaults to the directory name)"
25
25
  method_option :output, :aliases => "-o", :desc => "output build artifacts to this file"
26
26
  method_option :prefix, :aliases => "-p", :desc => "vulcan will look in this path for the compiled artifacts"
27
- method_option :source, :aliases => "-s", :desc => "the source directory to build from"
27
+ method_option :source, :aliases => "-s", :desc => "directory, tarball, or url containing the source"
28
28
  method_option :deps, :aliases => "-d", :desc => "urls of vulcan compiled libraries to build with", :type=>:array
29
29
  method_option :verbose, :aliases => "-v", :desc => "show the full build output", :type => :boolean
30
30
 
@@ -32,50 +32,71 @@ if no COMMAND is specified, a sensible default will be chosen for you
32
32
  app = read_config[:app] || "need a server first, use vulcan create"
33
33
 
34
34
  source = options[:source] || Dir.pwd
35
- name = options[:name] || File.basename(source)
35
+ name = options[:name] || File.basename(source, File.extname(source))
36
36
  output = options[:output] || "/tmp/#{name}.tgz"
37
37
  prefix = options[:prefix] || "/app/vendor/#{name}"
38
38
  command = options[:command] || "./configure --prefix #{prefix} && make install"
39
39
  deps = options[:deps] || []
40
40
  server = URI.parse(ENV["VULCAN_HOST"] || "http://#{app}.herokuapp.com")
41
41
 
42
+ source_is_url = URI.parse(source).scheme
43
+
42
44
  Dir.mktmpdir do |dir|
43
- action "Packaging local directory" do
44
- %x{ cd #{source} && tar czvf #{dir}/input.tgz . 2>&1 }
45
+ unless source_is_url
46
+ input_tgz = "#{dir}/input.tgz"
47
+ if File.directory?(source)
48
+ action "Packaging local directory" do
49
+ %x{ cd #{source} && tar czvf #{input_tgz} . 2>&1 }
50
+ end
51
+ else
52
+ input_tgz = source
53
+ end
54
+ input = File.open(input_tgz, "r")
55
+ end
56
+
57
+ make_options = {
58
+ "command" => command,
59
+ "prefix" => prefix,
60
+ "secret" => config[:secret],
61
+ "deps" => deps
62
+ }
63
+
64
+ if source_is_url
65
+ make_options["code_url"] = source
66
+ else
67
+ make_options["code"] = UploadIO.new(input, "application/octet-stream", "input.tgz")
45
68
  end
46
69
 
47
- File.open("#{dir}/input.tgz", "r") do |input|
48
- request = Net::HTTP::Post::Multipart.new "/make",
49
- "code" => UploadIO.new(input, "application/octet-stream", "input.tgz"),
50
- "command" => command,
51
- "prefix" => prefix,
52
- "secret" => config[:secret],
53
- "deps" => deps
70
+ request = Net::HTTP::Post::Multipart.new "/make", make_options
54
71
 
72
+ if source_is_url
73
+ print "Initializing build... "
74
+ else
55
75
  print "Uploading source package... "
56
- response = Net::HTTP.start(server.host, server.port) do |http|
57
- http.request(request) do |response|
58
- response.read_body do |chunk|
59
- unless chunk == 0.chr + "\n"
60
- print chunk if options[:verbose]
61
- end
76
+ end
77
+
78
+ response = Net::HTTP.start(server.host, server.port) do |http|
79
+ http.request(request) do |response|
80
+ response.read_body do |chunk|
81
+ unless chunk == 0.chr + "\n"
82
+ print chunk if options[:verbose]
62
83
  end
63
84
  end
64
85
  end
86
+ end
65
87
 
66
- error "Unknown error, no build output given" unless response["X-Make-Id"]
88
+ error "Unknown error, no build output given" unless response["X-Make-Id"]
67
89
 
68
- puts ">> Downloading build artifacts to: #{output}"
90
+ puts ">> Downloading build artifacts to: #{output}"
69
91
 
70
- output_url = "#{server}/output/#{response["X-Make-Id"]}"
71
- puts " (available at #{output_url})"
92
+ output_url = "#{server}/output/#{response["X-Make-Id"]}"
93
+ puts " (available at #{output_url})"
72
94
 
73
- File.open(output, "w") do |output|
74
- begin
75
- output.print RestClient.get(output_url)
76
- rescue Exception => ex
77
- puts ex.inspect
78
- end
95
+ File.open(output, "w") do |output|
96
+ begin
97
+ output.print RestClient.get(output_url)
98
+ rescue Exception => ex
99
+ puts ex.inspect
79
100
  end
80
101
  end
81
102
  end
@@ -1,5 +1,5 @@
1
1
  module Vulcan
2
2
 
3
- VERSION = "0.7.2"
3
+ VERSION = "0.8.0"
4
4
 
5
5
  end
@@ -2,7 +2,9 @@ coffee = require("coffee-script")
2
2
  express = require("express")
3
3
  fs = require("fs")
4
4
  logger = require("logger")
5
+ rest = require("restler")
5
6
  spawner = require("spawner").init()
7
+ url = require("url")
6
8
  util = require("util")
7
9
  uuid = require("node-uuid")
8
10
 
@@ -34,23 +36,36 @@ app.post "/make", (req, res, next) ->
34
36
  db.save id, command:command, prefix:prefix, deps:deps, (err, doc) ->
35
37
  return log.error(util.inspect(err)) if err
36
38
 
37
- # save uploaded code as an attachment
38
- log.info "saving attachment - [id:#{doc.id} rev:#{doc.rev}]"
39
- fs.createReadStream(req.files.code.path).pipe(
40
- db.saveAttachment {id:doc.id, rev:doc.rev}, {name:"input", "Content-Type":"application/octet-stream"}, (err, data) ->
41
- return log.error(err.reason) if err && err.error != "conflict"
39
+ save_attachment = (source, cb) ->
40
+ source.pipe(
41
+ db.saveAttachment {id:doc.id, rev:doc.rev}, {name:"input", "Content-Type":"application/octet-stream"}, (err, data) ->
42
+ return log.error(err.reason) if err && err.error != "conflict"
43
+ cb())
42
44
 
43
- res.write "done\n"
44
- res.write "Building with: #{command}\n"
45
- log.info "spawning build"
45
+ build = ->
46
+ res.write "done\n"
47
+ res.write "Building with: #{command}\n"
48
+ log.info "spawning build"
49
+ make = spawner.spawn "bin/make \"#{id}\"", env:
50
+ CLOUDANT_URL: process.env.CLOUDANT_URL
51
+ PATH: process.env.PATH
52
+ make.on "error", (err) -> log.error(err)
53
+ make.on "data", (data) -> res.write data
54
+ make.on "end", (code) -> res.end()
46
55
 
47
- make = spawner.spawn "bin/make \"#{id}\"", env:
48
- CLOUDANT_URL: process.env.CLOUDANT_URL
49
- PATH: process.env.PATH
56
+ if (req.files.code)
57
+ log.info "saving attachment - [id:#{doc.id} rev:#{doc.rev}]"
58
+ save_attachment fs.createReadStream(req.files.code.path), ->
59
+ build()
50
60
 
51
- make.on "error", (err) -> log.error(err)
52
- make.on "data", (data) -> res.write data
53
- make.on "end", (code) -> res.end())
61
+ else if (req.body.code_url)
62
+ log.info "downloading attachment: #{req.body.code_url}"
63
+ parts = url.parse(req.body.code_url)
64
+ client = if parts.protocol is "https:" then require("https") else require("http")
65
+ get = client.request parts, (res) ->
66
+ save_attachment res, ->
67
+ build()
68
+ get.end()
54
69
 
55
70
  app.get "/output/:id", (req, res, next) ->
56
71
  log = logger.init(res, next, req.params.id)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vulcan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: heroku
16
- requirement: &70147638459760 !ruby/object:Gem::Requirement
16
+ requirement: &70103648157100 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: '3.0'
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *70147638459760
27
+ version_requirements: *70103648157100
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: multipart-post
30
- requirement: &70147638457320 !ruby/object:Gem::Requirement
30
+ requirement: &70103648154600 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ~>
@@ -35,10 +35,10 @@ dependencies:
35
35
  version: 1.1.3
36
36
  type: :runtime
37
37
  prerelease: false
38
- version_requirements: *70147638457320
38
+ version_requirements: *70103648154600
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: rest-client
41
- requirement: &70147638455780 !ruby/object:Gem::Requirement
41
+ requirement: &70103648153680 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ~>
@@ -46,10 +46,10 @@ dependencies:
46
46
  version: 1.6.7
47
47
  type: :runtime
48
48
  prerelease: false
49
- version_requirements: *70147638455780
49
+ version_requirements: *70103648153680
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: thor
52
- requirement: &70147638454480 !ruby/object:Gem::Requirement
52
+ requirement: &70103648152920 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ~>
@@ -57,7 +57,7 @@ dependencies:
57
57
  version: 0.14.6
58
58
  type: :runtime
59
59
  prerelease: false
60
- version_requirements: *70147638454480
60
+ version_requirements: *70103648152920
61
61
  description: Build software in the cloud
62
62
  email: ddollar@gmail.com
63
63
  executables:
@@ -808,7 +808,7 @@ files:
808
808
  - server/vendor/gems/specifications/multi_json-1.0.3.gemspec
809
809
  - server/vendor/gems/specifications/rest-client-1.6.7.gemspec
810
810
  - server/web.coffee
811
- homepage: http://vulcan.com/
811
+ homepage: https://github.com/heroku/vulcan
812
812
  licenses: []
813
813
  post_install_message: Please run 'vulcan update' to update your build server.
814
814
  rdoc_options: []