hydra-queue-runner: Compress binary cache NARs using xz

[?]
Feb 15, 2016, 8:56 PM
3FQ65IXOIAWKEV67IXY7WRUX4OGMDYRA3RZJ2XPZ42AZXUANQ74QC

Dependencies

  • [2] 73YR46NJ hydra-queue-runner: Write directly to a binary cache

Change contents

  • edit in src/hydra-queue-runner/local-binary-cache.cc at line 4
    [2.1936]
    [2.1936]
    #include "compression.hh"
  • edit in src/hydra-queue-runner/local-binary-cache.cc at line 36
    [2.2806]
    [2.2806]
    Path narInfoFile = narInfoFileFor(info.path);
    if (pathExists(narInfoFile)) return;
  • edit in src/hydra-queue-runner/local-binary-cache.cc at line 47
    [2.3170]
    [2.3170]
    /* Compress the NAR. */
    string narXz = compressXZ(nar);
    Hash narXzHash = hashString(htSHA256, narXz);
  • replacement in src/hydra-queue-runner/local-binary-cache.cc at line 53
    [2.3212][2.3212:3274]()
    string narFileRel = "nar/" + printHash(narHash) + ".nar";
    [2.3212]
    [2.3274]
    string narFileRel = "nar/" + printHash32(narXzHash) + ".nar.xz";
  • replacement in src/hydra-queue-runner/local-binary-cache.cc at line 55
    [2.3328][2.3328:3385]()
    if (!pathExists(narFile)) atomicWrite(narFile, nar);
    [2.3328]
    [2.3385]
    if (!pathExists(narFile)) atomicWrite(narFile, narXz);
  • replacement in src/hydra-queue-runner/local-binary-cache.cc at line 58
    [2.3431][2.3431:3481]()
    Path narInfoFile = narInfoFileFor(info.path);
    [2.3431]
    [2.3481]
    Strings refs;
    for (auto & r : info.references)
    refs.push_back(baseNameOf(r));
  • replacement in src/hydra-queue-runner/local-binary-cache.cc at line 62
    [2.3482][2.3482:3518]()
    if (!pathExists(narInfoFile)) {
    [2.3482]
    [2.3518]
    std::string narInfo;
    narInfo += "StorePath: " + info.path + "\n";
    narInfo += "URL: " + narFileRel + "\n";
    narInfo += "Compression: xz\n";
    narInfo += "FileHash: sha256:" + printHash32(narXzHash) + "\n";
    narInfo += "FileSize: " + std::to_string(narXz.size()) + "\n";
    narInfo += "NarHash: sha256:" + printHash32(narHash) + "\n";
    narInfo += "NarSize: " + std::to_string(narSize) + "\n";
    narInfo += "References: " + concatStringsSep(" ", refs) + "\n";
  • replacement in src/hydra-queue-runner/local-binary-cache.cc at line 72
    [2.3519][2.3519:4136]()
    Strings refs;
    for (auto & r : info.references)
    refs.push_back(baseNameOf(r));
    std::string narInfo;
    narInfo += "StorePath: " + info.path + "\n";
    narInfo += "URL: " + narFileRel + "\n";
    narInfo += "Compression: none\n";
    narInfo += "FileHash: sha256:" + printHash(narHash) + "\n";
    narInfo += "FileSize: " + std::to_string(narSize) + "\n";
    narInfo += "NarHash: sha256:" + printHash(narHash) + "\n";
    narInfo += "NarSize: " + std::to_string(narSize) + "\n";
    narInfo += "References: " + concatStringsSep(" ", refs) + "\n";
    [2.3519]
    [2.4136]
    // FIXME: add signature
  • replacement in src/hydra-queue-runner/local-binary-cache.cc at line 74
    [2.4137][2.4137:4219]()
    // FIXME: add signature
    atomicWrite(narInfoFile, narInfo);
    }
    [2.4137]
    [2.4219]
    atomicWrite(narInfoFile, narInfo);
  • edit in src/hydra-queue-runner/local-binary-cache.cc at line 117
    [2.5476]
    [2.5476]
    else if (name == "Compression") {
    res.compression = value;
    }
  • edit in src/hydra-queue-runner/local-binary-cache.cc at line 145
    [2.6028]
    [2.6028]
    /* Decompress the NAR. FIXME: would be nice to have the remote
    side do this. */
    if (res.compression == "none")
    ;
    else if (res.compression == "xz")
    nar = decompressXZ(nar);
    else
    throw Error(format("unknown NAR compression type ‘%1%’") % nar);
  • edit in src/hydra-queue-runner/local-binary-cache.hh at line 27
    [2.9712]
    [2.9712]
    std::string compression = "none";