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).