Makefile: reformat - break long target lines.
[Samba.git] / packaging / SGI / idb.pl
blob529695b14b2bb84879e268d6895b81360ad6c57f
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 while (not eof(MAKEFILE)) {
39 $_ = <MAKEFILE>;
40 chomp;
41 last if /^# object file lists/ ;
42 if (/^EXEEXT/) {
43 /^.*=(.*)/;
44 $EXEEXT = $1;
46 if (/^srcdir/) {
47 /^.*=(.*)/;
48 $srcdir = $1;
50 if (/^builddir/) {
51 /^.*=(.*)/;
52 $builddir = $1;
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($_); }
63 close MAKEFILE;
65 # add my local files to the list of binaries to install
66 @bins = sort byfilename (@sbinprogs,@binprogs,@binprogs1,@binprogs2,@binprogs3,@scripts,("sambalp","smbprint"));
68 @nsswitch = sort byfilename (@shlibs);
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;
77 # get a complete list of all files in the tree
78 chdir "$SRCDIR/";
79 &dodir('.');
80 chdir $curdir;
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);
88 @libfiles = sort byfilename (grep (/^source\/codepages\/\w/,@allfiles),("packaging/SGI/smb.conf","source/bin/libsmbclient.a","source/bin/libsmbclient.so"));
90 @swatfiles = sort grep(/^packaging\/SGI\/swat/, @allfiles);
91 @catman = sort grep(/^packaging\/SGI\/catman/ & !/\/$/, @allfiles);
92 @catman = sort bydirnum @catman;
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);
98 open(IDB,"> $curdir/$PKG.idb") || die "Unable to open $PKG.idb for output\n";
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";
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";
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";
124 print IDB "d 0755 root sys usr/samba $SRCPFX/packaging/SGI $PKG.sw.base\n";
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/^.*\///;;
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";
135 elsif ($filename eq "swat") {
136 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";
138 elsif ($filename eq "sambalp") {
139 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/packaging/SGI/$filename $PKG.sw.base \n";
141 elsif ($filename eq "smbprint") {
142 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/packaging/SGI/$filename $PKG.sw.base\n";
144 elsif ($filename eq "smbd") {
145 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
146 if (-e "$SRCDIR/source/$nextfile.noquota") {
147 print IDB "f 0755 root sys usr/samba/bin/$filename.noquota $SRCPFX/source/$nextfile.noquota $PKG.sw.base \n";
149 if (-e "$SRCDIR/source/$nextfile.profile") {
150 print IDB "f 0755 root sys usr/samba/bin/$filename.profile $SRCPFX/source/$nextfile.profile $PKG.sw.base \n";
153 elsif ($filename eq "nmbd") {
154 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
155 if (-e "$SRCDIR/source/$nextfile.profile") {
156 print IDB "f 0755 root sys usr/samba/bin/$filename.profile $SRCPFX/source/$nextfile.profile $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 ($junk,$file) = split(/\//,$nextfile,2);
169 if (grep(/\/$/,$nextfile)) {
170 $file =~ s/\/$//;
171 $nextfile =~ s/\/$//;
172 print IDB "d 0755 root sys usr/samba/docs/$file $SRCPFX/$nextfile $PKG.man.doc\n";
174 else {
175 print IDB "f 0644 root sys usr/samba/docs/$file $SRCPFX/$nextfile $PKG.man.doc\n";
179 print IDB "d 0755 root sys usr/samba/include $SRCPFX/packaging/SGI $PKG.sw.base\n";
180 print IDB "f 0644 root sys usr/samba/include/libsmbclient.h $SRCPFX/source/include/libsmbclient.h $PKG.sw.base\n";
182 print IDB "d 0755 root sys usr/samba/lib $SRCPFX/packaging/SGI $PKG.sw.base\n";
183 while (@libfiles) {
184 $nextfile = shift @libfiles;
185 ($file = $nextfile) =~ s/.*\///;
186 if ($file eq "smb.conf") {
187 print IDB "f 0644 root sys usr/samba/lib/$file $SRCPFX/$nextfile $PKG.sw.base config(suggest)\n";
188 } else {
189 print IDB "f 0644 root sys usr/samba/lib/$file $SRCPFX/$nextfile $PKG.sw.base nostrip \n";
193 print IDB "d 0755 lp sys usr/samba/printer $SRCPFX/packaging/SGI $PKG.sw.base\n";
194 print IDB "d 0755 lp sys usr/samba/printer/W32ALPHA $SRCPFX/packaging/SGI $PKG.sw.base\n";
195 print IDB "d 0755 lp sys usr/samba/printer/W32MIPS $SRCPFX/packaging/SGI $PKG.sw.base\n";
196 print IDB "d 0755 lp sys usr/samba/printer/W32PPC $SRCPFX/packaging/SGI $PKG.sw.base\n";
197 print IDB "d 0755 lp sys usr/samba/printer/W32X86 $SRCPFX/packaging/SGI $PKG.sw.base\n";
198 print IDB "d 0755 lp sys usr/samba/printer/WIN40 $SRCPFX/packaging/SGI $PKG.sw.base\n";
200 print IDB "d 0644 root sys usr/samba/private $SRCPFX/packaging/SGI $PKG.sw.base\n";
201 print IDB "f 0600 root sys usr/samba/private/smbpasswd $SRCPFX/packaging/SGI/smbpasswd $PKG.sw.base config(suggest)\n";
203 print IDB "d 0755 root sys usr/samba/scripts $SRCPFX/packaging/SGI $PKG.src.samba\n";
204 print IDB "f 0755 root sys usr/samba/scripts/inetd.sh $SRCPFX/packaging/SGI/inetd.sh $PKG.sw.base\n";
205 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";
206 print IDB "f 0755 root sys usr/samba/scripts/mkprintcap.sh $SRCPFX/packaging/SGI/mkprintcap.sh $PKG.sw.base\n";
207 print IDB "f 0755 root sys usr/samba/scripts/removeswat.sh $SRCPFX/packaging/SGI/removeswat.sh $PKG.sw.base\n";
208 print IDB "f 0755 root sys usr/samba/scripts/startswat.sh $SRCPFX/packaging/SGI/startswat.sh $PKG.sw.base\n";
210 print IDB "d 0755 root sys usr/samba/src $SRCPFX/packaging/SGI $PKG.src.samba\n";
211 @sorted = sort(@allfiles);
212 while (@sorted) {
213 $nextfile = shift @sorted;
214 ($file = $nextfile) =~ s/^.*\///;
215 next if grep(/packaging\/SGI/& (/Makefile/ | /samba\.spec/ | /samba\.idb/),$nextfile);
216 next if grep(/source/,$nextfile) && ($ignores{$file});
217 next if ($nextfile eq "CVS");
218 if (grep(/\/$/,$nextfile)) {
219 $nextfile =~ s/\/$//;
220 print IDB "d 0755 root sys usr/samba/src/$nextfile $SRCPFX/$nextfile $PKG.src.samba\n";
222 else {
223 if (grep((/\.sh$/ | /configure$/ | /configure\.developer/ | /config\.guess/ | /config\.sub/ | /\.pl$/ | /mkman$/ | /pcp\/Install/ | /pcp\/Remove/),$nextfile)) {
224 print IDB "f 0755 root sys usr/samba/src/$nextfile $SRCPFX/$nextfile $PKG.src.samba\n";
226 else {
227 print IDB "f 0644 root sys usr/samba/src/$nextfile $SRCPFX/$nextfile $PKG.src.samba\n";
232 print IDB "d 0755 root sys usr/samba/swat $SRCPFX/packaging/SGI/swat $PKG.sw.base\n";
233 while (@swatfiles) {
234 $nextfile = shift @swatfiles;
235 ($file = $nextfile) =~ s/^packaging\/SGI\/swat\///;
236 next if !$file;
237 if (grep(/\/$/,$file)) {
238 $file =~ s/\/$//;
239 print IDB "d 0755 root sys usr/samba/swat/$file $SRCPFX/packaging/SGI/swat/$file $PKG.sw.base\n";
241 else {
242 print IDB "f 0444 root sys usr/samba/swat/$file $SRCPFX/packaging/SGI/swat/$file $PKG.sw.base\n";
246 print IDB "d 0755 root sys usr/samba/var $SRCPFX/packaging/SGI $PKG.sw.base\n";
247 print IDB "d 0755 root sys usr/samba/var/locks $SRCPFX/packaging/SGI $PKG.sw.base\n";
249 if ($PKG eq "samba_irix") {
250 while(@books) {
251 $nextfile = shift @books;
252 print IDB $nextfile;
256 print IDB "d 0755 root sys usr/share/catman/u_man $SRCPFX/packaging/SGI $PKG.man.manpages\n";
257 $olddirnum = "0";
258 while (@catman) {
259 $nextfile = shift @catman;
260 ($file = $nextfile) =~ s/^packaging\/SGI\/catman\///;
261 ($dirnum = $file) =~ s/^[\D]*//;
262 $dirnum =~ s/\.z//;
263 if ($dirnum ne $olddirnum) {
264 print IDB "d 0755 root sys usr/share/catman/u_man/cat$dirnum $SRCPFX/packaging/SGI $PKG.man.manpages\n";
265 $olddirnum = $dirnum;
267 print IDB "f 0664 root sys usr/share/catman/u_man/cat$dirnum/$file $SRCPFX/$nextfile $PKG.man.manpages\n";
270 if (@nsswitch) {
271 print IDB "d 0755 root sys var/ns/lib $SRCPFX/packaging/SGI $PKG.sw.base\n";
272 while(@nsswitch) {
273 $nextfile = shift @nsswitch;
274 next if $nextfile eq 'libsmbclient';
275 ($filename = $nextfile) =~ s/^.*\///;
276 $filename =~ s/libnss/libns/;
277 print IDB "f 0644 root sys var/ns/lib/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
281 print IDB "d 01777 lp sys var/spool/samba $SRCPFX/packaging/SGI $PKG.sw.base\n";
283 close IDB;
284 print "\n\n$PKG.idb file has been created\n";
286 sub dodir {
287 local($dir, $nlink) = @_;
288 local($dev,$ino,$mode,$subcount);
290 ($dev,$ino,$mode,$nlink) = stat('.') unless $nlink;
292 opendir(DIR,'.') || die "Can't open current directory";
293 local(@filenames) = sort readdir(DIR);
294 closedir(DIR);
296 if ($nlink ==2) { # This dir has no subdirectories.
297 for (@filenames) {
298 next if $_ eq '.';
299 next if $_ eq '..';
300 $this = substr($dir,2)."/$_";
301 push(@allfiles,$this);
304 else {
305 $subcount = $nlink -2;
306 for (@filenames) {
307 next if $_ eq '.';
308 next if $_ eq '..';
309 next if $_ eq 'CVS';
310 ($dev,$ino,$mode,$nlink) = lstat($_);
311 $name = "$dir/$_";
312 $this = substr($name,2);
313 $this .= '/' if -d;
314 push(@allfiles,$this);
315 next if $subcount == 0; # seen all the subdirs?
317 next unless -d _;
319 chdir $_ || die "Can't cd to $name";
320 &dodir($name,$nlink);
321 chdir '..';
322 --$subcount;
327 sub bynextdir {
328 ($f0,$f1) = split(/\//,$a,2);
329 ($f0,$f2) = split(/\//,$b,2);
330 $f1 cmp $f2;
333 sub byfilename {
334 ($f0,$f1) = split(/.*\//,$a,2);
335 if ($f1 eq "") { $f1 = $f0 };
336 ($f0,$f2) = split(/.*\//,$b,2);
337 if ($f2 eq "") { $f2 = $f0 };
338 $f1 cmp $f2;
341 sub bydirnum {
342 ($f1 = $a) =~ s/^.*\///;
343 ($f2 = $b) =~ s/^.*\///;
344 ($dir1 = $a) =~ s/^[\D]*//;
345 ($dir2 = $b) =~ s/^[\D]*//;
346 if (!($dir1 <=> $dir2)) {
347 $f1 cmp $f2;
349 else {
350 $dir1 <=> $dir2;
354 sub idbsort {
355 ($f0,$f1,$f2,$f3) = split(/ /,$a,4);
356 ($f0,$f1,$f2,$f4) = split(/ /,$b,4);
357 $f3 cmp $f4;
360 sub get_line {
361 local ($line) = @_;
363 $line =~ s/^.*=//;
364 while (($cont = index($line,"\\")) > 0) {
365 $_ = <MAKEFILE>;
366 chomp;
367 s/^\s*/ /;
368 substr($line,$cont,1) = $_;
370 $line =~ s/\$\(EXEEXT\)/$EXEEXT/g;
371 $line =~ s/\$\(srcdir\)//g;
372 $line =~ s/\$\(builddir\)//g;
373 $line =~ s/\$\(\S*\)\s*//g;
374 $line =~ s/\s\s*/ /g;
375 @line = split(' ',$line);
376 return @line;