* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-05-20 3:39 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-05-20 3:39 UTC (permalink / raw
To: gentoo-commits
commit: f40238e0c5644db5dcaaab9f0305cc9d62b144a1
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Mon May 18 22:52:36 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed May 20 01:49:37 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f40238e0
catalyst: Remove PythonDir setting
Was used to find the arch directory containing, e.g., sparc.py, but all
that code is gone now after the modules were converted to TOML.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/defaults.py | 1 -
catalyst/main.py | 3 ---
2 files changed, 4 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 404f4892..f6bc1e14 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -64,7 +64,6 @@ confdefaults = {
"options": set(),
"pkgdir": "/var/cache/binpkgs",
"port_tmpdir": "/var/tmp/portage",
- "PythonDir": "./catalyst",
"repo_basedir": "/var/db/repos",
"repo_name": "gentoo",
"repos": "%(storedir)s/repos",
diff --git a/catalyst/main.py b/catalyst/main.py
index bad712fa..b01d7a6a 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -55,9 +55,6 @@ def parse_config(config_files):
else:
conf_values[x] = confdefaults[x]
- # add our python base directory to use for loading target arch's
- conf_values["PythonDir"] = os.path.dirname(os.path.realpath(__file__))
-
# print out any options messages
for opt in conf_values['options']:
if opt in option_messages:
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
2020-05-20 1:52 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
@ 2020-05-20 3:39 ` Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-05-20 3:39 UTC (permalink / raw
To: gentoo-commits
commit: 3b721ac38a6d86c952e8d65e0bba942aa49a3628
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Mon May 18 22:41:54 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed May 20 01:49:37 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=3b721ac3
catalyst: Switch internal snapshot option parsing to SpecParser
The --snapshot/-s option internally creates a .spec file but uses the
ConfigParser (nominally used for parsing catalyst.conf) rather than
SpecParser (used for parsing .spec files) and as a result has to use
'=' rather than ':' as the key/value delimiter.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/main.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index b01d7a6a..be06ccd7 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -291,8 +291,8 @@ def _main(parser, opts):
mycmdline = list()
if opts.snapshot:
- mycmdline.append('target=snapshot')
- mycmdline.append('snapshot_treeish=' + opts.snapshot)
+ mycmdline.append('target: snapshot')
+ mycmdline.append('snapshot_treeish: ' + opts.snapshot)
conf_values['DEBUG'] = opts.debug
conf_values['VERBOSE'] = opts.debug or opts.verbose
@@ -354,7 +354,7 @@ def _main(parser, opts):
if mycmdline:
try:
- cmdline = catalyst.config.ConfigParser()
+ cmdline = catalyst.config.SpecParser()
cmdline.parse_lines(mycmdline)
addlargs.update(cmdline.get_values())
except CatalystError:
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
2020-05-20 1:52 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
@ 2020-05-20 3:39 ` Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-05-20 3:39 UTC (permalink / raw
To: gentoo-commits
commit: 4c97ff75f71b5fc86b0a3b89bc960966fd0959a6
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Mon May 18 23:43:52 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed May 20 01:49:37 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=4c97ff75
catalyst: Disallow DEBUG and VERBOSE in spec files
Catalyst has --debug/-d and --verbose/-v options for this.
Since conf_values is assigned in a very confusing manner in main.py, I
suspect these values were added to the list due to a misunderstanding.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/defaults.py | 2 --
1 file changed, 2 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 0da717f1..ccabd88d 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -20,13 +20,11 @@ valid_config_file_values.extend([
"compression_mode",
"compressor_arch",
"compressor_options",
- "DEBUG",
"decompressor_search_order",
"digests",
"distcc",
"envscript",
"options",
- "VERBOSE",
])
confdefaults = {
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
2020-05-20 1:52 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
@ 2020-05-20 3:39 ` Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-05-20 3:39 UTC (permalink / raw
To: gentoo-commits
commit: 59a3b592d0ede9f0bb6e323f58443acb6ef3b297
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Mon May 18 23:49:54 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed May 20 01:49:37 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=59a3b592
catalyst: Add a missing options to valid_config_file_values
And remove required_config_file_values since we want to support running
catalyst without a config file.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/defaults.py | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 2f2c907f..412cb956 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -8,18 +8,20 @@ from DeComp.definitions import COMPRESSOR_PROGRAM_OPTIONS, XATTRS_OPTIONS
from DeComp.definitions import DECOMPRESSOR_PROGRAM_OPTIONS, LIST_XATTRS_OPTIONS
-required_config_file_values = [
- "distdir",
- "portdir",
- "sharedir",
- "storedir",
-]
-
-valid_config_file_values = required_config_file_values[:]
-valid_config_file_values.extend([
+valid_config_file_values = frozenset([
"digests",
+ "distdir",
"envscript",
"options",
+ "port_logdir",
+ "repo_basedir",
+ "repo_name",
+ "repos",
+ "sharedir",
+ "storedir",
+ "target_distdir",
+ "target_pkgdir",
+ "var_tmpfs_portage",
])
confdefaults = {
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
2020-05-21 20:25 [gentoo-commits] proj/catalyst:master " Matt Turner
@ 2020-05-20 3:39 ` Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-05-20 3:39 UTC (permalink / raw
To: gentoo-commits
commit: fd731821ae4c7b15c7fedfad794bd3b0d05ebb7a
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Mon May 18 23:34:13 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed May 20 01:49:37 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=fd731821
catalyst: Disallow config file options in spec files
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/support.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index 0925af47..c4a5c797 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -8,7 +8,6 @@ import time
from subprocess import Popen
from catalyst import log
-from catalyst.defaults import valid_config_file_values
BASH_BINARY = "/bin/bash"
@@ -211,7 +210,7 @@ def addl_arg_parse(myspec, addlargs, requiredspec, validspec):
"helper function to help targets parse additional arguments"
messages = []
for x in addlargs.keys():
- if x not in validspec and x not in valid_config_file_values and x not in requiredspec:
+ if x not in validspec and x not in requiredspec:
messages.append("Argument \""+x+"\" not recognized.")
else:
myspec[x] = addlargs[x]
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
2020-05-21 20:25 [gentoo-commits] proj/catalyst:master " Matt Turner
@ 2020-05-20 3:39 ` Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-05-20 3:39 UTC (permalink / raw
To: gentoo-commits
commit: 6ed67c24fe3bb8e3baa8c936249e4507c45f86a2
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Mon May 18 23:48:22 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed May 20 01:49:37 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=6ed67c24
catalyst: Remove spec file options from valid_config_file_values
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/defaults.py | 5 -----
1 file changed, 5 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index ccabd88d..2f2c907f 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -17,12 +17,7 @@ required_config_file_values = [
valid_config_file_values = required_config_file_values[:]
valid_config_file_values.extend([
- "compression_mode",
- "compressor_arch",
- "compressor_options",
- "decompressor_search_order",
"digests",
- "distcc",
"envscript",
"options",
])
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
2020-05-21 20:25 [gentoo-commits] proj/catalyst:master " Matt Turner
@ 2020-05-20 3:39 ` Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-05-20 3:39 UTC (permalink / raw
To: gentoo-commits
commit: 5b1793bc3d71b81c70a83b8fd92c0069c490f64d
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Mon May 18 23:36:41 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed May 20 01:49:37 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=5b1793bc
catalyst: Delete unused {required,valid}_build_targets
Fixes: 11423a21603e ([2 of 3] Update module loading for the new python structure)
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/defaults.py | 19 -------------------
1 file changed, 19 deletions(-)
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index f6bc1e14..0da717f1 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -8,25 +8,6 @@ from DeComp.definitions import COMPRESSOR_PROGRAM_OPTIONS, XATTRS_OPTIONS
from DeComp.definitions import DECOMPRESSOR_PROGRAM_OPTIONS, LIST_XATTRS_OPTIONS
-# these should never be touched
-required_build_targets = [
- "generic_stage_target",
- "targetbase",
-]
-
-# new build types should be added here
-valid_build_targets = [
- "embedded_target",
- "livecd_stage1_target",
- "livecd_stage2_target",
- "netboot_target",
- "snapshot_target",
- "stage1_target",
- "stage2_target",
- "stage3_target",
- "stage4_target",
-]
-
required_config_file_values = [
"distdir",
"portdir",
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
2020-05-20 1:52 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
@ 2020-05-20 3:39 ` Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-05-20 3:39 UTC (permalink / raw
To: gentoo-commits
commit: 8443f89f3c5dfbc011a333e90bfef772a95e47cd
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Tue May 19 00:13:14 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed May 20 01:49:37 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=8443f89f
catalyst: Verify config options against valid_config_file_values
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/main.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 159fe454..543895c6 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -15,7 +15,8 @@ from DeComp.contents import ContentsMap
from catalyst import log
import catalyst.config
-from catalyst.defaults import confdefaults, option_messages, DEFAULT_CONFIG_FILE
+from catalyst.defaults import (confdefaults, option_messages,
+ DEFAULT_CONFIG_FILE, valid_config_file_values)
from catalyst.support import CatalystError
from catalyst.version import get_version
@@ -34,7 +35,12 @@ def parse_config(config_files):
for config_file in config_files:
log.notice('Loading configuration file: %s', config_file)
try:
- conf_values.update(toml.load(config_file))
+ config = toml.load(config_file)
+ for key in config:
+ if key not in valid_config_file_values:
+ log.critical("Unknown option '%s' in config file %s",
+ key, config_file)
+ conf_values.update(config)
except Exception as e:
log.critical('Could not find parse configuration file: %s: %s',
config_file, e)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-05-20 3:39 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-05-20 3:39 UTC (permalink / raw
To: gentoo-commits
commit: 103ae1aaa8a363b0cf2abb667ed13c624b3c431a
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Tue May 19 19:14:29 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed May 20 03:39:21 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=103ae1aa
catalyst: Drop ConfigParser
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/config.py | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/catalyst/config.py b/catalyst/config.py
index b527ada0..e1963f71 100644
--- a/catalyst/config.py
+++ b/catalyst/config.py
@@ -118,14 +118,3 @@ class SpecParser(ParserBase):
def __init__(self, filename=""):
if filename:
self.parse_file(filename)
-
-
-class ConfigParser(ParserBase):
-
- key_value_separator = '='
- multiple_values = False
- empty_values = True
-
- def __init__(self, filename=""):
- if filename:
- self.parse_file(filename)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-22 18:59 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-22 18:59 UTC (permalink / raw
To: gentoo-commits
commit: cbd0a3effad6a0e1dd6ce025f94b13bdb3b6472a
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 22 18:57:25 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=cbd0a3ef
catalyst: Rewrite ismount() to use libmount
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/support.py | 33 +++++++++++----------------------
1 file changed, 11 insertions(+), 22 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index f49315a5..00a95006 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -5,8 +5,11 @@ import os
import re
import shutil
import time
+from pathlib import Path
from subprocess import Popen
+import libmount
+
from catalyst import log
BASH_BINARY = "/bin/bash"
@@ -179,31 +182,17 @@ def read_makeconf(mymakeconffile):
return makeconf
-def pathcompare(path1, path2):
- # Change double slashes to slash
- path1 = re.sub(r"//", r"/", path1)
- path2 = re.sub(r"//", r"/", path2)
- # Removing ending slash
- path1 = re.sub("/$", "", path1)
- path2 = re.sub("/$", "", path2)
-
- if path1 == path2:
- return 1
- return 0
-
-
def ismount(path):
"""Like os.path.ismount, but also support bind mounts"""
if os.path.ismount(path):
- return 1
- a = os.popen("mount")
- mylines = a.readlines()
- a.close()
- for line in mylines:
- mysplit = line.split()
- if pathcompare(path, mysplit[2]):
- return 1
- return 0
+ return True
+
+ cxt = libmount.Context()
+ while (fs := cxt.mtab.next_fs()) is not None:
+ if Path(path) == Path(fs.source):
+ return True
+
+ return False
def addl_arg_parse(myspec, addlargs, requiredspec, validspec):
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-23 4:36 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-23 4:36 UTC (permalink / raw
To: gentoo-commits
commit: d960b7781a171a34172ee1c6351e654d4cdf281b
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: Fri Oct 23 04:36:22 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d960b778
catalyst: Rewrite ismount() to use libmount
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/support.py | 33 +++++++++++----------------------
1 file changed, 11 insertions(+), 22 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index f49315a5..00a95006 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -5,8 +5,11 @@ import os
import re
import shutil
import time
+from pathlib import Path
from subprocess import Popen
+import libmount
+
from catalyst import log
BASH_BINARY = "/bin/bash"
@@ -179,31 +182,17 @@ def read_makeconf(mymakeconffile):
return makeconf
-def pathcompare(path1, path2):
- # Change double slashes to slash
- path1 = re.sub(r"//", r"/", path1)
- path2 = re.sub(r"//", r"/", path2)
- # Removing ending slash
- path1 = re.sub("/$", "", path1)
- path2 = re.sub("/$", "", path2)
-
- if path1 == path2:
- return 1
- return 0
-
-
def ismount(path):
"""Like os.path.ismount, but also support bind mounts"""
if os.path.ismount(path):
- return 1
- a = os.popen("mount")
- mylines = a.readlines()
- a.close()
- for line in mylines:
- mysplit = line.split()
- if pathcompare(path, mysplit[2]):
- return 1
- return 0
+ return True
+
+ cxt = libmount.Context()
+ while (fs := cxt.mtab.next_fs()) is not None:
+ if Path(path) == Path(fs.source):
+ return True
+
+ return False
def addl_arg_parse(myspec, addlargs, requiredspec, validspec):
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-28 20:51 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-28 20:51 UTC (permalink / raw
To: gentoo-commits
commit: 535cfb36161461884fad7222d13fea70d010d584
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 28 20:50:00 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed Oct 28 20:50:00 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=535cfb36
catalyst: Replace pathcompare function
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/support.py | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index f49315a5..4458ed20 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -5,6 +5,7 @@ import os
import re
import shutil
import time
+from pathlib import Path
from subprocess import Popen
from catalyst import log
@@ -179,31 +180,20 @@ def read_makeconf(mymakeconffile):
return makeconf
-def pathcompare(path1, path2):
- # Change double slashes to slash
- path1 = re.sub(r"//", r"/", path1)
- path2 = re.sub(r"//", r"/", path2)
- # Removing ending slash
- path1 = re.sub("/$", "", path1)
- path2 = re.sub("/$", "", path2)
-
- if path1 == path2:
- return 1
- return 0
-
-
def ismount(path):
"""Like os.path.ismount, but also support bind mounts"""
if os.path.ismount(path):
- return 1
+ return True
+
a = os.popen("mount")
mylines = a.readlines()
a.close()
for line in mylines:
mysplit = line.split()
- if pathcompare(path, mysplit[2]):
- return 1
- return 0
+ if Path(path) == Path(mysplit[2]):
+ return True
+
+ return False
def addl_arg_parse(myspec, addlargs, requiredspec, validspec):
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-28 21:33 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-28 21:33 UTC (permalink / raw
To: gentoo-commits
commit: b32c42d1bd0e500a85db0cd17b6252dfa753bb61
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: Wed Oct 28 21:33:01 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b32c42d1
catalyst: Rewrite ismount() to use libmount
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/support.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
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] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-28 22:00 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-28 22:00 UTC (permalink / raw
To: gentoo-commits
commit: 717f5703011109971fc9d64f94a0ae9cbbbecb53
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 28 21:59:17 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed Oct 28 21:59:17 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=717f5703
catalyst: Switch to using snakeoil's Namespace context
This will allow us to run only parts of the build in a new namespace.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/main.py | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 543895c6..f870ab40 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -7,7 +7,7 @@ import textwrap
import toml
-from snakeoil.process import namespaces
+from snakeoil.contexts import Namespace
from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS,
CONTENTS_DEFINITIONS)
@@ -356,15 +356,14 @@ def _main(parser, opts):
# use pid & user namespaces, but snakeoil's namespace module has signal
# transfer issues (CTRL+C doesn't propagate), and user namespaces need
# more work due to Gentoo build process (uses sudo/root/portage).
- namespaces.simple_unshare(
- mount=True, uts=True, ipc=True, pid=False, net=False, user=False,
- hostname='catalyst')
+ with Namespace(mount=True, uts=True, ipc=True, net=False, pid=False,
+ user=False, hostname='catalyst'):
+ # everything is setup, so the build is a go
+ try:
+ success = build_target(addlargs)
+ except KeyboardInterrupt:
+ log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
- # everything is setup, so the build is a go
- try:
- success = build_target(addlargs)
- except KeyboardInterrupt:
- log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
if not success:
sys.exit(2)
sys.exit(0)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-28 22:08 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-28 22:08 UTC (permalink / raw
To: gentoo-commits
commit: 67d7a937df16cc7194986cc5dcc33ec3f6947847
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 28 21:59:17 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed Oct 28 22:08:47 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=67d7a937
catalyst: Switch to using snakeoil's Namespace context
This will allow us to run only parts of the build in a new namespace.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/main.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 543895c6..f4d3b7d7 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -7,7 +7,7 @@ import textwrap
import toml
-from snakeoil.process import namespaces
+from snakeoil.contexts import Namespace
from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS,
CONTENTS_DEFINITIONS)
@@ -356,15 +356,15 @@ def _main(parser, opts):
# use pid & user namespaces, but snakeoil's namespace module has signal
# transfer issues (CTRL+C doesn't propagate), and user namespaces need
# more work due to Gentoo build process (uses sudo/root/portage).
- namespaces.simple_unshare(
- mount=True, uts=True, ipc=True, pid=False, net=False, user=False,
- hostname='catalyst')
+ with Namespace(mount=True, uts=True, ipc=True, net=False, pid=False,
+ user=False, hostname='catalyst'):
+ # everything is setup, so the build is a go
+ try:
+ success = build_target(addlargs)
+ except KeyboardInterrupt:
+ success = False
+ log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
- # everything is setup, so the build is a go
- try:
- success = build_target(addlargs)
- except KeyboardInterrupt:
- log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
if not success:
sys.exit(2)
sys.exit(0)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-28 22:22 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-28 22:22 UTC (permalink / raw
To: gentoo-commits
commit: 0a2be9a29d11499d346d09628fabbe4a3d5b2822
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 28 22:21:50 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed Oct 28 22:22:23 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=0a2be9a2
wip
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/main.py | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index f4d3b7d7..0561aa1d 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -1,4 +1,5 @@
import argparse
+import contextlib
import datetime
import hashlib
import os
@@ -7,7 +8,7 @@ import textwrap
import toml
-from snakeoil.contexts import Namespace
+from snakeoil.process.namespaces import setns, simple_unshare
from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS,
CONTENTS_DEFINITIONS)
@@ -22,6 +23,33 @@ from catalyst.version import get_version
conf_values = confdefaults
+@contextlib.contextmanager
+def namespace(mount=True, uts=True, ipc=True, net=False, pid=False,
+ user=False, hostname=None):
+ namespaces = {
+ (mount, "mnt"): None,
+ (uts, "uts"): None,
+ (ipc, "ipc"): None,
+ (net, "net"): None,
+ (pid, "pid"): None,
+ (user, "user"): None,
+ }
+ pid = os.getpid()
+
+ # Save fds of current namespaces
+ for ns in [ns for ns in namespaces if ns[0]]:
+ fp = open(f"/proc/{pid}/ns/{ns[1]}")
+ namespaces[ns] = fp
+
+ simple_unshare(mount=mount, uts=uts, ipc=ipc, net=net, pid=pid, user=user,
+ hostname=hostname)
+ try:
+ yield None
+ finally:
+ for ns in [ns for ns in namespaces if ns[0]]:
+ fp = namespaces[ns]
+ setns(fp.fileno(), 0)
+ fp.close()
def version():
log.info(get_version())
@@ -356,13 +384,12 @@ def _main(parser, opts):
# use pid & user namespaces, but snakeoil's namespace module has signal
# transfer issues (CTRL+C doesn't propagate), and user namespaces need
# more work due to Gentoo build process (uses sudo/root/portage).
- with Namespace(mount=True, uts=True, ipc=True, net=False, pid=False,
+ with namespace(mount=True, uts=True, ipc=True, net=False, pid=False,
user=False, hostname='catalyst'):
# everything is setup, so the build is a go
try:
success = build_target(addlargs)
except KeyboardInterrupt:
- success = False
log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
if not success:
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-28 23:06 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-28 23:06 UTC (permalink / raw
To: gentoo-commits
commit: e1be09eedea2dba8c605a49d9211c868c2ee4dcc
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 28 21:59:17 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Wed Oct 28 23:06:09 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=e1be09ee
catalyst: ...
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/main.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 50 insertions(+), 9 deletions(-)
diff --git a/catalyst/main.py b/catalyst/main.py
index 543895c6..8f54ba89 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -1,4 +1,5 @@
import argparse
+import contextlib
import datetime
import hashlib
import os
@@ -7,7 +8,7 @@ import textwrap
import toml
-from snakeoil.process import namespaces
+from snakeoil.process.namespaces import setns, simple_unshare
from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS,
CONTENTS_DEFINITIONS)
@@ -22,6 +23,33 @@ from catalyst.version import get_version
conf_values = confdefaults
+@contextlib.contextmanager
+def namespace(mount=True, uts=True, ipc=True, net=False, pid=False,
+ user=False, hostname=None):
+ namespaces = {
+ (mount, "mnt"): None,
+ (uts, "uts"): None,
+ (ipc, "ipc"): None,
+ (net, "net"): None,
+ (pid, "pid"): None,
+ (user, "user"): None,
+ }
+ pid = os.getpid()
+
+ # Save fds of current namespaces
+ for ns in [ns for ns in namespaces if ns[0]]:
+ fp = open(f"/proc/{pid}/ns/{ns[1]}")
+ namespaces[ns] = fp
+
+ simple_unshare(mount=mount, uts=uts, ipc=ipc, net=net, pid=pid, user=user,
+ hostname=hostname)
+ try:
+ yield None
+ finally:
+ for ns in [ns for ns in namespaces if ns[0]]:
+ fp = namespaces[ns]
+ setns(fp.fileno(), 0)
+ fp.close()
def version():
log.info(get_version())
@@ -352,19 +380,32 @@ def _main(parser, opts):
# catalyst cannot be run as a normal user due to chroots, mounts, etc
log.critical('This script requires root privileges to operate')
+ cxt = libmount.Context()
+ print("Before")
+ while (fs := cxt.mtab.next_fs()) is not None:
+ print(fs.target)
+
# Start off by creating unique namespaces to run in. Would be nice to
# use pid & user namespaces, but snakeoil's namespace module has signal
# transfer issues (CTRL+C doesn't propagate), and user namespaces need
# more work due to Gentoo build process (uses sudo/root/portage).
- namespaces.simple_unshare(
- mount=True, uts=True, ipc=True, pid=False, net=False, user=False,
- hostname='catalyst')
+ with namespace(mount=True, uts=True, ipc=True, net=False, pid=False,
+ user=False, hostname='catalyst'):
+ # everything is setup, so the build is a go
+ try:
+ success = build_target(addlargs)
+ cxt = libmount.Context()
+ print("During")
+ while (fs := cxt.mtab.next_fs()) is not None:
+ print(fs.target)
+ except KeyboardInterrupt:
+ log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
+
+ cxt = libmount.Context()
+ print("After")
+ while (fs := cxt.mtab.next_fs()) is not None:
+ print(fs.target)
- # everything is setup, so the build is a go
- try:
- success = build_target(addlargs)
- except KeyboardInterrupt:
- log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
if not success:
sys.exit(2)
sys.exit(0)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-29 3:33 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-29 3:33 UTC (permalink / raw
To: gentoo-commits
commit: 6340855697e98ba4f393b4568810387c538d0245
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 28 20:50:00 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 03:33:08 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=63408556
catalyst: Replace pathcompare function
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/support.py | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index f49315a5..4458ed20 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -5,6 +5,7 @@ import os
import re
import shutil
import time
+from pathlib import Path
from subprocess import Popen
from catalyst import log
@@ -179,31 +180,20 @@ def read_makeconf(mymakeconffile):
return makeconf
-def pathcompare(path1, path2):
- # Change double slashes to slash
- path1 = re.sub(r"//", r"/", path1)
- path2 = re.sub(r"//", r"/", path2)
- # Removing ending slash
- path1 = re.sub("/$", "", path1)
- path2 = re.sub("/$", "", path2)
-
- if path1 == path2:
- return 1
- return 0
-
-
def ismount(path):
"""Like os.path.ismount, but also support bind mounts"""
if os.path.ismount(path):
- return 1
+ return True
+
a = os.popen("mount")
mylines = a.readlines()
a.close()
for line in mylines:
mysplit = line.split()
- if pathcompare(path, mysplit[2]):
- return 1
- return 0
+ if Path(path) == Path(mysplit[2]):
+ return True
+
+ return False
def addl_arg_parse(myspec, addlargs, requiredspec, validspec):
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-29 3:33 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-29 3:33 UTC (permalink / raw
To: gentoo-commits
commit: c24962dfa39cf76bcae004b3e90ce9b7ddf3c66c
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 03:33:10 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=c24962df
catalyst: Rewrite ismount() to use libmount
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/support.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
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] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-29 15:47 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-29 15:47 UTC (permalink / raw
To: gentoo-commits
commit: a27f635128e7aa0f125aa02df33ab431b991254e
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 28 21:59:17 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 15:32:52 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=a27f6351
catalyst: Add and use namespace context manager
Wraps snakeoil's simple_unshare; returns to the previous namespaces on
context exit. Will be used by the next commit.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/context.py | 33 +++++++++++++++++++++++++++++++++
catalyst/main.py | 17 +++++++----------
2 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/catalyst/context.py b/catalyst/context.py
new file mode 100644
index 00000000..b53be56e
--- /dev/null
+++ b/catalyst/context.py
@@ -0,0 +1,33 @@
+
+import contextlib
+import os
+
+from snakeoil.process.namespaces import setns, simple_unshare
+
+@contextlib.contextmanager
+def namespace(mount=False, uts=False, ipc=False, net=False, pid=False,
+ user=False, hostname=None):
+ namespaces = {
+ (mount, "mnt"): None,
+ (uts, "uts"): None,
+ (ipc, "ipc"): None,
+ (net, "net"): None,
+ (pid, "pid"): None,
+ (user, "user"): None,
+ }
+ process_id = os.getpid()
+
+ # Save fds of current namespaces
+ for ns in [ns for ns in namespaces if ns[0]]:
+ fp = open(f"/proc/{process_id}/ns/{ns[1]}")
+ namespaces[ns] = fp
+
+ simple_unshare(mount=mount, uts=uts, ipc=ipc, net=net, pid=pid, user=user,
+ hostname=hostname)
+ try:
+ yield None
+ finally:
+ for ns in [ns for ns in namespaces if ns[0]]:
+ fp = namespaces[ns]
+ setns(fp.fileno(), 0)
+ fp.close()
diff --git a/catalyst/main.py b/catalyst/main.py
index 543895c6..93a4a0d3 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -7,14 +7,13 @@ import textwrap
import toml
-from snakeoil.process import namespaces
-
from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS,
CONTENTS_DEFINITIONS)
from DeComp.contents import ContentsMap
from catalyst import log
import catalyst.config
+from catalyst.context import namespace
from catalyst.defaults import (confdefaults, option_messages,
DEFAULT_CONFIG_FILE, valid_config_file_values)
from catalyst.support import CatalystError
@@ -356,15 +355,13 @@ def _main(parser, opts):
# use pid & user namespaces, but snakeoil's namespace module has signal
# transfer issues (CTRL+C doesn't propagate), and user namespaces need
# more work due to Gentoo build process (uses sudo/root/portage).
- namespaces.simple_unshare(
- mount=True, uts=True, ipc=True, pid=False, net=False, user=False,
- hostname='catalyst')
+ with namespace(mount=True, uts=True, ipc=True, hostname='catalyst'):
+ # everything is setup, so the build is a go
+ try:
+ success = build_target(addlargs)
+ except KeyboardInterrupt:
+ log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
- # everything is setup, so the build is a go
- try:
- success = build_target(addlargs)
- except KeyboardInterrupt:
- log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
if not success:
sys.exit(2)
sys.exit(0)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-29 15:47 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-29 15:47 UTC (permalink / raw
To: gentoo-commits
commit: 7af99d080974b090056788ee3e89ee60931a9fe5
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 28 20:50:00 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 14:50:55 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=7af99d08
catalyst: Replace pathcompare()
Modern Python allows us to do this in a much cleaner way.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/support.py | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index f49315a5..4458ed20 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -5,6 +5,7 @@ import os
import re
import shutil
import time
+from pathlib import Path
from subprocess import Popen
from catalyst import log
@@ -179,31 +180,20 @@ def read_makeconf(mymakeconffile):
return makeconf
-def pathcompare(path1, path2):
- # Change double slashes to slash
- path1 = re.sub(r"//", r"/", path1)
- path2 = re.sub(r"//", r"/", path2)
- # Removing ending slash
- path1 = re.sub("/$", "", path1)
- path2 = re.sub("/$", "", path2)
-
- if path1 == path2:
- return 1
- return 0
-
-
def ismount(path):
"""Like os.path.ismount, but also support bind mounts"""
if os.path.ismount(path):
- return 1
+ return True
+
a = os.popen("mount")
mylines = a.readlines()
a.close()
for line in mylines:
mysplit = line.split()
- if pathcompare(path, mysplit[2]):
- return 1
- return 0
+ if Path(path) == Path(mysplit[2]):
+ return True
+
+ return False
def addl_arg_parse(myspec, addlargs, requiredspec, validspec):
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-29 16:04 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-29 16:04 UTC (permalink / raw
To: gentoo-commits
commit: 9bb9212679f88ca2f9a87650d98c3141f837e2c5
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 28 20:50:00 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=9bb92126
catalyst: Replace pathcompare()
Modern Python allows us to do this in a much cleaner way.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/support.py | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index f49315a5..4458ed20 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -5,6 +5,7 @@ import os
import re
import shutil
import time
+from pathlib import Path
from subprocess import Popen
from catalyst import log
@@ -179,31 +180,20 @@ def read_makeconf(mymakeconffile):
return makeconf
-def pathcompare(path1, path2):
- # Change double slashes to slash
- path1 = re.sub(r"//", r"/", path1)
- path2 = re.sub(r"//", r"/", path2)
- # Removing ending slash
- path1 = re.sub("/$", "", path1)
- path2 = re.sub("/$", "", path2)
-
- if path1 == path2:
- return 1
- return 0
-
-
def ismount(path):
"""Like os.path.ismount, but also support bind mounts"""
if os.path.ismount(path):
- return 1
+ return True
+
a = os.popen("mount")
mylines = a.readlines()
a.close()
for line in mylines:
mysplit = line.split()
- if pathcompare(path, mysplit[2]):
- return 1
- return 0
+ if Path(path) == Path(mysplit[2]):
+ return True
+
+ return False
def addl_arg_parse(myspec, addlargs, requiredspec, validspec):
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-29 16:04 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-29 16:04 UTC (permalink / raw
To: gentoo-commits
commit: f2b6d2b6fb312d5700024aafb0bfdddb8c0e66fa
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 28 21:59:17 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 16:03:41 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=f2b6d2b6
catalyst: Add and use namespace context manager
Wraps snakeoil's simple_unshare; returns to the previous namespaces on
context exit. Will be used by the next commit.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/context.py | 32 ++++++++++++++++++++++++++++++++
catalyst/main.py | 17 +++++++----------
2 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/catalyst/context.py b/catalyst/context.py
new file mode 100644
index 00000000..936b5c6b
--- /dev/null
+++ b/catalyst/context.py
@@ -0,0 +1,32 @@
+
+import contextlib
+import os
+
+from snakeoil.process.namespaces import setns, simple_unshare
+
+@contextlib.contextmanager
+def namespace(mount=False, uts=False, ipc=False, net=False, pid=False,
+ user=False, hostname=None):
+ namespaces = {
+ (mount, "mnt"): None,
+ (uts, "uts"): None,
+ (ipc, "ipc"): None,
+ (net, "net"): None,
+ (pid, "pid"): None,
+ (user, "user"): None,
+ }
+
+ # Save fds of current namespaces
+ for ns in [ns for ns in namespaces if ns[0]]:
+ fp = open(f"/proc/self/ns/{ns[1]}")
+ namespaces[ns] = fp
+
+ simple_unshare(mount=mount, uts=uts, ipc=ipc, net=net, pid=pid, user=user,
+ hostname=hostname)
+ try:
+ yield None
+ finally:
+ for ns in [ns for ns in namespaces if ns[0]]:
+ fp = namespaces[ns]
+ setns(fp.fileno(), 0)
+ fp.close()
diff --git a/catalyst/main.py b/catalyst/main.py
index 543895c6..93a4a0d3 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -7,14 +7,13 @@ import textwrap
import toml
-from snakeoil.process import namespaces
-
from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS,
CONTENTS_DEFINITIONS)
from DeComp.contents import ContentsMap
from catalyst import log
import catalyst.config
+from catalyst.context import namespace
from catalyst.defaults import (confdefaults, option_messages,
DEFAULT_CONFIG_FILE, valid_config_file_values)
from catalyst.support import CatalystError
@@ -356,15 +355,13 @@ def _main(parser, opts):
# use pid & user namespaces, but snakeoil's namespace module has signal
# transfer issues (CTRL+C doesn't propagate), and user namespaces need
# more work due to Gentoo build process (uses sudo/root/portage).
- namespaces.simple_unshare(
- mount=True, uts=True, ipc=True, pid=False, net=False, user=False,
- hostname='catalyst')
+ with namespace(mount=True, uts=True, ipc=True, hostname='catalyst'):
+ # everything is setup, so the build is a go
+ try:
+ success = build_target(addlargs)
+ except KeyboardInterrupt:
+ log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
- # everything is setup, so the build is a go
- try:
- success = build_target(addlargs)
- except KeyboardInterrupt:
- log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
if not success:
sys.exit(2)
sys.exit(0)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-29 16:14 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-29 16:14 UTC (permalink / raw
To: gentoo-commits
commit: 49066b78e514ef9b2d3ede0416a0a3561a4d8450
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 28 21:59:17 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 16:13:47 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=49066b78
catalyst: Add and use namespace context manager
Wraps snakeoil's simple_unshare; returns to the previous namespaces on
context exit. Will be used by the next commit.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/context.py | 32 ++++++++++++++++++++++++++++++++
catalyst/main.py | 17 +++++++----------
2 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/catalyst/context.py b/catalyst/context.py
new file mode 100644
index 00000000..936b5c6b
--- /dev/null
+++ b/catalyst/context.py
@@ -0,0 +1,32 @@
+
+import contextlib
+import os
+
+from snakeoil.process.namespaces import setns, simple_unshare
+
+@contextlib.contextmanager
+def namespace(mount=False, uts=False, ipc=False, net=False, pid=False,
+ user=False, hostname=None):
+ namespaces = {
+ (mount, "mnt"): None,
+ (uts, "uts"): None,
+ (ipc, "ipc"): None,
+ (net, "net"): None,
+ (pid, "pid"): None,
+ (user, "user"): None,
+ }
+
+ # Save fds of current namespaces
+ for ns in [ns for ns in namespaces if ns[0]]:
+ fp = open(f"/proc/self/ns/{ns[1]}")
+ namespaces[ns] = fp
+
+ simple_unshare(mount=mount, uts=uts, ipc=ipc, net=net, pid=pid, user=user,
+ hostname=hostname)
+ try:
+ yield None
+ finally:
+ for ns in [ns for ns in namespaces if ns[0]]:
+ fp = namespaces[ns]
+ setns(fp.fileno(), 0)
+ fp.close()
diff --git a/catalyst/main.py b/catalyst/main.py
index 543895c6..93a4a0d3 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -7,14 +7,13 @@ import textwrap
import toml
-from snakeoil.process import namespaces
-
from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS,
CONTENTS_DEFINITIONS)
from DeComp.contents import ContentsMap
from catalyst import log
import catalyst.config
+from catalyst.context import namespace
from catalyst.defaults import (confdefaults, option_messages,
DEFAULT_CONFIG_FILE, valid_config_file_values)
from catalyst.support import CatalystError
@@ -356,15 +355,13 @@ def _main(parser, opts):
# use pid & user namespaces, but snakeoil's namespace module has signal
# transfer issues (CTRL+C doesn't propagate), and user namespaces need
# more work due to Gentoo build process (uses sudo/root/portage).
- namespaces.simple_unshare(
- mount=True, uts=True, ipc=True, pid=False, net=False, user=False,
- hostname='catalyst')
+ with namespace(mount=True, uts=True, ipc=True, hostname='catalyst'):
+ # everything is setup, so the build is a go
+ try:
+ success = build_target(addlargs)
+ except KeyboardInterrupt:
+ log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
- # everything is setup, so the build is a go
- try:
- success = build_target(addlargs)
- except KeyboardInterrupt:
- log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
if not success:
sys.exit(2)
sys.exit(0)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-29 16:34 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-29 16:34 UTC (permalink / raw
To: gentoo-commits
commit: aefde1b7f8fde821a0ec423c94ecd380add55b43
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 28 21:59:17 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 16:34:10 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=aefde1b7
catalyst: Add and use namespace context manager
Wraps snakeoil's simple_unshare; returns to the previous namespaces on
context exit. Will be used by the next commit.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/context.py | 32 ++++++++++++++++++++++++++++++++
catalyst/main.py | 17 +++++++----------
2 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/catalyst/context.py b/catalyst/context.py
new file mode 100644
index 00000000..8a58f33d
--- /dev/null
+++ b/catalyst/context.py
@@ -0,0 +1,32 @@
+
+import contextlib
+import os
+
+from snakeoil.process.namespaces import setns, simple_unshare
+
+@contextlib.contextmanager
+def namespace(mount=False, uts=False, ipc=False, net=False, pid=False,
+ user=False, hostname=None):
+ namespaces = {
+ (mount, "mnt"): None,
+ (uts, "uts"): None,
+ (ipc, "ipc"): None,
+ (net, "net"): None,
+ (pid, "pid"): None,
+ (user, "user"): None,
+ }
+
+ # Save fds of current namespaces
+ for ns in [ns for ns in namespaces if ns[0]]:
+ fp = open(f"/proc/self/ns/{ns[1]}")
+ namespaces[ns] = fp
+
+ simple_unshare(mount=mount, uts=uts, ipc=ipc, net=net, pid=pid, user=user,
+ hostname=hostname)
+ try:
+ yield
+ finally:
+ for ns in [ns for ns in namespaces if ns[0]]:
+ fp = namespaces[ns]
+ setns(fp.fileno(), 0)
+ fp.close()
diff --git a/catalyst/main.py b/catalyst/main.py
index 543895c6..93a4a0d3 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -7,14 +7,13 @@ import textwrap
import toml
-from snakeoil.process import namespaces
-
from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS,
CONTENTS_DEFINITIONS)
from DeComp.contents import ContentsMap
from catalyst import log
import catalyst.config
+from catalyst.context import namespace
from catalyst.defaults import (confdefaults, option_messages,
DEFAULT_CONFIG_FILE, valid_config_file_values)
from catalyst.support import CatalystError
@@ -356,15 +355,13 @@ def _main(parser, opts):
# use pid & user namespaces, but snakeoil's namespace module has signal
# transfer issues (CTRL+C doesn't propagate), and user namespaces need
# more work due to Gentoo build process (uses sudo/root/portage).
- namespaces.simple_unshare(
- mount=True, uts=True, ipc=True, pid=False, net=False, user=False,
- hostname='catalyst')
+ with namespace(mount=True, uts=True, ipc=True, hostname='catalyst'):
+ # everything is setup, so the build is a go
+ try:
+ success = build_target(addlargs)
+ except KeyboardInterrupt:
+ log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
- # everything is setup, so the build is a go
- try:
- success = build_target(addlargs)
- except KeyboardInterrupt:
- log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
if not success:
sys.exit(2)
sys.exit(0)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2020-10-29 19:05 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2020-10-29 19:05 UTC (permalink / raw
To: gentoo-commits
commit: c84b2805b9de276809e694d506d8faee0eda961b
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 28 21:59:17 2020 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Oct 29 19:05:45 2020 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=c84b2805
catalyst: Add and use namespace context manager
Wraps snakeoil's simple_unshare; returns to the previous namespaces on
context exit. Will be used by the next commit.
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/context.py | 32 ++++++++++++++++++++++++++++++++
catalyst/main.py | 17 +++++++----------
2 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/catalyst/context.py b/catalyst/context.py
new file mode 100644
index 00000000..8a58f33d
--- /dev/null
+++ b/catalyst/context.py
@@ -0,0 +1,32 @@
+
+import contextlib
+import os
+
+from snakeoil.process.namespaces import setns, simple_unshare
+
+@contextlib.contextmanager
+def namespace(mount=False, uts=False, ipc=False, net=False, pid=False,
+ user=False, hostname=None):
+ namespaces = {
+ (mount, "mnt"): None,
+ (uts, "uts"): None,
+ (ipc, "ipc"): None,
+ (net, "net"): None,
+ (pid, "pid"): None,
+ (user, "user"): None,
+ }
+
+ # Save fds of current namespaces
+ for ns in [ns for ns in namespaces if ns[0]]:
+ fp = open(f"/proc/self/ns/{ns[1]}")
+ namespaces[ns] = fp
+
+ simple_unshare(mount=mount, uts=uts, ipc=ipc, net=net, pid=pid, user=user,
+ hostname=hostname)
+ try:
+ yield
+ finally:
+ for ns in [ns for ns in namespaces if ns[0]]:
+ fp = namespaces[ns]
+ setns(fp.fileno(), 0)
+ fp.close()
diff --git a/catalyst/main.py b/catalyst/main.py
index 543895c6..93a4a0d3 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -7,14 +7,13 @@ import textwrap
import toml
-from snakeoil.process import namespaces
-
from DeComp.definitions import (COMPRESS_DEFINITIONS, DECOMPRESS_DEFINITIONS,
CONTENTS_DEFINITIONS)
from DeComp.contents import ContentsMap
from catalyst import log
import catalyst.config
+from catalyst.context import namespace
from catalyst.defaults import (confdefaults, option_messages,
DEFAULT_CONFIG_FILE, valid_config_file_values)
from catalyst.support import CatalystError
@@ -356,15 +355,13 @@ def _main(parser, opts):
# use pid & user namespaces, but snakeoil's namespace module has signal
# transfer issues (CTRL+C doesn't propagate), and user namespaces need
# more work due to Gentoo build process (uses sudo/root/portage).
- namespaces.simple_unshare(
- mount=True, uts=True, ipc=True, pid=False, net=False, user=False,
- hostname='catalyst')
+ with namespace(mount=True, uts=True, ipc=True, hostname='catalyst'):
+ # everything is setup, so the build is a go
+ try:
+ success = build_target(addlargs)
+ except KeyboardInterrupt:
+ log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
- # everything is setup, so the build is a go
- try:
- success = build_target(addlargs)
- except KeyboardInterrupt:
- log.critical('Catalyst build aborted due to user interrupt (Ctrl-C)')
if not success:
sys.exit(2)
sys.exit(0)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
@ 2021-01-28 1:54 Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2021-01-28 1:54 UTC (permalink / raw
To: gentoo-commits
commit: 0a0bc60bac516746b67955abae7d81e281524689
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 24 02:34:06 2021 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Sun Jan 24 02:35:29 2021 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=0a0bc60b
catalyst: Remove fallback make.conf parsing code
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/support.py | 42 +++---------------------------------------
1 file changed, 3 insertions(+), 39 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index f3a865a7..fa652987 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -2,7 +2,6 @@
import glob
import sys
import os
-import re
import shutil
import time
from pathlib import Path
@@ -12,6 +11,8 @@ import libmount
from portage.repository.config import RepoConfig
+from snakeoil.bash import read_bash_dict
+
from catalyst import log
BASH_BINARY = "/bin/bash"
@@ -135,47 +136,10 @@ defined are not preserved. In other words, "foo", "bar", "oni" ordering is prese
print_traceback=True)
-def parse_makeconf(mylines):
- mymakeconf = {}
- pos = 0
- pat = re.compile("([0-9a-zA-Z_]*)=(.*)")
- while pos < len(mylines):
- if len(mylines[pos]) <= 1:
- # skip blanks
- pos += 1
- continue
- if mylines[pos][0] in ["#", " ", "\t"]:
- # skip indented lines, comments
- pos += 1
- continue
- else:
- myline = mylines[pos]
- mobj = pat.match(myline)
- pos += 1
- if mobj.group(2):
- clean_string = re.sub(r"\"", r"", mobj.group(2))
- mymakeconf[mobj.group(1)] = clean_string
- return mymakeconf
-
-
def read_makeconf(mymakeconffile):
if os.path.exists(mymakeconffile):
try:
- try:
- import snakeoil.bash # import snakeoil.fileutils
- return snakeoil.bash.read_bash_dict(mymakeconffile, sourcing_command="source")
- except ImportError:
- try:
- import portage.util
- return portage.util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True)
- except Exception:
- try:
- import portage_util
- return portage_util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True)
- except ImportError:
- with open(mymakeconffile, "r") as myf:
- mylines = myf.readlines()
- return parse_makeconf(mylines)
+ return read_bash_dict(mymakeconffile, sourcing_command="source")
except Exception:
raise CatalystError("Could not parse make.conf file " +
mymakeconffile, print_traceback=True)
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/
2021-01-29 23:50 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
@ 2021-01-28 2:09 ` Matt Turner
0 siblings, 0 replies; 28+ messages in thread
From: Matt Turner @ 2021-01-28 2:09 UTC (permalink / raw
To: gentoo-commits
commit: b8b6de7bc84677d9ae13cf8bfff2c0e6a281ff75
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 24 02:34:06 2021 +0000
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Thu Jan 28 02:06:46 2021 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=b8b6de7b
catalyst: Remove fallback make.conf parsing code
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>
catalyst/support.py | 42 +++---------------------------------------
1 file changed, 3 insertions(+), 39 deletions(-)
diff --git a/catalyst/support.py b/catalyst/support.py
index f3a865a7..fa652987 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -2,7 +2,6 @@
import glob
import sys
import os
-import re
import shutil
import time
from pathlib import Path
@@ -12,6 +11,8 @@ import libmount
from portage.repository.config import RepoConfig
+from snakeoil.bash import read_bash_dict
+
from catalyst import log
BASH_BINARY = "/bin/bash"
@@ -135,47 +136,10 @@ defined are not preserved. In other words, "foo", "bar", "oni" ordering is prese
print_traceback=True)
-def parse_makeconf(mylines):
- mymakeconf = {}
- pos = 0
- pat = re.compile("([0-9a-zA-Z_]*)=(.*)")
- while pos < len(mylines):
- if len(mylines[pos]) <= 1:
- # skip blanks
- pos += 1
- continue
- if mylines[pos][0] in ["#", " ", "\t"]:
- # skip indented lines, comments
- pos += 1
- continue
- else:
- myline = mylines[pos]
- mobj = pat.match(myline)
- pos += 1
- if mobj.group(2):
- clean_string = re.sub(r"\"", r"", mobj.group(2))
- mymakeconf[mobj.group(1)] = clean_string
- return mymakeconf
-
-
def read_makeconf(mymakeconffile):
if os.path.exists(mymakeconffile):
try:
- try:
- import snakeoil.bash # import snakeoil.fileutils
- return snakeoil.bash.read_bash_dict(mymakeconffile, sourcing_command="source")
- except ImportError:
- try:
- import portage.util
- return portage.util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True)
- except Exception:
- try:
- import portage_util
- return portage_util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True)
- except ImportError:
- with open(mymakeconffile, "r") as myf:
- mylines = myf.readlines()
- return parse_makeconf(mylines)
+ return read_bash_dict(mymakeconffile, sourcing_command="source")
except Exception:
raise CatalystError("Could not parse make.conf file " +
mymakeconffile, print_traceback=True)
^ permalink raw reply related [flat|nested] 28+ messages in thread
end of thread, other threads:[~2021-01-28 2:09 UTC | newest]
Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-28 20:51 [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/ Matt Turner
-- strict thread matches above, loose matches on Subject: below --
2021-01-29 23:50 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2021-01-28 2:09 ` [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
2021-01-28 1:54 Matt Turner
2020-10-29 19:05 Matt Turner
2020-10-29 16:34 Matt Turner
2020-10-29 16:14 Matt Turner
2020-10-29 16:04 Matt Turner
2020-10-29 16:04 Matt Turner
2020-10-29 15:47 Matt Turner
2020-10-29 15:47 Matt Turner
2020-10-29 3:33 Matt Turner
2020-10-29 3:33 Matt Turner
2020-10-28 23:06 Matt Turner
2020-10-28 22:22 Matt Turner
2020-10-28 22:08 Matt Turner
2020-10-28 22:00 Matt Turner
2020-10-28 21:33 Matt Turner
2020-10-23 4:36 Matt Turner
2020-10-22 18:59 Matt Turner
2020-05-21 20:25 [gentoo-commits] proj/catalyst:master " Matt Turner
2020-05-20 3:39 ` [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
2020-05-21 20:25 [gentoo-commits] proj/catalyst:master " Matt Turner
2020-05-20 3:39 ` [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
2020-05-21 20:25 [gentoo-commits] proj/catalyst:master " Matt Turner
2020-05-20 3:39 ` [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
2020-05-20 3:39 Matt Turner
2020-05-20 3:39 Matt Turner
2020-05-20 1:52 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2020-05-20 3:39 ` [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
2020-05-20 1:52 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2020-05-20 3:39 ` [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
2020-05-20 1:52 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2020-05-20 3:39 ` [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
2020-05-20 1:52 [gentoo-commits] proj/catalyst:wip/mattst88 " Matt Turner
2020-05-20 3:39 ` [gentoo-commits] proj/catalyst:pending/mattst88 " Matt Turner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox