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

1.1       harris41    1: #!/usr/bin/perl
                      2: 
                      3: # Scott Harrison
                      4: # November 2000
1.35      harris41    5: # 12/5/2000,12/7,12/8,12/9,12/10,12/11,12/12,12/13,12/14,12/21 Scott Harrison
                      6: # 1/8/2001,1/10/2001,1/13/2001,1/16/2001,1/18/2001,1/23/2001 Scott Harrison
                      7: # 2/26/2001,2/27/2001,3/5/2001,4/10/2001,4/11,2001,4/13,2001 Scott Harrison
                      8: # 4/17/2001 Scott Harrison
1.33      harris41    9: 
                     10: # Read in loncapa tags and metagroup tags.  Output various
                     11: # useful files for viewing, compiling, monitoring, updating,
                     12: # and installing.
                     13: 
                     14: # This code works well.  HOWEVER, I was in a rush when I
                     15: # wrote it.  Future plans are that the parsing should be
                     16: # much more event-state based and the input should be
                     17: # more XML-ish. -Scott
1.1       harris41   18: 
1.4       harris41   19: # ---------------------------------------------- Read in command line arguments
1.1       harris41   20: my ($file,$mode)=@ARGV;
1.2       harris41   21: 
1.4       harris41   22: # ---------------------------------------------------- Read in master data file
1.1       harris41   23: open IN,"<$file";
                     24: my @lines=<IN>;
                     25: close IN;
1.5       harris41   26: my $info1=join('',@lines);
                     27: my $info2=$info1; # value to allow for meta data group retrieval
1.1       harris41   28: 
1.4       harris41   29: # ------------------------------------------------------- Make default settings
                     30: my $distribution="redhat6.2";
                     31: my $date=`date +'%B %e, %Y'`; chop $date;
                     32: my $buildhost=`hostname`; chop $buildhost;
1.5       harris41   33: # file category mappings
                     34: my %fcm=(
                     35: 	 'conf' => 'configurable',
                     36: 	 'graphic file' => 'graphicfile',
                     37: 	 'handler' => 'handler',
                     38: 	 'interface file' => 'interfacefile',
                     39: 	 'symbolic link' => 'link',
                     40: 	 'root script' => 'rootscript',
                     41: 	 'script' => 'script',
                     42: 	 'setuid script' => 'setuid',
                     43: 	 'static conf' => 'static',
                     44: 	 'system file' => 'systemfile',
                     45: 	 );
1.4       harris41   46: 
                     47: # ---------------------------------------------------- Parse the marked up data
                     48: my %info; # big data storage object
1.5       harris41   49: while ($info1=~/\<loncapa\s+(.*?)\>/isg) {
1.1       harris41   50:     my $keystring=$1;
1.4       harris41   51:     # In the parsing of LON-CAPA tags, remove boundary white-space,
                     52:     # and handle quotation commands.
1.2       harris41   53:     my %hash=map {my ($key,$value)=split(/\=(?!")|\=(?=\s*"[^"]*"[^"]*$)/);
                     54:                                    $value=~s/^"//;
                     55:  				   $value=~s/"$//;
                     56:                                    (uc($key),$value);}
                     57:              split(/\s+(?=\w+\s*\=)/,$keystring);
1.4       harris41   58:     # Handle the different types of commands
1.1       harris41   59:     if (uc($hash{'TYPE'}) eq "OWNERSHIP") {
                     60:         $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHMOD'}=$hash{'CHMOD'};
                     61:         $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHOWN'}=$hash{'CHOWN'};
                     62:     }
                     63:     elsif (uc($hash{'TYPE'}) eq "DEVOWNERSHIP") {
                     64:         $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHMOD'}=$hash{'CHMOD'};
                     65:         $info{$hash{'TYPE'}}{$hash{'CATEGORY'}}{'CHOWN'}=$hash{'CHOWN'};
                     66:     }
                     67:     elsif (uc($hash{'TYPE'}) eq "RPM") {
                     68:         $hash{'VALUE'}=~s/\\n/\n/g;
                     69:         $info{$hash{'TYPE'}}{$hash{'NAME'}}=$hash{'VALUE'};
                     70:     }
                     71:     elsif (uc($hash{'TYPE'}) eq "DIRECTORY") {
1.4       harris41   72:         $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'CATEGORY'}=
                     73:                                                        $hash{'CATEGORY'};
                     74:         $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'DESCRIPTION'}=
                     75:                                $hash{'DESCRIPTION'} if $hash{'DESCRIPTION'};
1.1       harris41   76:     }
                     77:     elsif (uc($hash{'TYPE'}) eq "LOCATION") {
1.5       harris41   78:         $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'CATEGORY'}=                               $hash{'CATEGORY'};
1.10      harris41   79:         $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'LINKTO'}=                               $hash{'LINKTO'};
1.5       harris41   80:         $info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{'SOURCE'}=                                               $hash{'SOURCE'};
1.1       harris41   81:         # get surrounding metagroup information
                     82:         my $ckeystring=$keystring; $ckeystring=~s/(SOURCE\=\"[^"]*)\*/$1\\\*/g;
1.5       harris41   83:         $ckeystring=~s/(TARGET\=\"[^"]*)\*/$1\\\*/g;
1.1       harris41   84:         $info2=~/.*\<(?:metagroup|metasupergroup)\>(.*?)\<loncapa\s+$ckeystring\>(.*?)\<\/(?:metagroup|metasupergroup)\>/is;
                     85: 	my $data=$1.$2;
                     86:         my @meta=('description','build','dependencies','files','note');
                     87:         foreach my $m (@meta) {
                     88: 	    if ($data=~/\<($m)\>(.*?)\<\/$m\>/sgi) {
                     89: 		my ($key,$value)=($1,$2);
1.9       harris41   90: 		$info{$hash{'TYPE'}}{$hash{'DIST'}}{$hash{'TARGET'}}{uc($key)}=
1.4       harris41   91: 		                                                    $value;
1.1       harris41   92: 	    }
                     93:         }
                     94:     }
                     95:     else {
                     96:         warn("WARNING: this tag text will be ignored since it cannot be understood\n---> $keystring\n");
                     97:     }
                     98: }
                     99: 
1.10      harris41  100: my $a;
                    101: my @directories;
                    102: if ($mode eq "HTML") {
1.4       harris41  103:     $a=&begin_description_page;
                    104:     print $a;
                    105:     $a=&make_rpm_description_block;
                    106:     print $a;
                    107:     @directories=&determine_directory_structure;
                    108:     $a=&make_directory_structure_description_block(\@directories);
                    109:     print $a;
1.6       harris41  110:     $a=&make_file_type_ownership_and_permissions_description_block;
                    111:     print $a;
1.4       harris41  112:     $a=&make_directory_and_file_structure_description_block(\@directories);
                    113:     print $a;
                    114:     $a=&end_description_page;
                    115:     print $a;
                    116: }
1.10      harris41  117: elsif ($mode eq "SPEC") {
                    118:     my $out=$info{'RPM'}{'Name'} . '-' . $info{'RPM'}{'Version'} . '.spec';
                    119:     open OUT,">$out";
                    120:     $a=&make_rpm_spec_block;
                    121:     print OUT $a;
                    122:     $a=&make_rpm_build_block;
                    123:     print OUT $a;
                    124:     @directories=&determine_directory_structure;
                    125:     $a=&make_directory_structure_spec_block(\@directories);
                    126:     print OUT $a;
                    127:     $a=&make_directory_and_file_structure_spec_block(\@directories);
                    128:     print OUT $a;
                    129:     $a=&end_spec_page;
                    130:     print OUT $a;
                    131:     close OUT;
                    132: }
                    133: elsif ($mode eq "LCMakefile") {
                    134:     @directories=&determine_directory_structure;
1.14      harris41  135:     $a=&make_directory_LCMakefile_segment(\@directories);
1.10      harris41  136:     print $a;
1.14      harris41  137:     $a=&make_files_LCMakefile_segment(\@directories);
1.10      harris41  138:     print $a;
1.14      harris41  139:     $a=&make_links_LCMakefile_segment(\@directories);
1.10      harris41  140:     print $a;
                    141: }
1.11      harris41  142: elsif ($mode eq "BinaryRoot") {
                    143:     mkdir "BinaryRoot",0755;
                    144:     open OUT,">Makefile.BinaryRoot";
                    145:     @directories=&determine_directory_structure;
                    146:     $a=&make_directory_binaryroot_segment(\@directories);
                    147:     print OUT $a;
                    148:     $a=&make_files_binaryroot_segment(\@directories);
                    149:     print OUT $a;
                    150:     $a=&make_links_binaryroot_segment(\@directories);
                    151:     print OUT $a;
                    152:     close OUT;
                    153:     print `make -f Makefile.BinaryRoot TARGET='BinaryRoot' SOURCE='../..' directories`;
                    154:     print `make -f Makefile.BinaryRoot TARGET='BinaryRoot' SOURCE='../..' files`;
                    155:     print `make -f Makefile.BinaryRoot TARGET='BinaryRoot' SOURCE='../..' links`;
                    156:     open OUT,">base_file_list.txt";
                    157:     $a=&make_file_list(\@directories);
                    158:     print OUT $a;
                    159:     close OUT;
1.21      harris41  160:     open OUT,">setup_file_list.txt";
                    161:     print OUT "BinaryRoot/etc/passwd\n";
                    162:     close OUT;
                    163:     open OUT,">BinaryRoot/etc/passwd";
                    164:     print OUT<<END;
1.22      harris41  165: root::0:0:root:/root:/bin/bash
1.24      harris41  166: bin:!!:1:1:bin:/bin:
                    167: daemon:!!:2:2:daemon:/sbin:
                    168: adm:!!:3:4:adm:/var/adm:
                    169: lp:!!:4:7:lp:/var/spool/lpd:
                    170: sync:!!:5:0:sync:/sbin:/bin/sync
                    171: shutdown:!!:6:0:shutdown:/sbin:/sbin/shutdown
                    172: halt:!!:7:0:halt:/sbin:/sbin/halt
                    173: mail:!!:8:12:mail:/var/spool/mail:
                    174: news:!!:9:13:news:/var/spool/news:
                    175: uucp:!!:10:14:uucp:/var/spool/uucp:
                    176: operator:!!:11:0:operator:/root:
                    177: games:!!:12:100:games:/usr/games:
                    178: gopher:!!:13:30:gopher:/usr/lib/gopher-data:
                    179: ftp:!!:14:50:FTP User:/home/ftp:
                    180: nobody:!!:99:99:Nobody:/:
                    181: www:!!:500:500:www:/home/www:/bin/bash
1.21      harris41  182: END
                    183: close OUT;
1.23      harris41  184:     open OUT,">>setup_file_list.txt";
                    185:     print OUT "BinaryRoot/etc/hosts.deny\n";
                    186:     close OUT;
                    187:     open OUT,">BinaryRoot/etc/hosts.deny";
                    188:     print OUT<<END;
                    189: ALL: ALL
                    190: END
                    191: close OUT;
                    192:     
1.27      harris41  193:     `install -o 500 -g 500 -m 0700 -d BinaryRoot/home/www`;
                    194:     open OUT,">>setup_file_list.txt";
                    195:     print OUT "BinaryRoot/home/www\n";
                    196:     close OUT;
1.23      harris41  197:     `install -d BinaryRoot/etc/pam.d`;
                    198:     open OUT,">>setup_file_list.txt";
                    199:     print OUT "BinaryRoot/etc/pam.d/passwd\n";
                    200:     close OUT;
                    201:     open OUT,">BinaryRoot/etc/pam.d/passwd";
                    202:     print OUT<<END;
                    203: #%PAM-1.0
                    204: auth       required     /lib/security/pam_pwdb.so shadow nullok
                    205: account    required     /lib/security/pam_pwdb.so
                    206: password   required     /lib/security/pam_cracklib.so retry=3
                    207: password   required     /lib/security/pam_pwdb.so use_authtok nullok
                    208: END
                    209: close OUT;
                    210:     open OUT,">>setup_file_list.txt";
                    211:     print OUT "BinaryRoot/etc/pam.d/login\n";
                    212:     close OUT;
                    213:     open OUT,">BinaryRoot/etc/pam.d/login";
                    214:     print OUT<<END;
                    215: #%PAM-1.0
                    216: auth       required     /lib/security/pam_securetty.so
                    217: auth       required     /lib/security/pam_pwdb.so shadow nullok
                    218: auth       required     /lib/security/pam_nologin.so
                    219: account    required     /lib/security/pam_pwdb.so
                    220: password   required     /lib/security/pam_cracklib.so
                    221: password   required     /lib/security/pam_pwdb.so nullok use_authtok
                    222: session    required     /lib/security/pam_pwdb.so
                    223: session    optional     /lib/security/pam_console.so
                    224: END
                    225: close OUT;
1.21      harris41  226: 
1.11      harris41  227: }
1.10      harris41  228: elsif ($mode eq "status") {
1.25      harris41  229:     $a=&begin_description_page('status');
                    230:     print $a;
                    231:     $a=&make_rpm_description_block('status');
                    232:     print $a;
                    233:     @directories=&determine_directory_structure('status');
                    234:     $a=&make_directory_structure_description_block(\@directories,'status');
                    235:     print $a;
                    236:     $a=&make_file_type_ownership_and_permissions_description_block('status');
                    237:     print $a;
                    238:     $a=&make_directory_and_file_structure_description_block(\@directories,'status');
                    239:     print $a;
                    240:     $a=&end_description_page('status');
                    241:     print $a;
1.10      harris41  242: }
                    243: elsif ($mode eq "update") {
                    244: }
1.16      harris41  245: elsif ($mode eq "configinstall") {
                    246:     @directories=&determine_directory_structure;
                    247:     $a=&make_files_configinstall_segment(\@directories);
                    248:     print $a;
1.17      harris41  249:     $a=&make_files_configpermissions_segment(\@directories);
                    250:     print $a;
1.16      harris41  251: }
1.14      harris41  252: elsif ($mode eq "install") {
                    253:     @directories=&determine_directory_structure;
                    254:     $a=&make_directory_install_segment(\@directories);
                    255:     print $a;
                    256:     $a=&make_files_install_segment(\@directories);
                    257:     print $a;
                    258:     $a=&make_links_install_segment(\@directories);
                    259:     print $a;
1.11      harris41  260: }
1.15      harris41  261: elsif ($mode eq "build") {
                    262:     @directories=&determine_directory_structure;
                    263:     $a=&make_files_build_segment(\@directories);
                    264:     print $a;
                    265: }
1.11      harris41  266: 
                    267: # ------------------------------------------------------ a list of file targets
                    268: sub make_file_list {
                    269:     my ($dirs)=@_;
                    270:     my $description;
                    271:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    272:     foreach my $d (@$dirs) {
                    273: 	# set other values
1.19      harris41  274: 	$description.=<<END;
1.18      harris41  275: BinaryRoot/$d
                    276: END
1.11      harris41  277: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    278: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    279: 	# find files that are contained in this directory
                    280: 	my @files;
                    281: 	my @filesfull;
                    282: 	foreach my $f (@allfiles) {
                    283: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    284: 		push @files,$1;
                    285: 		push @filesfull,$f;
                    286: 	    }
                    287: 	}
                    288: 	# render starting HTML formatting elements
                    289: 	if (@files) {
                    290:         }
1.12      harris41  291: 	my $pwd=`pwd`; chop $pwd;
1.11      harris41  292: 	if (@files) {
                    293:             foreach my $i (0..$#files) {
                    294: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    295: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    296: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    297: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    298: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    299: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
                    300: 		my $rot="/".$filesfull[$i];
                    301: 		if ($rot=~/\*/) {
                    302: 		    $rot=~s/[^\/]+$// if $rot=~/\*/;
                    303: 		    my $listing=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
                    304: 		    chop $listing;
                    305: 		    my @list=split(/\s+/,$listing);
                    306: 		    my $rot2;
                    307: 		    foreach my $l (@list) {
                    308: 			$l=~s/^\s*//; $l=~s/\s*$//;
1.12      harris41  309: 			$rot2.="BinaryRoot$rot$l\n" if length($l);
1.11      harris41  310: 		    }
                    311: 		    chop $rot2;
                    312: 		    $rot=$rot2;
1.12      harris41  313: 		}
                    314: 		else {
                    315: 		    $rot="BinaryRoot$rot";
1.11      harris41  316: 		}
1.13      harris41  317: 		if ($category eq "conf") {
                    318: 		    $rot.=" # config";
                    319: 		}
1.11      harris41  320: 		$description.=<<END;
                    321: $rot
                    322: END
                    323: 	    }
                    324: 	}
                    325:     }
                    326:     $description.=<<END;
                    327: 
                    328: END
                    329:     return $description;
                    330: }
                    331: 
                    332: # --------------------------------- Commands to make BinaryRoot directories
                    333: sub make_directory_binaryroot_segment {
                    334:     my ($dirs)=@_;
                    335:     my $description=<<END;
                    336: directories:
                    337: END
                    338:     foreach my $d (@$dirs) {
                    339: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
                    340: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    341: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    342: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    343: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
1.20      harris41  344: 	my ($owner,$group)=split(/\:/,$devchown);
1.11      harris41  345: 	my $own=$devchown; $own=~s/\:/\,/;
                    346: 	$description.=<<END;
1.20      harris41  347: \tinstall -o $owner -g $group -m $devchmod -d \$(TARGET)/$d
1.11      harris41  348: END
                    349:     }
                    350:     $description.=<<END;
                    351: 
                    352: END
                    353:     return $description;
                    354: }
                    355: 
                    356: # --------------------------------------- Commands to make BinaryRoot files
                    357: sub make_files_binaryroot_segment {
                    358:     my ($dirs)=@_;
                    359:     my $description=<<END;
                    360: files:
                    361: END
                    362:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    363:     foreach my $d (@$dirs) {
                    364: 	# set other values
                    365: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    366: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    367: 	# find files that are contained in this directory
                    368: 	my @files;
                    369: 	my @filesfull;
                    370: 	foreach my $f (@allfiles) {
                    371: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    372: 		push @files,$1;
                    373: 		push @filesfull,$f;
                    374: 	    }
                    375: 	}
                    376: 	# render starting HTML formatting elements
                    377: 	if (@files) {
                    378: 	    $description.=<<END;
                    379: \t# $d $dirdescription
                    380: END
                    381:         }
                    382: 	if (@files) {
                    383:             foreach my $i (0..$#files) {
                    384: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    385: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    386: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    387: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    388: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    389: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
                    390: 		my $rot=$filesfull[$i];
                    391: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
1.20      harris41  392: 		my ($owner,$group)=split(/\:/,$devchown);
1.11      harris41  393: 		$description.=<<END if $category ne 'symbolic link';
1.20      harris41  394: \tinstall -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
1.11      harris41  395: END
                    396: 	    }
                    397: 	}
                    398:     }
                    399:     $description.=<<END;
                    400: 
                    401: END
                    402:     return $description;
                    403: }
                    404: 
                    405: # ------------------------------ Commands to make BinaryRoot symbolic links
                    406: sub make_links_binaryroot_segment {
                    407:     my ($dirs)=@_;
                    408:     my $description=<<END;
                    409: links:
                    410: END
                    411:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    412:     foreach my $d (@$dirs) {
                    413: 	# find files that are contained in this directory
                    414: 	my @files;
                    415: 	my @filesfull;
                    416: 	foreach my $f (@allfiles) {
                    417: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    418: 		push @files,$1;
                    419: 		push @filesfull,$f;
                    420: 	    }
                    421: 	}
                    422: 	# render starting HTML formatting elements
                    423: 	if (@files) {
                    424:             foreach my $i (0..$#files) {
                    425: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    426: 		my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
                    427: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    428: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    429: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    430: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    431: 		$description.=<<END if $category eq 'symbolic link';
                    432: \tln -s /$linkto \$(TARGET)/$filesfull[$i]
                    433: END
                    434: 	    }
                    435: 	}
                    436:     }
                    437:     $description.=<<END;
                    438: 
                    439: END
                    440:     return $description;
1.10      harris41  441: }
                    442: 
1.14      harris41  443: # ------ Installation commands for a Makefile used only by a rpm -ba invocation
                    444: sub make_directory_LCMakefile_segment {
                    445:     my ($dirs)=@_;
                    446:     my $description=<<END;
                    447: directories:
                    448: END
                    449:     foreach my $d (@$dirs) {
                    450: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
                    451: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    452: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    453: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    454: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    455: 	my $own=$devchown; $own=~s/\:/\,/;
                    456: 	$description.=<<END;
                    457: \tinstall -m $devchmod -d \$(SOURCE)/$d \$(ROOT)/$d
                    458: END
                    459:     }
                    460:     $description.=<<END;
                    461: 
                    462: END
                    463:     return $description;
                    464: }
                    465: 
                    466: # ------ Installation commands for a Makefile used only by a rpm -ba invocation
                    467: sub make_files_LCMakefile_segment {
                    468:     my ($dirs)=@_;
                    469:     my $description=<<END;
                    470: files:
                    471: END
                    472:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    473:     foreach my $d (@$dirs) {
                    474: 	# set other values
                    475: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    476: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    477: 	# find files that are contained in this directory
                    478: 	my @files;
                    479: 	my @filesfull;
                    480: 	foreach my $f (@allfiles) {
                    481: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    482: 		push @files,$1;
                    483: 		push @filesfull,$f;
                    484: 	    }
                    485: 	}
                    486: 	# render starting HTML formatting elements
                    487: 	if (@files) {
                    488: 	    $description.=<<END;
                    489: \t# $d $dirdescription
                    490: END
                    491:         }
                    492: 	if (@files) {
                    493:             foreach my $i (0..$#files) {
                    494: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    495: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    496: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    497: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    498: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    499: 		my $rot=$filesfull[$i];
                    500: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
                    501: 		$description.=<<END if $category ne 'symbolic link';
                    502: \tinstall -m $devchmod \$(SOURCE)/$filesfull[$i] \$(ROOT)/$rot
                    503: END
                    504: 	    }
                    505: 	}
                    506:     }
                    507:     $description.=<<END;
                    508: 
                    509: END
                    510:     return $description;
                    511: }
                    512: 
                    513: # ------ Installation commands for a Makefile used only by a rpm -ba invocation
                    514: sub make_links_LCMakefile_segment {
                    515:     my ($dirs)=@_;
                    516:     my $description=<<END;
                    517: links:
                    518: END
                    519:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    520:     foreach my $d (@$dirs) {
                    521: 	# find files that are contained in this directory
                    522: 	my @files;
                    523: 	my @filesfull;
                    524: 	foreach my $f (@allfiles) {
                    525: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    526: 		push @files,$1;
                    527: 		push @filesfull,$f;
                    528: 	    }
                    529: 	}
                    530: 	# render starting HTML formatting elements
                    531: 	if (@files) {
                    532:             foreach my $i (0..$#files) {
                    533: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    534: 		my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
                    535: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    536: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    537: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    538: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    539: 		$description.=<<END if $category eq 'symbolic link';
                    540: \tln -s /$linkto \$(ROOT)/$filesfull[$i]
                    541: END
                    542: 	    }
                    543: 	}
                    544:     }
                    545:     $description.=<<END;
                    546: 
                    547: END
                    548:     return $description;
                    549: }
                    550: 
1.10      harris41  551: # --------------------------------- Installation commands to install directories
                    552: sub make_directory_install_segment {
                    553:     my ($dirs)=@_;
                    554:     my $description=<<END;
                    555: directories:
                    556: END
                    557:     foreach my $d (@$dirs) {
                    558: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
1.14      harris41  559: 	my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
1.10      harris41  560: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    561: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    562: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    563: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
1.16      harris41  564: 	my ($owner,$group)=split(/\:/,$devchown);
1.10      harris41  565: 	my $own=$devchown; $own=~s/\:/\,/;
                    566: 	$description.=<<END;
1.16      harris41  567: \tinstall -o $owner -g $group -m $devchmod -d \$(TARGET)/$d
1.10      harris41  568: END
                    569:     }
                    570:     $description.=<<END;
                    571: 
                    572: END
                    573:     return $description;
                    574: }
                    575: 
1.15      harris41  576: # ------------------------------------------------------ Commands to build files
                    577: sub make_files_build_segment {
                    578:     my ($dirs)=@_;
                    579:     my $description;
                    580:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    581:     my $tab="\t";
1.33      harris41  582:     my $sources="# Dynamic Makefile generated by LON-CAPA build process\n\n";
                    583:     $sources.="SHELL=\"/bin/sh\"\n\n";
                    584:     $sources.="\nall: ";
1.15      harris41  585:     foreach my $d (@$dirs) {
                    586: 	# set other values
                    587: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    588: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    589: 	# find files that are contained in this directory
                    590: 	my @files;
                    591: 	my @filesfull;
                    592: 	foreach my $f (@allfiles) {
                    593: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    594: 		push @files,$1;
                    595: 		push @filesfull,$f;
                    596: 	    }
                    597: 	}
                    598: 	if (@files) {
                    599:             foreach my $i (0..$#files) {
                    600: 		# if has build information, output appropriate something
                    601: 		my $build=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'BUILD'};
                    602: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
                    603: 		$build=~s/^\s+//; $build=~s/\s+$//;
                    604: 		if ($build) {
                    605: 		    my $dependencies=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DEPENDENCIES'};
                    606: 		    my $source2=$source;
                    607: 		    $source2=~s/^[^\/]+\///;
                    608:  		    $source2="../" . $source2;
                    609: 		    $sources.="$source2 ";
                    610: 		    my $directory=$build;
                    611: 		    $directory=~s/^[^\/]+\///;
                    612: 		    $directory=~s/([^\/]+)$//;
                    613:  		    $directory="../" . $directory;
                    614: 		    my $buildfile=$1;
                    615: 		    my $sdir=$source;
                    616: 		    $sdir=~s/^[^\/]+\///;
                    617: 		    $sdir=~s/([^\/]+)$//;
                    618:  		    $sdir="../" . $sdir;
                    619: 		    $dependencies=~s/\s+$//;
                    620: 		    my $depstat="";
                    621: 		    if ($dependencies=~s/\s+\[ALWAYS_RUN_BUILD_COMMAND\]//) {
                    622: 			$depstat=" alwaysrun";
                    623: 		    }
                    624: 		    $dependencies=~s/\s+/ $sdir/gs;
1.33      harris41  625: 		    my @deps=split(/\s+/,$dependencies);
                    626: 		    shift @deps;
                    627: 		    my $testing=<<END;
                    628: 	\@if !(echo "");\\
                    629: 	        then echo "**** LON-CAPA WARNING **** Strange shell. Check your path settings.";\\
                    630: END
                    631: 		    foreach my $d (@deps) {
                    632: 			$testing.=<<END;
                    633: 	elif !(test -r $d);\\
                    634: 		then echo "**** LON-CAPA WARNING **** missing the file: $d";\\
                    635: END
                    636: 		    }
                    637: 		    chop $testing;
1.15      harris41  638: 		    $description.=<<END;
1.33      harris41  639: $source2: $depstat
                    640: $testing
                    641:         else \\
                    642: 	    ${tab}cd $directory; sh ./$buildfile;\\
                    643:         fi
1.15      harris41  644: 
                    645: END
                    646: 		}
                    647: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    648: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
                    649: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    650: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    651: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    652: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    653: 		my $rot=$filesfull[$i];
                    654: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
                    655: #		$description.=<<END if $category ne 'symbolic link';
1.16      harris41  656: #\tinstall -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
1.15      harris41  657: #END
                    658: 	    }
                    659: 	}
                    660:     }
                    661:     $description.=<<END;
                    662: alwaysrun:
                    663: 
                    664: END
                    665:     $sources.="\n\n";
                    666:     return ($sources . $description);
                    667: }
                    668: 
1.10      harris41  669: # --------------------------------------- Installation commands to install files
                    670: sub make_files_install_segment {
                    671:     my ($dirs)=@_;
                    672:     my $description=<<END;
                    673: files:
                    674: END
                    675:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    676:     foreach my $d (@$dirs) {
                    677: 	# set other values
                    678: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    679: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    680: 	# find files that are contained in this directory
                    681: 	my @files;
                    682: 	my @filesfull;
                    683: 	foreach my $f (@allfiles) {
                    684: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    685: 		push @files,$1;
                    686: 		push @filesfull,$f;
                    687: 	    }
                    688: 	}
                    689: 	# render starting HTML formatting elements
                    690: 	if (@files) {
                    691: 	    $description.=<<END;
                    692: \t# $d $dirdescription
                    693: END
                    694:         }
                    695: 	if (@files) {
                    696:             foreach my $i (0..$#files) {
                    697: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
1.14      harris41  698: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
1.10      harris41  699: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    700: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    701: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    702: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    703: 		my $rot=$filesfull[$i];
                    704: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
1.16      harris41  705: 		my ($owner,$group)=split(/\:/,$devchown);
1.35      harris41  706: 		if ($category ne 'conf' && $category ne 'symbolic link') {
                    707: 		    if ($source!~/\*/) {
                    708: 			$description.=<<END;
1.37    ! harris41  709: \ttest -e \$(SOURCE)/$source \&\& install -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot || echo "**** LON-CAPA WARNING **** CVS source file does not exist: \$(SOURCE)/$source"
1.16      harris41  710: END
1.35      harris41  711:                     }
                    712: 		    else {
1.36      harris41  713: 			$description.=<<END;
1.35      harris41  714: \tinstall -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
                    715: END
                    716: 		    }
1.16      harris41  717:                 }
                    718: 	    }
                    719: 	}
                    720:     }
                    721:     $description.=<<END;
                    722: 
                    723: END
                    724:     return $description;
                    725: }
                    726: 
                    727: # ------ Installation commands to install configuration files (and make backups)
                    728: sub make_files_configinstall_segment {
                    729:     my ($dirs)=@_;
                    730:     my $description=<<END;
                    731: configfiles:
                    732: END
                    733:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    734:     foreach my $d (@$dirs) {
                    735: 	# set other values
                    736: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    737: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    738: 	# find files that are contained in this directory
                    739: 	my @files;
                    740: 	my @filesfull;
                    741: 	foreach my $f (@allfiles) {
                    742: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    743: 		push @files,$1;
                    744: 		push @filesfull,$f;
                    745: 	    }
                    746: 	}
                    747: 	# render starting HTML formatting elements
                    748: 	if (@files) {
                    749: 	    $description.=<<END;
                    750: \t# $d $dirdescription
                    751: END
                    752:         }
                    753: 	if (@files) {
                    754:             foreach my $i (0..$#files) {
                    755: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    756: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
                    757: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    758: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    759: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    760: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    761: 		my $rot=$filesfull[$i];
                    762: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
                    763: 		my ($owner,$group)=split(/\:/,$devchown);
                    764: 		if ($category eq 'conf') {
                    765: 		    $description.=<<END;
1.32      harris41  766: \tcp -p \$(TARGET)/$rot \$(TARGET)/$rot`date +'.\%Y\%m\%d\%H\%M\%S'` 2>/dev/null; install -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
1.17      harris41  767: END
                    768:                 }
                    769: 	    }
                    770: 	}
                    771:     }
                    772:     $description.=<<END;
                    773: 
                    774: END
                    775:     return $description;
                    776: }
                    777: 
                    778: # ------ Commands to enforce configuration file permissions
                    779: sub make_files_configpermissions_segment {
                    780:     my ($dirs)=@_;
                    781:     my $description=<<END;
                    782: configpermissions:
                    783: END
                    784:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    785:     foreach my $d (@$dirs) {
                    786: 	# set other values
                    787: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    788: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    789: 	# find files that are contained in this directory
                    790: 	my @files;
                    791: 	my @filesfull;
                    792: 	foreach my $f (@allfiles) {
                    793: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    794: 		push @files,$1;
                    795: 		push @filesfull,$f;
                    796: 	    }
                    797: 	}
                    798: 	# render starting HTML formatting elements
                    799: 	if (@files) {
                    800: 	    $description.=<<END;
                    801: \t# $d $dirdescription
                    802: END
                    803:         }
                    804: 	if (@files) {
                    805:             foreach my $i (0..$#files) {
                    806: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    807: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
                    808: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    809: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    810: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    811: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    812: 		my $rot=$filesfull[$i];
                    813: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
                    814: 		my ($owner,$group)=split(/\:/,$devchown);
                    815: 		if ($category eq 'conf') {
                    816: 		    $description.=<<END;
                    817: \tchmod $devchmod \$(TARGET)/$rot
                    818: \tchown $devchown \$(TARGET)/$rot
1.10      harris41  819: END
1.15      harris41  820:                 }
1.10      harris41  821: 	    }
                    822: 	}
                    823:     }
                    824:     $description.=<<END;
                    825: 
                    826: END
                    827:     return $description;
                    828: }
                    829: 
                    830: # ------------------------------ Installation commands to install symbolic links
                    831: sub make_links_install_segment {
                    832:     my ($dirs)=@_;
                    833:     my $description=<<END;
                    834: links:
                    835: END
1.16      harris41  836:     chop $description;
                    837:     my $description2;
1.10      harris41  838:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    839:     foreach my $d (@$dirs) {
                    840: 	# find files that are contained in this directory
                    841: 	my @files;
                    842: 	my @filesfull;
                    843: 	foreach my $f (@allfiles) {
                    844: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    845: 		push @files,$1;
                    846: 		push @filesfull,$f;
                    847: 	    }
                    848: 	}
                    849: 	# render starting HTML formatting elements
                    850: 	if (@files) {
                    851:             foreach my $i (0..$#files) {
                    852: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    853: 		my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
                    854: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    855: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    856: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    857: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
1.16      harris41  858: 		if ($category eq 'symbolic link') {
                    859: 		    $description.=" \$(TARGET)/$filesfull[$i]";
                    860: 		    $description2.=<<END;
                    861: \$(TARGET)/$filesfull[$i]:
1.14      harris41  862: \tln -s /$linkto \$(TARGET)/$filesfull[$i]
1.16      harris41  863: 
1.10      harris41  864: END
1.16      harris41  865:                 }
1.10      harris41  866: 	    }
                    867: 	}
                    868:     }
                    869:     $description.=<<END;
1.4       harris41  870: 
1.10      harris41  871: END
1.16      harris41  872:     $description.=$description2;
1.10      harris41  873:     return $description;
                    874: }
                    875: 
                    876: # --------------------------------------------------------- Make RPM .spec block
                    877: sub make_rpm_spec_block {
                    878:     my $pwd=`pwd`; chop $pwd;
                    879:     my $buildroot="$pwd/LON-CAPA-BuildRoot";
                    880:     my $source=$info{'RPM'}{'Name'} . "-" . $info{'RPM'}{'Version'} . '.tar.gz';
                    881:     my $description=<<END;
                    882: Summary: $info{'RPM'}{'Summary'}
                    883: Name: $info{'RPM'}{'Name'}
                    884: Version: $info{'RPM'}{'Version'}
                    885: Release: $info{'RPM'}{'Release'}
                    886: Vendor: $info{'RPM'}{'Vendor'} 
                    887: BuildRoot: $buildroot
                    888: Copyright: $info{'RPM'}{'Copyright'}
                    889: Group: $info{'RPM'}{'Group'}
                    890: Source: $source
                    891: AutoReqProv: $info{'RPM'}{'AutoReqProv'}
                    892: \%description
                    893: $info{'RPM'}{'description'}
                    894: 
                    895: END
                    896:     return $description;
                    897: }
                    898: 
                    899: # --------------------------------------------------- Make RPM build .spec block
                    900: sub make_rpm_build_block {
                    901:     my $pwd=`pwd`; chop $pwd;
                    902:     my $buildroot="$pwd/LON-CAPA-BuildRoot";
                    903:     my $sourceroot="$pwd/LON-CAPA-SourceRoot";
                    904:     my $description=<<END;
                    905: 
                    906: \%prep
                    907: \%setup
                    908: 
                    909: \%build
                    910: rm -Rf "$buildroot"
                    911: 
                    912: \%install
                    913: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" directories
                    914: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" files
                    915: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" links
                    916: 
                    917: \%pre
                    918: $info{'RPM'}{'pre'}
                    919: 
                    920: \%post
                    921: \%postun
                    922: 
                    923: \%files
                    924: # \%doc README COPYING ChangeLog LICENSE
                    925: END
                    926:     return $description;
                    927: }
                    928: 
                    929: # ------------------------------------- Make directory structure RPM .spec block
                    930: sub make_directory_structure_spec_block {
                    931:     my ($dirs)=@_;
                    932:     foreach my $d (@$dirs) {
                    933: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
                    934: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    935: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    936: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    937: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    938: 	my $own=$devchown; $own=~s/\:/\,/;
                    939: 	$description.=<<END;
                    940: \%dir \%attr($devchmod,$own) /$d
                    941: END
                    942:     }
                    943:     return $description;
                    944: }
                    945: 
                    946: # ---------------------------- Make directory and file structure RPM .spec block
                    947: sub make_directory_and_file_structure_spec_block {
                    948:     my ($dirs)=@_;
                    949:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    950:     foreach my $d (@$dirs) {
                    951: 	# set other values
                    952: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    953: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    954: 	# find files that are contained in this directory
                    955: 	my @files;
                    956: 	my @filesfull;
                    957: 	foreach my $f (@allfiles) {
                    958: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    959: 		push @files,$1;
                    960: 		push @filesfull,$f;
                    961: 	    }
                    962: 	}
                    963: 	# render starting HTML formatting elements
                    964: 	if (@files) {
                    965: 	    $description.=<<END;
                    966: # $d $dirdescription
                    967: END
                    968:         }
                    969: 	if (@files) {
                    970:             foreach my $i (0..$#files) {
                    971: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    972: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    973: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    974: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    975: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    976: 		my $own=$devchown; $own=~s/\:/\,/;
                    977: 		my $config="";
                    978: 		$config="\%config " if $category eq 'conf';
                    979: 		$devchmod='-' if $category eq 'symbolic link';
                    980: 		$description.=<<END;
                    981: $config\%attr($devchmod,$own) /$filesfull[$i]
                    982: END
                    983: 	    }
                    984: 	}
                    985:     }
                    986:     return $description;
                    987: }
                    988: 
                    989: # ----------------------------------------------------------- End RPM .spec page
                    990: sub end_spec_page {
                    991: }
                    992: 
                    993: # ------------------------------------------------------- Begin description page
