home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 2000-03-15 | 53.1 KB | 1,505 lines
#!/usr/bin/perl use Getopt::Long; use File::Basename; use Config; use strict; use PPM; $PPM::VERSION = "1.1.3"; my $usage = <<'EOT'; usage: ppm genconfig ppm help [command] ppm install [--location=location] package1 [... packageN] ppm query [--case|nocase] [--searchtag=abstract|author|title] PATTERN ppm remove package1 [... packageN] ppm search [--case|nocase] [--location=location] [--searchtag=abstract|author|title] PATTERN ppm set [option] ppm verify [--location=location] [--upgrade] [--force] [package1 ... packageN] ppm version ppm [--location=location] EOT my %help; $help{'set'} = <<'EOT'; set - Displays current settings. set build DIRECTORY - Changes the package build directory. set case [Yes|No] - Set case-sensitive searches. set clean [Yes|No] - Set removal of temporary files from package's build area following successful installation. set confirm [Yes|No] - Sets confirmation of 'install', 'remove' and 'upgrade'. set force_install [Yes|No] - Continue installing a package if a dependency cannot be installed. set more NUMBER - Pause after displaying 'NUMBER' lines. Specifying '0' turns off paging capability. set repository /remove NAME - Removes the repository 'NAME' from the list of repositories. set repository NAME LOCATION - Adds a repository to the list of PPD repositories for this session. 'NAME' is the name by which this repository will be referred; 'LOCATION' is a URL or directory name. set root DIRECTORY - Changes install root directory for this session. set save - Save current options as defaults. set trace - Tracing level--default is 1, maximum is 4, 0 indicates no tracing. set tracefile - File to contain tracing information, default is 'PPM.LOG'. set verbose [Yes|No] - Display additional package information for 'query' and 'search' commands. EOT # Need to do this here, because the user's config file is probably # hosed. if ($#ARGV == 0 && $ARGV[0] eq 'genconfig') { &genconfig; exit 0; } my %options = PPM::GetPPMOptions(); use vars qw ($location $Ignorecase $clean $confirm $force_install $root $build_dir $more $trace $tracefile $verbose); *Ignorecase = \$options{'IGNORECASE'}; *clean = \$options{'CLEAN'}; *confirm = \$options{'CONFIRM'}; *force_install = \$options{'FORCE_INSTALL'}; *root = \$options{'ROOT'}; *build_dir = \$options{'BUILDDIR'}; *more = \$options{'MORE'}; *trace = \$options{'TRACE'}; *tracefile = \$options{'TRACEFILE'}; *verbose = \$options{'VERBOSE'}; my $moremsg = "[Press return to continue]"; my $interactive = 0; $help{'help'} = <<'EOT'; Commands: exit - leave the program. help [command] - prints this screen, or help on 'command'. install PACKAGES - installs specified PACKAGES. quit - leave the program. query [options] - query information about installed packages. remove PACKAGES - removes the specified PACKAGES from the system. search [options] - search information about available packages. set [options] - set/display current options. verify [options] - verifies current install is up to date. EOT $help{'search'} = <<'EOT'; search [PATTERN] search /abstract [PATTERN] search /author [PATTERN] search /title [PATTERN] search /location LOCATION [PATTERN] Searches for available packages. With no arguments, will display a list of all available packages. If a regular expression 'PATTERN' is supplied, only packages matching the pattern will be displayed. If the '/abstract', '/author' or '/title' argument is specified, the respective field of the package will be searched. If the '/location' option is specified, matching packages from that URL or directory will be listed. EOT $help{'install'} = <<'EOT'; install PACKAGE install /location LOCATION PACKAGE Installs the specified 'PACKAGE' onto the system. If the '/location' option is specified, the package will be looked for at that URL or directory. EOT $help{'remove'} = <<'EOT'; remove PACKAGE Removes the specified 'PACKAGE' from the system. EOT $help{'genconfig'} = <<'EOT'; genconfig This command will print a valid PPM config file (ppm.xml) to STDOUT. This can be useful if the PPM config file ever gets damaged leaving PPM unusable. If required, this command should be run from a shell prompt: C:\Perl\site\lib> ppm genconfig > ppm.xml EOT $help{'query'} = <<'EOT'; query [PATTERN] query /abstract [PATTERN] query /author [PATTERN] query /title [PATTERN] Queries information about installed packages. With no arguments, will display a list of all installed packages. If a regular expression 'PATTERN' is supplied, only packages matching the pattern will be displayed. If the '/abstract', '/author' or '/title' argument is specified, the respective field of the package will be searched. EOT $help{'verify'} = <<'EOT'; verify [packages] verify /upgrade [/force] [packages] verify /location LOCATION [packages] Verifies that the currently installed 'packages' are up to date. If 'packages' is not specified, all installed packages are verified. If the '/upgrade' option is specified, any packages for which an upgrade is available will be upgraded. If the '/location' option is specified, upgrades will be looked for at the specified URL or directory. EOT my %repositories = PPM::ListOfRepositories(); if ($#ARGV == -1 || ($#ARGV == 0 && $ARGV[0] =~ /^--location/)) { my $prompt = 'PPM> '; $interactive = 1; GetOptions("location=s" => \$location); print "PPM interactive shell ($PPM::VERSION) - type 'help' for available commands.\n"; $| = 1; while () { print $prompt; last unless defined ($_ = <> ); chomp; s/^\s+//; my @line = split(/\s+/, $_); my $cmd = shift @line; next if /^$/; # exit/quit if (command($cmd, "qu|it") or command($cmd, "|exit")) { print "Quit!\n"; last; } # help elsif (command($cmd, "|help")) { if (defined $line[0] && $help{$line[0]}) { print $help{$line[0]}; } else { print $help{'help'}; } } # query elsif (command($cmd, "qu|ery")) { my $package; my %summary = InstalledPackageProperties(); if (defined $line[0]) { my $searchtag; if ($line[0] =~ /^\/(abstract|author|title)$/i) { $searchtag = uc $1; shift @line; } my $RE = shift @line; eval { $RE =~ /$RE/ }; if ($@) { print "'$RE': invalid regular expression.\n"; next; } $RE = "(?i)$RE" if $Ignorecase eq "Yes"; foreach(keys %summary) { if (defined $searchtag) { delete $summary{$_} unless $summary{$_}{$searchtag} =~ /$RE/; } else { delete $summary{$_} unless /$RE/; } } } print_formatted(1, %summary); } # install elsif (command($cmd, "in|stall")) { my $package; local $location = $location; if (defined $line[0]) { if ($line[0] =~ /^\/location$/i) { shift @line; $location = shift @line; } } if (!@line) { print "Package not specified.\n"; next; } foreach $package (@line) { $package =~ s/::/-/g; if ($confirm eq "Yes") { print "Install package \'$package?\' (y/N): "; next if (<> ne "y\n"); } print "Retrieving package \'$package\'...\n"; if(!InstallPackage("package" => $package, "location" => $location)) { print "Error installing package '$package': $PPM::PPMERR\n"; } } } # remove elsif (command($cmd, "|remove")) { my $package; if (!@line) { print "Package not specified.\n"; next; } foreach $package (@line) { if ($confirm eq "Yes") { print "Remove package \'$package?\' (y/N): "; next if (<> ne "y\n"); } if (!RemovePackage("package" => $package)) { print "Error removing $package: $PPM::PPMERR\n"; } } } # search elsif (command($cmd, "se|arch")) { my ($package, %summary, $searchtag); local $location = $location; while (defined $line[0]) { if ($line[0] =~ /^\/(abstract|author|title)$/i) { $searchtag = uc $1; shift @line; } elsif ($line[0] =~ /^\/location$/i) { shift @line; $location = shift @line; } else { last; } } my $searchRE = $line[0]; %summary = search_PPDs("location" => $location, "searchtag" => $searchtag, "searchRE" => $searchRE, "ignorecase" => $Ignorecase); foreach (keys %summary) { print "Packages available from $_:\n"; print_formatted(2, %{$summary{$_}}); } } # set elsif (command($cmd, "se|t")) { set(@line); } # verify elsif (command($cmd, "|verify")) { my $upgrade; my $force; local $location = $location; while (defined $line[0]) { if ($line[0] =~ /^\/upgrade$/i) { $upgrade = 1; shift @line; next; } if ($line[0] =~ /^\/force$/i) { $force = 1; shift @line; next; } if ($line[0] =~ /^\/location$/i) { shift @line; $location = shift @line; next; } last; } if ($upgrade && $confirm eq "Yes") { print "Upgrade package" . ($#line == 0 ? " $line[0]" : "s") . "? (y/N): "; next if (<> ne "y\n"); } verify_packages("packages" => \@line, "location" => $location, "upgrade" => $upgrade, "force" => $force); } else { print "Unknown or ambiguous command '$cmd'; type 'help' for commands.\n"; } } } elsif ($ARGV[0] eq 'help') { $help{'install'} = <<'EOT'; install [--location=location] PACKAGE Installs the specified 'PACKAGE' onto the system. If 'location' is not specified, the default locations in the PPM data file will be used to locate the package. EOT $help{'search'} = <<'EOT'; search [--case|nocase] [--location=location] [PATTERN] search [--case|nocase] [--location=location] --searchtag=abstract [PATTERN] search [--case|nocase] [--location=location] --searchtag=author [PATTERN] search [--case|nocase] [--location=location] --searchtag=title [PATTERN] Searches for available packages. With no arguments, will display a list of all available packages. If a regular expression 'PATTERN' is supplied, only packages matching the pattern will be displayed. If the 'abstract', 'author' or 'title' --searchtag argument is specified, the respective field of the package will be searched. If 'location' is not specified, the repository locations in the PPM data file will be searched. '--case' or '--nocase' may be used to request case-sensitive or case-insensitive searches, respectively. EOT $help{'query'} = <<'EOT'; query [PATTERN] query [--case|nocase] --searchtag=abstract [PATTERN] query [--case|nocase] --searchtag=author [PATTERN] query [--case|nocase] --searchtag=title [PATTERN] Queries information about installed packages. With no arguments, will display a list of all installed packages. If a regular expression 'PATTERN' is supplied, only packages matching the pattern will be displayed. If the 'abstract', 'author' or 'title' --searchtag argument is specified, the respective field of the package will be searched. '--case' or '--nocase' may be used to request case-sensitive or case-insensitive searches, respectively. EOT $help{'verify'} = <<'EOT'; verify [--location=location] [packages] verify --upgrade [--force] [--location=location] [packages] Verifies that the currently installed 'packages' are up to date. If 'packages' is not specified, all installed packages are verified. If the '--upgrade' option is specified, any packages for which an upgrade is available will be upgraded. If 'location' is not specified, the repository locations in the PPM data file will be searched. If the '--force' option is specified packages will be reinstalled regardless of whether they are out of date or not. EOT shift; if (defined $ARGV[0] && $help{$ARGV[0]}) { print $help{$ARGV[0]}; } else { print $usage; } } elsif ($ARGV[0] eq 'version') { print $PPM::VERSION; } elsif ($ARGV[0] eq 'set') { shift; if (set(@ARGV) == 0) { PPM::SetPPMOptions("options" => \%options, "save" => 1); } } elsif ($ARGV[0] eq 'install') { my ($package); shift; GetOptions("location=s" => \$location); $package = shift; if (!defined $package && -d "blib" && -f "Makefile") { if(!InstallPackage("location" => $location)) { print "Error installing blib: $PPM::PPMERR\n"; } } while ($package) { $package =~ s/::/-/g; if(!InstallPackage("package" => $package, "location" => $location)) { print "Error installing package '$package': $PPM::PPMERR\n"; } $package = shift; } } elsif ($ARGV[0] eq 'remove') { shift; my $package = shift; while ($package) { if (!RemovePackage("package" => $package)) { print "Error removing $package: $PPM::PPMERR\n"; } $package = shift; } } elsif ($ARGV[0] eq 'verify') { my ($upgrade, $force, $package, @packages); shift; GetOptions("force" => \$force, "location=s" => \$location, "upgrade" => \$upgrade); verify_packages("packages" => \@ARGV, "location" => $location, "upgrade" => $upgrade, "force" => $force); } elsif ($ARGV[0] eq 'query') { my ($case, $nocase, $searchtag, $searchRE, $package); shift; GetOptions("nocase" => \$nocase, "case" => \$case, "searchtag=s" => \$searchtag ); $searchRE = shift; eval { $searchRE =~ /$searchRE/ }; if ($@) { print "'$searchRE': invalid regular expression.\n"; exit 1; } if (!defined $nocase) { if (!defined $case) { $nocase = $Ignorecase; # use the default setting } } if (defined $searchtag) { if (!$searchtag =~ /^(abstract|author|title)$/i) { print $usage; exit 1; } $searchtag = uc $searchtag; } $searchRE = "(?i)$searchRE" if $nocase eq "Yes"; my %summary = InstalledPackageProperties(); foreach(keys %summary) { if ($searchtag) { delete $summary{$_} unless $summary{$_}{$searchtag} =~ /$searchRE/; } else { delete $summary{$_} unless /$searchRE/; } } print_formatted(1, %summary); } elsif ($ARGV[0] eq 'search') { my ($case, $nocase, $searchtag, $searchRE, %summary); shift; GetOptions("nocase" => \$nocase, "case" => \$case, "location=s" => \$location, "searchtag=s" => \$searchtag ); $searchRE = shift; eval { $searchRE =~ /$searchRE/ }; if ($@) { print "'$searchRE': invalid regular expression.\n"; next; } if (defined $case) { $nocase = "No"; } elsif (defined $nocase) { $nocase = "Yes"; } else { $nocase = $Ignorecase; } if (defined $searchtag) { if ($searchtag !~ /^(abstract|author|title)$/i) { print $usage; exit 1; } $searchtag = uc $searchtag; } %summary = search_PPDs("location" => $location, "searchtag" => $searchtag, "searchRE" => $searchRE, "ignorecase" => $nocase); foreach (keys %summary) { print "Packages available from $_:\n"; print_formatted(2, %{$summary{$_}}); } } else { print $usage; exit 1; } exit 0; sub more { my ($lines) = shift @_; if (++$$lines >= $more) { print $moremsg; $_ = <>; $$lines = 1; } } # This nasty piece of business splits $pattern into a required prefix # and a "match any of this substring" suffix. E.g. "in|stall" will # match a $cmd of "ins", "inst", ..., "install". sub command { my ($cmd, $pattern) = @_; my @pattern = split(/\|/, $pattern); my @optchars = split(//, $pattern[1]); # build up a "foo(b|ba|bar)" string $pattern = "$pattern[0]("; $pattern[1] = shift @optchars; $pattern[1] .= "|$pattern[1]$_" foreach @optchars; $pattern .= "$pattern[1])"; return ($cmd =~ /^${pattern}$/i); } # This routine prints the output for query and search # in a nicely formatted way, if $verbose is set. sub print_formatted { my ($lines, %summary) = @_; my $package; if (!$verbose) { foreach $package (sort keys %summary) { print "$package\n"; &more(\$lines) if $more; } return; } my ($maxname, $maxversion) = (0, 0); # find the longest package name and version strings, so we can # format them nicely $maxname < length($_) and $maxname = length($_) for keys %summary; foreach $package (keys %summary) { $summary{$package}{'VERSION'} =~ s/(,0)*$//; $summary{$package}{'VERSION'} =~ tr/,/./; $maxversion = length $summary{$package}{'VERSION'} > $maxversion ? length $summary{$package}{'VERSION'} : $maxversion; } my $columns = $ENV{COLUMNS} ? $ENV{COLUMNS} : 80; my $namefield = "@" . "<" x ($maxname - 1); my $versionfield = "@" . "<" x ($maxversion - 1); my $abstractfield = "^" . "<" x ($columns - (6 + $maxname + $maxversion)); my $abstractpad = " " x ($maxname + $maxversion + 3); foreach $package (sort keys %summary) { # Avoid "Format STDOUT redefined..." warning in Perl 5.6 no warnings; eval "format STDOUT = \n" . "$namefield [$versionfield] $abstractfield\n" . '$package, $summary{$package}{VERSION}, $summary{$package}{ABSTRACT}' . "\n" . "$abstractpad $abstractfield~~\n" . '$summary{$package}{ABSTRACT}' . "\n" . ".\n"; my $diff = $-; write; $diff -= $-; $lines += ($diff - 1) if $diff > 1; &more(\$lines) if $more; } } sub set { my ($option) = shift @_; my $rc = 0; if (defined $option) { my ($value) = shift @_; if (command($option, "r|epository")) { if ($value =~ /\/remove/i) { $value = shift @_; while (@_) { $value .= " " . shift @_; } if (!defined $value) { print "Location not specified.\n"; $rc = 1; } else { PPM::RemoveRepository("repository" => $value); %repositories = PPM::ListOfRepositories(); } } else { my $location = shift @_; if (!defined $value || !defined $location) { print "Repository not specified.\n"; $rc = 1; } else { PPM::AddRepository("repository" => $value, "location" => $location); %repositories = PPM::ListOfRepositories(); } } } else { if (command($option, "c|onfirm")) { if (defined $value) { if ($value =~ /^Yes$/) { $confirm = $value; } elsif ($value =~ /^No$/) { $confirm = $value; } else { print "Value must be 'Yes' or 'No'.\n"; $rc = 1; return $rc; } } else { $confirm = $confirm eq "Yes" ? "No" : "Yes"; } print "Commands will " . ($confirm eq "Yes" ? "" : "not ") . "be confirmed.\n"; } elsif (command($option, "|save")) { PPM::SetPPMOptions("options" => \%options, "save" => 1); return $rc; } elsif (command($option, "c|ase")) { if (defined $value) { # N.B. These are reversed. if ($value =~ /^Yes$/) { $Ignorecase = "No"; } elsif ($value =~ /^No$/) { $Ignorecase = "Yes"; } else { print "Value must be 'Yes' or 'No'.\n"; $rc = 1; return $rc; } } else { $Ignorecase = $Ignorecase eq "Yes" ? "No" : "Yes"; } print "Case-" . ($Ignorecase eq "Yes" ? "in" : "") . "sensitive searches will be performed.\n"; } elsif (command($option, "r|oot")) { my $old_root; if (!defined $value) { print "Directory not specified.\n"; $rc = 1; } elsif(!($old_root = PPM::chroot("location" => $value))) { print "$PPM::PPMERR"; $rc = 1; } else { $root = $value; print "Root is now $value [was $old_root].\n"; } } elsif (command($option, "|build")) { if (!defined $value) { print "Directory not specified.\n"; $rc = 1; } elsif (-d $value) { $build_dir = $value; print "Build directory is now $value.\n"; } else { print "Directory '$value' does not exist.\n"; $rc = 1; } } elsif (command($option, "|force_install")) { if (defined $value) { if ($value =~ /^Yes$/) { $force_install = $value; } elsif ($value =~ /^No$/) { $force_install = $value; } else { print "Value must be 'Yes' or 'No'.\n"; $rc = 1; return $rc; } } else { $force_install = $force_install eq "Yes" ? "No" : "Yes"; } print "Package installations will " . ($force_install eq "Yes" ? "" : "not ") . "continue if a dependency cannot be installed.\n"; } elsif (command($option, "c|lean")) { if (defined $value) { if ($value =~ /^Yes$/) { $clean = $value; } elsif ($value =~ /^No$/) { $clean = $value; } else { print "Value must be 'Yes' or 'No'.\n"; $rc = 1; return $rc; } } else { $clean = $clean eq "Yes" ? "No" : "Yes"; } print "Temporary files will " . ($clean eq "Yes" ? "" : "not ") . "be deleted.\n"; } elsif (command($option, "|more")) { if (defined $value && $value =~ /^\d+$/) { $more = $value; } else { print "Numeric value must be given.\n"; $rc = 1; return $rc; } print "Screens will " . ($more > 0 ? "pause after $more lines.\n" : "not pause.\n"); } elsif (command($option, "trace|file")) { if (!defined $value) { print "Filename not specified.\n"; $rc = 1; } $tracefile = $value; print "Tracing info will be written to $tracefile.\n"; } elsif (command($option, "trace")) { if (defined $value && $value =~ /^\d+$/ && $value >= 0 && $value <= 4) { $trace = $value; } else { print "Numeric value between 0 and 4 must be given.\n"; $rc = 1; return $rc; } print "Tracing info will " . ($trace > 0 ? "be written to $tracefile.\n" : "not be written.\n"); } elsif (command($option, "|verbose")) { if (defined $value) { if ($value =~ /^(Yes|1)$/i) { $verbose = 1; } elsif ($value =~ /^(No|0)$/i) { $verbose = 0; } else { print "Invalid setting: must be 'Yes/No' or '1/0'.\n"; $rc = 1; return $rc; } } else { $verbose = $verbose eq "1" ? "0" : "1"; } print "Query/search results will " . ($verbose ? "" : "not ") . "be verbose.\n"; } else { print "Unknown or ambiguous option '$option'; see 'help set' for available options.\n"; $rc = 1; } if (!$rc) { PPM::SetPPMOptions("options" => \%options); } } } else { print "Commands will " . ($confirm eq "Yes" ? "" : "not ") . "be confirmed.\n"; print "Temporary files will " . ($clean eq "Yes" ? "" : "not ") . "be deleted.\n"; print "Case-" . ($Ignorecase eq "Yes" ? "in" : "") . "sensitive searches will be performed.\n"; print "Package installations will " . ($force_install eq "Yes" ? "" : "not ") . "continue if a dependency cannot be installed.\n"; print "Tracing info will " . (($trace && $trace > 0 )? "be written to '$tracefile'.\n" : "not be written.\n"); print "Screens will " . ($more > 0 ? "pause after $more lines.\n" : "not pause.\n"); print "Query/search results will " . ($verbose ? "" : "not ") . "be verbose.\n"; if (defined $location) { print "Current PPD repository: $location\n"; } else { print "Current PPD repository paths:\n"; my $location; foreach $_ (keys %repositories) { print "\t$_: $repositories{$_}\n"; } } if (defined $root) { print "Packages will be installed under: $root\n"; } if (defined $build_dir) { print "Packages will be built under: $build_dir\n"; } } return $rc; } sub search_PPDs { my (%argv) = @_; my (%packages, $arg, $ignorecase, $searchtag, $searchRE); local $location = $location; foreach $arg (keys %argv) { if ($arg eq 'location') { $location = $argv{$arg}; } if ($arg eq 'searchtag') { $searchtag = $argv{$arg}; } if ($arg eq 'ignorecase') { $ignorecase = $argv{$arg}; } if ($arg eq 'searchRE' && defined $argv{$arg}) { $searchRE = $argv{$arg}; eval { $searchRE =~ /$searchRE/ }; if ($@) { print "'$searchRE': invalid regular expression.\n"; return; } $searchRE = "(?i)$searchRE" if $ignorecase eq "Yes"; } } if (!defined $ignorecase) { $ignorecase = $Ignorecase; } my (%ppds, $loc, $package); %ppds = PPM::RepositoryPackages("location" => $location); foreach $loc (keys %ppds) { next if $#{$ppds{$loc}} == -1; # see if a summary file is available my %summary = RepositorySummary("location" => $loc); if (%summary) { foreach $package (keys %{$summary{$loc}}) { next if (defined $searchtag && $summary{$loc}{$package}{$searchtag} !~ /$searchRE/); next if (!defined $searchtag && defined $searchRE && $package !~ /$searchRE/); $packages{$loc}{$package} = \%{$summary{$loc}{$package}}; } } else { # No summary: oh my, nothing but 'Net foreach $package (@{$ppds{$loc}}) { my %package_details = RepositoryPackageProperties("package" => $package, "location" => $loc); next unless %package_details; next if (defined $searchtag && $package_details{$searchtag} !~ /$searchRE/); next if (!defined $searchtag && defined $searchRE && $package !~ /$searchRE/); $packages{$loc}{$package} = \%package_details; } } } return %packages; } sub verify_packages { my (%argv) = @_; my ($arg, @packages, $upgrade, $force); local $location = $location; foreach $arg (keys %argv) { if ($arg eq 'packages') { @packages = @{$argv{$arg}}; } if ($arg eq 'location') { $location = $argv{$arg}; } if ($arg eq 'upgrade') { $upgrade = $argv{$arg}; } if ($arg eq 'force') { $force = $argv{$arg}; } } my ($package); if (!defined $packages[0]) { my ($i, %info); @packages = (); %info = QueryInstalledPackages(); foreach $i (keys %info) { push @packages, $i; } } $package = shift @packages; # for each specified package while ($package) { my $status = VerifyPackage("package" => $package, "location" => $location, "upgrade" => $upgrade, "force" => $force); if (defined $status) { if ($status eq "0") { print "Package \'$package\' is up to date.\n"; } elsif ($upgrade) { print "Package $package upgraded to version $status\n"; } else { print "An upgrade to package \'$package\' is available.\n"; } } else { print "Error verifying $package: $PPM::PPMERR\n"; } $package = shift @packages; } } sub genconfig { my $PerlDir = $Config{'prefix'}; print <<"EOF"; <PPMCONFIG> <PPMVER>1,1,3,0</PPMVER> <PLATFORM CPU="x86" OSVALUE="$Config{'osname'}" OSVERSION="0,0,0,0" /> <OPTIONS BUILDDIR="$ENV{'TEMP'}" CLEAN="Yes" CONFIRM="Yes" FORCEINSTALL="Yes" IGNORECASE="Yes" MORE="0" ROOT="$PerlDir" TRACE="0" TRACEFILE="PPM.LOG" VERBOSE="1" /> <REPOSITORY LOCATION="soap://www.activestate.com/cgibin/SOAP/ppmserver.plex?class=PPM::SOAPServer" NAME="ActiveState Package Repository" SUMMARYFILE="fetch_summary"/> <PPMPRECIOUS>PPM;Archive-Tar;Compress-Zlib;libwww-perl;XML-Parser;XML-Element;MIME-Base64;HTML-Parser;libwin32</PPMPRECIOUS> <PACKAGE NAME="PPM"> <LOCATION>http://www.activestate.com/packages</LOCATION> <INSTPACKLIST>$PerlDir/lib/auto/PPM/.packlist</INSTPACKLIST> <INSTROOT>$PerlDir</INSTROOT> <INSTDATE>Fri Oct 2 16:14:32 1998</INSTDATE> <INSTPPD> <SOFTPKG NAME="PPM" VERSION="1,1,3,0"> <TITLE>PPM</TITLE> <ABSTRACT>Perl Package Manager: locate, install, upgrade software packages.</ABSTRACT> <AUTHOR>Murray Nesbitt <murray\@ActiveState.co></AUTHOR> <IMPLEMENTATION> <DEPENDENCY NAME="Compress-Zlib" VERSION="" /> <DEPENDENCY NAME="libwww-perl" VERSION="" /> <DEPENDENCY NAME="Archive-Tar" VERSION="" /> <DEPENDENCY NAME="MIME-Base64" VERSION="" /> <DEPENDENCY NAME="XML-Parser" VERSION="" /> <DEPENDENCY NAME="XML-Element" VERSION="" /> <CODEBASE HREF="x86/PPM.tar.gz" /> <INSTALL /> <UNINSTALL /> </IMPLEMENTATION> </SOFTPKG> </INSTPPD> </PACKAGE> <PACKAGE NAME="Archive-Tar"> <LOCATION>http://www.activestate.com/packages</LOCATION> <INSTPACKLIST>$PerlDir/site/lib/auto/Archive/Tar/.packlist</INSTPACKLIST> <INSTROOT>$PerlDir</INSTROOT> <INSTDATE>Fri Oct 2 16:14:37 1998</INSTDATE> <INSTPPD> <SOFTPKG NAME="Archive-Tar" VERSION="0,072,0,0"> <TITLE>Archive-Tar</TITLE> <ABSTRACT>module for manipulation of tar archives.</ABSTRACT> <AUTHOR>Stephen Zander <gibreel\@pobox.com></AUTHOR> <IMPLEMENTATION> <CODEBASE HREF="x86/Archive-Tar.tar.gz" /> <INSTALL /> <UNINSTALL /> </IMPLEMENTATION> </SOFTPKG> </INSTPPD> </PACKAGE> <PACKAGE NAME="MIME-Base64"> <LOCATION>http://www.ActiveState.com/packages</LOCATION> <INSTPACKLIST>$PerlDir/site/lib/auto/MIME/Base64/.packlist</INSTPACKLIST> <INSTROOT>$PerlDir</INSTROOT> <INSTDATE>Fri Nov 13 14:05:30 1998</INSTDATE> <INSTPPD> <SOFTPKG NAME="MIME-Base64" VERSION="2,11,0,0"> <TITLE>MIME-Base64</TITLE> <ABSTRACT>Encoding and decoding of base64 strings</ABSTRACT> <AUTHOR>Gisle Aas <gisle\@aas.no></AUTHOR> <IMPLEMENTATION> <CODEBASE HREF="x86/MIME-Base64.tar.gz" /> <INSTALL /> <UNINSTALL /> </IMPLEMENTATION> </SOFTPKG> </INSTPPD> </PACKAGE> <PACKAGE NAME="URI"> <LOCATION>http://www.activestate.com/packages</LOCATION> <INSTPACKLIST>$PerlDir/site/lib/auto/URI/.packlist</INSTPACKLIST> <INSTROOT>$PerlDir</INSTROOT> <INSTDATE>Fri Oct 2 16:15:15 1998</INSTDATE> <INSTPPD> <SOFTPKG NAME="URI" VERSION="1,04,0,0"> <TITLE>URI</TITLE> <ABSTRACT>Uniform Resource Identifiers (absolute and relative)</ABSTRACT> <AUTHOR>Gisle Aas <gisle\@aas.no></AUTHOR> <IMPLEMENTATION> <DEPENDENCY NAME="MIME-Base64" VERSION="" /> <CODEBASE HREF="x86/URI.tar.gz" /> <INSTALL /> <UNINSTALL /> </IMPLEMENTATION> </SOFTPKG> </INSTPPD> </PACKAGE> <PACKAGE NAME="HTML-Parser"> <LOCATION>http://www.activestate.com/packages</LOCATION> <INSTPACKLIST>$PerlDir/site/lib/auto/HTML/Parser/.packlist</INSTPACKLIST> <INSTROOT>$PerlDir</INSTROOT> <INSTDATE>Fri Oct 2 16:15:15 1998</INSTDATE> <INSTPPD> <SOFTPKG NAME="HTML-Parser" VERSION="2,23,0,0"> <TITLE>HTML-Parser</TITLE> <ABSTRACT>SGML parser class</ABSTRACT> <AUTHOR>Gisle Aas <gisle\@aas.no></AUTHOR> <IMPLEMENTATION> <CODEBASE HREF="x86/HTML-Parser.tar.gz" /> <INSTALL /> <UNINSTALL /> </IMPLEMENTATION> </SOFTPKG> </INSTPPD> </PACKAGE> <PACKAGE NAME="libwww-perl"> <LOCATION>http://www.activestate.com/packages</LOCATION> <INSTPACKLIST>$PerlDir/site/lib/auto/LWP/.packlist</INSTPACKLIST> <INSTROOT>$PerlDir</INSTROOT> <INSTDATE>Fri Oct 2 16:15:15 1998</INSTDATE> <INSTPPD> <SOFTPKG NAME="libwww-perl" VERSION="5,45,0,0"> <TITLE>libwww-perl</TITLE> <ABSTRACT>Library for WWW access in Perl</ABSTRACT> <AUTHOR>Gisle Aas <gisle\@aas.no></AUTHOR> <IMPLEMENTATION> <DEPENDENCY NAME="URI" VERSION="" /> <DEPENDENCY NAME="HTML-Parser" VERSION="" /> <CODEBASE HREF="x86/libwww-perl.tar.gz" /> <INSTALL /> <UNINSTALL /> </IMPLEMENTATION> </SOFTPKG> </INSTPPD> </PACKAGE> <PACKAGE NAME="XML-Element"> <LOCATION>http://www.activestate.com/packages</LOCATION> <INSTPACKLIST>$PerlDir/site/lib/auto/XML/Element/.packlist</INSTPACKLIST> <INSTROOT>$PerlDir</INSTROOT> <INSTDATE>Fri Oct 2 16:16:03 1998</INSTDATE> <INSTPPD> <SOFTPKG NAME="XML-Element" VERSION="0,10,0,0"> <TITLE>XML-Element</TITLE> <ABSTRACT>Base element class for XML elements</ABSTRACT> <AUTHOR>ActiveState Tool Corporation</AUTHOR> <IMPLEMENTATION> <DEPENDENCY NAME="XML-Parser" VERSION="" /> <CODEBASE HREF="x86/XML-Element.tar.gz" /> <INSTALL /> <UNINSTALL /> </IMPLEMENTATION> </SOFTPKG> </INSTPPD> </PACKAGE> <PACKAGE NAME="XML-Parser"> <LOCATION>http://www.activestate.com/packages</LOCATION> <INSTPACKLIST>$PerlDir/site/lib/auto/XML/Parser/.packlist</INSTPACKLIST> <INSTROOT>$PerlDir</INSTROOT> <INSTDATE>Fri Oct 2 16:16:03 1998</INSTDATE> <INSTPPD> <SOFTPKG NAME="XML-Parser" VERSION="2,27,0,0"> <TITLE>XML-Parser</TITLE> <ABSTRACT>A Perl module for parsing XML documents</ABSTRACT> <AUTHOR>Clark Cooper <coopercl\@sch.ge.com></AUTHOR> <IMPLEMENTATION> <CODEBASE HREF="x86/XML-Parser.tar.gz" /> <INSTALL /> <UNINSTALL /> </IMPLEMENTATION> </SOFTPKG> </INSTPPD> </PACKAGE> <PACKAGE NAME="Compress-Zlib"> <LOCATION>http://www.activestate.com/packages</LOCATION> <INSTPACKLIST>$PerlDir/site/lib/auto/Compress/Zlib/.packlist</INSTPACKLIST> <INSTROOT>$PerlDir</INSTROOT> <INSTDATE>Fri Oct 2 16:16:03 1998</INSTDATE> <INSTPPD> <SOFTPKG NAME="Compress-Zlib" VERSION="1,03,0,0"> <TITLE>Compress-Zlib</TITLE> <ABSTRACT>Interface to zlib compression library</ABSTRACT> <AUTHOR>Paul Marquess <pmarquess\@bfsec.bt.co.uk></AUTHOR> <IMPLEMENTATION> <CODEBASE HREF="x86/Compress-Zlib.tar.gz" /> <INSTALL /> <UNINSTALL /> </IMPLEMENTATION> </SOFTPKG> </INSTPPD> </PACKAGE> <PACKAGE NAME="libwin32"> <LOCATION>http://www.activestate.com/packages</LOCATION> <INSTPACKLIST>$PerlDir/site/lib/auto/Win32/.packlist</INSTPACKLIST> <INSTROOT>$PerlDir</INSTROOT> <INSTDATE>Fri Oct 2 16:16:03 1998</INSTDATE> <INSTPPD> <SOFTPKG NAME="libwin32" VERSION="0,15,1,0"> <TITLE>libwin32</TITLE> <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> <AUTHOR>Gurusamy Sarathy <gsar\@activestate.com></AUTHOR> <IMPLEMENTATION> <CODEBASE HREF="x86/libwin32.tar.gz" /> <INSTALL /> <UNINSTALL /> </IMPLEMENTATION> </SOFTPKG> </INSTPPD> </PACKAGE> </PPMCONFIG> EOF } __END__ =head1 NAME PPM - Perl Package Manager: locate, install, upgrade software packages. =head1 SYNOPSIS ppm genconfig ppm help [command] ppm install [--location=location] package1 [... packageN] ppm query [--case|nocase] [--searchtag=abstract|author|title] PATTERN ppm remove package1 [... packageN] ppm search [--case|nocase] [--location=location] [--searchtag=abstract|author|title] PATTERN ppm set [option] ppm verify [--location=location] [--upgrade] [--force] [package1 ... packageN] ppm version ppm [--location=location] =head1 DESCRIPTION ppm is a utility intended to simplify the tasks of locating, installing, upgrading and removing software packages. It is a front-end to the functionality provided in PPM.pm. It can determine if the most recent version of a software package is installed on a system, and can install or upgrade that package from a local or remote host. ppm runs in one of two modes: an interactive shell from which commands may be entered; and command-line mode, in which one specific action is performed per invocation of the program. ppm uses files containing an extended form of the Open Software Description (OSD) specification for information about software packages. These description files, which are written in Extensible Markup Language (XML) code, are referred to as 'PPD' files. Information about OSD can be found at the W3C web site (at the time of this writing, http://www.w3.org/TR/NOTE-OSD.html). The extensions to OSD used by ppm are documented in PPM.ppd. =head1 COMMAND-LINE MODE =over 4 =item Installing ppm install [--location=location] package1 [... packageN] Reads information from the PPD file (See the 'Files' section below) for the named software package and performs an installation. The 'package' arguments may be either package names ('foo'), or pathnames (P:\PACKAGES\FOO.PPD) or URLs (HTTP://www.ActiveState.com/packages/foo.ppd) to specific PPD files. In the case where a package name is specified, and the '--location' option is not used, the function will refer to repository locations stored in the PPM data file (see 'Files' section below) to locate the PPD file for the requested package. =item Removing ppm remove package1 [... packageN] Reads information from the PPD file for the named software package and removes the package from the system. =item Verifying ppm verify [--location=location] [--upgrade] [--force] [package1 ... packageN] Reads a PPD file for the specified package and compares the currently installed version of the package to the version available according to the PPD. The PPD file is expected to be on a local directory or remote site specified either in the PPM data file or on the command line using the '--location' option. The --location' argument may be a directory location or an Internet address. The '--upgrade' option forces an upgrade if the installed package is not up-to-date. If no packages are specified, all packages currently installed on the system will be verified (and updated if desired). The PPD file for each package will initially be searched for at the location specified with the '--location' argument, and if not found will then be searched for using the location specified in the PPM data file. =item Querying ppm query [--case|nocase] PATTERN Reports currently installed packages matching 'PATTERN' or all installed packages if no 'PATTERN' is specified. ppm query [--case|nocase] [--searchtag=abstract|author|title] PATTERN Searches for 'PATTERN' (a regular expression) in the <ABSTRACT>, <AUTHOR> or <TITLE> tags of all installed packages, according to the value of the '--searchtag' option. If a '--searchtag' value of 'abstract', 'author' or 'title' is not provided, any occurence of 'PATTERN' in the package name will match successfully. A case-sensitive search will be conducted by default, but this may be overridden by the options set in the PPM data file, which may in turn be overridden by the '--nocase' or '--case' option. If a search is successful, information about the matching package(s) is displayed. =item Searching ppm search [--case|nocase] [--location=location] PATTERN Displays a list of all packages matching 'PATTERN', with package description (PPD) files available at the specified location. 'location' may be either a remote address or a directory path. If a location is not specified, the repository location as specified in the PPM data file will be used. ppm search [--case|nocase] [--location=location] [--searchtag=abstract|author|title] PATTERN Searches for 'PATTERN' (a regular expression) in the <ABSTRACT>, <AUTHOR> or <TITLE> tags of all PPD files at 'location', according to the value of the '--searchtag' option. If a '--searchtag' value of 'abstract', 'author' or 'title' is not provided, any occurence of 'PATTERN' in the package name will match successfully. 'location' may be either a remote address or a directory path, and if it is not provided, repository locations specified in the PPM data file will be used. A case-sensitive search will be conducted by default, but this may be overridden by the options set in the PPM data file, which may in turn be overridden by the '--nocase' or '--case' option. If a search is successful, information about the matching package(s) is displayed. =item Summarizing =item Error Recovery ppm genconfig This command will print a valid PPM config file (ppm.xml) to STDOUT. This can be useful if the PPM config file ever gets damaged leaving PPM unusable. =back =head1 INTERACTIVE MODE If ppm is invoked with no command specified, it is started in interactive mode. If the '--location' argument is specified, it is used as the search location, otherwise the repositories specified in the PPM data file are used. The available commands, which may be displayed at any time by entering 'help', are: exit - Exits the program. help [command] - Prints a screen of available commands, or help on a specific command. install [/location LOCATION] PACKAGES - Installs the specified software PACKAGES. Attempts to install from the URL or directory 'LOCATION' if the '/location' option is specfied. See 'Installing' in the 'Command-line mode' section for details. See also: 'confirm' option. query [options] PATTERN - Queries information about currently installed packages. Available options: /abstract PATTERN - Searches for the regular expression 'PATTERN' in the 'abstract' section of all installed packages. See also: 'case' option. /author PATTERN - Searches for the regular expression 'PATTERN' in the 'author' section of all installed packages. See also: 'case' option. /title PATTERN - Searches for the regular expression 'PATTERN' in the 'title' section of all installed packages. See also: 'case' option. remove PACKAGES - Removes the specified 'PACKAGES'. See 'Removing' in the 'Command-line mode' section for details. See also: 'confirm' option. search [options] PATTERN - Searches for information about available packages. Available options: /abstract PATTERN - Searches for the regular expression 'PATTERN' in the 'abstract' section of all available PPD files. See also: 'case' option. /author PATTERN - Searches for the regular expression 'PATTERN' in the 'author' section of all available PPD files. See also: 'case' option. /title PATTERN - Searches for the regular expression 'PATTERN' in the 'title' section of all available PPD files. See also: 'case' option. /location LOCATION - Searches for packages available from the URL or directory 'LOCATION'. set [option value] - Sets or displays current options. With no arguments, options are displayed. Available options: build DIRECTORY - Changes the package build directory. case [Yes|No] - Sets case-sensitive searches. If one of 'Yes' or 'No is not specified, the current setting is toggled. clean [Yes|No] - Sets removal of temporary files from package's build area, on successful installation of a package. If one of 'Yes' or 'No is not specified, the current setting is toggled. confirm [Yes|No] - Sets confirmation of 'install', 'remove' and 'upgrade'. If one of 'Yes' or 'No is not specified, the current setting is toggled. force_install [Yes|No] - Continue installing a package even if a dependency cannot be installed. more NUMBER - Causes output to pause after NUMBER lines have been displayed. Specifying '0' turns off this capability. set repository /remove NAME - Removes the repository 'NAME' from the list of repositories. set repository NAME LOCATION - Adds a repository to the list of PPD repositories for this session. 'NAME' is the name by which this repository will be referred; 'LOCATION' is a URL or directory name. root DIRECTORY - Changes the install root directory. Packages will be installed under this new root. save - Saves the current options as default options for future sessions. trace - Tracing level--default is 1, maximum is 4, 0 indicates no tracing. tracefile - File to contain tracing information, default is 'PPM.LOG'. verbose [Yes|No] - Display additional package information for 'query' and 'search' commands. quit - Exits the program. verify [/upgrade] [/force] [/location LOCATION] PACKAGE - Verifies that currently installed 'PACKAGE' is up to date. If 'PACKAGE' is not specified, all installed packages are verified. If the /upgrade option is specified, any out-dated packages will be upgraded. If the /location option is specified, upgrades will be looked for at the URL or directory 'LOCATION'. See also: 'confirm' option. =over 4 =back =head1 EXAMPLES =over 4 =item ppm Starts ppm in interactive mode, using the repository locations specified in the PPM data file. A session might look like this: [show all available packages] PPM> search Packages available from P:\PACKAGES: bar [2.91 ] supplies bar methods for perl5. bax [0.072] module for manipulation of bax archives. baz [1.03 ] Interface to baz library foo [2.23 ] Foo parser class [list what has already been installed] PPM> query bax [0.071] module for manipulation of bax archives. baz [1.02 ] Interface to baz library [install a package] PPM> install foo Install package foo? (y/N): y [...] [toggle confirmations] PPM> set confirm Commands will not be confirmed. [see if 'baz' is up-to-date] PPM> verify baz An upgrade to package 'baz' is available. [upgrade 'baz'] PPM> verify /upgrade baz [...] [forced upgrade of 'baz'] PPM> verify /upgrade /force baz [...] [toggle case-sensitive searches] PPM> set case Case-sensitive searches will be performed. [display all available packages beginning with 'b'] PPM> search ^b bar [2.91 ] supplies bar methods for perl5. bax [0.072] module for manipulation of bax archives. baz [1.03 ] Interface to baz library [search for installed packages containing 'baz' in the /ABSTRACT tag] PPM> query /abstract baz Matching packages found at P:\PACKAGES: baz [1.03 ] Interface to baz library PPM> quit =item ppm install http://www.ActiveState.com/packages/foo.ppd Installs the software package 'foo' based on the information in the PPD obtained from the specified URL. =item ppm verify --upgrade foo Compares the currently installed version of the software package 'foo' to the one available according to the PPD obtained from the location specified for this package in the PPM data file, and upgrades to a newer version if available. =item ppm verify --location=P:\PACKAGES --upgrade foo Compares the currently installed version of the software package 'foo' to the one available according to the PPD obtained from the specified directory, and upgrades to a newer version if available. =item ppm verify --upgrade --force Forces verification and reinstalls every installed package on the system, using upgrade locations specified in the PPM data file. =item ppm search --location=http://www.ActiveState.com/packages Displays the packages with PPD files available at the specified location. =item ppm search --location=P:\PACKAGES --searchtag=author ActiveState Searches the specified location for any package with an <AUTHOR> tag containing the string 'ActiveState'. On a successful search, the package name and the matching string are displayed. =back =head1 ENVIRONMENT VARIABLES =over 4 =item HTTP_proxy If the environment variable 'HTTP_proxy' is set, then it will be used as the address of a proxy server for accessing the Internet. The value should be of the form: 'http://proxy:port'. =back =head1 FILES These files are fully described in the 'Files' section of PPM:ppm. =over 4 =item package.ppd A description of a software package, in extended Open Software Description (OSD) format. More information on this file format can be found in PPM::ppd. =item ppm.xml - PPM data file. This file is specified using the environment variable 'PPM_DAT'; if this is not set, the file 'ppm.xml' is expected to be located in the same directory as this script. An XML format file containing information about the local system, specifics regarding the locations from which PPM obtains PPD files, and the installation details for any package installed by ppm. =back =head1 AUTHOR Murray Nesbitt, E<lt>F<murray@activestate.com>E<gt> =cut