Mailinglist Archive: opensuse-buildservice (339 mails)

< Previous Next >
[opensuse-buildservice] chown issues
  • From: "John Calcote" <john.calcote@xxxxxxxxx>
  • Date: Mon, 24 Mar 2008 15:44:47 -0600
  • Message-id: <3ee91eb90803241444y797940b0gde31dafec1e3cc0d@xxxxxxxxxxxxxx>
I've got a package with this code snippet in one of my Makefiles:

$(install_sh) -d $(DESTDIR)$(sysrundir)
if [ `id -u` -eq 0 ]; then \
chown $(dnx_user):$(dnx_group) $(DESTDIR)$(sysrundir); \

Yes, this is actually an automake file, but that's irrelevant to the
issue at hand here.

I'm trying in this target to install a directory (usually
"/var/run/dnx"), and it's generally the case that this directory
belongs to my package. Because my daemon runs as it's own user,
$(dnx_user), I want to ensure this user can create files in this
directory, so I want to "chown" the directory.

When I install my package from the command line, it all works fine
because I chown as long as I'm running as root, but not if I'm running
as a user (can't chown anyway).

When I do a staged installation using DESTDIR=${BUILDROOT} on the make
command line (inside my spec file), it also works fine, because I
don't build my rpm as root.

When I build for ubuntu or debian, however, it appears that these
servers build their packages as root, so the build fails because the
package build is trying to chown something in the BUILDROOT.

Here's what I did to fix it:

$(install_sh) -d $(DESTDIR)$(sysrundir)
if [ `id -u` -eq 0 ] && [ -z ${DESTDIR} ]; then \
chown $(dnx_user):$(dnx_group) $(DESTDIR)$(sysrundir); \

I just added a check for an empty DESTDIR - no DESTDIR, no staged
installation. It seems to work.

My question: Is this a good approach, or am I TOTALLY off base? :)

Thanks in advance,
To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-buildservice+help@xxxxxxxxxxxx

< Previous Next >