This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[kai/samba.git] / packaging / SGI / idb.pl
1 #!/usr/bin/perl
2 require "pwd.pl" || die "Required pwd.pl not found";
3
4 # This perl script automatically generates the idb file
5
6 $PKG = 'samba';
7 $SRCDIR = '../..';
8 $SRCPFX = '.';
9
10 &initpwd;
11 $curdir = $ENV{"PWD"};
12
13 if ($PKG eq "samba_irix") {
14   open(BOOKS,"IDB.books") || die "Unable to open IDB.books file\n";
15   @books = sort idbsort <BOOKS>;
16   close BOOKS;
17 }
18
19 # We don't want the files listed in .cvsignore in the source tree
20 open(IGNORES,"$SRCDIR/source/.cvsignore") || die "Unable to open .cvsignore file\n";
21 while (<IGNORES>) {
22   chop;
23   next if /cvs\.log/;
24   $ignores{$_}++;
25 }
26 close IGNORES;
27
28 # We don't want the files listed in .cvsignore in the source/include tree
29 open(IGNORES,"$SRCDIR/source/include/.cvsignore") || die "Unable to open include/.cvsignore file\n";
30 while (<IGNORES>) {
31   chop;
32   $ignores{$_}++;
33 }
34 close IGNORES;
35
36 # get the names of all the binary files to be installed
37 open(MAKEFILE,"$SRCDIR/source/Makefile") || die "Unable to open Makefile\n";
38 while (not eof(MAKEFILE)) {
39   $_ = <MAKEFILE>;
40   chomp;
41   last if /^# object file lists/ ;
42   if (/^EXEEXT/) {
43     /^.*=(.*)/;
44     $EXEEXT = $1;
45   }
46   if (/^srcdir/) {
47     /^.*=(.*)/;
48     $srcdir = $1;
49   }
50   if (/^builddir/) {
51     /^.*=(.*)/;
52     $builddir = $1;
53   }
54   if (/^SBIN_PROGS/) { @sbinprogs = get_line($_); }
55   if (/^BIN_PROGS1/) { @binprogs1 = get_line($_); }
56   if (/^BIN_PROGS2/) { @binprogs2 = get_line($_); }
57   if (/^BIN_PROGS3/) { @binprogs3 = get_line($_); }
58   if (/^BIN_PROGS/) { @binprogs = get_line($_); }
59   if (/^SCRIPTS/) { @scripts = get_line($_); }
60   if (/^TORTURE_PROGS/) { @tortureprogs = get_line($_); }
61   if (/^SHLIBS/) { @shlibs = get_line($_); }
62 }
63 close MAKEFILE;
64
65 # add my local files to the list of binaries to install
66 @bins = sort byfilename (@sbinprogs,@binprogs,@binprogs1,@binprogs2,@binprogs3,@scripts,("sambalp","smbprint"));
67
68 @nsswitch = sort byfilename (@shlibs);
69
70 # install the swat files
71 chdir "$SRCDIR/source";
72 system("chmod +x ./script/installswat.sh");
73 system("./script/installswat.sh  ../packaging/SGI/swat ./ ../packaging/SGI/swat/using_samba");
74 system("cp -f ../swat/README ../packaging/SGI/swat");
75 chdir $curdir;
76
77 # get a complete list of all files in the tree
78 chdir "$SRCDIR/";
79 &dodir('.');
80 chdir $curdir;
81
82 # the files installed in docs include all the original files in docs plus all
83 # the "*.doc" files from the source tree
84 @docs = sort bynextdir grep (!/CVS/ & (/^source\/.*\.doc$/ | /^docs\/\w/),@allfiles);
85 @docs = grep(!/htmldocs/ & !/manpages/, @docs);
86 @docs = grep(!/docbook/, @docs);
87
88 @libfiles = sort byfilename (grep (/^source\/codepages\/\w/,@allfiles),("packaging/SGI/smb.conf","source/bin/libsmbclient.a","source/bin/libsmbclient.so"));
89
90 @swatfiles = sort grep(/^packaging\/SGI\/swat/, @allfiles);
91 @catman = sort grep(/^packaging\/SGI\/catman/ & !/\/$/, @allfiles);
92 @catman = sort bydirnum @catman;
93
94 # strip out all the generated directories and the "*.o" files from the source
95 # release
96 @allfiles = grep(!/^.*\.o$/ & !/^.*\.po$/ & !/^.*\.po32$/ & !/^.*\.so$/ & !/^source\/bin/ & !/^packaging\/SGI\/bins/ & !/^packaging\/SGI\/catman/ & !/^packaging\/SGI\/html/ & !/^packaging\/SGI\/codepages/ & !/^packaging\/SGI\/swat/, @allfiles);
97
98 open(IDB,"> $curdir/$PKG.idb") || die "Unable to open $PKG.idb for output\n";
99
100 print IDB "f 0644 root sys etc/config/samba $SRCPFX/packaging/SGI/samba.config $PKG.sw.base config(update)\n";
101 print IDB "f 0644 root sys etc/config/winbind $SRCPFX/packaging/SGI/winbindd.config $PKG.sw.base config(update)\n";
102 print IDB "f 0755 root sys etc/init.d/samba $SRCPFX/packaging/SGI/samba.rc $PKG.sw.base\n";
103 print IDB "f 0755 root sys etc/init.d/winbind $SRCPFX/packaging/SGI/winbindd.rc $PKG.sw.base\n";
104 print IDB "l 0000 root sys etc/rc0.d/K36winbind $SRCPFX/packaging/SGI $PKG.sw.base symval(../init.d/winbind)\n";
105 print IDB "l 0000 root sys etc/rc0.d/K37samba $SRCPFX/packaging/SGI $PKG.sw.base symval(../init.d/samba)\n";
106 print IDB "l 0000 root sys etc/rc2.d/S81samba $SRCPFX/packaging/SGI $PKG.sw.base symval(../init.d/samba)\n";
107 print IDB "l 0000 root sys etc/rc2.d/S82winbind $SRCPFX/packaging/SGI $PKG.sw.base symval(../init.d/winbind)\n";
108
109 if ($PKG eq "samba_irix") {
110   print IDB "d 0755 root sys usr/relnotes/samba_irix $SRCPFX/packaging/SGI $PKG.man.relnotes\n";
111   print IDB "f 0644 root sys usr/relnotes/samba_irix/TC relnotes/TC $PKG.man.relnotes\n";
112   print IDB "f 0644 root sys usr/relnotes/samba_irix/ch1.z relnotes/ch1.z $PKG.man.relnotes\n";
113   print IDB "f 0644 root sys usr/relnotes/samba_irix/ch2.z relnotes/ch2.z $PKG.man.relnotes\n";
114   print IDB "f 0644 root sys usr/relnotes/samba_irix/ch3.z relnotes/ch3.z $PKG.man.relnotes\n";
115 }
116 else {
117   @copyfile = grep (/^COPY/,@allfiles);
118   print IDB "d 0755 root sys usr/relnotes/samba $SRCPFX/packaging/SGI $PKG.man.relnotes\n";
119   print IDB "f 0644 root sys usr/relnotes/samba/@copyfile[0] $SRCPFX/@copyfile[0] $PKG.man.relnotes\n";
120   print IDB "f 0644 root sys usr/relnotes/samba/legal_notice.html $SRCPFX/packaging/SGI/legal_notice.html $PKG.man.relnotes\n";
121   print IDB "f 0644 root sys usr/relnotes/samba/samba-relnotes.html $SRCPFX/packaging/SGI/relnotes.html $PKG.man.relnotes\n";
122 }
123
124 print IDB "d 0755 root sys usr/samba $SRCPFX/packaging/SGI $PKG.sw.base\n";
125
126 print IDB "d 0755 root sys usr/samba/bin $SRCPFX/packaging/SGI $PKG.sw.base\n";
127 while(@bins) {
128   $nextfile = shift @bins;
129   ($filename = $nextfile) =~ s/^.*\///;;
130
131   if (index($nextfile,'$')) {
132     if ($filename eq "smbpasswd") {
133       print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
134     }
135     elsif ($filename eq "findsmb") {
136       print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/packaging/SGI/$filename $PKG.sw.base\n";
137     }
138     elsif ($filename eq "swat") {
139       print IDB "f 4755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base 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";
140     }
141     elsif ($filename eq "sambalp") {
142       print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/packaging/SGI/$filename $PKG.sw.base \n";
143     }
144     elsif ($filename eq "smbprint") {
145       print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/packaging/SGI/$filename $PKG.sw.base\n";
146     }
147     elsif ($filename eq "smbd") {
148       print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
149       if (-e "$SRCDIR/source/$nextfile.noquota") {
150         print IDB "f 0755 root sys usr/samba/bin/$filename.noquota $SRCPFX/source/$nextfile.noquota $PKG.sw.base \n";
151       }
152       if (-e "$SRCDIR/source/$nextfile.profile") {
153         print IDB "f 0755 root sys usr/samba/bin/$filename.profile $SRCPFX/source/$nextfile.profile $PKG.sw.base \n";
154       }
155     }
156     elsif ($filename eq "nmbd") {
157       print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
158       if (-e "$SRCDIR/source/$nextfile.profile") {
159         print IDB "f 0755 root sys usr/samba/bin/$filename.profile $SRCPFX/source/$nextfile.profile $PKG.sw.base \n";
160       }
161     }
162     else {
163       print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
164     }
165   }
166 }
167
168 print IDB "d 0755 root sys usr/samba/docs $SRCPFX/docs $PKG.man.doc\n";
169 while (@docs) {
170   $nextfile = shift @docs;
171   ($junk,$file) = split(/\//,$nextfile,2);
172   if (grep(/\/$/,$nextfile)) {
173     $file =~ s/\/$//;
174     $nextfile =~ s/\/$//;
175     print IDB "d 0755 root sys usr/samba/docs/$file $SRCPFX/$nextfile $PKG.man.doc\n";
176   }
177   else {
178     print IDB "f 0644 root sys usr/samba/docs/$file $SRCPFX/$nextfile $PKG.man.doc\n";
179   }
180 }
181
182 print IDB "d 0755 root sys usr/samba/include $SRCPFX/packaging/SGI $PKG.sw.base\n";
183 print IDB "f 0644 root sys usr/samba/include/libsmbclient.h $SRCPFX/source/include/libsmbclient.h $PKG.sw.base\n";
184
185 print IDB "d 0755 root sys usr/samba/lib $SRCPFX/packaging/SGI $PKG.sw.base\n";
186 while (@libfiles) {
187   $nextfile = shift @libfiles;
188   ($file = $nextfile) =~ s/.*\///;
189   if ($file eq "smb.conf") {
190     print IDB "f 0644 root sys usr/samba/lib/$file $SRCPFX/$nextfile $PKG.sw.base config(suggest)\n";
191   } else {
192     print IDB "f 0644 root sys usr/samba/lib/$file $SRCPFX/$nextfile $PKG.sw.base nostrip \n";
193   }
194 }
195
196 print IDB "d 0755 lp sys usr/samba/printer $SRCPFX/packaging/SGI $PKG.sw.base\n";
197 print IDB "d 0755 lp sys usr/samba/printer/W32ALPHA $SRCPFX/packaging/SGI $PKG.sw.base\n";
198 print IDB "d 0755 lp sys usr/samba/printer/W32MIPS $SRCPFX/packaging/SGI $PKG.sw.base\n";
199 print IDB "d 0755 lp sys usr/samba/printer/W32PPC $SRCPFX/packaging/SGI $PKG.sw.base\n";
200 print IDB "d 0755 lp sys usr/samba/printer/W32X86 $SRCPFX/packaging/SGI $PKG.sw.base\n";
201 print IDB "d 0755 lp sys usr/samba/printer/WIN40 $SRCPFX/packaging/SGI $PKG.sw.base\n";
202
203 print IDB "d 0644 root sys usr/samba/private $SRCPFX/packaging/SGI $PKG.sw.base\n";
204 print IDB "f 0600 root sys usr/samba/private/smbpasswd $SRCPFX/packaging/SGI/smbpasswd $PKG.sw.base config(suggest)\n";
205
206 print IDB "d 0755 root sys usr/samba/scripts $SRCPFX/packaging/SGI $PKG.src.samba\n";
207 print IDB "f 0755 root sys usr/samba/scripts/inetd.sh $SRCPFX/packaging/SGI/inetd.sh $PKG.sw.base\n";
208 print IDB "f 0755 root sys usr/samba/scripts/inst.msg $SRCPFX/packaging/SGI/inst.msg $PKG.sw.base exitop(\"chroot \$rbase /usr/samba/scripts/inst.msg\")\n";
209 print IDB "f 0755 root sys usr/samba/scripts/mkprintcap.sh $SRCPFX/packaging/SGI/mkprintcap.sh $PKG.sw.base\n";
210 print IDB "f 0755 root sys usr/samba/scripts/removeswat.sh $SRCPFX/packaging/SGI/removeswat.sh $PKG.sw.base\n";
211 print IDB "f 0755 root sys usr/samba/scripts/startswat.sh $SRCPFX/packaging/SGI/startswat.sh $PKG.sw.base\n";
212
213 print IDB "d 0755 root sys usr/samba/src $SRCPFX/packaging/SGI $PKG.src.samba\n";
214 @sorted = sort(@allfiles);
215 while (@sorted) {
216   $nextfile = shift @sorted;
217   ($file = $nextfile) =~ s/^.*\///;
218   next if grep(/packaging\/SGI/& (/Makefile/ | /samba\.spec/ | /samba\.idb/),$nextfile);
219   next if grep(/source/,$nextfile) && ($ignores{$file});
220   next if ($nextfile eq "CVS");
221   if (grep(/\/$/,$nextfile)) {
222     $nextfile =~ s/\/$//;
223     print IDB "d 0755 root sys usr/samba/src/$nextfile $SRCPFX/$nextfile $PKG.src.samba\n";
224   }
225   else {
226     if (grep((/\.sh$/ | /configure$/ | /configure\.developer/ | /config\.guess/ | /config\.sub/ | /\.pl$/ | /mkman$/ | /pcp\/Install/ | /pcp\/Remove/),$nextfile)) {
227         print IDB "f 0755 root sys usr/samba/src/$nextfile $SRCPFX/$nextfile $PKG.src.samba\n";
228     }
229     else {
230         print IDB "f 0644 root sys usr/samba/src/$nextfile $SRCPFX/$nextfile $PKG.src.samba\n";
231     }
232   }
233 }
234
235 print IDB "d 0755 root sys usr/samba/swat $SRCPFX/packaging/SGI/swat $PKG.sw.base\n";
236 while (@swatfiles) {
237   $nextfile = shift @swatfiles;
238   ($file = $nextfile) =~ s/^packaging\/SGI\/swat\///;
239   next if !$file;
240   if (grep(/\/$/,$file)) {
241     $file =~ s/\/$//;
242     print IDB "d 0755 root sys usr/samba/swat/$file $SRCPFX/packaging/SGI/swat/$file $PKG.sw.base\n";
243   }
244   else {
245     print IDB "f 0444 root sys usr/samba/swat/$file $SRCPFX/packaging/SGI/swat/$file $PKG.sw.base\n";
246   }
247 }
248
249 print IDB "d 0755 root sys usr/samba/var $SRCPFX/packaging/SGI $PKG.sw.base\n";
250 print IDB "d 0755 root sys usr/samba/var/locks $SRCPFX/packaging/SGI $PKG.sw.base\n";
251
252 if ($PKG eq "samba_irix") {
253   while(@books) {
254     $nextfile = shift @books;
255     print IDB $nextfile;
256   }
257 }
258
259 print IDB "d 0755 root sys usr/share/catman/u_man $SRCPFX/packaging/SGI $PKG.man.manpages\n";
260 $olddirnum = "0";
261 while (@catman) {
262   $nextfile = shift @catman;
263   ($file = $nextfile) =~ s/^packaging\/SGI\/catman\///;
264   ($dirnum = $file) =~ s/^[\D]*//;
265   $dirnum =~ s/\.z//;
266   if ($dirnum ne $olddirnum) {
267     print IDB "d 0755 root sys usr/share/catman/u_man/cat$dirnum $SRCPFX/packaging/SGI $PKG.man.manpages\n";
268     $olddirnum = $dirnum;
269   }
270   print IDB "f 0664 root sys usr/share/catman/u_man/cat$dirnum/$file $SRCPFX/$nextfile $PKG.man.manpages\n";
271 }
272
273 if (@nsswitch) {
274   print IDB "d 0755 root sys var/ns/lib $SRCPFX/packaging/SGI $PKG.sw.base\n";
275   while(@nsswitch) {
276     $nextfile = shift @nsswitch;
277     next if $nextfile eq 'libsmbclient';
278     ($filename = $nextfile) =~ s/^.*\///;
279     $filename =~ s/libnss/libns/;
280     print IDB "f 0644 root sys var/ns/lib/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
281   }
282 }
283
284 print IDB "d 01777 lp sys var/spool/samba $SRCPFX/packaging/SGI $PKG.sw.base\n";
285
286 close IDB;
287 print "\n\n$PKG.idb file has been created\n";
288
289 sub dodir {
290     local($dir, $nlink) = @_;
291     local($dev,$ino,$mode,$subcount);
292
293     ($dev,$ino,$mode,$nlink) = stat('.') unless $nlink;
294
295     opendir(DIR,'.') || die "Can't open current directory";
296     local(@filenames) = sort readdir(DIR);
297     closedir(DIR);
298
299     if ($nlink ==2) {           # This dir has no subdirectories.
300         for (@filenames) {
301             next if $_ eq '.';
302             next if $_ eq '..';
303             $this =  substr($dir,2)."/$_";
304             push(@allfiles,$this);
305         }
306     }
307     else {
308         $subcount = $nlink -2;
309         for (@filenames) {
310             next if $_ eq '.';
311             next if $_ eq '..';
312             next if $_ eq 'CVS';
313             ($dev,$ino,$mode,$nlink) = lstat($_);
314             $name = "$dir/$_";
315             $this = substr($name,2);
316             $this .= '/' if -d;
317             push(@allfiles,$this);
318             next if $subcount == 0;             # seen all the subdirs?
319
320             next unless -d _;
321
322             chdir $_ || die "Can't cd to $name";
323             &dodir($name,$nlink);
324             chdir '..';
325             --$subcount;
326         }
327     }
328 }
329
330 sub bynextdir {
331   ($f0,$f1) = split(/\//,$a,2);
332   ($f0,$f2) = split(/\//,$b,2);
333   $f1 cmp $f2;
334 }
335
336 sub byfilename {
337   ($f0,$f1) = split(/.*\//,$a,2);
338   if ($f1 eq "") { $f1 = $f0 };
339   ($f0,$f2) = split(/.*\//,$b,2);
340   if ($f2 eq "") { $f2 = $f0 };
341   $f1 cmp $f2;
342 }
343
344 sub bydirnum {
345   ($f1 = $a) =~ s/^.*\///;
346   ($f2 = $b) =~ s/^.*\///;
347   ($dir1 = $a) =~ s/^[\D]*//;
348   ($dir2 = $b) =~ s/^[\D]*//;
349   if (!($dir1 <=> $dir2)) {
350     $f1 cmp $f2;
351   }
352   else {
353     $dir1 <=> $dir2;
354   }
355 }
356
357 sub idbsort {
358   ($f0,$f1,$f2,$f3) = split(/ /,$a,4);
359   ($f0,$f1,$f2,$f4) = split(/ /,$b,4);
360   $f3 cmp $f4;
361 }
362
363 sub get_line {
364   local ($line) = @_;
365
366   $line =~ s/^.*=//;
367   while (($cont = index($line,"\\")) > 0) {
368     $_ = <MAKEFILE>;
369     chomp;
370     s/^\s*/ /;
371     substr($line,$cont,1,$_);
372   }
373   $line =~ s/\$\(EXEEXT\)/$EXEEXT/g;
374   $line =~ s/\$\(srcdir\)/$srcdir/g;
375   $line =~ s/\$\(builddir\)/$builddir/g;
376   $line =~ s/\$\(\S*\)\s*//g;
377   $line =~ s/\s\s*/ /g;
378   @line = split(' ',$line);
379   return @line;
380 }
381