Ejemplo n.º 1
0
Archivo: package.py Proyecto: 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)
Ejemplo n.º 2
0
Archivo: package.py Proyecto: 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)
Ejemplo n.º 3
0
Archivo: package.py Proyecto: 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)
Ejemplo n.º 4
0
Archivo: package.py Proyecto: 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)
Ejemplo n.º 5
0
Archivo: package.py Proyecto: 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)
Ejemplo n.º 6
0
Archivo: bosm.py Proyecto: bosm/bos
def bosm(args):

    args.target = _fuzzy_target(args.target)

    ## cleanup all existing logs
    if 'clean' in args.target:
        try: shutil.rmtree(Bos.logdir)
        except: pass


    ## BOS internal environments required by logging system.
    os.environ['_BOS_DEBUG_'] = 'yes' if args.debug == True else 'no'
    os.environ['_BOS_TRACE_'] = 'yes' if args.trace == True else 'no'
    os.environ['_BOS_VERBOSE_'] = 'yes' if args.verbose == True else 'no'


    ### bootstrap build system
    Bos.setup()
    Blog.debug("entering to build system, topdir: %s" % Bos.topdir)


    if _bootstrapcheck():
        Blog.debug("bootstrap required.")
        Bos.touch(os.path.join(Bos.cachedir, '.rebootstrap'))
        Bos.touch(os.path.join(Bos.cachedir, '.rebuild'))

    ret = 0
    if not 'bootstrap' in args.target:
        Blog.debug("checking to bootstrap ...")
        ret = call(['make', '-C', Bos.cachedir,
                    '-f', Bos.topdir + 'bos/mk/bootstrap.mk',
                    '--no-print-directory'])
        if 0 != ret: Blog.fatal('unable to bootstrap')

    ## from this point on, build system is bootstraped and ready:
    ## - all envorinments are in place and ready to consume build target
    if 'info' in args.target: _print_info()

    if 'all' in args.target: _check_package_version()

    if 0 == ret:
        for target in args.target:
            if target[-5:] == '-info': _print_pkg_info(target[:-5])

            Blog.debug("package %s top-level make" % target)
            call(['make', '-C', Bos.cachedir,
                  '-f', Bos.topdir + 'bos/mk/main.mk',
                  '-j' + str(args.jobs) if args.jobs else '-j',
                  '--no-print-directory', target])

    print ''
    print 'build summary at: {0}'.format(Blog.name())
Ejemplo n.º 7
0
Archivo: bosm.py Proyecto: bosm/bos
def _check_package_version():

    from bomb.package import BosPackage

    names = _all_pkgs()
    for name in names:
        pkg = BosPackage.open(name)

        dot_v = os.path.join(Bos.statesdir, name + '.v')
        dot_d = os.path.join(Bos.statesdir, name + '.d')
        if not os.path.exists(dot_v): Bos.touch(dot_v)

        if True == pkg.is_version_diff():
            if os.path.exists(dot_d):
                Blog.info("%s: rebuild required" % name)
                Bos.touch(dot_v)
        else:
            if not os.path.exists(dot_d):
               Bos.touch(os.path.join(Bos.statesdir, name + '.p'))
               Bos.touch(os.path.join(Bos.statesdir, name + '.f'))
               Bos.touch(os.path.join(Bos.statesdir, name + '.b'))
               Bos.touch(dot_d)