I can't figure out how to patch a merge request to this package (the
launchpad git configuration does not work for me and/or I cannot figure
the process out) - so here's the patch that should fix this issue:

diff --git a/apt_btrfs_snapshot.py b/apt_btrfs_snapshot.py
index 980c787..6ec4e0e 100644
--- a/apt_btrfs_snapshot.py
+++ b/apt_btrfs_snapshot.py
@@ -66,6 +66,12 @@ class FstabEntry(object):
             self.fs_spec, self.mountpoint, self.fstype,
             self.options, self.dump, self.passno)
 
+    def subvol(self):
+        opt = next((o for o in self.options.split(",") if "subvol=" in o), 
None)
+        if not opt:
+            return None
+        return opt.split("=")[1];
+
 
 class Fstab(list):
     """ a list of FstabEntry items """
@@ -134,7 +140,7 @@ class AptBtrfsSnapshot(object):
             if (
                     entry.mountpoint == "/" and
                     entry.fstype == "btrfs" and
-                    "subvol=@" in entry.options):
+                    "subvol=" in entry.options):
                 return entry
         return None
 
@@ -166,10 +172,17 @@ class AptBtrfsSnapshot(object):
     def create_btrfs_root_snapshot(self, additional_prefix=""):
         mp = self.mount_btrfs_root_volume()
         snap_id = self._get_now_str()
-        source = os.path.join(mp, "@")
+        fsentry = self._get_supported_btrfs_root_fstab_entry()
+        if not fsentry or not fsentry.subvol():
+            raise AptBtrfsNotSupportedError()
+        source = os.path.join(mp, *fsentry.subvol().split("/"))
         target = os.path.join(mp, self.SNAP_PREFIX + additional_prefix +
                               snap_id)
 
+        if not os.path.exists(source):
+            sys.stderr.write("Error: failed to find source subvolume '%s'\n" % 
(source))
+            return False
+
         if os.path.exists(target):
             print(_("INFO: snapshot directory '%s' already exists, "
                     "not creating duplicate") % (target,))

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2064274

Title:
  24.04 The system does not support apt-btrfs-snapshot

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apt-btrfs-snapshot/+bug/2064274/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to