realdep - moar dependency

Submitted scripts and programs
Forum rules
Your own work only.
machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

realdep - moar dependency

Unread post by machinebacon » Thu Feb 04, 2016 12:04 pm

realdep shows the next level dependencies of dependencies. "WTF" you ask? Here is the answer:

imagine you check the dependency count of a certain package you want to install, usually you use apt-cache depends <package>, like for xterm:

Code: Select all

xterm
  Depends: xbitmaps
  Depends: libc6
  Depends: libfontconfig1
  Depends: libice6
  Depends: libtinfo5
  Depends: libutempter0
  Depends: libx11-6
  Depends: libxaw7
  Depends: libxft2
  Depends: libxmu6
  Depends: libxpm4
  Depends: libxt6
  Recommends: x11-utils
  Suggests: xfonts-cyrillic
This does not show you the next dependency level. Using the realdep script, the output gets a bit more verbose:

Code: Select all

xterm depends on:
 xbitmaps
 libc6
 libfontconfig1
 libice6
 libtinfo5
 libutempter0
 libx11-6
 libxaw7
 libxft2
 libxmu6
 libxpm4
 libxt6
xbitmaps depends on: 
libc6 depends on: 
 libgcc1
libfontconfig1 depends on: 
 fontconfig-config
 libc6
 libexpat1
 libfreetype6
 multiarch-support
libice6 depends on: 
 libc6
 multiarch-support
 x11-common
libtinfo5 depends on: 
 libc6
libutempter0 depends on: 
 libc6
libx11-6 depends on: 
 libc6
 libx11-data
 libxcb1
 multiarch-support
libxaw7 depends on: 
 libc6
 libx11-6
 libxext6
 libxmu6
 libxpm4
 libxt6
libxft2 depends on: 
 libc6
 libfontconfig1
 libfreetype6
 libx11-6
 libxrender1
 multiarch-support
libxmu6 depends on: 
 libc6
 libx11-6
 libxext6
 libxt6
libxpm4 depends on: 
 libc6
 libx11-6
 multiarch-support
libxt6 depends on: 
 libc6
 libice6
 libsm6
 libx11-6
So here is the script:

Code: Select all

#!/bin/sh

PKG=$@
DEPLIST=/tmp/deplist.$$$
NEXTDEPLIST=/tmp/nextdeplist.$$$

apt-cache depends $PKG | grep epends | gawk -F: '{ print $2 } ' | sed '/^$/d' > $DEPLIST

printf "$PKG depends on:\n"
cat $DEPLIST

for line in $(cat $DEPLIST); do
    apt-cache depends $line | grep epends | gawk -F: '{ print $2 } ' | sed '/^$/d' | tr -d '<>' | sort -u | uniq > $NEXTDEPLIST
    printf "$line depends on: \n"
        cat $NEXTDEPLIST
done
It does not iterate through the second dependency level, because in (literally) all of the cases you will arrive at libc6 or libgcc1.
..gnutella..

User avatar
franksinistra
Ivana Fukalot
Posts: 1093
Joined: Mon Jan 27, 2014 2:03 am
Location: 印尼国

Re: realdep - moar dependency

Unread post by franksinistra » Thu Feb 04, 2016 12:11 pm

wonder why i never thought of creating useful thing like this.... mucho thanks MB!
rice no more.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: realdep - moar dependency

Unread post by machinebacon » Thu Feb 04, 2016 12:17 pm

^ you can have a try and write a function that puts the depends into an array, prints the dependencies, then repeats it again until there's nothing left ;)

some (if not all) of dpkg is written in Perl, maybe it lends itself as a better option than a shell script.
..gnutella..

User avatar
ivanovnegro
Minister of Truth
Posts: 5448
Joined: Wed Oct 17, 2012 11:12 pm

Re: realdep - moar dependency

Unread post by ivanovnegro » Thu Feb 04, 2016 12:29 pm

Insanely good.

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: realdep - moar dependency

Unread post by rhowaldt » Thu Feb 04, 2016 12:47 pm

great! - is this different from the bloat-script i once made? yeah it is, right? that didn't go as deep, iirc...
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: realdep - moar dependency

Unread post by machinebacon » Thu Feb 04, 2016 1:53 pm

^ I was thinking about that, too -- IIRC it checks which packages share dependencies.
..gnutella..

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: realdep - moar dependency

Unread post by rhowaldt » Fri Feb 05, 2016 7:22 am

yeah, something like that. i think i made it so you could see the impact it would have on your system. so relative bloat only, where it says "this will pull in this dependency list, but of those deps you already have this this and this on your system so its not as bad as it seems"
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

User avatar
wuxmedia
Grasshopper
Posts: 6445
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: realdep - moar dependency

Unread post by wuxmedia » Fri Feb 05, 2016 7:27 am

nice work.
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
Snap
Sperminator
Posts: 189
Joined: Sun Oct 05, 2014 8:11 pm

Re: realdep - moar dependency

Unread post by Snap » Fri Feb 05, 2016 8:10 am

Great. Thank you.

User avatar
Theo
CLIt Licker
Posts: 394
Joined: Wed Nov 11, 2015 10:19 pm
Location: Nieuw-Buinen, Netherlands

Re: realdep - moar dependency

Unread post by Theo » Fri Feb 05, 2016 7:44 pm

Funny I was thinking about something like this the otherday and now it's here :)
A big thank you!

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: realdep - moar dependency

Unread post by machinebacon » Fri Feb 05, 2016 7:54 pm

This version just cleans up the list a bit:

Code: Select all

#!/bin/sh

PKG=$@
DEPLIST=/tmp/deplist.$$$
NEXTDEPLIST=/tmp/nextdeplist.$$$
ALLDEPS=/tmp/alldeplist.$$$

apt-cache depends $PKG | grep epends | gawk -F: '{ print $2 } ' | sed '/^$/d' > $DEPLIST

printf "$PKG depends on:\n"
cat $DEPLIST

for line in $(cat $DEPLIST); do
    apt-cache depends $line | grep epends | gawk -F: '{ print $2 } ' | sed '/^$/d' | tr -d '<>' | sort -u | uniq > $NEXTDEPLIST
        cat $NEXTDEPLIST >> $ALLDEPS
done

cat $ALLDEPS | sort -u | uniq 
rm $ALLDEPS $NEXTDEPLIST $DEPLIST

..gnutella..

User avatar
ChefIronBelly
Approved BBQer
Posts: 1044
Joined: Mon Jan 13, 2014 6:01 am
Location: Michigan

Re: realdep - moar dependency

Unread post by ChefIronBelly » Sat Feb 06, 2016 6:30 pm

Thanks added to the arsenal.
(1/1) Installing: LinuxBBQ...................................[69%]==============[/]

Post Reply