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