Chapter 6. Frequently Asked Questions

Table of Contents

6.1. Are there any mailing lists for pkg-related discussion?
6.2. Where's the pkgviews documentation?
6.3. Utilities for package management (pkgtools)
6.4. How to use pkgsrc as non-root
6.5. How to resume transfers when fetching distfiles?
6.6. How can I install/use XFree86 from pkgsrc?
6.7. How can I install/use X.org from pkgsrc?
6.8. How to fetch files from behind a firewall
6.9. How do I tell make fetch to do passive FTP?
6.10. How to fetch all distfiles at once
6.11. What does “Don't know how to make /usr/share/tmac/tmac.andoc” mean?
6.12. What does “Could not find bsd.own.mk” mean?
6.13. Using 'sudo' with pkgsrc
6.14. Configuration files handling and placement
6.15. Automated security checks

This section contains hints, tips & tricks on special things in pkgsrc that we didn't find a better place for in the previous chapters, and it contains items for both pkgsrc users and developers.

6.1. Are there any mailing lists for pkg-related discussion?

The following mailing lists may be of interest to pkgsrc users:

  • pkgsrc-bugs -- a list where problem reports related to pkgsrc are sent and discussed

  • pkgsrc-bulk -- a list where the results of pkgsrc bulk builds are sent and discussed

  • pkgsrc-changes -- a list where all commit messages to pkgsrc are sent

  • tech-pkg -- a general discussion list for all things related to pkgsrc

To subscribe, do:

% echo subscribe listname | mail majordomo@NetBSD.org

Archives for all these mailing lists are available from http://mail-index.NetBSD.org/.

6.2. Where's the pkgviews documentation?

Pkgviews is tightly integrated with buildlink. You can find a pkgviews User's guide in pkgsrc/mk/buildlink3/PKGVIEWS_UG.

6.3. Utilities for package management (pkgtools)

The pkgsrc/pkgtools directory pkgtools contains a number of useful utilities for both users and developers of pkgsrc. This section attempts only to make the reader aware of the utilities and when they might be useful, and not to duplicate the documentation that comes with each package.

Utilities used by pkgsrc (automatically installed when needed):

OS tool augmentation (automatically installed when needed):

Utilities used by pkgsrc (not automatically installed):

  • pkgtools/pkg_tarup: create a binary package from an already-installed package. used by make replace to save the old package

  • pkgtools/dfdisk: adds extra functionality to pkgsrc, allowing it to fetch distfiles from multiple locations. It currently supports the following methods: multiple CD-ROMs and network FTP/HTTP connections.

  • pkgtools/xpkgwedge: put X11 packages someplace else (enabled by default)

  • devel/cpuflags: will determine the best compiler flags to optimise code for your current CPU and compiler.

Utilities for keeping track of installed packages, being up to date, etc:

Utilities for people maintaining or creating individual packages:

Utilities for people maintaining pkgsrc (or more obscure pkg utilities)

6.4. How to use pkgsrc as non-root

If you want to use pkgsrc as non-root user, you can set some variables to make pkgsrc work under these conditions. At the very least, you need to set UNPRIVILEGED to “yes”; this will turn on unprivileged mode and set multiple related variables to allow installation of packages as non-root.

In case the defaults are not enough, you may want to tune some other variables used. For example, if the automatic user/group detection leads to incorrect values (or not the ones you would like to use), you can change them by setting UNPRIVILEGED_USER and UNPRIVILEGED_GROUP respectively.

As regards bootstrapping, please note that the bootstrap script will ease non-root configuration when given the “--ignore-user-check” flag, as it will choose and use multiple default directories under ~/pkg as the installation targets. These directories can be overriden by the “--prefix” flag provided by the script, as well as some others that allow finer tuning of the tree layout.

6.5. How to resume transfers when fetching distfiles?

By default resuming transfers in pkgsrc is disabled, but you can enable this feature by adding the option PKG_RESUME_TRANSFERS=YES into /etc/mk.conf. If, during a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.

You can also use a different program than the default ftp(1) by changing the FETCH_CMD variable. Don't forget to set FETCH_RESUME_ARGS and FETCH_OUTPUT_ARGS if you are not using default values.

For example, if you want to use wget to resume downloads, you'll have to use something like:

        FETCH_CMD=wget
        FETCH_BEFORE_ARGS=--passive-ftp
        FETCH_RESUME_ARGS=-c
        FETCH_OUTPUT_ARGS=-O
    

6.6. How can I install/use XFree86 from pkgsrc?

If you want to use XFree86 from pkgsrc instead of your system's own X11 (/usr/X11R6, /usr/openwin, ...), you will have to add the following line into /etc/mk.conf:

      X11_TYPE=XFree86
    

6.7. How can I install/use X.org from pkgsrc?

If you want to use X.org from pkgsrc instead of your system's own X11 (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into /etc/mk.conf:

      X11_TYPE=xorg
    

6.8. How to fetch files from behind a firewall

If you are sitting behind a firewall which does not allow direct connections to Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This is done using an environment variable in the form of a URL e.g. in Amdahl, the machine “orpheus.amdahl.com” is one of the firewalls, and it uses port 80 as the proxy port number. So the proxy environment variables are:

  ftp_proxy=ftp://orpheus.amdahl.com:80/
http_proxy=http://orpheus.amdahl.com:80/

6.9. How do I tell make fetch to do passive FTP?

This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk, FETCH_CMD is assigned the first available command from the following list:

${LOCALBASE}/bin/ftp
/usr/bin/ftp

On a default NetBSD installation, this will be /usr/bin/ftp, which automatically tries passive connections first, and falls back to active connections if the server refuses to do passive. For the other tools, add the following to your /etc/mk.conf file: PASSIVE_FETCH=1.

Having that option present will prevent /usr/bin/ftp from falling back to active transfers.

6.10. How to fetch all distfiles at once

You would like to download all the distfiles in a single batch from work or university, where you can't run a make fetch. There is an archive of distfiles on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.

The answer here is to do a make fetch-list in /usr/pkgsrc or one of it's subdirectories, carry the resulting list to your machine at work/school and use it there. If you don't have a NetBSD-compatible ftp(1) (like lukemftp) at work, don't forget to set FETCH_CMD to something that fetches a URL:

At home:

% cd /usr/pkgsrc
% make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
% scp /tmp/fetch.sh work:/tmp

At work:

% sh /tmp/fetch.sh

then tar up /tmp/distfiles and take it home.

