From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Weber Date: Thu, 7 Jan 2021 15:27:35 -0600 Subject: [Buildroot] [PATCH] support/scripts/pkg-stats: properly handle host packages with -c option In-Reply-To: <20210107211336.3030397-2-thomas.petazzoni@bootlin.com> References: <20210107211336.3030397-1-thomas.petazzoni@bootlin.com> <20210107211336.3030397-2-thomas.petazzoni@bootlin.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: buildroot@busybox.net Thomas, On Thu, Jan 7, 2021 at 3:14 PM Thomas Petazzoni wrote: > > In commit 7a607dab336e7f78ab069cff1b503d0688950583 > ("support/scripts/pkg-stats: support generating stats based on > configured packages"), we added a -c option to pkg-stats to generate a > report based on the list of packages enabled in the configuration, > rather than for all packages. > > This is done based on the list of packages returned in JSON format by > "make show-info". However, this JSON output contains really the actual > name of packages, including their host- prefix for host packages. Due > to this, none of the host packages were matching and therefore > reported in the pkg-stats -c output. > > This commit fixes that by stripping the host- prefix for host > packages. > > Reported-by: Matt Weber > Cc: Matt Weber > Signed-off-by: Thomas Petazzoni > --- > support/scripts/pkg-stats | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats > index 4a9ff1ffa0..eabbcc72b6 100755 > --- a/support/scripts/pkg-stats > +++ b/support/scripts/pkg-stats > @@ -353,7 +353,13 @@ def get_pkglist(npackages, package_list): > def get_config_packages(): > cmd = ["make", "--no-print-directory", "show-info"] > js = json.loads(subprocess.check_output(cmd)) > - return js.keys() > + pkgs = list() > + for k, v in js.items(): > + if v["type"] == "host": > + pkgs.append(k[5:]) > + else: > + pkgs.append(k) > + return pkgs > Tested-by: Matt Weber