Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Show me your service dependency tree
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
bicolao
n00b
n00b


Joined: 05 Jan 2004
Posts: 50

PostPosted: Fri May 14, 2004 3:44 am    Post subject: Show me your service dependency tree Reply with quote

Hi,
I found /var/lib/init.d/deptree holding some info for parallel service starting. I wrote a script to visualize it using graphviz
The code is:
Code:

#!/bin/bash

source /var/lib/init.d/deptree
echo "digraph deptree {"
for i in `seq 1 ${RC_DEPEND_TREE[0]}`; do
        LABEL=${RC_DEPEND_TREE[$((${i}*${rc_index_scale}))]}
        NAME=`echo "$LABEL"|tr -cd '[a-zA-Z]'`
        echo "${NAME} [label=\"${LABEL}\"];"
done
for i in `seq 1 ${RC_DEPEND_TREE[0]}`; do
        LABEL=${RC_DEPEND_TREE[$((${i}*${rc_index_scale}))]}
        NAME=`echo "$LABEL"|tr -cd '[a-zA-Z]'`
        DEP=${RC_DEPEND_TREE[$((${i}*${rc_index_scale}+${rc_type_needsme}))]}
        for j in ${DEP}; do
                DEPNAME=`echo "$j"|tr -cd '[a-zA-Z]'`
                echo "${NAME} -> ${DEPNAME};"
        done
done
echo "}"

Use as follow:
Code:

dep2dot |dot -Tpng -o dep.png

dep2dot is the script name. Then you can look into dep.png. I don't know if i interpret deptree properly. If i'm wrong, please correct me.
Have fun.
_________________
Bi Cờ Lao
Back to top
View user's profile Send private message
ecatmur
Advocate
Advocate


Joined: 20 Oct 2003
Posts: 3595
Location: Edinburgh

PostPosted: Fri May 14, 2004 4:30 am    Post subject: Reply with quote

Hey, nice! That could turn out very useful in diagnosing startup problems...

Here's mine: http://home.jesus.ox.ac.uk/~ecatmur/gentoo/deptree.png
_________________
No more cruft
dep: Revdeps that work
Using command-line ACCEPT_KEYWORDS?
Back to top
View user's profile Send private message
langthang
Retired Dev
Retired Dev


Joined: 27 Nov 2003
Posts: 620

PostPosted: Fri May 14, 2004 4:41 am    Post subject: Reply with quote

really nice! now where is that package dependency tree minus the base system packages? :)
Back to top
View user's profile Send private message
bicolao
n00b
n00b


Joined: 05 Jan 2004
Posts: 50

PostPosted: Fri May 14, 2004 5:45 am    Post subject: Reply with quote

langthang wrote:
really nice! now where is that package dependency tree minus the base system packages? :)

Which package is base system package? How to know it? I may emphasize them to distinguish with others
_________________
Bi Cờ Lao
Back to top
View user's profile Send private message
langthang
Retired Dev
Retired Dev


Joined: 27 Nov 2003
Posts: 620

PostPosted: Fri May 14, 2004 4:26 pm    Post subject: Reply with quote

Look in '/usr/portage/profiles/default-[arch]-2004.0/packages' for base system packages.
Back to top
View user's profile Send private message
ecatmur
Advocate
Advocate


Joined: 20 Oct 2003
Posts: 3595
Location: Edinburgh

PostPosted: Fri May 14, 2004 5:08 pm    Post subject: Reply with quote

Actually, /etc/make.profile/packages is the right place to look, also /usr/portage/profiles/base/packages and /etc/portage/profile/packages.
_________________
No more cruft
dep: Revdeps that work
Using command-line ACCEPT_KEYWORDS?
Back to top
View user's profile Send private message
bicolao
n00b
n00b


Joined: 05 Jan 2004
Posts: 50

PostPosted: Sat May 15, 2004 6:11 am    Post subject: Reply with quote

Ok, new script
Code:

#!/bin/bash

[ -n "$NOEXTRA" -a -z "$BASESTYLE" ] && BASESTYLE=solid
[ -n "$BASESTYLE" ] || BASESTYLE=dashed
[ -n "$EXTRASTYLE" ] || EXTRASTYLE=solid

function myname
{
   echo `echo "$1"|tr -cd '[a-zA-Z]'`
}

if [ -f services.base ];then
   while read n;do
      if [ -n "$n" ]; then
         let "BASE_`myname $n`=1"
      fi
   done < services.base
fi


source /var/lib/init.d/deptree
echo "digraph deptree {"
for i in `seq 1 ${RC_DEPEND_TREE[0]}`; do
   LABEL=${RC_DEPEND_TREE[$((${i}*${rc_index_scale}))]}
   NAME=`myname "$LABEL"`
   eval ret=\$BASE_`myname ${NAME}`
   if [ "$ret" = 1 ]; then
      [ -n "$NOBASE" ] || echo "${NAME} [label=\"${LABEL}\" style=${BASESTYLE}];"
   else
      [ -n "$NOEXTRA" ] || echo "${NAME} [label=\"${LABEL}\" style=${EXTRASTYLE}];"
   fi
done
for i in `seq 1 ${RC_DEPEND_TREE[0]}`; do
   LABEL=${RC_DEPEND_TREE[$((${i}*${rc_index_scale}))]}
   NAME=`myname "$LABEL"`
   DEP=${RC_DEPEND_TREE[$((${i}*${rc_index_scale}+${rc_type_needsme}))]}
   for j in ${DEP}; do
      DEPNAME=`myname "$j"`
      eval ret1=\$BASE_`myname "${NAME}"`
      eval ret2=\$BASE_`myname "${DEPNAME}"`
      if [ "$ret1" = 1 -o "$ret2" = 1 ]; then
         if [ -z "$NOBASE" -a  '(' -z "$NOEXTRA" -o "$ret2" = 1 ')' ]; then
            echo "${NAME} -> ${DEPNAME} [style=${BASESTYLE}];"
         fi
      else
         [ -n "$NOEXTRA" ] || echo "${NAME} -> ${DEPNAME} [style=${EXTRASTYLE}];"
      fi
   done
done
echo "}"


It's pain to find out which service is base service. Base service names is stored in services.base file,
Code:


hdparm
hostname
keymaps
local
localmount
modules
net.eth0
net.lo
netmount
nscd
numlock
rmnologin
rsyncd
serial
sysklogd
urandom
xdm
xfs
bootmisc
checkfs
checkroot
clock
consolefont
crypto-loop
domainname
net


Use can set NOBASE=1 to remove base services from the graph or NOEXTRA=1 to remove the rest from the graph.
Change BASESTYLE, EXTRASTYLE to others (dashed, bold, solid ...) as you wish.
_________________
Bi Cờ Lao
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum