Exemplo n.º 1
0
    def spec_build (self, spec_name):
        spec = self.specs[spec_name]
        if self.spec_all_installed (spec):
            return
        checksum_fail_reason = self.failed_checksums.get (spec_name, '')
        if ((not checksum_fail_reason or self.options.lax_checksums)
            and not spec.install_after_build):
            return
        global logger
        if self.options.log == 'build':
            # This is expecially broken with multi-platform builds...
            logger = gub_log.default_logger
        else:
            if self.options.log == 'platform':
                log = os.path.join (spec.settings.logdir, 'build.log')
            else:
                log = os.path.join (spec.settings.logdir,
                                    misc.strip_platform (spec_name)) + '.log'
            if os.path.isfile (log):
                misc.rename_append_time (log)
            logger = gub_log.CommandLogger (log, gub_log.default_logger.threshold)
        if checksum_fail_reason:
            rebuild = 'must'
            if self.options.lax_checksums:
                rebuild = 'should'
            logger.write_log ('%(rebuild)s rebuild: %(spec_name)s\n' % locals (), 'verbose')
        else:
            logger.write_log ('checksum ok: %(spec_name)s\n' % locals (), 'verbose')

        if gub_log.get_numeric_loglevel ('verbose') > logger.threshold:
            logger.write_log ('\n'.join (checksum_fail_reason.split ('\n')[:10]), 'verbose')
        logger.write_log (checksum_fail_reason, 'output')

        if ((checksum_fail_reason and not self.options.lax_checksums)
            or not self.spec_is_installable (spec)):
            deferred_runner = runner.DeferredRunner (logger)
            spec.connect_command_runner (deferred_runner)
            spec.runner.stage ('building package: %s\n' % spec_name)
            skip = self.get_skip_stages () ### + spec.get_done ()
            skip = [x for x in skip if x != self.options.stage]
            
            spec.build (self.options, skip)
            spec.connect_command_runner (None)
            deferred_runner.execute_deferred_commands ()
            checksum_file = spec.expand ('%(checksum_file)s')
            if checksum_file:
                if len (self.checksums[spec_name].split ('\n')) < 5:
                    # Sanity check.  This can't be right.  Do not
                    # overwrite precious [possibly correct] checksum.
                    raise Exception ('BROKEN CHECKSUM:' + self.checksums[spec_name])
                if os.path.isfile (checksum_file):
                    misc.rename_append_time (checksum_file)
                open (checksum_file, 'w').write (self.checksums[spec_name])
            loggedos.system (gub_log.default_logger, spec.expand ('rm -f %(stamp_file)s'))
        # Ugh, pkg_install should be stage
        if spec.install_after_build and not self.spec_all_installed (spec):
            logger.write_log (spec.stage_message ('pkg_install'), 'stage')
            self.spec_install (spec)
        gub_log.default_logger.write_log ('\n', 'stage')
Exemplo n.º 2
0
    def spec_build(self, spec_name):
        spec = self.specs[spec_name]
        if self.spec_all_installed(spec):
            return
        checksum_fail_reason = self.failed_checksums.get(spec_name, '')
        if ((not checksum_fail_reason or self.options.lax_checksums)
                and not spec.install_after_build):
            return
        global logger
        if self.options.log == 'build':
            # This is expecially broken with multi-platform builds...
            logger = gub_log.default_logger
        else:
            if self.options.log == 'platform':
                log = os.path.join(spec.settings.logdir, 'build.log')
            else:
                log = os.path.join(spec.settings.logdir,
                                   misc.strip_platform(spec_name)) + '.log'
            if os.path.isfile(log):
                misc.rename_append_time(log)
            logger = gub_log.CommandLogger(log,
                                           gub_log.default_logger.threshold)
        if checksum_fail_reason:
            rebuild = 'must'
            if self.options.lax_checksums:
                rebuild = 'should'
            logger.write_log('%(rebuild)s rebuild: %(spec_name)s\n' % locals(),
                             'verbose')
        else:
            logger.write_log('checksum ok: %(spec_name)s\n' % locals(),
                             'verbose')

        if gub_log.get_numeric_loglevel('verbose') > logger.threshold:
            logger.write_log('\n'.join(checksum_fail_reason.split('\n')[:10]),
                             'verbose')
        logger.write_log(checksum_fail_reason, 'output')

        if ((checksum_fail_reason and not self.options.lax_checksums)
                or not self.spec_is_installable(spec)):
            deferred_runner = runner.DeferredRunner(logger)
            spec.connect_command_runner(deferred_runner)
            spec.runner.stage('building package: %s\n' % spec_name)
            skip = self.get_skip_stages()  ### + spec.get_done ()
            skip = [x for x in skip if x != self.options.stage]

            spec.build(self.options, skip)
            spec.connect_command_runner(None)
            deferred_runner.execute_deferred_commands()
            checksum_file = spec.expand('%(checksum_file)s')
            if checksum_file:
                if len(self.checksums[spec_name].split('\n')) < 5:
                    # Sanity check.  This can't be right.  Do not
                    # overwrite precious [possibly correct] checksum.
                    raise Exception('BROKEN CHECKSUM:' +
                                    self.checksums[spec_name])
                if os.path.isfile(checksum_file):
                    misc.rename_append_time(checksum_file)
                open(checksum_file, 'w').write(self.checksums[spec_name])
            loggedos.system(gub_log.default_logger,
                            spec.expand('rm -f %(stamp_file)s'))
        # Ugh, pkg_install should be stage
        if spec.install_after_build and not self.spec_all_installed(spec):
            logger.write_log(spec.stage_message('pkg_install'), 'stage')
            self.spec_install(spec)
        gub_log.default_logger.write_log('\n', 'stage')