Annotation of wikisrc/pkgsrc/how_to_use_pkgsrc_on_linux.mdwn, revision 1.3

1.2       schmonz     1: **This page should use cross references to avoid duplicate content. Please help us by cleaning it up. ?**
                      2: 
                      3: **Contents**
                      4: 
                      5: [[!toc levels=2]]
                      6: 
                      7: #What is pkgsrc
                      8: 
1.3     ! schmonz     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.
1.2       schmonz    10: #Software requirements
                     11: 
                     12: Before you can use pkgsrc, you need a few packages installed on your Linux system upfront.
                     13: 
                     14: * gcc (and libstdc++)
                     15: * libncurses-devel
                     16: * zlib and zlib-devel
                     17: * openssl-devel (optional but required for some packages) 
                     18: 
                     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
                     21: 
                     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
                     24: 
                     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
                     27: 
                     28: Please set your CVSROOT Environment Variable
                     29: 
                     30:     export CVSROOT=anoncvs@anoncvs.de.netbsd.org:/cvsroot
                     31: 
                     32: or if you are using the csh:
                     33: 
                     34:     setenv CVSROOT anoncvs@anoncvs.de.netbsd.org:/cvsroot
                     35: 
                     36: #Setting CVS_RSH
                     37: 
                     38: Unless otherwise noted, you have to set the CVS_RSH variable to use ssh
                     39: 
                     40:     export CVS_RSH=ssh
                     41: 
                     42: or if you are using csh
                     43: 
                     44:     setenv CVS_RSH ssh
                     45: 
                     46: #Creating the pkgsrc directory
                     47: 
                     48: This is a matter of taste, but the commonly used path for pkgsrc is /usr/pkgsrc/
                     49: 
                     50:     # mkdir /usr/pkgsrc
                     51: 
                     52: If you are checking out for the first time, change to /usr
                     53: 
                     54:     # cd /usr
                     55: 
                     56: and check out the sources.
                     57: 
                     58:     # cvs checkout -PA pkgsrc
                     59: 
                     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.
                     61: 
                     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.
                     63: 
                     64:     # cd /usr/pkgsrc
                     65:     # cvs update -dP
                     66: 
                     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
                     69: 
                     70: The toolchain contains the software that is needed to build bsd make (bmake) and other tools.
                     71: 
                     72: Please change your directory to /usr/pkgsrc/bootstrap and run ./bootstrap
                     73: 
                     74:     # cd /usr/pkgsrc/bootstrap
                     75:     # ./bootstrap
                     76: 
                     77: Pkgsrc will now determine what kind of operating system you are using and will build the toolchain.
                     78: <pre><code>
                     79: ===========================================================================
                     80: 
                     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.
                     83: 
                     84: An example mk.conf file with the settings you provided to "bootstrap"
                     85: has been created for you. It can be found in:
                     86: 
                     87:       /usr/pkgsrc/bootstrap/work/mk.conf.example
                     88: 
                     89: Please copy it to /usr/pkg/etc/mk.conf to use it.
                     90: 
                     91: You can find extensive documentation of the NetBSD Packages Collection
                     92: in /usr/pkgsrc/doc/pkgsrc.txt and packages(7).
                     93: 
                     94: Hopefully everything is now complete.
                     95: Thank you
                     96: 
                     97: ===========================================================================
                     98: 
                     99: ===> bootstrap started: Sun Dec 17 14:01:49 CET 2006
                    100: ===> bootstrap ended:   Sun Dec 17 14:02:50 CET 2006
                    101: </code></pre>
                    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
                    104: 
                    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
                    106: 
                    107:     # cd /usr/pkgsrc/misc/figlet/
                    108: 
                    109: and build the software. Pkgsrc will download the sourcefile for figlet, uncompress it and build it.
                    110: 
                    111:     # bmake 
                    112: 
                    113: and clean the working directories afterwards
                    114: 
                    115:     # bmake clean
                    116: 
                    117: and clean all dependencies
                    118: 
                    119:     # bmake clean-depends
                    120: 
                    121: or short:
                    122: 
                    123:     # bmake install clean clean-depends
                    124: 
                    125: #Running the new software
                    126: 
                    127: When the software has been successfully installed, it will reside by default in */usr/pkg/bin/*. To run figlet just run:
                    128: 
                    129:     # figlet
                    130: 
                    131: You need the /usr/pkg/bin in your PATH Variable as described above to do that.
                    132: 
                    133: If you have already installed a linux version of figlet on your system, run pkgsrc figlet with the absolute path.
                    134: 
                    135:     # /usr/pkg/bin/figlet
                    136: 
                    137: That's it. Have fun. Please write comments and questions to the pkgsrc user mailing list: pkgsrc-users@netbsd.org
                    138: #See also
                    139: 
                    140: [README.Linux](ftp://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/bootstrap/README.Linux)
                    141: #Troubleshooting bootstrap
                    142: ##Shell's echo command is not BSD-compatible
                    143: 
                    144: If you see this error
                    145: 
                    146:     ERROR: Your shell's echo command is not BSD-compatible.
                    147: 
                    148: This error is known to occur if /bin/sh is linked to /bin/dash (recent Ubuntu versions).
                    149: 
                    150: The fix is to issue the following before commencing bootstrap: export SH=/bin/bash
                    151: ##ARG_MAX undeclared
                    152: 
                    153: If bootstrap stops at
                    154: 
                    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)
                    158: 
                    159: Then apply this patch [1](http://mail-index.netbsd.org/pkgsrc-bugs/2008/06/21/msg026977.html)
                    160: ##FORTIFY_SOURCE
                    161: 
                    162: If bootstrap stops at
                    163: 
                    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
                    168: 
                    169: This error occurs because Linux uses -DFORTIFY_SOURCES by default. Bootstrap can be achieved by:
                    170: 
                    171:     CFLAGS="-U_FORTIFY_SOURCE" ./bootstrap 
                    172: 
                    173: ##libncurses not installed
                    174: 
                    175: If bootstrap stops at
                    176: 
                    177:     ERROR: This package has set PKG_FAIL_REASON:
                    178:     ERROR: No usable termcap library found on the system.
                    179: 
                    180: Then install the libncurses-dev package
                    181: 
1.3     ! schmonz   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