Annotation of loncom/build/parse.pl, revision 1.13
1.1 harris41 1: #!/usr/bin/perl
2:
3: # Scott Harrison
4: # November 2000
5:
1.2 harris41 6: # Read in loncapa tags and metagroup tags
1.1 harris41 7:
1.4 harris41 8: # ---------------------------------------------- Read in command line arguments
1.1 harris41 9: my ($file,$mode)=@ARGV;
1.2 harris41 10:
1.4 harris41 11: # ---------------------------------------------------- Read in master data file
1.1 harris41 12: open IN,"<$file";
13: my @lines=<IN>;
14: close IN;
1.5 harris41 15: my $info1=join('',@lines);
16: my $info2=$info1; # value to allow for meta data group retrieval
1.1 harris41 17:
1.4 harris41 18: # ------------------------------------------------------- Make default settings
19: my $distribution="redhat6.2";
20: my $date=`date +'%B %e, %Y'`; chop $date;
21: my $buildhost=`hostname`; chop $buildhost;
1.5 harris41 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: );
1.4 harris41 35:
36: # ---------------------------------------------------- Parse the marked up data
37: my %info; # big data storage object
1.5 harris41 38: while ($info1=~/\<loncapa\s+(.*?)\>/isg) {
1.1 harris41 39: my $keystring=$1;
1.4 harris41 40: # In the parsing of LON-CAPA tags, remove boundary white-space,
41: # and handle quotation commands.
1.2 harris41 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);
1.4 harris41 47: # Handle the different types of commands
1.1 harris41 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") {
1.4 harris41 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'};
1.1 harris41 65: }
66: elsif (uc($hash{'TYPE'}) eq "LOCATION") {
1.5 harris41 67: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'CATEGORY'}= $hash{'CATEGORY'};
1.10 harris41 68: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'LINKTO'}= $hash{'LINKTO'};
1.5 harris41 69: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'SOURCE'}= $hash{'SOURCE'};
1.1 harris41 70: # get surrounding metagroup information
71: my $ckeystring=$keystring; $ckeystring=~s/(SOURCE\=\"[^"]*)\*/$1\\\*/g;
1.5 harris41 72: $ckeystring=~s/(TARGET\=\"[^"]*)\*/$1\\\*/g;
1.1 harris41 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);
1.9 harris41 79: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{uc($key)}=
1.4 harris41 80: $value;
1.1 harris41 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:
1.10 harris41 89: my $a;
90: my @directories;
91: if ($mode eq "HTML") {
1.4 harris41 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;
1.6 harris41 99: $a=&make_file_type_ownership_and_permissions_description_block;
100: print $a;
1.4 harris41 101: $a=&make_directory_and_file_structure_description_block(\@directories);
102: print $a;
103: $a=&end_description_page;
104: print $a;
105: }
1.10 harris41 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_install_segment(\@directories);
125: print $a;
126: $a=&make_files_install_segment(\@directories);
127: print $a;
128: $a=&make_links_install_segment(\@directories);
129: print $a;
130: }
1.11 harris41 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:
150: }
1.10 harris41 151: elsif ($mode eq "status") {
152: }
153: elsif ($mode eq "update") {
154: }
155: elsif ($mode eq "freshinstall") {
1.11 harris41 156: }
157:
158: # ------------------------------------------------------ a list of file targets
159: sub make_file_list {
160: my ($dirs)=@_;
161: my $description;
162: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
163: foreach my $d (@$dirs) {
164: # set other values
165: my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
166: $dirdescription="(" . $dirdescription . ")" if $dirdescription;
167: # find files that are contained in this directory
168: my @files;
169: my @filesfull;
170: foreach my $f (@allfiles) {
171: if ($f=~/^$d\/([^\/]+)$/) {
172: push @files,$1;
173: push @filesfull,$f;
174: }
175: }
176: # render starting HTML formatting elements
177: if (@files) {
178: }
1.12 harris41 179: my $pwd=`pwd`; chop $pwd;
1.11 harris41 180: if (@files) {
181: foreach my $i (0..$#files) {
182: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
183: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
184: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
185: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
186: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
187: my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
188: my $rot="/".$filesfull[$i];
189: if ($rot=~/\*/) {
190: $rot=~s/[^\/]+$// if $rot=~/\*/;
191: my $listing=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
192: chop $listing;
193: my @list=split(/\s+/,$listing);
194: my $rot2;
195: foreach my $l (@list) {
196: $l=~s/^\s*//; $l=~s/\s*$//;
1.12 harris41 197: $rot2.="BinaryRoot$rot$l\n" if length($l);
1.11 harris41 198: }
199: chop $rot2;
200: $rot=$rot2;
1.12 harris41 201: }
202: else {
203: $rot="BinaryRoot$rot";
1.11 harris41 204: }
1.13 ! harris41 205: if ($category eq "conf") {
! 206: $rot.=" # config";
! 207: }
1.11 harris41 208: $description.=<<END;
209: $rot
210: END
211: }
212: }
213: }
214: $description.=<<END;
215:
216: END
217: return $description;
218: }
219:
220: # --------------------------------- Commands to make BinaryRoot directories
221: sub make_directory_binaryroot_segment {
222: my ($dirs)=@_;
223: my $description=<<END;
224: directories:
225: END
226: foreach my $d (@$dirs) {
227: my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
228: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
229: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
230: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
231: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
232: my $own=$devchown; $own=~s/\:/\,/;
233: $description.=<<END;
234: \tinstall -m $devchmod -d \$(TARGET)/$d
235: END
236: }
237: $description.=<<END;
238:
239: END
240: return $description;
241: }
242:
243: # --------------------------------------- Commands to make BinaryRoot files
244: sub make_files_binaryroot_segment {
245: my ($dirs)=@_;
246: my $description=<<END;
247: files:
248: END
249: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
250: foreach my $d (@$dirs) {
251: # set other values
252: my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
253: $dirdescription="(" . $dirdescription . ")" if $dirdescription;
254: # find files that are contained in this directory
255: my @files;
256: my @filesfull;
257: foreach my $f (@allfiles) {
258: if ($f=~/^$d\/([^\/]+)$/) {
259: push @files,$1;
260: push @filesfull,$f;
261: }
262: }
263: # render starting HTML formatting elements
264: if (@files) {
265: $description.=<<END;
266: \t# $d $dirdescription
267: END
268: }
269: if (@files) {
270: foreach my $i (0..$#files) {
271: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
272: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
273: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
274: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
275: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
276: my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
277: my $rot=$filesfull[$i];
278: $rot=~s/[^\/]+$/\./ if $rot=~/\*/;
279: $description.=<<END if $category ne 'symbolic link';
280: \tinstall -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
281: END
282: }
283: }
284: }
285: $description.=<<END;
286:
287: END
288: return $description;
289: }
290:
291: # ------------------------------ Commands to make BinaryRoot symbolic links
292: sub make_links_binaryroot_segment {
293: my ($dirs)=@_;
294: my $description=<<END;
295: links:
296: END
297: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
298: foreach my $d (@$dirs) {
299: # find files that are contained in this directory
300: my @files;
301: my @filesfull;
302: foreach my $f (@allfiles) {
303: if ($f=~/^$d\/([^\/]+)$/) {
304: push @files,$1;
305: push @filesfull,$f;
306: }
307: }
308: # render starting HTML formatting elements
309: if (@files) {
310: foreach my $i (0..$#files) {
311: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
312: my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
313: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
314: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
315: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
316: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
317: $description.=<<END if $category eq 'symbolic link';
318: \tln -s /$linkto \$(TARGET)/$filesfull[$i]
319: END
320: }
321: }
322: }
323: $description.=<<END;
324:
325: END
326: return $description;
1.10 harris41 327: }
328:
329: # --------------------------------- Installation commands to install directories
330: sub make_directory_install_segment {
331: my ($dirs)=@_;
332: my $description=<<END;
333: directories:
334: END
335: foreach my $d (@$dirs) {
336: my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
337: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
338: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
339: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
340: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
341: my $own=$devchown; $own=~s/\:/\,/;
342: $description.=<<END;
343: \tinstall -m $devchmod -d \$(SOURCE)/$d \$(ROOT)/$d
344: END
345: }
346: $description.=<<END;
347:
348: END
349: return $description;
350: }
351:
352: # --------------------------------------- Installation commands to install files
353: sub make_files_install_segment {
354: my ($dirs)=@_;
355: my $description=<<END;
356: files:
357: END
358: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
359: foreach my $d (@$dirs) {
360: # set other values
361: my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
362: $dirdescription="(" . $dirdescription . ")" if $dirdescription;
363: # find files that are contained in this directory
364: my @files;
365: my @filesfull;
366: foreach my $f (@allfiles) {
367: if ($f=~/^$d\/([^\/]+)$/) {
368: push @files,$1;
369: push @filesfull,$f;
370: }
371: }
372: # render starting HTML formatting elements
373: if (@files) {
374: $description.=<<END;
375: \t# $d $dirdescription
376: END
377: }
378: if (@files) {
379: foreach my $i (0..$#files) {
380: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
381: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
382: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
383: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
384: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
385: my $rot=$filesfull[$i];
386: $rot=~s/[^\/]+$/\./ if $rot=~/\*/;
387: $description.=<<END if $category ne 'symbolic link';
388: \tinstall -m $devchmod \$(SOURCE)/$filesfull[$i] \$(ROOT)/$rot
389: END
390: }
391: }
392: }
393: $description.=<<END;
394:
395: END
396: return $description;
397: }
398:
399: # ------------------------------ Installation commands to install symbolic links
400: sub make_links_install_segment {
401: my ($dirs)=@_;
402: my $description=<<END;
403: links:
404: END
405: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
406: foreach my $d (@$dirs) {
407: # find files that are contained in this directory
408: my @files;
409: my @filesfull;
410: foreach my $f (@allfiles) {
411: if ($f=~/^$d\/([^\/]+)$/) {
412: push @files,$1;
413: push @filesfull,$f;
414: }
415: }
416: # render starting HTML formatting elements
417: if (@files) {
418: foreach my $i (0..$#files) {
419: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
420: my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
421: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
422: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
423: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
424: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
425: $description.=<<END if $category eq 'symbolic link';
426: \tln -s /$linkto \$(ROOT)/$filesfull[$i]
427: END
428: }
429: }
430: }
431: $description.=<<END;
1.4 harris41 432:
1.10 harris41 433: END
434: return $description;
435: }
436:
437: # --------------------------------------------------------- Make RPM .spec block
438: sub make_rpm_spec_block {
439: my $pwd=`pwd`; chop $pwd;
440: my $buildroot="$pwd/LON-CAPA-BuildRoot";
441: my $source=$info{'RPM'}{'Name'} . "-" . $info{'RPM'}{'Version'} . '.tar.gz';
442: my $description=<<END;
443: Summary: $info{'RPM'}{'Summary'}
444: Name: $info{'RPM'}{'Name'}
445: Version: $info{'RPM'}{'Version'}
446: Release: $info{'RPM'}{'Release'}
447: Vendor: $info{'RPM'}{'Vendor'}
448: BuildRoot: $buildroot
449: Copyright: $info{'RPM'}{'Copyright'}
450: Group: $info{'RPM'}{'Group'}
451: Source: $source
452: AutoReqProv: $info{'RPM'}{'AutoReqProv'}
453: \%description
454: $info{'RPM'}{'description'}
455:
456: END
457: return $description;
458: }
459:
460: # --------------------------------------------------- Make RPM build .spec block
461: sub make_rpm_build_block {
462: my $pwd=`pwd`; chop $pwd;
463: my $buildroot="$pwd/LON-CAPA-BuildRoot";
464: my $sourceroot="$pwd/LON-CAPA-SourceRoot";
465: my $description=<<END;
466:
467: \%prep
468: \%setup
469:
470: \%build
471: rm -Rf "$buildroot"
472:
473: \%install
474: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" directories
475: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" files
476: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" links
477:
478: \%pre
479: $info{'RPM'}{'pre'}
480:
481: \%post
482: \%postun
483:
484: \%files
485: # \%doc README COPYING ChangeLog LICENSE
486: END
487: return $description;
488: }
489:
490: # ------------------------------------- Make directory structure RPM .spec block
491: sub make_directory_structure_spec_block {
492: my ($dirs)=@_;
493: foreach my $d (@$dirs) {
494: my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
495: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
496: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
497: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
498: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
499: my $own=$devchown; $own=~s/\:/\,/;
500: $description.=<<END;
501: \%dir \%attr($devchmod,$own) /$d
502: END
503: }
504: return $description;
505: }
506:
507: # ---------------------------- Make directory and file structure RPM .spec block
508: sub make_directory_and_file_structure_spec_block {
509: my ($dirs)=@_;
510: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
511: foreach my $d (@$dirs) {
512: # set other values
513: my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
514: $dirdescription="(" . $dirdescription . ")" if $dirdescription;
515: # find files that are contained in this directory
516: my @files;
517: my @filesfull;
518: foreach my $f (@allfiles) {
519: if ($f=~/^$d\/([^\/]+)$/) {
520: push @files,$1;
521: push @filesfull,$f;
522: }
523: }
524: # render starting HTML formatting elements
525: if (@files) {
526: $description.=<<END;
527: # $d $dirdescription
528: END
529: }
530: if (@files) {
531: foreach my $i (0..$#files) {
532: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
533: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
534: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
535: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
536: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
537: my $own=$devchown; $own=~s/\:/\,/;
538: my $config="";
539: $config="\%config " if $category eq 'conf';
540: $devchmod='-' if $category eq 'symbolic link';
541: $description.=<<END;
542: $config\%attr($devchmod,$own) /$filesfull[$i]
543: END
544: }
545: }
546: }
547: return $description;
548: }
549:
550: # ----------------------------------------------------------- End RPM .spec page
551: sub end_spec_page {
552: }
553:
554: # ------------------------------------------------------- Begin description page
1.4 harris41 555: sub begin_description_page {
556: my $description=<<END;
557: <HTML>
558: <HEAD>
559: <TITLE>LON-CAPA Software Description Page ($distribution, $date)</TITLE>
560: </HEAD>
561: <BODY>
562: <FONT SIZE=+2>LON-CAPA Software Description Page ($distribution, $date)</FONT>
563: <BR>Michigan State University
564: <BR>Learning Online with CAPA
565: <BR>Contact korte\@lon-capa.org
566: <UL>
567: <LI>About this file
568: <LI>Software Package Description
569: <LI>Directory Structure
1.7 harris41 570: <LI>File Type Ownership and Permissions
1.4 harris41 571: <LI>File and Directory Structure
572: </UL>
573: <FONT SIZE=+2>About this file</FONT>
574: <P>
575: This file is generated dynamically by <TT>parse.pl</TT> as
576: part of a development compilation process. See
577: http://install.lon-capa.org/compile/index.html for more
578: information.
579: </P>
580: END
581: return $description;
582: }
583:
584: # ------------------------------------------------- End description page
585: sub end_description_page {
586: my $description=<<END;
587: <HR>
1.5 harris41 588: <FONT SIZE=-1>LON-CAPA Software Development Team</FONT>
1.4 harris41 589: </BODY>
590: </HTML>
591: END
592: return $description;
593: }
594:
595: # ------------------------------------------------- Make RPM description block
596: sub make_rpm_description_block {
597: my $description=<<END;
598: <FONT SIZE=+2>Rolled in a RedHat 6.2 RPM, $date</FONT>
599: <P>
600: <TABLE BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=10 CELLSPACING=0>
601: <TR><TD>
602: <PRE>
603: Name : $info{'RPM'}{'Name'}
604: Version : $info{'RPM'}{'Version'}
605: Vendor : $info{'RPM'}{'Vendor'}
606: Release : $info{'RPM'}{'Release'}
607: Build Host : $buildhost
608: Group : $info{'RPM'}{'Group'}
609: License : $info{'RPM'}{'Copyright'}
610: Summary : $info{'RPM'}{'Summary'}
611: Description :
612: $info{'RPM'}{'description'}
613: </PRE>
614: </TD></TR>
615: </TABLE>
616: </P>
617: END
618: return $description;
619: }
620:
621: # ----------------------------------------------- Determine directory structure
622: sub determine_directory_structure {
623: my @directories=keys %{$info{'DIRECTORY'}{$distribution}};
624: return (sort @directories);
625: }
1.1 harris41 626:
1.4 harris41 627:
628: # ---------------------------------- Make directory structure description block
629: sub make_directory_structure_description_block {
630: my ($dirs)=@_;
631: my $description=<<END;
632: <FONT SIZE=+2>Directory Structure Description, $date</FONT>
633: <P>
1.9 harris41 634: The directory structure description below shows only those
635: directories which either contain LON-CAPA specific files
636: or normally do not exist on a RedHat Linux system (and
637: must be generated to allow proper placement of files
638: during LON-CAPA run-time operation).
639: </P>
640: <P>
1.4 harris41 641: <TABLE BORDER=1 CELLPADDING=3 CELLSPACING=0>
642: END
643: my $maxcount=0;
1.8 harris41 644: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
645: my %diraccount; # hash to track which directories are accounted for
646: foreach my $file (@allfiles) {
647: $file=~/^(.*)\/([^\/]+)$/;
648: $diraccount{$1}=1;
649: }
1.4 harris41 650: foreach my $d (@$dirs) {
651: my (@matches)=($d=~/\//g);
652: my $count=scalar(@matches);
653: $maxcount=$count if $count>$maxcount;
1.8 harris41 654: delete $diraccount{$d};
1.4 harris41 655: }
656: $description.=<<END;
657: <TR>
658: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Category</TH>
659: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
660: <TH ALIGN=LEFT BGCOLOR=#FFFFFF><FONT COLOR=#FF0000>Development<BR>Permissions</FONT></TH>
661: END
662: $description.="<TH ALIGN=LEFT BGCOLOR=#FFFFFF COLSPAN=".($maxcount+1).">Directory Path</TH>\n";
1.8 harris41 663: if (keys %diraccount) {
664: $description.= "<TR><TD ALIGN=LEFT BGCOLOR=#FFFFFF COLSPAN=".($maxcount+4)."><I><PRE>Directories that are unaccounted for: \n";
665: foreach my $d (keys %diraccount) {
666: $description.="$d\n";
667: }
668: $description.="</PRE></I></TH></TR>\n";
669: }
1.4 harris41 670: foreach my $d (@$dirs) {
671: my $dtable=$d;
672: $dtable=~s/\//\<\/TD\>\<TD\>/g;
673: my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
674: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
675: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
676: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
677: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
678: $description.=<<END;
679: <TR>
680: <TD BGCOLOR=#FFFFFF>$category</TD>
681: <TD BGCOLOR=#FFFFFF><TT>$chmod $chown</TT></TD>
682: <TD BGCOLOR=#FFFFFF><FONT COLOR=#FF0000><TT>$devchmod $devchown</TT></FONT></TD>
683: <TD>
684: $dtable
685: </TD>
686: </TR>
687: END
688: }
689: $description.=<<END;
690: </TABLE>
691: </P>
692: END
693: return $description;
694: }
695:
1.6 harris41 696: # ------------------- Make file type ownership and permissions description block
697: sub make_file_type_ownership_and_permissions_description_block {
698: my $description=<<END;
699: <FONT SIZE=+2>File Type Ownership and Permissions Descriptions, $date</FONT>
700: <P>
701: This table shows what permissions and ownership settings correspond
702: to each kind of file type.
703: </P>
704: <P>
705: <TABLE BORDER=1 CELLPADDING=5 WIDTH=60%>
706: <TR>
707: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Icon</TH>
708: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Type</TH>
709: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
710: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Development Permissions</TH>
711: </TR>
712: END
713: foreach my $type (keys %{$info{'OWNERSHIP'}}) {
714: if (defined($fcm{$type})) {
715: my $chmod=$info{'OWNERSHIP'}{$type}{'CHMOD'};
716: my $chown=$info{'OWNERSHIP'}{$type}{'CHOWN'};
717: my $devchmod=$info{'DEVOWNERSHIP'}{$type}{'CHMOD'};
718: my $devchown=$info{'DEVOWNERSHIP'}{$type}{'CHOWN'};
719: $description.=<<END;
720: <TR>
721: <TD><IMG SRC="$fcm{$type}.gif" ALT="$type"></TD>
722: <TD>$type</TD>
723: <TD><TT>$chmod $chown</TT></TD>
724: <TD><TT>$devchmod $devchown</TT></TD>
725: </TR>
726: END
727: }
728: }
729: $description.=<<END;
730: </TABLE>
731: </P>
732: END
733: }
734:
1.4 harris41 735: # ------------------------- Make directory and file structure description block
736: sub make_directory_and_file_structure_description_block {
737: my ($dirs)=@_;
738: my $description=<<END;
739: <FONT SIZE=+2>Directory and File Structure Description, $date</FONT>
1.6 harris41 740: <P>
741: The icons on the left column correspond to the file type
742: specified in the second column. The last column "Notes" shows compilation,
1.7 harris41 743: dependency, and configuration information. The CVS location
744: shows the location of the binary source file (if applicable) needed to
745: be copied to the target. If the binary source file is not at
746: the specified location, then the text is shown in
747: <FONT COLOR=#FF0000>red</FONT>.
1.6 harris41 748: </P>
1.4 harris41 749: <P>
1.9 harris41 750: <TABLE BORDER=1 CELLPADDING=5 WIDTH=500>
1.4 harris41 751: END
752: my $counter=0;
753: my @colorindex=("#80FF80","#80FFFF","#FFFF80");
1.5 harris41 754: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
1.4 harris41 755: foreach my $d (@$dirs) {
756: # set color
757: my $color=$colorindex[$counter%3];
758: # set other values
759: my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
760: $dirdescription="(" . $dirdescription . ")" if $dirdescription;
761: # find subdirectories that are contained in this directory
762: my @subdirs;
763: foreach my $d2 (@$dirs) {
1.5 harris41 764: if ($d2=~/^$d\/([^\/]+)$/) {
1.4 harris41 765: push @subdirs,$1;
766: }
767: }
768: # find files that are contained in this directory
769: my @files;
1.5 harris41 770: my @filesfull;
1.4 harris41 771: foreach my $f (@allfiles) {
1.5 harris41 772: if ($f=~/^$d\/([^\/]+)$/) {
1.4 harris41 773: push @files,$1;
1.5 harris41 774: push @filesfull,$f;
1.4 harris41 775: }
776: }
777: # render starting HTML formatting elements
778: if (@subdirs || @files) {
779: my $subdirstring="<BR>* Relevant subdirectories: " . join(", ",@subdirs) if @subdirs;
780: $description.=<<END;
1.5 harris41 781: <TR><TD BGCOLOR=#000000 COLSPAN=6><FONT COLOR=$color><IMG SRC="directory.gif" ALT="directory">DIRECTORY -- $d $dirdescription
782: $subdirstring</FONT></TD></TR>
1.4 harris41 783: END
784: }
785: else {
786: $description.=<<END;
1.5 harris41 787: <TR><TD BGCOLOR=#000000 COLSPAN=6><FONT COLOR=$color><IMG SRC="emptydirectory.gif" ALT="empty directory">EMPTY DIRECTORY - $d $dirdescription</FONT></TD></TR>
1.4 harris41 788: END
789: }
790: if (@files) {
791: $description.=<<END;
792: <TR>
1.5 harris41 793: <TH BGCOLOR=$color ALIGN=LEFT COLSPAN=2>Type</TH>
794: <TH BGCOLOR=$color ALIGN=LEFT>File Name</TH>
795: <TH BGCOLOR=$color ALIGN=LEFT>Function</TH>
796: <TH BGCOLOR=$color ALIGN=LEFT>CVS Location</TH>
797: <TH BGCOLOR=$color ALIGN=LEFT>Notes</TH>
1.4 harris41 798: </TR>
799: END
1.5 harris41 800: foreach my $i (0..$#files) {
801: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
802: my $fdescription=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DESCRIPTION'};
803: my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
1.9 harris41 804: my $note=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'NOTE'};
805: $note.="<BR>" if $note;
806: my $listing=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
807: my @E=split(/\s+/,$listing);
808: $source=~/(.*)\/[^\/]+$/;
809: my $sd=$1;
810: my $eflag=0;
811: foreach my $e (@E) {
812: unless (-e "../../$sd/$e") {
813: $e="<FONT COLOR=#FF0000>$e</FONT>";
814: $eflag=1;
815: }
816: }
817: $listing=join("\n",@E);
818: $listing="<B>listing</B><BR><FONT SIZE=-2>$listing</FONT>" if $listing;
819: $listing.="<BR>" if $listing;
820: my $build=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'BUILD'};
821: $build="<B>build</B><BR>$build" if $build;
822: $build.="<BR>" if $build;
823: my $dependencies=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DEPENDENCIES'};
824: $dependencies="<B>dependencies</B><BR>$dependencies" if $dependencies;
825: $dependencies.="<BR>" if $dependencies;
1.7 harris41 826: unless (-e "../../$source") {
827: $source=~/([^\/]+)$/;
828: my $s=$1;
1.9 harris41 829: if ($source!~/\*/) {
830: $source="<FONT COLOR=#FF0000>$source</FONT>";
831: }
832: elsif ($eflag) {
833: $source="<FONT COLOR=#FF0000>$source</FONT>";
834: }
1.7 harris41 835: }
1.5 harris41 836: $description.=<<END;
837: <TR>
838: <TD BGCOLOR=#A0A0A0><IMG SRC="$fcm{$category}.gif" ALT="$category"></TD>
839: <TD BGCOLOR=$color>$category</TD>
840: <TD BGCOLOR=$color>$files[$i]</TD>
841: <TD BGCOLOR=$color>$fdescription </TD>
842: <TD BGCOLOR=$color>$source</TD>
1.9 harris41 843: <TD BGCOLOR=$color>$note$listing$build$dependencies </TD>
1.4 harris41 844: </TR>
845: END
1.5 harris41 846: }
847: }
1.4 harris41 848: $counter++;
849: }
850: $description.=<<END;
851: </TABLE>
852: </P>
853: END
854: return $description;
855: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>