Last active
December 18, 2018 05:42
-
-
Save mika/9267385 to your computer and use it in GitHub Desktop.
generate a (partial) rubygems mirror
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Purpose: create a partial Rubygems mirror on Debian (7 AKA wheezy) | |
## Design goal: no system wide gems other than Debian packages | |
# make sure bundler, ruby-builder (required for generate_index) + rubygems-integration (required for gem<->builder integration) are available: | |
% sudo apt-get install ruby-bundler ruby-builder rubygems-integration | |
# We use gem-mirror (http://rubygems.org/gems/gem-mirror / https://github.com/YorickPeterse/gem-mirror), so | |
# install gem-mirror gem itself (requires ruby >=1.9) in local directory for execution via bundler: | |
% cat Gemfile | |
source 'https://rubygems.org/' | |
gem "gem-mirror" | |
% ruby1.9.1 -S bundle install --path=vendor | |
# Initialize mirror (creates template config.rb file): | |
% ruby1.9.1 -S bundle exec gem-mirror init | |
# Adjust gem-mirror configuration: | |
% cat config.rb | |
# This is the main configuration file for your RubyGems mirror. Here you can | |
# change settings such as the location to store Gem files in and what sources | |
# and Gems you'd like to mirror. | |
GemMirror.configuration.configure do | |
# The directory to store indexing information as well as the Gem files in. | |
destination File.expand_path('../public', __FILE__) | |
# Directory to use for storing SHA512 checksums of each Gem. | |
checksums File.expand_path('../public/checksums', __FILE__) | |
# When set to `true` development dependencies of Gems will also be mirrored. | |
development false | |
# If you're mirroring a lot of Gems you'll probably want to switch the | |
# logging level to Logger::ERROR or Logger::INFO to reduce the amount of | |
# noise. | |
logger.level = Logger::DEBUG | |
# A source is a remote location that you want to mirror. The first parameter | |
# of this method is the human readable name, the second one the URL. The | |
# supplied block is used to determine what Gems (and versions) to mirror. | |
source 'rubygems', 'https://rubygems.org' do | |
gem "selenium-webdriver" | |
gem "rspec" | |
gem "syntax" | |
gem 'rubyzip' | |
gem 'childprocess' | |
gem 'diff-lcs' | |
gem 'websocket' | |
end | |
end | |
# Update mirror (retrieving gems): | |
% ruby1.9.1 -S bundle exec gem-mirror update | |
# Checksums: | |
% ruby1.9.1 -S bundle exec gem-mirror checksums | |
# (NOTE: "gem-mirror index" as well as "ruby1.9.1 -S bundle exec gem1.9.1 generate_index --directory public/" | |
# are broken when executed inside the bundler directory, they announce the bundler gems from the vendor | |
# directory instead, see https://github.com/YorickPeterse/gem-mirror/issues/9 for details.) | |
# Generate index: | |
% gem1.9.1 generate_index --no-legacy --directory public | |
# Now you can announce the public directory through your webserver, like | |
% sudo ln -s /srv/mirror/rubygems/public/ /var/www/rubygems |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment