diff --git a/pkgs/build-support/release/debian-build.nix b/pkgs/build-support/release/debian-build.nix new file mode 100644 index 00000000000..96efd1913cc --- /dev/null +++ b/pkgs/build-support/release/debian-build.nix @@ -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})"; + }; + } + +)) diff --git a/pkgs/build-support/release/default.nix b/pkgs/build-support/release/default.nix index 6156dd2933a..dd46164d9f2 100644 --- a/pkgs/build-support/release/default.nix +++ b/pkgs/build-support/release/default.nix @@ -17,4 +17,10 @@ rec { doCoverageAnalysis = true; } // args); -} \ No newline at end of file + rpmBuild = args: import ./rpm-build.nix vmTools args; + + debBuild = args: import ./debian-build.nix vmTools ( + { inherit stdenv; + } // args); + +} diff --git a/pkgs/build-support/release/rpm-build.nix b/pkgs/build-support/release/rpm-build.nix new file mode 100644 index 00000000000..b9e0d7c508c --- /dev/null +++ b/pkgs/build-support/release/rpm-build.nix @@ -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})"; + }; + } + +) diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix index 10d353422f8..427e7dc58ff 100644 --- a/pkgs/build-support/vm/default.nix +++ b/pkgs/build-support/vm/default.nix @@ -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)];