openSUSE / obs-build

OBS build script, can be used with OBS or stand alone
GNU General Public License v2.0
132 stars 183 forks source link

Dockerfile build: HOME=/, but obs-build writes to /root/.rpmmacros #901

Closed vasiliy-ul closed 1 year ago

vasiliy-ul commented 1 year ago

When building a Dockerfile container image with --vm-type=kvm, the .rpmmacros file gets written to /root while the HOME env var is set to /. This leads to unexpected results when trying to evaluate RPM macros which are supposed to come from prjconf (e.g. by executing rpm --eval ... in the build environment via a build-time service).

vasiliy-ul commented 1 year ago

@Vogtinator FYI.

ping @mlschroe

Vogtinator commented 1 year ago

The issue also affects RPM builds, or at least did in the past. I had to add a workaround to obs-service-kde for that.

vasiliy-ul commented 1 year ago

I guess we would need to copy or link .rpmmacros so it's present in both / and /root. Otherwise, it will break the existing workarounds with HOME=/root rpm --eval .... Maybe smth like below would be enough?

diff --git a/build-recipe b/build-recipe
index 753faa4..d68b456 100644
--- a/build-recipe
+++ b/build-recipe
@@ -235,6 +235,7 @@ recipe_setup_macros() {
                EOF
     fi
     test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/$rawcfgmacros $BUILD_ROOT/home/abuild/$rawcfgmacros
+    cp -p $BUILD_ROOT/root/$rawcfgmacros $BUILD_ROOT/$rawcfgmacros
 }

 # generate a .build-changelog file from a .changes file
Vogtinator commented 1 year ago

No, obs-build just needs to make sure that $HOME is set properly.

vasiliy-ul commented 1 year ago

Yes, that will work either.... ofc, if nobody made assumptions about HOME=/ in their specs.