Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A script to validate your local gem cache against the public s3 repositories. If you find mismatches that contain both local and remote values, please post them in comments. For Rbenv
#!/usr/bin/env sh
set -e
if ! which md5sum > /dev/null; then
echo Install md5sum
exit 1
fi
if ! which curl > /dev/null; then
echo Install curl
exit 1
fi
echo This will take a while...
rbenv_versions=$HOME/.rbenv/versions
versions=$(ls $rbenv_versions)
for version in $versions; do
echo Checking rbenv Ruby version $version
home=$rbenv_versions/$version
cache=$home/lib/ruby/gems/*/cache
echo Now checking gems in $cache
for gem in $cache/*.gem; do
gemfile=$(basename $gem)
local=$(md5sum $gem | awk '{print $1}')
remote=$(curl -s -D - -X HEAD -H 'Connection:close' http://production.cf.rubygems.org/gems/$gemfile | grep 'ETag' | cut -d '"' -f 2)
if [[ ! $local = $remote ]]; then
echo $gemfile mismatch. local: $local, remote: $remote
fi
done
done
echo All done.
#!/usr/bin/env sh
set -e
if ! which openssl > /dev/null; then
echo Install openssl
exit 1
fi
if ! which curl > /dev/null; then
echo Install curl
exit 1
fi
rbenv_versions=$HOME/.rbenv/versions
versions=$(ls $rbenv_versions)
for version in $versions; do
echo Checking rbenv Ruby version $version
home=$rbenv_versions/$version
cache=$home/lib/ruby/gems/*/cache
echo Now checking gems in $cache
for gem in $cache/*.gem; do
gemfile=$(basename $gem)
local=$(openssl md5 $gem | awk '{print $2}')
remote=$(curl -s -D - -X HEAD -H 'Connection:close' http://production.cf.rubygems.org/gems/$gemfile | grep 'ETag' | cut -d '"' -f 2)
if [[ ! $local = $remote ]]; then
echo $gemfile mismatch. local: $local, remote: $remote
fi
done
done
echo All done.
Owner

revans commented Jan 31, 2013

For OSX users, install md5sum via hombrew: brew install md5sha1sum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment