next if $package{$depend} and $package{$depend}->{buildonly};
if ($flags =~ /\+/) {
if ($vdep = $package{$depend}->{vdepends}) {
- my @vdeps = @$vdep;
- $depend = shift @vdeps;
+ my @vdeps;
+ $depend = undef;
+
+ foreach my $v (@$vdep) {
+ if ($package{$v} && $package{$v}->{variant_default}) {
+ $depend = $v;
+ } else {
+ push @vdeps, $v;
+ }
+ }
+
+ if (!$depend) {
+ $depend = shift @vdeps;
+ }
+
if (@vdeps > 1) {
- $condition = '!('.join("||", map { "PACKAGE_".$_ } @vdeps).')';
+ $condition = ($condition ? "$condition && " : '') . '!('.join("||", map { "PACKAGE_".$_ } @vdeps).')';
} elsif (@vdeps > 0) {
- $condition = '!PACKAGE_'.$vdeps[0];
+ $condition = ($condition ? "$condition && " : '') . '!PACKAGE_'.$vdeps[0];
}
}
$m = "select";
next if $only_dep;
+
+ $flags =~ /@/ or $depend = "PACKAGE_$depend";
} else {
if ($vdep = $package{$depend}->{vdepends}) {
$depend = join("||", map { "PACKAGE_".$_ } @$vdep);
+ } else {
+ $flags =~ /@/ or $depend = "PACKAGE_$depend";
}
}
- $flags =~ /@/ or $depend = "PACKAGE_$depend";
+
if ($condition) {
if ($m =~ /select/) {
next if $depend eq $condition;
$depend = "$depend if $condition";
} else {
+ next if $dep->{"$depend if $condition"};
$depend = "!($condition) || $depend" unless $dep->{$condition} eq 'select';
}
}
print "menu \"$menu\"\n";
}
foreach my $pkg (@pkgs) {
+ next if $pkg->{ignore};
my $title = $pkg->{name};
my $c = (72 - length($pkg->{name}) - length($pkg->{title}));
if ($c > 0) {
keys %overrides > 0 or return;
print "\tconfig OVERRIDE_PKGS\n";
print "\t\tstring\n";
- print "\t\tdefault \"".join(" ", keys %overrides)."\"\n\n";
+ print "\t\tdefault \"".join(" ", sort keys %overrides)."\"\n\n";
}
sub gen_package_config() {
sub gen_package_mk() {
my %conf;
my %dep;
- my %done;
my $line;
parse_package_metadata($ARGV[0]) or exit 1;
- foreach my $name (sort {uc($a) cmp uc($b)} keys %package) {
- my $config;
- my $pkg = $package{$name};
+ foreach my $srcname (sort {uc($a) cmp uc($b)} keys %srcpackage) {
+ my $src = $srcpackage{$srcname};
+ my $variant_default;
my @srcdeps;
- next if defined $pkg->{vdepends};
+ foreach my $pkg (@{$src->{packages}}) {
+ next if defined $pkg->{vdepends};
+
+ my $config = '';
+ $config = "\$(CONFIG_PACKAGE_$pkg->{name})" unless $pkg->{buildonly};
+
+ $pkg->{prereq} and print "prereq-$config += $src->{path}\n";
+
+ next if $pkg->{buildonly};
+
+ print "package-$config += $src->{path}\n";
- $config = "\$(CONFIG_PACKAGE_$name)";
- if ($config) {
- $pkg->{buildonly} and $config = "";
- print "package-$config += $pkg->{subdir}$pkg->{src}\n";
if ($pkg->{variant}) {
- if (!defined($done{$pkg->{src}}) or $pkg->{variant_default}) {
- print "\$(curdir)/$pkg->{subdir}$pkg->{src}/default-variant := $pkg->{variant}\n";
+ if (!defined($variant_default) or $pkg->{variant_default}) {
+ $variant_default = $pkg->{variant};
}
- print "\$(curdir)/$pkg->{subdir}$pkg->{src}/variants += \$(if $config,$pkg->{variant})\n"
+ print "\$(curdir)/$src->{path}/variants += \$(if $config,$pkg->{variant})\n";
}
- $pkg->{prereq} and print "prereq-$config += $pkg->{subdir}$pkg->{src}\n";
}
- next if $done{$pkg->{src}};
- $done{$pkg->{src}} = 1;
+ if (defined($variant_default)) {
+ print "\$(curdir)/$src->{path}/default-variant := $variant_default\n";
+ }
- if (@{$pkg->{buildtypes}} > 0) {
- print "buildtypes-$pkg->{subdir}$pkg->{src} = ".join(' ', @{$pkg->{buildtypes}})."\n";
+ unless (grep {!$_->{buildonly}} @{$src->{packages}}) {
+ print "package- += $src->{path}\n";
}
- foreach my $spkg (@{$srcpackage{$pkg->{src}}}) {
- foreach my $dep (@{$spkg->{depends}}, @{$spkg->{builddepends}}) {
- $dep =~ /@/ or do {
- $dep =~ s/\+//g;
- push @srcdeps, $dep;
- };
- }
+ if (@{$src->{buildtypes}} > 0) {
+ print "buildtypes-$src->{path} = ".join(' ', @{$src->{buildtypes}})."\n";
+ }
+
+ foreach my $dep (@{$src->{builddepends}}, map { @{$_->{depends}} } @{$src->{packages}}) {
+ $dep =~ /@/ or do {
+ $dep =~ s/\+//g;
+ push @srcdeps, $dep;
+ };
}
- foreach my $type (@{$pkg->{buildtypes}}) {
+ foreach my $type (@{$src->{buildtypes}}) {
my @extra_deps;
my %deplines;
- next unless $pkg->{"builddepends/$type"};
- foreach my $dep (@{$pkg->{"builddepends/$type"}}) {
+ next unless $src->{"builddepends/$type"};
+ foreach my $dep (@{$src->{"builddepends/$type"}}) {
my $suffix = "";
+ my $deptype = "";
my $condition;
if ($dep =~ /^(.+):(.+)/) {
$condition = $1;
$dep = $2;
}
- if ($dep =~ /^(.+)(\/.+)/) {
+ if ($dep =~ /^(.+)\/(.+)/) {
$dep = $1;
- $suffix = $2;
+ $deptype = $2;
+ $suffix = "/$2";
}
my $idx = "";
my $pkg_dep = $package{$dep};
if (defined($pkg_dep) && defined($pkg_dep->{src})) {
- $idx = $pkg_dep->{subdir}.$pkg_dep->{src};
+ unless (!$deptype || grep { $_ eq $deptype } @{$pkg_dep->{src}{buildtypes}}) {
+ warn sprintf "WARNING: Makefile '%s' has a %s build dependency on '%s/%s' but '%s' does not implement a '%s' build type\n",
+ $src->{makefile}, $type, $pkg_dep->{src}{name}, $deptype, $pkg_dep->{makefile}, $deptype;
+ next;
+ }
+ $idx = $pkg_dep->{src}{path};
} elsif (defined($srcpackage{$dep})) {
- $idx = $subdir{$dep}.$dep;
+ $idx = $srcpackage{$dep}{path};
} else {
next;
}
}
my $depline = join(" ", sort keys %deplines);
if ($depline) {
- $line .= "\$(curdir)/".$pkg->{subdir}."$pkg->{src}/$type/compile += $depline\n";
+ $line .= "\$(curdir)/$src->{path}/$type/compile += $depline\n";
}
}
my $condition;
my $prefix = "";
my $suffix = "";
+ my $deptype = "";
if ($deps =~ /^(.+):(.+)/) {
$condition = $1;
$deps = $2;
}
- if ($deps =~ /^(.+)(\/.+)/) {
+ if ($deps =~ /^(.+)\/(.+)/) {
$deps = $1;
- $suffix = $2;
+ $deptype = $2;
+ $suffix = "/$2";
}
my $pkg_dep = $package{$deps};
foreach my $dep (@deps) {
$pkg_dep = $package{$deps};
if (defined $pkg_dep->{src}) {
- ($pkg->{src} ne $pkg_dep->{src}.$suffix) and $idx = $pkg_dep->{subdir}.$pkg_dep->{src};
+ unless (!$deptype || grep { $_ eq $deptype } @{$pkg_dep->{src}{buildtypes}}) {
+ warn sprintf "WARNING: Makefile '%s' has a build dependency on '%s/%s' but '%s' does not implement a '%s' build type\n",
+ $src->{makefile}, $pkg_dep->{src}{name}, $deptype, $pkg_dep->{makefile}, $deptype;
+ next;
+ }
+ $idx = $pkg_dep->{src}{path};
} elsif (defined($srcpackage{$dep})) {
- $idx = $subdir{$dep}.$dep;
+ $idx = $srcpackage{$dep}{path};
}
- undef $idx if $idx eq 'base-files';
+
if ($idx) {
$idx .= $suffix;
my $depline;
- next if $pkg->{src} eq $pkg_dep->{src}.$suffix;
- next if $dep{$condition.":".$pkg->{src}."->".$idx};
- next if $dep{$pkg->{src}."->($dep)".$idx} and $pkg_dep->{vdepends};
+ next if $srcname eq $pkg_dep->{src}{name}.$suffix;
+ next if $dep{$condition.":".$srcname."->".$idx};
+ next if $dep{$srcname."->($dep)".$idx} and $pkg_dep->{vdepends};
my $depstr;
if ($pkg_dep->{vdepends}) {
$depstr = "\$(if \$(CONFIG_PACKAGE_$dep),\$(curdir)/$idx/compile)";
- $dep{$pkg->{src}."->($dep)".$idx} = 1;
+ $dep{$srcname."->($dep)".$idx} = 1;
} else {
$depstr = "\$(curdir)/$idx/compile";
- $dep{$pkg->{src}."->".$idx} = 1;
+ $dep{$srcname."->".$idx} = 1;
}
$depline = get_conditional_dep($condition, $depstr);
if ($depline) {
}
my $depline = join(" ", sort keys %deplines);
if ($depline) {
- $line .= "\$(curdir)/".$pkg->{subdir}."$pkg->{src}/compile += $depline\n";
+ $line .= "\$(curdir)/$src->{path}/compile += $depline\n";
}
}
( \\
$cmds \\
) > \$@
-
+
ifneq (\$(IMAGEOPT)\$(CONFIG_IMAGEOPT),)
package/preconfig: \$(TARGET_DIR)/etc/uci-defaults/$preconfig
endif
}
}
+sub gen_usergroup_list() {
+ parse_package_metadata($ARGV[0]) or exit 1;
+ for my $name (keys %usernames) {
+ print "user $name $usernames{$name}{id} $usernames{$name}{makefile}\n";
+ }
+ for my $name (keys %groupnames) {
+ print "group $name $groupnames{$name}{id} $groupnames{$name}{makefile}\n";
+ }
+}
+
sub parse_command() {
GetOptions("ignore=s", \@ignore);
my $cmd = shift @ARGV;
/^subdirs$/ and return gen_package_subdirs();
/^license$/ and return gen_package_license(0);
/^licensefull$/ and return gen_package_license(1);
+ /^usergroup$/ and return gen_usergroup_list();
/^version_filter$/ and return gen_version_filtered_list();
}
die <<EOF
$0 subdirs [file] Package subdir information in makefile format
$0 license [file] Package license information
$0 licensefull [file] Package license information (full list)
+ $0 usergroup [file] Package usergroup allocation list
$0 version_filter [patchver] [list...] Filter list of version tagged strings
Options: