diff --git a/pkgs/development/python-modules/b2sdk/default.nix b/pkgs/development/python-modules/b2sdk/default.nix index a878a17b0f2a..d78a2b57a934 100644 --- a/pkgs/development/python-modules/b2sdk/default.nix +++ b/pkgs/development/python-modules/b2sdk/default.nix @@ -4,6 +4,7 @@ , fetchFromGitHub , glibcLocales , importlib-metadata +, packaging , logfury , pyfakefs , pytestCheckHook @@ -41,6 +42,7 @@ buildPythonPackage rec { ]; propagatedBuildInputs = [ + packaging logfury requests tqdm diff --git a/pkgs/tools/backup/duplicity/default.nix b/pkgs/tools/backup/duplicity/default.nix index 452fab128e14..1da3131f85b0 100644 --- a/pkgs/tools/backup/duplicity/default.nix +++ b/pkgs/tools/backup/duplicity/default.nix @@ -11,40 +11,48 @@ , rsync , makeWrapper , gettext +, getconf +, testers +, nix-update-script }: -python3.pkgs.buildPythonApplication rec { +let self = python3.pkgs.buildPythonApplication rec { pname = "duplicity"; - version = "0.8.23"; + version = "2.2.3"; src = fetchFromGitLab { owner = "duplicity"; repo = "duplicity"; rev = "rel.${version}"; - sha256 = "0my015zc8751smjgbsysmca7hvdm96cjw5zilqn3zq971nmmrksb"; + hash = "sha256-4IwKqXlG7jh1siuPT5pVgiYB+KlmCzF6+OMPT3I3yTQ="; }; patches = [ - # We use the tar binary on all platforms. - ./gnutar-in-test.patch - - # Our Python infrastructure runs test in installCheckPhase so we need - # to make the testing code stop assuming it is run from the source directory. - ./use-installed-scripts-in-test.patch - ] ++ lib.optionals stdenv.isLinux [ - # Broken on Linux in Nix' build environment - ./linux-disable-timezone-test.patch + ./keep-pythonpath-in-testing.patch ]; - preConfigure = '' - # fix version displayed by duplicity --version - # see SourceCopy in setup.py - ls - for i in bin/*.1 duplicity/__init__.py; do - substituteInPlace "$i" --replace '$version' "${version}" - done + postPatch = '' + patchShebangs duplicity/__main__.py + + # don't try to use gtar on darwin/bsd + substituteInPlace testing/functional/test_restart.py \ + --replace-fail 'tarcmd = "gtar"' 'tarcmd = "tar"' + '' + lib.optionalString stdenv.isDarwin '' + # tests try to access these files in the sandbox, but can't deal with EPERM + substituteInPlace testing/unit/test_globmatch.py \ + --replace-fail /var/log /test/log + substituteInPlace testing/unit/test_selection.py \ + --replace-fail /usr/bin /dev + # don't use /tmp/ in tests + substituteInPlace duplicity/backends/_testbackend.py \ + --replace-fail '"/tmp/' 'os.environ.get("TMPDIR")+"/' ''; + disabledTests = lib.optionals stdenv.isDarwin [ + # uses /tmp/ + "testing/unit/test_cli_main.py::CommandlineTest::test_intermixed_args" + ]; + nativeBuildInputs = [ makeWrapper gettext @@ -80,51 +88,54 @@ python3.pkgs.buildPythonApplication rec { par2cmdline # Add 'par2' to PATH. ] ++ lib.optionals stdenv.isLinux [ util-linux # Add 'setsid' to PATH. + ] ++ lib.optionals stdenv.isDarwin [ + getconf ] ++ (with python3.pkgs; [ lockfile mock pexpect pytest pytest-runner + fasteners ]); - postInstall = '' + postInstall = let + binPath = lib.makeBinPath ([ + gnupg + ncftp + rsync + ] ++ lib.optionals stdenv.isDarwin [ + getconf + ]); in '' wrapProgram $out/bin/duplicity \ - --prefix PATH : "${lib.makeBinPath [ gnupg ncftp rsync ]}" + --prefix PATH : "${binPath}" ''; preCheck = '' + # tests need writable $HOME + HOME=$PWD/.home + wrapPythonProgramsIn "$PWD/testing/overrides/bin" "$pythonPath" - - # Add 'duplicity' to PATH for tests. - # Normally, 'setup.py test' adds 'build/scripts-2.7/' to PATH before running - # tests. However, 'build/scripts-2.7/duplicity' is not wrapped, so its - # shebang is incorrect and it fails to run inside Nix' sandbox. - # In combination with use-installed-scripts-in-test.patch, make 'setup.py - # test' use the installed 'duplicity' instead. - PATH="$out/bin:$PATH" - - # Don't run developer-only checks (pep8, etc.). - export RUN_CODE_TESTS=0 - - # check version string - duplicity --version | grep ${version} - '' + lib.optionalString stdenv.isDarwin '' - # Work around the following error when running tests: - # > Max open files of 256 is too low, should be >= 1024. - # > Use 'ulimit -n 1024' or higher to correct. - ulimit -n 1024 ''; - # TODO: Fix test failures on macOS 10.13: - # - # > OSError: out of pty devices - doCheck = !stdenv.isDarwin; + doCheck = true; + + passthru = { + updateScript = nix-update-script { + extraArgs = [ "--version-regex" "rel\.(.*)" ]; + }; + + tests.version = testers.testVersion { + package = self; + }; + }; meta = with lib; { description = "Encrypted bandwidth-efficient backup using the rsync algorithm"; homepage = "https://duplicity.gitlab.io/duplicity-web/"; license = licenses.gpl2Plus; - maintainers = with maintainers; [ ]; + maintainers = with maintainers; [ corngood ]; }; -} +}; + +in self diff --git a/pkgs/tools/backup/duplicity/gnutar-in-test.patch b/pkgs/tools/backup/duplicity/gnutar-in-test.patch deleted file mode 100644 index ee95b68e2abb..000000000000 --- a/pkgs/tools/backup/duplicity/gnutar-in-test.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/testing/functional/test_restart.py b/testing/functional/test_restart.py -index 6d972c82..e8435fd5 100644 ---- a/testing/functional/test_restart.py -+++ b/testing/functional/test_restart.py -@@ -350,14 +350,7 @@ class RestartTestWithoutEncryption(RestartTest): - https://launchpad.net/bugs/929067 - """ - -- if platform.system().startswith(u'Linux'): -- tarcmd = u"tar" -- elif platform.system().startswith(u'Darwin'): -- tarcmd = u"gtar" -- elif platform.system().endswith(u'BSD'): -- tarcmd = u"gtar" -- else: -- raise Exception(u"Platform %s not supported by tar/gtar." % platform.platform()) -+ tarcmd = u"tar" - - # Intial normal backup - self.backup(u"full", u"{0}/testfiles/blocktartest".format(_runtest_dir)) diff --git a/pkgs/tools/backup/duplicity/keep-pythonpath-in-testing.patch b/pkgs/tools/backup/duplicity/keep-pythonpath-in-testing.patch new file mode 100644 index 000000000000..c0cc6a2226d1 --- /dev/null +++ b/pkgs/tools/backup/duplicity/keep-pythonpath-in-testing.patch @@ -0,0 +1,15 @@ +diff --git a/testing/functional/__init__.py b/testing/functional/__init__.py +index 6c82d2c7..22163fa3 100644 +--- a/testing/functional/__init__.py ++++ b/testing/functional/__init__.py +@@ -94,8 +94,8 @@ class FunctionalTestCase(DuplicityTestCase): + for item in passphrase_input: + assert isinstance(item, str), f"item {os.fsdecode(item)} in passphrase_input is not unicode" + +- # set python path to be dev directory +- os.environ["PYTHONPATH"] = _top_dir ++ # prepend dev directory to python path ++ os.environ["PYTHONPATH"] = _top_dir + ":" + os.environ["PYTHONPATH"] + + cmd_list = [] + diff --git a/pkgs/tools/backup/duplicity/linux-disable-timezone-test.patch b/pkgs/tools/backup/duplicity/linux-disable-timezone-test.patch deleted file mode 100644 index e322625cdbf4..000000000000 --- a/pkgs/tools/backup/duplicity/linux-disable-timezone-test.patch +++ /dev/null @@ -1,16 +0,0 @@ -commit f0142706c377b7c133753db57b5c4c90baa2de30 -Author: Guillaume Girol -Date: Sun Jul 11 17:48:15 2021 +0200 - -diff --git a/testing/unit/test_statistics.py b/testing/unit/test_statistics.py -index 4be5000c..80545853 100644 ---- a/testing/unit/test_statistics.py -+++ b/testing/unit/test_statistics.py -@@ -63,6 +63,7 @@ class StatsObjTest(UnitTestCase): - s1 = StatsDeltaProcess() - assert s1.get_stat(u'SourceFiles') == 0 - -+ @unittest.skip("Broken on Linux in Nix' build environment") - def test_get_stats_string(self): - u"""Test conversion of stat object into string""" - s = StatsObj() diff --git a/pkgs/tools/backup/duplicity/use-installed-scripts-in-test.patch b/pkgs/tools/backup/duplicity/use-installed-scripts-in-test.patch deleted file mode 100644 index a5ddc4381bd8..000000000000 --- a/pkgs/tools/backup/duplicity/use-installed-scripts-in-test.patch +++ /dev/null @@ -1,63 +0,0 @@ -commit ccd4dd92cd37acce1da20966ad9e4e0c7bcf1709 -Author: Guillaume Girol -Date: Sun Jul 11 12:00:00 2021 +0000 - - use installed duplicity when running tests - -diff --git a/setup.py b/setup.py -index fa474f20..604a242a 100755 ---- a/setup.py -+++ b/setup.py -@@ -205,10 +205,6 @@ class TestCommand(test): - except Exception: - pass - -- os.environ[u'PATH'] = u"%s:%s" % ( -- os.path.abspath(build_scripts_cmd.build_dir), -- os.environ.get(u'PATH')) -- - test.run(self) - - -diff --git a/testing/functional/__init__.py b/testing/functional/__init__.py -index 4221576d..3cf44945 100644 ---- a/testing/functional/__init__.py -+++ b/testing/functional/__init__.py -@@ -111,7 +111,7 @@ class FunctionalTestCase(DuplicityTestCase): - run_coverage = os.environ.get(u'RUN_COVERAGE', None) - if run_coverage is not None: - cmd_list.extend([u"-m", u"coverage", u"run", u"--source=duplicity", u"-p"]) -- cmd_list.extend([u"{0}/bin/duplicity".format(_top_dir)]) -+ cmd_list.extend([u"duplicity"]) - cmd_list.extend(options) - cmd_list.extend([u"-v0"]) - cmd_list.extend([u"--no-print-statistics"]) -diff --git a/testing/functional/test_log.py b/testing/functional/test_log.py -index 9dfc86a6..b9cb55db 100644 ---- a/testing/functional/test_log.py -+++ b/testing/functional/test_log.py -@@ -49,9 +49,9 @@ class LogTest(FunctionalTestCase): - # Run actual duplicity command (will fail, because no arguments passed) - basepython = os.environ.get(u'TOXPYTHON', None) - if basepython is not None: -- os.system(u"{0} {1}/bin/duplicity --log-file={2} >/dev/null 2>&1".format(basepython, _top_dir, self.logfile)) -+ os.system(u"{0} duplicity --log-file={1} >/dev/null 2>&1".format(basepython, self.logfile)) - else: -- os.system(u"{0}/bin/duplicity --log-file={1} >/dev/null 2>&1".format(_top_dir, self.logfile)) -+ os.system(u"duplicity --log-file={0} >/dev/null 2>&1".format(self.logfile)) - - # The format of the file should be: - # """ERROR 2 -diff --git a/testing/functional/test_rdiffdir.py b/testing/functional/test_rdiffdir.py -index 0cbfdb33..47acd029 100644 ---- a/testing/functional/test_rdiffdir.py -+++ b/testing/functional/test_rdiffdir.py -@@ -44,7 +44,7 @@ class RdiffdirTest(FunctionalTestCase): - basepython = os.environ.get(u'TOXPYTHON', None) - if basepython is not None: - cmd_list.extend([basepython]) -- cmd_list.extend([u"{0}/bin/rdiffdir".format(_top_dir)]) -+ cmd_list.extend([u"rdiffdir"]) - cmd_list.extend(argstring.split()) - cmdline = u" ".join([u'"%s"' % x for x in cmd_list]) - self.run_cmd(cmdline) diff --git a/pkgs/tools/networking/ncftp/default.nix b/pkgs/tools/networking/ncftp/default.nix index 02dd29c0fda5..c31e6333b684 100644 --- a/pkgs/tools/networking/ncftp/default.nix +++ b/pkgs/tools/networking/ncftp/default.nix @@ -17,7 +17,12 @@ stdenv.mkDerivation rec { # gcc-10. Otherwise build fails as: # ld: bookmark.o: (.bss+0x20): multiple definition of `gBm'; # gpshare.o:(.bss+0x0): first defined here - env.NIX_CFLAGS_COMPILE = "-fcommon"; + env.NIX_CFLAGS_COMPILE = toString ([ "-fcommon" ] + # these are required for the configure script to work with clang + ++ lib.optionals stdenv.isDarwin [ + "-Wno-implicit-int" + "-Wno-implicit-function-declaration" + ]); preConfigure = '' find -name Makefile.in | xargs sed -i '/^TMPDIR=/d'