public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/, /
@ 2020-10-29 16:04 Matt Turner
  0 siblings, 0 replies; only message in thread
From: Matt Turner @ 2020-10-29 16:04 UTC (permalink / raw
  To: gentoo-commits

commit:     5e51027fb293e0eb33ce7398bddff0365f7f7007
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 22 18:52:46 2020 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 15:55:57 2020 +0000
URL:        https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=5e51027f

catalyst: Rewrite ismount() to use libmount

libmount is provided by util-linux, so this adds a dependency on
sys-apps/util-linux[python]. A later patch will make more extensive use
of this API.

Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 README              |  2 +-
 catalyst/support.py | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/README b/README
index 1cceb63e..594de9e1 100644
--- a/README
+++ b/README
@@ -17,7 +17,7 @@ simple and reproducable manner. Use at your own risk.
 Requirements
 =======================
 
-- Python 3.6 or greater
+- Python 3.8 or greater
 - A generic stage3 tarball for your architecture
 - A squashfs ebuild repository snapshot
   - Or an ebuild git repo with sys-fs/squashfs-tools-ng and dev-vcs/git

diff --git a/catalyst/support.py b/catalyst/support.py
index 4458ed20..ddbd9ab9 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -8,6 +8,8 @@ import time
 from pathlib import Path
 from subprocess import Popen
 
+import libmount
+
 from catalyst import log
 
 BASH_BINARY = "/bin/bash"
@@ -182,15 +184,13 @@ def read_makeconf(mymakeconffile):
 
 def ismount(path):
     """Like os.path.ismount, but also support bind mounts"""
-    if os.path.ismount(path):
+    path = Path(path)
+    if path.is_mount():
         return True
 
-    a = os.popen("mount")
-    mylines = a.readlines()
-    a.close()
-    for line in mylines:
-        mysplit = line.split()
-        if Path(path) == Path(mysplit[2]):
+    cxt = libmount.Context()
+    while (fs := cxt.mtab.next_fs()) is not None:
+        if path == Path(fs.target):
             return True
 
     return False


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-10-29 16:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-29 16:04 [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/, / Matt Turner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox