Skip to content

Commit

Permalink
fix: do not copy own database during pyalpm initialization
Browse files Browse the repository at this point in the history
Previous implementation lead to warning in logs in case if the
repository itself wasn't configured on the host
  • Loading branch information
arcan1s committed Sep 25, 2024
1 parent 113a861 commit f0930be
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/ahriman/core/alpm/pacman.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ def __create_handle(self, *, refresh_database: PacmanSynchronization) -> Handle:
database = self.database_init(handle, repository, self.repository_id.architecture)
self.database_copy(handle, database, pacman_root, use_ahriman_cache=use_ahriman_cache)

# install repository database too
local_database = self.database_init(handle, self.repository_id.name, self.repository_id.architecture)
self.database_copy(handle, local_database, pacman_root, use_ahriman_cache=use_ahriman_cache)
# install repository database too (without copying)
self.database_init(handle, self.repository_id.name, self.repository_id.architecture)

if use_ahriman_cache and refresh_database:
self.database_sync(handle, force=refresh_database == PacmanSynchronization.Force)
Expand All @@ -115,6 +114,7 @@ def repository_database(root: Path) -> Path:

if not use_ahriman_cache:
return

# copy root database if no local copy found
pacman_db_path = Path(handle.dbpath)
if not pacman_db_path.is_dir():
Expand All @@ -123,11 +123,13 @@ def repository_database(root: Path) -> Path:
if dst.is_file():
return # file already exists, do not copy
dst.parent.mkdir(mode=0o755, exist_ok=True) # create sync directory if it doesn't exist

src = repository_database(pacman_root)
if not src.is_file():
self.logger.warning("repository %s is set to be used, however, no working copy was found", database.name)
return # database for some reason deos not exist
self.logger.info("copy pacman database from operating system root to ahriman's home")

self.logger.info("copy pacman database %s from operating system root to ahriman's home %s", src, dst)
shutil.copy(src, dst)
self.repository_paths.chown(dst)

Expand Down

0 comments on commit f0930be

Please sign in to comment.