If you have a machine running NetBSD, and you want to get all distfiles (even ones that aren't for your machine architecture), you can do so by using the above-mentioned make fetch-list approach, or fetch the distfiles directly by running:

% make mirror-distfiles

If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get everything by running:

% make fetch NO_SKIP=yes

6.11. What does “Don't know how to make /usr/share/tmac/tmac.andoc” mean?

When compiling the pkgtools/pkg_install package, you get the error from make that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates that you don't have installed the “text” set (nroff, ...) from the NetBSD base distribution on your machine. It is recommended to do that to format manpages.

In the case of the pkgtools/pkg_install package, you can get away with setting NOMAN=YES either in the environment or in /etc/mk.conf.

6.12. What does “Could not find bsd.own.mk” mean?

You didn't install the compiler set, comp.tgz, when you installed your NetBSD machine. Please get it and install it, by extracting it in /:

# cd /
# tar --unlink -zxvpf .../comp.tgz

comp.tgz is part of every NetBSD release. Get the one that corresponds to your release (determine via uname -r).

6.13. Using 'sudo' with pkgsrc

When installing packages as non-root user and using the just-in-time su(1) feature of pkgsrc, it can become annoying to type in the root password for each required package installed. To avoid this, the sudo package can be used, which does password caching over a limited time. To use it, install sudo (either as binary package or from security/sudo) and then put the following into your /etc/mk.conf:

        .if exists(${LOCALBASE}/bin/sudo)
        SU_CMD=${LOCALBASE}/bin/sudo /bin/sh -c
        .endif
    

6.14. Configuration files handling and placement

The global variable PKG_SYSCONFBASE (and some others) can be set by the system administrator in /etc/mk.conf to define the place where configuration files get installed. Therefore, packages must be adapted to support this feature. Keep in mind that you should only install files that are strictly necessary in the configuration directory, files that can go to $PREFIX/share should go there.

We will take a look at available variables first (bsd.pkg.mk contains more information). PKG_SYSCONFDIR is where the configuration files for a package may be found (that is, the full path, e.g. /etc or /usr/pkg/etc). This value may be customized in various ways:

  1. PKG_SYSCONFBASE is the main config directory under which all package configuration files are to be found. Users will typically want to set it to /etc, or accept the default location of $PREFIX/etc.

  2. PKG_SYSCONFSUBDIR is the subdirectory of PKG_SYSCONFBASE under which the configuration files for a particular package may be found. Defaults to ${SYSCONFBASE}.

  3. PKG_SYSCONFVAR is the special suffix used to distinguish any overriding values for a particular package (see next item). It defaults to ${PKGBASE}, but for a collection of related packages that should all have the same PKG_SYSCONFDIR value, it can be set in each of the package Makefiles to a common value.

  4. PKG_SYSCONFDIR.${PKG_SYSCONFVAR} overrides the value of ${PKG_SYSCONFDIR} for packages with the same value for PKG_SYSCONFVAR.

    As an example, all the various KDE packages may want to set PKG_SYSCONFVAR to “kde” so admins can set PKG_SYSCONFDIR.kde in /etc/mk.conf to define where to install KDE config files.

Programs' configuration directory should be defined during the configure stage. Packages that use GNU autoconf can usually do this by using the “--sysconfdir” parameter, but this brings some problems as we will see now. When you change this pathname in packages, you should not allow them to install files in that directory directly. Instead they need to install those files under share/examples/${PKGNAME} so PLIST can register them.

Once you have the required configuration files in place (under the share/examples directory) the variable CONF_FILES should be set to copy them into PKG_SYSCONFDIR. The contents of this variable is formed by pairs of filenames; the first element of the pair specifies the file inside the examples directory (registered by PLIST) and the second element specifies the target file. This is done this way to allow binary packages to place files in the right directory using INSTALL/DEINSTALL scripts which are created automatically. The package Makefile must also set USE_PKGINSTALL=YES to use these automatically generated scripts. The automatic copying of config files can be toggled by setting the environment variable PKG_CONFIG prior to package installation.

Here is an example, taken from mail/mutt/Makefile:

  EGDIR=            ${PREFIX}/share/doc/mutt/samples
CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc

As you can see, this package installs configuration files inside EGDIR, which are registered by PLIST. After that, the variable CONF_FILES lists the installed file first and then the target file. Users will also get an automatic message when files are installed using this method.

6.15. Automated security checks

Please be aware that there can often be bugs in third-party software, and some of these bugs can leave a machine vulnerable to exploitation by attackers. In an effort to lessen the exposure, the NetBSD packages team maintains a database of known-exploits to packages which have at one time been included in pkgsrc. The database can be downloaded automatically, and a security audit of all packages installed on a system can take place. To do this, install the security/audit-packages package. It has two components:

  1. download-vulnerability-list”, an easy way to download a list of the security vulnerabilities information. This list is kept up to date by the NetBSD security officer and the NetBSD packages team, and is distributed from the NetBSD ftp server:

    ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/pkg-vulnerabilities

  2. audit-packages”, an easy way to audit the current machine, checking each vulnerability which is known. If a vulnerable package is installed, it will be shown by output to stdout, including a description of the type of vulnerability, and a URL containing more information.

Use of the security/audit-packages package is strongly recommended! After “audit-packages” is installed, please read the package's message, which you can get by running pkg_info -D audit-package.