Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I install package patterns (e.g. "C/C++ development tools") and packages (e.g. "mercurial") at the same time? Currently, two commands are necessary; for example, the installation instructions I wrote for sketch-frontend are,

sudo zypper install -t pattern "devel_C_C++" "devel_java"
sudo zypper install java-1_6_0-openjdk-devel mercurial

[ link ].

(motivation). It's true one only needs two commands, but on machines with slower internet connections (or slower processors), not having the second command automatically continue is annoying. Also, the user does need to be prompted for package resolution, so just adding the --non-interactive flag is not an option.


share|improve this question

edit: appending <resolveabletype>: to the resolvable allows you to match different types in one command it seems.

zypper in java-1_6_0-openjdk-devel mercurial +pattern:devel_C_C++ +pattern:devel_java

creating a one-click install will let you do package resolution in one go, but i am unsure if a pattern can be called from within one. http://en.opensuse.org/openSUSE:One_Click_Install_ISV#Create_a_web_install_link you could then call it with oci /sbin/OCICLI /path/to/foobar.ymp

share|improve this answer
Looks good. Had to look up the syntax of zypper to see that in this case sh means zypper shell and in means zypper install. – Mikel Apr 19 '12 at 4:41
the answer wasn't documented in zypper's man page for some weird reason. – llua Apr 19 '12 at 12:42

Simplest solution:

sudo zypper install -t pattern "devel_C_C++" "devel_java" && sudo zypper install java-1_6_0-openjdk-devel mercurial

If you're worried that sudo will time out after 5 minutes and you don't want the user to have to type their password twice, you could do

sudo sh -c 'zypper install -t pattern "devel_C_C++" "devel_java" && zypper install java-1_6_0-openjdk-devel mercurial'


Since it sounds like you wanted it all to be a single call to zypper install, a few more ideas:

  1. run zypper search or zypper list twice, parse the package names, combine the output, and run zipper install once with a full list of packages
  2. run zypper install --dry-run to print the output, then ask the user to confirm, then run zypper install without the dry-run option if the user answers yes
  3. run zypper install --download-only twice with a custom packages dir, then run zypper install <that directory>/*.rpm (see mktemp -d and the packagesdir option in zypp.conf
share|improve this answer
The idea was to have zypper prompt for resolutions all in one go. The problem with your solution is that after the first command will finish, it will hang waiting for user input. (which, supposing the user has switched tasks since downloading may take time, is bad.) – gatoatigrado Apr 19 '12 at 5:03
Is it possible to parse the output of the info or search subcommands? Or use the --dry-run option to print what would happen, then ask the user to press Y or N, and then re-run the same command without the --dry-run option? – Mikel Apr 19 '12 at 5:35
It's not just "yes or no", in some cases the user needs to select a resolution option (Zypper prints out 3 choices, e.g. "do not install X", "downgrade Y", "uninstall Z"). Don't spend too much time on it if llua's answer works (I'll test it soon), thanks anyway! – gatoatigrado Apr 19 '12 at 6:23
#3 looks like it'll would work and will get package solution in one run, but it would be two commands again. @gatoatigrado i don't think you will be able to get this in 'one command' & 'one package resolution' without more work on your end. ie one-click install. – llua Apr 19 '12 at 11:52
but it is always possible just list whats in each pattern and add the packages to one huge zypper install ... – llua Apr 19 '12 at 11:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.