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