Diff for /wikisrc/pkgsrc/how_to_use_pkgsrc_on_linux.mdwn between versions 1.1 and 1.4

version 1.1, 2011/11/20 20:28:27 version 1.4, 2013/02/08 05:14:52
Line 1 Line 1
 **This page should use cross references to avoid duplicate content. Please help us by cleaning it up. ?**  
   
 **Contents**  
   
 [[!toc levels=2]]  
   
 #What is pkgsrc  
   
 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.  
 #Software requirements  
   
 Before you can use pkgsrc, you need a few packages installed on your Linux system upfront.  
   
 * gcc (and libstdc++)  
 * libncurses-devel  
 * zlib and zlib-devel  
 * openssl-devel (optional but required for some packages)  
   
 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.  
 #Disk space requirements  
   
 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.  
 #Obtaining the pkgsrc tree  
   
 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  
 #Setting CVSROOT  
   
 Please set your CVSROOT Environment Variable  
   
     export CVSROOT=anoncvs@anoncvs.de.netbsd.org:/cvsroot  
   
 or if you are using the csh:  
   
     setenv CVSROOT anoncvs@anoncvs.de.netbsd.org:/cvsroot  
   
 #Setting CVS_RSH  
   
 Unless otherwise noted, you have to set the CVS_RSH variable to use ssh  
   
     export CVS_RSH=ssh  
   
 or if you are using csh  
   
     setenv CVS_RSH ssh  
   
 #Creating the pkgsrc directory  
   
 This is a matter of taste, but the commonly used path for pkgsrc is /usr/pkgsrc/  
   
     # mkdir /usr/pkgsrc  
   
 If you are checking out for the first time, change to /usr  
   
     # cd /usr  
   
 and check out the sources.  
   
     # cvs checkout -PA pkgsrc  
   
 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.  
   
 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.  
   
     # cd /usr/pkgsrc  
     # cvs update -dP  
   
 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.  
 #Building the toolchain  
   
 The toolchain contains the software that is needed to build bsd make (bmake) and other tools.  
   
 Please change your directory to /usr/pkgsrc/bootstrap and run ./bootstrap  
   
     # cd /usr/pkgsrc/bootstrap  
     # ./bootstrap  
   
 Pkgsrc will now determine what kind of operating system you are using and will build the toolchain.  
 <pre><code>  
 ===========================================================================  
   
 Please remember to add /usr/pkg/bin to your PATH environment variable  
 and /usr/pkg/man to your MANPATH environment variable, if necessary.  
   
 An example mk.conf file with the settings you provided to "bootstrap"  
 has been created for you. It can be found in:  
   
       /usr/pkgsrc/bootstrap/work/mk.conf.example  
   
 Please copy it to /usr/pkg/etc/mk.conf to use it.  
   
 You can find extensive documentation of the NetBSD Packages Collection  
 in /usr/pkgsrc/doc/pkgsrc.txt and packages(7).  
   
 Hopefully everything is now complete.  
 Thank you  
   
 ===========================================================================  
   
 ===> bootstrap started: Sun Dec 17 14:01:49 CET 2006  
 ===> bootstrap ended:   Sun Dec 17 14:02:50 CET 2006  
 </code></pre>  
 It is now necessary to add /usr/pkg/bin to your PATH environment variable (/etc/profile) to be able to run bmake.  
 #Installing software  
   
 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  
   
     # cd /usr/pkgsrc/misc/figlet/  
   
 and build the software. Pkgsrc will download the sourcefile for figlet, uncompress it and build it.  
   
     # bmake  
   
 and clean the working directories afterwards  
   
     # bmake clean  
   
 and clean all dependencies  
   
     # bmake clean-depends  
   
 or short:  
   
     # bmake install clean clean-depends  
   
 #Running the new software  
   
 When the software has been successfully installed, it will reside by default in */usr/pkg/bin/*. To run figlet just run:  
   
     # figlet  
   
 You need the /usr/pkg/bin in your PATH Variable as described above to do that.  
   
 If you have already installed a linux version of figlet on your system, run pkgsrc figlet with the absolute path.  
   
     # /usr/pkg/bin/figlet  
   
 That's it. Have fun. Please write comments and questions to the pkgsrc user mailing list: pkgsrc-users@netbsd.org  
 #See also  
   
 [README.Linux](ftp://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/bootstrap/README.Linux)  
 #Troubleshooting bootstrap  
 ##Shell's echo command is not BSD-compatible  
   
 If you see this error  
   
     ERROR: Your shell's echo command is not BSD-compatible.  
   
 This error is known to occur if /bin/sh is linked to /bin/dash (recent Ubuntu versions).  
   
 The fix is to issue the following before commencing bootstrap: export SH=/bin/bash  
 ##ARG_MAX undeclared  
   
 If bootstrap stops at  
   
     In file included from glob.c:12:                                                  
     __glob13.c: In function globextend:                                              
     __glob13.c:836: error: ARG_MAX undeclared (first use in this function)  
   
 Then apply this patch [1](http://mail-index.netbsd.org/pkgsrc-bugs/2008/06/21/msg026977.html)  
 ##FORTIFY_SOURCE  
   
 If bootstrap stops at  
   
     /usr/pkgsrc/bootstrap/work/bmake/arch.c: In function 'Arch_Touch':  
     /usr/pkgsrc/bootstrap/work/bmake/arch.c:1038: warning: ignoring return  
     value of 'fwrite', declared with attribute warn_unused_result  
     *** Error code 1  
   
 This error occurs because Linux uses -DFORTIFY_SOURCES by default. Bootstrap can be achieved by:  
   
     CFLAGS="-U_FORTIFY_SOURCE" ./bootstrap  
   
 ##libncurses not installed  
   
 If bootstrap stops at  
   
     ERROR: This package has set PKG_FAIL_REASON:  
     ERROR: No usable termcap library found on the system.  
   
 Then install the libncurses-dev package  
   
 On an RPM based system this might be via 'yum install ncurses-devel', and on a debia/ubuntu system 'apt-get install ncurses5-dev'   
   
   **This page should use cross references to avoid duplicate content. Please help us by cleaning it up. ?**
   
   **Contents**
   
   [[!toc levels=2]]
   
   #See
   
   [README.Linux](ftp://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/bootstrap/README.Linux)
   #Software requirements
   
   Before you can use pkgsrc, you need a few packages installed on your Linux system upfront.
   
   * gcc (and libstdc++)
   * libncurses-devel
   * zlib and zlib-devel
   * openssl-devel (optional but required for some packages) 
   
   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.
   
   #Troubleshooting bootstrap
   ##Shell's echo command is not BSD-compatible
   
   If you see this error
   
       ERROR: Your shell's echo command is not BSD-compatible.
   
   This error is known to occur if /bin/sh is linked to /bin/dash (recent Ubuntu versions).
   
   The fix is to issue the following before commencing bootstrap: export SH=/bin/bash
   ##ARG_MAX undeclared
   
   If bootstrap stops at
   
       In file included from glob.c:12:                                                
       __glob13.c: In function globextend:                                             
       __glob13.c:836: error: ARG_MAX undeclared (first use in this function)
   
   Then apply this patch [1](http://mail-index.netbsd.org/pkgsrc-bugs/2008/06/21/msg026977.html)
   ##FORTIFY_SOURCE
   
   If bootstrap stops at
   
       /usr/pkgsrc/bootstrap/work/bmake/arch.c: In function 'Arch_Touch':
       /usr/pkgsrc/bootstrap/work/bmake/arch.c:1038: warning: ignoring return
       value of 'fwrite', declared with attribute warn_unused_result
       *** Error code 1
   
   This error occurs because Linux uses -DFORTIFY_SOURCES by default. Bootstrap can be achieved by:
   
       CFLAGS="-U_FORTIFY_SOURCE" ./bootstrap 
   
   ##libncurses not installed
   
   If bootstrap stops at
   
       ERROR: This package has set PKG_FAIL_REASON:
       ERROR: No usable termcap library found on the system.
   
   Then install the libncurses-dev package
   
   On an RPM based system this might be via 'yum install ncurses-devel', and on a debia/ubuntu system 'apt-get install ncurses5-dev' 

Removed from v.1.1  
changed lines
  Added in v.1.4


CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb