Using pkgsrc on Mac OS X
Frederic Cambus November 28, 2014 [Pkgsrc]Given NetBSD focus on portability, it's only logical that pkgsrc is also available on systems other than NetBSD, including Darwin (Mac OS X). Here are some notes showing to bootstrap pkgsrc in unprivileged mode, which means that everything can easily be installed in the user home directory.
Before starting, we need to install Xcode Command Line Tools to get a working compiler.
Fetching and extracting latest pkgsrc stable release
This will create a ~pkgsrc
directory:
cd
wget http://ftp.netbsd.org/pub/pkgsrc/stable/pkgsrc.txz
tar xfz pkgsrc.txz
Bootstrapping pkgsrc
Launching the bootstrap script and setting the ABI to 64-bit:
cd pkgsrc/bootstrap
./bootstrap --abi=64 --compiler=clang --unprivileged
This will create and start populating the ~pkg
directory where all built packages will be installed.
For a complete list of available options:
./bootstrap -h
===> bootstrap command: ./bootstrap -h
===> bootstrap started: Sat Sep 27 21:59:08 CEST 2014
Usage: ./bootstrap
[ --abi [32|64] ]
[ --binary-kit <tarball> ]
[ --binary-macpkg <pkg> ]
[ --compiler <compiler> ]
[ --full ]
[ --gzip-binary-kit <tarball> ]
[ --help ]
[ --mk-fragment <mk.conf> ]
[ --pkgdbdir <pkgdbdir> ]
[ --pkginfodir <pkginfodir> ]
[ --pkgmandir <pkgmandir> ]
[ --prefer-pkgsrc <list|yes|no> ]
[ --prefix <prefix> ]
[ --preserve-path ]
[ --quiet ]
[ --sysconfdir <sysconfdir> ]
[ --unprivileged | --ignore-user-check ]
[ --varbase <varbase> ]
[ --workdir <workdir> ]
Adding ~pkg
to the path:
export PATH=$PATH:~/pkg/bin:~/pkg/sbin
Fetching security vulnerabilities information:
pkg_admin fetch-pkg-vulnerabilities
Adding some acceptable licenses to our pkgsrc configuration:
echo "ACCEPTABLE_LICENSES+= vim-license" >> ~/pkg/etc/mk.conf
Building packages
Here is how to build a package and clean the working directory and all dependencies:
cd ~/pkgsrc/category/package
bmake install clean clean-depends
Keeping pkgsrc up-to-date
First, we need to build CVS:
cd ~/pkgsrc/devel/scmcvs
bmake install clean clean-depends
We can then update pkgsrc using the following command:
cd ~/pkgsrc && cvs update -dP
Checking for security vulnerabilities in packages:
pkg_admin audit
Installing CA certificates
cd ~/pkgsrc/security/mozilla-rootcerts
bmake install clean clean-depends
mozilla-rootcerts install
For more details, please read the following post: Installing CA certificates on NetBSD.
Using binary packages
For those who prefer using binary packages, please check the Joyent packages repository.
Final words
After running Fink in 2009 on my Mac mini, and then Homebrew since late 2011 on my MacBook Pro, it's nice to explore alternatives especially since they are not mutually exclusive. It's in fact a nice idea to combine pkgsrc and Homebrew to get the best of both worlds and access to even more packages.
Lastly, for a comprehensive searchable database of packages, please check the excellent pkgsrc.se.