gnu: mono: Make build reproducible.
[jackhill/guix/guix.git] / gnu / packages / backup.scm
index 2fafa2c..c927a14 100644 (file)
@@ -9,6 +9,9 @@
 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2017 Christopher Allan Webber <cwebber@dustycloud.org>
 ;;; Copyright © 2017 Rutger Helling <rhelling@mykolab.com>
+;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
+;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
 (define-module (gnu packages backup)
   #:use-module (guix packages)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix git-download)
   #:use-module (guix download)
   #:use-module (guix utils)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system go)
   #:use-module (guix build-system python)
   #:use-module (gnu packages)
   #:use-module (gnu packages acl)
@@ -44,6 +49,7 @@
   #:use-module (gnu packages ftp)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages gnupg)
+  #:use-module (gnu packages golang)
   #:use-module (gnu packages gperf)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages linux)
@@ -63,7 +69,7 @@
 (define-public duplicity
   (package
     (name "duplicity")
-    (version "0.7.12")
+    (version "0.7.18.1")
     (source
      (origin
       (method url-fetch)
                           version ".tar.gz"))
       (sha256
        (base32
-        "1rhgrz2lm9vbfdp2raykrih1c6n2lw5jd572z4dsz488m52avjqi"))))
+        "17c0203y5qz9w8iyhs26l44qf6a1vp26b5ykz1ypdr2kv6g02df9"))))
     (build-system python-build-system)
     (native-inputs
-     `(("util-linux" ,util-linux)     ;setsid command, for the tests
+     `(("util-linux" ,util-linux)       ; setsid command, for the tests
        ("par2cmdline" ,par2cmdline)
        ("python-pexpect" ,python2-pexpect)
+       ("python-fasteners" ,python2-fasteners)
        ("mock" ,python2-mock)))
     (propagated-inputs
      `(("lockfile" ,python2-lockfile)
     (inputs
      `(("librsync" ,librsync)
        ("lftp" ,lftp)
-       ("gnupg" ,gnupg)                 ;gpg executable needed
-       ("util-linux" ,util-linux)       ;for setsid
+       ("gnupg" ,gnupg)                 ; gpg executable needed
+       ("util-linux" ,util-linux)       ; for setsid
        ("tzdata" ,tzdata)))
     (arguments
-     `(#:python ,python-2               ;setup assumes Python 2
+     `(#:python ,python-2               ; setup assumes Python 2
        #:test-target "test"
        #:phases
        (modify-phases %standard-phases
-         (add-before 'build 'patch-source
+         (add-before 'build 'use-store-file-names
            (lambda* (#:key inputs #:allow-other-keys)
-             ;; embed gpg store name
              (substitute* "duplicity/gpginterface.py"
                (("self.call = 'gpg'")
                 (string-append "self.call = '" (assoc-ref inputs "gnupg") "/bin/gpg'")))
+
              (substitute* '("testing/functional/__init__.py"
                             "testing/overrides/bin/lftp")
                (("/bin/sh") (which "sh")))
              #t))
          (add-before 'check 'check-setup
            (lambda* (#:key inputs #:allow-other-keys)
-             (setenv "HOME" (getcwd)) ;gpg needs to write to $HOME
-             (setenv "TZDIR"          ;some timestamp checks need TZDIR
+             (setenv "HOME" (getcwd))   ; gpg needs to write to $HOME
+             (setenv "TZDIR"            ; some timestamp checks need TZDIR
                      (string-append (assoc-ref inputs "tzdata")
                                     "/share/zoneinfo"))
              #t)))))
@@ -127,22 +134,18 @@ spying and/or modification by the server.")
     (name "par2cmdline")
     (version "0.8.0")
     (source (origin
-              (method url-fetch)
-              (uri (string-append "https://github.com/Parchive/par2cmdline/archive/v"
-                                  version ".tar.gz"))
-              (file-name (string-append name "-" version ".tar.gz"))
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/Parchive/par2cmdline.git")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
               (sha256
                (base32
-                "1jpshmmcr81mxly0md2rr231qz9c8c680bbvcmhh100dg9i4a6s6"))))
+                "0f1jsd5sw2wynjzi7yjqjaf13yhyjfdid91p8yh0jn32y03kjyrz"))))
     (native-inputs
      `(("automake" ,automake)
        ("autoconf" ,autoconf)))
     (build-system gnu-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (add-after 'unpack 'autoreconf
-           (lambda _ (zero? (system* "autoreconf" "-vfi")))))))
     (synopsis "File verification and repair tools")
     (description "Par2cmdline uses Reed-Solomon error-correcting codes to
 generate and verify PAR2 recovery files.  These files can be distributed
@@ -203,7 +206,6 @@ backups (called chunks) to allow easy burning to CD/DVD.")
         (base32
          "1km0mzfl6in7l5vz9kl09a88ajx562rw93ng9h2jqavrailvsbgd"))))
     (build-system gnu-build-system)
-    ;; TODO: Add -L/path/to/nettle in libarchive.pc.
     (inputs
      `(("zlib" ,zlib)
        ("nettle" ,nettle)
@@ -226,12 +228,33 @@ backups (called chunks) to allow easy burning to CD/DVD.")
              ;; the chroot's /etc/passwd doesn't have it.  Turn off those tests.
              ;;
              ;; The tests allow one to disable tests matching a globbing pattern.
-             (and (zero? (system* "make"
-                                  "libarchive_test" "bsdcpio_test" "bsdtar_test"))
-                  ;; XXX: This glob disables too much.
-                  (zero? (system* "./libarchive_test" "^test_*_disk*"))
-                  (zero? (system* "./bsdcpio_test" "^test_owner_parse"))
-                  (zero? (system* "./bsdtar_test"))))))
+             (invoke "make" "libarchive_test" "bsdcpio_test" "bsdtar_test")
+             ;; XXX: This glob disables too much.
+             (invoke "./libarchive_test" "^test_*_disk*")
+             (invoke "./bsdcpio_test" "^test_owner_parse")
+             (invoke "./bsdtar_test")))
+         (add-after 'install 'add--L-in-libarchive-pc
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out     (assoc-ref outputs "out"))
+                    (lib     (string-append out "/lib"))
+                    (nettle  (assoc-ref inputs "nettle"))
+                    (libxml2 (assoc-ref inputs "libxml2"))
+                    (xz      (assoc-ref inputs "xz"))
+                    (zlib    (assoc-ref inputs "zlib"))
+                    (bzip2   (assoc-ref inputs "bzip2")))
+               (substitute* (string-append lib "/pkgconfig/libarchive.pc")
+                 (("-lnettle")
+                  (string-append "-L" nettle "/lib -lnettle"))
+                 (("-lxml2")
+                  (string-append "-L" libxml2 "/lib -lxml2"))
+                 (("-llzma")
+                  (string-append "-L" xz "/lib -llzma"))
+                 (("-lz")
+                  (string-append "-L" zlib "/lib -lz"))
+                 (("-lbz2")
+                  (string-append "-L" bzip2 "/lib -lbz2")))
+               #t))))
+
        ;; libarchive/test/test_write_format_gnutar_filenames.c needs to be
        ;; compiled with C99 or C11 or a gnu variant.
        #:configure-flags '("CFLAGS=-O2 -g -std=c99")))
@@ -278,9 +301,6 @@ random access nor for in-place modification.")
      `(#:parallel-build? #f             ;race conditions
        #:phases
        (modify-phases %standard-phases
-         (add-after 'unpack 'bootstrap
-           (lambda _
-             (invoke "autoreconf")))
          (add-before 'build 'qualify-inputs
            (lambda* (#:key inputs #:allow-other-keys)
              ;; This script is full of pitfalls.  Fix some that particularly
@@ -398,7 +418,7 @@ rdiff-backup is easy to use and settings have sensible defaults.")
                             "t/backup_exec/conf/backup_exec.conf")
                (("/bin/true") (which "true"))
                (("/bin/false") (which "false")))
-             (zero? (system* "make" "test")))))))
+             (invoke "make" "test"))))))
     (inputs
      `(("perl" ,perl)
        ("rsync" ,rsync)))
@@ -423,9 +443,27 @@ rsnapshot uses hard links to deduplicate identical files.")
                 "0fpdyxww41ba52d98blvnf543xvirq1v9xz1i3x1gm9lzlzpmc2g"))
               (patches (search-patches "diffutils-gets-undeclared.patch"))))
     (build-system gnu-build-system)
