Skip to content

Instantly share code, notes, and snippets.

@raggi
Last active December 11, 2015 23:39
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save raggi/4678189 to your computer and use it in GitHub Desktop.
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.
#!/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.
#!/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.
#!/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.
@lwdallas
Copy link

Much appreciated!

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