summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2004-10-13 18:39:08 +0000
committerMarc Espie <espie@cvs.openbsd.org>2004-10-13 18:39:08 +0000
commit79f73b643600b9cb3b1cf392b4b4d9ea232c4eea (patch)
tree851b0ff6f6dac438782f88d04736c28daaa95751
parentd0f9c6c45637daa9cb66a59e59d0a059a0831915 (diff)
@sysctl
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingElement.pm25
-rw-r--r--usr.sbin/pkg_add/pkg_add28
2 files changed, 51 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
index 1294d8d4cbb..0470b2fb9d9 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackingElement.pm,v 1.54 2004/10/12 21:05:20 espie Exp $
+# $OpenBSD: PackingElement.pm,v 1.55 2004/10/13 18:39:07 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -861,6 +861,29 @@ sub destate
}
}
+package OpenBSD::PackingElement::Sysctl;
+our @ISA=qw(OpenBSD::PackingElement::Action);
+
+__PACKAGE__->setKeyword('sysctl');
+sub keyword() { 'sysctl' }
+
+sub new
+
+{
+ my ($class, $args) = @_;
+ if ($args =~ m/^\s*(.*)\s*(\=|\>=)\s*(.*)\s*$/) {
+ bless { name => $1, mode => $2, value => $3}, $class;
+ } else {
+ die "Bad syntax for \@sysctl";
+ }
+}
+
+sub stringize
+{
+ my $self = $_[0];
+ return $self->{name}.$self->{mode}.$self->{value};
+}
+
package OpenBSD::PackingElement::ExeclikeAction;
use File::Basename;
use OpenBSD::Error;
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 750640758a4..ab6c87ffbe0 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.75 2004/10/12 09:35:15 espie Exp $
+# $OpenBSD: pkg_add,v 1.76 2004/10/13 18:39:07 espie Exp $
#
# Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org>
#
@@ -145,6 +145,32 @@ sub install
}
}
+package OpenBSD::PackingElement::Sysctl;
+use OpenBSD::Error;
+
+sub install
+{
+ my ($self, $state) = @_;
+
+ my $name = $self->{name};
+ open(my $pipe, '-|', '/sbin/sysctl', $name);
+ my $actual = <$pipe>;
+ chomp $actual;
+ $actual =~ s/^\Q$name\E\s*\=\s*//;
+ if ($self->{mode} eq '=' && $actual eq $self->{value}) {
+ return;
+ }
+ if ($self->{mode} eq '>=' && $actual >= $self->{value}) {
+ return;
+ }
+ if ($state->{not}) {
+ print "sysctl -w $name != ".
+ $self->{value}, "\n";
+ return;
+ }
+ VSystem($state->{verbose}, '/sbin/sysctl', $name.'='.$self->{value});
+}
+
package OpenBSD::PackingElement::FileBase;
use OpenBSD::Error;
use File::Basename;