2013-03-02 05:40:20 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
TYPES="html pdf-a4 pdf-letter text"
|
|
|
|
URL=http://docs.python.org/ftp/python/doc/VERSION/python-VERSION-docs-TYPE.tar.bz2
|
|
|
|
VERSIONS=$(curl http://www.python.org/download/releases/ 2>/dev/null | grep "releases/[123456789]"| cut -d/ -f4 |grep -v "^[12].[012345]" |grep -v "^1.6.1")
|
|
|
|
echo "Generating expressions for:
|
|
|
|
${VERSIONS}
|
|
|
|
"
|
|
|
|
|
|
|
|
|
|
|
|
cat >default.nix <<EOF
|
2013-03-05 12:28:30 +01:00
|
|
|
{ stdenv, fetchurl, lib }:
|
2013-03-02 05:40:20 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
pythonDocs = {
|
|
|
|
EOF
|
|
|
|
|
2013-03-03 06:43:31 +01:00
|
|
|
for type in $TYPES; do
|
2013-03-13 13:09:58 +01:00
|
|
|
cat >>default.nix <<EOF
|
|
|
|
${type/-/_} = {
|
|
|
|
recurseForDerivations = true;
|
|
|
|
EOF
|
|
|
|
|
2013-03-03 06:43:31 +01:00
|
|
|
for version in $VERSIONS; do
|
2013-03-02 05:40:20 +01:00
|
|
|
major=$(echo -n ${version}| cut -d. -f1)
|
|
|
|
minor=$(echo -n ${version}| cut -d. -f2)
|
|
|
|
outfile=${major}.${minor}-${type}.nix
|
|
|
|
hash=
|
|
|
|
if [ -e ${outfile} ]; then
|
|
|
|
currentversion=$(grep "url =" ${outfile} |cut -d/ -f7)
|
|
|
|
if [ ${version} = ${currentversion} ]; then
|
|
|
|
hash=$(grep sha256 ${outfile} | cut -d'"' -f2)
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo "Generating ${outfile}"
|
|
|
|
url=$(echo -n $URL |sed -e "s,VERSION,${version},g" -e "s,TYPE,${type},")
|
|
|
|
sha=$(nix-prefetch-url ${url} ${hash})
|
|
|
|
|
|
|
|
sed -e "s,VERSION,${version}," \
|
|
|
|
-e "s,MAJOR,${major}," \
|
|
|
|
-e "s,MINOR,${minor}," \
|
|
|
|
-e "s,TYPE,${type}," \
|
|
|
|
-e "s,URL,${url}," \
|
|
|
|
-e "s,SHA,${sha}," < template.nix > ${outfile}
|
|
|
|
|
2013-03-03 06:43:31 +01:00
|
|
|
attrname=python${major}${minor}
|
2013-03-02 05:40:20 +01:00
|
|
|
cat >>default.nix <<EOF
|
2013-03-03 06:43:31 +01:00
|
|
|
${attrname} = import ./${major}.${minor}-${type}.nix {
|
2013-03-05 12:28:30 +01:00
|
|
|
inherit stdenv fetchurl lib;
|
2013-03-03 06:43:31 +01:00
|
|
|
};
|
2013-03-02 05:40:20 +01:00
|
|
|
EOF
|
|
|
|
|
|
|
|
echo "done."
|
|
|
|
echo
|
|
|
|
done
|
2013-03-03 06:43:31 +01:00
|
|
|
echo " };" >> default.nix
|
2013-03-02 05:40:20 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
echo "}; in pythonDocs" >> default.nix
|