author | kergoth <kergoth> | 2002-11-05 16:33:50 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-11-05 16:33:50 (UTC) |
commit | d590a056fde3eb4ad37ecd202ea024a9ad110106 (patch) (unidiff) | |
tree | 4ab78078234f70d786e172a9408b208582e175a5 | |
parent | 6561744765fdc099767c285e95ab9eb09d6087cb (diff) | |
download | opie-d590a056fde3eb4ad37ecd202ea024a9ad110106.zip opie-d590a056fde3eb4ad37ecd202ea024a9ad110106.tar.gz opie-d590a056fde3eb4ad37ecd202ea024a9ad110106.tar.bz2 |
tweaks
-rwxr-xr-x | scripts/makecfg.pl | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/scripts/makecfg.pl b/scripts/makecfg.pl index 20c23f5..5dd66a4 100755 --- a/scripts/makecfg.pl +++ b/scripts/makecfg.pl | |||
@@ -1,98 +1,102 @@ | |||
1 | #!/usr/bin/perl -w | 1 | #!/usr/bin/perl -w |
2 | eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' | 2 | eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' |
3 | if 0; #$running_under_some_shell | 3 | if 0; #$running_under_some_shell |
4 | 4 | ||
5 | use strict; | 5 | use strict; |
6 | use File::Find; | 6 | use File::Find; |
7 | 7 | ||
8 | my $packages=""; | 8 | my $packages=""; |
9 | open(FILE, "<./packages"); | 9 | open(FILE, "<./packages"); |
10 | while(<FILE>){$packages.=$_;} | 10 | while(<FILE>){$packages.=$_;} |
11 | close(FILE); | 11 | close(FILE); |
12 | 12 | ||
13 | my ($dirname,$dir,$cfg,$filename,$tagname,$name,$caps,$pre,$post,$sources,@dupecheck); | 13 | my ($dirname,$dir,$file,@files,$filename,$tagname,$name,$caps,$pre,$post,$sources,@dupecheck); |
14 | $cfg = shift || die; | 14 | $file = shift || die; |
15 | push(@files, $file); | ||
16 | |||
17 | foreach(@files){ | ||
18 | my $cfg=$_; | ||
15 | ($dirname=$cfg)=~s,(.*)/(.*),$1,; | 19 | ($dirname=$cfg)=~s,(.*)/(.*),$1,; |
16 | ($filename=$cfg)=~s,(.*/)(.*),$2,; | 20 | ($filename=$cfg)=~s,(.*/)(.*),$2,; |
17 | ($tagname=$dirname)=~s,.*/,,; | 21 | ($tagname=$dirname)=~s,.*/,,; |
18 | ($caps=$tagname)=~tr/[a-z]/[A-Z]/; | 22 | ($caps=$tagname)=~tr/[a-z]/[A-Z]/; |
19 | #print "cfg is $cfg\n"; | 23 | #print "cfg is $cfg\n"; |
20 | #print "dir is $dirname\n"; | 24 | #print "dir is $dirname\n"; |
21 | #print "filename is $filename\n"; | 25 | #print "filename is $filename\n"; |
22 | sub wanted; | 26 | sub wanted; |
23 | 27 | ||
24 | if(-e "$dirname/config.in.in"){ | 28 | if(-e "$dirname/config.in.in"){ |
25 | my $contents; | 29 | my $contents; |
26 | open(FILE, "<$dirname/config.in.in"); | 30 | open(FILE, "<$dirname/config.in.in"); |
27 | while(<FILE>){ $contents.=$_; } | 31 | while(<FILE>){ $contents.=$_; } |
28 | close(FILE); | 32 | close(FILE); |
29 | if($contents=~/\@sources\@/){ | 33 | if($contents=~/\@sources\@/){ |
30 | ($post = $contents) =~ s/^.*\@sources\@//s; | 34 | ($post = $contents) =~ s/^.*\@sources\@//s; |
31 | ($pre = $contents) =~ s/\@sources\@.*$//s; | 35 | ($pre = $contents) =~ s/\@sources\@.*$//s; |
32 | } else { | 36 | } else { |
33 | $pre = $contents; | 37 | $pre = $contents; |
34 | } | 38 | } |
35 | } else { | 39 | } else { |
36 | $pre = "menu \"$tagname\"\n"; | 40 | $pre = "menu \"$tagname\"\n"; |
37 | $post = "endmenu\n"; | 41 | $post = "endmenu\n"; |
38 | } | 42 | } |
39 | 43 | ||
40 | open(CFG, ">$cfg") || die "Unable to open $cfg for writing\n"; | 44 | open(CFG, ">$cfg") || die "Unable to open $cfg for writing\n"; |
41 | select(CFG); | 45 | select(CFG); |
42 | print $pre; | 46 | print $pre; |
43 | @dupecheck=(); | 47 | @dupecheck=(); |
44 | File::Find::find({wanted => \&wanted}, $dirname); | 48 | File::Find::find({wanted => \&wanted}, $dirname); |
45 | print $post; | 49 | print $post; |
46 | select(STDOUT); | 50 | select(STDOUT); |
47 | close(CFG); | 51 | close(CFG); |
48 | 52 | } | |
49 | exit; | 53 | exit; |
50 | 54 | ||
51 | open(FILE,">$dir/config.in"); | 55 | open(FILE,">$dir/config.in"); |
52 | select(FILE); | 56 | select(FILE); |
53 | print "menu \"$name\"\n"; | 57 | print "menu \"$name\"\n"; |
54 | print "\n"; | 58 | print "\n"; |
55 | my @subdirs=(); | 59 | my @subdirs=(); |
56 | my @dirs; | 60 | my @dirs; |
57 | foreach(grep(/^$dir/, @dirs)){ | 61 | foreach(grep(/^$dir/, @dirs)){ |
58 | chomp; | 62 | chomp; |
59 | /^$dir\/$name.pro$/ && next; | 63 | /^$dir\/$name.pro$/ && next; |
60 | my $localdir=$_; | 64 | my $localdir=$_; |
61 | if($dir=~m,^$localdir$,){ | 65 | if($dir=~m,^$localdir$,){ |
62 | next; | 66 | next; |
63 | } | 67 | } |
64 | #($locadir=$_)~s,/[^/]+$,,g; | 68 | #($locadir=$_)~s,/[^/]+$,,g; |
65 | if($localdir=~/^\.$/){next;} | 69 | if($localdir=~/^\.$/){next;} |
66 | if(grep(/^$localdir$/, @subdirs)){next;} | 70 | if(grep(/^$localdir$/, @subdirs)){next;} |
67 | my $nslashes = $localdir =~ tr!/!!; | 71 | my $nslashes = $localdir =~ tr!/!!; |
68 | my $dirnslashes = $dir =~ tr!/!!; | 72 | my $dirnslashes = $dir =~ tr!/!!; |
69 | $dirnslashes++; | 73 | $dirnslashes++; |
70 | if($dirnslashes != $nslashes ){next;} | 74 | if($dirnslashes != $nslashes ){next;} |
71 | print STDERR "$localdir/config.in\n"; | 75 | print STDERR "$localdir/config.in\n"; |
72 | print " source $localdir/config.in\n"; | 76 | print " source $localdir/config.in\n"; |
73 | push(@subdirs, $localdir); | 77 | push(@subdirs, $localdir); |
74 | print "endmenu\n"; | 78 | print "endmenu\n"; |
75 | select(STDOUT); | 79 | select(STDOUT); |
76 | close(FILE); | 80 | close(FILE); |
77 | } | 81 | } |
78 | 82 | ||
79 | use vars qw/*name *dir *prune/; | 83 | use vars qw/*name *dir *prune/; |
80 | *name = *File::Find::name; | 84 | *name = *File::Find::name; |
81 | *dir = *File::Find::dir; | 85 | *dir = *File::Find::dir; |
82 | *prune = *File::Find::prune; | 86 | *prune = *File::Find::prune; |
83 | 87 | ||
84 | sub wanted { | 88 | sub wanted { |
85 | if( /config.in/s ) { | 89 | if( /config.in$/s ) { |
86 | if(grep(/^$File::Find::dir\/config.in$/, @dupecheck)){ | 90 | if(grep(/^$File::Find::dir\/config.in$/, @dupecheck)){ |
87 | return; | 91 | return; |
88 | } | 92 | } |
89 | my $nslashes = $File::Find::dir =~ tr!/!!; | 93 | my $nslashes = $File::Find::dir =~ tr!/!!; |
90 | my $dirnslashes = $dirname =~ tr!/!!; | 94 | my $dirnslashes = $dirname =~ tr!/!!; |
91 | $dirnslashes++; | 95 | $dirnslashes++; |
92 | # print STDERR "dirnslashes is $dirnslashes\n"; | 96 | # print STDERR "dirnslashes is $dirnslashes\n"; |
93 | # print STDERR "nslashes is $nslashes\n"; | 97 | # print STDERR "nslashes is $nslashes\n"; |
94 | if($dirnslashes != $nslashes){return;} | 98 | if($dirnslashes != $nslashes){return;} |
95 | print " source " . $File::Find::dir . "/config.in\n"; | 99 | print " source " . $File::Find::dir . "/config.in\n"; |
96 | push(@dupecheck, $File::Find::dir . "/config.in"); | 100 | push(@dupecheck, $File::Find::dir . "/config.in"); |
97 | } | 101 | } |
98 | } | 102 | } |