openSUSE / zypper

World's most powerful command line package manager
http://en.opensuse.org/Portal:Zypper
Other
405 stars 110 forks source link

Zypper ignoring piped inputs. #560

Closed PowerSnail closed 1 month ago

PowerSnail commented 1 month ago

It seems that zypper ignores piped stdin entirely.

For example, let's say zypper dup is encountering a conflict that needs a user-input for resolution,

echo 'c' | zypper dup

...does not do anything. Zypper still waits for the inputs from terminal.

I'm aware that this is a contrived example, since there are more robust ways to tell zypper to cancel on conflict. But it does illustrate the problem.

Thanks!


I've searched the man page and github issues tracker, and didn't find a solution or duplicate issue.

mlandres commented 1 month ago

@PowerSnail maybe a duplicate of bsc#1227205. If so, it should be fixed with zypper-1.14.75.

PowerSnail commented 1 month ago

I don't think that is the case. I have 1.14.76, and it's still not working for me.

mlandres commented 1 month ago

You are right. I checked the code and actually this behavior is intended.

Regarding conflict resolution there is no guarantee that problems and solutions will appear in the same order in different zypper calls. So accepting piped input to resolve them could lead to unexpected results.

PowerSnail commented 1 month ago

I understand the point that automating conflict resolution isn't something that is supported.

What I'm trying to do is to wrap zypper within another script, which calls zypper dup and also some other updates not handled by zypper. When it comes to resolution, I'm still reading the stdout and selecting the resolution manually, it's just being passed in through another layer.

I guess the only way to do that would be to simulate a tty to run zypper?

mlandres commented 1 month ago

Yes. Zypper does a fopen("/dev/tty", "r") to read the prompt reply.

PowerSnail commented 1 month ago

Thanks.