Building RPM packages directly from git without intermediate tarballs?
Hi *, I am currently working on an environment for software developers based on openSUSE Leap 15.3 (on WSL, but that should not matter in this context). The aim is to provide developers with a per-configured environment using RPM configuration packages, i. e. packages with add a bunch of environment-specific config files to the existing installation. (The choice to use the package system for configuration delivery is intentional: the package delivery infrastructure is already there and there neither need nor infrastructure for any dynamic configuration service like puppet or ansible, hence no need to blow up the technology stack.) Those configuration packages do not package an existing »foreign« tar ball (towards which rpmbuild seems to be optimized) but are maintained simply in a git repository containing the files according to their place in the file hierarchy. To make rpmbuild work properly, a tar ball has to be generated explicitly first. The current solution is to use a wrapper script that creates the tar ball from the contents of the git working directory and then calls rpmbuild. The problem with that approach is that that wrapper script must either be maintained in every package git simultaneously or by itself provided as an additional build tool in a dedicated package. Both solutions are a little odd. Hence I would prefer a solution which gets along without such auxiliary wrappers, ideally just by calling rpmbuild. (It would be still fine if different build steps rely on auxiliary scripts in the current git working directory or similar). Technically, the necessity to specify (at least) one source in the spec file is the core obstacle: the source, whatever it may be, must be provided somehow by an external script to make rpmbuild not choke on its absence. There might be tools for exactly that purpose, e. g. https://honk.sigxcpu.org/projects/git-buildpackage/manual-html/man.gbp.build... which is surely helpful, but it is difficult to judge what the most »canonical« or »established« tool is. Any hints appreciated. (I am happy to provide an example if needed but would first have to extract one from the existing material.) Cheers, Florian
On Friday 2022-02-04 16:32, Florian Haftmann wrote:
To make rpmbuild work properly, a tar ball has to be generated explicitly first.
Not really. You just have to be aware of the constraints imposed by rpm, which is that the %_builddir is deleted at the start of %build. Other than that there is little in the way of things. No Source: lines are needed in the .spec. %build mv %_sourcedir/* ./ %configure %make_build works, provided you somehow populated rpmbuild/SOURCES/ somehow (which is not a big deal when calling rpmbuild itself, but can be when extra layers like OBS are on top - but that's not rpmbuild's fault).
To make rpmbuild work properly, a tar ball has to be generated explicitly first.
Not really. You just have to be aware of the constraints imposed by rpm, which is that the %_builddir is deleted at the start of %build. Other than that there is little in the way of things. No Source: lines are needed in the .spec.
%build mv %_sourcedir/* ./ %configure %make_build
works, provided you somehow populated rpmbuild/SOURCES/ somehow (which is not a big deal when calling rpmbuild itself, but can be when extra layers like OBS are on top - but that's not rpmbuild's fault).
Thanks for that hint, that worked out finally. My misunderstanding was the %prep step, which, when left out completely, does not complain about anything missing any longer. And, as you said, the %_sourcedir has to be populated – my approach is to call rpmbuild as follows in the git working directory: rpmbuild --define "_sourcedir $(pwd)" -ba *.spec This overhead is fairly tolerable. Cheers, Florian
Florian Haftmann wrote:
[...] Those configuration packages do not package an existing »foreign« tar ball (towards which rpmbuild seems to be optimized) but are maintained simply in a git repository containing the files according to their place in the file hierarchy. To make rpmbuild work properly, a tar ball has to be generated explicitly first.
Actually I was looking into that just recently and wanted to write about it :-) rpmbuild has a '--build-in-place' option which is exactly what you want I think. With that rpmbuild stays in the current directory and ignores the %setup macro. Ie no extraction of sources that may be specified in the spec file. Other bits you may want to skip (like applying patches) can either be guarded with "%if 0%{!?_build_in_place}" or you pass "--noprep" to rpmbuild which makes it skip %prep entirely. For faster turnaround times during development one can also leverage the --short-circuit and -b* options to jump to specific stages directly. For that purpose it also makes sense to move %configure into %prep actually. So compilation can be executed without the time consuming configure run. Last week the obs-build script also gained support for the build-in-place mode (in git). So rpms for openSUSE packages that already have their spec file alongside the sources in git (all of yast for example) can now be built locally without intermediate tarballs. cu Ludwig -- (o_ Ludwig Nussel //\ V_/_ http://www.suse.com/ SUSE Software Solutions Germany GmbH, GF: Ivo Totev HRB 36809 (AG Nürnberg)
participants (3)
-
Florian Haftmann
-
Jan Engelhardt
-
Ludwig Nussel