Skip to content

Commit

Permalink
Reapply "pm: adapt oma package manager"
Browse files Browse the repository at this point in the history
This reverts commit 663bcaf.
  • Loading branch information
eatradish authored and MingcongBai committed Aug 7, 2024
1 parent 6a92a67 commit e333f55
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions acbs/pm.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,31 @@ def check_if_available(name: str) -> bool:


def install_from_repo(packages: List[str]):
logging.debug('Installing %s' % packages)
escaped = []
for package in packages:
escaped.append(escape_package_name_install(package))
command = ['apt-get', 'install', '-y', '-o', 'Dpkg::Options::=--force-confnew']
command.extend(escaped)
oma_is_success = install_from_repo_oma(packages)

if not oma_is_success:
logging.debug('Installing %s' % packages)
escaped = []
for package in packages:
escaped.append(escape_package_name_install(package))
command = ['apt-get', 'install', '-y', '-o', 'Dpkg::Options::=--force-confnew']
command.extend(escaped)
try:
subprocess.check_call(command, env={'DEBIAN_FRONTEND': 'noninteractive'})
except subprocess.CalledProcessError:
logging.warning(
'Failed to install dependencies, attempting to correct issues...')
fix_pm_states(escaped)
return

def install_from_repo_oma(packages: List[str]) -> bool:
logging.debug('Installing %s from oma' % packages)
command = ['oma', 'install', '-y', '--force-confnew', '--no-progress']
command.extend(packages)
try:
subprocess.check_call(command, env={'DEBIAN_FRONTEND': 'noninteractive'})
except subprocess.CalledProcessError:
subprocess.check_call(command)
except:
logging.warning(
'Failed to install dependencies, attempting to correct issues...')
fix_pm_states(escaped)
return
'Failed to use oma install dependencies, fallbacking to apt...')
return False
return True

0 comments on commit e333f55

Please sign in to comment.