Skip to content

Commit b8c97d5

Browse files
committed
create an osc container for package maintenance
1 parent 321c3ec commit b8c97d5

4 files changed

Lines changed: 152 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
@@ -1422,6 +1422,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
14221422
from .appcontainers import MARIADB_CLIENT_CONTAINERS # noqa: E402
14231423
from .appcontainers import MARIADB_CONTAINERS # noqa: E402
14241424
from .appcontainers import NGINX_CONTAINERS # noqa: E402
1425+
from .appcontainers import OSC_CONTAINER # noqa: E402
14251426
from .appcontainers import PCP_CONTAINERS # noqa: E402
14261427
from .appcontainers import POSTGRES_CONTAINERS # noqa: E402
14271428
from .appcontainers import PROMETHEUS_CONTAINERS # noqa: E402
@@ -1488,6 +1489,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
14881489
GITEA_RUNNER_CONTAINER,
14891490
*TOMCAT_CONTAINERS,
14901491
*GCC_CONTAINERS,
1492+
OSC_CONTAINER,
14911493
)
14921494
}
14931495

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: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Packaging Container
2+
3+
This is the openSUSE packaging container image, it includes all the necessary
4+
software to create and modify packages on 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.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+
as well:
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.reference }}
34+
```
35+
36+
### Connecting to build.suse.de
37+
38+
build.suse.de uses a ssh based authentication and thus requires additional
39+
resources to be available in the container:
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 /etc/ssl/ca-bundle.pem:/etc/ssl/ca-bundle.pem:ro,z \
46+
-v $SSH_AUTH_SOCK:/run/user/0/ssh-agent.socket:z \
47+
-e SSH_AUTH_SOCK=/var/run/user/0/ssh-agent.socket:z \
48+
-v "$PWD":/root/osc-workdir:z \
49+
{{ image.reference }}
50+
```
51+
52+
53+
## Limitations
54+
55+
- It is currently not possible to build packages in a container.
56+
57+
58+
## Volumes
59+
60+
The container image is preconfigured to put `/var/tmp` into a volume. This
61+
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)