A first attempt at generic release management. The goal

is to fully automate the building of distributions and
their release for distribution through a web-site, ftp
directory, etc. Inspired by nix-dist, but more generic
in order to deal with StrategoXT and related packages. 

The assumptions are the following:

  - package source is a subversion repository
  - the package is under autotool configuration
    (at least it has a configure.in with an AC_INIT)
  - standard autotools build interface:
    - bootstrap; configure; make install; 
      make check; make dist
  - optionally the release status can be indicated by
    a status="..." definition in configure.in

Creation of distributions is a two-step process:

  urls-to-nix.sh  # nix expressions for most recent commits
  build+upload.sh # instantiate the expressions

svn-to-nix.sh 

   Generates nix expression for head revision of the
   package; revision number, package name, and version
   are obtained from the source and do not have to
   be declared.

urls-to-nix.sh

   Contains a list of URLs to which svn-to-nix.sh is applied.

build+upload.sh

   Builds the packages and creates distributions in a www
   directory. Including the log of the build process (buildfarm)
   and files such as NEWS and README (for release management).
   (upload part of the script is currently turned off)

do-it.nix

   Top nix expression; collects pointers to required packages
   (e.g., stdenv, autotools, aterms, ...) and binds them
   to the parameters of the source-dist.nix packages.

package-source-dist.nix

   Generic Nix expression for a package parameterized with
   version info from svn and dependency info from do-it.nix.

package-dist.nix

   Generated; just imports 

package-version-rev.nix

   Generated; instantiates package-source-dist.nix with version,
   name, packagename, rev.

build-from-svn.sh

   Generic build script; obtains configuration flags from
   with... and enable... attributes of the Nix expression.
   Creates logs of the various parts of the build process.
   Creates distribution

Generalizations:

- Currently some information about a package resides in
  this directory, e.g., the generic Nix expression for
  a package, and the composition of the overall do-it.nix
  This information should also be obtained from the source
  tree.

- Upload facility lacking.
 



svn path=/nixpkgs/trunk/; revision=605
This commit is contained in:
Eelco Visser 2003-12-30 21:14:48 +00:00
parent 68361ac199
commit bad05cd2b6
11 changed files with 243 additions and 73 deletions

View file

@ -1,29 +1,22 @@
#! /bin/sh
#! /bin/sh -v
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 '<h2>Revision' \
| sed 's/.*Revision \(.*\):.*/\1/'); \
then exit 1; fi
# Build the distribution
echo "building revision $rev of $url"
echo $rev > head-revision.nix
if ! storeexprs=($(nix-instantiate -vvv do-it.nix)); then exit 1; fi
if ! storeexprs=($(nix-instantiate -vvvv do-it.nix)); then exit 1; fi
srcexpr=${storeexprs[0]}
testexpr=${storeexprs[1]}
#testexpr=${storeexprs[1]}
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/upload.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
#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
if ! nix-store -vvvv -r "$testexpr" > /dev/null; then exit 1; fi
#if ! nix-store -vvvv -r "$testexpr" > /dev/null; then exit 1; fi

View file

@ -0,0 +1,85 @@
#! /bin/sh -v
buildinputs="$make $automake $autoconf $libtool $which $withsdf"
. $stdenv/setup || exit 1
echo "pwd = `pwd`"
echo "PATH = $PATH"
# configuration flags
config_flags=""
for pack in `env | grep with | sed "s/^with\([A-Za-z]*\)=.*/\1/"`
do
config_flags="${config_flags} --with-${pack}=$(printenv with${pack})"
done
for feat in `env | grep enable | sed "s/^enable\([A-Za-z]*\)=.*/\1/"`
do
config_flags="${config_flags} --enable-${feat}=$(printenv enable${feat})"
done
echo "config_flags : $config_flags"
# keep a log
distdir=$out/www/strategoxt/$version-$rev
logdir=$distdir/log
mkdir -p $distdir || exit 1
mkdir -p $logdir || exit 1
# get the source
cp -r $src src || exit 1
chmod -R +w src
cd src || exit 1
echo ${rev} > svn-revision
# build it
GO="true"
./bootstrap 2>&1 | tee $logdir/bootstrap.txt
./configure --prefix=$out ${config_flags} 2>&1 | tee $logdir/configure.txt
if ! make install 2>&1 | tee $logdir/install.txt
then
GO="false"
fi
if test $GO = "true"
then
if ! make check 2>&1 | tee $logdir/check.txt
then
GO="false"
fi
fi
# make a distribution
if test $GO = "true"
then
if make dist 2>&1 | tee $logdir/dist.txt
then
if test "x${status}" = "xrelease"
then
cp ${packagename}-${version}.tar.gz $distdir || exit 1
else
tar zxf ${packagename}-${version}.tar.gz
mv ${packagename}-${version} ${name}
tar zcf ${name}.tar.gz ${name}
cp ${name}.tar.gz $distdir || exit 1
fi
fi
fi
# distribute documentation data
if test -f news/NEWS-$version
then
cp news/NEWS-$version $distdir || exit 1
fi
cp NEWS ChangeLog AUTHORS README COPYING $distdir || exit 1

