Created
June 30, 2015 02:46
-
-
Save eccstartup/5e16f148666ff2768c9d to your computer and use it in GitHub Desktop.
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
$ cat hackage-mirror.sh | |
``` | |
#!/bin/bash | |
cd /home/eccstartup/mirror/hackage | |
#echo "Cleaning up..." | |
# rm 00-index.tar.gz | |
mkdir -p package | |
echo "Downloading index..." | |
rm index.tar.gz | |
axel http://hdiff.luite.com/packages/archive/index.tar.gz -o index.tar.gz || curl http://hackage.haskell.org/packages/index.tar.gz -o index.tar.gz | |
for splitpk in `tar ztf index.tar.gz | cut -d/ -f 1,2 2>/dev/null`; do | |
pk=`echo $splitpk | sed 's|/|-|'` | |
name=$pk.tar.gz | |
if [[ ! -a package/$name ]]; then | |
wget http://hackage.haskell.org/package/$pk/$name -O package/$name | |
fi | |
done | |
rm package/preferred-versions.tar.gz | |
cp index.tar.gz 00-index.tar.gz | |
``` | |
$ cat hackagefixbroken.sh | |
``` | |
#!/bin/bash | |
here=`pwd` | |
cd /home/eccstartup/mirror/hackage/package | |
ls >filelist.txt | |
touch brokenfiles.txt | |
while read line; do echo $line ; tar -tzf $line >/dev/null || echo $line >>brokenfiles.txt; done <filelist.txt | |
cat brokenfiles.txt | xargs rm | |
#rm filelist.txt | |
rm brokenfiles.txt | |
cd $here | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment