commit: d8b2a96f1d96d1c64b10c3c9607fd8ebf2a983a5 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> AuthorDate: Thu Feb 11 13:11:36 2016 +0000 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> CommitDate: Thu Feb 11 13:11:36 2016 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d8b2a96f
stagebase: avoid using `sed` The `sed -i` command is not portable, so rewrite the logic in pure python. This is faster anyways. Bugzilla: https://bugs.gentoo.org/363577 Reported-by: Yuta SATOH <nigoro.dev <AT> gmail.com> catalyst/base/stagebase.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 8891b3f..e291c30 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -1188,9 +1188,16 @@ class StageBase(TargetBase, ClearBase, GenBase): if os.path.exists(self.settings["chroot_path"] + self.settings["local_overlay"]): cmd("rm -rf " + self.settings["chroot_path"] + self.settings["local_overlay"], "Could not remove " + self.settings["local_overlay"], env=self.env) - cmd("sed -i '/^PORTDIR_OVERLAY/d' "+self.settings["chroot_path"]+\ - self.settings["make_conf"],\ - "Could not remove PORTDIR_OVERLAY from make.conf",env=self.env) + + make_conf = self.settings['chroot_path'] + self.settings['make_conf'] + try: + with open(make_conf) as f: + data = f.readlines() + data = ''.join(x for x in data if not x.startswith('PORTDIR_OVERLAY')) + with open(make_conf, 'w') as f: + f.write(data) + except OSError as e: + raise CatalystError('Could not update %s: %s' % (make_conf, e)) # Clean up old and obsoleted files in /etc if os.path.exists(self.settings["stage_path"]+"/etc"):