Skip to content

Commit 012a05b

Browse files
committed
create an osc container for package maintenance
1 parent 77c5794 commit 012a05b

4 files changed

Lines changed: 187 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: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,3 +542,75 @@ 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+
version_in_uid=False,
560+
version="%%osc_version%%",
561+
replacements_via_service=[
562+
Replacement(regex_in_build_description="%%osc_version%%", package_name="osc")
563+
],
564+
extra_files={
565+
"entrypoint.sh": (Path(__file__).parent / "osc" / "entrypoint.sh").read_bytes()
566+
},
567+
extra_labels={
568+
"run": f"{_BASE_PODMAN_OSC_CMD} IMAGE",
569+
"runcwd": f"{_BASE_PODMAN_OSC_CMD} -v .:/root/osc-workdir:z IMAGE",
570+
},
571+
package_list=[
572+
"osc",
573+
"obs-service-appimage",
574+
"obs-service-cargo",
575+
"obs-service-cdi_containers_meta",
576+
"obs-service-compose_kiwi_description",
577+
"obs-service-docker_label_helper",
578+
"obs-service-download_assets",
579+
"obs-service-download_files",
580+
"obs-service-download_url",
581+
"obs-service-extract_file",
582+
"obs-service-format_spec_file",
583+
"obs-service-go_modules",
584+
"obs-service-kiwi_label_helper",
585+
"obs-service-kiwi_metainfo_helper",
586+
"obs-service-kubevirt_containers_meta",
587+
"obs-service-node_modules",
588+
"obs-service-obs_scm",
589+
"cpio",
590+
"obs-service-product_converter",
591+
"obs-service-recompress",
592+
"obs-service-refresh_patches",
593+
"obs-service-replace_using_env",
594+
"obs-service-replace_using_package_version",
595+
"obs-service-set_version",
596+
"obs-service-snapcraft",
597+
"obs-service-source_validator",
598+
"obs-service-tar",
599+
"obs-service-tar_scm",
600+
"obs-service-verify_file",
601+
*OsVersion.TUMBLEWEED.release_package_names,
602+
"git",
603+
"openssh-common",
604+
"openssh-clients",
605+
],
606+
cmd=["/bin/bash"],
607+
custom_end="""WORKDIR /root/osc-workdir
608+
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
609+
RUN chmod +x /usr/local/bin/entrypoint.sh
610+
""",
611+
entrypoint=["/usr/local/bin/entrypoint.sh"],
612+
volumes=[
613+
# default location of the build root & package cache
614+
"/var/tmp"
615+
],
616+
)
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
{{ image.pretty_reference }} ls openSUSE:Factory
46+
```
47+
48+
The above command will automatically forward the arguments to `osc` and call
49+
`osc ls openSUSE:Factory`.
50+
51+
52+
### Using the image labels
53+
54+
The image provides two labels `run` and `runcwd` which include the full command
55+
to run the `osc` container or run it with the local working directory mounted as
56+
well.
57+
58+
These labels can be shown via:
59+
60+
```ShellSession
61+
# podman container runlabel run --display {{ image.pretty_reference }}
62+
# podman container runlabel runcwd --display {{ image.pretty_reference }}
63+
```
64+
65+
Note that it is currently not yet possible to execute these labels with podman.
66+
67+
68+
### Connecting to build.suse.de
69+
70+
build.suse.de uses a ssh based authentication and thus requires additional
71+
resources to be available in the container. Additionally, you have to provide
72+
the internal certificate to the container as well:
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+
- It is currently not possible to build packages in a container.
89+
90+
91+
## Volumes
92+
93+
The container image is preconfigured to put `/var/tmp` into a volume. This
94+
directory is used by `osc` to store the buildroot and the package cache.
95+
96+
{% 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)