Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37570384
en ru br
ALT Linux repositórios
S:1.2.4-alt1

Group :: Ferramentas de Arquivo
RPM: borg

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

Patch: borg-unbundle-xxhash-1.1.10.patch
Download


From ce146c8b558ed2e83fd8c06d2978d3a47abe35fb Mon Sep 17 00:00:00 2001
From: Felix Schwarz <felix.schwarz@oss.schwarz.eu>
Date: Mon, 3 Jun 2019 23:34:20 +0200
Subject: [PATCH 1/2] reference struct "XXH64_state_t" only via an opaque
 pointer
Upstream recommends this whenever xxhash is linked dynamically:
https://github.com/Cyan4973/xxHash/issues/63#issuecomment-218376237
This change is required to unbundle xxhash in the next commit.
---
 src/borg/algorithms/checksums.pyx | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/borg/algorithms/checksums.pyx b/src/borg/algorithms/checksums.pyx
index 6645dd0fe..f848a2dd5 100644
--- a/src/borg/algorithms/checksums.pyx
+++ b/src/borg/algorithms/checksums.pyx
@@ -25,6 +25,8 @@ cdef extern from "xxh64/xxhash.c":
         XXH_OK,
         XXH_ERROR
 
+    XXH64_state_t* XXH64_createState();
+    XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr);
     XXH64_hash_t XXH64(const void* input, size_t length, unsigned long long seed);
 
     XXH_errorcode XXH64_reset(XXH64_state_t* statePtr, unsigned long long seed);
@@ -80,17 +82,21 @@ def xxh64(data, seed=0):
 
 
 cdef class StreamingXXH64:
-    cdef XXH64_state_t state
+    cdef XXH64_state_t* state
 
     def __cinit__(self, seed=0):
+        self.state = XXH64_createState()
         cdef unsigned long long _seed = seed
-        if XXH64_reset(&self.state, _seed) != XXH_OK:
+        if XXH64_reset(self.state, _seed) != XXH_OK:
             raise Exception('XXH64_reset failed')
 
+    def __dealloc__(self):
+        XXH64_freeState(self.state)
+
     def update(self, data):
         cdef Py_buffer data_buf = ro_buffer(data)
         try:
-            if XXH64_update(&self.state, data_buf.buf, data_buf.len) != XXH_OK:
+            if XXH64_update(self.state, data_buf.buf, data_buf.len) != XXH_OK:
                 raise Exception('XXH64_update failed')
         finally:
             PyBuffer_Release(&data_buf)
@@ -98,7 +104,7 @@ cdef class StreamingXXH64:
     def digest(self):
         cdef XXH64_hash_t hash
         cdef XXH64_canonical_t digest
-        hash = XXH64_digest(&self.state)
+        hash = XXH64_digest(self.state)
         XXH64_canonicalFromHash(&digest, hash)
         return PyBytes_FromStringAndSize(<const char*> digest.digest, 8)
 
From 2ff06c58f0488a82e17ea8f22bd3326f54959070 Mon Sep 17 00:00:00 2001
From: Felix Schwarz <felix.schwarz@oss.schwarz.eu>
Date: Mon, 3 Jun 2019 23:37:46 +0200
Subject: [PATCH 2/2] ability to use a system-provided version of "xxhash"
The build process can be controlled via environment variables
similar to other bundled libraries in borgbackup. The main difference
is probably that upstream does not provide a pkgconfig file for
xxhash.
Therefore borg will probably fail to detect the system-provided
version by default (tested on Fedora, seems like Debian and Ubuntu
do not ship a pkgconfig file either). I kept the pkgconfig lookup
code anyway to keep the code as similar as possible to
"setup_compress.py"/"setup_crypto.py".
Setting BORG_LIBXXHASH_PREFIX=/usr helps borg to detect xxhash
on my system (Fedora). You can force the use of the bundled
version of xxhash by setting BORG_USE_BUNDLED_XXHASH=1.
---
 setup.py                               | 11 ++++++-
 setup_checksums.py                     | 42 ++++++++++++++++++++++++++
 src/borg/algorithms/checksums.pyx      |  2 +-
 src/borg/algorithms/xxhash-libselect.h |  5 +++
 4 files changed, 58 insertions(+), 2 deletions(-)
 create mode 100644 setup_checksums.py
 create mode 100644 src/borg/algorithms/xxhash-libselect.h
--- borg-1.1.17.orig/setup.py	2021-07-17 12:20:53.870688307 +0000
+++ borg-1.1.17/setup.py	2021-07-17 12:22:40.453688307 +0000
@@ -816,6 +816,9 @@
                                                system_prefix=libxxhash_prefix, system=libxxhash_system,
                                                **crypto_ext_kwargs)
+    checksums_ext_kwargs = dict(sources=[checksums_source],
+                             include_dirs=include_dirs, library_dirs=library_dirs, define_macros=define_macros)
+
     msgpack_endian = '__BIG_ENDIAN__' if (sys.byteorder == 'big') else '__LITTLE_ENDIAN__'
     msgpack_macros = [(msgpack_endian, '1')]
     msgpack_packer_ext_kwargs = dict(
@@ -841,7 +844,7 @@
         Extension('borg.hashindex', [hashindex_source]),
         Extension('borg.item', [item_source]),
         Extension('borg.chunker', [chunker_source]),
-        Extension('borg.algorithms.checksums', [checksums_source]),
+        Extension('borg.algorithms.checksums', **checksums_ext_kwargs),
     ]
     if not sys.platform.startswith(('win32', )):
         ext_modules.append(Extension('borg.platform.posix', [platform_posix_source]))
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009