How to find the URI and repository name from which the package was installed?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to find the URI and repository name from which the package was installed?
Hello!
My task is to do the following: Build a script which, given a list of rpm packages, finds all the zypper repositories (name and URIs).
I have a package installed locally and I want to find the zypper URI and the repository name from which the package was installed from. I could search for the package and find it:
Code:
zypper info $PKG_NAME
It does give me the repo name (if there is one) but it does not give me the URI:
Code:
> zypper info tcsh
Information for package tcsh:
Repository: <REPO_NAME>
Name: tcsh
Version: 6.18.01-9.7.1
Arch: x86_64
Vendor: SUSE LINUX Products GmbH, Nuernberg, Germany
Support Level: unknown
Installed: Yes
Status: up-to-date
Installed Size: 1.0 MiB
Summary: The C SHell
Description:
Tcsh is an enhanced, but completely compatible, version of the Berkeley
UNIX C shell, csh(1). It is a command language interpreter usable as an
interactive login shell and a shell script command processor. It
includes a command-line editor, programmable word completion, spelling
correction, a history mechanism, job control, and a C-like syntax.
I want the "Repository:" part.
I'm also familiar with the
Code:
zypper repos -u
command to list all the repositories and URIs.
I could combine the two commands and find the repository name and then the URI. Is there a better approach? My biggest struggle is on how to parse it. So the questions are:
1. Is there a command that given the package name, returns the repository name (without the need to parse)?
2. Is there a command that given the package name, returns the repository URI (without the need to parse)? Is it possible to combine it with question 1 and just get those two?
3. If there is no way to get the repository URI based on the package name, is there a command to get the repository URI based on the repository name (without the need to parse)?
Read the zypper man page, it seems both the zypper and the info command have some options that might help.
Maybe there's other rpm tools that provide the info you are looking for.
Or maybe your package manager simply does not store that information, at least not directly, per package.
No. RPM database doesn't track repository data. That said, the repo can sometimes be indirectly inferred from fields like DISTRIBUTION, VENDOR, or BUILDHOST, but this is very unreliable and obviously not what you're looking for.
I don't know of any zypper command comparable to apt-cache madison tcsh or repoquery --location tcsh. Or even to
Code:
dnf -q rq --qf '%{repoid}' tcsh
But I don't use openSUSE.
Besides zypper if, zypper se -s should also display repository name. FWIW, zypper can produce parseable XML output with option --xmlout.
Read the zypper man page, it seems both the zypper and the info command have some options that might help.
Maybe there's other rpm tools that provide the info you are looking for.
Or maybe your package manager simply does not store that information, at least not directly, per package.
Hi, I tried to read the man page. This is why I figured that way above. The zypper info does not have any additional useful commands here:
Code:
zypper info --help
info (if) [options] <name> ...
Show detailed information for specified packages.
Command options:
-r, --repo <alias|#|URI> Work only with the specified repository.
-t, --type <type> Type of package (package, patch, pattern, product).
Default: package.
--requires Show also requires and prerequires.
--recommends Show also recommends.
Zypper repos as well. After looking into man, I opened this question.
Quote:
Originally Posted by shruggy
No. RPM database doesn't track repository data. That said, the repo can sometimes be indirectly inferred from fields like DISTRIBUTION, VENDOR, or BUILDHOST, but this is very unreliable and obviously not what you're looking for.
I don't know of any zypper command comparable to apt-cache madison tcsh. Or even to
Code:
dnf -q rq --qf '%{repoid}' tcsh
But I don't use openSUSE.
Besides zypper if, zypper se -s should also display repository name. FWIW, zypper can produce parseable XML output with option --xmlout.
I don't have dnf installed. zypper if is just zypper info that I used and there are no additional options. Also, I'm familiar with the xmlout option but it's quite bad:
Code:
zypper --xmlout info gcc
<?xml version='1.0'?>
<stream>
<message type="info">Loading repository data...</message>
<message type="info">Reading installed packages...</message>
Repository: sle11-sp4-pool-x86_64
Name: gcc
Version: 4.3-62.200.2
Arch: x86_64
Vendor: SUSE LINUX Products GmbH, Nuernberg, Germany
Support Level: Level 3
Installed: Yes
Status: up-to-date
Installed Size: 0 B
Summary: The system GNU C Compiler
Description:
The system GNU C Compiler.
Authors:
--------
The GCC team.
</stream>
Parsing the command without --xmlout is actually easier
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.