def clean(self): if self.clean_yes: Blog.info("cleaning %s" % self.name) Bos.get_env(self._native) ret,logname = bos_run(['make', '-C', os.path.join(Bos.topdir, self._src), '-f', os.path.join(Bos.mkdir, os.path.basename(self.mk)), '--no-print-directory', 'clean']) if 0 != ret: Blog.warn('%s unable to clean' % self.name) self._revert_patch() if self._gitdir: with BosLockFile(os.path.join(Bos.topdir, self._gitdir, '.bos.lock')) as lock: bos_run(['git', '--git-dir=%s' % os.path.join(Bos.topdir, self._gitdir), 'clean', '-Xfd']) self._uninstall() try: for fn in glob.glob('%s.?' % (Bos.statesdir + self.name)): os.unlink(fn) Bos.touch(Bos.statesdir + self.name + '.v') except OSError as e: Blog.warn(e.strerror + ': ' + e.filename) try: shutil.rmtree(os.path.dirname(self._get_logdir())) except: pass return (0, None)
def _get_gitdir(self): gitdir = None if self._src: from subprocess import Popen, PIPE out, err = Popen('cd %s; git rev-parse --show-toplevel' % os.path.join(Bos.topdir, self._src), shell = True, stdout = PIPE, stderr = PIPE ).communicate() if err: Blog.warn('%s: not a git repository.' % os.path.join(Bos.topdir, self._src)) else: gitdir = os.path.join(out.strip(), '.git')[len(Bos.topdir):] return gitdir
def purge(self): if self.clean_yes: Blog.info("purging %s" % self.name) Bos.get_env(self._native) ret,logname = bos_run(['make', '-C', os.path.join(Bos.topdir, self._src), '-f', os.path.join(Bos.mkdir, os.path.basename(self.mk)), '--no-print-directory', 'clean']) if 0 != ret: Blog.warn('%s unable to clean' % self.name) self._revert_patch() if self._gitdir: with BosLockFile(os.path.join(Bos.topdir, self._gitdir, '.bos.lock')) as lock: from subprocess import Popen, PIPE Popen('rm -fr %s/*' % os.path.join(Bos.topdir, self._src), shell = True, stdout = PIPE, stderr = PIPE ).communicate() Popen('cd %s/.. && git reset --hard' % os.path.join(Bos.topdir, self._gitdir), shell = True, stdout = PIPE, stderr = PIPE ).communicate() self._purge() try: for fn in glob.glob('%s.?' % (Bos.statesdir + self.name)): os.unlink(fn) Bos.touch(Bos.statesdir + self.name + '.v') except OSError as e: Blog.warn(e.strerror + ': ' + e.filename) try: shutil.rmtree(os.path.dirname(self._get_logdir())) except: pass return (0, None)