fix small bug in enumprinterdataex due to my changes (still more lurking
[Samba.git] / packaging / SGI / idb.pl
blobddbad8035696056cd00d95cab9499a0dd0ecbaa2
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"));
116 @nsswitch = sort byfilename (@winbind_lprogs,@winbind_pam_progs);
118 # get a complete list of all files in the tree
119 chdir "$SRCDIR/";
120 &dodir('.');
121 chdir $curdir;
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
134 # release
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";
155 else {
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";
166 while(@bins) {
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";
201 else {
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";
208 while (@docs) {
209 $nextfile = shift @docs;
210 next if ($nextfile eq "CVS");
211 ($junk,$file) = split(/\//,$nextfile,2);
212 if (grep(/\/$/,$nextfile)) {
213 $file =~ s/\/$//;
214 $nextfile =~ s/\/$//;
215 print IDB "d 0755 root sys usr/samba/docs/$file $SRCPFX/$nextfile $PKG.man.doc\n";
217 else {
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";
227 while (@codepage) {
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);
254 while (@sorted) {
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";
264 else {
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";
268 else {
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";
275 while (@swatfiles) {
276 $nextfile = shift @swatfiles;
277 ($file = $nextfile) =~ s/^packaging\/SGI\/swat\///;
278 next if !$file;
279 if (grep(/\/$/,$file)) {
280 $file =~ s/\/$//;
281 print IDB "d 0755 root sys usr/samba/swat/$file $SRCPFX/packaging/SGI/swat/$file $PKG.sw.base\n";
283 else {
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") {
292 while(@books) {
293 $nextfile = shift @books;
294 print IDB $nextfile;
298 print IDB "d 0755 root sys usr/share/catman/u_man $SRCPFX/packaging/SGI $PKG.man.manpages\n";
299 $olddirnum = "0";
300 while (@catman) {
301 $nextfile = shift @catman;
302 ($file = $nextfile) =~ s/^packaging\/SGI\/catman\///;
303 ($dirnum = $file) =~ s/^[\D]*//;
304 $dirnum =~ s/\.z//;
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";
312 if (@nsswitch) {
313 print IDB "d 0755 root sys var/ns/lib $SRCPFX/packaging/SGI $PKG.sw.base\n";
314 while(@nsswitch) {
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";
324 close IDB;
325 print "\n\n$PKG.idb file has been created\n";
327 sub dodir {
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);
335 closedir(DIR);
337 if ($nlink ==2) { # This dir has no subdirectories.
338 for (@filenames) {
339 next if $_ eq '.';
340 next if $_ eq '..';
341 $this = substr($dir,2)."/$_";
342 push(@allfiles,$this);
345 else {
346 $subcount = $nlink -2;
347 for (@filenames) {
348 next if $_ eq '.';
349 next if $_ eq '..';
350 next if $_ eq 'CVS';
351 ($dev,$ino,$mode,$nlink) = lstat($_);
352 $name = "$dir/$_";
353 $this = substr($name,2);
354 $this .= '/' if -d;
355 push(@allfiles,$this);
356 next if $subcount == 0; # seen all the subdirs?
358 next unless -d _;
360 chdir $_ || die "Can't cd to $name";
361 &dodir($name,$nlink);
362 chdir '..';
363 --$subcount;
368 sub byfilename {
369 ($f0,$f1) = split(/\//,$a,2);
370 ($f0,$f2) = split(/\//,$b,2);
371 $f1 cmp $f2;
374 sub bydirnum {
375 ($f1 = $a) =~ s/^.*\///;
376 ($f2 = $b) =~ s/^.*\///;
377 ($dir1 = $a) =~ s/^[\D]*//;
378 ($dir2 = $b) =~ s/^[\D]*//;
379 if (!($dir1 <=> $dir2)) {
380 $f1 cmp $f2;
382 else {
383 $dir1 <=> $dir2;
387 sub idbsort {
388 ($f0,$f1,$f2,$f3) = split(/ /,$a,4);
389 ($f0,$f1,$f2,$f4) = split(/ /,$b,4);
390 $f3 cmp $f4;