summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/pkg_delete
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2003-12-21 18:41:24 +0000
committerMarc Espie <espie@cvs.openbsd.org>2003-12-21 18:41:24 +0000
commite4f77a8787305c794f97b808b09e12679092c052 (patch)
tree4fe08ad7a9de73c56c594d6eb13d97eb843d914f /usr.sbin/pkg_add/pkg_delete
parentea056ddbeaa034e795d4767e2705c140eb0686c1 (diff)
Add virtual file system, so that pkg_add and pkg_delete can check for
read-only status, or size concerns, before even beginning to add/remove files. Allows pkg_add -n and pkg_delete -n to be more thorough as well. Some testing by Todd Millert, comments by Greg Steuck and Sam Smith.
Diffstat (limited to 'usr.sbin/pkg_add/pkg_delete')
-rw-r--r--usr.sbin/pkg_add/pkg_delete17
1 files changed, 15 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/pkg_delete b/usr.sbin/pkg_add/pkg_delete
index 8fdca93dbba..e12a164c3df 100644
--- a/usr.sbin/pkg_add/pkg_delete
+++ b/usr.sbin/pkg_add/pkg_delete
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_delete,v 1.15 2003/12/10 11:43:52 espie Exp $
+# $OpenBSD: pkg_delete,v 1.16 2003/12/21 18:41:23 espie Exp $
#
# Copyright (c) 2003 Marc Espie.
#
@@ -32,6 +32,7 @@ use OpenBSD::PackingList;
use OpenBSD::PackageInfo;
use OpenBSD::RequiredBy;
use OpenBSD::Logger;
+use OpenBSD::Vstat;
package OpenBSD::PackingElement;
sub delete
@@ -272,6 +273,19 @@ sub delete_package
die "Package $pkgname real name does not match";
}
+ my $problems = 0;
+ for my $item (@{$plist->{items}}) {
+ next unless $item->IsFile();
+ my $fname = $item->fullname();
+ my $s = OpenBSD::Vstat::remove($fname, $item->{size});
+ next unless defined $s;
+ if ($s->{ro}) {
+ print "Error: ", $s->{mnt}, " is read-only ($fname)\n";
+ $problems++;
+ }
+ }
+ die if $problems;
+
$ENV{'PKG_PREFIX'} = '/usr/local';
if ($plist->has(REQUIRE)) {
$plist->get(REQUIRE)->delete($state);
@@ -294,7 +308,6 @@ sub delete_package
remove_packing_info($dir) unless $opt_n;
}
-
getopts('vcDdnfqpS:');
if (defined $opt_p) {