Annotation of htdocs/docs/pkgsrc/pkgsrc.txt, revision 1.112
1.1 dsieger 1: The pkgsrc guide
2:
3: Documentation on the NetBSD packages system
4:
5: Alistair Crooks
6:
7: <agc@NetBSD.org>
8:
9: Hubert Feyrer
10:
11: <hubertf@NetBSD.org>
12:
13: The pkgsrc Developers
14:
1.107 jnemeth 15: Copyright 1994-2016 The NetBSD Foundation, Inc
1.1 dsieger 16:
1.108 rillig 17: $NetBSD: pkgsrc.xml,v 1.30 2016/06/11 18:14:42 rillig Exp $
1.1 dsieger 18:
19: Abstract
20:
21: pkgsrc is a centralized package management system for Unix-like operating
22: systems. This guide provides information for users and developers of pkgsrc. It
23: covers installation of binary and source packages, creation of binary and
24: source packages and a high-level overview about the infrastructure.
25:
26: -------------------------------------------------------------------------------
27:
28: Table of Contents
29:
30: 1. What is pkgsrc?
31:
32: 1.1. Introduction
33:
34: 1.1.1. Why pkgsrc?
35: 1.1.2. Supported platforms
36:
37: 1.2. Overview
38: 1.3. Terminology
39:
40: 1.3.1. Roles involved in pkgsrc
41:
42: 1.4. Typography
43:
44: I. The pkgsrc user's guide
45:
46: 2. Where to get pkgsrc and how to keep it up-to-date
47:
48: 2.1. Getting pkgsrc for the first time
49:
1.52 asau 50: 2.1.1. As tar archive
1.24 wiz 51: 2.1.2. Via anonymous CVS
1.1 dsieger 52:
53: 2.2. Keeping pkgsrc up-to-date
54:
55: 2.2.1. Via tar files
56: 2.2.2. Via CVS
57:
58: 3. Using pkgsrc on systems other than NetBSD
59:
60: 3.1. Binary distribution
61: 3.2. Bootstrapping pkgsrc
62: 3.3. Platform-specific notes
63:
64: 4. Using pkgsrc
65:
66: 4.1. Using binary packages
67:
68: 4.1.1. Finding binary packages
69: 4.1.2. Installing binary packages
70: 4.1.3. Deinstalling packages
71: 4.1.4. Getting information about installed packages
72: 4.1.5. Checking for security vulnerabilities in installed packages
73: 4.1.6. Finding if newer versions of your installed packages are in
74: pkgsrc
75: 4.1.7. Other administrative functions
76:
77: 4.2. Building packages from source
78:
79: 4.2.1. Requirements
80: 4.2.2. Fetching distfiles
81: 4.2.3. How to build and install
82:
83: 5. Configuring pkgsrc
84:
85: 5.1. General configuration
86: 5.2. Variables affecting the build process
1.9 rillig 87: 5.3. Variables affecting the installation process
1.4 rillig 88: 5.4. Selecting and configuring the compiler
1.1 dsieger 89:
1.4 rillig 90: 5.4.1. Selecting the compiler
91: 5.4.2. Additional flags to the compiler (CFLAGS)
92: 5.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 93:
1.4 rillig 94: 5.5. Developer/advanced settings
95: 5.6. Selecting Build Options
1.1 dsieger 96:
97: 6. Creating binary packages
98:
99: 6.1. Building a single binary package
100: 6.2. Settings for creation of binary packages
101:
1.6 rillig 102: 7. Creating binary packages for everything in pkgsrc (bulk builds)
103:
1.71 wiz 104: 7.1. Preparations
105: 7.2. Running a pbulk-style bulk build
1.6 rillig 106:
1.71 wiz 107: 7.2.1. Configuration
1.6 rillig 108:
1.71 wiz 109: 7.3. Requirements of a full bulk build
1.66 asau 110: 7.4. Creating a multiple CD-ROM packages collection
1.6 rillig 111:
1.66 asau 112: 7.4.1. Example of cdpack
1.6 rillig 113:
114: 8. Directory layout of the installed files
115:
116: 8.1. File system layout in ${LOCALBASE}
117: 8.2. File system layout in ${VARBASE}
118:
119: 9. Frequently Asked Questions
120:
121: 9.1. Are there any mailing lists for pkg-related discussion?
1.84 wiz 122: 9.2. Utilities for package management (pkgtools)
123: 9.3. How to use pkgsrc as non-root
124: 9.4. How to resume transfers when fetching distfiles?
125: 9.5. How can I install/use modular X.org from pkgsrc?
126: 9.6. How to fetch files from behind a firewall
127: 9.7. How to fetch files from HTTPS sites
128: 9.8. How do I tell make fetch to do passive FTP?
129: 9.9. How to fetch all distfiles at once
130: 9.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc"
1.24 wiz 131: mean?
1.84 wiz 132: 9.11. What does "Could not find bsd.own.mk" mean?
133: 9.12. Using 'sudo' with pkgsrc
134: 9.13. How do I change the location of configuration files?
135: 9.14. Automated security checks
136: 9.15. Why do some packages ignore my CFLAGS?
137: 9.16. A package does not build. What shall I do?
138: 9.17. What does "Makefile appears to contain unresolved cvs/rcs/???
1.24 wiz 139: merge conflicts" mean?
1.1 dsieger 140:
141: II. The pkgsrc developer's guide
142:
1.6 rillig 143: 10. Creating a new pkgsrc package from scratch
1.1 dsieger 144:
1.6 rillig 145: 10.1. Common types of packages
1.1 dsieger 146:
1.6 rillig 147: 10.1.1. Perl modules
1.66 asau 148: 10.1.2. KDE3 applications
1.17 imil 149: 10.1.3. Python modules and programs
1.1 dsieger 150:
1.6 rillig 151: 10.2. Examples
1.1 dsieger 152:
1.6 rillig 153: 10.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 154:
1.6 rillig 155: 11. Package components - files, directories and contents
1.1 dsieger 156:
1.6 rillig 157: 11.1. Makefile
158: 11.2. distinfo
159: 11.3. patches/*
1.1 dsieger 160:
1.6 rillig 161: 11.3.1. Structure of a single patch file
162: 11.3.2. Creating patch files
163: 11.3.3. Sources where the patch files come from
164: 11.3.4. Patching guidelines
165: 11.3.5. Feedback to the author
1.1 dsieger 166:
1.6 rillig 167: 11.4. Other mandatory files
168: 11.5. Optional files
1.1 dsieger 169:
1.6 rillig 170: 11.5.1. Files affecting the binary package
171: 11.5.2. Files affecting the build process
172: 11.5.3. Files affecting nothing at all
1.1 dsieger 173:
1.6 rillig 174: 11.6. work*
175: 11.7. files/*
1.1 dsieger 176:
1.6 rillig 177: 12. Programming in Makefiles
1.1 dsieger 178:
1.6 rillig 179: 12.1. Caveats
180: 12.2. Makefile variables
1.1 dsieger 181:
1.6 rillig 182: 12.2.1. Naming conventions
1.1 dsieger 183:
1.6 rillig 184: 12.3. Code snippets
1.1 dsieger 185:
1.6 rillig 186: 12.3.1. Adding things to a list
1.108 rillig 187: 12.3.2. Echoing a string exacty as-is
188: 12.3.3. Passing CFLAGS to GNU configure scripts
189: 12.3.4. Handling possibly empty variables
1.1 dsieger 190:
1.6 rillig 191: 13. PLIST issues
1.1 dsieger 192:
1.6 rillig 193: 13.1. RCS ID
194: 13.2. Semi-automatic PLIST generation
195: 13.3. Tweaking output of make print-PLIST
196: 13.4. Variable substitution in PLIST
197: 13.5. Man page compression
198: 13.6. Changing PLIST source with PLIST_SRC
199: 13.7. Platform-specific and differing PLISTs
1.86 wiz 200: 13.8. Build-specific PLISTs
201: 13.9. Sharing directories between packages
1.1 dsieger 202:
1.6 rillig 203: 14. Buildlink methodology
1.1 dsieger 204:
1.6 rillig 205: 14.1. Converting packages to use buildlink3
206: 14.2. Writing buildlink3.mk files
1.1 dsieger 207:
1.6 rillig 208: 14.2.1. Anatomy of a buildlink3.mk file
1.27 wiz 209: 14.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
210: BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.1 dsieger 211:
1.6 rillig 212: 14.3. Writing builtin.mk files
1.1 dsieger 213:
1.6 rillig 214: 14.3.1. Anatomy of a builtin.mk file
215: 14.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 216:
1.6 rillig 217: 15. The pkginstall framework
1.1 dsieger 218:
1.6 rillig 219: 15.1. Files and directories outside the installation prefix
1.1 dsieger 220:
1.6 rillig 221: 15.1.1. Directory manipulation
222: 15.1.2. File manipulation
1.1 dsieger 223:
1.6 rillig 224: 15.2. Configuration files
1.1 dsieger 225:
1.6 rillig 226: 15.2.1. How PKG_SYSCONFDIR is set
227: 15.2.2. Telling the software where configuration files are
228: 15.2.3. Patching installations
229: 15.2.4. Disabling handling of configuration files
1.1 dsieger 230:
1.6 rillig 231: 15.3. System startup scripts
1.1 dsieger 232:
1.6 rillig 233: 15.3.1. Disabling handling of system startup scripts
1.1 dsieger 234:
1.6 rillig 235: 15.4. System users and groups
236: 15.5. System shells
1.1 dsieger 237:
1.6 rillig 238: 15.5.1. Disabling shell registration
1.1 dsieger 239:
1.6 rillig 240: 15.6. Fonts
1.1 dsieger 241:
1.6 rillig 242: 15.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 243:
1.6 rillig 244: 16. Options handling
1.1 dsieger 245:
1.6 rillig 246: 16.1. Global default options
247: 16.2. Converting packages to use bsd.options.mk
248: 16.3. Option Names
1.7 rillig 249: 16.4. Determining the options of dependencies
1.1 dsieger 250:
1.6 rillig 251: 17. The build process
1.1 dsieger 252:
1.6 rillig 253: 17.1. Introduction
254: 17.2. Program location
255: 17.3. Directories used during the build process
256: 17.4. Running a phase
257: 17.5. The fetch phase
1.1 dsieger 258:
1.6 rillig 259: 17.5.1. What to fetch and where to get it from
260: 17.5.2. How are the files fetched?
1.1 dsieger 261:
1.6 rillig 262: 17.6. The checksum phase
263: 17.7. The extract phase
264: 17.8. The patch phase
265: 17.9. The tools phase
266: 17.10. The wrapper phase
267: 17.11. The configure phase
268: 17.12. The build phase
269: 17.13. The test phase
270: 17.14. The install phase
271: 17.15. The package phase
272: 17.16. Cleaning up
273: 17.17. Other helpful targets
1.1 dsieger 274:
1.6 rillig 275: 18. Tools needed for building or running
1.1 dsieger 276:
1.6 rillig 277: 18.1. Tools for pkgsrc builds
278: 18.2. Tools needed by packages
279: 18.3. Tools provided by platforms
1.1 dsieger 280:
1.6 rillig 281: 19. Making your package work
1.1 dsieger 282:
1.6 rillig 283: 19.1. General operation
1.1 dsieger 284:
1.108 rillig 285: 19.1.1. How to pull in user-settable variables from mk.conf
286: 19.1.2. User interaction
287: 19.1.3. Handling licenses
288: 19.1.4. Restricted packages
289: 19.1.5. Handling dependencies
290: 19.1.6. Handling conflicts with other packages
291: 19.1.7. Packages that cannot or should not be built
292: 19.1.8. Packages which should not be deleted, once installed
293: 19.1.9. Handling packages with security problems
294: 19.1.10. How to handle incrementing versions when fixing an
1.1 dsieger 295: existing package
1.108 rillig 296: 19.1.11. Substituting variable text in the package files (the SUBST
1.1 dsieger 297: framework)
298:
1.108 rillig 299: 19.2. The fetch phase
1.1 dsieger 300:
1.6 rillig 301: 19.2.1. Packages whose distfiles aren't available for plain
1.1 dsieger 302: downloading
1.6 rillig 303: 19.2.2. How to handle modified distfiles with the 'old' name
1.88 tnn 304: 19.2.3. Packages hosted on github.com
1.1 dsieger 305:
1.108 rillig 306: 19.3. The configure phase
1.1 dsieger 307:
1.6 rillig 308: 19.3.1. Shared libraries - libtool
309: 19.3.2. Using libtool on GNU packages that already support libtool
310: 19.3.3. GNU Autoconf/Automake
311:
312: 19.4. Programming languages
313:
314: 19.4.1. C, C++, and Fortran
315: 19.4.2. Java
316: 19.4.3. Packages containing perl scripts
1.41 wiz 317: 19.4.4. Packages containing shell scripts
318: 19.4.5. Other programming languages
1.6 rillig 319:
1.108 rillig 320: 19.5. The build phase
1.6 rillig 321:
322: 19.5.1. Compiling C and C++ code conditionally
323: 19.5.2. How to handle compiler bugs
1.24 wiz 324: 19.5.3. Undefined reference to "..."
1.6 rillig 325: 19.5.4. Running out of memory
326:
1.108 rillig 327: 19.6. The install phase
1.6 rillig 328:
329: 19.6.1. Creating needed directories
330: 19.6.2. Where to install documentation
331: 19.6.3. Installing highscore files
332: 19.6.4. Adding DESTDIR support to packages
333: 19.6.5. Packages with hardcoded paths to other interpreters
334: 19.6.6. Packages installing perl modules
335: 19.6.7. Packages installing info files
336: 19.6.8. Packages installing man pages
1.7 rillig 337: 19.6.9. Packages installing GConf data files
1.18 mishka 338: 19.6.10. Packages installing scrollkeeper/rarian data files
1.6 rillig 339: 19.6.11. Packages installing X11 fonts
340: 19.6.12. Packages installing GTK2 modules
341: 19.6.13. Packages installing SGML or XML data
342: 19.6.14. Packages installing extensions to the MIME database
343: 19.6.15. Packages using intltool
344: 19.6.16. Packages installing startup scripts
345: 19.6.17. Packages installing TeX modules
346: 19.6.18. Packages supporting running binaries in emulation
347: 19.6.19. Packages installing hicolor theme icons
348: 19.6.20. Packages installing desktop files
349:
350: 19.7. Marking packages as having problems
351:
352: 20. Debugging
353: 21. Submitting and Committing
354:
355: 21.1. Submitting binary packages
356: 21.2. Submitting source packages (for non-NetBSD-developers)
357: 21.3. General notes when adding, updating, or removing packages
1.34 wiz 358: 21.4. Committing: Adding a package to CVS
1.6 rillig 359: 21.5. Updating a package to a newer version
1.21 snj 360: 21.6. Renaming a package in pkgsrc
361: 21.7. Moving a package in pkgsrc
1.6 rillig 362:
363: 22. Frequently Asked Questions
364: 23. GNOME packaging and porting
365:
366: 23.1. Meta packages
367: 23.2. Packaging a GNOME application
368: 23.3. Updating GNOME to a newer version
369: 23.4. Patching guidelines
1.1 dsieger 370:
371: III. The pkgsrc infrastructure internals
372:
1.6 rillig 373: 24. Design of the pkgsrc infrastructure
1.1 dsieger 374:
1.6 rillig 375: 24.1. The meaning of variable definitions
376: 24.2. Avoiding problems before they arise
377: 24.3. Variable evaluation
1.1 dsieger 378:
1.6 rillig 379: 24.3.1. At load time
380: 24.3.2. At runtime
1.1 dsieger 381:
1.6 rillig 382: 24.4. How can variables be specified?
383: 24.5. Designing interfaces for Makefile fragments
1.1 dsieger 384:
1.6 rillig 385: 24.5.1. Procedures with parameters
386: 24.5.2. Actions taken on behalf of parameters
1.1 dsieger 387:
1.6 rillig 388: 24.6. The order in which files are loaded
1.1 dsieger 389:
1.6 rillig 390: 24.6.1. The order in bsd.prefs.mk
391: 24.6.2. The order in bsd.pkg.mk
1.1 dsieger 392:
1.6 rillig 393: 25. Regression tests
1.1 dsieger 394:
1.108 rillig 395: 25.1. Running the regression tests
396: 25.2. Adding a new regression test
1.1 dsieger 397:
1.108 rillig 398: 25.2.1. Overridable functions
399: 25.2.2. Helper functions
1.1 dsieger 400:
1.6 rillig 401: 26. Porting pkgsrc
1.1 dsieger 402:
1.6 rillig 403: 26.1. Porting pkgsrc to a new operating system
1.1 dsieger 404:
405: A. A simple example package: bison
406:
407: A.1. files
408:
409: A.1.1. Makefile
410: A.1.2. DESCR
411: A.1.3. PLIST
412: A.1.4. Checking a package with pkglint
413:
414: A.2. Steps for building, installing, packaging
415:
416: B. Build logs
417:
418: B.1. Building figlet
419: B.2. Packaging figlet
420:
421: C. Directory layout of the pkgsrc FTP server
422:
1.23 jakllsch 423: C.1. distfiles: The distributed source files
424: C.2. misc: Miscellaneous things
425: C.3. packages: Binary packages
426: C.4. reports: Bulk build reports
427: C.5. current, pkgsrc-20xxQy: source packages
1.1 dsieger 428:
429: D. Editing guidelines for the pkgsrc guide
430:
431: D.1. Make targets
432: D.2. Procedure
433:
434: List of Tables
435:
436: 1.1. Platforms supported by pkgsrc
1.6 rillig 437: 11.1. Patching examples
438: 23.1. PLIST handling for GNOME packages
1.1 dsieger 439:
440: Chapter 1. What is pkgsrc?
441:
442: Table of Contents
443:
444: 1.1. Introduction
445:
446: 1.1.1. Why pkgsrc?
447: 1.1.2. Supported platforms
448:
449: 1.2. Overview
450: 1.3. Terminology
451:
452: 1.3.1. Roles involved in pkgsrc
453:
454: 1.4. Typography
455:
456: 1.1. Introduction
457:
458: There is a lot of software freely available for Unix-based systems, which is
459: usually available in form of the source code. Before such software can be used,
460: it needs to be configured to the local system, compiled and installed, and this
461: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
462: some basic commands to handle binary packages, so that not every user has to
463: build the packages for himself, which is a time-costly task.
464:
465: pkgsrc currently contains several thousand packages, including:
466:
1.104 sevan 467: * www/apache24 - The Apache web server
1.1 dsieger 468:
469: * www/firefox - The Firefox web browser
470:
471: * meta-pkgs/gnome - The GNOME Desktop Environment
472:
1.102 ryoon 473: * meta-pkgs/kde4 - The K Desktop Environment
1.1 dsieger 474:
1.108 rillig 475: ? just to name a few.
1.1 dsieger 476:
477: pkgsrc has built-in support for handling varying dependencies, such as pthreads
478: and X11, and extended features such as IPv6 support on a range of platforms.
479:
480: 1.1.1. Why pkgsrc?
481:
482: pkgsrc provides the following key features:
483:
484: * Easy building of software from source as well as the creation and
485: installation of binary packages. The source and latest patches are
486: retrieved from a master or mirror download site, checksum verified, then
487: built on your system. Support for binary-only distributions is available
488: for both native platforms and NetBSD emulated platforms.
489:
490: * All packages are installed in a consistent directory tree, including
491: binaries, libraries, man pages and other documentation.
492:
1.104 sevan 493: * Tracking of package dependencies automatically, including when performing
494: updates, to ensure required packages are installed. The configuration files
495: of various packages are handled automatically during updates, so local
496: changes are preserved.
1.1 dsieger 497:
498: * Like NetBSD, pkgsrc is designed with portability in mind and consists of
499: highly portable code. This allows the greatest speed of development when
1.26 spz 500: porting to a new platform. This portability also ensures that pkgsrc is
1.1 dsieger 501: consistent across all platforms.
502:
503: * The installation prefix, acceptable software licenses, international
504: encryption requirements and build-time options for a large number of
505: packages are all set in a simple, central configuration file.
506:
507: * The entire source (not including the distribution files) is freely
508: available under a BSD license, so you may extend and adapt pkgsrc to your
509: needs. Support for local packages and patches is available right out of the
510: box, so you can configure it specifically for your environment.
511:
512: The following principles are basic to pkgsrc:
513:
514: * "It should only work if it's right." ? That means, if a package contains
515: bugs, it's better to find them and to complain about them rather than to
516: just install the package and hope that it works. There are numerous checks
517: in pkgsrc that try to find such bugs: Static analysis tools (pkgtools/
518: pkglint), build-time checks (portability of shell scripts), and
519: post-installation checks (installed files, references to shared libraries,
520: script interpreters).
521:
522: * "If it works, it should work everywhere" ? Like NetBSD has been ported to
523: many hardware architectures, pkgsrc has been ported to many operating
524: systems. Care is taken that packages behave the same on all platforms.
525:
526: 1.1.2. Supported platforms
527:
528: pkgsrc consists of both a source distribution and a binary distribution for
529: these operating systems. After retrieving the required source or binaries, you
530: can be up and running with pkgsrc in just minutes!
531:
532: pkgsrc was derived from FreeBSD's ports system, and initially developed for
533: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
534: platforms:
535:
536: Table 1.1. Platforms supported by pkgsrc
537:
1.92 sevan 538: +-----------------------------------------------------------------------------+
539: | Platform | Date Support | Notes |
540: | | Added | |
541: |--------------------------------------+---------------+----------------------|
542: |NetBSD | Aug 1997 | |
543: |--------------------------------------+---------------+----------------------|
544: |Solaris | Mar 1999 |README.Solaris |
545: |--------------------------------------+---------------+----------------------|
546: |Linux | Jun 1999 |README.Linux |
547: |--------------------------------------+---------------+----------------------|
548: |Darwin (Mac OS X) | Oct 2001 |README.MacOSX |
549: |--------------------------------------+---------------+----------------------|
550: |FreeBSD | Nov 2002 |README.FreeBSD |
551: |--------------------------------------+---------------+----------------------|
552: |OpenBSD | Nov 2002 |README.OpenBSD |
553: |--------------------------------------+---------------+----------------------|
554: |IRIX | Dec 2002 |README.IRIX |
555: | | |README.IRIX5.3 |
556: |--------------------------------------+---------------+----------------------|
557: |BSD/OS | Dec 2003 | |
558: |--------------------------------------+---------------+----------------------|
559: |AIX | Dec 2003 |README.AIX |
560: |--------------------------------------+---------------+----------------------|
561: |Interix (Microsoft Windows Services | Mar 2004 |README.Interix |
562: |for Unix) | | |
563: |--------------------------------------+---------------+----------------------|
564: |DragonFlyBSD | Oct 2004 | |
565: |--------------------------------------+---------------+----------------------|
566: |OSF/1 | Nov 2004 |README.OSF1 |
567: |--------------------------------------+---------------+----------------------|
568: |HP-UX | Apr 2007 |README.HPUX |
569: |--------------------------------------+---------------+----------------------|
570: |Haiku | Sep 2010 |README.Haiku |
571: |--------------------------------------+---------------+----------------------|
572: |MirBSD | Jan 2011 | |
573: |--------------------------------------+---------------+----------------------|
574: |Minix3 | Nov 2011 |README.Minix3 |
575: |--------------------------------------+---------------+----------------------|
576: |Cygwin | Mar 2013 |README.Cygwin |
577: |--------------------------------------+---------------+----------------------|
578: |GNU/kFreeBSD | Jul 2013 |README.GNUkFreeBSD |
1.104 sevan 579: |--------------------------------------+---------------+----------------------|
580: |Bitrig | Jun 2014 |README.Bitrig |
1.92 sevan 581: +-----------------------------------------------------------------------------+
1.1 dsieger 582:
583:
584: 1.2. Overview
585:
586: This document is divided into three parts. The first, The pkgsrc user's guide,
587: describes how one can use one of the packages in the Package Collection, either
588: by installing a precompiled binary package, or by building one's own copy using
589: the NetBSD package system. The second part, The pkgsrc developer's guide,
590: explains how to prepare a package so it can be easily built by other NetBSD
591: users without knowing about the package's building details. The third part, The
592: pkgsrc infrastructure internals is intended for those who want to understand
593: how pkgsrc is implemented.
594:
595: This document is available in various formats: HTML, PDF, PS, TXT.
596:
597: 1.3. Terminology
598:
599: There has been a lot of talk about "ports", "packages", etc. so far. Here is a
600: description of all the terminology used within this document.
601:
602: Package
603:
604: A set of files and building instructions that describe what's necessary to
605: build a certain piece of software using pkgsrc. Packages are traditionally
606: stored under /usr/pkgsrc.
607:
608: The NetBSD package system
609:
610: This is the former name of "pkgsrc". It is part of the NetBSD operating
611: system and can be bootstrapped to run on non-NetBSD operating systems as
612: well. It handles building (compiling), installing, and removing of
613: packages.
614:
615: Distfile
616:
617: This term describes the file or files that are provided by the author of
618: the piece of software to distribute his work. All the changes necessary to
619: build on NetBSD are reflected in the corresponding package. Usually the
620: distfile is in the form of a compressed tar-archive, but other types are
621: possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
622:
623: Port
624:
625: This is the term used by FreeBSD and OpenBSD people for what we call a
626: package. In NetBSD terminology, "port" refers to a different architecture.
627:
628: Precompiled/binary package
629:
630: A set of binaries built with pkgsrc from a distfile and stuffed together in
631: a single .tgz file so it can be installed on machines of the same machine
632: architecture without the need to recompile. Packages are usually generated
633: in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
634:
635: Sometimes, this is referred to by the term "package" too, especially in the
636: context of precompiled packages.
637:
638: Program
639:
640: The piece of software to be installed which will be constructed from all
641: the files in the distfile by the actions defined in the corresponding
642: package.
643:
644: 1.3.1. Roles involved in pkgsrc
645:
646: pkgsrc users
647:
648: The pkgsrc users are people who use the packages provided by pkgsrc.
649: Typically they are system administrators. The people using the software
650: that is inside the packages (maybe called "end users") are not covered by
651: the pkgsrc guide.
652:
653: There are two kinds of pkgsrc users: Some only want to install pre-built
654: binary packages. Others build the pkgsrc packages from source, either for
655: installing them directly or for building binary packages themselves. For
656: pkgsrc users Part I, "The pkgsrc user's guide" should provide all necessary
657: documentation.
658:
659: package maintainers
660:
661: A package maintainer creates packages as described in Part II, "The pkgsrc
662: developer's guide".
663:
664: infrastructure developers
665:
666: These people are involved in all those files that live in the mk/ directory
667: and below. Only these people should need to read through Part III, "The
668: pkgsrc infrastructure internals", though others might be curious, too.
669:
670: 1.4. Typography
671:
672: When giving examples for commands, shell prompts are used to show if the
673: command should/can be issued as root, or if "normal" user privileges are
674: sufficient. We use a # for root's shell prompt, and a % for users' shell
675: prompt, assuming they use the C-shell or tcsh.
676:
677: Part I. The pkgsrc user's guide
678:
679: Table of Contents
680:
681: 2. Where to get pkgsrc and how to keep it up-to-date
682:
683: 2.1. Getting pkgsrc for the first time
684:
1.52 asau 685: 2.1.1. As tar archive
1.24 wiz 686: 2.1.2. Via anonymous CVS
1.1 dsieger 687:
688: 2.2. Keeping pkgsrc up-to-date
689:
690: 2.2.1. Via tar files
691: 2.2.2. Via CVS
692:
693: 3. Using pkgsrc on systems other than NetBSD
694:
695: 3.1. Binary distribution
696: 3.2. Bootstrapping pkgsrc
697: 3.3. Platform-specific notes
698:
699: 4. Using pkgsrc
700:
701: 4.1. Using binary packages
702:
703: 4.1.1. Finding binary packages
704: 4.1.2. Installing binary packages
705: 4.1.3. Deinstalling packages
706: 4.1.4. Getting information about installed packages
707: 4.1.5. Checking for security vulnerabilities in installed packages
708: 4.1.6. Finding if newer versions of your installed packages are in
709: pkgsrc
710: 4.1.7. Other administrative functions
711:
712: 4.2. Building packages from source
713:
714: 4.2.1. Requirements
715: 4.2.2. Fetching distfiles
716: 4.2.3. How to build and install
717:
718: 5. Configuring pkgsrc
719:
720: 5.1. General configuration
721: 5.2. Variables affecting the build process
1.9 rillig 722: 5.3. Variables affecting the installation process
1.4 rillig 723: 5.4. Selecting and configuring the compiler
1.1 dsieger 724:
1.4 rillig 725: 5.4.1. Selecting the compiler
726: 5.4.2. Additional flags to the compiler (CFLAGS)
727: 5.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 728:
1.4 rillig 729: 5.5. Developer/advanced settings
730: 5.6. Selecting Build Options
1.1 dsieger 731:
732: 6. Creating binary packages
733:
734: 6.1. Building a single binary package
735: 6.2. Settings for creation of binary packages
736:
1.6 rillig 737: 7. Creating binary packages for everything in pkgsrc (bulk builds)
738:
1.71 wiz 739: 7.1. Preparations
740: 7.2. Running a pbulk-style bulk build
1.6 rillig 741:
1.71 wiz 742: 7.2.1. Configuration
1.6 rillig 743:
1.71 wiz 744: 7.3. Requirements of a full bulk build
1.66 asau 745: 7.4. Creating a multiple CD-ROM packages collection
1.6 rillig 746:
1.66 asau 747: 7.4.1. Example of cdpack
1.6 rillig 748:
749: 8. Directory layout of the installed files
750:
751: 8.1. File system layout in ${LOCALBASE}
752: 8.2. File system layout in ${VARBASE}
753:
754: 9. Frequently Asked Questions
755:
756: 9.1. Are there any mailing lists for pkg-related discussion?
1.84 wiz 757: 9.2. Utilities for package management (pkgtools)
758: 9.3. How to use pkgsrc as non-root
759: 9.4. How to resume transfers when fetching distfiles?
760: 9.5. How can I install/use modular X.org from pkgsrc?
761: 9.6. How to fetch files from behind a firewall
762: 9.7. How to fetch files from HTTPS sites
763: 9.8. How do I tell make fetch to do passive FTP?
764: 9.9. How to fetch all distfiles at once
765: 9.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
766: 9.11. What does "Could not find bsd.own.mk" mean?
767: 9.12. Using 'sudo' with pkgsrc
768: 9.13. How do I change the location of configuration files?
769: 9.14. Automated security checks
770: 9.15. Why do some packages ignore my CFLAGS?
771: 9.16. A package does not build. What shall I do?
772: 9.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24 wiz 773: conflicts" mean?
1.1 dsieger 774:
775: Chapter 2. Where to get pkgsrc and how to keep it up-to-date
776:
777: Table of Contents
778:
779: 2.1. Getting pkgsrc for the first time
780:
1.52 asau 781: 2.1.1. As tar archive
1.24 wiz 782: 2.1.2. Via anonymous CVS
1.1 dsieger 783:
784: 2.2. Keeping pkgsrc up-to-date
785:
786: 2.2.1. Via tar files
787: 2.2.2. Via CVS
788:
789: Before you download and extract the files, you need to decide where you want to
790: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
791: usr/pkgsrc. You are though free to install the sources and binary packages
792: wherever you want in your filesystem, provided that the pathname does not
793: contain white-space or other characters that are interpreted specially by the
794: shell and some other programs. A safe bet is to use only letters, digits,
795: underscores and dashes.
796:
797: 2.1. Getting pkgsrc for the first time
798:
1.25 wiz 799: Before you download any pkgsrc files, you should decide whether you want the
1.1 dsieger 800: current branch or the stable branch. The latter is forked on a quarterly basis
801: from the current branch and only gets modified for security updates. The names
802: of the stable branches are built from the year and the quarter, for example
1.78 snj 803: 2014Q3.
1.1 dsieger 804:
805: The second step is to decide how you want to download pkgsrc. You can get it as
1.24 wiz 806: a tar file or via CVS. Both ways are described here.
1.1 dsieger 807:
1.52 asau 808: Note that tar archive contains CVS working copy. Thus you can switch to using
809: CVS at any later time.
1.1 dsieger 810:
1.52 asau 811: 2.1.1. As tar archive
812:
813: The primary download location for all pkgsrc files is http://ftp.NetBSD.org/pub
814: /pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same location).
815: There are a number of subdirectories for different purposes, which are
1.1 dsieger 816: described in detail in Appendix C, Directory layout of the pkgsrc FTP server.
817:
1.52 asau 818: The tar archive for the current branch is in the directory current and is
819: called pkgsrc.tar.gz. It is autogenerated daily.
820:
821: To save download time we provide bzip2- and xz-compressed archives which are
822: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
823:
824: You can fetch the same files using FTP.
1.1 dsieger 825:
1.78 snj 826: The tar file for the stable branch 2014Q3 is in the directory pkgsrc-2014Q3 and
1.59 jnemeth 827: is also called pkgsrc.tar.gz.
1.1 dsieger 828:
1.12 weinem 829: To download a pkgsrc stable tarball, run:
830:
1.59 jnemeth 831: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-20xxQy/pkgsrc.tar.gz
1.12 weinem 832:
1.25 wiz 833: Where pkgsrc-20xxQy is the stable branch to be downloaded, for example, "
1.78 snj 834: pkgsrc-2014Q3".
1.12 weinem 835:
1.78 snj 836: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52 asau 837:
1.12 weinem 838: Then, extract it with:
839:
1.78 snj 840: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12 weinem 841:
842: This will create the directory pkgsrc/ in /usr/ and all the package source will
843: be stored under /usr/pkgsrc/.
844:
845: To download pkgsrc-current, run:
846:
847: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1 dsieger 848:
1.24 wiz 849: 2.1.2. Via anonymous CVS
1.1 dsieger 850:
1.24 wiz 851: To fetch a specific pkgsrc stable branch, run:
1.1 dsieger 852:
1.40 wiz 853: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-20xxQy -P pkgsrc
1.1 dsieger 854:
1.25 wiz 855: Where pkgsrc-20xxQy is the stable branch to be checked out, for example, "
1.78 snj 856: pkgsrc-2014Q3"
1.13 weinem 857:
1.24 wiz 858: This will create the directory pkgsrc/ in your /usr/ directory and all the
859: package source will be stored under /usr/pkgsrc/.
860:
861: To fetch the pkgsrc current branch, run:
1.1 dsieger 862:
1.40 wiz 863: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 864:
1.30 dholland 865: Refer to the list of available mirrors to choose a faster CVS mirror, if
866: needed.
1.1 dsieger 867:
1.24 wiz 868: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1 dsieger 869:
1.40 wiz 870: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 871:
1.24 wiz 872: Refer to documentation on your command shell how to set CVS_RSH=ssh
873: permanently. For Bourne shells, you can set it in your .profile or better
874: globally in /etc/profile:
875:
876: # set CVS remote shell command
877: CVS_RSH=ssh
878: export CVS_RSH
1.12 weinem 879:
1.13 weinem 880: By default, CVS doesn't do things like most people would expect it to do. But
881: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12 weinem 882: directory and saving the following lines to it. This file will save you lots of
883: headache and some bug reports, so we strongly recommend it. You can find an
884: explanation of this file in the CVS documentation.
1.2 rillig 885:
886: # recommended CVS configuration file from the pkgsrc guide
1.40 wiz 887: cvs -q -z2
1.2 rillig 888: checkout -P
1.4 rillig 889: update -dP
890: diff -upN
1.2 rillig 891: rdiff -u
1.24 wiz 892: release -d
1.1 dsieger 893:
894: 2.2. Keeping pkgsrc up-to-date
895:
896: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
897: have first installed it via a tar file). It saves bandwidth and hard disk
898: activity, compared to downloading the tar file again.
899:
900: 2.2.1. Via tar files
901:
902: Warning
903:
904: When updating from a tar file, you first need to completely remove the old
905: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
906: the mean time will not be removed on your local disk, resulting in
907: inconsistencies. When removing the old files, any changes that you have done to
908: the pkgsrc files will be lost after updating. Therefore updating via CVS is
909: strongly recommended.
910:
911: Note that by default the distfiles and the binary packages are saved in the
912: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78 snj 913: configure pkgsrc to store distfiles and packages in directories outside the
914: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter 5,
915: Configuring pkgsrc for the details.
1.1 dsieger 916:
917: To update pkgsrc from a tar file, download the tar file as explained above.
918: Then, make sure that you have not made any changes to the files in the pkgsrc
919: directory. Remove the pkgsrc directory and extract the new tar file. Done.
920:
921: 2.2.2. Via CVS
922:
1.26 spz 923: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12 weinem 924:
1.26 spz 925: $ cd /usr/pkgsrc && cvs update -dP
926:
927: If you get error messages from rsh, you need to set CVS_RSH variable as
928: described above. E.g.:
929:
930: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1 dsieger 931:
932: 2.2.2.1. Switching between different pkgsrc branches
933:
934: When updating pkgsrc, the CVS program keeps track of the branch you selected.
935: But if you, for whatever reason, want to switch from the stable branch to the
936: current one, you can do it by adding the option "-A" after the "update"
1.25 wiz 937: keyword. To switch from the current branch back to the stable branch, add the "
1.78 snj 938: -rpkgsrc-2014Q3" option.
1.1 dsieger 939:
940: 2.2.2.2. What happens to my changes when updating?
941:
942: When you update pkgsrc, the CVS program will only touch those files that are
943: registered in the CVS repository. That means that any packages that you created
944: on your own will stay unmodified. If you change files that are managed by CVS,
945: later updates will try to merge your changes with those that have been done by
946: others. See the CVS manual, chapter "update" for details.
947:
948: Chapter 3. Using pkgsrc on systems other than NetBSD
949:
950: Table of Contents
951:
952: 3.1. Binary distribution
953: 3.2. Bootstrapping pkgsrc
954: 3.3. Platform-specific notes
955:
956: 3.1. Binary distribution
957:
1.9 rillig 958: See Section 4.1, "Using binary packages".
1.1 dsieger 959:
960: 3.2. Bootstrapping pkgsrc
961:
1.44 asau 962: pkgsrc can be bootstrapped for use in two different modes: privileged and
963: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45 asau 964: programs are installed under one particular user and cannot utilise privileged
1.44 asau 965: operations (packages don't create special users and all special file
966: permissions like setuid are ignored).
967:
1.1 dsieger 968: Installing the bootstrap kit from source should be as simple as:
969:
1.60 asau 970: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 971: # cd pkgsrc/bootstrap
972: # ./bootstrap
973:
974:
1.44 asau 975: To bootstrap in unprivileged mode pass "--unprivileged" flag to bootstrap
976:
977: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
978: will be installed in, and /var/db/pkg for the package database directory where
979: pkgsrc will do its internal bookkeeping, /var is used as varbase, where
980: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
981: for prefix, ~/pkg/var/db/pkg for the package database, and ~/pkg/var for
982: varbase.
983:
984: You can change default layout using command-line arguments. Run "./bootstrap
985: --help" to get details.
1.1 dsieger 986:
987: Note
988:
989: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
990: For examples in this guide, use bmake instead of "make".
991:
1.44 asau 992: Note
993:
994: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
995: directories. Use bmake corresponding to the installation you're working with to
996: build and install packages.
997:
1.1 dsieger 998: 3.3. Platform-specific notes
999:
1.111 sevan 1000: For platform-specific notes consult the README files found in the notes column
1001: of Table 1.1, "Platforms supported by pkgsrc"
1.1 dsieger 1002:
1003: Chapter 4. Using pkgsrc
1004:
1005: Table of Contents
1006:
1007: 4.1. Using binary packages
1008:
1009: 4.1.1. Finding binary packages
1010: 4.1.2. Installing binary packages
1011: 4.1.3. Deinstalling packages
1012: 4.1.4. Getting information about installed packages
1013: 4.1.5. Checking for security vulnerabilities in installed packages
1014: 4.1.6. Finding if newer versions of your installed packages are in pkgsrc
1015: 4.1.7. Other administrative functions
1016:
1017: 4.2. Building packages from source
1018:
1019: 4.2.1. Requirements
1020: 4.2.2. Fetching distfiles
1021: 4.2.3. How to build and install
1022:
1023: Basically, there are two ways of using pkgsrc. The first is to only install the
1024: package tools and to use binary packages that someone else has prepared. This
1025: is the "pkg" in pkgsrc. The second way is to install the "src" of pkgsrc, too.
1026: Then you are able to build your own packages, and you can still use binary
1027: packages from someone else.
1028:
1029: 4.1. Using binary packages
1030:
1.9 rillig 1031: On the ftp.NetBSD.org server and its mirrors, there are collections of binary
1032: packages, ready to be installed. These binary packages have been built using
1033: the default settings for the directories, that is:
1034:
1035: * /usr/pkg for LOCALBASE, where most of the files are installed,
1036:
1037: * /usr/pkg/etc for configuration files,
1038:
1039: * /var for VARBASE, where those files are installed that may change after
1040: installation.
1041:
1042: If you cannot use these directories for whatever reasons (maybe because you're
1043: not root), you cannot use these binary packages, but have to build the packages
1044: yourself, which is explained in Section 3.2, "Bootstrapping pkgsrc".
1.1 dsieger 1045:
1046: 4.1.1. Finding binary packages
1047:
1.5 weinem 1048: To install binary packages, you first need to know from where to get them. The
1049: first place where you should look is on the main pkgsrc FTP server in the
1050: directory /pub/pkgsrc/packages.
1051:
1052: This directory contains binary packages for multiple platforms. First, select
1053: your operating system. (Ignore the directories with version numbers attached to
1054: it, they just exist for legacy reasons.) Then, select your hardware
1055: architecture, and in the third step, the OS version and the "version" of
1.9 rillig 1056: pkgsrc.
1057:
1058: In this directory, you often find a file called bootstrap.tar.gz which contains
1059: the package management tools. If the file is missing, it is likely that your
1060: operating system already provides those tools. Download the file and extract it
1061: in the / directory. It will create the directories /usr/pkg (containing the
1062: tools for managing binary packages) and /var/db/pkg (the database of installed
1063: packages).
1.1 dsieger 1064:
1065: 4.1.2. Installing binary packages
1066:
1.85 wiz 1067: In the directory from the last section, there is a subdirectory called All/,
1.9 rillig 1068: which contains all the binary packages that are available for the platform,
1069: excluding those that may not be distributed via FTP or CDROM (depending on
1.24 wiz 1070: which medium you are using).
1.9 rillig 1071:
1072: To install packages directly from an FTP or HTTP server, run the following
1073: commands in a Bourne-compatible shell (be sure to su to root first):
1074:
1075: # PATH="/usr/pkg/sbin:$PATH"
1.85 wiz 1076: # PKG_PATH="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/OPSYS/ARCH/VERSIONS/All/"
1.9 rillig 1077: # export PATH PKG_PATH
1078:
1079: Instead of URLs, you can also use local paths, for example if you are
1080: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
1081: to install packages from multiple sources, you can separate them by a semicolon
1082: in PKG_PATH.
1083:
1084: After these preparations, installing a package is very easy:
1085:
1086: # pkg_add openoffice2
1087: # pkg_add kde-3.5.7
1088: # pkg_add ap2-php5-*
1.1 dsieger 1089:
1090: Note that any prerequisite packages needed to run the package in question will
1091: be installed, too, assuming they are present where you install from.
1092:
1.25 wiz 1093: Adding packages might install vulnerable packages. Thus you should run
1.24 wiz 1094: pkg_admin audit regularly, especially after installing new packages, and verify
1095: that the vulnerabilities are acceptable for your configuration.
1.1 dsieger 1096:
1097: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
1098: in your PATH so you can actually start the just installed program.
1099:
1100: 4.1.3. Deinstalling packages
1101:
1102: To deinstall a package, it does not matter whether it was installed from source
1103: code or from a binary package. The pkg_delete command does not know it anyway.
1104: To delete a package, you can just run pkg_delete package-name. The package name
1105: can be given with or without version number. Wildcards can also be used to
1106: deinstall a set of packages, for example *emacs*. Be sure to include them in
1107: quotes, so that the shell does not expand them before pkg_delete sees them.
1108:
1109: The -r option is very powerful: it removes all the packages that require the
1110: package in question and then removes the package itself. For example:
1111:
1112: # pkg_delete -r jpeg
1113:
1114:
1115: will remove jpeg and all the packages that used it; this allows upgrading the
1116: jpeg package.
1117:
1118: 4.1.4. Getting information about installed packages
1119:
1120: The pkg_info shows information about installed packages or binary package
1121: files.
1122:
1123: 4.1.5. Checking for security vulnerabilities in installed packages
1124:
1125: The NetBSD Security-Officer and Packages Groups maintain a list of known
1126: security vulnerabilities to packages which are (or have been) included in
1127: pkgsrc. The list is available from the NetBSD FTP site at ftp://ftp.NetBSD.org/
1128: pub/pkgsrc/distfiles/vulnerabilities.
1129:
1.23 jakllsch 1130: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
1131: automatically, and a security audit of all packages installed on a system can
1132: take place.
1133:
1134: There are two components to auditing. The first step, pkg_admin
1135: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
1136: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
1137: your installed packages are vulnerable. If a package is vulnerable, you will
1138: see output similar to the following:
1.1 dsieger 1139:
1140: Package samba-2.0.9 has a local-root-shell vulnerability, see
1141: http://www.samba.org/samba/whatsnew/macroexploit.html
1142:
1.23 jakllsch 1143: You may wish to have the vulnerabilities file downloaded daily so that it
1144: remains current. This may be done by adding an appropriate entry to the root
1145: users crontab(5) entry. For example the entry
1146:
1147: # download vulnerabilities file
1148: 0 3 * * * /usr/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1149:
1150:
1151: will update the vulnerability list every day at 3AM. You may wish to do this
1152: more often than once a day. In addition, you may wish to run the package audit
1153: from the daily security script. This may be accomplished by adding the
1154: following line to /etc/security.local:
1155:
1156: /usr/sbin/pkg_admin audit
1157:
1.1 dsieger 1158:
1159: 4.1.6. Finding if newer versions of your installed packages are in pkgsrc
1160:
1.12 weinem 1161: Install pkgtools/lintpkgsrc and run lintpkgsrc with the "-i" argument to check
1162: if your packages are up-to-date, e.g.
1.1 dsieger 1163:
1164: % lintpkgsrc -i
1165: ...
1166: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
1167:
1168:
1169: You can then use make update to update the package on your system and rebuild
1170: any dependencies.
1171:
1172: 4.1.7. Other administrative functions
1173:
1174: The pkg_admin executes various administrative functions on the package system.
1175:
1176: 4.2. Building packages from source
1177:
1178: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25 wiz 1179: organized into categories. You can browse the online index of packages, or run
1.1 dsieger 1180: make readme from the pkgsrc directory to build local README.html files for all
1181: packages, viewable with any web browser such as www/lynx or www/firefox.
1182:
1183: The default prefix for installed packages is /usr/pkg. If you wish to change
1184: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
1185: use multiple different LOCALBASE definitions on the same system (inside a
1186: chroot is an exception).
1187:
1188: The rest of this chapter assumes that the package is already in pkgsrc. If it
1189: is not, see Part II, "The pkgsrc developer's guide" for instructions how to
1190: create your own packages.
1191:
1192: 4.2.1. Requirements
1193:
1194: To build packages from source, you need a working C compiler. On NetBSD, you
1195: need to install the "comp" and the "text" distribution sets. If you want to
1196: build X11-related packages, the "xbase" and "xcomp" distribution sets are
1197: required, too.
1198:
1199: 4.2.2. Fetching distfiles
1200:
1201: The first step for building a package is downloading the distfiles (i.e. the
1202: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
1203: them automatically.
1204:
1205: If you have all files that you need in the distfiles directory, you don't need
1206: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
1207: and add:
1208:
1209: DISTDIR=/cdrom/pkgsrc/distfiles
1210:
1211: to your mk.conf.
1212:
1213: By default a list of distribution sites will be randomly intermixed to prevent
1214: huge load on servers which holding popular packages (for example,
1215: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
1216: distfile all the mirrors will be tried in new (random) order. You can turn this
1217: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
1218: disabled).
1219:
1220: You can overwrite some of the major distribution sites to fit to sites that are
1221: close to your own. By setting one or two variables you can modify the order in
1222: which the master sites are accessed. MASTER_SORT contains a whitespace
1223: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
1224: contains a whitespace delimited list of regular expressions. It has higher
1225: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
1226: some examples. This may save some of your bandwidth and time.
1227:
1228: You can change these settings either in your shell's environment, or, if you
1.4 rillig 1229: want to keep the settings, by editing the mk.conf file, and adding the
1.1 dsieger 1230: definitions there.
1231:
1232: If a package depends on many other packages (such as meta-pkgs/kde3), the build
1233: process may alternate between periods of downloading source, and compiling. To
1234: ensure you have all the source downloaded initially you can run the command:
1235:
1236: % make fetch-list | sh
1237:
1238: which will output and run a set of shell commands to fetch the necessary files
1239: into the distfiles directory. You can also choose to download the files
1240: manually.
1241:
1242: 4.2.3. How to build and install
1243:
1244: Once the software has downloaded, any patches will be applied, then it will be
1245: compiled for you. This may take some time depending on your computer, and how
1246: many other packages the software depends on and their compile time.
1247:
1248: Note
1249:
1250: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
1251: command instead of "make" in the examples in this guide.
1252:
1253: For example, type
1254:
1255: % cd misc/figlet
1256: % make
1257:
1258:
1259: at the shell prompt to build the various components of the package.
1260:
1261: The next stage is to actually install the newly compiled program onto your
1262: system. Do this by entering:
1263:
1264: % make install
1265:
1266:
1267: while you are still in the directory for whatever package you are installing.
1268:
1269: Installing the package on your system may require you to be root. However,
1270: pkgsrc has a just-in-time-su feature, which allows you to only become root for
1271: the actual installation step.
1272:
1273: That's it, the software should now be installed and setup for use. You can now
1274: enter:
1275:
1276: % make clean
1277:
1278:
1279: to remove the compiled files in the work directory, as you shouldn't need them
1280: any more. If other packages were also added to your system (dependencies) to
1281: allow your program to compile, you can tidy these up also with the command:
1282:
1283: % make clean-depends
1284:
1285:
1286: Taking the figlet utility as an example, we can install it on our system by
1287: building as shown in Appendix B, Build logs.
1288:
1289: The program is installed under the default root of the packages tree - /usr/
1290: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
1291: environment, and it will use that value as the root of your packages tree. So,
1292: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
1293: that you should use a directory which is dedicated to packages and not shared
1294: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
1295: not try to add any of your own files or directories (such as src/, obj/, or
1296: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
1297: between programs and other files installed by the package system and whatever
1298: else may have been installed there.
1299:
1.4 rillig 1300: Some packages look in mk.conf to alter some configuration options at build
1.1 dsieger 1301: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
1302: be set there by default. Environment variables such as LOCALBASE can be set in
1.4 rillig 1303: mk.conf to save having to remember to set them each time you want to use
1.1 dsieger 1304: pkgsrc.
1305:
1306: Occasionally, people want to "look under the covers" to see what is going on
1307: when a package is building or being installed. This may be for debugging
1308: purposes, or out of simple curiosity. A number of utility values have been
1309: added to help with this.
1310:
1311: 1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
1312: amount of information will be displayed. For example,
1313:
1314: make patch PKG_DEBUG_LEVEL=2
1315:
1.25 wiz 1316: will show all the commands that are invoked, up to and including the "patch
1317: " stage.
1.1 dsieger 1318:
1319: 2. If you want to know the value of a certain make(1) definition, then the
1320: VARNAME definition should be used, in conjunction with the show-var target.
1321: e.g. to show the expansion of the make(1) variable LOCALBASE:
1322:
1323: % make show-var VARNAME=LOCALBASE
1324: /usr/pkg
1325: %
1326:
1327:
1328: If you want to install a binary package that you've either created yourself
1329: (see next section), that you put into pkgsrc/packages manually or that is
1330: located on a remote FTP server, you can use the "bin-install" target. This
1331: target will install a binary package - if available - via pkg_add(1), else do a
1332: make package. The list of remote FTP sites searched is kept in the variable
1333: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
1334: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
1335: for more details.
1336:
1337: A final word of warning: If you set up a system that has a non-standard setting
1338: for LOCALBASE, be sure to set that before any packages are installed, as you
1339: cannot use several directories for the same purpose. Doing so will result in
1340: pkgsrc not being able to properly detect your installed packages, and fail
1341: miserably. Note also that precompiled binary packages are usually built with
1342: the default LOCALBASE of /usr/pkg, and that you should not install any if you
1343: use a non-standard LOCALBASE.
1344:
1345: Chapter 5. Configuring pkgsrc
1346:
1347: Table of Contents
1348:
1349: 5.1. General configuration
1350: 5.2. Variables affecting the build process
1.9 rillig 1351: 5.3. Variables affecting the installation process
1.4 rillig 1352: 5.4. Selecting and configuring the compiler
1.1 dsieger 1353:
1.4 rillig 1354: 5.4.1. Selecting the compiler
1355: 5.4.2. Additional flags to the compiler (CFLAGS)
1356: 5.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 1357:
1.4 rillig 1358: 5.5. Developer/advanced settings
1359: 5.6. Selecting Build Options
1.1 dsieger 1360:
1361: The whole pkgsrc system is configured in a single file, usually called mk.conf.
1362: In which directory pkgsrc looks for that file depends on the installation. On
1363: NetBSD, when you use make(1) from the base system, it is in the directory /etc
1364: /. In all other cases the default location is ${PREFIX}/etc/, depending on
1365: where you told the bootstrap program to install the binary packages.
1366:
1367: The format of the configuration file is that of the usual BSD-style Makefiles.
1368: The whole pkgsrc configuration is done by setting variables in this file. Note
1369: that you can define all kinds of variables, and no special error checking (for
1.112 ! rillig 1370: example for spelling mistakes) takes place.
1.1 dsieger 1371:
1372: 5.1. General configuration
1373:
1.112 ! rillig 1374: The following variables apply to all pkgsrc packages. A complete list of the
! 1375: variables that can be configured by the user is available in mk/defaults/
! 1376: mk.conf, together with some comments that describe each variable's intent.
1.1 dsieger 1377:
1378: * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
1379: not mix binary packages with different LOCALBASEs!
1380:
1381: * CROSSBASE: Where "cross" category packages will be installed. The default
1382: is ${LOCALBASE}/cross.
1383:
1.84 wiz 1384: * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1 dsieger 1385:
1386: * DISTDIR: Where to store the downloaded copies of the original source
1387: distributions used for building pkgsrc packages. The default is $
1388: {PKGSRCDIR}/distfiles.
1389:
1390: * PKG_DBDIR: Where the database about installed packages is stored. The
1391: default is /var/db/pkg.
1392:
1393: * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
1394: value.
1395:
1396: * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
1397: files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.26 spz 1398: respectively. The defaults are ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1399: {DIST_SUBDIR}/ and ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/$
1.1 dsieger 1400: {DIST_SUBDIR}/.
1401:
1402: * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
1403: with OS release ("2.0", etc.) and architecture ("mipsel", etc.).
1404:
1.23 jakllsch 1405: * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
1406: case-sensitive. Whenever you try to build a package whose license is not in
1407: this list, you will get an error message. If the license condition is
1408: simple enough, the error message will include specific instructions on how
1409: to change this variable.
1.1 dsieger 1410:
1411: 5.2. Variables affecting the build process
1412:
1413: * PACKAGES: The top level directory for the binary packages. The default is $
1414: {PKGSRCDIR}/packages.
1415:
1416: * WRKOBJDIR: The top level directory where, if defined, the separate working
1417: directories will get created, and symbolically linked to from ${WRKDIR}
1418: (see below). This is useful for building packages on several architectures,
1419: then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
1420: architecture. (It should be noted that PKGSRCDIR should not be set by the
1421: user ? it is an internal definition which refers to the root of the pkgsrc
1422: tree. It is possible to have many pkgsrc tree instances.)
1423:
1424: * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.6 rillig 1425: Section 11.3, "patches/*" for more information.
1.1 dsieger 1426:
1427: * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
1428: Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
1429: up settings used by builds in /usr/src.
1430:
1431: * DEPENDS_TARGET: By default, dependencies are only installed, and no binary
1.66 asau 1432: package is created for them. You can set this variable to package-install
1433: to automatically create binary packages after installing dependencies.
1.84 wiz 1434: Please note that the PKGSRC_KEEP_BIN_PKGS can be set to yes to preserve
1.80 wiz 1435: binary packages when using the install as well.
1.1 dsieger 1436:
1.9 rillig 1437: 5.3. Variables affecting the installation process
1.1 dsieger 1438:
1.107 jnemeth 1439: Packages have to support installation into a subdirectory of WRKDIR. This
1440: allows a package to be built, before the actual filesystem is touched. DESTDIR
1441: support exists in two variations:
1.4 rillig 1442:
1443: * Basic DESTDIR support means that the package installation and packaging is
1444: still run as root.
1445:
1446: * Full DESTDIR support can run the complete build, installation and packaging
1447: as normal user. Root privileges are only needed to add packages.
1448:
1449: With basic DESTDIR support, make clean needs to be run as root.
1450:
1.17 imil 1451: Considering the foo/bar package, DESTDIR full support can be tested using the
1452: following commands
1453:
1454: $ id
1455: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
1456: $ mkdir $HOME/packages
1457: $ cd $PKGSRCDIR/foo/bar
1458:
1459: Verify DESTDIR full support, no root privileges should be needed
1460:
1.66 asau 1461: $ make stage-install
1.17 imil 1462:
1463: Create a package without root privileges
1464:
1.66 asau 1465: $ make PACKAGES=$HOME/packages package
1.17 imil 1466:
1467: For the following command, you must be able to gain root privileges using su(1)
1468:
1.66 asau 1469: $ make PACKAGES=$HOME/packages install
1.17 imil 1470:
1471: Then, as a simple user
1472:
1473: $ make clean
1474:
1.4 rillig 1475: 5.4. Selecting and configuring the compiler
1476:
1477: 5.4.1. Selecting the compiler
1.1 dsieger 1478:
1479: By default, pkgsrc will use GCC to build packages. This may be overridden by
1480: setting the following variables in /etc/mk.conf:
1481:
1482: PKGSRC_COMPILER:
1483:
1484: This is a list of values specifying the chain of compilers to invoke when
1485: building packages. Valid values are:
1486:
1.66 asau 1487: + ccc: Compaq C Compilers (Tru64)
1488:
1489: + ccache: compiler cache (chainable)
1490:
1491: + clang: Clang C and Objective-C compiler
1492:
1.42 asau 1493: + distcc: distributed C/C++ (chainable)
1.1 dsieger 1494:
1.66 asau 1495: + f2c: Fortran 77 to C compiler (chainable)
1496:
1497: + icc: Intel C++ Compiler (Linux)
1498:
1499: + ido: SGI IRIS Development Option cc (IRIX 5)
1.1 dsieger 1500:
1.42 asau 1501: + gcc: GNU C/C++ Compiler
1.1 dsieger 1502:
1.66 asau 1503: + hp: HP-UX C/aC++ compilers
1504:
1.42 asau 1505: + mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1 dsieger 1506:
1.66 asau 1507: + mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1 dsieger 1508:
1.42 asau 1509: + sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1 dsieger 1510:
1.66 asau 1511: + xlc: IBM's XL C/C++ compiler suite (Darwin/MacOSX)
1512:
1.1 dsieger 1513: The default is "gcc". You can use ccache and/or distcc with an appropriate
1514: PKGSRC_COMPILER setting, e.g. "ccache gcc". This variable should always be
1515: terminated with a value for a real compiler. Note that only one real
1516: compiler should be listed (e.g. "sunpro gcc" is not allowed).
1517:
1518: GCC_REQD:
1519:
1520: This specifies the minimum version of GCC to use when building packages. If
1521: the system GCC doesn't satisfy this requirement, then pkgsrc will build and
1522: install one of the GCC packages to use instead.
1523:
1.4 rillig 1524: 5.4.2. Additional flags to the compiler (CFLAGS)
1.1 dsieger 1525:
1526: If you wish to set the CFLAGS variable, please make sure to use the += operator
1527: instead of the = operator:
1528:
1529: CFLAGS+= -your -flags
1530:
1531: Using CFLAGS= (i.e. without the "+") may lead to problems with packages that
1.16 jnemeth 1532: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24 wiz 1533: package if you're interested in optimization specifically for the current CPU.
1.1 dsieger 1534:
1.4 rillig 1535: 5.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 1536:
1537: If you want to pass flags to the linker, both in the configure step and the
1538: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
1539: difference between the two is that LIBS will be appended to the command line,
1540: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
1541: machines depending on the setting of USE_IMAKE or the inclusion of mk/
1542: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
1543: settings, use the += operator:
1544:
1545: LDFLAGS+= -your -linkerflags
1546:
1.4 rillig 1547: 5.5. Developer/advanced settings
1.1 dsieger 1548:
1549: * PKG_DEVELOPER: Run some sanity checks that package developers want:
1550:
1.42 asau 1551: + make sure patches apply with zero fuzz
1.1 dsieger 1552:
1.42 asau 1553: + run check-shlibs to see that all binaries will find their shared libs.
1.1 dsieger 1554:
1555: * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
1556: making and installing the package. The default value for this is 0, which
1557: will not display the commands as they are executed (normal, default, quiet
1558: operation); the value 1 will display all shell commands before their
1559: invocation, and the value 2 will display both the shell commands before
1.112 ! rillig 1560: their invocation, as well as their actual execution progress with set -x.
1.1 dsieger 1561:
1.4 rillig 1562: 5.6. Selecting Build Options
1.1 dsieger 1563:
1564: Some packages have build time options, usually to select between different
1565: dependencies, enable optional support for big dependencies or enable
1566: experimental features.
1567:
1568: To see which options, if any, a package supports, and which options are
1569: mutually exclusive, run make show-options, for example:
1570:
1571: The following options are supported by this package:
1572: ssl Enable SSL support.
1573: Exactly one of the following gecko options is required:
1574: firefox Use firefox as gecko rendering engine.
1575: mozilla Use mozilla as gecko rendering engine.
1576: At most one of the following database options may be selected:
1577: mysql Enable support for MySQL database.
1578: pgsql Enable support for PostgreSQL database.
1579:
1580: These options are enabled by default: firefox
1581: These options are currently enabled: mozilla ssl
1582:
1.4 rillig 1583: The following variables can be defined in mk.conf to select which options to
1584: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1 dsieger 1585: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
1586: which can be used to select or disable options specifically for package pkgbase
1587: . Options listed in these variables are selected, options preceded by "-" are
1588: disabled. A few examples:
1589:
1.4 rillig 1590: $ grep "PKG.*OPTION" mk.conf
1.1 dsieger 1591: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
1592: PKG_OPTIONS.kdebase= debug -sasl
1593: PKG_OPTIONS.apache= suexec
1594:
1.11 rillig 1595: It is important to note that options that were specifically suggested by the
1.19 snj 1596: package maintainer must be explicitly removed if you do not wish to include the
1597: option. If you are unsure you can view the current state with make show-options
1598: .
1.11 rillig 1599:
1.1 dsieger 1600: The following settings are consulted in the order given, and the last setting
1601: that selects or disables an option is used:
1602:
1603: 1. the default options as suggested by the package maintainer
1604:
1605: 2. the options implied by the settings of legacy variables (see below)
1606:
1607: 3. PKG_DEFAULT_OPTIONS
1608:
1609: 4. PKG_OPTIONS.pkgbase
1610:
1611: For groups of mutually exclusive options, the last option selected is used, all
1612: others are automatically disabled. If an option of the group is explicitly
1613: disabled, the previously selected option, if any, is used. It is an error if no
1614: option from a required group of options is selected, and building the package
1615: will fail.
1616:
1617: Before the options framework was introduced, build options were selected by
1.4 rillig 1618: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
1619: transition to the options framework for the user, these legacy variables are
1620: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
1621: automatically. A warning is issued to prompt the user to update mk.conf to use
1622: the options framework directly. Support for the legacy variables will be
1.1 dsieger 1623: removed eventually.
1624:
1625: Chapter 6. Creating binary packages
1626:
1627: Table of Contents
1628:
1629: 6.1. Building a single binary package
1630: 6.2. Settings for creation of binary packages
1631:
1632: 6.1. Building a single binary package
1633:
1634: Once you have built and installed a package, you can create a binary package
1635: which can be installed on another system with pkg_add(1). This saves having to
1636: build the same package on a group of hosts and wasting CPU time. It also
1637: provides a simple means for others to install your package, should you
1638: distribute it.
1639:
1640: To create a binary package, change into the appropriate directory in pkgsrc,
1641: and run make package:
1642:
1.112 ! rillig 1643: $ cd misc/figlet
! 1644: $ make package
1.1 dsieger 1645:
1646: This will build and install your package (if not already done), and then build
1647: a binary package from what was installed. You can then use the pkg_* tools to
1648: manipulate it. Binary packages are created by default in /usr/pkgsrc/packages,
1649: in the form of a gzipped tar file. See Section B.2, "Packaging figlet" for a
1650: continuation of the above misc/figlet example.
1651:
1.6 rillig 1652: See Chapter 21, Submitting and Committing for information on how to submit such
1.1 dsieger 1653: a binary package.
1654:
1655: 6.2. Settings for creation of binary packages
1656:
1.6 rillig 1657: See Section 17.17, "Other helpful targets".
1658:
1659: Chapter 7. Creating binary packages for everything in pkgsrc (bulk builds)
1660:
1661: Table of Contents
1662:
1.71 wiz 1663: 7.1. Preparations
1664: 7.2. Running a pbulk-style bulk build
1.6 rillig 1665:
1.71 wiz 1666: 7.2.1. Configuration
1.6 rillig 1667:
1.71 wiz 1668: 7.3. Requirements of a full bulk build
1.66 asau 1669: 7.4. Creating a multiple CD-ROM packages collection
1.6 rillig 1670:
1.66 asau 1671: 7.4.1. Example of cdpack
1.6 rillig 1672:
1.71 wiz 1673: For a number of reasons you may want to build binary packages for a large
1674: selected set of packages in pkgsrc or even for all pkgsrc packages. For
1675: instance, when you have multiple machines that should run the same software, it
1676: is wasted time if they all build their packages themselves from source. Or you
1677: may want to build a list of packages you want and check them before deploying
1678: onto production system. There is a way of getting a set of binary packages: The
1.112 ! rillig 1679: bulk build system, or pbulk ("p" stands for "parallel"). This chapter describes
! 1680: how to set it up.
1.71 wiz 1681:
1682: 7.1. Preparations
1683:
1684: First of all, you have to decide whether you build all packages or a limited
1685: set of them. Full bulk builds usually consume a lot more resources, both space
1686: and time, than builds for some practical sets of packages. There exists a
1687: number of particularly heavy packages that are not actually interesting to a
1688: wide audience. For a limited bulk builds you need to make a list of packages
1.112 ! rillig 1689: you want to build. Note that all their dependencies will be built, so you don't
! 1690: need to track them manually.
1.71 wiz 1691:
1692: During bulk builds various packages are installed and deinstalled in /usr/pkg
1693: (or whatever LOCALBASE is), so make sure that you don't need any package during
1.112 ! rillig 1694: the builds. Essentially, you should provide a fresh system, either a chroot
1.71 wiz 1695: environment or something even more restrictive, depending on what the operating
1696: system provides, or dedicate the whole physical machine. As a useful side
1697: effect this makes sure that bulk builds cannot break anything in your system.
1698: There have been numerous cases where certain packages tried to install files
1699: outside the LOCALBASE or wanted to edit some files in /etc.
1.6 rillig 1700:
1.71 wiz 1701: 7.2. Running a pbulk-style bulk build
1.6 rillig 1702:
1.15 rillig 1703: Running a pbulk-style bulk build works roughly as follows:
1704:
1705: * First, build the pbulk infrastructure in a fresh pkgsrc location.
1706:
1707: * Then, build each of the packages from a clean installation directory using
1708: the infrastructure.
1709:
1.71 wiz 1710: 7.2.1. Configuration
1.6 rillig 1711:
1.112 ! rillig 1712: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6 rillig 1713:
1.68 asau 1714: In order to use it, prepare a clear system (real one, chroot environment, jail,
1715: zone, virtual machine). Configure network access to fetch distribution files.
1.112 ! rillig 1716: Create a user with name "pbulk".
1.68 asau 1717:
1718: Fetch and extract pkgsrc. Use a command like one of these:
1719:
1.72 wiz 1720: # (cd /usr && ftp -o - http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1721: # (cd /usr && fetch -o - http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1722: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68 asau 1723:
1724: Or any other way that fits (e.g., curl, wget).
1725:
1726: Deploy and configure pbulk tools, e.g.:
1727:
1728: # sh pbulk.sh -n # native (NetBSD)
1729: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
1730: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
1731:
1732: Note
1733:
1734: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
1735: to packages you build. For instance,
1736:
1.112 ! rillig 1737: PKG_DEVELOPER= yes # perform more checks
! 1738: X11_TYPE= modular # use pkgsrc X11
! 1739: SKIP_LICENSE_CHECK= yes # accept all licences (useful
! 1740: # when building all packages)
1.68 asau 1741:
1742: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112 ! rillig 1743: with your list of packages, one per line without empty lines or comments. E.g.:
1.68 asau 1744:
1745: www/firefox
1746: mail/thunderbird
1747: misc/libreoffice4
1748:
1.69 asau 1749: At this point you can also review configuration in /usr/pbulk/etc and make
1750: final amendments, if wanted.
1751:
1.68 asau 1752: Start it:
1753:
1754: # /usr/pbulk/bin/bulkbuild
1755:
1756: After it finishes, you'll have /mnt filled with distribution files, binary
1757: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
1758:
1759: Note
1760:
1761: The pbulk.sh script does not cover all possible use cases. While being ready to
1762: run, it serves as a good starting point to understand and build more complex
1763: setups. The script is kept small enough for better understanding.
1764:
1765: Note
1766:
1767: The pbulk.sh script supports running unprivileged bulk build and helps
1768: configuring distributed bulk builds.
1.15 rillig 1769:
1.71 wiz 1770: 7.3. Requirements of a full bulk build
1771:
1772: A complete bulk build requires lots of disk space. Some of the disk space can
1773: be read-only, some other must be writable. Some can be on remote filesystems
1774: (such as NFS) and some should be local. Some can be temporary filesystems,
1775: others must survive a sudden reboot.
1776:
1777: * 40 GB for the distfiles (read-write, remote, temporary)
1778:
1779: * 30 GB for the binary packages (read-write, remote, permanent)
1780:
1781: * 1 GB for the pkgsrc tree (read-only, remote, permanent)
1782:
1783: * 5 GB for LOCALBASE (read-write, local, temporary)
1784:
1785: * 10 GB for the log files (read-write, remote, permanent)
1786:
1787: * 5 GB for temporary files (read-write, local, temporary)
1788:
1.66 asau 1789: 7.4. Creating a multiple CD-ROM packages collection
1.1 dsieger 1790:
1791: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
1792: of the resulting binary packages to assist in installing packages on other
1793: machines. The pkgtools/cdpack package provides a simple tool for creating the
1794: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
1795: keeps all the dependencies for a given package on the same CD as that package.
1796:
1.66 asau 1797: 7.4.1. Example of cdpack
1.1 dsieger 1798:
1799: Complete documentation for cdpack is found in the cdpack(1) man page. The
1800: following short example assumes that the binary packages are left in /usr/
1801: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
1802: ISO 9660 images.
1803:
1804: # mkdir /u2/images
1805: # pkg_add /usr/pkgsrc/packages/All/cdpack
1806: # cdpack /usr/pkgsrc/packages/All /u2/images
1807:
1808:
1809: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
1810: CD in the collection, then you need to create a directory which contains these
1811: files. e.g.
1812:
1813: # mkdir /tmp/common
1814: # echo "This is a README" > /tmp/common/README
1815: # echo "Another file" > /tmp/common/COPYING
1816: # mkdir /tmp/common/bin
1817: # echo "#!/bin/sh" > /tmp/common/bin/myscript
1818: # echo "echo Hello world" >> /tmp/common/bin/myscript
1819: # chmod 755 /tmp/common/bin/myscript
1820:
1821:
1822: Now create the images:
1823:
1824: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
1825:
1826: Each image will contain README, COPYING, and bin/myscript in their root
1827: directories.
1828:
1.6 rillig 1829: Chapter 8. Directory layout of the installed files
1.1 dsieger 1830:
1831: Table of Contents
1832:
1.6 rillig 1833: 8.1. File system layout in ${LOCALBASE}
1834: 8.2. File system layout in ${VARBASE}
1.1 dsieger 1835:
1836: The files that are installed by pkgsrc are organized in a way that is similar
1837: to what you find in the /usr directory of the base system. But some details are
1838: different. This is because pkgsrc initially came from FreeBSD and had adopted
1839: its file system hierarchy. Later it was largely influenced by NetBSD. But no
1840: matter which operating system you are using pkgsrc with, you can expect the
1841: same layout for pkgsrc.
1842:
1843: There are mainly four root directories for pkgsrc, which are all configurable
1844: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
1845: default locations are:
1846:
1847: LOCALBASE= /usr/pkg
1848: PKG_SYSCONFBASE= /usr/pkg/etc
1849: VARBASE= /var
1850: PKG_DBDIR= /var/db/pkg
1851:
1852: In unprivileged mode (when pkgsrc has been installed as any other user), the
1853: default locations are:
1854:
1855: LOCALBASE= ${HOME}/pkg
1856: PKG_SYSCONFBASE= ${HOME}/pkg/etc
1857: VARBASE= ${HOME}/pkg/var
1858: PKG_DBDIR= ${HOME}/pkg/var/db/pkg
1859:
1860: What these four directories are for, and what they look like is explained
1861: below.
1862:
1.25 wiz 1863: * LOCALBASE corresponds to the /usr directory in the base system. It is the "
1864: main" directory where the files are installed and contains the well-known
1.1 dsieger 1865: subdirectories like bin, include, lib, share and sbin.
1866:
1867: * VARBASE corresponds to /var in the base system. Some programs (especially
1868: games, network daemons) need write access to it during normal operation.
1869:
1870: * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
1871: configuration files of the packages, as well as pkgsrc's mk.conf itself.
1872:
1.6 rillig 1873: 8.1. File system layout in ${LOCALBASE}
1.1 dsieger 1874:
1875: The following directories exist in a typical pkgsrc installation in $
1876: {LOCALBASE}.
1877:
1878: bin
1879:
1880: Contains executable programs that are intended to be directly used by the
1881: end user.
1882:
1883: emul
1884:
1885: Contains files for the emulation layers of various other operating systems,
1886: especially for NetBSD.
1887:
1888: etc (the usual location of ${PKG_SYSCONFDIR})
1889:
1890: Contains the configuration files.
1891:
1892: include
1893:
1894: Contains headers for the C and C++ programming languages.
1895:
1896: info
1897:
1898: Contains GNU info files of various packages.
1899:
1900: lib
1901:
1902: Contains shared and static libraries.
1903:
1904: libdata
1905:
1906: Contains data files that don't change after installation. Other data files
1907: belong into ${VARBASE}.
1908:
1909: libexec
1910:
1911: Contains programs that are not intended to be used by end users, such as
1912: helper programs or network daemons.
1913:
1914: libexec/cgi-bin
1915:
1916: Contains programs that are intended to be executed as CGI scripts by a web
1917: server.
1918:
1919: man (the usual value of ${PKGMANDIR})
1920:
1921: Contains brief documentation in form of manual pages.
1922:
1923: sbin
1924:
1925: Contains programs that are intended to be used only by the super-user.
1926:
1927: share
1928:
1929: Contains platform-independent data files that don't change after
1930: installation.
1931:
1932: share/doc
1933:
1934: Contains documentation files provided by the packages.
1935:
1936: share/examples
1937:
1938: Contains example files provided by the packages. Among others, the original
1939: configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
1940: installation.
1941:
1942: share/examples/rc.d
1943:
1944: Contains the original files for rc.d scripts.
1945:
1946: var (the usual location of ${VARBASE})
1947:
1948: Contains files that may be modified after installation.
1949:
1.6 rillig 1950: 8.2. File system layout in ${VARBASE}
1.1 dsieger 1951:
1952: db/pkg (the usual location of ${PKG_DBDIR})
1953:
1954: Contains information about the currently installed packages.
1955:
1956: games
1957:
1958: Contains highscore files.
1959:
1960: log
1961:
1962: Contains log files.
1963:
1964: run
1965:
1966: Contains informational files about daemons that are currently running.
1967:
1.6 rillig 1968: Chapter 9. Frequently Asked Questions
1.1 dsieger 1969:
1970: Table of Contents
1971:
1.6 rillig 1972: 9.1. Are there any mailing lists for pkg-related discussion?
1.84 wiz 1973: 9.2. Utilities for package management (pkgtools)
1974: 9.3. How to use pkgsrc as non-root
1975: 9.4. How to resume transfers when fetching distfiles?
1976: 9.5. How can I install/use modular X.org from pkgsrc?
1977: 9.6. How to fetch files from behind a firewall
1978: 9.7. How to fetch files from HTTPS sites
1979: 9.8. How do I tell make fetch to do passive FTP?
1980: 9.9. How to fetch all distfiles at once
1981: 9.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1982: 9.11. What does "Could not find bsd.own.mk" mean?
1983: 9.12. Using 'sudo' with pkgsrc
1984: 9.13. How do I change the location of configuration files?
1985: 9.14. Automated security checks
1986: 9.15. Why do some packages ignore my CFLAGS?
1987: 9.16. A package does not build. What shall I do?
1988: 9.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24 wiz 1989: conflicts" mean?
1.1 dsieger 1990:
1991: This section contains hints, tips & tricks on special things in pkgsrc that we
1992: didn't find a better place for in the previous chapters, and it contains items
1993: for both pkgsrc users and developers.
1994:
1.6 rillig 1995: 9.1. Are there any mailing lists for pkg-related discussion?
1.1 dsieger 1996:
1997: The following mailing lists may be of interest to pkgsrc users:
1998:
1999: * pkgsrc-users: This is a general purpose list for most issues regarding
2000: pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
2001: configuration, unexpected build failures, using particular packages,
2002: upgrading pkgsrc installations, questions regarding the pkgsrc release
2003: branches, etc. General announcements or proposals for changes that impact
2004: the pkgsrc user community, e.g. major infrastructure changes, new features,
2005: package removals, etc., may also be posted.
2006:
2007: * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
2008: discussed.
2009:
2010: * pkgsrc-changes: This list is for those who are interested in getting a
2011: commit message for every change committed to pkgsrc. It is also available
2012: in digest form, meaning one daily message containing all commit messages
2013: for changes to the package source tree in that 24 hour period.
2014:
2015: To subscribe, do:
2016:
2017: % echo subscribe listname | mail majordomo@NetBSD.org
2018:
2019: Archives for all these mailing lists are available from http://
2020: mail-index.NetBSD.org/.
2021:
1.84 wiz 2022: 9.2. Utilities for package management (pkgtools)
1.1 dsieger 2023:
2024: The directory pkgsrc/pkgtools contains a number of useful utilities for both
2025: users and developers of pkgsrc. This section attempts only to make the reader
2026: aware of the utilities and when they might be useful, and not to duplicate the
2027: documentation that comes with each package.
2028:
2029: Utilities used by pkgsrc (automatically installed when needed):
2030:
2031: * pkgtools/x11-links: Symlinks for use by buildlink.
2032:
2033: OS tool augmentation (automatically installed when needed):
2034:
2035: * pkgtools/digest: Calculates various kinds of checksums (including SHA1).
2036:
2037: * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
2038:
2039: * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
2040:
2041: * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
2042: for use on operating systems where pkg_install is not present.
2043:
2044: Utilities used by pkgsrc (not automatically installed):
2045:
2046: * pkgtools/pkg_tarup: Create a binary package from an already-installed
2047: package. Used by make replace to save the old package.
2048:
2049: * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
2050: distfiles from multiple locations. It currently supports the following
2051: methods: multiple CD-ROMs and network FTP/HTTP connections.
2052:
2053: * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24 wiz 2054: current CPU and compiler.
1.1 dsieger 2055:
2056: Utilities for keeping track of installed packages, being up to date, etc:
2057:
1.65 wiz 2058: * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
2059: and upgrade binary packages easily.
2060:
1.1 dsieger 2061: * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
2062: the latest pkgsrc entries.
2063:
2064: * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
2065: strategy for updating.
2066:
2067: * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
2068: graphviz).
2069:
1.12 weinem 2070: * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
2071:
2072: * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
2073: complete pkgsrc system.
1.1 dsieger 2074:
2075: * pkgtools/pkgsurvey: Report what packages you have installed.
2076:
2077: Utilities for people maintaining or creating individual packages:
2078:
2079: * pkgtools/pkgdiff: Automate making and maintaining patches for a package
2080: (includes pkgdiff, pkgvi, mkpatches, etc.).
2081:
1.65 wiz 2082: * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1 dsieger 2083:
2084: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
2085:
2086: * pkgtools/pkg_comp: Build packages in a chrooted area.
2087:
2088: * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
2089:
1.84 wiz 2090: 9.3. How to use pkgsrc as non-root
1.1 dsieger 2091:
1.108 rillig 2092: To install packages from source as a non-root user, download pkgsrc as
2093: described in Chapter 2, Where to get pkgsrc and how to keep it up-to-date, cd
2094: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
2095:
2096: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
2097: configuration mk.conf into ~/pkg/etc.
2098:
2099: For more details, see mk/unprivileged.mk.
1.1 dsieger 2100:
1.84 wiz 2101: 9.4. How to resume transfers when fetching distfiles?
1.1 dsieger 2102:
2103: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4 rillig 2104: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
2105: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1 dsieger 2106:
1.61 wiz 2107: You can also use a different program than the platform default program by
2108: changing the FETCH_USING variable. You can specify the program by using of ftp,
2109: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
2110: manual. A value of custom disables the system defaults and dependency tracking
2111: for the fetch program. In that case you have to provide FETCH_CMD,
2112: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1 dsieger 2113:
1.16 jnemeth 2114: For example, if you want to use wget to download, you'll have to use something
2115: like:
1.1 dsieger 2116:
1.16 jnemeth 2117: FETCH_USING= wget
1.1 dsieger 2118:
1.84 wiz 2119: 9.5. How can I install/use modular X.org from pkgsrc?
1.1 dsieger 2120:
1.4 rillig 2121: If you want to use modular X.org from pkgsrc instead of your system's own X11
2122: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1 dsieger 2123: mk.conf:
2124:
1.4 rillig 2125: X11_TYPE=modular
1.1 dsieger 2126:
2127: Note
2128:
1.4 rillig 2129: The DragonFly operating system defaults to using modular X.org from pkgsrc.
1.1 dsieger 2130:
1.84 wiz 2131: 9.6. How to fetch files from behind a firewall
1.1 dsieger 2132:
2133: If you are sitting behind a firewall which does not allow direct connections to
2134: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
2135: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
2136: machine "orpheus.amdahl.com" is one of the firewalls, and it uses port 80 as
2137: the proxy port number. So the proxy environment variables are:
2138:
2139: ftp_proxy=ftp://orpheus.amdahl.com:80/
2140: http_proxy=http://orpheus.amdahl.com:80/
2141:
1.84 wiz 2142: 9.7. How to fetch files from HTTPS sites
1.65 wiz 2143:
2144: Some fetch tools are not prepared to support HTTPS by default (for example, the
2145: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
2146: openssl dependency that low in the dependency graph).
2147:
2148: Usually you won't notice, because distribution files are mirrored weekly to "
2149: ftp.NetBSD.org", but that might not be often enough if you are following
2150: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to "curl" or
2151: "wget", which are both compiled with HTTPS support by default. Of course, these
2152: tools need to be installed before you can use them this way.
2153:
1.84 wiz 2154: 9.8. How do I tell make fetch to do passive FTP?
1.1 dsieger 2155:
2156: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
2157: FETCH_CMD is assigned the first available command from the following list:
2158:
2159: * ${LOCALBASE}/bin/ftp
2160:
2161: * /usr/bin/ftp
2162:
2163: On a default NetBSD installation, this will be /usr/bin/ftp, which
2164: automatically tries passive connections first, and falls back to active
2165: connections if the server refuses to do passive. For the other tools, add the
1.4 rillig 2166: following to your mk.conf file: PASSIVE_FETCH=1.
1.1 dsieger 2167:
2168: Having that option present will prevent /usr/bin/ftp from falling back to
2169: active transfers.
2170:
1.84 wiz 2171: 9.9. How to fetch all distfiles at once
1.1 dsieger 2172:
2173: You would like to download all the distfiles in a single batch from work or
2174: university, where you can't run a make fetch. There is an archive of distfiles
2175: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
2176:
2177: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
2178: subdirectories, carry the resulting list to your machine at work/school and use
2179: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
2180: don't forget to set FETCH_CMD to something that fetches a URL:
2181:
2182: At home:
2183:
2184: % cd /usr/pkgsrc
2185: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
2186: % scp /tmp/fetch.sh work:/tmp
2187:
2188: At work:
2189:
2190: % sh /tmp/fetch.sh
2191:
2192: then tar up /tmp/distfiles and take it home.
2193:
2194: If you have a machine running NetBSD, and you want to get all distfiles (even
2195: ones that aren't for your machine architecture), you can do so by using the
2196: above-mentioned make fetch-list approach, or fetch the distfiles directly by
2197: running:
2198:
2199: % make mirror-distfiles
2200:
2201: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
2202: everything by running:
2203:
2204: % make fetch NO_SKIP=yes
2205:
1.84 wiz 2206: 9.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1.1 dsieger 2207:
2208: When compiling the pkgtools/pkg_install package, you get the error from make
2209: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
2210: that you don't have installed the "text" set (nroff, ...) from the NetBSD base
2211: distribution on your machine. It is recommended to do that to format man pages.
2212:
2213: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4 rillig 2214: NOMAN=YES either in the environment or in mk.conf.
1.1 dsieger 2215:
1.84 wiz 2216: 9.11. What does "Could not find bsd.own.mk" mean?
1.1 dsieger 2217:
2218: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
2219: machine. Please get and install it, by extracting it in /:
2220:
2221: # cd /
2222: # tar --unlink -zxvpf .../comp.tgz
2223:
2224: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
2225: release (determine via uname -r).
2226:
1.84 wiz 2227: 9.12. Using 'sudo' with pkgsrc
1.1 dsieger 2228:
2229: When installing packages as non-root user and using the just-in-time su(1)
2230: feature of pkgsrc, it can become annoying to type in the root password for each
2231: required package installed. To avoid this, the sudo package can be used, which
2232: does password caching over a limited time. To use it, install sudo (either as
1.4 rillig 2233: binary package or from security/sudo) and then put the following into your
2234: mk.conf, somewhere after the definition of the LOCALBASE variable:
1.1 dsieger 2235:
2236: .if exists(${LOCALBASE}/bin/sudo)
2237: SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
2238: .endif
2239:
1.84 wiz 2240: 9.13. How do I change the location of configuration files?
1.1 dsieger 2241:
2242: As the system administrator, you can choose where configuration files are
2243: installed. The default settings make all these files go into ${PREFIX}/etc or
2244: some of its subdirectories; this may be suboptimal depending on your
2245: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
2246: configuration of the provided packages).
2247:
2248: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4 rillig 2249: (in mk.conf) to point to your preferred configuration directory; some common
2250: examples include /etc or /etc/pkg.
1.1 dsieger 2251:
2252: Furthermore, you can change this value on a per-package basis by setting the
2253: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
2254: matches the name of the package you would like to modify, that is, the contents
2255: of PKGBASE.
2256:
2257: Note that after changing these settings, you must rebuild and reinstall any
2258: affected packages.
2259:
1.84 wiz 2260: 9.14. Automated security checks
1.1 dsieger 2261:
2262: Please be aware that there can often be bugs in third-party software, and some
2263: of these bugs can leave a machine vulnerable to exploitation by attackers. In
2264: an effort to lessen the exposure, the NetBSD packages team maintains a database
2265: of known-exploits to packages which have at one time been included in pkgsrc.
2266: The database can be downloaded automatically, and a security audit of all
1.14 jmcneill 2267: packages installed on a system can take place. To do this, refer to the
2268: following two tools (installed as part of the pkgtools/pkg_install package):
1.1 dsieger 2269:
1.21 snj 2270: 1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
2271: security vulnerabilities information. This list is kept up to date by the
1.26 spz 2272: pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1 dsieger 2273:
1.26 spz 2274: ftp://ftp.NetBSD.org/pkgsrc/distfiles/pkg-vulnerabilities
1.1 dsieger 2275:
1.21 snj 2276: 2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24 wiz 2277: known vulnerability. If a vulnerable package is installed, it will be shown
2278: by output to stdout, including a description of the type of vulnerability,
2279: and a URL containing more information.
1.1 dsieger 2280:
1.14 jmcneill 2281: Use of these tools is strongly recommended! After "pkg_install" is installed,
2282: please read the package's message, which you can get by running pkg_info -D
2283: pkg_install.
1.1 dsieger 2284:
2285: If this package is installed, pkgsrc builds will use it to perform a security
2286: check before building any package. See Section 5.2, "Variables affecting the
2287: build process" for ways to control this check.
2288:
1.84 wiz 2289: 9.15. Why do some packages ignore my CFLAGS?
1.1 dsieger 2290:
2291: When you add your own preferences to the CFLAGS variable in your mk.conf, these
2292: flags are passed in environment variables to the ./configure scripts and to
2293: make(1). Some package authors ignore the CFLAGS from the environment variable
2294: by overriding them in the Makefiles of their package.
2295:
2296: Currently there is no solution to this problem. If you really need the package
2297: to use your CFLAGS you should run make patch in the package directory and then
2298: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
2299: Usually you can remove these lines. But be aware that some "smart" programmers
2300: write so bad code that it only works for the specific combination of CFLAGS
2301: they have chosen.
2302:
1.84 wiz 2303: 9.16. A package does not build. What shall I do?
1.1 dsieger 2304:
2305: 1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
2306: is that people only update pkgsrc in parts, because of performance reasons.
2307: Since pkgsrc is one large system, not a collection of many small systems,
2308: there are sometimes changes that only work when the whole pkgsrc tree is
2309: updated.
2310:
1.25 wiz 2311: 2. Make sure that you don't have any CVS conflicts. Search for "<<<<<<" or "
2312: >>>>>>" in all your pkgsrc files.
1.1 dsieger 2313:
1.25 wiz 2314: 3. Make sure that you don't have old copies of the packages extracted. Run
1.1 dsieger 2315: make clean clean-depends to verify this.
2316:
1.108 rillig 2317: 4. If you are a package developer who wants to invest some work, have a look
2318: at Chapter 19, Making your package work.
2319:
2320: 5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1 dsieger 2321:
1.84 wiz 2322: 9.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.1 dsieger 2323: conflicts" mean?
2324:
2325: You have modified a file from pkgsrc, and someone else has modified that same
2326: file afterwards in the CVS repository. Both changes are in the same region of
2327: the file, so when you updated pkgsrc, the cvs command marked the conflicting
2328: changes in the file. Because of these markers, the file is no longer a valid
2329: Makefile.
2330:
2331: Have a look at that file, and if you don't need your local changes anymore, you
2332: can remove that file and run cvs -q update -dP in that directory to download
2333: the current version.
2334:
2335: Part II. The pkgsrc developer's guide
2336:
2337: This part of the book deals with creating and modifying packages. It starts
2338: with a "HOWTO"-like guide on creating a new package. The remaining chapters are
2339: more like a reference manual for pkgsrc.
2340:
2341: Table of Contents
2342:
1.6 rillig 2343: 10. Creating a new pkgsrc package from scratch
1.1 dsieger 2344:
1.6 rillig 2345: 10.1. Common types of packages
1.1 dsieger 2346:
1.6 rillig 2347: 10.1.1. Perl modules
1.66 asau 2348: 10.1.2. KDE3 applications
1.17 imil 2349: 10.1.3. Python modules and programs
1.1 dsieger 2350:
1.6 rillig 2351: 10.2. Examples
1.1 dsieger 2352:
1.6 rillig 2353: 10.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 2354:
1.6 rillig 2355: 11. Package components - files, directories and contents
1.1 dsieger 2356:
1.6 rillig 2357: 11.1. Makefile
2358: 11.2. distinfo
2359: 11.3. patches/*
1.1 dsieger 2360:
1.6 rillig 2361: 11.3.1. Structure of a single patch file
2362: 11.3.2. Creating patch files
2363: 11.3.3. Sources where the patch files come from
2364: 11.3.4. Patching guidelines
2365: 11.3.5. Feedback to the author
1.1 dsieger 2366:
1.6 rillig 2367: 11.4. Other mandatory files
2368: 11.5. Optional files
1.1 dsieger 2369:
1.6 rillig 2370: 11.5.1. Files affecting the binary package
2371: 11.5.2. Files affecting the build process
2372: 11.5.3. Files affecting nothing at all
1.1 dsieger 2373:
1.6 rillig 2374: 11.6. work*
2375: 11.7. files/*
1.1 dsieger 2376:
1.6 rillig 2377: 12. Programming in Makefiles
1.1 dsieger 2378:
1.6 rillig 2379: 12.1. Caveats
2380: 12.2. Makefile variables
1.1 dsieger 2381:
1.6 rillig 2382: 12.2.1. Naming conventions
1.1 dsieger 2383:
1.6 rillig 2384: 12.3. Code snippets
1.1 dsieger 2385:
1.6 rillig 2386: 12.3.1. Adding things to a list
1.108 rillig 2387: 12.3.2. Echoing a string exacty as-is
2388: 12.3.3. Passing CFLAGS to GNU configure scripts
2389: 12.3.4. Handling possibly empty variables
1.1 dsieger 2390:
1.6 rillig 2391: 13. PLIST issues
1.1 dsieger 2392:
1.6 rillig 2393: 13.1. RCS ID
2394: 13.2. Semi-automatic PLIST generation
2395: 13.3. Tweaking output of make print-PLIST
2396: 13.4. Variable substitution in PLIST
2397: 13.5. Man page compression
2398: 13.6. Changing PLIST source with PLIST_SRC
2399: 13.7. Platform-specific and differing PLISTs
1.86 wiz 2400: 13.8. Build-specific PLISTs
2401: 13.9. Sharing directories between packages
1.1 dsieger 2402:
1.6 rillig 2403: 14. Buildlink methodology
1.1 dsieger 2404:
1.6 rillig 2405: 14.1. Converting packages to use buildlink3
2406: 14.2. Writing buildlink3.mk files
1.1 dsieger 2407:
1.6 rillig 2408: 14.2.1. Anatomy of a buildlink3.mk file
1.27 wiz 2409: 14.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
2410: pkg in buildlink3.mk files
1.1 dsieger 2411:
1.6 rillig 2412: 14.3. Writing builtin.mk files
1.1 dsieger 2413:
1.6 rillig 2414: 14.3.1. Anatomy of a builtin.mk file
2415: 14.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 2416:
1.6 rillig 2417: 15. The pkginstall framework
1.1 dsieger 2418:
1.6 rillig 2419: 15.1. Files and directories outside the installation prefix
1.1 dsieger 2420:
1.6 rillig 2421: 15.1.1. Directory manipulation
2422: 15.1.2. File manipulation
1.1 dsieger 2423:
1.6 rillig 2424: 15.2. Configuration files
1.1 dsieger 2425:
1.6 rillig 2426: 15.2.1. How PKG_SYSCONFDIR is set
2427: 15.2.2. Telling the software where configuration files are
2428: 15.2.3. Patching installations
2429: 15.2.4. Disabling handling of configuration files
1.1 dsieger 2430:
1.6 rillig 2431: 15.3. System startup scripts
1.1 dsieger 2432:
1.6 rillig 2433: 15.3.1. Disabling handling of system startup scripts
1.1 dsieger 2434:
1.6 rillig 2435: 15.4. System users and groups
2436: 15.5. System shells
1.1 dsieger 2437:
1.6 rillig 2438: 15.5.1. Disabling shell registration
1.1 dsieger 2439:
1.6 rillig 2440: 15.6. Fonts
1.1 dsieger 2441:
1.6 rillig 2442: 15.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 2443:
1.6 rillig 2444: 16. Options handling
1.1 dsieger 2445:
1.6 rillig 2446: 16.1. Global default options
2447: 16.2. Converting packages to use bsd.options.mk
2448: 16.3. Option Names
1.7 rillig 2449: 16.4. Determining the options of dependencies
1.1 dsieger 2450:
1.6 rillig 2451: 17. The build process
1.1 dsieger 2452:
1.6 rillig 2453: 17.1. Introduction
2454: 17.2. Program location
2455: 17.3. Directories used during the build process
2456: 17.4. Running a phase
2457: 17.5. The fetch phase
1.1 dsieger 2458:
1.6 rillig 2459: 17.5.1. What to fetch and where to get it from
2460: 17.5.2. How are the files fetched?
1.1 dsieger 2461:
1.6 rillig 2462: 17.6. The checksum phase
2463: 17.7. The extract phase
2464: 17.8. The patch phase
2465: 17.9. The tools phase
2466: 17.10. The wrapper phase
2467: 17.11. The configure phase
2468: 17.12. The build phase
2469: 17.13. The test phase
2470: 17.14. The install phase
2471: 17.15. The package phase
2472: 17.16. Cleaning up
2473: 17.17. Other helpful targets
1.1 dsieger 2474:
1.6 rillig 2475: 18. Tools needed for building or running
1.1 dsieger 2476:
1.6 rillig 2477: 18.1. Tools for pkgsrc builds
2478: 18.2. Tools needed by packages
2479: 18.3. Tools provided by platforms
1.1 dsieger 2480:
1.6 rillig 2481: 19. Making your package work
1.1 dsieger 2482:
1.6 rillig 2483: 19.1. General operation
1.1 dsieger 2484:
1.108 rillig 2485: 19.1.1. How to pull in user-settable variables from mk.conf
2486: 19.1.2. User interaction
2487: 19.1.3. Handling licenses
2488: 19.1.4. Restricted packages
2489: 19.1.5. Handling dependencies
2490: 19.1.6. Handling conflicts with other packages
2491: 19.1.7. Packages that cannot or should not be built
2492: 19.1.8. Packages which should not be deleted, once installed
2493: 19.1.9. Handling packages with security problems
2494: 19.1.10. How to handle incrementing versions when fixing an existing
1.1 dsieger 2495: package
1.108 rillig 2496: 19.1.11. Substituting variable text in the package files (the SUBST
1.1 dsieger 2497: framework)
2498:
1.108 rillig 2499: 19.2. The fetch phase
1.1 dsieger 2500:
1.6 rillig 2501: 19.2.1. Packages whose distfiles aren't available for plain downloading
2502: 19.2.2. How to handle modified distfiles with the 'old' name
1.88 tnn 2503: 19.2.3. Packages hosted on github.com
1.1 dsieger 2504:
1.108 rillig 2505: 19.3. The configure phase
1.1 dsieger 2506:
1.6 rillig 2507: 19.3.1. Shared libraries - libtool
2508: 19.3.2. Using libtool on GNU packages that already support libtool
2509: 19.3.3. GNU Autoconf/Automake
2510:
2511: 19.4. Programming languages
2512:
2513: 19.4.1. C, C++, and Fortran
2514: 19.4.2. Java
2515: 19.4.3. Packages containing perl scripts
1.41 wiz 2516: 19.4.4. Packages containing shell scripts
2517: 19.4.5. Other programming languages
1.6 rillig 2518:
1.108 rillig 2519: 19.5. The build phase
1.6 rillig 2520:
2521: 19.5.1. Compiling C and C++ code conditionally
2522: 19.5.2. How to handle compiler bugs
1.24 wiz 2523: 19.5.3. Undefined reference to "..."
1.6 rillig 2524: 19.5.4. Running out of memory
2525:
1.108 rillig 2526: 19.6. The install phase
1.6 rillig 2527:
2528: 19.6.1. Creating needed directories
2529: 19.6.2. Where to install documentation
2530: 19.6.3. Installing highscore files
2531: 19.6.4. Adding DESTDIR support to packages
2532: 19.6.5. Packages with hardcoded paths to other interpreters
2533: 19.6.6. Packages installing perl modules
2534: 19.6.7. Packages installing info files
2535: 19.6.8. Packages installing man pages
1.7 rillig 2536: 19.6.9. Packages installing GConf data files
1.18 mishka 2537: 19.6.10. Packages installing scrollkeeper/rarian data files
1.6 rillig 2538: 19.6.11. Packages installing X11 fonts
2539: 19.6.12. Packages installing GTK2 modules
2540: 19.6.13. Packages installing SGML or XML data
2541: 19.6.14. Packages installing extensions to the MIME database
2542: 19.6.15. Packages using intltool
2543: 19.6.16. Packages installing startup scripts
2544: 19.6.17. Packages installing TeX modules
2545: 19.6.18. Packages supporting running binaries in emulation
2546: 19.6.19. Packages installing hicolor theme icons
2547: 19.6.20. Packages installing desktop files
2548:
2549: 19.7. Marking packages as having problems
2550:
2551: 20. Debugging
2552: 21. Submitting and Committing
2553:
2554: 21.1. Submitting binary packages
2555: 21.2. Submitting source packages (for non-NetBSD-developers)
2556: 21.3. General notes when adding, updating, or removing packages
1.34 wiz 2557: 21.4. Committing: Adding a package to CVS
1.6 rillig 2558: 21.5. Updating a package to a newer version
1.21 snj 2559: 21.6. Renaming a package in pkgsrc
2560: 21.7. Moving a package in pkgsrc
1.6 rillig 2561:
2562: 22. Frequently Asked Questions
2563: 23. GNOME packaging and porting
2564:
2565: 23.1. Meta packages
2566: 23.2. Packaging a GNOME application
2567: 23.3. Updating GNOME to a newer version
2568: 23.4. Patching guidelines
1.1 dsieger 2569:
1.6 rillig 2570: Chapter 10. Creating a new pkgsrc package from scratch
1.1 dsieger 2571:
2572: Table of Contents
2573:
1.6 rillig 2574: 10.1. Common types of packages
1.1 dsieger 2575:
1.6 rillig 2576: 10.1.1. Perl modules
1.66 asau 2577: 10.1.2. KDE3 applications
1.17 imil 2578: 10.1.3. Python modules and programs
1.1 dsieger 2579:
1.6 rillig 2580: 10.2. Examples
1.1 dsieger 2581:
1.6 rillig 2582: 10.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 2583:
2584: When you find a package that is not yet in pkgsrc, you most likely have a URL
2585: from where you can download the source code. Starting with this URL, creating a
2586: package involves only a few steps.
2587:
2588: 1. First, install the packages pkgtools/url2pkg and pkgtools/pkglint.
2589:
2590: 2. Then, choose one of the top-level directories as the category in which you
2591: want to place your package. You can also create a directory of your own
2592: (maybe called local). In that category directory, create another directory
2593: for your package and change into it.
2594:
2595: 3. Run the program url2pkg, which will ask you for a URL. Enter the URL of the
2596: distribution file (in most cases a .tar.gz file) and watch how the basic
2597: ingredients of your package are created automatically. The distribution
2598: file is extracted automatically to fill in some details in the Makefile
2599: that would otherwise have to be done manually.
2600:
2601: 4. Examine the extracted files to determine the dependencies of your package.
2602: Ideally, this is mentioned in some README file, but things may differ. For
2603: each of these dependencies, look where it exists in pkgsrc, and if there is
2604: a file called buildlink3.mk in that directory, add a line to your package
2605: Makefile which includes that file just before the last line. If the
1.26 spz 2606: buildlink3.mk file does not exist, it must be created first. The
2607: buildlink3.mk file makes sure that the package's include files and
2608: libraries are provided.
2609:
2610: If you just need binaries from a package, add a DEPENDS line to the
2611: Makefile, which specifies the version of the dependency and where it can be
2612: found in pkgsrc. This line should be placed in the third paragraph. If the
1.1 dsieger 2613: dependency is only needed for building the package, but not when using it,
2614: use BUILD_DEPENDS instead of DEPENDS. Your package may then look like this:
2615:
2616: [...]
2617:
1.66 asau 2618: BUILD_DEPENDS+= libxslt-[0-9]*:../../textproc/libxslt
1.1 dsieger 2619: DEPENDS+= screen-[0-9]*:../../misc/screen
2620: DEPENDS+= screen>=4.0:../../misc/screen
2621:
2622: [...]
2623:
2624: .include "../../category/package/buildlink3.mk"
2625: .include "../../devel/glib2/buildlink3.mk"
2626: .include "../../mk/bsd.pkg.mk"
2627:
2628: 5. Run pkglint to see what things still need to be done to make your package a
2629: "good" one. If you don't know what pkglint's warnings want to tell you, try
2630: pkglint --explain or pkglint -e, which outputs additional explanations.
2631:
2632: 6. In many cases the package is not yet ready to build. You can find
1.6 rillig 2633: instructions for the most common cases in the next section, Section 10.1,
1.1 dsieger 2634: "Common types of packages". After you have followed the instructions over
2635: there, you can hopefully continue here.
2636:
2637: 7. Run bmake clean to clean the working directory from the extracted files.
2638: Besides these files, a lot of cache files and other system information has
2639: been saved in the working directory, which may become wrong after you
2640: edited the Makefile.
2641:
2642: 8. Now, run bmake to build the package. For the various things that can go
1.6 rillig 2643: wrong in this phase, consult Chapter 19, Making your package work.
1.1 dsieger 2644:
1.25 wiz 2645: 9. When the package builds fine, the next step is to install the package. Run
1.1 dsieger 2646: bmake install and hope that everything works.
2647:
2648: 10. Up to now, the file PLIST, which contains a list of the files that are
2649: installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
2650: generate a probably correct list. Check the file using your preferred text
2651: editor to see if the list of files looks plausible.
2652:
2653: 11. Run pkglint again to see if the generated PLIST contains garbage or not.
2654:
2655: 12. When you ran bmake install, the package has been registered in the database
2656: of installed files, but with an empty list of files. To fix this, run bmake
2657: deinstall and bmake install again. Now the package is registered with the
2658: list of files from PLIST.
2659:
2660: 13. Run bmake package to create a binary package from the set of installed
2661: files.
2662:
1.6 rillig 2663: 10.1. Common types of packages
1.1 dsieger 2664:
1.6 rillig 2665: 10.1.1. Perl modules
1.1 dsieger 2666:
2667: Simple Perl modules are handled automatically by url2pkg, including
2668: dependencies.
2669:
1.66 asau 2670: 10.1.2. KDE3 applications
1.1 dsieger 2671:
1.66 asau 2672: KDE3 applications should always include meta-pkgs/kde3/kde3.mk, which contains
2673: numerous settings that are typical of KDE3 packages.
1.1 dsieger 2674:
1.17 imil 2675: 10.1.3. Python modules and programs
2676:
2677: Python modules and programs packages are easily created using a set of
2678: predefined variables.
2679:
1.63 wiz 2680: If some Python versions are not supported by the software, set the
2681: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
2682: supported, e.g.
1.17 imil 2683:
1.93 sevan 2684: PYTHON_VERSIONS_INCOMPATIBLE= 27
1.17 imil 2685:
1.103 wiz 2686: If the packaged software is a Python module, include one of ../../lang/python/
2687: egg.mk, ../../lang/python/distutils.mk, or ../../lang/python/extension.mk.
2688:
2689: Most Python packages use either "distutils" or easy-setup/setuptools ("eggs").
2690: if the packaged software is using setuptools, you only need to include "../../
2691: lang/python/egg.mk". Otherwise, if the software uses "distutils", include "..
2692: /../lang/python/distutils.mk". so pkgsrc will use this framework. "distutils"
2693: uses a script called setup.py, if the "distutils" driver is not called
2694: setup.py, set the PYSETUP variable to the name of the script.
2695:
2696: Either way, the package directory should be called "py-software" and PKGNAME
2697: should be set to "${PYPKGPREFIX}-${DISTNAME}", e.g.
1.17 imil 2698:
2699: DISTNAME= foopymodule-1.2.10
2700: PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
2701:
1.63 wiz 2702: If it is an application, include "../../lang/python/application.mk". In order
2703: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
2704: variable and set it to the list of files (paths relative to WRKSRC) that must
2705: be corrected. For example:
1.17 imil 2706:
1.63 wiz 2707: REPLACE_PYTHON= *.py
1.17 imil 2708:
1.63 wiz 2709: Some Python modules have separate distributions for Python-2.x and Python-3.x
2710: support. In pkgsrc this is handled by the versioned_dependencies.mk file. Set
2711: PYTHON_VERSIONED_DEPENDENCIES to the list of packages that should be depended
2712: upon and include "../../lang/python/versioned_dependencies.mk", then the pkgsrc
2713: infrastructure will depend on the appropriate package version. For example:
1.17 imil 2714:
1.110 wiz 2715: PYTHON_VERSIONED_DEPENDENCIES=dateutil
1.63 wiz 2716:
2717: Look inside versioned_dependencies.mk for a list of supported packages.
1.17 imil 2718:
1.6 rillig 2719: 10.2. Examples
1.1 dsieger 2720:
1.6 rillig 2721: 10.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 2722:
1.6 rillig 2723: 10.2.1.1. The initial package
1.1 dsieger 2724:
2725: Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
2726: been imported into pkgsrc. As the description says it has to do with the web,
2727: the obvious choice for the category is "www".
2728:
2729: $ mkdir www/nvu
2730: $ cd www/nvu
2731:
2732: The web site says that the sources are available as a tar file, so I fed that
2733: URL to the url2pkg program:
2734:
2735: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
2736:
2737: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
2738: package name should not have the word "sources" in it. I also filled in the
2739: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
2740: that:
2741:
1.2 rillig 2742: # $NetBSD$
1.1 dsieger 2743: #
2744:
2745: DISTNAME= nvu-1.0-sources
2746: PKGNAME= nvu-1.0
2747: CATEGORIES= www
2748: MASTER_SITES= http://cvs.nvu.com/download/
2749: EXTRACT_SUFX= .tar.bz2
2750:
2751: MAINTAINER= rillig@NetBSD.org
2752: HOMEPAGE= http://cvs.nvu.com/
2753: COMMENT= Web Authoring System
2754:
2755: # url2pkg-marker (please do not remove this line.)
2756: .include "../../mk/bsd.pkg.mk"
2757:
2758: Then, I quit the editor and watched pkgsrc downloading a large source archive:
2759:
2760: url2pkg> Running "make makesum" ...
2761: => Required installed package digest>=20010302: digest-20060826 found
2762: => Fetching nvu-1.0-sources.tar.bz2
2763: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
2764: 100% |*************************************| 28992 KB 150.77 KB/s00:00 ETA
2765: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
2766: url2pkg> Running "make extract" ...
2767: => Required installed package digest>=20010302: digest-20060826 found
2768: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
2769: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
2770: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
2771: ===> Installing dependencies for nvu-1.0
2772: ===> Overriding tools for nvu-1.0
2773: ===> Extracting for nvu-1.0
2774: url2pkg> Adjusting the Makefile.
2775:
2776: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
2777:
2778: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
2779:
1.6 rillig 2780: 10.2.1.2. Fixing all kinds of problems to make the package work
1.1 dsieger 2781:
2782: Now that the package has been extracted, let's see what's inside it. The
2783: package has a README.txt, but that only says something about mozilla, so it's
2784: probably useless for seeing what dependencies this package has. But since there
2785: is a GNU configure script in the package, let's hope that it will complain
2786: about everything it needs.
2787:
2788: $ bmake
2789: => Required installed package digest>=20010302: digest-20060826 found
2790: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
2791: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
2792: ===> Patching for nvu-1.0
2793: ===> Creating toolchain wrappers for nvu-1.0
2794: ===> Configuring for nvu-1.0
2795: [...]
2796: configure: error: Perl 5.004 or higher is required.
2797: [...]
2798: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
2799: [...]
2800:
2801: That worked quite well. So I opened the package Makefile in my editor, and
2802: since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
2803: dependencies of the package have changed now, and since a perl wrapper is
2804: automatically installed in the "tools" phase, I need to build the package from
2805: scratch.
2806:
2807: $ bmake clean
2808: ===> Cleaning for nvu-1.0
2809: $ bmake
2810: [...]
2811: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
2812: GNU Make. You will not be able to build Mozilla without GNU Make.
2813: [...]
2814:
2815: So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
2816:
2817: [...]
2818: checking for GTK - version >= 1.2.0... no
2819: *** Could not run GTK test program, checking why...
2820: [...]
2821:
2822: Now to the other dependencies. The first question is: Where is the GTK package
2823: hidden in pkgsrc?
2824:
2825: $ echo ../../*/gtk*
2826: [many packages ...]
2827: $ echo ../../*/gtk
2828: ../../x11/gtk
2829: $ echo ../../*/gtk2
2830: ../../x11/gtk2
2831: $ echo ../../*/gtk2/bui*
2832: ../../x11/gtk2/buildlink3.mk
2833:
2834: The first try was definitely too broad. The second one had exactly one result,
2835: which is very good. But there is one pitfall with GNOME packages. Before GNOME
2836: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
2837: able to continue to use these packages, the GNOME 2 packages were imported as
2838: separate packages, and their names usually have a "2" appended. So I checked
2839: whether this was the case here, and indeed it was.
2840:
2841: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
2842: easy. I just inserted an .include line before the last line of the package
2843: Makefile, so that it now looks like this:
2844:
2845: [...]
2846: .include "../../x11/gtk2/buildlink3.mk"
2847: .include "../../mk/bsd.pkg.mk
2848:
2849: After another bmake clean && bmake, the answer was:
2850:
2851: [...]
2852: checking for gtk-config... /home/roland/pkg/bin/gtk-config
2853: checking for GTK - version >= 1.2.0... no
2854: *** Could not run GTK test program, checking why...
2855: *** The test program failed to compile or link. See the file config.log for the
2856: *** exact error that occured. This usually means GTK was incorrectly installed
2857: *** or that you have moved GTK since it was installed. In the latter case, you
2858: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
2859: configure: error: Test for GTK failed.
2860: [...]
2861:
2862: In this particular case, the assumption that "every package prefers GNOME 2"
2863: had been wrong. The first of the lines above told me that this package really
2864: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
2865: it would have looked for pkg-config instead of gtk-config. So I changed the x11
2866: /gtk2 to x11/gtk in the package Makefile, and tried again.
2867:
2868: [...]
1.59 jnemeth 2869: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\" [...]
1.1 dsieger 2870: In file included from xpidl.c:42:
2871: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
2872: In file included from xpidl.c:42:
2873: xpidl.h:132: error: parse error before "IDL_ns"
2874: [...]
2875:
2876: The package still does not find all of its dependencies. Now the question is:
2877: Which package provides the libIDL/IDL.h header file?
2878:
2879: $ echo ../../*/*idl*
2880: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
2881: $ echo ../../*/*IDL*
2882: ../../net/libIDL
2883:
2884: Let's take the one from the second try. So I included the ../../net/libIDL/
2885: buildlink3.mk file and tried again. But the error didn't change. After digging
2886: through some of the code, I concluded that the build process of the package was
2887: broken and couldn't have ever worked, but since the Mozilla source tree is
2888: quite large, I didn't want to fix it. So I added the following to the package
2889: Makefile and tried again:
2890:
2891: CPPFLAGS+= -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
2892: BUILDLINK_TRANSFORM+= -l:IDL:IDL-2
2893:
2894: The latter line is needed because the package expects the library libIDL.so,
2895: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
2896: that on the fly.
2897:
2898: The next problem was related to a recent change of the FreeType interface. I
2899: looked up in www/seamonkey which patch files were relevant for this issue and
2900: copied them to the patches directory. Then I retried, fixed the patches so that
2901: they applied cleanly and retried again. This time, everything worked.
2902:
1.6 rillig 2903: 10.2.1.3. Installing the package
1.1 dsieger 2904:
2905: $ bmake CHECK_FILES=no install
2906: [...]
2907: $ bmake print-PLIST >PLIST
2908: $ bmake deinstall
2909: $ bmake install
2910:
1.6 rillig 2911: Chapter 11. Package components - files, directories and contents
1.1 dsieger 2912:
2913: Table of Contents
2914:
1.6 rillig 2915: 11.1. Makefile
2916: 11.2. distinfo
2917: 11.3. patches/*
2918:
2919: 11.3.1. Structure of a single patch file
2920: 11.3.2. Creating patch files
2921: 11.3.3. Sources where the patch files come from
2922: 11.3.4. Patching guidelines
2923: 11.3.5. Feedback to the author
2924:
2925: 11.4. Other mandatory files
2926: 11.5. Optional files
2927:
2928: 11.5.1. Files affecting the binary package
2929: 11.5.2. Files affecting the build process
2930: 11.5.3. Files affecting nothing at all
1.1 dsieger 2931:
1.6 rillig 2932: 11.6. work*
2933: 11.7. files/*
1.1 dsieger 2934:
2935: Whenever you're preparing a package, there are a number of files involved which
2936: are described in the following sections.
2937:
1.6 rillig 2938: 11.1. Makefile
1.1 dsieger 2939:
2940: Building, installation and creation of a binary package are all controlled by
2941: the package's Makefile. The Makefile describes various things about a package,
2942: for example from where to get it, how to configure, build, and install it.
2943:
2944: A package Makefile contains several sections that describe the package.
2945:
2946: In the first section there are the following variables, which should appear
2947: exactly in the order given here. The order and grouping of the variables is
2948: mostly historical and has no further meaning.
2949:
2950: * DISTNAME is the basename of the distribution file to be downloaded from the
2951: package's website.
2952:
1.66 asau 2953: * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
2954: it if DISTNAME (which is the default) is not a good name for the package in
2955: pkgsrc or DISTNAME is not provided (no distribution file is required).
2956: Usually it is the pkgsrc directory name together with the version number.
2957: It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
2958: is, it starts with a letter or digit, and contains only letters, digits,
2959: dashes, underscores, dots and plus signs.
1.1 dsieger 2960:
2961: * CATEGORIES is a list of categories which the package fits in. You can
2962: choose any of the top-level directories of pkgsrc for it.
2963:
2964: Currently the following values are available for CATEGORIES. If more than
2965: one is used, they need to be separated by spaces:
2966:
2967: archivers cross geography meta-pkgs security
2968: audio databases graphics misc shells
2969: benchmarks devel ham multimedia sysutils
2970: biology editors inputmethod net textproc
2971: cad emulators lang news time
2972: chat finance mail parallel wm
2973: comms fonts math pkgtools www
2974: converters games mbone print x11
2975:
2976: * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
1.6 rillig 2977: are discussed in detail in Section 17.5, "The fetch phase".
1.1 dsieger 2978:
2979: The second section contains information about separately downloaded patches, if
2980: any.
2981:
2982: * PATCHFILES: Name(s) of additional files that contain distribution patches.
2983: There is no default. pkgsrc will look for them at PATCH_SITES. They will
2984: automatically be uncompressed before patching if the names end with .gz or
2985: .Z.
2986:
2987: * PATCH_SITES: Primary location(s) for distribution patch files (see
1.80 wiz 2988: PATCHFILES above) if not found locally.
2989:
2990: * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
2991: count to help find the correct files to patch. It defaults to -p0.
1.1 dsieger 2992:
2993: The third section contains the following variables.
2994:
2995: * MAINTAINER is the email address of the person who feels responsible for
2996: this package, and who is most likely to look at problems or questions
2997: regarding this package which have been reported with send-pr(1). Other
1.14 jmcneill 2998: developers may contact the MAINTAINER before making changes to the package,
2999: but are not required to do so. When packaging a new program, set MAINTAINER
3000: to yourself. If you really can't maintain the package for future updates,
3001: set it to <pkgsrc-users@NetBSD.org>.
3002:
3003: * OWNER should be used instead of MAINTAINER when you do not want other
3004: developers to update or change the package without contacting you first. A
3005: package Makefile should contain one of MAINTAINER or OWNER, but not both.
1.1 dsieger 3006:
3007: * HOMEPAGE is a URL where users can find more information about the package.
3008:
3009: * COMMENT is a one-line description of the package (should not include the
3010: package name).
3011:
3012: Other variables that affect the build:
3013:
3014: * WRKSRC: The directory where the interesting distribution files of the
3015: package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
3016: most packages.
3017:
3018: If a package doesn't create a subdirectory for itself (most GNU software
3019: does, for instance), but extracts itself in the current directory, you
3020: should set WRKSRC=${WRKDIR}.
3021:
3022: If a package doesn't create a subdirectory with the name of DISTNAME but
3023: some different name, set WRKSRC to point to the proper name in ${WRKDIR},
3024: for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
3025: other examples.
3026:
3027: The name of the working directory created by pkgsrc is taken from the
3028: WRKDIR_BASENAME variable. By default, its value is work. If you want to use
3029: the same pkgsrc tree for building different kinds of binary packages, you
3030: can change the variable according to your needs. Two other variables handle
3031: common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
1.4 rillig 3032: defined in mk.conf, the first component of the host's name is attached to
3033: the directory name. If OBJMACHINE is defined, the platform name is
1.1 dsieger 3034: attached, which might look like work.i386 or work.sparc.
3035:
3036: Please pay attention to the following gotchas:
3037:
3038: * Add MANCOMPRESSED if man pages are installed in compressed form by the
3039: package. For packages using BSD-style makefiles which honor MANZ, there is
3040: MANCOMPRESSED_IF_MANZ.
3041:
3042: * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
3043:
1.6 rillig 3044: * If the package installs any info files, see Section 19.6.7, "Packages
1.1 dsieger 3045: installing info files".
3046:
1.6 rillig 3047: 11.2. distinfo
1.1 dsieger 3048:
3049: The distinfo file contains the message digest, or checksum, of each distfile
3050: needed for the package. This ensures that the distfiles retrieved from the
3051: Internet have not been corrupted during transfer or altered by a malign force
1.108 rillig 3052: to introduce a security hole. To provide maximum security, all distfiles are
3053: protected using three different message digest algorithms (SHA1, RMD160,
3054: SHA512), as well as the file size.
1.1 dsieger 3055:
3056: The distinfo file also contains the checksums for all the patches found in the
1.6 rillig 3057: patches directory (see Section 11.3, "patches/*").
1.1 dsieger 3058:
1.108 rillig 3059: To regenerate the distinfo file, use the make distinfo command.
1.1 dsieger 3060:
3061: Some packages have different sets of distfiles depending on the platform, for
1.24 wiz 3062: example lang/openjdk7. These are kept in the same distinfo file and care should
3063: be taken when upgrading such a package to ensure distfile information is not
3064: lost.
1.1 dsieger 3065:
1.6 rillig 3066: 11.3. patches/*
1.1 dsieger 3067:
1.108 rillig 3068: Some packages don't work out-of-the box on the various platforms that are
3069: supported by pkgsrc. These packages need to be patched to make them work. The
3070: patch files can be found in the patches/ directory.
1.1 dsieger 3071:
3072: In the patch phase, these patches are applied to the files in WRKSRC directory
1.25 wiz 3073: after extracting them, in alphabetic order.
1.1 dsieger 3074:
1.6 rillig 3075: 11.3.1. Structure of a single patch file
1.1 dsieger 3076:
3077: The patch-* files should be in diff -bu format, and apply without a fuzz to
3078: avoid problems. (To force patches to apply with fuzz you can set
3079: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
3080: a single file, and no file should be patched by more than one patch file. This
3081: helps to keep future modifications simple.
3082:
3083: Each patch file is structured as follows: In the first line, there is the RCS
3084: Id of the patch itself. The second line should be empty for aesthetic reasons.
3085: After that, there should be a comment for each change that the patch does.
3086: There are a number of standard cases:
3087:
3088: * Patches for commonly known vulnerabilities should mention the vulnerability
3089: ID (CAN, CVE).
3090:
3091: * Patches that change source code should mention the platform and other
3092: environment (for example, the compiler) that the patch is needed for.
3093:
1.108 rillig 3094: The patch should be commented so that any developer who knows the code of the
3095: application can make some use of the patch. Special care should be taken for
3096: the upstream developers, since we generally want that they accept our patches,
3097: so we have less work in the future.
1.1 dsieger 3098:
1.6 rillig 3099: 11.3.2. Creating patch files
1.1 dsieger 3100:
3101: One important thing to mention is to pay attention that no RCS IDs get stored
3102: in the patch files, as these will cause problems when later checked into the
3103: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
3104: avoid these problems.
3105:
3106: For even more automation, we recommend using mkpatches from the same package to
3107: make a whole set of patches. You just have to backup files before you edit them
1.25 wiz 3108: to filename.orig, e.g. with cp -p filename filename.orig or, easier, by using
1.1 dsieger 3109: pkgvi again from the same package. If you upgrade a package this way, you can
1.25 wiz 3110: easily compare the new set of patches with the previously existing one with
3111: patchdiff. The files in patches are replaced by new files, so carefully check
3112: if you want to take all the changes.
1.1 dsieger 3113:
3114: When you have finished a package, remember to generate the checksums for the
1.6 rillig 3115: patch files by using the make makepatchsum command, see Section 11.2,
1.1 dsieger 3116: "distinfo".
3117:
3118: When adding a patch that corrects a problem in the distfile (rather than e.g.
3119: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
3120: report to the maintainer. This benefits non-pkgsrc users of the package, and
3121: usually makes it possible to remove the patch in future version.
3122:
1.25 wiz 3123: The file names of the patch files are usually of the form patch-
3124: path_to_file__with__underscores.c. Many packages still use the previous
3125: convention patch-[a-z][a-z], but new patches should be of the form containing
3126: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
3127: automatically.
1.2 rillig 3128:
1.6 rillig 3129: 11.3.3. Sources where the patch files come from
1.1 dsieger 3130:
3131: If you want to share patches between multiple packages in pkgsrc, e.g. because
3132: they use the same distfiles, set PATCHDIR to the path where the patch files can
3133: be found, e.g.:
3134:
3135: PATCHDIR= ${.CURDIR}/../xemacs/patches
3136:
3137: Patch files that are distributed by the author or other maintainers can be
3138: listed in PATCHFILES.
3139:
3140: If it is desired to store any patches that should not be committed into pkgsrc,
3141: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
3142: directory tree there is expected to have the same "category/package" structure
3143: as pkgsrc, and patches are expected to be stored inside these dirs (also known
3144: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
3145: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
3146: files in the named directory are expected to be patch files, and they are
3147: applied after pkgsrc patches are applied.
3148:
1.6 rillig 3149: 11.3.4. Patching guidelines
1.1 dsieger 3150:
3151: When fixing a portability issue in the code do not use preprocessor magic to
3152: check for the current operating system nor platform. Doing so hurts portability
3153: to other platforms because the OS-specific details are not abstracted
3154: appropriately.
3155:
3156: The general rule to follow is: instead of checking for the operating system the
3157: application is being built on, check for the specific features you need. For
3158: example, instead of assuming that kqueue is available under NetBSD and using
3159: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
3160: kqueue itself ? yes, this generally involves patching the configure script.
3161: There is absolutely nothing that prevents some OSes from adopting interfaces
3162: from other OSes (e.g. Linux implementing kqueue), something that the above
3163: checks cannot take into account.
3164:
3165: Of course, checking for features generally involves more work on the
3166: developer's side, but the resulting changes are cleaner and there are chances
3167: they will work on many other platforms. Not to mention that there are higher
3168: chances of being later integrated into the mainstream sources. Remember: It
3169: doesn't work unless it is right!
3170:
3171: Some typical examples:
3172:
1.6 rillig 3173: Table 11.1. Patching examples
1.1 dsieger 3174:
3175: +-------------------------------------------------------------------------------------------+
3176: | Where | Incorrect | Correct |
3177: |---------+--------------------------+------------------------------------------------------|
3178: | |case ${target_os} in | |
3179: |configure|netbsd*) have_kvm=yes ;; |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
3180: |script |*) have_kvm=no ;; | |
3181: | |esac | |
3182: |---------+--------------------------+------------------------------------------------------|
1.2 rillig 3183: |C source |#if defined(__NetBSD__) |#if defined(HAVE_SYS_EVENT_H) |
3184: |file |# include <sys/event.h> |# include <sys/event.h> |
3185: | |#endif |#endif |
1.1 dsieger 3186: |---------+--------------------------+------------------------------------------------------|
3187: | |int |int |
3188: | |monitor_file(...) |monitor_file(...) |
3189: | |{ |{ |
3190: | |#if defined(__NetBSD__) |#if defined(HAVE_KQUEUE) |
3191: |C source | int fd = kqueue();| int fd = kqueue(); |
3192: |file | ... | ... |
3193: | |#else |#else |
3194: | | ... | ... |
3195: | |#endif |#endif |
3196: | |} |} |
3197: +-------------------------------------------------------------------------------------------+
3198:
3199:
3200: For more information, please read the Making packager-friendly software article
3201: (part 1, part 2). It summarizes multiple details on how to make software easier
3202: to package; all the suggestions in it were collected from our experience in
3203: pkgsrc work, so they are possibly helpful when creating patches too.
3204:
1.6 rillig 3205: 11.3.5. Feedback to the author
1.1 dsieger 3206:
3207: Always, always, always feed back any portability fixes or improvements you do
3208: to a package to the mainstream developers. This is the only way to get their
3209: attention on portability issues and to ensure that future versions can be built
3210: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
3211: get the fixes straight from the packaged code.
3212:
3213: This generally involves cleaning up the patches (because sometimes the patches
1.41 wiz 3214: that are added to pkgsrc are quick hacks), filing bug reports in the
1.1 dsieger 3215: appropriate trackers for the projects and working with the mainstream authors
3216: to accept your changes. It is extremely important that you do it so that the
3217: packages in pkgsrc are kept simple and thus further changes can be done without
3218: much hassle.
3219:
1.25 wiz 3220: When you have done this, please add a URL to the upstream bug report to the
3221: patch comment.
3222:
1.1 dsieger 3223: Support the idea of free software!
3224:
1.6 rillig 3225: 11.4. Other mandatory files
1.1 dsieger 3226:
3227: DESCR
3228:
3229: A multi-line description of the piece of software. This should include any
3230: credits where they are due. Please bear in mind that others do not share
3231: your sense of humour (or spelling idiosyncrasies), and that others will
3232: read everything that you write here.
3233:
3234: PLIST
3235:
3236: This file governs the files that are installed on your system: all the
3237: binaries, manual pages, etc. There are other directives which may be
3238: entered in this file, to control the creation and deletion of directories,
1.6 rillig 3239: and the location of inserted files. See Chapter 13, PLIST issues for more
1.1 dsieger 3240: information.
3241:
1.6 rillig 3242: 11.5. Optional files
1.1 dsieger 3243:
1.6 rillig 3244: 11.5.1. Files affecting the binary package
1.1 dsieger 3245:
3246: INSTALL
3247:
3248: This shell script is invoked twice by pkg_add(1). First time after package
3249: extraction and before files are moved in place, the second time after the
3250: files to install are moved in place. This can be used to do any custom
3251: procedures not possible with @exec commands in PLIST. See pkg_add(1) and
1.6 rillig 3252: pkg_create(1) for more information. See also Section 15.1, "Files and
1.29 wiz 3253: directories outside the installation prefix". Please note that you can
3254: modify variables in it easily by using FILES_SUBST in the package's
3255: Makefile:
3256:
3257: FILES_SUBST+= SOMEVAR="somevalue"
3258:
3259: replaces "@SOMEVAR@" with "somevalue" in the INSTALL. By default,
3260: substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
3261: few others, type make help topic=FILES_SUBST for a complete list.
1.1 dsieger 3262:
3263: DEINSTALL
3264:
3265: This script is executed before and after any files are removed. It is this
3266: script's responsibility to clean up any additional messy details around the
3267: package's installation, since all pkg_delete knows is how to delete the
3268: files created in the original distribution. See pkg_delete(1) and
1.29 wiz 3269: pkg_create(1) for more information. The same methods to replace variables
3270: can be used as for the INSTALL file.
1.1 dsieger 3271:
3272: MESSAGE
3273:
3274: This file is displayed after installation of the package. Useful for things
3275: like legal notices on almost-free software and hints for updating config
3276: files after installing modules for apache, PHP etc. Please note that you
3277: can modify variables in it easily by using MESSAGE_SUBST in the package's
3278: Makefile:
3279:
3280: MESSAGE_SUBST+= SOMEVAR="somevalue"
3281:
3282: replaces "${SOMEVAR}" with "somevalue" in MESSAGE. By default, substitution
1.99 sevan 3283: is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
1.16 jnemeth 3284: PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1 dsieger 3285:
3286: You can display a different or additional files by setting the MESSAGE_SRC
3287: variable. Its default is MESSAGE, if the file exists.
3288:
3289: ALTERNATIVES
3290:
1.66 asau 3291: This file is used by the alternatives framework. It creates, configures,
3292: and destroys generic wrappers used to run programs with similar interfaces.
3293: See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
3294: information.
3295:
3296: Each line of the file contains two filenames, first the wrapper and then
3297: the alternative provided by the package. Both paths are relative to PREFIX.
1.1 dsieger 3298:
1.6 rillig 3299: 11.5.2. Files affecting the build process
1.1 dsieger 3300:
3301: Makefile.common
3302:
3303: This file contains arbitrary things that could also go into a Makefile, but
3304: its purpose is to be used by more than one package. This file should only
3305: be used when the packages that will use the file are known in advance. For
3306: other purposes it is often better to write a *.mk file and give it a good
3307: name that describes what it does.
3308:
3309: buildlink3.mk
3310:
3311: This file contains the dependency information for the buildlink3 framework
1.6 rillig 3312: (see Chapter 14, Buildlink methodology).
1.1 dsieger 3313:
3314: hacks.mk
3315:
3316: This file contains workarounds for compiler bugs and similar things. It is
3317: included automatically by the pkgsrc infrastructure, so you don't need an
3318: extra .include line for it.
3319:
3320: options.mk
3321:
3322: This file contains the code for the package-specific options (see
1.6 rillig 3323: Chapter 16, Options handling) that can be selected by the user. If a
1.1 dsieger 3324: package has only one or two options, it is equally acceptable to put the
3325: code directly into the Makefile.
3326:
1.6 rillig 3327: 11.5.3. Files affecting nothing at all
1.1 dsieger 3328:
3329: README*
3330:
3331: These files do not take place in the creation of a package and thus are
3332: purely informative to the package developer.
3333:
3334: TODO
3335:
3336: This file contains things that need to be done to make the package even
3337: better.
3338:
1.6 rillig 3339: 11.6. work*
1.1 dsieger 3340:
3341: When you type make, the distribution files are unpacked into the directory
3342: denoted by WRKDIR. It can be removed by running make clean. Besides the
3343: sources, this directory is also used to keep various timestamp files. The
3344: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
3345: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
3346:
1.6 rillig 3347: 11.7. files/*
1.1 dsieger 3348:
3349: If you have any files that you wish to be placed in the package prior to
3350: configuration or building, you could place these files here and use a ${CP}
3351: command in the "pre-configure" target to achieve this. Alternatively, you could
3352: simply diff the file against /dev/null and use the patch mechanism to manage
3353: the creation of this file.
3354:
3355: If you want to share files in this way with other packages, set the FILESDIR
3356: variable to point to the other package's files directory, e.g.:
3357:
3358: FILESDIR=${.CURDIR}/../xemacs/files
3359:
1.6 rillig 3360: Chapter 12. Programming in Makefiles
1.1 dsieger 3361:
3362: Table of Contents
3363:
1.6 rillig 3364: 12.1. Caveats
3365: 12.2. Makefile variables
1.1 dsieger 3366:
1.6 rillig 3367: 12.2.1. Naming conventions
1.1 dsieger 3368:
1.6 rillig 3369: 12.3. Code snippets
1.1 dsieger 3370:
1.6 rillig 3371: 12.3.1. Adding things to a list
1.108 rillig 3372: 12.3.2. Echoing a string exacty as-is
3373: 12.3.3. Passing CFLAGS to GNU configure scripts
3374: 12.3.4. Handling possibly empty variables
1.1 dsieger 3375:
3376: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
3377: part of the pkgsrc system. Using the make(1) system as a programming language
3378: for a big system like pkgsrc requires some discipline to keep the code correct
3379: and understandable.
3380:
3381: The basic ingredients for Makefile programming are variables (which are
3382: actually macros) and shell commands. Among these shell commands may even be
3383: more complex ones like awk(1) programs. To make sure that every shell command
3384: runs as intended it is necessary to quote all variables correctly when they are
3385: used.
3386:
3387: This chapter describes some patterns, that appear quite often in Makefiles,
3388: including the pitfalls that come along with them.
3389:
1.6 rillig 3390: 12.1. Caveats
1.1 dsieger 3391:
3392: * When you are creating a file as a target of a rule, always write the data
3393: to a temporary file first and finally rename that file. Otherwise there
3394: might occur an error in the middle of generating the file, and when the
3395: user runs make(1) for the second time, the file exists and will not be
3396: regenerated properly. Example:
3397:
3398: wrong:
3399: @echo "line 1" > ${.TARGET}
3400: @echo "line 2" >> ${.TARGET}
3401: @false
3402:
3403: correct:
3404: @echo "line 1" > ${.TARGET}.tmp
3405: @echo "line 2" >> ${.TARGET}.tmp
3406: @false
3407: @mv ${.TARGET}.tmp ${.TARGET}
3408:
3409: When you run make wrong twice, the file wrong will exist, although there
3410: was an error message in the first run. On the other hand, running make
3411: correct gives an error message twice, as expected.
3412:
3413: You might remember that make(1) sometimes removes ${.TARGET} in case of
3414: error, but this only happens when it is interrupted, for example by
3415: pressing ^C. This does not happen when one of the commands fails (like
3416: false(1) above).
3417:
1.6 rillig 3418: 12.2. Makefile variables
1.1 dsieger 3419:
3420: Makefile variables contain strings that can be processed using the five
3421: operators ``='', ``+='', ``?='', ``:='', and ``!='', which are described in the
3422: make(1) man page.
3423:
3424: When a variable's value is parsed from a Makefile, the hash character ``#'' and
3425: the backslash character ``\'' are handled specially. If a backslash is followed
3426: by a newline, any whitespace immediately in front of the backslash, the
3427: backslash, the newline, and any whitespace immediately behind the newline are
3428: replaced with a single space. A backslash character and an immediately
3429: following hash character are replaced with a single hash character. Otherwise,
3430: the backslash is passed as is. In a variable assignment, any hash character
3431: that is not preceded by a backslash starts a comment that continues upto the
3432: end of the logical line.
3433:
1.108 rillig 3434: The evaluation of variables either happens immediately or lazy. It happens
3435: immediately when the variable occurs on the right-hand side of the ``:='' or
3436: the ``!='' operator, in a .if condition or a .for loop. In the other cases, it
3437: is evaluated lazily.
1.1 dsieger 3438:
3439: Some of the modifiers split the string into words and then operate on the
3440: words, others operate on the string as a whole. When a string is split into
1.108 rillig 3441: words, it is split like in sh(1).
1.1 dsieger 3442:
3443: There are several types of variables that should be handled differently.
3444: Strings and two types of lists.
3445:
3446: * Strings can contain arbitrary characters. Nevertheless, you should restrict
3447: yourself to only using printable characters. Examples are PREFIX and
3448: COMMENT.
3449:
3450: * Internal lists are lists that are never exported to any shell command.
3451: Their elements are separated by whitespace. Therefore, the elements
3452: themselves cannot have embedded whitespace. Any other characters are
3453: allowed. Internal lists can be used in .for loops. Examples are DEPENDS and
3454: BUILD_DEPENDS.
3455:
3456: * External lists are lists that may be exported to a shell command. Their
3457: elements can contain any characters, including whitespace. That's why they
3458: cannot be used in .for loops. Examples are DISTFILES and MASTER_SITES.
3459:
1.6 rillig 3460: 12.2.1. Naming conventions
1.1 dsieger 3461:
3462: * All variable names starting with an underscore are reserved for use by the
3463: pkgsrc infrastructure. They shall not be used by package Makefiles.
3464:
3465: * In .for loops you should use lowercase variable names for the iteration
3466: variables.
3467:
3468: * All list variables should have a ``plural'' name, e.g. PKG_OPTIONS or
3469: DISTFILES.
3470:
1.6 rillig 3471: 12.3. Code snippets
1.1 dsieger 3472:
1.108 rillig 3473: 12.3.1. Adding things to a list
3474:
3475: When adding a string that possibly contains whitespace or quotes to a list
3476: (example 1), it must be quoted using the :Q modifier.
1.1 dsieger 3477:
1.108 rillig 3478: When adding another list to a list (example 2), it must not be quoted, since
3479: its elements are already quoted.
1.1 dsieger 3480:
1.108 rillig 3481: STRING= foo * bar `date`
3482: LIST= # empty
3483: ANOTHER_LIST= a=b c=d
1.1 dsieger 3484:
1.108 rillig 3485: LIST+= ${STRING:Q} # 1
3486: LIST+= ${ANOTHER_LIST} # 2
1.1 dsieger 3487:
1.108 rillig 3488: 12.3.2. Echoing a string exacty as-is
1.1 dsieger 3489:
1.108 rillig 3490: Echoing a string containing special characters needs special work.
1.1 dsieger 3491:
3492: STRING= foo bar < > * `date` $$HOME ' "
1.108 rillig 3493: EXAMPLE_ENV= string=${STRING:Q} x=multiple\ quoted\ words
1.1 dsieger 3494:
3495: all:
3496: echo ${STRING} # 1
1.108 rillig 3497: echo ${STRING:Q} # 2
3498: printf '%s\n' ${STRING:Q}'' # 3
3499: env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"' # 4
1.1 dsieger 3500:
3501: Example 1 leads to a syntax error in the shell, as the characters are just
3502: copied.
3503:
1.108 rillig 3504: Example 2 quotes the string so that the shell interprets it correctly. But the
3505: echo command may additionally interpret strings with a leading dash or those
3506: containing backslashes.
3507:
3508: Example 3 can handle arbitrary strings, since printf(1) only interprets the
3509: format string, but not the next argument.
3510:
3511: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
3512: has already been done when adding elements to the list.
3513:
3514: 12.3.3. Passing CFLAGS to GNU configure scripts
3515:
3516: When passing CFLAGS or similar variables to a GNU-style configure script
3517: (especially those that call other configure scripts), it must not have leading
3518: or trailing whitespace, since otherwise the configure script gets confused. To
3519: trim leading and trailing whitespace, use the :M modifier, as in the following
3520: example:
3521:
3522: CPPFLAGS= # empty
3523: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX}\"
3524: CPPFLAGS+= ${MY_CPPFLAGS}
3525:
3526: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
3527:
3528: all:
3529: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
3530: echo x${CONFIGURE_ARGS:Q}x # properly trimmed
3531:
3532: In this example, CPPFLAGS has both leading and trailing whitespace because the
3533: += operator always adds a space.
3534:
3535: 12.3.4. Handling possibly empty variables
3536:
3537: When a possibly empty variable is used in a shell program, it may lead to a
3538: syntax error.
3539:
3540: EGFILES= # empty
3541:
3542: install-examples: # produces a syntax error in the shell
3543: for egfile in ${EGFILES}; do \
3544: echo "Installing $$egfile"; \
3545: done
3546:
3547: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
3548: with an empty string by make(1). To fix this syntax error, use one of the
3549: snippets below.
3550:
3551: EMPTY= # empty
3552:
3553: install-examples:
3554: for egfile in ${EGFILES} ""; do \
3555: [ -n "$$egfile" ] || continue; \
3556: echo "Installing $$egfile"; \
3557: done
3558:
3559: In this case, an empty string is appended to the iteration list (to prevent the
3560: syntax error) and filtered out later.
1.1 dsieger 3561:
1.108 rillig 3562: EGFILES= # empty
1.1 dsieger 3563:
1.108 rillig 3564: install-examples:
3565: .for egfile in ${EGFILES}
3566: echo "Installing ${egfile}"
3567: .endfor
3568:
3569: This variant only works when EGFILES does not contain filenames with spaces,
3570: since the .for loop splits on simple whitespace.
3571:
3572: To have a shell command test whether a make variable is empty, use the
3573: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1 dsieger 3574:
1.6 rillig 3575: Chapter 13. PLIST issues
1.1 dsieger 3576:
3577: Table of Contents
3578:
1.6 rillig 3579: 13.1. RCS ID
3580: 13.2. Semi-automatic PLIST generation
3581: 13.3. Tweaking output of make print-PLIST
3582: 13.4. Variable substitution in PLIST
3583: 13.5. Man page compression
3584: 13.6. Changing PLIST source with PLIST_SRC
3585: 13.7. Platform-specific and differing PLISTs
1.86 wiz 3586: 13.8. Build-specific PLISTs
3587: 13.9. Sharing directories between packages
1.1 dsieger 3588:
3589: The PLIST file contains a package's "packing list", i.e. a list of files that
3590: belong to the package (relative to the ${PREFIX} directory it's been installed
3591: in) plus some additional statements - see the pkg_create(1) man page for a full
3592: list. This chapter addresses some issues that need attention when dealing with
3593: the PLIST file (or files, see below!).
3594:
1.6 rillig 3595: 13.1. RCS ID
1.1 dsieger 3596:
3597: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
3598:
1.2 rillig 3599: @comment $NetBSD$
1.1 dsieger 3600:
1.6 rillig 3601: 13.2. Semi-automatic PLIST generation
1.1 dsieger 3602:
3603: You can use the make print-PLIST command to output a PLIST that matches any new
1.6 rillig 3604: files since the package was extracted. See Section 17.17, "Other helpful
1.1 dsieger 3605: targets" for more information on this target.
3606:
1.6 rillig 3607: 13.3. Tweaking output of make print-PLIST
1.1 dsieger 3608:
3609: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
3610: used to filter the output of print-PLIST. You can append any chunk of AWK
3611: scripting you like to it, but be careful with quoting.
3612:
3613: For example, to get all files inside the libdata/foo directory removed from the
3614: resulting PLIST:
3615:
3616: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
3617:
1.6 rillig 3618: 13.4. Variable substitution in PLIST
1.1 dsieger 3619:
3620: A number of variables are substituted automatically in PLISTs when a package is
3621: installed on a system. This includes the following variables:
3622:
3623: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
3624:
3625: Some packages like emacs and perl embed information about which
3626: architecture they were built on into the pathnames where they install their
3627: files. To handle this case, PLIST will be preprocessed before actually
3628: used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
3629: gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
3630: PLIST somewhere - use this on packages that have GNU autoconf-created
3631: configure scripts.
3632:
3633: Legacy note
3634:
3635: There used to be a symbol "$ARCH" that was replaced by the output of uname
3636: -m, but that's no longer supported and has been removed.
3637:
3638: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
3639:
3640: Some packages want to embed the OS name and version into some paths. To do
3641: this, use these variables in the PLIST:
3642:
1.42 asau 3643: + ${OPSYS} - output of "uname -s"
1.1 dsieger 3644:
1.42 asau 3645: + ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
1.1 dsieger 3646:
1.42 asau 3647: + ${OS_VERSION} - "uname -r"
1.1 dsieger 3648:
1.88 tnn 3649: For a list of values which are replaced by default, the output of make help
3650: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
3651: PLIST_SUBST should help.
1.1 dsieger 3652:
3653: If you want to change other variables not listed above, you can add variables
3654: and their expansions to this variable in the following way, similar to
1.6 rillig 3655: MESSAGE_SUBST (see Section 11.5, "Optional files"):
1.1 dsieger 3656:
3657: PLIST_SUBST+= SOMEVAR="somevalue"
3658:
3659: This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
3660:
1.19 snj 3661: The PLIST_VARS variable can be used to simplify the common case of
3662: conditionally including some PLIST entries. It can be done by adding
3663: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
3664: entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
3665: either """" or ""@comment "". For example, in Makefile:
1.18 mishka 3666:
3667: PLIST_VARS+= foo
3668: .if condition
3669: PLIST.foo= yes
3670: .else
3671:
3672: And then in PLIST:
3673:
3674: @comment $NetBSD$
3675: bin/bar
3676: man/man1/bar.1
3677: ${PLIST.foo}bin/foo
3678: ${PLIST.foo}man/man1/foo.1
3679: ${PLIST.foo}share/bar/foo.data
3680:
1.6 rillig 3681: 13.5. Man page compression
1.1 dsieger 3682:
3683: Man pages should be installed in compressed form if MANZ is set (in
3684: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
3685: suffix ".gz" is appended/removed automatically for man pages according to MANZ
3686: and MANCOMPRESSED being set or not, see above for details. This modification of
3687: the PLIST file is done on a copy of it, not PLIST itself.
3688:
1.6 rillig 3689: 13.6. Changing PLIST source with PLIST_SRC
1.1 dsieger 3690:
3691: To use one or more files as source for the PLIST used in generating the binary
3692: package, set the variable PLIST_SRC to the names of that file(s). The files are
3693: later concatenated using cat(1), and the order of things is important. The
3694: default for PLIST_SRC is ${PKGDIR}/PLIST.
3695:
1.6 rillig 3696: 13.7. Platform-specific and differing PLISTs
1.1 dsieger 3697:
3698: Some packages decide to install a different set of files based on the operating
3699: system being used. These differences can be automatically handled by using the
3700: following files:
3701:
3702: * PLIST.common
3703:
3704: * PLIST.${OPSYS}
3705:
3706: * PLIST.${MACHINE_ARCH}
3707:
3708: * PLIST.${OPSYS}-${MACHINE_ARCH}
3709:
3710: * PLIST.common_end
3711:
1.86 wiz 3712: 13.8. Build-specific PLISTs
3713:
3714: Some packages decide to generate hard-to-guess file names during installation
3715: that are hard to wire down.
3716:
3717: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
3718: (with a semicolon) that will output PLIST entries which will be appended to the
3719: PLIST
3720:
3721: You can find one example in editors/xemacs:
3722:
1.111 sevan 3723: GENERATE_PLIST+= ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.86 wiz 3724:
3725: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
3726:
3727: 13.9. Sharing directories between packages
1.1 dsieger 3728:
3729: A "shared directory" is a directory where multiple (and unrelated) packages
1.23 jakllsch 3730: install files. These directories were problematic because you had to add
1.1 dsieger 3731: special tricks in the PLIST to conditionally remove them, or have some
3732: centralized package handle them.
3733:
1.23 jakllsch 3734: In pkgsrc, it is now easy: Each package should create directories and install
3735: files as needed; pkg_delete will remove any directories left empty after
3736: uninstalling a package.
1.1 dsieger 3737:
1.23 jakllsch 3738: If a package needs an empty directory to work, create the directory during
3739: installation as usual, and also add an entry to the PLIST:
1.1 dsieger 3740:
1.23 jakllsch 3741: @pkgdir path/to/empty/directory
1.1 dsieger 3742:
1.86 wiz 3743: or take a look at MAKE_DIRS and OWN_DIRS.
3744:
1.6 rillig 3745: Chapter 14. Buildlink methodology
1.1 dsieger 3746:
3747: Table of Contents
3748:
1.6 rillig 3749: 14.1. Converting packages to use buildlink3
3750: 14.2. Writing buildlink3.mk files
1.1 dsieger 3751:
1.6 rillig 3752: 14.2.1. Anatomy of a buildlink3.mk file
1.27 wiz 3753: 14.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
3754: buildlink3.mk files
1.1 dsieger 3755:
1.6 rillig 3756: 14.3. Writing builtin.mk files
1.1 dsieger 3757:
1.6 rillig 3758: 14.3.1. Anatomy of a builtin.mk file
3759: 14.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 3760:
3761: Buildlink is a framework in pkgsrc that controls what headers and libraries are
3762: seen by a package's configure and build processes. This is implemented in a two
3763: step process:
3764:
3765: 1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
3766: default is a subdirectory of WRKDIR.
3767:
3768: 2. Create wrapper scripts that are used in place of the normal compiler tools
3769: that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
3770: references to BUILDLINK_DIR. The wrapper scripts also make native compiler
3771: on some operating systems look like GCC, so that packages that expect GCC
3772: won't require modifications to build with those native compilers.
3773:
3774: This normalizes the environment in which a package is built so that the package
3775: may be built consistently despite what other software may be installed. Please
3776: note that the normal system header and library paths, e.g. /usr/include, /usr/
3777: lib, etc., are always searched -- buildlink3 is designed to insulate the
3778: package build from non-system-supplied software.
3779:
1.6 rillig 3780: 14.1. Converting packages to use buildlink3
1.1 dsieger 3781:
1.25 wiz 3782: The process of converting packages to use the buildlink3 framework ("bl3ifying"
3783: ) is fairly straightforward. The things to keep in mind are:
1.1 dsieger 3784:
3785: 1. Ensure that the build always calls the wrapper scripts instead of the
3786: actual toolchain. Some packages are tricky, and the only way to know for
3787: sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
3788: invoked.
3789:
3790: 2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
3791: standalone shells, etc., because the code to symlink files into $
3792: {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
3793:
3794: 3. Remember that only the buildlink3.mk files that you list in a package's
3795: Makefile are added as dependencies for that package.
3796:
3797: If a dependency on a particular package is required for its libraries and
3798: headers, then we replace:
3799:
3800: DEPENDS+= foo>=1.1.0:../../category/foo
3801:
3802: with
3803:
3804: .include "../../category/foo/buildlink3.mk"
3805:
3806: The buildlink3.mk files usually define the required dependencies. If you need a
3807: newer version of the dependency when using buildlink3.mk files, then you can
3808: define it in your Makefile; for example:
3809:
3810: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
3811: .include "../../category/foo/buildlink3.mk"
3812:
3813: There are several buildlink3.mk files in pkgsrc/mk that handle special package
3814: issues:
3815:
3816: * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
3817: implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
3818:
3819: * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
3820: this will take care to install the devel/ncurses package.
3821:
3822: * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
3823: a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
3824: implementation.
3825:
3826: * motif.buildlink3.mk checks for a system-provided Motif installation or adds
1.46 obache 3827: a dependency on x11/lesstif, x11/motif or x11/openmotif. The user can set
3828: MOTIF_TYPE to "dt", "lesstif", "motif" or "openmotif" to choose which Motif
3829: version will be used.
1.1 dsieger 3830:
1.57 wiz 3831: * readline.buildlink3.mk checks for a system-provided GNU readline or
3832: editline (libedit) installation, or adds a dependency on devel/readline,
3833: devel/editline. The user can set READLINE_DEFAULT to choose readline
1.56 ryoon 3834: implementation. If your package really needs GNU readline library, its
3835: Makefile should include devel/readline/buildlink3.mk instead of
3836: readline.buildlink3.mk.
3837:
1.1 dsieger 3838: * oss.buildlink3.mk defines several variables that may be used by packages
3839: that use the Open Sound System (OSS) API.
3840:
1.36 wiz 3841: * pgsql.buildlink3.mk will accept any of the Postgres versions in the
3842: variable PGSQL_VERSIONS_ACCEPTED and default to the version
3843: PGSQL_VERSION_DEFAULT. See the file for more information.
1.1 dsieger 3844:
3845: * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
3846: pthreads or adds a dependency on devel/pth as needed.
3847:
3848: * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
3849: widgets library.
3850:
3851: The comments in those buildlink3.mk files provide a more complete description
3852: of how to use them properly.
3853:
1.6 rillig 3854: 14.2. Writing buildlink3.mk files
1.1 dsieger 3855:
3856: A package's buildlink3.mk file is included by Makefiles to indicate the need to
3857: compile and link against header files and libraries provided by the package. A
3858: buildlink3.mk file should always provide enough information to add the correct
3859: type of dependency relationship and include any other buildlink3.mk files that
3860: it needs to find headers and libraries that it needs in turn.
3861:
3862: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
3863: pkgtools/createbuildlink package is highly recommended. For most packages, the
3864: following command will generate a good starting point for buildlink3.mk files:
3865:
3866: % cd pkgsrc/category/pkgdir
3867: % createbuildlink >buildlink3.mk
3868:
3869:
1.6 rillig 3870: 14.2.1. Anatomy of a buildlink3.mk file
1.1 dsieger 3871:
3872: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
3873: tiff:
3874:
1.19 snj 3875: # $NetBSD: buildlink3.mk,v 1.16 2009/03/20 19:24:45 joerg Exp $
1.1 dsieger 3876:
1.19 snj 3877: BUILDLINK_TREE+= tiff
1.1 dsieger 3878:
1.19 snj 3879: .if !defined(TIFF_BUILDLINK3_MK)
3880: TIFF_BUILDLINK3_MK:=
1.1 dsieger 3881:
1.19 snj 3882: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
3883: BUILDLINK_ABI_DEPENDS.tiff+= tiff>=3.7.2nb1
1.1 dsieger 3884: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
3885:
3886: .include "../../devel/zlib/buildlink3.mk"
3887: .include "../../graphics/jpeg/buildlink3.mk"
1.19 snj 3888: .endif # TIFF_BUILDLINK3_MK
1.1 dsieger 3889:
1.19 snj 3890: BUILDLINK_TREE+= -tiff
1.1 dsieger 3891:
1.19 snj 3892: The header and footer manipulate BUILDLINK_TREE, which is common across all
3893: buildlink3.mk files and is used to track the dependency tree.
1.1 dsieger 3894:
1.19 snj 3895: The main section is protected from multiple inclusion and controls how the
1.1 dsieger 3896: dependency on pkg is added. Several important variables are set in the section:
3897:
3898: * BUILDLINK_API_DEPENDS.pkg is the actual dependency recorded in the
3899: installed package; this should always be set using += to ensure that we're
3900: appending to any pre-existing list of values. This variable should be set
1.27 wiz 3901: to the first version of the package that had an backwards-incompatible API
3902: change.
1.1 dsieger 3903:
3904: * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
3905:
3906: * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
3907: BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
3908: is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
3909: full dependency is used.
3910:
3911: * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
3912: of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
3913: library search paths. These default to "include" and "lib" respectively.
3914:
3915: * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
3916: to add to CPPFLAGS, which are passed on to the configure and build phases.
3917: The "-I" option should be avoided and instead be handled using
3918: BUILDLINK_INCDIRS.pkg as above.
3919:
3920: The following variables are all optionally defined within this second section
3921: (protected against multiple inclusion) and control which package files are
3922: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
3923: symlinking:
3924:
3925: * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
3926: {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
3927: *.h.
3928:
3929: * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
3930: to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
3931: resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
3932: takes the +CONTENTS of a pkg and filters it through $
3933: {BUILDLINK_CONTENTS_FILTER.pkg}.
3934:
3935: * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
3936: filters +CONTENTS input into a list of files relative to $
1.84 wiz 3937: {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
3938: outputs the contents of the include and lib directories in the package
3939: +CONTENTS.
1.1 dsieger 3940:
3941: * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
3942: used to transform the name of the source filename into a destination
3943: filename, e.g. -e "s|/curses.h|/ncurses.h|g".
3944:
1.19 snj 3945: This section can additionally include any buildlink3.mk needed for pkg's
3946: library dependencies. Including these buildlink3.mk files means that the
3947: headers and libraries for these dependencies are also symlinked into $
3948: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
3949: are only added for directly include buildlink3.mk files.
1.1 dsieger 3950:
1.48 wiz 3951: When providing a buildlink3.mk and including other buildlink3.mk files in it,
1.51 wiz 3952: please only add necessary ones, i.e., those whose libraries or header files are
1.48 wiz 3953: automatically exposed when the package is use.
3954:
3955: In particular, if only an executable (bin/foo) is linked against a library,
3956: that library does not need to be propagated in the buildlink3.mk file.
3957:
3958: The following steps should help you decide if a buildlink3.mk file needs to be
3959: included:
3960:
3961: * Look at the installed header files: What headers do they include? The
3962: packages providing these files must be buildlinked.
3963:
1.50 wiz 3964: * Run ldd on all installed libraries and look against what other libraries
3965: they link. Some of the packages providing these probably need to be
3966: buildlinked; however, it's not automatic, since e.g. GTK on some systems
3967: pulls in the X libraries, so they will show up in the ldd output, while on
1.51 wiz 3968: others (like OS X) it won't. ldd output can thus only be used as a hint.
1.50 wiz 3969:
1.27 wiz 3970: 14.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
3971: buildlink3.mk files
1.1 dsieger 3972:
1.27 wiz 3973: These two variables differ in that one describes source compatibility (API) and
3974: the other binary compatibility (ABI). The difference is that a change in the
3975: API breaks compilation of programs while changes in the ABI stop compiled
3976: programs from running.
3977:
1.28 wiz 3978: Changes to the BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk file
3979: happen very rarely. One possible reason is that all packages depending on this
3980: already need a newer version. In case it is bumped see the description below.
1.27 wiz 3981:
3982: The most common example of an ABI change is that the major version of a shared
3983: library is increased. In this case, BUILDLINK_ABI_DEPENDS.pkg should be
3984: adjusted to require at least the new package version. Then the packages that
3985: depend on this package need their PKGREVISIONs increased and, if they have
3986: buildlink3.mk files, their BUILDLINK_ABI_DEPENDS.pkg adjusted, too. This is
3987: needed so pkgsrc will require the correct package dependency and not settle for
3988: an older one when building the source.
1.1 dsieger 3989:
1.108 rillig 3990: See Section 19.1.5, "Handling dependencies" for more information about
1.1 dsieger 3991: dependencies on other packages, including the BUILDLINK_ABI_DEPENDS and
3992: ABI_DEPENDS definitions.
3993:
3994: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
3995: BUILDLINK_ABI_DEPENDS.pkg as we don't want to cause unneeded package deletions
3996: and rebuilds. In many cases, new versions of packages work just fine with older
3997: dependencies.
3998:
3999: Also it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
4000: BUILDLINK_API_DEPENDS.pkg.
4001:
1.6 rillig 4002: 14.3. Writing builtin.mk files
1.1 dsieger 4003:
4004: Some packages in pkgsrc install headers and libraries that coincide with
4005: headers and libraries present in the base system. Aside from a buildlink3.mk
4006: file, these packages should also include a builtin.mk file that includes the
4007: necessary checks to decide whether using the built-in software or the pkgsrc
4008: software is appropriate.
4009:
4010: The only requirements of a builtin.mk file for pkg are:
4011:
4012: 1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
4013:
4014: 2. It should not override any USE_BUILTIN.pkg which is already set before the
4015: builtin.mk file is included.
4016:
4017: 3. It should be written to allow multiple inclusion. This is very important
4018: and takes careful attention to Makefile coding.
4019:
1.6 rillig 4020: 14.3.1. Anatomy of a builtin.mk file
1.1 dsieger 4021:
4022: The following is the recommended template for builtin.mk files:
4023:
4024: .if !defined(IS_BUILTIN.foo)
4025: #
4026: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
4027: # genuinely exists in the system or not.
4028: #
4029: IS_BUILTIN.foo?= no
4030:
4031: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
4032: # version can be determined.
4033: #
4034: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
4035: BUILTIN_PKG.foo?= foo-1.0
4036: . endif
4037: .endif # IS_BUILTIN.foo
4038:
4039: .if !defined(USE_BUILTIN.foo)
4040: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
4041: . if defined(BUILTIN_PKG.foo)
4042: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
4043: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
4044: USE_BUILTIN.foo!= \
4045: ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo} \
4046: && ${ECHO} "yes" || ${ECHO} "no"
4047: . endif
4048: . endfor
4049: . endif
4050: .endif # USE_BUILTIN.foo
4051:
4052: CHECK_BUILTIN.foo?= no
4053: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
4054: #
4055: # Here we place code that depends on whether USE_BUILTIN.foo is set to
4056: # "yes" or "no".
4057: #
4058: .endif # CHECK_BUILTIN.foo
4059:
4060: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
4061: base system. This should not be a base system software with similar
4062: functionality to pkg; it should only be "yes" if the actual package is included
4063: as part of the base system. This variable is only used internally within the
4064: builtin.mk file.
4065:
4066: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
4067: system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
4068: internally within the builtin.mk file.
4069:
4070: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
4071: The code in this section must make the determination whether the built-in
4072: software is adequate to satisfy the dependencies listed in
4073: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
1.25 wiz 4074: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg
1.1 dsieger 4075: must be set to the correct value by the end of the builtin.mk file. Note that
4076: USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
4077: the determination that the built-in version of the software is similar enough
4078: to be used as a replacement.
4079:
4080: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
4081: the value of USE_BUILTIN.pkg set in the previous section. This typically
4082: includes, e.g., adding additional dependency restrictions and listing
4083: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
4084:
1.6 rillig 4085: 14.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 4086:
4087: When building packages, it's possible to choose whether to set a global
4088: preference for using either the built-in (native) version or the pkgsrc version
4089: of software to satisfy a dependency. This is controlled by setting
1.25 wiz 4090: PREFER_PKGSRC and PREFER_NATIVE. These variables take values of either "yes", "
4091: no", or a list of packages. PREFER_PKGSRC tells pkgsrc to use the pkgsrc
1.1 dsieger 4092: versions of software, while PREFER_NATIVE tells pkgsrc to use the built-in
4093: versions. Preferences are determined by the most specific instance of the
4094: package in either PREFER_PKGSRC or PREFER_NATIVE. If a package is specified in
4095: neither or in both variables, then PREFER_PKGSRC has precedence over
4096: PREFER_NATIVE. For example, to require using pkgsrc versions of software for
4097: all but the most basic bits on a NetBSD system, you can set:
4098:
4099: PREFER_PKGSRC= yes
4100: PREFER_NATIVE= getopt skey tcp_wrappers
4101:
4102: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
4103: it is simply ignored in that list.
4104:
1.6 rillig 4105: Chapter 15. The pkginstall framework
1.1 dsieger 4106:
4107: Table of Contents
4108:
1.6 rillig 4109: 15.1. Files and directories outside the installation prefix
1.1 dsieger 4110:
1.6 rillig 4111: 15.1.1. Directory manipulation
4112: 15.1.2. File manipulation
1.1 dsieger 4113:
1.6 rillig 4114: 15.2. Configuration files
1.1 dsieger 4115:
1.6 rillig 4116: 15.2.1. How PKG_SYSCONFDIR is set
4117: 15.2.2. Telling the software where configuration files are
4118: 15.2.3. Patching installations
4119: 15.2.4. Disabling handling of configuration files
1.1 dsieger 4120:
1.6 rillig 4121: 15.3. System startup scripts
1.1 dsieger 4122:
1.6 rillig 4123: 15.3.1. Disabling handling of system startup scripts
1.1 dsieger 4124:
1.6 rillig 4125: 15.4. System users and groups
4126: 15.5. System shells
1.1 dsieger 4127:
1.6 rillig 4128: 15.5.1. Disabling shell registration
1.1 dsieger 4129:
1.6 rillig 4130: 15.6. Fonts
1.1 dsieger 4131:
1.6 rillig 4132: 15.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 4133:
4134: This chapter describes the framework known as pkginstall, whose key features
4135: are:
4136:
4137: * Generic installation and manipulation of directories and files outside the
4138: pkgsrc-handled tree, LOCALBASE.
4139:
4140: * Automatic handling of configuration files during installation, provided
4141: that packages are correctly designed.
4142:
4143: * Generation and installation of system startup scripts.
4144:
4145: * Registration of system users and groups.
4146:
4147: * Registration of system shells.
4148:
4149: * Automatic updating of fonts databases.
4150:
4151: The following sections inspect each of the above points in detail.
4152:
4153: You may be thinking that many of the things described here could be easily done
4154: with simple code in the package's post-installation target (post-install). This
4155: is incorrect, as the code in them is only executed when building from source.
4156: Machines using binary packages could not benefit from it at all (as the code
4157: itself could be unavailable). Therefore, the only way to achieve any of the
4158: items described above is by means of the installation scripts, which are
4159: automatically generated by pkginstall.
4160:
1.6 rillig 4161: 15.1. Files and directories outside the installation prefix
1.1 dsieger 4162:
4163: As you already know, the PLIST file holds a list of files and directories that
4164: belong to a package. The names used in it are relative to the installation
4165: prefix (${PREFIX}), which means that it cannot register files outside this
4166: directory (absolute path names are not allowed). Despite this restriction, some
4167: packages need to install files outside this location; e.g., under ${VARBASE} or
4168: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
4169: installation time by using installation scripts.
4170:
4171: The generic installation scripts are shell scripts that can contain arbitrary
4172: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
4173: which defaults to INSTALL. A similar variable exists for package removal
4174: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
4175: commands, so they have the potential to create and manage files anywhere in the
4176: file system.
4177:
4178: Using these general installation files is not recommended, but may be needed in
4179: some special cases. One reason for avoiding them is that the user has to trust
4180: the packager that there is no unwanted or simply erroneous code included in the
4181: installation script. Also, previously there were many similar scripts for the
4182: same functionality, and fixing a common error involved finding and changing all
4183: of them.
4184:
4185: The pkginstall framework offers another, standardized way. It provides generic
4186: scripts to abstract the manipulation of such files and directories based on
4187: variables set in the package's Makefile. The rest of this section describes
4188: these variables.
4189:
1.6 rillig 4190: 15.1.1. Directory manipulation
1.1 dsieger 4191:
4192: The following variables can be set to request the creation of directories
4193: anywhere in the file system:
4194:
4195: * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
4196: and should attempt to be destroyed by the installation scripts. The
4197: difference between the two is that the latter prompts the administrator to
4198: remove any directories that may be left after deinstallation (because they
1.108 rillig 4199: were not empty), while the former does not. Example:
4200:
4201: MAKE_DIRS+= ${VARBASE}/foo/private
1.1 dsieger 4202:
4203: * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
4204: which directories should be created and should attempt to be destroyed by
4205: the installation scripts. Each tuple holds the following values, separated
4206: by spaces: the directory name, its owner, its group and its numerical mode.
4207: For example:
4208:
1.108 rillig 4209: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private \
4210: ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1 dsieger 4211:
4212: The difference between the two is exactly the same as their non-PERMS
4213: counterparts.
4214:
1.6 rillig 4215: 15.1.2. File manipulation
1.1 dsieger 4216:
4217: Creating non-empty files outside the installation prefix is tricky because the
4218: PLIST forces all files to be inside it. To overcome this problem, the only
4219: solution is to extract the file in the known place (i.e., inside the
4220: installation prefix) and copy it to the appropriate location during
4221: installation (done by the installation scripts generated by pkginstall). We
4222: will call the former the master file in the following paragraphs, which
4223: describe the variables that can be used to automatically and consistently
4224: handle files outside the installation prefix:
4225:
1.31 wiz 4226: * CONF_FILES and REQD_FILES are pairs of master and target files. During
1.1 dsieger 4227: installation time, the master file is copied to the target one if and only
4228: if the latter does not exist. Upon deinstallation, the target file is
4229: removed provided that it was not modified by the installation.
4230:
4231: The difference between the two is that the latter prompts the administrator
4232: to remove any files that may be left after deinstallation (because they
4233: were not empty), while the former does not.
4234:
1.31 wiz 4235: * CONF_FILES_PERMS and REQD_FILES_PERMS contain tuples describing master
1.1 dsieger 4236: files as well as their target locations. For each of them, it also
4237: specifies their owner, their group and their numeric permissions, in this
4238: order. For example:
4239:
1.108 rillig 4240: REQD_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile \
4241: ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1 dsieger 4242:
4243: The difference between the two is exactly the same as their non-PERMS
4244: counterparts.
4245:
1.6 rillig 4246: 15.2. Configuration files
1.1 dsieger 4247:
4248: Configuration files are special in the sense that they are installed in their
4249: own specific directory, PKG_SYSCONFDIR, and need special treatment during
4250: installation (most of which is automated by pkginstall). The main concept you
4251: must bear in mind is that files marked as configuration files are automatically
4252: copied to the right place (somewhere inside PKG_SYSCONFDIR) during installation
4253: if and only if they didn't exist before. Similarly, they will not be removed if
4254: they have local modifications. This ensures that administrators never lose any
4255: custom changes they may have made.
4256:
1.6 rillig 4257: 15.2.1. How PKG_SYSCONFDIR is set
1.1 dsieger 4258:
4259: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
4260: shall be installed. Its contents are set based upon the following variables:
4261:
4262: * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
4263: etc although it may be overridden by the user to point to his preferred
4264: location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
4265:
4266: * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
4267: configuration files for the package being built shall be installed. The
4268: definition of this variable only makes sense in the package's Makefile
4269: (i.e., it is not user-customizable).
4270:
1.68 asau 4271: As an example, consider the Apache package, www/apache24, which places its
1.1 dsieger 4272: configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
4273: should be set in the package Makefile.
4274:
4275: * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
4276: package's configuration directory (if different from PKG_SYSCONFBASE). It
4277: defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
4278:
4279: * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
4280: configuration files for the package identified by PKG_SYSCONFVAR's shall be
4281: placed.
4282:
4283: Based on the above variables, pkginstall determines the value of
4284: PKG_SYSCONFDIR, which is the only variable that can be used within a package to
4285: refer to its configuration directory. The algorithm used to set its value is
4286: basically the following:
4287:
4288: 1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
4289:
4290: 2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
4291: package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
4292: {PKG_SYSCONFSUBDIR}.
4293:
4294: 3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
4295:
4296: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
1.16 jnemeth 4297: OWN_DIRS. See Section 15.1.1, "Directory manipulation" what this means. This
4298: does not apply to subdirectories of ${PKG_SYSCONFDIR}, they still have to be
4299: created with OWN_DIRS or MAKE_DIRS.
1.1 dsieger 4300:
1.6 rillig 4301: 15.2.2. Telling the software where configuration files are
1.1 dsieger 4302:
4303: Given that pkgsrc (and users!) expect configuration files to be in a known
4304: place, you need to teach each package where it shall install its files. In some
4305: cases you will have to patch the package Makefiles to achieve it. If you are
4306: lucky, though, it may be as easy as passing an extra flag to the configuration
4307: script; this is the case of GNU Autoconf- generated files:
4308:
4309: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
4310:
4311: Note that this specifies where the package has to look for its configuration
4312: files, not where they will be originally installed (although the difference is
4313: never explicit, unfortunately).
4314:
1.6 rillig 4315: 15.2.3. Patching installations
1.1 dsieger 4316:
4317: As said before, pkginstall automatically handles configuration files. This
4318: means that the packages themselves must not touch the contents of $
4319: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
4320: will, out of the box, mess with the contents of that directory. So what is the
4321: correct procedure to fix this issue?
4322:
4323: You must teach the package (usually by manually patching it) to install any
4324: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
4325: This way, the PLIST registers them and the administrator always has the
4326: original copies available.
4327:
4328: Once the required configuration files are in place (i.e., under the examples
4329: hierarchy), the pkginstall framework can use them as master copies during the
4330: package installation to update what is in ${PKG_SYSCONFDIR}. To achieve this,
4331: the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
1.6 rillig 4332: Section 15.1.2, "File manipulation" for information about their syntax and
1.1 dsieger 4333: their purpose. Here is an example, taken from the mail/mutt package:
4334:
4335: EGDIR= ${PREFIX}/share/doc/mutt/samples
4336: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
4337:
4338: Note that the EGDIR variable is specific to that package and has no meaning
4339: outside it.
4340:
1.6 rillig 4341: 15.2.4. Disabling handling of configuration files
1.1 dsieger 4342:
4343: The automatic copying of config files can be toggled by setting the environment
4344: variable PKG_CONFIG prior to package installation.
4345:
1.6 rillig 4346: 15.3. System startup scripts
1.1 dsieger 4347:
4348: System startup scripts are special files because they must be installed in a
4349: place known by the underlying OS, usually outside the installation prefix.
1.6 rillig 4350: Therefore, the same rules described in Section 15.1, "Files and directories
1.1 dsieger 4351: outside the installation prefix" apply, and the same solutions can be used.
4352: However, pkginstall provides a special mechanism to handle these files.
4353:
4354: In order to provide system startup scripts, the package has to:
4355:
4356: 1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
4357: Considering the print/cups package as an example, it has a cupsd.sh in its
4358: files directory.
4359:
4360: 2. Tell pkginstall to handle it, appending the name of the script, without its
4361: extension, to the RCD_SCRIPTS variable. Continuing the previous example:
4362:
4363: RCD_SCRIPTS+= cupsd
4364:
4365: Once this is done, pkginstall will do the following steps for each script in an
4366: automated fashion:
4367:
4368: 1. Process the file found in the files directory applying all the
4369: substitutions described in the FILES_SUBST variable.
4370:
4371: 2. Copy the script from the files directory to the examples hierarchy, $
4372: {PREFIX}/share/examples/rc.d/. Note that this master file must be
4373: explicitly registered in the PLIST.
4374:
4375: 3. Add code to the installation scripts to copy the startup script from the
4376: examples hierarchy into the system-wide startup scripts directory.
4377:
1.6 rillig 4378: 15.3.1. Disabling handling of system startup scripts
1.1 dsieger 4379:
4380: The automatic copying of config files can be toggled by setting the environment
4381: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
4382: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
4383: rc.d/, no matter what the value of this variable is.
4384:
1.6 rillig 4385: 15.4. System users and groups
1.1 dsieger 4386:
4387: If a package needs to create special users and/or groups during installation,
4388: it can do so by using the pkginstall framework.
4389:
4390: Users can be created by adding entries to the PKG_USERS variable. Each entry
4391: has the following syntax:
4392:
4393: user:group
4394:
4395: Further specification of user details may be done by setting per-user
4396: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
4397: user's description or comment. PKG_HOME.user is the user's home directory, and
4398: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
4399: and defaults to /sbin/nologin if not specified.
4400:
4401: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
4402: whose syntax is:
4403:
4404: group
4405:
4406: The numeric GID of the group may be set by defining PKG_GID.group.
4407:
4408: If a package needs to create the users and groups at an earlier stage, then it
4409: can set USERGROUP_PHASE to either configure or build to indicate the phase
4410: before which the users and groups are created. In this case, the numeric UIDs
4411: and GIDs of the created users and groups are automatically hardcoded into the
4412: final installation scripts.
4413:
1.6 rillig 4414: 15.5. System shells
1.1 dsieger 4415:
4416: Packages that install system shells should register them in the shell database,
4417: /etc/shells, to make things easier to the administrator. This must be done from
4418: the installation scripts to keep binary packages working on any system.
4419: pkginstall provides an easy way to accomplish this task.
4420:
4421: When a package provides a shell interpreter, it has to set the PKG_SHELL
4422: variable to its absolute file name. This will add some hooks to the
4423: installation scripts to handle it. Consider the following example, taken from
4424: shells/zsh:
4425:
4426: PKG_SHELL= ${PREFIX}/bin/zsh
4427:
1.6 rillig 4428: 15.5.1. Disabling shell registration
1.1 dsieger 4429:
4430: The automatic registration of shell interpreters can be disabled by the
4431: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
4432:
1.6 rillig 4433: 15.6. Fonts
1.1 dsieger 4434:
4435: Packages that install X11 fonts should update the database files that index the
4436: fonts within each fonts directory. This can easily be accomplished within the
4437: pkginstall framework.
4438:
4439: When a package installs X11 fonts, it must list the directories in which fonts
4440: are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
4441: "type1" or "x11". This will add hooks to the installation scripts to run the
4442: appropriate commands to update the fonts database files within each of those
4443: directories. For convenience, if the directory path is relative, it is taken to
4444: be relative to the package's installation prefix. Consider the following
4445: example, taken from fonts/dbz-ttf:
4446:
1.67 wiz 4447: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1 dsieger 4448:
1.6 rillig 4449: 15.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 4450:
4451: The automatic update of fonts databases can be disabled by the administrator by
4452: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
4453:
1.6 rillig 4454: Chapter 16. Options handling
1.1 dsieger 4455:
4456: Table of Contents
4457:
1.6 rillig 4458: 16.1. Global default options
4459: 16.2. Converting packages to use bsd.options.mk
4460: 16.3. Option Names
1.7 rillig 4461: 16.4. Determining the options of dependencies
1.1 dsieger 4462:
4463: Many packages have the ability to be built to support different sets of
4464: features. bsd.options.mk is a framework in pkgsrc that provides generic
4465: handling of those options that determine different ways in which the packages
4466: can be built. It's possible for the user to specify exactly which sets of
4467: options will be built into a package or to allow a set of global default
4468: options apply.
4469:
1.7 rillig 4470: There are two broad classes of behaviors that one might want to control via
4471: options. One is whether some particular feature is enabled in a program that
4472: will be built anyway, often by including or not including a dependency on some
4473: other package. The other is whether or not an additional program will be built
4474: as part of the package. Generally, it is better to make a split package for
4475: such additional programs instead of using options, because it enables binary
4476: packages to be built which can then be added separately. For example, the foo
4477: package might have minimal dependencies (those packages without which foo
4478: doesn't make sense), and then the foo-gfoo package might include the GTK
4479: frontend program gfoo. This is better than including a gtk option to foo that
4480: adds gfoo, because either that option is default, in which case binary users
4481: can't get foo without gfoo, or not default, in which case they can't get gfoo.
4482: With split packages, they can install foo without having GTK, and later decide
4483: to install gfoo (pulling in GTK at that time). This is an advantage to source
4484: users too, avoiding the need for rebuilds.
4485:
4486: Plugins with widely varying dependencies should usually be split instead of
4487: options.
4488:
4489: It is often more work to maintain split packages, especially if the upstream
4490: package does not support this. The decision of split vs. option should be made
4491: based on the likelihood that users will want or object to the various pieces,
4492: the size of the dependencies that are included, and the amount of work.
4493:
4494: A further consideration is licensing. Non-free parts, or parts that depend on
4495: non-free dependencies (especially plugins) should almost always be split if
4496: feasible.
4497:
1.6 rillig 4498: 16.1. Global default options
1.1 dsieger 4499:
4500: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
4501: the options that should be built into every package if that option is
1.4 rillig 4502: supported. This variable should be set in mk.conf.
1.1 dsieger 4503:
1.6 rillig 4504: 16.2. Converting packages to use bsd.options.mk
1.1 dsieger 4505:
4506: The following example shows how bsd.options.mk should be used by the
4507: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
4508: e.g. options.mk, that is included by the main package Makefile.
4509:
4510: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
4511: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
4512: PKG_OPTIONS_OPTIONAL_GROUPS= database
4513: PKG_OPTIONS_GROUP.database= mysql pgsql
4514: PKG_SUGGESTED_OPTIONS= wibble-foo
4515: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
4516: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
4517:
4518: .include "../../mk/bsd.prefs.mk"
4519:
4520: # this package was previously named wibble2
4521: .if defined(PKG_OPTIONS.wibble2)
4522: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
4523: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
4524: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
4525: .endif
4526:
4527: .include "../../mk/bsd.options.mk"
4528:
4529: # Package-specific option-handling
4530:
4531: ###
4532: ### FOO support
4533: ###
4534: .if !empty(PKG_OPTIONS:Mwibble-foo)
4535: CONFIGURE_ARGS+= --enable-foo
4536: .endif
4537:
4538: ###
4539: ### LDAP support
4540: ###
4541: .if !empty(PKG_OPTIONS:Mldap)
4542: . include "../../databases/openldap-client/buildlink3.mk"
4543: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
4544: .endif
4545:
4546: ###
4547: ### database support
4548: ###
4549: .if !empty(PKG_OPTIONS:Mmysql)
4550: . include "../../mk/mysql.buildlink3.mk"
4551: .endif
4552: .if !empty(PKG_OPTIONS:Mpgsql)
4553: . include "../../mk/pgsql.buildlink3.mk"
4554: .endif
4555:
4556: The first section contains the information about which build options are
4557: supported by the package, and any default options settings if needed.
4558:
4559: 1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
4560: to override the default options. It should be set to PKG_OPTIONS.pkgbase.
4561: Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
4562: the point where the options are processed.
4563:
4564: 2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
4565:
4566: 3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
4567: exclusive options. The options in each group are listed in
4568: PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
4569: the group takes precedence over all other options in the group. Options
4570: from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
4571:
4572: 4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
4573: building the packages will fail if no option from the group is selected.
4574:
4575: 5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
4576: one option from each set must be selected. The options in each set are
4577: listed in PKG_OPTIONS_SET.setname. Options from the sets will be
4578: automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
4579: fail if no option from the set is selected.
4580:
4581: 6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
4582: default.
4583:
4584: 7. PKG_OPTIONS_LEGACY_VARS is a list of "USE_VARIABLE:option" pairs that map
1.4 rillig 4585: legacy mk.conf variables to their option counterparts. Pairs should be
1.1 dsieger 4586: added with "+=" to keep the listing of global legacy variables. A warning
4587: will be issued if the user uses a legacy variable.
4588:
4589: 8. PKG_OPTIONS_LEGACY_OPTS is a list of "old-option:new-option" pairs that map
4590: options that have been renamed to their new counterparts. Pairs should be
4591: added with "+=" to keep the listing of global legacy options. A warning
4592: will be issued if the user uses a legacy option.
4593:
4594: 9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
4595: used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
4596: PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
4597:
4598: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
4599: variables or options used, and what to use instead.
4600:
4601: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
4602: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
4603: options, use PKG_SUGGESTED_OPTIONS.
4604:
4605: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
4606: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
4607: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
4608: options if none of them is supported on the current platform), PKG_OPTIONS is
4609: set to the empty list and the package is otherwise treated as not using the
4610: options framework.
4611:
4612: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
4613: list of selected build options, properly filtered to remove unsupported and
4614: duplicate options.
4615:
4616: The remaining sections contain the logic that is specific to each option. The
4617: correct way to check for an option is to check whether it is listed in
4618: PKG_OPTIONS:
4619:
4620: .if !empty(PKG_OPTIONS:Moption)
4621:
1.6 rillig 4622: 16.3. Option Names
1.1 dsieger 4623:
4624: Options that enable similar features in different packages (like optional
4625: support for a library) should use a common name in all packages that support it
4626: (like the name of the library). If another package already has an option with
4627: the same meaning, use the same name.
4628:
4629: Options that enable features specific to one package, where it's unlikely that
4630: another (unrelated) package has the same (or a similar) optional feature,
4631: should use a name prefixed with pkgname-.
4632:
4633: If a group of related packages share an optional feature specific to that
4634: group, prefix it with the name of the "main" package (e. g.
4635: djbware-errno-hack).
4636:
4637: For new options, add a line to mk/defaults/options.description. Lines have two
4638: fields, separated by tab. The first field is the option name, the second its
4639: description. The description should be a whole sentence (starting with an
4640: uppercase letter and ending with a period) that describes what enabling the
4641: option does. E. g. "Enable ispell support." The file is sorted by option names.
4642:
1.7 rillig 4643: 16.4. Determining the options of dependencies
4644:
4645: When writing buildlink3.mk files, it is often necessary to list different
4646: dependencies based on the options with which the package was built. For
4647: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
4648: A typical example looks like this:
4649:
4650: pkgbase := libpurple
4651: .include "../../mk/pkg-build-options.mk"
4652:
4653: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
4654: ...
4655: .endif
4656:
4657: Including pkg-build-options.mk here will set the variable
4658: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
4659: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
4660: pkg-build-options.mk for more details.
4661:
1.6 rillig 4662: Chapter 17. The build process
1.1 dsieger 4663:
4664: Table of Contents
4665:
1.6 rillig 4666: 17.1. Introduction
4667: 17.2. Program location
4668: 17.3. Directories used during the build process
4669: 17.4. Running a phase
4670: 17.5. The fetch phase
4671:
4672: 17.5.1. What to fetch and where to get it from
4673: 17.5.2. How are the files fetched?
4674:
4675: 17.6. The checksum phase
4676: 17.7. The extract phase
4677: 17.8. The patch phase
4678: 17.9. The tools phase
4679: 17.10. The wrapper phase
4680: 17.11. The configure phase
4681: 17.12. The build phase
4682: 17.13. The test phase
4683: 17.14. The install phase
4684: 17.15. The package phase
4685: 17.16. Cleaning up
4686: 17.17. Other helpful targets
1.1 dsieger 4687:
1.6 rillig 4688: 17.1. Introduction
1.1 dsieger 4689:
4690: This chapter gives a detailed description on how a package is built. Building a
4691: package is separated into different phases (for example fetch, build, install),
1.19 snj 4692: all of which are described in the following sections. Each phase is split into
4693: so-called stages, which take the name of the containing phase, prefixed by one
4694: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
4695: actual work is done in the do-* stages.
1.1 dsieger 4696:
4697: Never override the regular targets (like fetch), if you have to, override the
4698: do-* ones instead.
4699:
4700: The basic steps for building a program are always the same. First the program's
4701: source (distfile) must be brought to the local system and then extracted. After
4702: any pkgsrc-specific patches to compile properly are applied, the software can
4703: be configured, then built (usually by compiling), and finally the generated
4704: binaries, etc. can be put into place on the system.
4705:
4706: To get more details about what is happening at each step, you can set the
4707: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
4708: more details about the patch step.
4709:
1.6 rillig 4710: 17.2. Program location
1.1 dsieger 4711:
4712: Before outlining the process performed by the NetBSD package system in the next
4713: section, here's a brief discussion on where programs are installed, and which
4714: variables influence this.
4715:
4716: The automatic variable PREFIX indicates where all files of the final program
4717: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
4718: pkgs in the cross category. The value of PREFIX needs to be put into the
4719: various places in the program's source where paths to these files are encoded.
1.6 rillig 4720: See Section 11.3, "patches/*" and Section 19.3.1, "Shared libraries - libtool"
1.1 dsieger 4721: for more details.
4722:
4723: When choosing which of these variables to use, follow the following rules:
4724:
4725: * PREFIX always points to the location where the current pkg will be
1.25 wiz 4726: installed. When referring to a pkg's own installation path, use "${PREFIX}"
4727: .
1.1 dsieger 4728:
4729: * LOCALBASE is where all non-X11 pkgs are installed. If you need to construct
4730: a -I or -L argument to the compiler to find includes and libraries
4731: installed by another non-X11 pkg, use "${LOCALBASE}". The name LOCALBASE
4732: stems from FreeBSD, which installed all packages in /usr/local. As pkgsrc
4733: leaves /usr/local for the system administrator, this variable is a
4734: misnomer.
4735:
4736: * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
4737: installed. When looking for standard X11 includes (not those installed by a
4738: package), use "${X11BASE}".
4739:
1.99 sevan 4740: * X11-based packages using imake must set USE_IMAKE to be installed correctly
4741: under LOCALBASE.
1.1 dsieger 4742:
1.99 sevan 4743: * To determine the prefix of an installed package, the EVAL_PREFIX definition
4744: can be used. It takes pairs in the format "DIRNAME=<package>", and the make
4745: (1) variable DIRNAME will be set to the prefix of the installed package
4746: <package>, or "${PREFIX}" if the package is not installed.
1.1 dsieger 4747:
4748: This is best illustrated by example.
4749:
4750: The following lines are taken from pkgsrc/wm/scwm/Makefile:
4751:
4752: EVAL_PREFIX+= GTKDIR=gtk+
4753: CONFIGURE_ARGS+= --with-guile-prefix=${LOCALBASE:Q}
4754: CONFIGURE_ARGS+= --with-gtk-prefix=${GTKDIR:Q}
4755: CONFIGURE_ARGS+= --enable-multibyte
4756:
4757: Specific defaults can be defined for the packages evaluated using
4758: EVAL_PREFIX, by using a definition of the form:
4759:
4760: GTKDIR_DEFAULT= ${LOCALBASE}
4761:
4762: where GTKDIR corresponds to the first definition in the EVAL_PREFIX pair.
4763:
4764: * Within ${PREFIX}, packages should install files according to hier(7), with
4765: the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
4766: man.
4767:
1.6 rillig 4768: 17.3. Directories used during the build process
1.1 dsieger 4769:
1.14 jmcneill 4770: When building a package, various directories are used to store source files,
1.1 dsieger 4771: temporary files, pkgsrc-internal files, and so on. These directories are
4772: explained here.
4773:
4774: Some of the directory variables contain relative pathnames. There are two
4775: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
4776: used for directories that are pkgsrc-specific. WRKSRC is used for directories
4777: inside the package itself.
4778:
4779: PKGSRCDIR
4780:
4781: This is an absolute pathname that points to the pkgsrc root directory.
4782: Generally, you don't need it.
4783:
4784: PKGDIR
4785:
4786: This is an absolute pathname that points to the current package.
4787:
4788: PKGPATH
4789:
4790: This is a pathname relative to PKGSRCDIR that points to the current
4791: package.
4792:
4793: WRKDIR
4794:
4795: This is an absolute pathname pointing to the directory where all work takes
4796: place. The distfiles are extracted to this directory. It also contains
4797: temporary directories and log files used by the various pkgsrc frameworks,
4798: like buildlink or the wrappers.
4799:
4800: WRKSRC
4801:
4802: This is an absolute pathname pointing to the directory where the distfiles
4803: are extracted. It is usually a direct subdirectory of WRKDIR, and often
4804: it's the only directory entry that isn't hidden. This variable may be
4805: changed by a package Makefile.
4806:
1.14 jmcneill 4807: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
1.15 rillig 4808: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
1.14 jmcneill 4809: created in the pkgsrc entry's directory. If users would like to have their
4810: pkgsrc trees behave in a read-only manner, then the value of
4811: CREATE_WRKDIR_SYMLINK should be set to no.
4812:
1.6 rillig 4813: 17.4. Running a phase
1.1 dsieger 4814:
4815: You can run a particular phase by typing make phase, where phase is the name of
4816: the phase. This will automatically run all phases that are required for this
4817: phase. The default phase is build, that is, when you run make without
4818: parameters in a package directory, the package will be built, but not
4819: installed.
4820:
1.6 rillig 4821: 17.5. The fetch phase
1.1 dsieger 4822:
4823: The first step in building a package is to fetch the distribution files
1.25 wiz 4824: (distfiles) from the sites that are providing them. This is the task of the
1.1 dsieger 4825: fetch phase.
4826:
1.6 rillig 4827: 17.5.1. What to fetch and where to get it from
1.1 dsieger 4828:
4829: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
4830: name is derived from the DISTNAME variable, is fetched. The more complicated
4831: cases are described below.
4832:
4833: The variable DISTFILES specifies the list of distfiles that have to be fetched.
1.66 asau 4834: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
4835: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
4836: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
4837: your package requires additional distfiles to the default one, you cannot just
4838: append the additional filenames using the += operator, but you have write for
4839: example:
1.1 dsieger 4840:
1.66 asau 4841: DISTFILES= ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1 dsieger 4842:
4843: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
4844: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
4845: can set SITES.distfile to the list of URLs where the file distfile (including
4846: the suffix) can be found.
4847:
4848: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
4849: DISTFILES+= foo-file.tar.gz
4850: SITES.foo-file.tar.gz= \
4851: http://www.somewhere.com/somehow/ \
4852: http://www.somewhereelse.com/mirror/somehow/
4853:
4854: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
4855: gets the name of each distfile appended to it, without an intermediate slash.
4856: Therefore, all site values have to end with a slash or other separator
4857: character. This allows for example to set MASTER_SITES to a URL of a CGI script
4858: that gets the name of the distfile as a parameter. In this case, the definition
4859: would look like:
4860:
4861: MASTER_SITES= http://www.example.com/download.cgi?file=
4862:
1.23 jakllsch 4863: The exception to this rule are URLs starting with a dash. In that case the URL
4864: is taken as is, fetched and the result stored under the name of the distfile.
1.66 asau 4865: You can use this style for the case when the download URL style does not match
4866: the above common case. For example, if permanent download URL is a redirector
4867: to the real download URL, or the download file name is offered by an HTTP
4868: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
4869: created instead of the default v1.0.0.tar.gz.
4870:
4871: DISTNAME= foo-1.0.0
4872: MASTER_SITES= -http://www.example.com/archive/v1.0.0.tar.gz
1.23 jakllsch 4873:
1.1 dsieger 4874: There are some predefined values for MASTER_SITES, which can be used in
4875: packages. The names of the variables should speak for themselves.
4876:
4877: ${MASTER_SITE_APACHE}
4878: ${MASTER_SITE_BACKUP}
4879: ${MASTER_SITE_CYGWIN}
4880: ${MASTER_SITE_DEBIAN}
4881: ${MASTER_SITE_FREEBSD}
4882: ${MASTER_SITE_FREEBSD_LOCAL}
4883: ${MASTER_SITE_GENTOO}
4884: ${MASTER_SITE_GNOME}
4885: ${MASTER_SITE_GNU}
4886: ${MASTER_SITE_GNUSTEP}
1.66 asau 4887: ${MASTER_SITE_HASKELL_HACKAGE}
1.1 dsieger 4888: ${MASTER_SITE_IFARCHIVE}
4889: ${MASTER_SITE_KDE}
4890: ${MASTER_SITE_MOZILLA}
1.66 asau 4891: ${MASTER_SITE_MOZILLA_ALL}
4892: ${MASTER_SITE_MOZILLA_ESR}
1.1 dsieger 4893: ${MASTER_SITE_MYSQL}
1.66 asau 4894: ${MASTER_SITE_NETLIB}
1.1 dsieger 4895: ${MASTER_SITE_OPENOFFICE}
1.98 ryoon 4896: ${MASTER_SITE_OSDN}
1.1 dsieger 4897: ${MASTER_SITE_PERL_CPAN}
4898: ${MASTER_SITE_PGSQL}
1.66 asau 4899: ${MASTER_SITE_RUBYGEMS}
1.1 dsieger 4900: ${MASTER_SITE_R_CRAN}
4901: ${MASTER_SITE_SOURCEFORGE}
4902: ${MASTER_SITE_SUNSITE}
4903: ${MASTER_SITE_SUSE}
4904: ${MASTER_SITE_TEX_CTAN}
4905: ${MASTER_SITE_XCONTRIB}
4906: ${MASTER_SITE_XEMACS}
1.66 asau 4907: ${MASTER_SITE_XORG}
1.1 dsieger 4908:
4909: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
4910: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
1.27 wiz 4911: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
1.26 spz 4912: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
4913: distfiles/LOCAL_PORTS/.
1.1 dsieger 4914:
4915: If you choose one of these predefined sites, you may want to specify a
4916: subdirectory of that site. Since these macros may expand to more than one
4917: actual site, you must use the following construct to specify a subdirectory:
4918:
4919: MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/}
4920: MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/}
4921:
4922: Note the trailing slash after the subdirectory name.
4923:
1.6 rillig 4924: 17.5.2. How are the files fetched?
1.1 dsieger 4925:
4926: The fetch phase makes sure that all the distfiles exist in a local directory
4927: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
4928: are fetched using commands of the form
4929:
4930: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
4931:
4932: where ${site} varies through several possibilities in turn: first,
4933: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
4934: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
4935: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
4936: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
4937: MASTER_SORT_AWK or MASTER_SORT_REGEX.
4938:
1.16 jnemeth 4939: The specific command and arguments used depend on the FETCH_USING parameter.
4940: The example above is for FETCH_USING=custom.
4941:
1.1 dsieger 4942: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
4943: target to mirror the distfiles, if they are freely distributable. Packages
4944: setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
4945: distfiles mirrored.
4946:
1.6 rillig 4947: 17.6. The checksum phase
1.1 dsieger 4948:
4949: After the distfile(s) are fetched, their checksum is generated and compared
4950: with the checksums stored in the distinfo file. If the checksums don't match,
4951: the build is aborted. This is to ensure the same distfile is used for building,
4952: and that the distfile wasn't changed, e.g. by some malign force, deliberately
4953: changed distfiles on the master distribution site or network lossage.
4954:
1.6 rillig 4955: 17.7. The extract phase
1.1 dsieger 4956:
4957: When the distfiles are present on the local system, they need to be extracted,
4958: as they usually come in the form of some compressed archive format.
4959:
4960: By default, all DISTFILES are extracted. If you only need some of them, you can
4961: set the EXTRACT_ONLY variable to the list of those files.
4962:
4963: Extracting the files is usually done by a little program, mk/extract/extract,
4964: which already knows how to extract various archive formats, so most likely you
4965: will not need to change anything here. But if you need, the following variables
4966: may help you:
4967:
4968: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
4969:
4970: Use these variables to override the default options for an extract command,
4971: which are defined in mk/extract/extract.
4972:
4973: EXTRACT_USING
4974:
1.14 jmcneill 4975: This variable can be set to bsdtar, gtar, nbtar (which is the default
4976: value), pax, or an absolute pathname pointing to the command with which tar
4977: archives should be extracted. It is preferred to choose bsdtar over gtar if
4978: NetBSD's pax-as-tar is not good enough.
1.1 dsieger 4979:
4980: If the extract program doesn't serve your needs, you can also override the
4981: EXTRACT_CMD variable, which holds the command used for extracting the files.
4982: This command is executed in the ${WRKSRC} directory. During execution of this
4983: command, the shell variable extract_file holds the absolute pathname of the
4984: file that is going to be extracted.
4985:
4986: And if that still does not suffice, you can override the do-extract target in
4987: the package Makefile.
4988:
1.6 rillig 4989: 17.8. The patch phase
1.1 dsieger 4990:
4991: After extraction, all the patches named by the PATCHFILES, those present in the
4992: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
4993: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
4994: are uncompressed before they are applied, files ending in .orig or .rej are
4995: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
1.6 rillig 4996: Section 11.3, "patches/*" for more details.
1.1 dsieger 4997:
4998: By default patch(1) is given special args to make it fail if the patches apply
4999: with some lines of fuzz. Please fix (regen) the patches so that they apply
5000: cleanly. The rationale behind this is that patches that don't apply cleanly may
5001: end up being applied in the wrong place, and cause severe harm there.
5002:
1.6 rillig 5003: 17.9. The tools phase
1.1 dsieger 5004:
1.6 rillig 5005: This is covered in Chapter 18, Tools needed for building or running.
1.1 dsieger 5006:
1.6 rillig 5007: 17.10. The wrapper phase
1.1 dsieger 5008:
5009: This phase creates wrapper programs for the compilers and linkers. The
5010: following variables can be used to tweak the wrappers.
5011:
5012: ECHO_WRAPPER_MSG
5013:
5014: The command used to print progress messages. Does nothing by default. Set
5015: to ${ECHO} to see the progress messages.
5016:
5017: WRAPPER_DEBUG
5018:
5019: This variable can be set to yes (default) or no, depending on whether you
5020: want additional information in the wrapper log file.
5021:
5022: WRAPPER_UPDATE_CACHE
5023:
5024: This variable can be set to yes or no, depending on whether the wrapper
5025: should use its cache, which will improve the speed. The default value is
5026: yes, but is forced to no if the platform does not support it.
5027:
5028: WRAPPER_REORDER_CMDS
5029:
5030: A list of reordering commands. A reordering command has the form reorder:l:
5031: lib1:lib2. It ensures that that -llib1 occurs before -llib2.
5032:
5033: WRAPPER_TRANSFORM_CMDS
5034:
5035: A list of transformation commands. [TODO: investigate further]
5036:
1.6 rillig 5037: 17.11. The configure phase
1.1 dsieger 5038:
5039: Most pieces of software need information on the header files, system calls, and
5040: library routines which are available on the platform they run on. The process
5041: of determining this information is known as configuration, and is usually
5042: automated. In most cases, a script is supplied with the distfiles, and its
5043: invocation results in generation of header files, Makefiles, etc.
5044:
5045: If the package contains a configure script, this can be invoked by setting
5046: HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
5047: should set GNU_CONFIGURE to "yes" instead. What happens in the configure phase
5048: is roughly:
5049:
5050: .for d in ${CONFIGURE_DIRS}
5051: cd ${WRKSRC} \
5052: && cd ${d} \
5053: && env ${CONFIGURE_ENV} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
5054: .endfor
5055:
5056: CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
5057: each of these directories, the configure script is run with the environment
5058: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
5059: CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
5060: by the package.
5061:
1.38 wiz 5062: If the program uses the Perl way of configuration (mainly Perl modules, but not
5063: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
5064: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
5065: (e.g., MAKE_PARAMS+=foo=bar
5066:
1.1 dsieger 5067: If the program uses an Imakefile for configuration, the appropriate steps can
1.99 sevan 5068: be invoked by setting USE_IMAKE to "yes". If you only need xmkmf, add it to
5069: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
5070: SCRIPTS_ENV variable.
1.1 dsieger 5071:
1.11 rillig 5072: If the program uses cmake for configuration, the appropriate steps can be
5073: invoked by setting USE_CMAKE to "yes". You can add variables to cmake's
5074: environment by adding them to the CONFIGURE_ENV variable and arguments to cmake
5075: by adding them to the CMAKE_ARGS variable. The top directory argument is given
5076: by the CMAKE_ARG_PATH variable, that defaults to "." (relative to
5077: CONFIGURE_DIRS)
5078:
1.1 dsieger 5079: If there is no configure step at all, set NO_CONFIGURE to "yes".
5080:
1.6 rillig 5081: 17.12. The build phase
1.1 dsieger 5082:
5083: For building a package, a rough equivalent of the following code is executed.
5084:
5085: .for d in ${BUILD_DIRS}
5086: cd ${WRKSRC} \
5087: && cd ${d} \
5088: && env ${MAKE_ENV} \
5089: ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
5090: -f ${MAKE_FILE} \
5091: ${BUILD_TARGET}
5092: .endfor
5093:
5094: BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
5095: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
5096: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
5097: and BUILD_TARGET may all be changed by the package.
5098:
1.25 wiz 5099: The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
5100: make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
5101: defaults to "all".
1.1 dsieger 5102:
5103: If there is no build step at all, set NO_BUILD to "yes".
5104:
1.6 rillig 5105: 17.13. The test phase
1.1 dsieger 5106:
5107: [TODO]
5108:
1.6 rillig 5109: 17.14. The install phase
1.1 dsieger 5110:
5111: Once the build stage has completed, the final step is to install the software
5112: in public directories, so users can access the programs and files.
5113:
5114: In the install phase, a rough equivalent of the following code is executed.
5115: Additionally, before and after this code, much magic is performed to do
5116: consistency checks, registering the package, and so on.
5117:
5118: .for d in ${INSTALL_DIRS}
5119: cd ${WRKSRC} \
5120: && cd ${d} \
5121: && env ${MAKE_ENV} \
5122: ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
5123: -f ${MAKE_FILE} \
5124: ${INSTALL_TARGET}
5125: .endfor
5126:
5127: The variable's meanings are analogous to the ones in the build phase.
5128: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
5129: plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
5130: defined.
5131:
5132: In the install phase, the following variables are useful. They are all
5133: variations of the install(1) command that have the owner, group and permissions
5134: preset. INSTALL is the plain install command. The specialized variants,
5135: together with their intended use, are:
5136:
5137: INSTALL_PROGRAM_DIR
5138:
5139: directories that contain binaries
5140:
5141: INSTALL_SCRIPT_DIR
5142:
5143: directories that contain scripts
5144:
5145: INSTALL_LIB_DIR
5146:
5147: directories that contain shared and static libraries
5148:
5149: INSTALL_DATA_DIR
5150:
5151: directories that contain data files
5152:
5153: INSTALL_MAN_DIR
5154:
5155: directories that contain man pages
5156:
1.100 leot 5157: INSTALL_GAME_DIR
5158:
5159: directories that contain data files for games
5160:
1.1 dsieger 5161: INSTALL_PROGRAM
5162:
5163: binaries that can be stripped from debugging symbols
5164:
5165: INSTALL_SCRIPT
5166:
5167: binaries that cannot be stripped
5168:
5169: INSTALL_GAME
5170:
5171: game binaries
5172:
5173: INSTALL_LIB
5174:
5175: shared and static libraries
5176:
5177: INSTALL_DATA
5178:
5179: data files
5180:
5181: INSTALL_GAME_DATA
5182:
5183: data files for games
5184:
5185: INSTALL_MAN
5186:
5187: man pages
5188:
5189: Some other variables are:
5190:
1.106 tnn 5191: INSTALL_UNSTRIPPED
5192:
5193: If set to yes, do not run strip(1) when installing binaries. Any debugging
5194: sections and symbols present in binaries will be preserved.
5195:
1.1 dsieger 5196: INSTALLATION_DIRS
5197:
5198: A list of directories relative to PREFIX that are created by pkgsrc at the
5199: beginning of the install phase. The package is supposed to create all
5200: needed directories itself before installing files to it and list all other
5201: directories here.
5202:
1.25 wiz 5203: In the rare cases that a package shouldn't install anything, set NO_INSTALL to
1.1 dsieger 5204: "yes". This is mostly relevant for packages in the regress category.
5205:
1.6 rillig 5206: 17.15. The package phase
1.1 dsieger 5207:
5208: Once the install stage has completed, a binary package of the installed files
5209: can be built. These binary packages can be used for quick installation without
5210: previous compilation, e.g. by the make bin-install or by using pkg_add.
5211:
5212: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
5213: created in ${PACKAGES}/category, one for each category in the CATEGORIES
5214: variable. PACKAGES defaults to pkgsrc/packages.
5215:
1.6 rillig 5216: 17.16. Cleaning up
1.1 dsieger 5217:
5218: Once you're finished with a package, you can clean the work directory by
5219: running make clean. If you want to clean the work directories of all
5220: dependencies too, use make clean-depends.
5221:
1.6 rillig 5222: 17.17. Other helpful targets
1.1 dsieger 5223:
5224: pre/post-*
5225:
5226: For any of the main targets described in the previous section, two
5227: auxiliary targets exist with "pre-" and "post-" used as a prefix for the
5228: main target's name. These targets are invoked before and after the main
5229: target is called, allowing extra configuration or installation steps be
5230: performed from a package's Makefile, for example, which a program's
5231: configure script or install target omitted.
5232:
5233: do-*
5234:
5235: Should one of the main targets do the wrong thing, and should there be no
5236: variable to fix this, you can redefine it with the do-* target. (Note that
5237: redefining the target itself instead of the do-* target is a bad idea, as
5238: the pre-* and post-* targets won't be called anymore, etc.) You will not
5239: usually need to do this.
5240:
5241: reinstall
5242:
5243: If you did a make install and you noticed some file was not installed
5244: properly, you can repeat the installation with this target, which will
5245: ignore the "already installed" flag.
5246:
5247: This is the default value of DEPENDS_TARGET except in the case of make
5248: update and make package, where the defaults are "package" and "update",
5249: respectively.
5250:
5251: deinstall
5252:
5253: This target does a pkg_delete(1) in the current directory, effectively
5254: de-installing the package. The following variables can be used to tune the
5255: behaviour:
5256:
5257: PKG_VERBOSE
5258:
5259: Add a "-v" to the pkg_delete(1) command.
5260:
5261: DEINSTALLDEPENDS
5262:
5263: Remove all packages that require (depend on) the given package. This
5264: can be used to remove any packages that may have been pulled in by a
5265: given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
1.25 wiz 5266: pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
5267: " to the pkg_delete(1) command line.
1.1 dsieger 5268:
5269: bin-install
5270:
5271: Install a binary package from local disk and via FTP from a list of sites
5272: (see the BINPKG_SITES variable), and do a make package if no binary package
5273: is available anywhere. The arguments given to pkg_add can be set via
5274: BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
5275:
1.95 wiz 5276: install-clean
5277:
5278: This target removes the state files for the "install" and later phases so
5279: that the "install" target may be re-invoked. This can be used after editing
5280: the PLIST to install the package without rebuilding it.
5281:
5282: build-clean
5283:
5284: This target removes the state files for the "build" and later phases so
5285: that the "build" target may be re-invoked.
5286:
1.1 dsieger 5287: update
5288:
5289: This target causes the current package to be updated to the latest version.
5290: The package and all depending packages first get de-installed, then current
5291: versions of the corresponding packages get compiled and installed. This is
5292: similar to manually noting which packages are currently installed, then
5293: performing a series of make deinstall and make install (or whatever
5294: UPDATE_TARGET is set to) for these packages.
5295:
5296: You can use the "update" target to resume package updating in case a
5297: previous make update was interrupted for some reason. However, in this
5298: case, make sure you don't call make clean or otherwise remove the list of
5299: dependent packages in WRKDIR. Otherwise, you lose the ability to
5300: automatically update the current package along with the dependent packages
5301: you have installed.
5302:
5303: Resuming an interrupted make update will only work as long as the package
5304: tree remains unchanged. If the source code for one of the packages to be
5305: updated has been changed, resuming make update will most certainly fail!
5306:
1.4 rillig 5307: The following variables can be used either on the command line or in
1.1 dsieger 5308: mk.conf to alter the behaviour of make update:
5309:
5310: UPDATE_TARGET
5311:
5312: Install target to recursively use for the updated package and the
5313: dependent packages. Defaults to DEPENDS_TARGET if set, "install"
1.25 wiz 5314: otherwise for make update. Other good targets are "package" or "
5315: bin-install". Do not set this to "update" or you will get stuck in an
1.1 dsieger 5316: endless loop!
5317:
5318: NOCLEAN
5319:
5320: Don't clean up after updating. Useful if you want to leave the work
5321: sources of the updated packages around for inspection or other
1.25 wiz 5322: purposes. Be sure you eventually clean up the source tree (see the "
5323: clean-update" target below) or you may run into troubles with old
1.1 dsieger 5324: source code still lying around on your next make or make update.
5325:
5326: REINSTALL
5327:
5328: Deinstall each package before installing (making DEPENDS_TARGET). This
5329: may be necessary if the "clean-update" target (see below) was called
5330: after interrupting a running make update.
5331:
5332: DEPENDS_TARGET
5333:
5334: Allows you to disable recursion and hardcode the target for packages.
5335: The default is "update" for the update target, facilitating a recursive
5336: update of prerequisite packages. Only set DEPENDS_TARGET if you want to
5337: disable recursive updates. Use UPDATE_TARGET instead to just set a
5338: specific target for each package to be installed during make update
5339: (see above).
5340:
5341: clean-update
5342:
5343: Clean the source tree for all packages that would get updated if make
5344: update was called from the current directory. This target should not be
5345: used if the current package (or any of its depending packages) have already
5346: been de-installed (e.g., after calling make update) or you may lose some
1.25 wiz 5347: packages you intended to update. As a rule of thumb: only use this target
1.1 dsieger 5348: before the first time you run make update and only if you have a dirty
5349: package tree (e.g., if you used NOCLEAN).
5350:
5351: If you are unsure about whether your tree is clean, you can either perform
5352: a make clean at the top of the tree, or use the following sequence of
5353: commands from the directory of the package you want to update (before
5354: running make update for the first time, otherwise you lose all the packages
5355: you wanted to update!):
5356:
5357: # make clean-update
5358: # make clean CLEANDEPENDS=YES
5359: # make update
5360:
5361:
1.4 rillig 5362: The following variables can be used either on the command line or in
1.1 dsieger 5363: mk.conf to alter the behaviour of make clean-update:
5364:
5365: CLEAR_DIRLIST
5366:
5367: After make clean, do not reconstruct the list of directories to update
5368: for this package. Only use this if make update successfully installed
5369: all packages you wanted to update. Normally, this is done automatically
5370: on make update, but may have been suppressed by the NOCLEAN variable
5371: (see above).
5372:
5373: replace
5374:
5375: Update the installation of the current package. This differs from update in
5376: that it does not replace dependent packages. You will need to install
5377: pkgtools/pkg_tarup for this target to work.
5378:
5379: Be careful when using this target! There are no guarantees that dependent
5380: packages will still work, in particular they will most certainly break if
5381: you make replace a library package whose shared library major version
5382: changed between your installed version and the new one. For this reason,
5383: this target is not officially supported and only recommended for advanced
5384: users.
5385:
5386: info
5387:
5388: This target invokes pkg_info(1) for the current package. You can use this
5389: to check which version of a package is installed.
5390:
5391: index
5392:
5393: This is a top-level command, i.e. it should be used in the pkgsrc
5394: directory. It creates a database of all packages in the local pkgsrc tree,
5395: including dependencies, comment, maintainer, and some other useful
5396: information. Individual entries are created by running make describe in the
5397: packages' directories. This index file is saved as pkgsrc/INDEX. It can be
5398: displayed in verbose format by running make print-index. You can search in
5399: it with make search key=something. You can extract a list of all packages
5400: that depend on a particular one by running make show-deps PKG=somepackage.
5401:
5402: Running this command takes a very long time, some hours even on fast
5403: machines!
5404:
5405: readme
5406:
5407: This target generates a README.html file, which can be viewed using a
5408: browser such as www/firefox or www/links. The generated files contain
5409: references to any packages which are in the PACKAGES directory on the local
5410: host. The generated files can be made to refer to URLs based on
5411: FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
5412: README.html files which pointed to binary packages on the local machine, in
5413: the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
5414: FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
5415: subdirectories will be searched for all the binary packages.
5416:
5417: The target can be run at the toplevel or in category directories, in which
5418: case it descends recursively.
5419:
5420: readme-all
5421:
5422: This is a top-level command, run it in pkgsrc. Use this target to create a
5423: file README-all.html which contains a list of all packages currently
5424: available in the NetBSD Packages Collection, together with the category
5425: they belong to and a short description. This file is compiled from the
5426: pkgsrc/*/README.html files, so be sure to run this after a make readme.
5427:
5428: cdrom-readme
5429:
5430: This is very much the same as the "readme" target (see above), but is to be
5431: used when generating a pkgsrc tree to be written to a CD-ROM. This target
5432: also produces README.html files, and can be made to refer to URLs based on
5433: CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
5434:
5435: show-distfiles
5436:
5437: This target shows which distfiles and patchfiles are needed to build the
5438: package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
5439: patches/*).
5440:
5441: show-downlevel
5442:
5443: This target shows nothing if the package is not installed. If a version of
5444: this package is installed, but is not the version provided in this version
5445: of pkgsrc, then a warning message is displayed. This target can be used to
5446: show which of your installed packages are downlevel, and so the old
5447: versions can be deleted, and the current ones added.
5448:
5449: show-pkgsrc-dir
5450:
5451: This target shows the directory in the pkgsrc hierarchy from which the
5452: package can be built and installed. This may not be the same directory as
5453: the one from which the package was installed. This target is intended to be
5454: used by people who may wish to upgrade many packages on a single host, and
1.25 wiz 5455: can be invoked from the top-level pkgsrc Makefile by using the "
5456: show-host-specific-pkgs" target.
1.1 dsieger 5457:
5458: show-installed-depends
5459:
5460: This target shows which installed packages match the current package's
5461: DEPENDS. Useful if out of date dependencies are causing build problems.
5462:
1.95 wiz 5463: print-build-depends-list
5464:
5465: This target shows the list of packages that the current package depends on
5466: for building.
5467:
5468: print-run-depends-list
5469:
5470: This target shows the list of packages that the current package depends on
5471: for running.
5472:
1.1 dsieger 5473: check-shlibs
5474:
5475: After a package is installed, check all its binaries and (on ELF platforms)
5476: shared libraries to see if they find the shared libs they need. Run by
1.4 rillig 5477: default if PKG_DEVELOPER is set in mk.conf.
1.1 dsieger 5478:
5479: print-PLIST
5480:
5481: After a "make install" from a new or upgraded pkg, this prints out an
5482: attempt to generate a new PLIST from a find -newer work/.extract_done. An
5483: attempt is made to care for shared libs etc., but it is strongly
5484: recommended to review the result before putting it into PLIST. On upgrades,
5485: it's useful to diff the output of this command against an already existing
5486: PLIST file.
5487:
5488: If the package installs files via tar(1) or other methods that don't update
5489: file access times, be sure to add these files manually to your PLIST, as
5490: the "find -newer" command used by this target won't catch them!
5491:
1.6 rillig 5492: See Section 13.3, "Tweaking output of make print-PLIST" for more
1.1 dsieger 5493: information on this target.
5494:
5495: bulk-package
5496:
5497: Used to do bulk builds. If an appropriate binary package already exists, no
5498: action is taken. If not, this target will compile, install and package it
1.66 asau 5499: (and its depends, if PKG_DEPENDS is set properly. See Chapter 7, Creating
5500: binary packages for everything in pkgsrc (bulk builds)). After creating the
5501: binary package, the sources, the just-installed package and its required
5502: packages are removed, preserving free disk space.
1.1 dsieger 5503:
5504: Beware that this target may deinstall all packages installed on a system!
5505:
5506: bulk-install
5507:
5508: Used during bulk-installs to install required packages. If an up-to-date
1.25 wiz 5509: binary package is available, it will be installed via pkg_add(1). If not,
1.1 dsieger 5510: make bulk-package will be executed, but the installed binary won't be
5511: removed.
5512:
5513: A binary package is considered "up-to-date" to be installed via pkg_add(1)
5514: if:
5515:
1.42 asau 5516: + None of the package's files (Makefile, ...) were modified since it was
1.1 dsieger 5517: built.
5518:
1.42 asau 5519: + None of the package's required (binary) packages were modified since it
1.1 dsieger 5520: was built.
5521:
5522: Beware that this target may deinstall all packages installed on a system!
5523:
1.6 rillig 5524: Chapter 18. Tools needed for building or running
1.1 dsieger 5525:
5526: Table of Contents
5527:
1.6 rillig 5528: 18.1. Tools for pkgsrc builds
5529: 18.2. Tools needed by packages
5530: 18.3. Tools provided by platforms
1.1 dsieger 5531:
5532: The USE_TOOLS definition is used both internally by pkgsrc and also for
5533: individual packages to define what commands are needed for building a package
5534: (like BUILD_DEPENDS) or for later run-time of an installed packaged (such as
5535: DEPENDS). If the native system provides an adequate tool, then in many cases, a
5536: pkgsrc package will not be used.
5537:
5538: When building a package, the replacement tools are made available in a
5539: directory (as symlinks or wrapper scripts) that is early in the executable
5540: search path. Just like the buildlink system, this helps with consistent builds.
5541:
5542: A tool may be needed to help build a specific package. For example, perl, GNU
5543: make (gmake) or yacc may be needed.
5544:
5545: Also a tool may be needed, for example, because the native system's supplied
5546: tool may be inefficient for building a package with pkgsrc. For example, a
5547: package may need GNU awk, bison (instead of yacc) or a better sed.
5548:
5549: The tools used by a package can be listed by running make show-tools.
5550:
1.6 rillig 5551: 18.1. Tools for pkgsrc builds
1.1 dsieger 5552:
5553: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
5554: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
5555: seen by running: make show-var VARNAME=USE_TOOLS.
5556:
5557: If a package needs a specific program to build then the USE_TOOLS variable can
5558: be used to define the tools needed.
5559:
1.6 rillig 5560: 18.2. Tools needed by packages
1.1 dsieger 5561:
1.29 wiz 5562: In the following examples, the :run means that it is needed at run-time (and
5563: becomes a DEPENDS). The default is a build dependency which can be set with
5564: :build. (So in this example, it is the same as gmake:build and
5565: pkg-config:build.)
1.1 dsieger 5566:
5567: USE_TOOLS+= gmake perl:run pkg-config
5568:
5569: When using the tools framework, a TOOLS_PATH.foo variable is defined which
5570: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
5571: could be "/bin/bash" on Linux systems.
5572:
5573: If you always need a pkgsrc version of the tool at run-time, then just use
5574: DEPENDS instead.
5575:
1.6 rillig 5576: 18.3. Tools provided by platforms
1.1 dsieger 5577:
5578: When improving or porting pkgsrc to a new platform, have a look at (or create)
5579: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
5580: tools.${OPSYS}.mk which defines the name of the common tools. For example:
5581:
5582: .if exists(/usr/bin/bzcat)
5583: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
5584: .elif exists(/usr/bin/bzip2)
5585: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
5586: .endif
5587:
5588: TOOLS_PLATFORM.true?= true # shell builtin
5589:
1.6 rillig 5590: Chapter 19. Making your package work
1.1 dsieger 5591:
5592: Table of Contents
5593:
1.6 rillig 5594: 19.1. General operation
1.1 dsieger 5595:
1.108 rillig 5596: 19.1.1. How to pull in user-settable variables from mk.conf
5597: 19.1.2. User interaction
5598: 19.1.3. Handling licenses
5599: 19.1.4. Restricted packages
5600: 19.1.5. Handling dependencies
5601: 19.1.6. Handling conflicts with other packages
5602: 19.1.7. Packages that cannot or should not be built
5603: 19.1.8. Packages which should not be deleted, once installed
5604: 19.1.9. Handling packages with security problems
5605: 19.1.10. How to handle incrementing versions when fixing an existing
1.1 dsieger 5606: package
1.108 rillig 5607: 19.1.11. Substituting variable text in the package files (the SUBST
1.1 dsieger 5608: framework)
5609:
1.108 rillig 5610: 19.2. The fetch phase
1.1 dsieger 5611:
1.6 rillig 5612: 19.2.1. Packages whose distfiles aren't available for plain downloading
5613: 19.2.2. How to handle modified distfiles with the 'old' name
1.88 tnn 5614: 19.2.3. Packages hosted on github.com
1.1 dsieger 5615:
1.108 rillig 5616: 19.3. The configure phase
1.1 dsieger 5617:
1.6 rillig 5618: 19.3.1. Shared libraries - libtool
5619: 19.3.2. Using libtool on GNU packages that already support libtool
5620: 19.3.3. GNU Autoconf/Automake
5621:
5622: 19.4. Programming languages
5623:
5624: 19.4.1. C, C++, and Fortran
5625: 19.4.2. Java
5626: 19.4.3. Packages containing perl scripts
1.41 wiz 5627: 19.4.4. Packages containing shell scripts
5628: 19.4.5. Other programming languages
1.6 rillig 5629:
1.108 rillig 5630: 19.5. The build phase
1.6 rillig 5631:
5632: 19.5.1. Compiling C and C++ code conditionally
5633: 19.5.2. How to handle compiler bugs
1.24 wiz 5634: 19.5.3. Undefined reference to "..."
1.6 rillig 5635: 19.5.4. Running out of memory
5636:
1.108 rillig 5637: 19.6. The install phase
1.6 rillig 5638:
5639: 19.6.1. Creating needed directories
5640: 19.6.2. Where to install documentation
5641: 19.6.3. Installing highscore files
5642: 19.6.4. Adding DESTDIR support to packages
5643: 19.6.5. Packages with hardcoded paths to other interpreters
5644: 19.6.6. Packages installing perl modules
5645: 19.6.7. Packages installing info files
5646: 19.6.8. Packages installing man pages
1.7 rillig 5647: 19.6.9. Packages installing GConf data files
1.18 mishka 5648: 19.6.10. Packages installing scrollkeeper/rarian data files
1.6 rillig 5649: 19.6.11. Packages installing X11 fonts
5650: 19.6.12. Packages installing GTK2 modules
5651: 19.6.13. Packages installing SGML or XML data
5652: 19.6.14. Packages installing extensions to the MIME database
5653: 19.6.15. Packages using intltool
5654: 19.6.16. Packages installing startup scripts
5655: 19.6.17. Packages installing TeX modules
5656: 19.6.18. Packages supporting running binaries in emulation
5657: 19.6.19. Packages installing hicolor theme icons
5658: 19.6.20. Packages installing desktop files
1.1 dsieger 5659:
1.6 rillig 5660: 19.7. Marking packages as having problems
1.1 dsieger 5661:
1.6 rillig 5662: 19.1. General operation
1.1 dsieger 5663:
5664: One appealing feature of pkgsrc is that it runs on many different platforms. As
5665: a result, it is important to ensure, where possible, that packages in pkgsrc
5666: are portable. This chapter mentions some particular details you should pay
5667: attention to while working on pkgsrc.
5668:
1.108 rillig 5669: 19.1.1. How to pull in user-settable variables from mk.conf
1.1 dsieger 5670:
5671: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4 rillig 5672: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
5673: those variables in the preprocessor directives of make(1) (for example .if or
5674: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
5675: loads the user preferences.
1.1 dsieger 5676:
5677: But note that some variables may not be completely defined after ../../mk/
5678: bsd.prefs.mk has been included, as they may contain references to variables
1.108 rillig 5679: that are not yet defined. In shell commands (the lines in Makefile that are
5680: indented with a tab) this is no problem, since variables are only expanded when
5681: they are used. But in the preprocessor directives mentioned above and in
5682: dependency lines (of the form target: dependencies) the variables are expanded
5683: at load time.
1.1 dsieger 5684:
5685: Note
5686:
1.108 rillig 5687: To check whether a variable can be used at load time, run pkglint -Wall on your
5688: package.
1.1 dsieger 5689:
1.108 rillig 5690: 19.1.2. User interaction
1.1 dsieger 5691:
5692: Occasionally, packages require interaction from the user, and this can be in a
5693: number of ways:
5694:
5695: * When fetching the distfiles, some packages require user interaction such as
5696: entering username/password or accepting a license on a web page.
5697:
5698: * When extracting the distfiles, some packages may ask for passwords.
5699:
5700: * help to configure the package before it is built
5701:
5702: * help during the build process
5703:
5704: * help during the installation of a package
5705:
1.108 rillig 5706: A package can set the INTERACTIVE_STAGE variable to define which stages need
5707: interaction. This should be done in the package's Makefile, e.g.:
1.1 dsieger 5708:
5709: INTERACTIVE_STAGE= configure install
5710:
5711: The user can then decide to skip this package by setting the BATCH variable.
1.108 rillig 5712: Packages that require interaction are also excluded from bulk builds.
1.1 dsieger 5713:
1.108 rillig 5714: 19.1.3. Handling licenses
1.1 dsieger 5715:
5716: Authors of software can choose the licence under which software can be copied.
1.111 sevan 5717: The Free Software Foundation has declared some licenses "Free", and the Open
5718: Source Initiative has a definition of "Open Source".
5719:
5720: By default, pkgsrc allows packages with Free or Open Source licenses to be
5721: built. To allow packages with other licenses to be built as well, the pkgsrc
5722: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
5723: . Note that this variable only affects which packages may be built, while the
5724: license terms often also restrict the actual use of the package and its
5725: redistribution.
1.1 dsieger 5726:
5727: One might want to only install packages with a BSD license, or the GPL, and not
1.20 jnemeth 5728: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111 sevan 5729: variable. The pkgsrc user can override the default by setting the
5730: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
5731: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
5732: pkgsrc/mk/license.mk.
1.1 dsieger 5733:
5734: The license tag mechanism is intended to address copyright-related issues
5735: surrounding building, installing and using a package, and not to address
1.20 jnemeth 5736: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
5737: redistribution restrictions should set these tags.
1.1 dsieger 5738:
5739: Denoting that a package may be copied according to a particular license is done
5740: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
5741: string identifying the license, e.g. in graphics/xv:
5742:
5743: LICENSE= xv-license
5744:
5745: When trying to build, the user will get a notice that the package is covered by
5746: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
5747:
5748: % make
5749: ===> xv-3.10anb9 has an unacceptable license: xv-license.
5750: ===> To view the license, enter "/usr/bin/make show-license".
5751: ===> To indicate acceptance, add this line to your /etc/mk.conf:
5752: ===> ACCEPTABLE_LICENSES+=xv-license
5753: *** Error code 1
5754:
5755: The license can be viewed with make show-license, and if the user so chooses,
1.4 rillig 5756: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1 dsieger 5757: should not in the future fail because of that license:
5758:
5759: ACCEPTABLE_LICENSES+=xv-license
5760:
1.111 sevan 5761: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
5762: is deprecated because it does not crisply refer to a particular license text.
5763: Another problem with such usage is that it does not enable a user to tell
5764: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
5765: for all packages with that tag.
5766:
5767: 19.1.3.1. Adding a package with a new license
1.1 dsieger 5768:
1.49 rodent 5769: When adding a package with a new license, the following steps are required:
5770:
1.111 sevan 5771: 1. Check whether the license qualifies as Free or Open Source by referencing
5772: Various Licenses and Comments about Them and Licenses by Name | Open Source
5773: Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
5774: need the -license suffix, and the license name should be added to:
1.49 rodent 5775:
5776: + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
5777:
5778: + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
5779: license.c
5780:
5781: 2. The license text should be added to pkgsrc/licenses for displaying. A list
5782: of known licenses can be seen in this directory.
1.1 dsieger 5783:
1.111 sevan 5784: 19.1.3.2. Change to the license
1.1 dsieger 5785:
1.111 sevan 5786: When the license changes (in a way other than formatting), make sure that the
5787: new license has a different name (e.g., append the version number if it exists,
5788: or the date). Just because a user told pkgsrc to build programs under a
5789: previous version of a license does not mean that pkgsrc should build programs
5790: under the new licenses. The higher-level point is that pkgsrc does not evaluate
5791: licenses for reasonableness; the only test is a mechanistic test of whether a
5792: particular text has been approved by either of two bodies (FSF or OSI).
1.1 dsieger 5793:
1.108 rillig 5794: 19.1.4. Restricted packages
1.1 dsieger 5795:
1.111 sevan 5796: Some licenses restrict how software may be re-distributed. By declaring the
5797: restrictions, package tools can automatically refrain from e.g. placing binary
5798: packages on FTP sites.
5799:
5800: There are four possible restrictions, which are the cross product of sources
5801: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
5802: this is rarely the exact language in any license, and because non-Free licenses
5803: tend to be different from each other, pkgsrc adopts a definition of FTP and
5804: CD-ROM. "FTP" means making the source or binary file available over the
5805: Internet at no charge. "CD-ROM" means making the source or binary available on
5806: some kind of media, together with other source and binary packages, which is
5807: sold for a distribution charge.
1.1 dsieger 5808:
5809: In order to encode these restrictions, the package system defines five make
5810: variables that can be set to note these restrictions:
5811:
5812: * RESTRICTED
5813:
5814: This variable should be set whenever a restriction exists (regardless of
5815: its kind). Set this variable to a string containing the reason for the
5816: restriction. It should be understood that those wanting to understand the
5817: restriction will have to read the license, and perhaps seek advice of
5818: counsel.
5819:
5820: * NO_BIN_ON_CDROM
5821:
5822: Binaries may not be placed on CD-ROM containing other binary packages, for
5823: which a distribution charge may be made. In this case, set this variable to
5824: ${RESTRICTED}.
5825:
5826: * NO_BIN_ON_FTP
5827:
5828: Binaries may not made available on the Internet without charge. In this
5829: case, set this variable to ${RESTRICTED}. If this variable is set, binary
5830: packages will not be included on ftp.NetBSD.org.
5831:
5832: * NO_SRC_ON_CDROM
5833:
5834: Distfiles may not be placed on CD-ROM, together with other distfiles, for
5835: which a fee may be charged. In this case, set this variable to $
5836: {RESTRICTED}.
5837:
5838: * NO_SRC_ON_FTP
5839:
5840: Distfiles may not made available via FTP at no charge. In this case, set
5841: this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
5842: will not be mirrored on ftp.NetBSD.org.
5843:
1.111 sevan 5844: Please note that packages will be removed from pkgsrc when the distfiles are
1.33 wiz 5845: not distributable and cannot be obtained for a period of one full quarter
1.111 sevan 5846: branch. Packages with manual/interactive fetch must have a maintainer and it is
5847: his/her responsibility to ensure this.
1.33 wiz 5848:
1.108 rillig 5849: 19.1.5. Handling dependencies
1.1 dsieger 5850:
5851: Your package may depend on some other package being present - and there are
5852: various ways of expressing this dependency. pkgsrc supports the BUILD_DEPENDS
5853: and DEPENDS definitions, the USE_TOOLS definition, as well as dependencies via
5854: buildlink3.mk, which is the preferred way to handle dependencies, and which
1.6 rillig 5855: uses the variables named above. See Chapter 14, Buildlink methodology for more
1.1 dsieger 5856: information.
5857:
5858: The basic difference between the two variables is as follows: The DEPENDS
5859: definition registers that pre-requisite in the binary package so it will be
5860: pulled in when the binary package is later installed, whilst the BUILD_DEPENDS
5861: definition does not, marking a dependency that is only needed for building the
5862: package.
5863:
5864: This means that if you only need a package present whilst you are building, it
5865: should be noted as a BUILD_DEPENDS.
5866:
5867: The format for a BUILD_DEPENDS and a DEPENDS definition is:
5868:
5869: <pre-req-package-name>:../../<category>/<pre-req-package>
5870:
5871: Please note that the "pre-req-package-name" may include any of the wildcard
5872: version numbers recognized by pkg_info(1).
5873:
1.55 wiz 5874: 1. If your package needs another package's binaries or libraries to build and
1.1 dsieger 5875: run, and if that package has a buildlink3.mk file available, use it:
5876:
5877: .include "../../graphics/jpeg/buildlink3.mk"
5878:
1.55 wiz 5879: 2. If your package needs another package's binaries or libraries only for
5880: building, and if that package has a buildlink3.mk file available, use it:
5881:
5882: .include "../../graphics/jpeg/buildlink3.mk"
5883:
5884: but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
5885: This case is rather rare.
5886:
5887: 3. If your package needs binaries from another package to build, use the
1.26 spz 5888: BUILD_DEPENDS definition:
1.1 dsieger 5889:
1.26 spz 5890: BUILD_DEPENDS+= scons-[0-9]*:../../devel/scons
1.1 dsieger 5891:
1.55 wiz 5892: 4. If your package needs a library with which to link and there is no
1.26 spz 5893: buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
5894: because the include files and libraries will be hidden from the compiler.
1.1 dsieger 5895:
1.55 wiz 5896: 5. If your package needs some executable to be able to run correctly and if
1.26 spz 5897: there's no buildlink3.mk file, this is specified using the DEPENDS
5898: variable. The print/lyx package needs to be able to execute the latex
5899: binary from the teTeX package when it runs, and that is specified:
1.1 dsieger 5900:
1.26 spz 5901: DEPENDS+= teTeX-[0-9]*:../../print/teTeX
1.1 dsieger 5902:
1.55 wiz 5903: 6. You can use wildcards in package dependencies. Note that such wildcard
1.26 spz 5904: dependencies are retained when creating binary packages. The dependency is
5905: checked when installing the binary package and any package which matches
5906: the pattern will be used. Wildcard dependencies should be used with care.
1.1 dsieger 5907:
5908: The "-[0-9]*" should be used instead of "-*" to avoid potentially ambiguous
5909: matches such as "tk-postgresql" matching a "tk-*" DEPENDS.
5910:
5911: Wildcards can also be used to specify that a package will only build
5912: against a certain minimum version of a pre-requisite:
5913:
1.26 spz 5914: DEPENDS+= ImageMagick>=6.0:../../graphics/ImageMagick
1.1 dsieger 5915:
1.26 spz 5916: This means that the package will build using version 6.0 of ImageMagick or
5917: newer. Such a dependency may be warranted if, for example, the command line
5918: options of an executable have changed.
5919:
5920: If you need to depend on minimum versions of libraries, see the buildlink
5921: section of the pkgsrc guide.
1.1 dsieger 5922:
5923: For security fixes, please update the package vulnerabilities file. See
1.108 rillig 5924: Section 19.1.9, "Handling packages with security problems" for more
1.1 dsieger 5925: information.
5926:
5927: If your package needs files from another package to build, add the relevant
5928: distribution files to DISTFILES, so they will be extracted automatically. See
5929: the print/ghostscript package for an example. (It relies on the jpeg sources
5930: being present in source form during the build.)
5931:
1.108 rillig 5932: 19.1.6. Handling conflicts with other packages
1.1 dsieger 5933:
5934: Your package may conflict with other packages a user might already have
5935: installed on his system, e.g. if your package installs the same set of files as
1.80 wiz 5936: another package in the pkgsrc tree or has the same PKGNAME.
1.1 dsieger 5937:
1.80 wiz 5938: These cases are handled automatically by the packaging tools at package
5939: installation time and do not need to be handled manually.
1.1 dsieger 5940:
1.80 wiz 5941: In case the conflicts can not be recognized automatically (e.g., packages using
5942: the same config file location but no other shared files), you can set CONFLICTS
5943: to a space-separated list of packages (including version string) your package
5944: conflicts with.
1.1 dsieger 5945:
1.80 wiz 5946: For example, if both foo/bar and foo/baz use the same config file, you would
5947: set in foo/bar/Makefile:
1.1 dsieger 5948:
1.80 wiz 5949: CONFLICTS= baz-[0-9]*
1.1 dsieger 5950:
1.80 wiz 5951: and in pkgsrc/foo/baz/Makefile:
1.1 dsieger 5952:
1.80 wiz 5953: CONFLICTS= bar-[0-9]*
1.1 dsieger 5954:
1.108 rillig 5955: 19.1.7. Packages that cannot or should not be built
1.1 dsieger 5956:
5957: There are several reasons why a package might be instructed to not build under
5958: certain circumstances. If the package builds and runs on most platforms, the
1.83 dholland 5959: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
5960: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
5961: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
5962: (OS-version-platform) that can use glob-style wildcards.
5963:
5964: If a package is not appropriate for some platforms (as oopposed to merely
5965: broken), a different set of variables should be used as this affects failure
5966: reporting and statistics. If the package is appropriate for most platforms, the
5967: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
5968: for only a small handful of platforms (often exactly one), set
5969: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
5970: triples (OS-version-platform) that can use glob-style wildcards.
1.1 dsieger 5971:
5972: Some packages are tightly bound to a specific version of an operating system,
5973: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
5974: with other versions of the OS, and should be uploaded to a version specific
5975: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
5976: to "yes". This variable is not currently used by any of the package system
5977: internals, but may be used in the future.
5978:
5979: If the package should be skipped (for example, because it provides
5980: functionality already provided by the system), set PKG_SKIP_REASON to a
5981: descriptive message. If the package should fail because some preconditions are
5982: not met, set PKG_FAIL_REASON to a descriptive message.
5983:
1.108 rillig 5984: 19.1.8. Packages which should not be deleted, once installed
1.1 dsieger 5985:
5986: To ensure that a package may not be deleted, once it has been installed, the
5987: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.25 wiz 5988: carried into any binary package that is made from this pkgsrc entry. A "
5989: preserved" package will not be deleted using pkg_delete(1) unless the "-f"
1.1 dsieger 5990: option is used.
5991:
1.108 rillig 5992: 19.1.9. Handling packages with security problems
1.1 dsieger 5993:
5994: When a vulnerability is found, this should be noted in localsrc/security/
1.32 wiz 5995: advisories/pkg-vulnerabilities, and after committing that file, ask
5996: pkgsrc-security@NetBSD.org to update the file on ftp.NetBSD.org.
1.1 dsieger 5997:
5998: After fixing the vulnerability by a patch, its PKGREVISION should be increased
5999: (this is of course not necessary if the problem is fixed by using a newer
1.32 wiz 6000: release of the software), and the pattern in the pkg-vulnerabilities file must
6001: be updated.
1.1 dsieger 6002:
6003: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
6004: submit a pullup request!
6005:
6006: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
6007: a weekly cron job.
6008:
1.108 rillig 6009: 19.1.10. How to handle incrementing versions when fixing an existing package
1.1 dsieger 6010:
6011: When making fixes to an existing package it can be useful to change the version
6012: number in PKGNAME. To avoid conflicting with future versions by the original
6013: author, a "nb1", "nb2", ... suffix can be used on package versions by setting
6014: PKGREVISION=1 (2, ...). The "nb" is treated like a "." by the package tools.
6015: e.g.
6016:
6017: DISTNAME= foo-17.42
6018: PKGREVISION= 9
6019:
6020: will result in a PKGNAME of "foo-17.42nb9". If you want to use the original
6021: value of PKGNAME without the "nbX" suffix, e.g. for setting DIST_SUBDIR, use
6022: PKGNAME_NOREV.
6023:
6024: When a new release of the package is released, the PKGREVISION should be
6025: removed, e.g. on a new minor release of the above package, things should be
6026: like:
6027:
6028: DISTNAME= foo-17.43
6029:
6030: PKGREVISION should be incremented for any non-trivial change in the resulting
6031: binary package. Without a PKGREVISION bump, someone with the previous version
6032: installed has no way of knowing that their package is out of date. Thus,
6033: changes without increasing PKGREVISION are essentially labeled "this is so
6034: trivial that no reasonable person would want to upgrade", and this is the rough
6035: test for when increasing PKGREVISION is appropriate. Examples of changes that
6036: do not merit increasing PKGREVISION are:
6037:
1.14 jmcneill 6038: * Changing HOMEPAGE, MAINTAINER, OWNER, or comments in Makefile.
1.1 dsieger 6039:
6040: * Changing build variables if the resulting binary package is the same.
6041:
6042: * Changing DESCR.
6043:
6044: * Adding PKG_OPTIONS if the default options don't change.
6045:
6046: Examples of changes that do merit an increase to PKGREVISION include:
6047:
6048: * Security fixes
6049:
6050: * Changes or additions to a patch file
6051:
6052: * Changes to the PLIST
6053:
1.12 weinem 6054: * A dependency is changed or renamed.
6055:
1.1 dsieger 6056: PKGREVISION must also be incremented when dependencies have ABI changes.
6057:
1.108 rillig 6058: 19.1.11. Substituting variable text in the package files (the SUBST framework)
1.1 dsieger 6059:
6060: When you want to replace the same text in multiple files or when the
6061: replacement text varies, patches alone cannot help. This is where the SUBST
6062: framework comes in. It provides an easy-to-use interface for replacing text in
6063: files. Example:
6064:
6065: SUBST_CLASSES+= fix-paths
6066: SUBST_STAGE.fix-paths= pre-configure
6067: SUBST_MESSAGE.fix-paths= Fixing absolute paths.
6068: SUBST_FILES.fix-paths= src/*.c
6069: SUBST_FILES.fix-paths+= scripts/*.sh
6070: SUBST_SED.fix-paths= -e 's,"/usr/local,"${PREFIX},g'
6071: SUBST_SED.fix-paths+= -e 's,"/var/log,"${VARBASE}/log,g'
6072:
6073: SUBST_CLASSES is a list of identifiers that are used to identify the different
6074: SUBST blocks that are defined. The SUBST framework is heavily used by pkgsrc,
6075: so it is important to always use the += operator with this variable. Otherwise
6076: some substitutions may be skipped.
6077:
6078: The remaining variables of each SUBST block are parameterized with the
6079: identifier from the first line (fix-paths in this case.) They can be seen as
6080: parameters to a function call.
6081:
6082: SUBST_STAGE.* specifies the stage at which the replacement will take place. All
6083: combinations of pre-, do- and post- together with a phase name are possible,
6084: though only few are actually used. Most commonly used are post-patch and
6085: pre-configure. Of these two, pre-configure should be preferred because then it
6086: is possible to run bmake patch and have the state after applying the patches
6087: but before making any other changes. This is especially useful when you are
6088: debugging a package in order to create new patches for it. Similarly,
6089: post-build is preferred over pre-install, because the install phase should
6090: generally be kept as simple as possible. When you use post-build, you have the
6091: same files in the working directory that will be installed later, so you can
6092: check if the substitution has succeeded.
6093:
6094: SUBST_MESSAGE.* is an optional text that is printed just before the
6095: substitution is done.
6096:
6097: SUBST_FILES.* is the list of shell globbing patterns that specifies the files
6098: in which the substitution will take place. The patterns are interpreted
6099: relatively to the WRKSRC directory.
6100:
6101: SUBST_SED.* is a list of arguments to sed(1) that specify the actual
6102: substitution. Every sed command should be prefixed with -e, so that all SUBST
6103: blocks look uniform.
6104:
6105: There are some more variables, but they are so seldomly used that they are only
6106: documented in the mk/subst.mk file.
6107:
1.108 rillig 6108: 19.2. The fetch phase
1.1 dsieger 6109:
1.6 rillig 6110: 19.2.1. Packages whose distfiles aren't available for plain downloading
1.1 dsieger 6111:
6112: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
6113: a make fetch will call files/getsite.sh with the name of each file to download
6114: as an argument, expecting it to output the URL of the directory from which to
6115: download it. graphics/ns-cult3d is an example of this usage.
6116:
6117: If the download can't be automated, because the user must submit personal
6118: information to apply for a password, or must pay for the source, or whatever,
6119: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
6120: before aborting the build. Example:
6121:
6122: FETCH_MESSAGE= "Please download the files"
6123: FETCH_MESSAGE+= " "${DISTFILES:Q}
6124: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
6125:
1.6 rillig 6126: 19.2.2. How to handle modified distfiles with the 'old' name
1.1 dsieger 6127:
6128: Sometimes authors of a software package make some modifications after the
6129: software was released, and they put up a new distfile without changing the
6130: package's version number. If a package is already in pkgsrc at that time, the
6131: checksum will no longer match. The contents of the new distfile should be
6132: compared against the old one before changing anything, to make sure the
6133: distfile was really updated on purpose, and that no trojan horse or so crept
6134: in. Please mention that the distfiles were compared and what was found in your
1.54 rodent 6135: commit message.
6136:
6137: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109 wiz 6138: directory name, usually based on PKGNAME_NOREV (but take care with python or
6139: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
6140: PATCHFILES for this package will be put in that subdirectory of the local
6141: distfiles directory. (See Section 19.1.10, "How to handle incrementing versions
6142: when fixing an existing package" for more details.) In case this happens more
6143: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
6144: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54 rodent 6145:
6146: DIST_SUBDIR is also used when a distfile's name does not contain a version and
6147: the distfile is apt to change. In cases where the likelihood of this is very
6148: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
6149: removed unless the distfile name changes, even if a package is being moved or
6150: renamed.
6151:
6152: Do not forget regenerating the distinfo file after that, since it contains the
6153: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
6154: installed package is different. Furthermore, a mail to the package's authors
6155: seems appropriate telling them that changing distfiles after releases without
6156: changing the file names is not good practice.
1.1 dsieger 6157:
1.88 tnn 6158: 19.2.3. Packages hosted on github.com
6159:
1.90 tnn 6160: Helper methods exist for packages hosted on github.com which will often have
6161: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
6162: of the three recipes from below:
1.88 tnn 6163:
6164: 19.2.3.1. Fetch based on a tagged release
6165:
6166: If your distfile URL looks similar to http://github.com/username/exampleproject
6167: /archive/v1.0.zip, then you are packaging a tagged release.
6168:
6169: DISTNAME= exampleproject-1.0
1.90 tnn 6170: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
6171: #GITHUB_PROJECT= # can be omitted if same as DISTNAME
6172: GITHUB_TAG= v${PKGVERSION_NOREV}
1.88 tnn 6173: EXTRACT_SUFX= .zip
6174:
6175: 19.2.3.2. Fetch based on a specific commit
6176:
6177: If your distfile URL looks similar to http://github.com/example/example/archive
6178: /988881adc9fc3655077dc2d4d757d480b5ea0e11.tar.gz, then you are packaging a
6179: specific commit not tied to a release.
6180:
6181: DISTNAME= example-1.0
1.107 jnemeth 6182: MASTER_SITES= ${MASTER_SITE_GITHUB:=example/}
1.90 tnn 6183: #GITHUB_PROJECT= # can be omitted if same as DISTNAME
6184: GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88 tnn 6185:
6186: 19.2.3.3. Fetch based on release
6187:
6188: If your distfile URL looks similar to http://github.com/username/exampleproject
6189: /releases/download/rel-1.6/offensive-1.6.zip, then you are packaging a release.
6190:
1.90 tnn 6191: DISTNAME= offensive-1.6
1.88 tnn 6192: PKGNAME= ${DISTNAME:S/offensive/proper/}
1.90 tnn 6193: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
6194: GITHUB_PROJECT= exampleproject
6195: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
6196: EXTRACT_SUFX= .zip
1.88 tnn 6197:
1.108 rillig 6198: 19.3. The configure phase
1.1 dsieger 6199:
1.6 rillig 6200: 19.3.1. Shared libraries - libtool
1.1 dsieger 6201:
6202: pkgsrc supports many different machines, with different object formats like
6203: a.out and ELF, and varying abilities to do shared library and dynamic loading
6204: at all. To accompany this, varying commands and options have to be passed to
6205: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
6206: especially if you don't have all the machines at your hand to test things. The
6207: devel/libtool pkg can help here, as it just "knows" how to build both static
6208: and dynamic libraries from a set of source files, thus being
6209: platform-independent.
6210:
6211: Here's how to use libtool in a package in seven simple steps:
6212:
6213: 1. Add USE_LIBTOOL=yes to the package Makefile.
6214:
6215: 2. For library objects, use "${LIBTOOL} --mode=compile ${CC}" in place of "$
6216: {CC}". You could even add it to the definition of CC, if only libraries are
6217: being built in a given Makefile. This one command will build both PIC and
6218: non-PIC library objects, so you need not have separate shared and
6219: non-shared library rules.
6220:
6221: 3. For the linking of the library, remove any "ar", "ranlib", and "ld
6222: -Bshareable" commands, and instead use:
6223:
6224: ${LIBTOOL} --mode=link \
6225: ${CC} -o ${.TARGET:.a=.la} \
6226: ${OBJS:.o=.lo} \
6227: -rpath ${PREFIX}/lib \
6228: -version-info major:minor
6229:
6230: Note that the library is changed to have a .la extension, and the objects
6231: are changed to have a .lo extension. Change OBJS as necessary. This
6232: automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
6233: necessary) in the build directory. Be sure to include "-version-info",
6234: especially when major and minor are zero, as libtool will otherwise strip
6235: off the shared library version.
6236:
6237: From the libtool manual:
6238:
6239: So, libtool library versions are described by three integers:
6240:
6241: CURRENT
6242: The most recent interface number that this library implements.
6243:
6244: REVISION
6245: The implementation number of the CURRENT interface.
6246:
6247: AGE
6248: The difference between the newest and oldest interfaces that
6249: this library implements. In other words, the library implements
6250: all the interface numbers in the range from number `CURRENT -
6251: AGE' to `CURRENT'.
6252:
6253: If two libraries have identical CURRENT and AGE numbers, then the
6254: dynamic linker chooses the library with the greater REVISION number.
6255:
6256: The "-release" option will produce different results for a.out and ELF
1.25 wiz 6257: (excluding symlinks) in only one case. An ELF library of the form "
6258: libfoo-release.so.x.y" will have a symlink of "libfoo.so.x.y" on an a.out
1.1 dsieger 6259: platform. This is handled automatically.
6260:
6261: The "-rpath argument" is the install directory of the library being built.
6262:
6263: In the PLIST, include only the .la file, the other files will be added
6264: automatically.
6265:
6266: 4. When linking shared object (.so) files, i.e. files that are loaded via
6267: dlopen(3), NOT shared libraries, use "-module -avoid-version" to prevent
6268: them getting version tacked on.
6269:
6270: The PLIST file gets the foo.so entry.
6271:
6272: 5. When linking programs that depend on these libraries before they are
6273: installed, preface the cc(1) or ld(1) line with "${LIBTOOL} --mode=link",
6274: and it will find the correct libraries (static or shared), but please be
6275: aware that libtool will not allow you to specify a relative path in -L
6276: (such as "-L../somelib"), because it expects you to change that argument to
6277: be the .la file. e.g.
6278:
6279: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
6280:
6281: should be changed to:
6282:
6283: ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
6284:
6285: and it will do the right thing with the libraries.
6286:
6287: 6. When installing libraries, preface the install(1) or cp(1) command with "$
6288: {LIBTOOL} --mode=install", and change the library name to .la. e.g.
6289:
1.23 jakllsch 6290: ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1 dsieger 6291:
6292: This will install the static .a, shared library, any needed symlinks, and
6293: run ldconfig(8).
6294:
6295: 7. In your PLIST, include only the .la file (this is a change from previous
6296: behaviour).
6297:
1.6 rillig 6298: 19.3.2. Using libtool on GNU packages that already support libtool
1.1 dsieger 6299:
6300: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
6301: own libtool in most cases. For older libtool using packages, libtool is made by
6302: ltconfig script during the do-configure step; you can check the libtool script
6303: location by doing make configure; find work*/ -name libtool.
6304:
6305: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
6306: override. By default, it is set to "libtool */libtool */*/libtool". If this
6307: does not match the location of the package's libtool script(s), set it as
6308: appropriate.
6309:
6310: If you do not need *.a static libraries built and installed, then use
6311: SHLIBTOOL_OVERRIDE instead.
6312:
6313: If your package makes use of the platform-independent library for loading
6314: dynamic shared objects, that comes with libtool (libltdl), you should include
6315: devel/libltdl/buildlink3.mk.
6316:
6317: Some packages use libtool incorrectly so that the package may not work or build
6318: in some circumstances. Some of the more common errors are:
6319:
6320: * The inclusion of a shared object (-module) as a dependent library in an
6321: executable or library. This in itself isn't a problem if one of two things
6322: has been done:
6323:
6324: 1. The shared object is named correctly, i.e. libfoo.la, not foo.la
6325:
6326: 2. The -dlopen option is used when linking an executable.
6327:
6328: * The use of libltdl without the correct calls to initialisation routines.
6329: The function lt_dlinit() should be called and the macro
6330: LTDL_SET_PRELOADED_SYMBOLS included in executables.
6331:
1.6 rillig 6332: 19.3.3. GNU Autoconf/Automake
1.1 dsieger 6333:
6334: If a package needs GNU autoconf or automake to be executed to regenerate the
6335: configure script and Makefile.in makefile templates, then they should be
6336: executed in a pre-configure target.
6337:
6338: For packages that need only autoconf:
6339:
6340: AUTOCONF_REQD= 2.50 # if default version is not good enough
6341: USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
6342: ...
6343:
6344: pre-configure:
6345: cd ${WRKSRC} && autoconf
6346:
6347: ...
6348:
6349: and for packages that need automake and autoconf:
6350:
6351: AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
6352: USE_TOOLS+= automake # use "automake14" for automake-1.4
6353: ...
6354:
6355: pre-configure:
6356: set -e; cd ${WRKSRC}; \
6357: aclocal; autoheader; automake -a --foreign -i; autoconf
6358:
6359: ...
6360:
6361: Packages which use GNU Automake will almost certainly require GNU Make.
6362:
6363: There are times when the configure process makes additional changes to the
6364: generated files, which then causes the build process to try to re-execute the
6365: automake sequence. This is prevented by touching various files in the configure
6366: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
6367: NO in the package Makefile.
6368:
1.6 rillig 6369: 19.4. Programming languages
1.1 dsieger 6370:
1.6 rillig 6371: 19.4.1. C, C++, and Fortran
1.1 dsieger 6372:
6373: Compilers for the C, C++, and Fortran languages comes with the NetBSD base
6374: system. By default, pkgsrc assumes that a package is written in C and will hide
1.6 rillig 6375: all other compilers (via the wrapper framework, see Chapter 14, Buildlink
1.1 dsieger 6376: methodology).
6377:
6378: To declare which language's compiler a package needs, set the USE_LANGUAGES
6379: variable. Allowed values currently are "c", "c++", and "fortran" (and any
6380: combination). The default is "c". Packages using GNU configure scripts, even if
6381: written in C++, usually need a C compiler for the configure phase.
6382:
1.6 rillig 6383: 19.4.2. Java
1.1 dsieger 6384:
6385: If a program is written in Java, use the Java framework in pkgsrc. The package
6386: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
6387: variables:
6388:
6389: * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
6390: set to "run", then there is only a runtime dependency on the JDK. The
6391: default is "yes", which also adds a build dependency on the JDK.
6392:
6393: * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
6394: supported values are "yes", "1.4", and "1.5". "yes" accepts any Java2
6395: implementation, "1.4" insists on versions 1.4 or above, and "1.5" only
6396: accepts versions 1.5 or above. This variable is not set by default.
6397:
1.25 wiz 6398: * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
6399: implementation dependency. It may be used to set JAVA_HOME to a good value
6400: if the program needs this variable to be defined.
6401:
1.6 rillig 6402: 19.4.3. Packages containing perl scripts
1.1 dsieger 6403:
6404: If your package contains interpreted perl scripts, add "perl" to the USE_TOOLS
6405: variable and set REPLACE_PERL to ensure that the proper interpreter path is
6406: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74 wiz 6407: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
6408: replaced with the full path to the perl executable.
1.1 dsieger 6409:
6410: If a particular version of perl is needed, set the PERL5_REQD variable to the
6411: version number. The default is "5.0".
6412:
1.6 rillig 6413: See Section 19.6.6, "Packages installing perl modules" for information about
1.1 dsieger 6414: handling perl modules.
6415:
1.41 wiz 6416: 19.4.4. Packages containing shell scripts
6417:
6418: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
6419: shell hash bangs in files. Please use the appropriate one, prefering REPLACE_SH
1.74 wiz 6420: in case this shell is sufficient. Each should contain a list of scripts,
6421: relative to WRKSRC, that you want adjusted. Every occurrence of the matching
6422: shell in a she-bang line will be replaced with the full path to the shell
6423: executable. When using REPLACE_BASH, don't forget to add bash to USE_TOOLS.
1.41 wiz 6424:
6425: 19.4.5. Other programming languages
1.1 dsieger 6426:
6427: Currently, there is no special handling for other languages in pkgsrc. If a
6428: compiler package provides a buildlink3.mk file, include that, otherwise just
6429: add a (build) dependency on the appropriate compiler package.
6430:
1.108 rillig 6431: 19.5. The build phase
1.1 dsieger 6432:
6433: The most common failures when building a package are that some platforms do not
6434: provide certain header files, functions or libraries, or they provide the
6435: functions in a library that the original package author didn't know. To work
6436: around this, you can rewrite the source code in most cases so that it does not
6437: use the missing functions or provides a replacement function.
6438:
1.6 rillig 6439: 19.5.1. Compiling C and C++ code conditionally
1.1 dsieger 6440:
6441: If a package already comes with a GNU configure script, the preferred way to
6442: fix the build failure is to change the configure script, not the code. In the
6443: other cases, you can utilize the C preprocessor, which defines certain macros
6444: depending on the operating system and hardware architecture it compiles for.
6445: These macros can be queried using for example #if defined(__i386). Almost every
6446: operating system, hardware architecture and compiler has its own macro. For
6447: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
6448: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
6449: GCC.
6450:
6451: The list of the following macros for hardware and operating system depends on
6452: the compiler that is used. For example, if you want to conditionally compile
6453: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
6454: Use __sun instead.
6455:
1.6 rillig 6456: 19.5.1.1. C preprocessor macros to identify the operating system
1.1 dsieger 6457:
6458: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
6459: should use the following code.
6460:
6461: #include <sys/param.h>
6462: #if (defined(BSD) && BSD >= 199306)
6463: /* BSD-specific code goes here */
6464: #else
6465: /* non-BSD-specific code goes here */
6466: #endif
6467:
6468: If this distinction is not fine enough, you can also test for the following
6469: macros.
6470:
1.46 obache 6471: Cygwin __CYGWIN__
6472: DragonFly __DragonFly__
1.1 dsieger 6473: FreeBSD __FreeBSD__
1.46 obache 6474: Haiku __HAIKU__
1.1 dsieger 6475: Interix __INTERIX
6476: IRIX __sgi (TODO: get a definite source for this)
6477: Linux linux, __linux, __linux__
1.83 dholland 6478: Mac OS X __APPLE__
1.46 obache 6479: MirBSD __MirBSD__ (__OpenBSD__ is also defined)
6480: Minix3 __minix
1.1 dsieger 6481: NetBSD __NetBSD__
6482: OpenBSD __OpenBSD__
6483: Solaris sun, __sun
6484:
1.6 rillig 6485: 19.5.1.2. C preprocessor macros to identify the hardware architecture
1.1 dsieger 6486:
6487: i386 i386, __i386, __i386__
6488: MIPS __mips
6489: SPARC sparc, __sparc
6490:
1.6 rillig 6491: 19.5.1.3. C preprocessor macros to identify the compiler
1.1 dsieger 6492:
6493: GCC __GNUC__ (major version), __GNUC_MINOR__
6494: MIPSpro _COMPILER_VERSION (0x741 for MIPSpro 7.41)
6495: SunPro __SUNPRO_C (0x570 for Sun C 5.7)
6496: SunPro C++ __SUNPRO_CC (0x580 for Sun C++ 5.8)
6497:
1.6 rillig 6498: 19.5.2. How to handle compiler bugs
1.1 dsieger 6499:
6500: Some source files trigger bugs in the compiler, based on combinations of
6501: compiler version and architecture and almost always relation to optimisation
6502: being enabled. Common symptoms are gcc internal errors or never finishing
6503: compiling a file.
6504:
6505: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87 tnn 6506: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
6507:
6508: This used to be a big problem in the past, but is rarely needed now as compiler
6509: technology has matured. If you still need to add a compiler specific
6510: workaround, please do so in the file hacks.mk and describe the symptom and
6511: compiler version as detailed as possible.
1.1 dsieger 6512:
1.6 rillig 6513: 19.5.3. Undefined reference to "..."
1.1 dsieger 6514:
6515: This error message often means that a package did not link to a shared library
6516: it needs. The following functions are known to cause this error message over
6517: and over.
6518:
6519: +-----------------------------------------------------+
6520: | Function |Library |Affected platforms|
6521: |-------------------------+--------+------------------|
6522: |accept, bind, connect |-lsocket|Solaris |
6523: |-------------------------+--------+------------------|
6524: |crypt |-lcrypt |DragonFly, NetBSD |
6525: |-------------------------+--------+------------------|
6526: |dlopen, dlsym |-ldl |Linux |
6527: |-------------------------+--------+------------------|
6528: |gethost* |-lnsl |Solaris |
6529: |-------------------------+--------+------------------|
6530: |inet_aton |-lresolv|Solaris |
6531: |-------------------------+--------+------------------|
6532: |nanosleep, sem_*, timer_*|-lrt |Solaris |
6533: |-------------------------+--------+------------------|
6534: |openpty |-lutil |Linux |
6535: +-----------------------------------------------------+
6536:
6537: To fix these linker errors, it is often sufficient to say LIBS.OperatingSystem+
6538: = -lfoo to the package Makefile and then say bmake clean; bmake.
6539:
1.6 rillig 6540: 19.5.3.1. Special issue: The SunPro compiler
1.1 dsieger 6541:
6542: When you are using the SunPro compiler, there is another possibility. That
6543: compiler cannot handle the following code:
6544:
6545: extern int extern_func(int);
6546:
6547: static inline int
6548: inline_func(int x)
6549: {
6550: return extern_func(x);
6551: }
6552:
6553: int main(void)
6554: {
6555: return 0;
6556: }
6557:
6558: It generates the code for inline_func even if that function is never used. This
6559: code then refers to extern_func, which can usually not be resolved. To solve
6560: this problem you can try to tell the package to disable inlining of functions.
6561:
1.6 rillig 6562: 19.5.4. Running out of memory
1.1 dsieger 6563:
6564: Sometimes packages fail to build because the compiler runs into an operating
6565: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.94 wiz 6566: told to unlimit the resources. Currently, the allowed values are any
6567: combination of "cputime", "datasize", "memorysize", and "stacksize". Setting
6568: this variable is similar to running the shell builtin ulimit command to raise
6569: the maximum data segment size or maximum stack size of a process, respectively,
6570: to their hard limits.
1.1 dsieger 6571:
1.108 rillig 6572: 19.6. The install phase
1.1 dsieger 6573:
1.6 rillig 6574: 19.6.1. Creating needed directories
1.1 dsieger 6575:
6576: The BSD-compatible install supplied with some operating systems cannot create
6577: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
6578: like this:
6579:
6580: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
6581: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
6582:
6583: You can also just append "dir1 dir2" to the INSTALLATION_DIRS variable, which
6584: will automatically do the right thing.
6585:
1.6 rillig 6586: 19.6.2. Where to install documentation
1.1 dsieger 6587:
6588: In general, documentation should be installed into ${PREFIX}/share/doc/$
6589: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME} (the latter includes the version
6590: number of the package).
6591:
6592: Many modern packages using GNU autoconf allow to set the directory where HTML
6593: documentation is installed with the "--with-html-dir" option. Sometimes using
6594: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
6595: share/doc/html or other places.
6596:
6597: An exception to the above is that library API documentation generated with the
6598: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
6599: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
6600: can be recognized from files ending in .devhelp or .devhelp2. (It is also
6601: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
6602: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
6603: then, no additional subdirectory level is allowed in this case. This is usually
6604: achieved by using "--with-html-dir=${PREFIX}/share/doc". ${PREFIX}/share/
6605: gtk-doc is preferred though.)
6606:
1.6 rillig 6607: 19.6.3. Installing highscore files
1.1 dsieger 6608:
6609: Certain packages, most of them in the games category, install a score file that
6610: allows all users on the system to record their highscores. In order for this to
6611: work, the binaries need to be installed setgid and the score files owned by the
1.36 wiz 6612: appropriate group and/or owner (traditionally the "games" user/group). Set
6613: USE_GAMESGROUP to yes to support this. The following variables, documented in
6614: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100 leot 6615: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
6616: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
6617:
6618: An example that illustrates some of the variables described above is games/
6619: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
6620: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
6621: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
6622: to install setgid the game binary:
6623:
6624: USE_GAMESGROUP= yes
6625:
6626: BUILD_DEFS+= VARBASE
6627:
6628: OWN_DIRS_PERMS+= ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
6629: REQD_FILES_PERMS+= /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
6630: SPECIAL_PERMS+= ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
6631:
6632: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
6633: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
6634: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1 dsieger 6635:
1.14 jmcneill 6636: A package should therefore never hard code file ownership or access permissions
1.100 leot 6637: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
6638: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1 dsieger 6639:
1.6 rillig 6640: 19.6.4. Adding DESTDIR support to packages
1.4 rillig 6641:
1.14 jmcneill 6642: DESTDIR support means that a package installs into a staging directory, not the
6643: final location of the files. Then a binary package is created which can be used
6644: for installation as usual. There are two ways: Either the package must install
1.25 wiz 6645: as root ("destdir") or the package can install as non-root user ("user-destdir"
6646: ).
1.14 jmcneill 6647:
1.39 wiz 6648: * PKG_DESTDIR_SUPPORT has to be set to "none", "destdir", or "user-destdir".
6649: By default PKG_DESTDIR_SUPPORT is set to "user-destdir" to help catching
6650: more potential packaging problems. If bsd.prefs.mk is included in the
6651: Makefile, PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14 jmcneill 6652:
1.4 rillig 6653: * All installation operations have to be prefixed with ${DESTDIR}.
6654:
6655: * automake gets this DESTDIR mostly right automatically. Many manual rules
6656: and pre/post-install often are incorrect; fix them.
6657:
1.17 imil 6658: * If files are installed with special owner/group use SPECIAL_PERMS.
1.4 rillig 6659:
6660: * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
6661:
1.6 rillig 6662: 19.6.5. Packages with hardcoded paths to other interpreters
1.1 dsieger 6663:
6664: Your package may also contain scripts with hardcoded paths to other
6665: interpreters besides (or as well as) perl. To correct the full pathname to the
6666: script interpreter, you need to set the following definitions in your Makefile
6667: (we shall use tclsh in this example):
6668:
6669: REPLACE_INTERPRETER+= tcl
6670: REPLACE.tcl.old= .*/bin/tclsh
6671: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
6672: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
6673: # relative to ${WRKSRC}, just as in REPLACE_PERL
6674:
6675: Note
6676:
6677: Before March 2006, these variables were called _REPLACE.* and _REPLACE_FILES.*.
6678:
1.6 rillig 6679: 19.6.6. Packages installing perl modules
1.1 dsieger 6680:
6681: Makefiles of packages providing perl5 modules should include the Makefile
6682: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
6683: standard perl configuration for such modules as well as various hooks to tune
6684: this configuration. See comments in this file for details.
6685:
6686: Perl5 modules will install into different places depending on the version of
6687: perl used during the build process. To address this, pkgsrc will append lines
6688: to the PLIST corresponding to the files listed in the installed .packlist file
6689: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48 wiz 6690: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
6691: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1 dsieger 6692:
1.48 wiz 6693: PERL5_PACKLIST= auto/Pg/.packlist
1.1 dsieger 6694:
1.48 wiz 6695: The perl5 config variables installarchlib, installscript, installvendorbin,
6696: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
6697: and installvendorman3dir represent those locations in which components of perl5
6698: modules may be installed, provided as variable with uppercase and prefixed with
6699: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
6700: have a packlist. These variables are also substituted for in the PLIST as
6701: uppercase prefixed with PERL5_SUB_.
1.1 dsieger 6702:
1.6 rillig 6703: 19.6.7. Packages installing info files
1.1 dsieger 6704:
6705: Some packages install info files or use the "makeinfo" or "install-info"
6706: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
6707: and DEINSTALL scripts will be generated to handle registration of the info
6708: files in the Info directory file. The "install-info" command used for the info
6709: files registration is either provided by the system, or by a special purpose
6710: package automatically added as dependency if needed.
6711:
6712: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
6713: located. PKGINFODIR defaults to "info" and can be overridden by the user.
6714:
6715: The info files for the package should be listed in the package PLIST; however
6716: any split info files need not be listed.
6717:
6718: A package which needs the "makeinfo" command at build time must add "makeinfo"
6719: to USE_TOOLS in its Makefile. If a minimum version of the "makeinfo" command is
6720: needed it should be noted with the TEXINFO_REQD variable in the package
6721: Makefile. By default, a minimum version of 3.12 is required. If the system does
6722: not provide a makeinfo command or if it does not match the required minimum, a
6723: build dependency on the devel/gtexinfo package will be added automatically.
6724:
6725: The build and installation process of the software provided by the package
6726: should not use the install-info command as the registration of info files is
1.25 wiz 6727: the task of the package INSTALL script, and it must use the appropriate
1.1 dsieger 6728: makeinfo command.
6729:
6730: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
6731: the install-info and makeinfo commands in a directory listed early in PATH.
6732:
6733: The script overriding install-info has no effect except the logging of a
6734: message. The script overriding makeinfo logs a message and according to the
6735: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
6736: error.
6737:
1.6 rillig 6738: 19.6.8. Packages installing man pages
1.1 dsieger 6739:
6740: All packages that install manual pages should install them into the same
6741: directory, so that there is one common place to look for them. In pkgsrc, this
6742: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.25 wiz 6743: packages. The default for PKGMANDIR is "man". Another often-used value is "
6744: share/man".
1.1 dsieger 6745:
6746: Note
6747:
6748: The support for a custom PKGMANDIR is far from complete.
6749:
6750: The PLIST files can just use man/ as the top level directory for the man page
6751: file entries, and the pkgsrc framework will convert as needed. In all other
6752: places, the correct PKGMANDIR must be used.
6753:
6754: Packages that are configured with GNU_CONFIGURE set as "yes", by default will
6755: use the ./configure --mandir switch to set where the man pages should be
6756: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
6757: {PKGMANDIR}.
6758:
6759: Packages that use GNU_CONFIGURE but do not use --mandir, can set
6760: CONFIGURE_HAS_MANDIR to "no". Or if the ./configure script uses a non-standard
6761: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
6762:
1.6 rillig 6763: See Section 13.5, "Man page compression" for information on installation of
1.1 dsieger 6764: compressed manual pages.
6765:
1.7 rillig 6766: 19.6.9. Packages installing GConf data files
1.1 dsieger 6767:
1.7 rillig 6768: If a package installs .schemas or .entries files, used by GConf, you need to
1.1 dsieger 6769: take some extra steps to make sure they get registered in the database:
6770:
1.7 rillig 6771: 1. Include ../../devel/GConf/schemas.mk instead of its buildlink3.mk file.
6772: This takes care of rebuilding the GConf database at installation and
6773: deinstallation time, and tells the package where to install GConf data
1.1 dsieger 6774: files using some standard configure arguments. It also disallows any access
6775: to the database directly from the package.
6776:
6777: 2. Ensure that the package installs its .schemas files under ${PREFIX}/share/
6778: gconf/schemas. If they get installed under ${PREFIX}/etc, you will need to
6779: manually patch the package.
6780:
6781: 3. Check the PLIST and remove any entries under the etc/gconf directory, as
1.84 wiz 6782: they will be handled automatically. See Section 9.13, "How do I change the
1.1 dsieger 6783: location of configuration files?" for more information.
6784:
1.7 rillig 6785: 4. Define the GCONF_SCHEMAS variable in your Makefile with a list of all
1.1 dsieger 6786: .schemas files installed by the package, if any. Names must not contain any
6787: directories in them.
6788:
1.7 rillig 6789: 5. Define the GCONF_ENTRIES variable in your Makefile with a list of all
1.1 dsieger 6790: .entries files installed by the package, if any. Names must not contain any
6791: directories in them.
6792:
1.18 mishka 6793: 19.6.10. Packages installing scrollkeeper/rarian data files
1.1 dsieger 6794:
1.18 mishka 6795: If a package installs .omf files, used by scrollkeeper/rarian, you need to take
6796: some extra steps to make sure they get registered in the database:
1.1 dsieger 6797:
1.18 mishka 6798: 1. Include ../../mk/omf-scrollkeeper.mk instead of rarian's buildlink3.mk
6799: file. This takes care of rebuilding the scrollkeeper database at
6800: installation and deinstallation time, and disallows any access to it
6801: directly from the package.
1.1 dsieger 6802:
6803: 2. Check the PLIST and remove any entries under the libdata/scrollkeeper
6804: directory, as they will be handled automatically.
6805:
6806: 3. Remove the share/omf directory from the PLIST. It will be handled by
1.18 mishka 6807: rarian. (make print-PLIST does this automatically.)
1.1 dsieger 6808:
1.6 rillig 6809: 19.6.11. Packages installing X11 fonts
1.1 dsieger 6810:
6811: If a package installs font files, you will need to rebuild the fonts database
6812: in the directory where they get installed at installation and deinstallation
6813: time. This can be automatically done by using the pkginstall framework.
6814:
6815: You can list the directories where fonts are installed in the FONTS_DIRS.type
6816: variables, where type can be one of "ttf", "type1" or "x11". Also make sure
6817: that the database file fonts.dir is not listed in the PLIST.
6818:
6819: Note that you should not create new directories for fonts; instead use the
6820: standard ones to avoid that the user needs to manually configure his X server
6821: to find them.
6822:
1.6 rillig 6823: 19.6.12. Packages installing GTK2 modules
1.1 dsieger 6824:
6825: If a package installs GTK2 immodules or loaders, you need to take some extra
6826: steps to get them registered in the GTK2 database properly:
6827:
6828: 1. Include ../../x11/gtk2/modules.mk instead of its buildlink3.mk file. This
6829: takes care of rebuilding the database at installation and deinstallation
6830: time.
6831:
6832: 2. Set GTK2_IMMODULES=YES if your package installs GTK2 immodules.
6833:
6834: 3. Set GTK2_LOADERS=YES if your package installs GTK2 loaders.
6835:
6836: 4. Patch the package to not touch any of the GTK2 databases directly. These
6837: are:
6838:
1.42 asau 6839: + libdata/gtk-2.0/gdk-pixbuf.loaders
1.1 dsieger 6840:
1.42 asau 6841: + libdata/gtk-2.0/gtk.immodules
1.1 dsieger 6842:
6843: 5. Check the PLIST and remove any entries under the libdata/gtk-2.0 directory,
6844: as they will be handled automatically.
6845:
1.6 rillig 6846: 19.6.13. Packages installing SGML or XML data
1.1 dsieger 6847:
6848: If a package installs SGML or XML data files that need to be registered in
6849: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
6850: extra steps:
6851:
6852: 1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
6853: care of registering those files in system-wide catalogs at installation and
6854: deinstallation time.
6855:
6856: 2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
6857: package.
6858:
6859: 3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
6860: package.
6861:
6862: 4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
6863: These come in groups of three strings; see xmlcatmgr(1) for more
6864: information (specifically, arguments recognized by the 'add' action). Note
6865: that you will normally not use this variable.
6866:
6867: 5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
6868: come in groups of three strings; see xmlcatmgr(1) for more information
6869: (specifically, arguments recognized by the 'add' action). Note that you
6870: will normally not use this variable.
6871:
1.6 rillig 6872: 19.6.14. Packages installing extensions to the MIME database
1.1 dsieger 6873:
6874: If a package provides extensions to the MIME database by installing .xml files
6875: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
6876: ensure that the database is kept consistent with respect to these new files:
6877:
6878: 1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
6879: buildlink3.mk file from this same directory, which is reserved for
6880: inclusion from other buildlink3.mk files). It takes care of rebuilding the
6881: MIME database at installation and deinstallation time, and disallows any
6882: access to it directly from the package.
6883:
1.25 wiz 6884: 2. Check the PLIST and remove any entries under the share/mime directory,
1.1 dsieger 6885: except for files saved under share/mime/packages. The former are handled
6886: automatically by the update-mime-database program, but the latter are
6887: package-dependent and must be removed by the package that installed them in
6888: the first place.
6889:
6890: 3. Remove any share/mime/* directories from the PLIST. They will be handled by
6891: the shared-mime-info package.
6892:
1.6 rillig 6893: 19.6.15. Packages using intltool
1.1 dsieger 6894:
6895: If a package uses intltool during its build, add intltool to the USE_TOOLS,
6896: which forces it to use the intltool package provided by pkgsrc, instead of the
6897: one bundled with the distribution file.
6898:
6899: This tracks intltool's build-time dependencies and uses the latest available
6900: version; this way, the package benefits of any bug fixes that may have appeared
6901: since it was released.
6902:
1.6 rillig 6903: 19.6.16. Packages installing startup scripts
1.1 dsieger 6904:
6905: If a package contains a rc.d script, it won't be copied into the startup
6906: directory by default, but you can enable it, by adding the option
1.4 rillig 6907: PKG_RCD_SCRIPTS=YES in mk.conf. This option will copy the scripts into /etc/
6908: rc.d when a package is installed, and it will automatically remove the scripts
6909: when the package is deinstalled.
1.1 dsieger 6910:
1.6 rillig 6911: 19.6.17. Packages installing TeX modules
1.1 dsieger 6912:
6913: If a package installs TeX packages into the texmf tree, the ls-R database of
6914: the tree needs to be updated.
6915:
6916: Note
6917:
1.23 jakllsch 6918: Except the main TeX packages such as kpathsea, packages should install files
6919: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1 dsieger 6920:
1.23 jakllsch 6921: 1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
6922: ls-R database at installation and deinstallation time.
1.1 dsieger 6923:
1.23 jakllsch 6924: 2. If your package installs files into a texmf tree other than the one at $
6925: {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
6926: trees that need database update.
1.1 dsieger 6927:
6928: If your package also installs font map files that need to be registered
1.30 dholland 6929: using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
6930: and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then
6931: updmap will be run automatically at installation/deinstallation to enable/
6932: disable font map files for TeX output drivers.
1.1 dsieger 6933:
6934: 3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30 dholland 6935: be removed only by the kpathsea package.
1.1 dsieger 6936:
1.6 rillig 6937: 19.6.18. Packages supporting running binaries in emulation
1.1 dsieger 6938:
6939: There are some packages that provide libraries and executables for running
6940: binaries from a one operating system on a different one (if the latter supports
6941: it). One example is running Linux binaries on NetBSD.
6942:
6943: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
6944:
6945: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
6946: if all libraries for each installed executable can be found by the dynamic
6947: linker. Since the standard dynamic linker is run, this fails for emulation
6948: packages, because the libraries used by the emulation are not in the standard
6949: directories.
6950:
1.6 rillig 6951: 19.6.19. Packages installing hicolor theme icons
1.1 dsieger 6952:
6953: If a package installs images under the share/icons/hicolor and/or updates the
6954: share/icons/hicolor/icon-theme.cache database, you need to take some extra
6955: steps to make sure that the shared theme directory is handled appropriately and
6956: that the cache database is rebuilt:
6957:
6958: 1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
6959:
6960: 2. Check the PLIST and remove the entry that refers to the theme cache.
6961:
6962: 3. Ensure that the PLIST does not remove the shared icon directories from the
6963: share/icons/hicolor hierarchy because they will be handled automatically.
6964:
6965: The best way to verify that the PLIST is correct with respect to the last two
6966: points is to regenerate it using make print-PLIST.
6967:
1.6 rillig 6968: 19.6.20. Packages installing desktop files
1.1 dsieger 6969:
6970: If a package installs .desktop files under share/applications and these include
1.54 rodent 6971: MIME information (MimeType key), you need to take extra steps to ensure that
6972: they are registered into the MIME database:
1.1 dsieger 6973:
6974: 1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
6975:
6976: 2. Check the PLIST and remove the entry that refers to the share/applications/
6977: mimeinfo.cache file. It will be handled automatically.
6978:
6979: The best way to verify that the PLIST is correct with respect to the last point
6980: is to regenerate it using make print-PLIST.
6981:
1.6 rillig 6982: 19.7. Marking packages as having problems
1.1 dsieger 6983:
1.23 jakllsch 6984: In some cases one does not have the time to solve a problem immediately. In
6985: this case, one can plainly mark a package as broken. For this, one just sets
6986: the variable BROKEN to the reason why the package is broken (similar to the
6987: RESTRICTED variable). A user trying to build the package will immediately be
6988: shown this message, and the build will not be even tried.
1.1 dsieger 6989:
1.23 jakllsch 6990: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1 dsieger 6991:
1.6 rillig 6992: Chapter 20. Debugging
1.1 dsieger 6993:
6994: To check out all the gotchas when building a package, here are the steps that I
6995: do in order to get a package working. Please note this is basically the same as
6996: what was explained in the previous sections, only with some debugging aids.
6997:
1.4 rillig 6998: * Be sure to set PKG_DEVELOPER=yes in mk.conf.
1.1 dsieger 6999:
7000: * Install pkgtools/url2pkg, create a directory for a new package, change into
7001: it, then run url2pkg:
7002:
7003: % mkdir /usr/pkgsrc/category/examplepkg
7004: % cd /usr/pkgsrc/category/examplepkg
7005: % url2pkg http://www.example.com/path/to/distfile.tar.gz
7006:
7007: * Edit the Makefile as requested.
7008:
7009: * Fill in the DESCR file
7010:
7011: * Run make configure
7012:
7013: * Add any dependencies glimpsed from documentation and the configure step to
7014: the package's Makefile.
7015:
7016: * Make the package compile, doing multiple rounds of
7017:
7018: % make
7019: % pkgvi ${WRKSRC}/some/file/that/does/not/compile
7020: % mkpatches
7021: % patchdiff
7022: % mv ${WRKDIR}/.newpatches/* patches
7023: % make mps
7024: % make clean
7025:
7026: Doing this step as non-root user will ensure that no files are modified
7027: that shouldn't be, especially during the build phase. mkpatches, patchdiff
7028: and pkgvi are from the pkgtools/pkgdiff package.
7029:
1.6 rillig 7030: * Look at the Makefile, fix if necessary; see Section 11.1, "Makefile".
1.1 dsieger 7031:
7032: * Generate a PLIST:
7033:
7034: # make install
7035: # make print-PLIST >PLIST
7036: # make deinstall
7037: # make install
7038: # make deinstall
7039:
7040: You usually need to be root to do this. Look if there are any files left:
7041:
7042: # make print-PLIST
7043:
7044: If this reveals any files that are missing in PLIST, add them.
7045:
7046: * Now that the PLIST is OK, install the package again and make a binary
7047: package:
7048:
7049: # make reinstall
7050: # make package
7051:
7052: * Delete the installed package:
7053:
7054: # pkg_delete examplepkg
7055:
7056: * Repeat the above make print-PLIST command, which shouldn't find anything
7057: now:
7058:
7059: # make print-PLIST
7060:
7061: * Reinstall the binary package:
7062:
7063: # pkg_add .../examplepkg.tgz
7064:
7065: * Play with it. Make sure everything works.
7066:
7067: * Run pkglint from pkgtools/pkglint, and fix the problems it reports:
7068:
7069: # pkglint
7070:
1.6 rillig 7071: * Submit (or commit, if you have cvs access); see Chapter 21, Submitting and
1.1 dsieger 7072: Committing.
7073:
1.6 rillig 7074: Chapter 21. Submitting and Committing
1.1 dsieger 7075:
7076: Table of Contents
7077:
1.6 rillig 7078: 21.1. Submitting binary packages
7079: 21.2. Submitting source packages (for non-NetBSD-developers)
7080: 21.3. General notes when adding, updating, or removing packages
1.34 wiz 7081: 21.4. Committing: Adding a package to CVS
1.6 rillig 7082: 21.5. Updating a package to a newer version
1.21 snj 7083: 21.6. Renaming a package in pkgsrc
7084: 21.7. Moving a package in pkgsrc
1.1 dsieger 7085:
1.6 rillig 7086: 21.1. Submitting binary packages
1.1 dsieger 7087:
7088: Our policy is that we accept binaries only from pkgsrc developers to guarantee
7089: that the packages don't contain any trojan horses etc. This is not to annoy
7090: anyone but rather to protect our users! You're still free to put up your
7091: home-made binary packages and tell the world where to get them. NetBSD
1.66 asau 7092: developers doing bulk builds and wanting to upload them please see Chapter 7,
7093: Creating binary packages for everything in pkgsrc (bulk builds).
1.1 dsieger 7094:
1.6 rillig 7095: 21.2. Submitting source packages (for non-NetBSD-developers)
1.1 dsieger 7096:
7097: First, check that your package is complete, compiles and runs well; see
1.6 rillig 7098: Chapter 20, Debugging and the rest of this document. Next, generate an
1.1 dsieger 7099: uuencoded gzipped tar(1) archive that contains all files that make up the
7100: package. Finally, send this package to the pkgsrc bug tracking system, either
7101: with the send-pr(1) command, or if you don't have that, go to the web page
1.4 rillig 7102: http://www.NetBSD.org/support/send-pr.html, which contains some instructions
1.22 snj 7103: and a link to a form where you can submit packages. The sysutils/gtk-send-pr
7104: package is also available as a substitute for either of the above two tools.
1.1 dsieger 7105:
7106: In the form of the problem report, the category should be "pkg", the synopsis
7107: should include the package name and version number, and the description field
7108: should contain a short description of your package (contents of the COMMENT
1.25 wiz 7109: variable or DESCR file are OK). The uuencoded package data should go into the "
7110: fix" field.
1.1 dsieger 7111:
7112: If you want to submit several packages, please send a separate PR for each one,
7113: it's easier for us to track things that way.
7114:
7115: Alternatively, you can also import new packages into pkgsrc-wip ("pkgsrc
1.105 wiz 7116: work-in-progress"); see the homepage at http://pkgsrc.org/wip/ for details.
1.1 dsieger 7117:
1.6 rillig 7118: 21.3. General notes when adding, updating, or removing packages
1.1 dsieger 7119:
7120: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
7121: CHANGES-YYYY. It's very important to keep this file up to date and conforming
7122: to the existing format, because it will be used by scripts to automatically
7123: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
7124: doc/TODO file and remove the entry for the package you updated or removed, in
7125: case it was mentioned there.
7126:
7127: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
7128: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
7129: that result from a dependency being updated should not be mentioned. In all
7130: other cases it's the developer's decision.
7131:
7132: There is a make target that helps in creating proper CHANGES-YYYY entries: make
7133: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
7134: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
7135: (to avoid having to resolve conflicts later-on) and then to cd to the package
7136: directory. For package updates, make changes-entry is enough. For new packages,
7137: or package moves or removals, set the CTYPE variable on the command line to
1.4 rillig 7138: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23 jakllsch 7139: your local login name is not the same as your NetBSD login name. The target
7140: also automatically removes possibly existing entries for the package in the
7141: TODO file. Don't forget to commit the changes, e.g. by using make
1.66 asau 7142: commit-changes-entry! If you are not using a checkout directly from
1.23 jakllsch 7143: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
7144: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1 dsieger 7145:
1.34 wiz 7146: 21.4. Committing: Adding a package to CVS
1.1 dsieger 7147:
7148: This section is only of interest for pkgsrc developers with write access to the
1.34 wiz 7149: pkgsrc repository.
7150:
7151: When the package is finished, "cvs add" the files. Start by adding the
7152: directory and then files in the directory. Don't forget to add the new package
7153: to the category's Makefile. Make sure you don't forget any files; you can check
7154: by running "cvs status". An example:
7155:
7156: $ cd .../pkgsrc/category
7157: $ cvs add pkgname
7158: $ cd pkgname
7159: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
7160: $ cvs add patches/p*
7161: $ cvs status | less
1.35 wiz 7162: $ cvs commit
1.34 wiz 7163: $ cd ..
7164: $ vi Makefile # add SUBDIRS+=pkgname line
1.35 wiz 7165: $ cvs commit Makefile
1.66 asau 7166: $ cd pkgname
1.73 jnemeth 7167: $ make CTYPE=Added commit-changes-entry
1.1 dsieger 7168:
7169: The commit message of the initial import should include part of the DESCR file,
7170: so people reading the mailing lists know what the package is/does.
7171:
1.34 wiz 7172: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
7173:
7174: Previously, "cvs import" was suggested, but it was much easier to get wrong
7175: than "cvs add".
1.1 dsieger 7176:
1.6 rillig 7177: 21.5. Updating a package to a newer version
1.1 dsieger 7178:
7179: Please always put a concise, appropriate and relevant summary of the changes
7180: between old and new versions into the commit log when updating a package. There
7181: are various reasons for this:
7182:
7183: * A URL is volatile, and can change over time. It may go away completely or
7184: its information may be overwritten by newer information.
7185:
7186: * Having the change information between old and new versions in our CVS
7187: repository is very useful for people who use either cvs or anoncvs.
7188:
7189: * Having the change information between old and new versions in our CVS
7190: repository is very useful for people who read the pkgsrc-changes mailing
7191: list, so that they can make tactical decisions about when to upgrade the
7192: package.
7193:
7194: Please also recognize that, just because a new version of a package has been
7195: released, it should not automatically be upgraded in the CVS repository. We
7196: prefer to be conservative in the packages that are included in pkgsrc -
7197: development or beta packages are not really the best thing for most places in
7198: which pkgsrc is used. Please use your judgement about what should go into
7199: pkgsrc, and bear in mind that stability is to be preferred above new and
7200: possibly untested features.
7201:
1.21 snj 7202: 21.6. Renaming a package in pkgsrc
7203:
7204: Renaming packages is not recommended.
7205:
7206: When renaming packages, be sure to fix any references to old name in other
7207: Makefiles, options, buildlink files, etc.
7208:
7209: Also When renaming a package, please define SUPERSEDES to the package name and
7210: dewey version pattern(s) of the previous package name. This may be repeated for
7211: multiple renames. The new package would be an exact replacement.
7212:
7213: Note that "successor" in the CHANGES-YYYY file doesn't necessarily mean that it
7214: supersedes, as that successor may not be an exact replacement but is a
7215: suggestion for the replaced functionality.
7216:
7217: 21.7. Moving a package in pkgsrc
7218:
7219: It is preferred that packages are not renamed or moved, but if needed please
7220: follow these steps.
1.1 dsieger 7221:
7222: 1. Make a copy of the directory somewhere else.
7223:
7224: 2. Remove all CVS dirs.
7225:
7226: Alternatively to the first two steps you can also do:
7227:
7228: % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
7229:
7230: and use that for further work.
7231:
1.25 wiz 7232: 3. Fix CATEGORIES and any DEPENDS paths that just did "../package" instead of
1.1 dsieger 7233: "../../category/package".
7234:
1.21 snj 7235: 4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
7236: previous category/package pathname. The PREV_PKGPATH can be used by tools
7237: for doing an update using pkgsrc building; for example, it can search the
7238: pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
7239: the corresponding new PKGPATH for that moved package. Note that it may have
7240: multiple matches, so the tool should also check on the PKGBASE too. The
7241: PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
7242: PKGBASE stays the same.
7243:
7244: 5. cvs import the modified package in the new place.
1.1 dsieger 7245:
1.21 snj 7246: 6. Check if any package depends on it:
1.1 dsieger 7247:
7248: % cd /usr/pkgsrc
7249: % grep /package */*/Makefile* */*/buildlink*
7250:
1.21 snj 7251: 7. Fix paths in packages from step 5 to point to new location.
1.1 dsieger 7252:
1.21 snj 7253: 8. cvs rm (-f) the package at the old location.
1.1 dsieger 7254:
1.21 snj 7255: 9. Remove from oldcategory/Makefile.
1.1 dsieger 7256:
1.21 snj 7257: 10. Add to newcategory/Makefile.
1.1 dsieger 7258:
1.21 snj 7259: 11. Commit the changed and removed files:
1.1 dsieger 7260:
7261: % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
7262:
7263: (and any packages from step 5, of course).
7264:
1.6 rillig 7265: Chapter 22. Frequently Asked Questions
1.1 dsieger 7266:
7267: This section contains the answers to questions that may arise when you are
7268: writing a package. If you don't find your question answered here, first have a
7269: look in the other chapters, and if you still don't have the answer, ask on the
7270: pkgsrc-users mailing list.
7271:
1.6 rillig 7272: 22.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
7273: 22.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
7274: 22.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
7275: 22.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1 dsieger 7276: BUILDLINK_LIBS?
1.6 rillig 7277: 22.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
7278: 22.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1 dsieger 7279: the := inside it.
1.6 rillig 7280: 22.7. Which mailing lists are there for package developers?
7281: 22.8. Where is the pkgsrc documentation?
7282: 22.9. I have a little time to kill. What shall I do?
1.1 dsieger 7283:
1.6 rillig 7284: 22.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1 dsieger 7285:
7286: MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
7287: (1), while MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM
7288: when building the package. [FIXME: What is .MAKEFLAGS for?]
7289:
1.6 rillig 7290: 22.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1 dsieger 7291:
7292: MAKE is the path to the make(1) program that is used in the pkgsrc
7293: infrastructure. GMAKE is the path to GNU Make, but you need to say
7294: USE_TOOLS+=gmake to use that. MAKE_PROGRAM is the path to the Make
7295: program that is used for building the package.
7296:
1.6 rillig 7297: 22.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1 dsieger 7298:
7299: CC is the path to the real C compiler, which can be configured by the
7300: pkgsrc user. PKG_CC is the path to the compiler wrapper. PKGSRC_COMPILER
7301: is not a path to a compiler, but the type of compiler that should be
7302: used. See mk/compiler.mk for more information about the latter variable.
7303:
1.6 rillig 7304: 22.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1 dsieger 7305: BUILDLINK_LIBS?
7306:
7307: [FIXME]
7308:
1.6 rillig 7309: 22.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1 dsieger 7310:
1.25 wiz 7311: For optimization reasons, some variables are only available in the "
7312: wrapper" phase and later. To "simulate" the wrapper phase, append
1.1 dsieger 7313: PKG_PHASE=wrapper to the above command.
7314:
1.6 rillig 7315: 22.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1 dsieger 7316: the := inside it.
7317:
1.108 rillig 7318: The := is not really an assignment operator, although it looks like it.
7319: Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
7320: is documented in the make(1) man page and which is commonly used in the
7321: form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
7322: string and new_string is package/. That's where the : and the = fall
7323: together.
1.1 dsieger 7324:
1.6 rillig 7325: 22.7. Which mailing lists are there for package developers?
1.1 dsieger 7326:
7327: tech-pkg
7328:
7329: This is a list for technical discussions related to pkgsrc
7330: development, e.g. soliciting feedback for changes to pkgsrc
7331: infrastructure, proposed new features, questions related to porting
7332: pkgsrc to a new platform, advice for maintaining a package, patches
7333: that affect many packages, help requests moved from pkgsrc-users when
7334: an infrastructure bug is found, etc.
7335:
7336: pkgsrc-bugs
7337:
7338: All bug reports in category "pkg" sent with send-pr(1) appear here.
7339: Please do not report your bugs here directly; use one of the other
7340: mailing lists.
7341:
1.6 rillig 7342: 22.8. Where is the pkgsrc documentation?
1.1 dsieger 7343:
7344: There are many places where you can find documentation about pkgsrc:
7345:
7346: * The pkgsrc guide (this document) is a collection of chapters that
7347: explain large parts of pkgsrc, but some chapters tend to be outdated.
7348: Which ones they are is hard to say.
7349:
7350: * On the mailing list archives (see http://mail-index.NetBSD.org/), you
7351: can find discussions about certain features, announcements of new
7352: parts of the pkgsrc infrastructure and sometimes even announcements
7353: that a certain feature has been marked as obsolete. The benefit here
7354: is that each message has a date appended to it.
7355:
7356: * Many of the files in the mk/ directory start with a comment that
7357: describes the purpose of the file and how it can be used by the
7358: pkgsrc user and package authors. An easy way to find this
7359: documentation is to run bmake help.
7360:
7361: * The CVS log messages are a rich source of information, but they tend
7362: to be highly abbreviated, especially for actions that occur often.
7363: Some contain a detailed description of what has changed, but they are
7364: geared towards the other pkgsrc developers, not towards an average
7365: pkgsrc user. They also only document changes, so if you don't know
7366: what has been before, these messages may not be worth too much to
7367: you.
7368:
7369: * Some parts of pkgsrc are only "implicitly documented", that is the
7370: documentation exists only in the mind of the developer who wrote the
7371: code. To get this information, use the cvs annotate command to see
7372: who has written it and ask on the tech-pkg mailing list, so that
7373: others can find your questions later (see above). To be sure that the
7374: developer in charge reads the mail, you may CC him or her.
7375:
1.6 rillig 7376: 22.9. I have a little time to kill. What shall I do?
1.1 dsieger 7377:
7378: This is not really an FAQ yet, but here's the answer anyway.
7379:
7380: * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
7381: about newer versions of installed packages that are available, but
7382: not yet updated in pkgsrc.
7383:
7384: * Browse pkgsrc/doc/TODO ? it contains a list of suggested new packages
7385: and a list of cleanups and enhancements for pkgsrc that would be nice
7386: to have.
7387:
1.71 wiz 7388: * Review packages for which review was requested on the tech-pkg
7389: mailing list.
1.1 dsieger 7390:
1.6 rillig 7391: Chapter 23. GNOME packaging and porting
1.1 dsieger 7392:
7393: Table of Contents
7394:
1.6 rillig 7395: 23.1. Meta packages
7396: 23.2. Packaging a GNOME application
7397: 23.3. Updating GNOME to a newer version
7398: 23.4. Patching guidelines
1.1 dsieger 7399:
7400: Quoting GNOME's web site:
7401:
7402: The GNOME project provides two things: The GNOME desktop environment, an
7403: intuitive and attractive desktop for users, and the GNOME development
7404: platform, an extensive framework for building applications that integrate
7405: into the rest of the desktop.
7406:
7407: pkgsrc provides a seamless way to automatically build and install a complete
7408: GNOME environment under many different platforms. We can say with confidence
7409: that pkgsrc is one of the most advanced build and packaging systems for GNOME
7410: due to its included technologies buildlink3, the wrappers and tools framework
7411: and automatic configuration file management. Lots of efforts are put into
7412: achieving a completely clean deinstallation of installed software components.
7413:
7414: Given that pkgsrc is NetBSD's official packaging system, the above also means
7415: that great efforts are put into making GNOME work under this operating system.
7416: Recently, DragonFly BSD also adopted pkgsrc as its preferred packaging system,
7417: contributing lots of portability fixes to make GNOME build and install under
7418: it.
7419:
7420: This chapter is aimed at pkgsrc developers and other people interested in
7421: helping our GNOME porting and packaging efforts. It provides instructions on
7422: how to manage the existing packages and some important information regarding
7423: their internals.
7424:
7425: We need your help!
7426:
7427: Should you have some spare cycles to devote to NetBSD, pkgsrc and GNOME and are
7428: willing to learn new exciting stuff, please jump straight to the pending work
7429: list! There is still a long way to go to get a fully-functional GNOME desktop
7430: under NetBSD and we need your help to achieve it!
7431:
1.6 rillig 7432: 23.1. Meta packages
1.1 dsieger 7433:
7434: pkgsrc includes three GNOME-related meta packages:
7435:
7436: * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
7437: includes the necessary bits to get it to boot correctly, although it may
7438: lack important functionality for daily operation. The idea behind this
7439: package is to let end users build their own configurations on top of this
7440: one, first installing this meta package to achieve a functional setup and
7441: then adding individual applications.
7442:
7443: * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
7444: desktop as defined by the GNOME project; this is based on the components
7445: distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
7446: directories of the official FTP server. Developer-only tools found in those
7447: directories are not installed unless required by some other component to
7448: work properly. Similarly, packages from the bindings set (bindings/x.y/
7449: x.y.z/sources) are not pulled in unless required as a dependency for an
7450: end-user component. This package "extends" meta-pkgs/gnome-base.
7451:
7452: * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
7453: component when fetched from the CVS repository. These are required to let
7454: the autogen.sh scripts work appropriately.
7455:
7456: In all these packages, the DEPENDS lines are sorted in a way that eases
7457: updates: a package may depend on other packages listed before it but not on any
1.25 wiz 7458: listed after it. It is very important to keep this order to ease updates so...
1.1 dsieger 7459: do not change it to alphabetical sorting!
7460:
1.6 rillig 7461: 23.2. Packaging a GNOME application
1.1 dsieger 7462:
7463: Almost all GNOME applications are written in C and use a common set of tools as
7464: their build system. Things get different with the new bindings to other
7465: languages (such as Python), but the following will give you a general idea on
7466: the minimum required tools:
7467:
7468: * Almost all GNOME applications use the GNU Autotools as their build system.
7469: As a general rule you will need to tell this to your package:
7470:
7471: GNU_CONFIGURE=yes
7472: USE_LIBTOOL=yes
7473: USE_TOOLS+=gmake
7474:
7475: * If the package uses pkg-config to detect dependencies, add this tool to the
7476: list of required utilities:
7477:
7478: USE_TOOLS+=pkg-config
7479:
7480: Also use pkgtools/verifypc at the end of the build process to ensure that
7481: you did not miss to specify any dependency in your package and that the
7482: version requirements are all correct.
7483:
7484: * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
7485: handle dependencies and to force the package to use the latest available
7486: version.
7487:
7488: * If the package uses gtk-doc (a documentation generation utility), do not
7489: add a dependency on it. The tool is rather big and the distfile should come
7490: with pregenerated documentation anyway; if it does not, it is a bug that
7491: you ought to report. For such packages you should disable gtk-doc (unless
7492: it is the default):
7493:
7494: CONFIGURE_ARGS+=--disable-gtk-doc
7495:
7496: The default location of installed HTML files (share/gtk-doc/<package-name>)
7497: is correct and should not be changed unless the package insists on
7498: installing them somewhere else. Otherwise programs as devhelp will not be
7499: able to open them. You can do that with an entry similar to:
7500:
7501: CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...
7502:
7503: GNOME uses multiple shared directories and files under the installation prefix
7504: to maintain databases. In this context, shared means that those exact same
7505: directories and files are used among several different packages, leading to
7506: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
7507: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
7508: your file lists and omitting shared files from them. If you find yourself doing
7509: those, your package is most likely incorrect.
7510:
7511: The following table lists the common situations that result in using shared
7512: directories or files. For each of them, the appropriate solution is given.
1.25 wiz 7513: After applying the solution be sure to regenerate the package's file list with
1.1 dsieger 7514: make print-PLIST and ensure it is correct.
7515:
1.6 rillig 7516: Table 23.1. PLIST handling for GNOME packages
1.1 dsieger 7517:
7518: +-----------------------------------------------------------------------------+
7519: | If the package... | Then... |
7520: |-------------------------------------------+---------------------------------|
1.6 rillig 7521: | |See Section 19.6.10, "Packages |
1.18 mishka 7522: |Installs OMF files under share/omf. |installing scrollkeeper/rarian |
7523: | |data files". |
1.1 dsieger 7524: |-------------------------------------------+---------------------------------|
1.6 rillig 7525: |Installs icons under the share/icons/ |See Section 19.6.19, "Packages |
1.1 dsieger 7526: |hicolor hierarchy or updates share/icons/ |installing hicolor theme icons". |
7527: |hicolor/icon-theme.cache. | |
7528: |-------------------------------------------+---------------------------------|
1.6 rillig 7529: | |See Section 19.6.14, "Packages |
1.1 dsieger 7530: |Installs files under share/mime/packages. |installing extensions to the MIME|
7531: | |database". |
7532: |-------------------------------------------+---------------------------------|
1.6 rillig 7533: |Installs .desktop files under share/ |See Section 19.6.20, "Packages |
1.1 dsieger 7534: |applications and these include MIME |installing desktop files". |
7535: |information. | |
7536: +-----------------------------------------------------------------------------+
7537:
7538:
1.6 rillig 7539: 23.3. Updating GNOME to a newer version
1.1 dsieger 7540:
7541: When seeing GNOME as a whole, there are two kinds of updates:
7542:
7543: Major update
7544:
7545: Given that there is still a very long way for GNOME 3 (if it ever appears),
7546: we consider a major update one that goes from a 2.X version to a 2.Y one,
7547: where Y is even and greater than X. These are hard to achieve because they
7548: introduce lots of changes in the components' code and almost all GNOME
7549: distfiles are updated to newer versions. Some of them can even break API
7550: and ABI compatibility with the previous major version series. As a result,
7551: the update needs to be done all at once to minimize breakage.
7552:
7553: A major update typically consists of around 80 package updates and the
7554: addition of some new ones.
7555:
7556: Minor update
7557:
7558: We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
7559: one where Y is greater than X. These are easy to achieve because they do
7560: not update all GNOME components, can be done in an incremental way and do
7561: not break API nor ABI compatibility.
7562:
7563: A minor update typically consists of around 50 package updates, although
7564: the numbers here may vary a lot.
7565:
7566: In order to update the GNOME components in pkgsrc to a new stable release
7567: (either major or minor), the following steps should be followed:
7568:
7569: 1. Get a list of all the tarballs that form the new release by using the
1.19 snj 7570: following commands. These will leave the full list of the components'
1.1 dsieger 7571: distfiles into the list.txt file:
7572:
7573: % echo ls "*.tar.bz2" | \
7574: ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
7575: awk '{ print $9 }' >list.txt
7576: % echo ls "*.tar.bz2" | \
7577: ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
7578: awk '{ print $9 }' >>list.txt
7579:
7580: 2. Open each meta package's Makefile and bump their version to the release you
7581: are updating them to. The three meta packages should be always consistent
7582: with versioning. Obviously remove any PKGREVISIONs that might be in them.
7583:
7584: 3. For each meta package, update all its DEPENDS lines to match the latest
7585: versions as shown by the above commands. Do not list any newer version
7586: (even if found in the FTP) because the meta packages are supposed to list
7587: the exact versions that form a specific GNOME release. Exceptions are
7588: permitted here if a newer version solves a serious issue in the overall
7589: desktop experience; these typically come in the form of a revision bump in
7590: pkgsrc, not in newer versions from the developers.
7591:
7592: Packages not listed in the list.txt file should be updated to the latest
7593: version available (if found in pkgsrc). This is the case, for example, of
7594: the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
7595: package.
7596:
7597: 4. Generate a patch from the modified meta packages and extract the list of
7598: "new" lines. This will provide you an outline on what packages need to be
7599: updated in pkgsrc and in what order:
7600:
7601: % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
7602:
7603: 5. For major desktop updates it is recommended to zap all your installed
7604: packages and start over from scratch at this point.
7605:
7606: 6. Now comes the longest step by far: iterate over the contents of todo.txt
7607: and update the packages listed in it in order. For major desktop updates
7608: none of these should be committed until the entire set is completed because
7609: there are chances of breaking not-yet-updated packages.
7610:
7611: 7. Once the packages are up to date and working, commit them to the tree one
7612: by one with appropriate log messages. At the end, commit the three meta
7613: package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
7614: and pkgsrc/doc/TODO files.
7615:
1.6 rillig 7616: 23.4. Patching guidelines
1.1 dsieger 7617:
7618: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
7619: it is very important that you always, always, always feed back any portability
7620: fixes you do to a GNOME package to the mainstream developers (see
1.6 rillig 7621: Section 11.3.5, "Feedback to the author"). This is the only way to get their
1.1 dsieger 7622: attention on portability issues and to ensure that future versions can be built
7623: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
7624: updates are. Those developers in charge of issuing major GNOME updates will be
7625: grateful if you do that.
7626:
7627: The most common places to report bugs are the GNOME's Bugzilla and the
7628: freedesktop.org's Bugzilla. Not all components use these to track bugs, but
7629: most of them do. Do not be short on your reports: always provide detailed
7630: explanations of the current failure, how it can be improved to achieve maximum
7631: portability and, if at all possible, provide a patch against CVS head. The more
7632: verbose you are, the higher chances of your patch being accepted.
7633:
7634: Also, please avoid using preprocessor magic to fix portability issues. While
7635: the FreeBSD GNOME people are doing a great job in porting GNOME to their
7636: operating system, the official GNOME sources are now plagued by conditionals
7637: that check for __FreeBSD__ and similar macros. This hurts portability. Please
1.6 rillig 7638: see our patching guidelines (Section 11.3.4, "Patching guidelines") for more
1.1 dsieger 7639: details.
7640:
7641: Part III. The pkgsrc infrastructure internals
7642:
7643: This part of the guide deals with everything from the infrastructure that is
7644: behind the interfaces described in the developer's guide. A casual package
7645: maintainer should not need anything from this part.
7646:
7647: Table of Contents
7648:
1.6 rillig 7649: 24. Design of the pkgsrc infrastructure
1.1 dsieger 7650:
1.6 rillig 7651: 24.1. The meaning of variable definitions
7652: 24.2. Avoiding problems before they arise
7653: 24.3. Variable evaluation
1.1 dsieger 7654:
1.6 rillig 7655: 24.3.1. At load time
7656: 24.3.2. At runtime
1.1 dsieger 7657:
1.6 rillig 7658: 24.4. How can variables be specified?
7659: 24.5. Designing interfaces for Makefile fragments
1.1 dsieger 7660:
1.6 rillig 7661: 24.5.1. Procedures with parameters
7662: 24.5.2. Actions taken on behalf of parameters
1.1 dsieger 7663:
1.6 rillig 7664: 24.6. The order in which files are loaded
1.1 dsieger 7665:
1.6 rillig 7666: 24.6.1. The order in bsd.prefs.mk
7667: 24.6.2. The order in bsd.pkg.mk
1.1 dsieger 7668:
1.6 rillig 7669: 25. Regression tests
1.1 dsieger 7670:
1.108 rillig 7671: 25.1. Running the regression tests
7672: 25.2. Adding a new regression test
1.1 dsieger 7673:
1.108 rillig 7674: 25.2.1. Overridable functions
7675: 25.2.2. Helper functions
1.1 dsieger 7676:
1.6 rillig 7677: 26. Porting pkgsrc
1.1 dsieger 7678:
1.6 rillig 7679: 26.1. Porting pkgsrc to a new operating system
1.1 dsieger 7680:
1.6 rillig 7681: Chapter 24. Design of the pkgsrc infrastructure
1.1 dsieger 7682:
7683: Table of Contents
7684:
1.6 rillig 7685: 24.1. The meaning of variable definitions
7686: 24.2. Avoiding problems before they arise
7687: 24.3. Variable evaluation
1.1 dsieger 7688:
1.6 rillig 7689: 24.3.1. At load time
7690: 24.3.2. At runtime
1.1 dsieger 7691:
1.6 rillig 7692: 24.4. How can variables be specified?
7693: 24.5. Designing interfaces for Makefile fragments
1.1 dsieger 7694:
1.6 rillig 7695: 24.5.1. Procedures with parameters
7696: 24.5.2. Actions taken on behalf of parameters
1.1 dsieger 7697:
1.6 rillig 7698: 24.6. The order in which files are loaded
1.1 dsieger 7699:
1.6 rillig 7700: 24.6.1. The order in bsd.prefs.mk
7701: 24.6.2. The order in bsd.pkg.mk
1.1 dsieger 7702:
7703: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
7704: fragment needs a properly specified interface. This chapter explains how such
7705: an interface looks like.
7706:
1.6 rillig 7707: 24.1. The meaning of variable definitions
1.1 dsieger 7708:
7709: Whenever a variable is defined in the pkgsrc infrastructure, the location and
7710: the way of definition provide much information about the intended use of that
7711: variable. Additionally, more documentation may be found in a header comment or
7712: in this pkgsrc guide.
7713:
7714: A special file is mk/defaults/mk.conf, which lists all variables that are
7715: intended to be user-defined. They are either defined using the ?= operator or
7716: they are left undefined because defining them to anything would effectively
7717: mean "yes". All these variables may be overridden by the pkgsrc user in the
7718: MAKECONF file.
7719:
7720: Outside this file, the following conventions apply: Variables that are defined
7721: using the ?= operator may be overridden by a package.
7722:
7723: Variables that are defined using the = operator may be used read-only at
7724: run-time.
7725:
7726: Variables whose name starts with an underscore must not be accessed outside the
7727: pkgsrc infrastructure at all. They may change without further notice.
7728:
7729: Note
7730:
7731: These conventions are currently not applied consistently to the complete pkgsrc
7732: infrastructure.
7733:
1.6 rillig 7734: 24.2. Avoiding problems before they arise
1.1 dsieger 7735:
7736: All variables that contain lists of things should default to being empty. Two
7737: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
7738: variables cannot simply be modified using the += operator in package Makefiles
7739: (or other files included by them), since there is no guarantee whether the
7740: variable is already set or not, and what its value is. In the case of
7741: DISTFILES, the packages "know" the default value and just define it as in the
7742: following example.
7743:
7744: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
7745:
7746: Because of the selection of this default value, the same value appears in many
7747: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
7748: value ("c") is so short that it doesn't stand out. Nevertheless it is mentioned
7749: in many files.
7750:
1.6 rillig 7751: 24.3. Variable evaluation
1.1 dsieger 7752:
1.6 rillig 7753: 24.3.1. At load time
1.1 dsieger 7754:
7755: Variable evaluation takes place either at load time or at runtime, depending on
7756: the context in which they occur. The contexts where variables are evaluated at
7757: load time are:
7758:
7759: * The right hand side of the := and != operators,
7760:
7761: * Make directives like .if or .for,
7762:
7763: * Dependency lines.
7764:
7765: A special exception are references to the iteration variables of .for loops,
7766: which are expanded inline, no matter in which context they appear.
7767:
7768: As the values of variables may change during load time, care must be taken not
7769: to evaluate them by accident. Typical examples for variables that should not be
7770: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
7771: clear, here is an example:
7772:
7773: CONFIGURE_ARGS= # none
7774: CFLAGS= -O
7775: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
7776:
7777: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
7778:
7779: CFLAGS+= -Wall
7780:
7781: This code shows how the use of the := operator can quickly lead to unexpected
7782: results. The first paragraph is fairly common code. The second paragraph
7783: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
7784: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
7785: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
7786: typically occur in completely unrelated files.
7787:
1.6 rillig 7788: 24.3.2. At runtime
1.1 dsieger 7789:
7790: After all the files have been loaded, the values of the variables cannot be
7791: changed anymore. Variables that are used in the shell commands are expanded at
7792: this point.
7793:
1.6 rillig 7794: 24.4. How can variables be specified?
1.1 dsieger 7795:
7796: There are many ways in which the definition and use of a variable can be
7797: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108 rillig 7798: policies. A package can be checked with pkglint -Wall to see whether it meets
7799: these rules.
1.1 dsieger 7800:
1.6 rillig 7801: 24.5. Designing interfaces for Makefile fragments
1.1 dsieger 7802:
7803: Most of the .mk files fall into one of the following classes. Cases where a
7804: file falls into more than one class should be avoided as it often leads to
7805: subtle bugs.
7806:
1.6 rillig 7807: 24.5.1. Procedures with parameters
1.1 dsieger 7808:
7809: In a traditional imperative programming language some of the .mk files could be
1.23 jakllsch 7810: described as procedures. They take some input parameters and?after
7811: inclusion?provide a result in output parameters. Since all variables in
7812: Makefiles have global scope care must be taken not to use parameter names that
7813: have already another meaning. For example, PKGNAME is a bad choice for a
7814: parameter name.
1.1 dsieger 7815:
7816: Procedures are completely evaluated at preprocessing time. That is, when
7817: calling a procedure all input parameters must be completely resolvable. For
7818: example, CONFIGURE_ARGS should never be an input parameter since it is very
7819: likely that further text will be added after calling the procedure, which would
7820: effectively apply the procedure to only a part of the variable. Also,
1.108 rillig 7821: references to other variables will be modified after calling the procedure.
1.1 dsieger 7822:
7823: A procedure can declare its output parameters either as suitable for use in
7824: preprocessing directives or as only available at runtime. The latter
7825: alternative is for variables that contain references to other runtime
7826: variables.
7827:
7828: Procedures shall be written such that it is possible to call the procedure more
7829: than once. That is, the file must not contain multiple-inclusion guards.
7830:
7831: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
7832: To express that the parameters are evaluated at load time, they should be
7833: assigned using the := operator, which should be used only for this purpose.
7834:
1.6 rillig 7835: 24.5.2. Actions taken on behalf of parameters
1.1 dsieger 7836:
7837: Action files take some input parameters and may define runtime variables. They
7838: shall not define loadtime variables. There are action files that are included
7839: implicitly by the pkgsrc infrastructure, while other must be included
7840: explicitly.
7841:
7842: An example for action files is mk/subst.mk.
7843:
1.6 rillig 7844: 24.6. The order in which files are loaded
1.1 dsieger 7845:
7846: Package Makefiles usually consist of a set of variable definitions, and include
7847: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
7848: include various other *.mk files if they need to query the availability of
7849: certain features like the type of compiler or the X11 implementation. Due to
7850: the heavy use of preprocessor directives like .if and .for, the order in which
7851: the files are loaded matters.
7852:
7853: This section describes at which point the various files are loaded and gives
7854: reasons for that order.
7855:
1.6 rillig 7856: 24.6.1. The order in bsd.prefs.mk
1.1 dsieger 7857:
7858: The very first action in bsd.prefs.mk is to define some essential variables
7859: like OPSYS, OS_VERSION and MACHINE_ARCH.
7860:
1.4 rillig 7861: Then, the user settings are loaded from the file specified in MAKECONF, which
7862: is usually mk.conf. After that, those variables that have not been overridden
7863: by the user are loaded from mk/defaults/mk.conf.
1.1 dsieger 7864:
7865: After the user settings, the system settings and platform settings are loaded,
7866: which may override the user settings.
7867:
7868: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
7869: This only happens when building a package, so the proper variables must be used
7870: instead of the direct tool names.
7871:
7872: As the last steps, some essential variables from the wrapper and the package
7873: system flavor are loaded, as well as the variables that have been cached in
7874: earlier phases of a package build.
7875:
1.6 rillig 7876: 24.6.2. The order in bsd.pkg.mk
1.1 dsieger 7877:
7878: First, bsd.prefs.mk is loaded.
7879:
7880: Then, the various *-vars.mk files are loaded, which fill default values for
7881: those variables that have not been defined by the package. These variables may
7882: later be used even in unrelated files.
7883:
7884: Then, the file bsd.pkg.error.mk provides the target error-check that is added
7885: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
7886: DELAYED_WARNING_MSG.
7887:
7888: Then, the package-specific hacks from hacks.mk are included.
7889:
7890: Then, various other files follow. Most of them don't have any dependencies on
7891: what they need to have included before or after them, though some do.
7892:
7893: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
7894: restricts the use of these variables to all the files that have been included
7895: before. Appearances in later files will be silently ignored.
7896:
7897: Then, the files for the main targets are included, in the order of later
7898: execution, though the actual order should not matter.
7899:
7900: At last, some more files are included that don't set any interesting variables
7901: but rather just define make targets to be executed.
7902:
1.6 rillig 7903: Chapter 25. Regression tests
1.1 dsieger 7904:
7905: Table of Contents
7906:
1.108 rillig 7907: 25.1. Running the regression tests
7908: 25.2. Adding a new regression test
1.1 dsieger 7909:
1.108 rillig 7910: 25.2.1. Overridable functions
7911: 25.2.2. Helper functions
1.1 dsieger 7912:
7913: The pkgsrc infrastructure consists of a large codebase, and there are many
7914: corners where every little bit of a file is well thought out, making pkgsrc
7915: likely to fail as soon as anything is changed near those parts. To prevent most
7916: changes from breaking anything, a suite of regression tests should go along
7917: with every important part of the pkgsrc infrastructure. This chapter describes
7918: how regression tests work in pkgsrc and how you can add new tests.
7919:
1.108 rillig 7920: 25.1. Running the regression tests
1.1 dsieger 7921:
1.25 wiz 7922: You first need to install the pkgtools/pkg_regress package, which provides the
1.1 dsieger 7923: pkg_regress command. Then you can simply run that command, which will run all
7924: tests in the regress category.
7925:
1.108 rillig 7926: 25.2. Adding a new regression test
1.1 dsieger 7927:
7928: Every directory in the regress category that contains a file called spec is
7929: considered a regression test. This file is a shell program that is included by
7930: the pkg_regress command. The following functions can be overridden to suit your
7931: needs.
7932:
1.108 rillig 7933: 25.2.1. Overridable functions
1.1 dsieger 7934:
1.108 rillig 7935: These functions do not take any parameters. Although they are called in "set -e
7936: " mode, they don't stop at the first failing command. See this StackOverflow
7937: question for details.
1.1 dsieger 7938:
1.108 rillig 7939: do_setup
1.1 dsieger 7940:
7941: This function prepares the environment for the test. By default it does
7942: nothing.
7943:
1.108 rillig 7944: do_test
1.1 dsieger 7945:
7946: This function runs the actual test. By default, it calls TEST_MAKE with the
7947: arguments MAKEARGS_TEST and writes its output including error messages into
7948: the file TEST_OUTFILE.
7949:
1.108 rillig 7950: When defining this function, make sure that all output that needs to be
7951: checked is written to the correct output file. Example:
7952:
7953: do_test() {
7954: echo "Example output"
7955: } 1>$TEST_OUTFILE 2>&1
7956:
7957: check_result
1.1 dsieger 7958:
7959: This function is run after the test and is typically used to compare the
7960: actual output from the one that is expected. It can make use of the various
1.108 rillig 7961: helper functions from the next section. Example:
7962:
7963: check_result() {
7964: exit_status 0
7965: output_require "Example"
7966: output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
7967: output_prohibit "no such file or directory"
7968: }
1.1 dsieger 7969:
1.108 rillig 7970: do_cleanup
1.1 dsieger 7971:
7972: This function cleans everything up after the test has been run. By default
7973: it does nothing.
7974:
1.108 rillig 7975: 25.2.2. Helper functions
1.1 dsieger 7976:
1.108 rillig 7977: exit_status expected
1.1 dsieger 7978:
1.108 rillig 7979: This function compares the exitcode of the do_test function with its first
7980: parameter. If they differ, the test will fail.
1.1 dsieger 7981:
1.108 rillig 7982: output_require regex...
1.1 dsieger 7983:
7984: This function checks for each of its parameters if the output from do_test
1.108 rillig 7985: matches the extended regular expression. If it does not, the test will
7986: fail. Example:
7987:
7988: output_require "looks fine"
7989: output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1 dsieger 7990:
7991: output_prohibit(regex...)
7992:
7993: This function checks for each of its parameters if the output from do_test
7994: () does not match the extended regular expression. If any of the regular
7995: expressions matches, the test will fail.
7996:
1.6 rillig 7997: Chapter 26. Porting pkgsrc
1.1 dsieger 7998:
7999: Table of Contents
8000:
1.6 rillig 8001: 26.1. Porting pkgsrc to a new operating system
1.1 dsieger 8002:
8003: The pkgsrc system has already been ported to many operating systems, hardware
8004: architectures and compilers. This chapter explains the necessary steps to make
8005: pkgsrc even more portable.
8006:
1.6 rillig 8007: 26.1. Porting pkgsrc to a new operating system
1.1 dsieger 8008:
8009: To port pkgsrc to a new operating system (called MyOS in this example), you
8010: need to touch the following files:
8011:
8012: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
8013:
8014: This file contains some basic definitions, for example the name of the C
8015: compiler.
8016:
8017: mk/bsd.prefs.mk
8018:
8019: Insert code that defines the variables OPSYS, OS_VERSION, LOWER_OS_VERSION,
8020: LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
8021: that appear in this file.
8022:
8023: mk/platform/MyOS.mk
8024:
8025: This file contains the platform-specific definitions that are used by
8026: pkgsrc. Start by copying one of the other files and edit it to your needs.
8027:
8028: mk/tools/tools.MyOS.mk
8029:
8030: This file defines the paths to all the tools that are needed by one or the
8031: other package in pkgsrc, as well as by pkgsrc itself. Find out where these
8032: tools are on your platform and add them.
8033:
8034: Now, you should be able to build some basic packages, like lang/perl5, shells/
8035: bash.
8036:
8037: Appendix A. A simple example package: bison
8038:
8039: Table of Contents
8040:
8041: A.1. files
8042:
8043: A.1.1. Makefile
8044: A.1.2. DESCR
8045: A.1.3. PLIST
8046: A.1.4. Checking a package with pkglint
8047:
8048: A.2. Steps for building, installing, packaging
8049:
8050: We checked to find a piece of software that wasn't in the packages collection,
1.25 wiz 8051: and picked GNU bison. Quite why someone would want to have bison when Berkeley
1.1 dsieger 8052: yacc is already present in the tree is beyond us, but it's useful for the
8053: purposes of this exercise.
8054:
8055: A.1. files
8056:
8057: A.1.1. Makefile
8058:
1.2 rillig 8059: # $NetBSD$
1.1 dsieger 8060: #
8061:
8062: DISTNAME= bison-1.25
8063: CATEGORIES= devel
8064: MASTER_SITES= ${MASTER_SITE_GNU}
8065:
1.30 dholland 8066: MAINTAINER= pkgsrc-users@NetBSD.org
1.1 dsieger 8067: HOMEPAGE= http://www.gnu.org/software/bison/bison.html
8068: COMMENT= GNU yacc clone
8069:
8070: GNU_CONFIGURE= yes
1.47 wiz 8071: INFO_FILES= yes
1.1 dsieger 8072:
8073: .include "../../mk/bsd.pkg.mk"
8074:
8075: A.1.2. DESCR
8076:
8077: GNU version of yacc. Can make re-entrant parsers, and numerous other
8078: improvements. Why you would want this when Berkeley yacc(1) is part
8079: of the NetBSD source tree is beyond me.
8080:
8081: A.1.3. PLIST
8082:
1.2 rillig 8083: @comment $NetBSD$
1.1 dsieger 8084: bin/bison
8085: man/man1/bison.1.gz
8086: share/bison.simple
8087: share/bison.hairy
8088:
8089: A.1.4. Checking a package with pkglint
8090:
8091: The NetBSD package system comes with pkgtools/pkglint which helps to check the
8092: contents of these files. After installation it is quite easy to use, just
8093: change to the directory of the package you wish to examine and execute pkglint:
8094:
8095: $ pkglint
8096: looks fine.
8097:
8098: Depending on the supplied command line arguments (see pkglint(1)), more checks
8099: will be performed. Use e.g. pkglint -Call -Wall for a very thorough check.
8100:
8101: A.2. Steps for building, installing, packaging
8102:
8103: Create the directory where the package lives, plus any auxiliary directories:
8104:
8105: # cd /usr/pkgsrc/lang
8106: # mkdir bison
8107: # cd bison
8108: # mkdir patches
8109:
1.6 rillig 8110: Create Makefile, DESCR and PLIST (see Chapter 11, Package components - files,
1.1 dsieger 8111: directories and contents) then continue with fetching the distfile:
8112:
8113: # make fetch
8114: >> bison-1.25.tar.gz doesn't seem to exist on this system.
8115: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
8116: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8117: ftp: Error retrieving file: 500 Internal error
8118:
8119: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
8120: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8121: ftp: Error retrieving file: 500 Internal error
8122:
8123: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
8124: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8125: Successfully retrieved file.
8126:
8127: Generate the checksum of the distfile into distinfo:
8128:
8129: # make makedistinfo
8130:
8131: Now compile:
8132:
8133: # make
8134: >> Checksum OK for bison-1.25.tar.gz.
8135: ===> Extracting for bison-1.25
8136: ===> Patching for bison-1.25
8137: ===> Ignoring empty patch directory
8138: ===> Configuring for bison-1.25
8139: creating cache ./config.cache
8140: checking for gcc... cc
8141: checking whether we are using GNU C... yes
8142: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
8143: checking how to run the C preprocessor... cc -E
8144: checking for minix/config.h... no
8145: checking for POSIXized ISC... no
8146: checking whether cross-compiling... no
8147: checking for ANSI C header files... yes
8148: checking for string.h... yes
8149: checking for stdlib.h... yes
8150: checking for memory.h... yes
8151: checking for working const... yes
8152: checking for working alloca.h... no
8153: checking for alloca... yes
8154: checking for strerror... yes
8155: updating cache ./config.cache
8156: creating ./config.status
8157: creating Makefile
8158: ===> Building for bison-1.25
8159: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g LR0.c
8160: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g allocate.c
8161: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g closure.c
8162: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g conflicts.c
8163: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g derives.c
8164: cc -c -DXPFILE=\"/usr/pkg/share/bison.simple\" -DXPFILE1=\"/usr/pkg/share/bison.hairy\" -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -g ./files.c
8165: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g getargs.c
8166: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g gram.c
8167: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g lalr.c
8168: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g lex.c
8169: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g main.c
8170: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g nullable.c
8171: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g output.c
8172: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g print.c
8173: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g reader.c
8174: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g reduce.c
8175: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g symtab.c
8176: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g warshall.c
8177: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g version.c
8178: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g getopt.c
8179: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g getopt1.c
8180: cc -g -o bison LR0.o allocate.o closure.o conflicts.o derives.o files.o getargs.o gram.o lalr.o lex.o main.o nullable.o output.o print.o reader.o reduce.o symtab.o warshall.o version.o getopt.o getopt1.o
8181: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
8182: rm -f bison.s1
8183: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
8184:
8185: Everything seems OK, so install the files:
8186:
8187: # make install
8188: >> Checksum OK for bison-1.25.tar.gz.
8189: ===> Installing for bison-1.25
8190: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
8191: rm -f /usr/pkg/bin/bison
8192: cd /usr/pkg/share; rm -f bison.simple bison.hairy
8193: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
8194: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
8195: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
8196: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
8197: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
8198: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
8199: ===> Registering installation for bison-1.25
8200:
8201: You can now use bison, and also - if you decide so - remove it with pkg_delete
8202: bison. Should you decide that you want a binary package, do this now:
8203:
8204: # make package
8205: >> Checksum OK for bison-1.25.tar.gz.
8206: ===> Building package for bison-1.25
8207: Creating package bison-1.25.tgz
8208: Registering depends:.
8209: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
8210:
8211: Now that you don't need the source and object files any more, clean up:
8212:
8213: # make clean
8214: ===> Cleaning for bison-1.25
8215:
8216: Appendix B. Build logs
8217:
8218: Table of Contents
8219:
8220: B.1. Building figlet
8221: B.2. Packaging figlet
8222:
8223: B.1. Building figlet
8224:
8225: # make
8226: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8227: => figlet221.tar.gz doesn't seem to exist on this system.
8228: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
8229: => [172219 bytes]
8230: Connected to ftp.plig.net.
8231: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
8232: 331 Guest login ok, send your complete e-mail address as password.
8233: 230-You are user #5 of 500 simultaneous users allowed.
8234: 230-
8235: 230- ___ _ _ _
8236: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
8237: 230- | _| _| . |_| . | | | . |_| . | _| . |
8238: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
8239: 230- |_| |_| |___| |___|
8240: 230-
8241: 230-** Welcome to ftp.plig.org **
8242: 230-
8243: 230-Please note that all transfers from this FTP site are logged. If you
8244: 230-do not like this, please disconnect now.
8245: 230-
1.19 snj 8246: 230-This archive is available via
1.1 dsieger 8247: 230-
8248: 230-HTTP: http://ftp.plig.org/
8249: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
8250: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
8251: 230-
8252: 230-Please email comments, bug reports and requests for packages to be
8253: 230-mirrored to ftp-admin@plig.org.
8254: 230-
8255: 230-
8256: 230 Logged in anonymously.
8257: Remote system type is UNIX.
8258: Using binary mode to transfer files.
8259: 200 Type okay.
8260: 250 "/pub" is new cwd.
8261: 250-"/pub/figlet" is new cwd.
8262: 250-
8263: 250-Welcome to the figlet archive at ftp.figlet.org
8264: 250-
8265: 250- ftp://ftp.figlet.org/pub/figlet/
8266: 250-
8267: 250-The official FIGlet web page is:
8268: 250- http://www.figlet.org/
8269: 250-
8270: 250-If you have questions, please mailto:info@figlet.org. If you want to
8271: 250-contribute a font or something else, you can email us.
8272: 250
8273: 250 "/pub/figlet/program" is new cwd.
8274: 250 "/pub/figlet/program/unix" is new cwd.
8275: local: figlet221.tar.gz remote: figlet221.tar.gz
8276: 502 Unimplemented command.
8277: 227 Entering Passive Mode (195,40,6,41,246,104)
8278: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
8279: 38% |************** | 65800 64.16 KB/s 00:01 ETA
8280: 226 Transfer completed.
8281: 172219 bytes received in 00:02 (75.99 KB/s)
8282: 221 Goodbye.
8283: => Checksum OK for figlet221.tar.gz.
8284: ===> Extracting for figlet-2.2.1nb2
8285: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
8286: ===> Patching for figlet-2.2.1nb2
8287: ===> Applying pkgsrc patches for figlet-2.2.1nb2
8288: ===> Overriding tools for figlet-2.2.1nb2
8289: ===> Creating toolchain wrappers for figlet-2.2.1nb2
8290: ===> Configuring for figlet-2.2.1nb2
8291: ===> Building for figlet-2.2.1nb2
8292: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
8293: chmod a+x figlet
8294: gcc -O2 -o chkfont chkfont.c
8295: => Unwrapping files-to-be-installed.
8296: #
8297: # make install
8298: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8299: ===> Installing for figlet-2.2.1nb2
8300: install -d -o root -g wheel -m 755 /usr/pkg/bin
8301: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
8302: mkdir -p /usr/pkg/share/figlet
8303: cp figlet /usr/pkg/bin
8304: cp chkfont /usr/pkg/bin
8305: chmod 555 figlist showfigfonts
8306: cp figlist /usr/pkg/bin
8307: cp showfigfonts /usr/pkg/bin
8308: cp fonts/*.flf /usr/pkg/share/figlet
8309: cp fonts/*.flc /usr/pkg/share/figlet
8310: cp figlet.6 /usr/pkg/man/man6
8311: ===> Registering installation for figlet-2.2.1nb2
8312: #
8313:
8314: B.2. Packaging figlet
8315:
8316: # make package
8317: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8318: ===> Packaging figlet-2.2.1nb2
8319: ===> Building binary package for figlet-2.2.1nb2
8320: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
8321: Using SrcDir value of /usr/pkg
8322: Registering depends:.
8323: #
8324:
8325: Appendix C. Directory layout of the pkgsrc FTP server
8326:
8327: Table of Contents
8328:
1.23 jakllsch 8329: C.1. distfiles: The distributed source files
8330: C.2. misc: Miscellaneous things
8331: C.3. packages: Binary packages
8332: C.4. reports: Bulk build reports
8333: C.5. current, pkgsrc-20xxQy: source packages
1.1 dsieger 8334:
8335: As in other big projects, the directory layout of pkgsrc is quite complex for
8336: newbies. This chapter explains where you find things on the FTP server. The
8337: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
8338: different, but inside this directory, everything should look the same, no
8339: matter on which server you are. This directory contains some subdirectories,
8340: which are explained below.
8341:
1.23 jakllsch 8342: C.1. distfiles: The distributed source files
1.1 dsieger 8343:
8344: The directory distfiles contains lots of archive files from all pkgsrc
8345: packages, which are mirrored here. The subdirectories are called after their
8346: package names and are used when the distributed files have names that don't
8347: explicitly contain a version number or are otherwise too generic (for example
8348: release.tar.gz).
8349:
1.23 jakllsch 8350: C.2. misc: Miscellaneous things
1.1 dsieger 8351:
8352: This directory contains things that individual pkgsrc developers find worth
8353: publishing.
8354:
1.23 jakllsch 8355: C.3. packages: Binary packages
1.1 dsieger 8356:
1.3 rillig 8357: This directory contains binary packages for the various platforms that are
8358: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
8359: The meaning of these variables is:
8360:
8361: * OPSYS is the name of the operating system for which the packages have been
1.9 rillig 8362: built. The name is taken from the output of the uname command, so it may
8363: differ from the one you are used to hear.
1.3 rillig 8364:
1.8 rillig 8365: * ARCH is the hardware architecture of the platform for which the packages
1.10 hubertf 8366: have been built. It also includes the ABI (Application Binary Interface)
8367: for platforms that have several of them.
1.3 rillig 8368:
1.8 rillig 8369: * OSVERSION is the version of the operating system. For version numbers that
8370: change often (for example NetBSD-current), the often-changing part should
8371: be replaced with an x, for example 4.99.x.
1.3 rillig 8372:
1.23 jakllsch 8373: * TAG is either 20xxQy for a stable branch, or head for packages built from
1.8 rillig 8374: the HEAD branch. The latter should only be used when the packages are
8375: updated on a regular basis. Otherwise the date from checking out pkgsrc
8376: should be appended, for example head_20071015.
1.3 rillig 8377:
8378: The rationale for exactly this scheme is that the pkgsrc users looking for
8379: binary packages can quickly click through the directories on the server and
8380: find the best binary packages for their machines. Since they usually know the
8381: operating system and the hardware architecture, OPSYS and ARCH are placed
8382: first. After these choices, they can select the best combination of OSVERSION
8383: and TAG together, since it is usually the case that packages stay compatible
8384: between different version of the operating system.
8385:
8386: In each of these directories, there is a whole binary packages collection for a
8387: specific platform. It has a directory called All which contains all binary
8388: packages. Besides that, there are various category directories that contain
8389: symbolic links to the real binary packages.
1.1 dsieger 8390:
1.23 jakllsch 8391: C.4. reports: Bulk build reports
1.8 rillig 8392:
8393: Here are the reports from bulk builds, for those who want to fix packages that
8394: didn't build on some of the platforms. The structure of subdirectories should
1.23 jakllsch 8395: look like the one in Section C.3, "packages: Binary packages".
1.8 rillig 8396:
1.23 jakllsch 8397: C.5. current, pkgsrc-20xxQy: source packages
1.1 dsieger 8398:
8399: These directories contain the "real" pkgsrc, that is the files that define how
8400: to create binary packages from source archives.
8401:
8402: The directory pkgsrc contains a snapshot of the CVS repository, which is
8403: updated regularly. The file pkgsrc.tar.gz contains the same as the directory,
8404: ready to be downloaded as a whole.
8405:
8406: In the directories for the quarterly branches, there is an additional file
1.23 jakllsch 8407: called pkgsrc-20xxQy.tar.gz, which contains the state of pkgsrc when it was
1.1 dsieger 8408: branched.
8409:
8410: Appendix D. Editing guidelines for the pkgsrc guide
8411:
8412: Table of Contents
8413:
8414: D.1. Make targets
8415: D.2. Procedure
8416:
8417: This section contains information on editing the pkgsrc guide itself.
8418:
8419: D.1. Make targets
8420:
8421: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
8422: files are created from it:
8423:
8424: * pkgsrc/doc/pkgsrc.txt
8425:
8426: * pkgsrc/doc/pkgsrc.html
8427:
1.2 rillig 8428: * http://www.NetBSD.org/docs/pkgsrc/
1.1 dsieger 8429:
1.2 rillig 8430: * http://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the pkgsrc
8431: guide.
1.1 dsieger 8432:
1.2 rillig 8433: * http://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
8434: pkgsrc guide.
1.1 dsieger 8435:
8436: D.2. Procedure
8437:
8438: The procedure to edit the pkgsrc guide is:
8439:
8440: 1. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46 obache 8441: other XML-based NetBSD documentation) installed. These are automatically
8442: installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1 dsieger 8443:
8444: 2. Run cd doc/guide to get to the right directory. All further steps will take
8445: place here.
8446:
8447: 3. Edit the XML file(s) in files/.
8448:
8449: 4. Run bmake to check the pkgsrc guide for valid XML and to build the final
8450: output files. If you get any errors at this stage, you can just edit the
8451: files, as there are only symbolic links in the working directory, pointing
8452: to the files in files/.
8453:
8454: 5. (cd files && cvs commit)
8455:
8456: 6. Run bmake clean && bmake to regenerate the output files with the proper RCS
8457: Ids.
8458:
8459: 7. Run bmake regen to install and commit the files in both pkgsrc/doc and
8460: htdocs.
8461:
8462: Note
8463:
8464: If you have added, removed or renamed some chapters, you need to
8465: synchronize them using cvs add or cvs delete in the htdocs directory.
8466:
CVSweb <webmaster@jp.NetBSD.org>