1 |
commit: 5e51027fb293e0eb33ce7398bddff0365f7f7007 |
2 |
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Oct 22 18:52:46 2020 +0000 |
4 |
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Oct 29 15:55:57 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=5e51027f |
7 |
|
8 |
catalyst: Rewrite ismount() to use libmount |
9 |
|
10 |
libmount is provided by util-linux, so this adds a dependency on |
11 |
sys-apps/util-linux[python]. A later patch will make more extensive use |
12 |
of this API. |
13 |
|
14 |
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org> |
15 |
|
16 |
README | 2 +- |
17 |
catalyst/support.py | 14 +++++++------- |
18 |
2 files changed, 8 insertions(+), 8 deletions(-) |
19 |
|
20 |
diff --git a/README b/README |
21 |
index 1cceb63e..594de9e1 100644 |
22 |
--- a/README |
23 |
+++ b/README |
24 |
@@ -17,7 +17,7 @@ simple and reproducable manner. Use at your own risk. |
25 |
Requirements |
26 |
======================= |
27 |
|
28 |
-- Python 3.6 or greater |
29 |
+- Python 3.8 or greater |
30 |
- A generic stage3 tarball for your architecture |
31 |
- A squashfs ebuild repository snapshot |
32 |
- Or an ebuild git repo with sys-fs/squashfs-tools-ng and dev-vcs/git |
33 |
|
34 |
diff --git a/catalyst/support.py b/catalyst/support.py |
35 |
index 4458ed20..ddbd9ab9 100644 |
36 |
--- a/catalyst/support.py |
37 |
+++ b/catalyst/support.py |
38 |
@@ -8,6 +8,8 @@ import time |
39 |
from pathlib import Path |
40 |
from subprocess import Popen |
41 |
|
42 |
+import libmount |
43 |
+ |
44 |
from catalyst import log |
45 |
|
46 |
BASH_BINARY = "/bin/bash" |
47 |
@@ -182,15 +184,13 @@ def read_makeconf(mymakeconffile): |
48 |
|
49 |
def ismount(path): |
50 |
"""Like os.path.ismount, but also support bind mounts""" |
51 |
- if os.path.ismount(path): |
52 |
+ path = Path(path) |
53 |
+ if path.is_mount(): |
54 |
return True |
55 |
|
56 |
- a = os.popen("mount") |
57 |
- mylines = a.readlines() |
58 |
- a.close() |
59 |
- for line in mylines: |
60 |
- mysplit = line.split() |
61 |
- if Path(path) == Path(mysplit[2]): |
62 |
+ cxt = libmount.Context() |
63 |
+ while (fs := cxt.mtab.next_fs()) is not None: |
64 |
+ if path == Path(fs.target): |
65 |
return True |
66 |
|
67 |
return False |