From fb09818277d602e5f5b1c6ecde0b1944080291b7 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Date: Mon, 6 May 2019 22:36:43 -0400
Subject: gnu: restic: Fix build.

This fixes a regression introduced by commit f42e4ebb56.

* gnu/packages/backup.scm (restic)[arguments]: Remove "unpack-path" argument.
[phases]{build, check, install, install-docs}: Update the working directory to
"src/github.com/restic/restic".
---
 gnu/packages/backup.scm | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

(limited to 'gnu/packages/backup.scm')

diff --git a/gnu/packages/backup.scm b/gnu/packages/backup.scm
index 9b26ead91e..a70cf52e1b 100644
--- a/gnu/packages/backup.scm
+++ b/gnu/packages/backup.scm
@@ -887,16 +887,13 @@ (define-public restic
     (build-system go-build-system)
     (arguments
      `(#:import-path "github.com/restic/restic"
-       #:unpack-path "github.com/restic"
       ;; We don't need to install the source code for end-user applications.
        #:install-source? #f
        #:phases
        (modify-phases %standard-phases
          (replace 'build
            (lambda* (#:key inputs #:allow-other-keys)
-             (with-directory-excursion (string-append
-                                        "src/github.com/restic/restic-"
-                                        ,version)
+             (with-directory-excursion "src/github.com/restic/restic"
                ;; Disable 'restic self-update'.  It makes little sense in Guix.
                (substitute* "build.go" (("selfupdate") ""))
                (setenv "HOME" (getcwd)) ; for $HOME/.cache/go-build
@@ -904,9 +901,7 @@ (define-public restic
 
          (replace 'check
            (lambda _
-             (with-directory-excursion (string-append
-                                        "src/github.com/restic/restic-"
-                                        ,version)
+             (with-directory-excursion "src/github.com/restic/restic"
                ;; Disable FUSE tests.
                (setenv "RESTIC_TEST_FUSE" "0")
                (invoke "go" "run" "build.go" "--test"))))
@@ -914,8 +909,7 @@ (define-public restic
          (replace 'install
            (lambda* (#:key outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out"))
-                   (src (string-append "src/github.com/restic/restic-"
-                                       ,version)))
+                   (src "src/github.com/restic/restic"))
                (install-file (string-append src "/restic")
                              (string-append out "/bin"))
                #t)))
@@ -925,8 +919,7 @@ (define-public restic
              (let* ((out (assoc-ref outputs "out"))
                     (man "/share/man")
                     (man-section (string-append man "/man"))
-                    (src (string-append "src/github.com/restic/restic-"
-                                        ,version "/doc/man/")))
+                    (src "src/github.com/restic/restic/doc/man/"))
                ;; Install all the man pages to "out".
                (for-each
                  (lambda (file)
-- 
cgit v1.2.3


From 46ca002d1c22dc3570f6e28e20ca024aed1365f7 Mon Sep 17 00:00:00 2001
From: Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
Date: Tue, 14 May 2019 14:19:19 +0200
Subject: gnu: burp: Update to 2.3.6.

* gnu/packages/backup.scm (burp):  Update to 2.3.6.
---
 gnu/packages/backup.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'gnu/packages/backup.scm')

diff --git a/gnu/packages/backup.scm b/gnu/packages/backup.scm
index a70cf52e1b..97c7499c1c 100644
--- a/gnu/packages/backup.scm
+++ b/gnu/packages/backup.scm
@@ -988,14 +988,14 @@ (define-public restic
 (define-public burp
   (package
     (name "burp")
-    (version "2.3.4")
+    (version "2.3.6")
     (source (origin
               (method url-fetch)
               (uri (string-append "mirror://sourceforge/burp/burp-" version
                                   "/burp-" version ".tar.bz2"))
               (sha256
                (base32
-                "0r82mmfjm57yr4f34za3x3rkgc5z2c7nwbnsjjki16qfc9kjyai3"))))
+                "101nn30apcbmy9k0wksdf8d4ccw7sfcqzkasgg17a5y332x2imr9"))))
     (build-system gnu-build-system)
     (inputs
      `(("librsync" ,librsync)
-- 
cgit v1.2.3


From 08eafef8650922681bad10d9f5a3f92ff91616b6 Mon Sep 17 00:00:00 2001
From: Leo Famulari <leo@famulari.name>
Date: Tue, 14 May 2019 18:38:23 -0400
Subject: gnu: Borg: Fix a hang in the test suite.

* gnu/packages/patches/borg-fix-hard-link-preloading.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/backup.scm (borg)[source]: Use it.
---
 gnu/local.mk                                       |   1 +
 gnu/packages/backup.scm                            |   1 +
 .../patches/borg-fix-hard-link-preloading.patch    | 157 +++++++++++++++++++++
 3 files changed, 159 insertions(+)
 create mode 100644 gnu/packages/patches/borg-fix-hard-link-preloading.patch

(limited to 'gnu/packages/backup.scm')

diff --git a/gnu/local.mk b/gnu/local.mk
index e76e387e42..ac55e1dd28 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -686,6 +686,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/blender-2.79-newer-ffmpeg.patch		\
   %D%/packages/patches/blender-2.79-python-3.7-fix.patch	\
   %D%/packages/patches/boost-fix-icu-build.patch		\
+  %D%/packages/patches/borg-fix-hard-link-preloading.patch	\
   %D%/packages/patches/byobu-writable-status.patch		\
   %D%/packages/patches/calibre-no-updates-dialog.patch		\
   %D%/packages/patches/calibre-remove-test-bs4.patch		\
diff --git a/gnu/packages/backup.scm b/gnu/packages/backup.scm
index 97c7499c1c..b15c15ad46 100644
--- a/gnu/packages/backup.scm
+++ b/gnu/packages/backup.scm
@@ -519,6 +519,7 @@ (define-public borg
        (sha256
         (base32
          "0x95nhv4h34m8cxycbwc4xdz350saaxlgh727b23bgn4ci7gh3vx"))
+       (patches (search-patches "borg-fix-hard-link-preloading.patch"))
        (modules '((guix build utils)))
        (snippet
         '(begin
diff --git a/gnu/packages/patches/borg-fix-hard-link-preloading.patch b/gnu/packages/patches/borg-fix-hard-link-preloading.patch
new file mode 100644
index 0000000000..92a4e22674
--- /dev/null
+++ b/gnu/packages/patches/borg-fix-hard-link-preloading.patch
@@ -0,0 +1,157 @@
+Fix a bug that would cause the test suite to hang:
+
+https://github.com/borgbackup/borg/issues/4350
+
+Patch copied from upstream source repository:
+
+https://github.com/borgbackup/borg/commit/18242ab9e2f26c450b8507aa1d5eceadab8ad027
+
+From 18242ab9e2f26c450b8507aa1d5eceadab8ad027 Mon Sep 17 00:00:00 2001
+From: Thomas Waldmann <tw@waldmann-edv.de>
+Date: Thu, 2 May 2019 21:02:26 +0200
+Subject: [PATCH] preload chunks for hardlink slaves w/o preloaded master,
+ fixes #4350
+
+also split the hardlink extraction test into 2 tests.
+
+(cherry picked from commit f33f318d816505161d1449a02ddfdeb97d6fe80a)
+---
+ src/borg/archive.py            | 42 +++++++++++++++++++++++++++++-----
+ src/borg/archiver.py           |  5 ++--
+ src/borg/testsuite/archiver.py | 20 +++++++++-------
+ 3 files changed, 51 insertions(+), 16 deletions(-)
+
+diff --git a/src/borg/archive.py b/src/borg/archive.py
+index adc1f42c..0793672a 100644
+--- a/src/borg/archive.py
++++ b/src/borg/archive.py
+@@ -192,7 +192,7 @@ def __init__(self, repository, key):
+         self.repository = repository
+         self.key = key
+ 
+-    def unpack_many(self, ids, filter=None, preload=False):
++    def unpack_many(self, ids, filter=None, partial_extract=False, preload=False, hardlink_masters=None):
+         """
+         Return iterator of items.
+ 
+@@ -209,12 +209,40 @@ def unpack_many(self, ids, filter=None, preload=False):
+             for item in items:
+                 if 'chunks' in item:
+                     item.chunks = [ChunkListEntry(*e) for e in item.chunks]
++
++            def preload(chunks):
++                self.repository.preload([c.id for c in chunks])
++
+             if filter:
+                 items = [item for item in items if filter(item)]
++
+             if preload:
+-                for item in items:
+-                    if 'chunks' in item:
+-                        self.repository.preload([c.id for c in item.chunks])
++                if filter and partial_extract:
++                    # if we do only a partial extraction, it gets a bit
++                    # complicated with computing the preload items: if a hardlink master item is not
++                    # selected (== not extracted), we will still need to preload its chunks if a
++                    # corresponding hardlink slave is selected (== is extracted).
++                    # due to a side effect of the filter() call, we now have hardlink_masters dict populated.
++                    masters_preloaded = set()
++                    for item in items:
++                        if 'chunks' in item:  # regular file, maybe a hardlink master
++                            preload(item.chunks)
++                            # if this is a hardlink master, remember that we already preloaded it:
++                            if 'source' not in item and hardlinkable(item.mode) and item.get('hardlink_master', True):
++                                masters_preloaded.add(item.path)
++                        elif 'source' in item and hardlinkable(item.mode):  # hardlink slave
++                            source = item.source
++                            if source not in masters_preloaded:
++                                # we only need to preload *once* (for the 1st selected slave)
++                                chunks, _ = hardlink_masters[source]
++                                preload(chunks)
++                                masters_preloaded.add(source)
++                else:
++                    # easy: we do not have a filter, thus all items are selected, thus we need to preload all chunks.
++                    for item in items:
++                        if 'chunks' in item:
++                            preload(item.chunks)
++
+             for item in items:
+                 yield item
+ 
+@@ -433,8 +461,10 @@ def item_filter(self, item, filter=None):
+             return False
+         return filter(item) if filter else True
+ 
+-    def iter_items(self, filter=None, preload=False):
+-        for item in self.pipeline.unpack_many(self.metadata.items, preload=preload,
++    def iter_items(self, filter=None, partial_extract=False, preload=False, hardlink_masters=None):
++        assert not (filter and partial_extract and preload) or hardlink_masters is not None
++        for item in self.pipeline.unpack_many(self.metadata.items, partial_extract=partial_extract,
++                                              preload=preload, hardlink_masters=hardlink_masters,
+                                               filter=lambda item: self.item_filter(item, filter)):
+             yield item
+ 
+diff --git a/src/borg/archiver.py b/src/borg/archiver.py
+index 957959d6..dcc20455 100644
+--- a/src/borg/archiver.py
++++ b/src/borg/archiver.py
+@@ -755,7 +755,8 @@ def peek_and_store_hardlink_masters(item, matched):
+         else:
+             pi = None
+ 
+-        for item in archive.iter_items(filter, preload=True):
++        for item in archive.iter_items(filter, partial_extract=partial_extract,
++                                       preload=True, hardlink_masters=hardlink_masters):
+             orig_path = item.path
+             if strip_components:
+                 item.path = os.sep.join(orig_path.split(os.sep)[strip_components:])
+@@ -997,7 +998,7 @@ def item_to_tarinfo(item, original_path):
+                 return None, stream
+             return tarinfo, stream
+ 
+-        for item in archive.iter_items(filter, preload=True):
++        for item in archive.iter_items(filter, preload=True, hardlink_masters=hardlink_masters):
+             orig_path = item.path
+             if strip_components:
+                 item.path = os.sep.join(orig_path.split(os.sep)[strip_components:])
+diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py
+index c35ad800..935b3d79 100644
+--- a/src/borg/testsuite/archiver.py
++++ b/src/borg/testsuite/archiver.py
+@@ -823,7 +823,18 @@ def test_mount_hardlinks(self):
+             assert open('input/dir1/subdir/hardlink', 'rb').read() == b'123456'
+ 
+     @requires_hardlinks
+-    def test_extract_hardlinks(self):
++    def test_extract_hardlinks1(self):
++        self._extract_hardlinks_setup()
++        with changedir('output'):
++            self.cmd('extract', self.repository_location + '::test')
++            assert os.stat('input/source').st_nlink == 4
++            assert os.stat('input/abba').st_nlink == 4
++            assert os.stat('input/dir1/hardlink').st_nlink == 4
++            assert os.stat('input/dir1/subdir/hardlink').st_nlink == 4
++            assert open('input/dir1/subdir/hardlink', 'rb').read() == b'123456'
++
++    @requires_hardlinks
++    def test_extract_hardlinks2(self):
+         self._extract_hardlinks_setup()
+         with changedir('output'):
+             self.cmd('extract', self.repository_location + '::test', '--strip-components', '2')
+@@ -839,13 +850,6 @@ def test_extract_hardlinks(self):
+             assert open('input/dir1/subdir/hardlink', 'rb').read() == b'123456'
+             assert os.stat('input/dir1/aaaa').st_nlink == 2
+             assert os.stat('input/dir1/source2').st_nlink == 2
+-        with changedir('output'):
+-            self.cmd('extract', self.repository_location + '::test')
+-            assert os.stat('input/source').st_nlink == 4
+-            assert os.stat('input/abba').st_nlink == 4
+-            assert os.stat('input/dir1/hardlink').st_nlink == 4
+-            assert os.stat('input/dir1/subdir/hardlink').st_nlink == 4
+-            assert open('input/dir1/subdir/hardlink', 'rb').read() == b'123456'
+ 
+     def test_extract_include_exclude(self):
+         self.cmd('init', '--encryption=repokey', self.repository_location)
+-- 
+2.21.0
+
-- 
cgit v1.2.3


From 558d36e6bf4113771838811f2f0b2ce2ecf8f33f Mon Sep 17 00:00:00 2001
From: Tobias Geerinckx-Rice <me@tobias.gr>
Date: Mon, 20 May 2019 03:15:53 +0200
Subject: gnu: wimlib: Update to 1.13.1.

* gnu/packages/backup.scm (wimlib): Update to 1.13.1.
---
 gnu/packages/backup.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'gnu/packages/backup.scm')

diff --git a/gnu/packages/backup.scm b/gnu/packages/backup.scm
index b15c15ad46..fb5f047743 100644
--- a/gnu/packages/backup.scm
+++ b/gnu/packages/backup.scm
@@ -675,14 +675,14 @@ (define-public attic
 (define-public wimlib
   (package
     (name "wimlib")
-    (version "1.13.0")
+    (version "1.13.1")
     (source (origin
               (method url-fetch)
               (uri (string-append "https://wimlib.net/downloads/"
                                   "wimlib-" version ".tar.gz"))
               (sha256
                (base32
-                "02wpsxjlw9vysj6x6q7kmvbcdkpvdzw201mmj5x0q670mapjrnai"))))
+                "0pxgrpr3dr81rcf2jh71aiiq3v4anc5sj1nld18f2vhvbijbrx27"))))
     (build-system gnu-build-system)
     (native-inputs
      `(("pkg-config" ,pkg-config)))
-- 
cgit v1.2.3


From dd5fbf613ac177376cb801808b62bac166bbc9a9 Mon Sep 17 00:00:00 2001
From: Tobias Geerinckx-Rice <me@tobias.gr>
Date: Mon, 20 May 2019 03:20:45 +0200
Subject: gnu: restic: Update to 0.9.5.

* gnu/packages/backup.scm (restic): Update to 0.9.5.
---
 gnu/packages/backup.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'gnu/packages/backup.scm')

diff --git a/gnu/packages/backup.scm b/gnu/packages/backup.scm
index fb5f047743..262c6efc24 100644
--- a/gnu/packages/backup.scm
+++ b/gnu/packages/backup.scm
@@ -873,7 +873,7 @@ (define write-man
 (define-public restic
   (package
     (name "restic")
-    (version "0.9.4")
+    (version "0.9.5")
     ;; TODO Try packaging the bundled / vendored dependencies in the 'vendor/'
     ;; directory.
     (source (origin
@@ -884,7 +884,7 @@ (define-public restic
               (file-name (string-append name "-" version ".tar.gz"))
               (sha256
                (base32
-                "13ksprq1ia86px8x4lqrmx0l6y9rb1ppg8pnp7lcx0zxnq7skp67"))))
+                "0afl3dv7gzwdc9klikk3fsb57d0px2fwihb0xxb7zq7d8vlhh8p2"))))
     (build-system go-build-system)
     (arguments
      `(#:import-path "github.com/restic/restic"
-- 
cgit v1.2.3