]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- make some binary paths used in snbk configurable 971/head
authorArvin Schnell <aschnell@suse.de>
Tue, 17 Dec 2024 08:16:40 +0000 (09:16 +0100)
committerArvin Schnell <aschnell@suse.de>
Tue, 17 Dec 2024 08:16:40 +0000 (09:16 +0100)
client/snbk/BackupConfig.cc
client/snbk/BackupConfig.h
client/snbk/CmdBtrfs.cc
client/snbk/CmdBtrfs.h
client/snbk/CmdFindmnt.cc
client/snbk/CmdFindmnt.h
client/snbk/CmdRealpath.cc
client/snbk/CmdRealpath.h
client/snbk/TheBigThing.cc
doc/snapper-backup-configs.xml.in
package/snapper.changes

index 9d31a85b1c2f99cfffec32821226bf63ee9131b1..b55df94a1ee60b1478c86bbc8017558dcedad8d3 100644 (file)
@@ -69,6 +69,10 @@ namespace snapper
            get_child_value(json_file.get_root(), "ssh-user", ssh_user);
            get_child_value(json_file.get_root(), "ssh-identity", ssh_identity);
        }
+
+       get_child_value(json_file.get_root(), "target-btrfs-bin", target_btrfs_bin);
+       get_child_value(json_file.get_root(), "target-realpath-bin", target_realpath_bin);
+       get_child_value(json_file.get_root(), "target-findmnt-bin", target_findmnt_bin);
     }
 
 
index 254bc843bf753d1bbf1a3ef7ad53504912a79a7d..2bd5731e41c5547739fe1adbab8933dbfa3e4a41 100644 (file)
@@ -27,6 +27,7 @@
 #include <vector>
 
 #include <snapper/Enum.h>
+#include <snapper/SnapperDefines.h>
 
 #include "Shell.h"
 
@@ -68,6 +69,10 @@ namespace snapper
        Shell get_source_shell() const;
        Shell get_target_shell() const;
 
+       string target_btrfs_bin = BTRFS_BIN;
+       string target_realpath_bin = REALPATH_BIN;
+       string target_findmnt_bin = FINDMNT_BIN;
+
     private:
 
        vector<string> ssh_options() const;
index ac98b504f126d4216e7c2b0a42cb46ee90e88b35..34f9239adec0879af303bbf99e4708db7f9f7d08 100644 (file)
@@ -39,9 +39,9 @@ namespace snapper
     using namespace std;
 
 
-    CmdBtrfsSubvolumeList::CmdBtrfsSubvolumeList(const Shell& shell, const string& mount_point)
+    CmdBtrfsSubvolumeList::CmdBtrfsSubvolumeList(const string& btrfs_bin, const Shell& shell, const string& mount_point)
     {
-       SystemCmd::Args cmd_args = { BTRFS_BIN, "subvolume", "list", "-a", "-puqR", mount_point };
+       SystemCmd::Args cmd_args = { btrfs_bin, "subvolume", "list", "-a", "-puqR", mount_point };
        SystemCmd cmd(shellify(shell, cmd_args));
 
        if (cmd.retcode() != 0)
@@ -157,9 +157,9 @@ namespace snapper
     }
 
 
