Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

Thanks!

share|improve this question

2 Answers 2

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
1  
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. –  arx 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'

UPDATE

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. –  arx 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 ... –  arx Apr 19 '12 at 11:58

Your Answer

 
discard

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.