From patchwork Thu Feb 29 10:19:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Dymacz X-Patchwork-Id: 1906249 X-Patchwork-Delegate: pepe2k@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=WZhGFEGi; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=keP8iGXI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TlnMn4n7sz20Qg for ; Thu, 29 Feb 2024 21:22:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=3xrH3fxEoy1kqXsfZaHaNuRvDTYyfvSenrY9h3ZPLME=; b=WZhGFEGin06byc N87dhcSC77qgthWEBB++3gDO4NL99t0pMOK2cNDx7Y1jOJDS6CVf0Ee3JCbrS/u//uv5p2PpaglFr Viu6t2nlns2nf/qhlpJco+25layuWPtK0bBEtqQEAk/e3E9qj/attoOqQY9C6ZBkPBNRMukApK7jU upummurvpbURxunN0pV7+9OsRbMsGL2K/EMY+not8KFs9pFW6hS9wjT5VyBvqJck59feIcSNPqdlH tJWrDTC7bftygznetJmDUC1LDwKnyNZCOIszxBoJgf3xXYprBJdnx8Xm5tjpuRCN7h32AIfQhEdrx BMhFUWNWX4x6tUvJb+IQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfdWZ-0000000D7Tj-1O0e; Thu, 29 Feb 2024 10:20:23 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfdWV-0000000D7T8-3rIS for openwrt-devel@lists.openwrt.org; Thu, 29 Feb 2024 10:20:21 +0000 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-56647babfe6so1118306a12.3 for ; Thu, 29 Feb 2024 02:20:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709202018; x=1709806818; darn=lists.openwrt.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=lkMm0rAoI/nZ6QmI6J3L5DGWs+oBZ7IrVimnZ4CDdzw=; b=keP8iGXIk/IDn/+wDIH6/j1e54EnwaRPQyigfMsyBThKEkh9B8ZUzUs8uEWiveFvNI Nhs4VZjSJel5tpz1ITv+aze8hjLUBfC7cBf11wosDexfSfqH8AY2Q0m7hYBAz1ntXaz/ IeljgfO3cc6ZPwdXwv1I4v85uaKfw1/tkeTy+fkGX5M/p0KY1esw6wodJ/hkpyN4P8Q7 uZeHRybWabdq1xk+X++JmMGgeC9pQbMBRwVgd+ZdR82lPQ7M0g6rXquZQbsYhOQqlkyl +xmgGfcnNaBcU3bo9ApDDah+3xEUEMrvJxlLSD/aUP4zzJ7KSu2bw0WzSKgQVRUJLx+L wpyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709202018; x=1709806818; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lkMm0rAoI/nZ6QmI6J3L5DGWs+oBZ7IrVimnZ4CDdzw=; b=LK5MZ1YZ+o5/qCoFZYViSf5HbIp1XIZNqFsGz6QfEgj+zrS2BBux3fon/xLsrNAejD jCdgT5bvgnbXlalQLoOsqmZLcBglMwjheOr78jAQVrdhMlKyJYtb9P8wZ0cGa9Ufv17y VlYia3bnBGm3gKM2F4ZTaH7WQSaFMDdzKayUbCri/Z8LWKzgRtxCxBBVX9Q1jBHa6JYe zJagDsWN3xSn+PqwjwhwI9XNyzMIGq7j3DmvKI8DtFNgD2hYjAGMCpqezyu/jjzL/5AB /UGBa1LkUxmiSq2nzzeHEO1vGVdOBHx0jRnNw4LrZ7/RcMlnfi/AZZEB9QQluORDcfF7 Fy0g== X-Gm-Message-State: AOJu0YxSoXnAkLP8d4Sj9pvbCY7R5h9zzFw2kv0ILDk5vgytvweYRxaB 3Jmp2lXFT0tDwH7ggSvZzsnlcaSOJmH9KIiVIxcuOw8i5Jdp7AmI9Q78B8sL X-Google-Smtp-Source: AGHT+IFvV9ExTNc+FppS47c+u//7v9Gy+CQdMJynQR5qw6+c6XIDiYrXbOlugO3UhQJSHtYx/IJqxA== X-Received: by 2002:a17:906:1349:b0:a44:4c9e:8809 with SMTP id x9-20020a170906134900b00a444c9e8809mr642581ejb.32.1709202017708; Thu, 29 Feb 2024 02:20:17 -0800 (PST) Received: from localhost.localdomain ([45.142.162.8]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm531699ejc.65.2024.02.29.02.20.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 02:20:17 -0800 (PST) From: Piotr Dymacz To: openwrt-devel@lists.openwrt.org Subject: [PATCH RFC/PoC] scripts: {package-}metadata: use 'SUBMENU' as subcategory path Date: Thu, 29 Feb 2024 11:19:58 +0100 Message-ID: <20240229101958.76011-1-pepe2k@gmail.com> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240229_022019_984948_89151DA5 X-CRM114-Status: GOOD ( 13.10 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Motivation for this change is to allow for a more nested menu structure when manually configuring build system with 'make {menu,n,x}config'. The current solution provides only 2 levels of nesting (without using external/custom config/Config.in): - top level menu/category (Makefile variable 'CATEGORY') - 2nd level sub menu/category (Makefil [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [pepe2k(at)gmail.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:535 listed in] [list.dnswl.org] X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Motivation for this change is to allow for a more nested menu structure when manually configuring build system with 'make {menu,n,x}config'. The current solution provides only 2 levels of nesting (without using external/custom config/Config.in): - top level menu/category (Makefile variable 'CATEGORY') - 2nd level sub menu/category (Makefile variable 'SUBMENU') To allow placing packages in a more nested menu structure, the 'SUBMENU' variable is treated as a menu path with '\' character as separator*. Defining 'SUBMENU' as 'Foo\Bar\Qux' for package 'Bob' and 'Foo\Bar' for package 'Ben' with this change would create menu structure as follows: top level menu 'CATEGORY' ---> ..menu 'Foo' ---> ....menu 'Bar' ---> ......menu 'Qux' ---> ........[] package 'Bob' ......[] package 'Ben' Currently existing menus and packages sorting methods were preserved (menu first, packages below, alphabetical order) and the only difference applies to the usage of 'SUBMENUDEP' Makefile variable which will affect only last path element (the one package is placed under). * The backslash instead of a more natural slash '/' was selected due to the fact that some of already existing core and community packages use slash in 'SUBMENU' variables. As this is more a RFC/PoC, final change might use different character or approach for defining menu path. Signed-off-by: Piotr Dymacz --- scripts/metadata.pm | 6 ++- scripts/package-metadata.pl | 96 ++++++++++++++++++++++++------------- 2 files changed, 68 insertions(+), 34 deletions(-) diff --git a/scripts/metadata.pm b/scripts/metadata.pm index ecfe42c0bc..21e1a4b250 100644 --- a/scripts/metadata.pm +++ b/scripts/metadata.pm @@ -283,7 +283,11 @@ sub parse_package_metadata($) { defined $category{$1}{$src->{name}} or $category{$1}{$src->{name}} = []; push @{$category{$1}{$src->{name}}}, $pkg; }; - /^Description: \s*(.*)\s*$/ and $pkg->{description} = "\t\t $1\n". get_multiline(*FILE, "\t\t "); + /^Description: \s*(.*)\s*$/ and do { + my $tabs = 2; + $pkg->{submenu} and $tabs += scalar(split(/\\/, $pkg->{submenu})); + $pkg->{description} = ("\t" x $tabs)." $1\n".get_multiline(*FILE, ("\t" x $tabs)." "); + }; /^Type: \s*(.+)\s*$/ and do { $pkg->{type} = [ split /\s+/, $1 ]; undef $pkg->{tristate}; diff --git a/scripts/package-metadata.pl b/scripts/package-metadata.pl index 9e0e6dd9e5..fa6b007f38 100755 --- a/scripts/package-metadata.pl +++ b/scripts/package-metadata.pl @@ -143,6 +143,7 @@ sub package_depends($$) { } sub mconf_depends { + my $tabs = shift; my $pkgname = shift; my $depends = shift; my $only_dep = shift; @@ -233,24 +234,25 @@ sub mconf_depends { } foreach my $tdep (@t_depends) { - mconf_depends($pkgname, $tdep->[0], 1, $dep, $seen, $tdep->[1]); + mconf_depends($tabs, $pkgname, $tdep->[0], 1, $dep, $seen, $tdep->[1]); } foreach my $depend (sort keys %$dep) { my $m = $dep->{$depend}; - $res .= "\t\t$m $depend\n"; + $res .= ("\t" x $tabs)."$m $depend\n"; } return $res; } sub mconf_conflicts { + my $tabs = shift; my $pkgname = shift; my $depends = shift; my $res = ""; foreach my $depend (@$depends) { next unless $package{$depend}; - $res .= "\t\tdepends on m || (PACKAGE_$depend != y)\n"; + $res .= ("\t" x $tabs)."depends on m || (PACKAGE_$depend != y)\n"; } return $res; } @@ -265,34 +267,69 @@ sub print_package_config_category($) { print "menu \"$cat\"\n\n"; my %spkg = %{$category{$cat}}; + $menus{$cat} = {}; + foreach my $spkg (sort {uc($a) cmp uc($b)} keys %spkg) { foreach my $pkg (@{$spkg{$spkg}}) { next if $pkg->{buildonly}; - my $menu = $pkg->{submenu}; - if ($menu) { - $menu_dep{$menu} or $menu_dep{$menu} = $pkg->{submenudep}; + my $menu = $menus{$cat}; + if ($pkg->{submenu}) { + my @submenus = split(/\\/, $pkg->{submenu}); + foreach (@submenus) { + next unless length($_); + if (!$menu->{$_}) { + $menu->{$_} = {}; + } + + $menu = $menu->{$_}; + + if ($_ eq $submenus[-1]) { + $pkg->{submenudep} and $menu->{'_deps'} = $pkg->{submenudep}; + push(@{$menu->{'_pkgs'}}, $pkg); + } + } } else { - $menu = 'undef'; + push(@{$menu->{'_pkgs'}}, $pkg); } - $menus{$menu} or $menus{$menu} = []; - push @{$menus{$menu}}, $pkg; } } + + print_package_config_subcategory($menus{$cat}, 0); + print "endmenu\n\n"; + + undef $category{$cat}; +} + +sub print_package_config_subcategory($$) { + my $subcategory = shift; + my $tabs = shift; + my @menus = sort { - ($a eq 'undef' ? 1 : 0) or - ($b eq 'undef' ? -1 : 0) or + ($a eq '_pkgs' ? 1 : 0) or + ($b eq '_pkgs' ? -1 : 0) or ($a cmp $b) - } keys %menus; + } keys %{$subcategory}; + + $tabs++; + foreach (@menus) { + next if $_ eq '_deps'; + + if ($_ ne '_pkgs') { + $subcategory->{$_}->{'_deps'} and print "\t" x $tabs, "if $subcategory->{$_}->{'_deps'}\n"; + print "\t" x $tabs, "menu \"$_\"\n\n"; + print_package_config_subcategory($subcategory->{$_}, $tabs); + print "\t" x $tabs, "endmenu\n"; + $subcategory->{$_}->{'_deps'} and print "\t" x $tabs, "endif\n"; + print "\n"; + + next; + } - foreach my $menu (@menus) { my @pkgs = sort { package_depends($a, $b) or ($a->{name} cmp $b->{name}) - } @{$menus{$menu}}; - if ($menu ne 'undef') { - $menu_dep{$menu} and print "if $menu_dep{$menu}\n"; - print "menu \"$menu\"\n"; - } + } @{$subcategory->{$_}}; + foreach my $pkg (@pkgs) { next if $pkg->{src}{ignore}; my $title = $pkg->{name}; @@ -301,12 +338,12 @@ sub print_package_config_category($) { $title .= ("." x $c). " ". $pkg->{title}; } $title = "\"$title\""; - print "\t"; + print "\t" x $tabs; $pkg->{menu} and print "menu"; print "config PACKAGE_".$pkg->{name}."\n"; $pkg->{hidden} and $title = ""; - print "\t\t".($pkg->{tristate} ? 'tristate' : 'bool')." $title\n"; - print "\t\tdefault y if DEFAULT_".$pkg->{name}."\n"; + print "\t" x ($tabs + 1), ($pkg->{tristate} ? 'tristate' : 'bool')." $title\n"; + print "\t" x ($tabs + 1), "default y if DEFAULT_".$pkg->{name}."\n"; unless ($pkg->{hidden}) { my @def = ("ALL"); if (!exists($pkg->{repository})) { @@ -319,26 +356,19 @@ sub print_package_config_category($) { } if ($pkg->{default}) { foreach my $default (split /\s*,\s*/, $pkg->{default}) { - print "\t\tdefault $default\n"; + print "\t" x ($tabs + 1), "default $default\n"; } } - print mconf_depends($pkg->{name}, $pkg->{depends}, 0); - print mconf_depends($pkg->{name}, $pkg->{mdepends}, 0); - print mconf_conflicts($pkg->{name}, $pkg->{conflicts}); - print "\t\thelp\n"; + print mconf_depends($tabs + 1, $pkg->{name}, $pkg->{depends}, 0); + print mconf_depends($tabs + 1, $pkg->{name}, $pkg->{mdepends}, 0); + print mconf_conflicts($tabs + 1, $pkg->{name}, $pkg->{conflicts}); + print "\t" x ($tabs + 1), "help\n"; print $pkg->{description}; print "\n"; $pkg->{config} and print $pkg->{config}."\n"; } - if ($menu ne 'undef') { - print "endmenu\n"; - $menu_dep{$menu} and print "endif\n"; - } } - print "endmenu\n\n"; - - undef $category{$cat}; } sub print_package_overrides() {