jw.pkg.cmds.distro.CmdInstall: Support --only-update

Passing --only-update should keep "jw-pkg.py distro install" from
installing packages that are not already installed on the the system.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-03-03 10:52:36 +01:00
commit 6af16d2dca
5 changed files with 12 additions and 3 deletions

View file

@ -13,6 +13,7 @@ class CmdInstall(Cmd): # export
def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser)
parser.add_argument("packages", nargs="*", help="Packages to be installed")
parser.add_argument('--only-update', default=False, action='store_true', help='Only update the listed packages, don\'t install them')
async def _run(self, args: Namespace) -> None:
return await self._backend.run(args)

View file

@ -11,6 +11,8 @@ class Install(Base):
super().__init__(parent)
async def run(self, args: Namespace):
if args.only_update:
raise NotImplementedError('--only-update is not yet implemented for pacman')
pacman_args = ['-S', '--needed']
pacman_args.extend(args.packages)
await self.util.pacman(*pacman_args)

View file

@ -11,4 +11,9 @@ class Install(Base):
super().__init__(parent)
async def run(self, args: Namespace):
return await self.util.apt_get('install', *args.packages)
apt_get_args = ['install']
if args.only_update:
apt_get_args.append('--only-upgrade')
apt_get_args.append('--no-install-recommends')
apt_get_args.extend(args.packages)
return await self.apt_get(apt_get_args)

View file

@ -11,7 +11,7 @@ class Install(Base):
super().__init__(parent)
async def run(self, args: Namespace):
yum_args = ['install']
yum_args = ['update' if args.only_update else 'install']
if not self.interactive:
yum_args.append['-y']
yum_args.extend(args.packages)

View file

@ -11,4 +11,5 @@ class Install(Base):
super().__init__(parent)
async def run(self, args: Namespace):
return await self.util.zypper(['install', *args.packages])
zypper_cmd = 'update' if args.only_update else 'install'
return await self.util.zypper([zypper_cmd, *args.packages])