Packages and ports in FreeBSD

Explain to the inexperienced FreeBSD user the difference between ports and packages in FreeBSD. Why do we need ports if there are packages? Obviously, ported applications can be re-architected or redesigned in some way. It seems to me that either the pgk hierarchy is higher than the ports. I tried to install one application via packages and ports, pkg replaced it. It is also not clear where a lot of links for downloading are determined from when installing through ports for the archive. Where they are stored and how the system determines the links from where to download the source code archive.
 
I've read this part, but I still don't understand where download links are defined from. I'm using FreeBSD offline and need to figure out where the download paths for the archives come from.
 
Why do we need ports if there are packages?
Packages are build from ports with the default configuration options.

I tried to install one application via packages and ports, pkg replaced it.
pkg(8) replaced it because that port was most likely ahead in version of the available package on the remote package repository. See /etc/pkg/FreeBSD.conf.

It is also not clear where a lot of links for downloading are determined from when installing through ports for the archive. Where they are stored and how the system determines the links from where to download the source code archive.
Those download links are defined by variables in the ports Makefile and different supporting files of the ports framework where those variables are specified, see /usr/ports/Mk/bsd.sites.mk, grep(1) recursively for "SITE" in /usr/ports/Mk/.

To print a list of a ports download links see fetch-list and fetch-recursive-list in manual ports(7).

To the practical solution, the easiest way to get those archives for building a port and eventually its dependencies on the offline system, you need a FreeBSD system with internet connection and a ports tree installed, it can be a VM.

Next, change to the port which should be build and execute make fetch-recursive (see ports(7) manual for details). This will download those archives in /usr/ports/distfiles.

Copy the whole ports tree to the offline system, begin build and installation of ports.

To update the offline systems ports tree, update the online systems ports tree, this includes eventually fetching distfiles again, and synchronize it.

Another option, the better one, would be to build those ports as packages on a online machine and distribute them to the offline system (see ports-mgmt/poudriere-devel. This devel port of poudriere has the capability to use pre-build packages, if possible, for build dependencies, which will reduce build time significantly).
 
Another thought. I assume the offline system is not nearby a internet interface, surly you have a mobile phone, if you have a mobile data plan for internet, the phone could temporarily be connected to the offline machine, ports (or packages) can be installed much more comfortable that way.

Plug in the phone (Android or iOS) into a USB port of the offline system, activate USB tethering on the phone, look at dmesg(8) if a ue0 interface appeared, execute dhclient ue0 to get the interface configured, proceed with ports (packages installation).

The download speed might be slow with USB tethering, if the offline machine has a wifi device or if there is a USB WiFi dongle available, the phone can be used as a mobile WiFi hotspot.
 
If you dislike the idea of being tied to the internet, perhaps explore:

$ pkg fetch -a

To grab every package, then you can simply store on a ~40G usb stick ready for your offline machines.
 
Back
Top