Handle builds with multiple outputs correctly in Hydra channels

[?]
Oct 7, 2013, 3:06 PM
FG4JZPWS76SM2UQ7CJWO54S7SXRWPZPK4ZBIGLOVHWSJTOSCZFOQC

Dependencies

  • [2] LKPVSUCI Builds page: Remove redundant tab titles
  • [3] 6KIJX24R Get rid of unnecessary [%- and -%] tags
  • [4] L5Z6CN7M In Hydra channels, show only packages matching the user's system type
  • [5] 5NO7NCKT * Refactoring.
  • [6] BHZXGT2H * Channels: provide an index page that lists all the packages in the
  • [7] I42G2Z7P * Escape string literals.[
  • [8] PZL3SZM3 Give every page a consistent title
  • [9] HXBXDEFK Speed up channel processing
  • [10] LVJKRTIK * Generate a Nix expression for the channel.
  • [11] PMNWRTGJ Add multiple output support
  • [*] FPK5LF53 * Put the project-related actions in a separate controller. Put the
  • [*] U4TD3AIQ Add support for viewing jobset evaluations

Change contents

  • edit in src/lib/Hydra/Base/Controller/ListBuilds.pm at line 44
    [2.160]
    [5.479]
    , order_by => ["me.id", "buildoutputs.name"]
  • replacement in src/lib/Hydra/Base/Controller/NixChannel.pm at line 17
    [5.665][5.402:460](),[5.402][5.402:460](),[5.460][5.666:1110](),[5.1110][5.1045:1345](),[5.1045][5.1045:1345](),[5.1345][5.1111:1176](),[5.1176][5.1417:1424](),[5.1417][5.1417:1424]()
    foreach my $build ($c->stash->{channelBuilds}->all) {
    my $outPath = $build->get_column("outpath");
    my $outName = $build->get_column("outname");
    next if $checkValidity && !isValidPath($outPath);
    push @storePaths, $outPath;
    my $pkgName = $build->nixname . "-" . $build->system . "-" . $build->id . ($outName ne "out" ? "-" . $outName : "");
    push @{$c->stash->{nixPkgs}}, { build => $build, name => $pkgName, outPath => $outPath, outName => $outName };
    # Put the system type in the manifest (for top-level paths) as
    # a hint to the binary patch generator. (It shouldn't try to
    # generate patches between builds for different systems.) It
    # would be nice if Nix stored this info for every path but it
    # doesn't.
    $c->stash->{systemForPath}->{$outPath} = $build->system;
    };
    [5.665]
    [5.203]
    my @builds = $c->stash->{channelBuilds}->all;
    for (my $n = 0; $n < scalar @builds; ) {
    # Since channelData is a join of Builds and BuildOutputs, we
    # need to gather the rows that belong to a single build.
    my $build = $builds[$n++];
    my @outputs = ($build);
    push @outputs, $builds[$n++] while $n < scalar @builds && $builds[$n]->id == $build->id;
    @outputs = grep { $_->get_column("outpath") } @outputs;
    my $outputs = {};
    foreach my $output (@outputs) {
    my $outPath = $output->get_column("outpath");
    next if $checkValidity && !isValidPath($outPath);
    $outputs->{$output->get_column("outname")} = $outPath;
    push @storePaths, $outPath;
    # Put the system type in the manifest (for top-level
    # paths) as a hint to the binary patch generator. (It
    # shouldn't try to generate patches between builds for
    # different systems.) It would be nice if Nix stored this
    # info for every path but it doesn't.
    $c->stash->{systemForPath}->{$outPath} = $build->system;
    }
  • edit in src/lib/Hydra/Base/Controller/NixChannel.pm at line 42
    [5.204]
    [5.1425]
    next if !%$outputs;
    my $pkgName = $build->nixname . "-" . $build->system . "-" . $build->id;
    push @{$c->stash->{nixPkgs}}, { build => $build, name => $pkgName, outputs => $outputs };
    }
  • edit in src/lib/Hydra/Controller/JobsetEval.pm at line 185
    [5.4369]
    [5.4369]
    , order_by => ["build.id", "buildoutputs.name"]
  • replacement in src/lib/Hydra/View/NixExprs.pm at line 26
    [5.10956][4.20:503](),[5.381][5.1077:1113](),[4.503][5.1077:1113](),[5.1077][5.1077:1113](),[5.1113][4.504:582](),[5.468][5.1194:1234](),[4.582][5.1194:1234](),[5.1194][5.1194:1234](),[5.1234][4.583:645](),[5.539][5.1299:1331](),[4.645][5.1299:1331](),[5.1299][5.1299:1331](),[5.1331][4.646:846]()
    my $s = "";
    $s .= " # $pkg->{name}\n";
    $s .= " ${\escape $build->get_column('job')} = {\n";
    $s .= " type = \"derivation\";\n";
    $s .= " name = ${\escape ($build->get_column('releasename') or $build->nixname)};\n";
    $s .= " system = ${\escape $build->system};\n";
    $s .= " outPath = ${\escape $pkg->{outPath}};\n";
    $s .= " meta = {\n";
    $s .= " description = ${\escape $build->description};\n"
    if $build->description;
    $s .= " longDescription = ${\escape $build->longdescription};\n"
    if $build->longdescription;
    $s .= " license = ${\escape $build->license};\n"
    if $build->license;
    $s .= " maintainers = ${\escape $build->maintainers};\n"
    if $build->maintainers;
    $s .= " };\n";
    $s .= " };\n\n";
    $perSystem{$build->system} .= $s;
    [5.10956]
    [4.846]
    $perSystem{$build->system}->{$build->get_column('job')} = $pkg;
  • replacement in src/lib/Hydra/View/NixExprs.pm at line 29
    [4.853][4.853:911]()
    my $res = "{ system ? builtins.currentSystem }:\n\n";
    [4.853]
    [4.911]
    my $res = <<EOF;
    { system ? builtins.currentSystem }:
    let
    mkFakeDerivation = attrs: outputs:
    let
    outputNames = builtins.attrNames outputs;
    common = attrs // outputsSet //
    { type = "derivation";
    outputs = outputNames;
    all = outputsList;
    };
    outputToAttrListElement = outputName:
    { name = outputName;
    value = common // {
    inherit outputName;
    outPath = builtins.getAttr outputName outputs;
    };
    };
    outputsList = map outputToAttrListElement outputNames;
    outputsSet = builtins.listToAttrs outputsList;
    in outputsSet;
    in
  • edit in src/lib/Hydra/View/NixExprs.pm at line 55
    [4.912]
    [4.912]
    EOF
  • replacement in src/lib/Hydra/View/NixExprs.pm at line 61
    [4.1072][4.1072:1109]()
    $res .= $perSystem{$system};
    [4.1072]
    [4.1109]
    foreach my $job (keys $perSystem{$system}) {
    my $pkg = $perSystem{$system}->{$job};
    my $build = $pkg->{build};
    $res .= " # Hydra build ${\$build->id}\n";
    my $attr = $build->get_column('job');
    $attr =~ s/\./-/g;
    $res .= " ${\escape $attr} = (mkFakeDerivation {\n";
    $res .= " type = \"derivation\";\n";
    $res .= " name = ${\escape ($build->get_column('releasename') or $build->nixname)};\n";
    $res .= " system = ${\escape $build->system};\n";
    $res .= " meta = {\n";
    $res .= " description = ${\escape $build->description};\n"
    if $build->description;
    $res .= " longDescription = ${\escape $build->longdescription};\n"
    if $build->longdescription;
    $res .= " license = ${\escape $build->license};\n"
    if $build->license;
    $res .= " maintainers = ${\escape $build->maintainers};\n"
    if $build->maintainers;
    $res .= " };\n";
    $res .= " } {\n";
    my @outputNames = sort (keys $pkg->{outputs});
    $res .= " ${\escape $_} = ${\escape $pkg->{outputs}->{$_}};\n" foreach @outputNames;
    my $out = defined $pkg->{outputs}->{"out"} ? "out" : $outputNames[0];
    $res .= " }).$out;\n\n";
    }
  • edit in src/root/channel-contents.tt at line 63
    [3.480][5.14467:14536](),[5.4517][5.14467:14536]()
    [% IF pkg.outName != 'out' %] [[% pkg.outName %]][% END %]