manual_install.pl untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 67 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/perl -w
2 # manually install Games::Rezrov modules and script.
3 # - with no switch: install
4 # - with "-u" switch: uninstall
5
6 use strict;
7 use Config;
8
9 use File::Path;
10 use File::Copy;
11 use File::Spec;
12
13 my $scriptdir = $Config{"installscript"};
14 my $top_lib = $Config{"installsitelib"};
15
16 my $uninstall_mode = @ARGV ? lc($ARGV[0]) eq "-u" : 0;
17
18 my $glib = File::Spec->catfile($top_lib, "Games", "Rezrov");
19 unless (-d $glib) {
20 mkpath($glib) || die "can't create $glib";
21 # make Games::Rezrov directory
22 }
23
24 my @modules = glob("*.pm");
25 foreach my $module (@modules) {
26 my $target_file = File::Spec->catfile($glib, $module);
27 if ($uninstall_mode) {
28 unlink $target_file || printf STDERR "can't unlink $target_file\n";
29 } else {
30 # install
31 copy($module, $target_file) || die "can't copy $module to $target_file";
32 }
33 }
34
35 printf "Modules installed to: %s\n", $glib unless $uninstall_mode;
36
37 my $script_target = File::Spec->catfile($scriptdir, "rezrov");
38 if ($uninstall_mode) {
39 unlink($script_target) || printf STDERR "can't unlink $script_target\n";
40 } else {
41 copy("rezrov", $script_target) || die "can't copy rezrov to $script_target";
42 printf "rezrov installed to: %s\n", $script_target;
43 }
44
45
46
47
48