linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: linux-kbuild@vger.kernel.org
Cc: maximilian attems <max@stro.at>, Sam Ravnborg <sam@ravnborg.org>,
	Frans Pop <elendil@planet.nl>
Subject: [PATCH v2 2/2] scripts/package: use fakeroot if available
Date: Thu, 15 Oct 2009 08:39:13 -0500	[thread overview]
Message-ID: <20091015133913.GC6718@progeny.tock> (raw)
In-Reply-To: <20091015133139.GA6718@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 KBUILD_PKG_ROOTCMD or become root yourself to run
"make foo-pkg".

With this patch applied, 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.  This slows down the Linux
build with CONFIG_LOCALVERSION_AUTO a lot, since git notices that the
owners have changed and has to reread the entire kernel tree to learn
that the content has not changed.  Since "make modules_install" and
"scripts/package/foo" run within the same fakeroot session, we are
free to avoid this by telling fakeroot to use the actual owner and
group for preexisting files, by passing it the -u option.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Changes from v1:
 - rename ROOTCMD variable to KBUILD_PKG_ROOTCMD

 scripts/package/Makefile |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 6997f38..2aa7e8c 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 KBUILD_PKG_ROOTCMD
+ifneq ($(shell id -u),0)
+ifeq ($(shell which fakeroot >/dev/null 2>&1 && echo found),found)
+KBUILD_PKG_ROOTCMD := fakeroot -u
+endif
+endif
+endif
+
 # RPM target
 # ---------------------------------------------------------------------------
 # The rpm target generates two rpm files:
-- 
1.6.5.rc1.199.g596ec


  parent reply	other threads:[~2009-10-15 13:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-14  6:46 [PATCH resend 0/2] fakeroot dwimery for scripts/package/* Jonathan Nieder
2009-10-14  6:54 ` [PATCH resend 1/2] scripts/package: add ROOTCMD variable Jonathan Nieder
2009-10-14  6:55 ` [PATCH resend 2/2] scripts/package: use fakeroot if available Jonathan Nieder
2009-10-14  7:16 ` [PATCH resend 0/2] fakeroot dwimery for scripts/package/* Sam Ravnborg
2009-10-14  9:59   ` Frans Pop
2009-10-14 11:03     ` maximilian attems
2009-10-15 13:31       ` [PATCH v2 " Jonathan Nieder
2009-10-15 13:35         ` [PATCH v2 1/2] scripts/package: add KBUILD_PKG_ROOTCMD variable Jonathan Nieder
2009-11-24 11:27           ` Michal Marek
2009-11-24 12:03             ` Jonathan Nieder
2009-11-24 13:13               ` Michal Marek
2009-11-24 15:09             ` [PATCH v3 0/3] fakeroot dwimery for deb-pkg target Jonathan Nieder
2009-11-24 15:11               ` [PATCH 1/3] scripts/package: tar-pkg: use tar --owner=root Jonathan Nieder
2009-11-24 15:14               ` [PATCH v3 2/3] scripts/package: add KBUILD_PKG_ROOTCMD variable Jonathan Nieder
2009-11-24 15:21               ` [PATCH v3 3/3] scripts/package: deb-pkg: use fakeroot if available Jonathan Nieder
2009-11-24 19:07                 ` Michal Marek
2009-10-15 13:39         ` Jonathan Nieder [this message]
2009-11-04 21:22         ` [PATCH v2 0/2] fakeroot dwimery for scripts/package/* maximilian attems

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=20091015133913.GC6718@progeny.tock \
    --to=jrnieder@gmail.com \
    --cc=elendil@planet.nl \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=max@stro.at \
    --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;
as well as URLs for NNTP newsgroup(s).