Using zypper, how can I remove all packages installed from a specific repository?

13,323

Solution 1

I think there is no such command. You can list packages from specific repository:

zypper search --installed-only --repo devel:tools

or all orphaned packages if you've already removed that repository:

zypper packages --orphaned

Then you could try to cut package names from the output and pass it to zypper remove if it's worth the effort.

Solution 2

You can use a combination of zypper search, awk and xargs to remove all packages from a repository. For example:

zypper se --repo openSUSE-Tumbleweed-Debug --installed | awk '/^i(\+|\s)/ {print $3}' | xargs sudo zypper rm
Share:
13,323

Related videos on Youtube

Brandon
Author by

Brandon

Updated on September 18, 2022

Comments

  • Brandon
    Brandon over 1 year

    Say I've added a repository using zypper ar. Then, I've gone and installed multiple packages from that repository, but now I want to remove all of them.

    Is there a command that allows me to remove all the packages that I've installed just from that specific repository?

  • Push
    Push almost 10 years
    My openSuSE 12.3 system does not have the --orphaned option, but this might work: zypper packages -i -R: it lists the installed package in Reverse order of repository.
  • Mesco
    Mesco about 6 years
    awk '/^i(\+|\s)/ {print $3}' to match all installed packages (i or i+)
  • sebix
    sebix about 6 years
    @Mesco zypper itself should only print installed packages when using --installed.
  • Mesco
    Mesco about 6 years
    right, using -i or --installed-only. But also I've search for i and i+ at the beggining to skip first few rows (Loading repository data...). Maybe there are better methods, to skip first 5 rows but if you already use regex... ;)
  • Mesco
    Mesco about 6 years
    maybe I'm using different zypper version (1.14.4) but its man says that the order should be se [options] [query] so your solution didn't work.
  • sebix
    sebix about 6 years
    Ah, now I understand your concern. I updated the answer. About the search-syntax: I only use options and no query, so the order is correct I think.