Added InstallDir.DATA_OVERRIDES and modified install dir sorting to make use of it

DESTPATH has been renamed to PATCHDIR to make its purpose more clear
parent 7540889f
Pipeline #61541569 passed with stages
in 3 minutes and 36 seconds
......@@ -28,13 +28,14 @@ class InstallDir:
def __init__(self, path, **kwargs):
self.PATH = path
self.REQUIRED_USE = kwargs.get("REQUIRED_USE", "")
self.DESTPATH = kwargs.get("DESTPATH", ".")
self.PATCHDIR = kwargs.get("PATCHDIR", ".")
self.PLUGINS = kwargs.get("PLUGINS", [])
self.ARCHIVES = kwargs.get("ARCHIVES", [])
self.SOURCE = kwargs.get("SOURCE", None)
self.WHITELIST = kwargs.get("WHITELIST", None)
self.BLACKLIST = kwargs.get("BLACKLIST", None)
self.RENAME = kwargs.get("RENAME", None)
self.DATA_OVERRIDES = kwargs.get("DATA_OVERRIDES", "")
class File:
......@@ -227,7 +228,7 @@ class Pybuild1(Pybuild):
def update_config(self, config, install_dir):
path = os.path.normpath(
os.path.join(MOD_DIR, self.CATEGORY, self.MN, install_dir.DESTPATH)
os.path.join(MOD_DIR, self.CATEGORY, self.MN, install_dir.PATCHDIR)
)
# Add data directory
......@@ -245,7 +246,7 @@ class Pybuild1(Pybuild):
def clean_config(self, config, install_dir):
path = os.path.normpath(
os.path.join(MOD_DIR, self.CATEGORY, self.MN, install_dir.DESTPATH)
os.path.join(MOD_DIR, self.CATEGORY, self.MN, install_dir.PATCHDIR)
)
# Add data directory
......@@ -266,7 +267,7 @@ class Pybuild1(Pybuild):
):
print(
"Installing directory {} into {}".format(
install_dir.PATH, install_dir.DESTPATH
install_dir.PATH, install_dir.PATCHDIR
)
)
sourcedir, ext = os.path.splitext(install_dir.SOURCE)
......@@ -276,10 +277,10 @@ class Pybuild1(Pybuild):
source = os.path.join(self.WORKDIR, sourcedir, install_dir.PATH)
if install_dir.RENAME is None:
dest = os.path.join(self.D, install_dir.DESTPATH)
dest = os.path.join(self.D, install_dir.PATCHDIR)
else:
dest = os.path.join(
self.D, os.path.join(install_dir.DESTPATH, install_dir.RENAME)
self.D, os.path.join(install_dir.PATCHDIR, install_dir.RENAME)
)
for file in install_dir.ARCHIVES + install_dir.PLUGINS:
......@@ -453,7 +454,7 @@ class Pybuild1(Pybuild):
return True
def get_dir_path(self, install_dir):
return os.path.join(MOD_DIR, self.CATEGORY, self.MN, install_dir.DESTPATH)
return os.path.join(MOD_DIR, self.CATEGORY, self.MN, install_dir.PATCHDIR)
def get_file_path(self, install_dir, esp):
return os.path.join(self.get_dir_path(install_dir), esp.NAME)
......@@ -5,6 +5,7 @@ from typing import Dict, Iterable, List, Mapping, Set
from functools import lru_cache
import sys
import os
from enum import Enum
from colorama import Fore
from portmod.repo.loader import load_mod, load_all_installed, load_installed_mod
......@@ -223,27 +224,32 @@ def sort_config():
# Determine all Directories that are enabled
installed = [mod for group in load_all_installed().values() for mod in group]
for mod in installed:
graph[mod.CM] = set()
priorities[mod.CM] = mod.TIER
for install in mod.INSTALL_DIRS:
if check_required_use(
install.REQUIRED_USE, mod.INSTALLED_USE, mod.valid_use
):
default = os.path.normpath(install.PATCHDIR) == "."
path = '"' + mod.get_dir_path(install).rstrip("/.") + '"'
graph[(mod.CM, path, default)] = set()
priorities[(mod.CM, path, default)] = mod.TIER
# Add edges in the graph for each data override
for mod in installed:
for parent in get_all_deps(mod.DATA_OVERRIDES):
atom = next([key for key in graph.keys() if atom_sat(parent, key)])
graph[atom].add(mod.CM)
sorted_mods = tsort(graph, priorities)
new_dirs = []
# Turn the sorted list of atoms into a sorted list of data directories
for atom in sorted_mods:
mod = load_installed_mod(Atom(atom))
for install in mod.INSTALL_DIRS:
if check_required_use(
install.REQUIRED_USE, mod.INSTALLED_USE, mod.valid_use
):
path = '"' + mod.get_dir_path(install).rstrip("/.") + '"'
new_dirs.append(path)
idefault = os.path.normpath(install.PATCHDIR) == "."
ipath = '"' + mod.get_dir_path(install).rstrip("/.") + '"'
for parent in get_all_deps(
mod.DATA_OVERRIDES + " " + install.DATA_OVERRIDES
):
for (atom, path, default) in graph.keys():
if atom_sat(Atom(atom), parent) and default:
graph[(atom, path, default)].add((mod.CM, ipath, idefault))
sorted_mods = tsort(graph, priorities)
new_dirs = [path for (_, path, _) in sorted_mods]
config = read_config()
old_dirs = config["data"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment