This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
/
configure.pl
1231 lines (1059 loc) · 27.6 KB
/
configure.pl
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
#!/usr/local/bin/perl
#
# configure.pl - Configure the MiniVend program
#
# Version 1.0
# Copyright 1996 by Mike Heins <mikeh@iac.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# This script should be passed the Perl location as an argument,
# but there will be a chance to recover
#$DEBUG = 1;
# Set STDOUT to autoflush
$| = 1;
$Rerun = 0;
my $param;
PARAM: {
my $param = shift || '';
unless($param =~ /^-/) {
$PERL = $param if $param;
}
elsif ($param eq '-i') {
$InstallOnly = 1;
}
elsif ($param eq '-rerun') {
warn "**** Re-running with specified Perl ****\n";
$Rerun = 1;
}
elsif ($param eq '-D') {
warn "**** Setting DEBUG to on ****\n";
$DEBUG = 1;
}
elsif ($param eq '--' or $param eq '') {
# Do nothing
}
else {
warn "Unrecognized parameter $param, ignoring.\a\n"
if $param;
}
last PARAM unless $param;
redo PARAM;
} # PARAM
############### Configurable Variables ######################
#
chop($Initial{'VendRoot'} = `pwd`);
$Initial{'HelpFile'} = 'etc/mvconf.cmt';
#
############## END CONFIGURABLE VARIABLES ###################
sub is_yes {
return( defined($_[0]) && ($_[0] =~ /^[yt1]/i));
}
sub is_no {
return( !defined($_[0]) || ($_[0] =~ /^[nf0]/i));
}
sub do_msg {
my ($msg, $size) = @_;
$size = 60 unless defined $size;
my $len = length $msg;
return "$msg.." if ($len + 2) >= $size;
$msg .= '.' x ($size - $len);
return $msg;
}
sub cp {
my ($srcFile, $dstFile) = @_;
my ($buf,$len);
open (IN,"<$srcFile") or die "Can't open input $srcFile: $!\n";
open (OUT,">$dstFile") or die "Can't open output $dstFile: $!\n";
my ($access,$mod) = (stat IN)[8,9];
$ = 0;
syswrite(OUT, $buf, $len) while $len = sysread(IN, $buf, 8192);
$ = 1;
close IN;
close OUT;
utime $access, $mod, $dstFile;
}
sub regularize {
for (@_) {
s/[\\]\n//g;
s/\n\s+/ /g;
s/\s+$//g;
}
wantarray ? @_ : $_[0];
}
sub dontwarn {
}
sub initconfig {
my $file = shift;
my($status,$key,$val);
open(INITIAL, $file)
|| return undef;
while(<INITIAL>) {
next if /^\s*#/; # Ignore comments
next unless /\S/; # Ignore blanks
chomp;
($key, $value) = split(/[\t =]+/, $_, 2);
$Initial{$key} = $value;
}
close INITIAL;
1;
}
sub can_do_suid {
my $file = 'mytemp.fil';
my $status;
open(TEMPFILE,">$file");
close TEMPFILE;
eval { chmod 04755, $file; $@ = ''};
$status = $@ ? 0 : 1;
unlink $file;
return $status;
}
sub prompt {
my($pr) = shift || '? ';
my($def) = shift;
my($ans);
print $pr;
print "[$def] " if $def;
chop($ans = <STDIN>);
$ans ? $ans : $def;
}
sub install_file_lock {
mkdir('auto', 0755) or die "mkdir auto/: $!\n";
chdir 'src' or die "Source directory src/ not found: $!\n";
system "tar xf File-Lock-0.9.tar";
chdir 'File-Lock-0.9' or die "chdir: $!\n";
my $makemake = <<EOF;
$PERL Makefile.PL INSTALLPRIVLIB=$Initial{'VendRoot'} \
INSTALLARCHLIB=$Initial{'VendRoot'} \
INSTALLSITELIB=$Initial{'VendRoot'} \
INSTALLMAN1DIR=$Initial{'VendRoot'}/doc \
INSTALLMAN3DIR=$Initial{'VendRoot'}/doc \
INSTALLSITEARCH=$Initial{'VendRoot'} \
INSTALLDIRS=perl
EOF
for ($makemake, 'make', 'make test', 'make pure_perl_install') {
system $_;
if($?) {
die "File::Lock make process failed.\n";
return 0;
}
}
chdir '../..' or die "chdir: $!\n";
1;
}
sub adjustvars {
my ($file,%vars) = @_;
my $bak = 'mytemp.fil';
return undef unless $file && defined %vars;
my $check;
my $changed = 0;
my $save = $;
$ = 0;
for(keys %vars) {
$vars{$_} = qq|'$vars{$_}'|
unless int($vars{$_}) eq $vars{$_};
}
$ = $save;
rename $file, $bak;
open(ADJUST_IN,$bak)
|| die "Couldn't open $bak: $!\n";
open(ADJUST_OUT,">$file")
|| die "Couldn't create $file: $!\n";
while(<ADJUST_IN>) {
unless (/^\s*(my\s+)?\$/) {
print ADJUST_OUT $_;
last if /^\s*#+\s+end\s+config/i; # prevent parsing whole file
next;
}
$line = $_;
foreach $var (keys %vars) {
if ($line =~ /^\s*(my\s+)?\$(\w+::)?$var\s*=\s*('?[^']+'?)\s*;/) {
my $my = $1 || '';
my $pkg = $2 || '';
$check = $3 || '';
print "Found $var in $file\n" if $DEBUG;
unless ($check eq $vars{$var}) {
$changed++;
$line = $my . '$' . $pkg . $var . ' = ' . $vars{$var} . ";\n";
print "Adjusted $var in $file\n" if $DEBUG;
}
delete $vars{$var};
}
}
print ADJUST_OUT $line;
unless (scalar keys %vars) {
last;
}
}
if ($changed) {
while(<ADJUST_IN>) {print ADJUST_OUT $_}
close ADJUST_IN;
close ADJUST_OUT;
unlink $bak;
}
else {
close ADJUST_IN;
close ADJUST_OUT;
unlink $file;
rename $bak, $file;
}
! scalar keys %vars;
}
my %ModuleMessage = (
File::Basename => sub {
$msg = <<EOF;
You don't have the File::Basename module, why not? It is included
with every Perl 5 distribution. You should contact your system
administrator and ask them to install Perl properly. It is
included with MiniVend, so it may not be fatal. But don't e
surprised if you can't start the server.
This is a strong warning.
EOF
$msg;
},
Search::Dict => sub {
my $msg = <<EOF;
You don't have the Search::Dict module, why not? It is included
with every Perl 5 distribution. You should contact your system
administrator and ask them to install Perl properly.
It won't cause a problem except you cannot use the dictionary-ordered
fast binary search. MiniVend will crash if you do. An outside person
could even crash it if they knew the right URL to submit.
EOF
$msg;
},
File::CounterFile => sub {
my $msg = <<EOF;
You don't have the File::CounterFile module for some reason. It may
be because you are installing with Perl 5.001, naughty you! You
might want to upgrade.
It won't cause a problem except you cannot use the OrderNumber
directive. Please comment it out of any catalog.cfg file.
EOF
$msg;
},
File::Lock => sub {
if ($Config{'osname'} eq 'solaris') {
warn <<EOF . "\n";
You are running Solaris 2, and you don't have the File::Lock module
installed. This is a show-stopper -- Solaris doesn't support flock(),
and you need this module. The good news is that it is included with
MiniVend. It is also available at any CPAN site -- you can download it
from http://www.perl.com at any time.
MiniVend's attempt to install it apparently failed, so try and install
it manually. See you when you get it.
EOF
}
"";
},
Des => sub {
"You have no Des.pm module, no biggie.\n"
},
generic => sub {
my $msg = <<EOF;
You don't have the $_[0] module, this is normally not fatal.
EOF
$msg;
},
);
sub adjustmodules {
my ($file,@modules) = @_;
my($mod);
my $bak = 'mytemp.fil';
return undef unless $file and @modules;
my $check = '';
my $changed = 0;
rename $file, $bak;
open(ADJUST_IN,$bak)
|| die "Couldn't open $bak: $!\n";
open(ADJUST_OUT,">$file")
|| die "Couldn't create $file: $!\n";
while(<ADJUST_IN>) {
unless (/^\s*#*\s*use\s+/) {
print ADJUST_OUT $_;
last if /^\s*#+\s+end\s+config/i; # prevent parsing whole file
next;
}
$line = $_;
foreach $mod (@modules) {
$found = 0;
if ($line =~ /^\s*#*use\s+$mod\s?;?/ ) {
eval { eval "require $mod" and $found = 1};
print "Found reference to module $mod in $file\n" if $DEBUG;
if (!$found or $@) {
$changed++ if $line =~ s/^(\s*)use/$1#use/;
warn &{$ModuleMessage{$mod}}() . "\n"
if defined $ModuleMessage{$mod};
warn &{$ModuleMessage{'generic'}}($mod) . "\n"
if ! defined $ModuleMessage{$mod};
warn $found ? 'It was found but: ' : 'It was not found: ' .
"\n$@\n" if $DEBUG;
warn join "\n", '@INC was:', @INC, "" if $DEBUG;
}
else {
$changed++ if $line =~ s/^(\s*)#(\s*)(use\s+)/$1$2$3/;
}
$check = $mod;
last;
}
}
@modules = grep ! ($_ eq $check), @modules;
print ADJUST_OUT $line;
unless (@modules) {
last;
}
}
if ($changed) {
while(<ADJUST_IN>) {print ADJUST_OUT $_}
close ADJUST_IN;
close ADJUST_OUT;
unlink $bak;
}
else {
close ADJUST_IN;
close ADJUST_OUT;
unlink $file;
rename $bak, $file;
}
! scalar @modules;
}
sub adjusttext {
my ($file,$newfile,%text) = @_;
my ($done,$origtext,$newtext);
return undef unless
(defined $file) && (defined %text) &&
(defined $newfile);
open(ADJUST_IN,$file)
|| die "Couldn't open $file: $!\n";
open(ADJUST_OUT,">$newfile")
|| die "Couldn't create $newfile: $!\n";
while(<ADJUST_IN>) {
while( ($origtext,$newtext) = each %text) {
if (/$origtext/) {
s/$origtext/$Initial{$newtext}/g;
print "Adjusted '$origtext' to '$Initial{$newtext}' in $file\n"
if $DEBUG;
}
}
print ADJUST_OUT $_;
}
close ADJUST_IN;
close ADJUST_OUT;
1;
}
sub adjustdefs {
my ($file,%defs) = @_;
my $changed = 0;
my $bak = 'mytemp.fil';
return undef unless $file && defined %defs;
my $save = $;
$ = 0;
for(keys %defs) {
$defs{$_} = qq|"$defs{$_}"|
unless int($defs{$_}) eq $defs{$_};
}
$ = $save;
rename $file, $bak;
open(ADJUST_IN,$bak)
|| die "Couldn't open $bak: $!\n";
open(ADJUST_OUT,">$file")
|| die "Couldn't create $file: $!\n";
while(<ADJUST_IN>) {
unless (/^#define/) {
print ADJUST_OUT $_;
next;
}
$line = $_;
foreach $def (keys %defs) {
my $val;
if ($line =~ /^#define(\s+)$def(\s+)(.*)/) {
my $sp1 = $1;
my $sp2 = $2;
my $val = $3;
unless ( $val eq $defs{$def} ) {
$changed++;
$line = '#define' . $sp1 . $def . $sp2 . $defs{$def} . "\n";
print "Adjusted $def in $file\n" if $DEBUG;
}
delete $defs{$def};
}
}
print ADJUST_OUT $line;
unless (scalar keys %defs) {
last;
}
}
if ($changed) {
while(<ADJUST_IN>) {print ADJUST_OUT $_}
close ADJUST_IN;
close ADJUST_OUT;
unlink $bak;
}
else {
close ADJUST_IN;
close ADJUST_OUT;
unlink $file;
rename $bak, $file;
}
! scalar keys %defs;
}
sub shbang {
my $file = shift;
my $perl = shift;
my $changed = 0;
my $bak = 'mytemp.fil';
return undef unless $file && $perl;
rename $file, $bak;
open(ADJUST_IN,$bak)
|| die "Couldn't open $bak: $!\n";
open(ADJUST_OUT,">$file")
|| die "Couldn't create $file: $!\n";
while(<ADJUST_IN>) {
if (/^(#\!\s*)(\S+)/) {
my $precursor = $1;
my $current = $2;
unless ($perl eq $current) {
$changed++;
s/$current/$perl/;
}
}
else {
s/^/'#!' . $perl . "\n"/e;
}
print ADJUST_OUT $_;
last;
}
if ($changed) {
while(<ADJUST_IN>) {print ADJUST_OUT $_}
close ADJUST_IN;
close ADJUST_OUT;
print "Adjusted SHBANG in $file to $perl\n" if $DEBUG;
unlink $bak;
}
else {
close ADJUST_IN;
close ADJUST_OUT;
unlink $file;
rename $bak, $file;
}
1;
}
sub getvendsettings {
my $file = shift;
my($status,$key,$val);
my(%settings);
open(VENDSET, $file)
|| die "Couldn't open $file: $!\n";
while(<VENDSET>) {
next if /^\s*#/; # Ignore comments
next unless /\S/; # Ignore blanks
chomp;
($key, $value) = split(/[\t =]+/, $_, 2);
next unless $key =~ /\S/;
$settings{$key} = $value;
}
close VENDSET;
%settings;
}
sub findexe {
my($exe) = @_;
my($dir,$path) = ('', $ENV{PATH});
$path =~ s/\(\)//g;
$path =~ s/\s+/\s/g;
my(@dirs) = split /[\s:]+/, $path;
foreach $dir (@dirs) {
return "$dir/$exe" if -x "$dir/$exe";
}
return '';
}
sub writeconfig {
my($file) = shift;
my(@keys) = @_;
my($status,$key,$val);
open(WRITECONFIG, ">$file")
|| die "Couldn't write $file: $!, died";
if(grep /^PageDir/, @keys) {
@keys = grep !/^PageDir/, @keys;
unshift @keys, 'PageDir';
}
for(sort @keys) {
warn "Doing $_: Initial=$Initial{$_} Default=$Default{$_}\n" if $DEBUG;
next if $Initial{$_} eq $Default{$_};
next unless $Initial{$_};
printf WRITECONFIG "%-20s %s\n", $_, $Initial{$_};
}
close WRITECONFIG;
return 1;
}
sub copyfiles {
my ($srcdir,$targdir,@types) = @_;
my (%types);
my ($file, $tempfile, $source, $target);
my $dirmode = $targdir =~ m#/$# ? 1 : 0;
unless (scalar(@types)) {
@types = grep !$types{$_}++, values %Type;
}
else {
for(@types) { $types{$_} = 1 }
}
foreach $file (@Files) {
next unless $types{$Type{$file}};
$source = "$srcdir/$file";
if($dirmode) {
$tempfile = $file;
$tempfile =~ s:.*/::;
$target = $targdir . $tempfile;
}
else {
$target = "$targdir/$file";
}
if ($Type{$file} =~ /dir$/) {
unless (-d $target) {
mkdir $target, $Perms{$file}
or die "Couldn't make directory $target: $!\n";
}
if($Type{$file} =~ /odir/) {
system "(cd $file; tar -cf - *) | (cd $target; tar -xf -)";
}
}
else {
if(-f $target ) {
if (defined $Funcs{$file} and $Funcs{$file} =~ /\bbackup\b/) {
my $n = 0;
my $backup;
$backup = "$target~";
while (-f $backup) {
$backup .= '~';
$n++;
die "Too many backups of $target."
if $n > 9;
}
warn "Saving old $target to $backup.\n";
cp($target, $backup) or
die "Couldn't copy $target to $backup: $!\n";
}
elsif ( !-w _ ) {
next unless
is_yes(prompt "Overwrite read-only file $target? ", 'no');
chmod 0644, $target;
}
}
cp($source,$target) or
die "Couldn't copy $source to $target: $!\n";
}
if (defined $Funcs{$file} and $Funcs{$file} =~ /\bchown\b/) {
chown ($UserID, $GroupID, $target)
if defined $UserID;
}
chmod $Perms{$file}, $target ||
die "Couldn't change mode of $target to $Perms{$file}: $!\n";
}
1;
}
sub checkmanifest {
my ($targdir,@types) = @_;
my (%types);
my (@errors);
my ($file, $target);
unless (scalar(@types)) {
@types = grep !$types{$_}++, values %Type;
delete $types{'link'};
}
else {
for(@types) { $types{$_} = 1 }
}
foreach $file (@Files) {
next unless $types{$Type{$file}};
$target = "$targdir/$file";
push(@errors, "$target doesn't exist!") unless -e $target;
}
if (@errors) {
push (@Errors, @errors);
return undef;
}
1;
}
sub finduid {
my(@users) = @_;
my ($user, $login,$pass,$uid,$gid);
foreach $user (@users) {
($login,$pass,$uid,$gid) = getpwnam($user);
last if defined $uid;
}
defined $uid ? $uid : '';
}
sub get_detailed_param {
my $param = shift;
my $result;
if($Help{$param}) {
print "\n\n", $Help{$param};
}
unless (defined $Initial{$param}) {
$Initial{$param} = ($Default{$param} =~ /BLANK_DEFAULT|UNDEFINED/)
? ''
: $Default{$param};
}
$result = prompt("$param? ", $Initial{$param});
}
### Start main configuration
if (open(HELP, $Initial{'HelpFile'})) {
$/ = '';
while(<HELP>) {
my ($thing, $comment) = split /\n/, $_, 2;
my ($var, $default) = split /\s+/, $thing, 2;
$Help{$var} = $comment;
$Default{$var} = $default;
}
close HELP;
$/ = "\n";
}
else {
die "Ooops! No helpfile. Can't continue.\n";
}
require 5.002 || die <<EOF;
Sorry, MiniVend requires at least Perl 5.002 to be assured of running
properly. (If you know enough about UNIX and Perl to defeat this check,
then you _might_ know enough to get it running with 5.001m).
Please upgrade your Perl before installing MiniVend 2.0.
EOF
if (open(MANIFEST, 'manifest')) {
while(<MANIFEST>) {
next if /^#/;
next unless /\S/;
chomp;
($file,$type,$perms,$funcs) = split /\s+/, $_, 4;
push(@Files,$file);
$Type{$file} = $type;
$Perms{$file} = oct($perms);
$Funcs{$file} = $funcs;
}
close MANIFEST;
}
else {
$Nomove = 1;
warn "\nCouldn't open manifest: $!\n" .
"We won't be moving or changing any program files.\n";
}
if($InstallOnly) {
goto INSTALLPROGS;
}
if (checkmanifest('.')) {
$Fullpackage = 1;
$SamplesPresent = 1;
print "\nYou seem to have a complete package here.\n";
}
goto COPYFILES if $Rerun;
$param = 'VendRoot';
my $save = $Initial{$param};
unless (
($Initial{$param} = get_detailed_param($param))
eq $save) {
chop($Initial{$param} = `pwd`)
if $Initial{$param} eq '.';
$Changed{$param} = 1;
}
$Done{$param} = 1;
CHECKMANIFEST: {
last CHECKMANIFEST if $Nomove || $Fullpackage || $Rerun;
unless (checkmanifest('.', 'dir', 'static', 'script', 'csrc', 'conf')) {
$Nomove = 1;
for (@Errors) { print "$_\n" }
print "Not all the important files are here. I won't be copying files.\n";
@Errors = ();
}
else {
print "You have the important files.\n";
}
} # CHECKMANIFEST
chop($curdir = `pwd`);
$Samedir = 1 if $curdir eq $Initial{'VendRoot'};
COPYFILES: {
my(@types);
my($ans);
last COPYFILES if $Nomove || $Rerun;
if ($Fullpackage && $Samedir) {
print <<EOF;
It looks like you are installing in the current directory
and have a full package. Good.
EOF
last COPYFILES;
}
elsif ($Samedir) {
print "\nIt looks like you are installing in the current directory\n";
print "but don't have a full package.\n";
if ( -f $Initial{'ConfigFile'}) {
print "\nOh, just a reconfiguration. You have a configuration file.\n";
}
last COPYFILES;
}
if (checkmanifest($Initial{$param},
'dir', 'static', 'script', 'csrc')) {
print "All important files seem to be in $Initial{$param}.\n";
last COPYFILES if $Samedir;
$ans = prompt "Want to copy these over them? ", 'yes';
if(is_yes($ans)) {
push(@types, 'dir', 'static', 'script', 'csrc', 'conf');
}
else {
print "\nOK, continuing with the files already there.\n";
last COPYFILES;
}
$ans = prompt "Want to copy the sample files? ", 'yes';
if(is_yes($ans)) {
$SamplesPresent = 1;
push(@types, qw(odir demo html image));
}
else {
undef $SamplesPresent;
print "\nOK, continuing with the files already there.\n";
}
}
else {
if($Samedir) {
print "There is not a complete package here, I hope you\n";
print "know what you are doing.\n";
last COPYFILES;
}
unless (-d $Initial{$param}) {
$ans = prompt
"\nThe directory $Initial{$param} is not there.\nMake it? ",
'yes';
mkdir $Initial{$param}, 0755
or die "Couldn't make $Initial{$param}: $!\n";
}
else {
undef $SamplesPresent;
$ans = prompt
"The directory $Initial{$param} already exists.\nUse it? ",
'no';
exit if is_no($ans);
}
}
@Errors = ();
print "Copying files to $Initial{$param}...";
$::InitialCopy = 1;
copyfiles('.', $Initial{$param}, @types);
$::InitialCopy = 0;
for (@Errors) { print "$_\n" }
@Errors = ();
print "done.\n";
} # last COPYFILES
print "\nEntering $Initial{'VendRoot'}.\n"
unless $Samedir;
chdir $Initial{'VendRoot'}
|| die "Couldn't change directory to $Initial{'VendRoot'}: $!\n";
@Keyfiles = (
"$Initial{VendRoot}",
"$Initial{VendRoot}/error.log",
"$Initial{VendRoot}/etc",
);
# Change ownership of key files if we are root.
if($< == 0) {
print <<EOF;
The root user cannot run the MiniVend server for security reasons.
Since you are the superuser, you must change the ownership of the
MiniVend directory to that of the user ID that will run MiniVend.
You may also if you wish set the group -- it will default to the
default group of the user.
EOF
for(;;) {
$UserName = prompt("User who will run MiniVend? ", '');
($UserID,$GroupID) = (getpwnam($UserName))[2,3];
last if defined $UserID;
print "Error -- that is not a valid user name on this machine.\n\n";
}
$GroupName = (getgrgid($GroupID))[0];
for(;;) {
$GroupName = prompt("Group to own MiniVend? ", $GroupName);
$GroupID = (getgrnam($GroupName))[2];
last if defined $GroupID;
print "Error -- that is not a valid group name on this machine.\n\n";
}
for(@Keyfiles) {
chown ($UserID, $GroupID, $_)
or die "Couldn't change ownership of $Initial{VendRoot}: $!\n";
}
print "\n";
}
else {
print <<EOF;
-------------------------------------------------------------------
FYI, if you are installing this software as another user name than
the one which will ultimately run MiniVend, you will need to change
ownership of two directories to that user name before it will
work properly. That includes the main MiniVend directory
$Initial{VendRoot}, and the configuration directory
$Initial{VendRoot}/etc. The command to accomplish that
(as root) is:
EOF
for(@Keyfiles) { print "chown <username> $_\n"; }
print <<EOF;
Substitute the proper user name for <username>.
-------------------------------------------------------------------
EOF
}
use Config;
if ($PERL) {
$Initial{'PERL'} = $PERL;
}
HOSTNAME: {
my $host;
my $domain;
# Have to skip this for NT
unless (defined $Initial{'HostName'}) {
$Initial{'HostName'} = '';
chop($host = `hostname`);
last HOSTNAME if $?;
chop($domain = `domainname`);
last HOSTNAME if $?;
$host .= ".$domain"
if ($host =~ s/\.?\(?none\)?$//i or $host !~ /\./);
$Initial{'HostName'} = $host;
}
}
LOCK_GCC: {
last LOCK_GCC unless
$Config{'osname'} =~ /solaris/i;
$GCCFLAG = ' -lsocket -DSVR4';
eval {require File::Lock and last LOCK_GCC };
print <<EOF;
Your operating system ($Config{'osname'}) doesn't fully support
flock(), so you will need the File::Lock module in order for
MiniVend to operate. It is included with MiniVend, but the
latest version can be obtained from http://www.perl.com
in the CPAN area. Expect a ***fatal*** error if you don't have
it and MiniVend is not able to install it..
MiniVend will try and install the module now.
EOF
install_file_lock() or die "\nInstall FAILED.\n";
print "\nInstall successful, apparently.\n";
system $PERL,
'-npi', '-e',
"'s!^\s*#\s*(use\s+File::Lock)!$1!'",
'Vend/Util.pm';
} # last LOCK_GCC
my @params = qw(PERL);
for(@params) {
$ = 0;
$save = $Initial{$_};
$Done{$_} = 1;
next if $Rerun;
unless (
($Initial{$_} = get_detailed_param($_))
eq $save) {
$Changed{$_} = 1;
}
$ = 1;
}
CHECKPERL: {
last CHECKPERL if $Rerun;
if($] ne `$PERL -e 'print $]'`) {
print <<EOP;
We will now re-run this configure with the Perl you specified,
it will just take a moment...