duplicity: 0.8.23 -> 2.2.3

Fixes: #286749
This commit is contained in:
David McFarland 2024-03-26 22:51:32 -03:00
parent f1be43a54e
commit a6ae6b07d7
5 changed files with 66 additions and 144 deletions

View File

@ -11,40 +11,47 @@
, rsync
, makeWrapper
, gettext
, getconf
, testers
}:
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,46 +87,43 @@ 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 = {
tests.version = testers.testVersion {
package = self;
};
};
meta = with lib; {
description = "Encrypted bandwidth-efficient backup using the rsync algorithm";
@ -127,4 +131,6 @@ python3.pkgs.buildPythonApplication rec {
license = licenses.gpl2Plus;
maintainers = with maintainers; [ ];
};
}
};
in self

View File

@ -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))

View File

@ -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 = []

View File

@ -1,16 +0,0 @@
commit f0142706c377b7c133753db57b5c4c90baa2de30
Author: Guillaume Girol <symphorien+git@xlumurb.eu>
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()

View File

@ -1,63 +0,0 @@
commit ccd4dd92cd37acce1da20966ad9e4e0c7bcf1709
Author: Guillaume Girol <symphorien+git@xlumurb.eu>
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)