Esempio n. 1
0
    def look_for_maintainers(self):
        pkg_md = MetaDataXML(self.metadata, herds=None)
        for maint in pkg_md.maintainers():
            self.maintainers.append(maint.email)

        if len(self.maintainers) == 0:
            self.maintainers.append('*****@*****.**')
Esempio n. 2
0
def get_long_description(pkg_dir: Path) -> str:
    pkg_md = MetaDataXML(str(pkg_dir / "metadata.xml"), "")
    longdescription = ""
    for desc in pkg_md.descriptions():
        longdescription += ("".join(
            list(map(lambda s: s.strip() + " ",
                     desc.split("\n")))).strip().replace("  ", "\n"))
    return longdescription
Esempio n. 3
0
    def maintainers(self):
        # yes, seriously, the only API portage has is direct parser
        # for the XML file
        xml_path = os.path.join(os.path.dirname(self.path), 'metadata.xml')
        try:
            meta = MetaDataXML(xml_path, None)
        except (IOError, OSError) as e:
            if e.errno == errno.ENOENT:
                return ()
            raise

        return tuple(PortagePackageMaintainer(m) for m in meta.maintainers())
Esempio n. 4
0
def rdeps_with_slot(slot_rdeps, slot=None):
    """
    Prints a list of rev-deps which depend on the specified package and slot
    """
    pkg_maints = {}
    pkg_herds = {}
    if not slot_rdeps.has_key(slot):
        # No rdeps using the given slot
        return
    print "-------------------------------"
    print "All packages:"
    print "-------------------------------"
    for pkg in slot_rdeps[slot]:
        pkg_md = MetaDataXML(get_md_path(pkg), get_herds())
        for herd in pkg_md.herds():
            if not pkg_herds.has_key(herd):
                pkg_herds[herd] = []
            pkg_herds[herd].append(pkg)
        for maint in pkg_md.maintainers():
            if not pkg_maints.has_key(maint.email):
                pkg_maints[maint.email] = []
            pkg_maints[maint.email].append(pkg)
        print "\t%s\therds: " % pkg,
        for i in pkg_md.herds():
            print "%s" % i,
        print "\tmaintainers: ",
        for i in pkg_md.maintainers():
            print "%s" % i.email,
        print

    print "-------------------------------"
    print "Herd packages:"
    print "-------------------------------"
    for (herd, pkgs) in pkg_herds.iteritems():
        print "Herd: %s" % herd
        for pkg in pkgs:
            print "\t%s" % pkg

    print "-------------------------------"
    print "Maintainer packages:"
    print "-------------------------------"
    for (maint, pkgs) in pkg_maints.iteritems():
        print "Maintainer: %s" % maint
        for pkg in pkgs:
            print "\t%s" % pkg
Esempio n. 5
0
def get_metadata(pkg):
    metadata = {}

    pkg_metadata = None

    meta_override = os.path.join('metadata', pkg.category, pkg.name,
                                 'metadata.xml')

    try:
        if os.path.exists(meta_override):
            pkg_metadata = MetaDataXML(meta_override)
            output.einfo('Using custom metadata: %s' % meta_override)
        if not pkg_metadata:
            pkg_metadata = pkg.metadata
    except Exception as e:
        output.ewarn('Error when fetching metadata: %s' % str(e))

    if not pkg_metadata:
        return {}

    # Support multiple remote-id and multiple watch
    for upstream in pkg_metadata._xml_tree.findall("upstream"):
        for node in upstream.findall("watch"):
            options = dict(node.attrib)
            options['data'] = node.text

            if "type" in options:
                handler = options['type']
            else:
                handler = "url"
                options['type'] = "url"

            for key in ["versionmangle", "downloadurlmangle"]:
                value = options.get(key, None)
                if value:
                    options[key] = value.split(";")

            if handler not in metadata:
                metadata[handler] = []
            metadata[handler].append(options)

    for upstream in pkg_metadata._xml_tree.findall("upstream"):
        for node in upstream.findall("remote-id"):
            handler = node.attrib.get("type")
            if not handler:
                continue
            if handler in metadata:
                for i in range(len(metadata[handler])):
                    if not metadata[handler][i]['data']:
                        metadata[handler][i]['data'] = node.text
            else:
                metadata[handler] = [{'type': handler, 'data': node.text}]

    return metadata
