summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2004-01-27 14:50:53 +0000
committerMarc Espie <espie@cvs.openbsd.org>2004-01-27 14:50:53 +0000
commit644a222f2b8eadba27b873d39ed3507a1b789adb (patch)
treed849f72edb8a57ad78f6732f1e2c4bb106f91440 /usr.sbin
parent7ad973e337e04f36fa2df19675d574bb7560bb85 (diff)
first series of -forced switches, looks okay to henning@.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_add/pkg_add35
-rw-r--r--usr.sbin/pkg_add/pkg_add.119
-rw-r--r--usr.sbin/pkg_add/pkg_delete6
-rw-r--r--usr.sbin/pkg_add/pkg_delete.17
4 files changed, 54 insertions, 13 deletions
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index b891a77ccc0..5df10d1fabd 100644
--- a/usr.sbin/pkg_add/pkg_add
+++ b/usr.sbin/pkg_add/pkg_add
@@ -1,7 +1,7 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_add,v 1.23 2004/01/27 13:09:16 espie Exp $
+# $OpenBSD: pkg_add,v 1.24 2004/01/27 14:50:52 espie Exp $
#
# Copyright (c) 2003 Marc Espie.
#
@@ -126,6 +126,10 @@ if ($opt_f) {
%forced = map {($_, 1)} split(/,/, $opt_f);
}
+if ($< && !$forced{nonroot}) {
+ die "$0 must be run as root";
+}
+
my $conflict_list = {};
# first, find all possible potential conflicts
@@ -142,14 +146,14 @@ sub can_install($)
if (is_installed $pkgname) {
print "package $pkgname is already installed\n";
- return undef;
+ return undef unless $forced{installed};
}
while (my ($name, $l) = each %$conflict_list) {
if ($l->conflicts_with($pkgname)) {
print "package $pkgname conflicts with installed package $name\n";
$errors++;
- return undef;
+ return undef unless $forced{conflicts};
}
}
@@ -201,7 +205,7 @@ sub pre_add($$)
if ($l->conflicts_with(installed_packages())) {
print "package $pkg has conflicts\n";
$errors++;
- return undef;
+ return undef unless $forced{conflicts};
}
return $handle;
}
@@ -329,6 +333,17 @@ sub check_lib_specs
return 1;
}
+sub borked_script($)
+{
+ my $msg = shift;
+
+ if ($forced{scripts}) {
+ print "$msg borked\n";
+ } else {
+ die "$msg borked";
+ }
+}
+
sub really_add($)
{
my $handle = shift;
@@ -367,14 +382,16 @@ sub really_add($)
print "Require script: $dir",REQUIRE," $pkgname INSTALL\n" if $opt_v or $opt_n;
unless ($opt_n) {
chmod 0755, $dir.REQUIRE;
- system($dir.REQUIRE, $pkgname, "INSTALL") == 0 or die "require script borked";
+ system($dir.REQUIRE, $pkgname, "INSTALL") == 0 or
+ borked_script("require script");
}
}
if ($plist->has(INSTALL)) {
print "Install script: $dir",INSTALL," $pkgname PRE-INSTALL\n" if $opt_v or $opt_n;
unless ($opt_n) {
chmod 0755, $dir.INSTALL;
- system($dir.INSTALL, $pkgname, "PRE-INSTALL") == 0 or die "install script borked";
+ system($dir.INSTALL, $pkgname, "PRE-INSTALL") == 0 or
+ borked_script("install script");
}
}
@@ -398,7 +415,7 @@ sub really_add($)
unless ($opt_n) {
if (system($dir.INSTALL, $pkgname, "POST-INSTALL") != 0) {
print STDERR "install script for $pkgname borked\n";
- $errors++;
+ $errors++ unless $forced{scripts};
}
}
}
@@ -442,7 +459,7 @@ while (my $pkg = shift @todo) {
if ($plist->has('arch')) {
unless ($plist->{arch}->check()) {
print "$pkg is not for the right architecture\n";
- next MAINLOOP;
+ next MAINLOOP unless $forced{arch};
}
}
if (!defined $handle->{solved_dependencies}) {
@@ -466,7 +483,7 @@ while (my $pkg = shift @todo) {
if (!check_lib_specs('/usr/local', $dep->{libspec})) {
print "Can't install $pkg: incorrect libspec: ",
$dep->{libspec}, "\n";
- next MAINLOOP;
+ next MAINLOOP unless $forced{libdepends};
}
}
for my $dep (@{$handle->{solved_dependencies}}) {
diff --git a/usr.sbin/pkg_add/pkg_add.1 b/usr.sbin/pkg_add/pkg_add.1
index ad73b21b2b4..79a8e051be3 100644
--- a/usr.sbin/pkg_add/pkg_add.1
+++ b/usr.sbin/pkg_add/pkg_add.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pkg_add.1,v 1.9 2004/01/27 13:50:55 espie Exp $
+.\" $OpenBSD: pkg_add.1,v 1.10 2004/01/27 14:50:52 espie Exp $
.\"
.\" FreeBSD install - a package for the installation and maintenance
.\" of non-core utilities.
@@ -123,7 +123,22 @@ would be taken if it was.
Force installation of the package.
.Ar keys
is a comma-separated list of keywords that state what failsafes
-should be waived.
+should be waived.
+These include:
+.Bl -tag -width keyword
+.It Ar arch
+architecture recorded in package may not match.
+.It Ar conflicts
+package may conflict with other packages.
+.It Ar installed
+reinstall an existing package.
+.It Ar libdepends
+library specifications may not be fullfilled.
+.It Ar nonroot
+install even if not running as root.
+.It Ar scripts
+install scripts may fail.
+.El
.El
.Pp
By default, when adding packages via FTP, the
diff --git a/usr.sbin/pkg_add/pkg_delete b/usr.sbin/pkg_add/pkg_delete
index 5c4dd6aada4..b4b7a2e9839 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.19 2004/01/27 13:09:16 espie Exp $
+# $OpenBSD: pkg_delete,v 1.20 2004/01/27 14:50:52 espie Exp $
#
# Copyright (c) 2003 Marc Espie.
#
@@ -327,6 +327,10 @@ if ($opt_f) {
%forced = map {($_, 1)} split(/,/, $opt_f);
}
+if ($< && !$forced{nonroot}) {
+ die "$0 must be run as root";
+}
+
my %done;
my $removed;
diff --git a/usr.sbin/pkg_add/pkg_delete.1 b/usr.sbin/pkg_add/pkg_delete.1
index e9251c1f9de..d641659780b 100644
--- a/usr.sbin/pkg_add/pkg_delete.1
+++ b/usr.sbin/pkg_add/pkg_delete.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pkg_delete.1,v 1.4 2004/01/27 13:09:16 espie Exp $
+.\" $OpenBSD: pkg_delete.1,v 1.5 2004/01/27 14:50:52 espie Exp $
.\"
.\" FreeBSD install - a package for the installation and maintenance
.\" of non-core utilities.
@@ -64,6 +64,11 @@ Force removal of the package.
.Ar keys
is a comma-separated list of keywords that state what failsafes
should be waived.
+These include:
+.Bl -tag -width keyword
+.It Ar nonroot
+install even if not running as root.
+.El
.It Fl c
Delete extra configuration file, mentioned as
.Bd -literal