I have a few questions about moving from apt-get to zypper in bash scripts.
What is the equivalent of this?
sudo apt-get install curl --assume-yes
(where curl could be any package)
I found the Zypper Cheat Sheet – openSUSE. Very nice! But I would appreciate the voice of experience here — what's the right way to use zypper in a script where I want to auto agree to all prompts and not skip things that need a response?
With my inexperience I would be tempted to use:
sudo zypper --non-interactive --no-gpg-checks --quiet install --auto-agree-with-licenses curl
But is that really the equivalent of --assume-yes
?
What about the equivalent for these?
sudo apt-get autoremove -y
sudo apt-get autoclean -y
This suggests there isn't one…
Is there a replacement for gdebi-core? Or is gdebi not ever needed with zypper's "powerful satisfiability solver"? I use gdebi for situations where I need to install a package on an older version and I have a .deb file already (but not all the dependencies).
Best Answer
In general, you should use
--non-interactive
mode, in shortcut-n
, when running zypper non-interactively:That might seem confusing for someone coming from
apt-get install -y curl
. Some zypper sub-commands also support a command-specific-y
/--no-confirm
option as an alias for-n
/--non-interactive
, but not all sub-commands do. As theinstall
command does implement that, this command is equivalent to the above:Note that the
-y
must come afterinstall
, while the global-n
option comes before the subcommand (zypper install -n
means something different; read the man page for that).[Edit] The section below is no longer accurate, but is retained for historical reference. Current zypper supports the
--gpg-auto-import-keys
option to automatically import and trust the gpg keys associated with a new repository.According to documentation there's no way how to accept a GPG key without interactive mode:
Even with
--no-gpgp-checks
the GPG key will be rejected.A workaround for scripts is to use pipe and
echo
: