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.
22 $cur_menu_dep and do {
24 $cur_menu_dep = undef;
34 return 0 unless defined $pkg->{depends};
35 foreach my $dep (@{$pkg->{depends}}) {
36 return 1 if $dep eq $name;
37 return 1 if ($package{$dep} and (find_dep($package{$dep},$name) == 1));
47 if (find_dep($a, $b->{name}) == 1) {
49 } elsif (find_dep($b, $a->{name}) == 1) {
54 # print STDERR "depends($a->{name}, $b->{name}) == $ret\n";
59 sub print_category($) {
62 return unless $category{$cat};
64 print "menu \"$cat\"\n\n";
65 my %spkg = %{$category{$cat}};
66 foreach my $spkg (sort {uc($a) cmp uc($b)} keys %spkg) {
69 $a->{submenu}."->".$a->{name} cmp $b->{submenu}."->".$b->{name}
71 foreach my $pkg (@pkgs) {
72 if ($cur_menu ne $pkg->{submenu}) {
74 if ($pkg->{submenu}) {
75 $cur_menu = $pkg->{submenu};
76 $cur_menu_dep = $pkg->{submenudep} and print "if $cur_menu_dep\n";
77 print "menu \"$cur_menu\"\n";
80 my $title = $pkg->{name};
81 my $c = (72 - length($pkg->{name}) - length($pkg->{title}));
83 $title .= ("." x $c). " ". $pkg->{title};
86 $pkg->{menu} and print "menu";
87 print "config PACKAGE_".$pkg->{name}."\n";
88 print "\t\ttristate \"$title\"\n";
89 foreach my $default (split /\s*,\s*/, $pkg->{default}) {
90 print "\t\tdefault $default\n";
92 foreach my $depend (@{$pkg->{depends}}) {
94 $depend =~ s/^([@\+]+)//;
96 $flags =~ /@/ or $depend = "PACKAGE_$depend";
97 $flags =~ /\+/ and $m = "select";
98 print "\t\t$m $depend\n";
101 print $pkg->{description};
104 $pkg->{config} and print $pkg->{config}."\n";
110 undef $category{$cat};
116 $line =~ /^Source-Makefile: \s*(.+\/([^\/]+)\/Makefile)\s*$/ and do {
121 $line =~ /^Package: \s*(.+)\s*$/ and do {
124 $pkg->{makefile} = $makefile;
126 $pkg->{default} = "m if ALL";
129 $line =~ /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1;
130 $line =~ /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1;
131 $line =~ /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1;
132 $line =~ /^Submenu: \s*(.+)\s*$/ and $pkg->{submenu} = $1;
133 $line =~ /^Submenu-Depends: \s*(.+)\s*$/ and $pkg->{submenudep} = $1;
134 $line =~ /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
135 $line =~ /^Depends: \s*(.+)\s*$/ and do {
136 my @dep = split /\s+/, $1;
137 $pkg->{depends} = \@dep;
139 $line =~ /^Category: \s*(.+)\s*$/ and do {
140 $pkg->{category} = $1;
141 defined $category{$1} or $category{$1} = {};
142 defined $category{$1}->{$src} or $category{$1}->{$src} = [];
143 push @{$category{$1}->{$src}}, $pkg;
145 $line =~ /^Description: \s*(.*)\s*$/ and do {
146 my $desc = "\t\t$1\n\n";
149 last if $line =~ /^@@/;
150 $desc .= "\t\t$line";
152 $pkg->{description} = $desc;
154 $line =~ /^Config: \s*(.*)\s*$/ and do {
158 last if $line =~ /^@@/;
161 $pkg->{config} = $conf;
165 print_category 'Base system';
166 foreach my $cat (keys %category) {