Esempio n. 6
0
def findpackagedepslotops(porttree, cpv):
    depstr = porttree.dbapi.aux_get(cpv, ["RDEPEND"])[0]
    cleandeps = portage.dep.paren_reduce(depstr)
    for indep in portage.dep.flatten(cleandeps):
        if (portage.dep.isvalidatom(indep)): 
            indepslot = portage.dep.dep_getslot(indep)
            if indepslot == None or not indepslot.endswith("="):
                allavail = porttree.dep_match(indep)
                for inallavail in portage.dep.flatten(allavail):
                    slot = porttree.dbapi.aux_get(inallavail, ["SLOT"])[0]
                    if slot.find("/") > 0:
                        category, pkgname, version, rev = portage.catpkgsplit(cpv)
                        ebuild, path = porttree.dbapi.findname2(cpv)
                        metxml = path+"/"+category+"/"+pkgname+"/metadata.xml"
                        maints=[]
                        try:
                            pkg_md = MetaDataXML(metxml,"/usr/portage/metadata/herds.xml")
                            for maint in pkg_md.maintainers():
                                maints.append(maint.email)
                        except IOError: pass                        
                        print cpv + " - " + inallavail + " - " + slot + " - " + ', '.join(maints)
Esempio n. 7
0
def rdeps_with_slot(slot_rdeps, slot=None):
    """
    Prints a list of rev-deps which depend on the specified package and slot
    """
    pkg_maints = {}
    pkg_herds = {}
    if not slot_rdeps.has_key(slot):
        # No rdeps using the given slot
        return
    print "-------------------------------"
    print "All packages:"
    print "-------------------------------"
    for pkg in slot_rdeps[slot]:
        pkg_md = MetaDataXML(get_md_path(pkg), get_herds())
        for herd in pkg_md.herds():
            if not pkg_herds.has_key(herd):
                pkg_herds[herd] = []
            pkg_herds[herd].append(pkg)
        for maint in pkg_md.maintainers():
            if not pkg_maints.has_key(maint.email):
                pkg_maints[maint.email] = []
            pkg_maints[maint.email].append(pkg)
        print '\t%s\therds: ' % pkg,
        for i in pkg_md.herds():
            print '%s' % i,
        print '\tmaintainers: ',
        for i in pkg_md.maintainers():
            print '%s' % i.email,
        print

    print "-------------------------------"
    print "Herd packages:"
    print "-------------------------------"
    for (herd, pkgs) in pkg_herds.iteritems():
        print 'Herd: %s' % herd
        for pkg in pkgs:
            print '\t%s' % pkg

    print "-------------------------------"
    print "Maintainer packages:"
    print "-------------------------------"
    for (maint, pkgs) in pkg_maints.iteritems():
        print 'Maintainer: %s' % maint
        for pkg in pkgs:
            print '\t%s' % pkg
Esempio n. 8
0
    def _start(self):

        need_builddir = self.phase not in EbuildProcess._phases_without_builddir

        if need_builddir:
            phase_completed_file = os.path.join(
                self.settings['PORTAGE_BUILDDIR'],
                ".%sed" % self.phase.rstrip('e'))
            if not os.path.exists(phase_completed_file):
                # If the phase is really going to run then we want
                # to eliminate any stale elog messages that may
                # exist from a previous run.
                try:
                    os.unlink(
                        os.path.join(self.settings['T'], 'logging',
                                     self.phase))
                except OSError:
                    pass

        if self.phase in ('nofetch', 'pretend', 'setup'):

            use = self.settings.get('PORTAGE_BUILT_USE')
            if use is None:
                use = self.settings['PORTAGE_USE']

            maint_str = ""
            upstr_str = ""
            metadata_xml_path = os.path.join(
                os.path.dirname(self.settings['EBUILD']), "metadata.xml")
            if MetaDataXML is not None and os.path.isfile(metadata_xml_path):
                herds_path = os.path.join(self.settings['PORTDIR'],
                                          'metadata/herds.xml')
                try:
                    metadata_xml = MetaDataXML(metadata_xml_path, herds_path)
                    maint_str = metadata_xml.format_maintainer_string()
                    upstr_str = metadata_xml.format_upstream_string()
                except SyntaxError:
                    maint_str = "<invalid metadata.xml>"

            msg = []
            msg.append("Package:    %s" % self.settings.mycpv)
            if self.settings.get('PORTAGE_REPO_NAME'):
                msg.append("Repository: %s" %
                           self.settings['PORTAGE_REPO_NAME'])
            if maint_str:
                msg.append("Maintainer: %s" % maint_str)
            if upstr_str:
                msg.append("Upstream:   %s" % upstr_str)

            msg.append("USE:        %s" % use)
            relevant_features = []
            enabled_features = self.settings.features
            for x in self._features_display:
                if x in enabled_features:
                    relevant_features.append(x)
            if relevant_features:
                msg.append("FEATURES:   %s" % " ".join(relevant_features))

            # Force background=True for this header since it's intended
            # for the log and it doesn't necessarily need to be visible
            # elsewhere.
            self._elog('einfo', msg, background=True)

        if self.phase == 'package':
            if 'PORTAGE_BINPKG_TMPFILE' not in self.settings:
                self.settings['PORTAGE_BINPKG_TMPFILE'] = \
                 os.path.join(self.settings['PKGDIR'],
                 self.settings['CATEGORY'], self.settings['PF']) + '.tbz2'

        if self.phase in ("pretend", "prerm"):
            env_extractor = BinpkgEnvExtractor(background=self.background,
                                               scheduler=self.scheduler,
                                               settings=self.settings)
            if env_extractor.saved_env_exists():
                self._start_task(env_extractor, self._env_extractor_exit)
                return
            # If the environment.bz2 doesn't exist, then ebuild.sh will
            # source the ebuild as a fallback.

        self._start_lock()
Esempio n. 9
0
	def _start(self):

		need_builddir = self.phase not in EbuildProcess._phases_without_builddir

		if need_builddir:
			phase_completed_file = os.path.join(
				self.settings['PORTAGE_BUILDDIR'],
				".%sed" % self.phase.rstrip('e'))
			if not os.path.exists(phase_completed_file):
				# If the phase is really going to run then we want
				# to eliminate any stale elog messages that may
				# exist from a previous run.
				try:
					os.unlink(os.path.join(self.settings['T'],
						'logging', self.phase))
				except OSError:
					pass

		if self.phase in ('nofetch', 'pretend', 'setup'):

			use = self.settings.get('PORTAGE_BUILT_USE')
			if use is None:
				use = self.settings['PORTAGE_USE']

			maint_str = ""
			upstr_str = ""
			metadata_xml_path = os.path.join(os.path.dirname(self.settings['EBUILD']), "metadata.xml")
			if MetaDataXML is not None and os.path.isfile(metadata_xml_path):
				herds_path = os.path.join(self.settings['PORTDIR'],
					'metadata/herds.xml')
				try:
					metadata_xml = MetaDataXML(metadata_xml_path, herds_path)
					maint_str = metadata_xml.format_maintainer_string()
					upstr_str = metadata_xml.format_upstream_string()
				except SyntaxError:
					maint_str = "<invalid metadata.xml>"

			msg = []
			msg.append("Package:    %s" % self.settings.mycpv)
			if self.settings.get('PORTAGE_REPO_NAME'):
				msg.append("Repository: %s" % self.settings['PORTAGE_REPO_NAME'])
			if maint_str:
				msg.append("Maintainer: %s" % maint_str)
			if upstr_str:
				msg.append("Upstream:   %s" % upstr_str)

			msg.append("USE:        %s" % use)
			relevant_features = []
			enabled_features = self.settings.features
			for x in self._features_display:
				if x in enabled_features:
					relevant_features.append(x)
			if relevant_features:
				msg.append("FEATURES:   %s" % " ".join(relevant_features))

			# Force background=True for this header since it's intended
			# for the log and it doesn't necessarily need to be visible
			# elsewhere.
			self._elog('einfo', msg, background=True)

		if self.phase == 'package':
			if 'PORTAGE_BINPKG_TMPFILE' not in self.settings:
				self.settings['PORTAGE_BINPKG_TMPFILE'] = \
					os.path.join(self.settings['PKGDIR'],
					self.settings['CATEGORY'], self.settings['PF']) + '.tbz2'

		if self.phase in ("pretend", "prerm"):
			env_extractor = BinpkgEnvExtractor(background=self.background,
				scheduler=self.scheduler, settings=self.settings)
			if env_extractor.saved_env_exists():
				self._start_task(env_extractor, self._env_extractor_exit)
				return
			# If the environment.bz2 doesn't exist, then ebuild.sh will
			# source the ebuild as a fallback.

		self._start_lock()
Esempio n. 10
0
    async def _async_start(self):

        need_builddir = self.phase not in EbuildProcess._phases_without_builddir

        if need_builddir:
            phase_completed_file = os.path.join(
                self.settings["PORTAGE_BUILDDIR"],
                ".%sed" % self.phase.rstrip("e"))
            if not os.path.exists(phase_completed_file):
                # If the phase is really going to run then we want
                # to eliminate any stale elog messages that may
                # exist from a previous run.
                try:
                    os.unlink(
                        os.path.join(self.settings["T"], "logging",
                                     self.phase))
                except OSError:
                    pass
            ensure_dirs(
                os.path.join(self.settings["PORTAGE_BUILDDIR"], "empty"))

        if self.phase in ("nofetch", "pretend", "setup"):

            use = self.settings.get("PORTAGE_BUILT_USE")
            if use is None:
                use = self.settings["PORTAGE_USE"]

            maint_str = ""
            upstr_str = ""
            metadata_xml_path = os.path.join(
                os.path.dirname(self.settings["EBUILD"]), "metadata.xml")
            if MetaDataXML is not None and os.path.isfile(metadata_xml_path):
                herds_path = os.path.join(self.settings["PORTDIR"],
                                          "metadata/herds.xml")
                try:
                    metadata_xml = MetaDataXML(metadata_xml_path, herds_path)
                    maint_str = metadata_xml.format_maintainer_string()
                    upstr_str = metadata_xml.format_upstream_string()
                except SyntaxError:
                    maint_str = "<invalid metadata.xml>"

            msg = []
            msg.append("Package:    %s" % self.settings.mycpv)
            if self.settings.get("PORTAGE_REPO_NAME"):
                msg.append("Repository: %s" %
                           self.settings["PORTAGE_REPO_NAME"])
            if maint_str:
                msg.append("Maintainer: %s" % maint_str)
            if upstr_str:
                msg.append("Upstream:   %s" % upstr_str)

            msg.append("USE:        %s" % use)
            relevant_features = []
            enabled_features = self.settings.features
            for x in self._features_display:
                if x in enabled_features:
                    relevant_features.append(x)
            if relevant_features:
                msg.append("FEATURES:   %s" % " ".join(relevant_features))

            # Force background=True for this header since it's intended
            # for the log and it doesn't necessarily need to be visible
            # elsewhere.
            await self._elog("einfo", msg, background=True)

        if self.phase == "package":
            if "PORTAGE_BINPKG_TMPFILE" not in self.settings:
                self.settings["PORTAGE_BINPKG_TMPFILE"] = (os.path.join(
                    self.settings["PKGDIR"],
                    self.settings["CATEGORY"],
                    self.settings["PF"],
                ) + ".tbz2")
Esempio n. 11
0
def get_upstreams(pkg_dir: Path) -> List[Tuple]:
    pkg_md = MetaDataXML(str(pkg_dir / "metadata.xml"), "")
    result = []
    if upstream := pkg_md.upstream():
        for remote in upstream[0].remoteids:
            result += [remote]