On Mon Dec 21, 2020 at 11:20:31AM +0000, Stuart Henderson wrote:
> On 2020/12/21 10:24, Rafael Sadowski wrote:
> > ping
> 
> I don't think this makes sense, you already have "pkg_delete -D
> dependencies" for this case.
>

No this is not my (use) case. My use case: How to remove all kf5 5.76.0
packages without user interaction.

$ pkg_info -q |grep 5.76 | xargs doas pkg_delete
breeze-icons-5.76.0: ok
kactivities-stats-5.76.0: ok
kcalendarcore-5.76.0: ok
can't delete kcmutils-5.76.0 without deleting ktouch-20.08.3
kwalletmanager-20.08.3
can't delete kcontacts-5.76.0v0 without deleting
akonadi-contacts-20.08.3
can't delete kdeclarative-5.76.0 without deleting kcmutils-5.76.0
ktouch-20.08.3
kdnssd-5.76.0: ok
kf5-baloo-5.76.0v0: ok
kf5-icons-baloo-5.76.0: ok
can't delete kf5-kactivities-5.76.0 without deleting okular-20.08.3
kf5-kfilemetadata-5.76.0: ok
can't delete khtml-5.76.0 without deleting okular-20.08.3
kidletime-5.76.0: ok
can't delete kjs-5.76.0 without deleting khtml-5.76.0 okular-20.08.3
knotifyconfig-5.76.0p0: ok
kplotting-5.76.0: ok
can't delete kpty-5.76.0 without deleting okular-20.08.3
krunner-5.76.0: ok
can't delete plasma-framework-5.76.0 without deleting kmix-20.08.3
can't delete oxygen-icons-5.76.0 without deleting
plasma-framework-5.76.0
can't delete prison-kf5-5.76.0 without deleting akonadi-contacts-20.08.3
can't delete purpose-5.76.0 without deleting okular-20.08.3
sonnet-aspell-5.76.0: ok
can't delete threadweaver-5.76.0 without deleting okular-20.08.3
Running tags: ok
Read shared items: ok

not all packages removed

$ pkg_info -q |grep 5.76 | xargs doas pkg_delete -y
can't delete kcmutils-5.76.0 without deleting ktouch-20.08.3
kwalletmanager-20.08.3
kwalletmanager-20.08.3: ok
ktouch-20.08.3: ok
kcmutils-5.76.0: ok
can't delete kcontacts-5.76.0v0 without deleting
akonadi-contacts-20.08.3
akonadi-contacts-20.08.3: ok
kcontacts-5.76.0v0: ok
can't delete plasma-framework-5.76.0 without deleting kmix-20.08.3
kmix-20.08.3: ok
kdeclarative-5.76.0:plasma-framework-5.76.0: ok
kdeclarative-5.76.0: ok
can't delete kf5-kactivities-5.76.0 without deleting okular-20.08.3
okular-20.08.3: ok
kf5-kactivities-5.76.0: ok
khtml-5.76.0: ok
kjs-5.76.0: ok
kpty-5.76.0: ok
oxygen-icons-5.76.0: ok
prison-kf5-5.76.0: ok
purpose-5.76.0: ok
threadweaver-5.76.0: ok
Running tags: ok
Read shared items: ok

... all trash removed.

>
> And -n kind-of implies a pairing with -n,
> but -n is for something different (more of a "dry-run" mode).
> 
> > On Fri Nov 27, 2020 at 07:41:21AM +0100, Rafael Sadowski wrote:
> > > The following diff adds "-y" support in pkg_delete and pkg_add. The 
> > > option is
> > > quit simple when a yes/no prompt would be presented, assume that the user
> > > entered "yes". I often need that for pkg_delete when I work on KDE 
> > > updates.
> > > 
> > > A simple example:
> > > 
> > > $ doas pkg_delete prison-kf5-5.76.0
> > > can't delete prison-kf5-5.76.0 without deleting akonadi-contacts-20.08.3
> > > Delete them as well ? [y/N/a]
> > > 
> > > $ doas pkg_delete -y prison-kf5-5.76.0
> > > can't delete prison-kf5-5.76.0 without deleting akonadi-contacts-20.08.3
> > > can't delete akonadi-contacts-20.08.3 without deleting digikam-7.1.0p0
> > > digikam-7.1.0p0: ok
> > > akonadi-contacts-20.08.3: ok
> > > prison-kf5-5.76.0: ok
> > > Running tags: ok
> > > Read shared items: ok
> > > 
> > > Feedback, Ok?
> > > 
> > > Rafael
> > > 
> > > Index: pkg_add.1
> > > ===================================================================
> > > RCS file: /cvs/src/usr.sbin/pkg_add/pkg_add.1,v
> > > retrieving revision 1.163
> > > diff -u -p -r1.163 pkg_add.1
> > > --- pkg_add.1     24 Jan 2020 21:10:46 -0000      1.163
> > > +++ pkg_add.1     27 Nov 2020 06:38:45 -0000
> > > @@ -502,6 +502,8 @@ also shows dependencies adjustments, and
> > >  shows everything.
> > >  .It Fl x
> > >  Disable progress meter.
> > > +.It Fl y
> > > +When a yes/no prompt would be presented, assume that the user entered 
> > > "yes".
> > >  .It Fl z
> > >  Fuzzy package addition:
> > >  .Nm
> > > Index: pkg_delete.1
> > > ===================================================================
> > > RCS file: /cvs/src/usr.sbin/pkg_add/pkg_delete.1,v
> > > retrieving revision 1.59
> > > diff -u -p -r1.59 pkg_delete.1
> > > --- pkg_delete.1  10 Jul 2018 10:20:51 -0000      1.59
> > > +++ pkg_delete.1  27 Nov 2020 06:38:45 -0000
> > > @@ -169,6 +169,8 @@ shows everything.
> > >  Delete everything, except the list of packages that follow.
> > >  .It Fl x
> > >  Disable progress meter.
> > > +.It Fl y
> > > +When a yes/no prompt would be presented, assume that the user entered 
> > > "yes".
> > >  .El
> > >  .Sh TECHNICAL DETAILS
> > >  .Nm
> > > Index: OpenBSD/AddCreateDelete.pm
> > > ===================================================================
> > > RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm,v
> > > retrieving revision 1.48
> > > diff -u -p -r1.48 AddCreateDelete.pm
> > > --- OpenBSD/AddCreateDelete.pm    11 Jan 2020 13:46:39 -0000      1.48
> > > +++ OpenBSD/AddCreateDelete.pm    27 Nov 2020 06:38:45 -0000
> > > @@ -88,9 +88,11 @@ sub handle_options
> > >   }
> > >   if ($i) {
> > >           require OpenBSD::Interactive;
> > > -         $state->{interactive} = OpenBSD::Interactive->new($state, $i);
> > > +         $state->{interactive} = OpenBSD::Interactive->new($state, $i,
> > > +             $state->opt('y'));
> > >   }
> > > - $state->{interactive} //= OpenBSD::InteractiveStub->new($state);
> > > + $state->{interactive} //= OpenBSD::InteractiveStub->new($state,
> > > +     $state->opt('y'));
> > >  }
> > >  
> > >  
> > > @@ -209,8 +211,11 @@ sub try_and_run_command
> > >  package OpenBSD::InteractiveStub;
> > >  sub new
> > >  {
> > > - my $class = shift;
> > > - bless {}, $class;
> > > + my ($class, $state, $always) = @_;
> > > + bless {
> > > +     state => $state,
> > > +     always => $always,
> > > + }, $class;
> > >  }
> > >  
> > >  sub ask_list
> > > @@ -222,6 +227,9 @@ sub ask_list
> > >  sub confirm
> > >  {
> > >   my ($self, $prompt, $yesno) = @_;
> > > + if ($self->{always}) {
> > > +         return 1;
> > > + }
> > >   return $yesno;
> > >  }
> > >  
> > > Index: OpenBSD/AddDelete.pm
> > > ===================================================================
> > > RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/AddDelete.pm,v
> > > retrieving revision 1.93
> > > diff -u -p -r1.93 AddDelete.pm
> > > --- OpenBSD/AddDelete.pm  11 Jan 2020 13:46:39 -0000      1.93
> > > +++ OpenBSD/AddDelete.pm  27 Nov 2020 06:38:45 -0000
> > > @@ -231,7 +231,7 @@ sub handle_options
> > >   };
> > >   $state->{no_exports} = 1;
> > >   $state->add_interactive_options;
> > > - $state->SUPER::handle_options($opt_string.'aciInqsVB:', @usage);
> > > + $state->SUPER::handle_options($opt_string.'aciInqsyVB:', @usage);
> > >  
> > >   if ($state->opt('s')) {
> > >           $state->{not} = 1;
> > > Index: OpenBSD/FwUpdate.pm
> > > ===================================================================
> > > RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/FwUpdate.pm,v
> > > retrieving revision 1.32
> > > diff -u -p -r1.32 FwUpdate.pm
> > > --- OpenBSD/FwUpdate.pm   11 Feb 2020 16:20:05 -0000      1.32
> > > +++ OpenBSD/FwUpdate.pm   27 Nov 2020 06:38:45 -0000
> > > @@ -67,7 +67,7 @@ sub handle_options
> > >   $state->{localbase} = OpenBSD::Paths->localbase;
> > >   $state->{destdir} = '';
> > >   $state->{wantntogo} = 0;
> > > - $state->{interactive} = OpenBSD::InteractiveStub->new($state);
> > > + $state->{interactive} = OpenBSD::InteractiveStub->new($state, 0);
> > >   $state->{subst}->add('repair', 1);
> > >   if ($state->opt('a') && @ARGV != 0) {
> > >           $state->usage;
> > > Index: OpenBSD/Interactive.pm
> > > ===================================================================
> > > RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/Interactive.pm,v
> > > retrieving revision 1.22
> > > diff -u -p -r1.22 Interactive.pm
> > > --- OpenBSD/Interactive.pm        26 Feb 2018 13:53:31 -0000      1.22
> > > +++ OpenBSD/Interactive.pm        27 Nov 2020 06:38:45 -0000
> > > @@ -21,10 +21,10 @@ package OpenBSD::Interactive;
> > >  
> > >  sub new
> > >  {
> > > - my ($class, $state, $level) = @_;
> > > + my ($class, $state, $level, $always) = @_;
> > >   bless {
> > >       state => $state,
> > > -     always => 0,
> > > +     always => $always,
> > >       level => $level,
> > >   }, $class;
> > >  }
> > > Index: OpenBSD/PkgAdd.pm
> > > ===================================================================
> > > RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm,v
> > > retrieving revision 1.118
> > > diff -u -p -r1.118 PkgAdd.pm
> > > --- OpenBSD/PkgAdd.pm     8 Dec 2019 10:35:17 -0000       1.118
> > > +++ OpenBSD/PkgAdd.pm     27 Nov 2020 06:38:45 -0000
> > > @@ -113,7 +113,7 @@ sub handle_options
> > >  {
> > >   my $state = shift;
> > >   $state->SUPER::handle_options('druUzl:A:P:',
> > > -     '[-adcinqrsUuVvxz] [-A arch] [-B pkg-destdir] [-D name[=value]]',
> > > +     '[-adcinqrsUuVvxyz] [-A arch] [-B pkg-destdir] [-D name[=value]]',
> > >       '[-L localbase] [-l file] [-P type] pkg-name ...');
> > >  
> > >   $state->{arch} = $state->opt('A');
> > > Index: OpenBSD/PkgDelete.pm
> > > ===================================================================
> > > RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PkgDelete.pm,v
> > > retrieving revision 1.47
> > > diff -u -p -r1.47 PkgDelete.pm
> > > --- OpenBSD/PkgDelete.pm  9 Jun 2019 09:36:24 -0000       1.47
> > > +++ OpenBSD/PkgDelete.pm  27 Nov 2020 06:38:45 -0000
> > > @@ -101,7 +101,7 @@ sub handle_options
> > >  {
> > >   my $state = shift;
> > >   $state->SUPER::handle_options('X',
> > > -     '[-acimnqsVvXx] [-B pkg-destdir] [-D name[=value]] [pkg-name ...]');
> > > +     '[-acimnqsVvXxy] [-B pkg-destdir] [-D name[=value]] [pkg-name 
> > > ...]');
> > >  
> > >   $state->{exclude} = $state->opt('X');
> > >  }
> > > 
> > 

Reply via email to