aboutsummaryrefslogtreecommitdiff
path: root/src/allocator.py
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2019-10-13 17:16:35 +0200
committerFlorian Fischer <florian.fl.fischer@fau.de>2019-10-13 17:16:35 +0200
commit19e1ff660db8a6653d67884d10bc830babc1560d (patch)
treeead4b484e82ac7a2b352ea397e36cee1888703a0 /src/allocator.py
parent1c4986fbcfe3a8a012dfade02a4892dc775c7af5 (diff)
downloadallocbench-19e1ff660db8a6653d67884d10bc830babc1560d.tar.gz
allocbench-19e1ff660db8a6653d67884d10bc830babc1560d.zip
improve patch handling in allocator.py
* patches are only applied if they aren't applied already * patch no uses -p0 so git diff patches must be adjusted
Diffstat (limited to 'src/allocator.py')
-rw-r--r--src/allocator.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/allocator.py b/src/allocator.py
index b88b046..c418776 100644
--- a/src/allocator.py
+++ b/src/allocator.py
@@ -89,9 +89,17 @@ class Allocator:
print_status("Patching", self.name, "...")
for patch in self.patches:
with open(patch.format(patchdir=self.patchdir), "rb") as patch_file:
- proc = subprocess.run("patch -p1", shell=True, cwd=cwd,
+ patch_content = patch_file.read()
+
+ # check if patch is already applied
+ proc = subprocess.run(["patch", "-R", "-p0", "-s", "-f", "--dry-run"],
+ cwd=cwd, stderr=None, stdout=None,
+ input=patch_content)
+
+ if proc.returncode != 0:
+ proc = subprocess.run(["patch", "-p0"], cwd=cwd,
stderr=subprocess.PIPE, stdout=stdout,
- input=patch_file.read())
+ input=patch_content)
if proc.returncode:
print_debug(proc.stderr, file=sys.stderr)
@@ -115,7 +123,6 @@ class Allocator:
build_needed = not os.path.isdir(self.dir)
buildtimestamp_path = os.path.join(self.dir, ".buildtime")
- print_status("Building", self.name, "...")
if not build_needed:
print_info2("Old build found. Comparing build time with mtime")
@@ -133,6 +140,7 @@ class Allocator:
if build_needed:
self.prepare()
+ print_status("Building", self.name, "...")
if self.build_cmds:
stdout = subprocess.PIPE if src.globalvars.verbosity < 2 else None