* Moved here (doesn't belong in nixpkgs).

svn path=/nixpkgs/trunk/; revision=633
This commit is contained in:
Eelco Dolstra 2004-01-12 15:27:38 +00:00
parent 19c6f730c3
commit 5f0cf96dbb
10 changed files with 0 additions and 416 deletions

View File

@ -1,79 +0,0 @@
#! /bin/sh
url="https://svn.cs.uu.nl:12443/repos/trace/nix/trunk/"
curl="curl --fail --silent --show-error"
# auth-info file should have format `username:password'.
if ! auth_info=$(cat auth-info); then
echo "cannot get authentication info"
exit 1
fi
curl_up="$curl --user $auth_info"
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"
# !!! race
echo $rev > head-revision.nix
if ! storeexprs=($(nix-instantiate -vv do-it.nix)); then exit 1; fi
srcexpr=${storeexprs[0]}
testexpr=${storeexprs[1]}
rpmexpr=${storeexprs[2]}
if ! outpath=$(nix-store -vvvv -qnf "$srcexpr"); then exit 1; fi
uploader="http://catamaran.labs.cs.uu.nl/~eelco/cgi-bin/create-dist.pl"
# 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.
if ! exists=$($curl_up $uploader/exists/$relname); then
echo "cannot check for existence of $relname on the server"
exit 1
fi
if test "$exists" = "yes"; then
echo "server already has release $relname"
exit 0
fi
# Create an upload session on the server.
if ! sessionname=$($curl_up $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_up -T "$outpath"/nix-*.tar.bz2 "$uploader/upload/$sessionname/" || exit 1
$curl_up -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 ! rpmpath=$(nix-store -vvvv -qnf "$rpmexpr"); then exit 1; fi
$curl_up -T "$rpmpath"/nix-*.rpm "$uploader/upload/$sessionname/" || exit 1
# Finish the upload session.
$curl_up "$uploader/finish/$sessionname" || exit 1
# Publish the release on the Wiki.
# !!! create /tmp file
echo -n $relname > relname
$curl_up -T relname "$uploader/put/head-revision" || exit 1
rm -f $relname
# Force a refresh of the Wiki.
$curl 'http://www.cs.uu.nl/groups/ST/twiki/bin/fresh/Trace/NixDeploymentSystem' > /dev/null || exit 1

View File

@ -1,32 +0,0 @@
let {
system = "i686-linux";
pkgs = (import ../pkgs/system/all-packages.nix) {system = system;};
stdenv = pkgs.stdenv_;
sourcedist = (import ./nix-source-dist.nix) {
stdenv = stdenv;
autoconf = pkgs.autoconf;
automake = pkgs.automake;
libxml2 = pkgs.libxml2;
libxslt = pkgs.libxslt;
docbook_dtd = pkgs.docbook_xml_dtd;
docbook_xslt = pkgs.docbook_xml_xslt;
fetchurl = pkgs.fetchurl;
fetchsvn = pkgs.fetchsvn;
rev = import ./head-revision.nix;
};
testbuild = (import ./nix-test-build.nix) {
stdenv = stdenv;
getopt = pkgs.getopt;
src = sourcedist;
};
rpmbuild = (import ./nix-rpm-build.nix) {
stdenv = stdenv;
getopt = pkgs.getopt;
src = sourcedist;
};
body = [sourcedist testbuild rpmbuild];
}

View File

@ -1,33 +0,0 @@
#! /bin/sh
email=$1
shift
logfile=/tmp/logfile-$$ # !!! security
trap "rm $logfile" EXIT
echo $logfile
if ! "$@" > $logfile 2>&1; then
BLOCKER=/tmp/inhibit-notify
if ! test -f $BLOCKER; then
HEAD=`head $logfile`
TAIL=`tail $logfile`
bzip2 < $logfile > $logfile.bz2
mail -s "Nix build failed" -a $logfile.bz2 $email <<EOF
A Nix build failed. See the attached log file for details.
No further messages will be sent until the file $BLOCKER is removed.
The first few lines of the log are:
$HEAD
The last few lines are:
$TAIL
EOF
rm $logfile.bz2
touch $BLOCKER
fi
fi

View File

@ -1,16 +0,0 @@
{stdenv, getopt, src}:
derivation {
name = "nix-rpm-build";
system = stdenv.system;
builder = ./nix-rpm-build.sh;
src = src;
stdenv = stdenv;
getopt = getopt; # required by sdf2table
# Perhaps it's possible to build RPMs in a pure way? Probably not,
# since RPM needs its database to determine dependencies.
rpm = "/bin/rpm";
}

View File

@ -1,29 +0,0 @@
#! /bin/sh
buildinputs="$getopt"
. $stdenv/setup || exit 1
# Set up a RPM macros file. We have to use ~/.rpmmacros (`--rcfile'
# doesn't seem to work properly), so point HOME at the current
# directory.
export HOME=`pwd`
rpmmacros=$HOME/.rpmmacros
rpmdir=`pwd`/rpm
# Set up the directory structure expected by RPM.
mkdir $rpmdir || exit 1
mkdir $rpmdir/BUILD || exit 1
mkdir $rpmdir/SOURCE || exit 1
mkdir $rpmdir/SPECS || exit 1
mkdir $rpmdir/RPMS || exit 1
mkdir $rpmdir/SRPMS || exit 1
echo "%_topdir $rpmdir" > $rpmmacros
# Do the build.
$rpm -ta $src/*.tar.gz || exit 1
# Copy the resulting RPMs.
mkdir $out || exit 1
cp -p $rpmdir/RPMS/*/* $out || exit 1

View File

@ -1,38 +0,0 @@
{ stdenv, autoconf, automake, libxml2, libxslt
, docbook_dtd, docbook_xslt
, fetchurl, fetchsvn, rev
}:
derivation {
name = "nix-source-dist";
system = stdenv.system;
builder = ./nix-source-dist.sh;
src = fetchsvn {
url = "https://svn.cs.uu.nl:12443/repos/trace/nix/trunk/";
rev = rev;
};
bdbSrc = fetchurl {
url = "http://www.sleepycat.com/update/snapshot/db-4.2.52.tar.gz";
md5 = "cbc77517c9278cdb47613ce8cb55779f";
};
atermSrc = fetchurl {
url = http://www.cwi.nl/projects/MetaEnv/aterm/aterm-2.0.5.tar.gz;
md5 = "68aefb0c10b2ab876b8d3c0b2d0cdb1b";
};
sdfSrc = fetchurl {
url = ftp://ftp.stratego-language.org/pub/stratego/sdf2/sdf2-bundle-1.6.tar.gz;
md5 = "283be0b4c7c9575c1b5cc735316e6192";
};
stdenv = stdenv;
autoconf = autoconf;
automake = automake;
libxml2 = libxml2;
libxslt = libxslt;
docbook_dtd = docbook_dtd;
docbook_xslt = docbook_xslt;
}

View File

@ -1,32 +0,0 @@
#! /bin/sh
buildinputs="$autoconf $automake $libxml2 $libxslt"
. $stdenv/setup
echo "copying sources..."
cp -prd $src/* . || exit 1
chmod -R u+w . || exit 1
cp -p $bdbSrc externals/db-4.2.52.tar.gz || exit 1 # !!!
cp -p $atermSrc externals/aterm-2.0.5.tar.gz || exit 1
cp -p $sdfSrc externals/sdf2-bundle-1.6.tar.gz || exit 1
echo "autoconfing..."
autoreconf -i || exit 1
echo "configuring..."
./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
echo "building..."
make distdir || exit 1
pkgname=$(echo nix-*)
tar cvfz $pkgname.tar.gz $pkgname || exit 1
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
(cd doc/manual && make install) || exit 1
(cd inst/share/nix && tar cvfj $out/manual.tar.bz2 manual) || exit 1

View File

@ -1,12 +0,0 @@
{stdenv, getopt, src}:
derivation {
name = "nix-test-build";
system = stdenv.system;
builder = ./nix-test-build.sh;
src = src;
stdenv = stdenv;
getopt = getopt; # required by sdf2table
}

View File

@ -1,11 +0,0 @@
#! /bin/sh
buildinputs="$getopt"
. $stdenv/setup || exit 1
tar xvfj $src/*.tar.bz2 || exit 1
cd nix-* || exit 1
./configure --prefix=$out || exit 1
make || exit 1
make check || exit 1
make install || exit 1

View File

@ -1,134 +0,0 @@
#! /usr/bin/perl -w
use strict;
# Global settings.
my $releasesDir = "/home/eelco/public_html/nix";
umask 0002;
sub printResult {
my $result = shift;
print "Content-Type: text/plain\n\n";
print "$result\n";
}
sub uploadFileTo {
my $path = shift;
open OUT, ">$path" or die "cannot create $path: $!";
while (<STDIN>) {
print OUT "$_" or die;
}
close OUT or die;
}
my $args = $ENV{"PATH_INFO"};
# Parse command.
die unless $args =~ /^\/([a-z-]+)\/(.*)$/;
my $command = $1;
$args = $2;
# Perform the command.
# Start creation of a release.
if ($command eq "create") {
die unless $args =~ /^([A-Za-z0-9-][A-Za-z0-9-\.]*)$/;
my $releaseName = $1;
my $uniqueNr = int (rand 1000000);
my $sessionName = "tmp-$uniqueNr-$releaseName";
my $releaseDir = "$releasesDir/$sessionName";
mkdir $releaseDir, 0775 or die "cannot create $releaseDir: $!";
printResult "$sessionName";
}
# Upload a file to a release.
elsif ($command eq "upload") {
die unless $args =~ /^([A-Za-z0-9-][A-Za-z0-9-\.]*)((\/[A-Za-z0-9-][A-Za-z0-9-\.]*)+)$/;
my $sessionName = $1;
my $path = $2;
my $fullPath = "$releasesDir/$sessionName/$path";
uploadFileTo $fullPath;
printResult "ok";
}
# Upload and unpack a tar file to a release.
elsif ($command eq "upload-tar") {
die unless $args =~ /^([A-Za-z0-9-][A-Za-z0-9-\.]*)((\/[A-Za-z0-9-][A-Za-z0-9-\.]*)*)$/;
my $sessionName = $1;
my $path = $2; # may be empty
my $fullPath = "$releasesDir/$sessionName/$path";
system("cd $fullPath && tar xfj - 1>&2") == 0 or die "cannot unpack: $?";
printResult "ok";
}
# Finish the release.
elsif ($command eq "finish") {
die unless $args =~ /^([A-Za-z0-9-][A-Za-z0-9-\.]+)$/;
my $sessionName = $1;
die unless $sessionName =~ /^tmp-\d+-(.*)$/;
my $releaseName = $1;
my $releaseDir1 = "$releasesDir/$sessionName";
my $releaseDir2 = "$releasesDir/$releaseName";
system("chmod -R g=u $releaseDir1 1>&2") == 0 or die "cannot chmod: $?";
if (-d $releaseDir2) {
my $uniqueNr = int (rand 1000000);
my $releaseDir3 = "$releasesDir/replaced-$uniqueNr-$releaseName";
rename $releaseDir2, $releaseDir3
or die "cannot rename $releaseDir2 to $releaseDir3";
}
rename $releaseDir1, $releaseDir2
or die "cannot rename $releaseDir1 to $releaseDir2";
printResult "$releaseName";
}
# Check for release existence.
elsif ($command eq "exists") {
die unless $args =~ /^([A-Za-z0-9-][A-Za-z0-9-\.]*)$/;
my $releaseName = $1;
my $releaseDir = "$releasesDir/$releaseName";
if (-d $releaseDir) {
printResult "yes";
} else {
printResult "no";
}
}
# Upload a single file, outside of a release.
elsif ($command eq "put") {
$args = "/" . $args;
die unless $args =~ /^((\/[A-Za-z0-9-][A-Za-z0-9-\.]*)+)$/;
my $path = $1;
my $fullPath = "$releasesDir/$path";
uploadFileTo $fullPath;
printResult "ok";
}
else {
die "invalid command";
}