diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2017-01-02 16:12:06 +0100 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2017-01-02 16:29:14 +0100 |
commit | 3fe9cea03a6384fd8f57f10e172c134ed5c0552d (patch) | |
tree | 1148f745058b8885cd07edeb414f5822b05d616f /support | |
parent | a3712cc18de8283b25c3a8a034ecc8c9b7feca48 (diff) | |
download | gitlab-shell-redis-full-gem.tar.gz |
Vendor redis_rb from Rubygems, not GitHubredis-full-gem
Also just include the entire gem. Space used is negligible and this
way we don't have to think about what to leave in/out.
Create a vendor-gem script in Ruby instead of Make.
Diffstat (limited to 'support')
-rwxr-xr-x | support/vendor-gem.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/support/vendor-gem.rb b/support/vendor-gem.rb new file mode 100755 index 0000000..4115a56 --- /dev/null +++ b/support/vendor-gem.rb @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby +require 'fileutils' +require 'open3' + +VENDOR_PREFIX = 'lib/vendor' + +def main(gem, version, vendor_dir) + if !vendor_dir.start_with?(VENDOR_PREFIX) + abort "Invalid vendor_dir: must start with #{VENDOR_PREFIX}: #{vendor_dir.inspect}" + end + + FileUtils.rm_rf(vendor_dir) + + # Use clear-sources to force https://rubygems.org as the source + if !system(*%W[gem fetch #{gem} -v #{version} --clear-sources -s https://rubygems.org]) + abort "Failed to fetch gem" + end + + FileUtils.mkdir_p(vendor_dir) + + # A .gem file is a tar file containing a data.tar.gz file. + statuses = Open3.pipeline( + %W[tar -xOf - data.tar.gz], + %W[tar -zxf -], + in: "#{gem}-#{version}.gem", + chdir: vendor_dir + ) + + if !statuses.all?(&:success?) + abort "Failed to extract gem" + end +end + +if ARGV.count != 3 + abort "Usage: #{$PROGNAME} GEM VERSION VENDOR_DIR" +end + +main(*ARGV) |