How to check which repository provided package

I am sorry if this has been asked before, but I could not find anything on it. My question is: How do you check the repository which provided a package using the zypper command ?

You mean you can not find this in

man zypper

On 2014-09-17 09:26, hcvv wrote:
>
> You mean you can not find this in
>
> Code:
> --------------------
> man zypper
> --------------------

Mmmm…

There is this:


Telcontar:~ # zypper --no-refresh info man
Loading repository data...
Reading installed packages...


Information for package man:
----------------------------
Repository: openSUSE-13.1-Oss    <======
Name: man
Version: 2.6.3-9.1.3
Arch: x86_64
Vendor: openSUSE
Installed: Yes
Status: up-to-date
Installed Size: 1.8 MiB
Summary: A Program for Displaying man Pages
Description:
A program for displaying man pages on the screen or sending them to a
printer (using groff).
Telcontar:~ #

But that is far from usable, as a query. I do not know how to simply
produce a list of packages and the repos they came from.

The rpm database query does not keep that information, as far as I know;
but it could be I don’t know what tag they use, if they use any.


cer@Telcontar:~> rpm --querytags | grep -i repo
cer@Telcontar:~>

For some repos, it can be deduced from the “vendor” field, like packman,
which uses “http://packman.links2linux.de”, or wine, which uses
“obs://build.opensuse.org/Emulators”.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

To display a package’s origins and information

zypper info *packagename*

So, for instance in Carlos’ example above the repo that package came from is the OSS repo.

TSU

Hi
Here is a way to find packages installed by repository;


zypper pa -iR |grep `zypper lr -a **XX**|grep Name|cut -f2 -d":"|sed -e 's/^ 	]*//'|cut -f1-2 -d " "`