+    (arguments
+     '(#:phases (modify-phases %standard-phases
+                  (add-before 'configure 'adjust-configure-script
+                    (lambda _
+                      ;; Mimic upstream commit
+                      ;; 25750ab5ef82fd3cfce5205d5f1ef07b47098091.
+                      (substitute* "configure"
+                        (("GUILE=(.*)--variable bindir`" _ middle)
+                         (string-append "GUILE=" middle
+                                        "--variable bindir`/guile")))
+                      #t))
+                  (add-before 'check 'skip-test
+                    (lambda _
+                      ;; XXX: This test fails (1) because current GnuTLS no
+                      ;; longer supports OpenPGP authentication, and (2) for
+                      ;; some obscure reason.  Better skip it.
+                      (setenv "XFAIL_TESTS" "utils/block-server")
+                      #t)))))
     (native-inputs
      `(("guile" ,guile-2.0)
-       ("gperf" ,gperf)
+       ("gperf" ,gperf-3.0)                  ;see <https://bugs.gnu.org/32382>
        ("pkg-config" ,pkg-config)))
     (inputs
      `(("guile" ,guile-2.0)
@@ -453,22 +491,38 @@ detection, and lossless compression.")
 (define-public borg
   (package
     (name "borg")
-    (version "1.1.4")
+    (version "1.1.7")
     (source
      (origin
        (method url-fetch)
        (uri (pypi-uri "borgbackup" version))
+       (patches (search-patches "borg-respect-storage-quota.patch"))
        (sha256
-        (base32 "1cicqwh85wfp65y00qaq6q4i4jcyy9b66qz5gpl80qc880wab912"))
+        (base32
+         "1p3zia62vyg9vadkdjzzkzbj4dmgijr7ix5lmhfbxpwy5q9imdgp"))
        (modules '((guix build utils)))
        (snippet
         '(begin
+           ;; Delete files generated by Cython.  We used to have a regex
+           ;; that created the list of generated files but Borg has
+           ;; added new non-generated C files that cause the regex to
+           ;; generate the wrong list.
            (for-each delete-file
-                     (find-files "borg" "^(c|h|p).*\\.c$"))
+                     '("src/borg/algorithms/checksums.c"
+                       "src/borg/chunker.c"
+                       "src/borg/compress.c"
+                       "src/borg/crypto/low_level.c"
+                       "src/borg/hashindex.c"
+                       "src/borg/item.c"
+                       "src/borg/platform/darwin.c"
+                       "src/borg/platform/freebsd.c"
+                       "src/borg/platform/linux.c"
+                       "src/borg/platform/posix.c"))
            ;; Remove bundled shared libraries.
            (with-directory-excursion "src/borg/algorithms"
              (for-each delete-file-recursively
-                       (list "blake2" "lz4" "zstd")))))))
+                       (list "blake2" "lz4" "zstd")))
+           #t))))
     (build-system python-build-system)
     (arguments
      `(#:modules ((srfi srfi-26) ; for cut
@@ -500,25 +554,24 @@ detection, and lossless compression.")
              ;; The tests should be run in an empty directory.
              (mkdir-p "tests")
              (with-directory-excursion "tests"
-               (zero?
-                 (system* "py.test" "-v" "--pyargs" "borg.testsuite" "-k"
-                          (string-append
-                            ;; These tests need to write to '/var'.
-                            "not test_get_cache_dir "
-                            "and not test_get_config_dir "
-                            "and not test_get_keys_dir "
-                            "and not test_get_security_dir "
-                            ;; These tests assume there is a root user in
-                            ;; '/etc/passwd'.
-                            "and not test_access_acl "
-                            "and not test_default_acl "
-                            "and not test_non_ascii_acl "
-                            ;; This test needs the unpackaged pytest-benchmark.
-                            "and not benchmark "
-                            ;; These tests assume the kernel supports FUSE.
-                            "and not test_fuse "
-                            "and not test_fuse_allow_damaged_files "
-                            "and not test_mount_hardlinks"))))))
+               (invoke "py.test" "-v" "--pyargs" "borg.testsuite" "-k"
+                       (string-append
+                        ;; These tests need to write to '/var'.
+                        "not test_get_cache_dir "
+                        "and not test_get_config_dir "
+                        "and not test_get_keys_dir "
+                        "and not test_get_security_dir "
+                        ;; These tests assume there is a root user in
+                        ;; '/etc/passwd'.
+                        "and not test_access_acl "
+                        "and not test_default_acl "
+                        "and not test_non_ascii_acl "
+                        ;; This test needs the unpackaged pytest-benchmark.
+                        "and not benchmark "
+                        ;; These tests assume the kernel supports FUSE.
+                        "and not test_fuse "
+                        "and not test_fuse_allow_damaged_files "
+                        "and not test_mount_hardlinks")))))
          (add-after 'install 'install-doc
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (let* ((out (assoc-ref outputs "out"))
@@ -529,11 +582,9 @@ detection, and lossless compression.")
                            "docs/misc/internals-picture.txt"
                            "docs/misc/prune-example.txt"))
                (add-installed-pythonpath inputs outputs)
-               (and
-                 (zero? (system* "python3" "setup.py" "build_man"))
-                 (begin
-                   (copy-recursively "docs/man" man)
-                   #t))))))))
+               (invoke "python3" "setup.py" "build_man")
+               (copy-recursively "docs/man" man)
+               #t))))))
     (native-inputs
      `(("python-cython" ,python-cython)
        ("python-setuptools-scm" ,python-setuptools-scm)
@@ -663,17 +714,17 @@ NTFS volumes using @code{ntfs-3g}, preserving NTFS-specific attributes.")
          (replace 'check
                   (lambda _
                     (substitute* "obnamlib/vfs_local_tests.py"
-                      ;; Check for the nobody user instead of root
+                      ;; Check for the nobody user instead of root.
                       (("self.fs.get_username\\(0\\), 'root'")
                        "self.fs.get_username(65534), 'nobody'")
-                      ;; Disable tests checking for root group
+                      ;; Disable tests checking for root group.
                       (("self.fs.get_groupname\\(0\\)") "'root'"))
                     (substitute* "obnamlib/vfs_local.py"
-                      ;; Don't cover get_groupname function
+                      ;; Don't cover get_groupname function.
                       (("def get_groupname\\(self, gid\\):")
                        "def get_groupname(self, gid):  # pragma: no cover"))
-                    ;; Can't run network tests
-                    (zero? (system* "./check" "--unit-tests")))))))
+                    ;; Can't run network tests.
+                    (invoke "./check" "--unit-tests"))))))
     (inputs
      `(("python2-cliapp" ,python2-cliapp)
        ("python2-larch" ,python2-larch)
@@ -688,12 +739,15 @@ NTFS volumes using @code{ntfs-3g}, preserving NTFS-specific attributes.")
        ("python2-pep8" ,python2-pep8)
        ("python2-pylint" ,python2-pylint)))
     (home-page "https://obnam.org/")
-    (synopsis "Easy and secure backup program")
-    (description "Obnam is an easy, secure backup program.  Features
-include snapshot backups, data de-duplication and encrypted backups
-using GnuPG.  Backups can be stored on local hard disks, or online via
-the SSH SFTP protocol.  The backup server, if used, does not require
-any special software, on top of SSH.")
+    (synopsis "Retired backup program")
+    (description
+     "Warning: @uref{https://blog.liw.fi/posts/2017/08/13/retiring_obnam/,
+the Obnam project is retired}.  You should use another backup solution instead.
+
+Obnam was an easy, secure backup program.  Features included snapshot backups,
+data de-duplication and encrypted backups using GnuPG.  Backups can be stored on
+local hard disks, or online via the SSH SFTP protocol.  The backup server, if
+used, does not require any special software, on top of SSH.")
     (license license:gpl3+)))
 
 (define-public dirvish
@@ -802,3 +856,126 @@ file systems with unattended creation and expiration.  A dirvish backup vault
 is like a time machine for your data. ")
     (license (license:fsf-free "file://COPYING"
                                "Open Software License 2.0"))))
+
+(define-public restic
+  (package
+    (name "restic")
+    (version "0.9.3")
+    ;; TODO Try packaging the bundled / vendored dependencies in the 'vendor/'
+    ;; directory.
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://github.com/restic/restic/releases/download/"
+                    "v" version "/restic-" version ".tar.gz"))
+              (file-name (string-append name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "1l1ddnf61pfsrry97qwhhdzywin2mgnbrkhcc9pabsdfk602anmr"))))
+    (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)
+               ;; Disable 'restic self-update'.  It makes little sense in Guix.
+               (substitute* "build.go" (("selfupdate") ""))
+               (setenv "HOME" (getcwd)) ; for $HOME/.cache/go-build
+               (invoke "go" "run" "build.go"))))
+
+         (replace 'check
+           (lambda _
+             (with-directory-excursion (string-append
+                                        "src/github.com/restic/restic-"
+                                        ,version)
+               ;; Disable FUSE tests.
+               (setenv "RESTIC_TEST_FUSE" "0")
+               (invoke "go" "run" "build.go" "--test"))))
+
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out"))
+                   (src (string-append "src/github.com/restic/restic-"
+                                       ,version)))
+               (install-file (string-append src "/restic")
+                             (string-append out "/bin"))
+               #t)))
+
+         (add-after 'install 'install-docs
+           (lambda* (#:key outputs #:allow-other-keys)
+             (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/")))
+               ;; Install all the man pages to "out".
+               (for-each
+                 (lambda (file)
+                   (install-file file
+                                 (string-append out man-section
+                                                (string-take-right file 1))))
+                 (find-files src "\\.[1-9]"))
+               #t)))
+
+         (add-after 'install-docs 'install-shell-completion
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (bin (string-append out "/bin"))
+                    (etc (string-append out "/etc"))
+                    (share (string-append out "/share")))
+               (for-each
+                (lambda (shell)
+                  (let* ((shell-name (symbol->string shell))
+                         (dir (string-append "etc/completion/" shell-name)))
+                    (mkdir-p dir)
+                    (invoke (string-append bin "/restic") "generate"
+                            (string-append "--" shell-name "-completion")
+                            (string-append dir "/"
+                                           (case shell
+                                             ((bash) "restic")
+                                             ((zsh) "_restic"))))))
+                '(bash zsh))
+               (with-directory-excursion "etc/completion"
+                 (install-file "bash/restic"
+                               (string-append etc "/bash_completion.d"))
+                 (install-file "zsh/_restic"
+                               (string-append share "/zsh/site-functions")))
+               #t))))))
+    (home-page "https://restic.net/")
+    (synopsis "Backup program with multiple revisions, encryption and more")
+    (description "Restic is a program that does backups right and was designed
+with the following principles in mind:
+
+@itemize
+@item Easy: Doing backups should be a frictionless process, otherwise you
+might be tempted to skip it.  Restic should be easy to configure and use, so
+that, in the event of a data loss, you can just restore it.  Likewise,
+restoring data should not be complicated.
+
+@item Fast: Backing up your data with restic should only be limited by your
+network or hard disk bandwidth so that you can backup your files every day.
+Nobody does backups if it takes too much time.  Restoring backups should only
+transfer data that is needed for the files that are to be restored, so that
+this process is also fast.
+
+@item Verifiable: Much more important than backup is restore, so restic
+enables you to easily verify that all data can be restored.  @item Secure:
+Restic uses cryptography to guarantee confidentiality and integrity of your
+data.  The location the backup data is stored is assumed not to be a trusted
+environment (e.g.  a shared space where others like system administrators are
+able to access your backups).  Restic is built to secure your data against
+such attackers.
+
+@item Efficient: With the growth of data, additional snapshots should only
+take the storage of the actual increment.  Even more, duplicate data should be
+de-duplicated before it is actually written to the storage back end to save
+precious backup space.
+@end itemize")
+    (license license:bsd-2)))