Exemple #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)
Exemple #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)
Exemple #3
0
    def __getPackageNames(self, pspec):
        try:
            specFile = pisi.specfile.SpecFile(pspec)
        except:
            logger.error("Could not read pspec file: %s" % pspec)
            sys.exit(1)

        try:
            return [package.name for package in specFile.packages]
        except:
            return [""]
Exemple #4
0
    def __getSrcName(self, pspec):
        try:
            specFile = pisi.specfile.SpecFile(pspec)
        except:
            logger.error("Could not read pspec file: %s" % pspec)
            sys.exit(1)

        try:
            return specFile.source.name
        except:
            return None
Exemple #5
0
    def __getPackageNames(self, pspec):
        try:
            specFile = pisi.specfile.SpecFile(pspec)
        except:
            logger.error("Could not read pspec file: %s" % pspec)
            sys.exit(1)

        try:
            return [package.name for package in specFile.packages]
        except:
            return [""]
Exemple #6
0
    def __getSrcName(self, pspec):
        try:
            specFile = pisi.specfile.SpecFile(pspec)
        except:
            logger.error("Could not read pspec file: %s" % pspec)
            sys.exit(1)

        try:
            return specFile.source.name
        except:
            return None
Exemple #7
0
    def __getBuildDependencies(self, pspec):
        specFile = pisi.specfile.SpecFile()
        try:
            specFile.read(pspec)
        except:
            logger.error("Could not read pspec file: %s" % pspec)
            sys.exit(1)

        deps = []
        for package in specFile.source.buildDependencies:
            deps += [package.package]

        return deps
Exemple #8
0
    def __getBuildDependencies(self, pspec):
        specFile = pisi.specfile.SpecFile()
        try:
            specFile.read(pspec)
        except:
            logger.error("Could not read pspec file: %s" % pspec)
            sys.exit(1)

        deps = []
        for package in specFile.source.buildDependencies:
            deps += [package.package]

        return deps
Exemple #9
0
    def __getRuntimeDependencies(self, pspec):
        try:
            specFile = pisi.specfile.SpecFile(pspec)
        except:
            logger.error("Could not read pspec file: %s" % pspec)
            sys.exit(1)

        deps = []
        for package in specFile.packages:
            for dep in package.runtimeDependencies():
                deps += [dep.package]

        deps = list(set(deps).difference(set([p.name for p in specFile.packages])))

        return deps
Exemple #10
0
    def __getRuntimeDependencies(self, pspec):
        try:
            specFile = pisi.specfile.SpecFile(pspec)
        except:
            logger.error("Could not read pspec file: %s" % pspec)
            sys.exit(1)

        deps = []
        for package in specFile.packages:
            for dep in package.runtimeDependencies():
                deps += [dep.package]

        deps = list(
            set(deps).difference(set([p.name for p in specFile.packages])))

        return deps
Exemple #11
0
    def __init__(self):
        self.d = {}

        if not conf.basedeltarelease:
            return

        # Final local index that should exist
        local_index = os.path.join(conf.buildfarmdir,
                                   "index-%s.xml" % conf.basedeltarelease)

        if not os.path.exists(local_index):
            remote_index = utils.get_remote_tags_repository_index_url()
            try:
                index_file = pisi.file.File(
                    remote_index,
                    mode=pisi.file.File.read,
                    transfer_dir=conf.buildfarmdir,
                    compress=pisi.file.File.COMPRESSION_TYPE_AUTO)
                # Index available, rename it
                os.rename(os.path.join(conf.buildfarmdir, "pisi-index.xml"),
                          local_index)
                os.unlink(os.path.join(conf.buildfarmdir,
                                       "pisi-index.xml.bz2"))
            except:
                logger.error(
                    "Could not fetch %s will not build delta packages against %s release!"
                    % (remote_index, conf.basedeltarelease))
                return

        # Parse it
        doc = piksemel.parse(local_index)

        for specfile in doc.tags("SpecFile"):
            source = specfile.getTag("Source")
            name = source.getTagData("Name")

            history = specfile.getTag("History")
            update = history.getTag("Update")
            release = update.getAttribute("release")

            self.d[name] = release
    def __init__(self):
        self.d = {}

        if not conf.basedeltarelease:
            return

        # Final local index that should exist
        local_index = os.path.join(conf.buildfarmdir, "index-%s.xml" % conf.basedeltarelease)

        if not os.path.exists(local_index):
            remote_index = utils.get_remote_tags_repository_index_url()
            try:
                index_file = pisi.file.File(remote_index,
                                            mode=pisi.file.File.read,
                                            transfer_dir=conf.buildfarmdir,
                                            compress=pisi.file.File.COMPRESSION_TYPE_AUTO)
                # Index available, rename it
                os.rename(os.path.join(conf.buildfarmdir, "pisi-index.xml"), local_index)
                os.unlink(os.path.join(conf.buildfarmdir, "pisi-index.xml.bz2"))
            except:
                logger.error("Could not fetch %s will not build delta packages against %s release!" % (remote_index,
                                                                                                       conf.basedeltarelease))
                return

        # Parse it
        doc = piksemel.parse(local_index)

        for specfile in doc.tags("SpecFile"):
            source = specfile.getTag("Source")
            name = source.getTagData("Name")

            history = specfile.getTag("History")
            update = history.getTag("Update")
            release = update.getAttribute("release")

            self.d[name] = release
Exemple #13
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.")
Exemple #14
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.")