1.4       harris41  994: sub begin_description_page {
1.25      harris41  995:     my ($mode)=@_;
                    996:     my $description;
                    997:     unless ($mode eq 'status') {
                    998:     $description=<<END;
1.4       harris41  999: <HTML>
                   1000: <HEAD>
                   1001: <TITLE>LON-CAPA Software Description Page ($distribution, $date)</TITLE>
                   1002: </HEAD>
                   1003: <BODY>
                   1004: <FONT SIZE=+2>LON-CAPA Software Description Page ($distribution, $date)</FONT>
                   1005: <BR>Michigan State University
                   1006: <BR>Learning Online with CAPA
                   1007: <BR>Contact korte\@lon-capa.org
                   1008: <UL>
                   1009: <LI>About this file
                   1010: <LI>Software Package Description
                   1011: <LI>Directory Structure
1.7       harris41 1012: <LI>File Type Ownership and Permissions
1.4       harris41 1013: <LI>File and Directory Structure
                   1014: </UL>
                   1015: <FONT SIZE=+2>About this file</FONT>
                   1016: <P>
                   1017: This file is generated dynamically by <TT>parse.pl</TT> as
                   1018: part of a development compilation process.  See 
                   1019: http://install.lon-capa.org/compile/index.html for more
                   1020: information.
                   1021: </P>
                   1022: END
1.25      harris41 1023: }
                   1024:     else {
                   1025: 	$description=<<END;
                   1026: <HTML>
                   1027: <HEAD>
                   1028: <TITLE>LON-CAPA Software File System Status Page ($distribution, $date)</TITLE>
                   1029: </HEAD>
                   1030: <BODY>
                   1031: <FONT SIZE=+2>LON-CAPA Software File System Status Page ($distribution, $date)</FONT>
                   1032: <BR>Michigan State University
                   1033: <BR>Learning Online with CAPA
                   1034: <BR>Contact korte\@lon-capa.org
                   1035: <UL>
                   1036: <LI>About this file
                   1037: <LI>Software Package Description
                   1038: <LI>Directory Structure
                   1039: <LI>File Type Ownership and Permissions
                   1040: <LI>File and Directory Structure
                   1041: </UL>
                   1042: <FONT SIZE=+2>About this file</FONT>
                   1043: <P>
                   1044: This file is generated dynamically by <TT>parse.pl</TT> as
                   1045: part of a status checking process.  See http://install.lon-capa.org/
                   1046: for more information.
                   1047: </P>
                   1048: END
                   1049:     }
1.4       harris41 1050:     return $description;
1.25      harris41 1051: 
1.4       harris41 1052: }
                   1053: 
                   1054: # ------------------------------------------------- End description page
                   1055: sub end_description_page {
                   1056:     my $description=<<END;
                   1057: <HR>
1.5       harris41 1058: <FONT SIZE=-1>LON-CAPA Software Development Team</FONT>
1.4       harris41 1059: </BODY>
                   1060: </HTML>
                   1061: END
                   1062:     return $description;
                   1063: }
                   1064: 
                   1065: # ------------------------------------------------- Make RPM description block
                   1066: sub make_rpm_description_block {
1.25      harris41 1067:     my ($mode)=@_;
                   1068:     my $description;
                   1069:     unless ($mode eq 'status') {
                   1070:     $description=<<END;
1.4       harris41 1071: <FONT SIZE=+2>Rolled in a RedHat 6.2 RPM, $date</FONT>
                   1072: <P>
                   1073: <TABLE BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=10 CELLSPACING=0>
                   1074: <TR><TD>
                   1075: <PRE>
                   1076: Name        : $info{'RPM'}{'Name'}
                   1077: Version     : $info{'RPM'}{'Version'}
                   1078: Vendor      : $info{'RPM'}{'Vendor'} 
                   1079: Release     : $info{'RPM'}{'Release'}                             
                   1080: Build Host  : $buildhost
                   1081: Group       : $info{'RPM'}{'Group'}
                   1082: License     : $info{'RPM'}{'Copyright'}
                   1083: Summary     : $info{'RPM'}{'Summary'}
                   1084: Description : 
                   1085: $info{'RPM'}{'description'}
                   1086: </PRE>
                   1087: </TD></TR>
                   1088: </TABLE>
                   1089: </P>
                   1090: END
1.25      harris41 1091: }
                   1092:     else {
                   1093: 	my $exist=`rpm -q LON-CAPA-base 2>/dev/null`;
                   1094: 	unless ($exist) {
                   1095: 	    $description=<<END;
                   1096: <FONT SIZE=+2>No LON-CAPA RPM on the system, (installed ??????)</FONT>
                   1097: <P>
                   1098: <TABLE BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=10 CELLSPACING=0>
                   1099: <TR><TD>
                   1100: <FONT SIZE=+3>Error! A LON-CAPA-base RPM
                   1101: was never installed on this system!</FONT>
                   1102: </TD></TR>
                   1103: </TD></TR>
                   1104: </TABLE>
                   1105: </P>
                   1106: END
                   1107: 	}
                   1108: 	else {
                   1109: 	    chop $exist;
                   1110: 	    my $rpmname=`rpm -q --queryformat '%{NAME}' LON-CAPA-base`;
                   1111: 	    my $rpmversion=`rpm -q --queryformat '%{VERSION}' LON-CAPA-base`;
                   1112: 	    my $rpmrelease=`rpm -q --queryformat '%{RELEASE}' LON-CAPA-base`;
                   1113: 	    my $idate=`rpm -q --queryformat '%{INSTALLTIME:date}' LON-CAPA-base`;
                   1114: 	    my $rpmvendor=`rpm -q --queryformat '%{VENDOR}' LON-CAPA-base`;
                   1115: 	    my $rpmbuildhost=`rpm -q --queryformat '%{BUILDHOST}' LON-CAPA-base`;
                   1116: 	    my $rpmgroup=`rpm -q --queryformat '%{GROUP}' LON-CAPA-base`;
                   1117: 	    my $rpmlicense=`rpm -q --queryformat '%{LICENSE}' LON-CAPA-base`;
                   1118: 	    my $rpmsummary=`rpm -q --queryformat '%{SUMMARY}' LON-CAPA-base`;
                   1119: 	    my $rpmdescription=`rpm -q --queryformat '%{DESCRIPTION}' LON-CAPA-base`;
                   1120: 	    $description=<<END;
                   1121: <FONT SIZE=+2>Current RedHat RPM on the system, (installed $idate)</FONT>
                   1122: <P>
                   1123: <TABLE BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=10 CELLSPACING=0>
                   1124: <TR><TD>
                   1125: <PRE>
                   1126: Name        : $rpmname
                   1127: Version     : $rpmversion
                   1128: Vendor      : $rpmvendor
                   1129: Release     : $rpmrelease
                   1130: Build Host  : $rpmbuildhost
                   1131: Group       : $rpmgroup
                   1132: License     : $rpmlicense
                   1133: Summary     : $rpmsummary
                   1134: Description : 
                   1135: $rpmdescription
                   1136: </PRE>
                   1137: </TD></TR>
                   1138: </TABLE>
                   1139: </P>
                   1140: END
                   1141: }
                   1142:     }
1.4       harris41 1143:     return $description;
                   1144: }
                   1145: 
                   1146: # ----------------------------------------------- Determine directory structure
                   1147: sub determine_directory_structure {
                   1148:     my @directories=keys %{$info{'DIRECTORY'}{$distribution}};
                   1149:     return (sort @directories);
                   1150: }
