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'}}{'SOURCE'}= $hash{'SOURCE'};
69: # get surrounding metagroup information
70: my $ckeystring=$keystring; $ckeystring=~s/(SOURCE\=\"[^"]*)\*/$1\\\*/g;
71: $ckeystring=~s/(TARGET\=\"[^"]*)\*/$1\\\*/g;
72: $info2=~/.*\<(?:metagroup|metasupergroup)\>(.*?)\<loncapa\s+$ckeystring\>(.*?)\<\/(?:metagroup|metasupergroup)\>/is;
73: my $data=$1.$2;
74: my @meta=('description','build','dependencies','files','note');
75: foreach my $m (@meta) {
76: if ($data=~/\<($m)\>(.*?)\<\/$m\>/sgi) {
77: my ($key,$value)=($1,$2);
78: $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{$key}=
79: $value;
80: }
81: }
82: }
83: else {
84: warn("WARNING: this tag text will be ignored since it cannot be understood\n---> $keystring\n");
85: }
86: }
87:
88: if ($mode eq "ALL" || $mode eq "HTML") {
89: my $a;
90: $a=&begin_description_page;
91: print $a;
92: $a=&make_rpm_description_block;
93: print $a;
94: @directories=&determine_directory_structure;
95: $a=&make_directory_structure_description_block(\@directories);
96: print $a;
97: $a=&make_file_type_ownership_and_permissions_description_block;
98: print $a;
99: $a=&make_directory_and_file_structure_description_block(\@directories);
100: print $a;
101: $a=&end_description_page;
102: print $a;
103: }
104:
105: # ------------------------------------------------- Begin description page
106: sub begin_description_page {
107: my $description=<<END;
108: <HTML>
109: <HEAD>
110: <TITLE>LON-CAPA Software Description Page ($distribution, $date)</TITLE>
111: </HEAD>
112: <BODY>
113: <FONT SIZE=+2>LON-CAPA Software Description Page ($distribution, $date)</FONT>
114: <BR>Michigan State University
115: <BR>Learning Online with CAPA
116: <BR>Contact korte\@lon-capa.org
117: <UL>
118: <LI>About this file
119: <LI>Software Package Description
120: <LI>Directory Structure
121: <LI>File Type Ownership and Permissions
122: <LI>File and Directory Structure
123: </UL>
124: <FONT SIZE=+2>About this file</FONT>
125: <P>
126: This file is generated dynamically by <TT>parse.pl</TT> as
127: part of a development compilation process. See
128: http://install.lon-capa.org/compile/index.html for more
129: information.
130: </P>
131: END
132: return $description;
133: }
134:
135: # ------------------------------------------------- End description page
136: sub end_description_page {
137: my $description=<<END;
138: <HR>
139: <FONT SIZE=-1>LON-CAPA Software Development Team</FONT>
140: </BODY>
141: </HTML>
142: END
143: return $description;
144: }
145:
146: # ------------------------------------------------- Make RPM description block
147: sub make_rpm_description_block {
148: my $description=<<END;
149: <FONT SIZE=+2>Rolled in a RedHat 6.2 RPM, $date</FONT>
150: <P>
151: <TABLE BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=10 CELLSPACING=0>
152: <TR><TD>
153: <PRE>
154: Name : $info{'RPM'}{'Name'}
155: Version : $info{'RPM'}{'Version'}
156: Vendor : $info{'RPM'}{'Vendor'}
157: Release : $info{'RPM'}{'Release'}
158: Build Host : $buildhost
159: Group : $info{'RPM'}{'Group'}
160: License : $info{'RPM'}{'Copyright'}
161: Summary : $info{'RPM'}{'Summary'}
162: Description :
163: <PRE>
164: $info{'RPM'}{'description'}
165: </PRE>
166: </TD></TR>
167: </TABLE>
168: </P>
169: END
170: return $description;
171: }
172:
173: # ----------------------------------------------- Determine directory structure
174: sub determine_directory_structure {
175: my @directories=keys %{$info{'DIRECTORY'}{$distribution}};
176: return (sort @directories);
177: }
178:
179:
180: # ---------------------------------- Make directory structure description block
181: sub make_directory_structure_description_block {
182: my ($dirs)=@_;
183: my $description=<<END;
184: <FONT SIZE=+2>Directory Structure Description, $date</FONT>
185: <P>
186: <TABLE BORDER=1 CELLPADDING=3 CELLSPACING=0>
187: END
188: my $maxcount=0;
189: foreach my $d (@$dirs) {
190: my (@matches)=($d=~/\//g);
191: my $count=scalar(@matches);
192: $maxcount=$count if $count>$maxcount;
193: }
194: $description.=<<END;
195: <TR>
196: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Category</TH>
197: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
198: <TH ALIGN=LEFT BGCOLOR=#FFFFFF><FONT COLOR=#FF0000>Development<BR>Permissions</FONT></TH>
199: END
200: $description.="<TH ALIGN=LEFT BGCOLOR=#FFFFFF COLSPAN=".($maxcount+1).">Directory Path</TH>\n";
201: foreach my $d (@$dirs) {
202: my $dtable=$d;
203: $dtable=~s/\//\<\/TD\>\<TD\>/g;
204: my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
205: my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
206: my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
207: my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
208: my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
209: $description.=<<END;
210: <TR>
211: <TD BGCOLOR=#FFFFFF>$category</TD>
212: <TD BGCOLOR=#FFFFFF><TT>$chmod $chown</TT></TD>
213: <TD BGCOLOR=#FFFFFF><FONT COLOR=#FF0000><TT>$devchmod $devchown</TT></FONT></TD>
214: <TD>
215: $dtable
216: </TD>
217: </TR>
218: END
219: }
220: $description.=<<END;
221: </TABLE>
222: </P>
223: END
224: return $description;
225: }
226:
227: # ------------------- Make file type ownership and permissions description block
228: sub make_file_type_ownership_and_permissions_description_block {
229: my $description=<<END;
230: <FONT SIZE=+2>File Type Ownership and Permissions Descriptions, $date</FONT>
231: <P>
232: This table shows what permissions and ownership settings correspond
233: to each kind of file type.
234: </P>
235: <P>
236: <TABLE BORDER=1 CELLPADDING=5 WIDTH=60%>
237: <TR>
238: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Icon</TH>
239: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Type</TH>
240: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
241: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Development Permissions</TH>
242: </TR>
243: END
244: foreach my $type (keys %{$info{'OWNERSHIP'}}) {
245: if (defined($fcm{$type})) {
246: my $chmod=$info{'OWNERSHIP'}{$type}{'CHMOD'};
247: my $chown=$info{'OWNERSHIP'}{$type}{'CHOWN'};
248: my $devchmod=$info{'DEVOWNERSHIP'}{$type}{'CHMOD'};
249: my $devchown=$info{'DEVOWNERSHIP'}{$type}{'CHOWN'};
250: $description.=<<END;
251: <TR>
252: <TD><IMG SRC="$fcm{$type}.gif" ALT="$type"></TD>
253: <TD>$type</TD>
254: <TD><TT>$chmod $chown</TT></TD>
255: <TD><TT>$devchmod $devchown</TT></TD>
256: </TR>
257: END
258: }
259: }
260: $description.=<<END;
261: </TABLE>
262: </P>
263: END
264: }
265:
266: # ------------------------- Make directory and file structure description block
267: sub make_directory_and_file_structure_description_block {
268: my ($dirs)=@_;
269: my $description=<<END;
270: <FONT SIZE=+2>Directory and File Structure Description, $date</FONT>
271: <P>
272: The icons on the left column correspond to the file type
273: specified in the second column. The last column "Notes" shows compilation,
274: dependency, and configuration information. The CVS location
275: shows the location of the binary source file (if applicable) needed to
276: be copied to the target. If the binary source file is not at
277: the specified location, then the text is shown in
278: <FONT COLOR=#FF0000>red</FONT>.
279: </P>
280: <P>
281: <TABLE BORDER=1 CELLPADDING=5 WIDTH=60%>
282: END
283: my $counter=0;
284: my @colorindex=("#80FF80","#80FFFF","#FFFF80");
285: my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
286: foreach my $d (@$dirs) {
287: # set color
288: my $color=$colorindex[$counter%3];
289: # set other values
290: my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
291: $dirdescription="(" . $dirdescription . ")" if $dirdescription;
292: # find subdirectories that are contained in this directory
293: my @subdirs;
294: foreach my $d2 (@$dirs) {
295: if ($d2=~/^$d\/([^\/]+)$/) {
296: push @subdirs,$1;
297: }
298: }
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 (@subdirs || @files) {
310: my $subdirstring="<BR>* Relevant subdirectories: " . join(", ",@subdirs) if @subdirs;
311: $description.=<<END;
312: <TR><TD BGCOLOR=#000000 COLSPAN=6><FONT COLOR=$color><IMG SRC="directory.gif" ALT="directory">DIRECTORY -- $d $dirdescription
313: $subdirstring</FONT></TD></TR>
314: END
315: }
316: else {
317: $description.=<<END;
318: <TR><TD BGCOLOR=#000000 COLSPAN=6><FONT COLOR=$color><IMG SRC="emptydirectory.gif" ALT="empty directory">EMPTY DIRECTORY - $d $dirdescription</FONT></TD></TR>
319: END
320: }
321: if (@files) {
322: $description.=<<END;
323: <TR>
324: <TH BGCOLOR=$color ALIGN=LEFT COLSPAN=2>Type</TH>
325: <TH BGCOLOR=$color ALIGN=LEFT>File Name</TH>
326: <TH BGCOLOR=$color ALIGN=LEFT>Function</TH>
327: <TH BGCOLOR=$color ALIGN=LEFT>CVS Location</TH>
328: <TH BGCOLOR=$color ALIGN=LEFT>Notes</TH>
329: </TR>
330: END
331: foreach my $i (0..$#files) {
332: my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
333: my $fdescription=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DESCRIPTION'};
334: my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
335: unless (-e "../../$source") {
336: $source=~/([^\/]+)$/;
337: my $s=$1;
338: $source="<FONT COLOR=#FF0000>$source</FONT>";
339: # my $fr=`cd ../../; find . -name $s`;
340: # $source.="<BR>$fr\n";
341: }
342: my $notes=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'NOTES'};
343: $description.=<<END;
344: <TR>
345: <TD BGCOLOR=#A0A0A0><IMG SRC="$fcm{$category}.gif" ALT="$category"></TD>
346: <TD BGCOLOR=$color>$category</TD>
347: <TD BGCOLOR=$color>$files[$i]</TD>
348: <TD BGCOLOR=$color>$fdescription </TD>
349: <TD BGCOLOR=$color>$source</TD>
350: <TD BGCOLOR=$color>$notes </TD>
351: </TR>
352: END
353: }
354: }
355: $counter++;
356: }
357: $description.=<<END;
358: </TABLE>
359: </P>
360: END
361: return $description;
362: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>