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

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

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