Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
TIP: Record deps before trying package (for easy removal)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
timeBandit
Bodhisattva
Bodhisattva


Joined: 31 Dec 2004
Posts: 2672
Location: here, there or in transit

PostPosted: Fri Jan 12, 2007 5:18 am    Post subject: TIP: Record deps before trying package (for easy removal) Reply with quote

Suppose you want to try out a new package, and it needs a boatload of dependent packages you don't have installed. If you don't like the package and decide to remove it, how do you identify and clean out those now-unnecessary dependencies? You could review your Portage logs to find packages merged just before the main one, but that's a bit tedious. With a little forethought and a couple of one-liner commands, you can easily reverse such trial installations, without struggling to find all the pieces.

Let's use Banshee (a fairly nice media player) as an example. Before installing it, I previewed the result like every good Gentooer:
Code:
# emerge -p media-sound/banshee

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N    ] dev-dotnet/libgdiplus-1.2.2  USE="gif jpeg tiff -exif"
[ebuild  N    ] dev-lang/mono-1.2.2.1  USE="X nptl"
[ebuild  N    ] dev-dotnet/pe-format-0
[ebuild  N    ] dev-perl/XML-LibXML-Common-0.13
[ebuild  N    ] dev-perl/XML-LibXML-1.60
[ebuild  N    ] dev-dotnet/gtk-sharp-2.8.0  USE="-doc"
[ebuild  N    ] dev-dotnet/art-sharp-2.8.0
[ebuild  N    ] dev-dotnet/gnomevfs-sharp-2.8.0
[ebuild  N    ] dev-dotnet/gnome-sharp-2.8.0
[ebuild  N    ] dev-dotnet/glade-sharp-2.8.0
[ebuild  N    ] dev-dotnet/gconf-sharp-2.8.0
[ebuild  N    ] media-libs/gst-plugins-ugly-0.10.3  USE="-debug"
[ebuild  NS   ] media-plugins/gst-plugins-lame-0.10.4
[ebuild  N    ] media-sound/banshee-0.11.3  USE="encode mad vorbis -aac -boo -daap -debug -doc -flac -ipod -njb"

That's quite a lot of baggage to unload if I decide I don't like Banshee. So I did this first, to snapshot the changes:
Save a dependency list:
# emerge -p media-sound/banshee | awk '/ebuild/{print "="$4}' >~/media-sound:banshee.deps

This recorded the packages I was about to install, in ~/media-sound:banshee.deps:
Code:
# cat ~/media-sound:banshee.deps
=dev-dotnet/libgdiplus-1.2.2
=dev-lang/mono-1.2.2.1
=dev-dotnet/pe-format-0
=dev-perl/XML-LibXML-Common-0.13
=dev-perl/XML-LibXML-1.60
=dev-dotnet/gtk-sharp-2.8.0
=dev-dotnet/art-sharp-2.8.0
=dev-dotnet/gnomevfs-sharp-2.8.0
=dev-dotnet/gnome-sharp-2.8.0
=dev-dotnet/glade-sharp-2.8.0
=dev-dotnet/gconf-sharp-2.8.0
=media-libs/gst-plugins-ugly-0.10.3
=media-plugins/gst-plugins-lame-0.10.4
=media-sound/banshee-0.11.3

If I decide I don't want Banshee after all, I can now remove everything installed with it, using just one command:
Remove packages in saved list:
# emerge -aC $(<~/media-sound:banshee.deps)
That's it!

This technique works best if you decide on the fate of such trials fairly soon, before installing other packages whose dependencies overlap. If you can't avoid that, you can use equery and the snapshot file to determine which dependencies to keep. Continuing the example, shortly after installing Banshee I decided to test-drive Beagle as well. The snapshot file for Beagle is:
app-misc:beagle.deps:
=dev-libs/gmime-2.1.19
=app-misc/beagle-0.2.7
I know they are both Mono applications so Beagle must depend on some of the same pieces Banshee pulled in already. The question is, which ones? Easy answer:
Code:
# for p in $(sed -e 's/=\(.*\)-[0-9].*/\1/' media-sound:banshee.deps)
> do equery -N depends $p | egrep "Searching|beagle"; done

[ Searching for packages depending on dev-dotnet/libgdiplus... ]
[ Searching for packages depending on dev-lang/mono... ]
app-misc/beagle-0.2.7
[ Searching for packages depending on dev-dotnet/pe-format... ]
[ Searching for packages depending on dev-perl/XML-LibXML-Common... ]
[ Searching for packages depending on dev-perl/XML-LibXML... ]
[ Searching for packages depending on dev-dotnet/gtk-sharp... ]
app-misc/beagle-0.2.7
[ Searching for packages depending on dev-dotnet/art-sharp... ]
[ Searching for packages depending on dev-dotnet/gnomevfs-sharp... ]
[ Searching for packages depending on dev-dotnet/gnome-sharp... ]
app-misc/beagle-0.2.7
[ Searching for packages depending on dev-dotnet/glade-sharp... ]
app-misc/beagle-0.2.7
[ Searching for packages depending on dev-dotnet/gconf-sharp... ]
app-misc/beagle-0.2.7
[ Searching for packages depending on media-libs/gst-plugins-ugly... ]
[ Searching for packages depending on media-plugins/gst-plugins-lame... ]
[ Searching for packages depending on media-sound/banshee... ]
(Please note the > in the midst of that command is a shell continuation prompt, not a redirection [don't type it]).

So should I decide to keep Beagle but not Banshee, I would manually excise mono, gtk-sharp, gnome-sharp, glade-sharp and gconf-sharp from media-sound:banshee.deps before using it as input to emerge -aC, and I won't need to run revdep-rebuild afterward.

Edit: Fixed typo to create proper package atoms in .deps files.
_________________
Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others.


Last edited by timeBandit on Tue Apr 17, 2007 5:31 pm; edited 1 time in total
Back to top
View user's profile Send private message
Dan
Veteran
Veteran


Joined: 25 Oct 2005
Posts: 1301

PostPosted: Fri Jan 12, 2007 2:38 pm    Post subject: Reply with quote

why not use app-portage/udept and dep --help 8O
_________________
- Failure is not an option. It's bundled with your software.
Back to top
View user's profile Send private message
Conan
Guru
Guru


Joined: 02 Nov 2004
Posts: 360

PostPosted: Fri Jan 12, 2007 7:59 pm    Post subject: Reply with quote

Code:
emerge --depclean -av


much easier.
Back to top
View user's profile Send private message
timeBandit
Bodhisattva
Bodhisattva


Joined: 31 Dec 2004
Posts: 2672
Location: here, there or in transit

PostPosted: Fri Jan 12, 2007 9:30 pm    Post subject: Reply with quote

Conan wrote:
Code:
emerge --depclean -av

much easier.

Actually I've always found it rather worthless--it invariably selects many essential packages for removal. The point here was to locate/record only the deps just installed, not all the deps. If --depclean works for you...I'm envious. :)

As for dep, IIRC the last time I used it (or maybe its predecessor--it was years ago), it lacked a lot of the power it seems to have now. I'll check it out.

Ah well, I've made a fool of myself in far bigger ways than this. :oops: :)
_________________
Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others.
Back to top
View user's profile Send private message
red-wolf76
l33t
l33t


Joined: 13 Apr 2005
Posts: 714
Location: Rhein-Main Area

PostPosted: Sun Mar 11, 2007 9:49 am    Post subject: Reply with quote

Not to worry, I'd have suggested a notepad and pencil for this. :lol:
_________________
0mFg, G3nt00 r0X0r$ T3h B1g!1111 ;)

Use sane CFLAGS! If for no other reason, do it for the lulz!
Back to top
View user's profile Send private message
vandien
Tux's lil' helper
Tux's lil' helper


Joined: 03 May 2006
Posts: 137

PostPosted: Tue Apr 17, 2007 2:57 am    Post subject: Reply with quote

hey, nice work. I was doing something similar (though more manually) until I figured out how to make depclean function. So this might help, I dunno.

depclean needs two things to work:
    1. Your world file (/var/lib/portage/world) needs to be complete, with all the packages you've emerged and want installed. You can edit this file manually, or probably safer, just "emerge -n package" anything missing from the world file.

    2. Your USE flags need to be set correctly (as in, never running "USE=blah emerge package"). Make sure to set up the global USE variable in /etc/make.conf as well as per package USE flags in /etc/portage/package.use

Also, after you remove anything with depclean, it's a very good idea to run revdep-rebuild (from app-portage/gentoolkit), just to be safe. My routine is now (removing -p after each command if everything looks okay):

emerge --sync
emerge -DNupv world
emerge --depclean -p
revdep-rebuild -p

Gentoo has been running smoothly since I got my world and use flags in order and started doing this :)
Back to top
View user's profile Send private message
defenderBG
l33t
l33t


Joined: 20 Jun 2006
Posts: 817

PostPosted: Tue Apr 17, 2007 6:39 am    Post subject: Reply with quote

@timeBandit: do u really need that stuff? u can awlays take a look at ur log:
cat /var/log/emerge.log | grep 'emerge (' | less
once there just press '/' and search for the package...

@vandien: i used it once and forgot the revdev-rebuild... i had some nasty time and thus I don't use it anymore
Back to top
View user's profile Send private message
urcindalo
Guru
Guru


Joined: 08 Feb 2005
Posts: 553
Location: Almeria, Spain

PostPosted: Tue Apr 17, 2007 10:34 am    Post subject: Reply with quote

vandien wrote:
My routine is now (removing -p after each command if everything looks okay):

emerge --sync
emerge -DNupv world
emerge --depclean -p
revdep-rebuild -p

Gentoo has been running smoothly since I got my world and use flags in order and started doing this :)


Same for me. You're absolutely right about the conditions for --depclean to work. I use a slightly different four-step update routine: fis, fiuw, fic, fir. Each one of these commands is an alias entry in my .bashrc:
Code:
alias fis="sudo eix-sync && sudo update-eix-remote update"
alias fiuw="sudo emerge --update --newuse --deep --ask -vt world"
alias fic="sudo emerge --ask -v --depclean && sudo eclean -d distfiles && sudo eclean -d packages && sudo etcportclean -c111111 -r1 -w1 -d1 -v1 && sudo find /var/log/ -name "*.log" -mtime +1 -exec bzip2 -z '{}' \; && sudo find /var/log -name "*.bz2" -mtime +30 -exec rm '{}' \;"
alias fir="sudo revdep-rebuild -v"
Why I chose those alias names is out of the scope of this explanation, but has to be with 'fink' in OS X :)

I've never had a problem with this update/maintenance procedure, and the command names to remember are short and convenient. As a benefit, the procedure eliminates packages you don't need anymore as a dependency when you did nothing special to log them. This is what portage is all about, in the first place. For instance, today I got rid of:
Code:
>>> These are the packages that would be unmerged:

 virtual/jdk
    selected: 1.4.2
   protected: none
     omitted: 1.5.0

 dev-java/blackdown-jdk
    selected: 1.4.2.03-r12
   protected: none
     omitted: none

>>> 'Selected' packages are slated for removal.
>>> 'Protected' and 'omitted' packages will not be removed.

Would you like to unmerge these packages? [Yes/No]

that were installed way back in the past on my AMD64 box.
Back to top
View user's profile Send private message
timeBandit
Bodhisattva
Bodhisattva


Joined: 31 Dec 2004
Posts: 2672
Location: here, there or in transit

PostPosted: Tue Apr 17, 2007 12:46 pm    Post subject: Reply with quote

defenderBG wrote:
@timeBandit: do u really need that stuff? u can awlays take a look at ur log: ... and search for the package...

Yes of course, and the individual log files in /var/log/portage provide the same info with a simple ls -l. The points of the exercise are (1) not to search at all and (2) save a list for input to emerge to clean the packages.

@vandien and others: I know how to make --depclean work, but it's unusable on my system. I only update world once or twice a year, on average, so depclean rarely understands my dependency graph. Thanks anyway for trying to help. :)
_________________
Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others.
Back to top
View user's profile Send private message
jonnevers
Veteran
Veteran


Joined: 02 Jan 2003
Posts: 1593
Location: Gentoo64 land

PostPosted: Tue Apr 17, 2007 5:14 pm    Post subject: Reply with quote

timeBandit wrote:
defenderBG wrote:
@timeBandit: do u really need that stuff? u can awlays take a look at ur log: ... and search for the package...

Yes of course, and the individual log files in /var/log/portage provide the same info with a simple ls -l. The points of the exercise are (1) not to search at all and (2) save a list for input to emerge to clean the packages.

@vandien and others: I know how to make --depclean work, but it's unusable on my system. I only update world once or twice a year, on average, so depclean rarely understands my dependency graph. Thanks anyway for trying to help. :)


while this is a very nice hack, having to use sed (or any utility that is not specifically part of portage )to maintain a consistent portage is just silly.

I propose the next revision of Portage includes this functionality some how... so us users don't need to do manual hacks to keep portage clean and clear.

btw, this made GWN!
Back to top
View user's profile Send private message
timeBandit
Bodhisattva
Bodhisattva


Joined: 31 Dec 2004
Posts: 2672
Location: here, there or in transit

PostPosted: Tue Apr 17, 2007 5:22 pm    Post subject: Reply with quote

jonnevers wrote:
btw, this made GWN!

8O :o 8)
_________________
Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others.
Back to top
View user's profile Send private message
ian!
Bodhisattva
Bodhisattva


Joined: 25 Feb 2003
Posts: 3827
Location: Essen, Germany

PostPosted: Tue Apr 17, 2007 7:24 pm    Post subject: Reply with quote

jonnevers wrote:
while this is a very nice hack, having to use sed (or any utility that is not specifically part of portage )to maintain a consistent portage is just silly.


You might want to have a look at app-portage/demerge and the thread 'demerge - emerge the other ways around' then.
_________________
"To have a successful open source project, you need to be at least somewhat successful at getting along with people." -- Daniel Robbins
Back to top
View user's profile Send private message
mikenerone
n00b
n00b


Joined: 11 Feb 2004
Posts: 20
Location: San Antonio, TX

PostPosted: Thu Apr 19, 2007 6:16 pm    Post subject: Reply with quote

Thought I'd chime in with my upgrade procedure:

# gsync
...
# gup
...

gsync:
Code:

#! /bin/bash

termtitle 'Syncing layman overlays'
layman -S
termtitle ''

emerge --sync


gup:
Code:

#! /bin/bash

EMERGELOG=/var/log/emerge.log
TMPFILE=$(mktemp)

STOP=0

# Update
let SIZE=$(stat -c '%s' "${EMERGELOG}")+1
emerge -auvDN world || exit 1
tail --bytes=+${SIZE} "${EMERGELOG}" > ${TMPFILE}
qlop -lC -f ${TMPFILE} | grep -q ' >>> ' || STOP=1
rm -f ${TMPFILE}
[[ $STOP -eq 1 ]] && exit

# Handle configuration changes
termtitle 'Config changes'
dispatch-conf || { termtitle '' ; exit 1 ; }

# Clean stale dependencies
emerge -av --depclean

# Clean PORTDIR/distfiles and PORTDIR/packages

termtitle 'Cleaning distfiles directory'
eclean -d distfiles

termtitle 'Cleaning packages directory'
eclean packages
symlinks -dr /usr/portage/packages

# Check for broken packages
termtitle 'Checking for broken dependencies'
revdep-rebuild -p --nocolor | tee ${TMPFILE}
grep -q '^\[ebuild' <${TMPFILE} || STOP=1
rm -f ${TMPFILE}
if [[ $STOP -eq 1 ]]; then
  termtitle ''
  exit
fi

# Rebuild broken packages
echo ''
read -p 'Do you want me to remerge these packages? [Yes/No] '
if echo $REPLY | grep -Eq '^([yY]|$)'; then
  termtitle 'Rebuilding broken dependencies'
  revdep-rebuild
else
  rm -f ~/.revdep-rebuild.*
fi

termtitle ''


termtitle:
Code:

#! /bin/bash

printf "\e]0;$*\a"


BTW, if anyone knows a better way to do anything (such as the way I detect if any packages actually got merged by the "emerge -auvDN world"), do speak up.

Mike Nerone
Back to top
View user's profile Send private message
desultory
Administrator
Administrator


Joined: 04 Nov 2005
Posts: 7956

PostPosted: Fri Apr 20, 2007 7:58 am    Post subject: Reply with quote

mikenerone wrote:
BTW, if anyone knows a better way to do anything (such as the way I detect if any packages actually got merged by the "emerge -auvDN world"), do speak up.
One way would be to check /var/log/emerge.log.
Back to top
View user's profile Send private message
STEDevil
Apprentice
Apprentice


Joined: 24 Apr 2003
Posts: 156

PostPosted: Fri Apr 20, 2007 11:52 pm    Post subject: Re: TIP: Record deps before trying package (for easy removal Reply with quote

timeBandit wrote:
Suppose you want to try out a new package, and it needs a boatload of dependent packages you don't have installed. If you don't like the package and decide to remove it, how do you identify and clean out those now-unnecessary dependencies?


paludis media-sound/banshee --uninstall --with-unused-dependencies -p
Back to top
View user's profile Send private message
Cyker
Veteran
Veteran


Joined: 15 Jun 2006
Posts: 1497

PostPosted: Sat Apr 21, 2007 1:57 am    Post subject: Reply with quote

Someone mentioned a utility called demerge - It's awesome; It sortof takes a snapshot of the state of Portage, so you can try a bunch of stuff, then make it revert back to that state by 'intelligently' unmerging and re-merging anything that was added/removed :D
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks 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