Commit f52cee60 authored by Benjamin Winger's avatar Benjamin Winger

Modified blacklists to not remove files when installing

Instead skips files by passing an ignore function to our modified
version of copytree
parent 5d46680d
Pipeline #61130827 passed with stages
in 3 minutes and 14 seconds
......@@ -9,6 +9,7 @@ import shutil
from urllib.parse import urlparse
from pathlib import Path
from distutils.dir_util import copy_tree
from portmod.util import patch_dir
from portmod.globals import MOD_DIR
from portmod.repo.atom import Atom, InvalidAtom
from portmod.config import read_config, write_config, add_config, remove_config
......@@ -284,22 +285,28 @@ class Pybuild1(Pybuild):
):
os.remove(os.path.join(source, file.NAME))
if install_dir.BLACKLIST is not None:
for file in install_dir.BLACKLIST:
src_path = os.path.join(source, file)
if os.path.isdir(src_path):
shutil.rmtree(src_path)
else:
os.remove(src_path)
if install_dir.WHITELIST is not None:
for file in install_dir.WHITELIST:
src_path = os.path.join(source, file)
dst_path = os.path.join(dest, file)
os.makedirs(os.path.dirname(dst_path))
if os.path.isdir(src_path):
copy_tree(src_path, dst_path)
else:
shutil.copy(src_path, dst_path)
elif install_dir.BLACKLIST is not None:
patch_dir(
source,
dest,
ignore=lambda directory, contents: [
os.path.basename(file)
for file in install_dir.BLACKLIST
if os.path.normpath(
os.path.join(source, os.path.dirname(file))
)
== os.path.normpath(directory)
],
)
else:
copy_tree(source, dest)
else:
......
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