2 require "pwd.pl" || die "Required pwd.pl not found";
4 # This perl script automatically generates the samba.idb file
9 # We don't want the files listed in .cvsignore in the source tree
10 open(IGNORES,"../../source/.cvsignore") || die "Unable to open .cvsignore file\n";
17 # get the names of all the binary files to be installed
18 open(MAKEFILE,"../../source/Makefile") || die "Unable to open Makefile\n";
19 @makefile = <MAKEFILE>;
20 @sprogs = grep(/^SPROGS /,@makefile);
21 @progs1 = grep(/^PROGS1 /,@makefile);
22 @progs = grep(/^PROGS /,@makefile);
23 @scripts = grep(/^SCRIPTS /,@makefile);
24 @codepage = grep(/^CODEPAGELIST/,@makefile);
28 @sprogs[0] =~ s/^.*\=//;
29 @sprogs = split(' ',@sprogs[0]);
32 @progs[0] =~ s/^.*\=//;
33 @progs = split(' ',@progs[0]);
36 @progs1[0] =~ s/^.*\=//;
37 @progs1 = split(' ',@progs1[0]);
40 @scripts[0] =~ s/^.*\=//;
41 @scripts = split(' ',@scripts[0]);
44 @codepage[0] =~ s/^.*\=//;
46 # if we have codepages we need to create them for the package
47 system("chmod +x ./script/installcp.sh");
48 system("./script/installcp.sh . ../packaging/SGI/codepages ./bin @codepage[0]");
50 @codepage = sort split(' ',@codepage[0]);
52 # install the swat files
54 system("chmod +x ./script/installswat.sh");
55 system("./script/installswat.sh ../packaging/SGI/swat ./");
56 system("cp ../swat/README ../packaging/SGI/swat");
59 # add my local files to the list of binaries to install
60 @bins = sort byfilename (@sprogs,@progs,@progs1,@scripts,("/findsmb","/sambalp","/smbprint"));
62 # get a complete list of all files in the tree
67 # the files installed in docs include all the original files in docs plus all
68 # the "*.doc" files from the source tree
69 @docs = sort byfilename grep (!/^docs\/$/ & (/^source\/.*\.doc$/ | /^docs\//),@allfiles);
71 @swatfiles = sort grep(/^packaging\/SGI\/swat/, @allfiles);
72 @catman = sort grep(/^packaging\/SGI\/catman/ & !/\/$/, @allfiles);
73 @catman = sort bydirnum @catman;
75 # strip out all the generated directories and the "*.o" files from the source
77 @allfiles = grep(!/^.*\.o$/ & !/^packaging\/SGI\/bins/ & !/^packaging\/SGI\/catman/ & !/^packaging\/SGI\/html/ & !/^packaging\/SGI\/codepages/ & !/^packaging\/SGI\/swat/, @allfiles);
79 open(IDB,">samba.idb") || die "Unable to open samba.idb for output\n";
81 print IDB "f 0644 root sys etc/config/samba packaging/SGI/samba.config samba.sw.base config(update)\n";
82 print IDB "f 0755 root sys etc/init.d/samba packaging/SGI/samba.rc samba.sw.base\n";
83 print IDB "l 0000 root sys etc/rc0.d/K39samba packaging/SGI samba.sw.base symval(../init.d/samba)\n";
84 print IDB "l 0000 root sys etc/rc2.d/S81samba packaging/SGI samba.sw.base symval(../init.d/samba)\n";
86 @copyfile = grep (/^COPY/,@allfiles);
87 print IDB "d 0755 root sys usr/relnotes/samba/ packaging/SGI samba.man.relnotes\n";
88 print IDB "f 0644 root sys usr/relnotes/samba/@copyfile[0] @copyfile[0] samba.man.relnotes\n";
89 print IDB "f 0644 root sys usr/relnotes/samba/legal_notice.html packaging/SGI/legal_notice.html samba.man.relnotes\n";
90 print IDB "f 0644 root sys usr/relnotes/samba/samba-relnotes.html packaging/SGI/relnotes.html samba.man.relnotes\n";
92 print IDB "d 0755 root sys usr/samba/ packaging/SGI samba.sw.base\n";
93 print IDB "f 0444 root sys usr/samba/README packaging/SGI/README samba.sw.base\n";
95 print IDB "d 0755 root sys usr/samba/bin/ packaging/SGI samba.sw.base\n";
97 $nextfile = shift @bins;
98 ($filename = $nextfile) =~ s/^.*\///;;
100 if (index($nextfile,'$')) {
101 if ($filename eq "smbpasswd") {
102 print IDB "f 0755 root sys usr/samba/bin/$filename source/$nextfile samba.sw.base\n";
104 elsif ($filename eq "findsmb") {
105 print IDB "f 0755 root sys usr/samba/bin/$filename packaging/SGI/$filename samba.sw.base\n";
107 elsif ($filename eq "swat") {
108 print IDB "f 4755 root sys usr/samba/bin/$filename source/$nextfile samba.sw.base\n";
110 elsif ($filename eq "sambalp") {
111 print IDB "f 0755 root sys usr/samba/bin/$filename packaging/SGI/$filename samba.sw.base\n";
113 elsif ($filename eq "smbprint") {
114 print IDB "f 0755 root sys usr/samba/bin/$filename packaging/SGI/$filename samba.sw.base\n";
117 print IDB "f 0755 root sys usr/samba/bin/$filename source/$nextfile samba.sw.base\n";
122 print IDB "d 0755 root sys usr/samba/docs/ docs samba.man.doc\n";
124 $nextfile = shift @docs;
125 next if ($nextfile eq "CVS");
126 ($junk,$file) = split(/\//,$nextfile,2);
127 if (grep(/\/$/,$nextfile)) {
128 print IDB "d 0755 root sys usr/samba/docs/$file $nextfile samba.man.doc\n";
131 print IDB "f 0644 root sys usr/samba/docs/$file $nextfile samba.man.doc\n";
135 print IDB "f 0755 root sys usr/samba/inetd.sh packaging/SGI/inetd.sh samba.sw.base\n";
136 print IDB "d 0755 root sys usr/samba/lib/ packaging/SGI samba.sw.base\n";
138 print IDB "d 0755 root sys usr/samba/lib/codepages packaging/SGI samba.sw.base\n";
140 $nextpage = shift @codepage;
141 print IDB "f 0644 root sys usr/samba/lib/codepages/codepage.$nextpage packaging/SGI/codepages/codepage.$nextpage samba.sw.base\n";
144 print IDB "f 0644 root sys usr/samba/lib/smb.conf packaging/SGI/smb.conf samba.sw.base config(update)\n";
145 print IDB "f 0755 root sys usr/samba/mkprintcap.sh packaging/SGI/mkprintcap.sh samba.sw.base\n";
147 print IDB "d 0644 root sys usr/samba/private/ packaging/SGI samba.sw.base\n";
148 print IDB "f 0600 root sys usr/samba/private/smbpasswd packaging/SGI/smbpasswd samba.sw.base config(update)\n";
149 print IDB "d 0755 root sys usr/samba/src/ packaging/SGI samba.src.samba\n";
150 @sorted = sort(@allfiles);
152 $nextfile = shift @sorted;
153 ($file = $nextfile) =~ s/^.*\///;
154 next if grep(/packaging\/SGI/& (/Makefile/ | /samba\.spec/ | /samba\.idb/),$nextfile);
155 next if grep(/source/,$nextfile) && ($ignores{$file});
156 next if ($nextfile eq "CVS");
157 if (grep(/\/$/,$nextfile)) {
158 print IDB "d 0755 root sys usr/samba/src/$nextfile $nextfile samba.src.samba\n";
161 if (grep((/\.sh$/ | /\.pl$/ | /mkman$/),$nextfile)) {
162 print IDB "f 0755 root sys usr/samba/src/$nextfile $nextfile samba.src.samba\n";
165 print IDB "f 0644 root sys usr/samba/src/$nextfile $nextfile samba.src.samba\n";
170 print IDB "f 0755 root sys usr/samba/startswat.sh packaging/SGI/startswat.sh samba.sw.base\n";
171 print IDB "d 0755 root sys usr/samba/swat/ packaging/SGI/swat samba.sw.base\n";
173 $nextfile = shift @swatfiles;
174 ($file = $nextfile) =~ s/^packaging\/SGI\/swat\///;
176 if (grep(/\/$/,$file)) {
177 print IDB "d 0755 root sys usr/samba/swat/$file packaging/SGI/swat/$file samba.sw.base\n";
180 print IDB "f 0444 root sys usr/samba/swat/$file packaging/SGI/swat/$file samba.sw.base\n";
184 print IDB "d 0755 root sys usr/samba/var/ packaging/SGI samba.sw.base\n";
185 print IDB "d 0755 root sys usr/samba/var/locks/ packaging/SGI samba.sw.base\n";
187 print IDB "d 0755 root sys usr/share/catman/u_man/ packaging/SGI samba.man.manpages\n";
190 $nextfile = shift @catman;
191 ($file = $nextfile) =~ s/^packaging\/SGI\/catman\///;
192 ($dirnum = $file) =~ s/^[\D]*//;
194 if ($dirnum ne $olddirnum) {
195 print IDB "d 0755 root sys usr/share/catman/u_man/cat$dirnum packaging/SGI samba.man.manpages\n";
196 $olddirnum = $dirnum;
198 print IDB "f 0664 root sys usr/share/catman/u_man/cat$dirnum/$file $nextfile samba.man.manpages\n";
202 print "\n\nsamba.idb file has been created\n";
205 local($dir, $nlink) = @_;
206 local($dev,$ino,$mode,$subcount);
208 ($dev,$ino,$mode,$nlink) = stat('.') unless $nlink;
210 opendir(DIR,'.') || die "Can't open $dir";
211 local(@filenames) = sort readdir(DIR);
214 if ($nlink ==2) { # This dir has no subdirectories.
218 $this = substr($dir,2)."/$_";
219 push(@allfiles,$this);
223 $subcount = $nlink -2;
228 ($dev,$ino,$mode,$nlink) = lstat($_);
230 $this = substr($name,2);
232 push(@allfiles,$this);
233 next if $subcount == 0; # seen all the subdirs?
237 chdir $_ || die "Can't cd to $name";
238 &dodir($name,$nlink);
246 ($f0,$f1) = split(/\//,$a,2);
247 ($f0,$f2) = split(/\//,$b,2);
252 ($f1 = $a) =~ s/^.*\///;
253 ($f2 = $b) =~ s/^.*\///;
254 ($dir1 = $a) =~ s/^[\D]*//;
255 ($dir2 = $b) =~ s/^[\D]*//;
256 if (!($dir1 <=> $dir2)) {