Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17103925ybl; Wed, 1 Jan 2020 22:05:10 -0800 (PST) X-Google-Smtp-Source: APXvYqxy7/fnbO3wvvFdP1N55Ot/v6rBMy8gLUDL4UOROboqcOs/eNnb8JYfFFZlRgdnul1sMOMi X-Received: by 2002:a9d:367:: with SMTP id 94mr85423646otv.329.1577945110750; Wed, 01 Jan 2020 22:05:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577945110; cv=none; d=google.com; s=arc-20160816; b=uxRa46XKJtulz426+6/X7ftwbezBG1eJtdmL4iTOPkngJanmsbvoRDpPiFWstTuIQR 3ctMTO9DS++DBCFAfYm6aPwc7hhkuUU4l8Y7MowG9jPshzZ6XfLSfFQFNgedjo96m3RH GxyTjzDrQA9wxmrgbXDGTggiogSXbxfTpc5FxAfYXXTLv+SDm8z/vb+hAd7anqpwNXuq FlTnSP9oPHX1u/Yj7X9ek0IuAdtVqFbbc29HwrPmcVUfy7rORvEIzwXHAczntWSGwaAV QRYEuJVy3Is0V5IS0fXD2GJPne/0F7WQGbDe1zoEsM36xJYdpn/7UJ+HF6NQFW0xSdtG C9zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PkkzfRfLclc3mdFH+VRL0+gF0bnoP7beI/xdBP95oXE=; b=JVVb4egc/y/nA512fJqiKYBk8XePNWrjWtadlEJ9xkuqtY1omNMlIZ02z2xLDxFcvL TMPo9LclePSsyhSKk4xCWadVuD/l0fdU2ZJkiCL0fN6Zii0vArPDOFIHTVqAUloPE3iP f8GjXaIrNzeQ0sf/Okkv7Pp66UHF392WTEWCdxeEck752JI7LS2qd579mnsvUV+9wjEE t4e44P9oLt/65hjh/Xk/qdSKnmqiJu8kUANwJfPSH8VXc9wlKbaOgL0naODvSByNI55Z D52ekkk4RdZPRKotM31gr/nIQY+VB1V1UBKpV3c4z4gy2sz0gSU3qrON455cX2gHTYeG FtWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f43dtVLE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3si26416309oig.25.2020.01.01.22.04.58; Wed, 01 Jan 2020 22:05:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f43dtVLE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726204AbgABGED (ORCPT + 99 others); Thu, 2 Jan 2020 01:04:03 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:36101 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725788AbgABGEC (ORCPT ); Thu, 2 Jan 2020 01:04:02 -0500 Received: by mail-ot1-f65.google.com with SMTP id 19so43171918otz.3; Wed, 01 Jan 2020 22:04:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PkkzfRfLclc3mdFH+VRL0+gF0bnoP7beI/xdBP95oXE=; b=f43dtVLEFGJ/myRkbv51HVHgqyy7kbhiZEQ+1edeQZRRgX6I1JP896HJWFhM5U9bZD ObAfqehcQt+q5J/IMOMP5mKQGprjldV/H7DGcyg/cLbB3hlU2yBvVCJyiUfeGji0vxLr JsEYfOwFh3YLAI3BQYNmuxmzpHWBQKWdKYGtvUqc7aoxLSgCahP1XUq0oY4lHXRnHOE7 sikBKsd0NDKuOyhBGkObbdyypp3Qg4BNnayYyiovPjoSk622ytArAY9LhWCDDoot2TA0 5qusI+Se3WH2JX+J1Dj961Dzr0kYkKMLu6jTT0lCKd3flsAkvs44qktibVhtQM4jmrlq yS7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PkkzfRfLclc3mdFH+VRL0+gF0bnoP7beI/xdBP95oXE=; b=aNB+YiX2JLZvZEbU5QCMrwuiMxbKEHN/mcUxURg5UU4ifI4kNQO8Po2SW7ldenaIq7 mJrHKKzmbdajhnwE3zR86FbGJDDhG/6ytOwEJL9pWvQ3v2+YRSeq3dDV8dKIt5gArRGe ZVTlGr5+fE2foWrCOaMu0ITtqkR1NLE65qBcw5xHKeHiZKo7gXE650QsSof3TSZncGy6 nnd8dxc7dFaBwB/eQvz/mB3jq2L7Gg1KzjmiwqRckcNmu9t0JNEYxPzlrIcHL0hhW1br 6hR4EYBBPQksSluTF7eBJeYXGMB35ScvKyF/ErOxkwSM+YhiM4czlGMz+Z0afyX2yjjJ 13qg== X-Gm-Message-State: APjAAAW/H2T0O0Gfb37GR9iT1+8ZLASzsuaMf4Z0V0UiU1SbEKH7vz1b udl2yHqE9JlmhgVCXnd3V4jygOPk9A7aQ5TH0BY= X-Received: by 2002:a9d:6c92:: with SMTP id c18mr75128173otr.157.1577945041391; Wed, 01 Jan 2020 22:04:01 -0800 (PST) MIME-Version: 1.0 References: <20191230132006.7401-1-masahiroy@kernel.org> In-Reply-To: From: Justin Capella Date: Wed, 1 Jan 2020 22:03:49 -0800 Message-ID: Subject: Re: [PATCH] initramfs: fix 'bad variable name' error in gen_initramfs_list.sh To: Masahiro Yamada Cc: Linux Kbuild mailing list , "Jory A . Pratt" , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ah, I was wondering where the magic cmd_ prefix was coming from. But I still think that there is an issue there-- initfs vs initRAMfs On Tue, Dec 31, 2019 at 2:28 AM Masahiro Yamada wrote: > > On Tue, Dec 31, 2019 at 12:13 AM Justin Capella wrote: > > > > I was looking at this, and in theory there are other problems that > > could arise from non-escaped characters, or things with leading > > hyphens... In general it isn't great to assume ls output will play > > nicely with the internal field separator / IFS. I think a better > > solution would be to use something like ${foo@Q} and instead of trying > > to scrape ls -l, maybe using stat, since it can be asked to print out > > the device number. > > I am not sure if 'stat' is necessarily preferred over 'ls -l'. > > Commit a670b0b4aed129dc11b465c1c330bfe9202023e5 > says 'stat' is not standardized. > > There is some room for argument > how far we should care about the portability, though. > > > > > > But I don't think this patch fixes the problem mentioned at all-- I > > think the problem is initfs is not a variable name on line 61: > > cmd_initramfs is defined at line 46. > > Look into scripts/Kbuild.include > if you want to know how if_changed works. > > > > $(call if_changed,initfs) > > > > https://github.com/torvalds/linux/blob/351c8a09b00b5c51c8f58b016fffe51f87e2d820/usr/Makefile#L61 > > > > The Makefile and script look like more patches would be needed to fix > > mentioned issue, and I'm kind of wondering what the intent behind > > lines 31-32 is... > > > > ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \ > > $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d) > > > > why filter nothing, why shell echo? > > It does filter "", which is different from nothing. > > You need to notice GNU Make handles double-quote (") > as a normal character. > There is no special meaning as it has in shell. > > 'echo' is used just for ripping off the double-quotes. > > > > > > Quoting and/or proper escaping would be needed in many other places, > > and I suspect cpio input is always regenerated... > > I do not think so. > > If the cpio input is regenerated, > the following log is shown. > > GEN usr/initramfs_data.cpio > > > I do not see it every time. > > > > The use of sed to > > manually escape things and suggesting using \ instead of using the > > argument terminator "--"... If weird paths with spaces and stuff are a > > requirement for the script needs some overhauling > > If you find a problem in particular, a patch is welcome. > > But, what you stated above comes from your misunderstanding. > > > > > > On Mon, Dec 30, 2019 at 5:21 AM Masahiro Yamada wrote: > > > > > > Prior to commit 858805b336be ("kbuild: add $(BASH) to run scripts with > > > bash-extension"), this shell script was almost always run by bash since > > > bash is usually installed on the system by default. > > > > > > Now, this script is run by sh, which might be a symlink to dash. On such > > > distros, the following code emits an error: > > > > > > local dev=`LC_ALL=C ls -l "${location}"` > > > > > > You can reproduce the build error, for example by setting > > > CONFIG_INITRAMFS_SOURCE="/dev". > > > > > > GEN usr/initramfs_data.cpio.gz > > > ./usr/gen_initramfs_list.sh: 131: local: 1: bad variable name > > > make[1]: *** [usr/Makefile:61: usr/initramfs_data.cpio.gz] Error 2 > > > > > > This is because `LC_ALL=C ls -l "${location}"` contains spaces. > > > Surrounding it with double-quotes fixes the error. > > > > > > Fixes: 858805b336be ("kbuild: add $(BASH) to run scripts with bash-extension") > > > Reported-by: Jory A. Pratt > > > Signed-off-by: Masahiro Yamada > > > --- > > > > > > usr/gen_initramfs_list.sh | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/usr/gen_initramfs_list.sh b/usr/gen_initramfs_list.sh > > > index 0aad760fcd8c..2bbac73e6477 100755 > > > --- a/usr/gen_initramfs_list.sh > > > +++ b/usr/gen_initramfs_list.sh > > > @@ -128,7 +128,7 @@ parse() { > > > str="${ftype} ${name} ${location} ${str}" > > > ;; > > > "nod") > > > - local dev=`LC_ALL=C ls -l "${location}"` > > > + local dev="`LC_ALL=C ls -l "${location}"`" > > > local maj=`field 5 ${dev}` > > > local min=`field 6 ${dev}` > > > maj=${maj%,} > > > -- > > > 2.17.1 > > > > > > > -- > Best Regards > Masahiro Yamada