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

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.34      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 {
        !           713: \tinstall -o $owner -g $group -m $devchmod \$(SOURCE)/$source \$(TARGET)/$rot
        !           714: END
        !           715: 		    }
1.16      harris41  716:                 }
                    717: 	    }
                    718: 	}
                    719:     }
                    720:     $description.=<<END;
                    721: 
                    722: END
                    723:     return $description;
                    724: }
                    725: 
                    726: # ------ Installation commands to install configuration files (and make backups)
                    727: sub make_files_configinstall_segment {
                    728:     my ($dirs)=@_;
                    729:     my $description=<<END;
                    730: configfiles:
                    731: END
                    732:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    733:     foreach my $d (@$dirs) {
                    734: 	# set other values
                    735: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    736: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    737: 	# find files that are contained in this directory
                    738: 	my @files;
                    739: 	my @filesfull;
                    740: 	foreach my $f (@allfiles) {
                    741: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    742: 		push @files,$1;
                    743: 		push @filesfull,$f;
                    744: 	    }
                    745: 	}
                    746: 	# render starting HTML formatting elements
                    747: 	if (@files) {
                    748: 	    $description.=<<END;
                    749: \t# $d $dirdescription
                    750: END
                    751:         }
                    752: 	if (@files) {
                    753:             foreach my $i (0..$#files) {
                    754: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    755: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
                    756: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    757: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    758: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    759: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    760: 		my $rot=$filesfull[$i];
                    761: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
                    762: 		my ($owner,$group)=split(/\:/,$devchown);
                    763: 		if ($category eq 'conf') {
                    764: 		    $description.=<<END;
1.32      harris41  765: \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  766: END
                    767:                 }
                    768: 	    }
                    769: 	}
                    770:     }
                    771:     $description.=<<END;
                    772: 
                    773: END
                    774:     return $description;
                    775: }
                    776: 
                    777: # ------ Commands to enforce configuration file permissions
                    778: sub make_files_configpermissions_segment {
                    779:     my ($dirs)=@_;
                    780:     my $description=<<END;
                    781: configpermissions:
                    782: END
                    783:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    784:     foreach my $d (@$dirs) {
                    785: 	# set other values
                    786: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    787: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    788: 	# find files that are contained in this directory
                    789: 	my @files;
                    790: 	my @filesfull;
                    791: 	foreach my $f (@allfiles) {
                    792: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    793: 		push @files,$1;
                    794: 		push @filesfull,$f;
                    795: 	    }
                    796: 	}
                    797: 	# render starting HTML formatting elements
                    798: 	if (@files) {
                    799: 	    $description.=<<END;
                    800: \t# $d $dirdescription
                    801: END
                    802:         }
                    803: 	if (@files) {
                    804:             foreach my $i (0..$#files) {
                    805: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    806: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
                    807: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    808: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    809: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    810: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    811: 		my $rot=$filesfull[$i];
                    812: 		$rot=~s/[^\/]+$/\./ if $rot=~/\*/;
                    813: 		my ($owner,$group)=split(/\:/,$devchown);
                    814: 		if ($category eq 'conf') {
                    815: 		    $description.=<<END;
                    816: \tchmod $devchmod \$(TARGET)/$rot
                    817: \tchown $devchown \$(TARGET)/$rot
1.10      harris41  818: END
1.15      harris41  819:                 }
1.10      harris41  820: 	    }
                    821: 	}
                    822:     }
                    823:     $description.=<<END;
                    824: 
                    825: END
                    826:     return $description;
                    827: }
                    828: 
                    829: # ------------------------------ Installation commands to install symbolic links
                    830: sub make_links_install_segment {
                    831:     my ($dirs)=@_;
                    832:     my $description=<<END;
                    833: links:
                    834: END
1.16      harris41  835:     chop $description;
                    836:     my $description2;
1.10      harris41  837:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    838:     foreach my $d (@$dirs) {
                    839: 	# find files that are contained in this directory
                    840: 	my @files;
                    841: 	my @filesfull;
                    842: 	foreach my $f (@allfiles) {
                    843: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    844: 		push @files,$1;
                    845: 		push @filesfull,$f;
                    846: 	    }
                    847: 	}
                    848: 	# render starting HTML formatting elements
                    849: 	if (@files) {
                    850:             foreach my $i (0..$#files) {
                    851: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    852: 		my $linkto=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'LINKTO'};
                    853: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    854: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    855: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    856: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
1.16      harris41  857: 		if ($category eq 'symbolic link') {
                    858: 		    $description.=" \$(TARGET)/$filesfull[$i]";
                    859: 		    $description2.=<<END;
                    860: \$(TARGET)/$filesfull[$i]:
1.14      harris41  861: \tln -s /$linkto \$(TARGET)/$filesfull[$i]
1.16      harris41  862: 
1.10      harris41  863: END
1.16      harris41  864:                 }
1.10      harris41  865: 	    }
                    866: 	}
                    867:     }
                    868:     $description.=<<END;