-    CmdBtrfsSubvolumeShow::CmdBtrfsSubvolumeShow(const Shell& shell, const string& mount_point)
+    CmdBtrfsSubvolumeShow::CmdBtrfsSubvolumeShow(const string& btrfs_bin, const Shell& shell, const string& mount_point)
     {
-       SystemCmd::Args cmd_args = { BTRFS_BIN, "subvolume", "show", mount_point };
+       SystemCmd::Args cmd_args = { btrfs_bin, "subvolume", "show", mount_point };
        SystemCmd cmd(shellify(shell, cmd_args));
 
        if (cmd.retcode() != 0)
index db10c50448f821f580f48b3832c345aace2447a8..86a7e558a0d452a47963e1925da0da6f8235d5bf 100644 (file)
@@ -46,7 +46,7 @@ namespace snapper
        static const long top_level_id = 5;
        static const long unknown_id = -1;
 
-       CmdBtrfsSubvolumeList(const Shell& shell, const string& mount_point);
+       CmdBtrfsSubvolumeList(const string& btrfs_bin, const Shell& shell, const string& mount_point);
 
        /**
         * Entry for every subvolume (unfortunately except the top-level).
@@ -93,7 +93,7 @@ namespace snapper
     {
     public:
 
-       CmdBtrfsSubvolumeShow(const Shell& shell, const string& mount_point);
+       CmdBtrfsSubvolumeShow(const string& btrfs_bin, const Shell& shell, const string& mount_point);
 
        const string& get_uuid() const { return uuid; }
        const string& get_parent_uuid() const { return parent_uuid; }
index 4844c8b6eb452d84d784f3b6a0511841bc0e6d0b..ecda2aaa61442d9b2b3f7e0138e79f4e72135c28 100644 (file)
 namespace snapper
 {
 
-    CmdFindmnt::CmdFindmnt(const Shell& shell, const string& path)
+    CmdFindmnt::CmdFindmnt(const string& findmnt_bin, const Shell& shell, const string& path)
        : path(path)
     {
-       SystemCmd::Args cmd_args = { FINDMNT_BIN, "--json", "--target", path };
+       SystemCmd::Args cmd_args = { findmnt_bin, "--json", "--target", path };
        SystemCmd cmd(shellify(shell, cmd_args));
 
        if (cmd.retcode() != 0)
index 09cbea9691474df9bebbb6bc708c7dfa02dd921c..9a251419f650cf1a7f32a0b8ab9f96138daf039d 100644 (file)
@@ -41,7 +41,7 @@ namespace snapper
     {
     public:
 
-       CmdFindmnt(const Shell& shell, const string& path);
+       CmdFindmnt(const string& findmnt_bin, const Shell& shell, const string& path);
 
        const string& get_source() const { return source; }
        const string& get_target() const { return target; }
index 9600fdcbd8deddd1725be818f46f33001ce9680d..0eb417ab068291fd9e35d3e5ad00d284bba2332d 100644 (file)
 namespace snapper
 {
 
-    CmdRealpath::CmdRealpath(const Shell& shell, const string& path)
+    CmdRealpath::CmdRealpath(const string& realpath_bin, const Shell& shell, const string& path)
        : path(path)
     {
-       SystemCmd::Args cmd_args = { REALPATH_BIN, path };
+       SystemCmd::Args cmd_args = { realpath_bin, path };
        SystemCmd cmd(shellify(shell, cmd_args));
 
        if (cmd.retcode() != 0)
index 9668713ddc560632d43cfbd69435ebb1115efdd1..c69afb6249b9d7df2c2bf2e4f2113c65c1a17b57 100644 (file)
@@ -41,7 +41,7 @@ namespace snapper
     {
     public:
 
-       CmdRealpath(const Shell& shell, const string& path);
+       CmdRealpath(const string& realpath_bin, const Shell& shell, const string& path);
 
        const string& get_realpath() const { return realpath; }
 
index af7046f09533b0528ebd3f60397404c98bf192ba..3e6eb2f64b30f8579bcaf8d995e94a8471c9860c 100644 (file)
@@ -267,7 +267,7 @@ namespace snapper
 
            // Query additional information (uuids, read-only) from btrfs.
 
-           CmdBtrfsSubvolumeShow extra(shell_source, backup_config.source_path + "/" SNAPSHOTS_NAME "/" +
+           CmdBtrfsSubvolumeShow extra(BTRFS_BIN, shell_source, backup_config.source_path + "/" SNAPSHOTS_NAME "/" +
                                        to_string(num) + "/" SNAPSHOT_NAME);
 
            TheBigThing the_big_thing(num);
@@ -297,10 +297,10 @@ namespace snapper
        // In case the target-path is a symbolic link (or includes things like "/../") we
        // need a lookup for the realpath first.
 
-       CmdRealpath cmd_realpath(shell_target, backup_config.target_path);
+       CmdRealpath cmd_realpath(backup_config.target_realpath_bin, shell_target, backup_config.target_path);
        const string target_path = cmd_realpath.get_realpath();
 
-       CmdFindmnt cmd_findmnt(shell_target, target_path);
+       CmdFindmnt cmd_findmnt(backup_config.target_findmnt_bin, shell_target, target_path);
        const string mount_point = cmd_findmnt.get_target();
 
        if (target_path.size() < mount_point.size())
@@ -309,7 +309,7 @@ namespace snapper
        if (!boost::starts_with(target_path, mount_point))
            SN_THROW(Exception("unsupported target-path setup"));
 
-       CmdBtrfsSubvolumeList target_snapshots(shell_target, mount_point);
+       CmdBtrfsSubvolumeList target_snapshots(backup_config.target_btrfs_bin, shell_target, mount_point);
 
        string start;
        if (target_path != mount_point)
@@ -339,7 +339,7 @@ namespace snapper
 
            // Query additional information (receive-uuid, read-only) from btrfs.
 
-           CmdBtrfsSubvolumeShow y(shell_target, target_path + "/" + path);
+           CmdBtrfsSubvolumeShow y(backup_config.target_btrfs_bin, shell_target, target_path + "/" + path);
 
            bool is_read_only = y.is_read_only();
            if (!is_read_only)
index 8828359558a21679dd2e390115ba548f51c3ed6a..a486fa3b4d504239bfd469e047598e5f8357d6b3 100644 (file)
@@ -2,13 +2,13 @@
 <refentry id='snapper-backup-configs5'>
 
   <refentryinfo>
-    <date>2024-11-05</date>
+    <date>2024-12-17</date>
   </refentryinfo>
 
   <refmeta>
     <refentrytitle>snapper-backup-configs</refentrytitle>
     <manvolnum>5</manvolnum>
-    <refmiscinfo class='date'>2024-11-05</refmiscinfo>
+    <refmiscinfo class='date'>2024-12-17</refmiscinfo>
     <refmiscinfo class='version'>@VERSION@</refmiscinfo>
     <refmiscinfo class='manual'>Filesystem Snapshot Management</refmiscinfo>
   </refmeta>
          password or passphrase. Optional for target mode ssh-push.</para>
        </listitem>
       </varlistentry>
+
+      <varlistentry>
+       <term><option>target-btrfs-bin</option></term>
+       <listitem>
+         <para>Location of the btrfs binary on the target. Optional.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term><option>target-realpath-bin</option></term>
+       <listitem>
+         <para>Location of the realpath binary on the target. Optional.</para>
+       </listitem>
+      </varlistentry>
+
+      <varlistentry>
+       <term><option>target-findmnt-bin</option></term>
+       <listitem>
+         <para>Location of the findmnt binary on the target. Optional.</para>
+       </listitem>
+      </varlistentry>
+
     </variablelist>
   </refsect1>
 
index 31c950d429d1e895a263504dd8341fada8f21105..a1ceecdf766a3fd65c59d4aedce1f7848925c26d 100644 (file)
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Tue Dec 17 09:14:46 CET 2024 - aschnell@suse.com
+
+- make some binary paths used in snbk configurable
+  (gh#openSUSE/snapper#970)
+
 -------------------------------------------------------------------
 Mon Dec 02 16:51:50 CET 2024 - aschnell@suse.com