5 our @EXPORT = qw(%package %srcpackage %category %subdir %preconfig clear_packages parse_package_metadata get_multiline);
20 $str .= (($_ and $prefix) ? $prefix . $_ : $_);
23 return $str ? $str : "";
26 sub clear_packages() {
34 sub parse_package_metadata($) {
42 open FILE, "<$file" or do {
43 warn "Cannot open '$file': $!\n";
48 /^Source-Makefile: \s*((.+\/)([^\/]+)\/Makefile)\s*$/ and do {
52 $subdir =~ s/^package\///;
53 $subdir{$src} = $subdir;
54 $srcpackage{$src} = [];
58 /^Package:\s*(.+?)\s*$/ and do {
61 $pkg->{makefile} = $makefile;
63 $pkg->{default} = "m if ALL";
65 $pkg->{builddepends} = [];
66 $pkg->{subdir} = $subdir;
69 push @{$srcpackage{$src}}, $pkg;
71 /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1;
72 /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1;
73 /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1;
74 /^Submenu: \s*(.+)\s*$/ and $pkg->{submenu} = $1;
75 /^Submenu-Depends: \s*(.+)\s*$/ and $pkg->{submenudep} = $1;
76 /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
77 /^Provides: \s*(.+)\s*$/ and do {
78 my @vpkg = split /\s+/, $1;
79 foreach my $vpkg (@vpkg) {
80 $package{$vpkg} or $package{$vpkg} = {
87 push @{$package{$vpkg}->{vdepends}}, $pkg->{name};
90 /^Depends: \s*(.+)\s*$/ and $pkg->{depends} = [ split /\s+/, $1 ];
91 /^Build-Depends: \s*(.+)\s*$/ and $pkg->{builddepends} = [ split /\s+/, $1 ];
92 /^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 /^Description: \s*(.*)\s*$/ and $pkg->{description} = "\t\t $1\n". get_multiline(*FILE, "\t\t ");
99 /^Type: \s*(.+)\s*$/ and do {
100 $pkg->{type} = [ split /\s+/, $1 ];
101 undef $pkg->{tristate};
102 foreach my $type (@{$pkg->{type}}) {
103 $type =~ /ipkg/ and $pkg->{tristate} = 1;
106 /^Config: \s*(.*)\s*$/ and $pkg->{config} = "$1\n".get_multiline(*FILE, "\t");
107 /^Prereq-Check:/ and $pkg->{prereq} = 1;
108 /^Preconfig:\s*(.+)\s*$/ and do {
109 my $pkgname = $pkg->{name};
110 $preconfig{$pkgname} or $preconfig{$pkgname} = {};
111 if (exists $preconfig{$pkgname}->{$1}) {
112 $preconfig = $preconfig{$pkgname}->{$1};
117 $preconfig{$pkgname}->{$1} = $preconfig;
120 /^Preconfig-Type:\s*(.*?)\s*$/ and $preconfig->{type} = $1;
121 /^Preconfig-Label:\s*(.*?)\s*$/ and $preconfig->{label} = $1;
122 /^Preconfig-Default:\s*(.*?)\s*$/ and $preconfig->{default} = $1;