Charles Short 70fdb9cd9b repo: Refactor "repo" subcomand
Refactor the "repo" sub-command for easier maintenance
and readability. No functionality changes were made in this
refactoring.

As a side affect, this treats apt-ostree more like a library
so that other StarlingX projects can use apt-ostree to manage
images and/or packages.

Test Plan
PASSED Installed apt-ostree from git repo.
PASSED mkdir -p /var/repository
PASSED sudo apt-ostree repo init \
    --feed /var/repository --release bullseye
    --origin starlingx
PASSED sudo apt-ostree repo list --release bullseye

Story: 2010867
Task: 48556

Change-Id: Iaa5dbf6233b0175eefec67ba666c66b47bc01e66
Signed-off-by: Charles Short <charles.short@windriver.com>
2023-09-20 12:18:53 -04:00

35 lines
843 B
Python

"""
Copyright (c) 2023 Wind River Systems, Inc.
SPDX-License-Identifier: Apache-2.0
"""
import errno
import sys
import click
from apt_ostree.cmd.options import feed_option
from apt_ostree.cmd.options import packages_option
from apt_ostree.cmd.options import release_option
from apt_ostree.cmd import pass_state_context
from apt_ostree.repo import Repo
@click.command(help="Add Debian package(s) to repository.")
@pass_state_context
@feed_option
@release_option
@packages_option
def add(state, feed, release, packages):
try:
Repo(state).add()
except KeyboardInterrupt:
click.secho("\n" + ("Exiting at your request."))
sys.exit(130)
except BrokenPipeError:
sys.exit()
except OSError as error:
if error.errno == errno.ENOSPC:
sys.exit("errror - No space left on device.")