1.4       harris41  869: 
1.10      harris41  870: END
1.16      harris41  871:     $description.=$description2;
1.10      harris41  872:     return $description;
                    873: }
                    874: 
                    875: # --------------------------------------------------------- Make RPM .spec block
                    876: sub make_rpm_spec_block {
                    877:     my $pwd=`pwd`; chop $pwd;
                    878:     my $buildroot="$pwd/LON-CAPA-BuildRoot";
                    879:     my $source=$info{'RPM'}{'Name'} . "-" . $info{'RPM'}{'Version'} . '.tar.gz';
                    880:     my $description=<<END;
                    881: Summary: $info{'RPM'}{'Summary'}
                    882: Name: $info{'RPM'}{'Name'}
                    883: Version: $info{'RPM'}{'Version'}
                    884: Release: $info{'RPM'}{'Release'}
                    885: Vendor: $info{'RPM'}{'Vendor'} 
                    886: BuildRoot: $buildroot
                    887: Copyright: $info{'RPM'}{'Copyright'}
                    888: Group: $info{'RPM'}{'Group'}
                    889: Source: $source
                    890: AutoReqProv: $info{'RPM'}{'AutoReqProv'}
                    891: \%description
                    892: $info{'RPM'}{'description'}
                    893: 
                    894: END
                    895:     return $description;
                    896: }
                    897: 
                    898: # --------------------------------------------------- Make RPM build .spec block
                    899: sub make_rpm_build_block {
                    900:     my $pwd=`pwd`; chop $pwd;
                    901:     my $buildroot="$pwd/LON-CAPA-BuildRoot";
                    902:     my $sourceroot="$pwd/LON-CAPA-SourceRoot";
                    903:     my $description=<<END;
                    904: 
                    905: \%prep
                    906: \%setup
                    907: 
                    908: \%build
                    909: rm -Rf "$buildroot"
                    910: 
                    911: \%install
                    912: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" directories
                    913: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" files
                    914: make -f LCMakefile ROOT="\$RPM_BUILD_ROOT" SOURCE="$sourceroot" links
                    915: 
                    916: \%pre
                    917: $info{'RPM'}{'pre'}
                    918: 
                    919: \%post
                    920: \%postun
                    921: 
                    922: \%files
                    923: # \%doc README COPYING ChangeLog LICENSE
                    924: END
                    925:     return $description;
                    926: }
                    927: 
                    928: # ------------------------------------- Make directory structure RPM .spec block
                    929: sub make_directory_structure_spec_block {
                    930:     my ($dirs)=@_;
                    931:     foreach my $d (@$dirs) {
                    932: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
                    933: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    934: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    935: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    936: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    937: 	my $own=$devchown; $own=~s/\:/\,/;
                    938: 	$description.=<<END;
                    939: \%dir \%attr($devchmod,$own) /$d
                    940: END
                    941:     }
                    942:     return $description;
                    943: }
                    944: 
                    945: # ---------------------------- Make directory and file structure RPM .spec block
                    946: sub make_directory_and_file_structure_spec_block {
                    947:     my ($dirs)=@_;
                    948:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                    949:     foreach my $d (@$dirs) {
                    950: 	# set other values
                    951: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                    952: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                    953: 	# find files that are contained in this directory
                    954: 	my @files;
                    955: 	my @filesfull;
                    956: 	foreach my $f (@allfiles) {
                    957: 	    if ($f=~/^$d\/([^\/]+)$/) {
                    958: 		push @files,$1;
                    959: 		push @filesfull,$f;
                    960: 	    }
                    961: 	}
                    962: 	# render starting HTML formatting elements
                    963: 	if (@files) {
                    964: 	    $description.=<<END;
                    965: # $d $dirdescription
                    966: END
                    967:         }
                    968: 	if (@files) {
                    969:             foreach my $i (0..$#files) {
                    970: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                    971: 		my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                    972: 		my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                    973: 		my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                    974: 		my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                    975: 		my $own=$devchown; $own=~s/\:/\,/;
                    976: 		my $config="";
                    977: 		$config="\%config " if $category eq 'conf';
                    978: 		$devchmod='-' if $category eq 'symbolic link';
                    979: 		$description.=<<END;
                    980: $config\%attr($devchmod,$own) /$filesfull[$i]
                    981: END
                    982: 	    }
                    983: 	}
                    984:     }
                    985:     return $description;
                    986: }
                    987: 
                    988: # ----------------------------------------------------------- End RPM .spec page
                    989: sub end_spec_page {
                    990: }
                    991: 
                    992: # ------------------------------------------------------- Begin description page
1.4       harris41  993: sub begin_description_page {
1.25      harris41  994:     my ($mode)=@_;
                    995:     my $description;
                    996:     unless ($mode eq 'status') {
                    997:     $description=<<END;
1.4       harris41  998: <HTML>
                    999: <HEAD>
                   1000: <TITLE>LON-CAPA Software Description Page ($distribution, $date)</TITLE>
                   1001: </HEAD>
                   1002: <BODY>
                   1003: <FONT SIZE=+2>LON-CAPA Software Description Page ($distribution, $date)</FONT>
                   1004: <BR>Michigan State University
                   1005: <BR>Learning Online with CAPA
                   1006: <BR>Contact korte\@lon-capa.org
                   1007: <UL>
                   1008: <LI>About this file
                   1009: <LI>Software Package Description
                   1010: <LI>Directory Structure
1.7       harris41 1011: <LI>File Type Ownership and Permissions
1.4       harris41 1012: <LI>File and Directory Structure
                   1013: </UL>
                   1014: <FONT SIZE=+2>About this file</FONT>
                   1015: <P>
                   1016: This file is generated dynamically by <TT>parse.pl</TT> as
                   1017: part of a development compilation process.  See 
                   1018: http://install.lon-capa.org/compile/index.html for more
                   1019: information.
                   1020: </P>
                   1021: END
1.25      harris41 1022: }
                   1023:     else {
                   1024: 	$description=<<END;
                   1025: <HTML>
                   1026: <HEAD>
                   1027: <TITLE>LON-CAPA Software File System Status Page ($distribution, $date)</TITLE>
                   1028: </HEAD>
                   1029: <BODY>
                   1030: <FONT SIZE=+2>LON-CAPA Software File System Status Page ($distribution, $date)</FONT>
                   1031: <BR>Michigan State University
                   1032: <BR>Learning Online with CAPA
                   1033: <BR>Contact korte\@lon-capa.org
                   1034: <UL>
                   1035: <LI>About this file
                   1036: <LI>Software Package Description
                   1037: <LI>Directory Structure
                   1038: <LI>File Type Ownership and Permissions
                   1039: <LI>File and Directory Structure
                   1040: </UL>
                   1041: <FONT SIZE=+2>About this file</FONT>
                   1042: <P>
                   1043: This file is generated dynamically by <TT>parse.pl</TT> as
                   1044: part of a status checking process.  See http://install.lon-capa.org/
                   1045: for more information.
                   1046: </P>
                   1047: END
                   1048:     }
1.4       harris41 1049:     return $description;
1.25      harris41 1050: 
1.4       harris41 1051: }
                   1052: 
                   1053: # ------------------------------------------------- End description page
                   1054: sub end_description_page {
                   1055:     my $description=<<END;
                   1056: <HR>
1.5       harris41 1057: <FONT SIZE=-1>LON-CAPA Software Development Team</FONT>
1.4       harris41 1058: </BODY>
                   1059: </HTML>
                   1060: END
                   1061:     return $description;
                   1062: }
                   1063: 
                   1064: # ------------------------------------------------- Make RPM description block
                   1065: sub make_rpm_description_block {
1.25      harris41 1066:     my ($mode)=@_;
                   1067:     my $description;
                   1068:     unless ($mode eq 'status') {
                   1069:     $description=<<END;
1.4       harris41 1070: <FONT SIZE=+2>Rolled in a RedHat 6.2 RPM, $date</FONT>
                   1071: <P>
                   1072: <TABLE BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=10 CELLSPACING=0>
                   1073: <TR><TD>
                   1074: <PRE>
                   1075: Name        : $info{'RPM'}{'Name'}
                   1076: Version     : $info{'RPM'}{'Version'}
                   1077: Vendor      : $info{'RPM'}{'Vendor'} 
                   1078: Release     : $info{'RPM'}{'Release'}                             
                   1079: Build Host  : $buildhost
                   1080: Group       : $info{'RPM'}{'Group'}
                   1081: License     : $info{'RPM'}{'Copyright'}
                   1082: Summary     : $info{'RPM'}{'Summary'}
                   1083: Description : 
                   1084: $info{'RPM'}{'description'}
                   1085: </PRE>
                   1086: </TD></TR>
                   1087: </TABLE>
                   1088: </P>
                   1089: END
1.25      harris41 1090: }
                   1091:     else {
                   1092: 	my $exist=`rpm -q LON-CAPA-base 2>/dev/null`;
                   1093: 	unless ($exist) {
                   1094: 	    $description=<<END;
                   1095: <FONT SIZE=+2>No LON-CAPA RPM on the system, (installed ??????)</FONT>
                   1096: <P>
                   1097: <TABLE BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=10 CELLSPACING=0>
                   1098: <TR><TD>
                   1099: <FONT SIZE=+3>Error! A LON-CAPA-base RPM
                   1100: was never installed on this system!</FONT>
                   1101: </TD></TR>
                   1102: </TD></TR>
                   1103: </TABLE>
                   1104: </P>
                   1105: END
                   1106: 	}
                   1107: 	else {
                   1108: 	    chop $exist;
                   1109: 	    my $rpmname=`rpm -q --queryformat '%{NAME}' LON-CAPA-base`;
                   1110: 	    my $rpmversion=`rpm -q --queryformat '%{VERSION}' LON-CAPA-base`;
                   1111: 	    my $rpmrelease=`rpm -q --queryformat '%{RELEASE}' LON-CAPA-base`;
                   1112: 	    my $idate=`rpm -q --queryformat '%{INSTALLTIME:date}' LON-CAPA-base`;
                   1113: 	    my $rpmvendor=`rpm -q --queryformat '%{VENDOR}' LON-CAPA-base`;
                   1114: 	    my $rpmbuildhost=`rpm -q --queryformat '%{BUILDHOST}' LON-CAPA-base`;
                   1115: 	    my $rpmgroup=`rpm -q --queryformat '%{GROUP}' LON-CAPA-base`;
                   1116: 	    my $rpmlicense=`rpm -q --queryformat '%{LICENSE}' LON-CAPA-base`;
                   1117: 	    my $rpmsummary=`rpm -q --queryformat '%{SUMMARY}' LON-CAPA-base`;
                   1118: 	    my $rpmdescription=`rpm -q --queryformat '%{DESCRIPTION}' LON-CAPA-base`;
                   1119: 	    $description=<<END;
                   1120: <FONT SIZE=+2>Current RedHat RPM on the system, (installed $idate)</FONT>
                   1121: <P>
                   1122: <TABLE BGCOLOR=#FFFFFF BORDER=0 CELLPADDING=10 CELLSPACING=0>
                   1123: <TR><TD>
                   1124: <PRE>
                   1125: Name        : $rpmname
                   1126: Version     : $rpmversion
                   1127: Vendor      : $rpmvendor
                   1128: Release     : $rpmrelease
                   1129: Build Host  : $rpmbuildhost
                   1130: Group       : $rpmgroup
                   1131: License     : $rpmlicense
                   1132: Summary     : $rpmsummary
                   1133: Description : 
                   1134: $rpmdescription
                   1135: </PRE>
                   1136: </TD></TR>
                   1137: </TABLE>
                   1138: </P>
                   1139: END
                   1140: }
                   1141:     }
1.4       harris41 1142:     return $description;
                   1143: }
                   1144: 
                   1145: # ----------------------------------------------- Determine directory structure
                   1146: sub determine_directory_structure {
                   1147:     my @directories=keys %{$info{'DIRECTORY'}{$distribution}};
                   1148:     return (sort @directories);
                   1149: }
