Chapter 3. Using pkgsrc on systems other than NetBSD

Table of Contents

3.1. Binary distribution
3.2. Bootstrapping pkgsrc
3.3. Platform-specific notes
3.3.1. Cygwin
3.3.2. Darwin (Mac OS X)
3.3.3. FreeBSD
3.3.4. GNU/kFreeBSD
3.3.5. Interix
3.3.6. IRIX
3.3.7. Linux
3.3.8. MirBSD
3.3.9. OpenBSD
3.3.10. Solaris

3.1. Binary distribution

See Section 4.1, “Using binary packages”.

3.2. Bootstrapping pkgsrc

pkgsrc can be bootstrapped for use in two different modes: privileged and unprivileged one. In unprivileged mode in contrast to privileged one all programs are installed under one particular user and cannot utilise privileged operations (packages don't create special users and all special file permissions like setuid are ignored).

Installing the bootstrap kit from source should be as simple as:

# env CVS_RSH=ssh cvs -d [email protected]:/cvsroot checkout -P pkgsrc
# cd pkgsrc/bootstrap
# ./bootstrap
    

To bootstrap in unprivileged mode pass --unprivileged flag to bootstrap

By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs will be installed in, and /var/db/pkg for the package database directory where pkgsrc will do its internal bookkeeping, /var is used as varbase, where packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg for prefix, ~/pkg/var/db/pkg for the package database, and ~/pkg/var for varbase.

You can change default layout using command-line arguments. Run ./bootstrap --help to get details.

Note

The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc. For examples in this guide, use bmake instead of make.

Note

It is possible to bootstrap multiple instances of pkgsrc using non-intersecting directories. Use bmake corresponding to the installation you're working with to build and install packages.

3.3. Platform-specific notes

Here are some platform-specific notes you should be aware of.

3.3.1. Cygwin

Cygwin 1.7.x and later are supported.

You need to install minimal base packages in `Base' category plus any of compiler, gcc, gcc4, and/or clang. For gcc and gcc4, C and C++ compiler will be installed by default, but you can install Fortran compiler additionally because it will be required to use libtool. If it is not installed (or too old), Fortran compiler will be installed with pkgsrc automatically.

As noted in Cygwin FAQ: `Why doesn't su work?', su(1) command has been in Cygwin distribution, but it has never worked. Unless you bootstrap pkgsrc with the --unprivileged option, workaround is:

  • Right click "Cygwin Terminal" in your Start Menu, then pick "Run as administrator".

3.3.2. Darwin (Mac OS X)

Darwin 5.x and up are supported.

Before you start, you need to download and install the Mac OS X Developer Tools from Apple's Developer Connection. This requires (free) membership. See http://developer.apple.com/macosx/ for details. Also, make sure you install X11 (an optional package included with the Developer Tools) if you intend to build packages that use the X11 Window System. (If you don't want or need the full Xcode GUI, download and install Command Line Tools for Xcode.)

3.3.3. FreeBSD

FreeBSD 8.3 and 9.0 have been tested and are supported, other versions may work.

Care should be taken so that the tools that this kit installs do not conflict with the FreeBSD userland tools. There are several steps:

  1. FreeBSD stores its ports pkg database in /var/db/pkg. It is therefore recommended that you choose a different location (e.g. /usr/pkgdb) by using the --pkgdbdir option to the bootstrap script.

  2. If you do not intend to use the FreeBSD ports tools, it's probably a good idea to move them out of the way to avoid confusion, e.g.

    # cd /usr/sbin
    # mv pkg_add pkg_add.orig
    # mv pkg_create pkg_create.orig
    # mv pkg_delete pkg_delete.orig
    # mv pkg_info pkg_info.orig
    	  
  3. An example mk.conf file will be placed in /etc/mk.conf.example file when you use the bootstrap script.

3.3.4. GNU/kFreeBSD

Debian GNU/kFreeBSD is the only GNU/kFreeBSD distribution now. Debian GNU/kFreeBSD 7.0 or later is tested and supported.

You should install ncurses (libncurses and libncurses-dev) packages.

3.3.5. Interix

Interix is a POSIX-compatible subsystem for the Windows NT kernel, providing a Unix-like environment with a tighter kernel integration than available with Cygwin. It is part of the Windows Services for Unix package, available for free for any licensed copy of Windows 2000, XP (not including XP Home), or 2003. SFU can be downloaded from http://www.microsoft.com/windows/sfu/.

