Browse files

Allow reading gem list from a file during mirroring

This extends the gem mirroring script to support reading from a file, as well
as the command line, to find out which set of gems to mirror.

This allows an extended input format in the file, where we specify version
constraints, which resolves #59, a need to specify version constraints.
Now we have a clean mechanism for specifying them.

Signed-off-by: Daniel Pittman <>
  • Loading branch information...
1 parent 104a9bc commit 4ba16dd31c310d77341542f0b1e9b5ae8e363d71 @slippycheeze slippycheeze committed Feb 12, 2013
Showing with 15 additions and 2 deletions.
  1. +14 −1 bin/mirror-gem
  2. +1 −1
@@ -24,6 +24,10 @@ EOT
o.on('--server URL', '--gem-server URL', '-s URL', 'the remote gem source to use') do |url|
$server = url
+ o.on('--gemfile FILE', '-f FILE', 'a file with the list of gems to mirror') do |file|
+ $gemfile = file
+ end
@@ -74,7 +78,16 @@ $server and Gem.sources = [$server]
# We actually want the gems one level down, in their repository structure.
# REVISIT: Should we support gem version information here? (eg: ~> 2.7)
-ARGV.each {|gem| mirror_gem($where, gem) }
+if $gemfile then
+$gemfile).each_line do |line|
+ gem, version = line.chomp.split(/\s+/, 2)
+ gem or next # skip empty lines, just in case
+ gem =~ /^\s*#/ and next # also comments
+ mirror_gem($where, gem, version)
+ end
+ ARGV.each {|gem| mirror_gem($where, gem) }
puts "Generating the GEM mirror indexes..."
system('gem', 'generate_index', '-d', $where.parent.to_s)
@@ -260,7 +260,7 @@ mkdir -p tmp-build-dir/opt
cp -t tmp-build-dir/opt -p opt/boot*.sh
chmod +rx tmp-build-dir/opt/boot*.sh
-./bin/mirror-gem $GEM_SERVER_ARG -d tmp-build-dir/tmp/gem-mirror `cat opt/gems/gem.list`
+./bin/mirror-gem $GEM_SERVER_ARG -d tmp-build-dir/tmp/gem-mirror -f opt/gems/gem.list
# Add GemRC file to the ISO to use the mirror
cp -p opt/gems/gem.list tmp-build-dir/tmp/gem-mirror/gems/gem.list

0 comments on commit 4ba16dd

Please sign in to comment.