From 0697dd8b8105714a3acecc431954072492a66383 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Wed, 31 May 2017 05:53:29 +0200 Subject: [PATCH] pythonPackages.rarfile: use free libarchive by default. `unrar` is a non-free package, so it should only be used on request. rarfile can use the rar-mode of `libarchive` instead, which should work well enough for most cases. --- .../python-modules/rarfile/default.nix | 20 ++++++++++++++++--- pkgs/top-level/python-packages.nix | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pkgs/development/python-modules/rarfile/default.nix b/pkgs/development/python-modules/rarfile/default.nix index 183e5a2f1d93..c2c8c926432a 100644 --- a/pkgs/development/python-modules/rarfile/default.nix +++ b/pkgs/development/python-modules/rarfile/default.nix @@ -1,4 +1,10 @@ -{ stdenv, buildPythonPackage, fetchFromGitHub, pytest, nose, unrar, glibcLocales }: +{ stdenv, buildPythonPackage, fetchFromGitHub, pytest, nose, libarchive, glibcLocales +# unrar is non-free software +, useUnrar ? false, unrar +}: + +assert useUnrar -> unrar != null; +assert !useUnrar -> libarchive != null; buildPythonPackage rec { pname = "rarfile"; @@ -15,8 +21,16 @@ buildPythonPackage rec { prePatch = '' substituteInPlace rarfile.py \ - --replace 'UNRAR_TOOL = "unrar"' "UNRAR_TOOL = \"${unrar}/bin/unrar\"" - ''; + '' + (if useUnrar then + ''--replace 'UNRAR_TOOL = "unrar"' "UNRAR_TOOL = \"${unrar}/bin/unrar\"" + '' + else + ''--replace 'ALT_TOOL = "bsdtar"' "ALT_TOOL = \"${libarchive}/bin/bsdtar\"" + '') + + '' + ''; + # the tests only work with the standard unrar package + doCheck = useUnrar; LC_ALL = "en_US.UTF-8"; checkPhase = '' py.test test -k "not test_printdir" diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 107fd715b948..0c6318b79059 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2603,7 +2603,7 @@ in { }; - rarfile = callPackage ../development/python-modules/rarfile {}; + rarfile = callPackage ../development/python-modules/rarfile { inherit (pkgs) libarchive; }; proboscis = buildPythonPackage rec { name = "proboscis-1.2.6.0";