Sha256: aeef636796c86bde7082a0274aca4628397a2e0bb76cd7b764856848a116d1d1

Contents?: true

Size: 913 Bytes

Versions: 2

Compression:

Stored size: 913 Bytes

Contents

#!/usr/bin/env ruby

ENV["GEM_HOME"] = File.expand_path("../../vendor/gems", __FILE__)
ENV["GEM_PATH"] = File.expand_path("../../vendor/gems", __FILE__)

require "rubygems"

id  = ARGV.shift

require "couchrest"
require "fileutils"
require "tmpdir"

db = CouchRest.database!(ENV["CLOUDANT_URL"] + "/make")

Dir.mktmpdir do |dir|
  Dir.chdir(dir) do
    doc = db.get(id)

    command = doc["command"]
    prefix = doc["prefix"]

    File.open("input.tgz", "wb") do |file|
      file.print doc.fetch_attachment("input")
    end

    FileUtils.mkdir_p "input"

    Dir.chdir("input") do
      %x{ tar xzf ../input.tgz 2>&1 }
      system command
    end

    Dir.chdir(prefix) do
      %x{ tar czf #{dir}/output.tgz * 2>&1 }
    end

    begin
      doc.put_attachment("output", File.open("#{dir}/output.tgz"))
    rescue RestClient::Conflict
      # temporarily work around problem with bigcouch
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vulcan-0.4.0 server/bin/make
vulcan-0.2.5 server/bin/make