termux-packages/packages/borgbackup/use-distutils.patch

132 lines
4.7 KiB
Diff

From 2ae2e3a15fa3e361b5f2e186d2450a8ccd38f698 Mon Sep 17 00:00:00 2001
From: Leonid Pliushch <leonid.pliushch@gmail.com>
Date: Mon, 26 Jul 2021 13:30:08 +0300
Subject: [PATCH] Termux borgbackup: use distutils instead of packaging
Do not remove this patch unless you know what you are doing!
We don't have module "packaging" packaged and thus cannot use it without
installing through "pip". But for stable packages we cannot use it in
postinst script to add missing dependencies.
So if you decide to drop this patch:
* Add python3-packaging to termux-packages.
* Alternatively: create a postinst deb script (pip3 install packaging)
and move borgbackup to https://github.com/termux/unstable-packages
---
setup.py | 24 ++++++++----------------
src/borg/__init__.py | 5 ++---
src/borg/xattr.py | 6 +++---
3 files changed, 13 insertions(+), 22 deletions(-)
diff --git a/setup.py b/setup.py
index 87e93d25..5ca79af2 100644
--- a/setup.py
+++ b/setup.py
@@ -37,9 +37,7 @@
# Are we building on ReadTheDocs?
on_rtd = os.environ.get('READTHEDOCS')
-install_requires = [
- 'packaging',
-]
+install_requires = []
# note for package maintainers: if you package borgbackup for distribution,
# please add llfuse as a *requirement* on all platforms that have a working
@@ -54,8 +52,10 @@
],
}
-from setuptools import setup, find_packages, Extension, Command
+from setuptools import setup, find_packages, Extension
from setuptools.command.sdist import sdist
+from distutils.core import Command
+from distutils.command.clean import clean
compress_source = 'src/borg/compress.pyx'
crypto_ll_source = 'src/borg/crypto/low_level.pyx'
@@ -146,7 +146,7 @@ def __init__(self, *args, **kwargs):
msgpack_packer_source = msgpack_packer_source.replace('.pyx', '.cpp')
msgpack_unpacker_source = msgpack_unpacker_source.replace('.pyx', '.cpp')
- from setuptools.command.build_ext import build_ext
+ from distutils.command.build_ext import build_ext
if not on_rtd and not all(os.path.exists(path) for path in [
compress_source, crypto_ll_source, chunker_source, hashindex_source, item_source, checksums_source,
platform_posix_source, platform_linux_source, platform_syncfilerange_source, platform_freebsd_source, platform_darwin_source,
@@ -767,16 +767,9 @@ def rm(file):
pass
-class Clean(Command):
- user_options = []
-
- def initialize_options(self):
- pass
-
- def finalize_options(self):
- pass
-
+class Clean(clean):
def run(self):
+ super().run()
for source in cython_c_sources:
genc = source.replace('.pyx', '.c')
rm(genc)
@@ -793,7 +786,7 @@ def run(self):
'build_usage': build_usage,
'build_man': build_man,
'sdist': Sdist,
- 'clean2': Clean,
+ 'clean': Clean,
}
ext_modules = []
diff --git a/src/borg/__init__.py b/src/borg/__init__.py
index 9f13c7d6..47adb1b6 100644
--- a/src/borg/__init__.py
+++ b/src/borg/__init__.py
@@ -1,12 +1,11 @@
-from packaging.version import parse as parse_version
+from distutils.version import LooseVersion
# IMPORTANT keep imports from borg here to a minimum because our testsuite depends on
# being able to import borg.constants and then monkey patching borg.constants.PBKDF2_ITERATIONS
from ._version import version as __version__
-_v = parse_version(__version__)
-__version_tuple__ = _v._version.release
+__version_tuple__ = tuple(LooseVersion(__version__).version[:3])
# assert that all semver components are integers
# this is mainly to show errors when people repackage poorly
diff --git a/src/borg/xattr.py b/src/borg/xattr.py
index f611a80a..8f77ab95 100644
--- a/src/borg/xattr.py
+++ b/src/borg/xattr.py
@@ -8,7 +8,7 @@
import tempfile
from ctypes import CDLL, create_string_buffer, c_ssize_t, c_size_t, c_char_p, c_int, c_uint32, get_errno
from ctypes.util import find_library
-from packaging.version import parse as parse_version
+from distutils.version import LooseVersion
from .helpers import Buffer, prepare_subprocess_env
@@ -91,8 +91,8 @@ def get_all(path, follow_symlinks=True):
if preload.startswith("libfakeroot"):
env = prepare_subprocess_env(system=True)
fakeroot_output = subprocess.check_output(['fakeroot', '-v'], env=env)
- fakeroot_version = parse_version(fakeroot_output.decode('ascii').split()[-1])
- if fakeroot_version >= parse_version("1.20.2"):
+ fakeroot_version = LooseVersion(fakeroot_output.decode('ascii').split()[-1])
+ if fakeroot_version >= LooseVersion("1.20.2"):
# 1.20.2 has been confirmed to have xattr support
# 1.18.2 has been confirmed not to have xattr support
# Versions in-between are unknown
--
2.30.2