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 @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);
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]);
69 @sprogs[0] =~ s/^.*\=//;
70 @sprogs[0] =~ s/\$\(\S+\)\s//g;
71 @sprogs = split(' ',@sprogs[0]);
74 @progs[0] =~ s/^.*\=//;
75 @progs[0] =~ s/\$\(\S+\)\s//g;
76 @progs = split(' ',@progs[0]);
79 @mprogs[0] =~ s/^.*\=//;
80 @mprogs = split(' ',@mprogs[0]);
83 @progs1[0] =~ s/^.*\=//;
84 @progs1 = split(' ',@progs1[0]);
87 @progs2[0] =~ s/^.*\=//;
88 @progs2 = split(' ',@progs2[0]);
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]");
102 opendir(DIR
,"$SRCDIR/packaging/SGI/codepages") || die "Can't open codepages directory";
103 @codepage = sort readdir(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");
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"));
116 @nsswitch = sort byfilename
(@winbind_lprogs,@winbind_pam_progs);
118 # get a complete list of all files in the tree
123 # the files installed in docs include all the original files in docs plus all
124 # the "*.doc" files from the source tree
125 @docs = sort byfilename
grep (!/^docs\/$/ & (/^source\
/.*\.doc$/ | /^docs\//),@allfiles);
126 @docs = grep(!/htmldocs\/using_samba
/, @docs);
127 @docs = grep(!/docbook/, @docs);
129 @swatfiles = sort grep(/^packaging\/SGI\
/swat/, @allfiles);
130 @catman = sort grep(/^packaging\/SGI\
/catman/ & !/\/$/, @allfiles);
131 @catman = sort bydirnum
@catman;
133 # strip out all the generated directories and the "*.o" files from the source
135 @allfiles = grep(!/^.*\.o$/ & !/^.*\.po$/ & !/^.*\.po32$/ & !/^.*\.so$/ & !/^source\/bin
/ & !/^packaging\
/SGI\/bins
/ & !/^packaging\
/SGI\
/catman/ & !/^packaging\/SGI\
/html/ & !/^packaging\/SGI\
/codepages/ & !/^packaging\/SGI\
/swat/, @allfiles);
137 open(IDB
,"> $curdir/$PKG.idb") || die "Unable to open $PKG.idb for output\n";
139 print IDB
"f 0644 root sys etc/config/samba $SRCPFX/packaging/SGI/samba.config $PKG.sw.base config(update)\n";
140 print IDB
"f 0644 root sys etc/config/winbind $SRCPFX/packaging/SGI/winbindd.config $PKG.sw.base config(update)\n";
141 print IDB
"f 0755 root sys etc/init.d/samba $SRCPFX/packaging/SGI/samba.rc $PKG.sw.base\n";
142 print IDB
"f 0755 root sys etc/init.d/winbind $SRCPFX/packaging/SGI/winbindd.rc $PKG.sw.base\n";
143 print IDB
"l 0000 root sys etc/rc0.d/K36winbind $SRCPFX/packaging/SGI $PKG.sw.base symval(../init.d/winbind)\n";
144 print IDB
"l 0000 root sys etc/rc0.d/K37samba $SRCPFX/packaging/SGI $PKG.sw.base symval(../init.d/samba)\n";
145 print IDB
"l 0000 root sys etc/rc2.d/S81samba $SRCPFX/packaging/SGI $PKG.sw.base symval(../init.d/samba)\n";
146 print IDB
"l 0000 root sys etc/rc2.d/S82winbind $SRCPFX/packaging/SGI $PKG.sw.base symval(../init.d/winbind)\n";
148 if ($PKG eq "samba_irix") {
149 print IDB
"d 0755 root sys usr/relnotes/samba_irix $SRCPFX/packaging/SGI $PKG.man.relnotes\n";
150 print IDB
"f 0644 root sys usr/relnotes/samba_irix/TC build/TC $PKG.man.relnotes\n";
151 print IDB
"f 0644 root sys usr/relnotes/samba_irix/ch1.z build/ch1.z $PKG.man.relnotes\n";
152 print IDB
"f 0644 root sys usr/relnotes/samba_irix/ch2.z build/ch2.z $PKG.man.relnotes\n";
153 print IDB
"f 0644 root sys usr/relnotes/samba_irix/ch3.z build/ch3.z $PKG.man.relnotes\n";
156 @copyfile = grep (/^COPY/,@allfiles);
157 print IDB
"d 0755 root sys usr/relnotes/samba $SRCPFX/packaging/SGI $PKG.man.relnotes\n";
158 print IDB
"f 0644 root sys usr/relnotes/samba/@copyfile[0] $SRCPFX/@copyfile[0] $PKG.man.relnotes\n";
159 print IDB
"f 0644 root sys usr/relnotes/samba/legal_notice.html $SRCPFX/packaging/SGI/legal_notice.html $PKG.man.relnotes\n";
160 print IDB
"f 0644 root sys usr/relnotes/samba/samba-relnotes.html $SRCPFX/packaging/SGI/relnotes.html $PKG.man.relnotes\n";
163 print IDB
"d 0755 root sys usr/samba $SRCPFX/packaging/SGI $PKG.sw.base\n";
165 print IDB
"d 0755 root sys usr/samba/bin $SRCPFX/packaging/SGI $PKG.sw.base\n";
167 $nextfile = shift @bins;
168 ($filename = $nextfile) =~ s/^.*\///;;
170 if (index($nextfile,'$')) {
171 if ($filename eq "smbpasswd") {
172 print IDB
"f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
174 elsif ($filename eq "findsmb") {
175 print IDB
"f 0755 root sys usr/samba/bin/$filename $SRCPFX/packaging/SGI/$filename $PKG.sw.base\n";
177 elsif ($filename eq "swat") {
178 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";
180 elsif ($filename eq "sambalp") {
181 print IDB
"f 0755 root sys usr/samba/bin/$filename $SRCPFX/packaging/SGI/$filename $PKG.sw.base \n";
183 elsif ($filename eq "smbprint") {
184 print IDB
"f 0755 root sys usr/samba/bin/$filename $SRCPFX/packaging/SGI/$filename $PKG.sw.base\n";
186 elsif ($filename eq "smbd") {
187 print IDB
"f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
188 if (-e
"$SRCDIR/source/$nextfile.noquota") {
189 print IDB
"f 0755 root sys usr/samba/bin/$filename.noquota $SRCPFX/source/$nextfile.noquota $PKG.sw.base \n";
191 if (-e
"$SRCDIR/source/$nextfile.profile") {
192 print IDB
"f 0755 root sys usr/samba/bin/$filename.profile $SRCPFX/source/$nextfile.profile $PKG.sw.base \n";
195 elsif ($filename eq "nmbd") {
196 print IDB
"f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
197 if (-e
"$SRCDIR/source/$nextfile.profile") {
198 print IDB
"f 0755 root sys usr/samba/bin/$filename.profile $SRCPFX/source/$nextfile.profile $PKG.sw.base \n";
202 print IDB
"f 0755 root sys usr/samba/bin/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
207 print IDB
"d 0755 root sys usr/samba/docs $SRCPFX/docs $PKG.man.doc\n";
209 $nextfile = shift @docs;
210 next if ($nextfile eq "CVS");
211 ($junk,$file) = split(/\//,$nextfile,2);
212 if (grep(/\/$/,$nextfile)) {
214 $nextfile =~ s/\/$//;
215 print IDB
"d 0755 root sys usr/samba/docs/$file $SRCPFX/$nextfile $PKG.man.doc\n";
218 print IDB
"f 0644 root sys usr/samba/docs/$file $SRCPFX/$nextfile $PKG.man.doc\n";
222 print IDB
"d 0755 root sys usr/samba/include $SRCPFX/packaging/SGI $PKG.sw.base\n";
223 print IDB
"f 0644 root sys usr/samba/include/libsmbclient.h $SRCPFX/source/include/libsmbclient.h $PKG.sw.base\n";
225 print IDB
"d 0755 root sys usr/samba/lib $SRCPFX/packaging/SGI $PKG.sw.base\n";
226 print IDB
"d 0755 root sys usr/samba/lib/codepages $SRCPFX/packaging/SGI $PKG.sw.base\n";
228 $nextpage = shift @codepage;
229 print IDB
"f 0644 root sys usr/samba/lib/codepages/$nextpage $SRCPFX/packaging/SGI/codepages/$nextpage $PKG.sw.base nostrip \n";
231 print IDB
"f 0644 root sys usr/samba/lib/libsmbclient.a $SRCPFX/source/bin/libsmbclient.a $PKG.sw.base\n";
232 print IDB
"f 0644 root sys usr/samba/lib/libsmbclient.so $SRCPFX/source/bin/libsmbclient.so $PKG.sw.base\n";
233 print IDB
"f 0644 root sys usr/samba/lib/smb.conf $SRCPFX/packaging/SGI/smb.conf $PKG.sw.base config(suggest)\n";
235 print IDB
"d 0755 lp sys usr/samba/printer $SRCPFX/packaging/SGI $PKG.sw.base\n";
236 print IDB
"d 0755 lp sys usr/samba/printer/W32ALPHA $SRCPFX/packaging/SGI $PKG.sw.base\n";
237 print IDB
"d 0755 lp sys usr/samba/printer/W32MIPS $SRCPFX/packaging/SGI $PKG.sw.base\n";
238 print IDB
"d 0755 lp sys usr/samba/printer/W32PPC $SRCPFX/packaging/SGI $PKG.sw.base\n";
239 print IDB
"d 0755 lp sys usr/samba/printer/W32X86 $SRCPFX/packaging/SGI $PKG.sw.base\n";
240 print IDB
"d 0755 lp sys usr/samba/printer/WIN40 $SRCPFX/packaging/SGI $PKG.sw.base\n";
242 print IDB
"d 0644 root sys usr/samba/private $SRCPFX/packaging/SGI $PKG.sw.base\n";
243 print IDB
"f 0600 root sys usr/samba/private/smbpasswd $SRCPFX/packaging/SGI/smbpasswd $PKG.sw.base config(suggest)\n";
245 print IDB
"d 0755 root sys usr/samba/scripts $SRCPFX/packaging/SGI $PKG.src.samba\n";
246 print IDB
"f 0755 root sys usr/samba/scripts/inetd.sh $SRCPFX/packaging/SGI/inetd.sh $PKG.sw.base\n";
247 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";
248 print IDB
"f 0755 root sys usr/samba/scripts/mkprintcap.sh $SRCPFX/packaging/SGI/mkprintcap.sh $PKG.sw.base\n";
249 print IDB
"f 0755 root sys usr/samba/scripts/removeswat.sh $SRCPFX/packaging/SGI/removeswat.sh $PKG.sw.base\n";
250 print IDB
"f 0755 root sys usr/samba/scripts/startswat.sh $SRCPFX/packaging/SGI/startswat.sh $PKG.sw.base\n";
252 print IDB
"d 0755 root sys usr/samba/src $SRCPFX/packaging/SGI $PKG.src.samba\n";
253 @sorted = sort(@allfiles);
255 $nextfile = shift @sorted;
256 ($file = $nextfile) =~ s/^.*\///;
257 next if grep(/packaging\/SGI
/& (/Makefile
/ | /samba\
.spec
/ | /samba\
.idb
/),$nextfile);
258 next if grep(/source/,$nextfile) && ($ignores{$file});
259 next if ($nextfile eq "CVS");
260 if (grep(/\/$/,$nextfile)) {
261 $nextfile =~ s/\/$//;
262 print IDB
"d 0755 root sys usr/samba/src/$nextfile $SRCPFX/$nextfile $PKG.src.samba\n";
265 if (grep((/\.sh$/ | /configure$/ | /configure\.developer/ | /config\.guess/ | /config\.sub/ | /\.pl$/ | /mkman$/ | /pcp\/Install
/ | /pcp\
/Remove/),$nextfile)) {
266 print IDB
"f 0755 root sys usr/samba/src/$nextfile $SRCPFX/$nextfile $PKG.src.samba\n";
269 print IDB
"f 0644 root sys usr/samba/src/$nextfile $SRCPFX/$nextfile $PKG.src.samba\n";
274 print IDB
"d 0755 root sys usr/samba/swat $SRCPFX/packaging/SGI/swat $PKG.sw.base\n";
276 $nextfile = shift @swatfiles;
277 ($file = $nextfile) =~ s/^packaging\/SGI\/swat\
///;
279 if (grep(/\/$/,$file)) {
281 print IDB
"d 0755 root sys usr/samba/swat/$file $SRCPFX/packaging/SGI/swat/$file $PKG.sw.base\n";
284 print IDB
"f 0444 root sys usr/samba/swat/$file $SRCPFX/packaging/SGI/swat/$file $PKG.sw.base\n";
288 print IDB
"d 0755 root sys usr/samba/var $SRCPFX/packaging/SGI $PKG.sw.base\n";
289 print IDB
"d 0755 root sys usr/samba/var/locks $SRCPFX/packaging/SGI $PKG.sw.base\n";
291 if ($PKG eq "samba_irix") {
293 $nextfile = shift @books;
298 print IDB
"d 0755 root sys usr/share/catman/u_man $SRCPFX/packaging/SGI $PKG.man.manpages\n";
301 $nextfile = shift @catman;
302 ($file = $nextfile) =~ s/^packaging\/SGI\/catman\
///;
303 ($dirnum = $file) =~ s/^[\D]*//;
305 if ($dirnum ne $olddirnum) {
306 print IDB
"d 0755 root sys usr/share/catman/u_man/cat$dirnum $SRCPFX/packaging/SGI $PKG.man.manpages\n";
307 $olddirnum = $dirnum;
309 print IDB
"f 0664 root sys usr/share/catman/u_man/cat$dirnum/$file $SRCPFX/$nextfile $PKG.man.manpages\n";
313 print IDB
"d 0755 root sys var/ns/lib $SRCPFX/packaging/SGI $PKG.sw.base\n";
315 $nextfile = shift @nsswitch;
316 ($filename = $nextfile) =~ s/^.*\///;
317 $filename =~ s/libnss/libns/;
318 print IDB
"f 0644 root sys var/ns/lib/$filename $SRCPFX/source/$nextfile $PKG.sw.base \n";
322 print IDB
"d 01777 lp sys var/spool/samba $SRCPFX/packaging/SGI $PKG.sw.base\n";
325 print "\n\n$PKG.idb file has been created\n";
328 local($dir, $nlink) = @_;
329 local($dev,$ino,$mode,$subcount);
331 ($dev,$ino,$mode,$nlink) = stat('.') unless $nlink;
333 opendir(DIR
,'.') || die "Can't open current directory";
334 local(@filenames) = sort readdir(DIR
);
337 if ($nlink ==2) { # This dir has no subdirectories.
341 $this = substr($dir,2)."/$_";
342 push(@allfiles,$this);
346 $subcount = $nlink -2;
351 ($dev,$ino,$mode,$nlink) = lstat($_);
353 $this = substr($name,2);
355 push(@allfiles,$this);
356 next if $subcount == 0; # seen all the subdirs?
360 chdir $_ || die "Can't cd to $name";
361 &dodir
($name,$nlink);
369 ($f0,$f1) = split(/\//,$a,2);
370 ($f0,$f2) = split(/\//,$b,2);
375 ($f1 = $a) =~ s/^.*\///;
376 ($f2 = $b) =~ s/^.*\///;
377 ($dir1 = $a) =~ s/^[\D]*//;
378 ($dir2 = $b) =~ s/^[\D]*//;
379 if (!($dir1 <=> $dir2)) {
388 ($f0,$f1,$f2,$f3) = split(/ /,$a,4);
389 ($f0,$f1,$f2,$f4) = split(/ /,$b,4);