1.1       harris41 1150: 
1.4       harris41 1151: 
                   1152: # ---------------------------------- Make directory structure description block
                   1153: sub make_directory_structure_description_block {
1.25      harris41 1154:     my ($dirs,$mode)=@_;
                   1155:     my $dirstatus; my $statusheader;
1.4       harris41 1156:     my $description=<<END;
                   1157: <FONT SIZE=+2>Directory Structure Description, $date</FONT>
                   1158: <P>
1.9       harris41 1159: The directory structure description below shows only those
                   1160: directories which either contain LON-CAPA specific files
                   1161: or normally do not exist on a RedHat Linux system (and
                   1162: must be generated to allow proper placement of files
                   1163: during LON-CAPA run-time operation).
                   1164: </P>
                   1165: <P>
1.4       harris41 1166: <TABLE BORDER=1 CELLPADDING=3 CELLSPACING=0>
                   1167: END
                   1168:     my $maxcount=0;
1.8       harris41 1169:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
                   1170:     my %diraccount; # hash to track which directories are accounted for
                   1171:     foreach my $file (@allfiles) {
                   1172: 	$file=~/^(.*)\/([^\/]+)$/;
                   1173: 	$diraccount{$1}=1;
                   1174:     }
1.4       harris41 1175:     foreach my $d (@$dirs) {
                   1176:         my (@matches)=($d=~/\//g);
                   1177: 	my $count=scalar(@matches);
                   1178: 	$maxcount=$count if $count>$maxcount;
1.8       harris41 1179: 	delete $diraccount{$d};
1.4       harris41 1180:     }
1.25      harris41 1181:     if ($mode eq 'status') {
                   1182: 	$statusheader="<TH ALIGN=LEFT BGCOLOR=#FFFFFF>Current Status</TH>";
                   1183:     }
1.4       harris41 1184:     $description.=<<END;
                   1185: <TR>
1.25      harris41 1186: $statusheader
1.4       harris41 1187: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Category</TH>
                   1188: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
                   1189: <TH ALIGN=LEFT BGCOLOR=#FFFFFF><FONT COLOR=#FF0000>Development<BR>Permissions</FONT></TH>
                   1190: END
                   1191:     $description.="<TH ALIGN=LEFT BGCOLOR=#FFFFFF COLSPAN=".($maxcount+1).">Directory Path</TH>\n";
1.8       harris41 1192:     if (keys %diraccount) {
                   1193: 	$description.= "<TR><TD ALIGN=LEFT BGCOLOR=#FFFFFF COLSPAN=".($maxcount+4)."><I><PRE>Directories that are unaccounted for: \n";
                   1194: 	foreach my $d (keys %diraccount) {
                   1195: 	    $description.="$d\n";
                   1196: 	}
                   1197: 	$description.="</PRE></I></TH></TR>\n";
                   1198:     }
1.4       harris41 1199:     foreach my $d (@$dirs) {
                   1200: 	my $dtable=$d;
                   1201: 	$dtable=~s/\//\<\/TD\>\<TD\>/g;
                   1202: 	my $category=$info{'DIRECTORY'}{$distribution}{$d}{'CATEGORY'};
                   1203: 	my $chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                   1204: 	my $chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                   1205: 	my $devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                   1206: 	my $devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
1.25      harris41 1207: 	if ($mode eq 'status') {
                   1208: 	    my $ds=`find /$d -type d -prune -printf "\%m\t\%u\t\%g" 2>/dev/null`;
                   1209: 	    unless ($ds) {
                   1210: 		$dirstatus='<TD BGCOLOR=#FFFFFF><B><U>MISSING</U></B></TD>';
                   1211: 	    }
                   1212: 	    else {
                   1213: 		my @dss=split(/\t/,$ds);
                   1214: 		my $dssz=$dss[0];
                   1215: 		$dssz="0" . $dss[0] if length($dss[0])<4;
                   1216: 		$dss[0]=$dssz;
                   1217: 		$ds="$dss[0] $dss[1]:$dss[2]";
                   1218: 		if ($ds eq "$chmod $chown" && $ds eq "$devchmod $devchown") {
                   1219: 		    $dirstatus='<TD BGCOLOR=#FFFFFF>runtime+development</TD>';
                   1220: 		}
                   1221: 		elsif ($ds eq "$chmod $chown") {
                   1222: 		    $dirstatus='<TD BGCOLOR=#FFFFFF>runtime</TD>';
                   1223: 		}
                   1224: 		elsif ($ds eq "$devchmod $devchown") {
                   1225: 		    $dirstatus='<TD BGCOLOR=#FFFFFF>development</TD>';
                   1226: 		}
                   1227: 		else {
                   1228: 		    $dirstatus="<TD BGCOLOR=#FFFFFF><B><U>ERROR</U></B><BR>$ds</TD>";
                   1229: 		}
                   1230: 	    }
                   1231: 	}
1.4       harris41 1232: 	$description.=<<END;
                   1233: <TR>
1.25      harris41 1234: $dirstatus
1.4       harris41 1235: <TD BGCOLOR=#FFFFFF>$category</TD>
                   1236: <TD BGCOLOR=#FFFFFF><TT>$chmod $chown</TT></TD>
                   1237: <TD BGCOLOR=#FFFFFF><FONT COLOR=#FF0000><TT>$devchmod $devchown</TT></FONT></TD>
                   1238: <TD>
                   1239: $dtable
                   1240: </TD>
                   1241: </TR>
                   1242: END
                   1243:     }
                   1244:     $description.=<<END;
                   1245: </TABLE>
                   1246: </P>
                   1247: END
                   1248:     return $description;
                   1249: }
                   1250: 
1.6       harris41 1251: # ------------------- Make file type ownership and permissions description block
                   1252: sub make_file_type_ownership_and_permissions_description_block {
1.25      harris41 1253:     my ($mode)=@_;
1.6       harris41 1254:     my $description=<<END;
                   1255: <FONT SIZE=+2>File Type Ownership and Permissions Descriptions, $date</FONT>
                   1256: <P>
                   1257: This table shows what permissions and ownership settings correspond
                   1258: to each kind of file type.
                   1259: </P>
                   1260: <P>
                   1261: <TABLE BORDER=1 CELLPADDING=5 WIDTH=60%>
                   1262: <TR>
                   1263: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Icon</TH>
                   1264: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Type</TH>
                   1265: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Permissions</TH>
                   1266: <TH ALIGN=LEFT BGCOLOR=#FFFFFF>Development Permissions</TH>
                   1267: </TR>
                   1268: END
                   1269:     foreach my $type (keys %{$info{'OWNERSHIP'}}) {
                   1270: 	if (defined($fcm{$type})) {
                   1271: 	    my $chmod=$info{'OWNERSHIP'}{$type}{'CHMOD'};
                   1272: 	    my $chown=$info{'OWNERSHIP'}{$type}{'CHOWN'};
                   1273: 	    my $devchmod=$info{'DEVOWNERSHIP'}{$type}{'CHMOD'};
                   1274: 	    my $devchown=$info{'DEVOWNERSHIP'}{$type}{'CHOWN'};
                   1275: 	    $description.=<<END;
                   1276: <TR>
                   1277: <TD><IMG SRC="$fcm{$type}.gif" ALT="$type"></TD>
                   1278: <TD>$type</TD>
                   1279: <TD><TT>$chmod $chown</TT></TD>
                   1280: <TD><TT>$devchmod $devchown</TT></TD>
                   1281: </TR>
                   1282: END
                   1283:         }
                   1284:     }
                   1285:     $description.=<<END;
                   1286: </TABLE>
                   1287: </P>
                   1288: END
                   1289: }
                   1290: 
1.4       harris41 1291: # ------------------------- Make directory and file structure description block
                   1292: sub make_directory_and_file_structure_description_block {
1.25      harris41 1293:     my ($dirs,$mode)=@_;
                   1294:     my $statusheader; my $filestatus;
1.4       harris41 1295:     my $description=<<END;
                   1296: <FONT SIZE=+2>Directory and File Structure Description, $date</FONT>
1.6       harris41 1297: <P>
                   1298: The icons on the left column correspond to the file type
                   1299: specified in the second column.  The last column "Notes" shows compilation,
1.7       harris41 1300: dependency, and configuration information.  The CVS location
                   1301: shows the location of the binary source file (if applicable) needed to
                   1302: be copied to the target.  If the binary source file is not at
                   1303: the specified location, then the text is shown in 
                   1304: <FONT COLOR=#FF0000>red</FONT>.
1.6       harris41 1305: </P>
1.4       harris41 1306: <P>
1.9       harris41 1307: <TABLE BORDER=1 CELLPADDING=5 WIDTH=500>
1.4       harris41 1308: END
                   1309:     my $counter=0;
                   1310:     my @colorindex=("#80FF80","#80FFFF","#FFFF80");
1.5       harris41 1311:     my @allfiles=keys %{$info{'LOCATION'}{$distribution}};
1.4       harris41 1312:     foreach my $d (@$dirs) {
                   1313: 	# set color
                   1314: 	my $color=$colorindex[$counter%3];
                   1315: 	# set other values
                   1316: 	my $dirdescription=$info{'DIRECTORY'}{$distribution}{$d}{'DESCRIPTION'};
                   1317: 	$dirdescription="(" . $dirdescription . ")" if $dirdescription;
                   1318: 	# find subdirectories that are contained in this directory
                   1319: 	my @subdirs;
                   1320: 	foreach my $d2 (@$dirs) {
1.5       harris41 1321: 	    if ($d2=~/^$d\/([^\/]+)$/) {
1.4       harris41 1322: 		push @subdirs,$1;
                   1323: 	    }
                   1324: 	}
                   1325: 	# find files that are contained in this directory
                   1326: 	my @files;
1.5       harris41 1327: 	my @filesfull;
1.4       harris41 1328: 	foreach my $f (@allfiles) {
1.5       harris41 1329: 	    if ($f=~/^$d\/([^\/]+)$/) {
1.4       harris41 1330: 		push @files,$1;
1.5       harris41 1331: 		push @filesfull,$f;
1.4       harris41 1332: 	    }
                   1333: 	}
                   1334: 	# render starting HTML formatting elements
                   1335: 	if (@subdirs || @files) {
                   1336: 	    my $subdirstring="<BR>* Relevant subdirectories: " . join(", ",@subdirs) if @subdirs;
                   1337: 	    $description.=<<END;
1.5       harris41 1338: <TR><TD BGCOLOR=#000000 COLSPAN=6><FONT COLOR=$color><IMG SRC="directory.gif" ALT="directory">DIRECTORY -- $d $dirdescription
                   1339: $subdirstring</FONT></TD></TR>
1.4       harris41 1340: END
                   1341:         }
                   1342: 	else {
                   1343: 	    $description.=<<END;
1.5       harris41 1344: <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 1345: END
                   1346:         }
                   1347: 	if (@files) {
1.25      harris41 1348: 	    if ($mode eq 'status') {
                   1349: 		$statusheader=<<END;
                   1350: <TH BGCOLOR=$color ALIGN=LEFT>Current Status</TH>
                   1351: END
                   1352: 	    }
1.4       harris41 1353: 	    $description.=<<END;
                   1354: <TR>
1.25      harris41 1355: $statusheader
1.5       harris41 1356: <TH BGCOLOR=$color ALIGN=LEFT COLSPAN=2>Type</TH>
                   1357: <TH BGCOLOR=$color ALIGN=LEFT>File Name</TH>
                   1358: <TH BGCOLOR=$color ALIGN=LEFT>Function</TH>
                   1359: <TH BGCOLOR=$color ALIGN=LEFT>CVS Location</TH>
                   1360: <TH BGCOLOR=$color ALIGN=LEFT>Notes</TH>
1.4       harris41 1361: </TR>
                   1362: END
1.5       harris41 1363:             foreach my $i (0..$#files) {
                   1364: 		my $category=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'CATEGORY'};
                   1365: 		my $fdescription=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DESCRIPTION'};
                   1366: 		my $source=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
1.28      harris41 1367: 		my $source2=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'SOURCE'};
1.9       harris41 1368: 		my $note=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'NOTE'};
                   1369: 		$note.="<BR>" if $note;
                   1370: 		my $listing=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
                   1371: 		my @E=split(/\s+/,$listing);
                   1372: 		$source=~/(.*)\/[^\/]+$/;
                   1373: 		my $sd=$1;
                   1374: 		my $eflag=0;
                   1375: 		foreach my $e (@E) {
                   1376: 		    unless (-e "../../$sd/$e") {
                   1377: 			$e="<FONT COLOR=#FF0000>$e</FONT>";
                   1378: 			$eflag=1;
                   1379: 		    }
                   1380: 		}
                   1381: 		$listing=join("\n",@E);
                   1382: 		$listing="<B>listing</B><BR><FONT SIZE=-2>$listing</FONT>" if $listing;
                   1383: 		$listing.="<BR>" if $listing;
                   1384: 		my $build=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'BUILD'};
                   1385: 		$build="<B>build</B><BR>$build" if $build;
                   1386: 		$build.="<BR>" if $build;
                   1387: 		my $dependencies=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'DEPENDENCIES'};
                   1388: 		$dependencies="<B>dependencies</B><BR>$dependencies" if $dependencies;
                   1389: 		$dependencies.="<BR>" if $dependencies;
1.7       harris41 1390: 		unless (-e "../../$source") {
                   1391: 		    $source=~/([^\/]+)$/;
                   1392: 		    my $s=$1;
1.9       harris41 1393: 		    if ($source!~/\*/) {
                   1394: 			$source="<FONT COLOR=#FF0000>$source</FONT>";
                   1395: 		    }
                   1396: 		    elsif ($eflag) {
                   1397: 			$source="<FONT COLOR=#FF0000>$source</FONT>";
                   1398: 		    }
1.7       harris41 1399: 		}
1.28      harris41 1400: 		my $checksum;
                   1401: 		my $checksum_source;
                   1402: 		my $checksum_target;
1.25      harris41 1403: 		if ($mode eq 'status') {
                   1404: 		    $filestatus='';
                   1405: 		    my $fs;
                   1406: 		    my $listing2=$info{'LOCATION'}{$distribution}{$filesfull[$i]}{'FILES'};
                   1407: 		    my @E=split(/\s+/,$listing2); shift @E;
                   1408: 		    if (@E) {
                   1409: 			$fs=`find /$filesfull[$i] -prune -printf "\%m\t\%u\t\%g\n" 2>/dev/null | wc -l`; chop $fs;
                   1410: 			if ($fs!=(@E+0)) {
                   1411: 			    $ecount=(@E+0);
                   1412: 			    $estuff=join(",",@E);
                   1413: 			    $filestatus="<TD BGCOLOR=#FFFFFF><B><U>ERROR. SOME FILES ARE MISSING</U></B></TD>";
                   1414: 			}
                   1415: 			$fs=`find /$filesfull[$i] -prune -printf "\%m\t\%u\t\%g\n" 2>/dev/null | sort | uniq | wc -l`; chop $fs;
                   1416: 			if ($fs!=1) {
                   1417: 			    $filestatus='<TD BGCOLOR=#FFFFFF><B><U>ERROR. THERE ARE MULTIPLE OWNERSHIPS/PERMISSIONS WHEN ALL THESE FILES SHOULD HAVE THE SAME CONFIGURATION</U></B></TD>';
                   1418: 			}
                   1419: 			else {
                   1420: 			    $fs=`find /$filesfull[$i] -prune -printf "\%m\t\%u\t\%g\n" 2>/dev/null | sort | uniq`; chop $fs;
                   1421: 			}
                   1422: 		    }
                   1423: 		    else {
                   1424: 			$fs=`find /$filesfull[$i] -prune -printf "\%m\t\%u\t\%g" 2>/dev/null`;
1.28      harris41 1425: 			if (-f "/$filesfull[$i]" && !(-l "/$filesfull[$i]")) {
                   1426: 			    $checksum_source=`md5sum ../../$source2 | cut -d ' ' -f1`;
                   1427: 			    chop $checksum_source;
                   1428: 			    $checksum_target=`md5sum /$filesfull[$i] | cut -d ' ' -f1`;
                   1429: 			    chop $checksum_target;
1.29      harris41 1430: #			    warn ("CS: $checksum_source, CT: $checksum_target\n");
1.28      harris41 1431: 			    unless ($checksum_source eq $checksum_target) {
                   1432: 				$checksum="<BR><B><U>CHECKSUM DIFFERENCE</U></B>";
                   1433: 			    }
                   1434: 			}
1.25      harris41 1435: 		    }
                   1436: 		    my $fsl=`find /$filesfull[$i] -type l -prune -printf "\%m\t\%u\t\%g" 2>/dev/null`;
                   1437: 		    unless ($fs || $filestatus) {
                   1438: 			$filestatus='<TD BGCOLOR=#FFFFFF><B><U>MISSING</U></B></TD>';
                   1439: 		    }
                   1440: 		    elsif (!$filestatus) {
                   1441: 
                   1442: 			$chmod=$info{'OWNERSHIP'}{$category}{'CHMOD'};
                   1443: 			$chown=$info{'OWNERSHIP'}{$category}{'CHOWN'};
                   1444: 			$devchmod=$info{'DEVOWNERSHIP'}{$category}{'CHMOD'};
                   1445: 			$devchown=$info{'DEVOWNERSHIP'}{$category}{'CHOWN'};
                   1446: 
                   1447: 			my @fss=split(/\t/,$fs);
                   1448: 			my $fssz=$fss[0];
                   1449: 			$fssz="0" . $fss[0] if length($fss[0])<4;
                   1450: 			$fss[0]=$fssz;
                   1451: 			$fs="$fss[0] $fss[1]:$fss[2]";
                   1452: 			$s=' ';
                   1453: 			if ($fsl) {
                   1454: 			    $fs="$fss[1]:$fss[2]";
                   1455: 			    $s='';
                   1456: 			}
                   1457: 			if ($fs eq "$chmod$s$chown" && $fs eq "$devchmod$s$devchown") {
1.28      harris41 1458: 			    $filestatus="<TD BGCOLOR=#FFFFFF>runtime+development$checksum</TD>";
1.25      harris41 1459: 			}
                   1460: 			elsif ($fs eq "$chmod$s$chown") {
1.28      harris41 1461: 			    $filestatus="<TD BGCOLOR=#FFFFFF>runtime$checksum</TD>";
1.25      harris41 1462: 			}
                   1463: 			elsif ($fs eq "$devchmod$s$devchown") {
1.28      harris41 1464: 			    $filestatus="<TD BGCOLOR=#FFFFFF>development$checksum</TD>";
1.25      harris41 1465: 			}
                   1466: 			else {
                   1467: 			    $filestatus="<TD BGCOLOR=#FFFFFF><B><U>ERROR</U></B><BR>$fs</TD>";
                   1468: 			}
                   1469: 		    }
                   1470: 		}	    
1.5       harris41 1471: 		$description.=<<END;
                   1472: <TR>
1.25      harris41 1473: $filestatus
1.5       harris41 1474: <TD BGCOLOR=#A0A0A0><IMG SRC="$fcm{$category}.gif" ALT="$category"></TD>
                   1475: <TD BGCOLOR=$color>$category</TD>
                   1476: <TD BGCOLOR=$color>$files[$i]</TD>
                   1477: <TD BGCOLOR=$color>$fdescription&nbsp;</TD>
                   1478: <TD BGCOLOR=$color>$source</TD>
1.9       harris41 1479: <TD BGCOLOR=$color>$note$listing$build$dependencies&nbsp;</TD>
1.4       harris41 1480: </TR>
                   1481: END
1.5       harris41 1482: 	    }
                   1483: 	}
1.4       harris41 1484: 	$counter++;
                   1485:     }
                   1486:     $description.=<<END;
                   1487: </TABLE>
                   1488: </P>
                   1489: END
                   1490:     return $description;
                   1491: }

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