summaryrefslogtreecommitdiff
path: root/scripts/makecfg.pl
authorkergoth <kergoth>2003-01-16 04:38:48 (UTC)
committer kergoth <kergoth>2003-01-16 04:38:48 (UTC)
commit7ffd4623880396f07e34faf195f8c131218cf682 (patch) (side-by-side diff)
tree78aaf4470ef3ff18a871c0487dafe59d62f34ff3 /scripts/makecfg.pl
parent73927fe1c095507ce7fdd310917521fcd305b7e5 (diff)
downloadopie-7ffd4623880396f07e34faf195f8c131218cf682.zip
opie-7ffd4623880396f07e34faf195f8c131218cf682.tar.gz
opie-7ffd4623880396f07e34faf195f8c131218cf682.tar.bz2
General cleanup for generated configs. 1) Sort included config.in's, 2) capitalize first letter of generated menu sections.
Diffstat (limited to 'scripts/makecfg.pl') (more/less context) (show whitespace changes)
-rwxr-xr-xscripts/makecfg.pl43
1 files changed, 24 insertions, 19 deletions
diff --git a/scripts/makecfg.pl b/scripts/makecfg.pl
index d7dc41e..de9d71a 100755
--- a/scripts/makecfg.pl
+++ b/scripts/makecfg.pl
@@ -1,79 +1,84 @@
#!/usr/bin/perl -w
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; #$running_under_some_shell
use strict;
use File::Find;
my $packages="";
open(FILE, "<./packages");
while(<FILE>){$packages.=$_;}
close(FILE);
my ($dirname,$dir,$file,@files,$filename,$tagname,$name,$caps,$pre,$post,$sources,@dupecheck,$basedir);
+my @founddirs;
$file = shift || die;
$basedir = shift;
-push(@files, $file);
-foreach(@files){
-my $cfg=$_;
+my $cfg=$file;
($dirname=$cfg)=~s,(.*)/(.*),$1,;
($filename=$cfg)=~s,(.*/)(.*),$2,;
($tagname=$dirname)=~s,.*/,,;
($caps=$tagname)=~tr/[a-z]/[A-Z]/;
#print "cfg is $cfg\n";
#print "dir is $dirname\n";
#print "filename is $filename\n";
sub wanted;
if(-e "$dirname/config.in.in"){
my $contents;
open(FILE, "<$dirname/config.in.in");
while(<FILE>){ $contents.=$_; }
close(FILE);
if($contents=~/\@sources\@/){
($post = $contents) =~ s/^.*\@sources\@//s;
($pre = $contents) =~ s/\@sources\@.*$//s;
} else {
$pre = $contents;
}
} else {
+ my ($firstletter, $rest);
+ $firstletter = substr($tagname, 0, 1);
+ $rest = substr($tagname, 1);
+ $firstletter =~ tr/a-z/A-Z/;
+ $tagname = $firstletter . $rest;
$pre = "menu \"$tagname\"\n";
$post = "endmenu\n";
}
open(CFG, ">$cfg") || die "Unable to open $cfg for writing\n";
select(CFG);
print $pre;
@dupecheck=();
File::Find::find({wanted => \&wanted}, $dirname);
+@::founddirs=sort(@::founddirs);
+foreach (@::founddirs) {
+ if(grep(/^$_\/config.in$/, @dupecheck)){
+ next;
+ }
+ my $nslashes = $_ =~ tr!/!!;
+ my $dirnslashes = $dirname =~ tr!/!!;
+ $dirnslashes++;
+ if($dirnslashes != $nslashes){next;}
+ my $reldir;
+ if (defined($basedir)) {
+ ($reldir=$_)=~s,^$basedir/,,;
+ }
+ print " source " . $reldir . "/config.in\n";
+ push(@dupecheck, $_ . "/config.in");
+}
print $post;
select(STDOUT);
close(CFG);
-}
exit;
use vars qw/*name *dir *prune/;
*name = *File::Find::name;
*dir = *File::Find::dir;
*prune = *File::Find::prune;
sub wanted {
if( /config.in$/s ) {
- if(grep(/^$File::Find::dir\/config.in$/, @dupecheck)){
- return;
- }
- my $nslashes = $File::Find::dir =~ tr!/!!;
- my $dirnslashes = $dirname =~ tr!/!!;
- $dirnslashes++;
-# print STDERR "dirnslashes is $dirnslashes\n";
-# print STDERR "nslashes is $nslashes\n";
- if($dirnslashes != $nslashes){return;}
- my $reldir;
- if (defined($basedir)) {
- ($reldir=$File::Find::dir)=~s,^$basedir/,,;
- }
- print " source " . $reldir . "/config.in\n";
- push(@dupecheck, $File::Find::dir . "/config.in");
+ push(@::founddirs,$File::Find::dir);
}
}