Skip to content

Commit

Permalink
eclean handle when git3-src doesn't exist
Browse files Browse the repository at this point in the history
Bug: https://bugs.gentoo.org/922455

Signed-off-by: Siddhanth Rathod <[email protected]>
  • Loading branch information
hyprsyd committed Jan 19, 2024
1 parent a7846cf commit 5cc6df6
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions pym/gentoolkit/eclean/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@


import os
import shlex
import stat
import sys
import shlex
from functools import partial
from inspect import signature
from typing import Optional
from pathlib import Path
from typing import Optional, Set

import portage
from portage.dep import Atom, use_reduce
Expand Down Expand Up @@ -136,7 +137,7 @@ def findDistfiles(
# gather the files to be cleaned
self.output("...checking limits for %d ebuild sources" % len(pkgs))

vcs = self.vcs_check(_distdir)
vcs = self.vcs_check(Path(_distdir))
checks = self._get_default_checks(size_limit, time_limit, exclude, destructive)
checks.extend(extra_checks)
clean_me = self._check_limits(_distdir, checks, clean_me)
Expand Down Expand Up @@ -335,31 +336,30 @@ def _non_destructive(
deprecated.update(_deprecated)
return pkgs, deprecated

def vcs_check(self, distdir):
def vcs_check(self, distdir: Path) -> Set:
"""Checks $DISTDIR/vcs-src for checkouts which are not in the vardb"""
# For now we only check git
vcs_src = os.path.join(distdir, "git3-src")
if not os.path.exists(vcs_src):
return {}

vcs_src = distdir / "git3-src"
expected_dirs = set()
for i in set(self.vardb.cpv_all()):
if "live" in self.vardb.aux_get(i, ["PROPERTIES"]):
try:
# try to get the dir names of the cloned
# repos from the environment file.
vcs_dir = {
i.split("=")[-1].strip('"')
for i in shlex.split(
self.vardb._aux_env_search(i, ["EVCS_STORE_DIRS"])[
"EVCS_STORE_DIRS"
].strip("()")
)
}
expected_dirs.update(vcs_dir)
except KeyError:
pass
actual_dirs = {os.path.join(vcs_src, i) for i in os.listdir(vcs_src)}
actual_dirs = set()
if vcs_src.is_dir():
for i in set(self.vardb.cpv_all()):
if "live" in self.vardb.aux_get(i, ["PROPERTIES"]):
try:
# try to get the dir names of the cloned
# repos from the environment file.
vcs_dir = {
i.split("=")[-1].strip('"')
for i in shlex.split(
self.vardb._aux_env_search(i, ["EVCS_STORE_DIRS"])[
"EVCS_STORE_DIRS"
].strip("()")
)
}
expected_dirs.update(vcs_dir)
except KeyError:
pass
actual_dirs = {str(i) for i in vcs_src.iterdir() if i.is_dir()}
return actual_dirs.difference(expected_dirs)

def _fetch_restricted(self, pkgs_, cpvs):
Expand Down

0 comments on commit 5cc6df6

Please sign in to comment.