Installing packages without internet

Hello. I have a fresh FreeBSD install, and i want to install everything without internet on the computer. Through external media such as the original installation ISO (that i have on a USB stick), or other external storage media. I repeat that i do not want acces to the internet at this particular computer, at least for the time being. Thanks
 
Stuff all the packages you need on a USB stick and use pkg-add(8) to install them. Hint use FAT32 on the stick because that's the only filesystem you can reliably write with any other OS and read on a "barebones" FreeBSD install.
 
Something like env PACKAGESITE=file:///some/location pkg bootstrap

Alternatively you can simply unpack the pkg package and use the pkg-static inside the archive to install itself (which is basically what pkg(7) does automatically).
 
Through external media such as the original installation ISO (that i have on a USB stick), or other external storage media.
The easiest way to create a package repository for the offline machine is to install from the USB FreeBSD installer stick on the external media a full FreeBSD system, then connect that external device to a machine with internet connection.

It's more complicated to make the installer USB a package repository for the offline machine. First, the file system of an .img installer is write protected, it must be configured rw in /etc/fstab. Next, most likely there is not enough space on the installers file system. If there is free disk space on the USB stick, or growfs(8) the installers file system or create a proper second partition in the free space.

On the installed system, packages can be pkg-fetch(8)'ed for the offline machine, e.g.:

Code:
# pkg fetch -o /packages pkg

# pkg fetch -o /packages  -d  xorg-minimal  xfce
To upgrade the packages of the offline machine is another problem.
 
If I understand correctly (I'm not using installer to install FreeBSD), the install media having (limited amount of) pkg is *-dvd1.iso currently.
So assuming you have this written in memstick or something.
And if the media has a directory having subdirectories
  • All
  • Latest
and files
  • data.pkg
  • data.tzst
  • meta
  • meta.conf
  • packagesite.pkg
  • packagesite.tzst
in it, the directory can be considered as local pkg repository.

If this is true, you can create a pkg repo config file (i.e., custom.conf) in /usr/local/etc/pkg/repos/ which its contents are like below.
Code:
custom: {
    url: "file:///full_path_to_the_directory",
    enabled: yes,
}
In this example, you can install pkgs from there with pkg install -r custom pkg_to_be_installed.
 
Something like env PACKAGESITE=file:///some/location pkg bootstrap

Alternatively you can simply unpack the pkg package and use the pkg-static inside the archive to install itself (which is basically what pkg(7) does automatically).
Is there a guide or man page about how pkg-static works to bootstrap pkg? Because just running ./pkg-static gives a "pkg:not enough arguments" error.
I would like to keep the standard FreeBSD install convention structure for configs directories etc.
 
One of my long term plans has been to have a local pkg repository and wondered how much space all of FreeBSD's pkgs take up and is there a way of downloading all of them rather than specifying them individually?
 
Is there a guide or man page about how pkg-static works to bootstrap pkg? Because just running ./pkg-static gives a "pkg:not enough arguments" error.
The complete output when running pkg-static is:
Code:
[1-0] # pkg-static
pkg: not enough arguments
Usage: pkg [-v] [-d] [-l] [-N] [-j <jail name or id>|-c <chroot path>|-r <rootdir>] [-C <configuration file>] [-R <repo config dir>] [-o var=value] [-4|-6] <command> [<args>]

For more information on available commands and options see 'pkg help'.
[2->1<] #
This is, with respect to pkg-static(8), not very informative.

When searching for a specific man(1) page, you can use its options: the documented "search functionality" is apropos(1). You can use apropos pkg-staticpkg(8) and pkg-static(8) share their man page*. Unfortunately pkg help pkg-static is not functional; pkg help pkg, however, does display the shared man page.

With respect to pkg-static(8):
Code:
DESCRIPTION
       pkg  provides  an  interface  for  manipulating    packages: registering,
       adding, removing    and upgrading packages.     pkg-static  is     a  statically
       linked  variant of pkg typically    only used for the initial installation
       of pkg.    There are some differences in functionality.  See  pkg.conf(5)
       for details.
Therefore, in most cases, using pkg < ... > or pkg-static < ... > produces the same result.

Actual bootstrapping of pkg(8) is needed when /ports-mgmt/pkg from the ports tree (that includes pkg-static(8), see pkg list pkg) is not yet installed. For this bootstrapping, /usr/sbin/pkg, part of the FreeBSD base install (not located in the ports tree) is used, pkg(7)**:
Code:
       pkg [-46] bootstrap [-fy] [-r reponame]
           Attempt    to bootstrap and do not    forward    anything to pkg(8) af-
           ter it is installed.  With -4 and -6, pkg will  force  IPv4  or
           IPv6 respectively to fetch pkg(8) and its signatures as needed.
           If  the    -f  flag is specified, then pkg(8) will    be fetched and
           installed regardless if it is already  installed.   If  the  -y
           flag  is     specified,  no     confirmation will be asked when boot-
           strapping pkg(8).

           If a reponame has been specified, then  the  configuration  for
           that repository will be used.

Note that (using the tcsh(1)-s built-in where):
Rich (BB code):
# where pkg pkg-static
/usr/sbin/pkg              <- this is pkg(7)
/usr/local/sbin/pkg        <- this is part of /ports-mgmt/pkg
/usr/local/sbin/pkg-static <- this is also part of /ports-mgmt/pkg
Furthermore, when /ports-mgmt/pkg is installed /usr/local/sbin/pkg is usually executed by simply using pkg < ... > due to the search order defined in PATH. Executing pkg(8) is therefore usually the net result of the cascaded calling sequence via /usr/sbin/pkg, as documented in pkg(7)

___
* That is, of course, when /ports-mgmt/pkg is installed!
** When /ports-mgmt/pkg is installed, pkg-static bootstrap is in fact a NOP (no operation); see pkg(8).
However, when /ports-mgmt/pkg is not installed, there is, of course, no /usr/local/sbin/pkg-static.
 
Code:
$ pkg fetch -a
...
Number of packages to be fetched: 37013

The process will require 157 GiB more space.
157 GiB to be downloaded.

Proceed with fetching packages? [y/N]:
Assuming I fetch all these packages, what is required to use these packages as a local repository on my LAN?
 
Assuming I fetch all these packages, what is required to use these packages as a local repository on my LAN?
Assuming you're on 14.3-Release, amd64 and quarterly pkg, use the repo on the very computer you've fetched the pkg, and you don't want to install / configure web server to make things simple.

  1. Decide which directory to make local repo. Here, /usr/local/pkg-repo/ as an example.
  2. Create subdirectories All and Latest there.
  3. Fetch pkgs you want into the All subdirectory.
  4. Create symlink pkg.pkg pointing to /usr/local/pkg-repo/All/pkg.pkg.
  5. Fetch all files (not directories!) at https://pkg.freebsd.org/FreeBSD:14:amd64/quarterly/ into /usr/local/pkg-repo/.
  6. Create repository configuration file (here, custom.conf as example) like below in /usr/local/etc/pkg/repos/.
Example of custom.conf
Code:
custom: {
    url: "file:///usr/local/pkg-repo",
    enabled: yes,
}
 
7) Use pkg-repo(8) to generate the catalogue files required to make it a proper "repository". This will create the meta files and the catalogue database.

Code:
     pkg repo is used to create a catalogue of the available packages in a
     repository.  pkg repo catalogues are necessary for sharing your package
     repository, and are intrinsic to the operation of pkg install or pkg
     upgrade.

You can dump any number of packages in the All directory, then generate the meta files with pkg-repo(8) and you can use it as a "proper" repository.
 
Code:
$ pkg fetch -a
...
Number of packages to be fetched: 37013

The process will require 157 GiB more space.
157 GiB to be downloaded.

Proceed with fetching packages? [y/N]:
I have limited monthly download limit and wonder if would be able resume at the point where my download limit was exhausted if I tried the following month.
 
There is a thing I do not understand (well, tons of things but this is one). If I run the command make package in the ports tree, the result is a package of the port in the default packages directory /usr/ports/packages/All. If I set the environment variable PKGREPOSITORY=/usr/ports/packages and run the same command, the package will be created in /usr/ports/packages.

Am I to assume that it is more correct to set the variable PACKAGES=/usr/ports/packages and use the variable PKGREPOSITORY=All to be able to use pkg-repo(8)?
I'm just trying to understand how some internal mechanisms of the ports work to get consistent results, I tried setting only one or the other variable but not both because I didn't think they were related.
 
If I run the command make package in the ports tree, the result is a package of the port in the default packages directory /usr/ports/packages/All.
You should have kinda configuration to store resulting pkg into /usr/ports/packages/All/, at least building pkg on single port directory.
By default, pkg is created under ${WRKDIR}/pkg/, for example with x11/nvidia-kmod, /usr/ports/x11/nvidia-kmod/work/pkg/.
Code:
/usr/ports/x11/nvidia-kmod# make package
===>  Building packages for nvidia-kmod-580.119.02.1600007
===>   Building nvidia-kmod-580.119.02.1600007
/usr/ports/x11/nvidia-kmod# ls /usr/ports/x11/nvidia-kmod/work/pkg
nvidia-kmod-580.119.02.1600007.pkg
/usr/ports/x11/nvidia-kmod#

On the other hand, tools like ports-mgmt/portupgrade stores resulting pkg into /usr/ports/packages/All/ as you described, if specified to create package (for portupgrade, option -p but could be different on different tools).
 
...

On the other hand, tools like ports-mgmt/portupgrade stores resulting pkg into /usr/ports/packages/All/ as you described, if specified to create package (for portupgrade, option -p but could be different on different tools).
Yes, I'm writing my own tool. What I'd like to do is to use everything the ports infrastructure already provides and nothing more (at least this is my intention).What is confusing me is the directory used by the packages and all the possible forms. Here's a quick example:
Code:
cd /usr/ports/ports-mgmt/portmaster
make package
the package is in /usr/ports/ports-mgmt/portmaster/work/pkg, ok, no repository, every package is created in its work directory.
Code:
cd /usr/ports/ports-mgmt/portmaster
make PACKAGES=/usr/ports/packages package
the package is in /usr/ports/packages/All, ok, if I run the same command for other ports the packages are all in that directory, repository

Code:
cd /usr/ports/ports-mgmt/portmaster
make PKGREPOSITORY=/usr/ports/packages package
the package is in /usr/ports/packages, ok. Where did the All directory go? Is the same as the previous exemple? Should I have set PKGREPOSITORY=/usr/ports/packages/All? Is the directory All necessary?
I make the example with the directory /usr/ports/packages but it works the same way with another one.
Basically what I'm confused about is the All directory, I don't understand its necessity.
 
Back
Top