View file

@ -1,26 +1,26 @@
let {
system = "i686-linux";
pkgs = (import ../pkgs/system/all-packages.nix) {system = system;};
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;
strategoxtdist = (import ./strategoxt-dist.nix) {
stdenv = stdenv;
fetchsvn = pkgs.fetchsvn;
autotools = pkgs.autotools;
which = pkgs.which;
aterm = pkgs.aterm;
sdf = pkgs.sdf2;
};
testbuild = (import ./nix-test-build.nix) {
stdenv = stdenv;
getopt = pkgs.getopt;
src = sourcedist;
tigerdist = (import ./tiger-dist.nix) {
stdenv = stdenv;
fetchsvn = pkgs.fetchsvn;
autotools = pkgs.autotools;
which = pkgs.which;
aterm = pkgs.aterm;
sdf = pkgs.sdf2;
strategoxt = strategoxtdist;
};
body = [sourcedist testbuild];
body = [strategoxtdist tigerdist];
}

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.1.25.tar.gz";
md5 = "df71961002b552c0e72c6e4e358f27e1";
};
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

@ -0,0 +1,22 @@
{name, packagename, version, rev, url} :
{stdenv, fetchsvn, autotools, which, aterm, sdf}:
derivation {
name = name;
packagename = packagename;
rev = rev;
version = version;
system = stdenv.system;
builder = ./build-from-svn.sh;
src = fetchsvn {url = url; rev = rev;};
stdenv = stdenv;
make = autotools.make;
automake = autotools.automake;
autoconf = autotools.autoconf;
libtool = autotools.libtool;
which = which;
withaterm = aterm;
withsdf = sdf;
}

View file

@ -1,10 +1,10 @@
{stdenv, getopt, src}:
derivation {
name = "nix-test-build";
name = "strategoxt-test-build";
system = stdenv.system;
builder = ./nix-test-build.sh;
builder = ./strategoxt-test-build.sh;
src = src;
stdenv = stdenv;

71
strategoxt-dist/svn-to-nix.sh Executable file
View file

@ -0,0 +1,71 @@
#! /bin/sh -v
# Generate a Nix expression for the head revision of a directory in
# a subversion repository. The directory is assumed to contain
# a package with a configure.in file.
#
# Usage :
#
# svn-to-nix.sh url
#
# where url points to a subversion repository
# Obtain version information from repository
# Revision
url=$1
rev=`svn log ${url} \
| head -n 2 \
| grep rev \
| sed "s/rev \([0-9]*\):.*$/\1/"`
# The configure.in file
configure="/tmp/$$configure.in"
svn cat -r ${rev} ${url}/configure.in > $configure
# Version number from AC_INIT
version=`grep AC_INIT $configure \
| awk -F , -- "{print \\$2}" \
| sed "s/[[]//" \
| sed "s/[]]//"`
# Package name from AC_INIT
packagename=`grep AC_INIT $configure \
| awk -F , -- "{print \\$1}" \
| sed "s/AC_INIT([[]//" \
| sed "s/[]]//"`
# Status
status=`grep status $configure \
| sed "s/^status=\(.*\)/\1/"`
# The name of the distribution
name="${packagename}-${version}-${rev}"
rm $configure
###########################
# Generate Nix expressions
cat > ${packagename}-dist.nix <<EOF
import ./${name}.nix
EOF
cat > ${name}.nix <<EOF
(import ./${packagename}-source-dist.nix) {
name = "${name}";
packagename = "${packagename}";
version = "${version}";
rev = "${rev}";
url = "${url}";
}
EOF

View file

@ -0,0 +1,27 @@
{name, packagename, version, rev, url} :
{stdenv, fetchsvn, autotools, which, aterm, sdf, strategoxt}:
derivation {
name = name;
packagename = packagename;
rev = rev;
version = version;
system = stdenv.system;
builder = ./build-from-svn.sh;
src = fetchsvn {url = url; rev = rev; };
stdenv = stdenv;
make = autotools.make;
automake = autotools.automake;
autoconf = autotools.autoconf;
libtool = autotools.libtool;
which = which;
withaterm = aterm;
withsdf = sdf;
withstrategoxt = strategoxt;
enabletiger = "yes";
enableir = "yes";
enableasm = "yes";
}

10
strategoxt-dist/urls-to-nix.sh Executable file
View file

@ -0,0 +1,10 @@
#! /bin/sh
urls="https://svn.cs.uu.nl:12443/repos/StrategoXT/trunk/StrategoXT \
https://svn.cs.uu.nl:12443/repos/StrategoXT/trunk/tiger"
for url in ${urls}
do
echo ${url}
./svn-to-nix.sh ${url}
done