Services for Unix 3.5 has been tested. 3.0 or 3.1 may work, but are not officially supported. (The main difference in 3.0/3.1 is lack of pthreads, but other parts of libc may also be lacking.)

Services for Unix Applications (aka SUA) is an integrated component of Windows Server 2003 R2 (5.2), Windows Vista and Windows Server 2008 (6.0), Windows 7 and Windows Server 2008 R2 (6.1). As of this writing, the SUA's Interix 6.0 (32bit) and 6.1 (64bit) subsystems have been tested. Other versions may work as well. The Interix 5.x subsystem has not yet been tested with pkgsrc.

3.3.5.1. When installing Interix/SFU

At an absolute minimum, the following packages must be installed from the Windows Services for Unix 3.5 distribution in order to use pkgsrc:

  • Utilities -> Base Utilities

  • Interix GNU Components -> (all)

  • Remote Connectivity

  • Interix SDK

When using pkgsrc on Interix, DO NOT install the Utilities subcomponent "UNIX Perl". That is Perl 5.6 without shared module support, installed to /usr/local, and will only cause confusion. Instead, install Perl 5.8 from pkgsrc (or from a binary package).

The Remote Connectivity subcomponent "Windows Remote Shell Service" does not need to be installed, but Remote Connectivity itself should be installed in order to have a working inetd.

During installation you may be asked whether to enable setuid behavior for Interix programs, and whether to make pathnames default to case-sensitive. Setuid should be enabled, and case-sensitivity MUST be enabled. (Without case-sensitivity, a large number of packages including perl will not build.)

NOTE: Newer Windows service packs change the way binary execution works (via the Data Execution Prevention feature). In order to use pkgsrc and other gcc-compiled binaries reliably, a hotfix containing POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer) must be installed. Hotfixes are available from Microsoft through a support contract; however, Debian Interix Port has made most Interix hotfixes available for personal use from http://www.debian-interix.net/hotfixes/.

In addition to the hotfix noted above, it may be necessary to disable Data Execution Prevention entirely to make Interix functional. This may happen only with certain types of CPUs; the cause is not fully understood at this time. If gcc or other applications still segfault repeatedly after installing one of the hotfixes note above, the following option can be added to the appropriate "boot.ini" line on the Windows boot drive: /NoExecute=AlwaysOff (WARNING, this will disable DEP completely, which may be a security risk if applications are often run as a user in the Administrators group!)

3.3.5.2. What to do if Interix/SFU is already installed

If SFU is already installed and you wish to alter these settings to work with pkgsrc, note the following things.

  • To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft Windows Services for UNIX, then click Change. In the installer, choose Add or Remove, then uncheck Utilities->UNIX Perl.

  • To enable case-sensitivity for the file system, run REGEDIT.EXE, and change the following registry key:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel

    Set the DWORD value "obcaseinsensitive" to 0; then reboot.

  • To enable setuid binaries (optional), run REGEDIT.EXE, and change the following registry key:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX

    Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.

3.3.5.3. Important notes for using pkgsrc

The package manager (either the pkgsrc "su" user, or the user running "pkg_add") must be a member of the local Administrators group. Such a user must also be used to run the bootstrap. This is slightly relaxed from the normal pkgsrc requirement of "root".

The package manager should use a umask of 002. "make install" will automatically complain if this is not the case. This ensures that directories written in /var/db/pkg are Administrators-group writeable.

The popular Interix binary packages from http://www.interopsystems.com/ use an older version of pkgsrc's pkg_* tools. Ideally, these should NOT be used in conjunction with pkgsrc. If you choose to use them at the same time as the pkgsrc packages, ensure that you use the proper pkg_* tools for each type of binary package.

The TERM setting used for DOS-type console windows (including those invoked by the csh and ksh startup shortcuts) is "interix". Most systems don't have a termcap/terminfo entry for it, but the following .termcap entry provides adequate emulation in most cases:

interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
	

3.3.5.4. Limitations of the Interix platform

Though Interix suffices as a familiar and flexible substitute for a full Unix-like platform, it has some drawbacks that should be noted for those desiring to make the most of Interix.

  • X11:

    Interix comes with the standard set of X11R6 client libraries, and can run X11 based applications, but it does not come with an X server. Some options are StarNet X-Win32, Hummingbird Exceed (available in a trimmed version for Interix from Interop Systems as the Interop X Server), and the free X11 server included with Cygwin.

  • X11 acceleration:

    Because Interix runs in a completely different NT subsystem from Win32 applications, it does not currently support various X11 protocol extensions for acceleration (such as MIT-SHM or DGA). Most interactive applications to a local X server will run reasonably fast, but full motion video and other graphics intensive applications may require a faster-than-expected CPU.

  • Audio:

    Interix has no native support for audio output. For audio support, pkgsrc uses the esound client/server audio system on Interix. Unlike on most platforms, the audio/esound package does not contain the esd server component. To output audio via an Interix host, the emulators/cygwin_esound package must also be installed.

  • CD/DVDs, USB, and SCSI:

    Direct device access is not currently supported in Interix, so it is not currently possible to access CD/DVD drives, USB devices, or SCSI devices through non-filesystem means. Among other things, this makes it impossible to use Interix directly for CD/DVD burning.

  • Tape drives:

    Due to the same limitations as for CD-ROMs and SCSI devices, tape drives are also not directly accessible in Interix. However, support is in work to make tape drive access possible by using Cygwin as a bridge (similarly to audio bridged via Cygwin's esound server).

3.3.5.5. Known issues for pkgsrc on Interix

It is not necessary, in general, to have a "root" user on the Windows system; any member of the local Administrators group will suffice. However, some packages currently assume that the user named "root" is the privileged user. To accommodate these, you may create such a user; make sure it is in the local group Administrators (or your language equivalent).

pkg_add creates directories of mode 0755, not 0775, in $PKG_DBDIR. For the time being, install packages as the local Administrator (or your language equivalent), or run the following command after installing a package to work around the issue:

# chmod -R g+w $PKG_DBDIR
	

3.3.6. IRIX

You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro compiler (cc/c89). Please set the CC environment variable according to your preference. If you do not have a license for the MIPSpro compiler suite, you can download a gcc tardist file from http://freeware.sgi.com/.

Please note that you will need IRIX 6.5.17 or higher, as this is the earliest version of IRIX providing support for if_indextoname(3), if_nametoindex(3), etc.

At this point in time, pkgsrc only supports one ABI at a time. That is, you cannot switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI. If you start out using "abi=n32", that's what all your packages will be built with.

Therefore, please make sure that you have no conflicting CFLAGS in your environment or the mk.conf. Particularly, make sure that you do not try to link n32 object files with lib64 or vice versa. Check your /etc/compiler.defaults!

If you have the actual pkgsrc tree mounted via NFS from a different host, please make sure to set WRKOBJDIR to a local directory, as it appears that IRIX linker occasionally runs into issues when trying to link over a network-mounted file system.

The bootstrapping process should set all the right options for programs such as imake(1), but you may want to set some options depending on your local setup. Please see pkgsrc/mk/defaults/mk.conf and, of course, your compiler's man pages for details.

If you are using SGI's MIPSPro compiler, please set

PKGSRC_COMPILER=        mipspro
      

in mk.conf. Otherwise, pkgsrc will assume you are using gcc and may end up passing invalid flags to the compiler. Note that bootstrap should create an appropriate mk.conf.example by default.

If you have both the MIPSPro compiler chain installed as well as gcc, but want to make sure that MIPSPro is used, please set your PATH to not include the location of gcc (often /usr/freeware/bin), and (important) pass the '--preserve-path' flag.

3.3.7. Linux

Some versions of Linux (for example Debian GNU/Linux) need either libtermcap or libcurses (libncurses). Installing the distributions libncurses-dev package (or equivalent) should fix the problem.

pkgsrc supports both gcc (GNU Compiler Collection) and icc (Intel C++ Compiler). gcc is the default. icc 8.0 and 8.1 on i386 have been tested.

To bootstrap using icc, assuming the default icc installation directory:

env ICCBASE=/opt/intel/cc/10.1.008 ./bootstrap --compiler=icc
      

Note

For icc 8.0 you must add `LDFLAGS=-static-libcxa' to this.

For icc 8.1 you must add `LDFLAGS=-i-static' instead.

For icc 10.1 neither of these appears to be necessary.

Use a value for ICCBASE that corresponds to the directory where icc is installed. After bootstrapping, set ICCBASE in mk.conf:

ICCBASE=                /opt/intel/cc/10.1.008
      

The pkgsrc default for ICCBASE is /opt/intel_cc_80. This is the default install directory for icc 8.0. If you are using a more recent version, be sure to set the correct path explicitly.

pkgsrc uses the static linking method of the runtime libraries provided by icc, so binaries can be run on other systems which do not have the shared libraries installed.

Libtool, however, extracts a list of libraries from the ld(1) command run when linking a C++ shared library and records it, throwing away the -Bstatic and -Bdynamic options interspersed between the libraries. This means that libtool-linked C++ shared libraries will have a runtime dependency on the icc libraries until this is fixed in libtool.

3.3.8. MirBSD

pkgsrc has been tested on MirBSD #10-current (2011 and newer). Older versions might also work. Releases before #10 are not supported.

The package tools of the (older) native ports tree, MirPorts, have the same names as the ones used by pkgsrc. Care should be taken that the right tools are used. When installing packages from source, use the bmake command for pkgsrc and mmake for MirPorts.

pkgsrc and MirPorts use the same location for the package database, /var/db/pkg. It is strongly recommended to use /usr/pkg/db instead, so that the pkgsrc tree is self-contained. This is also the default setting used in the binary package builds.

Binary packages for MirBSD/i386 can be found on the pkgsrc ftp server. The bootstrap kit there already contains the pkgin package manager. See the pkgsrc on MirOS page for more details.

3.3.9. OpenBSD

OpenBSD 5.1 has been tested and supported, other versions may work.

Care should be taken so that the tools that this kit installs do not conflict with the OpenBSD userland tools. There are several steps:

  1. OpenBSD stores its ports pkg database in /var/db/pkg. It is therefore recommended that you choose a different location (e.g. /usr/pkgdb) by using the --pkgdbdir option to the bootstrap script.

  2. If you do not intend to use the OpenBSD ports tools, it's probably a good idea to move them out of the way to avoid confusion, e.g.

    # cd /usr/sbin
    # mv pkg_add pkg_add.orig
    # mv pkg_create pkg_create.orig
    # mv pkg_delete pkg_delete.orig
    # mv pkg_info pkg_info.orig
    	  
  3. An example mk.conf file will be placed in /etc/mk.conf.example file when you use the bootstrap script. OpenBSD's make program uses mk.conf as well. You can work around this by enclosing all the pkgsrc-specific parts of the file with:

    .ifdef BSD_PKG_MK
    # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
    .else
    # OpenBSD stuff
    .endif
    	  

3.3.10. Solaris

Solaris 2.6 through 10 are supported on both x86 and sparc. You will need a working C compiler. Both gcc 4.5.3 and Sun WorkShop 5 have been tested.

The following packages are required on Solaris 8 for the bootstrap process and to build packages.

  • SUNWsprot

  • SUNWarc

  • SUNWbtool

  • SUNWtoo

  • SUNWlibm

Please note that the use of GNU binutils on Solaris is not supported, as of June 2006.

Whichever compiler you use, please ensure the compiler tools and your $prefix are in your PATH. This includes /usr/ccs/{bin,lib} and e.g. /usr/pkg/{bin,sbin}.

3.3.10.1. If you are using gcc

It makes life much simpler if you only use the same gcc consistently for building all packages.

It is recommended that an external gcc be used only for bootstrapping, then either build gcc from lang/gcc46 or install a binary gcc package, then remove gcc used during bootstrapping.

Binary packages of gcc can be found through http://www.sunfreeware.com/.

3.3.10.2. If you are using Sun WorkShop

You will need at least the following packages installed (from WorkShop 5.0)

  • SPROcc - Sun WorkShop Compiler C 5.0

  • SPROcpl - Sun WorkShop Compiler C++ 5.0

  • SPROild - Sun WorkShop Incremental Linker

  • SPROlang - Sun WorkShop Compilers common components

You should set the following variables in your mk.conf file:

CC=     cc
CXX=    CC
CPP=    cc -E
CXXCPP= CC -E

Note

The CPP setting might break some packages that use the C preprocessor for processing things other than C source code.

3.3.10.3. Building 64-bit binaries with SunPro

To build 64-bit packages, you just need to have the following lines in your mk.conf file:

PKGSRC_COMPILER=        sunpro
ABI=                    64

Note

This setting has been tested for the SPARC architecture. Intel and AMD machines need some more work.

3.3.10.4. Common problems

Sometimes, when using libtool, /bin/ksh crashes with a segmentation fault. The workaround is to use another shell for the configure scripts, for example by installing shells/bash and adding the following lines to your mk.conf:

CONFIG_SHELL=   ${LOCALBASE}/bin/bash
WRAPPER_SHELL=  ${LOCALBASE}/bin/bash
      

Then, rebuild the devel/libtool-base package.