Skip to content

Commit

Permalink
add weak_deps option to alpm
Browse files Browse the repository at this point in the history
  • Loading branch information
Enchufa2 committed Aug 10, 2023
1 parent 23cef62 commit 1dbb804
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions inst/service/backend/alpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@ def _update(handle):
db.update(False)
_db_sync = False

def _install(handle, t, repos, name):
def _install(handle, t, repos, weak_deps, name):
ok, pkg = pycman.action_sync.find_sync_package(name, repos)
t.add_pkg(pkg)
if weak_deps == True:
for optdep in pkg.optdepends:
t.add_pkg(optdep)

def _remove(handle, t, repos, name):
def _remove(handle, t, repos, weak_deps, name):
pkg = handle.get_localdb().get_pkg(name)
t.remove_pkg(pkg)

Expand All @@ -82,13 +85,13 @@ def available(prefixes, exclusions):

return pkgs

def operation(op, prefixes, pkgs, exclusions):
def operation(op, prefixes, pkgs, exclusions, weak_deps=None):
handle = _get_handle()
repos = dict((db.name, db) for db in handle.get_syncdbs())
t = handle.init_transaction()
_update(handle)

fun = partial(op, handle, t, repos)
fun = partial(op, handle, t, repos, weak_deps)
notavail = mark(fun, prefixes, pkgs, exclusions, trans="lower")

try:
Expand All @@ -100,8 +103,8 @@ def operation(op, prefixes, pkgs, exclusions):

return notavail

def install(prefixes, pkgs, exclusions):
return operation(_install, prefixes, pkgs, exclusions)
def install(prefixes, pkgs, exclusions, weak_deps=None):
return operation(_install, prefixes, pkgs, exclusions, weak_deps)

def remove(prefixes, pkgs, exclusions):
return operation(_remove, prefixes, pkgs, exclusions)

0 comments on commit 1dbb804

Please sign in to comment.