Skip to content

Commit 7156525

Browse files
committed
WIP: create an osc container for package maintenance
1 parent 321c3ec commit 7156525

File tree

4 files changed

+144
-0
lines changed

4 files changed

+144
-0
lines changed

src/bci_build/package/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
14221422
from .appcontainers import MARIADB_CLIENT_CONTAINERS # noqa: E402
14231423
from .appcontainers import MARIADB_CONTAINERS # noqa: E402
14241424
from .appcontainers import NGINX_CONTAINERS # noqa: E402
1425+
from .appcontainers import OSC_CONTAINER # noqa: E402
14251426
from .appcontainers import PCP_CONTAINERS # noqa: E402
14261427
from .appcontainers import POSTGRES_CONTAINERS # noqa: E402
14271428
from .appcontainers import PROMETHEUS_CONTAINERS # noqa: E402
@@ -1488,6 +1489,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
14881489
GITEA_RUNNER_CONTAINER,
14891490
*TOMCAT_CONTAINERS,
14901491
*GCC_CONTAINERS,
1492+
OSC_CONTAINER,
14911493
)
14921494
}
14931495

src/bci_build/package/appcontainers.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from bci_build.package import SupportLevel
1919
from bci_build.package import _build_tag_prefix
2020
from bci_build.package import generate_disk_size_constraints
21+
from bci_build.package.basecontainers import _get_os_container_package_names
2122

2223
_PCP_FILES = {}
2324
for filename in (
@@ -808,3 +809,70 @@ def _get_nginx_kwargs(os_version: OsVersion):
808809
)
809810
for tomcat_major, os_version in product(_TOMCAT_VERSIONS, ALL_BASE_OS_VERSIONS)
810811
]
812+
813+
# FIXME: what's the correct name of the label?
814+
_BASE_PODMAN_CMD = "podman run run --rm -it -v ~/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z -v ~/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:z"
815+
OSC_CONTAINER = ApplicationStackContainer(
816+
name="osc",
817+
pretty_name="Packaging",
818+
package_name="packaging-image",
819+
os_version=OsVersion.TUMBLEWEED,
820+
is_latest=True,
821+
version_in_uid=False,
822+
version="%%osc_version%%",
823+
replacements_via_service=[
824+
Replacement(regex_in_build_description="%%osc_version%%", package_name="osc")
825+
],
826+
extra_files={
827+
"entrypoint.sh": (Path(__file__).parent / "osc" / "entrypoint.sh").read_bytes()
828+
},
829+
extra_labels={
830+
"run": f"{_BASE_PODMAN_CMD} $IMAGE",
831+
"runcwd": f"{_BASE_PODMAN_CMD} -v $PWD:/root/osc-workdir:z $IMAGE",
832+
},
833+
package_list=[
834+
"osc",
835+
"obs-service-appimage",
836+
"obs-service-cargo",
837+
"obs-service-cdi_containers_meta",
838+
"obs-service-compose_kiwi_description",
839+
"obs-service-docker_label_helper",
840+
"obs-service-download_assets",
841+
"obs-service-download_files",
842+
"obs-service-download_url",
843+
"obs-service-extract_file",
844+
"obs-service-format_spec_file",
845+
"obs-service-go_modules",
846+
"obs-service-kiwi_label_helper",
847+
"obs-service-kiwi_metainfo_helper",
848+
"obs-service-kubevirt_containers_meta",
849+
"obs-service-node_modules",
850+
"obs-service-obs_scm",
851+
"cpio",
852+
"obs-service-product_converter",
853+
"obs-service-recompress",
854+
"obs-service-refresh_patches",
855+
"obs-service-replace_using_env",
856+
"obs-service-replace_using_package_version",
857+
"obs-service-set_version",
858+
"obs-service-snapcraft",
859+
"obs-service-source_validator",
860+
"obs-service-tar",
861+
"obs-service-tar_scm",
862+
"obs-service-verify_file",
863+
*_get_os_container_package_names(OsVersion.TUMBLEWEED),
864+
"git",
865+
"openssh-common",
866+
"openssh-clients",
867+
],
868+
cmd=["/bin/bash"],
869+
custom_end="""WORKDIR /root/osc-workdir
870+
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
871+
RUN chmod +x /usr/local/bin/entrypoint.sh
872+
""",
873+
entrypoint=["/usr/local/bin/entrypoint.sh"],
874+
volumes=[
875+
# default location of the build root & package cache
876+
"/var/tmp"
877+
],
878+
)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Packaging Container
2+
3+
This is the openSUSE packaging container image, it includes all the necessary
4+
software to create and modify packages on the [Open Build
5+
Service](https://build.opensuse.org/) using
6+
[osc](https://github.com/openSUSE/osc/).
7+
8+
9+
## How to use this container image
10+
11+
This container image is intended for interactive usage with your `.oscrc` and
12+
the osc cookiejar mounted into the container:
13+
14+
```ShellSession
15+
# podman run --rm -it \
16+
-v ~/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z \
17+
-v ~/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:rw,z \
18+
{{ image.reference }}
19+
```
20+
21+
The above command launches an interactive shell where your local osc config will
22+
be used. You can then proceed to checkout packages, perform modifications and
23+
send submissions to OBS.
24+
25+
To work on an already checked out package, mount the current working directory
26+
as well:
27+
28+
```ShellSession
29+
# podman run --rm -it \
30+
-v ~/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z \
31+
-v ~/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:z \
32+
-v .:/root/osc-workdir:z \
33+
{{ image.reference }}
34+
```
35+
36+
### Connecting to build.suse.de
37+
38+
build.suse.de uses a ssh based authentication and thus requires additional
39+
resources to be available in the container:
40+
41+
```ShellSession
42+
# podman run --rm -it \
43+
-v ~/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z \
44+
-v ~/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:z \
45+
-v /etc/ssl/ca-bundle.pem:/etc/ssl/ca-bundle.pem:ro,z \
46+
-v $SSH_AUTH_SOCK:/run/user/0/ssh-agent.socket:z \
47+
-e SSH_AUTH_SOCK=/var/run/user/0/ssh-agent.socket:z \
48+
-v "$PWD":/root/osc-workdir:z \
49+
{{ image.reference }}
50+
```
51+
52+
53+
## Limitations
54+
55+
- It is currently not possible to build packages in a container.
56+
57+
58+
## Volumes
59+
60+
The container image is preconfigured to put `/var/tmp` into a volume. This
61+
directory is used by `osc` to store the buildroot and the package cache.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
if [[ ! -e /root/.config/osc/oscrc ]]; then
4+
cat << EOF
5+
This container is expected to be launched with your oscrc mounted to
6+
/root/.config/osc/oscrc
7+
8+
Please consult the README or the label 'run' for the full invocation.
9+
EOF
10+
fi
11+
12+
13+
exec "$@"

0 commit comments

Comments
 (0)