How to install patterns and packages at the same time?

9,151

Solution 1

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

Solution 2

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:
9,151

Related videos on Youtube

gatoatigrado
Author by

gatoatigrado

see website (zoratung.com)

Updated on September 18, 2022

Comments

  • gatoatigrado
    gatoatigrado over 1 year

    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!

  • Mikel
    Mikel almost 12 years
    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.
  • gatoatigrado
    gatoatigrado almost 12 years
    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.)
  • Mikel
    Mikel almost 12 years
    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?
  • gatoatigrado
    gatoatigrado almost 12 years
    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!
  • llua
    llua almost 12 years
    #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
    llua almost 12 years
    but it is always possible just list whats in each pattern and add the packages to one huge zypper install ...
  • llua
    llua almost 12 years
    the answer wasn't documented in zypper's man page for some weird reason.