Chapter 3. Using pkgsrc on systems other than NetBSD

Table of Contents

3.1. Bootstrapping pkgsrc
3.2. Platform specific notes
3.2.1. Darwin (Mac OS X)
3.2.2. FreeBSD
3.2.3. Interix
3.2.4. IRIX
3.2.5. OpenBSD
3.2.6. Solaris

3.1. Bootstrapping pkgsrc

For Operating Systems other than NetBSD, we provide a bootstrap kit to build the required tools to use pkgsrc on your platform. Besides support for native NetBSD, pkgsrc and the bootstrap kit have support for the following operating systems:

  • Darwin (Mac OS X)

  • FreeBSD

  • Interix (Windows 2000, XP, 2003)

  • IRIX

  • Linux

  • OpenBSD

  • Solaris

Support for other platforms is under development.

Installing the bootstrap kit should be as simple as:

# env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc
# cd pkgsrc/bootstrap
# ./bootstrap

See Chapter 2, Where to get pkgsrc for other ways to get pkgsrc before bootstrapping. The given bootstrap command will use the defaults of /usr/pkg for the prefix where programs will be installed in, and /var/db/pkg for the package database directory where pkgsrc will do it's internal bookkeeping. However, these can also be set using command-line parameters.

Binary packages for the pkgsrc tools and an initial set of packages is available for supported platforms. An up-to-date list of these can be found on www.pkgsrc.org.

3.2. Platform specific notes

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

3.2.1. Darwin (Mac OS X)

Darwin 5.x and 6.x are supported. There are two methods of using pkgsrc on Mac OS X, by using a disk image, or a UFS partition.

Before you start, you will need to download and install the Mac OS X Developer Tools from Apple's Developer Connection. See http://developer.apple.com/macosx/ for details. Also, make sure you install X11 for Mac OS X and the X11 SDK from http://www.apple.com/macosx/x11/download/ if you intend to build packages that use the X11 Window System.

If you already have a UFS partition, or have a spare partition that you can format as UFS, it is recommended to use that instead of the disk image. It'll be somewhat faster and will mount automatically at boot time, where you must manually mount a disk image.

Note

You cannot use a HFS+ file system for pkgsrc, because pkgsrc currently requires the filesystem to be case-sensitive, and HFS+ is not.

3.2.1.1. Using a disk image

Create the disk image:

# cd pkgsrc/bootstrap
# ./ufsdiskimage create ~/Documents/NetBSD 512 # megabytes - season to taste
# ./ufsdiskimage mount ~/Documents/NetBSD
# sudo chown `id -u`:`id -g` /Volumes/NetBSD

That's it!

3.2.1.2. Using a UFS partition

By default, /usr will be on your root file system, normally HFS+. It is possible to use the default prefix of /usr/pkg by symlinking /usr/pkg to a directory on a UFS file system. Obviously, another symlink is required if you want to place the package database directory outside the prefix. e.g.

# ./bootstrap --pkgdbdir=/usr/pkg/pkgdb --pkgsrcdir=/Volumes/ufs/pkgsrc

If you created your partitions at the time of installing Mac OS X and formatted the target partition as UFS, it should automatically mount on /Volumes/<volume name> when the machine boots. If you are (re)formatting a partition as UFS, you need to ensure that the partition map correctly reflects “Apple_UFS” and not “Apple_HFS”.

The problem is that none of the disk tools will let you touch a disk that is booted from. You can unmount the partition, but even if you newfs it, the partition type will be incorrect and the automounter won't mount it. It can be mounted manually, but it won't appear in Finder.

You'll need to boot off of the OS X Installation (User) CD. When the Installation program starts, go up to the menu and select Disk Utility. Now, you will be able to select the partition you want to be UFS, and Format it Apple UFS. Quit the Disk Utility, quit the installer which will reboot your machine. The new UFS file system will appear in Finder.

Be aware that the permissions on the new file system will be writable by root only.

This note is as of 10.2 (Jaguar) and applies to earlier versions. Hopefully Apple will fix Disk Utility in 10.3 (Panther).

3.2.2. FreeBSD

FreeBSD 4.7 and 5.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 /etc/mk.conf file will be placed in /etc/mk.conf.example file when you use the bootstrap script.

3.2.3. 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, or 2003. SFU can be downloaded from http://www.microsoft.com/windows/sfu/.

Services for Unix 3.5, current as of this writing, 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.)

3.2.3.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.

Finally, 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.)

3.2.3.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 filesystem, 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.2.3.3. Important notes for using pkgsrc

The package imanager (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.

3.2.4. 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. That is, you can not 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 /etc/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 filesystem.

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 compilers man pages for details.

3.2.5. OpenBSD

OpenBSD 3.0 and 3.2 are tested and supported.

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 /etc/mk.conf file will be placed in /etc/mk.conf.example file when you use the bootstrap script. OpenBSD's make program uses /etc/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.2.6. Solaris

Solaris 2.6 through 9 are supported on both x86 and sparc. You will need a working C compiler. Both gcc 2.95.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 the use of GNU binutils on Solaris is not supported.

3.2.6.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/gcc or install a binary gcc package, then remove gcc used during bootstrapping.

Binary packages of gcc can be found through http://www.sun.com/bigadmin/common/freewareSearch.html.

3.2.6.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 CC, CXX and optionally, CPP in /etc/mk.conf, eg.

CC=        cc
CXX=    CC
CPP=    /usr/ccs/lib/cpp

You may also want to build 64-bit binaries, eg.

CFLAGS= -xtarget=ultra -xarch=v9

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