4

I just upgraded to OpenSUSE 12.2 from OpenSUSE 12.1 by changing all of my repositories to target 12.2 (instead of 12.1). Now that I've upgraded, I've found a bunch of packages that have no repository*, which the YaST Software Manager marks with red text in the version column. I can scroll through these and remove every single one, but I'm wondering if the zypper search (zypper se) or the Software Manager has any way to target/select all of these at once.

*- These packages had a repository (OpenSUSE 12.1 something), but since I replaced those repositories with the 12.2 repositories, they no longer have a repository association. This doesn't create a problem, because the 12.2 repositories should contain everything I need to run my system.

palswim
  • 4,919
  • 6
  • 37
  • 53

5 Answers5

5
rpm -qa --qf '%-30{DISTRIBUTION} %{NAME}\n'| sort

gives you a list of all repos used by your packages. Finding the ones you don't want is left as an exercise to the reader. :-).

Martin Schröder
  • 939
  • 1
  • 10
  • 35
2

Packages that have 'lost' their repository or were installed directly from a .rpm file will show Repository: @System when you do a zypper info on them. So in theory it should be possible to find them all with a zypper packages --repo @System --installed-only but this is still missing in libzypp (openSUSE Bug 770239 - 'zypper pa' lacks support for @System repo).

As a workaround one has to do a zypper info on each installed package and filter for those who have the repository @System:

rpm -qa --queryformat="%{n}\n" | while read p; do zypper info $p | grep -q '^Repository: @System' && echo $p; done

Quite slow but does the job.

mleu
  • 196
  • 5
2

Using Martin's answer/guidance, I wrote a quick script to take a string of packages to remove, zremove.sh:

#!/bin/sh

pkgs=""
while read line
do
        pkgs="$pkgs $line"
done

zypper rm $pkgs

After noticing that all of my packages "without a repository" had a distribution of openSUSE 12.1 in the rpm query, I issued this command to locate and remove all of them:

rpm -qa --qf '%{DISTRIBUTION} : %{NAME}\n' | grep "openSUSE 12.1 :" | sed 's/openSUSE 12.1 : //' | sudo zremove.sh

This doesn't generally answer the question of how to find all packages without a backing repository, but it did solve my initial issue.

palswim
  • 4,919
  • 6
  • 37
  • 53
0

On newer OpenSuSE releases,

$ zypper pa --orphaned

does the trick.

Janka
  • 446
  • 3
  • 5
0

The following command lists all installed packages which do not have a referenced repository anymore or are installed via rpm directly:

LC_ALL=C zypper pa --installed | awk '$0 ~ /^i/ && $3 == "@System" {print $5}'

sealor
  • 139
  • 3