Where XX is the repostory number (#)via zypper lr. If you don’t use -iR but just -R it will show all packages in the repo…

The question is a bit badly phrased. Did you want to know how to find an arbitrary package and which repo has it? zypper and rpm will only tell you installed packages and packages in active repos. If you want to find an arbitrary package that may not be in standard repos you use the web

http://software.opensuse.org/search

On 2014-09-17 18:36, malcolmlewis wrote:
>
> Hi
> Here is a way to find packages installed by repository;
>
>
> Code:
> --------------------
>
> zypper pa -iR |grep zypper lr -a *XX*|grep Name|cut -f2 -d":"|sed -e 's/^ ]*//'|cut -f1-2 -d " "
>
> --------------------
>
> Where XX is the repostory number (#)via zypper lr. If you don’t use
> -iR but just -R it will show all packages in the repo…

Quite complex… I’ll try later, thanks.

Pity the “rpm” command can not provide that info in “querytags”.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

On 2014-09-17 18:36, gogalthorp wrote:
>
> The question is a bit badly phrased. Did you want to know how to find an
> arbitrary package and which repo has it? zypper and rpm will only tell
> you installed packages and packages in active repos.

I understand he wants to know where an already installed package came
from. I’ll check malcolmlewis idea later, it may be what /I/ want.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

On Wed 17 Sep 2014 05:33:06 PM CDT, Carlos E. R. wrote:

On 2014-09-17 18:36, malcolmlewis wrote:
>
> Hi
> Here is a way to find packages installed by repository;
>
>
> Code:
> --------------------
>
> zypper pa -iR |grep `zypper lr -a XX|grep Name|cut -f2 -d":"|sed

-e ‘s/^ ]*//’|cut -f1-2 -d " "`
> --------------------
>
> Where XX is the repostory number (#)via zypper lr. If you don’t use
> -iR but just -R it will show all packages in the repo…

Quite complex… I’ll try later, thanks.

Pity the “rpm” command can not provide that info in “querytags”.

Hi
OK so you can use -r to specify the repository, eg;


zypper pa -r 11 -iR|grep -e "bash"

i | openSUSE 13.1 | bash                                       | 4.2-68.1.5                      | x86_64
i | openSUSE 13.1 | bash-doc                                   | 4.2-68.1.5                      | noarch

I’m sure some additional tweaks with grep/sed etc would help…


Cheers Malcolm °¿° LFCS, SUSE Knowledge Partner (Linux Counter #276890)
openSUSE 13.1 (Bottle) (x86_64) GNOME 3.10.1 Kernel 3.11.10-21-desktop
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

zypper --no-refresh se -si | awk '/bash/'

Some pretty format

zypper --no-refresh se -si | awk '/bash/{printf("%-20s %s
", $3,$NF)}'

This function might be useful if you want to have some kind of shortcut for checking your package.

CheckPackage(){
  zypper --no-refresh se -si | awk -v pattern="$1" '$1 ~ /^[Si-]/ && $3 ~ pattern {printf("%-25s %-20s %s
", $3,$7,$NF)}'
}

I have given it a CheckPackage function name, you can name it to your own hearts content ;).
Put that code in your ~/.bashrc or some place you have your own functions. After that you can just run

CheckPackage «packagename»

To check for a specific package

ie

CheckPackage bash

or

CheckPackage 

To show packages that are installed.

I know the formatting sucks, feel free to modify though :). Of course it will only print something if the package is installed, see

zypper help se

for info about the zypper part.

Some modification

'/^[Si-]/' 

can just be

/^i/{next}

Since the first field starts with an i already because of the si from zypper. That means skip lines that do not start with an **i **

Here is the modified code.

CheckPackage(){ 
  zypper --no-refresh se -si | awk -v pattern="$1" '$1 !~ /^i/{next} $3 ~ pattern {printf("%-25s %-20s %s
", $3,$7,$NF)}'
}

If you want to search for the exact package name, add some anchors to the package name.

ie.

CheckPackage '^bash$'

List packages from packman, where packman can be <alias|#|URI>

zypper --no-refresh se -si -r packman | awk '$1 ~ /^i/{print $3}'

A useful function

ListPack(){ zypper --no-refresh se -si -r "$1" | awk '$1 ~ /^i/{print $3}'; }

Usage:

ListPack «alias|#|URI»

ie

ListPack packman

ListPack 1

ListPack http://ftp.gwdg.de/pub/linux/packman/suse/13.1/


Again ListPack is arbitary ;).

On 2014-09-17 23:46, jetchisel wrote:

> List packages from packman, where packman can be <alias|#|URI>
>
> Code:
> --------------------
> zypper --no-refresh se -si -r packman | awk ‘$1 ~ /^i/{print $3}’
> --------------------

Or:


zypper --no-refresh se -si

to produce the entire list, unsorted. However, it produces 9137 entries, while “rpm -qa | wc -l” produces 6154. The list of packages should be the same, shouldn’t it?

I have packages that were not installed from repos, some locally compiled. But 3000?

Ah, zypper also lists installed patches as if they were packages!


i | openSUSE-2013-1032                         | patch   | 1                                    | noarch | openSUSE-13.1-Update
i | openSUSE-2013-1033                         | patch   | 1                                    | noarch | openSUSE-13.1-Update
i | openSUSE-2013-624                          | patch   | 1                                    | noarch | openSUSE-13.1-Update-Non-Oss
i | openSUSE-2013-689                          | patch   | 1                                    | noarch | openSUSE-13.1-Update-Non-Oss
i | openSUSE-2013-810                          | patch   | 1                                    | noarch | openSUSE-13.1-Update
i | openSUSE-2013-829                          | patch   | 1                                    | noarch | openSUSE-13.1-Update
i | openSUSE-2013-830                          | patch   | 1                                    | noarch | openSUSE-13.1-Update


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

On 2014-09-17 20:05, malcolmlewis wrote:

> I’m sure some additional tweaks with grep/sed etc would help…

My current query is this:


rpm -q -a --queryformat "%{INSTALLTIME}	%{INSTALLTIME:day} \
%{BUILDTIME:day} %-30{NAME}	%15{VERSION}-%-7{RELEASE}	%{arch} \
%25{VENDOR}%25{PACKAGER} == %{DISTRIBUTION} %{DISTTAG}
"   | sort | cut --fields="2-" | tee rpmlist | less -S

It produces this type of list:



....

Mon Sep 15 2014    Wed Sep 03 2014 libreoffice-draw-extensions                  4.1.6.2-25.1    x86_64                     openSUSE http://bugs.opensuse.org == openSUSE 13.1 (none)
Mon Sep 15 2014    Wed Sep 03 2014 libreoffice-filters-optional                 4.1.6.2-25.1    x86_64                     openSUSE http://bugs.opensuse.org == openSUSE 13.1 (none)
Mon Sep 15 2014    Wed Sep 03 2014 libreoffice-calc-extensions                  4.1.6.2-25.1    x86_64                     openSUSE http://bugs.opensuse.org == openSUSE 13.1 (none)
Mon Sep 15 2014    Wed Sep 03 2014 libreoffice-base-extensions                  4.1.6.2-25.1    x86_64                     openSUSE http://bugs.opensuse.org == openSUSE 13.1 (none)
Mon Sep 15 2014    Wed Sep 03 2014 libreoffice-base-drivers-mysql               4.1.6.2-25.1    x86_64                     openSUSE http://bugs.opensuse.org == openSUSE 13.1 (none)
Wed Sep 17 2014    Tue Sep 16 2014 gpg-pubkey                                  1abd1afb-54176598        (none)                       (none)PackMan Project (signing key) <packman@links2linux.de> == (none) (none)

which has the entire list of installed packages, sorted by date (it is possible to sort on anything), and vendor. No repo data.

This other variant:


rpm -q -a --queryformat "%{INSTALLTIME};%{INSTALLTIME:day}; \
%{BUILDTIME:day}; %{NAME};%{VERSION}-%-7{RELEASE};%{arch}; \
%{VENDOR};%{PACKAGER};%{DISTRIBUTION};%{DISTTAG}
" \
| sort | cut --fields="2-" --delimiter=\; \
| tee rpmlist.csv | less -S

is the same list, but with fields separated with semicolons ‘;’, so that importing in a spreadsheet is trivial. Once there, you can do filters and searches to your heart content :slight_smile:



....

Mon Sep 15 2014;    Wed Sep 03 2014; libreoffice-draw-extensions;4.1.6.2-25.1   ;x86_64;    openSUSE;http://bugs.opensuse.org;openSUSE 13.1;(none)
Mon Sep 15 2014;    Wed Sep 03 2014; libreoffice-filters-optional;4.1.6.2-25.1   ;x86_64;    openSUSE;http://bugs.opensuse.org;openSUSE 13.1;(none)
Mon Sep 15 2014;    Wed Sep 03 2014; libreoffice-calc-extensions;4.1.6.2-25.1   ;x86_64;    openSUSE;http://bugs.opensuse.org;openSUSE 13.1;(none)
Mon Sep 15 2014;    Wed Sep 03 2014; libreoffice-base-extensions;4.1.6.2-25.1   ;x86_64;    openSUSE;http://bugs.opensuse.org;openSUSE 13.1;(none)
Mon Sep 15 2014;    Wed Sep 03 2014; libreoffice-base-drivers-mysql;4.1.6.2-25.1   ;x86_64;    openSUSE;http://bugs.opensuse.org;openSUSE 13.1;(none)
Wed Sep 17 2014;    Tue Sep 16 2014; gpg-pubkey;1abd1afb-54176598;(none);    (none);PackMan Project (signing key) <packman@links2linux.de>;(none);(none)

Can you generate the same information with a zypper command, plus the repository name of each package?


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

ListPack () { 
    zypper --no-refresh se -si -r "$1" | awk '$5 !~ /package/{next}; $1 ~ /^i/{print $3}'
}

That should only print packages and not pattern or patch etc. I will not go with the extensive explanation like i always do because someone might start crying again lol!.
see

zypper help se

and

man awk

On 2014-09-18 02:06, jetchisel wrote:
>
> Code:
> --------------------
> ListPack () {
> zypper --no-refresh se -si -r “$1” | awk ‘$5 !~ /package/{next}; $1 ~ /^i/{print $3}’
> }
>
> --------------------
>
> That should only print packages and not pattern or patch etc. I will not
> go with the extensive explanation like i always do because someone might
> start crying again lol!.

I assume you have to call that with some parameters. I see $1, $3 and
$5. I don’t know how you can generate a command line skipping parameters
2 and 4, and providing 1, 2, and 5 - nor what they should be. :-???


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

The “$1” before the pipe is a shell variable (positional parameter) and an argument to the zypper, which can be «alias|#|URI»
Those with the dollar sign after the pipe is part of the awk syntax which means fields. Starting from the first field which is $1 and the last field is $NF.
Awk is pattern , action so $5 !~ /package/ means if the fifth field is not package then skip it {next}.
$1 ~ /^i/ means if the first field starts with an i then print the third field {print $3}, again pattern action.

On 2014-09-18 04:36, jetchisel wrote:
>
> The “$1” before the pipe is a shell variable (positional parameter) and
> an argument to the zypper, which can be «alias|#|URI»
> Those with the dollar sign after the pipe is part of the awk syntax
> which means fields.

Ah, ok that’s what I needed to know, thanks :slight_smile:
Those things in awk being like parameters in bash confused me completely.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

On Wed, 17 Sep 2014 06:36:01 +0000, lowks wrote:

> How do you check the repository which provided a
> package using the zypper command ?

zypper if [packagename]

Note: “if” = “info”

Look at the “Vendor” line.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C