# Downloading FreeBSD packages without installing it



## ryanbram (Sep 26, 2012)

After read in FreeBSD manual page about pkg_add(1), I noticed that there are many option for it. For example:


*pkg_add -K* for keeping any downloaded package in PKGDIR;
*pkg_add -r* for using the remote fetching feature;
*pkg_add -d* if I do not actually install a package.

But I didn't notice how to download package with its dependencies without installing it. Because I want to bundle some packages in a CD for offline installation. Is there anyone who will to help me?


----------



## Beastie (Sep 26, 2012)

AFAIK, there's no way with the current pkg_* tools.
I usually download a package manually, extract the dependencies file and create a list of dependencies by appending a repository server's full URL to each line. This can be done through scripting or using vi/vim.
Of course I end up with as many lists as I have "main" packages (i.e. many duplicates), so they are later combined and processed using sort(1) and uniq(1).
The lists can finally be downloaded using fetch(1) in a loop, or more easily ftp/wget (using the *-i* option).


----------



## kpa (Sep 26, 2012)

With PKGNG you can do:

`# pkg fetch <pkg-name>`

The fetched package will be in /var/cache/pkg/All.


----------



## kpedersen (Sep 26, 2012)

For this I used a command called pkg_fetch.

It is part of ports-mgmt/portupgrade

The '-R' flag downloads required packages too.

Nowerdays I just download the whole ~30gig package folder from the FTP onto a large usb memory stick. It is just so convenient to have every (decent) bit of software imaginable in my pocket haha.


----------



## ryanbram (Sep 27, 2012)

Many thanks. I finally figured out why I can not find it in the FreeBSD's manual page, because it wasn't part of the base system.
But I wonder why this tool isn't included in FreeBSD's base system?


----------

