2010-01-14

FreeBSD - How to manage ports in FreeBSD using portmanager

There are various way of managing ports, using utilities. The usual "cd /usr/ports/<ports directory>; make; make install; make clean", portmaster, portupgrade and others. Today, this post will brief on how to use portmanager to install, upgrade and delete ports.

Using portmanager to manage ports have a few advantage :
  1. portmanager scans for what dependencies are needed and then determine what needed to be upgrade or install in order to fulfill the dependencies. At this stage, the dependencies are identified install/upgrade which is good as other utilities tends to fail in the mid of the installation just because some ports are too old or cannot install.
  2. portmanager supports output its messages to a log file. This is especially useful for trouble shooting what port / dependencies are giving problem.
  3. portmanager is also able to backup the current port/dependency before installing the new port. This useful when the new port cannot be install or interrupted during the installation, resulted a state where new port fail to install and new port have been deleted.
  4. portmanager collects its data by scanning the ports tree rather then building an index for the installed ports and depend on it. This is very less likely to cause problem as indexes are tend to be corrupted when abruptly (Ctrl-C) stopping installation in the halfway.
  5. portmanager gives a summary when installing dependencies/port. This gives an idea how many ports needs to be install or upgrade. This also means how much caffeine needed :p


Enough talking. Here are some example on how to manage ports using portmanager :
  • Port (Single) installation or upgrade, with logging.e.g. :
    portmanager net/rsync -l
  • Resume a halfway interrupted portmanager process.e.g. :
    portmanager net/rsync -l --resume
  • Backup the current port before proceed installing the new port. After the new port have been install, the current port will be deleted. This switch is to prevent problem occur when new port is unable to install and the old port have been deleted.e.g. :
    portmanager net/rsync -l -bu
  • List installed ports status and show what port needs update or upgrade.
    portmanager -s
  • List ports that are no dependency of other ports, aka "leafs".
    portmanager -sl
  • Upgrade all installed ports, with logging.
    portmanager -u -l
  • Install / Upgrade a single port then rebuild all of its dependency.e.g.
    portmanager audio/mp3blaster -f -l
    This might take a long time as it will rebuild all of its dependencies.
  • Upgrade and rebuild all installed ports. This will take a long time as it will rebuild ALL of the installed ports.
    portmanager -u -f
  • In case a particular port(s) is corrupted and cannot proceed to install or upgrade, fix the ports tree then rebuild all ports & dependencies.BEWARE : This will take a long time and all your current services will have to be stop as rebuilding will remove the binaries as well.
    rm -rf /usr/ports
    portsnap fetch update
    portmanager -u -f -l -y
    


Some basic stuff :
  1. Before proceeding to install ports using any utility, update the ports tree.
    portsnap fetch update
  2. Basic portmanager command line construction :
    portmanager <category>/<port name> <switches>
    <category>/<port name> ==> e.g. net/rsync, x11/kde4 or ftp/wget ...
  3. Refer to the post "FreeBSD – Tips to prepare large ports installation" for preparation of ports that has tens or hundreds of dependencies.

Ciao !!!

No comments: