#!/usr/freeware/bin/perl -w # -*- Perl -*- # Copyright 2002 Silicon Graphics, Inc. All rights reserved. # $Id: prereq.cgi,v 1.2 2006/07/21 20:58:06 dkascht Exp $ # # Render prereq.txt in a more readable per-package form. # Thanks to Andrea Suatoni for the inspiration, and # Jeff Hanson for the help and refinements. # # Possible extensions: # o Rework prereq.txt to include full per-subsys prereq data. # o Parse "versions -bn fw\*" output and prune existing packages. # o Generate a cut&paste list of download commands. # o Make it usable locally (off-line), rather than only from # freeware.sgi.com. use strict; use CGI; use CGI::Carp; # Hash tables entries are sets (hashes) of package names. my %PREREQS; my %USED_BY; # Set of all known products, indexed by real name. my %PRODUCTS; # Mapping for updates rules my %UPDATES; my %MAP; # Decode name mangling in prereq.txt my %DEMANGLE; my $known_demangling = 0; my $datafile = "prereq.txt"; my $mapfile = "name-map.txt"; my $template = "shared/index.template"; # General setup -- parse the query parameters. my $query = new CGI; my $product = $query->param('product'); my $display = $query->param('display'); # Assume some default values (recursive). $display = '' if (!defined $display); my $recursive = $display ne "direct"; my $flat = $display ne "nested"; # Load the name-map file. &load_map($mapfile); # Load the prereq data file. my $title = &load_data($datafile); my $title_ext = ""; if (defined $product && $product ne "") { $title_ext = "$product"; if ($display) { $title_ext .= " ($display)"; } } # Output some header information. print $query->header; # Assemble the title section. my $full_title = $title_ext ? "SGI IRIX Freeware Dependencies: " . $title_ext : $title; my $TITLE = join("\n", "$full_title", '', '', ''); # Assemble the contents section. my $CONTENTS = join("\n", $query->h1($title . ($title_ext ? ":\n
\n" . $title_ext : "")), ""); # Output the form. my @products = sort keys %PRODUCTS; $CONTENTS .= join("\n", $query->hr, "", $query->start_form(-action => $query->self_url, -method=>"GET"), $query->p("Freeware product: ", $query->popup_menu(-name => 'product', -values => \@products), "
Show references: ", $query->popup_menu(-name => 'display', -values => [ 'recursive', 'nested', 'direct' ], -default => 'recursive', -labels => { 'direct' => 'immediate dependencies only', 'nested' => 'hierarchically, without duplicates', 'recursive' => 'all dependencies' })), $query->submit, $query->end_form, ""); # Output some boilerplate. $CONTENTS .= join("\n", $query->p("Note: the output considers all possible dependencies, including those from non-default and mutually incompatible subsystems, as well as alternative prereqs. Your actual requirements may be less depending on which subsystems you choose to install. Also this output ignores version numbers, so although you may have all the listed required packages installed, you might still get conflicts from the software manager if your packages are out of date.\n"), $query->p("See the", $query->a({href=>"selections.html"}, "Freeware Selections Files"), "\n", "web page for more information.\nRaw data is in", $query->a({href=>$datafile}, $datafile))); # Output the query result if (not defined $product) { # No query was made. } elsif ($product && not exists $PRODUCTS{$product}) { $CONTENTS .= join("\n", $query->hr, "

Package '$product' is unknown.

"); } else { $CONTENTS .= join("\n", $query->hr, "

Package $product requires:

\n"); $CONTENTS .= show_deps($product, \%PREREQS); $CONTENTS .= join("\n", $query->p, "

Package $product is required by:

\n"); $CONTENTS .= show_deps($product, \%USED_BY); } # Load the entire template. open(TEMPLATE, "<$template") || die("Unable to open $template: $!\n"); my $output = join("",