You are not logged in.

#1 2008-07-16 03:40:19

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

pactree - dependencies viewer

The program has been completely rewritten in C and is included in pacman, so you shouldn't need to download anything. 2011-09-16

pactree - a dependency tree viewer

FEATURING
colored output: wowza
no duplicates: useful for backups
silent mode: useful to check for inconsistencies in the database
max-depth: self explanatory
image creation: generates a png of the dependency tree with graphviz (as of 20080719)

Examples:
pactree_graph.png
pactree_text.png

Grab the script here http://carlocci.ngi.it/arch/pactree

Enjoy

There used to be the code here

edit: fixed some bugs

edit2: fixed a minor bug I noticed thanks to marxav: it didn't strip the version number from the dependencies.

edit3: added something which should return colors to normal at the end of the script for users that don't set the colors in PS1

edit4: added graphviz support
It looks like the post was too long so you can grab the script at the link I placed at the beginning of the post

Last edited by carlocci (2011-09-17 00:53:37)

Offline

#2 2008-07-16 04:08:13

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

Re: pactree - dependencies viewer

I am really liking this script.  I will bump it on the pacman-dev list now to get comments on how provides should best be handled so this can be included with the pacman 3.2 release in the next week or so.

I will add a couple of comments here too:

> ./pactree glibc
|--glibc
   +--bash provides bash
      |--glibc
   |--tzdata

I think you can see the problem there!

Also, currently the depth limiter requires a space in the parameter list (pactree -d 2 blah).  That took me a while to figure out as I kept trying "pactree -d2 blah".  Anyway you can get both to work?

Offline

#3 2008-07-16 15:41:50

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

Re: pactree - dependencies viewer

> ./pactree glibc
|--glibc
   +--bash provides bash
      |--glibc
   |--tzdata

I think you can see the problem there!

I'll answer like I did in the script source:
# bash scoping ;_;
I fixed it now.

Also, currently the depth limiter requires a space in the parameter list (pactree -d 2 blah).  That took me a while to figure out as I kept trying "pactree -d2 blah".  Anyway you can get both to work?

I wanted to add that, but I thought it was too hard. In the end it wasn't.

Offline

#4 2008-07-16 21:34:59

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

Re: pactree - dependencies viewer

Wow I love it !!

 pactree -c pacman
|--pacman
   |--gcc-libs
   |--bash
      |--glibc
         +--bash provides sh
         |--tzdata

Offline

#5 2008-07-16 23:11:08

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

Re: pactree - dependencies viewer

I fixed another bug.

marxav wrote:

Wow I love it !!

 pactree -c pacman
|--pacman
   |--gcc-libs
   |--bash
      |--glibc
         +--bash provides sh
         |--tzdata

With you, sir, I doubled the userbase!
If this trend keeps going, in a month more than a billion people will be using this script!

Last edited by carlocci (2008-07-16 23:19:57)

Offline

#6 2008-07-16 23:30:40

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

Re: pactree - dependencies viewer

You are very enthusiastic LOL.

Offline

#7 2008-07-16 23:58:13

scj
Member
From: Sweden
Registered: 2007-09-23
Posts: 158

Re: pactree - dependencies viewer

I did something similar a few weeks ago, except it uses graphviz to generate an imagefile of the dependency graph.

#!/bin/bash
# dgraph - pacman dependency graph generator

type="png"

insert(){
    foundpkg=( ${foundpkg[@]} $1 )
}

is_in(){
    for i in $(seq 0 ${#foundpkg[@]}); do
    if [ "$1" == "${foundpkg[$i]}" ]; then
        return 0
    fi
    done
    return 1
}

deps(){
    pacman -Qi $1 2> /dev/null | grep "Depends On" | gawk -F: '{print $2}' | sed -re 's|[<>=]+[0-9\.]+||g'
}
depgraph(){
    pkg=$1
    shift
    insert $pkg
    de=$(deps $pkg)
    for d in $de; do
    if [ "$d" != "None" ] ; then
        echo \"$pkg\" '->' \"$d\"';'
    fi
    done
    for d in $de; do
    is_in $d || depgraph $d
    done
}

run() {
echo digraph deps{
depgraph $1 
echo }
}

run $1 | dot -T$type -o $1.deps.$type

So if you run

dgraph pacman

it will generate the file pacman.deps.png in the current directory that looks like this.

Offline

#8 2008-07-18 16:32:20

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

Re: pactree - dependencies viewer

That is quite cool, let me steal that idea smile

Offline

#9 2008-07-18 16:34:57

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

Re: pactree - dependencies viewer

carlocci wrote:

That is quite cool, let me steal that idea smile

Add color to the graph like the textbase you built tongue

Offline

#10 2008-07-18 17:14:08

DonVla
Member
From: Bonn, Germany
Registered: 2007-06-07
Posts: 997

Re: pactree - dependencies viewer

scj wrote:

So if you run

dgraph pacman

it will generate the file pacman.deps.png in the current directory that looks like this.

pretty cool! thanks

Offline

#11 2008-07-18 18:12:30

dwi
Member
Registered: 2008-01-27
Posts: 27

Re: pactree - dependencies viewer

Nice script!..but..

Not sure if this has been fixed or not, but I noticed it isn't handling the terminal colors quite right. After I run it, my default terminal color has changed.

Here is a screenshot showing what I mean: http://spinjax.com/arch-images/pactree-color.png

Keep up the good work. smile

Offline

#12 2008-07-18 20:36:34

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

Re: pactree - dependencies viewer

dwi wrote:

Not sure if this has been fixed or not, but I noticed it isn't handling the terminal colors quite right. After I run it, my default terminal color has changed.
Here is a screenshot showing what I mean: http://spinjax.com/arch-images/pactree-color.png

You are right: as I set the prompt colors in the PS1 variable I never experienced this problem.
I added
echo -ne '\033[0m' # return colors to normal?
at the end of the script which should do the trick.

Offline

#13 2008-07-19 02:10:06

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

Re: pactree - dependencies viewer

I added the graphviz support. You can edit the colors at the beginning of the script.
Here's an example: the kopete dependency tree!
http://it.tinypic.com/view.php?pic=16c6dz8&s=4

Offline

#14 2008-07-19 13:33:00

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

Re: pactree - dependencies viewer

Hey you were fast in adding colors !!  Lovely

Offline

#15 2008-07-19 14:28:57

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

Re: pactree - dependencies viewer

I just had an idea.   If I wanted to run pactree on a package that is not installed yet so I have an idea as to what the installation involves in terms of dependencies. 

Within the dependencies of the uninstalled packages, there might be packages that are already installed.  Many will not be installed of course.  These could show in red.  And while we are there, a summary of the MB already installed and the MB to be installed...

Offline

#16 2008-07-19 20:04:53

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: pactree - dependencies viewer

Very nice, I wrote something similar once but it wasn't very good. Nice work!

Do you mind if I distribute this tool with my pkgtools package in AUR? You will of course be given full credit, and if you like, I can set you up with push access to my github repo for it.

Last edited by Daenyth (2008-07-19 20:15:10)

Offline

#17 2008-07-20 08:56:24

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

Re: pactree - dependencies viewer

Hey!  I have already flagged this for inclusion in pacman's contrib section and thus in the pacman-contrib package. No stealing! smile

I wouldn't mind something like the pt-pacfix script for inclusion there too...

Offline

#18 2008-07-20 16:56:37

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: pactree - dependencies viewer

I'd appreciate it if you included my pkgtools in pacman-contrib too big_smile

Offline

#19 2008-07-20 17:43:09

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

Re: pactree - dependencies viewer

marxav wrote:

I just had an idea.   If I wanted to run pactree on a package that is not installed yet so I have an idea as to what the installation involves in terms of dependencies.

I approve of this idea!
It is easy to implement too, although the way I wrote the script, which I considered fancy and smart in the beginning, begins to show its inherent limitations.


Daenyth wrote:

Very nice, I wrote something similar once but it wasn't very good. Nice work!

Do you mind if I distribute this tool with my pkgtools package in AUR? You will of course be given full credit, and if you like, I can set you up with push access to my github repo for it.

You flatter my e-pe-nis!
You are all free to do as you please with the script, the more people finds this useful, the happier I am; hell, I couldn't stop you even if I wanted due to the GPL smile


Allan wrote:

Hey!  I have already flagged this for inclusion in pacman's contrib section and thus in the pacman-contrib package. No stealing!

hooray! smile 

I wouldn't mind something like the pt-pacfix script for inclusion there too...

I had a nice idea for a pacfix script and parsing the package versions and names for a cleaning cache script is so impossible my mind is blown away.

Offline

#20 2008-07-22 07:58:35

schivmeister
Developer/TU
From: Singapore
Registered: 2007-05-17
Posts: 971
Website

Re: pactree - dependencies viewer

man this is such a helpful piece of work..another set of thanks from me!


I need real, proper pen and paper for this.

Offline

#21 2008-07-22 08:08:17

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

Re: pactree - dependencies viewer

Daenyth wrote:

I'd appreciate it if you included my pkgtools in pacman-contrib too big_smile

Can be done...  Just send stuff to the pacman-dev list and its inclusion gets discussed there.

Someone already submitted a pacfile/pkgfile script which hasn't made the main codebase yet.  I will probably include one in the next pacman-contrib release anyway.

Offline

#22 2008-07-22 08:18:39

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: pactree - dependencies viewer

Allan wrote:

I am really liking this script.  I will bump it on the pacman-dev list now to get comments on how provides should best be handled so this can be included with the pacman 3.2 release in the next week or so.

Do you still plan to have this included in 3.2 source tarball?


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#23 2008-07-22 11:17:56

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

Re: pactree - dependencies viewer

shining wrote:
Allan wrote:

I am really liking this script.  I will bump it on the pacman-dev list now to get comments on how provides should best be handled so this can be included with the pacman 3.2 release in the next week or so.

Do you still plan to have this included in 3.2 source tarball?

Yes, carlocci is going to submit the latest version as a patch....  aren't you! big_smile

If it doesn't make it in time, I will stick it into pacman-contrib package anyway.  Still, it would be preferable to end up in the tarball.

Offline

#24 2008-07-23 01:44:32

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

Re: pactree - dependencies viewer

Allan wrote:
shining wrote:
Allan wrote:

I am really liking this script.  I will bump it on the pacman-dev list now to get comments on how provides should best be handled so this can be included with the pacman 3.2 release in the next week or so.

Do you still plan to have this included in 3.2 source tarball?

Yes, carlocci is going to submit the latest version as a patch....  aren't you! big_smile

Yes, master.
"Unfortunately" the date I set off on my trip to visit Quebec is drawing closer and closer, so my internet attention span gets smaller and smaller smile

Offline

#25 2008-07-23 11:58:55

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

Re: pactree - dependencies viewer

carlocci wrote:
Allan wrote:
shining wrote:

Do you still plan to have this included in 3.2 source tarball?

Yes, carlocci is going to submit the latest version as a patch....  aren't you! big_smile

Yes, master.
"Unfortunately" the date I set off on my trip to visit Quebec is drawing closer and closer, so my internet attention span gets smaller and smaller smile

Québec?  Stopping by Gatineau ? LOL

Offline

Board footer

Powered by FluxBB