On 2023-08-04 18:06:24 +0200, Sven Joachim wrote:
> On 2023-08-04 01:57 +0200, Vincent Lefevre wrote:
> 
> > On 2023-08-03 16:52:07 +0200, Sven Joachim wrote:
[...]
> >> It should prevent these errors from showing up in the first place.
> >
> > If aptitude knows what to do (or may ignore the issue), yes.
> 
> I was a bit imprecise, actually I meant that aptitude-changelog-parser
> should not emit these warnings to stderr, which is what #967911 is about.
> 
> >> See #967911, which has been tagged "pending" almost three years ago. :-(
> >
> > I forgot about this one.
> 
> Since the screen flashes created by aptitude-changelog-parser's warnings
> have been annoying me for so long, I have now created a merge request to
> cherry-pick the fix for unstable:
> 
> https://salsa.debian.org/apt-team/aptitude/-/merge_requests/20

First, I don't understand

  But we cannot currently change that verbose default when using
  changelog_parse() from Dpkg::Changelog::Parse.

in the patch. The following works as expected:

--- a/aptitude-changelog-parser 2022-08-06 05:45:53.000000000 +0200
+++ b/aptitude-changelog-parser 2023-08-05 10:55:39.291911672 +0200
@@ -15,6 +15,7 @@
 # Usage: aptitude-changelog-parser [<filename> [<from-version>]]
 
 my %opts;
+$opts{verbose} = 0;
 if (scalar @ARGV >= 1) {
     $opts{file} = shift @ARGV;
 }

This silences warnings from

sub parse_error {
    my ($self, $file, $line_nr, $error, $line) = @_;

    push @{$self->{parse_errors}}, [ $file, $line_nr, $error, $line ];

    if ($self->{verbose}) {
        if ($line) {
            warning("%20s(l$line_nr): $error\nLINE: $line", $file);
        } else {
            warning("%20s(l$line_nr): $error", $file);
        }
    }
}

in /usr/share/perl5/Dpkg/Changelog.pm.

Now, silenting such warnings for changelog_parse() will fix issues
like this one, but it will not fix the general problem with warnings
and errors.

For instance, aptitude-changelog-parser has

eval {
    require Dpkg::Changelog::Parse;
    Dpkg::Changelog::Parse->import();
    1;
} or do {
    warn "warning: Dpkg::Changelog::Parse not present, install libdpkg-perl\n";
    exit 0;
};

at the beginning, and this warning, which is important and must still
be output, will still quickly disappear. BTW, the "exit 0;" is also
incorrect, but that's another issue (bug 1043050, which I've just
reported).

And concerning errors, /usr/share/perl5/Dpkg/Changelog/Parse.pm has

    error(g_('changelog format %s is unknown: %s'), $format, $@) if $@;
    error(g_('changelog format %s is not a Dpkg::Changelog class'), $format)
        unless $changes->isa('Dpkg::Changelog');

and

        error(g_('unknown output format %s'), $options{format});

In /usr/share/perl5/Dpkg/ErrorHandling.pm, this corresponds to

sub error($;@)
{
    die report(REPORT_ERROR, @_);
}

This will not be silenced by "$SIG{__WARN__} = sub {};" like in your
patch. I don't think these fatal errors should be silenced at all,
but currently, they will also quickly disappear.

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

_______________________________________________
Aptitude-devel mailing list
Aptitude-devel@alioth-lists.debian.net
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/aptitude-devel

Reply via email to