Last active
December 11, 2015 23:39
-
-
Save raggi/4678189 to your computer and use it in GitHub Desktop.
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.
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
#!/usr/bin/env sh | |
if ! which md5sum > /dev/null; then | |
echo Install md5sum | |
exit 1 | |
fi | |
if ! which curl > /dev/null; then | |
echo Install curl | |
exit 1 | |
fi | |
home=$(gem env GEM_HOME) | |
cache=$home/cache | |
echo This will take a while... | |
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 | |
echo All done. |
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
#!/usr/bin/env sh | |
if ! which openssl > /dev/null; then | |
echo Install openssl | |
exit 1 | |
fi | |
if ! which curl > /dev/null; then | |
echo Install curl | |
exit 1 | |
fi | |
home=$(gem env GEM_HOME) | |
cache=$home/cache | |
echo This will take a while... | |
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 | |
echo All done. |
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
#!/usr/bin/env sh | |
if ! which openssl > /dev/null; then | |
echo Install openssl | |
exit 1 | |
fi | |
if ! which curl > /dev/null; then | |
echo Install curl | |
exit 1 | |
fi | |
echo This will take a while... | |
for gem in $(locate \*.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 | |
echo All done. |
Holek
commented
Jan 31, 2013
sahi-1.0.0.gem mismatch. local: c32f744846c751d51f3a4e296432daa8, remote: faff6ce473c47a4bcb5e0c9b5a4def11
robin@robin-harvey-workstation:gem-checker$ locate *.gem | grep sahi | xargs ls -lh
-rw-rw-r-- 1 robin robin 11K Jul 19 2011 /home/robin/sahi/ruby/sahi-1.0.0.gem
-rw-rw-r-- 1 robin robin 11K Jul 19 2011 /home/robin/sahi/ruby/sahi-1.0.1.gem
fission-0.4.0.gem mismatch. local: 0f010d636fbbdc036004710b91e3c2b1, remote: d34073ffa3435be30a5f92856c76ed33
Here's an OSX ready script, that also has some hints for folks using bundler. Also OSX md5 works fine, but awk must look at $4 not $1. Anyhoo: https://gist.github.com/4683645
Much appreciated!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment