1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
|
#!/usr/bin/perl
use Getopt::Long;
use File::Basename;
use Config;
use strict;
use PPM;
$PPM::VERSION = '0.01_01';
my %help;
# mapping of POD sections to command topics
my %topic = (
'Error Recovery' => 'genconfig',
'Installing' => 'install',
'Querying' => 'query',
'Removing' => 'remove',
'Searching' => 'search',
'Summarizing' => 'summary',
'Verifying' => 'verify',
'Synopsis' => 'usage',
'Options' => 'set',
);
$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.
version - displays PPM version number
EOT
# Build the rest of the online help from the POD
$/ = "\n=";
while (<DATA>) {
next unless my ($topic,$text) = /^(?:item|head[12]) ([^\n]+)\n\n(.*)=/s;
next unless $topic{$topic};
($help{$topic{$topic}} = "\n$text"); # =~ s/\n *([^\n])/\n $1/sg;
}
$/ = "\n";
# Need to do this here, because the user's config file is probably
# hosed.
if ($#ARGV == 0 && $ARGV[0] eq 'genconfig') {
&genconfig;
exit 0;
}
if ($#ARGV == 0 && $ARGV[0] eq 'getconfig') {
print $PPM::PPMdat;
exit 0;
}
my %options = PPM::GetPPMOptions();
my $location;
my $moremsg = "[Press return to continue or 'q' to quit] ";
my $interactive = 0;
my %repositories = PPM::ListOfRepositories();
my $prefix_pattern = $^O eq "MSWin32" ? '(--|-|\+|/)' : '(--|-|\+)';
$PPM::PPMShell = 1;
Getopt::Long::Configure("prefix_pattern=$prefix_pattern");
if ($#ARGV == -1 || ($#ARGV == 0 && $ARGV[0] =~ /^${prefix_pattern}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+//;
@ARGV = split(/\s+/, $_);
next unless @ARGV;
# exit/quit
if (command($ARGV[0], "qu|it") or command($ARGV[0], "|exit")) {
print "Quit!\n";
last;
}
exec_command();
}
exit 0;
}
exit exec_command();
sub exec_command
{
my $cmd = lc shift @ARGV;
for (@ARGV) {
s/::/-/g;
}
# help
if (command($cmd, "|help")) {
help(@ARGV);
}
# query
elsif (command($cmd, "qu|ery")) {
GetOptions("case!" => \my $case, "abstract" => \my $abstract,
"author" => \my $author );
my %summary = InstalledPackageProperties();
if (@ARGV) {
my $searchtag;
if ($abstract || $author) {
$searchtag = ($abstract ? 'ABSTRACT' : 'AUTHOR');
}
my $RE = shift @ARGV;
eval { $RE =~ /$RE/ };
if ($@) {
print "'$RE': invalid regular expression.\n";
return 1;
}
$case = !$options{'IGNORECASE'} unless defined $case;
$RE = "(?i)$RE" if ($case == 0);
foreach(keys %summary) {
if ($searchtag) {
delete $summary{$_} unless $summary{$_}{$searchtag} =~ /$RE/;
}
else {
delete $summary{$_} unless /$RE/;
}
}
}
print_formatted(1, %summary);
}
# install
elsif (command($cmd, "in|stall")) {
my $location = $location;
GetOptions("location=s" => \$location);
unless (@ARGV) {
if (!$interactive && -d "blib" && -f "Makefile") {
return if InstallPackage(location => $location);
print "Error installing blib: $PPM::PPMERR\n";
return 1;
}
print "Package not specified.\n";
return 1;
}
my %installed = InstalledPackageProperties();
foreach my $package (@ARGV) {
$package =~ s/::/-/g;
if (my $pkg = (grep {/^$package$/i} keys %installed)[0]) {
my $version = $installed{$pkg}{'VERSION'};
$version =~ s/(,0)*$//;
$version =~ tr/,/./;
print "Version $version of '$pkg' is already installed.\n" .
"Remove it, or use 'verify --upgrade $pkg'.\n";
next;
}
elsif ($interactive && $options{'CONFIRM'}) {
print "Install package '$package?' (y/N): ";
next unless <> =~ /^[yY]/;
}
print "Installing package '$package'...\n";
if(!InstallPackage("package" => $package, "location" => $location)) {
print "Error installing package '$package': $PPM::PPMERR\n";
}
}
}
# remove
elsif (command($cmd, "|remove")) {
unless (@ARGV) {
print "Package not specified.\n";
return 1;
}
foreach my $package (@ARGV) {
$package =~ s/::/-/g;
if ($interactive && $options{'CONFIRM'}) {
print "Remove package '$package?' (y/N): ";
next unless <> =~ /[yY]/;
}
unless (RemovePackage("package" => $package)) {
print "Error removing $package: $PPM::PPMERR\n";
}
}
}
# search
elsif (command($cmd, "se|arch")) {
my (%summary, $searchtag);
my $location = $location;
GetOptions("case!" => \my $case, "location=s" => \$location,
"abstract" => \my $abstract, "author" => \my $author );
my $searchRE = shift @ARGV;
if (defined $searchRE) {
eval { $searchRE =~ /$searchRE/ };
if ($@) {
print "'$searchRE': invalid regular expression.\n";
return 1;
}
}
$case = !$options{'IGNORECASE'} unless defined $case;
if ($abstract || $author) {
$searchtag = ($abstract ? 'ABSTRACT' : 'AUTHOR');
}
%summary = search_PPDs("location" => $location, "ignorecase" => !$case,
"searchtag" => $searchtag, "searchRE" => $searchRE);
foreach (keys %summary) {
print "Packages available from $_:\n";
print_formatted(2, %{$summary{$_}});
}
}
# set
elsif (command($cmd, "se|t")) {
unless (set(@ARGV) || $interactive) {
PPM::SetPPMOptions("options" => \%options, "save" => 1);
}
}
# verify
elsif (command($cmd, "ver|ify")) {
my $location = $location;
GetOptions("force" => \my $force, "location=s" => \$location,
"upgrade" => \my $upgrade);
if ($interactive && $upgrade && $options{'CONFIRM'}) {
printf "Upgrade package%s? (y/N): ", @ARGV == 1 ? " '$ARGV[0]'" : "s";
return unless <> =~ /^[yY]/;
}
verify_packages("packages" => \@ARGV, "location" => $location,
"upgrade" => $upgrade, "force" => $force);
}
elsif (command($cmd, "ver|sion")) {
print "$PPM::VERSION\n";
}
elsif ($cmd eq "purge") {
my %summary = InstalledPackageProperties();
foreach(keys %summary) {
print "Purging $_\n";
RemovePackage("package" => $_, "force" => 1);
}
}
elsif ($cmd eq 'refresh') {
my %summary = InstalledPackageProperties();
foreach(keys %summary) {
print "Refreshing $_\n";
InstallPackage("package" => $_);
}
}
else {
print "Unknown or ambiguous command '$cmd'; type 'help' for commands.\n";
}
}
sub help {
my $topic = @_ && $help{lc $_[0]} ? lc $_[0] : 'help';
my $help = $help{$topic};
$help =~ s/^(\s*)ppm\s+/$1/mg if $interactive;
print $help;
}
sub more
{
my ($lines) = shift @_;
if (++$$lines >= $options{'MORE'}) {
print $moremsg;
$_ = <>;
$$lines = $_ eq "q\n" ? -1 : 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);
if ($pattern[1]) {
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 $options{'VERBOSE'} is set.
sub print_formatted
{
my ($lines, %summary) = @_;
my $package;
unless ($options{'VERBOSE'}) {
foreach $package (sort keys %summary) {
print "$package\n";
&more(\$lines) if $options{'MORE'} && $interactive;
last if $lines == -1;
}
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) {
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 $options{'MORE'} && $interactive;
last if $lines == -1;
}
}
sub set
{
my $option = lc shift @_;
unless ($option) {
print "Commands will " . ($options{'CONFIRM'} ? "" : "not ") .
"be confirmed.\n";
print "Temporary files will " . ($options{'CLEAN'} ? "" : "not ") .
"be deleted.\n";
print "Download status will " . (($options{'DOWNLOADSTATUS'} > 0) ?
"be updated every $options{'DOWNLOADSTATUS'} bytes.\n" :
"not be updated.\n");
print "Case-" . ($options{'IGNORECASE'} ? "in" : "") .
"sensitive searches will be performed.\n";
print "Package installations will " .
($options{'FORCE_INSTALL'} ? "" : "not ") .
"continue if a dependency cannot be installed.\n";
print "Tracing info will " . (($options{'TRACE'} > 0 ) ?
"be written to '$options{'TRACEFILE'}'.\n" : "not be written.\n");
print "Screens will " . ($options{'MORE'} > 0 ?
"pause after $options{'MORE'} lines.\n" : "not pause.\n");
print "Query/search results will " .
($options{'VERBOSE'} ? "" : "not ") . "be verbose.\n";
if (defined $location) { print "Current PPD repository: $location\n"; }
else {
print "Current PPD repository paths:\n";
foreach $_ (keys %repositories) {
print "\t$_: $repositories{$_}\n";
}
}
print "Packages will be installed under: $options{'ROOT'}\n"
if ($options{'ROOT'});
print "Packages will be built under: $options{'BUILDDIR'}\n"
if ($options{'BUILDDIR'});
return;
}
my $value = shift @_;
if (command($option, "r|epository")) {
if ($value =~ /${prefix_pattern}remove/i) {
$value = join(" ", @_);
print "Location not specified.\n" and return 1
unless (defined $value);
PPM::RemoveRepository("repository" => $value);
%repositories = PPM::ListOfRepositories();
}
else {
my $location = shift @_;
print "Repository not specified.\n" and return 1
unless (defined $value and defined $location);
PPM::AddRepository("repository" => $value,
"location" => $location);
%repositories = PPM::ListOfRepositories();
}
}
else {
if (command($option, "c|onfirm")) {
$options{'CONFIRM'} = defined $value ?
($value != 0) : ($options{'CONFIRM'} ? 0 : 1);
print "Commands will " . ($options{'CONFIRM'} ? "" : "not ") .
"be confirmed.\n";
}
elsif (command($option, "|save")) {
PPM::SetPPMOptions("options" => \%options, "save" => 1);
return 0;
}
elsif (command($option, "c|ase")) {
$options{'IGNORECASE'} = defined $value ?
($value == 0) : ($options{'IGNORECASE'} ? 0 : 1);
print "Case-" . ($options{'IGNORECASE'} ? "in" : "") .
"sensitive searches will be performed.\n";
}
elsif (command($option, "r|oot")) {
my $old_root;
print "Directory not specified.\n" and return 1 unless ($value);
print "$PPM::PPMERR" and return 1
unless ($old_root = PPM::chroot("location" => $value));
$options{'ROOT'} = $value;
print "Root is now $value [was $old_root].\n";
}
elsif (command($option, "|build")) {
print "Directory not specified.\n" and return 1 unless ($value);
print "Directory '$value' does not exist.\n" and return 1
unless (-d $value);
$options{'BUILDDIR'} = $value;
print "Build directory is now $value.\n";
}
elsif (command($option, "|force_install")) {
$options{'FORCE_INSTALL'} = defined $value ? ($value != 0) :
($options{'FORCE_INSTALL'} ? 0 : 1);
print "Package installations will " .
($options{'FORCE_INSTALL'} ? "" : "not ") .
"continue if a dependency cannot be installed.\n";
}
elsif (command($option, "c|lean")) {
$options{'CLEAN'} = defined $value ?
($value != 0) : ($options{'CLEAN'} ? 0 : 1);
print "Temporary files will " . ($options{'CLEAN'} ? "" : "not ") .
"be deleted.\n";
}
elsif (command($option, "|downloadstatus")) {
print "Numeric value must be given.\n" and return 1
unless (defined $value && $value =~ /^\d+$/);
$options{'DOWNLOADSTATUS'} = $value;
print "Download status will " . (($options{'DOWNLOADSTATUS'} > 0) ?
"be updated every $options{'DOWNLOADSTATUS'} bytes.\n" :
"not be updated.\n");
}
elsif (command($option, "|more")) {
print "Numeric value must be given.\n" and return 1
unless (defined $value && $value =~ /^\d+$/);
$options{'MORE'} = $value;
print "Screens will " . ($options{'MORE'} > 0 ?
"pause after $options{'MORE'} lines.\n" : "not pause.\n");
}
elsif (command($option, "trace|file")) {
print "Filename not specified.\n" and return 1 unless ($value);
$options{'TRACEFILE'} = $value;
print "Tracing info will be written to $options{'TRACEFILE'}.\n";
}
elsif (command($option, "trace")) {
print "Numeric value between 0 and 4 must be given.\n" and return 1
unless (defined $value &&
$value =~ /^\d+$/ && $value >= 0 && $value <= 4);
$options{'TRACE'} = $value;
print "Tracing info will " . ($options{'TRACE'} > 0 ?
"be written to $options{'TRACEFILE'}.\n" : "not be written.\n");
}
elsif (command($option, "|verbose")) {
$options{'VERBOSE'} = defined $value ?
($value != 0) : ($options{'VERBOSE'} ? 0 : 1);
print "Query/search results will " .
($options{'VERBOSE'} ? "" : "not ") . "be verbose.\n";
}
else {
print "Unknown or ambiguous option '$option'; see 'help set' for available options.\n";
return 1;
}
PPM::SetPPMOptions("options" => \%options);
}
return;
}
sub search_PPDs
{
my %argv = @_;
my @locations = $argv{'location'} || $location;
my $searchtag = $argv{'searchtag'};
my $ignorecase = defined $argv{'ignorecase'} ?
$argv{'ignorecase'} : $options{'IGNORECASE'};
my $searchRE = $argv{'searchRE'};
if (defined $searchRE) {
eval { $searchRE =~ /$searchRE/ };
if ($@) {
print "'$searchRE': invalid regular expression.\n";
return;
}
$searchRE = "(?i)$searchRE" if $ignorecase;
}
my %packages;
unless (defined $locations[0]) {
my %reps = PPM::ListOfRepositories;
@locations = values %reps;
}
foreach my $loc (@locations) {
my %summary;
# see if the repository has server-side searching
if (defined $searchRE && (%summary = ServerSearch('location' => $loc,
'searchRE' => $searchRE, 'searchtag' => $searchtag))) {
# XXX: clean this up
foreach my $package (keys %{$summary{$loc}}) {
$packages{$loc}{$package} = \%{$summary{$loc}{$package}};
}
next;
}
# see if a summary file is available
%summary = RepositorySummary("location" => $loc);
if (%summary) {
foreach my $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 {
my %ppds = PPM::RepositoryPackages("location" => $loc);
# No summary: oh my, nothing but 'Net
foreach my $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 @packages = @{$argv{'packages'}};
my $upgrade = $argv{'upgrade'};
my $force = $argv{'force'};
my $location = $argv{'location'} || $location;
unless ($packages[0]) {
my %info = QueryInstalledPackages();
@packages = sort keys %info;
}
my $package = shift @packages;
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 {
# Couldn't find a PPD to compare it with.
print "Package \'$package\' is up to date.\n";
}
$package = shift @packages;
}
}
sub genconfig
{
my $repositories =
{'5.6' => {
'ActiveState' =>
{location => 'http://ppm.ActiveState.com/cgibin/PPM/ppmserver.pl?urn:/PPMServer',
summaryfile => 'fetch_summary',
},
'Bribes' =>
{location => 'http://www.bribes.org/perl/ppm',
summaryfile => 'searchsummary.ppm',
},
'UWinnipeg' =>
{location => 'http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer',
summaryfile => 'fetch_summary',
},
},
'5.8' => {
'ActiveState' =>
{location => 'http://ppm.activestate.com/PPMPackages/5.8-windows',
summaryfile => 'searchsummary.ppm',
},
'Bribes' =>
{location => 'http://www.bribes.org/perl/ppm',
summaryfile => 'searchsummary.ppm',
},
'UWinnipeg' =>
{location => 'http://theoryx5.uwinnipeg.ca/ppms',
summaryfile => 'searchsummary.ppm',
},
'Trouchelle' =>
{location => 'http://trouchelle.com/ppm',
summaryfile => 'searchsummary.ppm',
},
},
'5.10' => {
'ActiveState' =>
{location => 'http://ppm.activestate.com/PPMPackages/5.10-windows',
summaryfile => 'searchsummary.ppm',
},
'Bribes' =>
{location => 'http://www.bribes.org/perl/ppm',
summaryfile => 'searchsummary.ppm',
},
'UWinnipeg' =>
{location => 'http://cpan.uwinnipeg.ca/PPMPackages/10xx',
summaryfile => 'searchsummary.ppm',
},
'Trouchelle' =>
{location => 'http://trouchelle.com/ppm10',
summaryfile => 'package.xml',
},
},
};
my ($perl_version);
PERLV: {
($] < 5.008) and do {
$perl_version = '5.6';
last PERLV;
};
($] < 5.01) and do {
$perl_version = '5.8';
last PERLV;
};
$perl_version = '5.10';
}
my $reps = $repositories->{$perl_version};
my $PerlDir = $Config{'prefix'};
print <<"EOF";
<PPMCONFIG>
<PPMVER>2,1,8,0</PPMVER>
<PLATFORM CPU="x86" OSVALUE="$Config{'osname'}" OSVERSION="0,0,0,0" />
<OPTIONS BUILDDIR="$ENV{'TEMP'}" CLEAN="1" CONFIRM="1" DOWNLOADSTATUS="16384" FORCEINSTALL="1" IGNORECASE="1" MORE="0" ROOT="$PerlDir" TRACE="0" TRACEFILE="PPM.LOG" VERBOSE="1" />
EOF
foreach my $name(sort keys %$reps) {
my $loc = $reps->{$name}->{location};
my $sf = $reps->{$name}->{summaryfile};
print << "EOF";
<REPOSITORY LOCATION="$loc" NAME="$name" SUMMARYFILE="$sf" />
EOF
}
print <<"EOF";
<PPMPRECIOUS>Compress-Zlib;Archive-Tar;Digest-MD5;File-CounterFile;Font-AFM;HTML-Parser;HTML-Tree;MIME-Base64;URI;XML-Element;libwww-perl;XML-Parser;SOAP-Lite;PPM;libnet;libwin32</PPMPRECIOUS>
</PPMCONFIG>
EOF
}
__DATA__
=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] [--abstract|author] PATTERN
ppm remove package1 [... packageN]
ppm search [--case|nocase] [--location=location] [--abstract|author] 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 Using PPM
=over 4
=item 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 syntax of PPM commands is the same in interactive mode as it is in
command-line mode. The 'help' command lists the available commands.
ppm commands may be abbreviated to their shortest unique form.
=item Installing
ppm install [--location=location] package1 [... packageN]
Installs the specified software packages. Attempts to install from the
URL or directory 'location' if the '--location' option is specfied.
The 'package' arguments may be either package names ('foo'), 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, ppm will refer to the default repository locations.
See also: 'confirm' option.
=item Removing
ppm remove package1 [... packageN]
Reads information from the PPD file for the named software package and
removes the package from the system.
See also: 'confirm' option.
=item Verifying
ppm verify [--location=location] [--upgrade] [--force] [package1 ... packageN]
Verifies that the currently installed packages are up to date. If no
packages are specified as arguments, all installed packages will be verified.
If the '--upgrade' option is specified, any package 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.
If the '--force' option is specified, all currently installed packages will
be reinstalled regardless of whether they are out of date or not.
See also: 'confirm' option.
=item Querying
ppm query [--case|nocase] [--abstract|author] PATTERN
Searches for 'PATTERN' (a regular expression) in the name of any installed
package. If a search is successful, information about the matching
package(s) is displayed. If 'PATTERN' is omitted, information about
all installed packages will be displayed.
If either '--abstract' or '--author' is specified, PATTERN will be
searched for in the <ABSTRACT> or <AUTHOR> tags of the installed packages.
The '--case' and '--nocase' options can be used to override the default
case-sensitivity search settings.
See also: 'case' option.
=item Searching
ppm search [--case|nocase] [--location=location] [--abstract|author] PATTERN
Displays a list of any packages matching 'PATTERN' (a regular expression)
available from the specified location. If 'PATTERN' is omitted, information
about all available packages will be displayed.
If the '--location' option is specified, the specified URL or directory
will be searched. If '--location' is not specified, the repository location
as specified in the PPM data file will be searched.
If either '--abstract' or '--author' is specified, PATTERN will be
searched for in the <ABSTRACT> or <AUTHOR> tags of the available packages.
The '--case' and '--nocase' options can be used to override the default
case-sensitivity search settings.
See also: 'case' option.
=item Error Recovery
ppm genconfig
ppm getconfig
The genconfig 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
The getconfig command prints the location of the PPM configuration file
used at PPM startup.
=item Options
ppm set [option value]
Sets or displays current options. With no arguments, current option
settings are displayed.
Available options:
build DIRECTORY
- Changes the package build directory.
case [1|0]
- Sets case-sensitive searches. If one of '1' or '0' is
not specified, the current setting is toggled.
clean [1|0]
- Sets removal of temporary files from package's build
area, on successful installation of a package. If one of
'1' or '0' is not specified, the current setting is
toggled.
confirm [1|0]
- Sets confirmation of 'install', 'remove' and 'upgrade'.
If one of '1' or '0' is not specified, the current
setting is toggled.
downloadstatus NUMBER
- If non-zero, updates the download status after each NUMBER
of bytes transferred during an 'install'. This can be
reassuring when installing a large package (e.g. Tk) over
a low-speed connection.
force_install [1|0]
- 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 [1|0]
- Display additional package information for 'query' and
'search' commands.
=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://ppm.ActiveState.com/PPMpackages/5.6
Displays the packages with PPD files available at the specified location.
=item ppm search --location=P:\PACKAGES --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
The following 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.
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.
This file usually resides in '[perl]/site/lib'. If the environment
variable 'PPM_DAT' is set, its value will be used as the full pathname
to a PPM data file. If all else fails, ppm will look for a data file
in the current directory.
=back
=head1 AUTHOR
Murray Nesbitt, E<lt>F<murray@cpan.org>E<gt>
=head1 CREDITS
=over 4
=item *
The "geek-pit" at ActiveState.
=item *
Paul Kulchenko for his SOAP-Lite package, and for his enthusiastic
assistance in getting PPM to work with SOAP-Lite.
=back
=cut
|