Example #1
0
    def build(self, pspec, ignore_dep = False):
        if not os.path.exists(pspec):
            logger.error("'%s' does not exist." % pspec)

        if conf.sandboxblacklist and \
                utils.get_package_name_from_path(pspec) in conf.sandboxblacklist:
            logger.info("Disabling sandbox for %s" % pspec)
            pisi.api.ctx.set_option("ignore_sandbox", True)

        pisi.api.ctx.set_option("ignore_dependency", ignore_dep)
        logger.info("Building %s" % pspec)
        self.builder = pisi.operations.build.Builder(pspec)

        # This will only make builder search for old packages
        # 2 packages for testing repository
        self.builder.search_old_packages_for_delta(max_count=2,
                                                   search_paths=(utils.get_compiled_packages_directory(),))
        if utils.get_stable_packages_directory():
            # 3 packages for stable repository
            self.builder.search_old_packages_for_delta(max_count=3,
                                                       search_paths=(utils.get_stable_packages_directory(),))

            # and 1 for the previous distribution release (e.g. 2011.1)
            package_name = utils.get_package_name_from_path(pspec)
            last_distro_release = ReleaseCache().get_last_release(package_name)
            if last_distro_release:
                self.builder.search_old_packages_for_delta(release=last_distro_release,
                                                           search_paths=(utils.get_stable_packages_directory(),))

        self.builder.build()

        logger.info("Created package(s): %s" % self.builder.new_packages)
Example #2
0
    def build(self, pspec):
        if not os.path.exists(pspec):
            logger.error("'%s' does not exist." % pspec)

        if conf.sandboxblacklist and \
                utils.get_package_name_from_path(pspec) in conf.sandboxblacklist:
            logger.info("Disabling sandbox for %s" % pspec)
            pisi.api.ctx.set_option("ignore_sandbox", True)

        logger.info("Building %s" % pspec)
        self.builder = pisi.operations.build.Builder(pspec)

        # This will only make builder search for old packages
        # 2 packages for testing repository
        self.builder.search_old_packages_for_delta(
            max_count=2,
            search_paths=(utils.get_compiled_packages_directory(), ))
        if utils.get_stable_packages_directory():
            # 3 packages for stable repository
            self.builder.search_old_packages_for_delta(
                max_count=3,
                search_paths=(utils.get_stable_packages_directory(), ))

            # and 1 for the previous distribution release (e.g. 2011.1)
            package_name = utils.get_package_name_from_path(pspec)
            last_distro_release = ReleaseCache().get_last_release(package_name)
            if last_distro_release:
                self.builder.search_old_packages_for_delta(
                    release=last_distro_release,
                    search_paths=(utils.get_stable_packages_directory(), ))

        self.builder.build()

        logger.info("Created package(s): %s" % self.builder.new_packages)
Example #3
0
def send(msg, pspec = "", _type = "", subject=""):

    if not conf.sendemail:
        logger.info("Sending of notification e-mails is turned off.")
        return


    # Authentication stuff
    (username, password) = Auth().get_credentials("Mailer")

    # subjectID: ex: [release/{devel,stable}/arch]
    subject_id = "%s/%s/%s" % (conf.release.capitalize(),
                               conf.subrepository,
                               conf.architecture)

    logs_dir = "%s/%s/%s" % (conf.release,
                             conf.subrepository,
                             conf.architecture)


    recipients_name, recipients_email = [], []
    last_updater_name, last_updater_email = "", "" 
    logfilename = ""
    package_name_with_component = ""
    package_name = ""
    last_log = []
    if pspec:
        spec = pisi.specfile.SpecFile(os.path.join(utils.get_local_repository_url(), pspec))
        recipients_name.append(spec.source.packager.name)
        recipients_email.append(spec.source.packager.email)
        last_updater_name = spec.history[0].name
        last_updater_email = spec.history[0].email

        package_name = os.path.basename(os.path.dirname(pspec))
        package_name_with_component = utils.get_package_component_path(pspec)

        logfile = os.path.join(utils.get_package_log_directory(),
                               utils.get_package_logfile_name(pspec))
        logfilename = os.path.splitext(os.path.basename(logfile))[0]

        last_log = open(logfile.replace(".txt", ".log")).read().split("\n")[-50:]

        if _type == "check": package_name_with_component = ""

    message = templates.ALL[_type] % {
                                        'log'          : "\n".join(last_log),
                                        'recipientName': " ".join(recipients_name),
                                        'mailTo'       : ", ".join(recipients_email),
                                        'updaterName'  : last_updater_name,
                                        'mailToUpdater': last_updater_email,
                                        'ccList'       : conf.cclist,
                                        'mailFrom'     : conf.mailfrom,
                                        'announceAddr' : conf.announceaddr,
                                        'subject'      : package_name_with_component or subject or _type,
                                        'message'      : msg,
                                        'pspec'        : pspec,
                                        'type'         : _type,
                                        'packagename'  : package_name,
                                        'logfilename'  : logfilename,
                                        'distribution' : conf.name,
                                        'release'      : conf.release.capitalize(),
                                        'arch'         : conf.architecture,
                                        'logsdir'      : logs_dir,
                                        'subjectID'    : subject_id,
                                     }

    try:
        session = smtplib.SMTP(conf.smtpserver, timeout=10)
    except smtplib.SMTPConnectError:
        logger.error("Failed sending e-mail: Couldn't open session on %s." % conf.smtpserver)
        return

    try:
        session.login(username, password)
    except smtplib.SMTPAuthenticationError:
        logger.error("Failed sending e-mail: Authentication failed.")
        return

    try:
        if _type == "announce":
            session.sendmail(conf.mailfrom, conf.announceaddr, message)
        else:
            session.sendmail(conf.mailfrom, recipients_email + conf.cclist.split(","), message)
    except smtplib.SMTPException:
        logger.error("Failed sending e-mail: sendmail() raised an exception.")
