Fix for potential crash bug with bad fid.
[Samba/ekacnet.git] / packaging / SGI / idb.pl
blobba051495091e1ba48212c64877f28e4d06d8c792
1 #!/usr/bin/perl
2 require "pwd.pl" || die "Required pwd.pl not found";
4 # This perl script automatically generates the idb file
6 $PKG = 'samba';
7 $SRCDIR = '../..';
8 $SRCPFX = '.';
10 &initpwd;
11 $curdir = $ENV{"PWD"};
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;
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{$_}++;
26 close IGNORES;
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{$_}++;
34 close IGNORES;
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 @makefile = <MAKEFILE>;
39 @sprogs = grep(/^SPROGS /,@makefile);
40 @progs1 = grep(/^PROGS1 /,@makefile);
41 @progs2 = grep(/^PROGS2 /,@makefile);
42 @mprogs = grep(/^MPROGS /,@makefile);
43 @progs = grep(/^PROGS /,@makefile);
44 @scripts = grep(/^SCRIPTS /,@makefile);
45 @codepagelist = grep(/^CODEPAGELIST/,@makefile);
46 close MAKEFILE;
48 if (@sprogs) {
49 @sprogs[0] =~ s/^.*\=//;
50 @sprogs = split(' ',@sprogs[0]);
52 if (@progs) {
53 @progs[0] =~ s/^.*\=//;
54 @progs[0] =~ s/\$\(\S+\)\s//g;
55 @progs = split(' ',@progs[0]);
57 if (@mprogs) {
58 @mprogs[0] =~ s/^.*\=//;
59 @mprogs = split(' ',@mprogs[0]);
61 if (@progs1) {
62 @progs1[0] =~ s/^.*\=//;
63 @progs1 = split(' ',@progs1[0]);
65 if (@progs2) {
66 @progs2[0] =~ s/^.*\=//;
67 @progs2 = split(' ',@progs2[0]);
69 if (@scripts) {
70 @scripts[0] =~ s/^.*\=//;
71 @scripts[0] =~ s/\$\(srcdir\)\///g;
72 @scripts = split(' ',@scripts[0]);
75 # we need to create codepages for the package
76 @codepagelist[0] =~ s/^.*\=//;
77 chdir "$SRCDIR/source";
78 system("chmod +x ./script/installcp.sh");
79 system("./script/installcp.sh . . ../packaging/SGI/codepages ./bin @codepagelist[0]");
80 chdir $curdir;
81 opendir(DIR,"$SRCDIR/packaging/SGI/codepages") || die "Can't open codepages directory";
82 @codepage = sort readdir(DIR);
83 closedir(DIR);
85 # install the swat files
86 chdir "$SRCDIR/source";
87 system("chmod +x ./script/installswat.sh");
88 system("./script/installswat.sh ../packaging/SGI/swat ./ ../packaging/SGI/swat/using_samba");
89 system("cp -f ../swat/README ../packaging/SGI/swat");
90 chdir $curdir;
92 # add my local files to the list of binaries to install
93 @bins = sort byfilename (@sprogs,@progs,@progs1,@progs2,@mprogs,@scripts,("/findsmb","/sambalp","/smbprint"));
95 # get a complete list of all files in the tree
96 chdir "$SRCDIR/";
97 &dodir('.');
98 chdir $curdir;
100 # the files installed in docs include all the original files in docs plus all
101 # the "*.doc" files from the source tree
102 @docs = sort byfilename grep (!/^docs\/$/ & (/^source\/.*\.doc$/ | /^docs\//),@allfiles);
103 @docs = grep(!/htmldocs\/using_samba/, @docs);
104 @docs = grep(!/docbook/, @docs);
106 @swatfiles = sort grep(/^packaging\/SGI\/swat/, @allfiles);
107 @catman = sort grep(/^packaging\/SGI\/catman/ & !/\/$/, @allfiles);
108 @catman = sort bydirnum @catman;
110 # strip out all the generated directories and the "*.o" files from the source
111 # release
112 @allfiles = grep(!/^.*\.o$/ & !/^.*\.po$/ & !/^.*\.po32$/ & !/^source\/bin/ & !/^packaging\/SGI\/bins/ & !/^packaging\/SGI\/catman/ & !/^packaging\/SGI\/html/ & !/^packaging\/SGI\/codepages/ & !/^packaging\/SGI\/swat/, @allfiles);
114 open(IDB,"> $curdir/$PKG.idb") || die "Unable to open $PKG.idb for output\n";
116 print IDB "f 0644 root sys etc/config/samba $SRCPFX/packaging/SGI/samba.config $PKG.sw.base config(update)\n";
117 print IDB "f 0755 root sys etc/init.d/samba $SRCPFX/packaging/SGI/samba.rc $PKG.sw.base\n";
118 print IDB "l 0000 root sys etc/rc0.d/K39samba $SRCPFX/packaging/SGI $PKG.sw.base symval(../init.d/samba)\n";
119 print IDB "l 0000 root sys etc/rc2.d/S81samba $SRCPFX/packaging/SGI $PKG.sw.base symval(../init.d/samba)\n";
121 if ($PKG eq "samba_irix") {
122 print IDB "d 0755 root sys usr/relnotes/samba_irix $SRCPFX/packaging/SGI $PKG.man.relnotes\n";
123 print IDB "f 0644 root sys usr/relnotes/samba_irix/TC build/TC $PKG.man.relnotes\n";
124 print IDB "f 0644 root sys usr/relnotes/samba_irix/ch1.z build/ch1.z $PKG.man.relnotes\n";
125 print IDB "f 0644 root sys usr/relnotes/samba_irix/ch2.z build/ch2.z $PKG.man.relnotes\n";
126 print IDB "f 0644 root sys usr/relnotes/samba_irix/ch3.z build/ch3.z $PKG.man.relnotes\n";
128 else {
129 @copyfile = grep (/^COPY/,@allfiles);
130 print IDB "d 0755 root sys usr/relnotes/samba $SRCPFX/packaging/SGI $PKG.man.relnotes\n";
131 print IDB "f 0644 root sys usr/relnotes/samba/@copyfile[0] $SRCPFX/@copyfile[0] $PKG.man.relnotes\n";
132 print IDB "f 0644 root sys usr/relnotes/samba/legal_notice.html $SRCPFX/packaging/SGI/legal_notice.html $PKG.man.relnotes\n";
133 print IDB "f 0644 root sys usr/relnotes/samba/samba-relnotes.html $SRCPFX/packaging/SGI/relnotes.html $PKG.man.relnotes\n";
136 print IDB "d 0755 root sys usr/samba $SRCPFX/packaging/SGI $PKG.sw.base\n";
138 print IDB "d 0755 root sys usr/samba/bin $SRCPFX/packaging/SGI $PKG.sw.base\n";
139 while(@bins) {
140 $nextfile = shift @bins;
141 ($filename = $nextfile) =~ s/^.*\///;;
143 if (index($nextfile,'$')) {
144 if ($filename eq "smbpasswd") {
145 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
147 elsif ($filename eq "findsmb") {
148 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/packaging/SGI/$filename $PKG.sw.base\n";
150 elsif ($filename eq "swat") {
151 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";
153 elsif ($filename eq "sambalp") {
154 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/packaging/SGI/$filename $PKG.sw.base \n";
156 elsif ($filename eq "smbprint") {
157 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/packaging/SGI/$filename $PKG.sw.base\n";
159 else {
160 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
165 print IDB "d 0755 root sys usr/samba/docs $SRCPFX/docs $PKG.man.doc\n";
166 while (@docs) {
167 $nextfile = shift @docs;
168 next if ($nextfile eq "CVS");
169 ($junk,$file) = split(/\//,$nextfile,2);
170 if (grep(/\/$/,$nextfile)) {
171 $file =~ s/\/$//;
172 $nextfile =~ s/\/$//;
173 print IDB "d 0755 root sys usr/samba/docs/$file $SRCPFX/$nextfile $PKG.man.doc\n";
175 else {
176 print IDB "f 0644 root sys usr/samba/docs/$file $SRCPFX/$nextfile $PKG.man.doc\n";
180 print IDB "d 0755 root sys usr/samba/lib $SRCPFX/packaging/SGI $PKG.sw.base\n";
181 print IDB "d 0755 root sys usr/samba/lib/codepages $SRCPFX/packaging/SGI $PKG.sw.base\n";
182 while (@codepage) {
183 $nextpage = shift @codepage;
184 print IDB "f 0644 root sys usr/samba/lib/codepages/$nextpage $SRCPFX/packaging/SGI/codepages/$nextpage $PKG.sw.base nostrip \n";
186 print IDB "f 0644 root sys usr/samba/lib/smb.conf $SRCPFX/packaging/SGI/smb.conf $PKG.sw.base config(suggest)\n";
188 print IDB "d 0644 root sys usr/samba/private $SRCPFX/packaging/SGI $PKG.sw.base\n";
189 print IDB "f 0600 root sys usr/samba/private/smbpasswd $SRCPFX/packaging/SGI/smbpasswd $PKG.sw.base config(suggest)\n";
191 print IDB "d 0755 root sys usr/samba/scripts $SRCPFX/packaging/SGI $PKG.src.samba\n";
192 print IDB "f 0755 root sys usr/samba/scripts/inetd.sh $SRCPFX/packaging/SGI/inetd.sh $PKG.sw.base\n";
193 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";
194 print IDB "f 0755 root sys usr/samba/scripts/mkprintcap.sh $SRCPFX/packaging/SGI/mkprintcap.sh $PKG.sw.base\n";
195 print IDB "f 0755 root sys usr/samba/scripts/removeswat.sh $SRCPFX/packaging/SGI/removeswat.sh $PKG.sw.base\n";
196 print IDB "f 0755 root sys usr/samba/scripts/startswat.sh $SRCPFX/packaging/SGI/startswat.sh $PKG.sw.base\n";
198 print IDB "d 0755 root sys usr/samba/src $SRCPFX/packaging/SGI $PKG.src.samba\n";
199 @sorted = sort(@allfiles);
200 while (@sorted) {
201 $nextfile = shift @sorted;
202 ($file = $nextfile) =~ s/^.*\///;
203 next if grep(/packaging\/SGI/& (/Makefile/ | /samba\.spec/ | /samba\.idb/),$nextfile);
204 next if grep(/source/,$nextfile) && ($ignores{$file});
205 next if ($nextfile eq "CVS");
206 if (grep(/\/$/,$nextfile)) {
207 $nextfile =~ s/\/$//;
208 print IDB "d 0755 root sys usr/samba/src/$nextfile $SRCPFX/$nextfile $PKG.src.samba\n";
210 else {
211 if (grep((/\.sh$/ | /configure$/ | /configure\.developer/ | /config\.guess/ | /config\.sub/ | /\.pl$/ | /mkman$/ | /pcp\/Install/ | /pcp\/Remove/),$nextfile)) {
212 print IDB "f 0755 root sys usr/samba/src/$nextfile $SRCPFX/$nextfile $PKG.src.samba\n";
214 else {
215 print IDB "f 0644 root sys usr/samba/src/$nextfile $SRCPFX/$nextfile $PKG.src.samba\n";
220 print IDB "d 0755 root sys usr/samba/swat $SRCPFX/packaging/SGI/swat $PKG.sw.base\n";
221 while (@swatfiles) {
222 $nextfile = shift @swatfiles;
223 ($file = $nextfile) =~ s/^packaging\/SGI\/swat\///;
224 next if !$file;
225 if (grep(/\/$/,$file)) {
226 $file =~ s/\/$//;
227 print IDB "d 0755 root sys usr/samba/swat/$file $SRCPFX/packaging/SGI/swat/$file $PKG.sw.base\n";
229 else {
230 print IDB "f 0444 root sys usr/samba/swat/$file $SRCPFX/packaging/SGI/swat/$file $PKG.sw.base\n";
234 print IDB "d 0755 root sys usr/samba/var $SRCPFX/packaging/SGI $PKG.sw.base\n";
235 print IDB "d 0755 root sys usr/samba/var/locks $SRCPFX/packaging/SGI $PKG.sw.base\n";
237 if ($PKG eq "samba_irix") {
238 while(@books) {
239 $nextfile = shift @books;
240 print IDB $nextfile;
244 print IDB "d 0755 root sys usr/share/catman/u_man $SRCPFX/packaging/SGI $PKG.man.manpages\n";
245 $olddirnum = "0";
246 while (@catman) {
247 $nextfile = shift @catman;
248 ($file = $nextfile) =~ s/^packaging\/SGI\/catman\///;
249 ($dirnum = $file) =~ s/^[\D]*//;
250 $dirnum =~ s/\.z//;
251 if ($dirnum ne $olddirnum) {
252 print IDB "d 0755 root sys usr/share/catman/u_man/cat$dirnum $SRCPFX/packaging/SGI $PKG.man.manpages\n";
253 $olddirnum = $dirnum;
255 print IDB "f 0664 root sys usr/share/catman/u_man/cat$dirnum/$file $SRCPFX/$nextfile $PKG.man.manpages\n";
257 print IDB "d 01777 nobody nobody var/spool/samba $SRCPFX/packaging/SGI $PKG.sw.base\n";
259 close IDB;
260 print "\n\n$PKG.idb file has been created\n";
262 sub dodir {
263 local($dir, $nlink) = @_;
264 local($dev,$ino,$mode,$subcount);
266 ($dev,$ino,$mode,$nlink) = stat('.') unless $nlink;
268 opendir(DIR,'.') || die "Can't open current directory";
269 local(@filenames) = sort readdir(DIR);
270 closedir(DIR);
272 if ($nlink ==2) { # This dir has no subdirectories.
273 for (@filenames) {
274 next if $_ eq '.';
275 next if $_ eq '..';
276 $this = substr($dir,2)."/$_";
277 push(@allfiles,$this);
280 else {
281 $subcount = $nlink -2;
282 for (@filenames) {
283 next if $_ eq '.';
284 next if $_ eq '..';
285 next if $_ eq 'CVS';
286 ($dev,$ino,$mode,$nlink) = lstat($_);
287 $name = "$dir/$_";
288 $this = substr($name,2);
289 $this .= '/' if -d;
290 push(@allfiles,$this);
291 next if $subcount == 0; # seen all the subdirs?
293 next unless -d _;
295 chdir $_ || die "Can't cd to $name";
296 &dodir($name,$nlink);
297 chdir '..';
298 --$subcount;
303 sub byfilename {
304 ($f0,$f1) = split(/\//,$a,2);
305 ($f0,$f2) = split(/\//,$b,2);
306 $f1 cmp $f2;
309 sub bydirnum {
310 ($f1 = $a) =~ s/^.*\///;
311 ($f2 = $b) =~ s/^.*\///;
312 ($dir1 = $a) =~ s/^[\D]*//;
313 ($dir2 = $b) =~ s/^[\D]*//;
314 if (!($dir1 <=> $dir2)) {
315 $f1 cmp $f2;
317 else {
318 $dir1 <=> $dir2;
322 sub idbsort {
323 ($f0,$f1,$f2,$f3) = split(/ /,$a,4);
324 ($f0,$f1,$f2,$f4) = split(/ /,$b,4);
325 $f3 cmp $f4;