2.2. How to use

This section describes how to install binary packages from CDROM, local disk or via FTP. Regardles of where you install from, be sure to have /usr/pkg and /usr/X11R6 in your $PATH so you can actually start the just installed program.

2.2.1. Local packages

If you have the files on a CDROM or downloaded them to your hard disk, you can install them with the following command (be sure to ``su'' to root first):

	pkg_add /path/to/package-vers.tgz
  
Examples:
	# pkg_add /usr/pkgsrc/packages/All/wget-1.5.3.tgz
	# pkg_add /cdrom/packages/All/wget-1.5.3.tgz
  
If you want to see what's going on, you can always add the -v option to ``pkg_add''.

2.2.2. Packages available via FTP

If you have FTP access and you don't want to download the packages via FTP prior to installation, you can do this automatically by giving pkg_add an ftp-URL:

	pkg_add ftp://ftp.netbsd.org/pub/NetBSD/packages/OS-Version/arch/All/package-vers.tgz
If there is any doubt about which OS-Version and arch you need to use, the ``sysctl'' utility can be used to determine them by running ``sysctl kern.osrelease hw.machine_arch''.

Example:

	# sysctl kern.osrelease hw.machine_arch
	kern.osrelease = 1.4.2
	hw.machine_arch = i386
	# pkg_add ftp://ftp.netbsd.org/pub/NetBSD/packages/1.4.2/i386/All/wget-1.5.3.tgz
	# 
  

Note that any prerequisite packages needed to run the package in question will be installed too, assuming they are present where you install from. You do not need to handle these manually, your desired package will arrange for everything to get installed that it needs.

2.2.3. Tips & Tricks

If you don't know a package's version to install it, you can simply omit it, i.e.:

	pkg_add /path/to/package
	pkg_add ftp://ftp.netbsd.org/pub/NetBSD/packages/OS-Version/arch/All/package
will find out the most recent version of package, and then install it. Examples:
	# pkg_add /usr/pkgsrc/packages/i386ELF/All/wget
	# pkg_add ftp://ftp.netbsd.org/pub/NetBSD/packages/1.4.2/i386/All/wget
When installing packages via FTP and you don't give it a version number, don't be surprised by any errors you see - ``pkg_add'' will first try to find the exact file you give it, before trying to find any version, and as the exact file isn't there, there will be an error. If you use -v on ``pkg_add'', you'll see what's going on in detail.

If you want to install many packages and don't want to type the full path to the package each time, you can set the PKG_PATH environment variable to contain a semi(!)colon seperate list of locations that may contain packages. Example:

	# PKG_PATH=/usr/pkgsrc/packages/All';'ftp://ftp.netbsd.org/pub/NetBSD/packages/1.4.2/sparc/All
	# export PKG_PATH
After you've set this (maybe in your root's .cshrc or .profile), you can then just install a package without giving it's path/URL or version. Example:
	# pkg_add wget
	#