Skip to content

Commit

Permalink
add support for runtime apt installs
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Sep 21, 2023
1 parent 3b72722 commit 655e7f7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/ibek/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

IOC_DBDS = SUPPORT / "configure/dbd_list"
IOC_LIBS = SUPPORT / "configure/lib_list"
RUNTIME_DEBS = SUPPORT / "configure/runtime_debs"


class BaseSettings(BaseModel):
Expand Down
25 changes: 15 additions & 10 deletions src/ibek/support_cmds/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@
from git import Repo
from typing_extensions import Annotated

from ibek.globals import (
EPICS_ROOT,
IOC_DBDS,
IOC_LIBS,
RELEASE,
SUPPORT,
)
from ibek.globals import EPICS_ROOT, IOC_DBDS, IOC_LIBS, RELEASE, RUNTIME_DEBS, SUPPORT
from ibek.support import Support
from ibek.support_cmds.checks import (
add_macro,
Expand Down Expand Up @@ -129,7 +123,7 @@ def git_clone(

@support_cli.command()
def add_libs(
libs: List[str] = typer.Argument(..., help="list of libraries to add"),
libs: List[str] = typer.Argument(None, help="list of libraries to add"),
) -> None:
"""
declare the libraries for this support module for inclusion in IOC Makefile
Expand All @@ -139,7 +133,7 @@ def add_libs(

@support_cli.command()
def add_dbds(
dbds: List[str] = typer.Argument(..., help="list of dbd files to add"),
dbds: List[str] = typer.Argument(None, help="list of dbd files to add"),
) -> None:
"""
declare the dbd files for this support module for inclusion in IOC Makefile
Expand Down Expand Up @@ -195,14 +189,18 @@ def add_to_config_site(
)
def apt_install(
ctx: typer.Context,
debs: List[str] = typer.Argument(..., help="list of debian packages to install"),
debs: List[str] = typer.Argument(None, help="list of debian packages to install"),
runtime: bool = typer.Option(False, help="install list of runtime packages"),
):
"""
Install debian packages into the container. If they have an http:// or https://
prefix then they will be downloaded and installed from file.
"""
temp = Path("/tmp")

if runtime:
debs += RUNTIME_DEBS.read_text().split()

for i, pkg in enumerate(debs):
if pkg.startswith("http://") or pkg.startswith("https://"):
pkg_file = temp / pkg.split("/")[-1]
Expand All @@ -216,3 +214,10 @@ def apt_install(
)

exit(subprocess.call(["bash", "-c", command]))


@support_cli.command()
def apt_add_runtime(
debs: List[str] = typer.Argument(None, help="list of debian packages to install"),
):
add_list_to_file(RUNTIME_DEBS, debs)
1 change: 0 additions & 1 deletion src/ibek/support_cmds/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def add_list_to_file(file: Path, text_list: List[str]):
if len(text_list) == 0:
return

print(f"ADD LINE {text_list}")
for line in text_list:
# skip blanks and comments
if line.startswith("#") or line == "":
Expand Down

0 comments on commit 655e7f7

Please sign in to comment.