From patchwork Fri Sep 25 23:16:01 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Nieder X-Patchwork-Id: 50190 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8PN9WNd014556 for ; Fri, 25 Sep 2009 23:09:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752721AbZIYXJJ (ORCPT ); Fri, 25 Sep 2009 19:09:09 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752693AbZIYXJI (ORCPT ); Fri, 25 Sep 2009 19:09:08 -0400 Received: from mail-yx0-f173.google.com ([209.85.210.173]:60976 "EHLO mail-yx0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752690AbZIYXJD (ORCPT ); Fri, 25 Sep 2009 19:09:03 -0400 Received: by yxe3 with SMTP id 3so1009972yxe.4 for ; Fri, 25 Sep 2009 16:09:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=51M50wiPR3234JGM98nb3oGN3lPe5+73/HOUIJ/FUVA=; b=p+UarsjNvr6aXs2IoTJXKiEo1YESHiO9Pny/Ka3gfK3BMUUNuXVKdac2cabvspmV9D FpK9mWWk3CQdx7X4Vi5JzmCt+kd8wjULSvrNHJadgo3CsTmhDYibUt/HJxakhCXKuj+c eA8ktOrIOaWF7ZmZYNl7tuVpHe1fVo1mEWDvw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=SZelnNQi7X59Tjv6AEdnrwyPll+9jeT48gH9U1B20z1YfhT5GWdvDmiDZKxNo1Thqm 06rH+wjbnWygefEejSiklvAj8r5psD5fJTj7b2n4gzDi2l3FewjmkyGyeC+d80BQ4154 KRUNa+TjUOO3IPk49Mxo0CiFVADCzFpHg2ZNE= Received: by 10.150.236.18 with SMTP id j18mr3475351ybh.110.1253920145941; Fri, 25 Sep 2009 16:09:05 -0700 (PDT) Received: from progeny.tock (c-98-212-3-231.hsd1.il.comcast.net [98.212.3.231]) by mx.google.com with ESMTPS id 21sm463319yxe.9.2009.09.25.16.09.04 (version=SSLv3 cipher=RC4-MD5); Fri, 25 Sep 2009 16:09:05 -0700 (PDT) Date: Fri, 25 Sep 2009 18:16:01 -0500 From: Jonathan Nieder To: linux-kbuild@vger.kernel.org Cc: Sam Ravnborg , Ryan Anderson Subject: [PATCH 2/2] kbuild: scripts/package: set ROOTCMD="fakeroot -u" by default Message-ID: <20090925231601.GB28714@progeny.tock> References: <20090925231156.GA28714@progeny.tock> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20090925231156.GA28714@progeny.tock> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org 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 --- 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: