Esempio n. 1
0
File: package.py Progetto: bosm/bos
    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)
Esempio n. 2
0
File: package.py Progetto: bosm/bos
    def compile(self):

        if self.compile_yes:
            Blog.info("compiling %s" % self.name)
            Bos.get_env(self._native)
            return 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',
                            'compile'], self._get_logdir() + '-compile')
        return (0, None)
Esempio n. 3
0
File: package.py Progetto: bosm/bos
    def prepare(self):

        Blog.info("preparing %s" % self.name)
        self._apply_patch()

        if self.prepare_yes:
            Bos.get_env(self._native)
            return 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',
                            'MK=%s' % os.path.dirname(os.path.join(Bos.topdir, self.mk)),
                            'prepare'], self._get_logdir() + '-prepare')
        return (0, None)
Esempio n. 4
0
File: package.py Progetto: bosm/bos
    def _revert_patch(self):
        """
        revert package patches if available.
        """
        if self._patch and os.path.exists(self._patched):
            for p in reversed(self._patch):
                Blog.debug("reverting %s: %s" % (self.name, p))

                ret,logname = bos_run(
                    ['patch', '-Rp1',
                     '-d', os.path.join(Bos.topdir, self._src),
                     '-i', os.path.join(Bos.topdir, os.path.dirname(self.mk), p)])
                if 0 != ret:
                    Blog.fatal('%s unable to revert patch: %s' % (self.name, p))
            os.unlink(self._patched)
Esempio n. 5
0
File: package.py Progetto: bosm/bos
    def _apply_patch(self):
        """
        apply package patches if available.
        """

        ret = 0
        if self._patch and not os.path.exists(self._patched):
            for p in self._patch:
                Blog.debug("patching %s: %s" % (self.name, p))
                ret,logname = bos_run(
                    ['patch', '-p1',
                     '-d', os.path.join(Bos.topdir, self._src),
                     '-i', os.path.join(Bos.topdir, os.path.dirname(self.mk), p)])
                if 0 != ret:
                    Blog.fatal('%s unable to apply patch: %s' % (self.name, p))

        if 0 == ret and self._patch:
            Bos.touch(self._patched)
Esempio n. 6
0
File: package.py Progetto: bosm/bos
    def install(self):

        ret = 0
        logname = None
        self._uninstall()
        if self.install_yes:
            Blog.info("installing %s" % self.name)
            if not os.path.exists(self._get_stagingdir()): os.makedirs(self._get_stagingdir())
            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',
                                   'DESTDIR=%s' % self._get_stagingdir(),
                                   'install'], self._get_logdir() + '-install')
            if 0 == ret: ret = self._install()
            shutil.rmtree(self._get_stagingdir())

        if 0 == ret:
            ## record package version
            self._version = self._get_version()
            self._flush()
        return (ret, logname)
Esempio n. 7
0
File: package.py Progetto: bosm/bos
    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)