Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

While compiling some port, I realized that it depends on 1000+ of other ports and will install forever until I die or my disk is full (my hdd is really small).

I interrupted make install clean.

How do I uninstall and clean those dependencies which have already been built and installed? (there are at least 100+ of them)

pkg_cutleaves wont work in this case, since the main port wasn't registered yet.

Please help.

FreeBSD 9.0-RELEASE amd64

EDIT: Another way to ask this question: How can I see all dependencies for a non-registered port, and all subdependencies for those dependencies, independent with previously installed ports or their [sub]dependencies?

share|improve this question
    
May I ask what you isntalled? I'd really like to know which port has so many dependencies. –  Christopher Perrin Oct 21 '12 at 0:00
    
@ChristopherPerrin: Does it really matter? Even if there are 10 dependencies, it's nice to have a way to roll them back. Try any gaming port which uses X11. –  Radio Oct 21 '12 at 0:02
    
I'm sorry. I don't know the answer to your question. I'm just courious. I am administering a few servers and I want to make sure that I don't compile 1000+ ports :) –  Christopher Perrin Oct 21 '12 at 0:03
    
List of those 'heavy' ports will be created after my question will be answered. =)) –  Radio Oct 21 '12 at 0:05
    
Having read through your comments above and to @Voretaq7 below I really do get the impression that your not doing this in a professional environment which puts you outside of our faq. Perhaps unix.stackexchange.com would be a more appropriate place for this question. –  Iain Oct 21 '12 at 7:20

4 Answers 4

Next time run make all-depends-list before you start building the port.
If you don't like what you see on the list don't go any further.
This and other gems can be found in /usr/ports/Mk/bsd.port.mk. Not friendly reading though.

You're mildly screwed in terms of cleaning up the mess.
You really have two options that I can think of:

  • Option 1 - Run the command above, figure out what you don't need, and uninstall it.
    This is probably the least painful option.

  • Option 2 - run pkg_info -aR and look for packages with no dependencies.
    Determine which ones you don't need and uninstall them.
    (This is a good housekeeping practice every year or so IMHO, but it's annoying.)

In terms of cleaning up the build detritus a simple make clean in the offending port's directory should trigger cleaning of the dependencies. You can also do a make clean in /usr/ports, but it's probably faster to blow the tree away and re-extract it with portsnap if you want to go that route...


As another (dirtier) option that's very specific to this situation: If you know you haven't installed any other ports since the "mistake" and the last time you installed ports was a while ago you can use the create dates of the directories in /var/db/pkg - Simply remove the packages whose db entries were created around the time of the aborted install.

As with the other options above you'll still need to look at the packages you're removing in order to make sure you don't blow away anything important, but this should be a substantially shorter list than the other two options if it works for your situation.

share|improve this answer
    
In regards to Option 1, - how would I really know if I don't need some of those packages? They may depend on others installed earlier. –  Radio Oct 21 '12 at 0:20
    
@Radio That I'm afraid is the reason you're screwed. You can run pkg_info -R (note capital R, also fixed in my answer) against the package for each of them to see what installed packages list it as a dependency, but ultimately you need to exercise some human judgment: You could have a package with no dependents that's critical to you, and you obviously don't want to uninstall those. –  voretaq7 Oct 21 '12 at 0:26
    
Let's point it this way - I'm now screwed, I'm asking a question and playing games on FreeBSD. I'm rejecting your physiologist's advices to exercise my human judgment, since you have no idea what it's like in me. You are making dramatic judgments which is not correct to do in a place like here. –  Radio Oct 21 '12 at 0:38
    
Here it is - As another (dirtier) option! Seems very clean! Can you make it as an answer and I will accept it? –  Radio Oct 21 '12 at 0:45
    
@Radio I'm sorry if you're not happy with the answer, but exercising judgment is very often a sysadmin's job. You're welcome to wait for another answer that suits you better, but the only way I know of to safely remove unnecessary ports requires you to first manually verify that they are not necessary (for some other package or your use of the system). Blindly uninstalling every package entered into the DB after a certain date is not an inherently safe thing to do, and still requires you to look before you leap. –  voretaq7 Oct 21 '12 at 0:47

make install clean completes the install on all dependencies before it begins clean. If your ports tree was clean when you started, then the dependencies you just installed are the ones with work subdirectories and .install_done* files in those subdirectories.

find /usr/ports -mindepth 3 -maxdepth 3 -type d -name work -print |
while read wrkdir; do
  ls -1a "$wrkdir" | grep -q '^\.install_done' && dirname "$wrkdir"
done
share|improve this answer

Give portmaster -s a try. It will offer you to remove the ports that nothing on your system depends on. (If you don't have it installed, install it first from ports-mgmt/portmaster.)

share|improve this answer
up vote 1 down vote accepted

The solution is pretty easy if you know the date/time of when you started make install:

  • Get list of all installed packages and sort by modified date: ls -ltr /var/db/pkg
  • Copy results to your favorite text editor
  • Remove lines with the packages you need to keep
  • Remove all columns except for the file name only
  • Add pkg_delete before each file name
  • Copy result to your ssh console multiple times*** until selected packages will be deleted.

*** Running once is not enough, because in that list of packages you've generated - there are packages dependent on each other.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.