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