From ba4b14741dd5d9377822fef6ea2487c21e6c3ef1 Mon Sep 17 00:00:00 2001 From: Safa Ariman Date: Sun, 4 Aug 2019 17:35:59 +0300 Subject: [PATCH] fix pisitools and shelltools --- pisi/actionsapi/pisitools.py | 31 +++++++++++++++++++++++++++++++ pisi/actionsapi/shelltools.py | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/pisi/actionsapi/pisitools.py b/pisi/actionsapi/pisitools.py index 0b8e05db..eceead38 100644 --- a/pisi/actionsapi/pisitools.py +++ b/pisi/actionsapi/pisitools.py @@ -282,3 +282,34 @@ def removeDir(destinationDirectory): for directory in destdirGlob: unlinkDir(directory) + + +class Flags: + def __init__(self, *evars): + self.evars = evars + + def add(self, *flags): + for evar in self.evars: + os.environ[evar] = " ".join(os.environ[evar].split() + [f.strip() for f in flags]) + + def remove(self, *flags): + for evar in self.evars: + os.environ[evar] = " ".join([v for v in os.environ[evar].split() if v not in [f.strip() for f in flags]]) + + def replace(self, old_val, new_val): + for evar in self.evars: + os.environ[evar] = " ".join([new_val if v == old_val else v for v in os.environ[evar].split()]) + + def sub(self, pattern, repl, count=0, flags=0): + for evar in self.evars: + os.environ[evar] = re.sub(pattern, repl, os.environ[evar], count, flags) + + def reset(self): + for evar in self.evars: + os.environ[evar] = "" + + +cflags = Flags("CFLAGS") +ldflags = Flags("LDFLAGS") +cxxflags = Flags("CXXFLAGS") +flags = Flags("CFLAGS", "CXXFLAGS") diff --git a/pisi/actionsapi/shelltools.py b/pisi/actionsapi/shelltools.py index 8d54487b..73f8d13f 100644 --- a/pisi/actionsapi/shelltools.py +++ b/pisi/actionsapi/shelltools.py @@ -271,7 +271,7 @@ def dirName(filePath): def system(command): - command = string.join(string.split(command)) + command = ' '.join(command.split()) retValue = run_logged(command) #if return value is different than 0, it means error, raise exception