Charles Short 3153d3a145 repo: "add" subcommand
The purpose of the "add" subcommand is to add additional
Debian packages to a previously created Debian archive
repository.

The way this works is that when the add subcommand
runs, it makes a system call to reprepro. The command
that runs is reprepro with the includedeb option.

To add packages to the repository, you have to download
the packages locally to a directory and then run
"sudo apt-ostree repo add --release <release> *.deb".
Packages can be downloaded via "apt-get download <package>".
Please note, if the package is new and not found in the
regular Debin archive then run-time dependencies needed
to be added as well. Otherwise the package install
will fail when a user tries to install the package via
apt.

Testing:
PASSED Installed apt-ostree from git repo.
PASSED Download desired debian package
PASSED Run "sudo apt-ostree repo add \
      --release bookworm *.deb"
PASSED Check the output of
 "reprepo -b <repo dir> list

Story: 2010867
Task: 48556

Depends-On: https://review.opendev.org/c/starlingx/apt-ostree/+/891591

Change-Id: Ic773899fa57062e60c9e09d05eb383522c33e35c
Signed-off-by: Charles Short <charles.short@windriver.com>
2023-08-19 09:57:36 +00:00

45 lines
938 B
Python

"""
Copyright (c) 2023 Wind River Systems, Inc.
SPDX-License-Identifier: Apache-2.0
"""
import os
import subprocess
import click
from apt_ostree.log import log_step
def run_command(cmd,
debug=False,
stdin=None,
stdout=None,
stderr=None,
check=True,
env={},
cwd=None):
env = dict(
PATH=os.environ["PATH"],
TERM=os.getenv("TERM", "vt220"),
LANG="C.UTF-8",
) | env
try:
if debug:
log_step(f"Running {' '.join(cmd)}")
return subprocess.run(
cmd,
stdin=stdin,
stdout=stdout,
stderr=stderr,
env=env,
cwd=cwd,
check=check,
)
except FileNotFoundError:
click.secho(f"{cmd[0]} not found in PATH.")
except subprocess.CalledProcessError as e:
raise e