0

I am trying to install a package via zypper package manager in SUSE Micro OS.

I am trying to automate the software package installation with help of a bash/shell script.

$ zypper install libopenssl-devel
Loading repository data...
Reading installed packages...
Resolving package dependencies...

Problem: nothing provides libopenssl0_9_8 = 0.9.8h needed by libopenssl-devel-0.9.8h-30.11.x86_64
 Solution 1: do not install libopenssl-devel-0.9.8h-30.11.x86_64
 Solution 2: break libopenssl-devel-0.9.8h-30.11.x86_64 by ignoring some of its dependencies

Choose from above solutions by number or cancel [1/2/c] (c):

As part of the process, I would like to pre-select solution 2, that is, I need a way to choose the preferred solution in the script itself.

I tried some options and it didn't work. All the below options choose option c which is the default behaviour.

zypper install libopenssl-devel <<< echo "2"
echo "2" | zypper install libopenssl-devel
zypper -n install --force libopenssl-devel

I can't use the rpm package manager.

  • 3
    Does this answer your question? [Passing arguments to an interactive program non-interactively](https://stackoverflow.com/questions/14392525/passing-arguments-to-an-interactive-program-non-interactively) – Ahmet Said Akbulut Jul 01 '21 at 14:03
  • You can try `zypper --non-interactive ...` – LMC Jul 01 '21 at 14:23
  • Hello @LMC, I tried that. It didn't worked for me. – Kumaresan P Jul 09 '21 at 11:22
  • Hello @AhmetSaidAkbulut, I tried that. It didn't work for me. – Kumaresan P Jul 09 '21 at 11:23
  • I would like to emphasise the question. The issue is more with the zypper command itself; not on the script side. Need help on how to provide the pre-selection for the zypper command in the script itself so that, the zypper will use that selection. – Kumaresan P Jul 09 '21 at 11:27

1 Answers1

1

yes command should do it. Also take a look here for other methods => https://stackoverflow.com/a/53465375/14320738

$ yes 2 | zypper install libopenssl-devel

Edit

Create an expect script:

[root@10 folder]# cat expctscript
#!/usr/bin/expect -f
spawn bash -c "yum install perl"
expect "Is this ok"
send "N\r"
interact

make it an executable file to avoid permission denied error.

[root@10 folder]# chmod +x expctscript 

run expctscript

[root@10 folder]# ./expctscript

Output

[root@10 folder]# ./expctscript
spawn bash -c yum install perl
Last metadata expiration check: 1:40:25 ago on Wed 07 Jul 2021 11:05:58 AM +03.
Dependencies resolved.
================================================================================
 Package                      Arch   Version                    Repository
                                                                           Size
================================================================================
Installing:
 perl                         x86_64 4:5.26.3-419.el8           AppStream  73 k
...
...
...
...
...
...
Transaction Summary
================================================================================
Install  113 Packages
Upgrade    3 Packages

Total download size: 18 M
Is this ok [y/N]: N
Operation aborted.
[root@10 folder]#

note: I can't test installing libopenssl-devel on my centOS as it is a Suse package. So modify expctscript content accordingly.