diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2004-09-18 09:27:06 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2004-09-18 09:27:06 +0000 |
commit | 09b99511f272f8ef9662bb36e013887082e2f3ae (patch) | |
tree | 8078c2085aef328d679c19e0d9ed0c066fb1488f /usr.sbin | |
parent | a1dbaddef93361a8d7a9cf36787e598f5e23ff26 (diff) |
full support for @shell: insert shells into /etc/shells if they're
not already there, and remove them on deinstall.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 23 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_delete | 29 |
2 files changed, 50 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index 918aec4c2ab..a4fd519094d 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.54 2004/09/14 22:53:17 espie Exp $ +# $OpenBSD: pkg_add,v 1.55 2004/09/18 09:27:05 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -173,6 +173,27 @@ sub install "install-info", "--info-dir=".dirname($fullname), $fullname); } +package OpenBSD::PackingElement::Shell; +sub install +{ + my ($self, $archive, $destdir, $verbose, $not) = @_; + $self->SUPER::install($archive, $destdir, $verbose, $not); + return if $not; + my $fullname = $self->fullname(); + # go append to /etc/shells if needed + open(my $shells, '<', $destdir.'/etc/shells') or return; + local $_; + while(<$shells>) { + s/^\#.*//; + return if $_ =~ m/^\Q$fullname\E\s*$/; + } + close($shells); + open(my $shells2, '>>', $destdir.'/etc/shells') or return; + print $shells2 $fullname, "\n"; + close $shells2; + print "Shell $fullname appended to $destdir/etc/shells\n"; +} + package OpenBSD::PackingElement::Dir; sub install { diff --git a/usr.sbin/pkg_add/pkg_delete b/usr.sbin/pkg_add/pkg_delete index ac4dda9694d..9338f85ffcf 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.42 2004/09/14 22:58:30 espie Exp $ +# $OpenBSD: pkg_delete,v 1.43 2004/09/18 09:27:05 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -274,6 +274,33 @@ sub delete $self->SUPER::delete($state); } +package OpenBSD::PackingElement::Shell; +sub delete +{ + my ($self, $state) = @_; + unless ($state->{not}) { + my $destdir = $state->{destdir}; + my $fullname = $self->fullname(); + my @l=(); + if (open(my $shells, '<', $destdir.'/etc/shells')) { + local $_; + while(<$shells>) { + push(@l, $_); + s/^\#.*//; + if ($_ =~ m/^\Q$fullname\E\s*$/) { + pop(@l); + } + } + close($shells); + open(my $shells2, '>', $destdir.'/etc/shells'); + print $shells2 @l; + close $shells2; + print "Shell $fullname removed from $destdir/etc/shells\n"; + } + } + $self->SUPER::delete($state); +} + package OpenBSD::PackingElement::Extra; sub delete { |