Script to update local mirror of Hackage

Based on your example, I wrote the following script that shaves a couple of rough edges. I've tested it, it seems to work well enough:

#!/bin/bash -e

if [ -z "${SKETE_HASKELL_DIR}" ]; then
   export SKETE_HASKELL_DIR="${HOME}/src/skete-haskell"
fi

pushd ${SKETE_HASKELL_DIR}

# Optional: Create a location to save tarballs downloaded from hackage to avoid redownloading on future imports.
mkdir -p hackage-cache
# Prepare the skete-haskell git repository
mkdir -p haskell-packages

# Initialize git of Hackage mirror, if not already initialized
if [ ! -r haskell-packages/.git/config ]; then
   pushd haskell-packages
   git init
   popd
fi

# fetch the current index tarball from hackage to tell skete what to import
wget https://hackage.haskell.org/01-index.tar
# import the current hackage state (This will take about an hour, depending on internet and disk speed)
bin/skete-haskell-exe import --cache hackage-cache --repo haskell-packages/.git
# Optional: pack the newly created repository so it takes less space on disk.
pushd haskell-packages
git gc --aggressive --prune=now
popd
rm 01-index.tar

On a fast machine it took less than 20 minutes.

Edited by Mouse