5 our @EXPORT = qw(%package %srcpackage %category %subdir %preconfig %features clear_packages parse_package_metadata get_multiline);
20 $str .= (($_ and $prefix) ? $prefix . $_ : $_);
23 return $str ? $str : "";
26 sub clear_packages() {
35 sub parse_package_metadata($) {
44 open FILE, "<$file" or do {
45 warn "Cannot open '$file': $!\n";
50 /^Source-Makefile: \s*((.+\/)([^\/]+)\/Makefile)\s*$/ and do {
54 $subdir =~ s/^package\///;
55 $subdir{$src} = $subdir;
56 $srcpackage{$src} = [];
60 /^Package:\s*(.+?)\s*$/ and do {
64 $pkg->{makefile} = $makefile;
68 $pkg->{mdepends} = [];
69 $pkg->{builddepends} = [];
70 $pkg->{buildtypes} = [];
71 $pkg->{subdir} = $subdir;
74 push @{$srcpackage{$src}}, $pkg;
76 /^Feature:\s*(.+?)\s*$/ and do {
79 $feature->{name} = $1;
80 $feature->{priority} = 0;
83 /^Target-Name:\s*(.+?)\s*$/ and do {
84 $features{$1} or $features{$1} = [];
85 push @{$features{$1}}, $feature;
87 /^Target-Title:\s*(.+?)\s*$/ and $feature->{target_title} = $1;
88 /^Feature-Priority:\s*(\d+)\s*$/ and $feature->{priority} = $1;
89 /^Feature-Name:\s*(.+?)\s*$/ and $feature->{title} = $1;
90 /^Feature-Description:/ and $feature->{description} = get_multiline(\*FILE, "\t\t\t");
94 /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1;
95 /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1;
96 /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1;
97 /^Submenu: \s*(.+)\s*$/ and $pkg->{submenu} = $1;
98 /^Submenu-Depends: \s*(.+)\s*$/ and $pkg->{submenudep} = $1;
99 /^Source: \s*(.+)\s*$/ and $pkg->{source} = $1;
100 /^License: \s*(.+)\s*$/ and $pkg->{license} = $1;
101 /^LicenseFiles: \s*(.+)\s*$/ and $pkg->{licensefiles} = $1;
102 /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
103 /^Provides: \s*(.+)\s*$/ and do {
104 my @vpkg = split /\s+/, $1;
105 foreach my $vpkg (@vpkg) {
106 $package{$vpkg} or $package{$vpkg} = {
111 makefile => $makefile
113 push @{$package{$vpkg}->{vdepends}}, $pkg->{name};
116 /^Menu-Depends: \s*(.+)\s*$/ and $pkg->{mdepends} = [ split /\s+/, $1 ];
117 /^Depends: \s*(.+)\s*$/ and $pkg->{depends} = [ split /\s+/, $1 ];
118 /^Conflicts: \s*(.+)\s*$/ and $pkg->{conflicts} = [ split /\s+/, $1 ];
119 /^Hidden: \s*(.+)\s*$/ and $pkg->{hidden} = 1;
120 /^Build-Variant: \s*([\w\-]+)\s*/ and $pkg->{variant} = $1;
121 /^Default-Variant: .*/ and $pkg->{variant_default} = 1;
122 /^Build-Only: \s*(.+)\s*$/ and $pkg->{buildonly} = 1;
123 /^Build-Depends: \s*(.+)\s*$/ and $pkg->{builddepends} = [ split /\s+/, $1 ];
124 /^Build-Depends\/(\w+): \s*(.+)\s*$/ and $pkg->{"builddepends/$1"} = [ split /\s+/, $2 ];
125 /^Build-Types:\s*(.+)\s*$/ and $pkg->{buildtypes} = [ split /\s+/, $1 ];
126 /^Feed:\s*(.+?)\s*$/ and $pkg->{feed} = $1;
127 /^Category: \s*(.+)\s*$/ and do {
128 $pkg->{category} = $1;
129 defined $category{$1} or $category{$1} = {};
130 defined $category{$1}->{$src} or $category{$1}->{$src} = [];
131 push @{$category{$1}->{$src}}, $pkg;
133 /^Description: \s*(.*)\s*$/ and $pkg->{description} = "\t\t $1\n". get_multiline(*FILE, "\t\t ");
134 /^Type: \s*(.+)\s*$/ and do {
135 $pkg->{type} = [ split /\s+/, $1 ];
136 undef $pkg->{tristate};
137 foreach my $type (@{$pkg->{type}}) {
138 $type =~ /ipkg/ and $pkg->{tristate} = 1;
141 /^Config:\s*(.*)\s*$/ and $pkg->{config} = "$1\n".get_multiline(*FILE, "\t");
142 /^Prereq-Check:/ and $pkg->{prereq} = 1;
143 /^Preconfig:\s*(.+)\s*$/ and do {
144 my $pkgname = $pkg->{name};
145 $preconfig{$pkgname} or $preconfig{$pkgname} = {};
146 if (exists $preconfig{$pkgname}->{$1}) {
147 $preconfig = $preconfig{$pkgname}->{$1};
152 $preconfig{$pkgname}->{$1} = $preconfig;
155 /^Preconfig-Type:\s*(.*?)\s*$/ and $preconfig->{type} = $1;
156 /^Preconfig-Label:\s*(.*?)\s*$/ and $preconfig->{label} = $1;
157 /^Preconfig-Default:\s*(.*?)\s*$/ and $preconfig->{default} = $1;