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