1: **This page should use cross references to avoid duplicate content. Please help us by cleaning it up. ?**
5: [[!toc levels=2]]
7: #What is pkgsrc
9: pkgsrc is the NetBSD build framework for third party software that works on a lot of Unix™ like platforms and of course on Linux. In this chapter, I will explain how to set up and use pkgsrc on Linux.
10: #Software requirements
12: Before you can use pkgsrc, you need a few packages installed on your Linux system upfront.
14: * gcc (and libstdc++)
15: * libncurses-devel
16: * zlib and zlib-devel
17: * openssl-devel (optional but required for some packages)
19: The names may vary, depending on what Linux distribution you are using. Also be mindful of the platform you are using (eg. i686 vs. x86_64 - some have different pre-required packages). Also note that some very basic tools such as file, patch, sed, and others are required, as well.
20: #Disk space requirements
22: Pkgsrc is growing continuesly each month and contains currently about 6387 packages. You will need a minimum of 170 MB disk space at the moment. The pkgsrc tree doesn't contain all the software, but the scripts to build them from the source code.
23: #Obtaining the pkgsrc tree
25: For being able to use the pkgsrc framework, you have to get the pkgsrc tree first. The recommended way to do that and to keep your tree up to date is to use CVS. Alternatively you can use [cvsup|How_to_checkout_and_update_system_sources_and_pkgsrc_with_cvsup] or mercurial. But before you can check out the tree, you have to define where from. For that, please choose an anoncvs [mirror](http://www.de.netbsd.org/mirrors/#anoncvs) close to you. In this example I will use the german anoncvs mirror anoncvs.de.netbsd.org
26: #Setting CVSROOT
28: Please set your CVSROOT Environment Variable
30: export CVSROOTfirstname.lastname@example.org:/cvsroot
32: or if you are using the csh:
34: setenv CVSROOT email@example.com:/cvsroot
36: #Setting CVS_RSH
38: Unless otherwise noted, you have to set the CVS_RSH variable to use ssh
40: export CVS_RSH=ssh
42: or if you are using csh
44: setenv CVS_RSH ssh
46: #Creating the pkgsrc directory
48: This is a matter of taste, but the commonly used path for pkgsrc is /usr/pkgsrc/
50: # mkdir /usr/pkgsrc
52: If you are checking out for the first time, change to /usr
54: # cd /usr
56: and check out the sources.
58: # cvs checkout -PA pkgsrc
60: Checking out will take a while and a minimum of 170 MB of disk space. Please ensure enough free disk space, if you wish to work with pkgsrc. A minimum of 1024 MB should be available.
62: You need to **checkout** only once. If you have already checked out, you only need to **update** the sources. The Options -d allows to create new directories and -P to prune old directories.
64: # cd /usr/pkgsrc
65: # cvs update -dP
67: Please be aware, that updating your sources will take much more time than checking out. Please be patient when you're updating. If you wish to update regularly, say once a day, use [[basics/cron]] to do that for you.
68: #Building the toolchain
70: The toolchain contains the software that is needed to build bsd make (bmake) and other tools.
72: Please change your directory to /usr/pkgsrc/bootstrap and run ./bootstrap
74: # cd /usr/pkgsrc/bootstrap
75: # ./bootstrap
77: Pkgsrc will now determine what kind of operating system you are using and will build the toolchain.
81: Please remember to add /usr/pkg/bin to your PATH environment variable
82: and /usr/pkg/man to your MANPATH environment variable, if necessary.
84: An example mk.conf file with the settings you provided to "bootstrap"
85: has been created for you. It can be found in:
89: Please copy it to /usr/pkg/etc/mk.conf to use it.
91: You can find extensive documentation of the NetBSD Packages Collection
92: in /usr/pkgsrc/doc/pkgsrc.txt and packages(7).
94: Hopefully everything is now complete.
95: Thank you
99: ===> bootstrap started: Sun Dec 17 14:01:49 CET 2006
100: ===> bootstrap ended: Sun Dec 17 14:02:50 CET 2006
102: It is now necessary to add /usr/pkg/bin to your PATH environment variable (/etc/profile) to be able to run bmake.
103: #Installing software
105: Now, let's test pkgsrc, by installing a software package. The software is sorted by categories. I've chosen *figlet*, a small program to print big letters. Figlet is in the category misc. Change to the figlet directory
107: # cd /usr/pkgsrc/misc/figlet/
109: and build the software. Pkgsrc will download the sourcefile for figlet, uncompress it and build it.
111: # bmake
113: and clean the working directories afterwards
115: # bmake clean
117: and clean all dependencies
119: # bmake clean-depends
121: or short:
123: # bmake install clean clean-depends
125: #Running the new software
127: When the software has been successfully installed, it will reside by default in */usr/pkg/bin/*. To run figlet just run:
129: # figlet
131: You need the /usr/pkg/bin in your PATH Variable as described above to do that.
133: If you have already installed a linux version of figlet on your system, run pkgsrc figlet with the absolute path.
135: # /usr/pkg/bin/figlet
137: That's it. Have fun. Please write comments and questions to the pkgsrc user mailing list: firstname.lastname@example.org
138: #See also
141: #Troubleshooting bootstrap
142: ##Shell's echo command is not BSD-compatible
144: If you see this error
146: ERROR: Your shell's echo command is not BSD-compatible.
148: This error is known to occur if /bin/sh is linked to /bin/dash (recent Ubuntu versions).
150: The fix is to issue the following before commencing bootstrap: export SH=/bin/bash
151: ##ARG_MAX undeclared
153: If bootstrap stops at
155: In file included from glob.c:12:
156: __glob13.c: In function globextend:
157: __glob13.c:836: error: ARG_MAX undeclared (first use in this function)
159: Then apply this patch (http://mail-index.netbsd.org/pkgsrc-bugs/2008/06/21/msg026977.html)
162: If bootstrap stops at
164: /usr/pkgsrc/bootstrap/work/bmake/arch.c: In function 'Arch_Touch':
165: /usr/pkgsrc/bootstrap/work/bmake/arch.c:1038: warning: ignoring return
166: value of 'fwrite', declared with attribute warn_unused_result
167: *** Error code 1
169: This error occurs because Linux uses -DFORTIFY_SOURCES by default. Bootstrap can be achieved by:
171: CFLAGS="-U_FORTIFY_SOURCE" ./bootstrap
173: ##libncurses not installed
175: If bootstrap stops at
177: ERROR: This package has set PKG_FAIL_REASON:
178: ERROR: No usable termcap library found on the system.
180: Then install the libncurses-dev package
182: On an RPM based system this might be via 'yum install ncurses-devel', and on a debia/ubuntu system 'apt-get install ncurses5-dev'
CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb