5 our @EXPORT = qw(%package %srcpackage %category %subdir %preconfig %features %overrides clear_packages parse_package_metadata parse_target_metadata get_multiline @ignore);
22 $str .= (($_ and $prefix) ? $prefix . $_ : $_);
25 return $str ? $str : "";
30 $conf =~ tr#/\.\-/#___#;
34 sub parse_target_metadata($) {
36 my ($target, @target, $profile);
40 open FILE, "<$file" or do {
41 warn "Can't open file '$file': $!\n";
46 /^Source-Makefile: \s*((.+\/)([^\/]+)\/Makefile)\s*$/ and $makefile = $1;
47 /^Target:\s*(.+)\s*$/ and do {
52 makefile => $makefile,
53 boardconf => confstr($name),
54 conf => confstr($name),
60 push @target, $target;
61 $target{$name} = $target;
62 if ($name =~ /([^\/]+)\/([^\/]+)/) {
63 push @{$target{$1}->{subtargets}}, $2;
64 $target->{board} = $1;
65 $target->{boardconf} = confstr($1);
66 $target->{subtarget} = 1;
67 $target->{parent} = $target{$1};
70 /^Target-Name:\s*(.+)\s*$/ and $target->{name} = $1;
71 /^Target-Arch:\s*(.+)\s*$/ and $target->{arch} = $1;
72 /^Target-Arch-Packages:\s*(.+)\s*$/ and $target->{arch_packages} = $1;
73 /^Target-Features:\s*(.+)\s*$/ and $target->{features} = [ split(/\s+/, $1) ];
74 /^Target-Depends:\s*(.+)\s*$/ and $target->{depends} = [ split(/\s+/, $1) ];
75 /^Target-Description:/ and $target->{desc} = get_multiline(*FILE);
76 /^Target-Optimization:\s*(.+)\s*$/ and $target->{cflags} = $1;
77 /^CPU-Type:\s*(.+)\s*$/ and $target->{cputype} = $1;
78 /^Linux-Version:\s*(.+)\s*$/ and $target->{version} = $1;
79 /^Linux-Release:\s*(.+)\s*$/ and $target->{release} = $1;
80 /^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target->{karch} = $1;
81 /^Default-Subtarget:\s*(.+)\s*$/ and $target->{def_subtarget} = $1;
82 /^Default-Packages:\s*(.+)\s*$/ and $target->{packages} = [ split(/\s+/, $1) ];
83 /^Target-Profile:\s*(.+)\s*$/ and do {
90 push @{$target->{profiles}}, $profile;
92 /^Target-Profile-Name:\s*(.+)\s*$/ and do {
94 $profile->{name} = $1;
96 /^Target-Profile-Priority:\s*(\d+)\s*$/ and $profile->{priority} = $1;
97 /^Target-Profile-Packages:\s*(.*)\s*$/ and $profile->{packages} = [ split(/\s+/, $1) ];
98 /^Target-Profile-Description:\s*(.*)\s*/ and $profile->{desc} = get_multiline(*FILE);
99 /^Target-Profile-Config:/ and $profile->{config} = get_multiline(*FILE, "\t");
100 /^Target-Profile-Kconfig:/ and $profile->{kconfig} = 1;
103 foreach my $target (@target) {
104 if (@{$target->{subtargets}} > 0) {
105 $target->{profiles} = [];
108 @{$target->{profiles}} > 0 or $target->{profiles} = [
119 sub clear_packages() {
129 sub parse_package_metadata($) {
138 my %ignore = map { $_ => 1 } @ignore;
140 open FILE, "<$file" or do {
141 warn "Cannot open '$file': $!\n";
146 /^Source-Makefile: \s*((.+\/)([^\/]+)\/Makefile)\s*$/ and do {
150 $subdir =~ s/^package\///;
151 $subdir{$src} = $subdir;
152 $srcpackage{$src} = [];
156 /^Override: \s*(.+?)\s*$/ and do {
158 $overrides{$src} = 1;
161 next if $ignore{$src};
162 /^Package:\s*(.+?)\s*$/ and do {
166 $pkg->{makefile} = $makefile;
169 $pkg->{depends} = [];
170 $pkg->{mdepends} = [];
171 $pkg->{builddepends} = [];
172 $pkg->{buildtypes} = [];
173 $pkg->{subdir} = $subdir;
174 $pkg->{tristate} = 1;
175 $pkg->{override} = $override;
177 push @{$srcpackage{$src}}, $pkg;
179 /^Feature:\s*(.+?)\s*$/ and do {
182 $feature->{name} = $1;
183 $feature->{priority} = 0;
186 /^Target-Name:\s*(.+?)\s*$/ and do {
187 $features{$1} or $features{$1} = [];
188 push @{$features{$1}}, $feature;
190 /^Target-Title:\s*(.+?)\s*$/ and $feature->{target_title} = $1;
191 /^Feature-Priority:\s*(\d+)\s*$/ and $feature->{priority} = $1;
192 /^Feature-Name:\s*(.+?)\s*$/ and $feature->{title} = $1;
193 /^Feature-Description:/ and $feature->{description} = get_multiline(\*FILE, "\t\t\t");
197 /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1;
198 /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1;
199 /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1;
200 /^Submenu: \s*(.+)\s*$/ and $pkg->{submenu} = $1;
201 /^Submenu-Depends: \s*(.+)\s*$/ and $pkg->{submenudep} = $1;
202 /^Source: \s*(.+)\s*$/ and $pkg->{source} = $1;
203 /^License: \s*(.+)\s*$/ and $pkg->{license} = $1;
204 /^LicenseFiles: \s*(.+)\s*$/ and $pkg->{licensefiles} = $1;
205 /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
206 /^Provides: \s*(.+)\s*$/ and do {
207 my @vpkg = split /\s+/, $1;
208 foreach my $vpkg (@vpkg) {
209 $package{$vpkg} or $package{$vpkg} = {
214 makefile => $makefile
216 push @{$package{$vpkg}->{vdepends}}, $pkg->{name};
219 /^Menu-Depends: \s*(.+)\s*$/ and $pkg->{mdepends} = [ split /\s+/, $1 ];
220 /^Depends: \s*(.+)\s*$/ and $pkg->{depends} = [ split /\s+/, $1 ];
221 /^Conflicts: \s*(.+)\s*$/ and $pkg->{conflicts} = [ split /\s+/, $1 ];
222 /^Hidden: \s*(.+)\s*$/ and $pkg->{hidden} = 1;
223 /^Build-Variant: \s*([\w\-]+)\s*/ and $pkg->{variant} = $1;
224 /^Default-Variant: .*/ and $pkg->{variant_default} = 1;
225 /^Build-Only: \s*(.+)\s*$/ and $pkg->{buildonly} = 1;
226 /^Build-Depends: \s*(.+)\s*$/ and $pkg->{builddepends} = [ split /\s+/, $1 ];
227 /^Build-Depends\/(\w+): \s*(.+)\s*$/ and $pkg->{"builddepends/$1"} = [ split /\s+/, $2 ];
228 /^Build-Types:\s*(.+)\s*$/ and $pkg->{buildtypes} = [ split /\s+/, $1 ];
229 /^Repository:\s*(.+?)\s*$/ and $pkg->{repository} = $1;
230 /^Category: \s*(.+)\s*$/ and do {
231 $pkg->{category} = $1;
232 defined $category{$1} or $category{$1} = {};
233 defined $category{$1}->{$src} or $category{$1}->{$src} = [];
234 push @{$category{$1}->{$src}}, $pkg;
236 /^Description: \s*(.*)\s*$/ and $pkg->{description} = "\t\t $1\n". get_multiline(*FILE, "\t\t ");
237 /^Type: \s*(.+)\s*$/ and do {
238 $pkg->{type} = [ split /\s+/, $1 ];
239 undef $pkg->{tristate};
240 foreach my $type (@{$pkg->{type}}) {
241 $type =~ /ipkg/ and $pkg->{tristate} = 1;
244 /^Config:\s*(.*)\s*$/ and $pkg->{config} = "$1\n".get_multiline(*FILE, "\t");
245 /^Prereq-Check:/ and $pkg->{prereq} = 1;
246 /^Preconfig:\s*(.+)\s*$/ and do {
247 my $pkgname = $pkg->{name};
248 $preconfig{$pkgname} or $preconfig{$pkgname} = {};
249 if (exists $preconfig{$pkgname}->{$1}) {
250 $preconfig = $preconfig{$pkgname}->{$1};
255 $preconfig{$pkgname}->{$1} = $preconfig;
258 /^Preconfig-Type:\s*(.*?)\s*$/ and $preconfig->{type} = $1;
259 /^Preconfig-Label:\s*(.*?)\s*$/ and $preconfig->{label} = $1;
260 /^Preconfig-Default:\s*(.*?)\s*$/ and $preconfig->{default} = $1;