2011-10-05 07:01:45 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use Getopt::Long;
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
&main();
|
|
|
|
sub main
|
|
|
|
{
|
|
|
|
my($dev_output, $ndev_output, $loc) = ("-", "-", ".");
|
|
|
|
&Getopt::Long::Configure(qw(bundling));
|
|
|
|
&GetOptions(
|
|
|
|
"D=s" => \$dev_output,
|
|
|
|
"N=s" => \$ndev_output,
|
|
|
|
"L=s" => \$loc,
|
|
|
|
);
|
|
|
|
|
|
|
|
my($dev, $ndev) = &scan($loc);
|
|
|
|
&output($dev, $ndev, $dev_output, $ndev_output);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub scan
|
|
|
|
{
|
|
|
|
my $loc = shift @_;
|
|
|
|
my(@dev, @ndev);
|
|
|
|
|
|
|
|
foreach $_ (`find "$loc"`)
|
|
|
|
{
|
|
|
|
chomp $_;
|
2013-07-03 08:06:47 +02:00
|
|
|
if (-d $_ && !-l $_) {
|
2011-10-05 07:01:45 +02:00
|
|
|
# Generate directory list later.
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
my $is_devel =
|
|
|
|
m{^\Q$loc\E.*/Kconfig} ||
|
|
|
|
m{^\Q$loc\E.*/Kbuild} ||
|
|
|
|
m{^\Q$loc\E.*/Makefile} ||
|
2013-07-03 08:06:47 +02:00
|
|
|
m{^\Q$loc\E/arch/[^/]+/boot/dts/include/dt-bindings\b} ||
|
2011-10-05 07:01:45 +02:00
|
|
|
m{^\Q$loc\E/arch/[^/]+/include\b} ||
|
2015-11-30 08:05:48 +01:00
|
|
|
m{^\Q$loc\E/arch/.*/module\.lds\b} ||
|
2013-05-21 08:07:11 +02:00
|
|
|
m{^\Q$loc\E/arch/arm/[^/]+/include/mach\b} ||
|
|
|
|
m{^\Q$loc\E/arch/arm/[^/]+/include/plat\b} ||
|
2016-08-30 08:05:46 +02:00
|
|
|
m{^\Q$loc\E/arch/[^/]+/scripts\b} ||
|
2017-09-13 08:02:42 +02:00
|
|
|
m{^\Q$loc\E/arch/[^/]+/tools\b} ||
|
2011-10-05 07:01:45 +02:00
|
|
|
m{^\Q$loc\E/include/[^/]+\b} ||
|
|
|
|
m{^\Q$loc\E/scripts\b};
|
|
|
|
if (substr($_, 0, 1) ne "/") {
|
|
|
|
# We cannot use an absolute path during find,
|
|
|
|
# but rpm wants one later.
|
|
|
|
$_ = "/$_";
|
|
|
|
}
|
|
|
|
$is_devel ? push(@dev, $_) : push(@ndev, $_);
|
|
|
|
}
|
|
|
|
|
|
|
|
push(@dev, &calc_dirs("/$loc", \@dev));
|
|
|
|
push(@ndev, &calc_dirs("/$loc", \@ndev));
|
|
|
|
return (\@dev, \@ndev);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub calc_dirs
|
|
|
|
{
|
|
|
|
my($base, $files) = @_;
|
|
|
|
my %dirs;
|
|
|
|
|
|
|
|
foreach my $file (@$files) {
|
|
|
|
my $path = $file;
|
|
|
|
do {
|
|
|
|
$path =~ s{/[^/]+$}{};
|
|
|
|
$dirs{$path} = 1;
|
2023-03-09 07:13:29 +01:00
|
|
|
} while ($path ne $base and $path ne "");
|
2011-10-05 07:01:45 +02:00
|
|
|
# This loop also makes sure that $base itself is included.
|
|
|
|
}
|
|
|
|
|
|
|
|
return map { "\%dir $_" } keys %dirs;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub output
|
|
|
|
{
|
|
|
|
my($dev, $ndev, $dev_out, $ndev_out) = @_;
|
|
|
|
local *FH;
|
|
|
|
|
|
|
|
open(FH, "> $dev_out") || warn "Error writing to $dev_out: $!";
|
|
|
|
print FH join("\n", @$dev), "\n";
|
|
|
|
close FH;
|
|
|
|
|
|
|
|
open(FH, "> $ndev_out") || warn "Error writing to $ndev_out: $!";
|
|
|
|
print FH join("\n", @$ndev), "\n";
|
|
|
|
close FH;
|
|
|
|
}
|