Annotation of loncom/build/parse.pl, revision 1.22

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;
1.21      harris41  149:     open OUT,">setup_file_list.txt";
                    150:     print OUT "BinaryRoot/etc/passwd\n";
                    151:     close OUT;
                    152:     open OUT,">BinaryRoot/etc/passwd";
                    153:     print OUT<<END;
1.22    ! harris41  154: root::0:0:root:/root:/bin/bash
        !           155: bin:*:1:1:bin:/bin:
        !           156: daemon:*:2:2:daemon:/sbin:
        !           157: adm:*:3:4:adm:/var/adm:
        !           158: lp:*:4:7:lp:/var/spool/lpd:
        !           159: sync:*:5:0:sync:/sbin:/bin/sync
        !           160: shutdown:*:6:0:shutdown:/sbin:/sbin/shutdown
        !           161: halt:*:7:0:halt:/sbin:/sbin/halt
        !           162: mail:*:8:12:mail:/var/spool/mail:
        !           163: news:*:9:13:news:/var/spool/news:
        !           164: uucp:*:10:14:uucp:/var/spool/uucp:
        !           165: operator:*:11:0:operator:/root:
        !           166: games:*:12:100:games:/usr/games:
        !           167: gopher:*:13:30:gopher:/usr/lib/gopher-data:
        !           168: ftp:*:14:50:FTP User:/home/ftp:
        !           169: nobody:*:99:99:Nobody:/:
1.21      harris41  170: www:x:500:500:www:/home/www:/bin/bash
                    171: END
                    172: close OUT;
                    173: 
1.11      harris41  174: }
1.10      harris41  175: elsif ($mode eq "status") {
                    176: }
                    177: elsif ($mode eq "update") {
                    178: }
1.16      harris41  179: elsif ($mode eq "configinstall") {
                    180:     @directories=&determine_directory_structure;
                    181:     $a=&make_files_configinstall_segment(\@directories);
                    182:     print $a;
1.17      harris41  183:     $a=&make_files_configpermissions_segment(\@directories);
                    184:     print $a;
1.16      harris41  185: }
1.14      harris41  186: elsif ($mode eq "install") {
                    187:     @directories=&determine_directory_structure;
                    188:     $a=&make_directory_install_segment(\@directories);
                    189:     print $a;
                    190:     $a=&make_files_install_segment(\@directories);
                    191:     print $a;
                    192:     $a=&make_links_install_segment(\@directories);
                    193:     print $a;
1.11      harris41  194: }
1.15      harris41  195: elsif ($mode eq "build") {
                    196:     @directories=&determine_directory_structure;
                    197:     $a=&make_files_build_segment(\@directories);
                    198:     print $a;
                    199: }
1.11      harris41  200: 
                    201: # ------------------------------------------------------ a list of file targets
                    202: sub make_file_list {
                    203:     my ($dirs)=@_;
                    204:     my $description;
                    205:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    206:     foreach my $d (@$dirs) {
                    207: 	# set other values
1.19      harris41  208: 	$description.=<<END;
1.18      harris41  209: BinaryRoot/$d
                    210: END
1.11      harris41  211: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    212: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    213: 	# find files that are contained in this directory
                    214: 	my @files;
                    215: 	my @filesfull;
                    216: 	foreach my $f (@allfiles) {
                    217: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    218: 		push @files,$1;
                    219: 		push @filesfull,$f;
                    220: 	    }
                    221: 	}
                    222: 	# render starting HTML formatting elements
                    223: 	if (@files) {
                    224:         }
1.12      harris41  225: 	my $pwd=`pwd`; chop $pwd;
1.11      harris41  226: 	if (@files) {
                    227:             foreach my $i (0..$#files) {
                    228: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    229: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    230: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    231: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    232: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    233: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
                    234: 		my $rot="/".$filesfull[$i];
                    235: 		if ($rot=~/\*/) {
                    236: 		    $rot=~s/[^\/]+$// if $rot=~/\*/;
                    237: 		    my $listing=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
                    238: 		    chop $listing;
                    239: 		    my @list=split(/\s+/,$listing);
                    240: 		    my $rot2;
                    241: 		    foreach my $l (@list) {
                    242: 			$l=~s/^\s*//; $l=~s/\s*$//;
1.12      harris41  243: 			$rot2.="BinaryRoot$rot$l\n" if length($l);
1.11      harris41  244: 		    }
                    245: 		    chop $rot2;
                    246: 		    $rot=$rot2;
1.12      harris41  247: 		}
                    248: 		else {
                    249: 		    $rot="BinaryRoot$rot";
1.11      harris41  250: 		}
1.13      harris41  251: 		if ($category eq "conf") {
                    252: 		    $rot.=" # config";
                    253: 		}
1.11      harris41  254: 		$description.=<<END;
                    255: $rot
                    256: END
                    257: 	    }
                    258: 	}
                    259:     }
                    260:     $description.=<<END;
                    261: 
                    262: END
                    263:     return $description;
                    264: }
                    265: 
                    266: # --------------------------------- Commands to make BinaryRoot directories
                    267: sub make_directory_binaryroot_segment {
                    268:     my ($dirs)=@_;
                    269:     my $description=<<END;
                    270: directories:
                    271: END
                    272:     foreach my $d (@$dirs) {
                    273: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
                    274: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    275: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    276: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    277: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
1.20      harris41  278: 	my ($owner,$group)=split(/\:/,$devchown);
1.11      harris41  279: 	my $own=$devchown; $own=~s/\:/\,/;
                    280: 	$description.=<<END;
1.20      harris41  281: \tinstall -o $owner -g $group -m $devchmod -d \$(TARGET)/$d
1.11      harris41  282: END
                    283:     }
                    284:     $description.=<<END;
                    285: 
                    286: END
                    287:     return $description;
                    288: }
                    289: 
                    290: # --------------------------------------- Commands to make BinaryRoot files
                    291: sub make_files_binaryroot_segment {
                    292:     my ($dirs)=@_;
                    293:     my $description=<<END;
                    294: files:
                    295: END
                    296:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    297:     foreach my $d (@$dirs) {
                    298: 	# set other values
                    299: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    300: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    301: 	# find files that are contained in this directory
                    302: 	my @files;
                    303: 	my @filesfull;
                    304: 	foreach my $f (@allfiles) {
                    305: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    306: 		push @files,$1;
                    307: 		push @filesfull,$f;
                    308: 	    }
                    309: 	}
                    310: 	# render starting HTML formatting elements
                    311: 	if (@files) {
                    312: 	    $description.=<<END;
                    313: \t# $d $dirdescription
                    314: END
                    315:         }
                    316: 	if (@files) {
                    317:             foreach my $i (0..$#files) {
                    318: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    319: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    320: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    321: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    322: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    323: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
                    324: 		my $rot=$filesfull[$i];
                    325: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
1.20      harris41  326: 		my ($owner,$group)=split(/\:/,$devchown);
1.11      harris41  327: 		$description.=<<END if $category ne 'symbolic link';
1.20      harris41  328: \tinstall -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
1.11      harris41  329: END
                    330: 	    }
                    331: 	}
                    332:     }
                    333:     $description.=<<END;
                    334: 
                    335: END
                    336:     return $description;
                    337: }
                    338: 
                    339: # ------------------------------ Commands to make BinaryRoot symbolic links
                    340: sub make_links_binaryroot_segment {
                    341:     my ($dirs)=@_;
                    342:     my $description=<<END;
                    343: links:
                    344: END
                    345:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    346:     foreach my $d (@$dirs) {
                    347: 	# find files that are contained in this directory
                    348: 	my @files;
                    349: 	my @filesfull;
                    350: 	foreach my $f (@allfiles) {
                    351: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    352: 		push @files,$1;
                    353: 		push @filesfull,$f;
                    354: 	    }
                    355: 	}
                    356: 	# render starting HTML formatting elements
                    357: 	if (@files) {
                    358:             foreach my $i (0..$#files) {
                    359: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    360: 		my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
                    361: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    362: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    363: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    364: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    365: 		$description.=<<END if $category eq 'symbolic link';
                    366: \tln -s /$linkto \$(TARGET)/$filesfull[$i]
                    367: END
                    368: 	    }
                    369: 	}
                    370:     }
                    371:     $description.=<<END;
                    372: 
                    373: END
                    374:     return $description;
1.10      harris41  375: }
                    376: 
1.14      harris41  377: # ------ Installation commands for a Makefile used only by a rpm -ba invocation
                    378: sub make_directory_LCMakefile_segment {
                    379:     my ($dirs)=@_;
                    380:     my $description=<<END;
                    381: directories:
                    382: END
                    383:     foreach my $d (@$dirs) {
                    384: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
                    385: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    386: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    387: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    388: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    389: 	my $own=$devchown; $own=~s/\:/\,/;
                    390: 	$description.=<<END;
                    391: \tinstall -m $devchmod -d \$(SOURCE)/$d \$(ROOT)/$d
                    392: END
                    393:     }
                    394:     $description.=<<END;
                    395: 
                    396: END
                    397:     return $description;
                    398: }
                    399: 
                    400: # ------ Installation commands for a Makefile used only by a rpm -ba invocation
                    401: sub make_files_LCMakefile_segment {
                    402:     my ($dirs)=@_;
                    403:     my $description=<<END;
                    404: files:
                    405: END
                    406:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    407:     foreach my $d (@$dirs) {
                    408: 	# set other values
                    409: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    410: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    411: 	# find files that are contained in this directory
                    412: 	my @files;
                    413: 	my @filesfull;
                    414: 	foreach my $f (@allfiles) {
                    415: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    416: 		push @files,$1;
                    417: 		push @filesfull,$f;
                    418: 	    }
                    419: 	}
                    420: 	# render starting HTML formatting elements
                    421: 	if (@files) {
                    422: 	    $description.=<<END;
                    423: \t# $d $dirdescription
                    424: END
                    425:         }
                    426: 	if (@files) {
                    427:             foreach my $i (0..$#files) {
                    428: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    429: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    430: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    431: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    432: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    433: 		my $rot=$filesfull[$i];
                    434: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
                    435: 		$description.=<<END if $category ne 'symbolic link';
                    436: \tinstall -m $devchmod \$(SOURCE)/$filesfull[$i] \$(ROOT)/$rot
                    437: END
                    438: 	    }
                    439: 	}
                    440:     }
                    441:     $description.=<<END;
                    442: 
                    443: END
                    444:     return $description;
                    445: }
                    446: 
                    447: # ------ Installation commands for a Makefile used only by a rpm -ba invocation
                    448: sub make_links_LCMakefile_segment {
                    449:     my ($dirs)=@_;
                    450:     my $description=<<END;
                    451: links:
                    452: END
                    453:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    454:     foreach my $d (@$dirs) {
                    455: 	# find files that are contained in this directory
                    456: 	my @files;
                    457: 	my @filesfull;
                    458: 	foreach my $f (@allfiles) {
                    459: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    460: 		push @files,$1;
                    461: 		push @filesfull,$f;
                    462: 	    }
                    463: 	}
                    464: 	# render starting HTML formatting elements
                    465: 	if (@files) {
                    466:             foreach my $i (0..$#files) {
                    467: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    468: 		my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
                    469: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    470: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    471: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    472: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    473: 		$description.=<<END if $category eq 'symbolic link';
                    474: \tln -s /$linkto \$(ROOT)/$filesfull[$i]
                    475: END
                    476: 	    }
                    477: 	}
                    478:     }
                    479:     $description.=<<END;
                    480: 
                    481: END
                    482:     return $description;
                    483: }
                    484: 
1.10      harris41  485: # --------------------------------- Installation commands to install directories
                    486: sub make_directory_install_segment {
                    487:     my ($dirs)=@_;
                    488:     my $description=<<END;
                    489: directories:
                    490: END
                    491:     foreach my $d (@$dirs) {
                    492: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
1.14      harris41  493: 	my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
1.10      harris41  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'};
1.16      harris41  498: 	my ($owner,$group)=split(/\:/,$devchown);
1.10      harris41  499: 	my $own=$devchown; $own=~s/\:/\,/;
                    500: 	$description.=<<END;
1.16      harris41  501: \tinstall -o $owner -g $group -m $devchmod -d \$(TARGET)/$d
1.10      harris41  502: END
                    503:     }
                    504:     $description.=<<END;
                    505: 
                    506: END
                    507:     return $description;
                    508: }
                    509: 
1.15      harris41  510: # ------------------------------------------------------ Commands to build files
                    511: sub make_files_build_segment {
                    512:     my ($dirs)=@_;
                    513:     my $description;
                    514:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    515:     my $tab="\t";
                    516:     my $sources="all: ";
                    517:     foreach my $d (@$dirs) {
                    518: 	# set other values
                    519: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    520: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    521: 	# find files that are contained in this directory
                    522: 	my @files;
                    523: 	my @filesfull;
                    524: 	foreach my $f (@allfiles) {
                    525: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    526: 		push @files,$1;
                    527: 		push @filesfull,$f;
                    528: 	    }
                    529: 	}
                    530: 	if (@files) {
                    531:             foreach my $i (0..$#files) {
                    532: 		# if has build information, output appropriate something
                    533: 		my $build=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'BUILD'};
                    534: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
                    535: 		$build=~s/^\s+//; $build=~s/\s+$//;
                    536: 		if ($build) {
                    537: 		    my $dependencies=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DEPENDENCIES'};
                    538: 		    my $source2=$source;
                    539: 		    $source2=~s/^[^\/]+\///;
                    540:  		    $source2="../" . $source2;
                    541: 		    $sources.="$source2 ";
                    542: 		    my $directory=$build;
                    543: 		    $directory=~s/^[^\/]+\///;
                    544: 		    $directory=~s/([^\/]+)$//;
                    545:  		    $directory="../" . $directory;
                    546: 		    my $buildfile=$1;
                    547: 		    my $sdir=$source;
                    548: 		    $sdir=~s/^[^\/]+\///;
                    549: 		    $sdir=~s/([^\/]+)$//;
                    550:  		    $sdir="../" . $sdir;
                    551: 		    $dependencies=~s/\s+$//;
                    552: 		    my $depstat="";
                    553: 		    if ($dependencies=~s/\s+\[ALWAYS_RUN_BUILD_COMMAND\]//) {
                    554: 			$depstat=" alwaysrun";
                    555: 		    }
                    556: 		    $dependencies=~s/\s+/ $sdir/gs;
                    557: 		    $description.=<<END;
                    558: $source2: $dependencies$depstat
                    559: ${tab}cd $directory; sh ./$buildfile
                    560: 
                    561: END
                    562: 		}
                    563: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    564: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
                    565: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    566: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    567: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    568: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    569: 		my $rot=$filesfull[$i];
                    570: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
                    571: #		$description.=<<END if $category ne 'symbolic link';
1.16      harris41  572: #\tinstall -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
1.15      harris41  573: #END
                    574: 	    }
                    575: 	}
                    576:     }
                    577:     $description.=<<END;
                    578: alwaysrun:
                    579: 
                    580: END
                    581:     $sources.="\n\n";
                    582:     return ($sources . $description);
                    583: }
                    584: 
1.10      harris41  585: # --------------------------------------- Installation commands to install files
                    586: sub make_files_install_segment {
                    587:     my ($dirs)=@_;
                    588:     my $description=<<END;
                    589: files:
                    590: END
                    591:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    592:     foreach my $d (@$dirs) {
                    593: 	# set other values
                    594: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    595: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    596: 	# find files that are contained in this directory
                    597: 	my @files;
                    598: 	my @filesfull;
                    599: 	foreach my $f (@allfiles) {
                    600: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    601: 		push @files,$1;
                    602: 		push @filesfull,$f;
                    603: 	    }
                    604: 	}
                    605: 	# render starting HTML formatting elements
                    606: 	if (@files) {
                    607: 	    $description.=<<END;
                    608: \t# $d $dirdescription
                    609: END
                    610:         }
                    611: 	if (@files) {
                    612:             foreach my $i (0..$#files) {
                    613: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
1.14      harris41  614: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
1.10      harris41  615: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    616: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    617: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    618: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    619: 		my $rot=$filesfull[$i];
                    620: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
1.16      harris41  621: 		my ($owner,$group)=split(/\:/,$devchown);
1.15      harris41  622: 		if ($category ne 'conf') {
                    623: 		    $description.=<<END if $category ne 'symbolic link';
1.16      harris41  624: \tinstall -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
                    625: END
                    626:                 }
                    627: 	    }
                    628: 	}
                    629:     }
                    630:     $description.=<<END;
                    631: 
                    632: END
                    633:     return $description;
                    634: }
                    635: 
                    636: # ------ Installation commands to install configuration files (and make backups)
                    637: sub make_files_configinstall_segment {
                    638:     my ($dirs)=@_;
                    639:     my $description=<<END;
                    640: configfiles:
                    641: END
                    642:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    643:     foreach my $d (@$dirs) {
                    644: 	# set other values
                    645: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    646: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    647: 	# find files that are contained in this directory
                    648: 	my @files;
                    649: 	my @filesfull;
                    650: 	foreach my $f (@allfiles) {
                    651: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    652: 		push @files,$1;
                    653: 		push @filesfull,$f;
                    654: 	    }
                    655: 	}
                    656: 	# render starting HTML formatting elements
                    657: 	if (@files) {
                    658: 	    $description.=<<END;
                    659: \t# $d $dirdescription
                    660: END
                    661:         }
                    662: 	if (@files) {
                    663:             foreach my $i (0..$#files) {
                    664: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    665: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
                    666: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    667: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    668: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    669: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    670: 		my $rot=$filesfull[$i];
                    671: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
                    672: 		my ($owner,$group)=split(/\:/,$devchown);
                    673: 		if ($category eq 'conf') {
                    674: 		    $description.=<<END;
                    675: \tinstall -b -S `date +'.\%Y\%m\%d\%H\%M\%S'` -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
1.17      harris41  676: END
                    677:                 }
                    678: 	    }
                    679: 	}
                    680:     }
                    681:     $description.=<<END;
                    682: 
                    683: END
                    684:     return $description;
                    685: }
                    686: 
                    687: # ------ Commands to enforce configuration file permissions
                    688: sub make_files_configpermissions_segment {
                    689:     my ($dirs)=@_;
                    690:     my $description=<<END;
                    691: configpermissions:
                    692: END
                    693:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    694:     foreach my $d (@$dirs) {
                    695: 	# set other values
                    696: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    697: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    698: 	# find files that are contained in this directory
                    699: 	my @files;
                    700: 	my @filesfull;
                    701: 	foreach my $f (@allfiles) {
                    702: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    703: 		push @files,$1;
                    704: 		push @filesfull,$f;
                    705: 	    }
                    706: 	}
                    707: 	# render starting HTML formatting elements
                    708: 	if (@files) {
                    709: 	    $description.=<<END;
                    710: \t# $d $dirdescription
                    711: END
                    712:         }
                    713: 	if (@files) {
                    714:             foreach my $i (0..$#files) {
                    715: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    716: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
                    717: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    718: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    719: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    720: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    721: 		my $rot=$filesfull[$i];
                    722: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
                    723: 		my ($owner,$group)=split(/\:/,$devchown);
                    724: 		if ($category eq 'conf') {
                    725: 		    $description.=<<END;
                    726: \tchmod $devchmod \$(TARGET)/$rot
                    727: \tchown $devchown \$(TARGET)/$rot
1.10      harris41  728: END
1.15      harris41  729:                 }
1.10      harris41  730: 	    }
                    731: 	}
                    732:     }
                    733:     $description.=<<END;
                    734: 
                    735: END
                    736:     return $description;
                    737: }
                    738: 
                    739: # ------------------------------ Installation commands to install symbolic links
                    740: sub make_links_install_segment {
                    741:     my ($dirs)=@_;
                    742:     my $description=<<END;
                    743: links:
                    744: END
1.16      harris41  745:     chop $description;
                    746:     my $description2;
1.10      harris41  747:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    748:     foreach my $d (@$dirs) {
                    749: 	# find files that are contained in this directory
                    750: 	my @files;
                    751: 	my @filesfull;
                    752: 	foreach my $f (@allfiles) {
                    753: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    754: 		push @files,$1;
                    755: 		push @filesfull,$f;
                    756: 	    }
                    757: 	}
                    758: 	# render starting HTML formatting elements
                    759: 	if (@files) {
                    760:             foreach my $i (0..$#files) {
                    761: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    762: 		my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
                    763: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    764: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    765: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    766: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
1.16      harris41  767: 		if ($category eq 'symbolic link') {
                    768: 		    $description.=" \$(TARGET)/$filesfull[$i]";
                    769: 		    $description2.=<<END;
                    770: \$(TARGET)/$filesfull[$i]:
1.14      harris41  771: \tln -s /$linkto \$(TARGET)/$filesfull[$i]
1.16      harris41  772: 
1.10      harris41  773: END
1.16      harris41  774:                 }
1.10      harris41  775: 	    }
                    776: 	}
                    777:     }
                    778:     $description.=<<END;
1.4       harris41  779: 
1.10      harris41  780: END
1.16      harris41  781:     $description.=$description2;
1.10      harris41  782:     return $description;
                    783: }
                    784: 
                    785: # --------------------------------------------------------- Make RPM .spec block
                    786: sub make_rpm_spec_block {
                    787:     my $pwd=`pwd`; chop $pwd;
                    788:     my $buildroot="$pwd/LON-CAPA-BuildRoot";
                    789:     my $source=$info{'RPM'}{'Name'} . "-" . $info{'RPM'}{'Version'} . '.tar.gz';
                    790:     my $description=<<END;
                    791: Summary: $info{'RPM'}{'Summary'}
                    792: Name: $info{'RPM'}{'Name'}
                    793: Version: $info{'RPM'}{'Version'}
                    794: Release: $info{'RPM'}{'Release'}
                    795: Vendor: $info{'RPM'}{'Vendor'} 
                    796: BuildRoot: $buildroot
                    797: Copyright: $info{'RPM'}{'Copyright'}
                    798: Group: $info{'RPM'}{'Group'}
                    799: Source: $source
                    800: AutoReqProv: $info{'RPM'}{'AutoReqProv'}
                    801: \%description
                    802: $info{'RPM'}{'description'}
                    803: 
                    804: END
                    805:     return $description;
                    806: }
                    807: 
                    808: # --------------------------------------------------- Make RPM build .spec block
                    809: sub make_rpm_build_block {
                    810:     my $pwd=`pwd`; chop $pwd;
                    811:     my $buildroot="$pwd/LON-CAPA-BuildRoot";
                    812:     my $sourceroot="$pwd/LON-CAPA-SourceRoot";
                    813:     my $description=<<END;
                    814: 
                    815: \%prep
                    816: \%setup
                    817: 
                    818: \%build
                    819: rm -Rf "$buildroot"
                    820: 
                    821: \%install
                    822: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" directories
                    823: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" files
                    824: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" links
                    825: 
                    826: \%pre
                    827: $info{'RPM'}{'pre'}
                    828: 
                    829: \%post
                    830: \%postun
                    831: 
                    832: \%files
                    833: # \%doc README COPYING ChangeLog LICENSE
                    834: END
                    835:     return $description;
                    836: }
                    837: 
                    838: # ------------------------------------- Make directory structure RPM .spec block
                    839: sub make_directory_structure_spec_block {
                    840:     my ($dirs)=@_;
                    841:     foreach my $d (@$dirs) {
                    842: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
                    843: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    844: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    845: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    846: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    847: 	my $own=$devchown; $own=~s/\:/\,/;
                    848: 	$description.=<<END;
                    849: \%dir \%attr($devchmod,$own) /$d
                    850: END
                    851:     }
                    852:     return $description;
                    853: }
                    854: 
                    855: # ---------------------------- Make directory and file structure RPM .spec block
                    856: sub make_directory_and_file_structure_spec_block {
                    857:     my ($dirs)=@_;
                    858:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    859:     foreach my $d (@$dirs) {
                    860: 	# set other values
                    861: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    862: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    863: 	# find files that are contained in this directory
                    864: 	my @files;
                    865: 	my @filesfull;
                    866: 	foreach my $f (@allfiles) {
                    867: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    868: 		push @files,$1;
                    869: 		push @filesfull,$f;
                    870: 	    }
                    871: 	}
                    872: 	# render starting HTML formatting elements
                    873: 	if (@files) {
                    874: 	    $description.=<<END;
                    875: # $d $dirdescription
                    876: END
                    877:         }
                    878: 	if (@files) {
                    879:             foreach my $i (0..$#files) {
                    880: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    881: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    882: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    883: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    884: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    885: 		my $own=$devchown; $own=~s/\:/\,/;
                    886: 		my $config="";
                    887: 		$config="\%config " if $category eq 'conf';
                    888: 		$devchmod='-' if $category eq 'symbolic link';
                    889: 		$description.=<<END;
                    890: $config\%attr($devchmod,$own) /$filesfull[$i]
                    891: END
                    892: 	    }
                    893: 	}
                    894:     }
                    895:     return $description;
                    896: }
                    897: 
                    898: # ----------------------------------------------------------- End RPM .spec page
                    899: sub end_spec_page {
                    900: }
                    901: 
                    902: # ------------------------------------------------------- Begin description page
1.4       harris41  903: sub begin_description_page {
                    904:     my $description=<<END;
                    905: <HTML>
                    906: <HEAD>
                    907: <TITLE>LON-CAPA Software Description Page ($distribution, $date)</TITLE>
                    908: </HEAD>
                    909: <BODY>
                    910: <FONT SIZE=+2>LON-CAPA Software Description Page ($distribution, $date)</FONT>
                    911: <BR>Michigan State University
                    912: <BR>Learning Online with CAPA
                    913: <BR>Contact korte\@lon-capa.org
                    914: <UL>
                    915: <LI>About this file
                    916: <LI>Software Package Description
                    917: <LI>Directory Structure
1.7       harris41  918: <LI>File Type Ownership and Permissions
1.4       harris41  919: <LI>File and Directory Structure
                    920: </UL>
                    921: <FONT SIZE=+2>About this file</FONT>
                    922: <P>
                    923: This file is generated dynamically by <TT>parse.pl</TT> as
                    924: part of a development compilation process.  See 
                    925: http://install.lon-capa.org/compile/index.html for more
                    926: information.
                    927: </P>
                    928: END
                    929:     return $description;
                    930: }
                    931: 
                    932: # ------------------------------------------------- End description page
                    933: sub end_description_page {
                    934:     my $description=<<END;
                    935: <HR>
1.5       harris41  936: <FONT SIZE=-1>LON-CAPA Software Development Team</FONT>
1.4       harris41  937: </BODY>
                    938: </HTML>
                    939: END
                    940:     return $description;
                    941: }
                    942: 
                    943: # ------------------------------------------------- Make RPM description block
                    944: sub make_rpm_description_block {
                    945:     my $description=<<END;
                    946: <FONT SIZE=+2>Rolled in a RedHat 6.2 RPM, $date</FONT>
                    947: <P>
                    948: <TABLE BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=10 CELLSPACING=0>
                    949: <TR><TD>
                    950: <PRE>
                    951: Name        : $info{'RPM'}{'Name'}
                    952: Version     : $info{'RPM'}{'Version'}
                    953: Vendor      : $info{'RPM'}{'Vendor'} 
                    954: Release     : $info{'RPM'}{'Release'}                             
                    955: Build Host  : $buildhost
                    956: Group       : $info{'RPM'}{'Group'}
                    957: License     : $info{'RPM'}{'Copyright'}
                    958: Summary     : $info{'RPM'}{'Summary'}
                    959: Description : 
                    960: $info{'RPM'}{'description'}
                    961: </PRE>
                    962: </TD></TR>
                    963: </TABLE>
                    964: </P>
                    965: END
                    966:     return $description;
                    967: }
                    968: 
                    969: # ----------------------------------------------- Determine directory structure
                    970: sub determine_directory_structure {
                    971:     my @directories=keys %{$info{'DIRECTORY'}{$distribution}};
                    972:     return (sort @directories);
                    973: }
1.1       harris41  974: 
1.4       harris41  975: 
                    976: # ---------------------------------- Make directory structure description block
                    977: sub make_directory_structure_description_block {
                    978:     my ($dirs)=@_;
                    979:     my $description=<<END;
                    980: <FONT SIZE=+2>Directory Structure Description, $date</FONT>
                    981: <P>
1.9       harris41  982: The directory structure description below shows only those
                    983: directories which either contain LON-CAPA specific files
                    984: or normally do not exist on a RedHat Linux system (and
                    985: must be generated to allow proper placement of files
                    986: during LON-CAPA run-time operation).
                    987: </P>
                    988: <P>
1.4       harris41  989: <TABLE BORDER=1 CELLPADDING=3 CELLSPACING=0>
                    990: END
                    991:     my $maxcount=0;
1.8       harris41  992:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    993:     my %diraccount; # hash to track which directories are accounted for
                    994:     foreach my $file (@allfiles) {
                    995: 	$file=~/^(.*)\/([^\/]+)$/;
                    996: 	$diraccount{$1}=1;
                    997:     }
1.4       harris41  998:     foreach my $d (@$dirs) {
                    999:         my (@matches)=($d=~/\//g);
                   1000: 	my $count=scalar(@matches);
                   1001: 	$maxcount=$count if $count>$maxcount;
1.8       harris41 1002: 	delete $diraccount{$d};
1.4       harris41 1003:     }
                   1004:     $description.=<<END;
                   1005: <TR>
                   1006: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Category</TH>
                   1007: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
                   1008: <TH ALIGN=LEFT BGCOLOR=#FFFFFF><FONT COLOR=#FF0000>Development<BR>Permissions</FONT></TH>
                   1009: END
                   1010:     $description.="<TH ALIGN=LEFT BGCOLOR=#FFFFFF COLSPAN=".($maxcount+1).">Directory Path</TH>\n";
1.8       harris41 1011:     if (keys %diraccount) {
                   1012: 	$description.= "<TR><TD ALIGN=LEFT BGCOLOR=#FFFFFF COLSPAN=".($maxcount+4)."><I><PRE>Directories that are unaccounted for: \n";
                   1013: 	foreach my $d (keys %diraccount) {
                   1014: 	    $description.="$d\n";
                   1015: 	}
                   1016: 	$description.="</PRE></I></TH></TR>\n";
                   1017:     }
1.4       harris41 1018:     foreach my $d (@$dirs) {
                   1019: 	my $dtable=$d;
                   1020: 	$dtable=~s/\//\<\/TD\>\<TD\>/g;
                   1021: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
                   1022: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                   1023: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                   1024: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                   1025: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                   1026: 	$description.=<<END;
                   1027: <TR>
                   1028: <TD BGCOLOR=#FFFFFF>$category</TD>
                   1029: <TD BGCOLOR=#FFFFFF><TT>$chmod $chown</TT></TD>
                   1030: <TD BGCOLOR=#FFFFFF><FONT COLOR=#FF0000><TT>$devchmod $devchown</TT></FONT></TD>
                   1031: <TD>
                   1032: $dtable
                   1033: </TD>
                   1034: </TR>
                   1035: END
                   1036:     }
                   1037:     $description.=<<END;
                   1038: </TABLE>
                   1039: </P>
                   1040: END
                   1041:     return $description;
                   1042: }
                   1043: 
1.6       harris41 1044: # ------------------- Make file type ownership and permissions description block
                   1045: sub make_file_type_ownership_and_permissions_description_block {
                   1046:     my $description=<<END;
                   1047: <FONT SIZE=+2>File Type Ownership and Permissions Descriptions, $date</FONT>
                   1048: <P>
                   1049: This table shows what permissions and ownership settings correspond
                   1050: to each kind of file type.
                   1051: </P>
                   1052: <P>
                   1053: <TABLE BORDER=1 CELLPADDING=5 WIDTH=60%>
                   1054: <TR>
                   1055: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Icon</TH>
                   1056: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Type</TH>
                   1057: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
                   1058: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Development Permissions</TH>
                   1059: </TR>
                   1060: END
                   1061:     foreach my $type (keys %{$info{'OWNERSHIP'}}) {
                   1062: 	if (defined($fcm{$type})) {
                   1063: 	    my $chmod=$info{'OWNERSHIP'}{$type}{'CHMOD'};
                   1064: 	    my $chown=$info{'OWNERSHIP'}{$type}{'CHOWN'};
                   1065: 	    my $devchmod=$info{'DEVOWNERSHIP'}{$type}{'CHMOD'};
                   1066: 	    my $devchown=$info{'DEVOWNERSHIP'}{$type}{'CHOWN'};
                   1067: 	    $description.=<<END;
                   1068: <TR>
                   1069: <TD><IMG SRC="$fcm{$type}.gif" ALT="$type"></TD>
                   1070: <TD>$type</TD>
                   1071: <TD><TT>$chmod $chown</TT></TD>
                   1072: <TD><TT>$devchmod $devchown</TT></TD>
                   1073: </TR>
                   1074: END
                   1075:         }
                   1076:     }
                   1077:     $description.=<<END;
                   1078: </TABLE>
                   1079: </P>
                   1080: END
                   1081: }
                   1082: 
1.4       harris41 1083: # ------------------------- Make directory and file structure description block
                   1084: sub make_directory_and_file_structure_description_block {
                   1085:     my ($dirs)=@_;
                   1086:     my $description=<<END;
                   1087: <FONT SIZE=+2>Directory and File Structure Description, $date</FONT>
1.6       harris41 1088: <P>
                   1089: The icons on the left column correspond to the file type
                   1090: specified in the second column.  The last column "Notes" shows compilation,
1.7       harris41 1091: dependency, and configuration information.  The CVS location
                   1092: shows the location of the binary source file (if applicable) needed to
                   1093: be copied to the target.  If the binary source file is not at
                   1094: the specified location, then the text is shown in 
                   1095: <FONT COLOR=#FF0000>red</FONT>.
1.6       harris41 1096: </P>
1.4       harris41 1097: <P>
1.9       harris41 1098: <TABLE BORDER=1 CELLPADDING=5 WIDTH=500>
1.4       harris41 1099: END
                   1100:     my $counter=0;
                   1101:     my @colorindex=("#80FF80","#80FFFF","#FFFF80");
1.5       harris41 1102:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
1.4       harris41 1103:     foreach my $d (@$dirs) {
                   1104: 	# set color
                   1105: 	my $color=$colorindex[$counter%3];
                   1106: 	# set other values
                   1107: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                   1108: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                   1109: 	# find subdirectories that are contained in this directory
                   1110: 	my @subdirs;
                   1111: 	foreach my $d2 (@$dirs) {
1.5       harris41 1112: 	    if ($d2=~/^$d\/([^\/]+)$/) {
1.4       harris41 1113: 		push @subdirs,$1;
                   1114: 	    }
                   1115: 	}
                   1116: 	# find files that are contained in this directory
                   1117: 	my @files;
1.5       harris41 1118: 	my @filesfull;
1.4       harris41 1119: 	foreach my $f (@allfiles) {
1.5       harris41 1120: 	    if ($f=~/^$d\/([^\/]+)$/) {
1.4       harris41 1121: 		push @files,$1;
1.5       harris41 1122: 		push @filesfull,$f;
1.4       harris41 1123: 	    }
                   1124: 	}
                   1125: 	# render starting HTML formatting elements
                   1126: 	if (@subdirs || @files) {
                   1127: 	    my $subdirstring="<BR>* Relevant subdirectories: " . join(", ",@subdirs) if @subdirs;
                   1128: 	    $description.=<<END;
1.5       harris41 1129: <TR><TD BGCOLOR=#000000 COLSPAN=6><FONT COLOR=$color><IMG SRC="directory.gif" ALT="directory">DIRECTORY -- $d $dirdescription
                   1130: $subdirstring</FONT></TD></TR>
1.4       harris41 1131: END
                   1132:         }
                   1133: 	else {
                   1134: 	    $description.=<<END;
1.5       harris41 1135: <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 1136: END
                   1137:         }
                   1138: 	if (@files) {
                   1139: 	    $description.=<<END;
                   1140: <TR>
1.5       harris41 1141: <TH BGCOLOR=$color ALIGN=LEFT COLSPAN=2>Type</TH>
                   1142: <TH BGCOLOR=$color ALIGN=LEFT>File Name</TH>
                   1143: <TH BGCOLOR=$color ALIGN=LEFT>Function</TH>
                   1144: <TH BGCOLOR=$color ALIGN=LEFT>CVS Location</TH>
                   1145: <TH BGCOLOR=$color ALIGN=LEFT>Notes</TH>
1.4       harris41 1146: </TR>
                   1147: END
1.5       harris41 1148:             foreach my $i (0..$#files) {
                   1149: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                   1150: 		my $fdescription=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DESCRIPTION'};
                   1151: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
1.9       harris41 1152: 		my $note=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'NOTE'};
                   1153: 		$note.="<BR>" if $note;
                   1154: 		my $listing=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
                   1155: 		my @E=split(/\s+/,$listing);
                   1156: 		$source=~/(.*)\/[^\/]+$/;
                   1157: 		my $sd=$1;
                   1158: 		my $eflag=0;
                   1159: 		foreach my $e (@E) {
                   1160: 		    unless (-e "../../$sd/$e") {
                   1161: 			$e="<FONT COLOR=#FF0000>$e</FONT>";
                   1162: 			$eflag=1;
                   1163: 		    }
                   1164: 		}
                   1165: 		$listing=join("\n",@E);
                   1166: 		$listing="<B>listing</B><BR><FONT SIZE=-2>$listing</FONT>" if $listing;
                   1167: 		$listing.="<BR>" if $listing;
                   1168: 		my $build=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'BUILD'};
                   1169: 		$build="<B>build</B><BR>$build" if $build;
                   1170: 		$build.="<BR>" if $build;
                   1171: 		my $dependencies=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DEPENDENCIES'};
                   1172: 		$dependencies="<B>dependencies</B><BR>$dependencies" if $dependencies;
                   1173: 		$dependencies.="<BR>" if $dependencies;
1.7       harris41 1174: 		unless (-e "../../$source") {
                   1175: 		    $source=~/([^\/]+)$/;
                   1176: 		    my $s=$1;
1.9       harris41 1177: 		    if ($source!~/\*/) {
                   1178: 			$source="<FONT COLOR=#FF0000>$source</FONT>";
                   1179: 		    }
                   1180: 		    elsif ($eflag) {
                   1181: 			$source="<FONT COLOR=#FF0000>$source</FONT>";
                   1182: 		    }
1.7       harris41 1183: 		}
1.5       harris41 1184: 		$description.=<<END;
                   1185: <TR>
                   1186: <TD BGCOLOR=#A0A0A0><IMG SRC="$fcm{$category}.gif" ALT="$category"></TD>
                   1187: <TD BGCOLOR=$color>$category</TD>
                   1188: <TD BGCOLOR=$color>$files[$i]</TD>
                   1189: <TD BGCOLOR=$color>$fdescription&nbsp;</TD>
                   1190: <TD BGCOLOR=$color>$source</TD>
1.9       harris41 1191: <TD BGCOLOR=$color>$note$listing$build$dependencies&nbsp;</TD>
1.4       harris41 1192: </TR>
                   1193: END
1.5       harris41 1194: 	    }
                   1195: 	}
1.4       harris41 1196: 	$counter++;
                   1197:     }
                   1198:     $description.=<<END;
                   1199: </TABLE>
                   1200: </P>
                   1201: END
                   1202:     return $description;
                   1203: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>