From patchwork Tue Dec 26 13:52:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 183319 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp875183dyb; Tue, 26 Dec 2023 05:53:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IEgG7LoDKyiDA2oVrot+ynx4EMKIS94JUBKzuDeVugri4UEFUxJdSspbhubNFbdnbGb9nf7 X-Received: by 2002:a17:906:1097:b0:a23:67d2:c546 with SMTP id u23-20020a170906109700b00a2367d2c546mr3140643eju.80.1703598827550; Tue, 26 Dec 2023 05:53:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703598827; cv=none; d=google.com; s=arc-20160816; b=gQDZsOB8WkjYLcfHqxqwwCiCVbPWzOF6zw41wLMpqILxZ83mBeNOz2K9beXlaYXmXj T2acz5n+QrrUViKPz04hI+MOC8frGPpkTZTqnqMKJEE0hS6nTDg0/IRmHA68Xw5ui6h4 DS83tE1MFV7wBVYtMh0wXVLBcGGcNFSRIj8+s4cHbzlpQCKnzl+q2UhOJGWOWafeL2K5 UrKXXeuh1HDhS08H25wQ0Wd65kla0wJBtonZTkt/2bD9qSIujEhEWhVmKZCsfxjPx84T dr2Yc/eSCl09vC25f0XNedKflkyVcBQsqW7pOW+hiSwMQ9tW4fNtZfJaZ2dREjeExQej 10AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=6tb74LZlyhHN1r5szZooZyC5f32WLVMW4lbS9l/Qru4=; fh=5gYN4msaJmwnN8mGpibv8VZnTy0MtvGQcf5D09XpoaQ=; b=IlZYtqP/+EdRKLIfqBmidwBNK9KF7m84Pg2SrmLjUHpfeFIlBRhPwahYAaQTkMiXxK 6ulJQFddxM9EBzvaRkJ1nMTuNvQFMb6alHVoWv8VFexNT6ImZ1aENZaTfRww/wwgy5fL rzh1hkPT0bUX8kQaMgeqWvqZ4NNMCOMi26clyExkyTLIYzUoNVmNhXxBXQYU8TsYcgYM 1bWITn7mqPIVLGt1Sximi3ieHbwJ7w5C60HhOLNAO4dqY4kZXDHOyKwumlJfBdtGojzQ /ghKzkzUZf6hiYkrzFf3hiog/+knD8a5mq9z43PZaaBCffDQAx9DDN46Efvn1mWIjFSL NOeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="I9whyM/H"; spf=pass (google.com: domain of linux-kernel+bounces-11532-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11532-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gh29-20020a1709073c1d00b00a26dc87b7f2si2761458ejc.820.2023.12.26.05.53.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 05:53:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11532-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="I9whyM/H"; spf=pass (google.com: domain of linux-kernel+bounces-11532-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11532-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2E9511F22931 for ; Tue, 26 Dec 2023 13:53:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80C6D4F891; Tue, 26 Dec 2023 13:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I9whyM/H" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E21984F216; Tue, 26 Dec 2023 13:53:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 356D2C43391; Tue, 26 Dec 2023 13:52:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703598780; bh=GHEJTufmGu+U5ws6uli9pWrljzPPuOpjnKKiIXQ9OP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I9whyM/HAPsMMSg1XN9ZxtCtIVJSCpjEhZks2t2pdHelgP0JVYZL44424b/PqLRlk 1mj56KFfHC5zKF6uCqgl5oG8JFqieAfs7TxhMVTsNgsfL8IdJ1TmpYHHTX7l0ljywv eT70jgQ6XmRk1MXCYd8YsfAKa/acYi9t3NHmY6AMsaenIEfUKrq0E6R70FO7TJIEk1 yR5Mkd3EDLZMot6wH3HRIRQMrAK8yAXTY+mOc+qm7AFEcQDLUQ+D3m/hiwa0fjooZE cjRcNfOtbpZkeX6UDNWUvrEfZmTqIg184pv/S1MV9u5sDx0DLvbSQMjtpeNbq8nKGf aWzljeUwtPAFQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Ben Hutchings , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kernel@vger.kernel.org Subject: [PATCH 3/6] kbuild: deb-pkg: set DEB_* variables if debian/rules is directly executed Date: Tue, 26 Dec 2023 22:52:40 +0900 Message-Id: <20231226135243.1393780-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231226135243.1393780-1-masahiroy@kernel.org> References: <20231226135243.1393780-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786352844633735726 X-GMAIL-MSGID: 1786352844633735726 Since commit 491b146d4c13 ("kbuild: builddeb: Eliminate debian/arch use"), direct execution of debian/rules results in the following error: dpkg-architecture: error: unknown option 'DEB_HOST_MULTIARCH' The current code: dpkg-architecture -a$DEB_HOST_ARCH -qDEB_HOST_MULTIARCH ... does not look sensible because: - For this code to work correctly, DEB_HOST_ARCH must be pre-defined, which is true when the packages are built via dpkg-buildpackage. In this case, DEB_HOST_MULTIARCH is also likely defined, hence there is no need to query DEB_HOST_MULTIARCH in the first place. - If DEB_HOST_MULTIARCH is undefined, DEB_HOST_ARCH is likely undefined too. So, you cannot query DEB_HOST_MULTIARCH in this way. This is mostly the case where debian/rules is directly executed. When debian/rules is directly executed, querying DEB_HOST_MUCHARCH is not enough because we need to know DEB_{BUILD,HOST}_GNU_TYPE as well. All DEB_* variables are defined when the package build is initiated by dpkg-buildpackage, but otherwise, let's call dpkg-architecture to set all DEB_* environment variables. This implementation relies on dpkg commit 7c54fa2b232e ("dpkg-architecture: Add a --print-format option"). Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- scripts/package/builddeb | 5 ++--- scripts/package/debian/rules | 12 +++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 2fe51e6919da..2eb4910f0ef3 100755 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb @@ -171,9 +171,8 @@ install_libc_headers () { # move asm headers to /usr/include//asm to match the structure # used by Debian-based distros (to support multi-arch) - host_arch=$(dpkg-architecture -a$DEB_HOST_ARCH -qDEB_HOST_MULTIARCH) - mkdir $pdir/usr/include/$host_arch - mv $pdir/usr/include/asm $pdir/usr/include/$host_arch/ + mkdir "$pdir/usr/include/${DEB_HOST_MULTIARCH}" + mv "$pdir/usr/include/asm" "$pdir/usr/include/${DEB_HOST_MULTIARCH}" } rm -f debian/files diff --git a/scripts/package/debian/rules b/scripts/package/debian/rules index 529b71b55efa..8f24a8e84bf2 100755 --- a/scripts/package/debian/rules +++ b/scripts/package/debian/rules @@ -30,5 +30,15 @@ build-arch: .PHONY: clean clean: - rm -rf debian/files debian/linux-* + rm -rf debian/files debian/linux-* debian/deb-env.vars $(MAKE) -f $(srctree)/Makefile ARCH=$(ARCH) clean + +# If DEB_HOST_ARCH is empty, it is likely that debian/rules was executed +# directly. Run 'dpkg-architecture --print-set --print-format=make' to +# generate a makefile construct that exports all DEB_* variables. +ifndef DEB_HOST_ARCH +-include debian/deb-env.vars + +debian/deb-env.vars: + dpkg-architecture -a$$(cat debian/arch) --print-set --print-format=make > $@ +endif