Skip to content

Commit 84b5314

Browse files
committed
create an osc container for package maintenance
1 parent 3d4781c commit 84b5314

4 files changed

Lines changed: 184 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
@@ -1442,6 +1442,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
14421442
from .appcontainers import MARIADB_CLIENT_CONTAINERS # noqa: E402
14431443
from .appcontainers import MARIADB_CONTAINERS # noqa: E402
14441444
from .appcontainers import NGINX_CONTAINERS # noqa: E402
1445+
from .appcontainers import OSC_CONTAINER # noqa: E402
14451446
from .appcontainers import PCP_CONTAINERS # noqa: E402
14461447
from .appcontainers import POSTGRES_CONTAINERS # noqa: E402
14471448
from .appcontainers import PROMETHEUS_CONTAINERS # noqa: E402
@@ -1508,6 +1509,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
15081509
GITEA_RUNNER_CONTAINER,
15091510
*TOMCAT_CONTAINERS,
15101511
*GCC_CONTAINERS,
1512+
OSC_CONTAINER,
15111513
)
15121514
}
15131515

src/bci_build/package/appcontainers.py

Lines changed: 72 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,74 @@ 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+
_BASE_PODMAN_OSC_CMD = (
814+
"podman run --rm -it "
815+
+ r"-v \$HOME/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z "
816+
+ r"-v \$HOME/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:z"
817+
)
818+
819+
OSC_CONTAINER = ApplicationStackContainer(
820+
name="osc",
821+
pretty_name="Packaging",
822+
package_name="packaging-image",
823+
os_version=OsVersion.TUMBLEWEED,
824+
is_latest=True,
825+
version_in_uid=False,
826+
version="%%osc_version%%",
827+
replacements_via_service=[
828+
Replacement(regex_in_build_description="%%osc_version%%", package_name="osc")
829+
],
830+
extra_files={
831+
"entrypoint.sh": (Path(__file__).parent / "osc" / "entrypoint.sh").read_bytes()
832+
},
833+
extra_labels={
834+
"run": f"{_BASE_PODMAN_OSC_CMD} IMAGE",
835+
"runcwd": f"{_BASE_PODMAN_OSC_CMD} -v .:/root/osc-workdir:z IMAGE",
836+
},
837+
package_list=[
838+
"osc",
839+
"obs-service-appimage",
840+
"obs-service-cargo",
841+
"obs-service-cdi_containers_meta",
842+
"obs-service-compose_kiwi_description",
843+
"obs-service-docker_label_helper",
844+
"obs-service-download_assets",
845+
"obs-service-download_files",
846+
"obs-service-download_url",
847+
"obs-service-extract_file",
848+
"obs-service-format_spec_file",
849+
"obs-service-go_modules",
850+
"obs-service-kiwi_label_helper",
851+
"obs-service-kiwi_metainfo_helper",
852+
"obs-service-kubevirt_containers_meta",
853+
"obs-service-node_modules",
854+
"obs-service-obs_scm",
855+
"cpio",
856+
"obs-service-product_converter",
857+
"obs-service-recompress",
858+
"obs-service-refresh_patches",
859+
"obs-service-replace_using_env",
860+
"obs-service-replace_using_package_version",
861+
"obs-service-set_version",
862+
"obs-service-snapcraft",
863+
"obs-service-source_validator",
864+
"obs-service-tar",
865+
"obs-service-tar_scm",
866+
"obs-service-verify_file",
867+
*_get_os_container_package_names(OsVersion.TUMBLEWEED),
868+
"git",
869+
"openssh-common",
870+
"openssh-clients",
871+
],
872+
cmd=["/bin/bash"],
873+
custom_end="""WORKDIR /root/osc-workdir
874+
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
875+
RUN chmod +x /usr/local/bin/entrypoint.sh
876+
""",
877+
entrypoint=["/usr/local/bin/entrypoint.sh"],
878+
volumes=[
879+
# default location of the build root & package cache
880+
"/var/tmp"
881+
],
882+
)
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Packaging Container
2+
3+
This is the openSUSE packaging container image, it includes all the necessary
4+
software to create and modify packages in 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` and
12+
the osc cookiejar mounted into the container:
13+
14+
```ShellSession
15+
# podman run --rm -it \
16+
-v ~/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z \
17+
-v ~/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:rw,z \
18+
{{ image.documentation_reference }}
19+
```
20+
21+
The above command launches an interactive shell where your local osc config will
22+
be used. You can then proceed to checkout packages, perform modifications and
23+
send submissions to OBS.
24+
25+
To work on an already checked out package, mount the current working directory:
26+
27+
```ShellSession
28+
# podman run --rm -it \
29+
-v ~/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z \
30+
-v ~/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:z \
31+
-v .:/root/osc-workdir:z \
32+
{{ image.documentation_reference }}
33+
```
34+
35+
The container entrypoint recognizes whether you are launching it for interactive
36+
usage or whether you are invoking `osc` directly. For convenience, you can omit
37+
the command `osc` in the second case. E.g.:
38+
39+
```ShellSession
40+
# podman run --rm -it \
41+
-v ~/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z \
42+
-v ~/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:z \
43+
-v .:/root/osc-workdir:z \
44+
{{ image.documentation_reference }} ls openSUSE:Factory
45+
```
46+
47+
The above command will automatically invoke forward the arguments to `osc` and
48+
call `osc ls openSUSE:Factory`.
49+
50+
51+
### Using the image labels
52+
53+
The image provides two labels `run` and `runcwd` which include the full command
54+
to run the `osc` container or run it with the local working directory mounted as
55+
well.
56+
57+
These labels can be shown via:
58+
59+
```ShellSession
60+
# podman container runlabel run --display {{ image.documentation_reference }}
61+
# podman container runlabel runcwd --display {{ image.documentation_reference }}
62+
```
63+
64+
Note that it is currently not yet possible to execute these labels with podman.
65+
66+
67+
### Connecting to build.suse.de
68+
69+
build.suse.de uses a ssh based authentication and thus requires additional
70+
resources to be available in the container. Additionally, you have to provide
71+
the internal certificate to the container as well:
72+
73+
```ShellSession
74+
# podman run --rm -it \
75+
-v ~/.config/osc/oscrc:/root/.config/osc/oscrc:ro,z \
76+
-v ~/.local/state/osc/cookiejar:/root/.local/state/osc/cookiejar:z \
77+
-v /etc/ssl/ca-bundle.pem:/etc/ssl/ca-bundle.pem:ro,z \
78+
-v $SSH_AUTH_SOCK:/run/user/0/ssh-agent.socket:z \
79+
-e SSH_AUTH_SOCK=/var/run/user/0/ssh-agent.socket:z \
80+
-v "$PWD":/root/osc-workdir:z \
81+
{{ image.documentation_reference }}
82+
```
83+
84+
85+
## Limitations
86+
87+
- It is currently not possible to build packages in a container.
88+
89+
90+
## Volumes
91+
92+
The container image is preconfigured to put `/var/tmp` into a volume. This
93+
directory is used by `osc` to store the buildroot and the package cache.
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)