#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgAdd.pm,v 1.118 2019/12/08 10:35:17 espie Exp $
+# $OpenBSD: PkgAdd.pm,v 1.119 2021/06/28 11:25:14 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
$state->tracker->cant($set);
return ();
}
+ # sets with only tags can be updated without temp files while skipping
+ # installing
if ($set->older_to_do) {
require OpenBSD::Replace;
- if (!OpenBSD::Replace::is_set_safe($set, $state)) {
- $state->{bad}++;
- $set->cleanup(OpenBSD::Handle::CANT_INSTALL, "exec detected");
- $state->tracker->cant($set);
- return ();
- }
+ $set->{simple_update} =
+ OpenBSD::Replace::set_has_no_exec($set, $state);
+ } else {
+ $set->{simple_update} = 1;
+ }
+ if ($state->verbose && !$set->{simple_update}) {
+ $state->say("Update Set #1 runs exec commands", $set->print);
}
may_tie_files($set, $state);
if ($set->newer > 0 || $set->older_to_do > 0) {
# ex:ts=8 sw=4:
-# $OpenBSD: Replace.pm,v 1.90 2018/02/27 22:46:53 espie Exp $
+# $OpenBSD: Replace.pm,v 1.91 2021/06/28 11:25:14 espie Exp $
#
# Copyright (c) 2004-2014 Marc Espie <espie@openbsd.org>
#
use OpenBSD::Delete;
package OpenBSD::PackingElement;
-sub can_update
+sub scan_for_exec
{
- my ($self, $installing, $state) = @_;
-
- my $issue = $self->update_issue($installing);
-
- if (defined $issue) {
- push(@{$state->{journal}}, $issue);
- }
}
-sub update_issue { undef }
-
package OpenBSD::PackingElement::Exec;
-sub update_issue
+sub scan_for_exec
{
- my ($self, $installing) = @_;
- return if !$installing;
- return '@'.$self->keyword.' '.$self->{expanded};
+ my ($self, $installing, $r) = @_;
+ $$r = 1 if $installing;
}
package OpenBSD::PackingElement::ExecAdd;
-sub update_issue { undef }
+sub scan_for_exec {}
package OpenBSD::PackingElement::Unexec;
-sub update_issue
+sub scan_for_exec
{
- my ($self, $installing) = @_;
-
- return if $installing;
-
- return '@'.$self->keyword.' '.$self->{expanded};
+ my ($self, $installing, $r) = @_;
+ $$r = 1 if !$installing;
}
package OpenBSD::PackingElement::UnexecDelete;
-sub update_issue { undef }
+sub scan_for_exec { }
package OpenBSD::Replace;
-sub check_plist_exec
-{
- my ($plist, $state, $new) = @_;
-
- $state->{journal} = [];
- $plist->can_update($new, $state);
- return 1 if @{$state->{journal}} == 0;
-
- $state->errsay(($new ? "New": "Old").
- " package #1 will run the following commands", $plist->pkgname);
- for my $i (@{$state->{journal}}) {
- if ($new) {
- $state->errsay("+ #1", $i);
- } else {
- $state->errsay("- #1", $i);
- }
- }
- return 0;
-}
-
-sub can_old_package_be_replaced
+sub pkg_has_exec
{
- my ($plist, $state) = @_;
- return check_plist_exec($plist, $state, 0);
-}
+ my ($pkg, $new) = @_;
-sub is_new_package_safe
-{
- my ($plist, $state) = @_;
- return check_plist_exec($plist, $state, 1);
+ my $has_exec = 0;
+ $pkg->plist->scan_for_exec($new, \$has_exec);
+ return $has_exec;
}
-sub is_set_safe
+sub set_has_no_exec
{
my ($set, $state) = @_;
-
- if (!$state->defines('paranoid') && !$state->verbose) {
- return 1;
- }
-
- my $ok = 1;
-
for my $pkg ($set->older) {
- $ok = 0 unless can_old_package_be_replaced($pkg->plist, $state);
+ return 0 if pkg_has_exec($pkg, 0);
}
for my $pkg ($set->newer) {
- $ok = 0 unless is_new_package_safe($pkg->plist, $state);
+ return 0 if pkg_has_exec($pkg, 1);
}
- return 1 if $ok;
-
- if (!$state->defines('paranoid')) {
- $state->errsay("Running update");
- return 1;
- } elsif ($state->is_interactive) {
- if ($state->confirm_defaults_to_no(
- "proceed with update anyway")) {
- return 1;
- } else {
- return 0;
- }
- } else {
- $state->errsay("Cannot install #1",
- $set->print);
- return 0;
- }
+ return 1;
}
-
1;
-.\" $OpenBSD: pkg_add.1,v 1.164 2021/02/10 22:04:14 espie Exp $
+.\" $OpenBSD: pkg_add.1,v 1.165 2021/06/28 11:25:14 espie Exp $
.\"
.\" Documentation and design originally from FreeBSD. All the code has
.\" been rewritten since. We keep the documentation's notice:
.\" Jordan K. Hubbard
.\"
.\"
-.Dd $Mdocdate: February 10 2021 $
+.Dd $Mdocdate: June 28 2021 $
.Dt PKG_ADD 1
.Os
.Sh NAME
In update mode, reinstall an existing package with the same update signature.
.It Cm nonroot
Install even if not running as root.
-.It Cm paranoid
-Very safe update: don't run any @exec/@unexec.
-This may break some packages that will need manual intervention.
.It Cm repair
Attempt to repair installed packages with missing registration data.
.It Cm scripts