openSUSE / zypper

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

Zypper ignoring piped inputs. #560

Closed PowerSnail closed 4 months ago

PowerSnail commented 4 months 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 4 months ago

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

PowerSnail commented 4 months ago

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

mlandres commented 4 months 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 4 months 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 4 months ago

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

PowerSnail commented 4 months ago

Thanks.