From: Michael Tremer Date: Mon, 7 Feb 2011 11:39:36 +0000 (+0100) Subject: cli: Fix/implement install/localinstall command. X-Git-Tag: 0.9.3~192 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e87fa4f6d694d2104f3eaf60a1656841739cd3e;p=pakfire.git cli: Fix/implement install/localinstall command. --- diff --git a/pakfire/__init__.py b/pakfire/__init__.py index 4b9b914fb..25329169c 100644 --- a/pakfire/__init__.py +++ b/pakfire/__init__.py @@ -143,7 +143,7 @@ class Pakfire(object): ds = depsolve.DependencySet(pakfire=self) for req in requires: - if isinstance(packages.BinaryPackage, req): + if isinstance(req, packages.BinaryPackage): ds.add_package(req) else: ds.add_requires(req) diff --git a/pakfire/cli.py b/pakfire/cli.py index ca78a9b7b..e554b174f 100644 --- a/pakfire/cli.py +++ b/pakfire/cli.py @@ -46,6 +46,7 @@ class Cli(object): self.sub_commands = self.parser.add_subparsers() self.parse_command_install() + self.parse_command_localinstall() self.parse_command_info() self.parse_command_search() self.parse_command_update() @@ -61,10 +62,11 @@ class Cli(object): ) self.action2func = { - "install" : self.handle_install, - "update" : self.handle_update, - "info" : self.handle_info, - "search" : self.handle_search, + "install" : self.handle_install, + "localinstall" : self.handle_localinstall, + "update" : self.handle_update, + "info" : self.handle_info, + "search" : self.handle_search, } def parse_common_arguments(self): @@ -85,6 +87,14 @@ class Cli(object): help=_("Give name of at least one package to install.")) sub_install.add_argument("action", action="store_const", const="install") + def parse_command_localinstall(self): + # Implement the "localinstall" command. + sub_install = self.sub_commands.add_parser("localinstall", + help=_("Install one or more packages from the filesystem.")) + sub_install.add_argument("package", nargs="+", + help=_("Give filename of at least one package.")) + sub_install.add_argument("action", action="store_const", const="localinstall") + def parse_command_update(self): # Implement the "update" command. sub_update = self.sub_commands.add_parser("update", @@ -142,6 +152,22 @@ class Cli(object): def handle_update(self): pass + def handle_install(self, local=False): + if local: + repo = repository.FileSystemRepository(self.pakfire) + + pkgs = [] + for pkg in self.args.package: + if local and os.path.exists(pkg): + pkg = packages.BinaryPackage(self.pakfire, repo, pkg) + + pkgs.append(pkg) + + self.pakfire.install(pkgs) + + def handle_localinstall(self): + return self.handle_install(local=True) + class CliBuilder(Cli): def __init__(self):