Skip to content

Commit 8615638

Browse files
committed
create an osc container for package maintenance
1 parent 0797736 commit 8615638

4 files changed

Lines changed: 188 additions & 0 deletions

File tree

src/bci_build/package/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
14801480
from .appcontainers import MARIADB_CLIENT_CONTAINERS # noqa: E402
14811481
from .appcontainers import MARIADB_CONTAINERS # noqa: E402
14821482
from .appcontainers import NGINX_CONTAINERS # noqa: E402
1483+
from .appcontainers import OSC_CONTAINER # noqa: E402
14831484
from .appcontainers import PCP_CONTAINERS # noqa: E402
14841485
from .appcontainers import POSTGRES_CONTAINERS # noqa: E402
14851486
from .appcontainers import PROMETHEUS_CONTAINERS # noqa: E402
@@ -1548,6 +1549,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
15481549
*TOMCAT_CONTAINERS,
15491550
*GCC_CONTAINERS,
15501551
*SPACK_CONTAINERS,
1552+
OSC_CONTAINER,
15511553
)
15521554
}
15531555

src/bci_build/package/appcontainers.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from bci_build.package import SupportLevel
1818
from bci_build.package import _build_tag_prefix
1919
from bci_build.package import generate_disk_size_constraints
20+
from bci_build.package.basecontainers import _get_os_container_package_names
2021

2122
_PCP_FILES = {}
2223
for filename in (
@@ -730,3 +731,74 @@ def _get_nginx_kwargs(os_version: OsVersion):
730731
)
731732
for tomcat_major, os_version in product(_TOMCAT_VERSIONS, ALL_BASE_OS_VERSIONS)
732733
]
734+
735+
_BASE_PODMAN_OSC_CMD = (
736+
"podman run --rm -it "
737+
+ r"-v \$HOME/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z "
738+
+ r"-v \$HOME/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:z"
739+
)
740+
741+
OSC_CONTAINER = ApplicationStackContainer(
742+
name="osc",
743+
pretty_name="Packaging",
744+
package_name="packaging-image",
745+
os_version=OsVersion.TUMBLEWEED,
746+
is_latest=True,
747+
version_in_uid=False,
748+
version="%%osc_version%%",
749+
replacements_via_service=[
750+
Replacement(regex_in_build_description="%%osc_version%%", package_name="osc")
751+
],
752+
extra_files={
753+
"entrypoint.sh": (Path(__file__).parent / "osc" / "entrypoint.sh").read_bytes()
754+
},
755+
extra_labels={
756+
"run": f"{_BASE_PODMAN_OSC_CMD} IMAGE",
757+
"runcwd": f"{_BASE_PODMAN_OSC_CMD} -v .:/root/osc-workdir:z IMAGE",
758+
},
759+
package_list=[
760+
"osc",
761+
"obs-service-appimage",
762+
"obs-service-cargo",
763+
"obs-service-cdi_containers_meta",
764+
"obs-service-compose_kiwi_description",
765+
"obs-service-docker_label_helper",
766+
"obs-service-download_assets",
767+
"obs-service-download_files",
768+
"obs-service-download_url",
769+
"obs-service-extract_file",
770+
"obs-service-format_spec_file",
771+
"obs-service-go_modules",
772+
"obs-service-kiwi_label_helper",
773+
"obs-service-kiwi_metainfo_helper",
774+
"obs-service-kubevirt_containers_meta",
775+
"obs-service-node_modules",
776+
"obs-service-obs_scm",
777+
"cpio",
778+
"obs-service-product_converter",
779+
"obs-service-recompress",
780+
"obs-service-refresh_patches",
781+
"obs-service-replace_using_env",
782+
"obs-service-replace_using_package_version",
783+
"obs-service-set_version",
784+
"obs-service-snapcraft",
785+
"obs-service-source_validator",
786+
"obs-service-tar",
787+
"obs-service-tar_scm",
788+
"obs-service-verify_file",
789+
*_get_os_container_package_names(OsVersion.TUMBLEWEED),
790+
"git",
791+
"openssh-common",
792+
"openssh-clients",
793+
],
794+
cmd=["/bin/bash"],
795+
custom_end="""WORKDIR /root/osc-workdir
796+
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
797+
RUN chmod +x /usr/local/bin/entrypoint.sh
798+
""",
799+
entrypoint=["/usr/local/bin/entrypoint.sh"],
800+
volumes=[
801+
# default location of the build root & package cache
802+
"/var/tmp"
803+
],
804+
)
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# OSC Packaging Container
2+
3+
{% include 'badges.j2' %}
4+
5+
This is the openSUSE packaging container image, it includes all the necessary
6+
software to create and modify packages in the [Open Build
7+
Service](https://build.opensuse.org/) using
8+
[osc](https://github.com/openSUSE/osc/).
9+
10+
11+
## How to use this container image
12+
13+
This container image is intended for interactive usage with your `.oscrc` and
14+
the osc cookiejar mounted into the container:
15+
16+
```ShellSession
17+
# podman run --rm -it \
18+
-v ~/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z \
19+
-v ~/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:rw,z \
20+
{{ image.pretty_reference }}
21+
```
22+
23+
The above command launches an interactive shell where your local osc config will
24+
be used. You can then proceed to checkout packages, perform modifications and
25+
send submissions to OBS.
26+
27+
To work on an already checked out package, mount the current working directory:
28+
29+
```ShellSession
30+
# podman run --rm -it \
31+
-v ~/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z \
32+
-v ~/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:z \
33+
-v .:/root/osc-workdir:z \
34+
{{ image.pretty_reference }}
35+
```
36+
37+
The container entrypoint recognizes whether you are launching it for interactive
38+
usage or whether you are invoking `osc` directly. For convenience, you can omit
39+
the command `osc` in the second case. E.g.:
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 .:/root/osc-workdir:z \
46+
{{ image.pretty_reference }} ls openSUSE:Factory
47+
```
48+
49+
The above command will automatically invoke forward the arguments to `osc` and
50+
call `osc ls openSUSE:Factory`.
51+
52+
53+
### Using the image labels
54+
55+
The image provides two labels `run` and `runcwd` which include the full command
56+
to run the `osc` container or run it with the local working directory mounted as
57+
well.
58+
59+
These labels can be shown via:
60+
61+
```ShellSession
62+
# podman container runlabel run --display {{ image.pretty_reference }}
63+
# podman container runlabel runcwd --display {{ image.pretty_reference }}
64+
```
65+
66+
Note that it is currently not yet possible to execute these labels with podman.
67+
68+
69+
### Connecting to build.suse.de
70+
71+
build.suse.de uses a ssh based authentication and thus requires additional
72+
resources to be available in the container. Additionally, you have to provide
73+
the internal certificate to the container as well:
74+
75+
```ShellSession
76+
# podman run --rm -it \
77+
-v ~/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z \
78+
-v ~/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:z \
79+
-v /etc/ssl/ca-bundle.pem:/etc/ssl/ca-bundle.pem:ro,z \
80+
-v $SSH_AUTH_SOCK:/run/user/0/ssh-agent.socket:z \
81+
-e SSH_AUTH_SOCK=/var/run/user/0/ssh-agent.socket:z \
82+
-v "$PWD":/root/osc-workdir:z \
83+
{{ image.pretty_reference }}
84+
```
85+
86+
87+
## Limitations
88+
89+
- It is currently not possible to build packages in a container.
90+
91+
92+
## Volumes
93+
94+
The container image is preconfigured to put `/var/tmp` into a volume. This
95+
directory is used by `osc` to store the buildroot and the package cache.
96+
97+
{% include 'licensing_and_eula.j2' %}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
if [[ "-h --help -v --verbose -q --quiet --debug --debugger --post-mortem --traceback -H --http-debug --http-full-debug -A --apiurl --config --setopt --no-keyring add addchannels addcontainers addremove ar aggregatepac api branch getpac bco branchco browse build wipe shell chroot buildconfig buildhistory buildhist buildinfo buildlog buildlogtail blt bl cat less blame changedevelrequest changedevelreq cr checkconstraints checkout co clean cleanassets ca clone comment commit checkin ci config copypac create-pbuild-config cpc createincident createrequest creq delete remove del rm deleterequest deletereq droprequest dropreq dr dependson detachbranch develproject dp bsdevelproject diff di ldiff linkdiff distributions dists downloadassets da enablechannels enablechannel fork getbinaries help importsrcpkg info init jobhistory jobhist linkpac linktobranch list LL lL ll ls localbuildlog lbl lock log maintainer bugowner maintenancerequest mr mbranch maintained sm meta mkpac mv my patchinfo pdiff prdiff projdiff projectdiff prjresults pr pull pull_request rdelete rdiff rebuild rebuildpac release releaserequest remotebuildlog remotebuildlogtail rbuildlogtail rblt rbuildlog rbl repairlink repairwc repo repositories platforms repos repourls request review rq requestmaintainership reqbs reqms reqmaintainership requestbugownership reqbugownership resolved restartbuild abortbuild results r revert rpmlintlog lint rpmlint rremove search bse se sendsysrq service setdevelproject sdp setlinkrev showlinked signkey staging status st submitrequest submitpac submitreq sr token triggerreason tr undelete unlock update up updatepacmetafromspec updatepkgmetafromspec metafromspec vc version whatdependson whois user who wipebinaries unpublish workerinfo" =~ (^|[[:space:]])$1($|[[:space:]]) ]]; then
13+
# looks like the user is executing the container as the osc command
14+
osc "$@"
15+
else
16+
exec "$@"
17+
fi

0 commit comments

Comments
 (0)