LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 07-02-2021, 09:57 AM   #1
verilog15
LQ Newbie
 
Registered: Jun 2021
Posts: 7

Rep: Reputation: Disabled
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)?

Maybe this can be extract with RPM?

Last edited by verilog15; 07-02-2021 at 11:11 AM.
 
Old 07-03-2021, 02:41 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
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.
 
Old 07-03-2021, 04:36 AM   #3
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by verilog15 View Post
Maybe this can be extract with RPM?
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.

Last edited by shruggy; 07-03-2021 at 02:00 PM.
 
Old 07-03-2021, 02:00 PM   #4
verilog15
LQ Newbie
 
Registered: Jun 2021
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
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 View Post
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
 
Old 07-03-2021, 02:05 PM   #5
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Well, if it's SLE you're using, why won't you ask their support?
 
Old 07-03-2021, 02:22 PM   #6
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,342

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Why couldn't you use something like
zypper --xmlout info gcc | grep Repository
to great effect.
 
Old 07-03-2021, 02:34 PM   #7
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
@computersavvy. This is what I believe OP currently does (without --xmlout). They asked if there is a better approach.
 
Old 07-06-2021, 01:02 AM   #8
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,799
Blog Entries: 1

Rep: Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066Reputation: 2066
Not likely what you want, but the repo name and download URI do show up:
Code:
 # zypper -vv in -f -d release-notes-openSUSE
Verbosity: 3
...
Forcing installation of 'release-notes-openSUSE-15.2.20200604-lp152.1.1.noarch' from repository 'OSS'.
Resolving package dependencies......
The following package is going to be reinstalled:
  release-notes-openSUSE  15.2.20200604-lp152.1.1  noarch  OSS  openSUSE

1 package to reinstall.
Overall download size: 2.1 MiB. Already cached: 0 B. Download only.
Continue? [y/n/v/...? shows all options] (y): y
committing
Retrieving package release-notes-openSUSE-15.2.20200604-lp152.1.1.noarch           (1/1),   2.1 MiB (  4.1 MiB unpacked)
Retrieving: http://download.opensuse.org/distribution/leap/15.2/repo/oss/media.1/media ...........................[done]
Retrieving: http://download.opensuse.org/distribution/leap/15.2/repo/oss/noarch/release-notes-openSUSE-15.2.202006[done]
CommitResult  (total 1, done 0, error 0, skipped 1, updateMessages 0)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] No package 'x11' found No package 'xext' found No package 'xdamage' found No package 'xfixes' found No package 'x11-xcb' found Jigsaw Linux From Scratch 14 02-23-2021 08:35 PM
with dnf how to get the name of the repository a specific package was installed from? tshikose Linux - Software 3 11-23-2018 10:47 AM
how to add 4 to 9 repository urls in one repository with custom name? RehanKhan Ubuntu 1 08-06-2014 11:54 AM
Installing Squid on a cPanel Server - URI::URL Dependency Already Installed rustyz82 Linux - Server 1 01-14-2010 02:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration