def dep_virtual(mysplit, mysettings):
    "Does virtual dependency conversion"
    warnings.warn("portage.dep_virtual() is deprecated", DeprecationWarning, stacklevel=2)
    newsplit = []
    myvirtuals = mysettings.getvirtuals()
    for x in mysplit:
        if isinstance(x, list):
            newsplit.append(dep_virtual(x, mysettings))
        else:
            mykey = dep_getkey(x)
            mychoices = myvirtuals.get(mykey, None)
            if mychoices:
                if len(mychoices) == 1:
                    a = x.replace(mykey, dep_getkey(mychoices[0]), 1)
                else:
                    if x[0] == "!":
                        # blocker needs "and" not "or(||)".
                        a = []
                    else:
                        a = ["||"]
                    for y in mychoices:
                        a.append(x.replace(mykey, dep_getkey(y), 1))
                newsplit.append(a)
            else:
                newsplit.append(x)
    return newsplit
Example #2
0
def dep_virtual(mysplit, mysettings):
    "Does virtual dependency conversion"
    warnings.warn("portage.dep_virtual() is deprecated",
                  DeprecationWarning,
                  stacklevel=2)
    newsplit = []
    myvirtuals = mysettings.getvirtuals()
    for x in mysplit:
        if isinstance(x, list):
            newsplit.append(dep_virtual(x, mysettings))
        else:
            mykey = dep_getkey(x)
            mychoices = myvirtuals.get(mykey, None)
            if mychoices:
                if len(mychoices) == 1:
                    a = x.replace(mykey, dep_getkey(mychoices[0]), 1)
                else:
                    if x[0] == "!":
                        # blocker needs "and" not "or(||)".
                        a = []
                    else:
                        a = ['||']
                    for y in mychoices:
                        a.append(x.replace(mykey, dep_getkey(y), 1))
                newsplit.append(a)
            else:
                newsplit.append(x)
    return newsplit
Example #3
0
 def __init__(self, st):
     """An atom is initialized from an atom string"""
     if not isvalidatom(st):
         st = '=' + st
     cp = dep_getkey(st)
     self.ver = dep_getcpv(st)[len(cp) + 1:] # +1 to strip the leading '-'
     slashparts = cp.split("/")
     self.category = slashparts[0]
     self.name = slashparts[1]
Example #4
0
 def __init__(self, st):
     """An atom is initialized from an atom string"""
     if not isvalidatom(st):
         st = '=' + st
     cp = dep_getkey(st)
     self.ver = dep_getcpv(st)[len(cp) + 1:]  # +1 to strip the leading '-'
     slashparts = cp.split("/")
     self.category = slashparts[0]
     self.name = slashparts[1]
Example #5
0
def extract_cps(atom):
    cp = dep_getkey(atom)
    slot = dep_getslot(atom) or ''
    if slot.endswith('='):
        slot = slot[:-1]
    if slot and slot not in {'*', '0'}:
        return f'{cp}:{slot}'
    else:
        return cp
Example #6
0
def getDependencies(cur_overlay, catpkgs, levels=0, cur_level=0):
	cur_tree = cur_overlay.root
	try:
		with open(os.path.join(cur_tree, 'profiles/repo_name')) as f:
			cur_name = f.readline().strip()
	except FileNotFoundError:
			cur_name = cur_overlay.name
	env = os.environ.copy()
	env['PORTAGE_REPOSITORIES'] = '''
[DEFAULT]
main-repo = %s 

[%s]
location = %s
''' % (cur_name, cur_name, cur_tree)
	p = portage.portdbapi(mysettings=portage.config(env=env,config_profile_path=''))
	p.frozen = False
	mypkgs = set()
	for catpkg in list(catpkgs):
		for pkg in p.cp_list(catpkg):
			if pkg == '':
				print("No match for %s" % catpkg)
				continue
			try:
				aux = p.aux_get(pkg, ["DEPEND", "RDEPEND"])
			except PortageKeyError:
				print("Portage key error for %s" % repr(pkg))
				return mypkgs
			for dep in flatten(use_reduce(aux[0]+" "+aux[1], matchall=True)):
				if len(dep) and dep[0] == "!":
					continue
				try:
					mypkg = dep_getkey(dep)
				except portage.exception.InvalidAtom:
					continue
				if mypkg not in mypkgs:
					mypkgs.add(mypkg)
				if levels != cur_level:
					mypkgs = mypkgs.union(getDependencies(cur_overlay, mypkg, levels=levels, cur_level=cur_level+1))
	return mypkgs
Example #7
0
def scan_profile(path):
    return stack_lists([
        grabfile_package(os.path.join(x, path))
        for x in portage.settings.profiles
    ],
                       incremental=1)


# loaded the stacked packages / packages.build files
pkgs = scan_profile("packages")
buildpkgs = scan_profile("packages.build")

# go through the packages list and strip off all the
# crap to get just the <category>/<package> ... then
# search the buildpkg list for it ... if it's found,
# we replace the buildpkg item with the one in the
# system profile (it may have <,>,=,etc... operators
# and version numbers)
for pkg in pkgs:
    try:
        bidx = buildpkgs.index(dep_getkey(pkg))
        buildpkgs[bidx] = pkg
        if buildpkgs[bidx][0:1] == "*":
            buildpkgs[bidx] = buildpkgs[bidx][1:]
    except Exception:
        pass

for b in buildpkgs:
    sys.stdout.write(b + " ")
Example #8
0
def process(app, appname, portage, craft, indent):
    print("%sProcessing %s" % (indent, app))
    ebuild = "%s-17.08.1.ebuild" % app
    qtdeps = []
    frameworksdeps = []
    kdeappsdeps = []
    otherdeps = []
    qtre = re.compile("\$\(add_qt_dep ([^)]+)\)")
    frameworksre = re.compile("\$\(add_frameworks_dep ([^)]+)\)")
    kdeappsre = re.compile("\$\(add_kdeapps_dep ([^)]+)\)")
    optionalre = re.compile("^[^\?]+\?")

    with open(os.path.join(portage, app, ebuild), 'r') as ebuildfile:
        allfile = ebuildfile.read()
        dependencies = re.search("DEPEND=\"[^\"]*\"", allfile)

        if dependencies:
            deplines = dependencies.group(0).split("\n")

            del deplines[0]  # The first one is always spurious
            del deplines[-1]  # The last one is always spurious

            for d in deplines:
                depline = d.strip()
                qtmatch = qtre.match(depline)
                frameworksmatch = frameworksre.match(depline)
                kdeappsmatch = kdeappsre.match(depline)

                if qtmatch:
                    qtdeps.append(qtmatch.group(1))
                elif frameworksmatch:
                    frameworksdeps.append(frameworksmatch.group(1))
                elif kdeappsmatch:
                    appname = kdeappsmatch.group(1)

                    with subprocess.Popen([
                            "find",
                            os.path.join(craft, "kde", "applications"),
                            "-name", appname
                    ],
                                          stdout=subprocess.PIPE) as find:
                        craftdep = find.stdout.read().decode("utf-8").strip()

                    if len(craftdep) == 0:
                        if not process(appname, appname, portage, craft,
                                       "%s\t" % indent):
                            print("%sCould not add application %s, skipping" %
                                  (indent, appname))

                            return False

                    kdeappsdeps.append(appname)
                elif optionalre.match(depline):
                    print("%sOptional dep %s" % (indent, depline))
                else:
                    if portage_dep.isvalidatom(depline):
                        packagename = portage_dep.dep_getkey(depline).split(
                            "/")[1]

                        # TODO be smart about these types of mappings
                        if packagename == "eigen":
                            packagename = "eigen3"

                        with subprocess.Popen(
                            ["find", craft, "-name", packagename],
                                stdout=subprocess.PIPE) as find:
                            craftdep = find.stdout.read().decode(
                                "utf-8").strip()

                            if len(craftdep) > 0:
                                otherdeps.append(craftdep[len(craft):])
                            else:
                                print("%sDependency %s not found, skipping" %
                                      (indent, packagename))
                                return False
                    else:
                        print("%sGarbage: %s" % (indent, depline))

    fixedframeworks = []

    for f in frameworksdeps:
        with subprocess.Popen(["find", craft, "-name", f],
                              stdout=subprocess.PIPE) as find:
            fixedframeworks.append(
                find.stdout.read().decode("utf-8").strip()[len(craft):])

    qtdepsstr = "\n".join([
        "        self.runtimeDependencies[\"libs/qt5/%s\"] = \"default\"" % q
        for q in qtdeps
    ])
    frameworksdepsstr = "\n".join([
        "        self.runtimeDependencies[\"%s\"] = \"default\"" % f
        for f in fixedframeworks
    ])
    kdeappsdepsstr = "\n".join([
        "        self.runtimeDependencies[\"kde/applications/%s\"] = \"default\""
        % k for k in kdeappsdeps
    ])
    otherdepsstr = "\n".join([
        "        self.runtimeDependencies[\"%s\"] = \"default\"" % o
        for o in otherdeps
    ])
    recipe = template % {
        "appname": appname,
        "qtdeps": qtdepsstr,
        "frameworksdeps": frameworksdepsstr,
        "otherdeps": otherdepsstr
    }
    outdir = os.path.join(craft, "kde", "applications", app)

    os.mkdir(outdir)

    with open(os.path.join(outdir, "%s.py" % app), 'w') as out:
        out.write(recipe)

    return True