Skip to content

Commit f695c08

Browse files
dcermakDmitri Popovdmach
committed
create an osc container for package maintenance
Co-authored-by: Dmitri Popov <dmpop@cameracode.coffee> Co-authored-by: Daniel Mach <daniel.mach@suse.com>
1 parent 21c2244 commit f695c08

4 files changed

Lines changed: 198 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
@@ -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 POSTGRES_CONTAINERS # noqa: E402
15681569
from .appcontainers import PROMETHEUS_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: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,3 +542,85 @@ def _get_nginx_kwargs(os_version: OsVersion):
542542
)
543543
for os_version in (OsVersion.TUMBLEWEED,)
544544
]
545+
546+
547+
_BASE_PODMAN_OSC_CMD = (
548+
"podman run --rm -it "
549+
+ r"-v \$HOME/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z "
550+
+ r"-v \$HOME/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:z"
551+
)
552+
553+
OSC_CONTAINER = ApplicationStackContainer(
554+
name="osc",
555+
pretty_name="Packaging",
556+
package_name="packaging-image",
557+
os_version=OsVersion.TUMBLEWEED,
558+
is_latest=True,
559+
# we want all the recommends from osc & build
560+
no_recommends=False,
561+
version_in_uid=False,
562+
version="%%osc_version%%",
563+
replacements_via_service=[
564+
Replacement(regex_in_build_description="%%osc_version%%", package_name="osc")
565+
],
566+
extra_files={
567+
"entrypoint.sh": (Path(__file__).parent / "osc" / "entrypoint.sh").read_bytes()
568+
},
569+
extra_labels={
570+
"run": f"{_BASE_PODMAN_OSC_CMD} IMAGE",
571+
"runcwd": f"{_BASE_PODMAN_OSC_CMD} -v .:/root/osc-workdir:z IMAGE",
572+
},
573+
package_list=[
574+
# osc + osc build
575+
"osc",
576+
"build",
577+
"cpio",
578+
# all the services
579+
"obs-service-appimage",
580+
"obs-service-cargo",
581+
"obs-service-cdi_containers_meta",
582+
"obs-service-compose_kiwi_description",
583+
"obs-service-docker_label_helper",
584+
"obs-service-download_assets",
585+
"obs-service-download_files",
586+
"obs-service-download_url",
587+
"obs-service-extract_file",
588+
"obs-service-format_spec_file",
589+
"obs-service-go_modules",
590+
"obs-service-kiwi_label_helper",
591+
"obs-service-kiwi_metainfo_helper",
592+
"obs-service-kubevirt_containers_meta",
593+
"obs-service-node_modules",
594+
"obs-service-obs_scm",
595+
"obs-service-product_converter",
596+
"obs-service-recompress",
597+
"obs-service-refresh_patches",
598+
"obs-service-replace_using_env",
599+
"obs-service-replace_using_package_version",
600+
"obs-service-set_version",
601+
"obs-service-snapcraft",
602+
"obs-service-source_validator",
603+
"obs-service-tar",
604+
"obs-service-tar_scm",
605+
"obs-service-verify_file",
606+
*OsVersion.TUMBLEWEED.release_package_names,
607+
# for convenience
608+
"bash-completion",
609+
# for scmsync packages
610+
"git",
611+
"obs-scm-bridge",
612+
# IBS access
613+
"openssh-common",
614+
"openssh-clients",
615+
],
616+
cmd=["/bin/bash"],
617+
custom_end="""WORKDIR /root/osc-workdir
618+
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
619+
RUN chmod +x /usr/local/bin/entrypoint.sh
620+
""",
621+
entrypoint=["/usr/local/bin/entrypoint.sh"],
622+
volumes=[
623+
# default location of the build root & package cache
624+
"/var/tmp"
625+
],
626+
)
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 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 configuration. You can then check out packages, perform modifications, and
24+
send submissions to OBS.
25+
26+
To work on an already checked out package, mount the current working directory:
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.pretty_reference }}
34+
```
35+
36+
The container entrypoint recognizes whether you are launching it for interactive
37+
usage or invoking `osc` directly. You can omit
38+
the command `osc` in the second case. For example:
39+
40+
```ShellSession
41+
# podman run --rm -it \
42+
-v ~/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z \
43+
-v ~/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:z \
44+
{{ image.pretty_reference }} ls openSUSE:Factory
45+
```
46+
47+
The command automatically forwards the arguments to `osc` and calls
48+
`osc ls openSUSE:Factory`.
49+
50+
51+
### Using the image labels
52+
53+
The image provides two labels: `run` and `runcwd`. The first includes the full command, to run the `osc` container, while the second to run the container with the local working directory mounted.
54+
55+
To view the labels, use the following command:
56+
57+
```ShellSession
58+
# podman container runlabel run --display {{ image.pretty_reference }}
59+
# podman container runlabel runcwd --display {{ image.pretty_reference }}
60+
```
61+
62+
The labels can be used to run the container with Podman version 5.1.0 or later:
63+
```ShellSession
64+
# podman container runlabel run {{ image.pretty_reference }} \
65+
ls openSUSE:Factory
66+
```
67+
68+
69+
### Connecting to build.suse.de
70+
71+
build.suse.de uses an SSH-based authentication, which requires additional
72+
resources to be available in the container. You also must provide the internal certificate to the container:
73+
74+
```ShellSession
75+
# podman run --rm -it \
76+
-v ~/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z \
77+
-v ~/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:z \
78+
-v /etc/ssl/ca-bundle.pem:/etc/ssl/ca-bundle.pem:ro,z \
79+
-v $SSH_AUTH_SOCK:/run/user/0/ssh-agent.socket:z \
80+
-e SSH_AUTH_SOCK=/var/run/user/0/ssh-agent.socket:z \
81+
-v "$PWD":/root/osc-workdir:z \
82+
{{ image.pretty_reference }}
83+
```
84+
85+
86+
## Limitations
87+
88+
- Currently, it is not possible to build packages in a container.
89+
- The `runlabel run` command only works with Podman 5.1.0 and newer.
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)