| Filename | /usr/libdata/perl5/OpenBSD/PackageRepository.pm |
| Statements | Executed 67941 statements in 11.8s |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 9682 | 2 | 1 | 11.4s | 11.4s | OpenBSD::PackageRepository::HTTPorFTP::CORE:readline (opcode) |
| 1 | 1 | 1 | 237ms | 11.7s | OpenBSD::PackageRepository::HTTPorFTP::get_http_list |
| 9672 | 2 | 1 | 65.5ms | 82.5ms | OpenBSD::PackageRepository::add_to_list |
| 19339 | 2 | 1 | 58.8ms | 58.8ms | OpenBSD::PackageRepository::HTTPorFTP::CORE:match (opcode) |
| 9699 | 14 | 1 | 17.0ms | 17.0ms | OpenBSD::PackageRepository::CORE:match (opcode) |
| 9658 | 1 | 1 | 8.00ms | 8.00ms | OpenBSD::PackageRepository::HTTPorFTP::CORE:subst (opcode) |
| 2 | 1 | 1 | 2.43ms | 11.9s | OpenBSD::PackageRepository::stemlist |
| 2 | 1 | 1 | 2.41ms | 11.7s | OpenBSD::PackageRepository::available |
| 1 | 1 | 1 | 1.77ms | 3.62ms | OpenBSD::PackageRepository::BEGIN@30 |
| 1 | 1 | 1 | 1.62ms | 1.62ms | OpenBSD::PackageRepository::Local::CORE:open_dir (opcode) |
| 1 | 1 | 1 | 1.56ms | 1.88ms | OpenBSD::PackageLocator::BEGIN@24.12 |
| 1 | 1 | 1 | 1.11ms | 1.11ms | OpenBSD::PackageRepository::HTTPorFTP::CORE:open (opcode) |
| 1 | 1 | 1 | 326µs | 2.22ms | OpenBSD::PackageRepository::Local::list |
| 1 | 1 | 1 | 189µs | 1.30ms | OpenBSD::PackageRepository::HTTPorFTP::open_read_ftp |
| 1 | 1 | 1 | 158µs | 392µs | OpenBSD::PackageRepository::parse_problems |
| 20 | 1 | 1 | 111µs | 111µs | OpenBSD::PackageRepository::Local::CORE:ftfile (opcode) |
| 3 | 1 | 1 | 102µs | 6.06ms | OpenBSD::PackageRepository::parse |
| 21 | 1 | 1 | 75µs | 75µs | OpenBSD::PackageRepository::Local::CORE:readdir (opcode) |
| 1 | 1 | 1 | 73µs | 73µs | OpenBSD::PackageRepository::HTTPorFTP::CORE:close (opcode) |
| 1 | 1 | 1 | 71µs | 11.7s | OpenBSD::PackageRepository::HTTPorFTP::list |
| 1 | 1 | 1 | 61µs | 61µs | OpenBSD::PackageRepository::CORE:unlink (opcode) |
| 1 | 1 | 1 | 52µs | 5.47ms | OpenBSD::PackageRepository::Distant::parse_url |
| 1 | 1 | 1 | 52µs | 58µs | OpenBSD::PackageRepository::__ANON__[:86] |
| 6 | 1 | 1 | 47µs | 72µs | OpenBSD::PackageRepository::relative_url |
| 1 | 1 | 1 | 40µs | 5.61ms | OpenBSD::PackageRepository::parse_fullurl |
| 2 | 2 | 1 | 37µs | 141µs | OpenBSD::PackageRepository::unique |
| 2 | 1 | 1 | 36µs | 36µs | OpenBSD::PackageRepository::CORE:regcomp (opcode) |
| 1 | 1 | 1 | 36µs | 176µs | OpenBSD::PackageRepository::Local::parse_fullurl |
| 1 | 1 | 1 | 32µs | 42µs | OpenBSD::PackageRepository::make_room |
| 1 | 1 | 1 | 28µs | 28µs | OpenBSD::PackageRepository::HTTPorFTP::CORE:waitpid (opcode) |
| 1 | 1 | 1 | 26µs | 26µs | OpenBSD::PackageRepository::CORE:open (opcode) |
| 1 | 1 | 1 | 22µs | 123µs | OpenBSD::PackageRepository::HTTPorFTP::close_read_ftp |
| 4 | 1 | 1 | 20µs | 20µs | OpenBSD::PackageRepository::Distant::baseurl |
| 1 | 1 | 1 | 17µs | 21µs | OpenBSD::PackageLocator::BEGIN@18.10 |
| 1 | 1 | 1 | 16µs | 73µs | OpenBSD::PackageRepository::END |
| 2 | 1 | 1 | 16µs | 16µs | OpenBSD::PackageRepository::CORE:substcont (opcode) |
| 1 | 1 | 1 | 14µs | 11.7s | OpenBSD::PackageRepository::HTTP::obtain_list |
| 5 | 2 | 1 | 13µs | 13µs | OpenBSD::PackageRepository::HTTP::urlscheme |
| 3 | 1 | 1 | 13µs | 13µs | OpenBSD::PackageRepository::CORE:subst (opcode) |
| 1 | 1 | 1 | 12µs | 34µs | OpenBSD::PackageRepository::BEGIN@117 |
| 1 | 1 | 1 | 12µs | 87µs | OpenBSD::PackageRepository::Local::BEGIN@454 |
| 3 | 2 | 1 | 11µs | 11µs | OpenBSD::PackageRepository::baseurl |
| 1 | 1 | 1 | 10µs | 11µs | OpenBSD::PackageRepository::Local::pkg_db |
| 1 | 1 | 1 | 10µs | 17µs | OpenBSD::PackageLocator::BEGIN@19.11 |
| 1 | 1 | 1 | 9µs | 75µs | OpenBSD::PackageRepository::BEGIN@32 |
| 4 | 1 | 1 | 8µs | 8µs | OpenBSD::PackageRepository::CORE:readline (opcode) |
| 1 | 1 | 1 | 7µs | 7µs | OpenBSD::PackageRepository::HTTPorFTP::opened |
| 1 | 1 | 1 | 6µs | 6µs | OpenBSD::PackageRepository::Local::BEGIN@471 |
| 1 | 1 | 1 | 6µs | 6µs | OpenBSD::PackageRepository::BEGIN@31 |
| 2 | 1 | 1 | 6µs | 6µs | OpenBSD::PackageRepository::cleanup |
| 3 | 2 | 1 | 6µs | 6µs | OpenBSD::PackageRepository::Local::urlscheme |
| 1 | 1 | 1 | 5µs | 5µs | OpenBSD::PackageRepository::BEGIN@33 |
| 1 | 1 | 1 | 4µs | 4µs | OpenBSD::PackageRepository::CORE:close (opcode) |
| 2 | 2 | 1 | 4µs | 4µs | OpenBSD::PackageLocator::CORE:subst (opcode) |
| 1 | 1 | 1 | 4µs | 4µs | OpenBSD::PackageRepository::can_be_empty |
| 2 | 2 | 1 | 3µs | 3µs | OpenBSD::PackageRepository::HTTPorFTP::maxcount |
| 1 | 1 | 1 | 2µs | 2µs | OpenBSD::PackageRepository::Distant::CORE:match (opcode) |
| 1 | 1 | 1 | 2µs | 2µs | OpenBSD::PackageRepository::file (xsub) |
| 1 | 1 | 1 | 1µs | 1µs | OpenBSD::PackageRepository::http (xsub) |
| 1 | 1 | 1 | 800ns | 800ns | OpenBSD::PackageRepository::Local::CORE:close (opcode) |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::Distant::__ANON__[:616] |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::Distant::finish_and_close |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::Distant::open_pipe |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::Distant::pkg_copy |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::FTP::_list |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::FTP::get_ftp_list |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::FTP::obtain_list |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::FTP::urlscheme |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::HTTPS::urlscheme |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::HTTPorFTP::__ANON__[:876] |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::HTTPorFTP::__ANON__[:886] |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::HTTPorFTP::drop_privileges_and_setup_env |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::HTTPorFTP::find |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::HTTPorFTP::grabPlist |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::HTTPorFTP::grab_object |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::HTTPorFTP::should_have |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::HTTPorFTP::try_until_success |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::Local::is_local_file |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::Local::maxcount |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::Local::may_copy |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::Local::may_exist |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::Local::open_pipe |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::Local::opened |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::__ANON__[:212] |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::check_signed |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::close |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::did_it_fork |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::dont_cleanup |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::find |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::grabPlist |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::make_error_file |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::may_exist |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::new |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::open |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::opened |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::signify_pipe |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::uncompress |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::PackageRepository::wipe_info |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # ex:ts=8 sw=4: | ||||
| 2 | # $OpenBSD: PackageRepository.pm,v 1.146 2017/08/04 11:53:03 sthen Exp $ | ||||
| 3 | # | ||||
| 4 | # Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org> | ||||
| 5 | # | ||||
| 6 | # Permission to use, copy, modify, and distribute this software for any | ||||
| 7 | # purpose with or without fee is hereby granted, provided that the above | ||||
| 8 | # copyright notice and this permission notice appear in all copies. | ||||
| 9 | # | ||||
| 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||
| 11 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||
| 12 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||
| 13 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||
| 14 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||||
| 15 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||||
| 16 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
| 17 | |||||
| 18 | 2 | 34µs | 2 | 25µs | # spent 21µs (17+4) within OpenBSD::PackageLocator::BEGIN@18.10 which was called:
# once (17µs+4µs) by OpenBSD::PackageLocator::BEGIN@24 at line 18 # spent 21µs making 1 call to OpenBSD::PackageLocator::BEGIN@18.10
# spent 4µs making 1 call to strict::import |
| 19 | 2 | 27µs | 2 | 24µs | # spent 17µs (10+7) within OpenBSD::PackageLocator::BEGIN@19.11 which was called:
# once (10µs+7µs) by OpenBSD::PackageLocator::BEGIN@24 at line 19 # spent 17µs making 1 call to OpenBSD::PackageLocator::BEGIN@19.11
# spent 7µs making 1 call to warnings::import |
| 20 | |||||
| 21 | # XXX load extra class, grab match from Base class, and tweak inheritance | ||||
| 22 | # to get all methods. | ||||
| 23 | |||||
| 24 | 2 | 188µs | 1 | 1.88ms | # spent 1.88ms (1.56+311µs) within OpenBSD::PackageLocator::BEGIN@24.12 which was called:
# once (1.56ms+311µs) by OpenBSD::PackageLocator::BEGIN@24 at line 24 # spent 1.88ms making 1 call to OpenBSD::PackageLocator::BEGIN@24.12 |
| 25 | 1 | 1µs | $OpenBSD::PackageRepository::Installed::ISA = qw(OpenBSD::PackageRepository); | ||
| 26 | |||||
| 27 | package OpenBSD::PackageRepository; | ||||
| 28 | 1 | 7µs | our @ISA=(qw(OpenBSD::PackageRepositoryBase)); | ||
| 29 | |||||
| 30 | 2 | 140µs | 1 | 3.62ms | # spent 3.62ms (1.77+1.85) within OpenBSD::PackageRepository::BEGIN@30 which was called:
# once (1.77ms+1.85ms) by OpenBSD::PackageLocator::BEGIN@24 at line 30 # spent 3.62ms making 1 call to OpenBSD::PackageRepository::BEGIN@30 |
| 31 | 2 | 25µs | 1 | 6µs | # spent 6µs within OpenBSD::PackageRepository::BEGIN@31 which was called:
# once (6µs+0s) by OpenBSD::PackageLocator::BEGIN@24 at line 31 # spent 6µs making 1 call to OpenBSD::PackageRepository::BEGIN@31 |
| 32 | 2 | 27µs | 2 | 141µs | # spent 75µs (9+66) within OpenBSD::PackageRepository::BEGIN@32 which was called:
# once (9µs+66µs) by OpenBSD::PackageLocator::BEGIN@24 at line 32 # spent 75µs making 1 call to OpenBSD::PackageRepository::BEGIN@32
# spent 66µs making 1 call to Exporter::import |
| 33 | 2 | 395µs | 1 | 5µs | # spent 5µs within OpenBSD::PackageRepository::BEGIN@33 which was called:
# once (5µs+0s) by OpenBSD::PackageLocator::BEGIN@24 at line 33 # spent 5µs making 1 call to OpenBSD::PackageRepository::BEGIN@33 |
| 34 | |||||
| 35 | sub make_error_file | ||||
| 36 | { | ||||
| 37 | my ($self, $object) = @_; | ||||
| 38 | $object->{errors} = OpenBSD::Temp->file; | ||||
| 39 | if (!defined $object->{errors}) { | ||||
| 40 | $self->{state}->fatal("#1 not writable", | ||||
| 41 | $OpenBSD::Temp::tempbase); | ||||
| 42 | } | ||||
| 43 | } | ||||
| 44 | |||||
| 45 | sub baseurl | ||||
| 46 | { | ||||
| 47 | 3 | 2µs | my $self = shift; | ||
| 48 | |||||
| 49 | 3 | 12µs | return $self->{path}; | ||
| 50 | } | ||||
| 51 | |||||
| 52 | sub new | ||||
| 53 | { | ||||
| 54 | my ($class, $baseurl, $state) = @_; | ||||
| 55 | my $o = $class->parse(\$baseurl, $state); | ||||
| 56 | if ($baseurl ne '') { | ||||
| 57 | return undef; | ||||
| 58 | } | ||||
| 59 | return $o; | ||||
| 60 | } | ||||
| 61 | |||||
| 62 | sub can_be_empty | ||||
| 63 | # spent 4µs within OpenBSD::PackageRepository::can_be_empty which was called:
# once (4µs+0s) by OpenBSD::PackageRepository::Local::parse_fullurl at line 486 | ||||
| 64 | 1 | 900ns | my $self = shift; | ||
| 65 | 1 | 1µs | $self->{empty_okay} = 1; | ||
| 66 | 1 | 4µs | return $self; | ||
| 67 | } | ||||
| 68 | |||||
| 69 | 1 | 1µs | my $cache = {}; | ||
| 70 | |||||
| 71 | sub unique | ||||
| 72 | { | ||||
| 73 | 2 | 2µs | my ($class, $o) = @_; | ||
| 74 | 2 | 2µs | return $o unless defined $o; | ||
| 75 | 2 | 15µs | 2 | 69µs | if (defined $cache->{$o->url}) { # spent 69µs making 2 calls to OpenBSD::PackageRepositoryBase::url, avg 34µs/call |
| 76 | return $cache->{$o->url}; | ||||
| 77 | } | ||||
| 78 | 2 | 6µs | 2 | 35µs | $cache->{$o->url} = $o; # spent 35µs making 2 calls to OpenBSD::PackageRepositoryBase::url, avg 18µs/call |
| 79 | 2 | 7µs | return $o; | ||
| 80 | } | ||||
| 81 | |||||
| 82 | # spent 58µs (52+6) within OpenBSD::PackageRepository::__ANON__[/usr/libdata/perl5/OpenBSD/PackageRepository.pm:86] which was called:
# once (52µs+6µs) by OpenBSD::PackageRepository::END at line 88 | ||||
| 83 | 1 | 15µs | for my $repo (values %$cache) { | ||
| 84 | 2 | 32µs | 2 | 6µs | $repo->cleanup; # spent 6µs making 2 calls to OpenBSD::PackageRepository::cleanup, avg 3µs/call |
| 85 | } | ||||
| 86 | 1 | 3µs | }; | ||
| 87 | # spent 73µs (16+58) within OpenBSD::PackageRepository::END which was called:
# once (16µs+58µs) by main::RUNTIME at line 0 of /usr/sbin/pkg_info | ||||
| 88 | 1 | 11µs | 1 | 58µs | &$cleanup; # spent 58µs making 1 call to OpenBSD::PackageRepository::__ANON__[OpenBSD/PackageRepository.pm:86] |
| 89 | } | ||||
| 90 | |||||
| 91 | 1 | 4µs | 1 | 5µs | OpenBSD::Handler->register($cleanup); # spent 5µs making 1 call to OpenBSD::Handler::register |
| 92 | |||||
| 93 | sub parse_fullurl | ||||
| 94 | # spent 5.61ms (40µs+5.57) within OpenBSD::PackageRepository::parse_fullurl which was called:
# once (40µs+5.57ms) by OpenBSD::PackageRepository::parse at line 126 | ||||
| 95 | 1 | 1µs | my ($class, $r, $state) = @_; | ||
| 96 | |||||
| 97 | 1 | 5µs | 1 | 21µs | $class->strip_urlscheme($r) or return undef; # spent 21µs making 1 call to OpenBSD::PackageRepositoryBase::strip_urlscheme |
| 98 | 1 | 34µs | 2 | 5.55ms | return $class->unique($class->parse_url($r, $state)); # spent 5.47ms making 1 call to OpenBSD::PackageRepository::Distant::parse_url
# spent 82µs making 1 call to OpenBSD::PackageRepository::unique |
| 99 | } | ||||
| 100 | |||||
| 101 | sub dont_cleanup | ||||
| 102 | { | ||||
| 103 | } | ||||
| 104 | |||||
| 105 | sub ftp() { 'OpenBSD::PackageRepository::FTP' } | ||||
| 106 | sub http() { 'OpenBSD::PackageRepository::HTTP' } | ||||
| 107 | sub https() { 'OpenBSD::PackageRepository::HTTPS' } | ||||
| 108 | sub scp() { 'OpenBSD::PackageRepository::SCP' } | ||||
| 109 | sub file() { 'OpenBSD::PackageRepository::Local' } | ||||
| 110 | sub installed() { 'OpenBSD::PackageRepository::Installed' } | ||||
| 111 | |||||
| 112 | sub parse | ||||
| 113 | # spent 6.06ms (102µs+5.96) within OpenBSD::PackageRepository::parse which was called 3 times, avg 2.02ms/call:
# 3 times (102µs+5.96ms) by OpenBSD::PackageLocator::add_default at line 50 of OpenBSD/PackageLocator.pm, avg 2.02ms/call | ||||
| 114 | 3 | 3µs | my ($class, $r, $state) = @_; | ||
| 115 | |||||
| 116 | { | ||||
| 117 | 5 | 1.93ms | 2 | 56µs | # spent 34µs (12+22) within OpenBSD::PackageRepository::BEGIN@117 which was called:
# once (12µs+22µs) by OpenBSD::PackageLocator::BEGIN@24 at line 117 # spent 34µs making 1 call to OpenBSD::PackageRepository::BEGIN@117
# spent 22µs making 1 call to warnings::unimport |
| 118 | 3 | 54µs | 6 | 154µs | $$r =~ s/^installpath(\:|$)/$state->installpath.$1/e; # spent 126µs making 1 call to OpenBSD::Auto::__ANON__[OpenBSD/Error.pm:28]
# spent 16µs making 2 calls to OpenBSD::PackageRepository::CORE:substcont, avg 8µs/call
# spent 13µs making 3 calls to OpenBSD::PackageRepository::CORE:subst, avg 4µs/call |
| 119 | } | ||||
| 120 | |||||
| 121 | 3 | 5µs | my $u = $$r; | ||
| 122 | 3 | 5µs | return undef if $u eq ''; | ||
| 123 | |||||
| 124 | |||||
| 125 | |||||
| 126 | 2 | 47µs | 10 | 5.62ms | if ($u =~ m/^ftp\:/io) { # spent 5.61ms making 1 call to OpenBSD::PackageRepository::parse_fullurl
# spent 8µs making 8 calls to OpenBSD::PackageRepository::CORE:match, avg 1µs/call
# spent 1µs making 1 call to OpenBSD::PackageRepository::http |
| 127 | return $class->ftp->parse_fullurl($r, $state); | ||||
| 128 | } elsif ($u =~ m/^http\:/io) { | ||||
| 129 | # require OpenBSD::PackageRepository::HTTP; | ||||
| 130 | |||||
| 131 | return $class->http->parse_fullurl($r, $state); | ||||
| 132 | } elsif ($u =~ m/^https\:/io) { | ||||
| 133 | return $class->https->parse_fullurl($r, $state); | ||||
| 134 | } elsif ($u =~ m/^scp\:/io) { | ||||
| 135 | return undef if $state->defines("NO_SCP"); | ||||
| 136 | |||||
| 137 | require OpenBSD::PackageRepository::SCP; | ||||
| 138 | |||||
| 139 | return $class->scp->parse_fullurl($r, $state); | ||||
| 140 | } elsif ($u =~ m/^file\:/io) { | ||||
| 141 | return $class->file->parse_fullurl($r, $state); | ||||
| 142 | } elsif ($u =~ m/^inst\:$/io) { | ||||
| 143 | return $class->installed->parse_fullurl($r, $state); | ||||
| 144 | } else { | ||||
| 145 | 1 | 4µs | 1 | 700ns | if ($$r =~ m/^([a-z0-9][a-z0-9.]+\.[a-z0-9.]+)(\:|$)/ # spent 700ns making 1 call to OpenBSD::PackageRepository::CORE:match |
| 146 | && !-d $1) { | ||||
| 147 | $$r =~ s//http:\/\/$1\/%m$2/; | ||||
| 148 | return $class->http->parse_fullurl($r, $state); | ||||
| 149 | } | ||||
| 150 | 1 | 14µs | 2 | 177µs | return $class->file->parse_fullurl($r, $state); # spent 176µs making 1 call to OpenBSD::PackageRepository::Local::parse_fullurl
# spent 2µs making 1 call to OpenBSD::PackageRepository::file |
| 151 | } | ||||
| 152 | } | ||||
| 153 | |||||
| 154 | sub available | ||||
| 155 | # spent 11.7s (2.41ms+11.7) within OpenBSD::PackageRepository::available which was called 2 times, avg 5.87s/call:
# 2 times (2.41ms+11.7s) by OpenBSD::PackageRepository::stemlist at line 166, avg 5.87s/call | ||||
| 156 | 2 | 2µs | my $self = shift; | ||
| 157 | |||||
| 158 | 2 | 2.40ms | 2 | 11.7s | return @{$self->list}; # spent 11.7s making 1 call to OpenBSD::PackageRepository::HTTPorFTP::list
# spent 2.22ms making 1 call to OpenBSD::PackageRepository::Local::list |
| 159 | } | ||||
| 160 | |||||
| 161 | sub stemlist | ||||
| 162 | # spent 11.9s (2.43ms+11.9) within OpenBSD::PackageRepository::stemlist which was called 2 times, avg 5.94s/call:
# 2 times (2.43ms+11.9s) by OpenBSD::Search::PartialStem::match at line 166 of OpenBSD/Search.pm, avg 5.94s/call | ||||
| 163 | 2 | 2µs | my $self = shift; | ||
| 164 | 2 | 4µs | if (!defined $self->{stemlist}) { | ||
| 165 | 2 | 2µs | require OpenBSD::PackageName; | ||
| 166 | 2 | 2.02ms | 2 | 11.7s | my @l = $self->available; # spent 11.7s making 2 calls to OpenBSD::PackageRepository::available, avg 5.87s/call |
| 167 | 2 | 4µs | if (@l == 0 && !$self->{empty_okay}) { | ||
| 168 | $self->{state}->errsay("#1: #2", $self->url, | ||||
| 169 | $self->{no_such_dir} ? "no such dir" : "empty"); | ||||
| 170 | } | ||||
| 171 | 2 | 463µs | 2 | 137ms | $self->{stemlist} = OpenBSD::PackageName::avail2stems(@l); # spent 137ms making 2 calls to OpenBSD::PackageName::avail2stems, avg 68.3ms/call |
| 172 | } | ||||
| 173 | 2 | 14µs | return $self->{stemlist}; | ||
| 174 | } | ||||
| 175 | |||||
| 176 | sub wipe_info | ||||
| 177 | { | ||||
| 178 | my ($self, $pkg) = @_; | ||||
| 179 | |||||
| 180 | require File::Path; | ||||
| 181 | |||||
| 182 | my $dir = $pkg->{dir}; | ||||
| 183 | if (defined $dir) { | ||||
| 184 | OpenBSD::Error->rmtree($dir); | ||||
| 185 | OpenBSD::Temp->reclaim($dir); | ||||
| 186 | delete $pkg->{dir}; | ||||
| 187 | } | ||||
| 188 | } | ||||
| 189 | |||||
| 190 | # by default, all objects may exist | ||||
| 191 | sub may_exist | ||||
| 192 | { | ||||
| 193 | return 1; | ||||
| 194 | } | ||||
| 195 | |||||
| 196 | # by default, we don't track opened files for this key | ||||
| 197 | |||||
| 198 | sub opened | ||||
| 199 | { | ||||
| 200 | undef; | ||||
| 201 | } | ||||
| 202 | |||||
| 203 | # hint: 0 premature close, 1 real error. undef, normal ! | ||||
| 204 | |||||
| 205 | sub close | ||||
| 206 | { | ||||
| 207 | my ($self, $object, $hint) = @_; | ||||
| 208 | close($object->{fh}) if defined $object->{fh}; | ||||
| 209 | if (defined $object->{pid2}) { | ||||
| 210 | local $SIG{ALRM} = sub { | ||||
| 211 | kill HUP => $object->{pid2}; | ||||
| 212 | }; | ||||
| 213 | alarm(30); | ||||
| 214 | waitpid($object->{pid2}, 0); | ||||
| 215 | alarm(0); | ||||
| 216 | } | ||||
| 217 | $self->parse_problems($object->{errors}, $hint, $object) | ||||
| 218 | if defined $object->{errors}; | ||||
| 219 | undef $object->{errors}; | ||||
| 220 | $object->deref; | ||||
| 221 | } | ||||
| 222 | |||||
| 223 | sub make_room | ||||
| 224 | # spent 42µs (32+10) within OpenBSD::PackageRepository::make_room which was called:
# once (32µs+10µs) by OpenBSD::PackageRepository::HTTPorFTP::list at line 893 | ||||
| 225 | 1 | 800ns | my $self = shift; | ||
| 226 | |||||
| 227 | # kill old files if too many | ||||
| 228 | 1 | 7µs | 1 | 7µs | my $already = $self->opened; # spent 7µs making 1 call to OpenBSD::PackageRepository::HTTPorFTP::opened |
| 229 | 1 | 2µs | if (defined $already) { | ||
| 230 | # gc old objects | ||||
| 231 | 1 | 4µs | 1 | 2µs | if (@$already >= $self->maxcount) { # spent 2µs making 1 call to OpenBSD::PackageRepository::HTTPorFTP::maxcount |
| 232 | @$already = grep { defined $_->{fh} } @$already; | ||||
| 233 | } | ||||
| 234 | 1 | 4µs | 1 | 2µs | while (@$already >= $self->maxcount) { # spent 2µs making 1 call to OpenBSD::PackageRepository::HTTPorFTP::maxcount |
| 235 | my $o = shift @$already; | ||||
| 236 | $self->close_now($o); | ||||
| 237 | } | ||||
| 238 | } | ||||
| 239 | 1 | 7µs | return $already; | ||
| 240 | } | ||||
| 241 | |||||
| 242 | # open method that tracks opened files per-host. | ||||
| 243 | sub open | ||||
| 244 | { | ||||
| 245 | my ($self, $object) = @_; | ||||
| 246 | |||||
| 247 | return unless $self->may_exist($object->{name}); | ||||
| 248 | |||||
| 249 | # kill old files if too many | ||||
| 250 | my $already = $self->make_room; | ||||
| 251 | local $SIG{'PIPE'} = 'DEFAULT'; | ||||
| 252 | my $fh = $self->open_pipe($object); | ||||
| 253 | if (!defined $fh) { | ||||
| 254 | return; | ||||
| 255 | } | ||||
| 256 | $object->{fh} = $fh; | ||||
| 257 | if (defined $already) { | ||||
| 258 | push @$already, $object; | ||||
| 259 | } | ||||
| 260 | return $fh; | ||||
| 261 | } | ||||
| 262 | |||||
| 263 | sub find | ||||
| 264 | { | ||||
| 265 | my ($repository, $name) = @_; | ||||
| 266 | my $self = $repository->new_location($name); | ||||
| 267 | |||||
| 268 | if ($self->contents) { | ||||
| 269 | return $self; | ||||
| 270 | } | ||||
| 271 | } | ||||
| 272 | |||||
| 273 | sub grabPlist | ||||
| 274 | { | ||||
| 275 | my ($repository, $name, $code) = @_; | ||||
| 276 | my $self = $repository->new_location($name); | ||||
| 277 | |||||
| 278 | return $self->grabPlist($code); | ||||
| 279 | } | ||||
| 280 | |||||
| 281 | sub parse_problems | ||||
| 282 | # spent 392µs (158+234) within OpenBSD::PackageRepository::parse_problems which was called:
# once (158µs+234µs) by OpenBSD::PackageRepository::HTTPorFTP::list at line 900 | ||||
| 283 | 1 | 1µs | my ($self, $filename, $hint, $object) = @_; | ||
| 284 | 1 | 37µs | 1 | 26µs | CORE::open(my $fh, '<', $filename) or return; # spent 26µs making 1 call to OpenBSD::PackageRepository::CORE:open |
| 285 | |||||
| 286 | 1 | 10µs | 1 | 43µs | my $baseurl = $self->url; # spent 43µs making 1 call to OpenBSD::PackageRepositoryBase::url |
| 287 | 1 | 800ns | my $url = $baseurl; | ||
| 288 | 1 | 1µs | if (defined $object) { | ||
| 289 | $url = $object->url; | ||||
| 290 | } | ||||
| 291 | 1 | 900ns | my $notyet = 1; | ||
| 292 | 1 | 800ns | my $broken = 0; | ||
| 293 | 1 | 600ns | my $signify_error = 0; | ||
| 294 | 1 | 4µs | $self->{last_error} = 0; | ||
| 295 | 1 | 22µs | 4 | 8µs | while(<$fh>) { # spent 8µs making 4 calls to OpenBSD::PackageRepository::CORE:readline, avg 2µs/call |
| 296 | 3 | 14µs | 3 | 7µs | next if m/^(?:200|220|221|226|229|230|227|250|331|500|150)[\s\-]/o; # spent 7µs making 3 calls to OpenBSD::PackageRepository::CORE:match, avg 2µs/call |
| 297 | 3 | 14µs | 3 | 2µs | next if m/^EPSV command not understood/o; # spent 2µs making 3 calls to OpenBSD::PackageRepository::CORE:match, avg 700ns/call |
| 298 | 3 | 18µs | 3 | 9µs | next if m/^Trying [\da-f\.\:]+\.\.\./o; # spent 9µs making 3 calls to OpenBSD::PackageRepository::CORE:match, avg 3µs/call |
| 299 | 2 | 59µs | 4 | 38µs | next if m/^Requesting \Q$baseurl\E/; # spent 36µs making 2 calls to OpenBSD::PackageRepository::CORE:regcomp, avg 18µs/call
# spent 2µs making 2 calls to OpenBSD::PackageRepository::CORE:match, avg 950ns/call |
| 300 | 1 | 13µs | 1 | 10µs | next if m/^Remote system type is\s+/o; # spent 10µs making 1 call to OpenBSD::PackageRepository::CORE:match |
| 301 | 1 | 6µs | 1 | 900ns | next if m/^Connected to\s+/o; # spent 900ns making 1 call to OpenBSD::PackageRepository::CORE:match |
| 302 | 1 | 4µs | 1 | 800ns | next if m/^remote\:\s+/o; # spent 800ns making 1 call to OpenBSD::PackageRepository::CORE:match |
| 303 | 1 | 4µs | 1 | 900ns | next if m/^Using binary mode to transfer files/o; # spent 900ns making 1 call to OpenBSD::PackageRepository::CORE:match |
| 304 | 1 | 4µs | 1 | 800ns | next if m/^Retrieving\s+/o; # spent 800ns making 1 call to OpenBSD::PackageRepository::CORE:match |
| 305 | 1 | 5µs | 1 | 1µs | next if m/^Success?fully retrieved file/o; # spent 1µs making 1 call to OpenBSD::PackageRepository::CORE:match |
| 306 | 1 | 6µs | 1 | 2µs | next if m/^\d+\s+bytes\s+received\s+in/o; # spent 2µs making 1 call to OpenBSD::PackageRepository::CORE:match |
| 307 | next if m/^ftp: connect to address.*: No route to host/o; | ||||
| 308 | if (m/^ftp: Writing -: Broken pipe/o) { | ||||
| 309 | $broken = 1; | ||||
| 310 | next; | ||||
| 311 | } | ||||
| 312 | # http error | ||||
| 313 | if (m/^ftp: Error retrieving file: 404/o) { | ||||
| 314 | if (!defined $object) { | ||||
| 315 | $self->{no_such_dir} = 1; | ||||
| 316 | next; | ||||
| 317 | } else { | ||||
| 318 | $self->{lasterror} = 404; | ||||
| 319 | } | ||||
| 320 | # ignore errors for stable packages | ||||
| 321 | next if $self->can_be_empty; | ||||
| 322 | } | ||||
| 323 | |||||
| 324 | if (defined $hint && $hint == 0) { | ||||
| 325 | next if m/^ftp: -: short write/o; | ||||
| 326 | next if m/^ftp: local: -: Broken pipe/o; | ||||
| 327 | next if m/^421\s+/o; | ||||
| 328 | } | ||||
| 329 | # not retrieving the file => always the same message | ||||
| 330 | # so it's superfluous | ||||
| 331 | next if m/^signify:/ && $self->{lasterror}; | ||||
| 332 | if ($notyet) { | ||||
| 333 | $self->{state}->errprint("#1: ", $url); | ||||
| 334 | if (defined $object) { | ||||
| 335 | $object->{error_reported} = 1; | ||||
| 336 | } | ||||
| 337 | $notyet = 0; | ||||
| 338 | } | ||||
| 339 | if (m/^signify:/) { | ||||
| 340 | $signify_error = 1; | ||||
| 341 | s/.*unsigned .*archive.*/unsigned package (signify(1) doesn't see old-style signatures)/; | ||||
| 342 | } | ||||
| 343 | if (m/^421\s+/o || | ||||
| 344 | m/^ftp: connect: Connection timed out/o || | ||||
| 345 | m/^ftp: Can't connect or login to host/o) { | ||||
| 346 | $self->{lasterror} = 421; | ||||
| 347 | } | ||||
| 348 | if (m/^550\s+/o) { | ||||
| 349 | $self->{lasterror} = 550; | ||||
| 350 | } | ||||
| 351 | $self->{state}->errprint("#1", $_); | ||||
| 352 | } | ||||
| 353 | 1 | 800ns | if ($broken) { | ||
| 354 | unless ($signify_error || defined $hint && $hint == 0) { | ||||
| 355 | $self->{state}->errprint('#1', "ftp: Broken pipe"); | ||||
| 356 | } | ||||
| 357 | } | ||||
| 358 | 1 | 13µs | 1 | 4µs | CORE::close($fh); # spent 4µs making 1 call to OpenBSD::PackageRepository::CORE:close |
| 359 | 1 | 20µs | 1 | 19µs | OpenBSD::Temp->reclaim($filename); # spent 19µs making 1 call to OpenBSD::Temp::reclaim |
| 360 | 1 | 84µs | 1 | 61µs | unlink $filename; # spent 61µs making 1 call to OpenBSD::PackageRepository::CORE:unlink |
| 361 | } | ||||
| 362 | |||||
| 363 | sub cleanup | ||||
| 364 | 2 | 14µs | # spent 6µs within OpenBSD::PackageRepository::cleanup which was called 2 times, avg 3µs/call:
# 2 times (6µs+0s) by OpenBSD::PackageRepository::__ANON__[/usr/libdata/perl5/OpenBSD/PackageRepository.pm:86] at line 84, avg 3µs/call | ||
| 365 | # nothing to do | ||||
| 366 | } | ||||
| 367 | |||||
| 368 | sub relative_url | ||||
| 369 | # spent 72µs (47+25) within OpenBSD::PackageRepository::relative_url which was called 6 times, avg 12µs/call:
# 6 times (47µs+25µs) by OpenBSD::PackageRepositoryBase::url at line 122 of OpenBSD/PackageRepository/Installed.pm, avg 12µs/call | ||||
| 370 | 6 | 5µs | my ($self, $name) = @_; | ||
| 371 | 6 | 5µs | if (defined $name) { | ||
| 372 | return $self->baseurl.$name.".tgz"; | ||||
| 373 | } else { | ||||
| 374 | 6 | 37µs | 6 | 25µs | return $self->baseurl; # spent 20µs making 4 calls to OpenBSD::PackageRepository::Distant::baseurl, avg 5µs/call
# spent 5µs making 2 calls to OpenBSD::PackageRepository::baseurl, avg 3µs/call |
| 375 | } | ||||
| 376 | } | ||||
| 377 | |||||
| 378 | sub add_to_list | ||||
| 379 | # spent 82.5ms (65.5+17.0) within OpenBSD::PackageRepository::add_to_list which was called 9672 times, avg 9µs/call:
# 9658 times (65.4ms+17.0ms) by OpenBSD::PackageRepository::HTTPorFTP::get_http_list at line 919, avg 9µs/call
# 14 times (66µs+16µs) by OpenBSD::PackageRepository::Local::list at line 562, avg 6µs/call | ||||
| 380 | 9672 | 9.15ms | my ($self, $list, $filename) = @_; | ||
| 381 | 9672 | 114ms | 9672 | 17.0ms | if ($filename =~ m/^(.*\-\d.*)\.tgz$/o) { # spent 17.0ms making 9672 calls to OpenBSD::PackageRepository::CORE:match, avg 2µs/call |
| 382 | push(@$list, $1); | ||||
| 383 | } | ||||
| 384 | } | ||||
| 385 | |||||
| 386 | sub did_it_fork | ||||
| 387 | { | ||||
| 388 | my ($self, $pid) = @_; | ||||
| 389 | if (!defined $pid) { | ||||
| 390 | $self->{state}->fatal("Cannot fork: #1", $!); | ||||
| 391 | } | ||||
| 392 | if ($pid == 0) { | ||||
| 393 | delete $SIG{'WINCH'}; | ||||
| 394 | delete $SIG{'CONT'}; | ||||
| 395 | delete $SIG{'INFO'}; | ||||
| 396 | } | ||||
| 397 | } | ||||
| 398 | |||||
| 399 | sub uncompress | ||||
| 400 | { | ||||
| 401 | my $self = shift; | ||||
| 402 | my $object = shift; | ||||
| 403 | require IO::Uncompress::Gunzip; | ||||
| 404 | my $fh = IO::Uncompress::Gunzip->new(@_, MultiStream => 1); | ||||
| 405 | my $result = ""; | ||||
| 406 | if ($object->{is_signed}) { | ||||
| 407 | my $h = $fh->getHeaderInfo; | ||||
| 408 | if ($h) { | ||||
| 409 | for my $line (split /\n/, $h->{Comment}) { | ||||
| 410 | if ($line =~ m/^key=.*\/(.*)\.sec$/) { | ||||
| 411 | $result .= "\@signer $1\n"; | ||||
| 412 | } elsif ($line =~ m/^date=(.*)$/) { | ||||
| 413 | $result .= "\@digital-signature signify2:$1:external\n"; | ||||
| 414 | } | ||||
| 415 | } | ||||
| 416 | } else { | ||||
| 417 | $fh->close; | ||||
| 418 | return undef; | ||||
| 419 | } | ||||
| 420 | } | ||||
| 421 | $object->{extra_content} = $result; | ||||
| 422 | return $fh; | ||||
| 423 | } | ||||
| 424 | |||||
| 425 | sub signify_pipe | ||||
| 426 | { | ||||
| 427 | my $self = shift; | ||||
| 428 | my $object = shift; | ||||
| 429 | CORE::open STDERR, ">>", $object->{errors}; | ||||
| 430 | exec {OpenBSD::Paths->signify} | ||||
| 431 | ("signify", | ||||
| 432 | "-zV", | ||||
| 433 | @_) | ||||
| 434 | or $self->{state}->fatal("Can't run #1: #2", | ||||
| 435 | OpenBSD::Paths->signify, $!); | ||||
| 436 | } | ||||
| 437 | |||||
| 438 | sub check_signed | ||||
| 439 | { | ||||
| 440 | my ($self, $object) = @_; | ||||
| 441 | if ($object->{repository}{trusted}) { | ||||
| 442 | return 0; | ||||
| 443 | } | ||||
| 444 | if ($self->{state}{signature_style} eq 'new') { | ||||
| 445 | $object->{is_signed} = 1; | ||||
| 446 | return 1; | ||||
| 447 | } else { | ||||
| 448 | return 0; | ||||
| 449 | } | ||||
| 450 | } | ||||
| 451 | |||||
| 452 | package OpenBSD::PackageRepository::Local; | ||||
| 453 | 1 | 5µs | our @ISA=qw(OpenBSD::PackageRepository); | ||
| 454 | 2 | 74µs | 2 | 162µs | # spent 87µs (12+75) within OpenBSD::PackageRepository::Local::BEGIN@454 which was called:
# once (12µs+75µs) by OpenBSD::PackageLocator::BEGIN@24 at line 454 # spent 87µs making 1 call to OpenBSD::PackageRepository::Local::BEGIN@454
# spent 75µs making 1 call to Exporter::import |
| 455 | |||||
| 456 | sub is_local_file | ||||
| 457 | { | ||||
| 458 | return 1; | ||||
| 459 | } | ||||
| 460 | |||||
| 461 | sub urlscheme | ||||
| 462 | # spent 6µs within OpenBSD::PackageRepository::Local::urlscheme which was called 3 times, avg 2µs/call:
# 2 times (4µs+0s) by OpenBSD::PackageRepositoryBase::url at line 122 of OpenBSD/PackageRepository/Installed.pm, avg 2µs/call
# once (2µs+0s) by OpenBSD::PackageRepositoryBase::strip_urlscheme at line 100 of OpenBSD/PackageRepository/Installed.pm | ||||
| 463 | 3 | 11µs | return 'file'; | ||
| 464 | } | ||||
| 465 | |||||
| 466 | 1 | 600ns | my $pkg_db; | ||
| 467 | |||||
| 468 | sub pkg_db | ||||
| 469 | # spent 11µs (10+1) within OpenBSD::PackageRepository::Local::pkg_db which was called:
# once (10µs+1µs) by OpenBSD::PackageRepository::Local::parse_fullurl at line 483 | ||||
| 470 | 1 | 1µs | if (!defined $pkg_db) { | ||
| 471 | 2 | 2.72ms | 1 | 6µs | # spent 6µs within OpenBSD::PackageRepository::Local::BEGIN@471 which was called:
# once (6µs+0s) by OpenBSD::PackageLocator::BEGIN@24 at line 471 # spent 6µs making 1 call to OpenBSD::PackageRepository::Local::BEGIN@471 |
| 472 | 1 | 8µs | 1 | 1µs | $pkg_db = $ENV{"PKG_DBDIR"} || OpenBSD::Paths->pkgdb; # spent 1µs making 1 call to OpenBSD::Paths::pkgdb |
| 473 | } | ||||
| 474 | 1 | 4µs | return $pkg_db; | ||
| 475 | } | ||||
| 476 | |||||
| 477 | sub parse_fullurl | ||||
| 478 | # spent 176µs (36+139) within OpenBSD::PackageRepository::Local::parse_fullurl which was called:
# once (36µs+139µs) by OpenBSD::PackageRepository::parse at line 150 | ||||
| 479 | 1 | 800ns | my ($class, $r, $state) = @_; | ||
| 480 | |||||
| 481 | 1 | 6µs | 1 | 36µs | my $ok = $class->strip_urlscheme($r); # spent 36µs making 1 call to OpenBSD::PackageRepositoryBase::strip_urlscheme |
| 482 | 1 | 4µs | 1 | 30µs | my $o = $class->parse_url($r, $state); # spent 30µs making 1 call to OpenBSD::PackageRepositoryBase::parse_url |
| 483 | 1 | 6µs | 1 | 11µs | if (!$ok && $o->{path} eq $class->pkg_db."/") { # spent 11µs making 1 call to OpenBSD::PackageRepository::Local::pkg_db |
| 484 | return $class->installed->new(0, $state); | ||||
| 485 | } else { | ||||
| 486 | 1 | 4µs | 1 | 4µs | if ($o->{path} eq './') { # spent 4µs making 1 call to OpenBSD::PackageRepository::can_be_empty |
| 487 | $o->can_be_empty; | ||||
| 488 | } | ||||
| 489 | 1 | 7µs | 1 | 59µs | return $class->unique($o); # spent 59µs making 1 call to OpenBSD::PackageRepository::unique |
| 490 | } | ||||
| 491 | } | ||||
| 492 | |||||
| 493 | # wrapper around copy, that sometimes does not copy | ||||
| 494 | sub may_copy | ||||
| 495 | { | ||||
| 496 | my ($self, $object, $destdir) = @_; | ||||
| 497 | my $src = $self->relative_url($object->{name}); | ||||
| 498 | require File::Spec; | ||||
| 499 | my (undef, undef, $base) = File::Spec->splitpath($src); | ||||
| 500 | my $dest = File::Spec->catfile($destdir, $base); | ||||
| 501 | if (File::Spec->canonpath($dest) eq File::Spec->canonpath($src)) { | ||||
| 502 | return; | ||||
| 503 | } | ||||
| 504 | if (-f $dest) { | ||||
| 505 | my ($ddev, $dino) = (stat $dest)[0,1]; | ||||
| 506 | my ($sdev, $sino) = (stat $src)[0, 1]; | ||||
| 507 | if ($ddev == $sdev and $sino == $dino) { | ||||
| 508 | return; | ||||
| 509 | } | ||||
| 510 | } | ||||
| 511 | $self->{state}->copy_file($src, $destdir); | ||||
| 512 | } | ||||
| 513 | |||||
| 514 | sub open_pipe | ||||
| 515 | { | ||||
| 516 | my ($self, $object) = @_; | ||||
| 517 | if (defined $ENV{'PKG_CACHE'}) { | ||||
| 518 | $self->may_copy($object, $ENV{'PKG_CACHE'}); | ||||
| 519 | } | ||||
| 520 | my $name = $self->relative_url($object->{name}); | ||||
| 521 | if ($self->check_signed($object)) { | ||||
| 522 | $self->make_error_file($object); | ||||
| 523 | my $pid = open(my $fh, "-|"); | ||||
| 524 | $self->did_it_fork($pid); | ||||
| 525 | if ($pid) { | ||||
| 526 | $object->{pid} = $pid; | ||||
| 527 | return $self->uncompress($object, $fh); | ||||
| 528 | } else { | ||||
| 529 | $self->signify_pipe($object, "-x", $name); | ||||
| 530 | } | ||||
| 531 | } else { | ||||
| 532 | return $self->uncompress($object, $name); | ||||
| 533 | } | ||||
| 534 | } | ||||
| 535 | |||||
| 536 | sub may_exist | ||||
| 537 | { | ||||
| 538 | my ($self, $name) = @_; | ||||
| 539 | return -r $self->relative_url($name); | ||||
| 540 | } | ||||
| 541 | |||||
| 542 | 1 | 1µs | my $local = []; | ||
| 543 | |||||
| 544 | sub opened | ||||
| 545 | { | ||||
| 546 | return $local; | ||||
| 547 | } | ||||
| 548 | |||||
| 549 | sub maxcount | ||||
| 550 | { | ||||
| 551 | return 3; | ||||
| 552 | } | ||||
| 553 | |||||
| 554 | sub list | ||||
| 555 | # spent 2.22ms (326µs+1.90) within OpenBSD::PackageRepository::Local::list which was called:
# once (326µs+1.90ms) by OpenBSD::PackageRepository::available at line 158 | ||||
| 556 | 1 | 600ns | my $self = shift; | ||
| 557 | 1 | 1µs | my $l = []; | ||
| 558 | 1 | 5µs | 1 | 6µs | my $dname = $self->baseurl; # spent 6µs making 1 call to OpenBSD::PackageRepository::baseurl |
| 559 | 1 | 1.63ms | 1 | 1.62ms | opendir(my $dir, $dname) or return $l; # spent 1.62ms making 1 call to OpenBSD::PackageRepository::Local::CORE:open_dir |
| 560 | 1 | 233µs | 21 | 75µs | while (my $e = readdir $dir) { # spent 75µs making 21 calls to OpenBSD::PackageRepository::Local::CORE:readdir, avg 4µs/call |
| 561 | 20 | 182µs | 20 | 111µs | next unless -f "$dname/$e"; # spent 111µs making 20 calls to OpenBSD::PackageRepository::Local::CORE:ftfile, avg 6µs/call |
| 562 | 14 | 43µs | 14 | 82µs | $self->add_to_list($l, $e); # spent 82µs making 14 calls to OpenBSD::PackageRepository::add_to_list, avg 6µs/call |
| 563 | } | ||||
| 564 | 1 | 7µs | 1 | 800ns | close($dir); # spent 800ns making 1 call to OpenBSD::PackageRepository::Local::CORE:close |
| 565 | 1 | 19µs | return $l; | ||
| 566 | } | ||||
| 567 | |||||
| 568 | package OpenBSD::PackageRepository::Distant; | ||||
| 569 | 1 | 3µs | our @ISA=qw(OpenBSD::PackageRepository); | ||
| 570 | |||||
| 571 | sub baseurl | ||||
| 572 | # spent 20µs within OpenBSD::PackageRepository::Distant::baseurl which was called 4 times, avg 5µs/call:
# 4 times (20µs+0s) by OpenBSD::PackageRepository::relative_url at line 374, avg 5µs/call | ||||
| 573 | 4 | 4µs | my $self = shift; | ||
| 574 | |||||
| 575 | 4 | 20µs | return "//$self->{host}$self->{path}"; | ||
| 576 | } | ||||
| 577 | |||||
| 578 | sub parse_url | ||||
| 579 | # spent 5.47ms (52µs+5.42) within OpenBSD::PackageRepository::Distant::parse_url which was called:
# once (52µs+5.42ms) by OpenBSD::PackageRepository::parse_fullurl at line 98 | ||||
| 580 | 1 | 900ns | my ($class, $r, $state) = @_; | ||
| 581 | # same heuristics as ftp(1): | ||||
| 582 | # find host part, rest is parsed as a local url | ||||
| 583 | 1 | 8µs | 1 | 2µs | if (my ($host, $path) = $$r =~ m/^\/\/(.*?)(\/.*)$/) { # spent 2µs making 1 call to OpenBSD::PackageRepository::Distant::CORE:match |
| 584 | |||||
| 585 | 1 | 1µs | $$r = $path; | ||
| 586 | 1 | 4µs | 1 | 5.42ms | my $o = $class->SUPER::parse_url($r, $state); # spent 5.42ms making 1 call to OpenBSD::PackageRepositoryBase::parse_url |
| 587 | 1 | 29µs | $o->{host} = $host; | ||
| 588 | 1 | 1µs | if (defined $o->{release}) { | ||
| 589 | $o->can_be_empty; | ||||
| 590 | $$r = $class->urlscheme."://$o->{host}$o->{release}:$$r"; | ||||
| 591 | } | ||||
| 592 | 1 | 12µs | return $o; | ||
| 593 | } else { | ||||
| 594 | return undef; | ||||
| 595 | } | ||||
| 596 | } | ||||
| 597 | |||||
| 598 | 1 | 500ns | my $buffsize = 2 * 1024 * 1024; | ||
| 599 | |||||
| 600 | sub pkg_copy | ||||
| 601 | { | ||||
| 602 | my ($self, $in, $object) = @_; | ||||
| 603 | |||||
| 604 | my $name = $object->{name}; | ||||
| 605 | my $dir = $object->{cache_dir}; | ||||
| 606 | |||||
| 607 | my ($copy, $filename) = OpenBSD::Temp::permanent_file($dir, $name) or die "Can't write copy to cache"; | ||||
| 608 | chmod((0666 & ~umask), $filename); | ||||
| 609 | $object->{tempname} = $filename; | ||||
| 610 | my $handler = sub { | ||||
| 611 | my ($sig) = @_; | ||||
| 612 | unlink $filename; | ||||
| 613 | close($in); | ||||
| 614 | $SIG{$sig} = 'DEFAULT'; | ||||
| 615 | kill $sig, $$; | ||||
| 616 | }; | ||||
| 617 | |||||
| 618 | my $nonempty = 0; | ||||
| 619 | my $error = 0; | ||||
| 620 | { | ||||
| 621 | |||||
| 622 | local $SIG{'PIPE'} = $handler; | ||||
| 623 | local $SIG{'INT'} = $handler; | ||||
| 624 | local $SIG{'HUP'} = $handler; | ||||
| 625 | local $SIG{'QUIT'} = $handler; | ||||
| 626 | local $SIG{'KILL'} = $handler; | ||||
| 627 | local $SIG{'TERM'} = $handler; | ||||
| 628 | |||||
| 629 | my ($buffer, $n); | ||||
| 630 | # copy stuff over | ||||
| 631 | do { | ||||
| 632 | $n = sysread($in, $buffer, $buffsize); | ||||
| 633 | if (!defined $n) { | ||||
| 634 | $self->{state}->fatal("Error reading: #1", $!); | ||||
| 635 | } | ||||
| 636 | if ($n > 0) { | ||||
| 637 | $nonempty = 1; | ||||
| 638 | } | ||||
| 639 | if (!$error) { | ||||
| 640 | my $r = syswrite $copy, $buffer; | ||||
| 641 | if (!defined $r || $r < $n) { | ||||
| 642 | $error = 1; | ||||
| 643 | } | ||||
| 644 | } | ||||
| 645 | syswrite STDOUT, $buffer; | ||||
| 646 | } while ($n != 0); | ||||
| 647 | close($copy); | ||||
| 648 | } | ||||
| 649 | |||||
| 650 | if ($nonempty && !$error) { | ||||
| 651 | rename $filename, "$dir/$name.tgz"; | ||||
| 652 | } else { | ||||
| 653 | unlink $filename; | ||||
| 654 | } | ||||
| 655 | close($in); | ||||
| 656 | } | ||||
| 657 | |||||
| 658 | sub open_pipe | ||||
| 659 | { | ||||
| 660 | my ($self, $object) = @_; | ||||
| 661 | $self->make_error_file($object); | ||||
| 662 | my $d = $ENV{'PKG_CACHE'}; | ||||
| 663 | if (defined $d) { | ||||
| 664 | $object->{cache_dir} = $d; | ||||
| 665 | if (! -d -w $d) { | ||||
| 666 | $self->{state}->fatal("bad PKG_CACHE directory #1", $d); | ||||
| 667 | } | ||||
| 668 | $object->{cache_dir} = $d; | ||||
| 669 | } | ||||
| 670 | $object->{parent} = $$; | ||||
| 671 | |||||
| 672 | my ($rdfh, $wrfh); | ||||
| 673 | |||||
| 674 | pipe($rdfh, $wrfh); | ||||
| 675 | my $pid2 = fork(); | ||||
| 676 | $self->did_it_fork($pid2); | ||||
| 677 | if ($pid2) { | ||||
| 678 | $object->{pid2} = $pid2; | ||||
| 679 | close($wrfh); | ||||
| 680 | } else { | ||||
| 681 | open STDERR, '>>', $object->{errors}; | ||||
| 682 | open(STDOUT, '>&', $wrfh); | ||||
| 683 | close($rdfh); | ||||
| 684 | close($wrfh); | ||||
| 685 | if (defined $d) { | ||||
| 686 | my $pid3 = open(my $in, "-|"); | ||||
| 687 | $self->did_it_fork($pid3); | ||||
| 688 | if ($pid3) { | ||||
| 689 | $self->dont_cleanup; | ||||
| 690 | $self->pkg_copy($in, $object); | ||||
| 691 | } else { | ||||
| 692 | $self->grab_object($object); | ||||
| 693 | } | ||||
| 694 | } else { | ||||
| 695 | $self->grab_object($object); | ||||
| 696 | } | ||||
| 697 | exit(0); | ||||
| 698 | } | ||||
| 699 | |||||
| 700 | if ($self->check_signed($object)) { | ||||
| 701 | my $pid = open(my $fh, "-|"); | ||||
| 702 | $self->did_it_fork($pid); | ||||
| 703 | if ($pid) { | ||||
| 704 | $object->{pid} = $pid; | ||||
| 705 | close($rdfh); | ||||
| 706 | } else { | ||||
| 707 | open(STDIN, '<&', $rdfh) or | ||||
| 708 | $self->{state}->fatal("Bad dup: #1", $!); | ||||
| 709 | close($rdfh); | ||||
| 710 | $self->signify_pipe($object); | ||||
| 711 | } | ||||
| 712 | |||||
| 713 | return $self->uncompress($object, $fh); | ||||
| 714 | } else { | ||||
| 715 | return $self->uncompress($object, $rdfh); | ||||
| 716 | } | ||||
| 717 | } | ||||
| 718 | |||||
| 719 | sub finish_and_close | ||||
| 720 | { | ||||
| 721 | my ($self, $object) = @_; | ||||
| 722 | if (defined $object->{cache_dir}) { | ||||
| 723 | while (defined $object->next) { | ||||
| 724 | } | ||||
| 725 | } | ||||
| 726 | $self->SUPER::finish_and_close($object); | ||||
| 727 | } | ||||
| 728 | |||||
| 729 | package OpenBSD::PackageRepository::HTTPorFTP; | ||||
| 730 | 1 | 4µs | our @ISA=qw(OpenBSD::PackageRepository::Distant); | ||
| 731 | |||||
| 732 | 1 | 1µs | our %distant = (); | ||
| 733 | |||||
| 734 | sub drop_privileges_and_setup_env | ||||
| 735 | { | ||||
| 736 | my $self = shift; | ||||
| 737 | my $user = '_pkgfetch'; | ||||
| 738 | if ($< == 0) { | ||||
| 739 | # we can't cache anything, we happen after the fork, | ||||
| 740 | # right before exec | ||||
| 741 | if (my (undef, undef, $uid, $gid) = getpwnam($user)) { | ||||
| 742 | $( = $gid; | ||||
| 743 | $) = "$gid $gid"; | ||||
| 744 | $< = $uid; | ||||
| 745 | $> = $uid; | ||||
| 746 | } else { | ||||
| 747 | $self->{state}->fatal("Couldn't change identity: can't find #1 user", $user); | ||||
| 748 | } | ||||
| 749 | } else { | ||||
| 750 | ($user) = getpwuid($<); | ||||
| 751 | } | ||||
| 752 | # create sanitized env for ftp | ||||
| 753 | my %newenv = ( | ||||
| 754 | HOME => '/var/empty', | ||||
| 755 | USER => $user, | ||||
| 756 | LOGNAME => $user, | ||||
| 757 | SHELL => '/bin/sh', | ||||
| 758 | LC_ALL => 'C', # especially, laundry error messages | ||||
| 759 | PATH => '/bin:/usr/bin' | ||||
| 760 | ); | ||||
| 761 | |||||
| 762 | # copy selected stuff; | ||||
| 763 | for my $k (qw( | ||||
| 764 | TERM | ||||
| 765 | FTPMODE | ||||
| 766 | FTPSERVER | ||||
| 767 | FTPSERVERPORT | ||||
| 768 | ftp_proxy | ||||
| 769 | http_proxy | ||||
| 770 | http_cookies | ||||
| 771 | ALL_PROXY | ||||
| 772 | FTP_PROXY | ||||
| 773 | HTTPS_PROXY | ||||
| 774 | HTTP_PROXY | ||||
| 775 | NO_PROXY)) { | ||||
| 776 | if (exists $ENV{$k}) { | ||||
| 777 | $newenv{$k} = $ENV{$k}; | ||||
| 778 | } | ||||
| 779 | } | ||||
| 780 | # don't forget to swap! | ||||
| 781 | %ENV = %newenv; | ||||
| 782 | } | ||||
| 783 | |||||
| 784 | |||||
| 785 | sub grab_object | ||||
| 786 | { | ||||
| 787 | my ($self, $object) = @_; | ||||
| 788 | my ($ftp, @extra) = split(/\s+/, OpenBSD::Paths->ftp); | ||||
| 789 | $self->drop_privileges_and_setup_env; | ||||
| 790 | exec {$ftp} | ||||
| 791 | $ftp, | ||||
| 792 | @extra, | ||||
| 793 | "-o", | ||||
| 794 | "-", $self->url($object->{name}) | ||||
| 795 | or $self->{state}->fatal("Can't run #1: #2", OpenBSD::Paths->ftp, $!); | ||||
| 796 | } | ||||
| 797 | |||||
| 798 | sub open_read_ftp | ||||
| 799 | # spent 1.30ms (189µs+1.11) within OpenBSD::PackageRepository::HTTPorFTP::open_read_ftp which was called:
# once (189µs+1.11ms) by OpenBSD::PackageRepository::HTTPorFTP::get_http_list at line 911 | ||||
| 800 | 1 | 1µs | my ($self, $cmd, $errors) = @_; | ||
| 801 | 1 | 1.25ms | 1 | 1.11ms | my $child_pid = open(my $fh, '-|'); # spent 1.11ms making 1 call to OpenBSD::PackageRepository::HTTPorFTP::CORE:open |
| 802 | 1 | 6µs | if ($child_pid) { | ||
| 803 | 1 | 5µs | $self->{pipe_pid} = $child_pid; | ||
| 804 | 1 | 63µs | return $fh; | ||
| 805 | } else { | ||||
| 806 | open STDERR, '>>', $errors if defined $errors; | ||||
| 807 | |||||
| 808 | $self->drop_privileges_and_setup_env; | ||||
| 809 | exec($cmd) | ||||
| 810 | or $self->{state}->fatal("Can't run #1: #2", $cmd, $!); | ||||
| 811 | } | ||||
| 812 | } | ||||
| 813 | |||||
| 814 | sub close_read_ftp | ||||
| 815 | # spent 123µs (22+101) within OpenBSD::PackageRepository::HTTPorFTP::close_read_ftp which was called:
# once (22µs+101µs) by OpenBSD::PackageRepository::HTTPorFTP::get_http_list at line 922 | ||||
| 816 | 1 | 1µs | my ($self, $fh) = @_; | ||
| 817 | 1 | 84µs | 1 | 73µs | close($fh); # spent 73µs making 1 call to OpenBSD::PackageRepository::HTTPorFTP::CORE:close |
| 818 | 1 | 43µs | 1 | 28µs | waitpid $self->{pipe_pid}, 0; # spent 28µs making 1 call to OpenBSD::PackageRepository::HTTPorFTP::CORE:waitpid |
| 819 | } | ||||
| 820 | |||||
| 821 | sub maxcount | ||||
| 822 | { | ||||
| 823 | 2 | 10µs | return 1; | ||
| 824 | } | ||||
| 825 | |||||
| 826 | sub opened | ||||
| 827 | # spent 7µs within OpenBSD::PackageRepository::HTTPorFTP::opened which was called:
# once (7µs+0s) by OpenBSD::PackageRepository::make_room at line 228 | ||||
| 828 | 1 | 1µs | my $self = $_[0]; | ||
| 829 | 1 | 1µs | my $k = $self->{host}; | ||
| 830 | 1 | 2µs | if (!defined $distant{$k}) { | ||
| 831 | $distant{$k} = []; | ||||
| 832 | } | ||||
| 833 | 1 | 8µs | return $distant{$k}; | ||
| 834 | } | ||||
| 835 | |||||
| 836 | sub should_have | ||||
| 837 | { | ||||
| 838 | my ($self, $pkgname) = @_; | ||||
| 839 | if (defined $self->{lasterror} && $self->{lasterror} == 421) { | ||||
| 840 | return (defined $self->{list}) && | ||||
| 841 | grep { $_ eq $pkgname } @{$self->{list}}; | ||||
| 842 | } else { | ||||
| 843 | return 0; | ||||
| 844 | } | ||||
| 845 | } | ||||
| 846 | |||||
| 847 | sub try_until_success | ||||
| 848 | { | ||||
| 849 | my ($self, $pkgname, $code) = @_; | ||||
| 850 | |||||
| 851 | for (my $retry = 5; $retry <= 160; $retry *= 2) { | ||||
| 852 | undef $self->{lasterror}; | ||||
| 853 | my $o = &$code; | ||||
| 854 | if (defined $o) { | ||||
| 855 | return $o; | ||||
| 856 | } | ||||
| 857 | if (defined $self->{lasterror} && | ||||
| 858 | ($self->{lasterror} == 550 || $self->{lasterror} == 404)) { | ||||
| 859 | last; | ||||
| 860 | } | ||||
| 861 | if ($self->should_have($pkgname)) { | ||||
| 862 | $self->errsay("Temporary error, sleeping #1 seconds", | ||||
| 863 | $retry); | ||||
| 864 | sleep($retry); | ||||
| 865 | } | ||||
| 866 | } | ||||
| 867 | return undef; | ||||
| 868 | } | ||||
| 869 | |||||
| 870 | sub find | ||||
| 871 | { | ||||
| 872 | my ($self, $pkgname, @extra) = @_; | ||||
| 873 | |||||
| 874 | return $self->try_until_success($pkgname, | ||||
| 875 | sub { | ||||
| 876 | return $self->SUPER::find($pkgname, @extra); }); | ||||
| 877 | |||||
| 878 | } | ||||
| 879 | |||||
| 880 | sub grabPlist | ||||
| 881 | { | ||||
| 882 | my ($self, $pkgname, @extra) = @_; | ||||
| 883 | |||||
| 884 | return $self->try_until_success($pkgname, | ||||
| 885 | sub { | ||||
| 886 | return $self->SUPER::grabPlist($pkgname, @extra); }); | ||||
| 887 | } | ||||
| 888 | |||||
| 889 | sub list | ||||
| 890 | # spent 11.7s (71µs+11.7) within OpenBSD::PackageRepository::HTTPorFTP::list which was called:
# once (71µs+11.7s) by OpenBSD::PackageRepository::available at line 158 | ||||
| 891 | 1 | 1µs | my ($self) = @_; | ||
| 892 | 1 | 2µs | if (!defined $self->{list}) { | ||
| 893 | 1 | 16µs | 1 | 42µs | $self->make_room; # spent 42µs making 1 call to OpenBSD::PackageRepository::make_room |
| 894 | 1 | 10µs | 1 | 234µs | my $error = OpenBSD::Temp->file; # spent 234µs making 1 call to OpenBSD::Temp::file |
| 895 | 1 | 700ns | if (!defined $error) { | ||
| 896 | $self->{state}->fatal("#1 not writable", | ||||
| 897 | $OpenBSD::Temp::tempbase); | ||||
| 898 | } | ||||
| 899 | 1 | 8µs | 1 | 11.7s | $self->{list} = $self->obtain_list($error); # spent 11.7s making 1 call to OpenBSD::PackageRepository::HTTP::obtain_list |
| 900 | 1 | 12µs | 1 | 392µs | $self->parse_problems($error); # spent 392µs making 1 call to OpenBSD::PackageRepository::parse_problems |
| 901 | } | ||||
| 902 | 1 | 9µs | return $self->{list}; | ||
| 903 | } | ||||
| 904 | |||||
| 905 | sub get_http_list | ||||
| 906 | # spent 11.7s (237ms+11.5) within OpenBSD::PackageRepository::HTTPorFTP::get_http_list which was called:
# once (237ms+11.5s) by OpenBSD::PackageRepository::HTTP::obtain_list at line 937 | ||||
| 907 | 1 | 700ns | my ($self, $error) = @_; | ||
| 908 | |||||
| 909 | 1 | 3µs | 1 | 22µs | my $fullname = $self->url; # spent 22µs making 1 call to OpenBSD::PackageRepositoryBase::url |
| 910 | 1 | 1µs | my $l = []; | ||
| 911 | 1 | 29µs | 2 | 1.31ms | my $fh = $self->open_read_ftp(OpenBSD::Paths->ftp." -o - $fullname", # spent 1.30ms making 1 call to OpenBSD::PackageRepository::HTTPorFTP::open_read_ftp
# spent 9µs making 1 call to OpenBSD::Paths::ftp |
| 912 | $error) or return; | ||||
| 913 | 1 | 10.8s | 1 | 10.8s | while(<$fh>) { # spent 10.8s making 1 call to OpenBSD::PackageRepository::HTTPorFTP::CORE:readline |
| 914 | 9681 | 7.03ms | chomp; | ||
| 915 | 9681 | 657ms | 19362 | 579ms | for my $pkg (m/\<A[^>]*\s+HREF=\"(.*?\.tgz)\"/gio) { # spent 528ms making 9681 calls to OpenBSD::PackageRepository::HTTPorFTP::CORE:readline, avg 54µs/call
# spent 51.1ms making 9681 calls to OpenBSD::PackageRepository::HTTPorFTP::CORE:match, avg 5µs/call |
| 916 | 9658 | 49.5ms | 9658 | 7.70ms | $pkg = $1 if $pkg =~ m|^.*/(.*)$|; # spent 7.70ms making 9658 calls to OpenBSD::PackageRepository::HTTPorFTP::CORE:match, avg 797ns/call |
| 917 | # decode uri-encoding; from URI::Escape | ||||
| 918 | 9658 | 35.5ms | 9658 | 8.00ms | $pkg =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg; # spent 8.00ms making 9658 calls to OpenBSD::PackageRepository::HTTPorFTP::CORE:subst, avg 828ns/call |
| 919 | 9658 | 41.7ms | 9658 | 82.4ms | $self->add_to_list($l, $pkg); # spent 82.4ms making 9658 calls to OpenBSD::PackageRepository::add_to_list, avg 9µs/call |
| 920 | } | ||||
| 921 | } | ||||
| 922 | 1 | 22µs | 1 | 123µs | $self->close_read_ftp($fh); # spent 123µs making 1 call to OpenBSD::PackageRepository::HTTPorFTP::close_read_ftp |
| 923 | 1 | 13µs | return $l; | ||
| 924 | } | ||||
| 925 | |||||
| 926 | package OpenBSD::PackageRepository::HTTP; | ||||
| 927 | 1 | 4µs | our @ISA=qw(OpenBSD::PackageRepository::HTTPorFTP); | ||
| 928 | |||||
| 929 | sub urlscheme | ||||
| 930 | # spent 13µs within OpenBSD::PackageRepository::HTTP::urlscheme which was called 5 times, avg 3µs/call:
# 4 times (11µs+0s) by OpenBSD::PackageRepositoryBase::url at line 122 of OpenBSD/PackageRepository/Installed.pm, avg 3µs/call
# once (2µs+0s) by OpenBSD::PackageRepositoryBase::strip_urlscheme at line 100 of OpenBSD/PackageRepository/Installed.pm | ||||
| 931 | 5 | 22µs | return 'http'; | ||
| 932 | } | ||||
| 933 | |||||
| 934 | sub obtain_list | ||||
| 935 | # spent 11.7s (14µs+11.7) within OpenBSD::PackageRepository::HTTP::obtain_list which was called:
# once (14µs+11.7s) by OpenBSD::PackageRepository::HTTPorFTP::list at line 899 | ||||
| 936 | 1 | 1µs | my ($self, $error) = @_; | ||
| 937 | 1 | 14µs | 1 | 11.7s | return $self->get_http_list($error); # spent 11.7s making 1 call to OpenBSD::PackageRepository::HTTPorFTP::get_http_list |
| 938 | } | ||||
| 939 | |||||
| 940 | package OpenBSD::PackageRepository::HTTPS; | ||||
| 941 | 1 | 4µs | our @ISA=qw(OpenBSD::PackageRepository::HTTP); | ||
| 942 | |||||
| 943 | sub urlscheme | ||||
| 944 | { | ||||
| 945 | return 'https'; | ||||
| 946 | } | ||||
| 947 | |||||
| 948 | package OpenBSD::PackageRepository::FTP; | ||||
| 949 | 1 | 4µs | our @ISA=qw(OpenBSD::PackageRepository::HTTPorFTP); | ||
| 950 | |||||
| 951 | sub urlscheme | ||||
| 952 | { | ||||
| 953 | return 'ftp'; | ||||
| 954 | } | ||||
| 955 | |||||
| 956 | sub _list | ||||
| 957 | { | ||||
| 958 | my ($self, $cmd, $error) = @_; | ||||
| 959 | my $l =[]; | ||||
| 960 | my $fh = $self->open_read_ftp($cmd, $error) or return; | ||||
| 961 | while(<$fh>) { | ||||
| 962 | chomp; | ||||
| 963 | next if m/^\d\d\d\s+\S/; | ||||
| 964 | if (m/No such file or directory|Failed to change directory/i) { | ||||
| 965 | $self->{no_such_dir} = 1; | ||||
| 966 | } | ||||
| 967 | next unless m/^(?:\.\/)?(\S+\.tgz)\s*$/; | ||||
| 968 | $self->add_to_list($l, $1); | ||||
| 969 | } | ||||
| 970 | $self->close_read_ftp($fh); | ||||
| 971 | return $l; | ||||
| 972 | } | ||||
| 973 | |||||
| 974 | sub get_ftp_list | ||||
| 975 | { | ||||
| 976 | my ($self, $error) = @_; | ||||
| 977 | |||||
| 978 | my $fullname = $self->url; | ||||
| 979 | return $self->_list("echo 'nlist'| ".OpenBSD::Paths->ftp | ||||
| 980 | ." $fullname", $error); | ||||
| 981 | } | ||||
| 982 | |||||
| 983 | sub obtain_list | ||||
| 984 | { | ||||
| 985 | my ($self, $error) = @_; | ||||
| 986 | if (defined $ENV{'ftp_proxy'} && $ENV{'ftp_proxy'} ne '') { | ||||
| 987 | return $self->get_http_list($error); | ||||
| 988 | } else { | ||||
| 989 | return $self->get_ftp_list($error); | ||||
| 990 | } | ||||
| 991 | } | ||||
| 992 | |||||
| 993 | 1 | 9µs | 1; | ||
# spent 4µs within OpenBSD::PackageLocator::CORE:subst which was called 2 times, avg 2µs/call:
# once (3µs+0s) by OpenBSD::PackageLocator::add_default at line 49 of OpenBSD/PackageLocator.pm
# once (2µs+0s) by OpenBSD::PackageLocator::add_default at line 48 of OpenBSD/PackageLocator.pm | |||||
# spent 4µs within OpenBSD::PackageRepository::CORE:close which was called:
# once (4µs+0s) by OpenBSD::PackageRepository::parse_problems at line 358 | |||||
# spent 17.0ms within OpenBSD::PackageRepository::CORE:match which was called 9699 times, avg 2µs/call:
# 9672 times (17.0ms+0s) by OpenBSD::PackageRepository::add_to_list at line 381, avg 2µs/call
# 8 times (8µs+0s) by OpenBSD::PackageRepository::parse at line 126, avg 1µs/call
# 3 times (9µs+0s) by OpenBSD::PackageRepository::parse_problems at line 298, avg 3µs/call
# 3 times (7µs+0s) by OpenBSD::PackageRepository::parse_problems at line 296, avg 2µs/call
# 3 times (2µs+0s) by OpenBSD::PackageRepository::parse_problems at line 297, avg 700ns/call
# 2 times (2µs+0s) by OpenBSD::PackageRepository::parse_problems at line 299, avg 950ns/call
# once (10µs+0s) by OpenBSD::PackageRepository::parse_problems at line 300
# once (2µs+0s) by OpenBSD::PackageRepository::parse_problems at line 306
# once (1µs+0s) by OpenBSD::PackageRepository::parse_problems at line 305
# once (900ns+0s) by OpenBSD::PackageRepository::parse_problems at line 303
# once (900ns+0s) by OpenBSD::PackageRepository::parse_problems at line 301
# once (800ns+0s) by OpenBSD::PackageRepository::parse_problems at line 302
# once (800ns+0s) by OpenBSD::PackageRepository::parse_problems at line 304
# once (700ns+0s) by OpenBSD::PackageRepository::parse at line 145 | |||||
# spent 26µs within OpenBSD::PackageRepository::CORE:open which was called:
# once (26µs+0s) by OpenBSD::PackageRepository::parse_problems at line 284 | |||||
# spent 8µs within OpenBSD::PackageRepository::CORE:readline which was called 4 times, avg 2µs/call:
# 4 times (8µs+0s) by OpenBSD::PackageRepository::parse_problems at line 295, avg 2µs/call | |||||
# spent 36µs within OpenBSD::PackageRepository::CORE:regcomp which was called 2 times, avg 18µs/call:
# 2 times (36µs+0s) by OpenBSD::PackageRepository::parse_problems at line 299, avg 18µs/call | |||||
# spent 13µs within OpenBSD::PackageRepository::CORE:subst which was called 3 times, avg 4µs/call:
# 3 times (13µs+0s) by OpenBSD::PackageRepository::parse at line 118, avg 4µs/call | |||||
# spent 16µs within OpenBSD::PackageRepository::CORE:substcont which was called 2 times, avg 8µs/call:
# 2 times (16µs+0s) by OpenBSD::PackageRepository::parse at line 118, avg 8µs/call | |||||
# spent 61µs within OpenBSD::PackageRepository::CORE:unlink which was called:
# once (61µs+0s) by OpenBSD::PackageRepository::parse_problems at line 360 | |||||
# spent 2µs within OpenBSD::PackageRepository::Distant::CORE:match which was called:
# once (2µs+0s) by OpenBSD::PackageRepository::Distant::parse_url at line 583 | |||||
# spent 73µs within OpenBSD::PackageRepository::HTTPorFTP::CORE:close which was called:
# once (73µs+0s) by OpenBSD::PackageRepository::HTTPorFTP::close_read_ftp at line 817 | |||||
# spent 58.8ms within OpenBSD::PackageRepository::HTTPorFTP::CORE:match which was called 19339 times, avg 3µs/call:
# 9681 times (51.1ms+0s) by OpenBSD::PackageRepository::HTTPorFTP::get_http_list at line 915, avg 5µs/call
# 9658 times (7.70ms+0s) by OpenBSD::PackageRepository::HTTPorFTP::get_http_list at line 916, avg 797ns/call | |||||
# spent 1.11ms within OpenBSD::PackageRepository::HTTPorFTP::CORE:open which was called:
# once (1.11ms+0s) by OpenBSD::PackageRepository::HTTPorFTP::open_read_ftp at line 801 | |||||
# spent 11.4s within OpenBSD::PackageRepository::HTTPorFTP::CORE:readline which was called 9682 times, avg 1.17ms/call:
# 9681 times (528ms+0s) by OpenBSD::PackageRepository::HTTPorFTP::get_http_list at line 915, avg 54µs/call
# once (10.8s+0s) by OpenBSD::PackageRepository::HTTPorFTP::get_http_list at line 913 | |||||
# spent 8.00ms within OpenBSD::PackageRepository::HTTPorFTP::CORE:subst which was called 9658 times, avg 828ns/call:
# 9658 times (8.00ms+0s) by OpenBSD::PackageRepository::HTTPorFTP::get_http_list at line 918, avg 828ns/call | |||||
# spent 28µs within OpenBSD::PackageRepository::HTTPorFTP::CORE:waitpid which was called:
# once (28µs+0s) by OpenBSD::PackageRepository::HTTPorFTP::close_read_ftp at line 818 | |||||
# spent 800ns within OpenBSD::PackageRepository::Local::CORE:close which was called:
# once (800ns+0s) by OpenBSD::PackageRepository::Local::list at line 564 | |||||
# spent 111µs within OpenBSD::PackageRepository::Local::CORE:ftfile which was called 20 times, avg 6µs/call:
# 20 times (111µs+0s) by OpenBSD::PackageRepository::Local::list at line 561, avg 6µs/call | |||||
# spent 1.62ms within OpenBSD::PackageRepository::Local::CORE:open_dir which was called:
# once (1.62ms+0s) by OpenBSD::PackageRepository::Local::list at line 559 | |||||
# spent 75µs within OpenBSD::PackageRepository::Local::CORE:readdir which was called 21 times, avg 4µs/call:
# 21 times (75µs+0s) by OpenBSD::PackageRepository::Local::list at line 560, avg 4µs/call | |||||
# spent 2µs within OpenBSD::PackageRepository::file which was called:
# once (2µs+0s) by OpenBSD::PackageRepository::parse at line 150 | |||||
# spent 1µs within OpenBSD::PackageRepository::http which was called:
# once (1µs+0s) by OpenBSD::PackageRepository::parse at line 126 |