Skip to content

Commit d4af88b

Browse files
dcermakDmitri Popovdmach
committed
create an osc container for package maintenance
Co-authored-by: Dmitri Popov <[email protected]> Co-authored-by: Daniel Mach <[email protected]>
1 parent 574f40c commit d4af88b

File tree

4 files changed

+213
-0
lines changed

4 files changed

+213
-0
lines changed

src/bci_build/package/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
15631563
from .appcontainers import GRAFANA_CONTAINERS # noqa: E402
15641564
from .appcontainers import HELM_CONTAINERS # noqa: E402
15651565
from .appcontainers import NGINX_CONTAINERS # noqa: E402
1566+
from .appcontainers import OSC_CONTAINER # noqa: E402
15661567
from .appcontainers import PCP_CONTAINERS # noqa: E402
15671568
from .appcontainers import PROMETHEUS_CONTAINERS # noqa: E402
15681569
from .appcontainers import REGISTRY_CONTAINERS # noqa: E402
@@ -1636,6 +1637,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
16361637
*TOMCAT_CONTAINERS,
16371638
*GCC_CONTAINERS,
16381639
*SPACK_CONTAINERS,
1640+
OSC_CONTAINER,
16391641
)
16401642
}
16411643

src/bci_build/package/appcontainers.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,3 +486,89 @@ def _get_nginx_kwargs(os_version: OsVersion):
486486
)
487487
for os_version in (OsVersion.TUMBLEWEED,)
488488
]
489+
490+
491+
_BASE_PODMAN_OSC_CMD = (
492+
"podman run --rm -it --privileged "
493+
+ r"-v \$HOME/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z "
494+
+ r"-v \$HOME/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:z"
495+
)
496+
497+
OSC_CONTAINER = ApplicationStackContainer(
498+
name="osc",
499+
pretty_name="Packaging",
500+
package_name="packaging-image",
501+
os_version=OsVersion.TUMBLEWEED,
502+
is_latest=True,
503+
# we want all the recommends from osc & build
504+
no_recommends=False,
505+
version_in_uid=False,
506+
version="%%osc_version%%",
507+
replacements_via_service=[
508+
Replacement(regex_in_build_description="%%osc_version%%", package_name="osc")
509+
],
510+
extra_files={
511+
"entrypoint.sh": (Path(__file__).parent / "osc" / "entrypoint.sh").read_bytes()
512+
},
513+
extra_labels={
514+
"run": f"{_BASE_PODMAN_OSC_CMD} IMAGE",
515+
"runcwd": f"{_BASE_PODMAN_OSC_CMD} -v .:/root/osc-workdir:z IMAGE",
516+
},
517+
package_list=[
518+
# osc + osc build
519+
"osc",
520+
"build",
521+
"cpio",
522+
# all the services
523+
"obs-service-appimage",
524+
"obs-service-cargo",
525+
"obs-service-cdi_containers_meta",
526+
"obs-service-compose_kiwi_description",
527+
"obs-service-docker_label_helper",
528+
"obs-service-download_assets",
529+
"obs-service-download_files",
530+
"obs-service-download_url",
531+
"obs-service-extract_file",
532+
"obs-service-format_spec_file",
533+
"obs-service-go_modules",
534+
"obs-service-kiwi_label_helper",
535+
"obs-service-kiwi_metainfo_helper",
536+
"obs-service-kubevirt_containers_meta",
537+
"obs-service-node_modules",
538+
"obs-service-obs_scm",
539+
"obs-service-product_converter",
540+
"obs-service-recompress",
541+
"obs-service-refresh_patches",
542+
"obs-service-replace_using_env",
543+
"obs-service-replace_using_package_version",
544+
"obs-service-set_version",
545+
"obs-service-snapcraft",
546+
"obs-service-source_validator",
547+
"obs-service-tar",
548+
"obs-service-tar_scm",
549+
"obs-service-verify_file",
550+
*OsVersion.TUMBLEWEED.release_package_names,
551+
# for convenience
552+
"bash-completion",
553+
# for scmsync packages
554+
"git",
555+
"obs-scm-bridge",
556+
# IBS access
557+
"openssh-common",
558+
"openssh-clients",
559+
# for building
560+
"podman",
561+
"runc",
562+
],
563+
cmd=["/bin/bash"],
564+
custom_end="""WORKDIR /root/osc-workdir
565+
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
566+
RUN chmod +x /usr/local/bin/entrypoint.sh
567+
ENV OSC_VM_TYPE=podman
568+
""",
569+
entrypoint=["/usr/local/bin/entrypoint.sh"],
570+
volumes=[
571+
# default location of the build root & package cache
572+
"/var/tmp"
573+
],
574+
)
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# OSC Packaging Container
2+
3+
{% include 'badges.j2' %}
4+
5+
This is the openSUSE packaging container image that includes all the required
6+
tools for creating and modifying 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+
The container image is intended for interactive usage with a `.oscrc` configuration file 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 command launches an interactive shell environment that uses the local osc
24+
configuration. You can then check out packages, perform modifications, and send
25+
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 invoking `osc` directly. You can omit the command `osc` in the second
39+
case. For example:
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+
{{ image.pretty_reference }} \
46+
ls openSUSE:Factory
47+
```
48+
49+
The command automatically forwards the arguments to `osc` and calls
50+
`osc ls openSUSE:Factory`.
51+
52+
53+
### Building packages
54+
55+
The container image can be used to build packages using the podman build
56+
backend. You **must** launch the container in privileged mode for building.
57+
58+
59+
### Using the image labels
60+
61+
The image provides two labels: `run` and `runcwd`. The first includes the full
62+
command, to run the `osc` container, while the second to run the container with
63+
the local working directory mounted.
64+
65+
To view the labels, use the following command:
66+
67+
```ShellSession
68+
# podman container runlabel run --display {{ image.pretty_reference }}
69+
# podman container runlabel runcwd --display {{ image.pretty_reference }}
70+
```
71+
72+
The labels can be used to run the container with Podman version 5.1.0 or later:
73+
```ShellSession
74+
# podman container runlabel run \
75+
{{ image.pretty_reference }} \
76+
ls openSUSE:Factory
77+
```
78+
79+
80+
### Connecting to build.suse.de
81+
82+
build.suse.de uses an SSH-based authentication, which requires additional
83+
resources to be available in the container. You also must provide the internal certificate to the container:
84+
85+
```ShellSession
86+
# podman run --rm -it \
87+
-v ~/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z \
88+
-v ~/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:z \
89+
-v /etc/ssl/ca-bundle.pem:/etc/ssl/ca-bundle.pem:ro,z \
90+
-v $SSH_AUTH_SOCK:/run/user/0/ssh-agent.socket:z \
91+
-e SSH_AUTH_SOCK=/var/run/user/0/ssh-agent.socket:z \
92+
-v "$PWD":/root/osc-workdir:z \
93+
{{ image.pretty_reference }}
94+
```
95+
96+
97+
## Limitations
98+
99+
- Currently, it is not possible to build packages in a container.
100+
- The `runlabel run` command only works with Podman 5.1.0 and newer.
101+
102+
103+
## Volumes
104+
105+
The container image is preconfigured to put `/var/tmp` into a volume. This
106+
directory is used by `osc` to store the buildroot and the package cache.
107+
108+
{% 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)