Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make-system-tarball: allow alternate compression methods #37288

Merged
merged 1 commit into from Apr 4, 2018

Conversation

cleverca22
Copy link
Contributor

@cleverca22 cleverca22 commented Mar 18, 2018

Motivation for this change

sometimes an xz based tarball cant be used, and sometimes you may want to compress in parallel with pixz or pigz

Things done

added support for gzip, lzma, bzip2, parallel xz/gz
tested with nix-build nixos/release.nix -A containerTarball.x86_64-linux

  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

the stats i gathered during testing:


xz:
real: 5m, user: 4m53s, size: 118mb

pixz:
real: 1m20, user: 5m26s, size: 129m

gzip:
real: 52sec, user: 39sec, size: 209mb

pigz:
real: 26sec, user: 41sec, size: 209mb

bzip2:
real: 1m39s, user: 1m18s, size: 180mb

lzma:
real: 5m3s, user: 4m56s, size: 118mb

Copy link
Member

@disassembler disassembler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the options for building release tarballs. I built locally since I'm not sure if borg can handle arguments and everything worked as expected.

@@ -54,8 +53,8 @@ mkdir -p $out/tarball

rm env-vars

tar --sort=name --mtime='@1' --owner=0 --group=0 --numeric-owner -cvJf $out/tarball/$fileName.tar.xz * $extraArgs
time tar --sort=name --mtime='@1' --owner=0 --group=0 --numeric-owner -c * $extraArgs | $compression $compressorFlags > $out/tarball/$fileName.tar.${extension}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you intend to leave time in here or was it just for testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bit of both, with the -v gone its a bit too silent, and it could be handy to know how long just the compression phase took, since half the time is taken up by a cp

Copy link
Member

@lheckemann lheckemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! Maybe a no-compression option would be nice too.

gzip = gzip;
pigz = pigz;
bzip2 = bzip2;
lzma = lzma;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could just use inherit xz pixz gzip pigz bzip2 lzma;

@cleverca22
Copy link
Contributor Author

@grahamc

2018-03-18 11:03:15 < clever> gchristensen: how does this look to you?, and would there be any way for ofborg to check nixos/release.nix and see what has changed? https://github.com/NixOS/nixpkgs/pull/37288


inherit fileName pathsFromGraph extraArgs extraCommands;
inherit fileName pathsFromGraph extraArgs extraCommands compressorFlags;
compression = if (compression == "none") then "cat" else compression;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this in to the inputMap so there is no special case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inputMap is a list of derivations to have in buildInputs, but this one is a string, what command to pipe the tar file thru, i would need a 3rd mapping

Copy link
Member

@grahamc grahamc Mar 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps instead:

{
compression = {
  none = {
    inputs = [ ];
    extension = "";
    command = "cat";
  };
  pigz = {
    inputs = [ pigz ];
    extension = ".pigz";
    command = "pigz";
  };
};
}

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that can work

@@ -1,5 +1,4 @@
source $stdenv/setup
set -x
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was overly verbose, and i thought that this is typically only kept in when debugging things

inputMap = {
inherit xz pixz gzip pigz bzip2 lzma;
none = null;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love that this isn't extendable by the caller, but perhaps it is not necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i could also just add some more arguments, that default to looking things up in the map, so you can bypass the map easily?

@edolstra
Copy link
Member

To be honest, this seems like over-engineering. If you really need a different compression method, you can easily keep that in a local git tree.

@cleverca22
Copy link
Contributor Author

mainly wanted to avoid duplicating the code

@grahamc
Copy link
Member

grahamc commented Mar 19, 2018

Perhaps, then, the best way would be to allow overriding but not build-in the different compression algos.

@cleverca22
Copy link
Contributor Author

that can work, just move everything to arguments, and remove the mappings

# extra inputs, like the compressor to use
, extraInputs ? [ pixz ]
# flags passed to the compressor
, compressorFlags ? ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe drop compressorFlags and just pass yourcmd -abc as the command, instead of as a separate parameter. This simplifies the calling code and we don't do anything special at all with the arguments anyway. Beyond this, which is a minor nit, this LGTM.

@grahamc grahamc merged commit 9b30d48 into NixOS:master Apr 4, 2018
# Extension for the compressed tarball
, compressionExtension ? ".xz"
# extra inputs, like the compressor to use
, extraInputs ? [ pixz ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than this, compressCommand could just be ${pixz}/bin/pixz?

@cleverca22 cleverca22 deleted the improve-make-tarball branch April 4, 2018 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants