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

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;
                    124:     $a=&make_directory_install_segment(\@directories);
                    125:     print $a;
                    126:     $a=&make_files_install_segment(\@directories);
                    127:     print $a;
                    128:     $a=&make_links_install_segment(\@directories);
                    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: }
                    155: elsif ($mode eq "freshinstall") {
1.11    ! harris41  156: }
        !           157: 
        !           158: # ------------------------------------------------------ a list of file targets
        !           159: sub make_file_list {
        !           160:     my ($dirs)=@_;
        !           161:     my $description;
        !           162:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
        !           163:     foreach my $d (@$dirs) {
        !           164: 	# set other values
        !           165: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
        !           166: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
        !           167: 	# find files that are contained in this directory
        !           168: 	my @files;
        !           169: 	my @filesfull;
        !           170: 	foreach my $f (@allfiles) {
        !           171: 	    if ($f=~/^$d\/([^\/]+)$/) {
        !           172: 		push @files,$1;
        !           173: 		push @filesfull,$f;
        !           174: 	    }
        !           175: 	}
        !           176: 	# render starting HTML formatting elements
        !           177: 	if (@files) {
        !           178:         }
        !           179: 	if (@files) {
        !           180:             foreach my $i (0..$#files) {
        !           181: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
        !           182: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
        !           183: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
        !           184: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
        !           185: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
        !           186: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
        !           187: 		my $rot="/".$filesfull[$i];
        !           188: 		if ($rot=~/\*/) {
        !           189: 		    $rot=~s/[^\/]+$// if $rot=~/\*/;
        !           190: 		    my $listing=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
        !           191: 		    chop $listing;
        !           192: 		    my @list=split(/\s+/,$listing);
        !           193: 		    my $rot2;
        !           194: 		    foreach my $l (@list) {
        !           195: 			$l=~s/^\s*//; $l=~s/\s*$//;
        !           196: 			$rot2.="$rot$l\n" if length($l);
        !           197: 		    }
        !           198: 		    chop $rot2;
        !           199: 		    $rot=$rot2;
        !           200: 		}
        !           201: 		$description.=<<END;
        !           202: $rot
        !           203: END
        !           204: 	    }
        !           205: 	}
        !           206:     }
        !           207:     $description.=<<END;
        !           208: 
        !           209: END
        !           210:     return $description;
        !           211: }
        !           212: 
        !           213: # --------------------------------- Commands to make BinaryRoot directories
        !           214: sub make_directory_binaryroot_segment {
        !           215:     my ($dirs)=@_;
        !           216:     my $description=<<END;
        !           217: directories:
        !           218: END
        !           219:     foreach my $d (@$dirs) {
        !           220: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
        !           221: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
        !           222: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
        !           223: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
        !           224: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
        !           225: 	my $own=$devchown; $own=~s/\:/\,/;
        !           226: 	$description.=<<END;
        !           227: \tinstall -m $devchmod -d \$(TARGET)/$d
        !           228: END
        !           229:     }
        !           230:     $description.=<<END;
        !           231: 
        !           232: END
        !           233:     return $description;
        !           234: }
        !           235: 
        !           236: # --------------------------------------- Commands to make BinaryRoot files
        !           237: sub make_files_binaryroot_segment {
        !           238:     my ($dirs)=@_;
        !           239:     my $description=<<END;
        !           240: files:
        !           241: END
        !           242:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
        !           243:     foreach my $d (@$dirs) {
        !           244: 	# set other values
        !           245: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
        !           246: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
        !           247: 	# find files that are contained in this directory
        !           248: 	my @files;
        !           249: 	my @filesfull;
        !           250: 	foreach my $f (@allfiles) {
        !           251: 	    if ($f=~/^$d\/([^\/]+)$/) {
        !           252: 		push @files,$1;
        !           253: 		push @filesfull,$f;
        !           254: 	    }
        !           255: 	}
        !           256: 	# render starting HTML formatting elements
        !           257: 	if (@files) {
        !           258: 	    $description.=<<END;
        !           259: \t# $d $dirdescription
        !           260: END
        !           261:         }
        !           262: 	if (@files) {
        !           263:             foreach my $i (0..$#files) {
        !           264: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
        !           265: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
        !           266: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
        !           267: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
        !           268: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
        !           269: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
        !           270: 		my $rot=$filesfull[$i];
        !           271: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
        !           272: 		$description.=<<END if $category ne 'symbolic link';
        !           273: \tinstall -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
        !           274: END
        !           275: 	    }
        !           276: 	}
        !           277:     }
        !           278:     $description.=<<END;
        !           279: 
        !           280: END
        !           281:     return $description;
        !           282: }
        !           283: 
        !           284: # ------------------------------ Commands to make BinaryRoot symbolic links
        !           285: sub make_links_binaryroot_segment {
        !           286:     my ($dirs)=@_;
        !           287:     my $description=<<END;
        !           288: links:
        !           289: END
        !           290:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
        !           291:     foreach my $d (@$dirs) {
        !           292: 	# find files that are contained in this directory
        !           293: 	my @files;
        !           294: 	my @filesfull;
        !           295: 	foreach my $f (@allfiles) {
        !           296: 	    if ($f=~/^$d\/([^\/]+)$/) {
        !           297: 		push @files,$1;
        !           298: 		push @filesfull,$f;
        !           299: 	    }
        !           300: 	}
        !           301: 	# render starting HTML formatting elements
        !           302: 	if (@files) {
        !           303:             foreach my $i (0..$#files) {
        !           304: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
        !           305: 		my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
        !           306: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
        !           307: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
        !           308: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
        !           309: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
        !           310: 		$description.=<<END if $category eq 'symbolic link';
        !           311: \tln -s /$linkto \$(TARGET)/$filesfull[$i]
        !           312: END
        !           313: 	    }
        !           314: 	}
        !           315:     }
        !           316:     $description.=<<END;
        !           317: 
        !           318: END
        !           319:     return $description;
1.10      harris41  320: }
                    321: 
                    322: # --------------------------------- Installation commands to install directories
                    323: sub make_directory_install_segment {
                    324:     my ($dirs)=@_;
                    325:     my $description=<<END;
                    326: directories:
                    327: END
                    328:     foreach my $d (@$dirs) {
                    329: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
                    330: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    331: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    332: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    333: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    334: 	my $own=$devchown; $own=~s/\:/\,/;
                    335: 	$description.=<<END;
                    336: \tinstall -m $devchmod -d \$(SOURCE)/$d \$(ROOT)/$d
                    337: END
                    338:     }
                    339:     $description.=<<END;
                    340: 
                    341: END
                    342:     return $description;
                    343: }
                    344: 
                    345: # --------------------------------------- Installation commands to install files
                    346: sub make_files_install_segment {
                    347:     my ($dirs)=@_;
                    348:     my $description=<<END;
                    349: files:
                    350: END
                    351:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    352:     foreach my $d (@$dirs) {
                    353: 	# set other values
                    354: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    355: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    356: 	# find files that are contained in this directory
                    357: 	my @files;
                    358: 	my @filesfull;
                    359: 	foreach my $f (@allfiles) {
                    360: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    361: 		push @files,$1;
                    362: 		push @filesfull,$f;
                    363: 	    }
                    364: 	}
                    365: 	# render starting HTML formatting elements
                    366: 	if (@files) {
                    367: 	    $description.=<<END;
                    368: \t# $d $dirdescription
                    369: END
                    370:         }
                    371: 	if (@files) {
                    372:             foreach my $i (0..$#files) {
                    373: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    374: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    375: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    376: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    377: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    378: 		my $rot=$filesfull[$i];
                    379: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
                    380: 		$description.=<<END if $category ne 'symbolic link';
                    381: \tinstall -m $devchmod \$(SOURCE)/$filesfull[$i] \$(ROOT)/$rot
                    382: END
                    383: 	    }
                    384: 	}
                    385:     }
                    386:     $description.=<<END;
                    387: 
                    388: END
                    389:     return $description;
                    390: }
                    391: 
                    392: # ------------------------------ Installation commands to install symbolic links
                    393: sub make_links_install_segment {
                    394:     my ($dirs)=@_;
                    395:     my $description=<<END;
                    396: links:
                    397: END
                    398:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    399:     foreach my $d (@$dirs) {
                    400: 	# find files that are contained in this directory
                    401: 	my @files;
                    402: 	my @filesfull;
                    403: 	foreach my $f (@allfiles) {
                    404: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    405: 		push @files,$1;
                    406: 		push @filesfull,$f;
                    407: 	    }
                    408: 	}
                    409: 	# render starting HTML formatting elements
                    410: 	if (@files) {
                    411:             foreach my $i (0..$#files) {
                    412: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    413: 		my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
                    414: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    415: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    416: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    417: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    418: 		$description.=<<END if $category eq 'symbolic link';
                    419: \tln -s /$linkto \$(ROOT)/$filesfull[$i]
                    420: END
                    421: 	    }
                    422: 	}
                    423:     }
                    424:     $description.=<<END;
1.4       harris41  425: 
1.10      harris41  426: END
                    427:     return $description;
                    428: }
                    429: 
                    430: # --------------------------------------------------------- Make RPM .spec block
                    431: sub make_rpm_spec_block {
                    432:     my $pwd=`pwd`; chop $pwd;
                    433:     my $buildroot="$pwd/LON-CAPA-BuildRoot";
                    434:     my $source=$info{'RPM'}{'Name'} . "-" . $info{'RPM'}{'Version'} . '.tar.gz';
                    435:     my $description=<<END;
                    436: Summary: $info{'RPM'}{'Summary'}
                    437: Name: $info{'RPM'}{'Name'}
                    438: Version: $info{'RPM'}{'Version'}
                    439: Release: $info{'RPM'}{'Release'}
                    440: Vendor: $info{'RPM'}{'Vendor'} 
                    441: BuildRoot: $buildroot
                    442: Copyright: $info{'RPM'}{'Copyright'}
                    443: Group: $info{'RPM'}{'Group'}
                    444: Source: $source
                    445: AutoReqProv: $info{'RPM'}{'AutoReqProv'}
                    446: \%description
                    447: $info{'RPM'}{'description'}
                    448: 
                    449: END
                    450:     return $description;
                    451: }
                    452: 
                    453: # --------------------------------------------------- Make RPM build .spec block
                    454: sub make_rpm_build_block {
                    455:     my $pwd=`pwd`; chop $pwd;
                    456:     my $buildroot="$pwd/LON-CAPA-BuildRoot";
                    457:     my $sourceroot="$pwd/LON-CAPA-SourceRoot";
                    458:     my $description=<<END;
                    459: 
                    460: \%prep
                    461: \%setup
                    462: 
                    463: \%build
                    464: rm -Rf "$buildroot"
                    465: 
                    466: \%install
                    467: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" directories
                    468: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" files
                    469: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" links
                    470: 
                    471: \%pre
                    472: $info{'RPM'}{'pre'}
                    473: 
                    474: \%post
                    475: \%postun
                    476: 
                    477: \%files
                    478: # \%doc README COPYING ChangeLog LICENSE
                    479: END
                    480:     return $description;
                    481: }
                    482: 
                    483: # ------------------------------------- Make directory structure RPM .spec block
                    484: sub make_directory_structure_spec_block {
                    485:     my ($dirs)=@_;
                    486:     foreach my $d (@$dirs) {
                    487: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
                    488: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    489: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    490: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    491: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    492: 	my $own=$devchown; $own=~s/\:/\,/;
                    493: 	$description.=<<END;
                    494: \%dir \%attr($devchmod,$own) /$d
                    495: END
                    496:     }
                    497:     return $description;
                    498: }
                    499: 
                    500: # ---------------------------- Make directory and file structure RPM .spec block
                    501: sub make_directory_and_file_structure_spec_block {
                    502:     my ($dirs)=@_;
                    503:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    504:     foreach my $d (@$dirs) {
                    505: 	# set other values
                    506: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    507: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    508: 	# find files that are contained in this directory
                    509: 	my @files;
                    510: 	my @filesfull;
                    511: 	foreach my $f (@allfiles) {
                    512: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    513: 		push @files,$1;
                    514: 		push @filesfull,$f;
                    515: 	    }
                    516: 	}
                    517: 	# render starting HTML formatting elements
                    518: 	if (@files) {
                    519: 	    $description.=<<END;
                    520: # $d $dirdescription
                    521: END
                    522:         }
                    523: 	if (@files) {
                    524:             foreach my $i (0..$#files) {
                    525: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    526: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    527: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    528: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    529: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    530: 		my $own=$devchown; $own=~s/\:/\,/;
                    531: 		my $config="";
                    532: 		$config="\%config " if $category eq 'conf';
                    533: 		$devchmod='-' if $category eq 'symbolic link';
                    534: 		$description.=<<END;
                    535: $config\%attr($devchmod,$own) /$filesfull[$i]
                    536: END
                    537: 	    }
                    538: 	}
                    539:     }
                    540:     return $description;
                    541: }
                    542: 
                    543: # ----------------------------------------------------------- End RPM .spec page
                    544: sub end_spec_page {
                    545: }
                    546: 
                    547: # ------------------------------------------------------- Begin description page
1.4       harris41  548: sub begin_description_page {
                    549:     my $description=<<END;
                    550: <HTML>
                    551: <HEAD>
                    552: <TITLE>LON-CAPA Software Description Page ($distribution, $date)</TITLE>
                    553: </HEAD>
                    554: <BODY>
                    555: <FONT SIZE=+2>LON-CAPA Software Description Page ($distribution, $date)</FONT>
                    556: <BR>Michigan State University
                    557: <BR>Learning Online with CAPA
                    558: <BR>Contact korte\@lon-capa.org
                    559: <UL>
                    560: <LI>About this file
                    561: <LI>Software Package Description
                    562: <LI>Directory Structure
1.7       harris41  563: <LI>File Type Ownership and Permissions
1.4       harris41  564: <LI>File and Directory Structure
                    565: </UL>
                    566: <FONT SIZE=+2>About this file</FONT>
                    567: <P>
                    568: This file is generated dynamically by <TT>parse.pl</TT> as
                    569: part of a development compilation process.  See 
                    570: http://install.lon-capa.org/compile/index.html for more
                    571: information.
                    572: </P>
                    573: END
                    574:     return $description;
                    575: }
                    576: 
                    577: # ------------------------------------------------- End description page
                    578: sub end_description_page {
                    579:     my $description=<<END;
                    580: <HR>
1.5       harris41  581: <FONT SIZE=-1>LON-CAPA Software Development Team</FONT>
1.4       harris41  582: </BODY>
                    583: </HTML>
                    584: END
                    585:     return $description;
                    586: }
                    587: 
                    588: # ------------------------------------------------- Make RPM description block
                    589: sub make_rpm_description_block {
                    590:     my $description=<<END;
                    591: <FONT SIZE=+2>Rolled in a RedHat 6.2 RPM, $date</FONT>
                    592: <P>
                    593: <TABLE BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=10 CELLSPACING=0>
                    594: <TR><TD>
                    595: <PRE>
                    596: Name        : $info{'RPM'}{'Name'}
                    597: Version     : $info{'RPM'}{'Version'}
                    598: Vendor      : $info{'RPM'}{'Vendor'} 
                    599: Release     : $info{'RPM'}{'Release'}                             
                    600: Build Host  : $buildhost
                    601: Group       : $info{'RPM'}{'Group'}
                    602: License     : $info{'RPM'}{'Copyright'}
                    603: Summary     : $info{'RPM'}{'Summary'}
                    604: Description : 
                    605: $info{'RPM'}{'description'}
                    606: </PRE>
                    607: </TD></TR>
                    608: </TABLE>
                    609: </P>
                    610: END
                    611:     return $description;
                    612: }
                    613: 
                    614: # ----------------------------------------------- Determine directory structure
                    615: sub determine_directory_structure {
                    616:     my @directories=keys %{$info{'DIRECTORY'}{$distribution}};
                    617:     return (sort @directories);
                    618: }
1.1       harris41  619: 
1.4       harris41  620: 
                    621: # ---------------------------------- Make directory structure description block
                    622: sub make_directory_structure_description_block {
                    623:     my ($dirs)=@_;
                    624:     my $description=<<END;
                    625: <FONT SIZE=+2>Directory Structure Description, $date</FONT>
                    626: <P>
1.9       harris41  627: The directory structure description below shows only those
                    628: directories which either contain LON-CAPA specific files
                    629: or normally do not exist on a RedHat Linux system (and
                    630: must be generated to allow proper placement of files
                    631: during LON-CAPA run-time operation).
                    632: </P>
                    633: <P>
1.4       harris41  634: <TABLE BORDER=1 CELLPADDING=3 CELLSPACING=0>
                    635: END
                    636:     my $maxcount=0;
1.8       harris41  637:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    638:     my %diraccount; # hash to track which directories are accounted for
                    639:     foreach my $file (@allfiles) {
                    640: 	$file=~/^(.*)\/([^\/]+)$/;
                    641: 	$diraccount{$1}=1;
                    642:     }
1.4       harris41  643:     foreach my $d (@$dirs) {
                    644:         my (@matches)=($d=~/\//g);
                    645: 	my $count=scalar(@matches);
                    646: 	$maxcount=$count if $count>$maxcount;
1.8       harris41  647: 	delete $diraccount{$d};
1.4       harris41  648:     }
                    649:     $description.=<<END;
                    650: <TR>
                    651: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Category</TH>
                    652: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
                    653: <TH ALIGN=LEFT BGCOLOR=#FFFFFF><FONT COLOR=#FF0000>Development<BR>Permissions</FONT></TH>
                    654: END
                    655:     $description.="<TH ALIGN=LEFT BGCOLOR=#FFFFFF COLSPAN=".($maxcount+1).">Directory Path</TH>\n";
1.8       harris41  656:     if (keys %diraccount) {
                    657: 	$description.= "<TR><TD ALIGN=LEFT BGCOLOR=#FFFFFF COLSPAN=".($maxcount+4)."><I><PRE>Directories that are unaccounted for: \n";
                    658: 	foreach my $d (keys %diraccount) {
                    659: 	    $description.="$d\n";
                    660: 	}
                    661: 	$description.="</PRE></I></TH></TR>\n";
                    662:     }
1.4       harris41  663:     foreach my $d (@$dirs) {
                    664: 	my $dtable=$d;
                    665: 	$dtable=~s/\//\<\/TD\>\<TD\>/g;
                    666: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
                    667: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    668: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    669: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    670: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    671: 	$description.=<<END;
                    672: <TR>
                    673: <TD BGCOLOR=#FFFFFF>$category</TD>
                    674: <TD BGCOLOR=#FFFFFF><TT>$chmod $chown</TT></TD>
                    675: <TD BGCOLOR=#FFFFFF><FONT COLOR=#FF0000><TT>$devchmod $devchown</TT></FONT></TD>
                    676: <TD>
                    677: $dtable
                    678: </TD>
                    679: </TR>
                    680: END
                    681:     }
                    682:     $description.=<<END;
                    683: </TABLE>
                    684: </P>
                    685: END
                    686:     return $description;
                    687: }
                    688: 
1.6       harris41  689: # ------------------- Make file type ownership and permissions description block
                    690: sub make_file_type_ownership_and_permissions_description_block {
                    691:     my $description=<<END;
                    692: <FONT SIZE=+2>File Type Ownership and Permissions Descriptions, $date</FONT>
                    693: <P>
                    694: This table shows what permissions and ownership settings correspond
                    695: to each kind of file type.
                    696: </P>
                    697: <P>
                    698: <TABLE BORDER=1 CELLPADDING=5 WIDTH=60%>
                    699: <TR>
                    700: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Icon</TH>
                    701: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Type</TH>
                    702: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
                    703: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Development Permissions</TH>
                    704: </TR>
                    705: END
                    706:     foreach my $type (keys %{$info{'OWNERSHIP'}}) {
                    707: 	if (defined($fcm{$type})) {
                    708: 	    my $chmod=$info{'OWNERSHIP'}{$type}{'CHMOD'};
                    709: 	    my $chown=$info{'OWNERSHIP'}{$type}{'CHOWN'};
                    710: 	    my $devchmod=$info{'DEVOWNERSHIP'}{$type}{'CHMOD'};
                    711: 	    my $devchown=$info{'DEVOWNERSHIP'}{$type}{'CHOWN'};
                    712: 	    $description.=<<END;
                    713: <TR>
                    714: <TD><IMG SRC="$fcm{$type}.gif" ALT="$type"></TD>
                    715: <TD>$type</TD>
                    716: <TD><TT>$chmod $chown</TT></TD>
                    717: <TD><TT>$devchmod $devchown</TT></TD>
                    718: </TR>
                    719: END
                    720:         }
                    721:     }
                    722:     $description.=<<END;
                    723: </TABLE>
                    724: </P>
                    725: END
                    726: }
                    727: 
1.4       harris41  728: # ------------------------- Make directory and file structure description block
                    729: sub make_directory_and_file_structure_description_block {
                    730:     my ($dirs)=@_;
                    731:     my $description=<<END;
                    732: <FONT SIZE=+2>Directory and File Structure Description, $date</FONT>
1.6       harris41  733: <P>
                    734: The icons on the left column correspond to the file type
                    735: specified in the second column.  The last column "Notes" shows compilation,
1.7       harris41  736: dependency, and configuration information.  The CVS location
                    737: shows the location of the binary source file (if applicable) needed to
                    738: be copied to the target.  If the binary source file is not at
                    739: the specified location, then the text is shown in 
                    740: <FONT COLOR=#FF0000>red</FONT>.
1.6       harris41  741: </P>
1.4       harris41  742: <P>
1.9       harris41  743: <TABLE BORDER=1 CELLPADDING=5 WIDTH=500>
1.4       harris41  744: END
                    745:     my $counter=0;
                    746:     my @colorindex=("#80FF80","#80FFFF","#FFFF80");
1.5       harris41  747:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
1.4       harris41  748:     foreach my $d (@$dirs) {
                    749: 	# set color
                    750: 	my $color=$colorindex[$counter%3];
                    751: 	# set other values
                    752: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    753: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    754: 	# find subdirectories that are contained in this directory
                    755: 	my @subdirs;
                    756: 	foreach my $d2 (@$dirs) {
1.5       harris41  757: 	    if ($d2=~/^$d\/([^\/]+)$/) {
1.4       harris41  758: 		push @subdirs,$1;
                    759: 	    }
                    760: 	}
                    761: 	# find files that are contained in this directory
                    762: 	my @files;
1.5       harris41  763: 	my @filesfull;
1.4       harris41  764: 	foreach my $f (@allfiles) {
1.5       harris41  765: 	    if ($f=~/^$d\/([^\/]+)$/) {
1.4       harris41  766: 		push @files,$1;
1.5       harris41  767: 		push @filesfull,$f;
1.4       harris41  768: 	    }
                    769: 	}
                    770: 	# render starting HTML formatting elements
                    771: 	if (@subdirs || @files) {
                    772: 	    my $subdirstring="<BR>* Relevant subdirectories: " . join(", ",@subdirs) if @subdirs;
                    773: 	    $description.=<<END;
1.5       harris41  774: <TR><TD BGCOLOR=#000000 COLSPAN=6><FONT COLOR=$color><IMG SRC="directory.gif" ALT="directory">DIRECTORY -- $d $dirdescription
                    775: $subdirstring</FONT></TD></TR>
1.4       harris41  776: END
                    777:         }
                    778: 	else {
                    779: 	    $description.=<<END;
1.5       harris41  780: <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  781: END
                    782:         }
                    783: 	if (@files) {
                    784: 	    $description.=<<END;
                    785: <TR>
1.5       harris41  786: <TH BGCOLOR=$color ALIGN=LEFT COLSPAN=2>Type</TH>
                    787: <TH BGCOLOR=$color ALIGN=LEFT>File Name</TH>
                    788: <TH BGCOLOR=$color ALIGN=LEFT>Function</TH>
                    789: <TH BGCOLOR=$color ALIGN=LEFT>CVS Location</TH>
                    790: <TH BGCOLOR=$color ALIGN=LEFT>Notes</TH>
1.4       harris41  791: </TR>
                    792: END
1.5       harris41  793:             foreach my $i (0..$#files) {
                    794: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    795: 		my $fdescription=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DESCRIPTION'};
                    796: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
1.9       harris41  797: 		my $note=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'NOTE'};
                    798: 		$note.="<BR>" if $note;
                    799: 		my $listing=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
                    800: 		my @E=split(/\s+/,$listing);
                    801: 		$source=~/(.*)\/[^\/]+$/;
                    802: 		my $sd=$1;
                    803: 		my $eflag=0;
                    804: 		foreach my $e (@E) {
                    805: 		    unless (-e "../../$sd/$e") {
                    806: 			$e="<FONT COLOR=#FF0000>$e</FONT>";
                    807: 			$eflag=1;
                    808: 		    }
                    809: 		}
                    810: 		$listing=join("\n",@E);
                    811: 		$listing="<B>listing</B><BR><FONT SIZE=-2>$listing</FONT>" if $listing;
                    812: 		$listing.="<BR>" if $listing;
                    813: 		my $build=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'BUILD'};
                    814: 		$build="<B>build</B><BR>$build" if $build;
                    815: 		$build.="<BR>" if $build;
                    816: 		my $dependencies=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DEPENDENCIES'};
                    817: 		$dependencies="<B>dependencies</B><BR>$dependencies" if $dependencies;
                    818: 		$dependencies.="<BR>" if $dependencies;
1.7       harris41  819: 		unless (-e "../../$source") {
                    820: 		    $source=~/([^\/]+)$/;
                    821: 		    my $s=$1;
1.9       harris41  822: 		    if ($source!~/\*/) {
                    823: 			$source="<FONT COLOR=#FF0000>$source</FONT>";
                    824: 		    }
                    825: 		    elsif ($eflag) {
                    826: 			$source="<FONT COLOR=#FF0000>$source</FONT>";
                    827: 		    }
1.7       harris41  828: 		}
1.5       harris41  829: 		$description.=<<END;
                    830: <TR>
                    831: <TD BGCOLOR=#A0A0A0><IMG SRC="$fcm{$category}.gif" ALT="$category"></TD>
                    832: <TD BGCOLOR=$color>$category</TD>
                    833: <TD BGCOLOR=$color>$files[$i]</TD>
                    834: <TD BGCOLOR=$color>$fdescription&nbsp;</TD>
                    835: <TD BGCOLOR=$color>$source</TD>
1.9       harris41  836: <TD BGCOLOR=$color>$note$listing$build$dependencies&nbsp;</TD>
1.4       harris41  837: </TR>
                    838: END
1.5       harris41  839: 	    }
                    840: 	}
1.4       harris41  841: 	$counter++;
                    842:     }
                    843:     $description.=<<END;
                    844: </TABLE>
                    845: </P>
                    846: END
                    847:     return $description;
                    848: }

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