2 require "pwd.pl" || die "Required pwd.pl not found";
4 # This perl script automatically generates the idb file
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
>;
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";
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";
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
)) {
41 last if /^# object file lists/ ;
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
($_); }
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");
77 # get a complete list of all files in the tree
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
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";
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";
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";
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";
167 $nextfile = shift @docs;
168 ($junk,$file) = split(/\//,$nextfile,2);
169 if (grep(/\/$/,$nextfile)) {
171 $nextfile =~ s/\/$//;
172 print IDB
"d 0755 root sys usr/samba/docs/$file $SRCPFX/$nextfile $PKG.man.doc\n";
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";
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";
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);
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";
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";
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";
234 $nextfile = shift @swatfiles;
235 ($file = $nextfile) =~ s/^packaging\/SGI\/swat\
///;
237 if (grep(/\/$/,$file)) {
239 print IDB
"d 0755 root sys usr/samba/swat/$file $SRCPFX/packaging/SGI/swat/$file $PKG.sw.base\n";
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") {
251 $nextfile = shift @books;
256 print IDB
"d 0755 root sys usr/share/catman/u_man $SRCPFX/packaging/SGI $PKG.man.manpages\n";
259 $nextfile = shift @catman;
260 ($file = $nextfile) =~ s/^packaging\/SGI\/catman\
///;
261 ($dirnum = $file) =~ s/^[\D]*//;
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";
271 print IDB
"d 0755 root sys var/ns/lib $SRCPFX/packaging/SGI $PKG.sw.base\n";
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";
284 print "\n\n$PKG.idb file has been created\n";
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
);
296 if ($nlink ==2) { # This dir has no subdirectories.
300 $this = substr($dir,2)."/$_";
301 push(@allfiles,$this);
305 $subcount = $nlink -2;
310 ($dev,$ino,$mode,$nlink) = lstat($_);
312 $this = substr($name,2);
314 push(@allfiles,$this);
315 next if $subcount == 0; # seen all the subdirs?
319 chdir $_ || die "Can't cd to $name";
320 &dodir
($name,$nlink);
328 ($f0,$f1) = split(/\//,$a,2);
329 ($f0,$f2) = split(/\//,$b,2);
334 ($f0,$f1) = split(/.*\//,$a,2);
335 if ($f1 eq "") { $f1 = $f0 };
336 ($f0,$f2) = split(/.*\//,$b,2);
337 if ($f2 eq "") { $f2 = $f0 };
342 ($f1 = $a) =~ s/^.*\///;
343 ($f2 = $b) =~ s/^.*\///;
344 ($dir1 = $a) =~ s/^[\D]*//;
345 ($dir2 = $b) =~ s/^[\D]*//;
346 if (!($dir1 <=> $dir2)) {
355 ($f0,$f1,$f2,$f3) = split(/ /,$a,4);
356 ($f0,$f1,$f2,$f4) = split(/ /,$b,4);
364 while (($cont = index($line,"\\")) > 0) {
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);