Skip to content

Commit 024ff4c

Browse files
committed
WIP: create an osc container for package maintenance
1 parent bc66a50 commit 024ff4c

File tree

4 files changed

+127
-0
lines changed

4 files changed

+127
-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: 60 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,62 @@ 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+
814+
OSC_CONTAINER = ApplicationStackContainer(
815+
name="osc",
816+
pretty_name="Packaging",
817+
package_name="packaging-image",
818+
os_version=OsVersion.TUMBLEWEED,
819+
is_latest=True,
820+
version_in_uid=False,
821+
version="%%osc_version%%",
822+
replacements_via_service=[
823+
Replacement(regex_in_build_description="%%osc_version%%", package_name="osc")
824+
],
825+
extra_files={
826+
"entrypoint.sh": (Path(__file__).parent / "osc" / "entrypoint.sh").read_bytes()
827+
},
828+
package_list=[
829+
"osc",
830+
"obs-service-appimage",
831+
"obs-service-cargo",
832+
"obs-service-cdi_containers_meta",
833+
"obs-service-compose_kiwi_description",
834+
"obs-service-docker_label_helper",
835+
"obs-service-download_assets",
836+
"obs-service-download_files",
837+
"obs-service-download_url",
838+
"obs-service-extract_file",
839+
"obs-service-format_spec_file",
840+
"obs-service-go_modules",
841+
"obs-service-kiwi_label_helper",
842+
"obs-service-kiwi_metainfo_helper",
843+
"obs-service-kubevirt_containers_meta",
844+
"obs-service-node_modules",
845+
"obs-service-obs_scm",
846+
"cpio",
847+
"obs-service-product_converter",
848+
"obs-service-recompress",
849+
"obs-service-refresh_patches",
850+
"obs-service-replace_using_env",
851+
"obs-service-replace_using_package_version",
852+
"obs-service-set_version",
853+
"obs-service-snapcraft",
854+
"obs-service-source_validator",
855+
"obs-service-tar",
856+
"obs-service-tar_scm",
857+
"obs-service-verify_file",
858+
*_get_os_container_package_names(OsVersion.TUMBLEWEED),
859+
],
860+
custom_end="""WORKDIR /src/
861+
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
862+
RUN chmod +x /usr/local/bin/entrypoint.sh
863+
""",
864+
entrypoint=["/usr/local/bin/entrypoint.sh"],
865+
env={"OSC_APIURL": "https://api.opensuse.org"},
866+
volumes=[
867+
# default location of the build root & package cache
868+
"/var/tmp"
869+
],
870+
)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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`
12+
mounted into the container:
13+
14+
```ShellSession
15+
# podman run --rm -it -v ~/.config/osc/oscrc:/root/.config/osc/oscrc:Z \
16+
{{ image.reference }}
17+
```
18+
19+
The above command launches an interactive shell where your local osc config will
20+
be used. You can then proceed to checkout packages, perform modifications and
21+
send submissions to OBS.
22+
23+
You can also let the container image's entrypoint generate a `oscrc` for you
24+
using the environment variables `OSC_USER` and `OSC_PASSWORD`. It will create a
25+
configuration for the OBS instance with the API URL saved in the environment variable
26+
`OSC_APIURL` (defaults to api.opensuse.org):
27+
28+
```ShellSession
29+
# podman run --rm -it -e OSC_USER=my_user -e OSC_PASSWORD=mySecretPassword \
30+
{{ image.reference }}
31+
```
32+
33+
Note that you should disable your shell's history as it will otherwise container
34+
your password in plain text.
35+
36+
37+
## Limitations
38+
39+
- It is currently not possible to build packages in a container.
40+
41+
- Cannot communicate with build.suse.de
42+
43+
44+
## Volumes
45+
46+
The container image is preconfigured to put `/var/tmp` into a volume. This
47+
directory is used by `osc` to store the buildroot and the package cache.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
if [ ! -f "$HOME/.config/osc/oscrc" ]; then
6+
mkdir -p "$HOME/.config/osc"
7+
if [ -z ${OSC_USER+x} ] && [ -z ${OSC_PASSWORD+y} ]; then
8+
echo "[general]
9+
apiurl = ${OSC_APIURL}
10+
11+
[${OSC_APIURL}]
12+
user = ${OSC_USER}
13+
pass = ${OSC_PASSWORD}
14+
" > "$HOME/.config/osc/oscrc"
15+
fi
16+
fi
17+
18+
exec "$@"

0 commit comments

Comments
 (0)