| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package RPM::CPAN::Repository; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
210428
|
use strict; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
55
|
|
|
4
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
78
|
|
|
5
|
2
|
|
|
2
|
|
790
|
use Config::Tiny; |
|
|
2
|
|
|
|
|
2390
|
|
|
|
2
|
|
|
|
|
68
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use File::Basename qw(dirname); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
176
|
|
|
7
|
2
|
|
|
2
|
|
779
|
use POSIX qw(uname); |
|
|
2
|
|
|
|
|
13624
|
|
|
|
2
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.0.1'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $REPO_FILE = '/etc/yum.repos.d/mediaalpha-public.repo'; |
|
12
|
|
|
|
|
|
|
my $REPO_CONTENT = <<'END'; |
|
13
|
|
|
|
|
|
|
[mediaalpha-public-perl] |
|
14
|
|
|
|
|
|
|
name = mediaalpha-public-perl-5.42.2 |
|
15
|
|
|
|
|
|
|
baseurl = https://mediaalpha-public-rpm-repo.s3.amazonaws.com/perl/5.42.2/$basearch |
|
16
|
|
|
|
|
|
|
gpgcheck = 1 |
|
17
|
|
|
|
|
|
|
gpgkey = https://mediaalpha-public-rpm-repo.s3.amazonaws.com/RPM-GPG-KEY-mediaalpha |
|
18
|
|
|
|
|
|
|
END |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# we only support AL2023 |
|
21
|
|
|
|
|
|
|
sub detect_al2023 { |
|
22
|
1
|
|
|
1
|
1
|
196060
|
my $os_release = '/etc/os-release'; |
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
50
|
|
|
|
15
|
my $config = Config::Tiny->read($os_release) |
|
25
|
|
|
|
|
|
|
or die "Can't read $os_release: " . Config::Tiny->errstr . "\n"; |
|
26
|
|
|
|
|
|
|
|
|
27
|
1
|
|
50
|
|
|
618
|
my $name = $config->{_}{NAME} // ''; |
|
28
|
1
|
|
50
|
|
|
10
|
my $version = $config->{_}{VERSION} // ''; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Strip surrounding quotes if present |
|
31
|
1
|
|
|
|
|
8
|
$name =~ s/^"(.*)"$/$1/; |
|
32
|
1
|
|
|
|
|
7
|
$version =~ s/^"(.*)"$/$1/; |
|
33
|
|
|
|
|
|
|
|
|
34
|
1
|
50
|
|
|
|
5
|
unless ($name =~ /amazon linux/i) { |
|
35
|
1
|
|
|
|
|
19
|
die "Error: This script requires Amazon Linux (found: $name)\n"; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
0
|
if ($version ne '2023') { |
|
39
|
0
|
|
|
|
|
0
|
die "Error: This script requires Amazon Linux 2023 (found: Amazon Linux $version)\n"; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
0
|
print "OK: Amazon Linux 2023 detected\n"; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# supports x86_64 and aarch64 (Graviton) |
|
46
|
|
|
|
|
|
|
sub detect_architecture { |
|
47
|
1
|
|
|
1
|
1
|
1182
|
my (undef, undef, undef, undef, $arch) = uname(); |
|
48
|
|
|
|
|
|
|
|
|
49
|
1
|
50
|
33
|
|
|
7
|
unless ($arch eq 'x86_64' || $arch eq 'aarch64') { |
|
50
|
0
|
|
|
|
|
0
|
die "Error: Unsupported architecture (found: $arch, supported: x86_64, aarch64)\n"; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
24
|
print "OK: $arch architecture detected\n"; |
|
54
|
1
|
|
|
|
|
6
|
return $arch; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub check_if_repo_dir_exists { |
|
58
|
3
|
|
|
3
|
1
|
142301
|
my $dir = dirname($REPO_FILE); |
|
59
|
3
|
100
|
|
|
|
199
|
unless (-d $dir) { |
|
60
|
2
|
|
|
|
|
52
|
die "Error: $dir directory does not exist\n"; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub add_the_public_ma_repo { |
|
65
|
1
|
50
|
|
1
|
1
|
477
|
open(my $fh, '>', $REPO_FILE) or die "Can't write $REPO_FILE: $!\n"; |
|
66
|
1
|
|
|
|
|
19
|
print $fh $REPO_CONTENT; |
|
67
|
1
|
|
|
|
|
39
|
close($fh); |
|
68
|
1
|
|
|
|
|
13
|
print "OK: Wrote $REPO_FILE\n"; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub check_the_public_ma_repo { |
|
72
|
3
|
100
|
|
3
|
1
|
2195
|
open(my $fh, '<', $REPO_FILE) or die "Error: $REPO_FILE does not exist or can't be read: $!\n"; |
|
73
|
2
|
|
|
|
|
4
|
my $existing = do { local $/; <$fh> }; |
|
|
2
|
|
|
|
|
12
|
|
|
|
2
|
|
|
|
|
62
|
|
|
74
|
2
|
|
|
|
|
21
|
close($fh); |
|
75
|
|
|
|
|
|
|
|
|
76
|
2
|
100
|
|
|
|
8
|
if ($existing eq $REPO_CONTENT) { |
|
77
|
1
|
|
|
|
|
9
|
print "OK: $REPO_FILE exists and is correct\n"; |
|
78
|
|
|
|
|
|
|
} else { |
|
79
|
1
|
|
|
|
|
16
|
die "Error: $REPO_FILE exists but content differs from expected\n"; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub remove_the_public_ma_repo { |
|
84
|
2
|
100
|
|
2
|
1
|
1258
|
unless (-f $REPO_FILE) { |
|
85
|
1
|
|
|
|
|
5
|
print "OK: $REPO_FILE does not exist (nothing to remove)\n"; |
|
86
|
1
|
|
|
|
|
3
|
return; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
1
|
50
|
|
|
|
77
|
unlink($REPO_FILE) or die "Error: Failed to remove $REPO_FILE: $!\n"; |
|
90
|
1
|
|
|
|
|
9
|
print "OK: Successfully removed $REPO_FILE\n"; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; # Must return true |
|
94
|
|
|
|
|
|
|
__END__ |