* Moved more stuff from the release tree.

svn path=/nixpkgs/trunk/; revision=13395
This commit is contained in:
Eelco Dolstra 2008-11-25 00:20:51 +00:00
parent 044c4dfe9f
commit da8bcbd9a5
4 changed files with 112 additions and 3 deletions

View File

@ -0,0 +1,53 @@
# This function compiles a source tarball in a virtual machine image
# that contains a Debian-like (i.e. dpkg-based) OS. Currently this is
# just for portability testing: it doesn't produce any Debian
# packages.
vmTools: args: with args;
vmTools.runInLinuxImage (stdenv.mkDerivation (
{
name = "debian-build";
doCheck = true;
# Don't install the result in the Nix store.
useTempPrefix = true;
phases = "sysInfoPhase unpackPhase patchPhase configurePhase buildPhase checkPhase installPhase distPhase";
}
// args //
{
src = src.path;
# !!! cut&paste from rpm-build.nix
postHook = ''
ensureDir $out/nix-support
cat "$diskImage"/nix-support/full-name > $out/nix-support/full-name
# If `src' is the result of a call to `makeSourceTarball', then it
# has a subdirectory containing the actual tarball(s). If there are
# multiple tarballs, just pick the first one.
echo $src
if test -d $src/tarballs; then
src=$(ls $src/tarballs/*.tar.bz2 $src/tarballs/*.tar.gz | sort | head -1)
fi
''; # */
sysInfoPhase = ''
echo "System/kernel: $(uname -a)"
if test -e /etc/debian_version; then echo "Debian release: $(cat /etc/debian_version)"; fi
header "installed Debian packages"
dpkg-query --list
stopNest
'';
meta = {
description = "Test build on ${args.diskImage.fullName} (${args.diskImage.name})";
};
}
))

View File

@ -17,4 +17,10 @@ rec {
doCoverageAnalysis = true;
} // args);
}
rpmBuild = args: import ./rpm-build.nix vmTools args;
debBuild = args: import ./debian-build.nix vmTools (
{ inherit stdenv;
} // args);
}

View File

@ -0,0 +1,41 @@
# This function builds an RPM from a source tarball that contains a
# RPM spec file (i.e., one that can be built using `rpmbuild -ta').
vmTools: args: with args;
vmTools.buildRPM (
{
name = "rpm-build";
}
// args //
{
src = src.path;
preBuild = ''
ensureDir $out/nix-support
cat "$diskImage"/nix-support/full-name > $out/nix-support/full-name
# If `src' is the result of a call to `makeSourceTarball', then it
# has a subdirectory containing the actual tarball(s). If there are
# multiple tarballs, just pick the first one.
if test -d $src/tarballs; then
src=$(ls $src/tarballs/*.tar.bz2 $src/tarballs/*.tar.gz | sort | head -1)
fi
''; # */
postInstall = ''
shopt -s nullglob
for i in $out/rpms/*/*.rpm; do
echo "file rpm $i" >> $out/nix-support/hydra-build-products
done
''; # */
meta = {
description = "Build of an RPM package on ${args.diskImage.fullName} (${args.diskImage.name})";
};
}
)

View File

@ -233,6 +233,15 @@ rec {
'';
modifyDerivation = f: attrs:
let attrsCleaned = removeAttrs attrs ["meta" "passthru" "outPath" "drvPath"];
newDrv = derivation (attrsCleaned // (f attrs));
in newDrv //
{ meta = if attrs ? meta then attrs.meta else {};
passthru = if attrs ? passthru then attrs.passthru else {};
};
/* Run a derivation in a Linux virtual machine (using Qemu/KVM). By
default, there is no disk image; the root filesystem is a tmpfs,
and /nix/store is shared with the host (via the CIFS protocol to
@ -254,7 +263,7 @@ rec {
`run-vm' will be left behind in the temporary build directory
that allows you to boot into the VM and debug it interactively. */
runInLinuxVM = attrs: derivation (removeAttrs attrs ["meta" "passthru" "outPath" "drvPath"] // {
runInLinuxVM = modifyDerivation (attrs: {
builder = "${bash}/bin/sh";
args = ["-e" (vmRunCommand qemuCommandLinux)];
origArgs = attrs.args;
@ -289,7 +298,7 @@ rec {
- Reboot to shutdown the machine (because Qemu doesn't seem
capable of a APM/ACPI VM shutdown).
*/
runInGenericVM = attrs: derivation (removeAttrs attrs ["meta" "passthru" "outPath" "drvPath"] // {
runInGenericVM = modifyDerivation (attrs: {
system = "i686-linux";
builder = "${bash}/bin/sh";
args = ["-e" (vmRunCommand qemuCommandGeneric)];