1: #!/usr/bin/perl
2:
3: # Scott Harrison
4: # November 2000
5:
6: # Read in loncapa tags and metagroup tags
7:
8: # ---------------------------------------------- Read in command line arguments
9: my ($file,$mode)=@ARGV;
10:
11: # ---------------------------------------------------- Read in master data file
12: open IN,"<$file";
13: my @lines=<IN>;
14: close IN;
15: my $info1=join('',@lines);
16: my $info2=$info1; # value to allow for meta data group retrieval
17:
18: # ------------------------------------------------------- Make default settings
19: my $distribution="redhat6.2";
20: my $date=`date +'%B %e, %Y'`; chop $date;
21: my $buildhost=`hostname`; chop $buildhost;
22: # file category mappings
23: my %fcm=(
24: 'conf' => 'configurable',
25: 'graphic file' => 'graphicfile',
26: 'handler' => 'handler',
27: 'interface file' => 'interfacefile',
28: 'symbolic link' => 'link',
29: 'root script' => 'rootscript',
30: 'script' => 'script',
31: 'setuid script' => 'setuid',
32: 'static conf' => 'static',
33: 'system file' => 'systemfile',
34: );
35:
36: # ---------------------------------------------------- Parse the marked up data
37: my %info; # big data storage object
38: while ($info1=~/\<loncapa\s+(.*?)\>/isg) {
39: my $keystring=$1;
40: # In the parsing of LON-CAPA tags, remove boundary white-space,
41: # and handle quotation commands.
42: my %hash=map {my ($key,$value)=split(/\=(?!")|\=(?=\s*"[^"]*"[^"]*$)/);
43: $value=~s/^"//;
44: $value=~s/"$//;
45: (uc($key),$value);}
46: split(/\s+(?=\w+\s*\=)/,$keystring);
47: # Handle the different types of commands
48: if (uc($hash{'TYPE'}) eq "OWNERSHIP") {
49: $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHMOD'}=$hash{'CHMOD'};
50: $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHOWN'}=$hash{'CHOWN'};
51: }
52: elsif (uc($hash{'TYPE'}) eq "DEVOWNERSHIP") {
53: $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHMOD'}=$hash{'CHMOD'};
54: $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHOWN'}=$hash{'CHOWN'};
55: }
56: elsif (uc($hash{'TYPE'}) eq "RPM") {
57: $hash{'VALUE'}=~s/\\n/\n/g;
58: $info{$hash{'TYPE'}}{$hash{'NAME'}}=$hash{'VALUE'};
59: }
60: elsif (uc($hash{'TYPE'}) eq "DIRECTORY") {
61: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'CATEGORY'}=
62: $hash{'CATEGORY'};
63: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'DESCRIPTION'}=
64: $hash{'DESCRIPTION'} if $hash{'DESCRIPTION'};
65: }
66: elsif (uc($hash{'TYPE'}) eq "LOCATION") {
67: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'CATEGORY'}= $hash{'CATEGORY'};
68: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'LINKTO'}= $hash{'LINKTO'};
69: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'SOURCE'}= $hash{'SOURCE'};
70: # get surrounding metagroup information
71: my $ckeystring=$keystring; $ckeystring=~s/(SOURCE\=\"[^"]*)\*/$1\\\*/g;
72: $ckeystring=~s/(TARGET\=\"[^"]*)\*/$1\\\*/g;
73: $info2=~/.*\<(?:metagroup|metasupergroup)\>(.*?)\<loncapa\s+$ckeystring\>(.*?)\<\/(?:metagroup|metasupergroup)\>/is;
74: my $data=$1.$2;
75: my @meta=('description','build','dependencies','files','note');
76: foreach my $m (@meta) {
77: if ($data=~/\<($m)\>(.*?)\<\/$m\>/sgi) {
78: my ($key,$value)=($1,$2);
79: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{uc($key)}=
80: $value;
81: }
82: }
83: }
84: else {
85: warn("WARNING: this tag text will be ignored since it cannot be understood\n---> $keystring\n");
86: }
87: }
88:
89: my $a;
90: my @directories;
91: if ($mode eq "HTML") {
92: $a=&begin_description_page;
93: print $a;
94: $a=&make_rpm_description_block;
95: print $a;
96: @directories=&determine_directory_structure;
97: $a=&make_directory_structure_description_block(\@directories);
98: print $a;
99: $a=&make_file_type_ownership_and_permissions_description_block;
100: print $a;
101: $a=&make_directory_and_file_structure_description_block(\@directories);
102: print $a;
103: $a=&end_description_page;
104: print $a;
105: }
106: elsif ($mode eq "SPEC") {
107: my $out=$info{'RPM'}{'Name'} . '-' . $info{'RPM'}{'Version'} . '.spec';
108: open OUT,">$out";
109: $a=&make_rpm_spec_block;
110: print OUT $a;
111: $a=&make_rpm_build_block;
112: print OUT $a;
113: @directories=&determine_directory_structure;
114: $a=&make_directory_structure_spec_block(\@directories);
115: print OUT $a;
116: $a=&make_directory_and_file_structure_spec_block(\@directories);
117: print OUT $a;
118: $a=&end_spec_page;
119: print OUT $a;
120: close OUT;
121: }
122: elsif ($mode eq "LCMakefile") {
123: @directories=&determine_directory_structure;
124: $a=&make_directory_LCMakefile_segment(\@directories);
125: print $a;
126: $a=&make_files_LCMakefile_segment(\@directories);
127: print $a;
128: $a=&make_links_LCMakefile_segment(\@directories);
129: print $a;
130: }
131: elsif ($mode eq "BinaryRoot") {
132: mkdir "BinaryRoot",0755;
133: open OUT,">Makefile.BinaryRoot";
134: @directories=&determine_directory_structure;
135: $a=&make_directory_binaryroot_segment(\@directories);
136: print OUT $a;
137: $a=&make_files_binaryroot_segment(\@directories);
138: print OUT $a;
139: $a=&make_links_binaryroot_segment(\@directories);
140: print OUT $a;
141: close OUT;
142: print `make -f Makefile.BinaryRoot TARGET='BinaryRoot' SOURCE='../..' directories`;
143: print `make -f Makefile.BinaryRoot TARGET='BinaryRoot' SOURCE='../..' files`;
144: print `make -f Makefile.BinaryRoot TARGET='BinaryRoot' SOURCE='../..' links`;
145: open OUT,">base_file_list.txt";
146: $a=&make_file_list(\@directories);
147: print OUT $a;
148: close OUT;
149: open OUT,">setup_file_list.txt";
150: print OUT "BinaryRoot/etc/passwd\n";
151: close OUT;
152: open OUT,">BinaryRoot/etc/passwd";
153: print OUT<<END;
154: root::0:0:root:/root:/bin/bash
155: bin:!!:1:1:bin:/bin:
156: daemon:!!:2:2:daemon:/sbin:
157: adm:!!:3:4:adm:/var/adm:
158: lp:!!:4:7:lp:/var/spool/lpd:
159: sync:!!:5:0:sync:/sbin:/bin/sync
160: shutdown:!!:6:0:shutdown:/sbin:/sbin/shutdown
161: halt:!!:7:0:halt:/sbin:/sbin/halt
162: mail:!!:8:12:mail:/var/spool/mail:
163: news:!!:9:13:news:/var/spool/news:
164: uucp:!!:10:14:uucp:/var/spool/uucp:
165: operator:!!:11:0:operator:/root:
166: games:!!:12:100:games:/usr/games:
167: gopher:!!:13:30:gopher:/usr/lib/gopher-data:
168: ftp:!!:14:50:FTP User:/home/ftp:
169: nobody:!!:99:99:Nobody:/:
170: www:!!:500:500:www:/home/www:/bin/bash
171: END
172: close OUT;
173: open OUT,">>setup_file_list.txt";
174: print OUT "BinaryRoot/etc/hosts.deny\n";
175: close OUT;
176: open OUT,">BinaryRoot/etc/hosts.deny";
177: print OUT<<END;
178: ALL: ALL
179: END
180: close OUT;
181:
182: `install -d BinaryRoot/etc/pam.d`;
183: open OUT,">>setup_file_list.txt";
184: print OUT "BinaryRoot/etc/pam.d/passwd\n";
185: close OUT;
186: open OUT,">BinaryRoot/etc/pam.d/passwd";
187: print OUT<<END;
188: #%PAM-1.0
189: auth required /lib/security/pam_pwdb.so shadow nullok
190: account required /lib/security/pam_pwdb.so
191: password required /lib/security/pam_cracklib.so retry=3
192: password required /lib/security/pam_pwdb.so use_authtok nullok
193: END
194: close OUT;
195: open OUT,">>setup_file_list.txt";
196: print OUT "BinaryRoot/etc/pam.d/login\n";
197: close OUT;
198: open OUT,">BinaryRoot/etc/pam.d/login";
199: print OUT<<END;
200: #%PAM-1.0
201: auth required /lib/security/pam_securetty.so
202: auth required /lib/security/pam_pwdb.so shadow nullok
203: auth required /lib/security/pam_nologin.so
204: account required /lib/security/pam_pwdb.so
205: password required /lib/security/pam_cracklib.so
206: password required /lib/security/pam_pwdb.so nullok use_authtok
207: session required /lib/security/pam_pwdb.so
208: session optional /lib/security/pam_console.so
209: END
210: close OUT;
211:
212: }
213: elsif ($mode eq "status") {
214: $a=&begin_description_page('status');
215: print $a;
216: $a=&make_rpm_description_block('status');
217: print $a;
218: @directories=&determine_directory_structure('status');
219: $a=&make_directory_structure_description_block(\@directories,'status');
220: print $a;
221: $a=&make_file_type_ownership_and_permissions_description_block('status');
222: print $a;
223: $a=&make_directory_and_file_structure_description_block(\@directories,'status');
224: print $a;
225: $a=&end_description_page('status');
226: print $a;
227: }
228: elsif ($mode eq "update") {
229: }
230: elsif ($mode eq "configinstall") {
231: @directories=&determine_directory_structure;
232: $a=&make_files_configinstall_segment(\@directories);
233: print $a;
234: $a=&make_files_configpermissions_segment(\@directories);
235: print $a;
236: }
237: elsif ($mode eq "install") {
238: @directories=&determine_directory_structure;
239: $a=&make_directory_install_segment(\@directories);
240: print $a;
241: $a=&make_files_install_segment(\@directories);
242: print $a;
243: $a=&make_links_install_segment(\@directories);
244: print $a;
245: }
246: elsif ($mode eq "build") {
247: @directories=&determine_directory_structure;
248: $a=&make_files_build_segment(\@directories);
249: print $a;
250: }
251:
252: # ------------------------------------------------------ a list of file targets
253: sub make_file_list {
254: my ($dirs)=@_;
255: my $description;
256: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
257: foreach my $d (@$dirs) {
258: # set other values
259: $description.=<<END;
260: BinaryRoot/$d
261: END
262: my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
263: $dirdescription="(" . $dirdescription . ")" if $dirdescription;
264: # find files that are contained in this directory
265: my @files;
266: my @filesfull;
267: foreach my $f (@allfiles) {
268: if ($f=~/^$d\/([^\/]+)$/) {
269: push @files,$1;
270: push @filesfull,$f;
271: }
272: }
273: # render starting HTML formatting elements
274: if (@files) {
275: }
276: my $pwd=`pwd`; chop $pwd;
277: if (@files) {
278: foreach my $i (0..$#files) {
279: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
280: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
281: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
282: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
283: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
284: my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
285: my $rot="/".$filesfull[$i];
286: if ($rot=~/\*/) {
287: $rot=~s/[^\/]+$// if $rot=~/\*/;
288: my $listing=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
289: chop $listing;
290: my @list=split(/\s+/,$listing);
291: my $rot2;
292: foreach my $l (@list) {
293: $l=~s/^\s*//; $l=~s/\s*$//;
294: $rot2.="BinaryRoot$rot$l\n" if length($l);
295: }
296: chop $rot2;
297: $rot=$rot2;
298: }
299: else {
300: $rot="BinaryRoot$rot";
301: }
302: if ($category eq "conf") {
303: $rot.=" # config";
304: }
305: $description.=<<END;
306: $rot
307: END
308: }
309: }
310: }
311: $description.=<<END;
312:
313: END
314: return $description;
315: }
316:
317: # --------------------------------- Commands to make BinaryRoot directories
318: sub make_directory_binaryroot_segment {
319: my ($dirs)=@_;
320: my $description=<<END;
321: directories:
322: END
323: foreach my $d (@$dirs) {
324: my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
325: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
326: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
327: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
328: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
329: my ($owner,$group)=split(/\:/,$devchown);
330: my $own=$devchown; $own=~s/\:/\,/;
331: $description.=<<END;
332: \tinstall -o $owner -g $group -m $devchmod -d \$(TARGET)/$d
333: END
334: }
335: $description.=<<END;
336:
337: END
338: return $description;
339: }
340:
341: # --------------------------------------- Commands to make BinaryRoot files
342: sub make_files_binaryroot_segment {
343: my ($dirs)=@_;
344: my $description=<<END;
345: files:
346: END
347: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
348: foreach my $d (@$dirs) {
349: # set other values
350: my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
351: $dirdescription="(" . $dirdescription . ")" if $dirdescription;
352: # find files that are contained in this directory
353: my @files;
354: my @filesfull;
355: foreach my $f (@allfiles) {
356: if ($f=~/^$d\/([^\/]+)$/) {
357: push @files,$1;
358: push @filesfull,$f;
359: }
360: }
361: # render starting HTML formatting elements
362: if (@files) {
363: $description.=<<END;
364: \t# $d $dirdescription
365: END
366: }
367: if (@files) {
368: foreach my $i (0..$#files) {
369: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
370: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
371: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
372: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
373: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
374: my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
375: my $rot=$filesfull[$i];
376: $rot=~s/[^\/]+$/\./ if $rot=~/\*/;
377: my ($owner,$group)=split(/\:/,$devchown);
378: $description.=<<END if $category ne 'symbolic link';
379: \tinstall -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
380: END
381: }
382: }
383: }
384: $description.=<<END;
385:
386: END
387: return $description;
388: }
389:
390: # ------------------------------ Commands to make BinaryRoot symbolic links
391: sub make_links_binaryroot_segment {
392: my ($dirs)=@_;
393: my $description=<<END;
394: links:
395: END
396: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
397: foreach my $d (@$dirs) {
398: # find files that are contained in this directory
399: my @files;
400: my @filesfull;
401: foreach my $f (@allfiles) {
402: if ($f=~/^$d\/([^\/]+)$/) {
403: push @files,$1;
404: push @filesfull,$f;
405: }
406: }
407: # render starting HTML formatting elements
408: if (@files) {
409: foreach my $i (0..$#files) {
410: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
411: my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
412: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
413: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
414: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
415: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
416: $description.=<<END if $category eq 'symbolic link';
417: \tln -s /$linkto \$(TARGET)/$filesfull[$i]
418: END
419: }
420: }
421: }
422: $description.=<<END;
423:
424: END
425: return $description;
426: }
427:
428: # ------ Installation commands for a Makefile used only by a rpm -ba invocation
429: sub make_directory_LCMakefile_segment {
430: my ($dirs)=@_;
431: my $description=<<END;
432: directories:
433: END
434: foreach my $d (@$dirs) {
435: my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
436: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
437: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
438: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
439: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
440: my $own=$devchown; $own=~s/\:/\,/;
441: $description.=<<END;
442: \tinstall -m $devchmod -d \$(SOURCE)/$d \$(ROOT)/$d
443: END
444: }
445: $description.=<<END;
446:
447: END
448: return $description;
449: }
450:
451: # ------ Installation commands for a Makefile used only by a rpm -ba invocation
452: sub make_files_LCMakefile_segment {
453: my ($dirs)=@_;
454: my $description=<<END;
455: files:
456: END
457: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
458: foreach my $d (@$dirs) {
459: # set other values
460: my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
461: $dirdescription="(" . $dirdescription . ")" if $dirdescription;
462: # find files that are contained in this directory
463: my @files;
464: my @filesfull;
465: foreach my $f (@allfiles) {
466: if ($f=~/^$d\/([^\/]+)$/) {
467: push @files,$1;
468: push @filesfull,$f;
469: }
470: }
471: # render starting HTML formatting elements
472: if (@files) {
473: $description.=<<END;
474: \t# $d $dirdescription
475: END
476: }
477: if (@files) {
478: foreach my $i (0..$#files) {
479: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
480: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
481: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
482: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
483: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
484: my $rot=$filesfull[$i];
485: $rot=~s/[^\/]+$/\./ if $rot=~/\*/;
486: $description.=<<END if $category ne 'symbolic link';
487: \tinstall -m $devchmod \$(SOURCE)/$filesfull[$i] \$(ROOT)/$rot
488: END
489: }
490: }
491: }
492: $description.=<<END;
493:
494: END
495: return $description;
496: }
497:
498: # ------ Installation commands for a Makefile used only by a rpm -ba invocation
499: sub make_links_LCMakefile_segment {
500: my ($dirs)=@_;
501: my $description=<<END;
502: links:
503: END
504: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
505: foreach my $d (@$dirs) {
506: # find files that are contained in this directory
507: my @files;
508: my @filesfull;
509: foreach my $f (@allfiles) {
510: if ($f=~/^$d\/([^\/]+)$/) {
511: push @files,$1;
512: push @filesfull,$f;
513: }
514: }
515: # render starting HTML formatting elements
516: if (@files) {
517: foreach my $i (0..$#files) {
518: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
519: my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
520: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
521: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
522: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
523: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
524: $description.=<<END if $category eq 'symbolic link';
525: \tln -s /$linkto \$(ROOT)/$filesfull[$i]
526: END
527: }
528: }
529: }
530: $description.=<<END;
531:
532: END
533: return $description;
534: }
535:
536: # --------------------------------- Installation commands to install directories
537: sub make_directory_install_segment {
538: my ($dirs)=@_;
539: my $description=<<END;
540: directories:
541: END
542: foreach my $d (@$dirs) {
543: my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
544: my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
545: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
546: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
547: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
548: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
549: my ($owner,$group)=split(/\:/,$devchown);
550: my $own=$devchown; $own=~s/\:/\,/;
551: $description.=<<END;
552: \tinstall -o $owner -g $group -m $devchmod -d \$(TARGET)/$d
553: END
554: }
555: $description.=<<END;
556:
557: END
558: return $description;
559: }
560:
561: # ------------------------------------------------------ Commands to build files
562: sub make_files_build_segment {
563: my ($dirs)=@_;
564: my $description;
565: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
566: my $tab="\t";
567: my $sources="all: ";
568: foreach my $d (@$dirs) {
569: # set other values
570: my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
571: $dirdescription="(" . $dirdescription . ")" if $dirdescription;
572: # find files that are contained in this directory
573: my @files;
574: my @filesfull;
575: foreach my $f (@allfiles) {
576: if ($f=~/^$d\/([^\/]+)$/) {
577: push @files,$1;
578: push @filesfull,$f;
579: }
580: }
581: if (@files) {
582: foreach my $i (0..$#files) {
583: # if has build information, output appropriate something
584: my $build=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'BUILD'};
585: my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
586: $build=~s/^\s+//; $build=~s/\s+$//;
587: if ($build) {
588: my $dependencies=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DEPENDENCIES'};
589: my $source2=$source;
590: $source2=~s/^[^\/]+\///;
591: $source2="../" . $source2;
592: $sources.="$source2 ";
593: my $directory=$build;
594: $directory=~s/^[^\/]+\///;
595: $directory=~s/([^\/]+)$//;
596: $directory="../" . $directory;
597: my $buildfile=$1;
598: my $sdir=$source;
599: $sdir=~s/^[^\/]+\///;
600: $sdir=~s/([^\/]+)$//;
601: $sdir="../" . $sdir;
602: $dependencies=~s/\s+$//;
603: my $depstat="";
604: if ($dependencies=~s/\s+\[ALWAYS_RUN_BUILD_COMMAND\]//) {
605: $depstat=" alwaysrun";
606: }
607: $dependencies=~s/\s+/ $sdir/gs;
608: $description.=<<END;
609: $source2: $dependencies$depstat
610: ${tab}cd $directory; sh ./$buildfile
611:
612: END
613: }
614: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
615: my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
616: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
617: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
618: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
619: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
620: my $rot=$filesfull[$i];
621: $rot=~s/[^\/]+$/\./ if $rot=~/\*/;
622: # $description.=<<END if $category ne 'symbolic link';
623: #\tinstall -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
624: #END
625: }
626: }
627: }
628: $description.=<<END;
629: alwaysrun:
630:
631: END
632: $sources.="\n\n";
633: return ($sources . $description);
634: }
635:
636: # --------------------------------------- Installation commands to install files
637: sub make_files_install_segment {
638: my ($dirs)=@_;
639: my $description=<<END;
640: files:
641: END
642: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
643: foreach my $d (@$dirs) {
644: # set other values
645: my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
646: $dirdescription="(" . $dirdescription . ")" if $dirdescription;
647: # find files that are contained in this directory
648: my @files;
649: my @filesfull;
650: foreach my $f (@allfiles) {
651: if ($f=~/^$d\/([^\/]+)$/) {
652: push @files,$1;
653: push @filesfull,$f;
654: }
655: }
656: # render starting HTML formatting elements
657: if (@files) {
658: $description.=<<END;
659: \t# $d $dirdescription
660: END
661: }
662: if (@files) {
663: foreach my $i (0..$#files) {
664: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
665: my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
666: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
667: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
668: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
669: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
670: my $rot=$filesfull[$i];
671: $rot=~s/[^\/]+$/\./ if $rot=~/\*/;
672: my ($owner,$group)=split(/\:/,$devchown);
673: if ($category ne 'conf') {
674: $description.=<<END if $category ne 'symbolic link';
675: \tinstall -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
676: END
677: }
678: }
679: }
680: }
681: $description.=<<END;
682:
683: END
684: return $description;
685: }
686:
687: # ------ Installation commands to install configuration files (and make backups)
688: sub make_files_configinstall_segment {
689: my ($dirs)=@_;
690: my $description=<<END;
691: configfiles:
692: END
693: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
694: foreach my $d (@$dirs) {
695: # set other values
696: my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
697: $dirdescription="(" . $dirdescription . ")" if $dirdescription;
698: # find files that are contained in this directory
699: my @files;
700: my @filesfull;
701: foreach my $f (@allfiles) {
702: if ($f=~/^$d\/([^\/]+)$/) {
703: push @files,$1;
704: push @filesfull,$f;
705: }
706: }
707: # render starting HTML formatting elements
708: if (@files) {
709: $description.=<<END;
710: \t# $d $dirdescription
711: END
712: }
713: if (@files) {
714: foreach my $i (0..$#files) {
715: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
716: my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
717: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
718: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
719: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
720: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
721: my $rot=$filesfull[$i];
722: $rot=~s/[^\/]+$/\./ if $rot=~/\*/;
723: my ($owner,$group)=split(/\:/,$devchown);
724: if ($category eq 'conf') {
725: $description.=<<END;
726: \tinstall -b -S `date +'.\%Y\%m\%d\%H\%M\%S'` -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
727: END
728: }
729: }
730: }
731: }
732: $description.=<<END;
733:
734: END
735: return $description;
736: }
737:
738: # ------ Commands to enforce configuration file permissions
739: sub make_files_configpermissions_segment {
740: my ($dirs)=@_;
741: my $description=<<END;
742: configpermissions:
743: END
744: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
745: foreach my $d (@$dirs) {
746: # set other values
747: my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
748: $dirdescription="(" . $dirdescription . ")" if $dirdescription;
749: # find files that are contained in this directory
750: my @files;
751: my @filesfull;
752: foreach my $f (@allfiles) {
753: if ($f=~/^$d\/([^\/]+)$/) {
754: push @files,$1;
755: push @filesfull,$f;
756: }
757: }
758: # render starting HTML formatting elements
759: if (@files) {
760: $description.=<<END;
761: \t# $d $dirdescription
762: END
763: }
764: if (@files) {
765: foreach my $i (0..$#files) {
766: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
767: my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
768: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
769: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
770: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
771: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
772: my $rot=$filesfull[$i];
773: $rot=~s/[^\/]+$/\./ if $rot=~/\*/;
774: my ($owner,$group)=split(/\:/,$devchown);
775: if ($category eq 'conf') {
776: $description.=<<END;
777: \tchmod $devchmod \$(TARGET)/$rot
778: \tchown $devchown \$(TARGET)/$rot
779: END
780: }
781: }
782: }
783: }
784: $description.=<<END;
785:
786: END
787: return $description;
788: }
789:
790: # ------------------------------ Installation commands to install symbolic links
791: sub make_links_install_segment {
792: my ($dirs)=@_;
793: my $description=<<END;
794: links:
795: END
796: chop $description;
797: my $description2;
798: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
799: foreach my $d (@$dirs) {
800: # find files that are contained in this directory
801: my @files;
802: my @filesfull;
803: foreach my $f (@allfiles) {
804: if ($f=~/^$d\/([^\/]+)$/) {
805: push @files,$1;
806: push @filesfull,$f;
807: }
808: }
809: # render starting HTML formatting elements
810: if (@files) {
811: foreach my $i (0..$#files) {
812: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
813: my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
814: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
815: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
816: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
817: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
818: if ($category eq 'symbolic link') {
819: $description.=" \$(TARGET)/$filesfull[$i]";
820: $description2.=<<END;
821: \$(TARGET)/$filesfull[$i]:
822: \tln -s /$linkto \$(TARGET)/$filesfull[$i]
823:
824: END
825: }
826: }
827: }
828: }
829: $description.=<<END;
830:
831: END
832: $description.=$description2;
833: return $description;
834: }
835:
836: # --------------------------------------------------------- Make RPM .spec block
837: sub make_rpm_spec_block {
838: my $pwd=`pwd`; chop $pwd;
839: my $buildroot="$pwd/LON-CAPA-BuildRoot";
840: my $source=$info{'RPM'}{'Name'} . "-" . $info{'RPM'}{'Version'} . '.tar.gz';
841: my $description=<<END;
842: Summary: $info{'RPM'}{'Summary'}
843: Name: $info{'RPM'}{'Name'}
844: Version: $info{'RPM'}{'Version'}
845: Release: $info{'RPM'}{'Release'}
846: Vendor: $info{'RPM'}{'Vendor'}
847: BuildRoot: $buildroot
848: Copyright: $info{'RPM'}{'Copyright'}
849: Group: $info{'RPM'}{'Group'}
850: Source: $source
851: AutoReqProv: $info{'RPM'}{'AutoReqProv'}
852: \%description
853: $info{'RPM'}{'description'}
854:
855: END
856: return $description;
857: }
858:
859: # --------------------------------------------------- Make RPM build .spec block
860: sub make_rpm_build_block {
861: my $pwd=`pwd`; chop $pwd;
862: my $buildroot="$pwd/LON-CAPA-BuildRoot";
863: my $sourceroot="$pwd/LON-CAPA-SourceRoot";
864: my $description=<<END;
865:
866: \%prep
867: \%setup
868:
869: \%build
870: rm -Rf "$buildroot"
871:
872: \%install
873: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" directories
874: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" files
875: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" links
876:
877: \%pre
878: $info{'RPM'}{'pre'}
879:
880: \%post
881: \%postun
882:
883: \%files
884: # \%doc README COPYING ChangeLog LICENSE
885: END
886: return $description;
887: }
888:
889: # ------------------------------------- Make directory structure RPM .spec block
890: sub make_directory_structure_spec_block {
891: my ($dirs)=@_;
892: foreach my $d (@$dirs) {
893: my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
894: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
895: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
896: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
897: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
898: my $own=$devchown; $own=~s/\:/\,/;
899: $description.=<<END;
900: \%dir \%attr($devchmod,$own) /$d
901: END
902: }
903: return $description;
904: }
905:
906: # ---------------------------- Make directory and file structure RPM .spec block
907: sub make_directory_and_file_structure_spec_block {
908: my ($dirs)=@_;
909: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
910: foreach my $d (@$dirs) {
911: # set other values
912: my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
913: $dirdescription="(" . $dirdescription . ")" if $dirdescription;
914: # find files that are contained in this directory
915: my @files;
916: my @filesfull;
917: foreach my $f (@allfiles) {
918: if ($f=~/^$d\/([^\/]+)$/) {
919: push @files,$1;
920: push @filesfull,$f;
921: }
922: }
923: # render starting HTML formatting elements
924: if (@files) {
925: $description.=<<END;
926: # $d $dirdescription
927: END
928: }
929: if (@files) {
930: foreach my $i (0..$#files) {
931: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
932: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
933: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
934: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
935: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
936: my $own=$devchown; $own=~s/\:/\,/;
937: my $config="";
938: $config="\%config " if $category eq 'conf';
939: $devchmod='-' if $category eq 'symbolic link';
940: $description.=<<END;
941: $config\%attr($devchmod,$own) /$filesfull[$i]
942: END
943: }
944: }
945: }
946: return $description;
947: }
948:
949: # ----------------------------------------------------------- End RPM .spec page
950: sub end_spec_page {
951: }
952:
953: # ------------------------------------------------------- Begin description page
954: sub begin_description_page {
955: my ($mode)=@_;
956: my $description;
957: unless ($mode eq 'status') {
958: $description=<<END;
959: <HTML>
960: <HEAD>
961: <TITLE>LON-CAPA Software Description Page ($distribution, $date)</TITLE>
962: </HEAD>
963: <BODY>
964: <FONT SIZE=+2>LON-CAPA Software Description Page ($distribution, $date)</FONT>
965: <BR>Michigan State University
966: <BR>Learning Online with CAPA
967: <BR>Contact korte\@lon-capa.org
968: <UL>
969: <LI>About this file
970: <LI>Software Package Description
971: <LI>Directory Structure
972: <LI>File Type Ownership and Permissions
973: <LI>File and Directory Structure
974: </UL>
975: <FONT SIZE=+2>About this file</FONT>
976: <P>
977: This file is generated dynamically by <TT>parse.pl</TT> as
978: part of a development compilation process. See
979: http://install.lon-capa.org/compile/index.html for more
980: information.
981: </P>
982: END
983: }
984: else {
985: $description=<<END;
986: <HTML>
987: <HEAD>
988: <TITLE>LON-CAPA Software File System Status Page ($distribution, $date)</TITLE>
989: </HEAD>
990: <BODY>
991: <FONT SIZE=+2>LON-CAPA Software File System Status Page ($distribution, $date)</FONT>
992: <BR>Michigan State University
993: <BR>Learning Online with CAPA
994: <BR>Contact korte\@lon-capa.org
995: <UL>
996: <LI>About this file
997: <LI>Software Package Description
998: <LI>Directory Structure
999: <LI>File Type Ownership and Permissions
1000: <LI>File and Directory Structure
1001: </UL>
1002: <FONT SIZE=+2>About this file</FONT>
1003: <P>
1004: This file is generated dynamically by <TT>parse.pl</TT> as
1005: part of a status checking process. See http://install.lon-capa.org/
1006: for more information.
1007: </P>
1008: END
1009: }
1010: return $description;
1011:
1012: }
1013:
1014: # ------------------------------------------------- End description page
1015: sub end_description_page {
1016: my $description=<<END;
1017: <HR>
1018: <FONT SIZE=-1>LON-CAPA Software Development Team</FONT>
1019: </BODY>
1020: </HTML>
1021: END
1022: return $description;
1023: }
1024:
1025: # ------------------------------------------------- Make RPM description block
1026: sub make_rpm_description_block {
1027: my ($mode)=@_;
1028: my $description;
1029: unless ($mode eq 'status') {
1030: $description=<<END;
1031: <FONT SIZE=+2>Rolled in a RedHat 6.2 RPM, $date</FONT>
1032: <P>
1033: <TABLE BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=10 CELLSPACING=0>
1034: <TR><TD>
1035: <PRE>
1036: Name : $info{'RPM'}{'Name'}
1037: Version : $info{'RPM'}{'Version'}
1038: Vendor : $info{'RPM'}{'Vendor'}
1039: Release : $info{'RPM'}{'Release'}
1040: Build Host : $buildhost
1041: Group : $info{'RPM'}{'Group'}
1042: License : $info{'RPM'}{'Copyright'}
1043: Summary : $info{'RPM'}{'Summary'}
1044: Description :
1045: $info{'RPM'}{'description'}
1046: </PRE>
1047: </TD></TR>
1048: </TABLE>
1049: </P>
1050: END
1051: }
1052: else {
1053: my $exist=`rpm -q LON-CAPA-base 2>/dev/null`;
1054: unless ($exist) {
1055: $description=<<END;
1056: <FONT SIZE=+2>No LON-CAPA RPM on the system, (installed ??????)</FONT>
1057: <P>
1058: <TABLE BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=10 CELLSPACING=0>
1059: <TR><TD>
1060: <FONT SIZE=+3>Error! A LON-CAPA-base RPM
1061: was never installed on this system!</FONT>
1062: </TD></TR>
1063: </TD></TR>
1064: </TABLE>
1065: </P>
1066: END
1067: }
1068: else {
1069: chop $exist;
1070: my $rpmname=`rpm -q --queryformat '%{NAME}' LON-CAPA-base`;
1071: my $rpmversion=`rpm -q --queryformat '%{VERSION}' LON-CAPA-base`;
1072: my $rpmrelease=`rpm -q --queryformat '%{RELEASE}' LON-CAPA-base`;
1073: my $idate=`rpm -q --queryformat '%{INSTALLTIME:date}' LON-CAPA-base`;
1074: my $rpmvendor=`rpm -q --queryformat '%{VENDOR}' LON-CAPA-base`;
1075: my $rpmbuildhost=`rpm -q --queryformat '%{BUILDHOST}' LON-CAPA-base`;
1076: my $rpmgroup=`rpm -q --queryformat '%{GROUP}' LON-CAPA-base`;
1077: my $rpmlicense=`rpm -q --queryformat '%{LICENSE}' LON-CAPA-base`;
1078: my $rpmsummary=`rpm -q --queryformat '%{SUMMARY}' LON-CAPA-base`;
1079: my $rpmdescription=`rpm -q --queryformat '%{DESCRIPTION}' LON-CAPA-base`;
1080: $description=<<END;
1081: <FONT SIZE=+2>Current RedHat RPM on the system, (installed $idate)</FONT>
1082: <P>
1083: <TABLE BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=10 CELLSPACING=0>
1084: <TR><TD>
1085: <PRE>
1086: Name : $rpmname
1087: Version : $rpmversion
1088: Vendor : $rpmvendor
1089: Release : $rpmrelease
1090: Build Host : $rpmbuildhost
1091: Group : $rpmgroup
1092: License : $rpmlicense
1093: Summary : $rpmsummary
1094: Description :
1095: $rpmdescription
1096: </PRE>
1097: </TD></TR>
1098: </TABLE>
1099: </P>
1100: END
1101: }
1102: }
1103: return $description;
1104: }
1105:
1106: # ----------------------------------------------- Determine directory structure
1107: sub determine_directory_structure {
1108: my @directories=keys %{$info{'DIRECTORY'}{$distribution}};
1109: return (sort @directories);
1110: }
1111:
1112:
1113: # ---------------------------------- Make directory structure description block
1114: sub make_directory_structure_description_block {
1115: my ($dirs,$mode)=@_;
1116: my $dirstatus; my $statusheader;
1117: my $description=<<END;
1118: <FONT SIZE=+2>Directory Structure Description, $date</FONT>
1119: <P>
1120: The directory structure description below shows only those
1121: directories which either contain LON-CAPA specific files
1122: or normally do not exist on a RedHat Linux system (and
1123: must be generated to allow proper placement of files
1124: during LON-CAPA run-time operation).
1125: </P>
1126: <P>
1127: <TABLE BORDER=1 CELLPADDING=3 CELLSPACING=0>
1128: END
1129: my $maxcount=0;
1130: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
1131: my %diraccount; # hash to track which directories are accounted for
1132: foreach my $file (@allfiles) {
1133: $file=~/^(.*)\/([^\/]+)$/;
1134: $diraccount{$1}=1;
1135: }
1136: foreach my $d (@$dirs) {
1137: my (@matches)=($d=~/\//g);
1138: my $count=scalar(@matches);
1139: $maxcount=$count if $count>$maxcount;
1140: delete $diraccount{$d};
1141: }
1142: if ($mode eq 'status') {
1143: $statusheader="<TH ALIGN=LEFT BGCOLOR=#FFFFFF>Current Status</TH>";
1144: }
1145: $description.=<<END;
1146: <TR>
1147: $statusheader
1148: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Category</TH>
1149: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
1150: <TH ALIGN=LEFT BGCOLOR=#FFFFFF><FONT COLOR=#FF0000>Development<BR>Permissions</FONT></TH>
1151: END
1152: $description.="<TH ALIGN=LEFT BGCOLOR=#FFFFFF COLSPAN=".($maxcount+1).">Directory Path</TH>\n";
1153: if (keys %diraccount) {
1154: $description.= "<TR><TD ALIGN=LEFT BGCOLOR=#FFFFFF COLSPAN=".($maxcount+4)."><I><PRE>Directories that are unaccounted for: \n";
1155: foreach my $d (keys %diraccount) {
1156: $description.="$d\n";
1157: }
1158: $description.="</PRE></I></TH></TR>\n";
1159: }
1160: foreach my $d (@$dirs) {
1161: my $dtable=$d;
1162: $dtable=~s/\//\<\/TD\>\<TD\>/g;
1163: my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
1164: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
1165: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
1166: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
1167: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
1168: if ($mode eq 'status') {
1169: my $ds=`find /$d -type d -prune -printf "\%m\t\%u\t\%g" 2>/dev/null`;
1170: unless ($ds) {
1171: $dirstatus='<TD BGCOLOR=#FFFFFF><B><U>MISSING</U></B></TD>';
1172: }
1173: else {
1174: my @dss=split(/\t/,$ds);
1175: my $dssz=$dss[0];
1176: $dssz="0" . $dss[0] if length($dss[0])<4;
1177: $dss[0]=$dssz;
1178: $ds="$dss[0] $dss[1]:$dss[2]";
1179: if ($ds eq "$chmod $chown" && $ds eq "$devchmod $devchown") {
1180: $dirstatus='<TD BGCOLOR=#FFFFFF>runtime+development</TD>';
1181: }
1182: elsif ($ds eq "$chmod $chown") {
1183: $dirstatus='<TD BGCOLOR=#FFFFFF>runtime</TD>';
1184: }
1185: elsif ($ds eq "$devchmod $devchown") {
1186: $dirstatus='<TD BGCOLOR=#FFFFFF>development</TD>';
1187: }
1188: else {
1189: $dirstatus="<TD BGCOLOR=#FFFFFF><B><U>ERROR</U></B><BR>$ds</TD>";
1190: }
1191: }
1192: }
1193: $description.=<<END;
1194: <TR>
1195: $dirstatus
1196: <TD BGCOLOR=#FFFFFF>$category</TD>
1197: <TD BGCOLOR=#FFFFFF><TT>$chmod $chown</TT></TD>
1198: <TD BGCOLOR=#FFFFFF><FONT COLOR=#FF0000><TT>$devchmod $devchown</TT></FONT></TD>
1199: <TD>
1200: $dtable
1201: </TD>
1202: </TR>
1203: END
1204: }
1205: $description.=<<END;
1206: </TABLE>
1207: </P>
1208: END
1209: return $description;
1210: }
1211:
1212: # ------------------- Make file type ownership and permissions description block
1213: sub make_file_type_ownership_and_permissions_description_block {
1214: my ($mode)=@_;
1215: my $description=<<END;
1216: <FONT SIZE=+2>File Type Ownership and Permissions Descriptions, $date</FONT>
1217: <P>
1218: This table shows what permissions and ownership settings correspond
1219: to each kind of file type.
1220: </P>
1221: <P>
1222: <TABLE BORDER=1 CELLPADDING=5 WIDTH=60%>
1223: <TR>
1224: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Icon</TH>
1225: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Type</TH>
1226: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
1227: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Development Permissions</TH>
1228: </TR>
1229: END
1230: foreach my $type (keys %{$info{'OWNERSHIP'}}) {
1231: if (defined($fcm{$type})) {
1232: my $chmod=$info{'OWNERSHIP'}{$type}{'CHMOD'};
1233: my $chown=$info{'OWNERSHIP'}{$type}{'CHOWN'};
1234: my $devchmod=$info{'DEVOWNERSHIP'}{$type}{'CHMOD'};
1235: my $devchown=$info{'DEVOWNERSHIP'}{$type}{'CHOWN'};
1236: $description.=<<END;
1237: <TR>
1238: <TD><IMG SRC="$fcm{$type}.gif" ALT="$type"></TD>
1239: <TD>$type</TD>
1240: <TD><TT>$chmod $chown</TT></TD>
1241: <TD><TT>$devchmod $devchown</TT></TD>
1242: </TR>
1243: END
1244: }
1245: }
1246: $description.=<<END;
1247: </TABLE>
1248: </P>
1249: END
1250: }
1251:
1252: # ------------------------- Make directory and file structure description block
1253: sub make_directory_and_file_structure_description_block {
1254: my ($dirs,$mode)=@_;
1255: my $statusheader; my $filestatus;
1256: my $description=<<END;
1257: <FONT SIZE=+2>Directory and File Structure Description, $date</FONT>
1258: <P>
1259: The icons on the left column correspond to the file type
1260: specified in the second column. The last column "Notes" shows compilation,
1261: dependency, and configuration information. The CVS location
1262: shows the location of the binary source file (if applicable) needed to
1263: be copied to the target. If the binary source file is not at
1264: the specified location, then the text is shown in
1265: <FONT COLOR=#FF0000>red</FONT>.
1266: </P>
1267: <P>
1268: <TABLE BORDER=1 CELLPADDING=5 WIDTH=500>
1269: END
1270: my $counter=0;
1271: my @colorindex=("#80FF80","#80FFFF","#FFFF80");
1272: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
1273: foreach my $d (@$dirs) {
1274: # set color
1275: my $color=$colorindex[$counter%3];
1276: # set other values
1277: my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
1278: $dirdescription="(" . $dirdescription . ")" if $dirdescription;
1279: # find subdirectories that are contained in this directory
1280: my @subdirs;
1281: foreach my $d2 (@$dirs) {
1282: if ($d2=~/^$d\/([^\/]+)$/) {
1283: push @subdirs,$1;
1284: }
1285: }
1286: # find files that are contained in this directory
1287: my @files;
1288: my @filesfull;
1289: foreach my $f (@allfiles) {
1290: if ($f=~/^$d\/([^\/]+)$/) {
1291: push @files,$1;
1292: push @filesfull,$f;
1293: }
1294: }
1295: # render starting HTML formatting elements
1296: if (@subdirs || @files) {
1297: my $subdirstring="<BR>* Relevant subdirectories: " . join(", ",@subdirs) if @subdirs;
1298: $description.=<<END;
1299: <TR><TD BGCOLOR=#000000 COLSPAN=6><FONT COLOR=$color><IMG SRC="directory.gif" ALT="directory">DIRECTORY -- $d $dirdescription
1300: $subdirstring</FONT></TD></TR>
1301: END
1302: }
1303: else {
1304: $description.=<<END;
1305: <TR><TD BGCOLOR=#000000 COLSPAN=6><FONT COLOR=$color><IMG SRC="emptydirectory.gif" ALT="empty directory">EMPTY DIRECTORY - $d $dirdescription</FONT></TD></TR>
1306: END
1307: }
1308: if (@files) {
1309: if ($mode eq 'status') {
1310: $statusheader=<<END;
1311: <TH BGCOLOR=$color ALIGN=LEFT>Current Status</TH>
1312: END
1313: }
1314: $description.=<<END;
1315: <TR>
1316: $statusheader
1317: <TH BGCOLOR=$color ALIGN=LEFT COLSPAN=2>Type</TH>
1318: <TH BGCOLOR=$color ALIGN=LEFT>File Name</TH>
1319: <TH BGCOLOR=$color ALIGN=LEFT>Function</TH>
1320: <TH BGCOLOR=$color ALIGN=LEFT>CVS Location</TH>
1321: <TH BGCOLOR=$color ALIGN=LEFT>Notes</TH>
1322: </TR>
1323: END
1324: foreach my $i (0..$#files) {
1325: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
1326: my $fdescription=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DESCRIPTION'};
1327: my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
1328: my $note=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'NOTE'};
1329: $note.="<BR>" if $note;
1330: my $listing=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
1331: my @E=split(/\s+/,$listing);
1332: $source=~/(.*)\/[^\/]+$/;
1333: my $sd=$1;
1334: my $eflag=0;
1335: foreach my $e (@E) {
1336: unless (-e "../../$sd/$e") {
1337: $e="<FONT COLOR=#FF0000>$e</FONT>";
1338: $eflag=1;
1339: }
1340: }
1341: $listing=join("\n",@E);
1342: $listing="<B>listing</B><BR><FONT SIZE=-2>$listing</FONT>" if $listing;
1343: $listing.="<BR>" if $listing;
1344: my $build=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'BUILD'};
1345: $build="<B>build</B><BR>$build" if $build;
1346: $build.="<BR>" if $build;
1347: my $dependencies=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DEPENDENCIES'};
1348: $dependencies="<B>dependencies</B><BR>$dependencies" if $dependencies;
1349: $dependencies.="<BR>" if $dependencies;
1350: unless (-e "../../$source") {
1351: $source=~/([^\/]+)$/;
1352: my $s=$1;
1353: if ($source!~/\*/) {
1354: $source="<FONT COLOR=#FF0000>$source</FONT>";
1355: }
1356: elsif ($eflag) {
1357: $source="<FONT COLOR=#FF0000>$source</FONT>";
1358: }
1359: }
1360: if ($mode eq 'status') {
1361: $filestatus='';
1362: my $fs;
1363: my $listing2=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
1364: my @E=split(/\s+/,$listing2); shift @E;
1365: if (@E) {
1366: $fs=`find /$filesfull[$i] -prune -printf "\%m\t\%u\t\%g\n" 2>/dev/null | wc -l`; chop $fs;
1367: if ($fs!=(@E+0)) {
1368: $ecount=(@E+0);
1369: $estuff=join(",",@E);
1370: $filestatus="<TD BGCOLOR=#FFFFFF><B><U>ERROR. SOME FILES ARE MISSING</U></B></TD>";
1371: }
1372: $fs=`find /$filesfull[$i] -prune -printf "\%m\t\%u\t\%g\n" 2>/dev/null | sort | uniq | wc -l`; chop $fs;
1373: if ($fs!=1) {
1374: $filestatus='<TD BGCOLOR=#FFFFFF><B><U>ERROR. THERE ARE MULTIPLE OWNERSHIPS/PERMISSIONS WHEN ALL THESE FILES SHOULD HAVE THE SAME CONFIGURATION</U></B></TD>';
1375: }
1376: else {
1377: $fs=`find /$filesfull[$i] -prune -printf "\%m\t\%u\t\%g\n" 2>/dev/null | sort | uniq`; chop $fs;
1378: }
1379: }
1380: else {
1381: $fs=`find /$filesfull[$i] -prune -printf "\%m\t\%u\t\%g" 2>/dev/null`;
1382: }
1383: my $fsl=`find /$filesfull[$i] -type l -prune -printf "\%m\t\%u\t\%g" 2>/dev/null`;
1384: unless ($fs || $filestatus) {
1385: $filestatus='<TD BGCOLOR=#FFFFFF><B><U>MISSING</U></B></TD>';
1386: }
1387: elsif (!$filestatus) {
1388:
1389: $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
1390: $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
1391: $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
1392: $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
1393:
1394: my @fss=split(/\t/,$fs);
1395: my $fssz=$fss[0];
1396: $fssz="0" . $fss[0] if length($fss[0])<4;
1397: $fss[0]=$fssz;
1398: $fs="$fss[0] $fss[1]:$fss[2]";
1399: $s=' ';
1400: if ($fsl) {
1401: $fs="$fss[1]:$fss[2]";
1402: $s='';
1403: }
1404: if ($fs eq "$chmod$s$chown" && $fs eq "$devchmod$s$devchown") {
1405: $filestatus='<TD BGCOLOR=#FFFFFF>runtime+development</TD>';
1406: }
1407: elsif ($fs eq "$chmod$s$chown") {
1408: $filestatus='<TD BGCOLOR=#FFFFFF>runtime</TD>';
1409: }
1410: elsif ($fs eq "$devchmod$s$devchown") {
1411: $filestatus='<TD BGCOLOR=#FFFFFF>development</TD>';
1412: }
1413: else {
1414: $filestatus="<TD BGCOLOR=#FFFFFF><B><U>ERROR</U></B><BR>$fs</TD>";
1415: }
1416: }
1417: }
1418: $description.=<<END;
1419: <TR>
1420: $filestatus
1421: <TD BGCOLOR=#A0A0A0><IMG SRC="$fcm{$category}.gif" ALT="$category"></TD>
1422: <TD BGCOLOR=$color>$category</TD>
1423: <TD BGCOLOR=$color>$files[$i]</TD>
1424: <TD BGCOLOR=$color>$fdescription </TD>
1425: <TD BGCOLOR=$color>$source</TD>
1426: <TD BGCOLOR=$color>$note$listing$build$dependencies </TD>
1427: </TR>
1428: END
1429: }
1430: }
1431: $counter++;
1432: }
1433: $description.=<<END;
1434: </TABLE>
1435: </P>
1436: END
1437: return $description;
1438: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>