[Nix-dev] Re: [Nix-commits] SVN commit: nix - r23483 - in nix/branches/sqlite: scripts src/libstore src/libutil
maggesi at math.unifi.it
maggesi at math.unifi.it
Sat Aug 28 21:27:02 CEST 2010
Interesting!
I have the following use in mind for this feature: build derivations
that use blcr (which also needs features in the kernel) to produce
checkpointed binaries.
HOL Light binaries is the only relevant example of such a derivation
for me now.
M.
Quoting Eelco Dolstra <e.dolstra at tudelft.nl>:
> Author: eelco
> Date: Fri Aug 27 13:18:13 2010
> New Revision: 23483
> URL: https://svn.nixos.org/websvn/nix/?rev=23483&sc=1
>
> Log:
> * Experimental feature: allow a derivation to tell the build hook that
> it requires a certain feature on the build machine, e.g.
>
> requiredSystemFeatures = [ "kvm" ];
>
> We need this in Hydra to make sure that builds that require KVM
> support are forwarded to machines that have KVM support. Probably
> this should also be enforced for local builds.
>
> Modified:
> nix/branches/sqlite/scripts/build-remote.pl.in
> nix/branches/sqlite/src/libstore/build.cc
> nix/branches/sqlite/src/libutil/util.cc
> nix/branches/sqlite/src/libutil/util.hh
>
> Modified: nix/branches/sqlite/scripts/build-remote.pl.in
> ==============================================================================
> --- nix/branches/sqlite/scripts/build-remote.pl.in Fri Aug 27
> 12:10:56 2010 (r23482)
> +++ nix/branches/sqlite/scripts/build-remote.pl.in Fri Aug 27
> 13:18:13 2010 (r23483)
> @@ -36,6 +36,8 @@
> print STDERR "# $reply\n";
> }
>
> +sub all { $_ || return 0 for @_; 1 }
> +
>
> # Initialisation.
> my $loadIncreased = 0;
> @@ -64,13 +66,14 @@
> chomp;
> s/\#.*$//g;
> next if /^\s*$/;
> - /^\s*(\S+)\s+(\S+)\s+(\S+)\s+(\d+)(\s+([0-9\.]+))?\s*$/ or die;
> + my @tokens = split /\s/, $_;
> push @machines,
> - { hostName => $1
> - , systemTypes => [split(/,/, $2)]
> - , sshKeys => $3
> - , maxJobs => $4
> - , speedFactor => 1.0 * ($6 || 1)
> + { hostName => $tokens[0]
> + , systemTypes => [ split(/,/, $tokens[1]) ]
> + , sshKeys => $tokens[2]
> + , maxJobs => int($tokens[3])
> + , speedFactor => 1.0 * (defined $tokens[4] ?
> int($tokens[4]) : 1)
> + , features => [ split(/,/, $tokens[5] || "") ]
> , enabled => 1
> };
> }
> @@ -85,7 +88,8 @@
> REQ: while (1) {
> $_ = <STDIN> || exit 0;
> my ($amWilling, $neededSystem);
> - ($amWilling, $neededSystem, $drvPath) = split;
> + ($amWilling, $neededSystem, $drvPath, $requiredFeatures) = split;
> + my @requiredFeatures = split /,/, $requiredFeatures;
>
> my $canBuildLocally = $amWilling && ($localSystem eq $neededSystem);
>
> @@ -103,12 +107,15 @@
>
> while (1) {
> # Find all machine that can execute this build, i.e., that
> - # support builds for the given platform and are not at their
> - # job limit.
> + # support builds for the given platform and features, and are
> + # not at their job limit.
> my $rightType = 0;
> my @available = ();
> LOOP: foreach my $cur (@machines) {
> - if ($cur->{enabled} && grep { $neededSystem eq $_ }
> @{$cur->{systemTypes}}) {
> + if ($cur->{enabled}
> + && (grep { $neededSystem eq $_ } @{$cur->{systemTypes}})
> + && all(map { my $f = $_; 0 != grep { $f eq $_ }
> @{$cur->{features}} } @requiredFeatures))
> + {
> $rightType = 1;
>
> # We have a machine of the right type. Determine
> the load on
>
> Modified: nix/branches/sqlite/src/libstore/build.cc
> ==============================================================================
> --- nix/branches/sqlite/src/libstore/build.cc Fri Aug 27 12:10:56
> 2010 (r23482)
> +++ nix/branches/sqlite/src/libstore/build.cc Fri Aug 27 13:18:13
> 2010 (r23483)
> @@ -1327,8 +1327,16 @@
> if (!worker.hook)
> worker.hook = boost::shared_ptr<HookInstance>(new HookInstance);
>
> - writeLine(worker.hook->toHook.writeSide, (format("%1% %2% %3%") %
> - (worker.getNrLocalBuilds() < maxBuildJobs ? "1" : "0") %
> drv.platform % drvPath).str());
> + /* Tell the hook about system features (beyond the system type)
> + required from the build machine. (The hook could parse the
> + drv file itself, but this is easier.) */
> + Strings features = tokenizeString(drv.env["requiredSystemFeatures"]);
> + foreach (Strings::iterator, i, features) checkStoreName(*i); /*
> !!! abuse */
> +
> + /* Send the request to the hook. */
> + writeLine(worker.hook->toHook.writeSide, (format("%1% %2% %3% %4%")
> + % (worker.getNrLocalBuilds() < maxBuildJobs ? "1" : "0")
> + % drv.platform % drvPath % concatStringsSep(",", features)).str());
>
> /* Read the first line of input, which should be a word indicating
> whether the hook wishes to perform the build. */
>
> Modified: nix/branches/sqlite/src/libutil/util.cc
> ==============================================================================
> --- nix/branches/sqlite/src/libutil/util.cc Fri Aug 27 12:10:56 2010 (r23482)
> +++ nix/branches/sqlite/src/libutil/util.cc Fri Aug 27 13:18:13 2010 (r23483)
> @@ -966,6 +966,17 @@
> }
>
>
> +string concatStringsSep(const string & sep, const Strings & ss)
> +{
> + string s;
> + foreach (Strings::const_iterator, i, ss) {
> + if (s.size() != 0) s += sep;
> + s += *i;
> + }
> + return s;
> +}
> +
> +
> string statusToString(int status)
> {
> if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
>
> Modified: nix/branches/sqlite/src/libutil/util.hh
> ==============================================================================
> --- nix/branches/sqlite/src/libutil/util.hh Fri Aug 27 12:10:56 2010 (r23482)
> +++ nix/branches/sqlite/src/libutil/util.hh Fri Aug 27 13:18:13 2010 (r23483)
> @@ -280,6 +280,11 @@
> Strings tokenizeString(const string & s, const string & separators
> = " \t\n\r");
>
>
> +/* Concatenate the given strings with a separator between the
> + elements. */
> +string concatStringsSep(const string & sep, const Strings & ss);
> +
> +
> /* Convert the exit status of a child as returned by wait() into an
> error string. */
> string statusToString(int status);
> _______________________________________________
> nix-commits mailing list
> nix-commits at cs.uu.nl
> http://mail.cs.uu.nl/mailman/listinfo/nix-commits
>
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
More information about the nix-dev
mailing list