openSUSE / obs-service-replace_using_package_version

An OBS service to replace a regex with some package version available in the build time repositories
GNU General Public License v3.0
4 stars 12 forks source link

Replace with version inside container #21

Closed tacerus closed 2 years ago

tacerus commented 2 years ago

Hello,

I use this service to build containers using Dockerfiles. The service seems to not work if the package inside the container was installed from a non-default repository (i.e. a zypper ar to an OBS devel project in the Dockerfile):

[   66s] Traceback (most recent call last):
[   66s]   File "/usr/lib/obs/service/replace_using_package_version", line 186, in <module>
[   66s]     init(__name__)
[   66s]   File "/usr/lib/obs/service/replace_using_package_version", line 183, in init
[   66s]     main()
[   66s]   File "/usr/lib/obs/service/replace_using_package_version", line 81, in main
[   66s]     version = find_package_version(command_args['--package'], rpm_dir)
[   66s]   File "/usr/lib/obs/service/replace_using_package_version", line 128, in find_package_version
[   66s]     raise Exception('Package version not found')
[   66s] Exception: Package version not found

Is it possible to feed the package version from inside the container during the build?

Or is there a way to "tell" the service worker about this other repository?

Best, Georg

dcermak commented 2 years ago

Hello,

I use this service to build containers using Dockerfiles. The service seems to not work if the package inside the container was installed from a non-default repository (i.e. a zypper ar to an OBS devel project in the Dockerfile):

[   66s] Traceback (most recent call last):
[   66s]   File "/usr/lib/obs/service/replace_using_package_version", line 186, in <module>
[   66s]     init(__name__)
[   66s]   File "/usr/lib/obs/service/replace_using_package_version", line 183, in init
[   66s]     main()
[   66s]   File "/usr/lib/obs/service/replace_using_package_version", line 81, in main
[   66s]     version = find_package_version(command_args['--package'], rpm_dir)
[   66s]   File "/usr/lib/obs/service/replace_using_package_version", line 128, in find_package_version
[   66s]     raise Exception('Package version not found')
[   66s] Exception: Package version not found

Is it possible to feed the package version from inside the container during the build?

Or is there a way to "tell" the service worker about this other repository?

That should not be necessary, as OBS collects all your zypper ar calls, constructs a buildroot from that and dumps all rpms in there.

I suspect there is something else going wrong, but I could be wrong. Would you have a link to a failing build?

tacerus commented 2 years ago

Oh, I did not realize that. Thank you for getting back so quickly!

Here is the container in question:

https://build.opensuse.org/package/show/home:crameleon:gdev:containers/gdev-sle-powerdns-authoritative

tacerus commented 2 years ago

In this case the issue might be me executing the zypper in call in a separate expect script and not within the Dockerfile?

dcermak commented 2 years ago

In this case the issue might be me executing the zypper in call in a separate expect script and not within the Dockerfile?

The dockerfile that you have created will sadly never build in OBS: you cannot run any actions requiring an active internet connection. OBS runs your build fully offline. Do achieve that it pre-processes your Dockerfile and checks for any zypper ar calls injecting the repositories into the build root and pre-calculates all dependencies. This is also the reason why your a dockerfile will build outside of obs but in obs you will suddenly get dependency resolution errors…

In a nutshell, this is unfortunately not a bug in obs-service-replace_using_package_version, but rather your Dockerfile is invalid.

Btw, I have tried to make your Dockerfile build, but now OBS barfs with the dreaded have choice error: https://build.opensuse.org/package/show/home:dancermak:branches:home:crameleon:gdev:containers/gdev-sle-powerdns-authoritative

tacerus commented 2 years ago

Thank you very much for your effort! I thought zypper from OBS repositories would work regardless.

The choice error was the reason for my expect script - I suppose then I may have to fork the original package and remove the dependency.

Thanks again and my apologies for the false alarm here!