You are not logged in.

#1 2008-07-10 23:08:13

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

Required By info.

This is not really a pacman issue.  I am wondering if there exists an equivalent to the /var/lib/pacman/sync/*/package_name/desc|depends that contains the list of "Required By" for a given packages.  I know I can get that through pacman -Qi, but it is not really convenient for me.  Or if I rephrase, where does pacman -Qi get the "Required by" info.

Offline

#2 2008-07-11 00:01:23

carlocci
Member
From: Padova - Italy
Registered: 2008-02-12
Posts: 368

Re: Required By info.

from the packages which depend on that package.
That's why pacman -Qi pkgname is slower than cat /usr/lib/pacman/local/pkgdir/* : pacman has to load the database

edit: that was stupid of me

Actually there is a %REQUIREDBY% field in the database, probably it's generated at install time to speed up pacman queries.

You can't find that field because you should be looking in local (the database with the installed packages) not in sync (the database you download from internet when you sync).

Last edited by carlocci (2008-07-11 00:29:47)

Offline

#3 2008-07-11 00:28:44

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

Re: Required By info.

Hum are you saying that if I do

pacman -Qi bash

, the packages listed in the Required by are actually the result of a query where pacman looks at what is installed and all installed packages that depends on bash will be listed.  I guess that really makes sense though because it means that the required by depends on what is installed on your machine.

Offline

#4 2008-07-11 00:35:09

carlocci
Member
From: Padova - Italy
Registered: 2008-02-12
Posts: 368

Re: Required By info.

damn, it was a matter of seconds!

cat /var/lib/pacman/local/bash-3.2.033-2/depends 
%DEPENDS%
readline
glibc

%REQUIREDBY%
glibc
coreutils
findutils
gawk
perl
gzip
hwdetect
util-linux-ng
initscripts
mkinitcpio
man
pacman
tar
tcp_wrappers
abs
m4
autoconf
automake
flex
libtool
make
capi4k-utils

%PROVIDES%
sh

as you can see there really is a %REQUIREDBY% field

Last edited by carlocci (2008-07-11 00:37:18)

Offline

#5 2008-07-11 01:15:06

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

Re: Required By info.

Outstanding.  Thanks.  There was a typo in your previous post, /usr versus /var.  I should have known...  Anyway, does that means that the /var/lib/pacman/local contains a list of all installed packages ?

Offline

#6 2008-07-11 02:04:20

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

Re: Required By info.

carlocci wrote:

from the packages which depend on that package.
That's why pacman -Qi pkgname is slower than cat /usr/lib/pacman/local/pkgdir/* : pacman has to load the database

edit: that was stupid of me

Actually there is a %REQUIREDBY% field in the database, probably it's generated at install time to speed up pacman queries.

You can't find that field because you should be looking in local (the database with the installed packages) not in sync (the database you download from internet when you sync).

That's not stupidity, it is dedications smile.  I guess my question now is:  Is the content of the REQUIREDBY dependant on what's installed or generic.  i.e.  And by the way, now that I look at it, I don't have that REQUIREDBY ?? sad

Offline

#7 2008-07-11 02:22:36

carlocci
Member
From: Padova - Italy
Registered: 2008-02-12
Posts: 368

Re: Required By info.

I don't really know. It looks like it's static content:

$  sudo pacman -R tar
caricamento dei dati in corso...
controllo delle dipendenze in corso...
(1/1) rimozione in corso di tar                     [------------------] 100%
$  cat /var/lib/pacman/local/bash-3.2.033-2/depends 
%DEPENDS%
readline
glibc

%REQUIREDBY%
glibc
coreutils
findutils
gawk
perl
gzip
hwdetect
util-linux-ng
initscripts
mkinitcpio
man
pacman
tar
tcp_wrappers
abs
m4
autoconf
automake
flex
libtool
make
capi4k-utils

%PROVIDES%
sh

But I'm quite sure this piece of information is not contained in the downloaded package: it really looks like it's generated by pacman.

Maybe some pacman god can explain this to us

Offline

#8 2008-07-11 03:02:43

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

Re: Required By info.

Well, I am not claiming the title of pacman god.  That is reserved for toofishes and shining...

The REQUIREDBY field is not used any more (since pacman 3.1 I think).  The list of packages in the "Required By" field of "pacman -Qi <pkg>" is generated as needed.  I wasn't doing any coding for pacman when this was decided but my guess is that this made installing packages faster and importantly less complex and error prone at a trade off of making the -Qi operation slower.  The speed of -Qi should pick up again once the tar based backend get implemented after the next pacman release.

If you look in the pacman.install file of the pacman package you will see:

# TODO not used yet, we'll use it in later pacman upgrades
_cleanrequiredby() {
    dbpath="/var/lib/pacman/local"
    echo ">>> Cleaning out unnecessary requiredby entries from DB."
    echo ">>> -> making local DB backup at /tmp/pacmanDB.tgz..."
    bsdtar -czf /tmp/pacmanDB.tgz "$dbpath"
    echo ">>> -> removing entries..."
    grep -Rl REQUIREDBY /var/lib/pacman/local | xargs sed -i '/^%REQUIREDBY%/,/^$/ d'
    echo ">>> -> done."
}

which will clean up your database at some stage.

Offline

#9 2008-07-11 04:25:33

marxav
Member
From: Gatineau, PQ, Canada
Registered: 2006-09-24
Posts: 386

Re: Required By info.

I am not in front of my main machine now.  I will look at your recommendation Allan.  But that would explain why my /var/lib/local has nothing about REQUESTEDBY. 

You see, I am working on a desklet (pacmansentry in the AUR) and I was looking at a way of ranking the importance of packages, amongst other things, so that they appear listed in a certain order.  The number of "dependants" would be a criteria a user could assign a weight.

Offline

#10 2008-07-11 04:33:03

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

Re: Required By info.

marxav wrote:

I am not in front of my main machine now.  I will look at your recommendation Allan.  But that would explain why my /var/lib/local has nothing about REQUESTEDBY.

I will just point out that I am not recommending you to run that script (it will happen automatically in a pacman upgrade in the future).  I'm not sure how tested it is and given you probably installed since pacman 3.1 came out (and hence no required by info) then you have no need to run it.

marxav wrote:

You see, I am working on a desklet (pacmansentry in the AUR) and I was looking at a way of ranking the importance of packages, amongst other things, so that they appear listed in a certain order.  The number of "dependants" would be a criteria a user could assign a weight.

Well,

grep "^bash$" $(find /var/lib/pacman/local -name depends) | wc -l

will tell you how many packages require bash.  Not the "^" matches the start of the line and "$" matches the end.

Edit: Just so you know that this may not be the best way to tell how many packages depend on another package.  E.g. Only 19 packages directly depend on gtk2 on my system despite having a XFCE desktop with only gnome apps.

Offline

Board footer

Powered by FluxBB