[CMake] rpmbuild breaks if HOME is wrong

fatman at crackmonkey.us fatman at crackmonkey.us
Tue Oct 5 05:33:28 EDT 2010


On Mon, 4 Oct 2010 20:45:21 +0200
Eric Noulard <eric.noulard at gmail.com> wrote:

> May be you can check in the generated spec file whether
> if this field has an appropriate value.

Apologies/length.

buildbot at nikko:/var/lib/buildbot/Reu2/slave/bin/nikko/build/cmake$ grep
-iFlr "BUILDROOT" .
./_CPack_Packages/Linux/RPM/SPECS/reu2.spec.in
./_CPack_Packages/Linux/RPM/SPECS/reu2.spec
buildbot at nikko:/var/lib/buildbot/Reu2/slave/bin/nikko/build/cmake$

Field is present in two files. I'm guessing the .in file is the more
interesting of the two so I'll check that first.

buildbot at nikko:/var/lib/buildbot/Reu2/slave/bin/nikko/build/cmake$ head
-n 5 ./_CPack_Packages/Linux/RPM/SPECS/reu2.spec.in
# -*- rpm-spec -*-
Buildroot:      @CPACK_RPM_DIRECTORY@/@CPACK_PACKAGE_FILE_NAME@
Summary:        @CPACK_RPM_PACKAGE_SUMMARY@
Name:           @CPACK_RPM_PACKAGE_NAME@
Version:        @CPACK_RPM_PACKAGE_VERSION@
buildbot at nikko:/var/lib/buildbot/Reu2/slave/bin/nikko/build/cmake$ head
-n 5 ./_CPack_Packages/Linux/RPM/SPECS/reu2.spec
# -*- rpm-spec -*-
Buildroot:     
/var/lib/buildbot/Reu2/slave/bin/nikko/build/cmake/_CPack_Packages/Linux/RPM/Reu2-0.1.1-Linux
Summary:        Reu2 - a reusable C++ modules library based on Boost
Name:           reu2
Version:        0.1.1
buildbot at nikko:/var/lib/buildbot/Reu2/slave/bin/nikko/build/cmake$

Seems one is an expanded version of the other. The value does seem to
be correct.

> Could you explain me why the buildbot would have an invalid HOME

Heh. This takes some explaining. Here goes. HOME is actually defined
correctly in /etc/passwd as "/var/lib/buildbot". (Why buildbot chose
*that* as opposed to "/home/buildbot" I don't know.)

The buildbot script is in two parts, buildmaster and buildslave. The
buildslave(s) run a series of build steps ("darcs pull", "make all",
etc) whenever they're told to. The buildmaster coordinates the actions
of the buildslaves and contains the build steps.

Let's assume the buildmaster is up and running already, and the
buildslave is already configured. Here's how I start the buildslave.

1. Log into the buildslave over SSH using my normal user account,
"fatman". The SSH daemon is set for public-key authentication only, so
"fatman" is the only account I can use.
2. Switch to a bash shell controlled by my non-login-enabled account,
"buildbot", using the command "sudo -u buildbot bash". Note, HOME
still points to "/home/fatman" because sudo doesn't change user
context.
3. Start the buildslave. It detaches itself from the console.
4. Exit from the buildbot shell and log out, leaving the buildslave
running in daemon mode.

Now, note that the buildslave environment is running with user
buildbot, but has the HOME of user fatman. When the buildmaster
instructs it to start a build and it gets around to running CPackRPM,
it still has the wrong HOME.

> If yes from which user to su from using which method (a,b,c,d,e)?

c) sudo

> from your point of view should I see the problem or do you have some
> other steps I miss ?

No, that is essentially what I do. You will see the problem.

> > error: failed to create directory %{_topdir}: /home/fatman/rpmbuild:
> > Permission denied
> 
> May be you can send me the whole rpmbuild.err and rpmbuild.out files?

The .out file is empty, and the .err file contains only that single
line.

buildbot at nikko:/var/lib/buildbot/Reu2/slave/bin/nikko/build/cmake$ cat
_CPack_Packages/Linux/RPM/rpmbuild.err
error: failed to create directory %{_topdir}: /home/fatman/rpmbuild:
Permission denied
buildbot at nikko:/var/lib/buildbot/Reu2/slave/bin/nikko/build/cmake$

My interpretation: rpmbuild is trying to make a temporary folder in
HOME and build the RPM package in it. HOME is wrong, so the permissions
for HOME are inappropriate, and we get "permission denied". Does that
sound plausible?

> > Note the different user. This is why the HOME variable is wrong.
> 
> Why would it be wrong?

I believe you are correct about su, but I'm using sudo, which for
reasons I forget doesn't switch user context (in Ubuntu at least).

> > /var/lib/buildbot/Reu2/slave/bin/nikko/build/cmake/_CPack_Packages/Linux/RPM
> 
> is the previous directory belonging to user buildbot ?

User buildbot owns /var/lib/buildbot and all subdirectories and files.

> > By the way, I am also building a DEB and TGZ package. They both
> > complete successfully.
> 
> Yes but even if rpm building is enabled on Debian based host it's
> possible that rpmbuild is not "working as expected" on such host.

Quite so. I meant that the aberrant behaviour seems to occur in the
part of the system governed by CPackRPM, rather than CMake, CPack,
CPackDEB or CPackTGZ (if those are the names).

> By any chance do you have any other buildbot machine which would be
> RPM based which exhibits the same trouble?

No. I do have a temporary buildslave, Vostro, running Ubuntu 32-bit.
The entire build succeeds and I get a pretty green column in my
buildmaster's waterfall webpage :D We don't see the same error because
I'm using my main user to start the buildslave. So that "sudo" isn't
needed, which means that the user's permission set is correct for HOME.

By the way, this deep folder hierarchy is getting on my nerves, so I am
going to symlink "/var/lib/buildbot/Reu2/slave/bin/nikko/build/cmake"
to "/var/lib/buildbot/deep" (owner: buildbot) to make things easier to
read. I don't think this will affect our testing, but I will double
check.


More information about the CMake mailing list