diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2012-04-28 15:22:50 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2012-04-28 15:22:50 +0000 |
commit | a7bc54da116f679023f7d44d1ee1a2b1fe5e140e (patch) | |
tree | a2a187a148265445ed693b432e06087326d990ad /usr.sbin | |
parent | a48e7989f38d175aea2bab66e110dc3f13bf1af5 (diff) |
File::Path::rmtree is very stupid and spews out warning messages if there's
no cwd.
Well, if there's no cwd, we don't care about getting back there, so wrap
rmtree to just move to / before calling the real rmtree.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Error.pm | 14 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepository.pm | 7 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Temp.pm | 6 |
3 files changed, 20 insertions, 7 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Error.pm b/usr.sbin/pkg_add/OpenBSD/Error.pm index 6e5f42a9a9e..8aee71a8c74 100644 --- a/usr.sbin/pkg_add/OpenBSD/Error.pm +++ b/usr.sbin/pkg_add/OpenBSD/Error.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Error.pm,v 1.30 2010/12/24 09:04:14 espie Exp $ +# $OpenBSD: Error.pm,v 1.31 2012/04/28 15:22:49 espie Exp $ # # Copyright (c) 2004-2010 Marc Espie <espie@openbsd.org> # @@ -196,6 +196,18 @@ sub catchall(&) bless $_[0], "OpenBSD::Error::catchall"; } +sub rmtree +{ + my $class = shift; + require File::Path; + require Cwd; + + # XXX make sure we live somewhere + Cwd::getcwd() || chdir('/'); + + File::Path::rmtree(@_); +} + package OpenBSD::Error::catch; sub exec { diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm index 55e663e6784..47b86d1cf26 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageRepository.pm,v 1.94 2011/08/26 08:46:10 espie Exp $ +# $OpenBSD: PackageRepository.pm,v 1.95 2012/04/28 15:22:49 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org> # @@ -29,6 +29,7 @@ our @ISA=(qw(OpenBSD::PackageRepositoryBase)); use OpenBSD::PackageLocation; use OpenBSD::Paths; +use OpenBSD::Error; sub baseurl { @@ -104,6 +105,8 @@ sub parse if (m/^ftp\:/io) { return $class->ftp->parse_fullurl($r, $state); } elsif (m/^http\:/io) { +# require OpenBSD::PackageRepository::HTTP; + return $class->http->parse_fullurl($r, $state); } elsif (m/^https\:/io) { return $class->https->parse_fullurl($r, $state); @@ -156,7 +159,7 @@ sub wipe_info my $dir = $pkg->{dir}; if (defined $dir) { - File::Path::rmtree($dir); + OpenBSD::Error->rmtree($dir); delete $pkg->{dir}; } } diff --git a/usr.sbin/pkg_add/OpenBSD/Temp.pm b/usr.sbin/pkg_add/OpenBSD/Temp.pm index e7892f7c1b6..d57940720fa 100644 --- a/usr.sbin/pkg_add/OpenBSD/Temp.pm +++ b/usr.sbin/pkg_add/OpenBSD/Temp.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Temp.pm,v 1.24 2012/04/27 12:52:57 espie Exp $ +# $OpenBSD: Temp.pm,v 1.25 2012/04/28 15:22:49 espie Exp $ # # Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org> # @@ -30,13 +30,11 @@ my $dirs = {}; my $files = {}; my $cleanup = sub { - require File::Path; - while (my ($name, $pid) = each %$files) { unlink($name) if $pid == $$; } while (my ($dir, $pid) = each %$dirs) { - File::Path::rmtree([$dir]) if $pid == $$; + OpenBSD::Error->rmtree([$dir]) if $pid == $$; } }; |