Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sonic-package-manager/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
'natsort',
'prettyprinter',
'sonic-py-common',
'swsssdk', # Temporary dependency till the issue with py-swsscommon is resolved.
'requests',
'www_authenticate',
'filelock',
],
setup_requires=[
'pytest-runner',
Expand Down
7 changes: 5 additions & 2 deletions src/sonic-package-manager/sonic_package_manager/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

""" Repository Database interface module. """
import json
import os
from dataclasses import dataclass, replace
from typing import Optional, Dict, Callable

from sonic_package_manager.errors import PackageManagerError, PackageNotFoundError, PackageAlreadyExistsError
from sonic_package_manager.version import Version

DB_FILE_PATH = '/var/lib/sonic-package-manager/packages.json'
BASE_LIBRARY_PATH = '/var/lib/sonic-package-manager/'
PACKAGE_MANAGER_DB_FILE_PATH = os.path.join(BASE_LIBRARY_PATH, 'packages.json')
PACKAGE_MANAGER_LOCK_FILE = os.path.join(BASE_LIBRARY_PATH, '.lock')


@dataclass(order=True)
Expand Down Expand Up @@ -176,7 +179,7 @@ def __iter__(self):
yield self.get_package(name)

@staticmethod
def from_file(db_file=DB_FILE_PATH) -> 'PackageDatabase':
def from_file(db_file=PACKAGE_MANAGER_DB_FILE_PATH) -> 'PackageDatabase':
""" Read database content from file. """

def on_save(database):
Expand Down
13 changes: 9 additions & 4 deletions src/sonic-package-manager/sonic_package_manager/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,15 @@ def remove(ctx, name):
@cli.command()
@click.option('-f', '--force', is_flag=True)
@click.option('-y', '--yes', is_flag=True)
@click.option('--enable', is_flag=True)
@click.option('--default-owner',
type=click.Choice(['local', 'kube']),
default='local')
@click.argument('expression')
@click.pass_context
@click_log.simple_verbosity_option(log)
@root_privileges_required
def install(ctx, expression, force, yes):
def install(ctx, expression, force, yes, enable, default_owner):
""" Install a package. """

manager: PackageManager = ctx.obj
Expand All @@ -232,7 +236,7 @@ def install(ctx, expression, force, yes):
f'continue?', abort=True, show_default=True)

try:
manager.install(expression, force)
manager.install(expression, force, enable, default_owner)
except Exception as err:
exit_cli(f'Failed to install package {expression}: {err}', fg='red')
except KeyboardInterrupt:
Expand Down Expand Up @@ -290,11 +294,12 @@ def uninstall(ctx, name, force, yes):
@cli.command()
@click.option('-f', '--force', is_flag=True)
@click.option('-y', '--yes', is_flag=True)
@click.option('--dockerd-socket', type=click.Path())
@click.argument('database', type=click.Path())
@click.pass_context
@click_log.simple_verbosity_option(log)
@root_privileges_required
def migrate(ctx, database, force, yes):
def migrate(ctx, database, force, yes, dockerd_socket):
""" Migrate SONiC packages from the given database file. """

manager: PackageManager = ctx.obj
Expand All @@ -303,7 +308,7 @@ def migrate(ctx, database, force, yes):
click.confirm('Continue with package migration?', abort=True, show_default=True)

try:
manager.migrate_packages(PackageDatabase.from_file(database))
manager.migrate_packages(PackageDatabase.from_file(database), dockerd_socket)
except Exception as err:
exit_cli(f'Failed to migrate packages {err}', fg='red')
except KeyboardInterrupt:
Expand Down
Loading