Re: Various bugs with the new 5.7 kernel on Fedora 32

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sreyan Chakravarty wrote:
> 
> On 7/27/20 12:23 AM, Todd Zullinger wrote:
>> Refer to the "SPECIFYING PACKAGES" section in the dnf man
>> page.  It explains the syntax options you can use to
>> specify a <package-spec>, which is used by many dnf
>> commands, like dnf remove.
> 
> The doc is all good but without some real examples I find
> it difficult to translate the doc to actual commands.
> 
> But that's probably because I am a noob and not use to
> reading docs seriously yet.

Yeah, I can still remember that.  And it still happens to me
with some documentation. :)

In the example below, I used kernel*-5.7.* as the package
spec.  To turn that into an example which helps illustrate
the man page, let's break it up...

The subsection "NEVRA Matching" lists the forms dnf accepts.
For kernel*-5.7.*, we're matching the name-[epoch:]version
form (the '[epoch:]' portion means it's optional to provide
the Epoch portion (that's the E in NEVRA¹).

So kernel* is the Name part and 5.7.* is the Version part in
the specification.  As both have globs in them, we look at
the Globs section which says:

    *      Matches any number of characters.

That's what allows the package-spec to match all the kernel
subpackages.  (In theory, you could list them all out using
the '{}' notation -- but I think that's either buggy or
incorrect documentation.  It likely relies on the shell's
brace expansion rather than dnf's.)

We do the same '*' glob to match kernel patch releases like
5.7.9 or 5.7.10.  We could use 5.7* there, but then it would
match 5.70 (and any other 5.7x version).  While that isn't a
real problem in this case, with one extra '.' the pattern
can be explicit about what we want.

¹ The others are Name, Version, Release, and Architecture,
  just to be be clear.

>> As you'll find in the man page, dnf accepts glob patterns,
>> which are much like shell glob patterns.  You can use them
>> to remove all 5.7 kernels, something like:
>> 
>>      $ sudo dnf remove 'kernel*-5.7.*'
> 
> Would this have had the same effect as:
> 
>     sudo dnf remove $(rpm -qa | grep ^kernel | grep 5\.7)
> 
> ??

Indeed.  And without the cost of forking several
subprocesses.  (Those extra subprocesses don't cost enough
to matter here, but in some cases they can be much more
expensive.  I try to avoid them when I can easily do so and
where doing so doesn't come at the expense of readability of
the resulting command line.)

Similar to dnf, rpm's query option (-q or --query) accepts
globs.  So if I were doing rpm -qa, I'd drop the first grep
pattern and use:

    rpm -qa 'kernel*' | grep -- '-5\.7'

I think it's worth noting that the grep pattern should be
quoted too, or otherwise escaped so the '\' makes it to
grep.  As written (grep 5\.7), the pattern which grep gets
after the shell parses it is 5.7.  Since '.' is a regular
expression metacharacter which means "any character", 'grep
5\.7' would match 5N7, 507, and all sorts of things.  Again,
that doesn't happen to cause false positives in this case,
but that's relying a bit too much on luck and it _will_ burn
you some day.

>> Similarly, you can use the patterns to avoid the need for
>> the pipe to grep above (which also didn't need the -i
>> option, as your argument is numeric):
>> 
>>      $ sudo dnf list installed 'kernel*-5.7.*'
> Yeah I tried this but this does not give the name of the packages in a way I
> can use in 'dnf remove' command, thus it was not very helpful.

That's the thing, you can use the same pattern to dnf
remove, so you don't have to futz around copying and pasting
the output at all.  That's both error-prone and waste of
time. :)

If you _do_ need such output from dnf, you can control the
format a lot more using the repoquery subcommand.  It
accepts the --qf (or --queryformat) option.  With that, you
can format the output almost any way you'd like.  The
default output from repoquery is much more suitable already:

    $ sudo dnf repoquery --installed 'kernel*-5.7*'

The --qf option could be used as:

    --qf "%{name}-%{version}-%{release}"

But that's common enough that there's a shortcut to it, the
--nvr option:

    $ sudo dnf repoquery --installed --nvr 'kernel*-5.7*'

The --qf / --queryformat option in dnf behaves almost
exactly like the corresponding option in rpm.  In dnf, there
are a few additional query tags, like the repo a package
comes from, which rpm does not have.  But they're pretty
close to identical in most respects.

Hope that's helpful.  It should give you some concrete
examples to think of while reading the man page.  And then
you can experiment with dnf list or dnf repoquery to see how
the patterns apply.

P.S.: Unlike some other mail lists, we tend not to include
each other in the To or Cc fields for replies.  The list
requires a subscription to post, so anyone who has sent a
message is a member and can read replies via the list. :)

-- 
Todd

Attachment: signature.asc
Description: PGP signature

_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux