From bbecd1b033463c7aae152af0aeea310ba6466f3a Mon Sep 17 00:00:00 2001 From: espie Date: Mon, 28 Jun 2021 11:25:14 +0000 Subject: [PATCH] remove old "paranoid" option, I'm pretty sure nobody uses it. refactor the code into figuring out simple updates: if we don't have any @execs but just @tags, we can probably do something simpler wrt temporary files and temporary filenames, which should speed up texlive updates significantly. (the tempfile code is not there yet, just the check for safe updates) --- usr.sbin/pkg_add/OpenBSD/PkgAdd.pm | 17 ++--- usr.sbin/pkg_add/OpenBSD/Replace.pm | 98 ++++++----------------------- usr.sbin/pkg_add/pkg_add.1 | 7 +-- 3 files changed, 31 insertions(+), 91 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm index 67ce5be2d0a..938ba77148b 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm @@ -1,7 +1,7 @@ #! /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 # @@ -1024,14 +1024,17 @@ sub process_set $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) { diff --git a/usr.sbin/pkg_add/OpenBSD/Replace.pm b/usr.sbin/pkg_add/OpenBSD/Replace.pm index 2c5596d701b..e1dddc78b3d 100644 --- a/usr.sbin/pkg_add/OpenBSD/Replace.pm +++ b/usr.sbin/pkg_add/OpenBSD/Replace.pm @@ -1,5 +1,5 @@ # 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 # @@ -20,111 +20,51 @@ use warnings; 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; diff --git a/usr.sbin/pkg_add/pkg_add.1 b/usr.sbin/pkg_add/pkg_add.1 index 734a7748221..84abcc31017 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.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: @@ -15,7 +15,7 @@ .\" Jordan K. Hubbard .\" .\" -.Dd $Mdocdate: February 10 2021 $ +.Dd $Mdocdate: June 28 2021 $ .Dt PKG_ADD 1 .Os .Sh NAME @@ -341,9 +341,6 @@ Don't filter out package versions older than what's currently installed. 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 -- 2.20.1