You are not logged in.

#1 2013-03-27 23:01:40

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,237
Website

pacman -Qip option for repository database?

Is there a way to query a specific repository database (ie, foobar.db.tar.gz) for information on a specific package, without necessarily having that repository configured in pacman.conf (like the -p option to -Q)?

I want to query a specific repo database to determine if a given package (or packages) are present, but the repository may or may not be in pacman.conf

The best I have at the moment (assuming the repo IS configured in pacman.conf) is:

pacman -Sl foobar | cut -d' ' -f2 | grep -P '^package$"

(EDIT: foobat is foobar's long long cousin)

Last edited by fukawi2 (2013-03-27 23:02:22)

Offline

#2 2013-03-28 03:10:34

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: pacman -Qip option for repository database?

I use a second pacman config where I have a bunch of unofficial repos listed, so I can search for some package, like so:

$ pacman --config /etc/pac2.conf -Sl | grep opera
community opera 12.14.1738-1
archstuff opera-devel 10.70_6396-1
herecura-stable opera-adblock-elements 20130324-1
herecura-stable opera-adblock-main 20130324-1
herecura-stable opera-adblock-stat 20130324-1
herecura-testing opera-next 12.15_1745-1

I think you can use the '-q' switch instead of cutting:

pacman -Slq foobar | grep -P '^package$"

Last edited by karol (2013-03-28 03:10:56)

Offline

#3 2013-03-28 03:33:22

progandy
Member
Registered: 2012-05-17
Posts: 5,317

Re: pacman -Qip option for repository database?

You should consider using the json interface. xyne does this in his package downloader
https://bbs.archlinux.org/viewtopic.php?id=160069
Edit: If you want to query a local database file you could also write something with pyalpm.

Last edited by progandy (2013-03-28 03:38:04)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#4 2013-03-28 03:36:15

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,237
Website

Re: pacman -Qip option for repository database?

karol wrote:

I use a second pacman config where I have a bunch of unofficial repos listed, so I can search for some package, like so:
...
I think you can use the '-q' switch instead of cutting:

I'm aiming for something completely independent... Worst case I'll have to extract the DB to a temp location and check that way.

progandy wrote:

You should consider using the json interface. xyne does this in his package downloader
https://bbs.archlinux.org/viewtopic.php?id=160069

There's no JSON interface for a repo I've created myself using repo-add wink

Offline

#5 2013-03-28 03:55:26

progandy
Member
Registered: 2012-05-17
Posts: 5,317

Re: pacman -Qip option for repository database?

If you simply want to read a package, here is something. Using pyalpm seems to be a bit too much wink

# query info for a specific package (allow any version and pkgrel)
bsdtar -Oxf /var/lib/pacman/sync/extra.db "zip-?*-?*/desc"
# query info for a specific package version:
bsdtar -Oxf /var/lib/pacman/sync/extra.db zip-3.0-3/desc
# check for existence of a package with specific version but any pkgrel
bsdtar -tf /var/lib/pacman/sync/extra.db zip-3.0-?*/desc
# list all packages
bsdtar -tf /var/lib/pacman/sync/extra.db | grep "/\$"

Last edited by progandy (2013-03-28 04:00:41)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#6 2013-03-28 04:20:00

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,237
Website

Re: pacman -Qip option for repository database?

# query info for a specific package (allow any version and pkgrel)
bsdtar -Oxf /var/lib/pacman/sync/extra.db "zip-?*-?*/desc"

Not quite... For example, searching for "PostgreSQL" returns:
postgresql
postgresql-docs
postgresql-libs
postgresql-old-upgrade

If "postgresql" didn't actually exist, I'd have a false-positive sad

Offline

#7 2013-03-28 04:25:54

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,672
Website

Re: pacman -Qip option for repository database?

falconindy has a patchset for pacman that allows you to add repos to your pacman.conf for only things like searching or explicitly installing from  (e.g. "pacman -S foo" will not work, but "pacman -S bar/foo" will is the "bar" repo is set with limited usage).

Offline

#8 2013-03-28 04:30:40

progandy
Member
Registered: 2012-05-17
Posts: 5,317

Re: pacman -Qip option for repository database?

Then you'll have to combine it with grep for better patterns. The only other thing you can do with a glob pattern is to force a number after the first dash:
"zip-[0-9]*-?*/desc"


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

Board footer

Powered by FluxBB