diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 41 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add | 26 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_add.1 | 4 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_delete | 35 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_delete.1 | 8 |
5 files changed, 59 insertions, 55 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index a6328086e07..0ed55e2fdb5 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.48 2004/10/11 10:30:34 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.49 2004/10/11 13:10:25 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -963,9 +963,9 @@ our %fonts_todo = (); sub install { - my ($self, $archive, $destdir, $verbose, $not) = @_; - $self->SUPER::install($archive, $destdir, $verbose, $not); - $fonts_todo{$destdir.$self->fullname()} = 1; + my ($self, $state) = @_; + $self->SUPER::install($state); + $fonts_todo{$state->{destdir}.$self->fullname()} = 1; } sub reload @@ -1065,6 +1065,30 @@ package OpenBSD::PackingElement::FCONTENTS; our @ISA=qw(OpenBSD::PackingElement::SpecialFile); sub category() { OpenBSD::PackageInfo::CONTENTS } +package OpenBSD::PackingElement::ScriptFile; +our @ISA=qw(OpenBSD::PackingElement::SpecialFile); +use OpenBSD::Error; + +sub run +{ + my ($self, $state, @args) = @_; + + my $dir = $state->{dir}; + my $verbose = $state->{verbose}; + my $not = $state->{not}; + my $pkgname = $state->{pkgname}; + my $name = $self->{name}; + + return if $state->{dont_run_scripts}; + + main::ensure_ldconfig($verbose) unless $not; + print $self->beautify(), " script: $dir$name $pkgname ", join(' ', @args), "\n" if $state->{beverbose}; + return if $not; + chmod 0755, $dir.$name; + return if System($dir.$name, $pkgname, @args) == 0; + Fatal $self->beautify()." script borked"; +} + package OpenBSD::PackingElement::FCOMMENT; our @ISA=qw(OpenBSD::PackingElement::SpecialFile); sub category() { OpenBSD::PackageInfo::COMMENT } @@ -1074,16 +1098,19 @@ our @ISA=qw(OpenBSD::PackingElement::SpecialFile); sub category() { OpenBSD::PackageInfo::DESC } package OpenBSD::PackingElement::FINSTALL; -our @ISA=qw(OpenBSD::PackingElement::SpecialFile); +our @ISA=qw(OpenBSD::PackingElement::ScriptFile); sub category() { OpenBSD::PackageInfo::INSTALL } +sub beautify() { "Install" } package OpenBSD::PackingElement::FDEINSTALL; -our @ISA=qw(OpenBSD::PackingElement::SpecialFile); +our @ISA=qw(OpenBSD::PackingElement::ScriptFile); sub category() { OpenBSD::PackageInfo::DEINSTALL } +sub beautify() { "Deinstall" } package OpenBSD::PackingElement::FREQUIRE; -our @ISA=qw(OpenBSD::PackingElement::SpecialFile); +our @ISA=qw(OpenBSD::PackingElement::ScriptFile); sub category() { OpenBSD::PackageInfo::REQUIRE } +sub beautify() { "Require" } package OpenBSD::PackingElement::FREQUIRED_BY; our @ISA=qw(OpenBSD::PackingElement::SpecialFile); diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index d138db72f76..4e65bb0768a 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.69 2004/10/11 12:50:09 espie Exp $ +# $OpenBSD: pkg_add,v 1.70 2004/10/11 13:10:25 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -367,6 +367,7 @@ if ($< && !$forced{nonroot}) { $state->{conflict_list} = {}; $state->{not} = $opt_n; +$state->{dont_run_scripts} = $opt_I; $state->{verbose} = $opt_v; $state->{beverbose} = $opt_n || $opt_v; @@ -671,18 +672,9 @@ sub validate_plist($$) sub do_script { - my ($plist, $dir, $name, $msg, $pkgname, $args, $opt_v, $opt_n) = @_; + my ($plist, $name, $state, $args) = @_; return unless $plist->has($name); - ensure_ldconfig($opt_v) unless $opt_n; - print "$msg script: $dir$name $pkgname $args\n" if $opt_v or $opt_n; - return if $opt_n; - chmod 0755, $dir.$name; - return if System($dir.$name, $pkgname, $args) == 0; - if ($forced{scripts}) { - Warn "$msg borked\n"; - } else { - Fatal "$msg borked"; - } + $plist->get($name)->run($state, $args); } sub manpages_index @@ -711,6 +703,8 @@ sub really_add($$) my $dir = $handle->info(); my $pkgname = $plist->pkgname(); $state->{archive} = $handle; + $state->{dir} = $dir; + $state->{pkgname} = $pkgname; validate_plist($plist, $destdir); @@ -725,9 +719,9 @@ sub really_add($$) $interrupted = 1; }; - do_script($plist, $dir, REQUIRE, "Require", $pkgname, "INSTALL", $verbose, $not); + do_script($plist, REQUIRE, $state, "INSTALL"); - do_script($plist, $dir, INSTALL, "Install", $pkgname, "PRE-INSTALL", $verbose, $not) unless $opt_I; + do_script($plist, INSTALL, $state, "PRE-INSTALL"); $plist->{done} = []; for my $item (@{$plist->{groups}}, @{$plist->{users}}, @{$plist->{items}}) { @@ -744,8 +738,8 @@ sub really_add($$) manpages_index($plist, $destdir); $handle->close(); - if (!$opt_I && !$interrupted) { - eval { do_script($plist, $dir, INSTALL, "Install", $pkgname, "POST-INSTALL", $verbose, $not) }; + if (!$interrupted) { + eval { do_script($plist, INSTALL, $state, "POST-INSTALL") }; if ($@) { Warn $@; $errors++; diff --git a/usr.sbin/pkg_add/pkg_add.1 b/usr.sbin/pkg_add/pkg_add.1 index b554769ec87..09c00f2d545 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.17 2004/10/11 10:07:37 espie Exp $ +.\" $OpenBSD: pkg_add.1,v 1.18 2004/10/11 13:10:25 espie Exp $ .\" .\" FreeBSD install - a package for the installation and maintenance .\" of non-core utilities. @@ -121,7 +121,7 @@ Automated package installation, do not record packages as installed manually. .It Fl v Turn on verbose output. .It Fl I -If an installation script exists for a given package, do not execute it. +If scripts exist for a given package, do not execute them. .It Fl n Don't actually install a package, just report the steps that would be taken if it was. diff --git a/usr.sbin/pkg_add/pkg_delete b/usr.sbin/pkg_add/pkg_delete index 575f9b92048..16757c23b22 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.51 2004/10/11 12:31:02 espie Exp $ +# $OpenBSD: pkg_delete,v 1.52 2004/10/11 13:10:25 espie Exp $ # # Copyright (c) 2003-2004 Marc Espie <espie@openbsd.org> # @@ -452,18 +452,7 @@ sub delete { my ($self, $state) = @_; - my $dir = $state->{dir}; - my $opt_v = $state->{verbose}; - my $opt_n = $state->{not}; - my $pkgname = $state->{pkgname}; - - main::ensure_ldconfig($opt_v) unless $opt_n; - print "Require script: $dir",REQUIRE," $pkgname DEINSTALL\n" if $opt_v or $opt_n; - unless ($opt_n) { - chmod 0755, $dir.REQUIRE; - System($dir.REQUIRE, $pkgname, "DEINSTALL") == 0 or - Fatal "Require script borked"; - } + $self->run($state, "DEINSTALL"); } package OpenBSD::PackingElement::FDEINSTALL; @@ -474,17 +463,7 @@ sub delete { my ($self, $state) = @_; - my $dir = $state->{dir}; - my $opt_v = $state->{verbose}; - my $opt_n = $state->{not}; - my $pkgname = $state->{pkgname}; - main::ensure_ldconfig($opt_v) unless $opt_n; - print "Deinstall script: $dir",DEINSTALL ," $pkgname DEINSTALL\n" if $opt_v or $opt_n; - unless ($opt_n) { - chmod 0755, $dir.DEINSTALL; - System($dir.DEINSTALL, $pkgname, "DEINSTALL") == 0 or - Fatal "deinstall script borked"; - } + $self->run($state, "DEINSTALL"); } package OpenBSD::PackingElement::FUNDISPLAY; @@ -502,7 +481,7 @@ sub delete package main; -our ($opt_v, $opt_D, $opt_d, $opt_n, $opt_f, $opt_q, $opt_p, $opt_c, $opt_L, $opt_B); +our ($opt_v, $opt_D, $opt_d, $opt_n, $opt_f, $opt_q, $opt_p, $opt_c, $opt_L, $opt_B, $opt_I); sub remove_packing_info { @@ -596,7 +575,10 @@ sub delete_package remove_packing_info($dir) unless $opt_n; } -getopts('vcDdnf:qpS:L:B:'); +getopts('vcDdnf:qpS:L:B:I'); +if ($opt_D) { + $opt_I = 1; +} $opt_B = $ENV{'PKG_DESTDIR'} unless defined $opt_B; $opt_B = '' unless defined $opt_B; if ($opt_B ne '') { @@ -630,6 +612,7 @@ $state->{quick} = $opt_q; $state->{verbose} = $opt_v; $state->{beverbose} = $opt_n || $opt_v; $state->{extra} = $opt_c; +$state->{dont_run_scripts} = $opt_I; $ENV{'PKG_DELETE_EXTRA'} = $state->{extra} ? "Yes" : "No"; # First, resolve pkg names diff --git a/usr.sbin/pkg_add/pkg_delete.1 b/usr.sbin/pkg_add/pkg_delete.1 index bd6bf6751ab..119ca4c145a 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.9 2004/10/11 10:07:37 espie Exp $ +.\" $OpenBSD: pkg_delete.1,v 1.10 2004/10/11 13:10:25 espie Exp $ .\" .\" FreeBSD install - a package for the installation and maintenance .\" of non-core utilities. @@ -25,7 +25,7 @@ .Nd a utility for deleting previously installed software package distributions .Sh SYNOPSIS .Nm pkg_delete -.Op Fl cDnqv +.Op Fl cDInqv .Op Fl B Ar pkg-destdir .Op Fl f Ar keys .Ar pkgname Op Ar ... @@ -59,8 +59,8 @@ Set as the prefix to prepend to any object deleted. .It Fl v Turn on verbose output. -.It Fl D -If a deinstallation script exists for a given package, do not execute it. +.It Fl I +If scripts exist for a given package, do not execute them. .It Fl n Don't actually deinstall a package, just report the steps that would be taken if it were. |