3 # Copyright (C) 2006 OpenWrt.org
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
17 sub print_category($) {
20 return unless $category{$cat};
22 print "menu \"$cat\"\n\n";
23 my %spkg = %{$category{$cat}};
24 foreach my $spkg (sort {uc($a) cmp uc($b)} keys %spkg) {
25 foreach my $pkg (@{$spkg{$spkg}}) {
26 if ($cur_menu ne $pkg->{submenu}) {
31 if ($pkg->{submenu}) {
32 $cur_menu = $pkg->{submenu};
33 print "menu \"$cur_menu\"\n";
36 my $title = $pkg->{name};
37 my $c = (72 - length($pkg->{name}) - length($pkg->{title}));
39 $title .= ("." x $c). " ". $pkg->{title};
42 $pkg->{menu} and print "menu";
43 print "config PACKAGE_".$pkg->{name}."\n";
44 print "\t\ttristate \"$title\"\n";
45 foreach my $default (split /\s*,\s*/, $pkg->{default}) {
46 print "\t\tdefault $default\n";
48 foreach my $depend (@{$pkg->{depends}}) {
50 $depend =~ s/^([@\+]+)//;
52 $flags =~ /@/ or $depend = "PACKAGE_$depend";
53 $flags =~ /\+/ and $m = "select";
54 print "\t\t$m $depend\n";
57 print $pkg->{description};
60 $pkg->{config} and print $pkg->{config}."\n";
65 undef $category{$cat};
71 $line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
76 $line =~ /^Package: \s*(.+)\s*$/ and do {
79 $pkg->{makefile} = $makefile;
81 $pkg->{default} = "m if ALL";
83 $line =~ /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1;
84 $line =~ /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1;
85 $line =~ /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1;
86 $line =~ /^Submenu: \s*(.+)\s*$/ and $pkg->{submenu} = $1;
87 $line =~ /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
88 $line =~ /^Depends: \s*(.+)\s*$/ and do {
89 my @dep = split /\s+/, $1;
90 $pkg->{depends} = \@dep;
92 $line =~ /^Category: \s*(.+)\s*$/ and do {
93 $pkg->{category} = $1;
94 defined $category{$1} or $category{$1} = {};
95 defined $category{$1}->{$src} or $category{$1}->{$src} = [];
96 push @{$category{$1}->{$src}}, $pkg;
98 $line =~ /^Description: \s*(.*)\s*$/ and do {
99 my $desc = "\t\t$1\n\n";
102 last if $line =~ /^@@/;
103 $desc .= "\t\t$line";
105 $pkg->{description} = $desc;
107 $line =~ /^Config: \s*(.*)\s*$/ and do {
111 last if $line =~ /^@@/;
114 $pkg->{config} = $conf;
118 print_category 'Base system';
119 foreach my $cat (keys %category) {