Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp264114rwd; Tue, 6 Jun 2023 22:49:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7BCu8dKsSIDkzQBwNdqeO0NWkTxqfQJT8I2/jTU5T7+QPfIQRI7mYukrChelyuzCdtLvMw X-Received: by 2002:a25:7a86:0:b0:bb1:650c:8c04 with SMTP id v128-20020a257a86000000b00bb1650c8c04mr4851743ybc.56.1686116983009; Tue, 06 Jun 2023 22:49:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686116982; cv=none; d=google.com; s=arc-20160816; b=naOUwL7QqlRzperrS5aYw86R5cYVPukHMWKYa1N45Z2J8etCN8RuvQwUzHeAExvbBA qhEsAL6m3P6jvwlPjeynBOpzJ7C2CaxQcHeHE3UywcphvmR6rkn5y3oEofKigA+4sGdq 8/J5SuEz/RrGS7jGRyZ2K0jhssFsiIzWH61k6RpTy9QxbA9yFbXfMr0GZIZ9yvt89/q0 eno3o2ic3KoCAb3HmervXkzgueohsIc7g1Wx3L00QbtpUp9JnSKb24qRoh5iY7H5I91e ZYtIwgC9WXukkSyxGqkbaHx+4pmId+c2RSv+U3zveMyaM1wdsejCzAEtb7+Lk20o4Z+y ssyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=wEMtDIQJX21Zvw5PhONl46ownyRfojrayaFOVV0BR3M=; b=vbtnR8QJxhntcpD3XwjfB49ss8UBQCd7NDIJ17OQ38WPjBxqLs9+JE3444RzintFnY kUTac16z84iHP5e1qzPRBAQb5ca5Jv+8fwZqXxuNtzhP9BuUVPg2JUGmi3zqwJTPPAFw FsGtzEjhzEbSuQF6kY3gAOpGDurLox0c+iZh02PprOhU0r0x/f34JX2jjbD3LQ11U9il 1du7HnFPGb7rmCIEDBP/SCJqTdKeP6s6BSZfYHqMRLuKE6iziiqXE8yCU2OGlrXCNia8 750V1lrstxRxlBLpaIgOZDg8mOtwNucci22JDSxBdTpD6kvLe+d4C20ho1qCOrx0fWSx dp/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iffVS97y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc8-20020a170902930800b001b049396679si8205208plb.556.2023.06.06.22.49.28; Tue, 06 Jun 2023 22:49:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iffVS97y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229503AbjFGFfe (ORCPT + 99 others); Wed, 7 Jun 2023 01:35:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232123AbjFGFfb (ORCPT ); Wed, 7 Jun 2023 01:35:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFEE419AA; Tue, 6 Jun 2023 22:35:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 587E263A7E; Wed, 7 Jun 2023 05:35:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE690C4339B; Wed, 7 Jun 2023 05:35:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686116129; bh=Cz6SN9RqMOYGdXRwEOaCy8og6z2MAlsLW1X6BHhj7Po=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=iffVS97yvnPbpmyAy2RM3CWZxmNLo5G5w7pGFJoMEIPUZ4w1sDhoRUWWm5HsJXkle zGKMDj6pIxJfjTEcrMWpxDAPv5EJhI4ORo3ExYPEWrTDRmSRZIgazHvYbGPcncOsO1 PcFFovHEi0Enmp939K2vAM6FiIMq5RkeWTX0IeUClxCGpLi9PEs6SZpi0vQktcLD/T UejWv9HwtAAup/9nv2w7Ce5eNovL3RvmYiyn5qI6qcvccObKsy5whOlE0PBKy1X6j5 1F10RgviaA2FkHYyVSyV6EE/+yfW5/oybYuyVLLLaHqTcbc03pAKSQ2t2neTcCI0q6 0+IsyN7K0EyFA== Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-3f6b2f1a04bso76112911cf.3; Tue, 06 Jun 2023 22:35:29 -0700 (PDT) X-Gm-Message-State: AC+VfDxYIGtwEEeIxfIEOpBtT67vFANZ/hZNuuu7rCWUaZeEnPiEYYGP LLJZZArHKSt04QYaVJc4TFqSbtsuYyHQ7C6WDTs= X-Received: by 2002:a05:622a:1355:b0:3f5:c9f:1b27 with SMTP id w21-20020a05622a135500b003f50c9f1b27mr2533009qtk.1.1686116128847; Tue, 06 Jun 2023 22:35:28 -0700 (PDT) MIME-Version: 1.0 References: <20230606061741.69755-1-bgray@linux.ibm.com> In-Reply-To: <20230606061741.69755-1-bgray@linux.ibm.com> From: Masahiro Yamada Date: Wed, 7 Jun 2023 14:34:52 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] initramfs: Encode dependency on KBUILD_BUILD_TIMESTAMP To: Benjamin Gray Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Andrew Donnellan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 6, 2023 at 3:18=E2=80=AFPM Benjamin Gray = wrote: > > gen_initramfs.sh has an internal dependency on KBUILD_BUILD_TIMESTAMP > for generating file mtimes that is not exposed to make, so changing > KBUILD_BUILD_TIMESTAMP will not trigger a rebuild of the archive. > > Declare the mtime date as a new parameter to gen_initramfs.sh to encode > KBUILD_BUILD_TIMESTAMP in the shell command, thereby making make aware > of the dependency. > > It will rebuild if KBUILD_BUILD_TIMESTAMP changes or is newly set/unset. > It will _not_ rebuild if KBUILD_BUILD_TIMESTAMP is unset before and > after. This should be fine for anyone who doesn't care about setting > specific build times in the first place. > > Reviewed-by: Andrew Donnellan > Tested-by: Andrew Donnellan > Signed-off-by: Benjamin Gray > > --- Applied to linux-kbuild. Thanks. > v2: Remove redundant comment, quote argument to shell script > --- > usr/Makefile | 1 + > usr/gen_initramfs.sh | 16 +++++++++------- > 2 files changed, 10 insertions(+), 7 deletions(-) > > diff --git a/usr/Makefile b/usr/Makefile > index 59d9e8b07a01..f8e1ad19e05c 100644 > --- a/usr/Makefile > +++ b/usr/Makefile > @@ -64,6 +64,7 @@ quiet_cmd_initfs =3D GEN $@ > $(CONFIG_SHELL) $< -o $@ -l $(obj)/.initramfs_data.cpio.d \ > $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID= )) \ > $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID= )) \ > + $(if $(KBUILD_BUILD_TIMESTAMP), -d "$(KBUILD_BUILD_TIMESTAMP)") \ > $(ramfs-input) > > # We rebuild initramfs_data.cpio if: > diff --git a/usr/gen_initramfs.sh b/usr/gen_initramfs.sh > index 63476bb70b41..14b5782f961a 100755 > --- a/usr/gen_initramfs.sh > +++ b/usr/gen_initramfs.sh > @@ -23,6 +23,7 @@ $0 [-o ] [-l ] [-u ] [-g ] {-= d | } ... > -g Group ID to map to group ID 0 (root). > is only meaningful if is a > directory. "squash" forces all files to gid 0. > + -d Use date for all file mtime values > File list or directory for cpio archive. > If is a .cpio file it will be used > as direct input to initramfs. > @@ -190,6 +191,7 @@ prog=3D$0 > root_uid=3D0 > root_gid=3D0 > dep_list=3D > +timestamp=3D > cpio_list=3D$(mktemp ${TMPDIR:-/tmp}/cpiolist.XXXXXX) > output=3D"/dev/stdout" > > @@ -218,6 +220,13 @@ while [ $# -gt 0 ]; do > [ "$root_gid" =3D "-1" ] && root_gid=3D$(id -g ||= echo 0) > shift > ;; > + "-d") # date for file mtimes > + timestamp=3D"$(date -d"$1" +%s || :)" > + if test -n "$timestamp"; then > + timestamp=3D"-t $timestamp" > + fi > + shift > + ;; > "-h") > usage > exit 0 > @@ -237,11 +246,4 @@ done > > # If output_file is set we will generate cpio archive > # we are careful to delete tmp files > -timestamp=3D > -if test -n "$KBUILD_BUILD_TIMESTAMP"; then > - timestamp=3D"$(date -d"$KBUILD_BUILD_TIMESTAMP" +%s || :)" > - if test -n "$timestamp"; then > - timestamp=3D"-t $timestamp" > - fi > -fi > usr/gen_init_cpio $timestamp $cpio_list > $output > -- > 2.40.1 > --=20 Best Regards Masahiro Yamada