Permalink
Browse files

Remove missing files from packages spec after vcap split

Change-Id: I0d7bca9bccf1b893302d2ab0eb980efde682983f
  • Loading branch information...
1 parent 87b9f52 commit 336c344213edb9e5c86bec39149257bc6bcd8f8c @mariash mariash committed Jul 11, 2012
Showing with 44 additions and 3 deletions.
  1. +0 −1 packages/acm/spec
  2. +0 −1 packages/dea_seed/pre_packaging
  3. +0 −1 packages/dea_seed/spec
  4. +44 −0 src/dea_seed/gem_cache.rb
View
@@ -9,4 +9,3 @@ files:
- acm/lib/**/*
- acm/db/**/*
- acm/vendor/**/*
-- core/common/**/*
@@ -3,5 +3,4 @@ set -e
cd ${BUILD_DIR}
-cp -a core/staging/lib/vcap/staging/plugin/gem_cache.rb dea_seed
rm -rf core
@@ -10,4 +10,3 @@ dependencies:
- libpq
files:
- dea_seed/**/*
- - core/staging/lib/vcap/staging/plugin/gem_cache.rb
@@ -0,0 +1,44 @@
+require "digest/sha1"
+require "fileutils"
+require "tempfile"
+require "tmpdir"
+
+class GemCache
+
+ def initialize(directory)
+ @directory = directory
+ end
+
+ def put(gemfile_path, installed_gem_path)
+ return unless gemfile_path && File.exists?(gemfile_path)
+ return unless installed_gem_path && File.exists?(installed_gem_path)
+
+ dst_dir = cached_obj_dir(gemfile_path)
+
+ spec_dir = File.join(dst_dir, "specifications")
+ FileUtils.mkdir_p(spec_dir)
+
+ `cp -n #{installed_gem_path}/specifications/*.gemspec #{spec_dir}`
+ # Someone else is copying gem?
+ return installed_gem_path if $?.exitstatus != 0
+
+ `cp -a #{installed_gem_path}/* #{dst_dir} && touch #{dst_dir}/.done`
+ return installed_gem_path if $?.exitstatus != 0
+ dst_dir
+ end
+
+ def get(path)
+ return nil unless path && File.exists?(path)
+ dir = cached_obj_dir(path)
+ return nil if !File.exists?(File.join(dir, ".done"))
+ File.directory?(dir) ? dir : nil
+ end
+
+ private
+
+ def cached_obj_dir(path)
+ sha1 = Digest::SHA1.file(path).hexdigest
+ "%s/%s/%s/%s" % [ @directory, sha1[0..1], sha1[2..3], sha1[4..-1] ]
+ end
+
+end

0 comments on commit 336c344

Please sign in to comment.