Osc build - how to not clean BUILD and BUILDROOT directories

Hello,

I am building packages using “osc build” command (version 0.182.0) in Tumbleweed. Find that once a package has been built successfully, contents in the following directories are removed:

/var/tmp/build-root/standard-x86_64/home/abuild/rpmbuild/BUILD
/var/tmp/build-root/standard-x86_64/home/abuild/rpmbuild/BUILDROOT

Also the stdout logs show that the default behavior is to keep rpmbuild (if --clean option is not specified) but remove all contents under BUILD/ and BUILDROOT/

[  254s] Executing(%clean): /usr/bin/bash -e /var/tmp/rpm-tmp.6Ya5cM
[  254s] + umask 022
[  254s] + cd /home/abuild/rpmbuild/BUILD
[  254s] + cd tar-1.34
[  254s] + /usr/bin/rm -rf /home/abuild/rpmbuild/BUILDROOT/tar-1.34-0.x86_64
[  254s] + RPM_EC=0
[  254s] ++ jobs -p
[  254s] + exit 0
[  254s] Executing(rmbuild): /usr/bin/bash -e /var/tmp/rpm-tmp.kMeDFY
[  254s] + umask 022
[  254s] + cd /home/abuild/rpmbuild/BUILD
[  254s] + rm -rf tar-1.34 tar-1.34.gemspec
[  254s] + RPM_EC=0
[  254s] ++ jobs -p
[  254s] + exit 0

Is there an option or a way to keep these directories without being cleaned? (It is probably can be achieved using chroot and rpmbuild command directly but I’d prefer an “osc way”).

Thanks.

Hi
I create a separate build-root (owned by root), not in the default location and specify in oscrc. In my case build-root = /data/build-root.

This hack does not work for me. I set the same build-root with you in oscrc and then executed osc build command, directories were cleaned.
Did you make other configurations to restrict it from running rm command?

@we3i not a hack a configuration change… aside from that and packagecache location, just use the sudo wrapper. Same config for many many years.

@malcolmlewis It still does not work. I have following configurations:

su-wrapper = sudo
build-root = /data/build-root/

My own solution is to add exit 1 in the %install section in the spec, and remove it after the failed building process.

Both of methods look like hack for me because these settings are not intended to be used for keeping files originally. A specific option should be more convenient. Maybe I will consider a feature request in future.

@we3i I’ve never seen what you describe, even with rpmbuild as my user the build is not deleted…

For sudo, you added your username and build to sudo?

cat /etc/sudoers.d/01-build
username ALL=NOPASSWD: /usr/bin/build

@we3i another thought, you can always look at the build log to see what is failing osc lbl maybe it’s my workflow, if it fails, see what fails and fix it, don’t generally need to look in /home/abuild directory.

Hello there,

I’m afraid there’s no “osc way” here, OBS’s build environment is designed to be hermetic - and as much as possible when using chroot as VM type, rather than e.g. KVM. If the build succeeds, there’s no reason to keep the builddir and buildroot directories around.

Out of curiosity, what’s the use case here?

@luc14n0 @malcolmlewis

What I’d like to do is just to keep the source code that the patches have been applied, and an environment that binaries have been installed, so I could use it for the further development. I know I can patch it manually, also other information can be found in the logs, but if osc provides a way then I can save some commands.

As what you have suggested, I agree that this request is not so important and probably very few people need it.

Ah, I see. Indeed osc, wasn’t designed for this kind of workflow, at least not exactly for the way you’re describing.