2006-04-21 03:12:18 +03:00
|
|
|
#!/usr/bin/perl
|
2006-06-27 03:35:46 +03:00
|
|
|
#
|
|
|
|
# Copyright (C) 2006 OpenWrt.org
|
|
|
|
#
|
|
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
|
|
# See /LICENSE for more information.
|
|
|
|
#
|
|
|
|
|
2006-04-21 03:12:18 +03:00
|
|
|
use strict;
|
|
|
|
|
|
|
|
my $src;
|
|
|
|
my $makefile;
|
|
|
|
my $pkg;
|
2006-10-17 20:45:14 +03:00
|
|
|
my %package;
|
2006-04-21 03:12:18 +03:00
|
|
|
my %category;
|
|
|
|
|
2006-07-22 01:48:58 +03:00
|
|
|
|
2006-10-17 20:45:14 +03:00
|
|
|
sub find_dep($$) {
|
|
|
|
my $pkg = shift;
|
|
|
|
my $name = shift;
|
2006-10-17 22:01:08 +03:00
|
|
|
my $deps = ($pkg->{vdepends} or $pkg->{depends});
|
|
|
|
|
|
|
|
return 0 unless defined $deps;
|
|
|
|
foreach my $dep (@{$deps}) {
|
2006-10-17 20:45:14 +03:00
|
|
|
return 1 if $dep eq $name;
|
|
|
|
return 1 if ($package{$dep} and (find_dep($package{$dep},$name) == 1));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub depends($$) {
|
|
|
|
my $a = shift;
|
|
|
|
my $b = shift;
|
|
|
|
my $ret;
|
2006-10-17 22:01:08 +03:00
|
|
|
|
2006-10-17 23:51:25 +03:00
|
|
|
return 0 if ($a->{submenu} ne $b->{submenu});
|
2006-10-17 20:45:14 +03:00
|
|
|
if (find_dep($a, $b->{name}) == 1) {
|
|
|
|
$ret = 1;
|
|
|
|
} elsif (find_dep($b, $a->{name}) == 1) {
|
|
|
|
$ret = -1;
|
|
|
|
} else {
|
2006-10-17 22:01:08 +03:00
|
|
|
return 0;
|
2006-10-17 20:45:14 +03:00
|
|
|
}
|
|
|
|
# print STDERR "depends($a->{name}, $b->{name}) == $ret\n";
|
|
|
|
return $ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-21 03:12:18 +03:00
|
|
|
sub print_category($) {
|
|
|
|
my $cat = shift;
|
2006-10-17 23:51:25 +03:00
|
|
|
my %menus;
|
|
|
|
my %menu_dep;
|
2006-04-21 03:12:18 +03:00
|
|
|
|
|
|
|
return unless $category{$cat};
|
|
|
|
|
|
|
|
print "menu \"$cat\"\n\n";
|
|
|
|
my %spkg = %{$category{$cat}};
|
2006-10-17 23:51:25 +03:00
|
|
|
|
2006-04-21 03:12:18 +03:00
|
|
|
foreach my $spkg (sort {uc($a) cmp uc($b)} keys %spkg) {
|
2006-10-17 23:51:25 +03:00
|
|
|
foreach my $pkg (@{$spkg{$spkg}}) {
|
|
|
|
my $menu = $pkg->{submenu};
|
|
|
|
if ($menu) {
|
|
|
|
$menu_dep{$menu} or $menu_dep{$menu} = $pkg->{submenudep};
|
|
|
|
} else {
|
|
|
|
$menu = 'undef';
|
|
|
|
}
|
|
|
|
$menus{$menu} or $menus{$menu} = [];
|
|
|
|
push @{$menus{$menu}}, $pkg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
my @menus = sort {
|
|
|
|
($a eq 'undef' ? 1 : 0) or
|
|
|
|
($b eq 'undef' ? -1 : 0) or
|
|
|
|
($a cmp $b)
|
|
|
|
} keys %menus;
|
|
|
|
|
|
|
|
foreach my $menu (@menus) {
|
2006-10-17 16:08:57 +03:00
|
|
|
my @pkgs = sort {
|
2006-10-17 20:45:14 +03:00
|
|
|
depends($a, $b) or
|
2006-10-17 23:51:25 +03:00
|
|
|
($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";
|
|
|
|
}
|
2006-10-17 16:08:57 +03:00
|
|
|
foreach my $pkg (@pkgs) {
|
2006-04-21 03:12:18 +03:00
|
|
|
my $title = $pkg->{name};
|
|
|
|
my $c = (72 - length($pkg->{name}) - length($pkg->{title}));
|
|
|
|
if ($c > 0) {
|
|
|
|
$title .= ("." x $c). " ". $pkg->{title};
|
|
|
|
}
|
2006-11-12 07:06:56 +02:00
|
|
|
print "\tconfig DEFAULT_".$pkg->{name}."\n";
|
|
|
|
print "\t\tbool\n\n";
|
2006-04-21 03:12:18 +03:00
|
|
|
print "\t";
|
|
|
|
$pkg->{menu} and print "menu";
|
|
|
|
print "config PACKAGE_".$pkg->{name}."\n";
|
|
|
|
print "\t\ttristate \"$title\"\n";
|
2006-11-12 07:06:56 +02:00
|
|
|
print "\t\tdefault y if DEFAULT_".$pkg->{name}."\n";
|
2006-05-30 23:22:43 +03:00
|
|
|
foreach my $default (split /\s*,\s*/, $pkg->{default}) {
|
|
|
|
print "\t\tdefault $default\n";
|
|
|
|
}
|
2006-04-21 03:12:18 +03:00
|
|
|
foreach my $depend (@{$pkg->{depends}}) {
|
2006-05-30 21:55:52 +03:00
|
|
|
my $m = "depends";
|
2006-06-20 20:50:49 +03:00
|
|
|
$depend =~ s/^([@\+]+)//;
|
2006-05-30 21:55:52 +03:00
|
|
|
my $flags = $1;
|
2006-10-17 22:01:08 +03:00
|
|
|
my $vdep;
|
|
|
|
|
|
|
|
if ($vdep = $package{$depend}->{vdepends}) {
|
|
|
|
$depend = join("||", map { "PACKAGE_".$_ } @$vdep);
|
|
|
|
} else {
|
|
|
|
$flags =~ /@/ or $depend = "PACKAGE_$depend";
|
|
|
|
$flags =~ /\+/ and $m = "select";
|
|
|
|
}
|
2006-05-30 21:55:52 +03:00
|
|
|
print "\t\t$m $depend\n";
|
2006-04-21 03:12:18 +03:00
|
|
|
}
|
2006-04-21 03:50:48 +03:00
|
|
|
print "\t\thelp\n";
|
|
|
|
print $pkg->{description};
|
2006-05-20 01:46:24 +03:00
|
|
|
print "\n";
|
|
|
|
|
|
|
|
$pkg->{config} and print $pkg->{config}."\n";
|
2006-04-21 03:12:18 +03:00
|
|
|
}
|
2006-10-17 23:51:25 +03:00
|
|
|
if ($menu ne 'undef') {
|
|
|
|
print "endmenu\n";
|
|
|
|
$menu_dep{$menu} and print "endif\n";
|
|
|
|
}
|
2006-04-21 03:12:18 +03:00
|
|
|
}
|
|
|
|
print "endmenu\n\n";
|
|
|
|
|
|
|
|
undef $category{$cat};
|
|
|
|
}
|
|
|
|
|
|
|
|
my $line;
|
|
|
|
while ($line = <>) {
|
|
|
|
chomp $line;
|
|
|
|
$line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
|
|
|
|
$makefile = $1;
|
|
|
|
$src = $2;
|
|
|
|
undef $pkg;
|
|
|
|
};
|
|
|
|
$line =~ /^Package: \s*(.+)\s*$/ and do {
|
|
|
|
$pkg = {};
|
|
|
|
$pkg->{src} = $src;
|
|
|
|
$pkg->{makefile} = $makefile;
|
|
|
|
$pkg->{name} = $1;
|
|
|
|
$pkg->{default} = "m if ALL";
|
2006-10-17 20:45:14 +03:00
|
|
|
$package{$1} = $pkg;
|
2006-04-21 03:12:18 +03:00
|
|
|
};
|
|
|
|
$line =~ /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1;
|
|
|
|
$line =~ /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1;
|
|
|
|
$line =~ /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1;
|
2006-06-25 19:05:43 +03:00
|
|
|
$line =~ /^Submenu: \s*(.+)\s*$/ and $pkg->{submenu} = $1;
|
2006-07-21 17:27:45 +03:00
|
|
|
$line =~ /^Submenu-Depends: \s*(.+)\s*$/ and $pkg->{submenudep} = $1;
|
2006-04-21 03:12:18 +03:00
|
|
|
$line =~ /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
|
2006-10-17 22:01:08 +03:00
|
|
|
$line =~ /^Provides: \s*(.+)\s*$/ and do {
|
|
|
|
my @vpkg = split /\s+/, $1;
|
|
|
|
foreach my $vpkg (@vpkg) {
|
|
|
|
$package{$vpkg} or $package{$vpkg} = { vdepends => [] };
|
|
|
|
push @{$package{$vpkg}->{vdepends}}, $pkg->{name};
|
|
|
|
}
|
|
|
|
};
|
2006-04-21 03:12:18 +03:00
|
|
|
$line =~ /^Depends: \s*(.+)\s*$/ and do {
|
2006-05-30 21:55:52 +03:00
|
|
|
my @dep = split /\s+/, $1;
|
2006-04-21 03:12:18 +03:00
|
|
|
$pkg->{depends} = \@dep;
|
|
|
|
};
|
|
|
|
$line =~ /^Category: \s*(.+)\s*$/ and do {
|
|
|
|
$pkg->{category} = $1;
|
|
|
|
defined $category{$1} or $category{$1} = {};
|
|
|
|
defined $category{$1}->{$src} or $category{$1}->{$src} = [];
|
|
|
|
push @{$category{$1}->{$src}}, $pkg;
|
|
|
|
};
|
|
|
|
$line =~ /^Description: \s*(.*)\s*$/ and do {
|
2006-04-21 03:50:48 +03:00
|
|
|
my $desc = "\t\t$1\n\n";
|
2006-04-21 03:12:18 +03:00
|
|
|
my $line;
|
2006-04-21 03:50:48 +03:00
|
|
|
while ($line = <>) {
|
|
|
|
last if $line =~ /^@@/;
|
|
|
|
$desc .= "\t\t$line";
|
2006-04-21 03:12:18 +03:00
|
|
|
}
|
|
|
|
$pkg->{description} = $desc;
|
2006-05-20 01:46:24 +03:00
|
|
|
};
|
|
|
|
$line =~ /^Config: \s*(.*)\s*$/ and do {
|
|
|
|
my $conf = "$1\n";
|
|
|
|
my $line;
|
|
|
|
while ($line = <>) {
|
|
|
|
last if $line =~ /^@@/;
|
|
|
|
$conf .= "$line";
|
|
|
|
}
|
|
|
|
$pkg->{config} = $conf;
|
2006-04-21 03:12:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print_category 'Base system';
|
|
|
|
foreach my $cat (keys %category) {
|
|
|
|
print_category $cat;
|
|
|
|
}
|