Skip to content

Instantly share code, notes, and snippets.

@eccstartup
Created June 30, 2015 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eccstartup/5e16f148666ff2768c9d to your computer and use it in GitHub Desktop.
Save eccstartup/5e16f148666ff2768c9d to your computer and use it in GitHub Desktop.
$ 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