5 our @EXPORT = qw(%package %srcpackage %category %subdir %preconfig %features %overrides clear_packages parse_package_metadata get_multiline);
21 $str .= (($_ and $prefix) ? $prefix . $_ : $_);
24 return $str ? $str : "";
27 sub clear_packages() {
37 sub parse_package_metadata($) {
47 open FILE, "<$file" or do {
48 warn "Cannot open '$file': $!\n";
53 /^Source-Makefile: \s*((.+\/)([^\/]+)\/Makefile)\s*$/ and do {
57 $subdir =~ s/^package\///;
58 $subdir{$src} = $subdir;
59 $srcpackage{$src} = [];
63 /^Override: \s*(.+?)\s*$/ and do {
68 /^Package:\s*(.+?)\s*$/ and do {
72 $pkg->{makefile} = $makefile;
76 $pkg->{mdepends} = [];
77 $pkg->{builddepends} = [];
78 $pkg->{buildtypes} = [];
79 $pkg->{subdir} = $subdir;
81 $pkg->{override} = $override;
83 push @{$srcpackage{$src}}, $pkg;
85 /^Feature:\s*(.+?)\s*$/ and do {
88 $feature->{name} = $1;
89 $feature->{priority} = 0;
92 /^Target-Name:\s*(.+?)\s*$/ and do {
93 $features{$1} or $features{$1} = [];
94 push @{$features{$1}}, $feature;
96 /^Target-Title:\s*(.+?)\s*$/ and $feature->{target_title} = $1;
97 /^Feature-Priority:\s*(\d+)\s*$/ and $feature->{priority} = $1;
98 /^Feature-Name:\s*(.+?)\s*$/ and $feature->{title} = $1;
99 /^Feature-Description:/ and $feature->{description} = get_multiline(\*FILE, "\t\t\t");
103 /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1;
104 /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1;
105 /^Menu: \s*(.+)\s*$/ and $pkg->{menu} = $1;
106 /^Submenu: \s*(.+)\s*$/ and $pkg->{submenu} = $1;
107 /^Submenu-Depends: \s*(.+)\s*$/ and $pkg->{submenudep} = $1;
108 /^Source: \s*(.+)\s*$/ and $pkg->{source} = $1;
109 /^License: \s*(.+)\s*$/ and $pkg->{license} = $1;
110 /^LicenseFiles: \s*(.+)\s*$/ and $pkg->{licensefiles} = $1;
111 /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
112 /^Provides: \s*(.+)\s*$/ and do {
113 my @vpkg = split /\s+/, $1;
114 foreach my $vpkg (@vpkg) {
115 $package{$vpkg} or $package{$vpkg} = {
120 makefile => $makefile
122 push @{$package{$vpkg}->{vdepends}}, $pkg->{name};
125 /^Menu-Depends: \s*(.+)\s*$/ and $pkg->{mdepends} = [ split /\s+/, $1 ];
126 /^Depends: \s*(.+)\s*$/ and $pkg->{depends} = [ split /\s+/, $1 ];
127 /^Conflicts: \s*(.+)\s*$/ and $pkg->{conflicts} = [ split /\s+/, $1 ];
128 /^Hidden: \s*(.+)\s*$/ and $pkg->{hidden} = 1;
129 /^Build-Variant: \s*([\w\-]+)\s*/ and $pkg->{variant} = $1;
130 /^Default-Variant: .*/ and $pkg->{variant_default} = 1;
131 /^Build-Only: \s*(.+)\s*$/ and $pkg->{buildonly} = 1;
132 /^Build-Depends: \s*(.+)\s*$/ and $pkg->{builddepends} = [ split /\s+/, $1 ];
133 /^Build-Depends\/(\w+): \s*(.+)\s*$/ and $pkg->{"builddepends/$1"} = [ split /\s+/, $2 ];
134 /^Build-Types:\s*(.+)\s*$/ and $pkg->{buildtypes} = [ split /\s+/, $1 ];
135 /^Feed:\s*(.+?)\s*$/ and $pkg->{feed} = $1;
136 /^Category: \s*(.+)\s*$/ and do {
137 $pkg->{category} = $1;
138 defined $category{$1} or $category{$1} = {};
139 defined $category{$1}->{$src} or $category{$1}->{$src} = [];
140 push @{$category{$1}->{$src}}, $pkg;
142 /^Description: \s*(.*)\s*$/ and $pkg->{description} = "\t\t $1\n". get_multiline(*FILE, "\t\t ");
143 /^Type: \s*(.+)\s*$/ and do {
144 $pkg->{type} = [ split /\s+/, $1 ];
145 undef $pkg->{tristate};
146 foreach my $type (@{$pkg->{type}}) {
147 $type =~ /ipkg/ and $pkg->{tristate} = 1;
150 /^Config:\s*(.*)\s*$/ and $pkg->{config} = "$1\n".get_multiline(*FILE, "\t");
151 /^Prereq-Check:/ and $pkg->{prereq} = 1;
152 /^Preconfig:\s*(.+)\s*$/ and do {
153 my $pkgname = $pkg->{name};
154 $preconfig{$pkgname} or $preconfig{$pkgname} = {};
155 if (exists $preconfig{$pkgname}->{$1}) {
156 $preconfig = $preconfig{$pkgname}->{$1};
161 $preconfig{$pkgname}->{$1} = $preconfig;
164 /^Preconfig-Type:\s*(.*?)\s*$/ and $preconfig->{type} = $1;
165 /^Preconfig-Label:\s*(.*?)\s*$/ and $preconfig->{label} = $1;
166 /^Preconfig-Default:\s*(.*?)\s*$/ and $preconfig->{default} = $1;