home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / full / activeperl / APi522e.exe / data.z / ppm.pl < prev    next >
Encoding:
Perl Script  |  1999-11-01  |  52.7 KB  |  1,497 lines

  1. #!/usr/bin/perl
  2.  
  3. use Getopt::Long;
  4. use File::Basename;
  5. use Config;
  6. use strict;
  7.  
  8. use PPM;
  9.  
  10. $PPM::VERSION = "1.1.1";
  11.  
  12. my $usage = <<'EOT';
  13.     usage: ppm genconfig
  14.            ppm help [command]
  15.            ppm install [--location=location] package1 [... packageN]
  16.            ppm query [--case|nocase] [--searchtag=abstract|author|title] PATTERN
  17.            ppm remove package1 [... packageN]
  18.            ppm search [--case|nocase] [--location=location] [--searchtag=abstract|author|title] PATTERN
  19.            ppm set [option]
  20.            ppm verify [--location=location] [--upgrade] [package1 ... packageN]
  21.            ppm version
  22.            ppm [--location=location]
  23.  
  24. EOT
  25.  
  26. my %help;
  27.  
  28. $help{'set'} = <<'EOT';
  29.     set
  30.         - Displays current settings.
  31.     set build DIRECTORY
  32.         - Changes the package build directory.
  33.     set case [Yes|No]
  34.         - Set case-sensitive searches.
  35.     set clean [Yes|No]
  36.         - Set removal of temporary files from package's build area
  37.           following successful installation.
  38.     set confirm [Yes|No]
  39.         - Sets confirmation of 'install', 'remove' and 'upgrade'.
  40.     set force_install [Yes|No]
  41.         - Continue installing a package if a dependency cannot be installed.
  42.     set more NUMBER
  43.         - Pause after displaying 'NUMBER' lines.  Specifying '0' turns
  44.           off paging capability.
  45.     set repository /remove NAME
  46.         - Removes the repository 'NAME' from the list of repositories.
  47.     set repository NAME LOCATION
  48.         - Adds a repository to the list of PPD repositories for this session.
  49.           'NAME' is the name by which this repository will be referred;
  50.           'LOCATION' is a URL or directory name.
  51.     set root DIRECTORY
  52.         - Changes install root directory for this session.
  53.     set save
  54.         - Save current options as defaults.
  55.     set trace
  56.         - Tracing level--default is 1, maximum is 4, 0 indicates
  57.           no tracing.
  58.     set tracefile
  59.         - File to contain tracing information, default is 'PPM.LOG'.
  60.     set verbose [Yes|No]
  61.         - Display additional package information for 'query' and
  62.           'search' commands.
  63. EOT
  64.  
  65. # Need to do this here, because the user's config file is probably
  66. # hosed.
  67. if ($#ARGV == 0 && $ARGV[0] eq 'genconfig') {
  68.     &genconfig;
  69.     exit 0;
  70. }
  71.  
  72. my %options = PPM::GetPPMOptions();
  73. use vars qw ($location $Ignorecase $clean $confirm $force_install $root $build_dir $more $trace $tracefile $verbose);
  74. *Ignorecase = \$options{'IGNORECASE'};
  75. *clean = \$options{'CLEAN'};
  76. *confirm = \$options{'CONFIRM'};
  77. *force_install = \$options{'FORCE_INSTALL'};
  78. *root = \$options{'ROOT'};
  79. *build_dir = \$options{'BUILDDIR'};
  80. *more = \$options{'MORE'};
  81. *trace = \$options{'TRACE'};
  82. *tracefile = \$options{'TRACEFILE'};
  83. *verbose = \$options{'VERBOSE'};
  84.  
  85. my $moremsg = "[Press return to continue]";
  86. my $interactive = 0;
  87.  
  88. $help{'help'} = <<'EOT';
  89. Commands:
  90.     exit              - leave the program.
  91.     genconfig         - prints a valid PPM.XML file to STDOUT.
  92.     help [command]    - prints this screen, or help on 'command'.
  93.     install PACKAGES  - installs specified PACKAGES.
  94.     quit              - leave the program.
  95.     query [options]   - query information about installed packages.
  96.     remove PACKAGES   - removes the specified PACKAGES from the system.
  97.     search [options]  - search information about available packages.
  98.     set [options]     - set/display current options.
  99.     verify [options]  - verifies current install is up to date.
  100.  
  101. EOT
  102.  
  103. $help{'search'} = <<'EOT';
  104.     search [PATTERN]
  105.     search /abstract [PATTERN]
  106.     search /author [PATTERN]
  107.     search /title [PATTERN]
  108.     search /location LOCATION [PATTERN]
  109.  
  110.     Searches for available packages.  With no arguments, will display
  111.     a list of all available packages. If a regular expression 'PATTERN'
  112.     is supplied, only packages matching the pattern will be displayed.
  113.     If the '/abstract', '/author' or '/title' argument is specified,
  114.     the respective field of the package will be searched.  If the
  115.     '/location' option is specified, matching packages from that
  116.     URL or directory will be listed.
  117.  
  118. EOT
  119.  
  120. $help{'install'} = <<'EOT';
  121.     install PACKAGE
  122.     install /location LOCATION PACKAGE
  123.  
  124.     Installs the specified 'PACKAGE' onto the system.  If the '/location'
  125.     option is specified, the package will be looked for at that URL
  126.     or directory.
  127.  
  128. EOT
  129.  
  130. $help{'remove'} = <<'EOT';
  131.     remove PACKAGE
  132.  
  133.     Removes the specified 'PACKAGE' from the system.
  134.  
  135. EOT
  136.  
  137. $help{'genconfig'} = <<'EOT';
  138.     genconfig
  139.  
  140.     This command will print a valid PPM config file (ppm.xml) to 
  141.     STDOUT.  This can be useful if the PPM config file ever gets 
  142.     damaged leaving PPM unusable.
  143.  
  144. EOT
  145.  
  146. $help{'query'} = <<'EOT';
  147.     query [PATTERN]
  148.     query /abstract [PATTERN]
  149.     query /author [PATTERN]
  150.     query /title [PATTERN]
  151.  
  152.     Queries information about installed packages. With no arguments, will
  153.     display a list of all installed packages. If a regular expression
  154.     'PATTERN' is supplied, only packages matching the pattern will be
  155.     displayed.  If the '/abstract', '/author' or '/title' argument is
  156.     specified, the respective field of the package will be searched.
  157.  
  158. EOT
  159.  
  160. $help{'verify'} = <<'EOT';
  161.     verify [packages]
  162.     verify /upgrade [packages]
  163.     verify /location LOCATION [packages]
  164.  
  165.     Verifies that the currently installed 'packages' are up to date.
  166.     If 'packages' is not specified, all installed packages are verified.
  167.     If the '/upgrade' option is specified, any packages for which an
  168.     upgrade is available will be upgraded.  If the '/location' option
  169.     is specified, upgrades will be looked for at the specified URL
  170.     or directory.
  171.  
  172. EOT
  173.  
  174. my %repositories = PPM::ListOfRepositories();
  175.  
  176. if ($#ARGV == -1 || ($#ARGV == 0 && $ARGV[0] =~ /^--location/)) {
  177.     my $prompt = 'PPM> ';
  178.     $interactive = 1;
  179.     GetOptions("location=s" => \$location);
  180.  
  181.     print "PPM interactive shell ($PPM::VERSION) - type 'help' for available commands.\n";
  182.     $| = 1;
  183.     while () {
  184.         print $prompt;
  185.         last unless defined ($_ = <> );
  186.         chomp;
  187.         s/^\s+//;
  188.         my @line = split(/\s+/, $_);
  189.         my $cmd = shift @line;
  190.         next if /^$/;
  191.  
  192.         # exit/quit
  193.         if (command($cmd, "qu|it") or command($cmd, "|exit")) {
  194.             print "Quit!\n";
  195.             last;
  196.         }
  197.         # help
  198.         elsif (command($cmd, "|help")) {
  199.             if (defined $line[0] && $help{$line[0]}) {
  200.                 print $help{$line[0]};
  201.             }
  202.             else {
  203.                 print $help{'help'};
  204.             }
  205.         }
  206.         # query
  207.         elsif (command($cmd, "qu|ery")) {
  208.             my $package;
  209.             my %summary = InstalledPackageProperties();
  210.             if (defined $line[0]) {
  211.                 my $searchtag;
  212.                 if ($line[0] =~ /^\/(abstract|author|title)$/i) {
  213.                     $searchtag = uc $1;
  214.                     shift @line;
  215.                 }
  216.                 my $RE = shift @line;
  217.                 eval { $RE =~ /$RE/ };
  218.                 if ($@) {
  219.                     print "'$RE': invalid regular expression.\n";
  220.                     next;
  221.                 }
  222.                 $RE = "(?i)$RE" if $Ignorecase eq "Yes";
  223.                 foreach(keys %summary) {
  224.                     if (defined $searchtag) {
  225.                         delete $summary{$_} unless $summary{$_}{$searchtag} =~ /$RE/;
  226.                     }
  227.                     else {
  228.                         delete $summary{$_} unless /$RE/;
  229.                     }
  230.                 }
  231.             }
  232.             print_formatted(1, %summary);
  233.         }
  234.         # install
  235.         elsif (command($cmd, "in|stall")) {
  236.             my $package;
  237.             local $location = $location;
  238.             if (defined $line[0]) {
  239.                 if ($line[0] =~ /^\/location$/i) {
  240.                     shift @line;
  241.                     $location = shift @line;
  242.                 }
  243.             }
  244.             if (!defined @line) {
  245.                 print "Package not specified.\n";
  246.                 next;
  247.             }
  248.             foreach $package (@line) {
  249.                 if ($confirm eq "Yes") {
  250.                     print "Install package \'$package?\' (y/N): ";
  251.                     next if (<> ne "y\n");
  252.                 }
  253.                 print "Retrieving package \'$package\'...\n";
  254.                 if(!InstallPackage("package" => $package, "location" => $location)) {
  255.                     print "Error installing package '$package': $PPM::PPMERR\n";
  256.                 }
  257.             }
  258.         }
  259.         # remove
  260.         elsif (command($cmd, "|remove")) {
  261.             my $package;
  262.             if (!defined @line) {
  263.                 print "Package not specified.\n";
  264.                 next;
  265.             }
  266.             foreach $package (@line) {
  267.                 if ($confirm eq "Yes") {
  268.                     print "Remove package \'$package?\' (y/N): ";
  269.                     next if (<> ne "y\n");
  270.                 }
  271.                 if (!RemovePackage("package" => $package)) {
  272.                     print "Error removing $package: $PPM::PPMERR\n";
  273.                 }
  274.             }
  275.         }
  276.         # search
  277.         elsif (command($cmd, "se|arch")) {
  278.             my ($package, %summary, $searchtag);
  279.             local $location = $location;
  280.             while (defined $line[0]) {
  281.                 if ($line[0] =~ /^\/(abstract|author|title)$/i) {
  282.                     $searchtag = uc $1;
  283.                     shift @line;
  284.                 }
  285.                 elsif ($line[0] =~ /^\/location$/i) {
  286.                     shift @line;
  287.                     $location = shift @line;
  288.                 }
  289.                 else { last; }
  290.             }
  291.             my $searchRE = $line[0];
  292.             %summary = search_PPDs("location" => $location, "searchtag" => $searchtag, 
  293.                         "searchRE" => $searchRE, "ignorecase" => $Ignorecase);
  294.             foreach (keys %summary) {
  295.                 print "Packages available from $_:\n";
  296.                 print_formatted(2, %{$summary{$_}});
  297.             }
  298.         }
  299.         # set
  300.         elsif (command($cmd, "se|t")) {
  301.             set(@line);
  302.         }
  303.         # verify
  304.         elsif (command($cmd, "|verify")) {
  305.             my $upgrade;
  306.             local $location = $location;
  307.             while (defined $line[0]) {
  308.                 if ($line[0] =~ /^\/upgrade$/i) {
  309.                     $upgrade = 1;
  310.                     shift @line;
  311.                     next;
  312.                 }
  313.                 if ($line[0] =~ /^\/location$/i) {
  314.                     shift @line;
  315.                     $location = shift @line;
  316.                     next;
  317.                 }
  318.                 last;
  319.             }
  320.             if ($upgrade && $confirm eq "Yes") {
  321.                 print "Upgrade package" . ($#line == 0 ? " $line[0]" : "s") . "? (y/N): ";
  322.                 next if (<> ne "y\n");
  323.             }
  324.             verify_packages("packages" => \@line, "location" => $location, "upgrade" => $upgrade);
  325.         }
  326.         else {
  327.             print "Unknown or ambiguous command '$cmd'; type 'help' for commands.\n";
  328.         }
  329.     }
  330. }
  331. elsif ($ARGV[0] eq 'help') {
  332. $help{'install'} = <<'EOT';
  333.     install [--location=location] PACKAGE
  334.  
  335.     Installs the specified 'PACKAGE' onto the system.  If 'location' is
  336.     not specified, the default locations in the PPM data file will be
  337.     used to locate the package.
  338.  
  339. EOT
  340.  
  341. $help{'search'} = <<'EOT';
  342.     search [--case|nocase] [--location=location] [PATTERN]
  343.     search [--case|nocase] [--location=location] --searchtag=abstract [PATTERN]
  344.     search [--case|nocase] [--location=location] --searchtag=author [PATTERN]
  345.     search [--case|nocase] [--location=location] --searchtag=title [PATTERN]
  346.  
  347.     Searches for available packages.  With no arguments, will display
  348.     a list of all available packages. If a regular expression 'PATTERN'
  349.     is supplied, only packages matching the pattern will be displayed.
  350.     If the 'abstract', 'author' or 'title' --searchtag argument is
  351.     specified, the respective field of the package will be searched.
  352.     If 'location' is not specified, the repository locations in the PPM
  353.     data file will be searched.  '--case' or '--nocase' may be used to
  354.     request case-sensitive or case-insensitive searches, respectively.
  355.  
  356. EOT
  357.  
  358. $help{'query'} = <<'EOT';
  359.     query [PATTERN]
  360.     query [--case|nocase] --searchtag=abstract [PATTERN]
  361.     query [--case|nocase] --searchtag=author [PATTERN]
  362.     query [--case|nocase] --searchtag=title [PATTERN]
  363.  
  364.     Queries information about installed packages. With no arguments, will
  365.     display a list of all installed packages. If a regular expression
  366.     'PATTERN' is supplied, only packages matching the pattern will
  367.     be displayed.  If the 'abstract', 'author' or 'title' --searchtag
  368.     argument is specified, the respective field of the package will
  369.     be searched.  '--case' or '--nocase' may be used to request
  370.     case-sensitive or case-insensitive searches, respectively.
  371.  
  372. EOT
  373.  
  374. $help{'verify'} = <<'EOT';
  375.     verify [--location=location] [packages]
  376.     verify --upgrade [--location=location] [packages]
  377.  
  378.     Verifies that the currently installed 'packages' are up to date.
  379.     If 'packages' is not specified, all installed packages are verified.
  380.     If the '--upgrade' option is specified, any packages for which
  381.     an upgrade is available will be upgraded.  If 'location' is not
  382.     specified, the repository locations in the PPM data file will be
  383.     searched.
  384.  
  385. EOT
  386.  
  387. $help{'summary'} = <<'EOT';
  388.     summary [--location=location] [packages]
  389.  
  390.     Prints a summary (name, version and abstract) of the specified
  391.     package, or all packages available at a repository if no package
  392.     is specified.  If the '--location' option is specified, a summary
  393.     of packages at the specified repository (if available) will be 
  394.     printed.
  395.  
  396. EOT
  397.     shift;
  398.     if (defined $ARGV[0] && $help{$ARGV[0]}) {
  399.         print $help{$ARGV[0]};
  400.     }
  401.     else {
  402.         print $usage;
  403.     }
  404. }
  405. elsif ($ARGV[0] eq 'version') {
  406.     print $PPM::VERSION;
  407. }
  408. elsif ($ARGV[0] eq 'set') {
  409.     shift;
  410.     if (set(@ARGV) == 0) {
  411.         PPM::SetPPMOptions("options" => \%options, "save" => 1);
  412.     }
  413. }
  414. elsif ($ARGV[0] eq 'install') {
  415.     my ($package);
  416.  
  417.     shift;
  418.     GetOptions("location=s" => \$location);
  419.  
  420.     $package = shift;
  421.     if (!defined $package && -d "blib" && -f "Makefile") {
  422.         if(!InstallPackage("location" => $location)) {
  423.             print "Error installing blib: $PPM::PPMERR\n";
  424.         }
  425.     }
  426.     while ($package) {
  427.         if(!InstallPackage("package" => $package, "location" => $location)) {
  428.             print "Error installing package '$package': $PPM::PPMERR\n";
  429.         }
  430.         $package = shift;
  431.     }
  432. }
  433. elsif ($ARGV[0] eq 'remove') {
  434.     shift;
  435.  
  436.     my $package = shift;
  437.  
  438.     while ($package) {
  439.         if (!RemovePackage("package" => $package)) {
  440.             print "Error removing $package: $PPM::PPMERR\n";
  441.         }
  442.         $package = shift;
  443.     }
  444. }
  445. elsif ($ARGV[0] eq 'verify') {
  446.     my ($upgrade, $package, @packages);
  447.  
  448.     shift;
  449.     GetOptions("location=s" => \$location, "upgrade" => \$upgrade);
  450.  
  451.     verify_packages("packages" => \@ARGV, "location" => $location, "upgrade" => $upgrade);
  452. }
  453. elsif ($ARGV[0] eq 'query') {
  454.     my ($case, $nocase, $searchtag, $searchRE, $package);
  455.     shift;
  456.     GetOptions("nocase" => \$nocase, "case" => \$case,
  457.                 "searchtag=s" => \$searchtag );
  458.     $searchRE = shift;
  459.     eval { $searchRE =~ /$searchRE/ };
  460.     if ($@) {
  461.         print "'$searchRE': invalid regular expression.\n";
  462.         exit 1;
  463.     }
  464.     if (!defined $nocase) {
  465.         if (!defined $case) {
  466.             $nocase = $Ignorecase;  # use the default setting
  467.         }
  468.     }
  469.     if (defined $searchtag) {
  470.         if (!$searchtag =~ /^(abstract|author|title)$/i) {
  471.             print $usage;
  472.             exit 1;
  473.         }
  474.         $searchtag = uc $searchtag;
  475.     }
  476.     $searchRE = "(?i)$searchRE" if $nocase eq "Yes";
  477.     my %summary = InstalledPackageProperties();
  478.     foreach(keys %summary) {
  479.         if ($searchtag) {
  480.            delete $summary{$_} unless $summary{$_}{$searchtag} =~ /$searchRE/;
  481.         }
  482.         else {
  483.            delete $summary{$_} unless /$searchRE/;
  484.         }
  485.     }
  486.     print_formatted(1, %summary);
  487. }
  488. elsif ($ARGV[0] eq 'search') {
  489.     my ($case, $nocase, $searchtag, $searchRE, %summary);
  490.     shift;
  491.     GetOptions("nocase" => \$nocase, "case" => \$case,
  492.                 "location=s" => \$location, "searchtag=s" => \$searchtag );
  493.     $searchRE = shift;
  494.     eval { $searchRE =~ /$searchRE/ };
  495.     if ($@) {
  496.         print "'$searchRE': invalid regular expression.\n";
  497.         next;
  498.     }
  499.     if (defined $case) {
  500.         $nocase = "No";
  501.     }
  502.     elsif (defined $nocase) {
  503.         $nocase = "Yes";
  504.     }
  505.     else {
  506.         $nocase = $Ignorecase;
  507.     }
  508.     if (defined $searchtag) {
  509.         if ($searchtag !~ /^(abstract|author|title)$/i) {
  510.             print $usage;
  511.             exit 1;
  512.         }
  513.         $searchtag = uc $searchtag;
  514.     }
  515.     %summary = search_PPDs("location" => $location, "searchtag" => $searchtag, 
  516.                 "searchRE" => $searchRE, "ignorecase" => $nocase);
  517.     foreach (keys %summary) {
  518.         print "Packages available from $_:\n";
  519.         print_formatted(2, %{$summary{$_}});
  520.     }
  521. }
  522. else {
  523.     print $usage;
  524.     exit 1;
  525. }
  526.  
  527. exit 0;
  528.  
  529. sub more
  530. {
  531.     my ($lines) = shift @_;
  532.     if (++$$lines >= $more) {
  533.         print $moremsg;
  534.         $_ = <>;
  535.         $$lines = 1;
  536.     }
  537. }
  538.  
  539. # This nasty piece of business splits $pattern into a required prefix 
  540. # and a "match any of this substring" suffix.  E.g. "in|stall" will
  541. # match a $cmd of "ins", "inst", ..., "install".
  542. sub command
  543. {
  544.     my ($cmd, $pattern) = @_;
  545.     my @pattern = split(/\|/, $pattern);
  546.     my @optchars = split(//, $pattern[1]);
  547.     # build up a "foo(b|ba|bar)" string
  548.     $pattern = "$pattern[0](";
  549.     $pattern[1] = shift @optchars;
  550.     $pattern[1] .= "|$pattern[1]$_" foreach @optchars;
  551.     $pattern .= "$pattern[1])";
  552.     return ($cmd =~ /^${pattern}$/i);
  553. }
  554.  
  555. # This routine prints the output for query and search
  556. # in a nicely formatted way, if $verbose is set.
  557. sub print_formatted
  558. {
  559.     my ($lines, %summary) = @_;
  560.     my $package;
  561.  
  562.     if (!$verbose) {
  563.         foreach $package (sort keys %summary) {
  564.             print "$package\n";
  565.             &more(\$lines) if $more;
  566.         }
  567.         return;
  568.     }
  569.  
  570.     my ($maxname, $maxversion);
  571.     # find the longest package name and version strings, so we can
  572.     # format them nicely
  573.     $maxname < length($_) and $maxname = length($_) for keys %summary;
  574.     foreach $package (keys %summary) {
  575.         $summary{$package}{'VERSION'} =~ s/(,0)*$//;
  576.         $summary{$package}{'VERSION'} =~ tr/,/./;
  577.         $maxversion = length $summary{$package}{'VERSION'} > $maxversion ? length $summary{$package}{'VERSION'} : $maxversion;
  578.     }
  579.     my $columns = $ENV{COLUMNS} ? $ENV{COLUMNS} : 80;
  580.     my $namefield = "@" . "<" x ($maxname - 1);
  581.     my $versionfield = "@" . "<" x ($maxversion - 1);
  582.     my $abstractfield = "^" . "<" x ($columns - (6 + $maxname + $maxversion));
  583.     my $abstractpad = " " x ($maxname + $maxversion + 3);
  584.  
  585.     foreach $package (sort keys %summary) {
  586.         my $format = "format STDOUT = \n"
  587.                    . "$namefield [$versionfield] $abstractfield\n"
  588.                    . '$package, $summary{$package}{VERSION}, $summary{$package}{ABSTRACT}'
  589.                    . "\n"
  590.                    . "$abstractpad $abstractfield~~\n"
  591.                    . '$summary{$package}{ABSTRACT}' 
  592.                    . "\n"
  593.                    . ".\n";
  594.  
  595.         eval $format;
  596.         my $diff = $-;
  597.         write;
  598.         $diff -= $-;
  599.         $lines += ($diff - 1) if $diff > 1;
  600.         &more(\$lines) if $more;
  601.     }
  602. }
  603.  
  604. sub set
  605. {
  606.     my ($option) = shift @_;
  607.     my $rc = 0;
  608.     if (defined $option) {
  609.         my ($value) = shift @_;
  610.         if (command($option, "r|epository")) {
  611.             if ($value =~ /\/remove/i) {
  612.                 $value = shift @_;
  613.                 while (@_) {
  614.                     $value .= " " . shift @_;
  615.                 }
  616.                 if (!defined $value) {
  617.                     print "Location not specified.\n";
  618.                     $rc = 1;
  619.                 }
  620.                 else {
  621.                     PPM::RemoveRepository("repository" => $value);
  622.                     %repositories = PPM::ListOfRepositories();
  623.                 }
  624.             }
  625.             else {
  626.                 my $location = shift @_;
  627.                 if (!defined $value || !defined $location) {
  628.                     print "Repository not specified.\n";
  629.                     $rc = 1;
  630.                 }
  631.                 else {
  632.                     PPM::AddRepository("repository" => $value,
  633.                                        "location" => $location);
  634.                     %repositories = PPM::ListOfRepositories();
  635.                 }
  636.             }
  637.         }
  638.         else {
  639.             if (command($option, "c|onfirm")) {
  640.                 if (defined $value) {
  641.                     if ($value =~ /^Yes$/) { $confirm = $value; }
  642.                     elsif ($value =~ /^No$/) { $confirm = $value; }
  643.                     else {
  644.                         print "Value must be 'Yes' or 'No'.\n";
  645.                         $rc = 1;
  646.                         return $rc;
  647.                     }
  648.                 }
  649.                 else { $confirm = $confirm eq "Yes" ? "No" : "Yes"; }
  650.                 print "Commands will " . ($confirm eq "Yes" ? "" : "not ") . "be confirmed.\n";
  651.             }
  652.             elsif (command($option, "|save")) {
  653.                 PPM::SetPPMOptions("options" => \%options, "save" => 1);
  654.                 return $rc;
  655.             }
  656.             elsif (command($option, "c|ase")) {
  657.                 if (defined $value) {
  658.                     # N.B. These are reversed.
  659.                     if ($value =~ /^Yes$/) { $Ignorecase = "No"; }
  660.                     elsif ($value =~ /^No$/) { $Ignorecase = "Yes"; }
  661.                     else {
  662.                         print "Value must be 'Yes' or 'No'.\n";
  663.                         $rc = 1;
  664.                         return $rc;
  665.                     }
  666.                 }
  667.                 else { $Ignorecase = $Ignorecase eq "Yes" ? "No" : "Yes"; }
  668.                 print "Case-" . ($Ignorecase eq "Yes" ? "in" : "") . "sensitive searches will be performed.\n";
  669.             }
  670.             elsif (command($option, "r|oot")) {
  671.                 my $old_root;
  672.                 if (!defined $value) {
  673.                     print "Directory not specified.\n";
  674.                     $rc = 1;
  675.                 }
  676.                 elsif(!($old_root = PPM::chroot("location" => $value))) {
  677.                     print "$PPM::PPMERR";
  678.                     $rc = 1;
  679.                 }
  680.                 else {
  681.                     $root = $value;
  682.                     print "Root is now $value [was $old_root].\n";
  683.                 }
  684.             }
  685.             elsif (command($option, "|build")) {
  686.                 if (!defined $value) {
  687.                     print "Directory not specified.\n";
  688.                     $rc = 1;
  689.                 }
  690.                 elsif (-d $value) {
  691.                     $build_dir = $value;
  692.                     print "Build directory is now $value.\n";
  693.                 }
  694.                 else {
  695.                     print "Directory '$value' does not exist.\n";
  696.                     $rc = 1;
  697.                 }
  698.             }
  699.             elsif (command($option, "|force_install")) {
  700.                 if (defined $value) {
  701.                     if ($value =~ /^Yes$/) { $force_install = $value; }
  702.                     elsif ($value =~ /^No$/) { $force_install = $value; }
  703.                     else {
  704.                         print "Value must be 'Yes' or 'No'.\n";
  705.                         $rc = 1;
  706.                         return $rc;
  707.                     }
  708.                 }
  709.                 else { $force_install = $force_install eq "Yes" ? "No" : "Yes"; }
  710.                 print "Package installations will " .
  711.                       ($force_install eq "Yes" ? "" : "not ") .
  712.                       "continue if a dependency cannot be installed.\n";
  713.             }
  714.             elsif (command($option, "c|lean")) {
  715.                 if (defined $value) {
  716.                     if ($value =~ /^Yes$/) { $clean = $value; }
  717.                     elsif ($value =~ /^No$/) { $clean = $value; }
  718.                     else {
  719.                         print "Value must be 'Yes' or 'No'.\n";
  720.                         $rc = 1;
  721.                         return $rc;
  722.                     }
  723.                 }
  724.                 else { $clean = $clean eq "Yes" ? "No" : "Yes"; }
  725.                 print "Temporary files will " . ($clean eq "Yes" ? "" : "not ") . "be deleted.\n";
  726.             }
  727.             elsif (command($option, "|more")) {
  728.                 if (defined $value && $value =~ /^\d+$/) {
  729.                     $more = $value;
  730.                 }
  731.                 else {
  732.                     print "Numeric value must be given.\n";
  733.                     $rc = 1;
  734.                     return $rc;
  735.                 }
  736.                 print "Screens will " . ($more > 0 ? "pause after $more lines.\n" : "not pause.\n");
  737.             }
  738.             elsif (command($option, "trace|file")) {
  739.                 if (!defined $value) {
  740.                     print "Filename not specified.\n";
  741.                     $rc = 1;
  742.                 }
  743.                 $tracefile = $value;
  744.                 print "Tracing info will be written to $tracefile.\n";
  745.             }
  746.             elsif (command($option, "trace")) {
  747.                 if (defined $value && $value =~ /^\d+$/ && $value >= 0 && $value <= 4) {
  748.                     $trace = $value;
  749.                 }
  750.                 else {
  751.                     print "Numeric value between 0 and 4 must be given.\n";
  752.                     $rc = 1;
  753.                     return $rc;
  754.                 }
  755.                 print "Tracing info will " . ($trace > 0 ? "be written to $tracefile.\n" : "not be written.\n");
  756.             }
  757.             elsif (command($option, "|verbose")) {
  758.                 if (defined $value) {
  759.                     if ($value =~ /^(Yes|1)$/i) { $verbose = 1; }
  760.                     elsif ($value =~ /^(No|0)$/i) { $verbose = 0; }
  761.                     else {
  762.                         print "Invalid setting: must be 'Yes/No' or '1/0'.\n";
  763.                         $rc = 1;
  764.                         return $rc;
  765.                     }
  766.                 }
  767.                 else { $verbose = $verbose eq "1" ? "0" : "1"; }
  768.                 print "Query/search results will " . ($verbose ? "" : "not ") . "be verbose.\n";
  769.             }
  770.             else {
  771.                 print "Unknown or ambiguous option '$option'; see 'help set' for available options.\n";
  772.                 $rc = 1;
  773.             }
  774.             if (!$rc) {
  775.                 PPM::SetPPMOptions("options" => \%options);
  776.             }
  777.         }
  778.     }
  779.     else {
  780.         print "Commands will " . ($confirm eq "Yes" ? "" : "not ") . "be confirmed.\n";
  781.         print "Temporary files will " . ($clean eq "Yes" ? "" : "not ") . "be deleted.\n";
  782.         print "Case-" . ($Ignorecase eq "Yes" ? "in" : "") . "sensitive searches will be performed.\n";
  783.         print "Package installations will " . ($force_install eq "Yes" ? "" : "not ") . "continue if a dependency cannot be installed.\n";
  784.         print "Tracing info will " . (($trace && $trace > 0 )? "be written to '$tracefile'.\n" : "not be written.\n");
  785.         print "Screens will " . ($more > 0 ? "pause after $more lines.\n" : "not pause.\n");
  786.         print "Query/search results will " . ($verbose ? "" : "not ") . "be verbose.\n";
  787.         if (defined $location) { print "Current PPD repository: $location\n"; }
  788.         else {
  789.             print "Current PPD repository paths:\n";
  790.             my $location;
  791.             foreach $_ (keys %repositories) {
  792.                 print "\t$_: $repositories{$_}\n";
  793.             }
  794.         }
  795.         if (defined $root) { print "Packages will be installed under: $root\n"; }
  796.         if (defined $build_dir) { print "Packages will be built under: $build_dir\n"; }
  797.     }
  798.     return $rc;
  799. }
  800.  
  801. sub search_PPDs
  802. {
  803.     my (%argv) = @_;
  804.     my (%packages, $arg, $ignorecase, $searchtag, $searchRE);
  805.     local $location = $location;
  806.     foreach $arg (keys %argv) {
  807.         if ($arg eq 'location') { $location = $argv{$arg}; }
  808.         if ($arg eq 'searchtag') { $searchtag = $argv{$arg}; }
  809.         if ($arg eq 'ignorecase') { $ignorecase = $argv{$arg}; }
  810.         if ($arg eq 'searchRE' && defined $argv{$arg}) {
  811.             $searchRE = $argv{$arg};
  812.             eval { $searchRE =~ /$searchRE/ };
  813.             if ($@) {
  814.                 print "'$searchRE': invalid regular expression.\n";
  815.                 return;
  816.             }
  817.             $searchRE = "(?i)$searchRE" if $ignorecase eq "Yes";
  818.         }
  819.     }
  820.     if (!defined $ignorecase) {
  821.         $ignorecase = $Ignorecase;
  822.     }
  823.     my (%ppds, $loc, $package);
  824.     %ppds = PPM::RepositoryPackages("location" => $location);
  825.     foreach $loc (keys %ppds) {
  826.         next if $#{$ppds{$loc}} == -1;
  827.         # see if a summary file is available
  828.         my %summary = RepositorySummary("location" => $loc);
  829.         if (%summary) {
  830.             foreach $package (keys %{$summary{$loc}}) {
  831.                 next if (defined $searchtag && $summary{$loc}{$package}{$searchtag} !~ /$searchRE/);
  832.                 next if (!defined $searchtag && defined $searchRE && $package !~ /$searchRE/);
  833.                 $packages{$loc}{$package} = \%{$summary{$loc}{$package}};
  834.             }
  835.         }
  836.         else {
  837.             # No summary: oh my, nothing but 'Net
  838.             foreach $package (@{$ppds{$loc}}) {
  839.                 my %package_details = RepositoryPackageProperties("package" => $package, "location" => $loc);
  840.                 next unless %package_details;
  841.                 next if (defined $searchtag && $package_details{$searchtag} !~ /$searchRE/);
  842.                 next if (!defined $searchtag && defined $searchRE && $package !~ /$searchRE/);
  843.                 $packages{$loc}{$package} = \%package_details;
  844.             }
  845.         }
  846.     }
  847.     return %packages;
  848. }
  849.  
  850. sub verify_packages
  851. {
  852.     my (%argv) = @_;
  853.     my ($arg, @packages, $upgrade);
  854.     local $location = $location;
  855.     foreach $arg (keys %argv) {
  856.         if ($arg eq 'packages') { @packages = @{$argv{$arg}}; }
  857.         if ($arg eq 'location') { $location = $argv{$arg}; }
  858.         if ($arg eq 'upgrade') { $upgrade = $argv{$arg}; }
  859.     }
  860.     my ($package);
  861.  
  862.     if (!defined $packages[0]) {
  863.         my ($i, %info);
  864.  
  865.         @packages = ();
  866.         %info = QueryInstalledPackages();
  867.         foreach $i (keys %info) {
  868.             push @packages, $i;
  869.         }
  870.     }
  871.  
  872.     $package = shift @packages;
  873.  
  874.     # for each specified package
  875.     while ($package) {
  876.         my $status = VerifyPackage("package" => $package, "location" => $location, "upgrade" => $upgrade);
  877.         if (defined $status) {
  878.             if ($status eq "0") {
  879.                 print "Package \'$package\' is up to date.\n";
  880.             }
  881.             elsif ($upgrade) {
  882.                 print "Package $package upgraded to version $status\n";
  883.             }
  884.             else {
  885.                 print "An upgrade to package \'$package\' is available.\n";
  886.             }
  887.         }
  888.         else {
  889.             print "Error verifying $package: $PPM::PPMERR\n";
  890.         }
  891.         $package = shift @packages;
  892.     }
  893. }
  894.  
  895. sub genconfig
  896. {
  897. my $PerlDir = $Config{'prefix'};
  898. print <<"EOF";
  899. <PPMCONFIG>
  900.     <PPMVER>1,1,0,0</PPMVER>
  901.     <PLATFORM CPU="x86" OSVALUE="MSWin32" OSVERSION="4,0,0,0" />
  902.     <OPTIONS BUILDDIR="$ENV{'TEMP'}" CLEAN="Yes" CONFIRM="Yes" FORCEINSTALL="Yes" IGNORECASE="No" MORE="0" ROOT="$PerlDir" TRACE="0" TRACEFILE="PPM.LOG" VERBOSE="1" />
  903.     <REPOSITORY LOCATION="http://www.activestate.com/packages/" NAME="ActiveState Package Repository" SUMMARYFILE="package.lst" />
  904.     <PPMPRECIOUS>PPM;Archive-Tar;Compress-Zlib;libwww-perl;XML-Parser;XML-Element;MIME-Base64;HTML-Parser;libwin32</PPMPRECIOUS>
  905.  
  906. <PACKAGE NAME="PPM">
  907. <LOCATION>http://www.activestate.com/packages</LOCATION>
  908. <INSTPACKLIST>$PerlDir/lib/auto/PPM/.packlist</INSTPACKLIST>
  909. <INSTROOT>$PerlDir</INSTROOT>
  910. <INSTDATE>Fri Oct  2 16:14:32 1998</INSTDATE>
  911. <INSTPPD>
  912. <SOFTPKG NAME="PPM" VERSION="1,1,0,0">
  913. <TITLE>PPM</TITLE>
  914. <ABSTRACT>Perl Package Manager: locate, install, upgrade software packages.</ABSTRACT>
  915. <AUTHOR>Murray Nesbitt <murray\@ActiveState.co></AUTHOR>
  916. <IMPLEMENTATION>
  917. <DEPENDENCY NAME="Compress-Zlib" VERSION="" />
  918. <DEPENDENCY NAME="libwww-perl" VERSION="" />
  919. <DEPENDENCY NAME="Archive-Tar" VERSION="" />
  920. <DEPENDENCY NAME="MIME-Base64" VERSION="" />
  921. <DEPENDENCY NAME="XML-Parser" VERSION="" />
  922. <DEPENDENCY NAME="XML-Element" VERSION="" />
  923. <CODEBASE HREF="x86/PPM.tar.gz" />
  924. <INSTALL />
  925. <UNINSTALL />
  926. </IMPLEMENTATION>
  927. </SOFTPKG>
  928. </INSTPPD>
  929. </PACKAGE>
  930.  
  931. <PACKAGE NAME="Archive-Tar">
  932. <LOCATION>http://www.activestate.com/packages</LOCATION>
  933. <INSTPACKLIST>$PerlDir/site/lib/auto/Archive/Tar/.packlist</INSTPACKLIST>
  934. <INSTROOT>$PerlDir</INSTROOT>
  935. <INSTDATE>Fri Oct  2 16:14:37 1998</INSTDATE>
  936. <INSTPPD>
  937. <SOFTPKG NAME="Archive-Tar" VERSION="0,072,0,0">
  938. <TITLE>Archive-Tar</TITLE>
  939. <ABSTRACT>module for manipulation of tar archives.</ABSTRACT>
  940. <AUTHOR>Stephen Zander <gibreel\@pobox.com></AUTHOR>
  941. <IMPLEMENTATION>
  942. <CODEBASE HREF="x86/Archive-Tar.tar.gz" />
  943. <INSTALL />
  944. <UNINSTALL />
  945. </IMPLEMENTATION>
  946. </SOFTPKG>
  947. </INSTPPD>
  948. </PACKAGE>
  949.  
  950. <PACKAGE NAME="MIME-Base64">
  951. <LOCATION>http://www.ActiveState.com/packages</LOCATION>
  952. <INSTPACKLIST>$PerlDir/site/lib/auto/MIME/Base64/.packlist</INSTPACKLIST>
  953. <INSTROOT>$PerlDir</INSTROOT>
  954. <INSTDATE>Fri Nov 13 14:05:30 1998</INSTDATE>
  955. <INSTPPD>
  956. <SOFTPKG NAME="MIME-Base64" VERSION="2,11,0,0">
  957. <TITLE>MIME-Base64</TITLE>
  958. <ABSTRACT>Encoding and decoding of base64 strings</ABSTRACT>
  959. <AUTHOR>Gisle Aas <gisle\@aas.no></AUTHOR>
  960. <IMPLEMENTATION>
  961. <CODEBASE HREF="x86/MIME-Base64.tar.gz" />
  962. <INSTALL />
  963. <UNINSTALL />
  964. </IMPLEMENTATION>
  965. </SOFTPKG>
  966. </INSTPPD>
  967. </PACKAGE>
  968.  
  969. <PACKAGE NAME="URI">
  970. <LOCATION>http://www.activestate.com/packages</LOCATION>
  971. <INSTPACKLIST>$PerlDir/site/lib/auto/URI/.packlist</INSTPACKLIST>
  972. <INSTROOT>$PerlDir</INSTROOT>
  973. <INSTDATE>Fri Oct  2 16:15:15 1998</INSTDATE>
  974. <INSTPPD>
  975. <SOFTPKG NAME="URI" VERSION="5,42,0,0">
  976. <TITLE>URI</TITLE>
  977. <ABSTRACT>Uniform Resource Identifiers (absolute and relative)</ABSTRACT>
  978. <AUTHOR>Gisle Aas <gisle\@aas.no></AUTHOR>
  979. <IMPLEMENTATION>
  980. <DEPENDENCY NAME="MIME-Base64" VERSION="" />
  981. <CODEBASE HREF="x86/URI.tar.gz" />
  982. <INSTALL />
  983. <UNINSTALL />
  984. </IMPLEMENTATION>
  985. </SOFTPKG>
  986. </INSTPPD>
  987. </PACKAGE>
  988.  
  989. <PACKAGE NAME="HTML-Parser">
  990. <LOCATION>http://www.activestate.com/packages</LOCATION>
  991. <INSTPACKLIST>$PerlDir/site/lib/auto/HTML/Parser/.packlist</INSTPACKLIST>
  992. <INSTROOT>$PerlDir</INSTROOT>
  993. <INSTDATE>Fri Oct  2 16:15:15 1998</INSTDATE>
  994. <INSTPPD>
  995. <SOFTPKG NAME="HTML-Parser" VERSION="5,42,0,0">
  996. <TITLE>HTML-Parser</TITLE>
  997. <ABSTRACT>SGML parser class</ABSTRACT>
  998. <AUTHOR>Gisle Aas <gisle\@aas.no></AUTHOR>
  999. <IMPLEMENTATION>
  1000. <CODEBASE HREF="x86/HTML-Parser.tar.gz" />
  1001. <INSTALL />
  1002. <UNINSTALL />
  1003. </IMPLEMENTATION>
  1004. </SOFTPKG>
  1005. </INSTPPD>
  1006. </PACKAGE>
  1007.  
  1008. <PACKAGE NAME="libwww-perl">
  1009. <LOCATION>http://www.activestate.com/packages</LOCATION>
  1010. <INSTPACKLIST>$PerlDir/site/lib/auto/LWP/.packlist</INSTPACKLIST>
  1011. <INSTROOT>$PerlDir</INSTROOT>
  1012. <INSTDATE>Fri Oct  2 16:15:15 1998</INSTDATE>
  1013. <INSTPPD>
  1014. <SOFTPKG NAME="libwww-perl" VERSION="5,42,0,0">
  1015. <TITLE>libwww-perl</TITLE>
  1016. <ABSTRACT>Library for WWW access in Perl</ABSTRACT>
  1017. <AUTHOR>Gisle Aas  <gisle\@aas.no></AUTHOR>
  1018. <IMPLEMENTATION>
  1019. <DEPENDENCY NAME="URI" VERSION="" />
  1020. <DEPENDENCY NAME="HTML-Parser" VERSION="" />
  1021. <CODEBASE HREF="x86/libwww-perl.tar.gz" />
  1022. <INSTALL />
  1023. <UNINSTALL />
  1024. </IMPLEMENTATION>
  1025. </SOFTPKG>
  1026. </INSTPPD>
  1027. </PACKAGE>
  1028.  
  1029. <PACKAGE NAME="XML-Element">
  1030. <LOCATION>http://www.activestate.com/packages</LOCATION>
  1031. <INSTPACKLIST>$PerlDir/site/lib/auto/XML/Element/.packlist</INSTPACKLIST>
  1032. <INSTROOT>$PerlDir</INSTROOT>
  1033. <INSTDATE>Fri Oct  2 16:16:03 1998</INSTDATE>
  1034. <INSTPPD>
  1035. <SOFTPKG NAME="XML-Element" VERSION="0,10,0,0">
  1036. <TITLE>XML-Element</TITLE>
  1037. <ABSTRACT>Base element class for XML elements</ABSTRACT>
  1038. <AUTHOR>ActiveState Tool Corporation</AUTHOR>
  1039. <IMPLEMENTATION>
  1040. <DEPENDENCY NAME="XML-Parser" VERSION="" />
  1041. <CODEBASE HREF="x86/XML-Element.tar.gz" />
  1042. <INSTALL />
  1043. <UNINSTALL />
  1044. </IMPLEMENTATION>
  1045. </SOFTPKG>
  1046. </INSTPPD>
  1047. </PACKAGE>
  1048.  
  1049. <PACKAGE NAME="XML-Parser">
  1050. <LOCATION>http://www.activestate.com/packages</LOCATION>
  1051. <INSTPACKLIST>$PerlDir/site/lib/auto/XML/Parser/.packlist</INSTPACKLIST>
  1052. <INSTROOT>$PerlDir</INSTROOT>
  1053. <INSTDATE>Fri Oct  2 16:16:03 1998</INSTDATE>
  1054. <INSTPPD>
  1055. <SOFTPKG NAME="XML-Parser" VERSION="2,22,0,0">
  1056. <TITLE>XML-Parser</TITLE>
  1057. <ABSTRACT>A Perl module for parsing XML documents</ABSTRACT>
  1058. <AUTHOR>Clark Cooper <coopercl\@sch.ge.com></AUTHOR>
  1059. <IMPLEMENTATION>
  1060. <CODEBASE HREF="x86/XML-Parser.tar.gz" />
  1061. <INSTALL />
  1062. <UNINSTALL />
  1063. </IMPLEMENTATION>
  1064. </SOFTPKG>
  1065. </INSTPPD>
  1066. </PACKAGE>
  1067.  
  1068. <PACKAGE NAME="Compress-Zlib">
  1069. <LOCATION>http://www.activestate.com/packages</LOCATION>
  1070. <INSTPACKLIST>$PerlDir/site/lib/auto/Compress/Zlib/.packlist</INSTPACKLIST>
  1071. <INSTROOT>$PerlDir</INSTROOT>
  1072. <INSTDATE>Fri Oct  2 16:16:03 1998</INSTDATE>
  1073. <INSTPPD>
  1074. <SOFTPKG NAME="Compress-Zlib" VERSION="1,03,0,0">
  1075. <TITLE>Compress-Zlib</TITLE>
  1076. <ABSTRACT>Interface to zlib compression library</ABSTRACT>
  1077. <AUTHOR>Paul Marquess <pmarquess\@bfsec.bt.co.uk></AUTHOR>
  1078. <IMPLEMENTATION>
  1079. <CODEBASE HREF="x86/Compress-Zlib.tar.gz" />
  1080. <INSTALL />
  1081. <UNINSTALL />
  1082. </IMPLEMENTATION>
  1083. </SOFTPKG>
  1084. </INSTPPD>
  1085. </PACKAGE>
  1086.  
  1087. <PACKAGE NAME="libwin32">
  1088. <LOCATION>http://www.activestate.com/packages</LOCATION>
  1089. <INSTPACKLIST>$PerlDir/site/lib/auto/Win32/.packlist</INSTPACKLIST>
  1090. <INSTROOT>$PerlDir</INSTROOT>
  1091. <INSTDATE>Fri Oct  2 16:16:03 1998</INSTDATE>
  1092. <INSTPPD>
  1093. <SOFTPKG NAME="libwin32" VERSION="0,14,1,0">
  1094. <TITLE>libwin32</TITLE>
  1095. <ABSTRACT>Win32-only extensions that provides a quick migration path for people wanting to use the core support for win32 in perl 5.004 and later.</ABSTRACT>
  1096. <AUTHOR>Gurusamy Sarathy <gsar\@activestate.com></AUTHOR>
  1097. <IMPLEMENTATION>
  1098. <CODEBASE HREF="x86/libwin32.tar.gz" />
  1099. <INSTALL />
  1100. <UNINSTALL />
  1101. </IMPLEMENTATION>
  1102. </SOFTPKG>
  1103. </INSTPPD>
  1104. </PACKAGE>
  1105.  
  1106. </PPMCONFIG>
  1107. EOF
  1108. }
  1109.  
  1110. __END__
  1111.  
  1112. =head1 NAME
  1113.  
  1114. PPM - Perl Package Manager: locate, install, upgrade software packages.
  1115.  
  1116. =head1 SYNOPSIS
  1117.  
  1118.  ppm genconfig
  1119.  ppm help [command]
  1120.  ppm install [--location=location] package1 [... packageN]
  1121.  ppm query [--case|nocase] [--searchtag=abstract|author|title] PATTERN
  1122.  ppm remove package1 [... packageN]
  1123.  ppm search [--case|nocase] [--location=location] [--searchtag=abstract|author|title] PATTERN
  1124.  ppm set [option]
  1125.  ppm verify [--location=location] [--upgrade] [package1 ... packageN]
  1126.  ppm version
  1127.  ppm [--location=location]
  1128.  
  1129. =head1 DESCRIPTION
  1130.  
  1131. ppm is a utility intended to simplify the tasks of locating, installing,
  1132. upgrading and removing software packages.  It is a front-end to the
  1133. functionality provided in PPM.pm.  It can determine if the most recent
  1134. version of a software package is installed on a system, and can install
  1135. or upgrade that package from a local or remote host.
  1136.  
  1137. ppm runs in one of two modes: an interactive shell from which commands
  1138. may be entered; and command-line mode, in which one specific action is
  1139. performed per invocation of the program.
  1140.  
  1141. ppm uses files containing an extended form of the Open Software
  1142. Description (OSD) specification for information about software packages.
  1143. These description files, which are written in Extensible Markup
  1144. Language (XML) code, are referred to as 'PPD' files.  Information about
  1145. OSD can be found at the W3C web site (at the time of this writing,
  1146. http://www.w3.org/TR/NOTE-OSD.html).  The extensions to OSD used by ppm
  1147. are documented in PPM.ppd.
  1148.  
  1149. =head1 COMMAND-LINE MODE
  1150.  
  1151. =over 4
  1152.  
  1153. =item Installing
  1154.  
  1155. ppm install [--location=location] package1 [... packageN]
  1156.  
  1157. Reads information from the PPD file (See the 'Files' section
  1158. below) for the named software package and performs an
  1159. installation.  The 'package' arguments may be either package
  1160. names ('foo'), or pathnames (P:\PACKAGES\FOO.PPD) or URLs
  1161. (HTTP://www.ActiveState.com/packages/foo.ppd) to specific PPD files.
  1162.  
  1163. In the case where a package name is specified, and the '--location'
  1164. option is not used, the function will refer to repository locations stored
  1165. in the PPM data file (see 'Files' section below) to locate the PPD file
  1166. for the requested package.
  1167.  
  1168. =item Removing
  1169.  
  1170. ppm remove package1 [... packageN]
  1171.  
  1172. Reads information from the PPD file for the named software package and
  1173. removes the package from the system.
  1174.  
  1175. =item Verifying
  1176.  
  1177. ppm verify [--location=location] [--upgrade] [package1 ... packageN]
  1178.  
  1179. Reads a PPD file for the specified package and compares the currently
  1180. installed version of the package to the version available according to
  1181. the PPD.  The PPD file is expected to be on a local directory or remote
  1182. site specified either in the PPM data file or on the command
  1183. line using the '--location' option.  The --location' argument may be
  1184. a directory location or an Internet address.  The '--upgrade' option
  1185. forces an upgrade if the installed package is not up-to-date.
  1186.  
  1187. If no packages are specified, all packages currently installed on the
  1188. system will be verified (and updated if desired).  The PPD file for each
  1189. package will initially be searched for at the location specified with the
  1190. '--location' argument, and if not found will then be searched for using
  1191. the location specified in the PPM data file.
  1192.  
  1193. =item Querying
  1194.  
  1195. ppm query [--case|nocase] PATTERN
  1196.  
  1197. Reports currently installed packages matching 'PATTERN' or all installed
  1198. packages if no 'PATTERN' is specified.
  1199.  
  1200. ppm query [--case|nocase] [--searchtag=abstract|author|title] PATTERN
  1201.  
  1202. Searches for 'PATTERN' (a regular expression) in the <ABSTRACT>, <AUTHOR>
  1203. or <TITLE> tags of all installed packages, according to the value of
  1204. the '--searchtag' option.  If a '--searchtag' value of 'abstract',
  1205. 'author' or 'title' is not provided, any occurence of 'PATTERN' in the
  1206. package name will match successfully.  A case-sensitive search will be
  1207. conducted by default, but this may be overridden by the options set in
  1208. the PPM data file, which may in turn be overridden by the '--nocase' or
  1209. '--case' option.  If a search is successful, information about the 
  1210. matching package(s) is displayed.
  1211.  
  1212. =item Searching
  1213.  
  1214. ppm search [--case|nocase] [--location=location] PATTERN
  1215.  
  1216. Displays a list of all packages matching 'PATTERN', with package
  1217. description (PPD) files available at the specified location.  'location'
  1218. may be either a remote address or a directory path.  If a location is
  1219. not specified, the repository location as specified in the PPM data file
  1220. will be used.
  1221.  
  1222. ppm search [--case|nocase] [--location=location] [--searchtag=abstract|author|title] PATTERN
  1223.  
  1224. Searches for 'PATTERN' (a regular expression) in the <ABSTRACT>, <AUTHOR>
  1225. or <TITLE> tags of all PPD files at 'location', according to the value
  1226. of the '--searchtag' option.  If a '--searchtag' value of 'abstract',
  1227. 'author' or 'title' is not provided, any occurence of 'PATTERN' in
  1228. the package name will match successfully.  'location' may be either a
  1229. remote address or a directory path, and if it is not provided, repository
  1230. locations specified in the PPM data file will be used.  A case-sensitive
  1231. search will be conducted by default, but this may be overridden by the
  1232. options set in the PPM data file, which may in turn be overridden by the
  1233. '--nocase' or '--case' option.  If a search is successful, information 
  1234. about the matching package(s) is displayed.
  1235.  
  1236. =item Summarizing
  1237.  
  1238. =item Error Recovery
  1239.  
  1240. ppm genconfig
  1241.  
  1242. This command will print a valid PPM config file (ppm.xml) to STDOUT.  This 
  1243. can be useful if the PPM config file ever gets damaged leaving PPM
  1244. unusable.
  1245.  
  1246. =back
  1247.  
  1248. =head1 INTERACTIVE MODE
  1249.  
  1250. If ppm is invoked with no command specified, it is started in interactive
  1251. mode.  If the '--location' argument is specified, it is used as the
  1252. search location, otherwise the repositories specified in the PPM data file are 
  1253. used. The available commands, which may be displayed at any time by entering
  1254. 'help', are:
  1255.  
  1256.     exit
  1257.         - Exits the program.
  1258.  
  1259.     help [command]
  1260.         - Prints a screen of available commands, or help on a specific command.
  1261.  
  1262.     install [/location LOCATION] PACKAGES
  1263.         - Installs the specified software PACKAGES.  Attempts to install
  1264.           from the URL or directory 'LOCATION' if the '/location' option
  1265.           is specfied.  See 'Installing' in the 'Command-line mode' 
  1266.           section for details.  See also: 'confirm' option.
  1267.  
  1268.     query [options] PATTERN
  1269.         - Queries information about currently installed packages.
  1270.  
  1271.         Available options:
  1272.         /abstract PATTERN
  1273.             - Searches for the regular expression 'PATTERN' in the 'abstract' section
  1274.               of all installed packages.  See also: 'case' option.
  1275.         /author PATTERN
  1276.             - Searches for the regular expression 'PATTERN' in the 'author' section
  1277.               of all installed packages.  See also: 'case' option.
  1278.         /title PATTERN
  1279.             - Searches for the regular expression 'PATTERN' in the 'title' section
  1280.               of all installed packages.  See also: 'case' option.
  1281.  
  1282.     remove PACKAGES
  1283.         - Removes the specified 'PACKAGES'.  See 'Removing' in the 'Command-line 
  1284.           mode' section for details.  See also: 'confirm' option.
  1285.  
  1286.     search [options] PATTERN
  1287.         - Searches for information about available packages.
  1288.  
  1289.         Available options:
  1290.         /abstract PATTERN
  1291.             - Searches for the regular expression 'PATTERN' in the 'abstract' section
  1292.               of all available PPD files.  See also: 'case' option.
  1293.         /author PATTERN
  1294.             - Searches for the regular expression 'PATTERN' in the 'author' section
  1295.               of all available PPD files.  See also: 'case' option.
  1296.         /title PATTERN
  1297.             - Searches for the regular expression 'PATTERN' in the 'title' section
  1298.               of all available PPD files.  See also: 'case' option.
  1299.         /location LOCATION
  1300.             - Searches for packages available from the URL or directory
  1301.               'LOCATION'.
  1302.  
  1303.     set [option value]
  1304.         - Sets or displays current options.  With no arguments, options are
  1305.           displayed.
  1306.  
  1307.           Available options:
  1308.               build DIRECTORY
  1309.                   - Changes the package build directory.
  1310.               case [Yes|No]
  1311.                   - Sets case-sensitive searches.  If one of 'Yes' or 'No is
  1312.                     not specified, the current setting is toggled.
  1313.               clean [Yes|No]
  1314.                   - Sets removal of temporary files from package's build 
  1315.                     area, on successful installation of a package.  If one of
  1316.                     'Yes' or 'No is not specified, the current setting is
  1317.                     toggled.
  1318.               confirm [Yes|No]
  1319.                   - Sets confirmation of 'install', 'remove' and 'upgrade'.
  1320.                     If one of 'Yes' or 'No is not specified, the current
  1321.                     setting is toggled.
  1322.               force_install [Yes|No]
  1323.                   - Continue installing a package even if a dependency cannot
  1324.                     be installed.
  1325.               more NUMBER
  1326.                   - Causes output to pause after NUMBER lines have been
  1327.                     displayed.  Specifying '0' turns off this capability.
  1328.               set repository /remove NAME
  1329.                   - Removes the repository 'NAME' from the list of repositories.
  1330.               set repository NAME LOCATION
  1331.                   - Adds a repository to the list of PPD repositories for this
  1332.                     session.  'NAME' is the name by which this repository will
  1333.                     be referred; 'LOCATION' is a URL or directory name.
  1334.               root DIRECTORY
  1335.                   - Changes the install root directory.  Packages will be
  1336.                     installed under this new root.
  1337.               save
  1338.                   - Saves the current options as default options for future
  1339.                     sessions.
  1340.               trace
  1341.                   - Tracing level--default is 1, maximum is 4, 0 indicates
  1342.                     no tracing.
  1343.               tracefile
  1344.                   - File to contain tracing information, default is 'PPM.LOG'.
  1345.               verbose [Yes|No]
  1346.                   - Display additional package information for 'query' and
  1347.                     'search' commands.
  1348.  
  1349.     quit
  1350.         - Exits the program.
  1351.  
  1352.     verify [/upgrade] [/location LOCATION] PACKAGE
  1353.         - Verifies that currently installed 'PACKAGE' is up to date.  If
  1354.           'PACKAGE' is not specified, all installed packages are verified.  If
  1355.           the /upgrade option is specified, any out-dated packages will be
  1356.           upgraded.  If the /location option is specified, upgrades will
  1357.           be looked for at the URL or directory 'LOCATION'.  See also: 'confirm'
  1358.           option.
  1359.  
  1360. =over 4
  1361.  
  1362. =back
  1363.  
  1364. =head1 EXAMPLES
  1365.  
  1366. =over 4
  1367.  
  1368. =item ppm
  1369.  
  1370. Starts ppm in interactive mode, using the repository locations specified
  1371. in the PPM data file.  A session might look like this:
  1372.  
  1373.     [show all available packages]
  1374.     PPM> search
  1375.     Packages available from P:\PACKAGES:
  1376.     bar [2.91 ] supplies bar methods for perl5.
  1377.     bax [0.072] module for manipulation of bax archives.
  1378.     baz [1.03 ] Interface to baz library
  1379.     foo [2.23 ] Foo parser class
  1380.     
  1381.     [list what has already been installed]
  1382.     PPM> query
  1383.     bax [0.071] module for manipulation of bax archives.
  1384.     baz [1.02 ] Interface to baz library
  1385.     
  1386.     [install a package]
  1387.     PPM> install foo
  1388.     Install package foo? (y/N): y
  1389.     [...]
  1390.     
  1391.     [toggle confirmations]
  1392.     PPM> set confirm
  1393.     Commands will not be confirmed.
  1394.     
  1395.     [see if 'baz' is up-to-date]
  1396.     PPM> verify baz
  1397.     An upgrade to package 'baz' is available.
  1398.     
  1399.     [upgrade 'baz']
  1400.     PPM> verify /upgrade baz
  1401.     [...]
  1402.     
  1403.     [toggle case-sensitive searches]
  1404.     PPM> set case
  1405.     Case-sensitive searches will be performed.
  1406.     
  1407.     [display all available packages beginning with 'b']
  1408.     PPM> search ^b
  1409.     bar [2.91 ] supplies bar methods for perl5.
  1410.     bax [0.072] module for manipulation of bax archives.
  1411.     baz [1.03 ] Interface to baz library
  1412.     
  1413.     [search for installed packages containing 'baz' in the /ABSTRACT tag]
  1414.     PPM> query /abstract baz
  1415.     Matching packages found at P:\PACKAGES:
  1416.     baz [1.03 ] Interface to baz library
  1417.     PPM> quit
  1418.  
  1419. =item ppm install http://www.ActiveState.com/packages/foo.ppd
  1420.  
  1421. Installs the software package 'foo' based on the information in the PPD
  1422. obtained from the specified URL.
  1423.  
  1424. =item ppm verify --upgrade foo
  1425.  
  1426. Compares the currently installed version of the software package 'foo'
  1427. to the one available according to the PPD obtained from the location
  1428. specified for this package in the PPM data file, and upgrades
  1429. to a newer version if available.
  1430.  
  1431. =item ppm verify --location=P:\PACKAGES --upgrade foo
  1432.  
  1433. Compares the currently installed version of the software package 'foo'
  1434. to the one available according to the PPD obtained from the specified
  1435. directory, and upgrades to a newer version if available.
  1436.  
  1437. =item ppm verify --upgrade
  1438.  
  1439. Verifies and updates every installed package on the system, using upgrade
  1440. locations specified in the PPM data file.
  1441.  
  1442. =item ppm search --location=http://www.ActiveState.com/packages
  1443.  
  1444. Displays the packages with PPD files available at the specified location.
  1445.  
  1446. =item ppm search --location=P:\PACKAGES --searchtag=author ActiveState
  1447.  
  1448. Searches the specified location for any package with an <AUTHOR> tag
  1449. containing the string 'ActiveState'.  On a successful search, the package
  1450. name and the matching string are displayed.
  1451.  
  1452. =back
  1453.  
  1454. =head1 ENVIRONMENT VARIABLES
  1455.  
  1456. =over 4
  1457.  
  1458. =item HTTP_proxy
  1459.  
  1460. If the environment variable 'HTTP_proxy' is set, then it will
  1461. be used as the address of a proxy server for accessing the Internet.
  1462.  
  1463. The value should be of the form: 'http://proxy:port'.
  1464.  
  1465. =back
  1466.  
  1467. =head1 FILES
  1468.  
  1469. These files are fully described in the 'Files' section of PPM:ppm.
  1470.  
  1471. =over 4
  1472.  
  1473. =item package.ppd
  1474.  
  1475. A description of a software package, in extended Open Software Description
  1476. (OSD) format.  More information on this file format can be found in
  1477. PPM::ppd.
  1478.  
  1479. =item ppm.xml - PPM data file.
  1480.  
  1481. This file is specified using the environment variable 'PPM_DAT';  if this
  1482. is not set, the file 'ppm.xml' is expected to be located in the same 
  1483. directory as this script.
  1484.  
  1485. An XML format file containing information about the local system,
  1486. specifics regarding the locations from which PPM obtains PPD files, and
  1487. the installation details for any package installed by ppm.
  1488.  
  1489. =back
  1490.  
  1491. =head1 AUTHOR
  1492.  
  1493. Murray Nesbitt, E<lt>F<murray@activestate.com>E<gt>
  1494.  
  1495. =cut
  1496.  
  1497.