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) (unidiff)
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) (ignore 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
@@ -8,18 +8,17 @@ use File::Find;
8my $packages=""; 8my $packages="";
9open(FILE, "<./packages"); 9open(FILE, "<./packages");
10while(<FILE>){$packages.=$_;} 10while(<FILE>){$packages.=$_;}
11close(FILE); 11close(FILE);
12 12
13my ($dirname,$dir,$file,@files,$filename,$tagname,$name,$caps,$pre,$post,$sources,@dupecheck,$basedir); 13my ($dirname,$dir,$file,@files,$filename,$tagname,$name,$caps,$pre,$post,$sources,@dupecheck,$basedir);
14my @founddirs;
14$file = shift || die; 15$file = shift || die;
15$basedir = shift; 16$basedir = shift;
16push(@files, $file);
17 17
18foreach(@files){ 18my $cfg=$file;
19my $cfg=$_;
20($dirname=$cfg)=~s,(.*)/(.*),$1,; 19($dirname=$cfg)=~s,(.*)/(.*),$1,;
21($filename=$cfg)=~s,(.*/)(.*),$2,; 20($filename=$cfg)=~s,(.*/)(.*),$2,;
22($tagname=$dirname)=~s,.*/,,; 21($tagname=$dirname)=~s,.*/,,;
23($caps=$tagname)=~tr/[a-z]/[A-Z]/; 22($caps=$tagname)=~tr/[a-z]/[A-Z]/;
24#print "cfg is $cfg\n"; 23#print "cfg is $cfg\n";
25#print "dir is $dirname\n"; 24#print "dir is $dirname\n";
@@ -35,45 +34,51 @@ if(-e "$dirname/config.in.in"){
35 ($post = $contents) =~ s/^.*\@sources\@//s; 34 ($post = $contents) =~ s/^.*\@sources\@//s;
36 ($pre = $contents) =~ s/\@sources\@.*$//s; 35 ($pre = $contents) =~ s/\@sources\@.*$//s;
37 } else { 36 } else {
38 $pre = $contents; 37 $pre = $contents;
39 } 38 }
40} else { 39} else {
40 my ($firstletter, $rest);
41 $firstletter = substr($tagname, 0, 1);
42 $rest = substr($tagname, 1);
43 $firstletter =~ tr/a-z/A-Z/;
44 $tagname = $firstletter . $rest;
41 $pre = "menu \"$tagname\"\n"; 45 $pre = "menu \"$tagname\"\n";
42 $post = "endmenu\n"; 46 $post = "endmenu\n";
43} 47}
44 48
45open(CFG, ">$cfg") || die "Unable to open $cfg for writing\n"; 49open(CFG, ">$cfg") || die "Unable to open $cfg for writing\n";
46select(CFG); 50select(CFG);
47print $pre; 51print $pre;
48@dupecheck=(); 52@dupecheck=();
49File::Find::find({wanted => \&wanted}, $dirname); 53File::Find::find({wanted => \&wanted}, $dirname);
54@::founddirs=sort(@::founddirs);
55foreach (@::founddirs) {
56 if(grep(/^$_\/config.in$/, @dupecheck)){
57 next;
58 }
59 my $nslashes = $_ =~ tr!/!!;
60 my $dirnslashes = $dirname =~ tr!/!!;
61 $dirnslashes++;
62 if($dirnslashes != $nslashes){next;}
63 my $reldir;
64 if (defined($basedir)) {
65 ($reldir=$_)=~s,^$basedir/,,;
66 }
67 print " source " . $reldir . "/config.in\n";
68 push(@dupecheck, $_ . "/config.in");
69}
50print $post; 70print $post;
51select(STDOUT); 71select(STDOUT);
52close(CFG); 72close(CFG);
53}
54exit; 73exit;
55 74
56use vars qw/*name *dir *prune/; 75use vars qw/*name *dir *prune/;
57*name = *File::Find::name; 76*name = *File::Find::name;
58*dir = *File::Find::dir; 77*dir = *File::Find::dir;
59*prune = *File::Find::prune; 78*prune = *File::Find::prune;
60 79
61sub wanted { 80sub wanted {
62 if( /config.in$/s ) { 81 if( /config.in$/s ) {
63 if(grep(/^$File::Find::dir\/config.in$/, @dupecheck)){ 82 push(@::founddirs,$File::Find::dir);
64 return;
65 }
66 my $nslashes = $File::Find::dir =~ tr!/!!;
67 my $dirnslashes = $dirname =~ tr!/!!;
68 $dirnslashes++;
69 # print STDERR "dirnslashes is $dirnslashes\n";
70 # print STDERR "nslashes is $nslashes\n";
71 if($dirnslashes != $nslashes){return;}
72 my $reldir;
73 if (defined($basedir)) {
74 ($reldir=$File::Find::dir)=~s,^$basedir/,,;
75 }
76 print " source " . $reldir . "/config.in\n";
77 push(@dupecheck, $File::Find::dir . "/config.in");
78 } 83 }
79} 84}