diff --git a/nix-dist/build+upload.sh b/nix-dist/build+upload.sh
index 6f8cf7c910d1..b0cf9aa7abd2 100755
--- a/nix-dist/build+upload.sh
+++ b/nix-dist/build+upload.sh
@@ -2,10 +2,14 @@
url="https://svn.cs.uu.nl:12443/repos/trace/nix/trunk/"
-if ! rev=$(curl --silent -k https://svn.cs.uu.nl:12443/repos/trace/nix/trunk/ \
- | grep '
Revision' \
- | sed 's/.*Revision \(.*\):.*/\1/'); \
- then exit 1; fi
+rev=$(svn log --quiet --non-interactive "$url" \
+ | grep '^r' \
+ | sed "s/r\([0-9]*\).*$/\1/" \
+ | head -n 1)
+if test -z "$rev"; then
+ echo "cannot fetch head revision number"
+ exit 1
+fi
echo "building revision $rev of $url"
@@ -20,15 +24,37 @@ rpmexpr=${storeexprs[2]}
if ! nix-store -vvvv -r "$srcexpr" > /dev/null; then exit 1; fi
if ! outpath=$(nix-store -qn "$srcexpr"); then exit 1; fi
-uploader="http://losser.st-lab.cs.uu.nl/~eelco/cgi-bin/upload.pl/"
+uploader="http://losser.st-lab.cs.uu.nl/~eelco/cgi-bin/create-dist.pl"
-curl --silent -T "$outpath/manual.html" "$uploader" || exit 1
-curl --silent -T "$outpath/style.css" "$uploader" || exit 1
-curl --silent -T "$outpath"/nix-*.tar.bz2 "$uploader" || exit 1
+# Extract the name of the release.
+relname=$((cd $outpath && echo nix-*.tar.bz2) | sed -e s/.tar.bz2//)
+echo "release is $relname"
+# If it already exists on the server, quit.
+exists=$(curl -f --silent $uploader/exists/$relname)
+if test "$exists" = "yes"; then
+ echo "server already has release $relname"
+ exit 0
+fi
+
+# Create an upload session on the server.
+if ! sessionname=$(curl -f --silent $uploader/create/$relname); then
+ echo "cannot create upload session"
+ exit 1
+fi
+echo "session name is $sessionname"
+
+# Upload the source distribution and the manual.
+curl -f --silent -T "$outpath"/nix-*.tar.bz2 "$uploader/upload/$sessionname/" || exit 1
+curl -f --silent -T "$outpath"/manual.tar.bz2 "$uploader/upload-tar/$sessionname" || exit 1
+
+# Perform a test build.
#if ! nix-store -vvvv -r "$testexpr" > /dev/null; then exit 1; fi
+# Perform an RPM build, and upload the RPM to the server.
if ! nix-store -vvvv -r "$rpmexpr" > /dev/null; then exit 1; fi
if ! rpmpath=$(nix-store -qn "$rpmexpr"); then exit 1; fi
+curl -f --silent -T "$rpmpath"/nix-*.rpm "$uploader/upload/$sessionname/" || exit 1
-curl --silent -T "$rpmpath"/nix-*.rpm "$uploader" || exit 1
+# Finish the upload session.
+curl -f --silent "$uploader/finish/$sessionname" || exit 1
diff --git a/nix-dist/nix-source-dist.sh b/nix-dist/nix-source-dist.sh
index 2387a3b47bf3..3453ef7056cc 100755
--- a/nix-dist/nix-source-dist.sh
+++ b/nix-dist/nix-source-dist.sh
@@ -14,7 +14,7 @@ echo "autoconfing..."
autoreconf -i || exit 1
echo "configuring..."
-./configure \
+./configure --prefix=`pwd`/inst \
--with-docbook-catalog=$docbook_dtd/xml/dtd/docbook/docbook.cat \
--with-docbook-xsl=$docbook_xslt/xml/xsl/docbook \
--with-xml-flags="--nonet" || exit 1
@@ -28,5 +28,5 @@ tar cvfj $pkgname.tar.bz2 $pkgname || exit 1
echo "copying result..."
mkdir $out || exit 1
cp -p $pkgname.tar.gz $pkgname.tar.bz2 $out || exit 1
-cp -p doc/manual/book.html $out/manual.html || exit 1
-cp -p doc/manual/style.css $out/ || exit 1
+(cd doc/manual && make install) || exit 1
+(cd inst/share/nix && tar cvfj $out/manual.tar.bz2 manual) || exit 1