1.1       harris41 1151: 
1.4       harris41 1152: 
                   1153: # ---------------------------------- Make directory structure description block
                   1154: sub make_directory_structure_description_block {
1.25      harris41 1155:     my ($dirs,$mode)=@_;
                   1156:     my $dirstatus; my $statusheader;
1.4       harris41 1157:     my $description=<<END;
                   1158: <FONT SIZE=+2>Directory Structure Description, $date</FONT>
                   1159: <P>
1.9       harris41 1160: The directory structure description below shows only those
                   1161: directories which either contain LON-CAPA specific files
                   1162: or normally do not exist on a RedHat Linux system (and
                   1163: must be generated to allow proper placement of files
                   1164: during LON-CAPA run-time operation).
                   1165: </P>
                   1166: <P>
1.4       harris41 1167: <TABLE BORDER=1 CELLPADDING=3 CELLSPACING=0>
                   1168: END
                   1169:     my $maxcount=0;
1.8       harris41 1170:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                   1171:     my %diraccount; # hash to track which directories are accounted for
                   1172:     foreach my $file (@allfiles) {
                   1173: 	$file=~/^(.*)\/([^\/]+)$/;
                   1174: 	$diraccount{$1}=1;
                   1175:     }
1.4       harris41 1176:     foreach my $d (@$dirs) {
                   1177:         my (@matches)=($d=~/\//g);
                   1178: 	my $count=scalar(@matches);
                   1179: 	$maxcount=$count if $count>$maxcount;
1.8       harris41 1180: 	delete $diraccount{$d};
1.4       harris41 1181:     }
1.25      harris41 1182:     if ($mode eq 'status') {
                   1183: 	$statusheader="<TH ALIGN=LEFT BGCOLOR=#FFFFFF>Current Status</TH>";
                   1184:     }
1.4       harris41 1185:     $description.=<<END;
                   1186: <TR>
1.25      harris41 1187: $statusheader
1.4       harris41 1188: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Category</TH>
                   1189: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
                   1190: <TH ALIGN=LEFT BGCOLOR=#FFFFFF><FONT COLOR=#FF0000>Development<BR>Permissions</FONT></TH>
                   1191: END
                   1192:     $description.="<TH ALIGN=LEFT BGCOLOR=#FFFFFF COLSPAN=".($maxcount+1).">Directory Path</TH>\n";
1.8       harris41 1193:     if (keys %diraccount) {
                   1194: 	$description.= "<TR><TD ALIGN=LEFT BGCOLOR=#FFFFFF COLSPAN=".($maxcount+4)."><I><PRE>Directories that are unaccounted for: \n";
                   1195: 	foreach my $d (keys %diraccount) {
                   1196: 	    $description.="$d\n";
                   1197: 	}
                   1198: 	$description.="</PRE></I></TH></TR>\n";
                   1199:     }
1.4       harris41 1200:     foreach my $d (@$dirs) {
                   1201: 	my $dtable=$d;
                   1202: 	$dtable=~s/\//\<\/TD\>\<TD\>/g;
                   1203: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
                   1204: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                   1205: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                   1206: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                   1207: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
1.25      harris41 1208: 	if ($mode eq 'status') {
                   1209: 	    my $ds=`find /$d -type d -prune -printf "\%m\t\%u\t\%g" 2>/dev/null`;
                   1210: 	    unless ($ds) {
                   1211: 		$dirstatus='<TD BGCOLOR=#FFFFFF><B><U>MISSING</U></B></TD>';
                   1212: 	    }
                   1213: 	    else {
                   1214: 		my @dss=split(/\t/,$ds);
                   1215: 		my $dssz=$dss[0];
                   1216: 		$dssz="0" . $dss[0] if length($dss[0])<4;
                   1217: 		$dss[0]=$dssz;
                   1218: 		$ds="$dss[0] $dss[1]:$dss[2]";
                   1219: 		if ($ds eq "$chmod $chown" && $ds eq "$devchmod $devchown") {
                   1220: 		    $dirstatus='<TD BGCOLOR=#FFFFFF>runtime+development</TD>';
                   1221: 		}
                   1222: 		elsif ($ds eq "$chmod $chown") {
                   1223: 		    $dirstatus='<TD BGCOLOR=#FFFFFF>runtime</TD>';
                   1224: 		}
                   1225: 		elsif ($ds eq "$devchmod $devchown") {
                   1226: 		    $dirstatus='<TD BGCOLOR=#FFFFFF>development</TD>';
                   1227: 		}
                   1228: 		else {
                   1229: 		    $dirstatus="<TD BGCOLOR=#FFFFFF><B><U>ERROR</U></B><BR>$ds</TD>";
                   1230: 		}
                   1231: 	    }
                   1232: 	}
1.4       harris41 1233: 	$description.=<<END;
                   1234: <TR>
1.25      harris41 1235: $dirstatus
1.4       harris41 1236: <TD BGCOLOR=#FFFFFF>$category</TD>
                   1237: <TD BGCOLOR=#FFFFFF><TT>$chmod $chown</TT></TD>
                   1238: <TD BGCOLOR=#FFFFFF><FONT COLOR=#FF0000><TT>$devchmod $devchown</TT></FONT></TD>
                   1239: <TD>
                   1240: $dtable
                   1241: </TD>
                   1242: </TR>
                   1243: END
                   1244:     }
                   1245:     $description.=<<END;
                   1246: </TABLE>
                   1247: </P>
                   1248: END
                   1249:     return $description;
                   1250: }
                   1251: 
1.6       harris41 1252: # ------------------- Make file type ownership and permissions description block
                   1253: sub make_file_type_ownership_and_permissions_description_block {
1.25      harris41 1254:     my ($mode)=@_;
1.6       harris41 1255:     my $description=<<END;
                   1256: <FONT SIZE=+2>File Type Ownership and Permissions Descriptions, $date</FONT>
                   1257: <P>
                   1258: This table shows what permissions and ownership settings correspond
                   1259: to each kind of file type.
                   1260: </P>
                   1261: <P>
                   1262: <TABLE BORDER=1 CELLPADDING=5 WIDTH=60%>
                   1263: <TR>
                   1264: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Icon</TH>
                   1265: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Type</TH>
                   1266: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
                   1267: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Development Permissions</TH>
                   1268: </TR>
                   1269: END
                   1270:     foreach my $type (keys %{$info{'OWNERSHIP'}}) {
                   1271: 	if (defined($fcm{$type})) {
                   1272: 	    my $chmod=$info{'OWNERSHIP'}{$type}{'CHMOD'};
                   1273: 	    my $chown=$info{'OWNERSHIP'}{$type}{'CHOWN'};
                   1274: 	    my $devchmod=$info{'DEVOWNERSHIP'}{$type}{'CHMOD'};
                   1275: 	    my $devchown=$info{'DEVOWNERSHIP'}{$type}{'CHOWN'};
                   1276: 	    $description.=<<END;
                   1277: <TR>
                   1278: <TD><IMG SRC="$fcm{$type}.gif" ALT="$type"></TD>
                   1279: <TD>$type</TD>
                   1280: <TD><TT>$chmod $chown</TT></TD>
                   1281: <TD><TT>$devchmod $devchown</TT></TD>
                   1282: </TR>
                   1283: END
                   1284:         }
                   1285:     }
                   1286:     $description.=<<END;
                   1287: </TABLE>
                   1288: </P>
                   1289: END
                   1290: }
                   1291: 
1.4       harris41 1292: # ------------------------- Make directory and file structure description block
                   1293: sub make_directory_and_file_structure_description_block {
1.25      harris41 1294:     my ($dirs,$mode)=@_;
                   1295:     my $statusheader; my $filestatus;
1.4       harris41 1296:     my $description=<<END;
                   1297: <FONT SIZE=+2>Directory and File Structure Description, $date</FONT>
1.6       harris41 1298: <P>
                   1299: The icons on the left column correspond to the file type
                   1300: specified in the second column.  The last column "Notes" shows compilation,
1.7       harris41 1301: dependency, and configuration information.  The CVS location
                   1302: shows the location of the binary source file (if applicable) needed to
                   1303: be copied to the target.  If the binary source file is not at
                   1304: the specified location, then the text is shown in 
                   1305: <FONT COLOR=#FF0000>red</FONT>.
1.6       harris41 1306: </P>
1.4       harris41 1307: <P>
1.9       harris41 1308: <TABLE BORDER=1 CELLPADDING=5 WIDTH=500>
1.4       harris41 1309: END
                   1310:     my $counter=0;
                   1311:     my @colorindex=("#80FF80","#80FFFF","#FFFF80");
1.5       harris41 1312:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
1.4       harris41 1313:     foreach my $d (@$dirs) {
                   1314: 	# set color
                   1315: 	my $color=$colorindex[$counter%3];
                   1316: 	# set other values
                   1317: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                   1318: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                   1319: 	# find subdirectories that are contained in this directory
                   1320: 	my @subdirs;
                   1321: 	foreach my $d2 (@$dirs) {
1.5       harris41 1322: 	    if ($d2=~/^$d\/([^\/]+)$/) {
1.4       harris41 1323: 		push @subdirs,$1;
                   1324: 	    }
                   1325: 	}
                   1326: 	# find files that are contained in this directory
                   1327: 	my @files;
1.5       harris41 1328: 	my @filesfull;
1.4       harris41 1329: 	foreach my $f (@allfiles) {
1.5       harris41 1330: 	    if ($f=~/^$d\/([^\/]+)$/) {
1.4       harris41 1331: 		push @files,$1;
1.5       harris41 1332: 		push @filesfull,$f;
1.4       harris41 1333: 	    }
                   1334: 	}
                   1335: 	# render starting HTML formatting elements
                   1336: 	if (@subdirs || @files) {
                   1337: 	    my $subdirstring="<BR>* Relevant subdirectories: " . join(", ",@subdirs) if @subdirs;
                   1338: 	    $description.=<<END;
1.5       harris41 1339: <TR><TD BGCOLOR=#000000 COLSPAN=6><FONT COLOR=$color><IMG SRC="directory.gif" ALT="directory">DIRECTORY -- $d $dirdescription
                   1340: $subdirstring</FONT></TD></TR>
1.4       harris41 1341: END
                   1342:         }
                   1343: 	else {
                   1344: 	    $description.=<<END;
1.5       harris41 1345: <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 1346: END
                   1347:         }
                   1348: 	if (@files) {
1.25      harris41 1349: 	    if ($mode eq 'status') {
                   1350: 		$statusheader=<<END;
                   1351: <TH BGCOLOR=$color ALIGN=LEFT>Current Status</TH>
                   1352: END
                   1353: 	    }
1.4       harris41 1354: 	    $description.=<<END;
                   1355: <TR>
1.25      harris41 1356: $statusheader
1.5       harris41 1357: <TH BGCOLOR=$color ALIGN=LEFT COLSPAN=2>Type</TH>
                   1358: <TH BGCOLOR=$color ALIGN=LEFT>File Name</TH>
                   1359: <TH BGCOLOR=$color ALIGN=LEFT>Function</TH>
                   1360: <TH BGCOLOR=$color ALIGN=LEFT>CVS Location</TH>
                   1361: <TH BGCOLOR=$color ALIGN=LEFT>Notes</TH>
1.4       harris41 1362: </TR>
                   1363: END
1.5       harris41 1364:             foreach my $i (0..$#files) {
                   1365: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                   1366: 		my $fdescription=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DESCRIPTION'};
                   1367: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
1.28      harris41 1368: 		my $source2=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
1.9       harris41 1369: 		my $note=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'NOTE'};
                   1370: 		$note.="<BR>" if $note;
                   1371: 		my $listing=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
                   1372: 		my @E=split(/\s+/,$listing);
                   1373: 		$source=~/(.*)\/[^\/]+$/;
                   1374: 		my $sd=$1;
                   1375: 		my $eflag=0;
                   1376: 		foreach my $e (@E) {
                   1377: 		    unless (-e "../../$sd/$e") {
                   1378: 			$e="<FONT COLOR=#FF0000>$e</FONT>";
                   1379: 			$eflag=1;
                   1380: 		    }
                   1381: 		}
                   1382: 		$listing=join("\n",@E);
                   1383: 		$listing="<B>listing</B><BR><FONT SIZE=-2>$listing</FONT>" if $listing;
                   1384: 		$listing.="<BR>" if $listing;
                   1385: 		my $build=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'BUILD'};
                   1386: 		$build="<B>build</B><BR>$build" if $build;
                   1387: 		$build.="<BR>" if $build;
                   1388: 		my $dependencies=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DEPENDENCIES'};
                   1389: 		$dependencies="<B>dependencies</B><BR>$dependencies" if $dependencies;
                   1390: 		$dependencies.="<BR>" if $dependencies;
1.7       harris41 1391: 		unless (-e "../../$source") {
                   1392: 		    $source=~/([^\/]+)$/;
                   1393: 		    my $s=$1;
1.9       harris41 1394: 		    if ($source!~/\*/) {
                   1395: 			$source="<FONT COLOR=#FF0000>$source</FONT>";
                   1396: 		    }
                   1397: 		    elsif ($eflag) {
                   1398: 			$source="<FONT COLOR=#FF0000>$source</FONT>";
                   1399: 		    }
1.7       harris41 1400: 		}
1.28      harris41 1401: 		my $checksum;
                   1402: 		my $checksum_source;
                   1403: 		my $checksum_target;
1.25      harris41 1404: 		if ($mode eq 'status') {
                   1405: 		    $filestatus='';
                   1406: 		    my $fs;
                   1407: 		    my $listing2=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
                   1408: 		    my @E=split(/\s+/,$listing2); shift @E;
                   1409: 		    if (@E) {
                   1410: 			$fs=`find /$filesfull[$i] -prune -printf "\%m\t\%u\t\%g\n" 2>/dev/null | wc -l`; chop $fs;
                   1411: 			if ($fs!=(@E+0)) {
                   1412: 			    $ecount=(@E+0);
                   1413: 			    $estuff=join(",",@E);
                   1414: 			    $filestatus="<TD BGCOLOR=#FFFFFF><B><U>ERROR. SOME FILES ARE MISSING</U></B></TD>";
                   1415: 			}
                   1416: 			$fs=`find /$filesfull[$i] -prune -printf "\%m\t\%u\t\%g\n" 2>/dev/null | sort | uniq | wc -l`; chop $fs;
                   1417: 			if ($fs!=1) {
                   1418: 			    $filestatus='<TD BGCOLOR=#FFFFFF><B><U>ERROR. THERE ARE MULTIPLE OWNERSHIPS/PERMISSIONS WHEN ALL THESE FILES SHOULD HAVE THE SAME CONFIGURATION</U></B></TD>';
                   1419: 			}
                   1420: 			else {
                   1421: 			    $fs=`find /$filesfull[$i] -prune -printf "\%m\t\%u\t\%g\n" 2>/dev/null | sort | uniq`; chop $fs;
                   1422: 			}
                   1423: 		    }
                   1424: 		    else {
                   1425: 			$fs=`find /$filesfull[$i] -prune -printf "\%m\t\%u\t\%g" 2>/dev/null`;
1.28      harris41 1426: 			if (-f "/$filesfull[$i]" && !(-l "/$filesfull[$i]")) {
                   1427: 			    $checksum_source=`md5sum ../../$source2 | cut -d ' ' -f1`;
                   1428: 			    chop $checksum_source;
                   1429: 			    $checksum_target=`md5sum /$filesfull[$i] | cut -d ' ' -f1`;
                   1430: 			    chop $checksum_target;
1.29      harris41 1431: #			    warn ("CS: $checksum_source, CT: $checksum_target\n");
1.28      harris41 1432: 			    unless ($checksum_source eq $checksum_target) {
                   1433: 				$checksum="<BR><B><U>CHECKSUM DIFFERENCE</U></B>";
                   1434: 			    }
                   1435: 			}
1.25      harris41 1436: 		    }
                   1437: 		    my $fsl=`find /$filesfull[$i] -type l -prune -printf "\%m\t\%u\t\%g" 2>/dev/null`;
                   1438: 		    unless ($fs || $filestatus) {
                   1439: 			$filestatus='<TD BGCOLOR=#FFFFFF><B><U>MISSING</U></B></TD>';
                   1440: 		    }
                   1441: 		    elsif (!$filestatus) {
                   1442: 
                   1443: 			$chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                   1444: 			$chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                   1445: 			$devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                   1446: 			$devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                   1447: 
                   1448: 			my @fss=split(/\t/,$fs);
                   1449: 			my $fssz=$fss[0];
                   1450: 			$fssz="0" . $fss[0] if length($fss[0])<4;
                   1451: 			$fss[0]=$fssz;
                   1452: 			$fs="$fss[0] $fss[1]:$fss[2]";
                   1453: 			$s=' ';
                   1454: 			if ($fsl) {
                   1455: 			    $fs="$fss[1]:$fss[2]";
                   1456: 			    $s='';
                   1457: 			}
                   1458: 			if ($fs eq "$chmod$s$chown" && $fs eq "$devchmod$s$devchown") {
1.28      harris41 1459: 			    $filestatus="<TD BGCOLOR=#FFFFFF>runtime+development$checksum</TD>";
1.25      harris41 1460: 			}
                   1461: 			elsif ($fs eq "$chmod$s$chown") {
1.28      harris41 1462: 			    $filestatus="<TD BGCOLOR=#FFFFFF>runtime$checksum</TD>";
1.25      harris41 1463: 			}
                   1464: 			elsif ($fs eq "$devchmod$s$devchown") {
1.28      harris41 1465: 			    $filestatus="<TD BGCOLOR=#FFFFFF>development$checksum</TD>";
1.25      harris41 1466: 			}
                   1467: 			else {
                   1468: 			    $filestatus="<TD BGCOLOR=#FFFFFF><B><U>ERROR</U></B><BR>$fs</TD>";
                   1469: 			}
                   1470: 		    }
                   1471: 		}	    
1.5       harris41 1472: 		$description.=<<END;
                   1473: <TR>
1.25      harris41 1474: $filestatus
1.5       harris41 1475: <TD BGCOLOR=#A0A0A0><IMG SRC="$fcm{$category}.gif" ALT="$category"></TD>
                   1476: <TD BGCOLOR=$color>$category</TD>
                   1477: <TD BGCOLOR=$color>$files[$i]</TD>
                   1478: <TD BGCOLOR=$color>$fdescription&nbsp;</TD>
                   1479: <TD BGCOLOR=$color>$source</TD>
1.9       harris41 1480: <TD BGCOLOR=$color>$note$listing$build$dependencies&nbsp;</TD>
1.4       harris41 1481: </TR>
                   1482: END
1.5       harris41 1483: 	    }
                   1484: 	}
1.4       harris41 1485: 	$counter++;
                   1486:     }
                   1487:     $description.=<<END;
                   1488: </TABLE>
                   1489: </P>
                   1490: END
                   1491:     return $description;
                   1492: }

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