Example #4
0
def send(msg, pspec="", _type="", subject=""):

    if not conf.sendemail:
        logger.info("Sending of notification e-mails is turned off.")
        return

    # Authentication stuff
    (username, password) = Auth().get_credentials("Mailer")

    # subjectID: ex: [release/{devel,stable}/arch]
    subject_id = "%s/%s/%s" % (conf.release.capitalize(), conf.subrepository,
                               conf.architecture)

    logs_dir = "%s/%s/%s" % (conf.release, conf.subrepository,
                             conf.architecture)

    recipients_name, recipients_email = [], []
    last_updater_name, last_updater_email = "", ""
    logfilename = ""
    package_name_with_component = ""
    package_name = ""
    last_log = []
    if pspec:
        spec = pisi.specfile.SpecFile(
            os.path.join(utils.get_local_repository_url(), pspec))
        recipients_name.append(spec.source.packager.name)
        recipients_email.append(spec.source.packager.email)
        last_updater_name = spec.history[0].name
        last_updater_email = spec.history[0].email

        package_name = os.path.basename(os.path.dirname(pspec))
        package_name_with_component = utils.get_package_component_path(pspec)

        logfile = os.path.join(utils.get_package_log_directory(),
                               utils.get_package_logfile_name(pspec))
        logfilename = os.path.splitext(os.path.basename(logfile))[0]

        last_log = open(logfile.replace(".txt",
                                        ".log")).read().split("\n")[-50:]

        if _type == "check": package_name_with_component = ""

    message = templates.ALL[_type] % {
        'log': "\n".join(last_log),
        'recipientName': " ".join(recipients_name),
        'mailTo': ", ".join(recipients_email),
        'updaterName': last_updater_name,
        'mailToUpdater': last_updater_email,
        'ccList': conf.cclist,
        'mailFrom': conf.mailfrom,
        'announceAddr': conf.announceaddr,
        'subject': package_name_with_component or subject or _type,
        'message': msg,
        'pspec': pspec,
        'type': _type,
        'packagename': package_name,
        'logfilename': logfilename,
        'distribution': conf.name,
        'release': conf.release.capitalize(),
        'arch': conf.architecture,
        'logsdir': logs_dir,
        'subjectID': subject_id,
    }

    try:
        session = smtplib.SMTP(conf.smtpserver, timeout=10)
    except smtplib.SMTPConnectError:
        logger.error("Failed sending e-mail: Couldn't open session on %s." %
                     conf.smtpserver)
        return

    try:
        session.login(username, password)
    except smtplib.SMTPAuthenticationError:
        logger.error("Failed sending e-mail: Authentication failed.")
        return

    try:
        if _type == "announce":
            session.sendmail(conf.mailfrom, conf.announceaddr, message)
        else:
            session.sendmail(conf.mailfrom,
                             recipients_email + conf.cclist.split(","),
                             message)
    except smtplib.SMTPException:
        logger.error("Failed sending e-mail: sendmail() raised an exception.")