From: Jonathan Nieder <jrnieder@gmail.com>
To: linux-kbuild@vger.kernel.org
Cc: Sam Ravnborg <sam@ravnborg.org>, Ryan Anderson <ryan@michonline.com>
Subject: [PATCH 2/2] kbuild: scripts/package: set ROOTCMD="fakeroot -u" by default
Date: Fri, 25 Sep 2009 18:16:01 -0500 [thread overview]
Message-ID: <20090925231601.GB28714@progeny.tock> (raw)
In-Reply-To: <20090925231156.GA28714@progeny.tock>
Unless already running as root, use fakeroot to ensure the files
in the generated binary packages are owned by root. Without this
change, you have to set ROOTCMD or become root yourself to run
"make foo-pkg".
With this change, you can run "make oldconfig rpm-pkg" as an
ordinary user to build a binary package for an updated kernel
tree and it should just work.
fakeroot is a bit too zealous by default in pretending files are
owned by root: unless directed otherwise, its wrapped stat() and
lstat() set st_uid and st_gid to 0 for all files. If
CONFIG_LOCALVERSION_AUTO=y is set, git notices that the owners
have changed and has to reread the entire kernel tree to discover
that the version string does not need a "-dirty" suffix. But as
long as "make install" and "scripts/package/foo" run within the
same fakeroot invocation, it is perfectly safe to use the actual
owner and group for preexisting files. Make it so by passing
fakeroot the -u option.
Note: if fakeroot is missing, all members of the package
generated by "make tar-pkg" will be owned and writable by the
invoking user, even once the archive is extracted. This is true
even without this patch and probably should be addressed
separately.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Actually, this is all just an excuse to include a reminder about fakeroot -u
in the kernel. :) But maybe it could be convenient for others, anyway.
I look forward to your thoughts.
Thanks,
Jonathan
scripts/package/Makefile | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index a5d9088..260e3e6 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -1,6 +1,15 @@
# Makefile for the different targets used to generate full packages of a kernel
# It uses the generic clean infrastructure of kbuild
+# How to acquire (fake) root privileges
+ifndef ROOTCMD
+ifneq ($(shell id -u),0)
+ifeq ($(shell which fakeroot >/dev/null 2>&1 && echo found),found)
+ROOTCMD := fakeroot -u
+endif
+endif
+endif
+
# RPM target
# ---------------------------------------------------------------------------
# The rpm target generates two rpm files:
--
1.6.5.rc1.199.g596ec
prev parent reply other threads:[~2009-09-25 23:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-25 23:11 [PATCH 1/2] kbuild: scripts/package: use $(ROOTCMD) to become root Jonathan Nieder
2009-09-25 23:16 ` Jonathan Nieder [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090925231601.GB28714@progeny.tock \
--to=jrnieder@gmail.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=ryan@michonline.com \
--cc=sam@ravnborg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox