fixed bad link noticed by Martin Schwenke
[Samba.git] / packaging / SGI / idb.pl
blobd1d8245f4540c044447352c2f1a464777379e485
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 @winbind_progs = grep(/^WINBIND_PROGS /,@makefile);
40 @winbind_sprogs = grep(/^WINBIND_SPROGS /,@makefile);
41 @winbind_lprogs = grep(/^WINBIND_LPROGS /,@makefile);
42 @winbind_pam_progs = grep(/^WINBIND_PAM_PROGS /,@makefile);
43 @sprogs = grep(/^SPROGS /,@makefile);
44 @progs1 = grep(/^PROGS1 /,@makefile);
45 @progs2 = grep(/^PROGS2 /,@makefile);
46 @mprogs = grep(/^MPROGS /,@makefile);
47 @progs = grep(/^PROGS /,@makefile);
48 @scripts = grep(/^SCRIPTS /,@makefile);
49 @codepagelist = grep(/^CODEPAGELIST/,@makefile);
50 close MAKEFILE;
52 if (@winbind_progs) {
53 @winbind_progs[0] =~ s/^.*\=//;
54 @winbind_progs = split(' ',@winbind_progs[0]);
56 if (@winbind_sprogs) {
57 @winbind_sprogs[0] =~ s/^.*\=//;
58 @winbind_sprogs = split(' ',@winbind_sprogs[0]);
60 if (@winbind_lprogs) {
61 @winbind_lprogs[0] =~ s/^.*\=//;
62 @winbind_lprogs = split(' ',@winbind_lprogs[0]);
64 if (@winbind_pam_progs) {
65 @winbind_pam_progs[0] =~ s/^.*\=//;
66 @winbind_pam_progs = split(' ',@winbind_pam_progs[0]);
68 if (@sprogs) {
69 @sprogs[0] =~ s/^.*\=//;
70 @sprogs[0] =~ s/\$\(\S+\)\s//g;
71 @sprogs = split(' ',@sprogs[0]);
73 if (@progs) {
74 @progs[0] =~ s/^.*\=//;
75 @progs[0] =~ s/\$\(\S+\)\s//g;
76 @progs = split(' ',@progs[0]);
78 if (@mprogs) {
79 @mprogs[0] =~ s/^.*\=//;
80 @mprogs = split(' ',@mprogs[0]);
82 if (@progs1) {
83 @progs1[0] =~ s/^.*\=//;
84 @progs1 = split(' ',@progs1[0]);
86 if (@progs2) {
87 @progs2[0] =~ s/^.*\=//;
88 @progs2 = split(' ',@progs2[0]);
90 if (@scripts) {
91 @scripts[0] =~ s/^.*\=//;
92 @scripts[0] =~ s/\$\(srcdir\)\///g;
93 @scripts = split(' ',@scripts[0]);
96 # we need to create codepages for the package
97 @codepagelist[0] =~ s/^.*\=//;
98 chdir "$SRCDIR/source";
99 system("chmod +x ./script/installcp.sh");
100 system("./script/installcp.sh . . ../packaging/SGI/codepages ./bin @codepagelist[0]");
101 chdir $curdir;
102 opendir(DIR,"$SRCDIR/packaging/SGI/codepages") || die "Can't open codepages directory";
103 @codepage = sort readdir(DIR);
104 closedir(DIR);
106 # install the swat files
107 chdir "$SRCDIR/source";
108 system("chmod +x ./script/installswat.sh");
109 system("./script/installswat.sh ../packaging/SGI/swat ./ ../packaging/SGI/swat/using_samba");
110 system("cp -f ../swat/README ../packaging/SGI/swat");
111 chdir $curdir;
113 # add my local files to the list of binaries to install
114 @bins = sort byfilename (@sprogs,@progs,@progs1,@progs2,@mprogs,@scripts,@winbind_progs,@winbind_sprogs,("/findsmb","/sambalp","/smbprint"));
115 @nsswitch = sort byfilename (@winbind_lprogs,@winbind_pam_progs);
117 # get a complete list of all files in the tree
118 chdir "$SRCDIR/";
119 &dodir('.');
120 chdir $curdir;
122 # the files installed in docs include all the original files in docs plus all
123 # the "*.doc" files from the source tree
124 @docs = sort byfilename grep (!/^docs\/$/ & (/^source\/.*\.doc$/ | /^docs\//),@allfiles);
125 @docs = grep(!/htmldocs\/using_samba/, @docs);
126 @docs = grep(!/docbook/, @docs);
128 @swatfiles = sort grep(/^packaging\/SGI\/swat/, @allfiles);
129 @catman = sort grep(/^packaging\/SGI\/catman/ & !/\/$/, @allfiles);
130 @catman = sort bydirnum @catman;
132 # strip out all the generated directories and the "*.o" files from the source
133 # release
134 @allfiles = grep(!/^.*\.o$/ & !/^.*\.po$/ & !/^.*\.po32$/ & !/^source\/bin/ & !/^packaging\/SGI\/bins/ & !/^packaging\/SGI\/catman/ & !/^packaging\/SGI\/html/ & !/^packaging\/SGI\/codepages/ & !/^packaging\/SGI\/swat/, @allfiles);
136 open(IDB,"> $curdir/$PKG.idb") || die "Unable to open $PKG.idb for output\n";
138 print IDB "f 0644 root sys etc/config/samba $SRCPFX/packaging/SGI/samba.config $PKG.sw.base config(update)\n";
139 print IDB "f 0755 root sys etc/init.d/samba $SRCPFX/packaging/SGI/samba.rc $PKG.sw.base\n";
140 print IDB "l 0000 root sys etc/rc0.d/K39samba $SRCPFX/packaging/SGI $PKG.sw.base symval(../init.d/samba)\n";
141 print IDB "l 0000 root sys etc/rc2.d/S81samba $SRCPFX/packaging/SGI $PKG.sw.base symval(../init.d/samba)\n";
143 if ($PKG eq "samba_irix") {
144 print IDB "d 0755 root sys usr/relnotes/samba_irix $SRCPFX/packaging/SGI $PKG.man.relnotes\n";
145 print IDB "f 0644 root sys usr/relnotes/samba_irix/TC build/TC $PKG.man.relnotes\n";
146 print IDB "f 0644 root sys usr/relnotes/samba_irix/ch1.z build/ch1.z $PKG.man.relnotes\n";
147 print IDB "f 0644 root sys usr/relnotes/samba_irix/ch2.z build/ch2.z $PKG.man.relnotes\n";
148 print IDB "f 0644 root sys usr/relnotes/samba_irix/ch3.z build/ch3.z $PKG.man.relnotes\n";
150 else {
151 @copyfile = grep (/^COPY/,@allfiles);
152 print IDB "d 0755 root sys usr/relnotes/samba $SRCPFX/packaging/SGI $PKG.man.relnotes\n";
153 print IDB "f 0644 root sys usr/relnotes/samba/@copyfile[0] $SRCPFX/@copyfile[0] $PKG.man.relnotes\n";
154 print IDB "f 0644 root sys usr/relnotes/samba/legal_notice.html $SRCPFX/packaging/SGI/legal_notice.html $PKG.man.relnotes\n";
155 print IDB "f 0644 root sys usr/relnotes/samba/samba-relnotes.html $SRCPFX/packaging/SGI/relnotes.html $PKG.man.relnotes\n";
158 print IDB "d 0755 root sys usr/samba $SRCPFX/packaging/SGI $PKG.sw.base\n";
160 print IDB "d 0755 root sys usr/samba/bin $SRCPFX/packaging/SGI $PKG.sw.base\n";
161 while(@bins) {
162 $nextfile = shift @bins;
163 ($filename = $nextfile) =~ s/^.*\///;;
165 if (index($nextfile,'$')) {
166 if ($filename eq "smbpasswd") {
167 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
169 elsif ($filename eq "findsmb") {
170 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/packaging/SGI/$filename $PKG.sw.base\n";
172 elsif ($filename eq "swat") {
173 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";
175 elsif ($filename eq "sambalp") {
176 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/packaging/SGI/$filename $PKG.sw.base \n";
178 elsif ($filename eq "smbprint") {
179 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/packaging/SGI/$filename $PKG.sw.base\n";
181 elsif ($filename eq "smbd") {
182 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
183 print IDB "f 0755 root sys usr/samba/bin/$filename.noquota $SRCPFX/source/$nextfile.noquota $PKG.sw.base \n";
184 print IDB "f 0755 root sys usr/samba/bin/$filename.profile $SRCPFX/source/$nextfile.profile $PKG.sw.base \n";
186 elsif ($filename eq "nmbd") {
187 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
188 print IDB "f 0755 root sys usr/samba/bin/$filename.profile $SRCPFX/source/$nextfile.profile $PKG.sw.base \n";
190 else {
191 print IDB "f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
196 print IDB "d 0755 root sys usr/samba/docs $SRCPFX/docs $PKG.man.doc\n";
197 while (@docs) {
198 $nextfile = shift @docs;
199 next if ($nextfile eq "CVS");
200 ($junk,$file) = split(/\//,$nextfile,2);
201 if (grep(/\/$/,$nextfile)) {
202 $file =~ s/\/$//;
203 $nextfile =~ s/\/$//;
204 print IDB "d 0755 root sys usr/samba/docs/$file $SRCPFX/$nextfile $PKG.man.doc\n";
206 else {
207 print IDB "f 0644 root sys usr/samba/docs/$file $SRCPFX/$nextfile $PKG.man.doc\n";
211 print IDB "d 0755 root sys usr/samba/lib $SRCPFX/packaging/SGI $PKG.sw.base\n";
212 print IDB "d 0755 root sys usr/samba/lib/codepages $SRCPFX/packaging/SGI $PKG.sw.base\n";
213 while (@codepage) {
214 $nextpage = shift @codepage;
215 print IDB "f 0644 root sys usr/samba/lib/codepages/$nextpage $SRCPFX/packaging/SGI/codepages/$nextpage $PKG.sw.base nostrip \n";
217 print IDB "f 0644 root sys usr/samba/lib/smb.conf $SRCPFX/packaging/SGI/smb.conf $PKG.sw.base config(suggest)\n";
219 if (@nsswitch) {
220 print IDB "d 0644 root sys usr/samba/nsswitch $SRCPFX/packaging/SGI $PKG.sw.base\n";
221 while(@nsswitch) {
222 $nextfile = shift @nsswitch;
223 ($filename = $nextfile) =~ s/^.*\///;;
224 print IDB "f 0755 root sys usr/samba/nsswitch/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
228 print IDB "d 0644 root sys usr/samba/private $SRCPFX/packaging/SGI $PKG.sw.base\n";
229 print IDB "f 0600 root sys usr/samba/private/smbpasswd $SRCPFX/packaging/SGI/smbpasswd $PKG.sw.base config(suggest)\n";
231 print IDB "d 0755 root sys usr/samba/scripts $SRCPFX/packaging/SGI $PKG.src.samba\n";
232 print IDB "f 0755 root sys usr/samba/scripts/inetd.sh $SRCPFX/packaging/SGI/inetd.sh $PKG.sw.base\n";
233 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";
234 print IDB "f 0755 root sys usr/samba/scripts/mkprintcap.sh $SRCPFX/packaging/SGI/mkprintcap.sh $PKG.sw.base\n";
235 print IDB "f 0755 root sys usr/samba/scripts/removeswat.sh $SRCPFX/packaging/SGI/removeswat.sh $PKG.sw.base\n";
236 print IDB "f 0755 root sys usr/samba/scripts/startswat.sh $SRCPFX/packaging/SGI/startswat.sh $PKG.sw.base\n";
238 print IDB "d 0755 root sys usr/samba/src $SRCPFX/packaging/SGI $PKG.src.samba\n";
239 @sorted = sort(@allfiles);
240 while (@sorted) {
241 $nextfile = shift @sorted;
242 ($file = $nextfile) =~ s/^.*\///;
243 next if grep(/packaging\/SGI/& (/Makefile/ | /samba\.spec/ | /samba\.idb/),$nextfile);
244 next if grep(/source/,$nextfile) && ($ignores{$file});
245 next if ($nextfile eq "CVS");
246 if (grep(/\/$/,$nextfile)) {
247 $nextfile =~ s/\/$//;
248 print IDB "d 0755 root sys usr/samba/src/$nextfile $SRCPFX/$nextfile $PKG.src.samba\n";
250 else {
251 if (grep((/\.sh$/ | /configure$/ | /configure\.developer/ | /config\.guess/ | /config\.sub/ | /\.pl$/ | /mkman$/ | /pcp\/Install/ | /pcp\/Remove/),$nextfile)) {
252 print IDB "f 0755 root sys usr/samba/src/$nextfile $SRCPFX/$nextfile $PKG.src.samba\n";
254 else {
255 print IDB "f 0644 root sys usr/samba/src/$nextfile $SRCPFX/$nextfile $PKG.src.samba\n";
260 print IDB "d 0755 root sys usr/samba/swat $SRCPFX/packaging/SGI/swat $PKG.sw.base\n";
261 while (@swatfiles) {
262 $nextfile = shift @swatfiles;
263 ($file = $nextfile) =~ s/^packaging\/SGI\/swat\///;
264 next if !$file;
265 if (grep(/\/$/,$file)) {
266 $file =~ s/\/$//;
267 print IDB "d 0755 root sys usr/samba/swat/$file $SRCPFX/packaging/SGI/swat/$file $PKG.sw.base\n";
269 else {
270 print IDB "f 0444 root sys usr/samba/swat/$file $SRCPFX/packaging/SGI/swat/$file $PKG.sw.base\n";
274 print IDB "d 0755 root sys usr/samba/var $SRCPFX/packaging/SGI $PKG.sw.base\n";
275 print IDB "d 0755 root sys usr/samba/var/locks $SRCPFX/packaging/SGI $PKG.sw.base\n";
277 if ($PKG eq "samba_irix") {
278 while(@books) {
279 $nextfile = shift @books;
280 print IDB $nextfile;
284 print IDB "d 0755 root sys usr/share/catman/u_man $SRCPFX/packaging/SGI $PKG.man.manpages\n";
285 $olddirnum = "0";
286 while (@catman) {
287 $nextfile = shift @catman;
288 ($file = $nextfile) =~ s/^packaging\/SGI\/catman\///;
289 ($dirnum = $file) =~ s/^[\D]*//;
290 $dirnum =~ s/\.z//;
291 if ($dirnum ne $olddirnum) {
292 print IDB "d 0755 root sys usr/share/catman/u_man/cat$dirnum $SRCPFX/packaging/SGI $PKG.man.manpages\n";
293 $olddirnum = $dirnum;
295 print IDB "f 0664 root sys usr/share/catman/u_man/cat$dirnum/$file $SRCPFX/$nextfile $PKG.man.manpages\n";
297 print IDB "d 01777 nobody nobody var/spool/samba $SRCPFX/packaging/SGI $PKG.sw.base\n";
299 close IDB;
300 print "\n\n$PKG.idb file has been created\n";
302 sub dodir {
303 local($dir, $nlink) = @_;
304 local($dev,$ino,$mode,$subcount);
306 ($dev,$ino,$mode,$nlink) = stat('.') unless $nlink;
308 opendir(DIR,'.') || die "Can't open current directory";
309 local(@filenames) = sort readdir(DIR);
310 closedir(DIR);
312 if ($nlink ==2) { # This dir has no subdirectories.
313 for (@filenames) {
314 next if $_ eq '.';
315 next if $_ eq '..';
316 $this = substr($dir,2)."/$_";
317 push(@allfiles,$this);
320 else {
321 $subcount = $nlink -2;
322 for (@filenames) {
323 next if $_ eq '.';
324 next if $_ eq '..';
325 next if $_ eq 'CVS';
326 ($dev,$ino,$mode,$nlink) = lstat($_);
327 $name = "$dir/$_";
328 $this = substr($name,2);
329 $this .= '/' if -d;
330 push(@allfiles,$this);
331 next if $subcount == 0; # seen all the subdirs?
333 next unless -d _;
335 chdir $_ || die "Can't cd to $name";
336 &dodir($name,$nlink);
337 chdir '..';
338 --$subcount;
343 sub byfilename {
344 ($f0,$f1) = split(/\//,$a,2);
345 ($f0,$f2) = split(/\//,$b,2);
346 $f1 cmp $f2;
349 sub bydirnum {
350 ($f1 = $a) =~ s/^.*\///;
351 ($f2 = $b) =~ s/^.*\///;
352 ($dir1 = $a) =~ s/^[\D]*//;
353 ($dir2 = $b) =~ s/^[\D]*//;
354 if (!($dir1 <=> $dir2)) {
355 $f1 cmp $f2;
357 else {
358 $dir1 <=> $dir2;
362 sub idbsort {
363 ($f0,$f1,$f2,$f3) = split(/ /,$a,4);
364 ($f0,$f1,$f2,$f4) = split(/ /,$b,4);
365 $f3 cmp $f4;