summary refs log tree commit diff
path: root/pkgs/tools/backup
diff options
context:
space:
mode:
authorMoritz Ulrich <moritz@tarn-vedra.de>2016-03-18 14:50:49 +0100
committerMoritz Ulrich <moritz@tarn-vedra.de>2016-03-18 14:53:19 +0100
commitea30f868140c70fe4157d4d935efa1f3b84a93bb (patch)
tree3022f79c05257f50e3770fc2bee55af6f32f5672 /pkgs/tools/backup
parentedac7f0ee27190a9f9d27c4cfa196cb018d9fe82 (diff)
downloadnixpkgs-ea30f868140c70fe4157d4d935efa1f3b84a93bb.tar
nixpkgs-ea30f868140c70fe4157d4d935efa1f3b84a93bb.tar.gz
nixpkgs-ea30f868140c70fe4157d4d935efa1f3b84a93bb.tar.bz2
nixpkgs-ea30f868140c70fe4157d4d935efa1f3b84a93bb.tar.lz
nixpkgs-ea30f868140c70fe4157d4d935efa1f3b84a93bb.tar.xz
nixpkgs-ea30f868140c70fe4157d4d935efa1f3b84a93bb.tar.zst
nixpkgs-ea30f868140c70fe4157d4d935efa1f3b84a93bb.zip
btrbk: Init at 0.22.2
Diffstat (limited to 'pkgs/tools/backup')
-rw-r--r--pkgs/tools/backup/btrbk/btrbk-Prefix-PATH-instead-of-resetting-it.patch39
-rw-r--r--pkgs/tools/backup/btrbk/btrbk-mail-Use-btrbk-instead-of-unbound-variable-btr.patch25
-rw-r--r--pkgs/tools/backup/btrbk/default.nix52
3 files changed, 116 insertions, 0 deletions
diff --git a/pkgs/tools/backup/btrbk/btrbk-Prefix-PATH-instead-of-resetting-it.patch b/pkgs/tools/backup/btrbk/btrbk-Prefix-PATH-instead-of-resetting-it.patch
new file mode 100644
index 00000000000..1ebb34ded9e
--- /dev/null
+++ b/pkgs/tools/backup/btrbk/btrbk-Prefix-PATH-instead-of-resetting-it.patch
@@ -0,0 +1,39 @@
+From d5978c207f2b266165140dd21e9746ace5792daf Mon Sep 17 00:00:00 2001
+From: Moritz Ulrich <moritz@tarn-vedra.de>
+Date: Fri, 18 Mar 2016 14:01:22 +0100
+Subject: [PATCH] btrbk: Prefix PATH instead of resetting it.
+
+Some distros don't even install use /usr/bin, /sbin, etc. (notably
+NixOS). Instead, they use PATH to specify which programs are available
+to a given executable.
+
+This patch changes the behavior or `btrbk` so it extends PATH with its
+own search paths instead of resetting it. This allows users and distros
+to specify their own custom location for `btrfs` via `PATH`.
+---
+ btrbk | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/btrbk b/btrbk
+index ab15858..0b91cbe 100755
+--- a/btrbk
++++ b/btrbk
+@@ -2464,10 +2464,11 @@ sub exit_status
+ 
+ MAIN:
+ {
+-  # set PATH instead of using absolute "/sbin/btrfs" (for now), as
+-  # different distros (and even different versions of btrfs-progs)
+-  # install the "btrfs" executable to different locations.
+-  $ENV{PATH} = '/sbin:/bin:/usr/sbin:/usr/bin';
++  # Prefix PATH with /sbin etc. instead of using absolute
++  # "/sbin/btrfs" (for now), as different distros (and even different
++  # versions of btrfs-progs) install the "btrfs" executable to
++  # different locations.
++  $ENV{PATH} .= '/sbin:/bin:/usr/sbin:/usr/bin';
+ 
+   Getopt::Long::Configure qw(gnu_getopt);
+   $Data::Dumper::Sortkeys = 1;
+-- 
+2.7.3
+
diff --git a/pkgs/tools/backup/btrbk/btrbk-mail-Use-btrbk-instead-of-unbound-variable-btr.patch b/pkgs/tools/backup/btrbk/btrbk-mail-Use-btrbk-instead-of-unbound-variable-btr.patch
new file mode 100644
index 00000000000..050f1a6c430
--- /dev/null
+++ b/pkgs/tools/backup/btrbk/btrbk-mail-Use-btrbk-instead-of-unbound-variable-btr.patch
@@ -0,0 +1,25 @@
+From 8abe8a915aa2d0c79c4dbe00dc7d255c32b7b85d Mon Sep 17 00:00:00 2001
+From: Moritz Ulrich <moritz@tarn-vedra.de>
+Date: Fri, 18 Mar 2016 13:20:48 +0100
+Subject: [PATCH] btrbk-mail: Use `btrbk` instead of unbound variable `$btrbk`
+
+---
+ contrib/cron/btrbk-mail | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/contrib/cron/btrbk-mail b/contrib/cron/btrbk-mail
+index f7e4f12..9143f2d 100755
+--- a/contrib/cron/btrbk-mail
++++ b/contrib/cron/btrbk-mail
+@@ -113,7 +113,7 @@ case $exitcode in
+ 	;;
+     10) status="ERROR: At least one backup task aborted!"
+ 	;;
+-    *)  status="ERROR: $btrbk failed with error code $exitcode"
++    *)  status="ERROR: btrbk failed with error code $exitcode"
+ 	;;
+ esac
+ 
+-- 
+2.7.3
+
diff --git a/pkgs/tools/backup/btrbk/default.nix b/pkgs/tools/backup/btrbk/default.nix
new file mode 100644
index 00000000000..d4e058d143f
--- /dev/null
+++ b/pkgs/tools/backup/btrbk/default.nix
@@ -0,0 +1,52 @@
+{ stdenv, fetchurl, coreutils, bash, btrfs-progs, perl, perlPackages, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "btrbk-${version}";
+  version = "0.22.2";
+
+  src = fetchurl {
+    url = "http://digint.ch/download/btrbk/releases/${name}.tar.xz";
+    sha256 = "1gbgi0dp62wlw7y72pgxjs6byxkrk73g35kqxzw0gjf32r5i4sb8";
+  };
+
+  patches = [
+    # https://github.com/digint/btrbk/pull/74
+    ./btrbk-Prefix-PATH-instead-of-resetting-it.patch
+    # https://github.com/digint/btrbk/pull/73
+    ./btrbk-mail-Use-btrbk-instead-of-unbound-variable-btr.patch
+  ];
+
+  buildInputs = with perlPackages; [ makeWrapper perl DateCalc ];
+
+  preInstall = ''
+    substituteInPlace Makefile \
+      --replace "/usr" "$out" \
+      --replace "/etc" "$out/etc"
+
+    # Tainted Mode disables PERL5LIB
+    substituteInPlace btrbk --replace "perl -T" "perl"
+
+    # Fix btrbk-mail
+    substituteInPlace contrib/cron/btrbk-mail \
+      --replace "/bin/date" "${coreutils}/bin/date" \
+      --replace "/bin/echo" "${coreutils}/bin/echo" \
+      --replace '$btrbk' 'btrbk'
+  '';
+
+  fixupPhase = ''
+    patchShebangs $out/
+
+    wrapProgram $out/sbin/btrbk \
+      --set PERL5LIB $PERL5LIB \
+      --prefix PATH ':' "${btrfs-progs}/bin:${bash}/bin/"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "A backup tool for btrfs subvolumes";
+    homepage = http://digint.ch/btrbk;
+    license = licenses.gpl3;
+    platforms = platforms.unix;
+    maintainers = with maintainers; [ the-kenny ];
+    inherit version;
+  };
+}