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";
18 # We don't want the files listed in .cvsignore in the source/include tree
19 open(IGNORES,"../../source/include/.cvsignore") || die "Unable to open include/.cvsignore file\n";
26 # get the names of all the binary files to be installed
27 open(MAKEFILE,"../../source/Makefile") || die "Unable to open Makefile\n";
28 @makefile = <MAKEFILE>;
29 @sprogs = grep(/^SPROGS /,@makefile);
30 @progs1 = grep(/^PROGS1 /,@makefile);
31 @progs2 = grep(/^PROGS2 /,@makefile);
32 @mprogs = grep(/^MPROGS /,@makefile);
33 @progs = grep(/^PROGS /,@makefile);
34 @scripts = grep(/^SCRIPTS /,@makefile);
35 @codepage = grep(/^CODEPAGELIST/,@makefile);
39 @sprogs[0] =~ s/^.*\=//;
40 @sprogs = split(' ',@sprogs[0]);
43 @progs[0] =~ s/^.*\=//;
44 @progs[0] =~ s/\$\(\S+\)\s//g;
45 @progs = split(' ',@progs[0]);
48 @mprogs[0] =~ s/^.*\=//;
49 @mprogs = split(' ',@mprogs[0]);
52 @progs1[0] =~ s/^.*\=//;
53 @progs1 = split(' ',@progs1[0]);
56 @progs2[0] =~ s/^.*\=//;
57 @progs2 = split(' ',@progs2[0]);
60 @scripts[0] =~ s/^.*\=//;
61 @scripts[0] =~ s/\$\(srcdir\)\///g;
62 @scripts = split(' ',@scripts[0]);
65 @codepage[0] =~ s/^.*\=//;
67 # if we have codepages we need to create them for the package
68 system("chmod +x ./script/installcp.sh");
69 system("./script/installcp.sh . . ../packaging/SGI/codepages ./bin @codepage[0]");
71 @codepage = sort split(' ',@codepage[0]);
73 # install the swat files
75 system("chmod +x ./script/installswat.sh");
76 system("./script/installswat.sh ../packaging/SGI/swat ./");
77 system("cp ../swat/README ../packaging/SGI/swat");
80 # add my local files to the list of binaries to install
81 @bins = sort byfilename (@sprogs,@progs,@progs1,@progs2,@mprogs,@scripts,("/findsmb","/sambalp","/smbprint"));
83 # get a complete list of all files in the tree
88 # the files installed in docs include all the original files in docs plus all
89 # the "*.doc" files from the source tree
90 @docs = sort byfilename grep (!/^docs\/$/ & (/^source\/.*\.doc$/ | /^docs\//),@allfiles);
92 @swatfiles = sort grep(/^packaging\/SGI\/swat/, @allfiles);
93 @catman = sort grep(/^packaging\/SGI\/catman/ & !/\/$/, @allfiles);
94 @catman = sort bydirnum @catman;
96 # strip out all the generated directories and the "*.o" files from the source
98 @allfiles = grep(!/^.*\.o$/ & !/^.*\.po$/ & !/^.*\.po32$/ & !/^source\/bin/ & !/^packaging\/SGI\/bins/ & !/^packaging\/SGI\/catman/ & !/^packaging\/SGI\/html/ & !/^packaging\/SGI\/codepages/ & !/^packaging\/SGI\/swat/, @allfiles);
100 open(IDB,">samba.idb") || die "Unable to open samba.idb for output\n";
102 print IDB "f 0644 root sys etc/config/samba packaging/SGI/samba.config samba.sw.base config(update)\n";
103 print IDB "f 0755 root sys etc/init.d/samba packaging/SGI/samba.rc samba.sw.base\n";
104 print IDB "l 0000 root sys etc/rc0.d/K39samba packaging/SGI samba.sw.base symval(../init.d/samba)\n";
105 print IDB "l 0000 root sys etc/rc2.d/S81samba packaging/SGI samba.sw.base symval(../init.d/samba)\n";
107 @copyfile = grep (/^COPY/,@allfiles);
108 print IDB "d 0755 root sys usr/relnotes/samba packaging/SGI samba.man.relnotes\n";
109 print IDB "f 0644 root sys usr/relnotes/samba/@copyfile[0] @copyfile[0] samba.man.relnotes\n";
110 print IDB "f 0644 root sys usr/relnotes/samba/legal_notice.html packaging/SGI/legal_notice.html samba.man.relnotes\n";
111 print IDB "f 0644 root sys usr/relnotes/samba/samba-relnotes.html packaging/SGI/relnotes.html samba.man.relnotes\n";
113 print IDB "d 0755 root sys usr/samba packaging/SGI samba.sw.base\n";
114 print IDB "f 0444 root sys usr/samba/README packaging/SGI/README samba.sw.base\n";
116 print IDB "d 0755 root sys usr/samba/bin packaging/SGI samba.sw.base\n";
118 $nextfile = shift @bins;
119 ($filename = $nextfile) =~ s/^.*\///;;
121 if (index($nextfile,'$')) {
122 if ($filename eq "smbpasswd") {
123 print IDB "f 0755 root sys usr/samba/bin/$filename source/$nextfile samba.sw.base nostrip\n";
125 elsif ($filename eq "findsmb") {
126 print IDB "f 0755 root sys usr/samba/bin/$filename packaging/SGI/$filename samba.sw.base\n";
128 elsif ($filename eq "swat") {
129 print IDB "f 4755 root sys usr/samba/bin/$filename source/$nextfile samba.sw.base nostrip preop(\"chroot \$rbase /etc/init.d/samba stop\") exitop(\"chroot \$rbase /usr/samba/scripts/startswat.sh\") removeop(\"chroot \$rbase /sbin/cp /etc/inetd.conf /etc/inetd.conf.O ; chroot \$rbase /sbin/sed -e '/^swat/D' -e '/^#SWAT/D' /etc/inetd.conf.O >/etc/inetd.conf; /etc/killall -HUP inetd || true\")\n";
131 elsif ($filename eq "sambalp") {
132 print IDB "f 0755 root sys usr/samba/bin/$filename packaging/SGI/$filename samba.sw.base nostrip\n";
134 elsif ($filename eq "smbprint") {
135 print IDB "f 0755 root sys usr/samba/bin/$filename packaging/SGI/$filename samba.sw.base\n";
138 print IDB "f 0755 root sys usr/samba/bin/$filename source/$nextfile samba.sw.base nostrip\n";
143 print IDB "d 0755 root sys usr/samba/docs docs samba.man.doc\n";
145 $nextfile = shift @docs;
146 next if ($nextfile eq "CVS");
147 ($junk,$file) = split(/\//,$nextfile,2);
148 if (grep(/\/$/,$nextfile)) {
150 $nextfile =~ s/\/$//;
151 print IDB "d 0755 root sys usr/samba/docs/$file $nextfile samba.man.doc\n";
154 print IDB "f 0644 root sys usr/samba/docs/$file $nextfile samba.man.doc\n";
158 print IDB "d 0755 root sys usr/samba/lib packaging/SGI samba.sw.base\n";
160 print IDB "d 0755 root sys usr/samba/lib/codepages packaging/SGI samba.sw.base\n";
162 $nextpage = shift @codepage;
163 print IDB "f 0644 root sys usr/samba/lib/codepages/codepage.$nextpage packaging/SGI/codepages/codepage.$nextpage samba.sw.base\n";
166 print IDB "f 0644 root sys usr/samba/lib/smb.conf packaging/SGI/smb.conf samba.sw.base config(suggest)\n";
168 print IDB "d 0644 root sys usr/samba/private packaging/SGI samba.sw.base\n";
169 print IDB "f 0600 root sys usr/samba/private/smbpasswd packaging/SGI/smbpasswd samba.sw.base config(suggest)\n";
171 print IDB "d 0755 root sys usr/samba/scripts packaging/SGI samba.src.samba\n";
172 print IDB "f 0755 root sys usr/samba/scripts/inetd.sh packaging/SGI/inetd.sh samba.sw.base\n";
173 print IDB "f 0755 root sys usr/samba/scripts/inst.msg packaging/SGI/inst.msg samba.sw.base exitop(\"chroot \$rbase /usr/samba/scripts/inst.msg\")\n";
174 print IDB "f 0755 root sys usr/samba/scripts/mkprintcap.sh packaging/SGI/mkprintcap.sh samba.sw.base\n";
175 print IDB "f 0755 root sys usr/samba/scripts/removeswat.sh packaging/SGI/removeswat.sh samba.sw.base\n";
176 print IDB "f 0755 root sys usr/samba/scripts/startswat.sh packaging/SGI/startswat.sh samba.sw.base\n";
178 print IDB "d 0755 root sys usr/samba/src packaging/SGI samba.src.samba\n";
179 @sorted = sort(@allfiles);
181 $nextfile = shift @sorted;
182 ($file = $nextfile) =~ s/^.*\///;
183 next if grep(/packaging\/SGI/& (/Makefile/ | /samba\.spec/ | /samba\.idb/),$nextfile);
184 next if grep(/source/,$nextfile) && ($ignores{$file});
185 next if ($nextfile eq "CVS");
186 if (grep(/\/$/,$nextfile)) {
187 $nextfile =~ s/\/$//;
188 print IDB "d 0755 root sys usr/samba/src/$nextfile $nextfile samba.src.samba\n";
191 if (grep((/\.sh$/ | /configure$/ | /configure\.developer/ | /config\.guess/ | /config\.sub/ | /\.pl$/ | /mkman$/),$nextfile)) {
192 print IDB "f 0755 root sys usr/samba/src/$nextfile $nextfile samba.src.samba\n";
195 print IDB "f 0644 root sys usr/samba/src/$nextfile $nextfile samba.src.samba\n";
200 print IDB "d 0755 root sys usr/samba/swat packaging/SGI/swat samba.sw.base\n";
202 $nextfile = shift @swatfiles;
203 ($file = $nextfile) =~ s/^packaging\/SGI\/swat\///;
205 if (grep(/\/$/,$file)) {
207 print IDB "d 0755 root sys usr/samba/swat/$file packaging/SGI/swat/$file samba.sw.base\n";
210 print IDB "f 0444 root sys usr/samba/swat/$file packaging/SGI/swat/$file samba.sw.base\n";
214 print IDB "d 0755 root sys usr/samba/var packaging/SGI samba.sw.base\n";
215 print IDB "d 0755 root sys usr/samba/var/locks packaging/SGI samba.sw.base\n";
216 print IDB "f 0644 root sys usr/samba/var/locks/STATUS..LCK packaging/SGI/STATUS..LCK samba.sw.base\n";
218 print IDB "d 0755 root sys usr/share/catman/u_man packaging/SGI samba.man.manpages\n";
221 $nextfile = shift @catman;
222 ($file = $nextfile) =~ s/^packaging\/SGI\/catman\///;
223 ($dirnum = $file) =~ s/^[\D]*//;
225 if ($dirnum ne $olddirnum) {
226 print IDB "d 0755 root sys usr/share/catman/u_man/cat$dirnum packaging/SGI samba.man.manpages\n";
227 $olddirnum = $dirnum;
229 print IDB "f 0664 root sys usr/share/catman/u_man/cat$dirnum/$file $nextfile samba.man.manpages\n";
233 print "\n\nsamba.idb file has been created\n";
236 local($dir, $nlink) = @_;
237 local($dev,$ino,$mode,$subcount);
239 ($dev,$ino,$mode,$nlink) = stat('.') unless $nlink;
241 opendir(DIR,'.') || die "Can't open $dir";
242 local(@filenames) = sort readdir(DIR);
245 if ($nlink ==2) { # This dir has no subdirectories.
249 $this = substr($dir,2)."/$_";
250 push(@allfiles,$this);
254 $subcount = $nlink -2;
259 ($dev,$ino,$mode,$nlink) = lstat($_);
261 $this = substr($name,2);
263 push(@allfiles,$this);
264 next if $subcount == 0; # seen all the subdirs?
268 chdir $_ || die "Can't cd to $name";
269 &dodir($name,$nlink);
277 ($f0,$f1) = split(/\//,$a,2);
278 ($f0,$f2) = split(/\//,$b,2);
283 ($f1 = $a) =~ s/^.*\///;
284 ($f2 = $b) =~ s/^.*\///;
285 ($dir1 = $a) =~ s/^[\D]*//;
286 ($dir2 = $b) =~ s/^[\D]*//;
287 if (!($dir1 <=> $dir2)) {