On a fresh FreeBSD 11.2 machine, my /usr/ports folder is empty.


portsnap fetch extract

…as discussed in the Handbook results in filling my /usr/ports with a gig of content.

If I only want one thing from the Ports Collection, such as the Postgres database server, this huge download is a needless waste of network traffic, disk space, and time.

➥ Is there a way to download only a single port to install?

If not, is there a way to download only one subset of the Ports Collection? For example, get just the databases sub-collection so I end up with only a /usr/ports/databases?

  • This is generally impossible, because ports tend to have dependencies, which also have their dependencies, and all of these also use some port infrastructure. So it is pretty hard to figure out minimal slice of the whole tree that is sufficient to build given port. – arrowd Nov 25 '18 at 12:44


You can't do it with portsnap. If you've already a snapshot (you downloaded it already) you can extract only parts of ports tree (portsnap extract databases/postgresql11-server), see man portsnap:

 path         For extract command only, operate only on parts of the ports                                                             

              tree starting with path.  (e.g. portsnap extract                                                                                  
              sysutils/port would extract sysutils/portsman,                                                                                    
              sysutils/portsnap, sysutils/portupgrade, etc.)


If you don't want fetch these big files you can use svn instead of portsnap:

svn checkout https://svn.freebsd.org/ports/head/databases/postgresql11-server

See the relevant part of handbook.

The svn is part of the base system (/usr/bin/svnlite - you can use an alias or replace svn to svnlite) so you don't have to install devel/subversion.


Yes, and it is simple. It is in the very chapter of the Handbook that you are looking at.

You will need the ports tree installed, which the Handbook explains how to do. It gives two ways, portsnap and checking out the tree (or even part of it, although cross-package dependencies militate against this) from source control. (PC-BSD/TrueOS users use git instead of subversion.)

Change to the individual directory of the port/package desired, run make fetch to fetch the source archive(s), and run make extract to extract the contents. You end up with the ports tree skeleton and only the files for that port present.

A fetch can also be performed at a higher level, such as /usr/ports/databases, as the Handbook explains in §

  • My Question is not about the make. My Question is about the ports tree of 34,000 apps that takes up a gig. I’m not interested in installing 34,000 apps. So I really don’t want to install a ports tree for 34,000 apps. I want to access the ports collection for only a single port, for the Postgres database server app, along with its few dependencies. – Basil Bourque Nov 25 '18 at 8:50
  • Then do not install 34,000 apps. You've nowhere been told to, in any answer here or in the Handbook. Installing the ports tree is not, of course, installing any of the applications. – JdeBP Nov 25 '18 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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