Create offline package with all dependencies

Is there a way to use pkg-create to create a package (for example openjdk17) that when installed does not require any internet access at all? (that is, to include all it's dependencies)
Also, can I do pkg-create -a and create a complete repo of my local packages in the same fashion, such as these then need no internet access nor perform any updates?
 
Must it be a single package?

If not, you can get all the transitive dependencies for a package with pkg fetch -Udo $TEMP_DIR $PACKAGE_NAME.
That will put all of the packages in $TEMP_DIR. You can distribute those.
Using pkg-fetch(8) will re-download those file, which is not ideal. If you don't want that, you can use the list it prints to copy them from /var/cache/pkg or wherever your pkg cache is.

You can install the with pkg add -A $TEMP_DIR/All/Hashed/*.pkg.
Then pkg set -A0 $PACKAGE_NAME to mark the target package as not automatic (not a dependency).
 
They'll just be downloaded to $TEMP_DIR. That's what the -U option does. It does not attempt to update the package database. I'm not sure its actually necessary.
 
Is there a way to use pkg-create to create a package (for example openjdk17) that when installed does not require any internet access at all? (that is, to include all it's dependencies)
Also, can I do pkg-create -a and create a complete repo of my local packages in the same fashion, such as these then need no internet access nor perform any updates?
Code:
     package          Make a binary package for the port.  The port will be
                      installed if it has not already been.  The package is a
                      .pkg file that you can use to install the port on other
                      machines with pkg-add(8).  If the directory specified by
                      PACKAGES does not exist, the package will be put in
                      /usr/ports/category/port/work/pkg.  See PKGREPOSITORY
                      and PKGFILE for more information.

     package-recursive
                      Like package, but makes a package for each depending
                      port as well.
ports(7)
 
Code:
     package          Make a binary package for the port.  The port will be
                      installed if it has not already been.  The package is a
                      .pkg file that you can use to install the port on other
                      machines with pkg-add(8).  If the directory specified by
                      PACKAGES does not exist, the package will be put in
                      /usr/ports/category/port/work/pkg.  See PKGREPOSITORY
                      and PKGFILE for more information.

     package-recursive
                      Like package, but makes a package for each depending
                      port as well.
ports(7)
Thank you! Does this work for packages that are installed from binaries though? How do I get access to `ports` ? Do I have to install ports-tools-1.8 ?
Thanks again!
 
Back
Top