[opensuse-buildservice] chown issues
I've got a package with this code snippet in one of my Makefiles: install-exec-hook: $(install_sh) -d $(DESTDIR)$(sysrundir) if [ `id -u` -eq 0 ]; then \ chown $(dnx_user):$(dnx_group) $(DESTDIR)$(sysrundir); \ fi 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-exec-hook: $(install_sh) -d $(DESTDIR)$(sysrundir) if [ `id -u` -eq 0 ] && [ -z ${DESTDIR} ]; then \ chown $(dnx_user):$(dnx_group) $(DESTDIR)$(sysrundir); \ fi 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, John --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
John Calcote escribió: rk.
My question: Is this a good approach, or am I TOTALLY off base? :)
As long as you %dir %attr(750,%{dnx_user},%{dnx_group}) /var/run/dnx in the spec file and create the needed dnx_user and dnx_group on the system by using useradd and groupadd in %pre it looks like an acceptable solution ;-) -- "Morality is merely an interpretation of certain phenomena — more precisely, a misinterpretation." - Friedrich Nietzsche Cristian Rodríguez R. Platform/OpenSUSE - Core Services SUSE LINUX Products GmbH Research & Development http://www.opensuse.org/ --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
On Mon, Mar 24, 2008 at 03:44:47PM -0600, John Calcote wrote:
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.
Actually they shouldn't build as root, I've to investigate what's going on here. Thanks, Michael. -- Michael Schroeder mls@suse.de SUSE LINUX Products GmbH, GF Markus Rex, HRB 16746 AG Nuernberg main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);} --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
Michael Schroeder wrote:
On Mon, Mar 24, 2008 at 03:44:47PM -0600, John Calcote wrote:
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.
Actually they shouldn't build as root, I've to investigate what's going on here.
Guess: they don't build as root, but due to fakeroot usage the 'id -u' call returns 0. But as there's no dnx user at build time, the chown call fails. Michal --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
participants (4)
-
Cristian Rodríguez
-
John Calcote
-
Michael Schroeder
-
Michal Marek