Message ID | 20231128235356.527642-1-masahiroy@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp5981vqn; Tue, 28 Nov 2023 15:54:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDF9nI3r02jjfGC4xkfr02A1CfFrwdaJR9zduoK6OrWt5D/WJ9WvYBtqyGxnkiFNZ5nJ8W X-Received: by 2002:a05:6808:1b1f:b0:3b6:cb6a:18b1 with SMTP id bx31-20020a0568081b1f00b003b6cb6a18b1mr19819192oib.32.1701215650062; Tue, 28 Nov 2023 15:54:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701215650; cv=none; d=google.com; s=arc-20160816; b=ZTfjtTOsRM5iSPS7ucIVq3tN9WFZuTzjF/FcubGLo1y/PY/BSqAzOXz583VNq7rJOG QPW7FlZhRQpkrCGFBpGVOSO9TqYrgAPXCnw24ikPTeRPzsneZf9Bv3VWcdTKjK1w540U dPTehMsSte83GwVK+U9Mv21j16kvwXsWyTZ7HJPvCYsrsBEZ1rRXxMgRz+ACkqaNAq0r ahxiw3Nsl8Ev0YcJIu6PFFfU9RiRST3L/32Qx3WFvOTLhgYFA+B9vKEFlszTVLh9gIPM 81mhcu+XhXF5ILlkcRM3UP10HBP8X5go8EwnJZoIOMd2vG7J1Y8o5fEIK7XbrJS9RQ17 i+dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=UvFKGZaW15xvD9q0EtubMkAvz2lIn2ozItk666MrmSc=; fh=YRXGQk/HFQa4m0Wt8I2zBZV8pwB8/PsOmZZYsB3Rim8=; b=MSi266eMx37fJI3QVEVKdTa0f7y0jVpz7jOvSZmrNvv3f2nt3oGcNk1qv+S0qL4+iA OAnCHF7FMHroURS/yQnN18ApMDqxHx4AHanPDhX9JJ3Yl/jsRH77vwnVvfukRnZhvd7r jDOhTM3QCd3lBZTVFfC25AJhHzqOQXOp5I95QSQ98ha9lkuPEEe664AcDWxJf7q3fF4c /2N8v8QgROlMB1gHmmqOs1KEQeWl7jKvFx6Gu35/4YjYeSJBcqHwqOiFXulgy8o9i86J 0//T9uzB+pPh63aGg/YqwaiU3gM1nW3NzIWY/92OU/FFGKb5UGaC7A3IWN6cxN//jK8/ C/eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P2ttvRu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id e7-20020a636907000000b005be10674e53si12636696pgc.479.2023.11.28.15.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 15:54:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P2ttvRu6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 925D08205FEB; Tue, 28 Nov 2023 15:54:06 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376652AbjK1Xx6 (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Tue, 28 Nov 2023 18:53:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjK1Xxz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 28 Nov 2023 18:53:55 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8343419AD for <linux-kernel@vger.kernel.org>; Tue, 28 Nov 2023 15:54:02 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8D90C433C7; Tue, 28 Nov 2023 23:54:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701215642; bh=VbzLBZ/YYyTvUGv4/iK4ZZqJeQrZU/0QjMg1LUuUi1k=; h=From:To:Cc:Subject:Date:From; b=P2ttvRu6LCRc2NS+7C8SHzFk3J3EUa3WYM98z1Irrlea6vASLS4w/4xGhR5UY5xHm cBdNMNzHf0FdxNgIGPulW2p98FuME9N+Vm2i5TvpNiZOQ82YDKcgtn4+ttpxTgQlwh C7DsA3h5gtSld+qmeswoYwZp9NHtVN+z2z35hwS9Uo2+oCD/jWJn8AiUN8rWL5/2ko dTV6xjc5VvB4wUkExly+a3/RFS5z/JdjwNhWgvPMqQb0CmbZw2tK6JQu3gV2dAIQj8 pat6wPu+25qbXVswIv8Ab+7HaeX5pGipLQUUjkq42QGP2ddHADgJdUvy1f806SM3hL 6HNYOw+koeXLg== From: Masahiro Yamada <masahiroy@kernel.org> To: linux-kbuild@vger.kernel.org Cc: Guillem Jover <guillem@debian.org>, Ben Hutchings <ben@decadent.org.uk>, Masahiro Yamada <masahiroy@kernel.org>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Nicolas Schier <nicolas@fjasle.eu>, linux-kernel@vger.kernel.org Subject: [PATCH v3] kbuild: deb-pkg: remove the fakeroot builds support Date: Wed, 29 Nov 2023 08:53:56 +0900 Message-Id: <20231128235356.527642-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 28 Nov 2023 15:54:06 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783812559357728357 X-GMAIL-MSGID: 1783853901366529010 |
Series |
[v3] kbuild: deb-pkg: remove the fakeroot builds support
|
|
Commit Message
Masahiro Yamada
Nov. 28, 2023, 11:53 p.m. UTC
In 2017, the dpkg suite introduced the rootless builds support with the
following commits:
- 2436807c87b0 ("dpkg-deb: Add support for rootless builds")
- fca1bfe84068 ("dpkg-buildpackage: Add support for rootless builds")
This feature is available in the default dpkg on Debian 10 and Ubuntu
20.04.
Remove the old method.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
Changes in v3:
- Remove DEB_RULES_REQUIRES_ROOT=no again
(resent in order to clarify which one should be applied)
Changes in v2:
- add DEB_RULES_REQUIRES_ROOT=no to debian/rules
scripts/Makefile.package | 4 +---
scripts/package/builddeb | 8 +-------
2 files changed, 2 insertions(+), 10 deletions(-)
Comments
Hi! On Wed, 2023-11-29 at 08:53:56 +0900, Masahiro Yamada wrote: > In 2017, the dpkg suite introduced the rootless builds support with the > following commits: > > - 2436807c87b0 ("dpkg-deb: Add support for rootless builds") > - fca1bfe84068 ("dpkg-buildpackage: Add support for rootless builds") > > This feature is available in the default dpkg on Debian 10 and Ubuntu > 20.04. > > Remove the old method. > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > --- > > Changes in v3: > - Remove DEB_RULES_REQUIRES_ROOT=no again > (resent in order to clarify which one should be applied) Thanks, as this variable is supposed to be defined by the build driver (such as dpkg-buildpackage) that calls debian/rules, as covered in the rootless-builds.txt spec. > diff --git a/scripts/Makefile.package b/scripts/Makefile.package > index 0c3adc48dfe8..a81dfb1f5181 100644 > --- a/scripts/Makefile.package > +++ b/scripts/Makefile.package > @@ -109,8 +109,6 @@ debian-orig: linux.tar$(debian-orig-suffix) debian > cp $< ../$(orig-name); \ > fi > > -KBUILD_PKG_ROOTCMD ?= 'fakeroot -u' > - > PHONY += deb-pkg srcdeb-pkg bindeb-pkg > > deb-pkg: private build-type := source,binary > @@ -125,7 +123,7 @@ deb-pkg srcdeb-pkg bindeb-pkg: > $(if $(findstring source, $(build-type)), \ > --unsigned-source --compression=$(KDEB_SOURCE_COMPRESS)) \ > $(if $(findstring binary, $(build-type)), \ > - -R'$(MAKE) -f debian/rules' -j1 -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch), \ > + -R'$(MAKE) -f debian/rules' -j1 -a$$(cat debian/arch), \ Since dpkg 1.14.7, dpkg-buildpackage uses fakeroot if available, so regardless of anything else this removal seems safe. > --no-check-builddeps) \ > $(DPKG_FLAGS)) > > diff --git a/scripts/package/builddeb b/scripts/package/builddeb > index d7dd0d04c70c..2fe51e6919da 100755 > --- a/scripts/package/builddeb > +++ b/scripts/package/builddeb > @@ -36,19 +36,13 @@ create_package() { > sh -c "cd '$pdir'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' \ > | xargs -r0 md5sum > DEBIAN/md5sums" > > - # Fix ownership and permissions > - if [ "$DEB_RULES_REQUIRES_ROOT" = "no" ]; then > - dpkg_deb_opts="--root-owner-group" > - else > - chown -R root:root "$pdir" > - fi > # a+rX in case we are in a restrictive umask environment like 0077 > # ug-s in case we build in a setuid/setgid directory > chmod -R go-w,a+rX,ug-s "$pdir" > > # Create the package > dpkg-gencontrol -p$pname -P"$pdir" > - dpkg-deb $dpkg_deb_opts ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. > + dpkg-deb --root-owner-group ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. If you want to make sure dpkg-deb supports that option, perhaps add «dpkg (>= 1.19.0)» to the package Build-Depends? If that version seems old enough to be assumed to be present, then unconditionally using it seems fine. > } > > install_linux_image () { Otherwise, the change LGTM. Thanks, Guillem
On Wed, Nov 29, 2023 at 12:04 PM Guillem Jover <guillem@debian.org> wrote: > > Hi! > > On Wed, 2023-11-29 at 08:53:56 +0900, Masahiro Yamada wrote: > > In 2017, the dpkg suite introduced the rootless builds support with the > > following commits: > > > > - 2436807c87b0 ("dpkg-deb: Add support for rootless builds") > > - fca1bfe84068 ("dpkg-buildpackage: Add support for rootless builds") > > > > This feature is available in the default dpkg on Debian 10 and Ubuntu > > 20.04. > > > > Remove the old method. > > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> > > --- > > > > Changes in v3: > > - Remove DEB_RULES_REQUIRES_ROOT=no again > > (resent in order to clarify which one should be applied) > > Thanks, as this variable is supposed to be defined by the build driver > (such as dpkg-buildpackage) that calls debian/rules, as covered in the > rootless-builds.txt spec. > > > diff --git a/scripts/Makefile.package b/scripts/Makefile.package > > index 0c3adc48dfe8..a81dfb1f5181 100644 > > --- a/scripts/Makefile.package > > +++ b/scripts/Makefile.package > > @@ -109,8 +109,6 @@ debian-orig: linux.tar$(debian-orig-suffix) debian > > cp $< ../$(orig-name); \ > > fi > > > > -KBUILD_PKG_ROOTCMD ?= 'fakeroot -u' > > - > > PHONY += deb-pkg srcdeb-pkg bindeb-pkg > > > > deb-pkg: private build-type := source,binary > > @@ -125,7 +123,7 @@ deb-pkg srcdeb-pkg bindeb-pkg: > > $(if $(findstring source, $(build-type)), \ > > --unsigned-source --compression=$(KDEB_SOURCE_COMPRESS)) \ > > $(if $(findstring binary, $(build-type)), \ > > - -R'$(MAKE) -f debian/rules' -j1 -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch), \ > > + -R'$(MAKE) -f debian/rules' -j1 -a$$(cat debian/arch), \ > > Since dpkg 1.14.7, dpkg-buildpackage uses fakeroot if available, so > regardless of anything else this removal seems safe. You are right. Even without the explicit -r option, fakeroot will be used when dpkg-buildpackage determines it is necessary. Only a use-case I can come up with is, the fakeroot command is not installed on the system, and a user may want to do "make bindeb-pkg KBUILD_PKG_ROOTCMD=sudo" as a backup plan. Anyway, now we always assume "--root-command=none" should work, so -r$(KBUILD_PKG_ROOTCMD) is unneeded. > > --no-check-builddeps) \ > > $(DPKG_FLAGS)) > > > > diff --git a/scripts/package/builddeb b/scripts/package/builddeb > > index d7dd0d04c70c..2fe51e6919da 100755 > > --- a/scripts/package/builddeb > > +++ b/scripts/package/builddeb > > @@ -36,19 +36,13 @@ create_package() { > > sh -c "cd '$pdir'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' \ > > | xargs -r0 md5sum > DEBIAN/md5sums" > > > > - # Fix ownership and permissions > > - if [ "$DEB_RULES_REQUIRES_ROOT" = "no" ]; then > > - dpkg_deb_opts="--root-owner-group" > > - else > > - chown -R root:root "$pdir" > > - fi > > # a+rX in case we are in a restrictive umask environment like 0077 > > # ug-s in case we build in a setuid/setgid directory > > chmod -R go-w,a+rX,ug-s "$pdir" > > > > # Create the package > > dpkg-gencontrol -p$pname -P"$pdir" > > - dpkg-deb $dpkg_deb_opts ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. > > + dpkg-deb --root-owner-group ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. > > If you want to make sure dpkg-deb supports that option, perhaps add > «dpkg (>= 1.19.0)» to the package Build-Depends? If that version seems > old enough to be assumed to be present, then unconditionally using it > seems fine. Personally, I do not want to list an essential tool in the dependency. The Debian kernel does not do it either. Anyway, thank you for your comments. > > } > > > > install_linux_image () { > > Otherwise, the change LGTM. > > Thanks, > Guillem
diff --git a/scripts/Makefile.package b/scripts/Makefile.package index 0c3adc48dfe8..a81dfb1f5181 100644 --- a/scripts/Makefile.package +++ b/scripts/Makefile.package @@ -109,8 +109,6 @@ debian-orig: linux.tar$(debian-orig-suffix) debian cp $< ../$(orig-name); \ fi -KBUILD_PKG_ROOTCMD ?= 'fakeroot -u' - PHONY += deb-pkg srcdeb-pkg bindeb-pkg deb-pkg: private build-type := source,binary @@ -125,7 +123,7 @@ deb-pkg srcdeb-pkg bindeb-pkg: $(if $(findstring source, $(build-type)), \ --unsigned-source --compression=$(KDEB_SOURCE_COMPRESS)) \ $(if $(findstring binary, $(build-type)), \ - -R'$(MAKE) -f debian/rules' -j1 -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch), \ + -R'$(MAKE) -f debian/rules' -j1 -a$$(cat debian/arch), \ --no-check-builddeps) \ $(DPKG_FLAGS)) diff --git a/scripts/package/builddeb b/scripts/package/builddeb index d7dd0d04c70c..2fe51e6919da 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -36,19 +36,13 @@ create_package() { sh -c "cd '$pdir'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' \ | xargs -r0 md5sum > DEBIAN/md5sums" - # Fix ownership and permissions - if [ "$DEB_RULES_REQUIRES_ROOT" = "no" ]; then - dpkg_deb_opts="--root-owner-group" - else - chown -R root:root "$pdir" - fi # a+rX in case we are in a restrictive umask environment like 0077 # ug-s in case we build in a setuid/setgid directory chmod -R go-w,a+rX,ug-s "$pdir" # Create the package dpkg-gencontrol -p$pname -P"$pdir" - dpkg-deb $dpkg_deb_opts ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. + dpkg-deb --root-owner-group ${KDEB_COMPRESS:+-Z$KDEB_COMPRESS} --build "$pdir" .. } install_linux_image () {