5 our @EXPORT = qw(%package %srcpackage %category %subdir %preconfig %features %overrides clear_packages parse_package_metadata parse_target_metadata get_multiline);
21 $str .= (($_ and $prefix) ? $prefix . $_ : $_);
24 return $str ? $str : "";
29 $conf =~ tr#/\.\-/#___#;
33 sub parse_target_metadata($) {
35 my ($target, @target, $profile);
38 open FILE, "<$file" or do {
39 warn "Can't open file '$file': $!\n";
44 /^Target:\s*(.+)\s*$/ and do {
49 boardconf => confstr($name),
50 conf => confstr($name),
56 push @target, $target;
57 $target{$name} = $target;
58 if ($name =~ /([^\/]+)\/([^\/]+)/) {
59 push @{$target{$1}->{subtargets}}, $2;
60 $target->{board} = $1;
61 $target->{boardconf} = confstr($1);
62 $target->{subtarget} = 1;
63 $target->{parent} = $target{$1};
66 /^Target-Name:\s*(.+)\s*$/ and $target->{name} = $1;
67 /^Target-Path:\s*(.+)\s*$/ and $target->{path} = $1;
68 /^Target-Arch:\s*(.+)\s*$/ and $target->{arch} = $1;
69 /^Target-Arch-Packages:\s*(.+)\s*$/ and $target->{arch_packages} = $1;
70 /^Target-Features:\s*(.+)\s*$/ and $target->{features} = [ split(/\s+/, $1) ];
71 /^Target-Depends:\s*(.+)\s*$/ and $target->{depends} = [ split(/\s+/, $1) ];
72 /^Target-Description:/ and $target->{desc} = get_multiline(*FILE);
73 /^Target-Optimization:\s*(.+)\s*$/ and $target->{cflags} = $1;
74 /^CPU-Type:\s*(.+)\s*$/ and $target->{cputype} = $1;
75 /^Linux-Version:\s*(.+)\s*$/ and $target->{version} = $1;
76 /^Linux-Release:\s*(.+)\s*$/ and $target->{release} = $1;
77 /^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target->{karch} = $1;
78 /^Default-Subtarget:\s*(.+)\s*$/ and $target->{def_subtarget} = $1;
79 /^Default-Packages:\s*(.+)\s*$/ and $target->{packages} = [ split(/\s+/, $1) ];
80 /^Target-Profile:\s*(.+)\s*$/ and do {
86 push @{$target->{profiles}}, $profile;
88 /^Target-Profile-Name:\s*(.+)\s*$/ and $profile->{name} = $1;
89 /^Target-Profile-Packages:\s*(.*)\s*$/ and $profile->{packages} = [ split(/\s+/, $1) ];
90 /^Target-Profile-Description:\s*(.*)\s*/ and $profile->{desc} = get_multiline(*FILE);
91 /^Target-Profile-Config:/ and $profile->{config} = get_multiline(*FILE, "\t");
92 /^Target-Profile-Kconfig:/ and $profile->{kconfig} = 1;
95 foreach my $target (@target) {
96 if (@{$target->{subtargets}} > 0) {
97 $target->{profiles} = [];
100 @{$target->{profiles}} > 0 or $target->{profiles} = [
111 sub clear_packages() {
121 sub parse_package_metadata($) {
131 open FILE, "<$file" or do {
132 warn "Cannot open '$file': $!\n";
137 /^Source-Makefile: \s*((.+\/)([^\/]+)\/Makefile)\s*$/ and do {
141 $subdir =~ s/^package\///;
142 $subdir{$src} = $subdir;
143 $srcpackage{$src} = [];
147 /^Override: \s*(.+?)\s*$/ and do {
149 $overrides{$src} = 1;
152 /^Package:\s*(.+?)\s*$/ and do {
156 $pkg->{makefile} = $makefile;
159 $pkg->{depends} = [];
160 $pkg->{mdepends} = [];
161 $pkg->{builddepends} = [];
162 $pkg->{buildtypes} = [];
163 $pkg->{subdir} = $subdir;
164 $pkg->{tristate} = 1;
165 $pkg->{override} = $override;
167 push @{$srcpackage{$src}}, $pkg;
169 /^Feature:\s*(.+?)\s*$/ and do {
172 $feature->{name} = $1;
173 $feature->{priority} = 0;
176 /^Target-Name:\s*(.+?)\s*$/ and do {
177 $features{$1} or $features{$1} = [];
178 push @{$features{$1}}, $feature;
180 /^Target-Title:\s*(.+?)\s*$/ and $feature->{target_title} = $1;
181 /^Feature-Priority:\s*(\d+)\s*$/ and $feature->{priority} = $1;
182 /^Feature-Name:\s*(.+?)\s*$/ and $feature->{title} = $1;
183 /^Feature-Description:/ and $feature->{description} = get_multiline(\*FILE, "\t\t\t");
187 /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1;
188 /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1;
189 /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1;
190 /^Submenu: \s*(.+)\s*$/ and $pkg->{submenu} = $1;
191 /^Submenu-Depends: \s*(.+)\s*$/ and $pkg->{submenudep} = $1;
192 /^Source: \s*(.+)\s*$/ and $pkg->{source} = $1;
193 /^License: \s*(.+)\s*$/ and $pkg->{license} = $1;
194 /^LicenseFiles: \s*(.+)\s*$/ and $pkg->{licensefiles} = $1;
195 /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
196 /^Provides: \s*(.+)\s*$/ and do {
197 my @vpkg = split /\s+/, $1;
198 foreach my $vpkg (@vpkg) {
199 $package{$vpkg} or $package{$vpkg} = {
204 makefile => $makefile
206 push @{$package{$vpkg}->{vdepends}}, $pkg->{name};
209 /^Menu-Depends: \s*(.+)\s*$/ and $pkg->{mdepends} = [ split /\s+/, $1 ];
210 /^Depends: \s*(.+)\s*$/ and $pkg->{depends} = [ split /\s+/, $1 ];
211 /^Conflicts: \s*(.+)\s*$/ and $pkg->{conflicts} = [ split /\s+/, $1 ];
212 /^Hidden: \s*(.+)\s*$/ and $pkg->{hidden} = 1;
213 /^Build-Variant: \s*([\w\-]+)\s*/ and $pkg->{variant} = $1;
214 /^Default-Variant: .*/ and $pkg->{variant_default} = 1;
215 /^Build-Only: \s*(.+)\s*$/ and $pkg->{buildonly} = 1;
216 /^Build-Depends: \s*(.+)\s*$/ and $pkg->{builddepends} = [ split /\s+/, $1 ];
217 /^Build-Depends\/(\w+): \s*(.+)\s*$/ and $pkg->{"builddepends/$1"} = [ split /\s+/, $2 ];
218 /^Build-Types:\s*(.+)\s*$/ and $pkg->{buildtypes} = [ split /\s+/, $1 ];
219 /^Feed:\s*(.+?)\s*$/ and $pkg->{feed} = $1;
220 /^Category: \s*(.+)\s*$/ and do {
221 $pkg->{category} = $1;
222 defined $category{$1} or $category{$1} = {};
223 defined $category{$1}->{$src} or $category{$1}->{$src} = [];
224 push @{$category{$1}->{$src}}, $pkg;
226 /^Description: \s*(.*)\s*$/ and $pkg->{description} = "\t\t $1\n". get_multiline(*FILE, "\t\t ");
227 /^Type: \s*(.+)\s*$/ and do {
228 $pkg->{type} = [ split /\s+/, $1 ];
229 undef $pkg->{tristate};
230 foreach my $type (@{$pkg->{type}}) {
231 $type =~ /ipkg/ and $pkg->{tristate} = 1;
234 /^Config:\s*(.*)\s*$/ and $pkg->{config} = "$1\n".get_multiline(*FILE, "\t");
235 /^Prereq-Check:/ and $pkg->{prereq} = 1;
236 /^Preconfig:\s*(.+)\s*$/ and do {
237 my $pkgname = $pkg->{name};
238 $preconfig{$pkgname} or $preconfig{$pkgname} = {};
239 if (exists $preconfig{$pkgname}->{$1}) {
240 $preconfig = $preconfig{$pkgname}->{$1};
245 $preconfig{$pkgname}->{$1} = $preconfig;
248 /^Preconfig-Type:\s*(.*?)\s*$/ and $preconfig->{type} = $1;
249 /^Preconfig-Label:\s*(.*?)\s*$/ and $preconfig->{label} = $1;
250 /^Preconfig-Default:\s*(.*?)\s*$/ and $preconfig->{default} = $1;