Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving unnecessary notice about empty rpm packages to debug message. #615

Closed

Conversation

snevolin
Copy link

This notice makes a problem when you want to process an output of rpm -ql of an empty rpm package in a shell script.

Example:
$ rpm -ql gpg-pubkey-f2ee9d55-560cfc0a
(contains no files)
$ rpm -ql gpg-pubkey-f2ee9d55-560cfc0a | wc -l
1

But the package is empty!

This notice makes a problem when you want to process an output of rpm -ql of an empty rpm package in a shell script.
@Conan-Kudo
Copy link
Member

Isn't that what the --quiet switch is for...? I'm not sure this patch makes sense...

@snevolin
Copy link
Author

Isn't that what the --quiet switch is for...?

No, definitely no. Because --quiet switch suppresses all output, so the output of rpm -ql of a normal package with a set of files included in will be also empty.

Example:
$ rpm -ql bzip2-devel-1.0.6-28.fc29.x86_64 | wc -l
6
$ rpm -ql --quiet bzip2-devel-1.0.6-28.fc29.x86_64 | wc -l
0

So you can't use --quiet switch to get number of package's files in a shell script.

Copy link
Member

@Conan-Kudo Conan-Kudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pmatilai
Copy link
Member

This (spewing "helpful" messages into stdout) is a much broader problem than just this one message, and we should address them all at once or not at all. As much as mostly everybody hates these "helpful" messages, changing them will break some scripts that expect them there, so if/when breakage is necessary it's better to break clean once than a little bit here in one release and some other bit in the next etc.

@andreas-schwab
Copy link
Contributor

You can use rpm -q --qf='%{FILENAMES:arraysize}\n' to get the number of files.

@snevolin
Copy link
Author

snevolin commented Dec 21, 2018

changing them will break some scripts that expect them there

No, you can't even rely on this behavior in scripts, because this message (contains no files) is locale-dependent. You can't use it.

Example:
$ LANG=C rpm -ql gpg-pubkey-f2ee9d55-560cfc0a
(contains no files)
$ LANG=ru_RU.UTF8 rpm -ql gpg-pubkey-f2ee9d55-560cfc0a
(не содержит файлов)

@snevolin
Copy link
Author

You can use rpm -q --qf='%{FILENAMES:arraysize}\n' to get the number of files.

Ok. And what about getting a list of included files? Do you have a dirty trick for that? And why we can't just trust rpm -ql to do this simple task?

@herrold
Copy link

herrold commented Dec 21, 2018

if the problem is an empty file being queried, why not solve teh problem where the action occurs (before the test), with something simple like:

[ -s $ARG ] && ...

I don't see that this is the rpm binary's issue

@dima-takoy-zz
Copy link

dima-takoy-zz commented Dec 21, 2018

I don't see that this is the rpm binary's issue

I completely disagree with this imprisonment.

You (or your team ) made strange, unpopular decision that makes problems for simple (popular, expected) case. Other software put this warning to stderr or just return nothing with success code.

You forced developers to produce hardcode that forces bugs with different behaviors in environments.

Software shouldn't force you to write bad code.

@ignatenkobrain makes same pr previusly.

@andreas-schwab
Copy link
Contributor

You can get the list of files with rpm -q --qf='[%{FILENAMES}\n]'. There is nothing dirty about that, those are the building blocks.

@dima-takoy-zz
Copy link

You can get the list of files with rpm -q --qf='[%{FILENAMES}\n]'. There is nothing dirty about that, those are the building blocks.

So, for what rpm -ql ?

And, as example same behaviour of ls (Why you have OWN WAY and why this solution right?):

$ mkdir empty_dir
$ cd empty_dir/
$ ls
$ echo $?
0

@andreas-schwab
Copy link
Contributor

For the same reason there is ls when a script uses *.

@snevolin
Copy link
Author

snevolin commented Dec 21, 2018

I think that the patch fixes an ERROR in user interface of rpm utility.
When a user asks for a list of package's files he wants to get exactly the list of files, doesn't he? And if there's no files in the package then he wants to get an empty output, doesn't he? Why instead of empty output he gets a text message (according to user's locale)? I think it looks unpredictable and non intuitive.

Also look at PO files of the project. Some of translators understand this issue and got rid of this message from translations (i.e. po/sl.po, po/da.po, po/id.po and some others).

@pmatilai
Copy link
Member

pmatilai commented Jan 2, 2019

Like said, this is a generic problem in rpm where diagnostic messages are dumped on stdout. Other similar examples include (but not limited to):

[pmatilai@sopuli ~]$ rpm -q --whatprovides bar
no package provides bar
[pmatilai@sopuli ~]$ touch foo
[pmatilai@sopuli ~]$ rpm -qf foo
file /home/pmatilai/foo is not owned by any package

All spewed into stdout against core unix principles. But the world is full of scripts that grep specifically for these messages because they've always been there. And so there are scripts that test for empty packages by grepping specifically for that "(contains no files)" message, and changing it would break those scripts. Ditto for all the other similar cases. And that's exactly why we need to address the generic problem rather than individual messages so we can do a clean break that people can also then adjust to, once.

I fully agree the rpm behavior is in error, but this is not the right fix to the overall problem. NAK.

@pmatilai pmatilai closed this Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants