Properly deinstall ports and dependencies

Hello
I'm very new to FreeBSD/Unix/Linux and just installed a 9.1RC2 system with X. After reading the whole handbook, I'm still quite unsure how I properly uninstall ports I don't need and especially, how I remove their dependencies.

For example...I installed firefox...and I didn't like it. So (before reading the handbook), I typed
Code:
cd /usr/ports/www/firefox
make deinstall clean
and got rid of it.
However, it probably only removed firefox, not the dependencies.

How can I do that? What should I do now to remove the (unused) dependencies of firefox?

I installed cutleaves, but when I use it, it just asks me about every installed port if I want to remove it or not. Isn't there a way to detect, which ports a port depends on and which ports depend on it and offer a method to get rid of all the dependency-ports which are not used by any other port?

Thanks a lot, I would just like to have a clean system. :)

-Decsis
 
pkg_cutleaves(1) is the way to go. Either that or doing it by hand. Firefox has quite a large dependency list.

Code:
root@molly:~# cd /usr/ports/www/firefox
root@molly:/usr/ports/www/firefox# make all-depends-list
/usr/ports/ports-mgmt/pkg
/usr/ports/lang/perl5.14
/usr/ports/devel/nspr
/usr/ports/security/nss
/usr/ports/databases/sqlite3
/usr/ports/databases/py-sqlite3
/usr/ports/graphics/cairo
/usr/ports/archivers/unzip
/usr/ports/lang/python27
/usr/ports/archivers/zip
/usr/ports/devel/yasm
/usr/ports/devel/gmake
/usr/ports/x11/printproto
/usr/ports/x11/libSM
/usr/ports/x11-toolkits/libXt
/usr/ports/x11/libXi
/usr/ports/x11/libXext
/usr/ports/x11/libX11
/usr/ports/x11/libXinerama
/usr/ports/x11/libICE
/usr/ports/x11/xproto
/usr/ports/devel/autoconf213
/usr/ports/textproc/intltool
/usr/ports/devel/pkgconf
/usr/ports/devel/desktop-file-utils
/usr/ports/devel/libevent2
/usr/ports/devel/libffi
/usr/ports/textproc/hunspell
/usr/ports/graphics/jpeg
/usr/ports/graphics/png
/usr/ports/multimedia/libvpx
/usr/ports/devel/dbus-glib
/usr/ports/devel/libnotify
/usr/ports/x11/startup-notification
/usr/ports/audio/alsa-lib
/usr/ports/converters/libiconv
/usr/ports/graphics/libGL
/usr/ports/accessibility/atk
/usr/ports/devel/glib20
/usr/ports/x11-toolkits/gtk20
/usr/ports/devel/libIDL
/usr/ports/x11-toolkits/pango
/usr/ports/audio/alsa-plugins
/usr/ports/devel/gio-fam-backend
/usr/ports/devel/libtool
/usr/ports/x11/xcb-util-renderutil
/usr/ports/x11/libXrender
/usr/ports/print/freetype2
/usr/ports/x11-fonts/fontconfig
/usr/ports/x11/pixman
/usr/ports/devel/gettext
/usr/ports/devel/xorg-macros
/usr/ports/x11/xtrans
/usr/ports/x11/kbproto
/usr/ports/x11/xextproto
/usr/ports/x11/inputproto
/usr/ports/x11/libXau
/usr/ports/x11/libxcb
/usr/ports/x11/bigreqsproto
/usr/ports/x11/xcmiscproto
/usr/ports/x11-fonts/xf86bigfontproto
/usr/ports/x11/libXdmcp
/usr/ports/x11/xineramaproto
/usr/ports/devel/m4
/usr/ports/devel/autoconf-wrapper
/usr/ports/textproc/p5-XML-Parser
/usr/ports/devel/cmake
/usr/ports/shells/bash
/usr/ports/devel/dbus
/usr/ports/devel/gobject-introspection
/usr/ports/x11/xcb-util
/usr/ports/devel/makedepend
/usr/ports/textproc/py-libxml2
/usr/ports/devel/bison
/usr/ports/x11/glproto
/usr/ports/x11/dri2proto
/usr/ports/x11/libXxf86vm
/usr/ports/x11/libXdamage
/usr/ports/x11/libXfixes
/usr/ports/graphics/libdrm
/usr/ports/textproc/expat2
/usr/ports/devel/pcre
/usr/ports/x11/libXrandr
/usr/ports/x11/libXcursor
/usr/ports/x11/libXcomposite
/usr/ports/graphics/gtk-update-icon-cache
/usr/ports/print/cups-client
/usr/ports/graphics/gdk-pixbuf2
/usr/ports/misc/shared-mime-info
/usr/ports/misc/hicolor-icon-theme
/usr/ports/x11-fonts/libXft
/usr/ports/x11-fonts/xorg-fonts-truetype
/usr/ports/x11-fonts/encodings
/usr/ports/devel/gamin
/usr/ports/x11/renderproto
/usr/ports/devel/libcheck
/usr/ports/textproc/libxslt
/usr/ports/x11/xcb-proto
/usr/ports/devel/libpthread-stubs
/usr/ports/devel/cmake-modules
/usr/ports/textproc/libxml2
/usr/ports/sysutils/gnome_subr
/usr/ports/devel/gperf
/usr/ports/x11/xf86vidmodeproto
/usr/ports/x11/damageproto
/usr/ports/x11/fixesproto
/usr/ports/devel/libpciaccess
/usr/ports/x11/randrproto
/usr/ports/x11/compositeproto
/usr/ports/security/libgcrypt
/usr/ports/security/gnutls
/usr/ports/graphics/jasper
/usr/ports/graphics/tiff
/usr/ports/x11-fonts/font-bh-ttf
/usr/ports/x11-fonts/font-misc-meltho
/usr/ports/x11-fonts/font-misc-ethiopic
/usr/ports/x11-fonts/bitstream-vera
/usr/ports/x11-fonts/mkfontscale
/usr/ports/x11-fonts/bdftopcf
/usr/ports/x11-fonts/font-util
/usr/ports/misc/pciids
/usr/ports/security/libgpg-error
/usr/ports/security/nettle
/usr/ports/security/p11-kit
/usr/ports/graphics/jbigkit
/usr/ports/x11-fonts/mkfontdir
/usr/ports/x11-fonts/libfontenc
/usr/ports/x11-fonts/libXfont
/usr/ports/math/gmp
/usr/ports/x11-fonts/fontsproto
root@molly:/usr/ports/www/firefox#
 
I use pkg_cutleaves -gx , then answer the questions as to which you want to keep and delete. Then when finished it will write a file to /usr/local/etc/pkg_leaves.exclude. Then the next time you run it just use pkg_cutleaves -x and it will read this file and then only act upon ports which are not included in this file. If you ever install new ports you want to keep just run it with -gx again.
 
portmaster(8) can remove unneeded dependencies after deinstalling something. However, it will ask to remove all unneeded dependencies, not just those freed up by deinstalling that port.
 
wblock@ said:
portmaster(8) can remove unneeded dependencies after deinstalling something. However, it will ask to remove all unneeded dependencies, not just those freed up by deinstalling that port.

I guess the command option to do this is

# portmaster -s

or use the -e option.

Code:
[-n|y] [-b] [-D|d] -e name/glob of a single port directory in /var/db/pkg
    expunge a port using pkg_delete(1), and optionally remove all distfiles.  Calls -s after
    it is done expunging in case removing the port causes a dependency to no longer be necessary.

To remove firefox and its (no more referenced) dependencies

# portmaster -e 'firefox-*'
 
With PKGNG it becomes very simple:

# pkg delete package
# pkg autoremove

That removes no longer depended on packages assuming they were installed automatically as dependencies of the removed package.
 
sacii said:
Try this:

Code:
cd /usr/ports/www/firefox
make all-depends-list | xargs -I {} make -C {} deinstall clean

(I could not edit my original post.)

The above may not be a complete solution. Unless all-depends-list also lists dependencies of dependencies, this will only deinstall the first tier of dependencies.
 
Um... make deinstall will deinstall ports even if there are other dependencies on them. So that is probably going to remove a lot more than the user wants.
 
wblock@ said:
Um... make deinstall will deinstall ports even if there are other dependencies on them. So that is probably going to remove a lot more than the user wants.

Um... the OP said he wanted to deinstall firefox and dependencies. Using make deinstall will only deinstall firefox.
 
sacii said:
Um... the OP said he wanted to deinstall firefox and dependencies. Using make deinstall will only deinstall firefox.

But that script feeds all those dependencies to xargs(1). They will all be deinstalled, regardless of whether or not other things are depending on them. The message will be "... is required by these other packages and may not be deinstalled (but I'll delete it anyway)".

Code:
% make -C /usr/ports/www/firefox all-depends-list | wc -l
123

The first one of those is Perl, which is definitely needed by other things.
 
wblock@ said:
But that script feeds all those dependencies to xargs(1). They will all be deinstalled, regardless of whether or not other things are depending on them...

True, which is why I added the note about pkg_delete.
 
Back
Top