Annotation of htdocs/docs/pkgsrc/pkgsrc.txt, revision 1.263
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.259 leot 15: Copyright 1994-2025 The NetBSD Foundation, Inc
1.1 dsieger 16:
1.263 ! wiz 17: $NetBSD: pkgsrc.xml,v 1.45 2025/04/17 22:00:11 wiz 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: 1.1. Introduction
32: 1.1.1. Why pkgsrc?
33: 1.1.2. Supported platforms
34: 1.2. Overview
35: 1.3. Terminology
36: 1.3.1. Roles involved in pkgsrc
37: 1.4. Typography
38: I. The pkgsrc user's guide
1.154 rillig 39: 2. Getting help
40: 3. Where to get pkgsrc and how to keep it up-to-date
41: 3.1. Getting pkgsrc for the first time
42: 3.1.1. As tar archive
43: 3.1.2. Via anonymous CVS
44: 3.2. Keeping pkgsrc up-to-date
45: 3.2.1. Via tar files
46: 3.2.2. Via CVS
47: 4. Using pkgsrc on systems other than NetBSD
48: 4.1. Binary distribution
49: 4.2. Bootstrapping pkgsrc
50: 5. Using pkgsrc
51: 5.1. Using binary packages
52: 5.1.1. Finding binary packages
53: 5.1.2. Installing binary packages
1.202 nia 54: 5.1.3. Updating packages
55: 5.1.4. Deinstalling packages
56: 5.1.5. Getting information about installed packages
57: 5.1.6. Checking for security vulnerabilities in installed packages
58: 5.1.7. Finding if newer versions of your installed packages are in
1.259 leot 59: pkgsrc
1.202 nia 60: 5.1.8. Other administrative functions
1.154 rillig 61: 5.2. Building packages from source
62: 5.2.1. Requirements
63: 5.2.2. Fetching distfiles
64: 5.2.3. How to build and install
65: 6. Configuring pkgsrc
66: 6.1. General configuration
67: 6.2. Variables affecting the build process
1.241 rillig 68: 6.3. Preferences for native or pkgsrc software
69: 6.4. Variables affecting the installation process
70: 6.5. Selecting and configuring the compiler
71: 6.5.1. Selecting the compiler
72: 6.5.2. Additional flags to the compiler (CFLAGS)
73: 6.5.3. Additional flags to the linker (LDFLAGS)
74: 6.6. Developer/advanced settings
75: 6.7. Selecting Build Options
1.154 rillig 76: 7. Creating binary packages
77: 7.1. Building a single binary package
78: 7.2. Settings for creation of binary packages
79: 8. Creating binary packages for everything in pkgsrc (bulk builds)
80: 8.1. Preparations
1.180 rillig 81: 8.2. Running a bulk build
1.154 rillig 82: 8.2.1. Configuration
83: 8.3. Requirements of a full bulk build
1.178 rillig 84: 8.4. Bulk build variants
1.179 rillig 85: 8.4.1. Detect unknown configure options
86: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.181 rillig 87: 8.4.3. Force compiler options only in the build phase
88: 8.4.4. Use custom directories
89: 8.4.5. Turn warnings into errors
90: 8.4.6. Reject packages for which pkglint reports errors
91: 8.4.7. Reject packages that contain forbidden strings
92: 8.4.8. Reject packages whose self-test fails
93: 8.4.9. Reject packages that use undefined shell variables
94: 8.4.10. Turn off verbose logging
1.178 rillig 95: 8.5. Creating a multiple CD-ROM packages collection
96: 8.5.1. Example of cdpack
1.154 rillig 97: 9. Directory layout of the installed files
98: 9.1. File system layout in ${LOCALBASE}
99: 9.2. File system layout in ${VARBASE}
100: 10. Frequently Asked Questions
101: 10.1. Are there any mailing lists for pkg-related discussion?
102: 10.2. Utilities for package management (pkgtools)
103: 10.3. How to use pkgsrc as non-root
104: 10.4. How to resume transfers when fetching distfiles?
105: 10.5. How can I install/use modular X.org from pkgsrc?
106: 10.6. How to fetch files from behind a firewall
107: 10.7. How to fetch files from HTTPS sites
108: 10.8. How do I tell make fetch to do passive FTP?
109: 10.9. How to fetch all distfiles at once
110: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc"
1.259 leot 111: mean?
1.154 rillig 112: 10.11. What does "Could not find bsd.own.mk" mean?
1.221 nia 113: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154 rillig 114: 10.13. How do I change the location of configuration files?
115: 10.14. Automated security checks
116: 10.15. Why do some packages ignore my CFLAGS?
117: 10.16. A package does not build. What shall I do?
118: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/???
1.259 leot 119: merge conflicts" mean?
1.1 dsieger 120: II. The pkgsrc developer's guide
1.154 rillig 121: 11. Getting help
1.184 rillig 122: 12. Package components - files, directories and contents
123: 12.1. Makefile
124: 12.2. distinfo
125: 12.3. patches/*
126: 12.3.1. Structure of a single patch file
127: 12.3.2. Creating patch files
128: 12.3.3. Sources where the patch files come from
129: 12.3.4. Patching guidelines
130: 12.3.5. Feedback to the author
131: 12.4. Other mandatory files
132: 12.5. Optional files
133: 12.5.1. Files affecting the binary package
134: 12.5.2. Files affecting the build process
135: 12.5.3. Files affecting nothing at all
136: 12.6. work*
137: 12.7. files/*
138: 13. The build process
139: 13.1. Introduction
140: 13.2. Program location
141: 13.3. Directories used during the build process
142: 13.4. Running a phase
143: 13.5. The fetch phase
144: 13.5.1. What to fetch and where to get it from
145: 13.5.2. How are the files fetched?
146: 13.6. The checksum phase
147: 13.7. The extract phase
148: 13.8. The patch phase
149: 13.9. The tools phase
150: 13.10. The wrapper phase
151: 13.11. The configure phase
152: 13.12. The build phase
153: 13.13. The test phase
154: 13.14. The install phase
155: 13.15. The package phase
156: 13.16. Cleaning up
157: 13.17. Other helpful targets
158: 14. Creating a new pkgsrc package from scratch
159: 14.1. Common types of packages
1.219 nia 160: 14.1.1. Python modules and programs
161: 14.1.2. R packages
162: 14.1.3. TeXlive packages
1.184 rillig 163: 14.2. Examples
164: 14.2.1. How the www/nvu package came into pkgsrc
165: 15. Programming in Makefiles
166: 15.1. Caveats
167: 15.2. Makefile variables
168: 15.2.1. Naming conventions
169: 15.3. Code snippets
170: 15.3.1. Adding things to a list
171: 15.3.2. Echoing a string exactly as-is
172: 15.3.3. Passing CFLAGS to GNU configure scripts
173: 15.3.4. Handling possibly empty variables
1.229 gutterid 174: 15.3.5. Testing yes/no variables in conditions
1.184 rillig 175: 16. Options handling
176: 16.1. Global default options
177: 16.2. Converting packages to use bsd.options.mk
178: 16.3. Option Names
179: 16.4. Determining the options of dependencies
180: 17. Tools needed for building or running
181: 17.1. Tools for pkgsrc builds
182: 17.2. Tools needed by packages
183: 17.3. Tools provided by platforms
184: 18. Buildlink methodology
185: 18.1. Converting packages to use buildlink3
186: 18.2. Writing buildlink3.mk files
187: 18.2.1. Anatomy of a buildlink3.mk file
188: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
1.259 leot 189: BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.184 rillig 190: 18.3. Writing builtin.mk files
191: 18.3.1. Anatomy of a builtin.mk file
192: 19. PLIST issues
193: 19.1. RCS ID
194: 19.2. Semi-automatic PLIST generation
195: 19.3. Tweaking output of make print-PLIST
196: 19.4. Variable substitution in PLIST
197: 19.5. Man page compression
198: 19.6. Changing PLIST source with PLIST_SRC
199: 19.7. Platform-specific and differing PLISTs
200: 19.8. Build-specific PLISTs
201: 19.9. Sharing directories between packages
202: 20. The pkginstall framework
203: 20.1. Files and directories outside the installation prefix
204: 20.1.1. Directory manipulation
205: 20.1.2. File manipulation
206: 20.2. Configuration files
207: 20.2.1. How PKG_SYSCONFDIR is set
208: 20.2.2. Telling the software where configuration files are
1.239 dholland 209: 20.2.3. Patching installation
210: 20.2.4. Declaring configuration files
211: 20.2.5. Disabling handling of configuration files
1.184 rillig 212: 20.3. System startup scripts
213: 20.3.1. Disabling handling of system startup scripts
214: 20.4. System users and groups
215: 20.5. System shells
216: 20.5.1. Disabling shell registration
217: 20.6. Fonts
218: 20.6.1. Disabling automatic update of the fonts databases
1.154 rillig 219: 21. Making your package work
220: 21.1. General operation
221: 21.1.1. How to pull in user-settable variables from mk.conf
222: 21.1.2. User interaction
223: 21.1.3. Handling licenses
224: 21.1.4. Restricted packages
225: 21.1.5. Handling dependencies
226: 21.1.6. Handling conflicts with other packages
227: 21.1.7. Packages that cannot or should not be built
228: 21.1.8. Packages which should not be deleted, once installed
229: 21.1.9. Handling packages with security problems
230: 21.1.10. How to handle incrementing versions when fixing an
1.259 leot 231: existing package
1.154 rillig 232: 21.1.11. Substituting variable text in the package files (the SUBST
1.259 leot 233: framework)
1.154 rillig 234: 21.2. The fetch phase
235: 21.2.1. Packages whose distfiles aren't available for plain
1.259 leot 236: downloading
1.154 rillig 237: 21.2.2. How to handle modified distfiles with the 'old' name
238: 21.2.3. Packages hosted on github.com
239: 21.3. The configure phase
240: 21.3.1. Shared libraries - libtool
241: 21.3.2. Using libtool on GNU packages that already support libtool
242: 21.3.3. GNU Autoconf/Automake
1.223 nia 243: 21.3.4. Meson / ninja
1.260 wiz 244: 21.3.5. Determining the endianness
1.154 rillig 245: 21.4. Programming languages
246: 21.4.1. C, C++, and Fortran
247: 21.4.2. Java
1.205 wiz 248: 21.4.3. Go
1.223 nia 249: 21.4.4. Rust
250: 21.4.5. Packages containing Perl scripts
251: 21.4.6. Packages containing shell scripts
252: 21.4.7. Other programming languages
1.154 rillig 253: 21.5. The build phase
254: 21.5.1. Compiling C and C++ code conditionally
255: 21.5.2. How to handle compiler bugs
1.172 rillig 256: 21.5.3. No such file or directory
257: 21.5.4. Undefined reference to "..."
258: 21.5.5. Running out of memory
1.154 rillig 259: 21.6. The install phase
260: 21.6.1. Creating needed directories
261: 21.6.2. Where to install documentation
262: 21.6.3. Installing highscore files
263: 21.6.4. Adding DESTDIR support to packages
264: 21.6.5. Packages with hardcoded paths to other interpreters
1.203 nia 265: 21.6.6. Packages installing Perl modules
1.254 wiz 266: 21.6.7. Packages installing pkg-config files
267: 21.6.8. Packages installing info files
268: 21.6.9. Packages installing man pages
269: 21.6.10. Packages installing X11 fonts
270: 21.6.11. Packages installing SGML or XML data
271: 21.6.12. Packages installing extensions to the MIME database
272: 21.6.13. Packages using intltool
273: 21.6.14. Packages installing startup scripts
274: 21.6.15. Packages installing TeX modules
275: 21.6.16. Packages supporting running binaries in emulation
276: 21.6.17. Packages installing hicolor icons
277: 21.6.18. Packages installing desktop files
1.154 rillig 278: 21.7. Marking packages as having problems
1.184 rillig 279: 22. GNOME packaging and porting
280: 22.1. Meta packages
281: 22.2. Packaging a GNOME application
282: 22.3. Updating GNOME to a newer version
283: 22.4. Patching guidelines
1.154 rillig 284: 23. Submitting and Committing
285: 23.1. Submitting binary packages
286: 23.2. Submitting source packages (for non-NetBSD-developers)
287: 23.3. General notes when adding, updating, or removing packages
288: 23.4. Commit Messages
289: 23.5. Committing: Adding a package to CVS
290: 23.6. Updating a package to a newer version
291: 23.7. Renaming a package in pkgsrc
292: 23.8. Moving a package in pkgsrc
1.263 ! wiz 293: 24. pkgsrc Policies
! 294: 24.1. Packages for which updating is restricted
! 295: 24.1.1. Limited Updates - ABI
! 296: 24.1.2. Limited Updates - Bootstrap
! 297: 25. Frequently Asked Questions
1.1 dsieger 298: III. The pkgsrc infrastructure internals
1.263 ! wiz 299: 26. Design of the pkgsrc infrastructure
! 300: 26.1. The meaning of variable definitions
! 301: 26.2. Avoiding problems before they arise
! 302: 26.3. Variable evaluation
! 303: 26.3.1. At load time
! 304: 26.3.2. At runtime
! 305: 26.4. How can variables be specified?
! 306: 26.5. Designing interfaces for Makefile fragments
! 307: 26.5.1. Procedures with parameters
! 308: 26.5.2. Actions taken on behalf of parameters
! 309: 26.6. The order in which files are loaded
! 310: 26.6.1. The order in bsd.prefs.mk
! 311: 26.6.2. The order in bsd.pkg.mk
! 312: 27. Regression tests
! 313: 27.1. Running the regression tests
! 314: 27.2. Adding a new regression test
! 315: 27.2.1. Overridable functions
! 316: 27.2.2. Helper functions
! 317: 28. Porting pkgsrc
! 318: 28.1. Porting pkgsrc to a new operating system
1.1 dsieger 319: A. A simple example package: bison
320: A.1. files
321: A.1.1. Makefile
322: A.1.2. DESCR
323: A.1.3. PLIST
324: A.1.4. Checking a package with pkglint
325: A.2. Steps for building, installing, packaging
1.207 leot 326: B. Security hardening
327: B.1. Mechanisms
328: B.1.1. Enabled by default
329: B.1.2. Not enabled by default
330: B.2. Caveats
331: B.2.1. Problems with PKGSRC_MKPIE
332: B.2.2. Problems with PKGSRC_USE_FORTIFY
333: B.2.3. Problems with PKGSRC_USE_RELRO
334: B.2.4. Problems with PKGSRC_USE_SSP
335: B.3. Auditing the system
336: B.3.1. Checking for PIE
337: B.3.2. Checking for partial RELRO
338: B.3.3. Checking for full RELRO
339: B.3.4. Checking for SSP
340: C. Build logs
341: C.1. Building figlet
342: C.2. Packaging figlet
343: D. Directory layout of the pkgsrc FTP server
344: D.1. distfiles: The distributed source files
345: D.2. misc: Miscellaneous things
346: D.3. packages: Binary packages
347: D.4. reports: Bulk build reports
348: D.5. current, stable, pkgsrc-20xxQy: source packages
349: E. Help topics
350: F. Editing guidelines for the pkgsrc guide
351: F.1. Make targets
352: F.2. Procedure
1.1 dsieger 353:
354: List of Tables
355:
356: 1.1. Platforms supported by pkgsrc
1.184 rillig 357: 12.1. Patching examples
358: 22.1. PLIST handling for GNOME packages
1.1 dsieger 359:
360: Chapter 1. What is pkgsrc?
361:
362: Table of Contents
363:
364: 1.1. Introduction
365: 1.1.1. Why pkgsrc?
366: 1.1.2. Supported platforms
367: 1.2. Overview
368: 1.3. Terminology
369: 1.3.1. Roles involved in pkgsrc
370: 1.4. Typography
371:
372: 1.1. Introduction
373:
374: There is a lot of software freely available for Unix-based systems, which is
375: usually available in form of the source code. Before such software can be used,
376: it needs to be configured to the local system, compiled and installed, and this
377: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
378: some basic commands to handle binary packages, so that not every user has to
379: build the packages for himself, which is a time-costly task.
380:
381: pkgsrc currently contains several thousand packages, including:
382:
1.104 sevan 383: * www/apache24 - The Apache web server
1.1 dsieger 384:
385: * www/firefox - The Firefox web browser
386:
387: * meta-pkgs/gnome - The GNOME Desktop Environment
388:
1.102 ryoon 389: * meta-pkgs/kde4 - The K Desktop Environment
1.1 dsieger 390:
1.108 rillig 391: ? just to name a few.
1.1 dsieger 392:
393: pkgsrc has built-in support for handling varying dependencies, such as pthreads
394: and X11, and extended features such as IPv6 support on a range of platforms.
395:
396: 1.1.1. Why pkgsrc?
397:
398: pkgsrc provides the following key features:
399:
400: * Easy building of software from source as well as the creation and
401: installation of binary packages. The source and latest patches are
402: retrieved from a master or mirror download site, checksum verified, then
403: built on your system. Support for binary-only distributions is available
404: for both native platforms and NetBSD emulated platforms.
405:
406: * All packages are installed in a consistent directory tree, including
407: binaries, libraries, man pages and other documentation.
408:
1.104 sevan 409: * Tracking of package dependencies automatically, including when performing
410: updates, to ensure required packages are installed. The configuration files
411: of various packages are handled automatically during updates, so local
412: changes are preserved.
1.1 dsieger 413:
414: * Like NetBSD, pkgsrc is designed with portability in mind and consists of
415: highly portable code. This allows the greatest speed of development when
1.26 spz 416: porting to a new platform. This portability also ensures that pkgsrc is
1.1 dsieger 417: consistent across all platforms.
418:
419: * The installation prefix, acceptable software licenses, international
420: encryption requirements and build-time options for a large number of
421: packages are all set in a simple, central configuration file.
422:
423: * The entire source (not including the distribution files) is freely
424: available under a BSD license, so you may extend and adapt pkgsrc to your
425: needs. Support for local packages and patches is available right out of the
426: box, so you can configure it specifically for your environment.
427:
428: The following principles are basic to pkgsrc:
429:
1.198 leot 430: * "It should only work if it's right." -- That means, if a package contains
1.1 dsieger 431: bugs, it's better to find them and to complain about them rather than to
432: just install the package and hope that it works. There are numerous checks
1.175 gutterid 433: in pkgsrc that try to find such bugs: static analysis tools (pkgtools/
1.1 dsieger 434: pkglint), build-time checks (portability of shell scripts), and
435: post-installation checks (installed files, references to shared libraries,
436: script interpreters).
437:
1.198 leot 438: * "If it works, it should work everywhere" -- Like NetBSD has been ported to
1.1 dsieger 439: many hardware architectures, pkgsrc has been ported to many operating
440: systems. Care is taken that packages behave the same on all platforms.
441:
442: 1.1.2. Supported platforms
443:
444: pkgsrc consists of both a source distribution and a binary distribution for
445: these operating systems. After retrieving the required source or binaries, you
446: can be up and running with pkgsrc in just minutes!
447:
448: pkgsrc was derived from FreeBSD's ports system, and initially developed for
449: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
450: platforms:
451:
452: Table 1.1. Platforms supported by pkgsrc
453:
1.92 sevan 454: +-----------------------------------------------------------------------------+
1.229 gutterid 455: | Platform | Date Support | Notes |
456: | | Added | |
457: |-------------------------------------+---------------+-----------------------|
458: |NetBSD | Aug 1997 | |
459: |-------------------------------------+---------------+-----------------------|
460: |Solaris | Mar 1999 |README.Solaris |
461: |-------------------------------------+---------------+-----------------------|
462: |Linux | Jun 1999 |README.Linux |
463: |-------------------------------------+---------------+-----------------------|
464: |Darwin / Mac OS X / OS X / macOS | Oct 2001 |README.macOS |
465: |-------------------------------------+---------------+-----------------------|
466: |FreeBSD | Nov 2002 |README.FreeBSD |
467: |-------------------------------------+---------------+-----------------------|
468: |OpenBSD | Nov 2002 |README.OpenBSD |
469: |-------------------------------------+---------------+-----------------------|
470: |IRIX | Dec 2002 |README.IRIX |
471: |-------------------------------------+---------------+-----------------------|
1.262 dholland 472: |BSD/OS | Dec 2003 |Removed from pkgsrc Mar|
473: | | | 2025 |
1.229 gutterid 474: |-------------------------------------+---------------+-----------------------|
475: |AIX | Dec 2003 |README.AIX |
476: |-------------------------------------+---------------+-----------------------|
477: |Interix (Microsoft Windows Services | Mar 2004 |README.Interix |
478: |for Unix) | | |
479: |-------------------------------------+---------------+-----------------------|
480: |DragonFlyBSD | Oct 2004 | |
481: |-------------------------------------+---------------+-----------------------|
482: |OSF/1 | Nov 2004 |README.OSF1 |
483: |-------------------------------------+---------------+-----------------------|
484: |HP-UX | Apr 2007 |README.HPUX |
485: |-------------------------------------+---------------+-----------------------|
486: |Haiku | Sep 2010 |README.Haiku |
487: |-------------------------------------+---------------+-----------------------|
1.262 dholland 488: |MirBSD | Jan 2011 |Removed from pkgsrc Mar|
489: | | | 2025 |
1.229 gutterid 490: |-------------------------------------+---------------+-----------------------|
491: |Minix3 | Nov 2011 |README.Minix3 |
492: |-------------------------------------+---------------+-----------------------|
493: |Cygwin | Mar 2013 |README.Cygwin |
494: |-------------------------------------+---------------+-----------------------|
1.261 maya 495: |GNU/kFreeBSD | Jul 2013 |Removed from pkgsrc Mar|
496: | | |2025 |
1.229 gutterid 497: |-------------------------------------+---------------+-----------------------|
498: |Bitrig | Jun 2014 |Removed from pkgsrc Sep|
499: | | |2022 |
1.92 sevan 500: +-----------------------------------------------------------------------------+
1.1 dsieger 501:
502:
503: 1.2. Overview
504:
505: This document is divided into three parts. The first, The pkgsrc user's guide,
506: describes how one can use one of the packages in the Package Collection, either
507: by installing a precompiled binary package, or by building one's own copy using
508: the NetBSD package system. The second part, The pkgsrc developer's guide,
509: explains how to prepare a package so it can be easily built by other NetBSD
510: users without knowing about the package's building details. The third part, The
511: pkgsrc infrastructure internals is intended for those who want to understand
512: how pkgsrc is implemented.
513:
514: This document is available in various formats: HTML, PDF, PS, TXT.
515:
516: 1.3. Terminology
517:
518: There has been a lot of talk about "ports", "packages", etc. so far. Here is a
519: description of all the terminology used within this document.
520:
521: Package
522:
523: A set of files and building instructions that describe what's necessary to
524: build a certain piece of software using pkgsrc. Packages are traditionally
1.123 wiz 525: stored under /usr/pkgsrc, but may be stored in any location, referred to as
526: PKGSRCDIR.
1.1 dsieger 527:
528: The NetBSD package system
529:
530: This is the former name of "pkgsrc". It is part of the NetBSD operating
531: system and can be bootstrapped to run on non-NetBSD operating systems as
532: well. It handles building (compiling), installing, and removing of
533: packages.
534:
535: Distfile
536:
537: This term describes the file or files that are provided by the author of
538: the piece of software to distribute his work. All the changes necessary to
539: build on NetBSD are reflected in the corresponding package. Usually the
540: distfile is in the form of a compressed tar-archive, but other types are
541: possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
542:
543: Port
544:
545: This is the term used by FreeBSD and OpenBSD people for what we call a
546: package. In NetBSD terminology, "port" refers to a different architecture.
547:
548: Precompiled/binary package
549:
550: A set of binaries built with pkgsrc from a distfile and stuffed together in
551: a single .tgz file so it can be installed on machines of the same machine
552: architecture without the need to recompile. Packages are usually generated
553: in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
554:
555: Sometimes, this is referred to by the term "package" too, especially in the
556: context of precompiled packages.
557:
558: Program
559:
560: The piece of software to be installed which will be constructed from all
561: the files in the distfile by the actions defined in the corresponding
562: package.
563:
564: 1.3.1. Roles involved in pkgsrc
565:
566: pkgsrc users
567:
568: The pkgsrc users are people who use the packages provided by pkgsrc.
569: Typically they are system administrators. The people using the software
570: that is inside the packages (maybe called "end users") are not covered by
571: the pkgsrc guide.
572:
573: There are two kinds of pkgsrc users: Some only want to install pre-built
574: binary packages. Others build the pkgsrc packages from source, either for
575: installing them directly or for building binary packages themselves. For
576: pkgsrc users Part I, "The pkgsrc user's guide" should provide all necessary
577: documentation.
578:
579: package maintainers
580:
581: A package maintainer creates packages as described in Part II, "The pkgsrc
582: developer's guide".
583:
584: infrastructure developers
585:
586: These people are involved in all those files that live in the mk/ directory
587: and below. Only these people should need to read through Part III, "The
588: pkgsrc infrastructure internals", though others might be curious, too.
589:
590: 1.4. Typography
591:
592: When giving examples for commands, shell prompts are used to show if the
593: command should/can be issued as root, or if "normal" user privileges are
1.115 sevan 594: sufficient. We use a # for root's shell prompt, a % for users' shell prompt,
1.229 gutterid 595: assuming they use the C-shell or tcsh and a $ for Bourne shell and derivatives.
1.1 dsieger 596:
597: Part I. The pkgsrc user's guide
598:
599: Table of Contents
600:
1.154 rillig 601: 2. Getting help
602: 3. Where to get pkgsrc and how to keep it up-to-date
603: 3.1. Getting pkgsrc for the first time
604: 3.1.1. As tar archive
605: 3.1.2. Via anonymous CVS
606: 3.2. Keeping pkgsrc up-to-date
607: 3.2.1. Via tar files
608: 3.2.2. Via CVS
609: 4. Using pkgsrc on systems other than NetBSD
610: 4.1. Binary distribution
611: 4.2. Bootstrapping pkgsrc
612: 5. Using pkgsrc
613: 5.1. Using binary packages
614: 5.1.1. Finding binary packages
615: 5.1.2. Installing binary packages
1.202 nia 616: 5.1.3. Updating packages
617: 5.1.4. Deinstalling packages
618: 5.1.5. Getting information about installed packages
619: 5.1.6. Checking for security vulnerabilities in installed packages
620: 5.1.7. Finding if newer versions of your installed packages are in
1.259 leot 621: pkgsrc
1.202 nia 622: 5.1.8. Other administrative functions
1.154 rillig 623: 5.2. Building packages from source
624: 5.2.1. Requirements
625: 5.2.2. Fetching distfiles
626: 5.2.3. How to build and install
627: 6. Configuring pkgsrc
628: 6.1. General configuration
629: 6.2. Variables affecting the build process
1.241 rillig 630: 6.3. Preferences for native or pkgsrc software
631: 6.4. Variables affecting the installation process
632: 6.5. Selecting and configuring the compiler
633: 6.5.1. Selecting the compiler
634: 6.5.2. Additional flags to the compiler (CFLAGS)
635: 6.5.3. Additional flags to the linker (LDFLAGS)
636: 6.6. Developer/advanced settings
637: 6.7. Selecting Build Options
1.154 rillig 638: 7. Creating binary packages
639: 7.1. Building a single binary package
640: 7.2. Settings for creation of binary packages
641: 8. Creating binary packages for everything in pkgsrc (bulk builds)
642: 8.1. Preparations
1.180 rillig 643: 8.2. Running a bulk build
1.154 rillig 644: 8.2.1. Configuration
645: 8.3. Requirements of a full bulk build
1.178 rillig 646: 8.4. Bulk build variants
1.179 rillig 647: 8.4.1. Detect unknown configure options
648: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.181 rillig 649: 8.4.3. Force compiler options only in the build phase
650: 8.4.4. Use custom directories
651: 8.4.5. Turn warnings into errors
652: 8.4.6. Reject packages for which pkglint reports errors
653: 8.4.7. Reject packages that contain forbidden strings
654: 8.4.8. Reject packages whose self-test fails
655: 8.4.9. Reject packages that use undefined shell variables
656: 8.4.10. Turn off verbose logging
1.178 rillig 657: 8.5. Creating a multiple CD-ROM packages collection
658: 8.5.1. Example of cdpack
1.154 rillig 659: 9. Directory layout of the installed files
660: 9.1. File system layout in ${LOCALBASE}
661: 9.2. File system layout in ${VARBASE}
662: 10. Frequently Asked Questions
663: 10.1. Are there any mailing lists for pkg-related discussion?
664: 10.2. Utilities for package management (pkgtools)
665: 10.3. How to use pkgsrc as non-root
666: 10.4. How to resume transfers when fetching distfiles?
667: 10.5. How can I install/use modular X.org from pkgsrc?
668: 10.6. How to fetch files from behind a firewall
669: 10.7. How to fetch files from HTTPS sites
670: 10.8. How do I tell make fetch to do passive FTP?
671: 10.9. How to fetch all distfiles at once
672: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
673: 10.11. What does "Could not find bsd.own.mk" mean?
1.221 nia 674: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154 rillig 675: 10.13. How do I change the location of configuration files?
676: 10.14. Automated security checks
677: 10.15. Why do some packages ignore my CFLAGS?
678: 10.16. A package does not build. What shall I do?
679: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.259 leot 680: conflicts" mean?
1.1 dsieger 681:
1.154 rillig 682: Chapter 2. Getting help
683:
684: To get help when using pkgsrc, the definitive source is this document, the
685: pkgsrc guide. If you don't find anything here, there are alternatives:
686:
687: * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
688: Run bmake help topic=? to get help for any topic, such as a variable name
689: like BUILD_DEFS, a make target like do-build, a missing C or C++ function
690: like strcasecmp or any other topic.
691:
1.207 leot 692: The available help topics are listed in Appendix E, Help topics.
1.154 rillig 693:
1.163 rillig 694: * To see the value of a single variable, run bmake show-var VARNAME=X.
695:
696: * To see the values of the most common variables, run bmake show-all. These
697: variables are grouped by topic. To see the variables for a single topic,
698: run bmake show-all-topic, for example bmake show-all-fetch.
699:
1.154 rillig 700: * The pkgsrc-users mailing list, to which you can subscribe and then ask your
701: questions.
702:
703: * The #pkgsrc IRC channel, which is accessible via a web browser or by using
704: a specialized chat program such as XChat. Pick any user name and join the
705: channel #pkgsrc.
706:
707: Chapter 3. Where to get pkgsrc and how to keep it up-to-date
1.1 dsieger 708:
709: Table of Contents
710:
1.154 rillig 711: 3.1. Getting pkgsrc for the first time
712: 3.1.1. As tar archive
713: 3.1.2. Via anonymous CVS
714: 3.2. Keeping pkgsrc up-to-date
715: 3.2.1. Via tar files
716: 3.2.2. Via CVS
1.1 dsieger 717:
718: Before you download and extract the files, you need to decide where you want to
719: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
720: usr/pkgsrc. You are though free to install the sources and binary packages
721: wherever you want in your filesystem, provided that the pathname does not
722: contain white-space or other characters that are interpreted specially by the
723: shell and some other programs. A safe bet is to use only letters, digits,
724: underscores and dashes.
725:
1.154 rillig 726: 3.1. Getting pkgsrc for the first time
1.1 dsieger 727:
1.25 wiz 728: Before you download any pkgsrc files, you should decide whether you want the
1.1 dsieger 729: current branch or the stable branch. The latter is forked on a quarterly basis
730: from the current branch and only gets modified for security updates. The names
731: of the stable branches are built from the year and the quarter, for example
1.259 leot 732: 2024Q4.
1.1 dsieger 733:
734: The second step is to decide how you want to download pkgsrc. You can get it as
1.24 wiz 735: a tar file or via CVS. Both ways are described here.
1.1 dsieger 736:
1.52 asau 737: Note that tar archive contains CVS working copy. Thus you can switch to using
738: CVS at any later time.
1.1 dsieger 739:
1.154 rillig 740: 3.1.1. As tar archive
1.52 asau 741:
1.151 sevan 742: The primary download location for all pkgsrc files is https://cdn.NetBSD.org/
743: pub/pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same
744: location). There are a number of subdirectories for different purposes, which
1.207 leot 745: are described in detail in Appendix D, Directory layout of the pkgsrc FTP
1.151 sevan 746: server.
1.1 dsieger 747:
1.52 asau 748: The tar archive for the current branch is in the directory current and is
1.118 sevan 749: called pkgsrc.tar.gz. It is autogenerated weekly.
1.52 asau 750:
751: To save download time we provide bzip2- and xz-compressed archives which are
752: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
753:
754: You can fetch the same files using FTP.
1.1 dsieger 755:
1.259 leot 756: The tar file for the stable branch 2024Q4 is in the directory pkgsrc-2024Q4 and
1.59 jnemeth 757: is also called pkgsrc.tar.gz.
1.1 dsieger 758:
1.136 leot 759: To download the latest pkgsrc stable tarball, run:
1.12 weinem 760:
1.259 leot 761: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2024Q4/pkgsrc.tar.gz
1.12 weinem 762:
1.78 snj 763: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52 asau 764:
1.12 weinem 765: Then, extract it with:
766:
1.78 snj 767: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12 weinem 768:
769: This will create the directory pkgsrc/ in /usr/ and all the package source will
770: be stored under /usr/pkgsrc/.
771:
772: To download pkgsrc-current, run:
773:
774: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1 dsieger 775:
1.154 rillig 776: 3.1.2. Via anonymous CVS
1.1 dsieger 777:
1.24 wiz 778: To fetch a specific pkgsrc stable branch, run:
1.1 dsieger 779:
1.259 leot 780: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2024Q4 -P pkgsrc
1.13 weinem 781:
1.24 wiz 782: This will create the directory pkgsrc/ in your /usr/ directory and all the
783: package source will be stored under /usr/pkgsrc/.
784:
785: To fetch the pkgsrc current branch, run:
1.1 dsieger 786:
1.40 wiz 787: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 788:
1.30 dholland 789: Refer to the list of available mirrors to choose a faster CVS mirror, if
790: needed.
1.1 dsieger 791:
1.24 wiz 792: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1 dsieger 793:
1.40 wiz 794: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 795:
1.24 wiz 796: Refer to documentation on your command shell how to set CVS_RSH=ssh
797: permanently. For Bourne shells, you can set it in your .profile or better
798: globally in /etc/profile:
799:
800: # set CVS remote shell command
801: CVS_RSH=ssh
802: export CVS_RSH
1.12 weinem 803:
1.13 weinem 804: By default, CVS doesn't do things like most people would expect it to do. But
805: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12 weinem 806: directory and saving the following lines to it. This file will save you lots of
807: headache and some bug reports, so we strongly recommend it. You can find an
808: explanation of this file in the CVS documentation.
1.2 rillig 809:
810: # recommended CVS configuration file from the pkgsrc guide
1.155 sevan 811: cvs -q
1.2 rillig 812: checkout -P
1.4 rillig 813: update -dP
814: diff -upN
1.2 rillig 815: rdiff -u
1.24 wiz 816: release -d
1.1 dsieger 817:
1.154 rillig 818: 3.2. Keeping pkgsrc up-to-date
1.1 dsieger 819:
820: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
821: have first installed it via a tar file). It saves bandwidth and hard disk
822: activity, compared to downloading the tar file again.
823:
1.154 rillig 824: 3.2.1. Via tar files
1.1 dsieger 825:
826: Warning
827:
828: When updating from a tar file, you first need to completely remove the old
829: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
830: the mean time will not be removed on your local disk, resulting in
831: inconsistencies. When removing the old files, any changes that you have done to
832: the pkgsrc files will be lost after updating. Therefore updating via CVS is
833: strongly recommended.
834:
835: Note that by default the distfiles and the binary packages are saved in the
836: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78 snj 837: configure pkgsrc to store distfiles and packages in directories outside the
1.154 rillig 838: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter 6,
1.78 snj 839: Configuring pkgsrc for the details.
1.1 dsieger 840:
841: To update pkgsrc from a tar file, download the tar file as explained above.
842: Then, make sure that you have not made any changes to the files in the pkgsrc
843: directory. Remove the pkgsrc directory and extract the new tar file. Done.
844:
1.154 rillig 845: 3.2.2. Via CVS
1.1 dsieger 846:
1.26 spz 847: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12 weinem 848:
1.26 spz 849: $ cd /usr/pkgsrc && cvs update -dP
850:
851: If you get error messages from rsh, you need to set CVS_RSH variable as
852: described above. E.g.:
853:
854: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1 dsieger 855:
1.154 rillig 856: 3.2.2.1. Switching between different pkgsrc branches
1.1 dsieger 857:
858: When updating pkgsrc, the CVS program keeps track of the branch you selected.
859: But if you, for whatever reason, want to switch from the stable branch to the
860: current one, you can do it by adding the option "-A" after the "update"
1.25 wiz 861: keyword. To switch from the current branch back to the stable branch, add the "
1.259 leot 862: -rpkgsrc-2024Q4" option.
1.1 dsieger 863:
1.154 rillig 864: 3.2.2.2. What happens to my changes when updating?
1.1 dsieger 865:
866: When you update pkgsrc, the CVS program will only touch those files that are
867: registered in the CVS repository. That means that any packages that you created
868: on your own will stay unmodified. If you change files that are managed by CVS,
869: later updates will try to merge your changes with those that have been done by
870: others. See the CVS manual, chapter "update" for details.
871:
1.154 rillig 872: Chapter 4. Using pkgsrc on systems other than NetBSD
1.1 dsieger 873:
874: Table of Contents
875:
1.154 rillig 876: 4.1. Binary distribution
877: 4.2. Bootstrapping pkgsrc
1.1 dsieger 878:
1.154 rillig 879: 4.1. Binary distribution
1.1 dsieger 880:
1.154 rillig 881: See Section 5.1, "Using binary packages".
1.1 dsieger 882:
1.154 rillig 883: 4.2. Bootstrapping pkgsrc
1.1 dsieger 884:
1.44 asau 885: pkgsrc can be bootstrapped for use in two different modes: privileged and
886: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45 asau 887: programs are installed under one particular user and cannot utilise privileged
1.44 asau 888: operations (packages don't create special users and all special file
889: permissions like setuid are ignored).
890:
1.1 dsieger 891: Installing the bootstrap kit from source should be as simple as:
892:
1.60 asau 893: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 894: # cd pkgsrc/bootstrap
895: # ./bootstrap
896:
897:
1.44 asau 898: To bootstrap in unprivileged mode pass "--unprivileged" flag to bootstrap
899:
900: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1.118 sevan 901: will be installed in, and /usr/pkg/pkgdb for the package database directory
902: where pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1.44 asau 903: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1.118 sevan 904: for prefix, ~/pkg/pkgdb for the package database, and ~/pkg/var for varbase.
1.44 asau 905:
906: You can change default layout using command-line arguments. Run "./bootstrap
907: --help" to get details.
1.1 dsieger 908:
909: Note
910:
911: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
912: For examples in this guide, use bmake instead of "make".
913:
1.44 asau 914: Note
915:
916: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
917: directories. Use bmake corresponding to the installation you're working with to
918: build and install packages.
919:
1.154 rillig 920: Chapter 5. Using pkgsrc
1.1 dsieger 921:
922: Table of Contents
923:
1.154 rillig 924: 5.1. Using binary packages
925: 5.1.1. Finding binary packages
926: 5.1.2. Installing binary packages
1.202 nia 927: 5.1.3. Updating packages
928: 5.1.4. Deinstalling packages
929: 5.1.5. Getting information about installed packages
930: 5.1.6. Checking for security vulnerabilities in installed packages
931: 5.1.7. Finding if newer versions of your installed packages are in pkgsrc
932: 5.1.8. Other administrative functions
1.154 rillig 933: 5.2. Building packages from source
934: 5.2.1. Requirements
935: 5.2.2. Fetching distfiles
936: 5.2.3. How to build and install
1.1 dsieger 937:
938: Basically, there are two ways of using pkgsrc. The first is to only install the
939: package tools and to use binary packages that someone else has prepared. This
940: is the "pkg" in pkgsrc. The second way is to install the "src" of pkgsrc, too.
941: Then you are able to build your own packages, and you can still use binary
942: packages from someone else.
943:
1.154 rillig 944: 5.1. Using binary packages
1.1 dsieger 945:
1.151 sevan 946: On the cdn.NetBSD.org site and mirrors, there are collections of binary
1.9 rillig 947: packages, ready to be installed. These binary packages have been built using
948: the default settings for the directories, that is:
949:
950: * /usr/pkg for LOCALBASE, where most of the files are installed,
951:
952: * /usr/pkg/etc for configuration files,
953:
954: * /var for VARBASE, where those files are installed that may change after
955: installation.
956:
957: If you cannot use these directories for whatever reasons (maybe because you're
958: not root), you cannot use these binary packages, but have to build the packages
1.154 rillig 959: yourself, which is explained in Section 4.2, "Bootstrapping pkgsrc".
1.1 dsieger 960:
1.154 rillig 961: 5.1.1. Finding binary packages
1.1 dsieger 962:
1.5 weinem 963: To install binary packages, you first need to know from where to get them. The
1.202 nia 964: first place where you should look is on the main pkgsrc CDN in the directory /
965: pub/pkgsrc/packages.
1.5 weinem 966:
967: This directory contains binary packages for multiple platforms. First, select
1.226 gutterid 968: your operating system. Then, select your hardware architecture, and in the
969: third step, the OS version and the "version" of pkgsrc.
1.9 rillig 970:
1.226 gutterid 971: In this directory, you may find a file called bootstrap.tar.gz which contains
1.9 rillig 972: the package management tools. If the file is missing, it is likely that your
973: operating system already provides those tools. Download the file and extract it
974: in the / directory. It will create the directories /usr/pkg (containing the
1.118 sevan 975: tools for managing binary packages and the database of installed packages).
1.1 dsieger 976:
1.154 rillig 977: 5.1.2. Installing binary packages
1.1 dsieger 978:
1.85 wiz 979: In the directory from the last section, there is a subdirectory called All/,
1.9 rillig 980: which contains all the binary packages that are available for the platform,
1.202 nia 981: excluding those that may not be distributed via HTTP or FTP.
1.9 rillig 982:
983: To install packages directly from an FTP or HTTP server, run the following
984: commands in a Bourne-compatible shell (be sure to su to root first):
985:
1.202 nia 986: # PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
987: # PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages"
1.169 rillig 988: # PKG_PATH="$PKG_PATH/OPSYS/ARCH/VERSIONS/All/"
1.9 rillig 989: # export PATH PKG_PATH
1.202 nia 990: # pkg_add pkgin
1.9 rillig 991:
992: Instead of URLs, you can also use local paths, for example if you are
993: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
994: to install packages from multiple sources, you can separate them by a semicolon
995: in PKG_PATH.
996:
997: After these preparations, installing a package is very easy:
998:
1.202 nia 999: # pkgin search nginx
1000: nginx-1.19.6 Lightweight HTTP server and mail proxy server
1001: nginx-1.18.0nb8 Lightweight HTTP server and mail proxy server
1002: # pkgin install zsh nginx-1.19.6 vim
1.1 dsieger 1003:
1.202 nia 1004: Note that pkgin is a user-friendly frontend to the pkg_* tools.
1.1 dsieger 1005:
1.202 nia 1006: Any prerequisite packages needed to run the package in question will be
1007: installed, too, assuming they are present in the repository.
1.1 dsieger 1008:
1009: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
1010: in your PATH so you can actually start the just installed program.
1011:
1.202 nia 1012: 5.1.3. Updating packages
1.1 dsieger 1013:
1.202 nia 1014: To update binary packages, it is recommended that you use pkgin upgrade. This
1015: will compare the remote package repository to your locally installed packages
1016: and safely replace any older packages.
1.1 dsieger 1017:
1.202 nia 1018: Note that pkgsrc is released as quarterly branches. If you are updating to a
1019: newer quarterly branch of pkgsrc, you may need to adjust the repository in /usr
1020: /pkg/etc/pkgin/repositories.conf.
1.1 dsieger 1021:
1.202 nia 1022: 5.1.4. Deinstalling packages
1.1 dsieger 1023:
1.202 nia 1024: To deinstall a package, it does not matter whether it was installed from source
1025: code or from a binary package. Neither the pkgin or the pkg_delete command need
1026: to know.
1.1 dsieger 1027:
1.202 nia 1028: To delete a package, you can just run pkgin remove package-name. The package
1029: name can be given with or without version number.
1.1 dsieger 1030:
1.202 nia 1031: 5.1.5. Getting information about installed packages
1.1 dsieger 1032:
1033: The pkg_info shows information about installed packages or binary package
1.202 nia 1034: files. As with other management tools, it works with packages installed from
1035: source or binaries.
1.1 dsieger 1036:
1.202 nia 1037: 5.1.6. Checking for security vulnerabilities in installed packages
1.1 dsieger 1038:
1.202 nia 1039: The pkgsrc Security Team and Packages Groups maintain a list of known
1.164 leot 1040: vulnerabilities to packages which are (or have been) included in pkgsrc. The
1.202 nia 1041: list is available from the NetBSD CDN at https://cdn.NetBSD.org/pub/NetBSD/
1.179 rillig 1042: packages/vulns/pkg-vulnerabilities.
1.1 dsieger 1043:
1.202 nia 1044: Please note that not every "vulnerability" with a CVE assignment is exploitable
1045: in every configuration. Some bugs are marked as active simply because an fix
1046: was not marked as such. Operating system specific hardening and mitigation
1047: features may also reduce the impact of bugs.
1048:
1.23 jakllsch 1049: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
1050: automatically, and a security audit of all packages installed on a system can
1051: take place.
1052:
1053: There are two components to auditing. The first step, pkg_admin
1054: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
1055: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
1056: your installed packages are vulnerable. If a package is vulnerable, you will
1057: see output similar to the following:
1.1 dsieger 1058:
1059: Package samba-2.0.9 has a local-root-shell vulnerability, see
1.174 leot 1060: https://www.samba.org/samba/whatsnew/macroexploit.html
1.1 dsieger 1061:
1.23 jakllsch 1062: You may wish to have the vulnerabilities file downloaded daily so that it
1063: remains current. This may be done by adding an appropriate entry to the root
1064: users crontab(5) entry. For example the entry
1065:
1.121 sevan 1066: # Download vulnerabilities file
1.118 sevan 1067: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.121 sevan 1068: # Audit the installed packages and email results to root
1069: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
1070: root >/dev/null 2>&1
1.118 sevan 1071:
1072:
1073: will update the vulnerability list every day at 3AM, followed by an audit at
1074: 3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
1075: accomplished instead by adding the following line to /etc/daily.conf:
1076:
1077: fetch_pkg_vulnerabilities=YES
1078:
1.23 jakllsch 1079:
1.118 sevan 1080: to fetch the vulnerability list from the daily security script. The system is
1081: set to audit the packages by default but can be set explicitly, if desired (not
1.123 wiz 1082: required), by adding the following line to /etc/security.conf:
1.23 jakllsch 1083:
1.118 sevan 1084: check_pkg_vulnerabilities=YES
1.23 jakllsch 1085:
1086:
1.118 sevan 1087: see daily.conf(5) and security.conf(5) for more details.
1.1 dsieger 1088:
1.202 nia 1089: 5.1.7. Finding if newer versions of your installed packages are in pkgsrc
1.1 dsieger 1090:
1.12 weinem 1091: Install pkgtools/lintpkgsrc and run lintpkgsrc with the "-i" argument to check
1.202 nia 1092: if any packages are stale, e.g.
1.1 dsieger 1093:
1094: % lintpkgsrc -i
1095: ...
1096: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
1097:
1098:
1.202 nia 1099: 5.1.8. Other administrative functions
1.1 dsieger 1100:
1101: The pkg_admin executes various administrative functions on the package system.
1102:
1.154 rillig 1103: 5.2. Building packages from source
1.1 dsieger 1104:
1105: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25 wiz 1106: organized into categories. You can browse the online index of packages, or run
1.1 dsieger 1107: make readme from the pkgsrc directory to build local README.html files for all
1108: packages, viewable with any web browser such as www/lynx or www/firefox.
1109:
1110: The default prefix for installed packages is /usr/pkg. If you wish to change
1111: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
1112: use multiple different LOCALBASE definitions on the same system (inside a
1113: chroot is an exception).
1114:
1115: The rest of this chapter assumes that the package is already in pkgsrc. If it
1116: is not, see Part II, "The pkgsrc developer's guide" for instructions how to
1117: create your own packages.
1118:
1.154 rillig 1119: 5.2.1. Requirements
1.1 dsieger 1120:
1121: To build packages from source, you need a working C compiler. On NetBSD, you
1122: need to install the "comp" and the "text" distribution sets. If you want to
1123: build X11-related packages, the "xbase" and "xcomp" distribution sets are
1124: required, too.
1125:
1.154 rillig 1126: 5.2.2. Fetching distfiles
1.1 dsieger 1127:
1128: The first step for building a package is downloading the distfiles (i.e. the
1129: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
1130: them automatically.
1131:
1132: If you have all files that you need in the distfiles directory, you don't need
1133: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
1134: and add:
1135:
1136: DISTDIR=/cdrom/pkgsrc/distfiles
1137:
1138: to your mk.conf.
1139:
1140: By default a list of distribution sites will be randomly intermixed to prevent
1141: huge load on servers which holding popular packages (for example,
1142: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
1143: distfile all the mirrors will be tried in new (random) order. You can turn this
1144: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
1145: disabled).
1146:
1147: You can overwrite some of the major distribution sites to fit to sites that are
1148: close to your own. By setting one or two variables you can modify the order in
1149: which the master sites are accessed. MASTER_SORT contains a whitespace
1150: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
1151: contains a whitespace delimited list of regular expressions. It has higher
1152: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
1153: some examples. This may save some of your bandwidth and time.
1154:
1155: You can change these settings either in your shell's environment, or, if you
1.4 rillig 1156: want to keep the settings, by editing the mk.conf file, and adding the
1.1 dsieger 1157: definitions there.
1158:
1.132 wiz 1159: If a package depends on many other packages (such as meta-pkgs/kde4), the build
1.1 dsieger 1160: process may alternate between periods of downloading source, and compiling. To
1161: ensure you have all the source downloaded initially you can run the command:
1162:
1163: % make fetch-list | sh
1164:
1165: which will output and run a set of shell commands to fetch the necessary files
1166: into the distfiles directory. You can also choose to download the files
1167: manually.
1168:
1.154 rillig 1169: 5.2.3. How to build and install
1.1 dsieger 1170:
1171: Once the software has downloaded, any patches will be applied, then it will be
1172: compiled for you. This may take some time depending on your computer, and how
1173: many other packages the software depends on and their compile time.
1174:
1175: Note
1176:
1177: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
1178: command instead of "make" in the examples in this guide.
1179:
1180: For example, type
1181:
1182: % cd misc/figlet
1183: % make
1184:
1185:
1186: at the shell prompt to build the various components of the package.
1187:
1188: The next stage is to actually install the newly compiled program onto your
1189: system. Do this by entering:
1190:
1191: % make install
1192:
1193:
1194: while you are still in the directory for whatever package you are installing.
1195:
1196: Installing the package on your system may require you to be root. However,
1197: pkgsrc has a just-in-time-su feature, which allows you to only become root for
1198: the actual installation step.
1199:
1200: That's it, the software should now be installed and setup for use. You can now
1201: enter:
1202:
1203: % make clean
1204:
1205:
1206: to remove the compiled files in the work directory, as you shouldn't need them
1207: any more. If other packages were also added to your system (dependencies) to
1208: allow your program to compile, you can tidy these up also with the command:
1209:
1210: % make clean-depends
1211:
1212:
1213: Taking the figlet utility as an example, we can install it on our system by
1.207 leot 1214: building as shown in Appendix C, Build logs.
1.1 dsieger 1215:
1216: The program is installed under the default root of the packages tree - /usr/
1217: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
1218: environment, and it will use that value as the root of your packages tree. So,
1219: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
1220: that you should use a directory which is dedicated to packages and not shared
1221: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
1222: not try to add any of your own files or directories (such as src/, obj/, or
1223: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
1224: between programs and other files installed by the package system and whatever
1225: else may have been installed there.
1226:
1.4 rillig 1227: Some packages look in mk.conf to alter some configuration options at build
1.1 dsieger 1228: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
1229: be set there by default. Environment variables such as LOCALBASE can be set in
1.4 rillig 1230: mk.conf to save having to remember to set them each time you want to use
1.1 dsieger 1231: pkgsrc.
1232:
1233: Occasionally, people want to "look under the covers" to see what is going on
1234: when a package is building or being installed. This may be for debugging
1235: purposes, or out of simple curiosity. A number of utility values have been
1236: added to help with this.
1237:
1238: 1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
1239: amount of information will be displayed. For example,
1240:
1241: make patch PKG_DEBUG_LEVEL=2
1242:
1.25 wiz 1243: will show all the commands that are invoked, up to and including the "patch
1244: " stage.
1.1 dsieger 1245:
1246: 2. If you want to know the value of a certain make(1) definition, then the
1247: VARNAME definition should be used, in conjunction with the show-var target.
1248: e.g. to show the expansion of the make(1) variable LOCALBASE:
1249:
1250: % make show-var VARNAME=LOCALBASE
1251: /usr/pkg
1252: %
1253:
1254:
1255: If you want to install a binary package that you've either created yourself
1256: (see next section), that you put into pkgsrc/packages manually or that is
1257: located on a remote FTP server, you can use the "bin-install" target. This
1258: target will install a binary package - if available - via pkg_add(1), else do a
1259: make package. The list of remote FTP sites searched is kept in the variable
1260: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
1261: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
1262: for more details.
1263:
1264: A final word of warning: If you set up a system that has a non-standard setting
1265: for LOCALBASE, be sure to set that before any packages are installed, as you
1266: cannot use several directories for the same purpose. Doing so will result in
1267: pkgsrc not being able to properly detect your installed packages, and fail
1268: miserably. Note also that precompiled binary packages are usually built with
1269: the default LOCALBASE of /usr/pkg, and that you should not install any if you
1270: use a non-standard LOCALBASE.
1271:
1.154 rillig 1272: Chapter 6. Configuring pkgsrc
1.1 dsieger 1273:
1274: Table of Contents
1275:
1.154 rillig 1276: 6.1. General configuration
1277: 6.2. Variables affecting the build process
1.241 rillig 1278: 6.3. Preferences for native or pkgsrc software
1279: 6.4. Variables affecting the installation process
1280: 6.5. Selecting and configuring the compiler
1281: 6.5.1. Selecting the compiler
1282: 6.5.2. Additional flags to the compiler (CFLAGS)
1283: 6.5.3. Additional flags to the linker (LDFLAGS)
1284: 6.6. Developer/advanced settings
1285: 6.7. Selecting Build Options
1.1 dsieger 1286:
1287: The whole pkgsrc system is configured in a single file, usually called mk.conf.
1288: In which directory pkgsrc looks for that file depends on the installation. On
1289: NetBSD, when you use make(1) from the base system, it is in the directory /etc
1290: /. In all other cases the default location is ${PREFIX}/etc/, depending on
1291: where you told the bootstrap program to install the binary packages.
1292:
1293: The format of the configuration file is that of the usual BSD-style Makefiles.
1294: The whole pkgsrc configuration is done by setting variables in this file. Note
1295: that you can define all kinds of variables, and no special error checking (for
1.112 rillig 1296: example for spelling mistakes) takes place.
1.1 dsieger 1297:
1.154 rillig 1298: 6.1. General configuration
1.1 dsieger 1299:
1.112 rillig 1300: The following variables apply to all pkgsrc packages. A complete list of the
1301: variables that can be configured by the user is available in mk/defaults/
1302: mk.conf, together with some comments that describe each variable's intent.
1.1 dsieger 1303:
1304: * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
1305: not mix binary packages with different LOCALBASEs!
1306:
1307: * CROSSBASE: Where "cross" category packages will be installed. The default
1308: is ${LOCALBASE}/cross.
1309:
1.84 wiz 1310: * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1 dsieger 1311:
1312: * DISTDIR: Where to store the downloaded copies of the original source
1313: distributions used for building pkgsrc packages. The default is $
1314: {PKGSRCDIR}/distfiles.
1315:
1316: * PKG_DBDIR: Where the database about installed packages is stored. The
1.118 sevan 1317: default is /usr/pkg/pkgdb.
1.1 dsieger 1318:
1319: * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
1320: value.
1321:
1322: * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
1323: files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.118 sevan 1324: respectively. The defaults is ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1.1 dsieger 1325: {DIST_SUBDIR}/.
1326:
1327: * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
1328: with OS release ("2.0", etc.) and architecture ("mipsel", etc.).
1329:
1.23 jakllsch 1330: * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
1331: case-sensitive. Whenever you try to build a package whose license is not in
1332: this list, you will get an error message. If the license condition is
1333: simple enough, the error message will include specific instructions on how
1334: to change this variable.
1.1 dsieger 1335:
1.154 rillig 1336: 6.2. Variables affecting the build process
1.1 dsieger 1337:
1338: * PACKAGES: The top level directory for the binary packages. The default is $
1339: {PKGSRCDIR}/packages.
1340:
1341: * WRKOBJDIR: The top level directory where, if defined, the separate working
1342: directories will get created, and symbolically linked to from ${WRKDIR}
1343: (see below). This is useful for building packages on several architectures,
1344: then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
1345: architecture. (It should be noted that PKGSRCDIR should not be set by the
1.198 leot 1346: user -- it is an internal definition which refers to the root of the pkgsrc
1.1 dsieger 1347: tree. It is possible to have many pkgsrc tree instances.)
1348:
1349: * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.184 rillig 1350: Section 12.3, "patches/*" for more information.
1.1 dsieger 1351:
1352: * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
1353: Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
1354: up settings used by builds in /usr/src.
1355:
1.241 rillig 1356: 6.3. Preferences for native or pkgsrc software
1357:
1358: Whenever a package depends on a package that has a builtin.mk file, the
1359: dependent package can either use the built-in (native) version from the base
1360: system or the pkgsrc-provided version. This only affects dependencies, so it is
1361: still possible to build the pkgsrc package devel/pcre++ even when other
1362: packages depend on the native pcre++ version instead.
1363:
1364: To force using the pkgsrc-provided version for a particular package, define "
1365: PREFER_PKGSRC = package-ID" in mk.conf. To force using the native package,
1366: define "PREFER_NATIVE = package-ID". In both cases, the package-ID is the one
1367: from the buildlink3.mk of the package. In most cases, this ID is the same as
1368: the directory name of the package, but for example, devel/pcre++ has the
1369: package ID "pcrexx".
1370:
1371: For the packages that are not listed by their package ID, pkgsrc uses the
1372: pkgsrc-provided version if PREFER_PKGSRC contains the word "yes". Otherwise, if
1373: PREFER_NATIVE contains the word "yes", pkgsrc uses the native version. For
1374: example, to require using the pkgsrc-provided versions for all but the most
1375: basic bits on a NetBSD system, you can set:
1376:
1377: PREFER_PKGSRC= yes
1378: PREFER_NATIVE= getopt skey tcp_wrappers
1379:
1380: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
1381: it is simply ignored in that list.
1382:
1383: PREFER_PKGSRC and PREFER_NATIVE should be set during bootstrap to ensure that
1384: the bootstrap process does not use inapropriate native tools as dependencies
1385: for core packages.
1386:
1387: # ./bootstrap --prefer-pkgsrc yes --prefer-native openssl
1388:
1389: Switching between settings globally at a later date can introduce complications
1390: with dependency resolution. This is caused by packages built with the opposite
1391: preference being installed alongside each other. Hence, when changing any of
1392: these variables after bootstrap, you need to rebuild all packages depending on
1393: those whose preference has been changed. This is not trivial and should be
1394: avoided.
1395:
1396: When using pkgsrc on Linux systems, there is high risk of "leakage", where
1397: programs installed by pkgsrc may inadvertently use a command or library not
1398: installed by pkgsrc, e.g. those installed by yum or apt. Such foreign
1399: dependencies may be installed, removed, or upgraded to a version incompatible
1400: with the pkgsrc package at any time, causing pkgsrc packages to subsequently
1401: malfunction. Pkgsrc cannot prevent this, as it has no control over other
1402: package managers. Another potential problem is that under Redhat Enterprise and
1403: related Linux systems, yum packages are only patched and never upgraded, so
1404: eventually they may become too outdated for use by pkgsrc. Even intentionally
1405: using foreign dependencies, not considered leakage, can lead to these problems,
1406: so it is generally discouraged. In order to minimize such problems,
1407: PREFER_PKGSRC defaults to "yes" on Linux systems. This ensures that pkgsrc is
1408: aware of any changes to dependency packages and can rebuild or upgrade the
1409: entire dependency tree as needed. This default can be overridden by setting
1410: --prefer-pkgsrc to a list of packages and --prefer-native to "yes".
1411:
1412: 6.4. Variables affecting the installation process
1.1 dsieger 1413:
1.198 leot 1414: * PKGSRC_KEEP_BIN_PKGS: By default, binary packages of built packages are
1.150 leot 1415: preserved in ${PACKAGES}/All. Setting this variable to "no" prevents this.
1.1 dsieger 1416:
1.107 jnemeth 1417: Packages have to support installation into a subdirectory of WRKDIR. This
1418: allows a package to be built, before the actual filesystem is touched. DESTDIR
1419: support exists in two variations:
1.4 rillig 1420:
1421: * Basic DESTDIR support means that the package installation and packaging is
1422: still run as root.
1423:
1424: * Full DESTDIR support can run the complete build, installation and packaging
1425: as normal user. Root privileges are only needed to add packages.
1426:
1427: With basic DESTDIR support, make clean needs to be run as root.
1428:
1.17 imil 1429: Considering the foo/bar package, DESTDIR full support can be tested using the
1430: following commands
1431:
1432: $ id
1433: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
1434: $ mkdir $HOME/packages
1435: $ cd $PKGSRCDIR/foo/bar
1436:
1437: Verify DESTDIR full support, no root privileges should be needed
1438:
1.66 asau 1439: $ make stage-install
1.17 imil 1440:
1441: Create a package without root privileges
1442:
1.66 asau 1443: $ make PACKAGES=$HOME/packages package
1.17 imil 1444:
1445: For the following command, you must be able to gain root privileges using su(1)
1446:
1.66 asau 1447: $ make PACKAGES=$HOME/packages install
1.17 imil 1448:
1449: Then, as a simple user
1450:
1451: $ make clean
1452:
1.241 rillig 1453: 6.5. Selecting and configuring the compiler
1.4 rillig 1454:
1.241 rillig 1455: 6.5.1. Selecting the compiler
1.1 dsieger 1456:
1457: By default, pkgsrc will use GCC to build packages. This may be overridden by
1458: setting the following variables in /etc/mk.conf:
1459:
1460: PKGSRC_COMPILER:
1461:
1462: This is a list of values specifying the chain of compilers to invoke when
1463: building packages. Valid values are:
1464:
1.259 leot 1465: + ccc: Compaq C Compilers (Tru64)
1.66 asau 1466:
1.259 leot 1467: + ccache: compiler cache (chainable)
1.66 asau 1468:
1.259 leot 1469: + clang: Clang C and Objective-C compiler
1.66 asau 1470:
1.259 leot 1471: + distcc: distributed C/C++ (chainable)
1.1 dsieger 1472:
1.259 leot 1473: + f2c: Fortran 77 to C compiler (chainable)
1.66 asau 1474:
1.259 leot 1475: + icc: Intel C++ Compiler (Linux)
1.66 asau 1476:
1.259 leot 1477: + ido: SGI IRIS Development Option cc (IRIX 5)
1.1 dsieger 1478:
1.259 leot 1479: + gcc: GNU C/C++ Compiler
1.1 dsieger 1480:
1.259 leot 1481: + hp: HP-UX C/aC++ compilers
1.66 asau 1482:
1.259 leot 1483: + mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1 dsieger 1484:
1.259 leot 1485: + mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1 dsieger 1486:
1.259 leot 1487: + sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1 dsieger 1488:
1.259 leot 1489: + xlc: IBM's XL C/C++ compiler suite
1.66 asau 1490:
1.1 dsieger 1491: The default is "gcc". You can use ccache and/or distcc with an appropriate
1492: PKGSRC_COMPILER setting, e.g. "ccache gcc". This variable should always be
1493: terminated with a value for a real compiler. Note that only one real
1494: compiler should be listed (e.g. "sunpro gcc" is not allowed).
1495:
1496: GCC_REQD:
1497:
1498: This specifies the minimum version of GCC to use when building packages. If
1499: the system GCC doesn't satisfy this requirement, then pkgsrc will build and
1500: install one of the GCC packages to use instead.
1501:
1.153 leot 1502: PYTHON_VERSION_DEFAULT:
1.114 maya 1503:
1504: Specifies which version of python to use when several options are
1505: available.
1506:
1507: PKGSRC_FORTRAN:
1508:
1.176 gutterid 1509: Specifies the Fortran compiler to use. The default is gfortran.
1.114 maya 1510:
1511: GFORTRAN_VERSION:
1512:
1513: If PKGSRC_FORTRAN= gfortran is used, this option specifies which version to
1514: use.
1515:
1.241 rillig 1516: 6.5.2. Additional flags to the compiler (CFLAGS)
1.1 dsieger 1517:
1518: If you wish to set the CFLAGS variable, please make sure to use the += operator
1519: instead of the = operator:
1520:
1521: CFLAGS+= -your -flags
1522:
1523: Using CFLAGS= (i.e. without the "+") may lead to problems with packages that
1.16 jnemeth 1524: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24 wiz 1525: package if you're interested in optimization specifically for the current CPU.
1.1 dsieger 1526:
1.241 rillig 1527: 6.5.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 1528:
1529: If you want to pass flags to the linker, both in the configure step and the
1530: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
1531: difference between the two is that LIBS will be appended to the command line,
1532: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
1533: machines depending on the setting of USE_IMAKE or the inclusion of mk/
1534: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
1535: settings, use the += operator:
1536:
1537: LDFLAGS+= -your -linkerflags
1538:
1.241 rillig 1539: 6.6. Developer/advanced settings
1.1 dsieger 1540:
1541: * PKG_DEVELOPER: Run some sanity checks that package developers want:
1542:
1.42 asau 1543: + make sure patches apply with zero fuzz
1.1 dsieger 1544:
1.42 asau 1545: + run check-shlibs to see that all binaries will find their shared libs.
1.1 dsieger 1546:
1.232 gutterid 1547: * CHECK_FILES_STRICT: Also check VARBASE and PKG_SYSCONFDIR values in PLIST
1548: entries.
1549:
1.1 dsieger 1550: * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
1551: making and installing the package. The default value for this is 0, which
1552: will not display the commands as they are executed (normal, default, quiet
1553: operation); the value 1 will display all shell commands before their
1554: invocation, and the value 2 will display both the shell commands before
1.112 rillig 1555: their invocation, as well as their actual execution progress with set -x.
1.1 dsieger 1556:
1.241 rillig 1557: 6.7. Selecting Build Options
1.1 dsieger 1558:
1559: Some packages have build time options, usually to select between different
1560: dependencies, enable optional support for big dependencies or enable
1561: experimental features.
1562:
1563: To see which options, if any, a package supports, and which options are
1564: mutually exclusive, run make show-options, for example:
1565:
1566: The following options are supported by this package:
1567: ssl Enable SSL support.
1568: Exactly one of the following gecko options is required:
1569: firefox Use firefox as gecko rendering engine.
1570: mozilla Use mozilla as gecko rendering engine.
1571: At most one of the following database options may be selected:
1572: mysql Enable support for MySQL database.
1573: pgsql Enable support for PostgreSQL database.
1574:
1575: These options are enabled by default: firefox
1576: These options are currently enabled: mozilla ssl
1577:
1.4 rillig 1578: The following variables can be defined in mk.conf to select which options to
1579: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1 dsieger 1580: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
1581: which can be used to select or disable options specifically for package pkgbase
1582: . Options listed in these variables are selected, options preceded by "-" are
1583: disabled. A few examples:
1584:
1.4 rillig 1585: $ grep "PKG.*OPTION" mk.conf
1.1 dsieger 1586: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
1587: PKG_OPTIONS.kdebase= debug -sasl
1588: PKG_OPTIONS.apache= suexec
1589:
1.11 rillig 1590: It is important to note that options that were specifically suggested by the
1.19 snj 1591: package maintainer must be explicitly removed if you do not wish to include the
1592: option. If you are unsure you can view the current state with make show-options
1593: .
1.11 rillig 1594:
1.1 dsieger 1595: The following settings are consulted in the order given, and the last setting
1596: that selects or disables an option is used:
1597:
1598: 1. the default options as suggested by the package maintainer
1599:
1600: 2. the options implied by the settings of legacy variables (see below)
1601:
1602: 3. PKG_DEFAULT_OPTIONS
1603:
1604: 4. PKG_OPTIONS.pkgbase
1605:
1606: For groups of mutually exclusive options, the last option selected is used, all
1607: others are automatically disabled. If an option of the group is explicitly
1608: disabled, the previously selected option, if any, is used. It is an error if no
1609: option from a required group of options is selected, and building the package
1610: will fail.
1611:
1612: Before the options framework was introduced, build options were selected by
1.4 rillig 1613: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
1614: transition to the options framework for the user, these legacy variables are
1615: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
1616: automatically. A warning is issued to prompt the user to update mk.conf to use
1617: the options framework directly. Support for the legacy variables will be
1.1 dsieger 1618: removed eventually.
1619:
1.154 rillig 1620: Chapter 7. Creating binary packages
1.1 dsieger 1621:
1622: Table of Contents
1623:
1.154 rillig 1624: 7.1. Building a single binary package
1625: 7.2. Settings for creation of binary packages
1.1 dsieger 1626:
1.154 rillig 1627: 7.1. Building a single binary package
1.1 dsieger 1628:
1629: Once you have built and installed a package, you can create a binary package
1630: which can be installed on another system with pkg_add(1). This saves having to
1631: build the same package on a group of hosts and wasting CPU time. It also
1632: provides a simple means for others to install your package, should you
1633: distribute it.
1634:
1635: To create a binary package, change into the appropriate directory in pkgsrc,
1636: and run make package:
1637:
1.112 rillig 1638: $ cd misc/figlet
1639: $ make package
1.1 dsieger 1640:
1.242 gutterid 1641: This will build your package (if not already done) and package it into a binary
1642: package. You can then use the pkg_* tools to manipulate it. Binary packages are
1643: created in PACKAGES, which defaults to /usr/pkgsrc/packages, in the form of a
1644: compressed tar file. See Section C.2, "Packaging figlet" for a continuation of
1645: the above misc/figlet example.
1.1 dsieger 1646:
1.154 rillig 1647: See Chapter 23, Submitting and Committing for information on how to submit such
1.1 dsieger 1648: a binary package.
1649:
1.154 rillig 1650: 7.2. Settings for creation of binary packages
1.1 dsieger 1651:
1.184 rillig 1652: See Section 13.17, "Other helpful targets".
1.6 rillig 1653:
1.154 rillig 1654: Chapter 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6 rillig 1655:
1656: Table of Contents
1657:
1.154 rillig 1658: 8.1. Preparations
1.180 rillig 1659: 8.2. Running a bulk build
1.154 rillig 1660: 8.2.1. Configuration
1661: 8.3. Requirements of a full bulk build
1.178 rillig 1662: 8.4. Bulk build variants
1.179 rillig 1663: 8.4.1. Detect unknown configure options
1664: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.181 rillig 1665: 8.4.3. Force compiler options only in the build phase
1666: 8.4.4. Use custom directories
1667: 8.4.5. Turn warnings into errors
1668: 8.4.6. Reject packages for which pkglint reports errors
1669: 8.4.7. Reject packages that contain forbidden strings
1670: 8.4.8. Reject packages whose self-test fails
1671: 8.4.9. Reject packages that use undefined shell variables
1672: 8.4.10. Turn off verbose logging
1.178 rillig 1673: 8.5. Creating a multiple CD-ROM packages collection
1674: 8.5.1. Example of cdpack
1.6 rillig 1675:
1.175 gutterid 1676: For a number of reasons, you may want to build binary packages for a large
1677: selected set of packages in pkgsrc, or even for all pkgsrc packages. For
1.71 wiz 1678: instance, when you have multiple machines that should run the same software, it
1679: is wasted time if they all build their packages themselves from source. Or you
1680: may want to build a list of packages you want and check them before deploying
1.175 gutterid 1681: onto production systems. There is a way of getting a set of binary packages:
1682: the bulk build system, or pbulk ("p" stands for "parallel"). This chapter
1683: describes how to set it up.
1.71 wiz 1684:
1.154 rillig 1685: 8.1. Preparations
1.71 wiz 1686:
1687: First of all, you have to decide whether you build all packages or a limited
1688: set of them. Full bulk builds usually consume a lot more resources, both space
1.175 gutterid 1689: and time, than builds for some practical sets of packages. A number of
1690: particularly heavy packages exist that are not actually interesting to a wide
1691: audience. (The approximate resource consumption for a full bulk build is given
1692: in section Section 8.3, "Requirements of a full bulk build".) For limited bulk
1693: builds you need to make a list of packages you want to build. Note that all
1694: their dependencies will be built, so you don't need to track them manually.
1.71 wiz 1695:
1696: During bulk builds various packages are installed and deinstalled in /usr/pkg
1697: (or whatever LOCALBASE is), so make sure that you don't need any package during
1.112 rillig 1698: the builds. Essentially, you should provide a fresh system, either a chroot
1.71 wiz 1699: environment or something even more restrictive, depending on what the operating
1700: system provides, or dedicate the whole physical machine. As a useful side
1701: effect this makes sure that bulk builds cannot break anything in your system.
1702: There have been numerous cases where certain packages tried to install files
1703: outside the LOCALBASE or wanted to edit some files in /etc.
1.6 rillig 1704:
1.180 rillig 1705: 8.2. Running a bulk build
1.6 rillig 1706:
1.180 rillig 1707: Running a bulk build works roughly as follows:
1.15 rillig 1708:
1709: * First, build the pbulk infrastructure in a fresh pkgsrc location.
1710:
1711: * Then, build each of the packages from a clean installation directory using
1712: the infrastructure.
1713:
1.154 rillig 1714: 8.2.1. Configuration
1.6 rillig 1715:
1.112 rillig 1716: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6 rillig 1717:
1.68 asau 1718: In order to use it, prepare a clear system (real one, chroot environment, jail,
1719: zone, virtual machine). Configure network access to fetch distribution files.
1.112 rillig 1720: Create a user with name "pbulk".
1.68 asau 1721:
1722: Fetch and extract pkgsrc. Use a command like one of these:
1723:
1.151 sevan 1724: # (cd /usr && ftp -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1725: # (cd /usr && fetch -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1.72 wiz 1726: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68 asau 1727:
1728: Or any other way that fits (e.g., curl, wget).
1729:
1730: Deploy and configure pbulk tools, e.g.:
1731:
1.118 sevan 1732: # sh pbulk.sh -n # use native make, no bootstrap kit needed (for use on NetBSD)
1.68 asau 1733: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
1734: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
1735:
1736: Note
1737:
1738: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
1739: to packages you build. For instance,
1740:
1.112 rillig 1741: PKG_DEVELOPER= yes # perform more checks
1742: X11_TYPE= modular # use pkgsrc X11
1743: SKIP_LICENSE_CHECK= yes # accept all licences (useful
1744: # when building all packages)
1.68 asau 1745:
1746: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112 rillig 1747: with your list of packages, one per line without empty lines or comments. E.g.:
1.68 asau 1748:
1749: www/firefox
1750: mail/thunderbird
1751: misc/libreoffice4
1752:
1.69 asau 1753: At this point you can also review configuration in /usr/pbulk/etc and make
1754: final amendments, if wanted.
1755:
1.68 asau 1756: Start it:
1757:
1758: # /usr/pbulk/bin/bulkbuild
1759:
1760: After it finishes, you'll have /mnt filled with distribution files, binary
1761: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
1762:
1763: Note
1764:
1765: The pbulk.sh script does not cover all possible use cases. While being ready to
1766: run, it serves as a good starting point to understand and build more complex
1767: setups. The script is kept small enough for better understanding.
1768:
1769: Note
1770:
1771: The pbulk.sh script supports running unprivileged bulk build and helps
1.205 wiz 1772: configuring distributed bulk builds. Distributed bulk builds support either
1773: building in worker chroots (each node is a path to a different chroot) that
1774: replicate the target system, including the pbulk prefix, or remote machines
1775: (each node is an IP address that must be accessible over SSH without a
1776: password).
1.15 rillig 1777:
1.154 rillig 1778: 8.3. Requirements of a full bulk build
1.71 wiz 1779:
1780: A complete bulk build requires lots of disk space. Some of the disk space can
1781: be read-only, some other must be writable. Some can be on remote filesystems
1782: (such as NFS) and some should be local. Some can be temporary filesystems,
1783: others must survive a sudden reboot.
1784:
1.205 wiz 1785: * 70 GB for the distfiles (read-write, remote, temporary)
1.71 wiz 1786:
1.205 wiz 1787: * 60 GB for the binary packages (read-write, remote, permanent)
1.71 wiz 1788:
1789: * 1 GB for the pkgsrc tree (read-only, remote, permanent)
1790:
1791: * 5 GB for LOCALBASE (read-write, local, temporary)
1792:
1793: * 10 GB for the log files (read-write, remote, permanent)
1794:
1795: * 5 GB for temporary files (read-write, local, temporary)
1796:
1.178 rillig 1797: 8.4. Bulk build variants
1798:
1799: To ensure that pkgsrc packages work in different configurations, it makes sense
1800: to run non-default bulk builds from time to time. This section lists some ideas
1801: for bulk builds that intentionally let packages fail if they don't follow the
1802: pkgsrc style.
1803:
1.179 rillig 1804: 8.4.1. Detect unknown configure options
1.178 rillig 1805:
1806: Add the following line to mk.conf.
1807:
1808: GNU_CONFIGURE_STRICT= yes
1809:
1810: When a package fails this additional check, the most common cause is that the
1811: configure option was valid for an older version of the package but does not
1812: apply anymore. In that case, just remove it.
1813:
1.179 rillig 1814: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.178 rillig 1815:
1816: The job of a compiler is not restricted to producing executable code, most
1.179 rillig 1817: compilers also detect typical programming mistakes. The pkgsrc compiler
1818: wrappers make it easy to force compiler options when the package is built. This
1819: can be used to find typical bugs across all packages that are in pkgsrc. By
1820: reporting these bugs upstream, the packages will be more reliable with the next
1821: updates.
1.178 rillig 1822:
1.179 rillig 1823: Add some of the following lines to mk.conf:
1.178 rillig 1824:
1825: CFLAGS+= -Werror=char-subscripts
1.179 rillig 1826: CFLAGS+= -Werror=implicit-function-declaration
1.178 rillig 1827:
1.179 rillig 1828: When a package fails to build using these stricter compiler options, document
1829: the circumstances in which the compiler produced the error message. This
1830: includes:
1.178 rillig 1831:
1832: * The platform (MACHINE_PLATFORM)
1833:
1834: * The source file
1835:
1836: * An excerpt of the code. GCC and Clang already do this as part of the
1837: diagnostic.
1838:
1.179 rillig 1839: * The exact error message from the compiler.
1.178 rillig 1840:
1.179 rillig 1841: If a package produces these error messages, but the package is fine, record
1842: this in your local mk.conf, like this, to skip this check in the next builds:
1.178 rillig 1843:
1.179 rillig 1844: .if ${PKGPATH} == category/package
1.178 rillig 1845: # Version ${VERSION} failed on ${MACHINE_PLATFORM}:
1846: # error message
1847: # code
1.179 rillig 1848: # Reason why the code does not need to be fixed.
1.178 rillig 1849: BUILDLINK_TRANSFORM+= rm:-Werror=char-subscripts
1.179 rillig 1850: .endif
1.178 rillig 1851:
1852: If the error messages from the compiler are valid and the code needs to be
1.179 rillig 1853: fixed, prepare a local patch (see LOCALPATCHES) and report the bug to the
1854: upstream authors of the package, providing them with the information you
1855: collected above.
1.178 rillig 1856:
1.179 rillig 1857: Patches that are not essential for the package to work should only be reported
1858: upstream but not committed to pkgsrc, to make future updates easier.
1859:
1.181 rillig 1860: 8.4.3. Force compiler options only in the build phase
1861:
1862: When adding custom compiler flags via CFLAGS, these apply to all phases of the
1863: package build process. Especially in the configure phase, adding -Werror leads
1864: to wrong decisions. The GNU configure scripts feed many small test programs to
1865: the C compiler to see whether certain headers are available, functions are
1866: defined in a library and programs can be run. In many cases these programs
1867: would not survive a strict compiler run with -Wall -Wextra -Werror.
1868:
1869: The pkgsrc infrastructure is flexible enough to support compiler options being
1870: added between the configure and build phases. It's a little more complicated
1871: than the other examples in this section but still easy enough.
1872:
1873: The basic idea is to use the pkgsrc compiler wrapper to inject the desired
1874: compiler options. The compiler wrapper's original task is to hide unwanted
1875: directories of include files and to normalize compiler options. It does this by
1876: wrapping the compiler command and rewriting the command line. To see this in
1877: action, run bmake patch in a package directory and examine the work/.cwrappers/
1878: config directory. It contains individual configurations for the C compiler and
1879: the related tools. The plan is to find a hook between the configure and build
1880: phases, and to modify these configuration files at that point.
1881:
1882: To find this hook, have a look at mk/build/build.mk, which contains among
1883: others the pre-build-checks-hook. The word checks doesn't quite fit, but the
1884: pre-build-hook sounds good enough.
1885:
1886: The code to be included in mk.conf is:
1887:
1888: # Just a few example options.
1889: BUILD_ONLY_CFLAGS= -Wall -Werror -O2 -DTEMPDIR='"/tmp"'
1890:
1891: .if ${BUILD_ONLY_CFLAGS:U:M*}
1892: pre-build-checks-hook: add-build-only-cflags
1893:
1894: add-build-only-cflags: .PHONY
1895: ${RUN} cd ${CWRAPPERS_CONFIG_DIR}; \
1896: ${TEST} ! -f ${.TARGET} || exit 0; \
1897: for flag in ${BUILD_ONLY_CFLAGS}; do \
1898: ${ECHO} "append=$$flag" >> cc; \
1899: done; \
1900: > ${.TARGET}
1901: .endif
1902:
1903: (When editing the mk.conf, make sure that the commands of the
1904: add-build-only-cflags target are indented with a tab, not with spaces.)
1905:
1906: The condition in the .if statement contains the :U modifier to prevent parse
1907: errors if the variable should be undefined, possibly because it is only defined
1908: for a subset of the packages. The :M* modifier ensures that there is at least
1909: one compiler option, to prevent a syntax error in the shell parser.
1910:
1911: The code around the ${.TARGET} variable ensures that the additional compiler
1912: options are only appended once, even if bmake build is run multiple times. To
1913: do this, it creates a marker file.
1914:
1915: To verify that this setup works, run bmake configure in a package directory. Up
1916: to now, everything works as usual. Examine the directory work/.cwrappers/config
1917: to see that the compiler options from BUILD_ONLY_CFLAGS are not yet added to
1918: the file cc. Examine the tail of the work/.work.log file to see that the normal
1919: compiler options are used.
1920:
1921: Now run bmake build. This will append the options to the file cc and will
1922: create the marker file in the same directory. After that, the build starts as
1923: usual, but with the added compiler options. Examine the tail of the file work
1924: /.work.log to see that the lines starting with [*] don't contain the compiler
1925: options, but the corresponding lines starting with <.> do end with these
1926: options.
1927:
1928: Building packages using this setup variant and fixing the resulting bugs is the
1929: same as in Section 8.4.2, "Detect classes of bugs by forcing compiler warnings"
1930: .
1931:
1932: 8.4.4. Use custom directories
1.178 rillig 1933:
1934: Some directories like PREFIX, VARBASE, PKG_SYSCONFDIR, PKGMANDIR, PKG_INFODIR
1935: can be configured in pkgsrc. Set these to arbitrary paths during bootstrap or
1936: afterwards in mk.conf.
1937:
1938: PREFIX= /a-random-uuid
1939: PKG_SYSCONFDIR= /a-random-uuid
1940: VARBASE= /a-random-uuid
1941: PKGMANDIR= a-random-uuid
1942: PKG_INFODIR= a-random-uuid
1943:
1.181 rillig 1944: 8.4.5. Turn warnings into errors
1.178 rillig 1945:
1946: When building a package, warnings are typically ignored since they just flow by
1947: and do not cause the build to fail immediately. To find these warnings,
1948: redefine them to errors in mk.conf.
1949:
1950: DELAYED_WARNING_MSG= ${DELAYED_ERROR_MSG} "(was warning)"
1951: WARNING_MSG= ${FAIL_MSG} "(was warning)"
1952:
1953: (There are many more classes of warnings in pkgsrc, and most of them can be
1954: redefined with a simple definition like above.
1955:
1.179 rillig 1956: If a package suggests to add USE_TOOLS+=perl to the package Makefile, research
1.178 rillig 1957: whether the package actually needs Perl. If it does, add USE_TOOLS+=perl to the
1958: package Makefile, and if it doesn't, add TOOLS_BROKEN+=perl.
1959:
1.181 rillig 1960: 8.4.6. Reject packages for which pkglint reports errors
1.178 rillig 1961:
1962: Using pkglint as part of the regular build process is mostly a waste of time.
1963: If you want to fix some of the warnings, just run pkglint recursively on the
1964: whole pkgsrc tree. This will take a few minutes (up to 10), which is much
1965: faster than a complete bulk build.
1966:
1.181 rillig 1967: 8.4.7. Reject packages that contain forbidden strings
1.178 rillig 1968:
1969: To ensure that the binary packages don't contain references to the build
1970: directory, there is already CHECK_WRKREF. If that variable includes the item
1971: extra, it is possible to define additional patterns that must not appear in any
1972: installed file. This is specified in mk.conf.
1973:
1974: CHECK_WRKREF= extra
1975: CHECK_WRKREF_EXTRA_DIRS+= /usr/local
1976: CHECK_WRKREF_EXTRA_DIRS+= /usr/pkg
1977: CHECK_WRKREF_EXTRA_DIRS+= @[A-Z][A-Z]*@
1978:
1979: The above patterns will probably generate many false positives, therefore the
1980: results need to be taken with a grain of salt.
1981:
1.181 rillig 1982: 8.4.8. Reject packages whose self-test fails
1.178 rillig 1983:
1984: To run the test suites that come with each package, add this line to mk.conf.
1985:
1986: PKGSRC_RUN_TEST= yes
1987:
1988: Be prepared that even the most basic packages fail this test. When doing a bulk
1989: build with this, it will often abort in the early phase where the packages are
1990: scanned for their dependencies since there are cyclic dependencies. There is
1991: still a lot to do in this area.
1992:
1.181 rillig 1993: 8.4.9. Reject packages that use undefined shell variables
1.178 rillig 1994:
1995: To catch typos in the shell snippets from the Makefile fragments, add the -u
1996: flag to most of the commands by adding this line to mk.conf.
1997:
1998: RUN= @set -eu;
1999:
1.181 rillig 2000: After that, ensure that none of the bulk build log files (even those for
2001: successfully built packages) contains the string parameter not set or whatever
2002: error message the command sh -ceu '$undefined' outputs.
2003:
1.178 rillig 2004: See mk/misc/common.mk for the existing definition.
2005:
1.181 rillig 2006: 8.4.10. Turn off verbose logging
1.178 rillig 2007:
2008: The build logs of a package are often quite long. This allows error messages or
2009: other interesting details to hide between the noise. To make the actual error
2010: message stand out more, add these lines to mk.conf.
2011:
2012: GNU_CONFIGURE_QUIET= yes
2013: MAKE_FLAGS+= -s
2014:
2015: The -s option works for both GNU Make and BSD Make. On exotic platforms with
2016: their own make, it may be a little different.
2017:
2018: 8.5. Creating a multiple CD-ROM packages collection
1.1 dsieger 2019:
2020: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
2021: of the resulting binary packages to assist in installing packages on other
2022: machines. The pkgtools/cdpack package provides a simple tool for creating the
2023: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
2024: keeps all the dependencies for a given package on the same CD as that package.
2025:
1.178 rillig 2026: 8.5.1. Example of cdpack
1.1 dsieger 2027:
2028: Complete documentation for cdpack is found in the cdpack(1) man page. The
2029: following short example assumes that the binary packages are left in /usr/
2030: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
2031: ISO 9660 images.
2032:
2033: # mkdir /u2/images
2034: # pkg_add /usr/pkgsrc/packages/All/cdpack
2035: # cdpack /usr/pkgsrc/packages/All /u2/images
2036:
2037:
2038: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
2039: CD in the collection, then you need to create a directory which contains these
1.175 gutterid 2040: files, e.g.:
1.1 dsieger 2041:
2042: # mkdir /tmp/common
2043: # echo "This is a README" > /tmp/common/README
2044: # echo "Another file" > /tmp/common/COPYING
2045: # mkdir /tmp/common/bin
2046: # echo "#!/bin/sh" > /tmp/common/bin/myscript
2047: # echo "echo Hello world" >> /tmp/common/bin/myscript
2048: # chmod 755 /tmp/common/bin/myscript
2049:
2050:
2051: Now create the images:
2052:
2053: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
2054:
2055: Each image will contain README, COPYING, and bin/myscript in their root
2056: directories.
2057:
1.154 rillig 2058: Chapter 9. Directory layout of the installed files
1.1 dsieger 2059:
2060: Table of Contents
2061:
1.154 rillig 2062: 9.1. File system layout in ${LOCALBASE}
2063: 9.2. File system layout in ${VARBASE}
1.1 dsieger 2064:
2065: The files that are installed by pkgsrc are organized in a way that is similar
2066: to what you find in the /usr directory of the base system. But some details are
2067: different. This is because pkgsrc initially came from FreeBSD and had adopted
2068: its file system hierarchy. Later it was largely influenced by NetBSD. But no
2069: matter which operating system you are using pkgsrc with, you can expect the
2070: same layout for pkgsrc.
2071:
2072: There are mainly four root directories for pkgsrc, which are all configurable
2073: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
2074: default locations are:
2075:
2076: LOCALBASE= /usr/pkg
2077: PKG_SYSCONFBASE= /usr/pkg/etc
2078: VARBASE= /var
1.119 sevan 2079: PKG_DBDIR= /usr/pkg/pkgdb
1.1 dsieger 2080:
2081: In unprivileged mode (when pkgsrc has been installed as any other user), the
2082: default locations are:
2083:
2084: LOCALBASE= ${HOME}/pkg
2085: PKG_SYSCONFBASE= ${HOME}/pkg/etc
2086: VARBASE= ${HOME}/pkg/var
1.119 sevan 2087: PKG_DBDIR= ${HOME}/pkg/pkgdb
1.1 dsieger 2088:
2089: What these four directories are for, and what they look like is explained
2090: below.
2091:
1.25 wiz 2092: * LOCALBASE corresponds to the /usr directory in the base system. It is the "
2093: main" directory where the files are installed and contains the well-known
1.1 dsieger 2094: subdirectories like bin, include, lib, share and sbin.
2095:
2096: * VARBASE corresponds to /var in the base system. Some programs (especially
2097: games, network daemons) need write access to it during normal operation.
2098:
2099: * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
2100: configuration files of the packages, as well as pkgsrc's mk.conf itself.
2101:
1.154 rillig 2102: 9.1. File system layout in ${LOCALBASE}
1.1 dsieger 2103:
2104: The following directories exist in a typical pkgsrc installation in $
2105: {LOCALBASE}.
2106:
2107: bin
2108:
2109: Contains executable programs that are intended to be directly used by the
2110: end user.
2111:
2112: emul
2113:
2114: Contains files for the emulation layers of various other operating systems,
2115: especially for NetBSD.
2116:
2117: etc (the usual location of ${PKG_SYSCONFDIR})
2118:
2119: Contains the configuration files.
2120:
2121: include
2122:
2123: Contains headers for the C and C++ programming languages.
2124:
2125: info
2126:
2127: Contains GNU info files of various packages.
2128:
2129: lib
2130:
2131: Contains shared and static libraries.
2132:
2133: libdata
2134:
2135: Contains data files that don't change after installation. Other data files
2136: belong into ${VARBASE}.
2137:
2138: libexec
2139:
2140: Contains programs that are not intended to be used by end users, such as
2141: helper programs or network daemons.
2142:
2143: libexec/cgi-bin
2144:
2145: Contains programs that are intended to be executed as CGI scripts by a web
2146: server.
2147:
2148: man (the usual value of ${PKGMANDIR})
2149:
2150: Contains brief documentation in form of manual pages.
2151:
2152: sbin
2153:
2154: Contains programs that are intended to be used only by the super-user.
2155:
2156: share
2157:
2158: Contains platform-independent data files that don't change after
2159: installation.
2160:
2161: share/doc
2162:
2163: Contains documentation files provided by the packages.
2164:
2165: share/examples
2166:
2167: Contains example files provided by the packages. Among others, the original
2168: configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
2169: installation.
2170:
2171: share/examples/rc.d
2172:
2173: Contains the original files for rc.d scripts.
2174:
2175: var (the usual location of ${VARBASE})
2176:
2177: Contains files that may be modified after installation.
2178:
1.154 rillig 2179: 9.2. File system layout in ${VARBASE}
1.1 dsieger 2180:
2181: db/pkg (the usual location of ${PKG_DBDIR})
2182:
2183: Contains information about the currently installed packages.
2184:
2185: games
2186:
2187: Contains highscore files.
2188:
2189: log
2190:
2191: Contains log files.
2192:
2193: run
2194:
2195: Contains informational files about daemons that are currently running.
2196:
1.154 rillig 2197: Chapter 10. Frequently Asked Questions
1.1 dsieger 2198:
2199: Table of Contents
2200:
1.154 rillig 2201: 10.1. Are there any mailing lists for pkg-related discussion?
2202: 10.2. Utilities for package management (pkgtools)
2203: 10.3. How to use pkgsrc as non-root
2204: 10.4. How to resume transfers when fetching distfiles?
2205: 10.5. How can I install/use modular X.org from pkgsrc?
2206: 10.6. How to fetch files from behind a firewall
2207: 10.7. How to fetch files from HTTPS sites
2208: 10.8. How do I tell make fetch to do passive FTP?
2209: 10.9. How to fetch all distfiles at once
2210: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
2211: 10.11. What does "Could not find bsd.own.mk" mean?
1.221 nia 2212: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154 rillig 2213: 10.13. How do I change the location of configuration files?
2214: 10.14. Automated security checks
2215: 10.15. Why do some packages ignore my CFLAGS?
2216: 10.16. A package does not build. What shall I do?
2217: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.259 leot 2218: conflicts" mean?
1.1 dsieger 2219:
2220: This section contains hints, tips & tricks on special things in pkgsrc that we
2221: didn't find a better place for in the previous chapters, and it contains items
2222: for both pkgsrc users and developers.
2223:
1.154 rillig 2224: 10.1. Are there any mailing lists for pkg-related discussion?
1.1 dsieger 2225:
2226: The following mailing lists may be of interest to pkgsrc users:
2227:
2228: * pkgsrc-users: This is a general purpose list for most issues regarding
2229: pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
2230: configuration, unexpected build failures, using particular packages,
2231: upgrading pkgsrc installations, questions regarding the pkgsrc release
2232: branches, etc. General announcements or proposals for changes that impact
2233: the pkgsrc user community, e.g. major infrastructure changes, new features,
2234: package removals, etc., may also be posted.
2235:
2236: * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
2237: discussed.
2238:
2239: * pkgsrc-changes: This list is for those who are interested in getting a
2240: commit message for every change committed to pkgsrc. It is also available
2241: in digest form, meaning one daily message containing all commit messages
2242: for changes to the package source tree in that 24 hour period.
2243:
2244: To subscribe, do:
2245:
2246: % echo subscribe listname | mail majordomo@NetBSD.org
2247:
1.174 leot 2248: Archives for all these mailing lists are available from https://
1.1 dsieger 2249: mail-index.NetBSD.org/.
2250:
1.154 rillig 2251: 10.2. Utilities for package management (pkgtools)
1.1 dsieger 2252:
2253: The directory pkgsrc/pkgtools contains a number of useful utilities for both
2254: users and developers of pkgsrc. This section attempts only to make the reader
1.121 sevan 2255: aware of some of the utilities and when they might be useful, and not to
2256: duplicate the documentation that comes with each package.
1.1 dsieger 2257:
2258: Utilities used by pkgsrc (automatically installed when needed):
2259:
2260: * pkgtools/x11-links: Symlinks for use by buildlink.
2261:
2262: OS tool augmentation (automatically installed when needed):
2263:
1.121 sevan 2264: * pkgtools/digest: Calculates various kinds of checksums (including SHA3).
1.1 dsieger 2265:
2266: * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
2267:
2268: * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
2269:
2270: * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
2271: for use on operating systems where pkg_install is not present.
2272:
2273: Utilities used by pkgsrc (not automatically installed):
2274:
2275: * pkgtools/pkg_tarup: Create a binary package from an already-installed
2276: package. Used by make replace to save the old package.
2277:
2278: * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
2279: distfiles from multiple locations. It currently supports the following
2280: methods: multiple CD-ROMs and network FTP/HTTP connections.
2281:
2282: * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24 wiz 2283: current CPU and compiler.
1.1 dsieger 2284:
2285: Utilities for keeping track of installed packages, being up to date, etc:
2286:
1.65 wiz 2287: * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
2288: and upgrade binary packages easily.
2289:
1.1 dsieger 2290: * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
2291: the latest pkgsrc entries.
2292:
2293: * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
2294: strategy for updating.
2295:
2296: * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
2297: graphviz).
2298:
1.12 weinem 2299: * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
2300:
2301: * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
2302: complete pkgsrc system.
1.1 dsieger 2303:
2304: * pkgtools/pkgsurvey: Report what packages you have installed.
2305:
2306: Utilities for people maintaining or creating individual packages:
2307:
2308: * pkgtools/pkgdiff: Automate making and maintaining patches for a package
2309: (includes pkgdiff, pkgvi, mkpatches, etc.).
2310:
1.65 wiz 2311: * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1 dsieger 2312:
2313: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
2314:
2315: * pkgtools/pkg_comp: Build packages in a chrooted area.
2316:
2317: * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
2318:
1.154 rillig 2319: 10.3. How to use pkgsrc as non-root
1.1 dsieger 2320:
1.108 rillig 2321: To install packages from source as a non-root user, download pkgsrc as
1.154 rillig 2322: described in Chapter 3, Where to get pkgsrc and how to keep it up-to-date, cd
1.108 rillig 2323: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
2324:
2325: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
2326: configuration mk.conf into ~/pkg/etc.
2327:
2328: For more details, see mk/unprivileged.mk.
1.1 dsieger 2329:
1.154 rillig 2330: 10.4. How to resume transfers when fetching distfiles?
1.1 dsieger 2331:
2332: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4 rillig 2333: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
2334: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1 dsieger 2335:
1.61 wiz 2336: You can also use a different program than the platform default program by
2337: changing the FETCH_USING variable. You can specify the program by using of ftp,
2338: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
2339: manual. A value of custom disables the system defaults and dependency tracking
2340: for the fetch program. In that case you have to provide FETCH_CMD,
2341: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1 dsieger 2342:
1.16 jnemeth 2343: For example, if you want to use wget to download, you'll have to use something
2344: like:
1.1 dsieger 2345:
1.16 jnemeth 2346: FETCH_USING= wget
1.1 dsieger 2347:
1.154 rillig 2348: 10.5. How can I install/use modular X.org from pkgsrc?
1.1 dsieger 2349:
1.4 rillig 2350: If you want to use modular X.org from pkgsrc instead of your system's own X11
2351: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1 dsieger 2352: mk.conf:
2353:
1.4 rillig 2354: X11_TYPE=modular
1.1 dsieger 2355:
1.154 rillig 2356: 10.6. How to fetch files from behind a firewall
1.1 dsieger 2357:
2358: If you are sitting behind a firewall which does not allow direct connections to
2359: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
2360: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
2361: machine "orpheus.amdahl.com" is one of the firewalls, and it uses port 80 as
2362: the proxy port number. So the proxy environment variables are:
2363:
2364: ftp_proxy=ftp://orpheus.amdahl.com:80/
2365: http_proxy=http://orpheus.amdahl.com:80/
2366:
1.154 rillig 2367: 10.7. How to fetch files from HTTPS sites
1.65 wiz 2368:
2369: Some fetch tools are not prepared to support HTTPS by default (for example, the
2370: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
2371: openssl dependency that low in the dependency graph).
2372:
2373: Usually you won't notice, because distribution files are mirrored weekly to "
2374: ftp.NetBSD.org", but that might not be often enough if you are following
2375: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to "curl" or
2376: "wget", which are both compiled with HTTPS support by default. Of course, these
2377: tools need to be installed before you can use them this way.
2378:
1.154 rillig 2379: 10.8. How do I tell make fetch to do passive FTP?
1.1 dsieger 2380:
2381: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
2382: FETCH_CMD is assigned the first available command from the following list:
2383:
2384: * ${LOCALBASE}/bin/ftp
2385:
2386: * /usr/bin/ftp
2387:
2388: On a default NetBSD installation, this will be /usr/bin/ftp, which
2389: automatically tries passive connections first, and falls back to active
2390: connections if the server refuses to do passive. For the other tools, add the
1.4 rillig 2391: following to your mk.conf file: PASSIVE_FETCH=1.
1.1 dsieger 2392:
2393: Having that option present will prevent /usr/bin/ftp from falling back to
2394: active transfers.
2395:
1.154 rillig 2396: 10.9. How to fetch all distfiles at once
1.1 dsieger 2397:
2398: You would like to download all the distfiles in a single batch from work or
2399: university, where you can't run a make fetch. There is an archive of distfiles
2400: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
2401:
2402: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
2403: subdirectories, carry the resulting list to your machine at work/school and use
2404: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
2405: don't forget to set FETCH_CMD to something that fetches a URL:
2406:
2407: At home:
2408:
2409: % cd /usr/pkgsrc
2410: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
2411: % scp /tmp/fetch.sh work:/tmp
2412:
2413: At work:
2414:
2415: % sh /tmp/fetch.sh
2416:
2417: then tar up /tmp/distfiles and take it home.
2418:
2419: If you have a machine running NetBSD, and you want to get all distfiles (even
2420: ones that aren't for your machine architecture), you can do so by using the
2421: above-mentioned make fetch-list approach, or fetch the distfiles directly by
2422: running:
2423:
2424: % make mirror-distfiles
2425:
2426: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
2427: everything by running:
2428:
2429: % make fetch NO_SKIP=yes
2430:
1.154 rillig 2431: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1.1 dsieger 2432:
2433: When compiling the pkgtools/pkg_install package, you get the error from make
2434: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
2435: that you don't have installed the "text" set (nroff, ...) from the NetBSD base
2436: distribution on your machine. It is recommended to do that to format man pages.
2437:
2438: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4 rillig 2439: NOMAN=YES either in the environment or in mk.conf.
1.1 dsieger 2440:
1.154 rillig 2441: 10.11. What does "Could not find bsd.own.mk" mean?
1.1 dsieger 2442:
2443: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
2444: machine. Please get and install it, by extracting it in /:
2445:
2446: # cd /
2447: # tar --unlink -zxvpf .../comp.tgz
2448:
2449: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
2450: release (determine via uname -r).
2451:
1.221 nia 2452: 10.12. Using 'sudo' or `priv` with pkgsrc
1.1 dsieger 2453:
2454: When installing packages as non-root user and using the just-in-time su(1)
2455: feature of pkgsrc, it can become annoying to type in the root password for each
2456: required package installed. To avoid this, the sudo package can be used, which
1.221 nia 2457: does password caching over a limited time. To use it, install sudo or priv
2458: (either as binary package, from security/priv, or security/sudo) and then put
2459: the following into your mk.conf, somewhere after the definition of the
2460: LOCALBASE variable:
1.1 dsieger 2461:
2462: .if exists(${LOCALBASE}/bin/sudo)
1.260 wiz 2463: SU_CMD= ${LOCALBASE}/bin/sudo -E /bin/sh -c
1.1 dsieger 2464: .endif
2465:
1.260 wiz 2466: Note the -E flag; that tells sudo to preserve the environment. Without this,
2467: the bin-install target will fail when building a package with a non-default
2468: python version.
2469:
1.154 rillig 2470: 10.13. How do I change the location of configuration files?
1.1 dsieger 2471:
2472: As the system administrator, you can choose where configuration files are
2473: installed. The default settings make all these files go into ${PREFIX}/etc or
2474: some of its subdirectories; this may be suboptimal depending on your
2475: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
2476: configuration of the provided packages).
2477:
2478: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4 rillig 2479: (in mk.conf) to point to your preferred configuration directory; some common
2480: examples include /etc or /etc/pkg.
1.1 dsieger 2481:
2482: Furthermore, you can change this value on a per-package basis by setting the
2483: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
2484: matches the name of the package you would like to modify, that is, the contents
2485: of PKGBASE.
2486:
2487: Note that after changing these settings, you must rebuild and reinstall any
2488: affected packages.
2489:
1.154 rillig 2490: 10.14. Automated security checks
1.1 dsieger 2491:
2492: Please be aware that there can often be bugs in third-party software, and some
2493: of these bugs can leave a machine vulnerable to exploitation by attackers. In
2494: an effort to lessen the exposure, the NetBSD packages team maintains a database
2495: of known-exploits to packages which have at one time been included in pkgsrc.
2496: The database can be downloaded automatically, and a security audit of all
1.14 jmcneill 2497: packages installed on a system can take place. To do this, refer to the
2498: following two tools (installed as part of the pkgtools/pkg_install package):
1.1 dsieger 2499:
1.21 snj 2500: 1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
2501: security vulnerabilities information. This list is kept up to date by the
1.26 spz 2502: pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1 dsieger 2503:
1.177 leot 2504: https://ftp.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities
1.1 dsieger 2505:
1.21 snj 2506: 2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24 wiz 2507: known vulnerability. If a vulnerable package is installed, it will be shown
2508: by output to stdout, including a description of the type of vulnerability,
2509: and a URL containing more information.
1.1 dsieger 2510:
1.202 nia 2511: Use of these tools is strongly recommended! See Section 5.1.6, "Checking for
1.121 sevan 2512: security vulnerabilities in installed packages" for instructions on how to
2513: automate checking and reporting.
2514:
2515: If this database is installed, pkgsrc builds will use it to perform a security
2516: check before building any package.
1.1 dsieger 2517:
1.154 rillig 2518: 10.15. Why do some packages ignore my CFLAGS?
1.1 dsieger 2519:
2520: When you add your own preferences to the CFLAGS variable in your mk.conf, these
2521: flags are passed in environment variables to the ./configure scripts and to
2522: make(1). Some package authors ignore the CFLAGS from the environment variable
2523: by overriding them in the Makefiles of their package.
2524:
2525: Currently there is no solution to this problem. If you really need the package
2526: to use your CFLAGS you should run make patch in the package directory and then
2527: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
2528: Usually you can remove these lines. But be aware that some "smart" programmers
2529: write so bad code that it only works for the specific combination of CFLAGS
2530: they have chosen.
2531:
1.172 rillig 2532: To find out where the CFLAGS are ignored, add the following lines to mk.conf:
2533:
2534: CPPFLAGS+= -Dpkgsrc___CPPFLAGS
2535: CFLAGS+= -Dpkgsrc___CFLAGS
2536: CXXFLAGS+= -Dpkgsrc___CXXFLAGS
2537:
2538: Then run bmake show-all-configure show-all-build to see whether the above flags
2539: are passed to the actual build commands in general.
2540:
2541: To find out whether the flags are passed to individual compiler commands, have
2542: a look at the file work/.work.log. In most cases, the flags from the original
2543: command lines (the lines starting with [*]) are passed unmodified to the actual
2544: compiler (the lines starting with <.>). If the flag is missing from the actual
2545: compiler command, it must have been removed by the pkgsrc compiler wrappers.
2546:
1.154 rillig 2547: 10.16. A package does not build. What shall I do?
1.1 dsieger 2548:
2549: 1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
2550: is that people only update pkgsrc in parts, because of performance reasons.
2551: Since pkgsrc is one large system, not a collection of many small systems,
2552: there are sometimes changes that only work when the whole pkgsrc tree is
2553: updated.
2554:
1.25 wiz 2555: 2. Make sure that you don't have any CVS conflicts. Search for "<<<<<<" or "
2556: >>>>>>" in all your pkgsrc files.
1.1 dsieger 2557:
1.25 wiz 2558: 3. Make sure that you don't have old copies of the packages extracted. Run
1.1 dsieger 2559: make clean clean-depends to verify this.
2560:
1.108 rillig 2561: 4. If you are a package developer who wants to invest some work, have a look
1.154 rillig 2562: at Chapter 21, Making your package work.
1.108 rillig 2563:
2564: 5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1 dsieger 2565:
1.154 rillig 2566: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.1 dsieger 2567: conflicts" mean?
2568:
2569: You have modified a file from pkgsrc, and someone else has modified that same
2570: file afterwards in the CVS repository. Both changes are in the same region of
2571: the file, so when you updated pkgsrc, the cvs command marked the conflicting
2572: changes in the file. Because of these markers, the file is no longer a valid
2573: Makefile.
2574:
2575: Have a look at that file, and if you don't need your local changes anymore, you
2576: can remove that file and run cvs -q update -dP in that directory to download
2577: the current version.
2578:
2579: Part II. The pkgsrc developer's guide
2580:
2581: This part of the book deals with creating and modifying packages. It starts
2582: with a "HOWTO"-like guide on creating a new package. The remaining chapters are
2583: more like a reference manual for pkgsrc.
2584:
2585: Table of Contents
2586:
1.154 rillig 2587: 11. Getting help
1.184 rillig 2588: 12. Package components - files, directories and contents
2589: 12.1. Makefile
2590: 12.2. distinfo
2591: 12.3. patches/*
2592: 12.3.1. Structure of a single patch file
2593: 12.3.2. Creating patch files
2594: 12.3.3. Sources where the patch files come from
2595: 12.3.4. Patching guidelines
2596: 12.3.5. Feedback to the author
2597: 12.4. Other mandatory files
2598: 12.5. Optional files
2599: 12.5.1. Files affecting the binary package
2600: 12.5.2. Files affecting the build process
2601: 12.5.3. Files affecting nothing at all
2602: 12.6. work*
2603: 12.7. files/*
2604: 13. The build process
2605: 13.1. Introduction
2606: 13.2. Program location
2607: 13.3. Directories used during the build process
2608: 13.4. Running a phase
2609: 13.5. The fetch phase
2610: 13.5.1. What to fetch and where to get it from
2611: 13.5.2. How are the files fetched?
2612: 13.6. The checksum phase
2613: 13.7. The extract phase
2614: 13.8. The patch phase
2615: 13.9. The tools phase
2616: 13.10. The wrapper phase
2617: 13.11. The configure phase
2618: 13.12. The build phase
2619: 13.13. The test phase
2620: 13.14. The install phase
2621: 13.15. The package phase
2622: 13.16. Cleaning up
2623: 13.17. Other helpful targets
2624: 14. Creating a new pkgsrc package from scratch
2625: 14.1. Common types of packages
1.219 nia 2626: 14.1.1. Python modules and programs
2627: 14.1.2. R packages
2628: 14.1.3. TeXlive packages
1.184 rillig 2629: 14.2. Examples
2630: 14.2.1. How the www/nvu package came into pkgsrc
2631: 15. Programming in Makefiles
2632: 15.1. Caveats
2633: 15.2. Makefile variables
2634: 15.2.1. Naming conventions
2635: 15.3. Code snippets
2636: 15.3.1. Adding things to a list
2637: 15.3.2. Echoing a string exactly as-is
2638: 15.3.3. Passing CFLAGS to GNU configure scripts
2639: 15.3.4. Handling possibly empty variables
1.229 gutterid 2640: 15.3.5. Testing yes/no variables in conditions
1.184 rillig 2641: 16. Options handling
2642: 16.1. Global default options
2643: 16.2. Converting packages to use bsd.options.mk
2644: 16.3. Option Names
2645: 16.4. Determining the options of dependencies
2646: 17. Tools needed for building or running
2647: 17.1. Tools for pkgsrc builds
2648: 17.2. Tools needed by packages
2649: 17.3. Tools provided by platforms
2650: 18. Buildlink methodology
2651: 18.1. Converting packages to use buildlink3
2652: 18.2. Writing buildlink3.mk files
2653: 18.2.1. Anatomy of a buildlink3.mk file
2654: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
1.259 leot 2655: pkg in buildlink3.mk files
1.184 rillig 2656: 18.3. Writing builtin.mk files
2657: 18.3.1. Anatomy of a builtin.mk file
2658: 19. PLIST issues
2659: 19.1. RCS ID
2660: 19.2. Semi-automatic PLIST generation
2661: 19.3. Tweaking output of make print-PLIST
2662: 19.4. Variable substitution in PLIST
2663: 19.5. Man page compression
2664: 19.6. Changing PLIST source with PLIST_SRC
2665: 19.7. Platform-specific and differing PLISTs
2666: 19.8. Build-specific PLISTs
2667: 19.9. Sharing directories between packages
2668: 20. The pkginstall framework
2669: 20.1. Files and directories outside the installation prefix
2670: 20.1.1. Directory manipulation
2671: 20.1.2. File manipulation
2672: 20.2. Configuration files
2673: 20.2.1. How PKG_SYSCONFDIR is set
2674: 20.2.2. Telling the software where configuration files are
1.239 dholland 2675: 20.2.3. Patching installation
2676: 20.2.4. Declaring configuration files
2677: 20.2.5. Disabling handling of configuration files
1.184 rillig 2678: 20.3. System startup scripts
2679: 20.3.1. Disabling handling of system startup scripts
2680: 20.4. System users and groups
2681: 20.5. System shells
2682: 20.5.1. Disabling shell registration
2683: 20.6. Fonts
2684: 20.6.1. Disabling automatic update of the fonts databases
1.154 rillig 2685: 21. Making your package work
2686: 21.1. General operation
2687: 21.1.1. How to pull in user-settable variables from mk.conf
2688: 21.1.2. User interaction
2689: 21.1.3. Handling licenses
2690: 21.1.4. Restricted packages
2691: 21.1.5. Handling dependencies
2692: 21.1.6. Handling conflicts with other packages
2693: 21.1.7. Packages that cannot or should not be built
2694: 21.1.8. Packages which should not be deleted, once installed
2695: 21.1.9. Handling packages with security problems
2696: 21.1.10. How to handle incrementing versions when fixing an existing
1.259 leot 2697: package
1.154 rillig 2698: 21.1.11. Substituting variable text in the package files (the SUBST
1.259 leot 2699: framework)
1.154 rillig 2700: 21.2. The fetch phase
2701: 21.2.1. Packages whose distfiles aren't available for plain downloading
2702: 21.2.2. How to handle modified distfiles with the 'old' name
2703: 21.2.3. Packages hosted on github.com
2704: 21.3. The configure phase
2705: 21.3.1. Shared libraries - libtool
2706: 21.3.2. Using libtool on GNU packages that already support libtool
2707: 21.3.3. GNU Autoconf/Automake
1.223 nia 2708: 21.3.4. Meson / ninja
1.260 wiz 2709: 21.3.5. Determining the endianness
1.154 rillig 2710: 21.4. Programming languages
2711: 21.4.1. C, C++, and Fortran
2712: 21.4.2. Java
1.205 wiz 2713: 21.4.3. Go
1.223 nia 2714: 21.4.4. Rust
2715: 21.4.5. Packages containing Perl scripts
2716: 21.4.6. Packages containing shell scripts
2717: 21.4.7. Other programming languages
1.154 rillig 2718: 21.5. The build phase
2719: 21.5.1. Compiling C and C++ code conditionally
2720: 21.5.2. How to handle compiler bugs
1.172 rillig 2721: 21.5.3. No such file or directory
2722: 21.5.4. Undefined reference to "..."
2723: 21.5.5. Running out of memory
1.154 rillig 2724: 21.6. The install phase
2725: 21.6.1. Creating needed directories
2726: 21.6.2. Where to install documentation
2727: 21.6.3. Installing highscore files
2728: 21.6.4. Adding DESTDIR support to packages
2729: 21.6.5. Packages with hardcoded paths to other interpreters
1.203 nia 2730: 21.6.6. Packages installing Perl modules
1.254 wiz 2731: 21.6.7. Packages installing pkg-config files
2732: 21.6.8. Packages installing info files
2733: 21.6.9. Packages installing man pages
2734: 21.6.10. Packages installing X11 fonts
2735: 21.6.11. Packages installing SGML or XML data
2736: 21.6.12. Packages installing extensions to the MIME database
2737: 21.6.13. Packages using intltool
2738: 21.6.14. Packages installing startup scripts
2739: 21.6.15. Packages installing TeX modules
2740: 21.6.16. Packages supporting running binaries in emulation
2741: 21.6.17. Packages installing hicolor icons
2742: 21.6.18. Packages installing desktop files
1.154 rillig 2743: 21.7. Marking packages as having problems
1.184 rillig 2744: 22. GNOME packaging and porting
2745: 22.1. Meta packages
2746: 22.2. Packaging a GNOME application
2747: 22.3. Updating GNOME to a newer version
2748: 22.4. Patching guidelines
1.154 rillig 2749: 23. Submitting and Committing
2750: 23.1. Submitting binary packages
2751: 23.2. Submitting source packages (for non-NetBSD-developers)
2752: 23.3. General notes when adding, updating, or removing packages
2753: 23.4. Commit Messages
2754: 23.5. Committing: Adding a package to CVS
2755: 23.6. Updating a package to a newer version
2756: 23.7. Renaming a package in pkgsrc
2757: 23.8. Moving a package in pkgsrc
1.263 ! wiz 2758: 24. pkgsrc Policies
! 2759: 24.1. Packages for which updating is restricted
! 2760: 24.1.1. Limited Updates - ABI
! 2761: 24.1.2. Limited Updates - Bootstrap
! 2762: 25. Frequently Asked Questions
1.154 rillig 2763:
2764: Chapter 11. Getting help
2765:
2766: To get help when developing pkgsrc, the definitive source is this document, the
2767: pkgsrc guide. If you don't find anything here, there are alternatives:
2768:
2769: * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
2770: Run bmake help topic=? to get help for any topic, such as a variable name
2771: like BUILD_DEFS, a make target like do-build, a missing C or C++ function
2772: like strcasecmp or any other topic.
2773:
1.207 leot 2774: The available help topics are listed in Appendix E, Help topics.
1.154 rillig 2775:
1.163 rillig 2776: * To see the value of a single variable, run bmake show-var VARNAME=X.
2777:
2778: * To see the values of the most common variables, run bmake show-all. These
2779: variables are grouped by topic. To see the variables for a single topic,
2780: run bmake show-all-topic, for example bmake show-all-fetch.
2781:
1.154 rillig 2782: * The tech-pkg mailing list, to which you can subscribe and then ask your
2783: questions.
2784:
2785: * The #pkgsrc IRC channel, which is accessible via a web browser or by using
2786: a specialized chat program such as XChat. Pick any user name and join the
2787: channel #pkgsrc.
1.1 dsieger 2788:
1.184 rillig 2789: Chapter 12. Package components - files, directories and contents
1.1 dsieger 2790:
2791: Table of Contents
2792:
1.184 rillig 2793: 12.1. Makefile
2794: 12.2. distinfo
2795: 12.3. patches/*
2796: 12.3.1. Structure of a single patch file
2797: 12.3.2. Creating patch files
2798: 12.3.3. Sources where the patch files come from
2799: 12.3.4. Patching guidelines
2800: 12.3.5. Feedback to the author
2801: 12.4. Other mandatory files
2802: 12.5. Optional files
2803: 12.5.1. Files affecting the binary package
2804: 12.5.2. Files affecting the build process
2805: 12.5.3. Files affecting nothing at all
2806: 12.6. work*
2807: 12.7. files/*
1.1 dsieger 2808:
1.184 rillig 2809: Whenever you're preparing a package, there are a number of files involved which
2810: are described in the following sections.
1.1 dsieger 2811:
1.184 rillig 2812: 12.1. Makefile
1.1 dsieger 2813:
1.184 rillig 2814: Building, installation and creation of a binary package are all controlled by
2815: the package's Makefile. The Makefile describes various things about a package,
2816: for example from where to get it, how to configure, build, and install it.
1.1 dsieger 2817:
1.184 rillig 2818: A package Makefile contains several sections that describe the package.
1.1 dsieger 2819:
1.184 rillig 2820: In the first section there are the following variables, which should appear
2821: exactly in the order given here. The order and grouping of the variables is
2822: mostly historical and has no further meaning.
1.1 dsieger 2823:
1.184 rillig 2824: * DISTNAME is the basename of the distribution file to be downloaded from the
2825: package's website.
1.1 dsieger 2826:
1.184 rillig 2827: * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
2828: it if DISTNAME (which is the default) is not a good name for the package in
2829: pkgsrc or DISTNAME is not provided (no distribution file is required).
2830: Usually it is the pkgsrc directory name together with the version number.
2831: It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
2832: is, it starts with a letter or digit, and contains only letters, digits,
1.204 nia 2833: dashes, underscores, dots and plus signs. New packages should have entirely
2834: lower-case names, with the exception of some that must follow pre-existing
2835: conventions (e.g. R packages begin with R-). You can use the :tl variable
2836: modifier to lower-case the package name.
1.26 spz 2837:
1.184 rillig 2838: * CATEGORIES is a list of categories which the package fits in. You can
2839: choose any of the top-level directories of pkgsrc for it.
1.1 dsieger 2840:
1.184 rillig 2841: Currently the following values are available for CATEGORIES. If more than
2842: one is used, they need to be separated by spaces:
1.1 dsieger 2843:
1.184 rillig 2844: archivers cross geography meta-pkgs security
2845: audio databases graphics misc shells
2846: benchmarks devel ham multimedia sysutils
2847: biology editors inputmethod net textproc
2848: cad emulators lang news time
2849: chat finance mail parallel wm
2850: comms fonts math pkgtools www
2851: converters games mbone print x11
1.1 dsieger 2852:
1.184 rillig 2853: * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
2854: are discussed in detail in Section 13.5, "The fetch phase".
1.1 dsieger 2855:
1.184 rillig 2856: The second section contains information about separately downloaded patches, if
2857: any.
1.1 dsieger 2858:
1.184 rillig 2859: * PATCHFILES: Name(s) of additional files that contain distribution patches.
2860: There is no default. pkgsrc will look for them at PATCH_SITES. They will
2861: automatically be uncompressed before patching if the names end with .gz or
2862: .Z.
1.1 dsieger 2863:
1.184 rillig 2864: * PATCH_SITES: Primary location(s) for distribution patch files (see
2865: PATCHFILES above) if not found locally.
1.1 dsieger 2866:
1.184 rillig 2867: * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
2868: count to help find the correct files to patch. It defaults to -p0.
1.1 dsieger 2869:
1.184 rillig 2870: The third section contains the following variables.
1.1 dsieger 2871:
1.253 gutterid 2872: * MAINTAINER is the email address of the person who is currently responsible
2873: for this package. In theory, the maintainer will be aware of upstream
2874: release, keep it updated, and generally resolve problems. Others
2875: contemplating significant changes should ask the maintainer for advice or
2876: review of a proposed change. This is not necessary for micro updates, bug
2877: fixes, pkgsrc-wide changes affecting many packages, and other things
2878: expected to be uncontroversial. It goes with this "should ask" that the
2879: maintainer should respond to inquiries reasonably promptly (most of the
2880: time), and either approve changes or provide reasons why not. Typically,
2881: when packaging a new program, set MAINTAINER to yourself. If you don't
2882: intend to maintain the package (especially if you feel you have no special
2883: insight), set it to <pkgsrc-users@NetBSD.org>. This special value is a code
2884: point indicating that there is no maintainer, but the variable is
2885: mandatory, absent OWNER.
2886:
2887: * OWNER can be used instead of MAINTAINER in relatively rare circumstances
2888: when the package is such that modifying it is riskier than normal. This is
2889: a stronger form of being the maintainer, with an expectation that others
2890: will ask for almost all changes, except revbumps and accommodating
2891: structural changes. Someone who becomes OWNER has a strong obligation to
2892: keep the package very well maintained, to answer queries promptly and to be
2893: a steward of the package on behalf of users. In this case, MAINTAINER
2894: should be omitted.
2895:
2896: Because of the friction that OWNER adds, PMC may downgrade it to MAINTAINER
2897: at any time.
1.1 dsieger 2898:
1.184 rillig 2899: * HOMEPAGE is a URL where users can find more information about the package.
1.1 dsieger 2900:
1.184 rillig 2901: * COMMENT is a one-line description of the package (should not include the
2902: package name).
1.1 dsieger 2903:
1.184 rillig 2904: * LICENSE indicates the license(s) applicable for the package. See
2905: Section 21.1.3, "Handling licenses" for further details.
1.1 dsieger 2906:
1.184 rillig 2907: Other variables that affect the build:
1.1 dsieger 2908:
1.184 rillig 2909: * WRKSRC: The directory where the interesting distribution files of the
2910: package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
2911: most packages.
1.1 dsieger 2912:
1.184 rillig 2913: If a package doesn't create a subdirectory for itself (most GNU software
2914: does, for instance), but extracts itself in the current directory, you
2915: should set WRKSRC=${WRKDIR}.
1.1 dsieger 2916:
1.184 rillig 2917: If a package doesn't create a subdirectory with the name of DISTNAME but
2918: some different name, set WRKSRC to point to the proper name in ${WRKDIR},
2919: for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
2920: other examples.
1.17 imil 2921:
1.184 rillig 2922: The name of the working directory created by pkgsrc is taken from the
2923: WRKDIR_BASENAME variable. By default, its value is work. If you want to use
2924: the same pkgsrc tree for building different kinds of binary packages, you
2925: can change the variable according to your needs. Two other variables handle
2926: common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
2927: defined in mk.conf, the first component of the host's name is attached to
2928: the directory name. If OBJMACHINE is defined, the platform name is
2929: attached, which might look like work.i386 or work.sparc.
1.17 imil 2930:
1.184 rillig 2931: Please pay attention to the following gotchas:
1.17 imil 2932:
1.184 rillig 2933: * Add MANCOMPRESSED if man pages are installed in compressed form by the
2934: package. For packages using BSD-style makefiles which honor MANZ, there is
2935: MANCOMPRESSED_IF_MANZ.
1.17 imil 2936:
1.184 rillig 2937: * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
1.103 wiz 2938:
1.254 wiz 2939: * If the package installs any info files, see Section 21.6.8, "Packages
1.184 rillig 2940: installing info files".
1.103 wiz 2941:
1.184 rillig 2942: 12.2. distinfo
1.17 imil 2943:
1.184 rillig 2944: The distinfo file contains the message digest, or checksum, of each distfile
2945: needed for the package. This ensures that the distfiles retrieved from the
2946: Internet have not been corrupted during transfer or altered by a malign force
2947: to introduce a security hole. To provide maximum security, all distfiles are
1.243 gutterid 2948: protected using two different message digest algorithms (BLAKE2s and SHA512),
2949: as well as the file size.
1.17 imil 2950:
1.184 rillig 2951: The distinfo file also contains the checksums for all the patches found in the
2952: patches directory (see Section 12.3, "patches/*"). These checksums ensure that
2953: patches are only applied intentionally and that they don't accidentally change,
2954: e.g. when merging different changes together. They also make sure that new
2955: patches are actually added to CVS and old ones are removed. Too see whether the
2956: patches and the distinfo file match, run pkglint after changing the patches.
1.17 imil 2957:
1.184 rillig 2958: To regenerate the distinfo file, use the make distinfo command.
1.17 imil 2959:
1.184 rillig 2960: Some packages have different sets of distfiles depending on the platform, for
2961: example lang/openjdk8. These are kept in the same distinfo file and care should
2962: be taken when upgrading such a package to ensure distfile information is not
2963: lost.
1.17 imil 2964:
1.184 rillig 2965: 12.3. patches/*
1.63 wiz 2966:
1.184 rillig 2967: Some packages don't work out-of-the box on the various platforms that are
2968: supported by pkgsrc. These packages need to be patched to make them work. The
2969: patch files can be found in the patches/ directory.
1.17 imil 2970:
1.184 rillig 2971: In the patch phase, these patches are applied to the files in WRKSRC directory
2972: after extracting them, in alphabetic order.
1.160 brook 2973:
1.184 rillig 2974: 12.3.1. Structure of a single patch file
1.160 brook 2975:
1.184 rillig 2976: The patch-* files should be in diff -bu format, and apply without a fuzz to
2977: avoid problems. (To force patches to apply with fuzz you can set
2978: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
2979: a single file, and no file should be patched by more than one patch file. This
2980: helps to keep future modifications simple.
1.160 brook 2981:
1.184 rillig 2982: Each patch file is structured as follows: In the first line, there is the RCS
2983: Id of the patch itself. The second line should be empty for aesthetic reasons.
2984: After that, there should be a comment for each change that the patch does.
2985: There are a number of standard cases:
1.160 brook 2986:
1.184 rillig 2987: * Patches for commonly known vulnerabilities should mention the vulnerability
2988: ID (CAN, CVE).
1.160 brook 2989:
1.184 rillig 2990: * Patches that change source code should mention the platform and other
2991: environment (for example, the compiler) that the patch is needed for.
1.160 brook 2992:
1.184 rillig 2993: The patch should be commented so that any developer who knows the code of the
2994: application can make some use of the patch. Special care should be taken for
2995: the upstream developers, since we generally want that they accept our patches,
2996: so we have less work in the future.
1.160 brook 2997:
1.184 rillig 2998: 12.3.2. Creating patch files
1.160 brook 2999:
1.184 rillig 3000: One important thing to mention is to pay attention that no RCS IDs get stored
3001: in the patch files, as these will cause problems when later checked into the
3002: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
3003: avoid these problems.
1.160 brook 3004:
1.184 rillig 3005: For even more automation, we recommend using mkpatches from the same package to
1.222 gutterid 3006: make a whole set of patches. You just have to back up files before you edit
3007: them to filename.orig, e.g., with cp -p filename filename.orig or, easier, by
3008: using pkgvi again from the same package. If you upgrade a package this way, you
3009: can easily compare the new set of patches with the previously existing one with
1.184 rillig 3010: patchdiff. The files in patches are replaced by new files, so carefully check
3011: if you want to take all the changes.
1.160 brook 3012:
1.184 rillig 3013: When you have finished a package, remember to generate the checksums for the
3014: patch files by using the make makepatchsum command, see Section 12.2,
3015: "distinfo".
1.1 dsieger 3016:
1.184 rillig 3017: When adding a patch that corrects a problem in the distfile (rather than e.g.
3018: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
3019: report to the maintainer. This benefits non-pkgsrc users of the package, and
3020: usually makes it possible to remove the patch in future version.
1.1 dsieger 3021:
1.184 rillig 3022: The file names of the patch files are usually of the form patch-
3023: path_to_file__with__underscores.c. Many packages still use the previous
3024: convention patch-[a-z][a-z], but new patches should be of the form containing
3025: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
3026: automatically.
1.1 dsieger 3027:
1.222 gutterid 3028: When updating pre-existing patch files, if a file uses the old patch-[a-z][a-z]
3029: convention, it's best not to change it to the new form, as that will just cause
3030: churn that makes it harder to track changes to patching over time. Similarly,
3031: if a patch now applies at different line offsets, but still applies cleanly
3032: as-is, there's no need to update it, as that also unnecessarily complicates the
3033: patch history.
3034:
1.184 rillig 3035: 12.3.3. Sources where the patch files come from
1.1 dsieger 3036:
1.184 rillig 3037: If you want to share patches between multiple packages in pkgsrc, e.g. because
3038: they use the same distfiles, set PATCHDIR to the path where the patch files can
3039: be found, e.g.:
1.1 dsieger 3040:
1.184 rillig 3041: PATCHDIR= ../../editors/xemacs/patches
1.1 dsieger 3042:
1.184 rillig 3043: Patch files that are distributed by the author or other maintainers can be
3044: listed in PATCHFILES.
1.1 dsieger 3045:
1.184 rillig 3046: If it is desired to store any patches that should not be committed into pkgsrc,
3047: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
3048: directory tree there is expected to have the same "category/package" structure
3049: as pkgsrc, and patches are expected to be stored inside these dirs (also known
3050: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
3051: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
3052: files in the named directory are expected to be patch files, and they are
3053: applied after pkgsrc patches are applied.
1.1 dsieger 3054:
1.184 rillig 3055: 12.3.4. Patching guidelines
1.1 dsieger 3056:
1.184 rillig 3057: When fixing a portability issue in the code do not use preprocessor magic to
3058: check for the current operating system nor platform. Doing so hurts portability
3059: to other platforms because the OS-specific details are not abstracted
3060: appropriately.
1.1 dsieger 3061:
1.184 rillig 3062: The general rule to follow is: instead of checking for the operating system the
3063: application is being built on, check for the specific features you need. For
3064: example, instead of assuming that kqueue is available under NetBSD and using
3065: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
1.198 leot 3066: kqueue itself -- yes, this generally involves patching the configure script.
1.184 rillig 3067: There is absolutely nothing that prevents some OSes from adopting interfaces
3068: from other OSes (e.g. Linux implementing kqueue), something that the above
3069: checks cannot take into account.
1.1 dsieger 3070:
1.184 rillig 3071: Of course, checking for features generally involves more work on the
3072: developer's side, but the resulting changes are cleaner and there are chances
3073: they will work on many other platforms. Not to mention that there are higher
3074: chances of being later integrated into the mainstream sources. Remember: It
3075: doesn't work unless it is right!
1.1 dsieger 3076:
1.184 rillig 3077: Some typical examples:
1.121 sevan 3078:
1.184 rillig 3079: Table 12.1. Patching examples
1.1 dsieger 3080:
1.184 rillig 3081: +-------------------------------------------------------------------------------------------+
3082: | Where | Incorrect | Correct |
3083: |---------+--------------------------+------------------------------------------------------|
3084: | |case ${target_os} in | |
3085: |configure|netbsd*) have_kvm=yes ;; |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
3086: |script |*) have_kvm=no ;; | |
3087: | |esac | |
3088: |---------+--------------------------+------------------------------------------------------|
3089: |C source |#if defined(__NetBSD__) |#if defined(HAVE_SYS_EVENT_H) |
3090: |file |# include <sys/event.h> |# include <sys/event.h> |
3091: | |#endif |#endif |
3092: |---------+--------------------------+------------------------------------------------------|
3093: | |int |int |
3094: | |monitor_file(...) |monitor_file(...) |
3095: | |{ |{ |
3096: | |#if defined(__NetBSD__) |#if defined(HAVE_KQUEUE) |
3097: |C source | int fd = kqueue();| int fd = kqueue(); |
3098: |file | ... | ... |
3099: | |#else |#else |
3100: | | ... | ... |
3101: | |#endif |#endif |
3102: | |} |} |
3103: +-------------------------------------------------------------------------------------------+
1.1 dsieger 3104:
3105:
1.184 rillig 3106: 12.3.5. Feedback to the author
1.1 dsieger 3107:
1.184 rillig 3108: Always, always, always feed back any portability fixes or improvements you do
3109: to a package to the mainstream developers. This is the only way to get their
3110: attention on portability issues and to ensure that future versions can be built
3111: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
3112: get the fixes straight from the packaged code.
1.1 dsieger 3113:
1.184 rillig 3114: This generally involves cleaning up the patches (because sometimes the patches
3115: that are added to pkgsrc are quick hacks), filing bug reports in the
3116: appropriate trackers for the projects and working with the mainstream authors
3117: to accept your changes. It is extremely important that you do it so that the
3118: packages in pkgsrc are kept simple and thus further changes can be done without
3119: much hassle.
1.1 dsieger 3120:
1.184 rillig 3121: When you have done this, please add a URL to the upstream bug report to the
3122: patch comment.
1.1 dsieger 3123:
1.184 rillig 3124: Support the idea of free software!
1.1 dsieger 3125:
1.184 rillig 3126: 12.4. Other mandatory files
1.1 dsieger 3127:
1.184 rillig 3128: DESCR
1.1 dsieger 3129:
1.184 rillig 3130: A multi-line description of the piece of software. This should include any
3131: credits where they are due. Please bear in mind that others do not share
3132: your sense of humour (or spelling idiosyncrasies), and that others will
3133: read everything that you write here.
1.1 dsieger 3134:
1.184 rillig 3135: PLIST
1.1 dsieger 3136:
1.184 rillig 3137: This file governs the files that are installed on your system: all the
3138: binaries, manual pages, etc. There are other directives which may be
3139: entered in this file, to control the creation and deletion of directories,
3140: and the location of inserted files. See Chapter 19, PLIST issues for more
3141: information.
1.1 dsieger 3142:
1.184 rillig 3143: 12.5. Optional files
1.1 dsieger 3144:
1.184 rillig 3145: 12.5.1. Files affecting the binary package
1.1 dsieger 3146:
1.184 rillig 3147: INSTALL
1.1 dsieger 3148:
1.184 rillig 3149: This shell script is invoked twice by pkg_add(1). First time after package
3150: extraction and before files are moved in place, the second time after the
3151: files to install are moved in place. This can be used to do any custom
3152: procedures not possible with @exec commands in PLIST. See pkg_add(1) and
3153: pkg_create(1) for more information. See also Section 20.1, "Files and
3154: directories outside the installation prefix". Please note that you can
3155: modify variables in it easily by using FILES_SUBST in the package's
3156: Makefile:
1.1 dsieger 3157:
1.184 rillig 3158: FILES_SUBST+= SOMEVAR="somevalue"
1.1 dsieger 3159:
1.184 rillig 3160: replaces "@SOMEVAR@" with "somevalue" in the INSTALL. By default,
3161: substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
3162: few others, type make help topic=FILES_SUBST for a complete list.
1.1 dsieger 3163:
1.184 rillig 3164: DEINSTALL
1.1 dsieger 3165:
1.184 rillig 3166: This script is executed before and after any files are removed. It is this
3167: script's responsibility to clean up any additional messy details around the
3168: package's installation, since all pkg_delete knows is how to delete the
3169: files created in the original distribution. See pkg_delete(1) and
3170: pkg_create(1) for more information. The same methods to replace variables
3171: can be used as for the INSTALL file.
1.1 dsieger 3172:
1.184 rillig 3173: MESSAGE
1.1 dsieger 3174:
1.198 leot 3175: This file is displayed after installation of the package. While this was
3176: used often in the past, it has two problems: the display will be missed if
1.257 jkoshy 3177: many packages are installed at once, and the person installing the package
1.198 leot 3178: and the one using or configuring it may be different. It should therefore
3179: be used only in exceptional circumstances where lasting negative
3180: consequences would result from someone not reading it.
3181:
3182: MESSAGE should not be used for:
3183:
1.259 leot 3184: + exhortations to read the documentation
1.198 leot 3185:
1.259 leot 3186: + reminders to install rc.d files and set variables
1.198 leot 3187:
1.259 leot 3188: + anything that should be explained in the installation/configuration
1.198 leot 3189: documentation that should come with the package
3190:
3191: If the documentation provided by upstream needs enhancing, create e.g.
3192: files/README.pkgsrc and install it in the package's documentation
3193: directory.
3194:
3195: Note that MESSAGE is shown for all operating systems and all init systems.
3196: If a MESSAGE is necessary, it should be narrowed to only those operating
3197: systems and init systems to which it applies.
3198:
3199: Note that you can modify variables in it easily by using MESSAGE_SUBST in
3200: the package's Makefile:
1.1 dsieger 3201:
1.184 rillig 3202: MESSAGE_SUBST+= SOMEVAR="somevalue"
1.1 dsieger 3203:
1.184 rillig 3204: replaces "${SOMEVAR}" with "somevalue" in MESSAGE. By default, substitution
3205: is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
3206: PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1 dsieger 3207:
1.184 rillig 3208: You can display a different or additional files by setting the MESSAGE_SRC
3209: variable. Its default is MESSAGE, if the file exists.
1.1 dsieger 3210:
1.184 rillig 3211: ALTERNATIVES
1.1 dsieger 3212:
1.184 rillig 3213: This file is used by the alternatives framework. It creates, configures,
3214: and destroys generic wrappers used to run programs with similar interfaces.
3215: See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
3216: information.
1.1 dsieger 3217:
1.184 rillig 3218: Each line of the file contains two filenames, first the wrapper and then
3219: the alternative provided by the package. Both paths are relative to PREFIX.
1.1 dsieger 3220:
1.184 rillig 3221: 12.5.2. Files affecting the build process
1.1 dsieger 3222:
1.184 rillig 3223: Makefile.common
1.1 dsieger 3224:
1.184 rillig 3225: This file contains arbitrary things that could also go into a Makefile, but
3226: its purpose is to be used by more than one package. This file should only
3227: be used when the packages that will use the file are known in advance. For
3228: other purposes it is often better to write a *.mk file and give it a good
3229: name that describes what it does.
1.1 dsieger 3230:
1.184 rillig 3231: buildlink3.mk
1.1 dsieger 3232:
1.184 rillig 3233: This file contains the dependency information for the buildlink3 framework
3234: (see Chapter 18, Buildlink methodology).
1.1 dsieger 3235:
1.184 rillig 3236: hacks.mk
1.1 dsieger 3237:
1.184 rillig 3238: This file contains workarounds for compiler bugs and similar things. It is
3239: included automatically by the pkgsrc infrastructure, so you don't need an
3240: extra .include line for it.
1.1 dsieger 3241:
1.184 rillig 3242: options.mk
1.1 dsieger 3243:
1.184 rillig 3244: This file contains the code for the package-specific options (see
3245: Chapter 16, Options handling) that can be selected by the user. If a
3246: package has only one or two options, it is equally acceptable to put the
3247: code directly into the Makefile.
1.1 dsieger 3248:
1.184 rillig 3249: 12.5.3. Files affecting nothing at all
1.1 dsieger 3250:
1.184 rillig 3251: README*
1.1 dsieger 3252:
1.184 rillig 3253: These files do not take place in the creation of a package and thus are
3254: purely informative to the package developer.
1.1 dsieger 3255:
1.184 rillig 3256: TODO
1.1 dsieger 3257:
1.184 rillig 3258: This file contains things that need to be done to make the package even
3259: better.
1.1 dsieger 3260:
1.184 rillig 3261: 12.6. work*
1.1 dsieger 3262:
1.184 rillig 3263: When you type make, the distribution files are unpacked into the directory
3264: denoted by WRKDIR. It can be removed by running make clean. Besides the
3265: sources, this directory is also used to keep various timestamp files. The
3266: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
3267: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
1.1 dsieger 3268:
1.184 rillig 3269: 12.7. files/*
1.80 wiz 3270:
1.184 rillig 3271: If you have any files that you wish to be placed in the package prior to
3272: configuration or building, you can place these files here and use a ${CP}
3273: command in the "post-extract" target to achieve this.
1.1 dsieger 3274:
1.184 rillig 3275: If you want to share files in this way with other packages, set the FILESDIR
3276: variable to point to the other package's files directory, e.g.:
1.1 dsieger 3277:
1.184 rillig 3278: FILESDIR= ../../editors/xemacs/files
1.14 jmcneill 3279:
1.184 rillig 3280: Chapter 13. The build process
1.1 dsieger 3281:
1.184 rillig 3282: Table of Contents
1.1 dsieger 3283:
1.184 rillig 3284: 13.1. Introduction
3285: 13.2. Program location
3286: 13.3. Directories used during the build process
3287: 13.4. Running a phase
3288: 13.5. The fetch phase
3289: 13.5.1. What to fetch and where to get it from
3290: 13.5.2. How are the files fetched?
3291: 13.6. The checksum phase
3292: 13.7. The extract phase
3293: 13.8. The patch phase
3294: 13.9. The tools phase
3295: 13.10. The wrapper phase
3296: 13.11. The configure phase
3297: 13.12. The build phase
3298: 13.13. The test phase
3299: 13.14. The install phase
3300: 13.15. The package phase
3301: 13.16. Cleaning up
3302: 13.17. Other helpful targets
1.1 dsieger 3303:
1.184 rillig 3304: 13.1. Introduction
1.122 leot 3305:
1.184 rillig 3306: This chapter gives a detailed description on how a package is built. Building a
3307: package is separated into different phases (for example fetch, build, install),
3308: all of which are described in the following sections. Each phase is split into
3309: so-called stages, which take the name of the containing phase, prefixed by one
3310: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
3311: actual work is done in the do-* stages.
1.1 dsieger 3312:
1.184 rillig 3313: Never override the regular targets (like fetch), if you have to, override the
3314: do-* ones instead.
1.1 dsieger 3315:
1.184 rillig 3316: The basic steps for building a program are always the same. First the program's
3317: source (distfile) must be brought to the local system and then extracted. After
3318: any pkgsrc-specific patches to compile properly are applied, the software can
3319: be configured, then built (usually by compiling), and finally the generated
3320: binaries, etc. can be put into place on the system.
1.1 dsieger 3321:
1.184 rillig 3322: To get more details about what is happening at each step, you can set the
3323: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
3324: more details about the patch step.
1.1 dsieger 3325:
1.184 rillig 3326: 13.2. Program location
1.1 dsieger 3327:
1.184 rillig 3328: Before outlining the process performed by the NetBSD package system in the next
3329: section, here's a brief discussion on where programs are installed, and which
3330: variables influence this.
1.1 dsieger 3331:
1.184 rillig 3332: The automatic variable PREFIX indicates where all files of the final program
3333: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
3334: pkgs in the cross category. The value of PREFIX needs to be put into the
3335: various places in the program's source where paths to these files are encoded.
3336: See Section 12.3, "patches/*" and Section 21.3.1, "Shared libraries - libtool"
3337: for more details.
1.1 dsieger 3338:
1.184 rillig 3339: When choosing which of these variables to use, follow the following rules:
1.1 dsieger 3340:
1.184 rillig 3341: * PREFIX always points to the location where the current pkg will be
3342: installed. When referring to a pkg's own installation path, use "${PREFIX}"
3343: .
1.1 dsieger 3344:
1.223 nia 3345: * LOCALBASE is where all pkgs are installed. If you need to construct a -I or
3346: -L argument to the compiler to find includes and libraries installed by
3347: another pkg, use "${LOCALBASE}". The name LOCALBASE stems from FreeBSD,
3348: which installed all packages in /usr/local. As pkgsrc leaves /usr/local for
3349: the system administrator, this variable is a misnomer.
1.1 dsieger 3350:
1.184 rillig 3351: * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
3352: installed. When looking for standard X11 includes (not those installed by a
3353: package), use "${X11BASE}".
1.1 dsieger 3354:
1.184 rillig 3355: * X11-based packages using imake must set USE_IMAKE to be installed correctly
3356: under LOCALBASE.
1.1 dsieger 3357:
1.184 rillig 3358: * Within ${PREFIX}, packages should install files according to hier(7), with
3359: the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
3360: man.
1.1 dsieger 3361:
1.184 rillig 3362: 13.3. Directories used during the build process
1.2 rillig 3363:
1.184 rillig 3364: When building a package, various directories are used to store source files,
3365: temporary files, pkgsrc-internal files, and so on. These directories are
3366: explained here.
1.1 dsieger 3367:
1.184 rillig 3368: Some of the directory variables contain relative pathnames. There are two
3369: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
3370: used for directories that are pkgsrc-specific. WRKSRC is used for directories
3371: inside the package itself.
1.1 dsieger 3372:
1.184 rillig 3373: PKGSRCDIR
1.1 dsieger 3374:
1.184 rillig 3375: This is an absolute pathname that points to the pkgsrc root directory.
3376: Generally, you don't need it.
1.1 dsieger 3377:
1.184 rillig 3378: PKGDIR
1.1 dsieger 3379:
1.184 rillig 3380: This is an absolute pathname that points to the current package.
1.1 dsieger 3381:
1.184 rillig 3382: PKGPATH
1.1 dsieger 3383:
1.184 rillig 3384: This is a pathname relative to PKGSRCDIR that points to the current
1.228 gutterid 3385: package. It is defined after including bsd.prefs.mk and can be used in
3386: makefile fragments that are used by several packages to distinguish between
3387: these packages. Other variables that would serve the same purpose are
3388: PKGBASE and PKGNAME, but these are only defined after including bsd.pkg.mk,
3389: which is too late.
3390:
3391: In mk.conf, the pkgsrc user can use PKGPATH to tweak variables like
3392: MAKE_JOBS and CFLAGS.
1.1 dsieger 3393:
1.184 rillig 3394: WRKDIR
1.1 dsieger 3395:
1.184 rillig 3396: This is an absolute pathname pointing to the directory where all work takes
3397: place. The distfiles are extracted to this directory. It also contains
3398: temporary directories and log files used by the various pkgsrc frameworks,
3399: like buildlink or the wrappers.
1.1 dsieger 3400:
1.184 rillig 3401: WRKSRC
1.1 dsieger 3402:
1.184 rillig 3403: This is an absolute pathname pointing to the directory where the distfiles
3404: are extracted. It is usually a direct subdirectory of WRKDIR, and often
3405: it's the only directory entry that isn't hidden. This variable may be
3406: changed by a package Makefile.
1.1 dsieger 3407:
1.184 rillig 3408: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
3409: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
3410: created in the pkgsrc entry's directory. If users would like to have their
3411: pkgsrc trees behave in a read-only manner, then the value of
3412: CREATE_WRKDIR_SYMLINK should be set to no.
1.1 dsieger 3413:
1.184 rillig 3414: 13.4. Running a phase
1.1 dsieger 3415:
1.184 rillig 3416: You can run a particular phase by typing make phase, where phase is the name of
3417: the phase. This will automatically run all phases that are required for this
3418: phase. The default phase is build, that is, when you run make without
3419: parameters in a package directory, the package will be built, but not
3420: installed.
1.1 dsieger 3421:
1.184 rillig 3422: 13.5. The fetch phase
1.1 dsieger 3423:
1.184 rillig 3424: The first step in building a package is to fetch the distribution files
3425: (distfiles) from the sites that are providing them. This is the task of the
3426: fetch phase.
1.25 wiz 3427:
1.184 rillig 3428: 13.5.1. What to fetch and where to get it from
1.1 dsieger 3429:
1.184 rillig 3430: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
3431: name is derived from the DISTNAME variable, is fetched. The more complicated
3432: cases are described below.
1.1 dsieger 3433:
1.184 rillig 3434: The variable DISTFILES specifies the list of distfiles that have to be fetched.
3435: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
3436: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
3437: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
3438: your package requires additional distfiles to the default one, you cannot just
3439: append the additional filenames using the += operator, but you have write for
3440: example:
1.1 dsieger 3441:
1.184 rillig 3442: DISTFILES= ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1 dsieger 3443:
1.184 rillig 3444: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
3445: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
3446: can set SITES.distfile to the list of URLs where the file distfile (including
3447: the suffix) can be found.
1.1 dsieger 3448:
1.184 rillig 3449: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
3450: DISTFILES+= foo-file.tar.gz
3451: SITES.foo-file.tar.gz= \
3452: https://www.somewhere.com/somehow/ \
3453: https://www.somewhereelse.com/mirror/somehow/
1.1 dsieger 3454:
1.184 rillig 3455: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
3456: gets the name of each distfile appended to it, without an intermediate slash.
3457: Therefore, all site values have to end with a slash or other separator
3458: character. This allows for example to set MASTER_SITES to a URL of a CGI script
3459: that gets the name of the distfile as a parameter. In this case, the definition
3460: would look like:
1.1 dsieger 3461:
1.184 rillig 3462: MASTER_SITES= https://www.example.com/download.cgi?file=
1.1 dsieger 3463:
1.184 rillig 3464: The exception to this rule are URLs starting with a dash. In that case the URL
3465: is taken as is, fetched and the result stored under the name of the distfile.
3466: You can use this style for the case when the download URL style does not match
3467: the above common case. For example, if permanent download URL is a redirector
3468: to the real download URL, or the download file name is offered by an HTTP
3469: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
3470: created instead of the default v1.0.0.tar.gz.
1.1 dsieger 3471:
1.184 rillig 3472: DISTNAME= foo-1.0.0
3473: MASTER_SITES= -https://www.example.com/archive/v1.0.0.tar.gz
1.29 wiz 3474:
1.184 rillig 3475: There are some predefined values for MASTER_SITES, which can be used in
3476: packages. The names of the variables should speak for themselves.
1.29 wiz 3477:
1.260 wiz 3478: MASTER_SITE_APACHE MASTER_SITE_BACKUP
3479: MASTER_SITE_CRATESIO MASTER_SITE_CYGWIN
3480: MASTER_SITE_DEBIAN MASTER_SITE_FREEBSD
3481: MASTER_SITE_FREEBSD_LOCAL MASTER_SITE_GENTOO
3482: MASTER_SITE_GITHUB MASTER_SITE_GITLAB
3483: MASTER_SITE_GNOME MASTER_SITE_GNU
3484: MASTER_SITE_GNUPG MASTER_SITE_GNUSTEP
3485: MASTER_SITE_HASKELL_HACKAGE MASTER_SITE_IFARCHIVE
3486: MASTER_SITE_KDE MASTER_SITE_MOZILLA
3487: MASTER_SITE_MOZILLA_ALL MASTER_SITE_MYSQL
3488: MASTER_SITE_NETLIB MASTER_SITE_OPENBSD
3489: MASTER_SITE_OPENOFFICE MASTER_SITE_OSDN
3490: MASTER_SITE_PERL_CPAN MASTER_SITE_PGSQL
3491: MASTER_SITE_PYPI MASTER_SITE_RUBYGEMS
3492: MASTER_SITE_R_CRAN MASTER_SITE_SOURCEFORGE
3493: MASTER_SITE_SUNSITE MASTER_SITE_SUSE
3494: MASTER_SITE_TEX_CTAN MASTER_SITE_XCONTRIB
3495: MASTER_SITE_XEMACS MASTER_SITE_XORG
1.1 dsieger 3496:
1.184 rillig 3497: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
3498: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
3499: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
3500: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
3501: distfiles/LOCAL_PORTS/.
1.1 dsieger 3502:
1.184 rillig 3503: If you choose one of these predefined sites, you may want to specify a
3504: subdirectory of that site. Since these macros may expand to more than one
3505: actual site, you must use the following construct to specify a subdirectory:
1.1 dsieger 3506:
1.184 rillig 3507: MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/}
3508: MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1 dsieger 3509:
1.184 rillig 3510: Note the trailing slash after the subdirectory name.
1.1 dsieger 3511:
1.184 rillig 3512: 13.5.2. How are the files fetched?
1.1 dsieger 3513:
1.184 rillig 3514: The fetch phase makes sure that all the distfiles exist in a local directory
3515: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
3516: are fetched using commands of the form
1.1 dsieger 3517:
1.184 rillig 3518: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
1.1 dsieger 3519:
1.184 rillig 3520: where ${site} varies through several possibilities in turn: first,
3521: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
3522: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
3523: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
3524: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
3525: MASTER_SORT_AWK or MASTER_SORT_REGEX.
1.1 dsieger 3526:
1.184 rillig 3527: The specific command and arguments used depend on the FETCH_USING parameter.
3528: The example above is for FETCH_USING=custom.
1.66 asau 3529:
1.184 rillig 3530: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
3531: target to mirror the distfiles, if they are freely distributable. Packages
3532: setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
3533: distfiles mirrored.
1.1 dsieger 3534:
1.184 rillig 3535: 13.6. The checksum phase
1.1 dsieger 3536:
1.184 rillig 3537: After the distfile(s) are fetched, their checksum is generated and compared
3538: with the checksums stored in the distinfo file. If the checksums don't match,
3539: the build is aborted. This is to ensure the same distfile is used for building,
3540: and that the distfile wasn't changed, e.g. by some malign force, deliberately
3541: changed distfiles on the master distribution site or network lossage.
1.1 dsieger 3542:
1.184 rillig 3543: 13.7. The extract phase
1.1 dsieger 3544:
1.184 rillig 3545: When the distfiles are present on the local system, they need to be extracted,
3546: as they usually come in the form of some compressed archive format.
1.1 dsieger 3547:
1.184 rillig 3548: By default, all DISTFILES are extracted. If you only need some of them, you can
3549: set the EXTRACT_ONLY variable to the list of those files.
1.1 dsieger 3550:
1.184 rillig 3551: Extracting the files is usually done by a little program, mk/extract/extract,
3552: which already knows how to extract various archive formats, so most likely you
3553: will not need to change anything here. But if you need, the following variables
3554: may help you:
1.1 dsieger 3555:
1.184 rillig 3556: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
1.1 dsieger 3557:
1.184 rillig 3558: Use these variables to override the default options for an extract command,
3559: which are defined in mk/extract/extract.
1.1 dsieger 3560:
1.184 rillig 3561: EXTRACT_USING
1.1 dsieger 3562:
1.184 rillig 3563: This variable can be set to bsdtar, gtar, nbtar (which is the default
3564: value), pax, or an absolute pathname pointing to the command with which tar
3565: archives should be extracted. It is preferred to choose bsdtar over gtar if
3566: NetBSD's pax-as-tar is not good enough.
1.1 dsieger 3567:
1.184 rillig 3568: If the extract program doesn't serve your needs, you can also override the
3569: EXTRACT_CMD variable, which holds the command used for extracting the files.
3570: This command is executed in the ${WRKSRC} directory. During execution of this
3571: command, the shell variable extract_file holds the absolute pathname of the
3572: file that is going to be extracted.
1.1 dsieger 3573:
1.184 rillig 3574: And if that still does not suffice, you can override the do-extract target in
3575: the package Makefile.
1.1 dsieger 3576:
1.184 rillig 3577: 13.8. The patch phase
1.1 dsieger 3578:
1.184 rillig 3579: After extraction, all the patches named by the PATCHFILES, those present in the
3580: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
3581: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
3582: are uncompressed before they are applied, files ending in .orig or .rej are
3583: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
3584: Section 12.3, "patches/*" for more details.
1.1 dsieger 3585:
1.184 rillig 3586: By default patch(1) is given special arguments to make it fail if the expected
3587: text from the patch context is not found in the patched file. If that happens,
3588: fix the patch file by comparing it with the actual text in the file to be
3589: patched.
1.1 dsieger 3590:
1.184 rillig 3591: 13.9. The tools phase
1.1 dsieger 3592:
1.184 rillig 3593: This is covered in Chapter 17, Tools needed for building or running.
1.1 dsieger 3594:
1.184 rillig 3595: 13.10. The wrapper phase
1.1 dsieger 3596:
1.184 rillig 3597: This phase creates wrapper programs for the compilers and linkers. The
3598: following variables can be used to tweak the wrappers.
1.1 dsieger 3599:
1.184 rillig 3600: ECHO_WRAPPER_MSG
1.1 dsieger 3601:
1.184 rillig 3602: The command used to print progress messages. Does nothing by default. Set
3603: to ${ECHO} to see the progress messages.
1.1 dsieger 3604:
1.184 rillig 3605: WRAPPER_DEBUG
1.1 dsieger 3606:
1.184 rillig 3607: This variable can be set to yes (default) or no, depending on whether you
3608: want additional information in the wrapper log file.
1.1 dsieger 3609:
1.184 rillig 3610: WRAPPER_UPDATE_CACHE
1.1 dsieger 3611:
1.184 rillig 3612: This variable can be set to yes or no, depending on whether the wrapper
3613: should use its cache, which will improve the speed. The default value is
3614: yes, but is forced to no if the platform does not support it.
1.1 dsieger 3615:
1.184 rillig 3616: WRAPPER_REORDER_CMDS
1.1 dsieger 3617:
1.184 rillig 3618: A list of reordering commands. A reordering command has the form reorder:l:
3619: lib1:lib2. It ensures that that -llib1 occurs before -llib2.
1.1 dsieger 3620:
1.184 rillig 3621: 13.11. The configure phase
1.1 dsieger 3622:
1.184 rillig 3623: Most pieces of software need information on the header files, system calls, and
3624: library routines which are available on the platform they run on. The process
3625: of determining this information is known as configuration, and is usually
3626: automated. In most cases, a script is supplied with the distfiles, and its
3627: invocation results in generation of header files, Makefiles, etc.
1.1 dsieger 3628:
1.184 rillig 3629: If the package contains a configure script, this can be invoked by setting
3630: HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
1.187 rillig 3631: should set GNU_CONFIGURE to "yes" instead.
1.1 dsieger 3632:
1.187 rillig 3633: In the do-configure stage, a rough equivalent of the following command is run.
3634: See mk/configure/configure.mk, target do-configure-script for the exact
3635: definition.
3636:
3637: .for dir in ${CONFIGURE_DIRS}
3638: cd ${WRKSRC} && cd ${dir} \
3639: && env ${CONFIGURE_ENV} \
3640: ${CONFIG_SHELL} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
1.184 rillig 3641: .endfor
1.1 dsieger 3642:
1.184 rillig 3643: CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
3644: each of these directories, the configure script is run with the environment
3645: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
3646: CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
3647: by the package.
1.1 dsieger 3648:
1.184 rillig 3649: If the program uses the Perl way of configuration (mainly Perl modules, but not
3650: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
3651: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
3652: (e.g., MAKE_PARAMS+=foo=bar
1.1 dsieger 3653:
1.184 rillig 3654: If the program uses an Imakefile for configuration, the appropriate steps can
3655: be invoked by setting USE_IMAKE to "yes". If you only need xmkmf, add it to
3656: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
3657: SCRIPTS_ENV variable.
1.1 dsieger 3658:
1.184 rillig 3659: If the program uses cmake for configuration, the appropriate steps can be
1.233 wiz 3660: invoked by including ../../devel/cmake/build.mk. You can add variables to
3661: cmake's environment by adding them to the CONFIGURE_ENV variable and arguments
1.256 wiz 3662: to cmake by adding them to the CMAKE_CONFIGURE_ARGS variable. If you want to
3663: add arguments only for particular stages, you can use the CMAKE_CONFIGURE_ARGS,
1.233 wiz 3664: CMAKE_BUILD_ARGS, and CMAKE_INSTALL_ARGS variables. You can set the
3665: CONFIGURE_DIRS variable to the directories in which CMake should be run,
3666: relative to WRKSRC. This defaults to to ".".
1.1 dsieger 3667:
1.256 wiz 3668: Any package using the now-deprecated USE_CMAKE=yes should be converted.
3669: Essentially, replace with an include of ../../devel/cmake/build.mk, prune
3670: creation of a build directory and settings to use it, and check/fix settings
3671: that intend to perform the build in a subdirectory.
3672:
1.184 rillig 3673: If there is no configure step at all, set NO_CONFIGURE to "yes".
1.1 dsieger 3674:
1.184 rillig 3675: 13.12. The build phase
1.1 dsieger 3676:
1.187 rillig 3677: For building a package, a rough equivalent of the following code is executed;
3678: see mk/build/build.mk, target do-build for the exact definition.
1.154 rillig 3679:
1.187 rillig 3680: .for dir in ${BUILD_DIRS}
3681: cd ${WRKSRC} && cd ${dir} \
1.184 rillig 3682: && env ${MAKE_ENV} \
1.187 rillig 3683: ${MAKE_PROGRAM} ${MAKE_FLAGS} ${BUILD_MAKE_FLAGS} \
1.184 rillig 3684: -f ${MAKE_FILE} \
3685: ${BUILD_TARGET}
3686: .endfor
1.1 dsieger 3687:
1.184 rillig 3688: BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
3689: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
3690: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
3691: and BUILD_TARGET may all be changed by the package.
1.1 dsieger 3692:
1.184 rillig 3693: The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
3694: make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
3695: defaults to "all".
1.1 dsieger 3696:
1.184 rillig 3697: If there is no build step at all, set NO_BUILD to "yes".
1.1 dsieger 3698:
1.184 rillig 3699: 13.13. The test phase
1.1 dsieger 3700:
1.184 rillig 3701: [TODO]
1.1 dsieger 3702:
1.184 rillig 3703: 13.14. The install phase
1.1 dsieger 3704:
1.184 rillig 3705: Once the build stage has completed, the final step is to install the software
3706: in public directories, so users can access the programs and files.
1.1 dsieger 3707:
1.187 rillig 3708: In the install phase, a rough equivalent of the following code is executed; see
3709: mk/install/install.mk, target do-install for the exact definition.
3710: Additionally, before and after this code, several consistency checks are run
3711: against the files-to-be-installed, see mk/check/*.mk for details.
3712:
3713: .for dir in ${INSTALL_DIRS}
3714: cd ${WRKSRC} && cd ${dir} \
3715: && env ${INSTALL_ENV} ${MAKE_ENV} \
3716: ${MAKE_PROGRAM} ${MAKE_FLAGS} ${INSTALL_MAKE_FLAGS} \
3717: -f ${MAKE_FILE} ${INSTALL_TARGET}
1.184 rillig 3718: .endfor
1.1 dsieger 3719:
1.184 rillig 3720: The variable's meanings are analogous to the ones in the build phase.
3721: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
3722: plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
3723: defined.
1.1 dsieger 3724:
1.184 rillig 3725: In the install phase, the following variables are useful. They are all
3726: variations of the install(1) command that have the owner, group and permissions
3727: preset. INSTALL is the plain install command. The specialized variants,
3728: together with their intended use, are:
1.1 dsieger 3729:
1.184 rillig 3730: INSTALL_PROGRAM_DIR
1.1 dsieger 3731:
1.184 rillig 3732: directories that contain binaries
1.1 dsieger 3733:
1.184 rillig 3734: INSTALL_SCRIPT_DIR
1.1 dsieger 3735:
1.184 rillig 3736: directories that contain scripts
1.1 dsieger 3737:
1.184 rillig 3738: INSTALL_LIB_DIR
1.1 dsieger 3739:
1.184 rillig 3740: directories that contain shared and static libraries
1.1 dsieger 3741:
1.184 rillig 3742: INSTALL_DATA_DIR
1.108 rillig 3743:
1.184 rillig 3744: directories that contain data files
1.108 rillig 3745:
1.184 rillig 3746: INSTALL_MAN_DIR
1.108 rillig 3747:
1.184 rillig 3748: directories that contain man pages
1.108 rillig 3749:
1.184 rillig 3750: INSTALL_GAME_DIR
1.108 rillig 3751:
1.184 rillig 3752: directories that contain data files for games
1.108 rillig 3753:
1.184 rillig 3754: INSTALL_PROGRAM
1.108 rillig 3755:
1.184 rillig 3756: binaries that can be stripped from debugging symbols
1.108 rillig 3757:
1.184 rillig 3758: INSTALL_SCRIPT
1.108 rillig 3759:
1.184 rillig 3760: binaries that cannot be stripped
1.108 rillig 3761:
1.184 rillig 3762: INSTALL_GAME
1.108 rillig 3763:
1.184 rillig 3764: game binaries
1.108 rillig 3765:
1.184 rillig 3766: INSTALL_LIB
1.108 rillig 3767:
1.184 rillig 3768: shared and static libraries
1.108 rillig 3769:
1.184 rillig 3770: INSTALL_DATA
1.108 rillig 3771:
1.184 rillig 3772: data files
1.1 dsieger 3773:
1.184 rillig 3774: INSTALL_GAME_DATA
1.1 dsieger 3775:
1.184 rillig 3776: data files for games
1.108 rillig 3777:
1.184 rillig 3778: INSTALL_MAN
1.108 rillig 3779:
1.184 rillig 3780: man pages
1.1 dsieger 3781:
1.184 rillig 3782: Some other variables are:
1.1 dsieger 3783:
1.184 rillig 3784: INSTALL_UNSTRIPPED
1.1 dsieger 3785:
1.184 rillig 3786: If set to yes, do not run strip(1) when installing binaries. Any debugging
3787: sections and symbols present in binaries will be preserved.
1.1 dsieger 3788:
1.184 rillig 3789: INSTALLATION_DIRS
1.1 dsieger 3790:
1.184 rillig 3791: A list of directories relative to PREFIX that are created by pkgsrc at the
3792: beginning of the install phase. The package is supposed to create all
3793: needed directories itself before installing files to it and list all other
3794: directories here.
1.1 dsieger 3795:
1.184 rillig 3796: In the rare cases that a package shouldn't install anything, set NO_INSTALL to
3797: "yes". This is mostly relevant for packages in the regress category.
1.1 dsieger 3798:
1.184 rillig 3799: 13.15. The package phase
1.121 sevan 3800:
1.184 rillig 3801: Once the install stage has completed, a binary package of the installed files
3802: can be built. These binary packages can be used for quick installation without
3803: previous compilation, e.g. by the make bin-install or by using pkg_add.
1.1 dsieger 3804:
1.184 rillig 3805: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
3806: created in ${PACKAGES}/category, one for each category in the CATEGORIES
3807: variable. PACKAGES defaults to pkgsrc/packages.
1.1 dsieger 3808:
1.184 rillig 3809: 13.16. Cleaning up
1.1 dsieger 3810:
1.184 rillig 3811: Once you're finished with a package, you can clean the work directory by
3812: running make clean. If you want to clean the work directories of all
3813: dependencies too, use make clean-depends.
1.1 dsieger 3814:
1.184 rillig 3815: 13.17. Other helpful targets
1.1 dsieger 3816:
1.184 rillig 3817: pre/post-*
1.1 dsieger 3818:
1.184 rillig 3819: For any of the main targets described in the previous section (configure,
3820: build, install, etc.), two auxiliary targets exist with "pre-" and "post-"
3821: used as a prefix for the main target's name. These targets are invoked
3822: before and after the main target is called, allowing extra configuration or
3823: installation steps be performed from a package's Makefile, for example,
3824: which a program's configure script or install target omitted.
3825:
3826: About 5% of the pkgsrc packages define their custom post-extract target,
3827: another 5% define pre-configure, and 10% define post-install. The other pre
3828: /post-* targets are defined even less often.
1.1 dsieger 3829:
1.184 rillig 3830: do-*
1.182 leot 3831:
1.184 rillig 3832: Should one of the main targets do the wrong thing, and should there be no
3833: variable to fix this, you can redefine it with the do-* target. (Note that
3834: redefining the target itself instead of the do-* target is a bad idea, as
3835: the pre-* and post-* targets won't be called anymore, etc.)
1.1 dsieger 3836:
1.184 rillig 3837: About 15% of the pkgsrc packages override the default do-install, the other
3838: do-* targets are overridden even less often.
1.1 dsieger 3839:
1.184 rillig 3840: reinstall
1.1 dsieger 3841:
1.184 rillig 3842: If you did a make install and you noticed some file was not installed
3843: properly, you can repeat the installation with this target, which will
3844: ignore the "already installed" flag.
1.1 dsieger 3845:
1.184 rillig 3846: This is the default value of DEPENDS_TARGET except in the case of make
3847: update and make package, where the defaults are "package" and "update",
3848: respectively.
1.1 dsieger 3849:
1.184 rillig 3850: deinstall
1.1 dsieger 3851:
1.184 rillig 3852: This target does a pkg_delete(1) in the current directory, effectively
3853: de-installing the package. The following variables can be used to tune the
3854: behaviour:
1.1 dsieger 3855:
1.184 rillig 3856: PKG_VERBOSE
1.1 dsieger 3857:
1.184 rillig 3858: Add a "-v" to the pkg_delete(1) command.
1.1 dsieger 3859:
1.184 rillig 3860: DEINSTALLDEPENDS
1.1 dsieger 3861:
1.184 rillig 3862: Remove all packages that require (depend on) the given package. This
3863: can be used to remove any packages that may have been pulled in by a
3864: given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
3865: pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
3866: " to the pkg_delete(1) command line.
1.1 dsieger 3867:
1.184 rillig 3868: bin-install
1.1 dsieger 3869:
1.184 rillig 3870: Install a binary package from local disk and via FTP from a list of sites
3871: (see the BINPKG_SITES variable), and do a make package if no binary package
3872: is available anywhere. The arguments given to pkg_add can be set via
3873: BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
1.1 dsieger 3874:
1.184 rillig 3875: install-clean
1.1 dsieger 3876:
1.184 rillig 3877: This target removes the state files for the "install" and later phases so
3878: that the "install" target may be re-invoked. This can be used after editing
3879: the PLIST to install the package without rebuilding it.
1.1 dsieger 3880:
1.184 rillig 3881: build-clean
1.18 mishka 3882:
1.184 rillig 3883: This target removes the state files for the "build" and later phases so
3884: that the "build" target may be re-invoked.
1.18 mishka 3885:
1.184 rillig 3886: update
1.18 mishka 3887:
1.184 rillig 3888: This target causes the current package to be updated to the latest version.
3889: The package and all depending packages first get de-installed, then current
3890: versions of the corresponding packages get compiled and installed. This is
3891: similar to manually noting which packages are currently installed, then
3892: performing a series of make deinstall and make install (or whatever
3893: UPDATE_TARGET is set to) for these packages.
1.18 mishka 3894:
1.184 rillig 3895: You can use the "update" target to resume package updating in case a
3896: previous make update was interrupted for some reason. However, in this
3897: case, make sure you don't call make clean or otherwise remove the list of
3898: dependent packages in WRKDIR. Otherwise, you lose the ability to
3899: automatically update the current package along with the dependent packages
3900: you have installed.
1.121 sevan 3901:
1.184 rillig 3902: Resuming an interrupted make update will only work as long as the package
3903: tree remains unchanged. If the source code for one of the packages to be
3904: updated has been changed, resuming make update will most certainly fail!
1.1 dsieger 3905:
1.184 rillig 3906: The following variables can be used either on the command line or in
3907: mk.conf to alter the behaviour of make update:
1.1 dsieger 3908:
1.184 rillig 3909: UPDATE_TARGET
1.1 dsieger 3910:
1.184 rillig 3911: Install target to recursively use for the updated package and the
3912: dependent packages. Defaults to DEPENDS_TARGET if set, "install"
3913: otherwise for make update. Other good targets are "package" or "
3914: bin-install". Do not set this to "update" or you will get stuck in an
3915: endless loop!
1.1 dsieger 3916:
1.184 rillig 3917: NOCLEAN
1.1 dsieger 3918:
1.184 rillig 3919: Don't clean up after updating. Useful if you want to leave the work
3920: sources of the updated packages around for inspection or other
3921: purposes. Be sure you eventually clean up the source tree (see the "
3922: clean-update" target below) or you may run into troubles with old
3923: source code still lying around on your next make or make update.
1.1 dsieger 3924:
1.184 rillig 3925: REINSTALL
1.1 dsieger 3926:
1.184 rillig 3927: Deinstall each package before installing (making DEPENDS_TARGET). This
3928: may be necessary if the "clean-update" target (see below) was called
3929: after interrupting a running make update.
1.1 dsieger 3930:
1.184 rillig 3931: DEPENDS_TARGET
1.1 dsieger 3932:
1.184 rillig 3933: Allows you to disable recursion and hardcode the target for packages.
3934: The default is "update" for the update target, facilitating a recursive
3935: update of prerequisite packages. Only set DEPENDS_TARGET if you want to
3936: disable recursive updates. Use UPDATE_TARGET instead to just set a
3937: specific target for each package to be installed during make update
3938: (see above).
1.1 dsieger 3939:
1.184 rillig 3940: clean-update
1.1 dsieger 3941:
1.184 rillig 3942: Clean the source tree for all packages that would get updated if make
3943: update was called from the current directory. This target should not be
3944: used if the current package (or any of its depending packages) have already
3945: been de-installed (e.g., after calling make update) or you may lose some
3946: packages you intended to update. As a rule of thumb: only use this target
3947: before the first time you run make update and only if you have a dirty
3948: package tree (e.g., if you used NOCLEAN).
1.86 wiz 3949:
1.184 rillig 3950: If you are unsure about whether your tree is clean, you can either perform
3951: a make clean at the top of the tree, or use the following sequence of
3952: commands from the directory of the package you want to update (before
3953: running make update for the first time, otherwise you lose all the packages
3954: you wanted to update!):
1.86 wiz 3955:
1.184 rillig 3956: # make clean-update
3957: # make clean CLEANDEPENDS=YES
3958: # make update
1.86 wiz 3959:
3960:
1.184 rillig 3961: The following variables can be used either on the command line or in
3962: mk.conf to alter the behaviour of make clean-update:
1.86 wiz 3963:
1.184 rillig 3964: CLEAR_DIRLIST
1.86 wiz 3965:
1.184 rillig 3966: After make clean, do not reconstruct the list of directories to update
3967: for this package. Only use this if make update successfully installed
3968: all packages you wanted to update. Normally, this is done automatically
3969: on make update, but may have been suppressed by the NOCLEAN variable
3970: (see above).
1.1 dsieger 3971:
1.184 rillig 3972: replace
1.1 dsieger 3973:
1.184 rillig 3974: Update the installation of the current package. This differs from update in
3975: that it does not replace dependent packages. You will need to install
3976: pkgtools/pkg_tarup for this target to work.
1.1 dsieger 3977:
1.184 rillig 3978: Be careful when using this target! There are no guarantees that dependent
3979: packages will still work, in particular they will most certainly break if
3980: you make replace a library package whose shared library major version
3981: changed between your installed version and the new one. For this reason,
3982: this target is not officially supported and only recommended for advanced
3983: users.
1.1 dsieger 3984:
1.184 rillig 3985: info
1.1 dsieger 3986:
1.184 rillig 3987: This target invokes pkg_info(1) for the current package. You can use this
3988: to check which version of a package is installed.
1.86 wiz 3989:
1.184 rillig 3990: index
1.1 dsieger 3991:
1.184 rillig 3992: This is a top-level command, i.e. it should be used in the pkgsrc
3993: directory. It creates a database of all packages in the local pkgsrc tree,
3994: including dependencies, comment, maintainer, and some other useful
3995: information. Individual entries are created by running make describe in the
3996: packages' directories. This index file is saved as pkgsrc/INDEX. It can be
3997: displayed in verbose format by running make print-index. You can search in
3998: it with make search key=something. You can extract a list of all packages
3999: that depend on a particular one by running make show-deps PKG=somepackage.
1.1 dsieger 4000:
1.184 rillig 4001: Running this command takes a very long time, some hours even on fast
4002: machines!
1.1 dsieger 4003:
1.184 rillig 4004: readme
1.1 dsieger 4005:
1.199 nia 4006: This target generates a index.html file, which can be viewed using a
1.184 rillig 4007: browser such as www/firefox or www/links. The generated files contain
4008: references to any packages which are in the PACKAGES directory on the local
4009: host. The generated files can be made to refer to URLs based on
4010: FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
1.199 nia 4011: index.html files which pointed to binary packages on the local machine, in
1.184 rillig 4012: the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
4013: FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
4014: subdirectories will be searched for all the binary packages.
1.1 dsieger 4015:
1.184 rillig 4016: The target can be run at the toplevel or in category directories, in which
4017: case it descends recursively.
1.1 dsieger 4018:
1.184 rillig 4019: readme-all
1.1 dsieger 4020:
1.184 rillig 4021: This is a top-level command, run it in pkgsrc. Use this target to create a
4022: file README-all.html which contains a list of all packages currently
4023: available in the NetBSD Packages Collection, together with the category
4024: they belong to and a short description. This file is compiled from the
1.199 nia 4025: pkgsrc/*/index.html files, so be sure to run this after a make readme.
1.1 dsieger 4026:
1.184 rillig 4027: cdrom-readme
1.1 dsieger 4028:
1.184 rillig 4029: This is very much the same as the "readme" target (see above), but is to be
4030: used when generating a pkgsrc tree to be written to a CD-ROM. This target
1.199 nia 4031: also produces index.html files, and can be made to refer to URLs based on
1.184 rillig 4032: CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
1.1 dsieger 4033:
1.184 rillig 4034: show-distfiles
1.1 dsieger 4035:
1.184 rillig 4036: This target shows which distfiles and patchfiles are needed to build the
4037: package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
4038: patches/*).
1.1 dsieger 4039:
1.184 rillig 4040: show-downlevel
1.1 dsieger 4041:
1.184 rillig 4042: This target shows nothing if the package is not installed. If a version of
4043: this package is installed, but is not the version provided in this version
4044: of pkgsrc, then a warning message is displayed. This target can be used to
4045: show which of your installed packages are downlevel, and so the old
4046: versions can be deleted, and the current ones added.
1.1 dsieger 4047:
1.184 rillig 4048: show-pkgsrc-dir
1.1 dsieger 4049:
1.184 rillig 4050: This target shows the directory in the pkgsrc hierarchy from which the
4051: package can be built and installed. This may not be the same directory as
4052: the one from which the package was installed. This target is intended to be
4053: used by people who may wish to upgrade many packages on a single host, and
4054: can be invoked from the top-level pkgsrc Makefile by using the "
4055: show-host-specific-pkgs" target.
1.1 dsieger 4056:
1.184 rillig 4057: show-installed-depends
1.1 dsieger 4058:
1.184 rillig 4059: This target shows which installed packages match the current package's
4060: DEPENDS. Useful if out of date dependencies are causing build problems.
1.1 dsieger 4061:
1.184 rillig 4062: print-build-depends-list
1.1 dsieger 4063:
1.184 rillig 4064: This target shows the list of packages that the current package depends on
4065: for building.
1.1 dsieger 4066:
1.184 rillig 4067: print-run-depends-list
1.1 dsieger 4068:
1.184 rillig 4069: This target shows the list of packages that the current package depends on
4070: for running.
1.1 dsieger 4071:
1.184 rillig 4072: check-shlibs
1.1 dsieger 4073:
1.184 rillig 4074: After a package is installed, check all its binaries and (on ELF platforms)
4075: shared libraries to see if they find the shared libs they need. Run by
4076: default if PKG_DEVELOPER is set in mk.conf.
1.1 dsieger 4077:
1.184 rillig 4078: print-PLIST
1.1 dsieger 4079:
1.184 rillig 4080: After a "make install" from a new or upgraded pkg, this prints out an
4081: attempt to generate a new PLIST from a find -newer work/.extract_done. An
4082: attempt is made to care for shared libs etc., but it is strongly
4083: recommended to review the result before putting it into PLIST. On upgrades,
4084: it's useful to diff the output of this command against an already existing
4085: PLIST file.
1.1 dsieger 4086:
1.184 rillig 4087: If the package installs files via tar(1) or other methods that don't update
4088: file access times, be sure to add these files manually to your PLIST, as
4089: the "find -newer" command used by this target won't catch them!
1.56 ryoon 4090:
1.184 rillig 4091: See Section 19.3, "Tweaking output of make print-PLIST" for more
4092: information on this target.
1.1 dsieger 4093:
1.255 wiz 4094: rebuild
4095:
4096: If you did a make build and you noticed some further modifications of
4097: sources are needed, you can repeat the build with this target, which will
4098: ignore the "already built" flag. This target is helpful while working with
4099: patches.
4100:
4101: repackage
4102:
4103: If you did a make package and you noticed some further modifications of
4104: sources are needed, you can repeat the package with this target, which will
4105: ignore the "already packaged" flag. This target is helpful while working
4106: with patches, PLIST* files etc.
4107:
4108: retest
4109:
4110: If you did a make test and you noticed some further modifications of
4111: sources are needed, you can repeat the test with this target, which will
4112: ignore the "already tested" flag. This target is helpful while working with
4113: patches.
4114:
1.184 rillig 4115: Chapter 14. Creating a new pkgsrc package from scratch
1.1 dsieger 4116:
1.184 rillig 4117: Table of Contents
1.1 dsieger 4118:
1.184 rillig 4119: 14.1. Common types of packages
1.219 nia 4120: 14.1.1. Python modules and programs
4121: 14.1.2. R packages
4122: 14.1.3. TeXlive packages
1.184 rillig 4123: 14.2. Examples
4124: 14.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 4125:
1.184 rillig 4126: When you find a package that is not yet in pkgsrc, you most likely have a URL
4127: from where you can download the source code. Starting with this URL, creating a
4128: package involves only a few steps.
1.1 dsieger 4129:
1.184 rillig 4130: 1. In your mk.conf, set PKG_DEVELOPER=yes to enable the basic quality checks.
1.1 dsieger 4131:
1.184 rillig 4132: 2. Install the package meta-pkgs/pkg_developer, which among others will
4133: install the utilities url2pkg, pkglint, pkgvi and mkpatches:
1.1 dsieger 4134:
1.184 rillig 4135: $ cd /usr/pkgsrc
4136: $ (cd meta-pkgs/pkg_developer && bmake update)
1.1 dsieger 4137:
1.184 rillig 4138: 3. Choose one of the top-level directories as the category in which you want
4139: to place your package. You can also create a directory of your own (maybe
1.219 nia 4140: called local). Change into that category directory:
1.1 dsieger 4141:
1.219 nia 4142: $ cd category
1.1 dsieger 4143:
1.219 nia 4144: 4. Run the program url2pkg, passing as argument the URL of the distribution
4145: file (in most cases a .tar.gz file). This will download the distribution
4146: file and create the necessary files of the package, based on what's in the
4147: distribution file:
1.1 dsieger 4148:
1.184 rillig 4149: $ url2pkg https://www.example.org/packages/package-1.0.tar.gz
1.1 dsieger 4150:
1.184 rillig 4151: 5. Examine the extracted files to determine the dependencies of your package.
4152: Ideally, this is mentioned in some README file, but things may differ. For
4153: each of these dependencies, look where it exists in pkgsrc, and if there is
4154: a file called buildlink3.mk in that directory, add a line to your package
4155: Makefile which includes that file just before the last line. If the
4156: buildlink3.mk file does not exist, it must be created first. The
4157: buildlink3.mk file makes sure that the package's include files and
4158: libraries are provided.
1.1 dsieger 4159:
1.219 nia 4160: If you just need binaries from a dependent package, add a DEPENDS line to
4161: the Makefile, which specifies the version of the dependency and where it
4162: can be found in pkgsrc. This line should be placed in the third paragraph.
4163: If the dependency is only needed for building the package, but not when
4164: using it, use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The
4165: difference between TOOL_DEPENDS and BUILD_DEPENDS occurs when
4166: cross-compiling: TOOL_DEPENDS are native packages, i.e. packages for the
4167: platform where the package is built; BUILD_DEPENDS are target packages,
4168: i.e. packages for the platform for which the package is built. There is
4169: also TEST_DEPENDS, which specifies a dependency used only for testing the
4170: resulting package built, using the upstream project's included test suite,
4171: on the native platform. Your package may then look like this:
1.1 dsieger 4172:
1.184 rillig 4173: [...]
1.1 dsieger 4174:
1.184 rillig 4175: TOOL_DEPENDS+= libxslt-[0-9]*:../../textproc/libxslt
4176: DEPENDS+= screen-[0-9]*:../../misc/screen
4177: DEPENDS+= screen>=4.0:../../misc/screen
1.1 dsieger 4178:
1.184 rillig 4179: [...]
1.1 dsieger 4180:
1.184 rillig 4181: .include "../../category/package/buildlink3.mk"
4182: .include "../../devel/glib2/buildlink3.mk"
4183: .include "../../mk/bsd.pkg.mk"
1.1 dsieger 4184:
1.184 rillig 4185: 6. Run pkglint to see what things still need to be done to make your package a
4186: "good" one. If you don't know what pkglint's warnings want to tell you, try
4187: pkglint --explain or pkglint -e, which outputs additional explanations.
1.1 dsieger 4188:
1.184 rillig 4189: 7. In many cases the package is not yet ready to build. You can find
4190: instructions for the most common cases in the next section, Section 14.1,
4191: "Common types of packages". After you have followed the instructions over
4192: there, you can hopefully continue here.
1.1 dsieger 4193:
1.184 rillig 4194: 8. Run bmake clean to clean the working directory from the extracted files.
1.219 nia 4195: Besides these files, a lot of cache files and other system information have
4196: been saved in the working directory, which may have become outdated after
4197: you edited the Makefile.
1.1 dsieger 4198:
1.184 rillig 4199: 9. Now, run bmake to build the package. For the various things that can go
4200: wrong in this phase, consult Chapter 21, Making your package work.
1.1 dsieger 4201:
1.184 rillig 4202: If the extracted files from the package need to be fixed, run multiple
4203: rounds of these commands:
1.1 dsieger 4204:
1.219 nia 4205: $ bmake
1.184 rillig 4206: $ pkgvi ${WRKSRC}/some/file/that/does/not/compile
4207: $ mkpatches
1.219 nia 4208: $ bmake mps
4209: $ bmake clean
1.1 dsieger 4210:
1.184 rillig 4211: 10. When the package builds fine, the next step is to install the package. Run
4212: bmake install and hope that everything works.
1.1 dsieger 4213:
1.184 rillig 4214: 11. Up to now, the file PLIST, which contains a list of the files that are
4215: installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
4216: generate a probably correct list. Check the file using your preferred text
4217: editor to see if the list of files looks plausible.
1.1 dsieger 4218:
1.184 rillig 4219: 12. Run pkglint again to see if the generated PLIST contains garbage or not.
1.1 dsieger 4220:
1.184 rillig 4221: 13. When you ran bmake install, the package had been registered in the database
4222: of installed files, but with an empty list of files. To fix this, run bmake
4223: deinstall and bmake install again. Now the package is registered with the
4224: list of files from PLIST.
1.48 wiz 4225:
1.219 nia 4226: 14. Run bmake clean update to run everything from above again in a single step,
1.184 rillig 4227: making sure that the PLIST is correct and the whole package is created as
4228: intended.
1.48 wiz 4229:
1.219 nia 4230: 15. Run pkglint to see if there's anything left to do.
1.48 wiz 4231:
1.219 nia 4232: 16. Commit the package to pkgsrc-wip or main pkgsrc; see Chapter 23, Submitting
1.184 rillig 4233: and Committing.
1.50 wiz 4234:
1.184 rillig 4235: 14.1. Common types of packages
1.1 dsieger 4236:
1.219 nia 4237: 14.1.1. Python modules and programs
1.1 dsieger 4238:
1.184 rillig 4239: Python modules and programs packages are easily created using a set of
4240: predefined variables.
1.1 dsieger 4241:
1.184 rillig 4242: If some Python versions are not supported by the software, set the
4243: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
4244: supported, e.g.
1.1 dsieger 4245:
1.184 rillig 4246: PYTHON_VERSIONS_INCOMPATIBLE= 27
1.1 dsieger 4247:
1.249 gutterid 4248: If the packaged software is a Python module, include ../../lang/python/
1.258 wiz 4249: wheel.mk. Note per PEP-518, the minimum and default requirement to create .whl
4250: files is devel/py-setuptools; however, there are various other possible tools
4251: that projects can use. Thus inclusion of wheel.mk does not imply these defaults
4252: are defined as TOOL_DEPENDS. Whatever the project specifically requires as
4253: packaging tools must be defined in the package Makefile.
1.1 dsieger 4254:
1.248 wiz 4255: The package directory should be called "py-software" and PKGNAME should be set
4256: to "${PYPKGPREFIX}-${DISTNAME}", e.g.
1.1 dsieger 4257:
1.184 rillig 4258: DISTNAME= foopymodule-1.2.10
4259: PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
1.1 dsieger 4260:
1.226 gutterid 4261: For software in PyPi, the name should match what PyPi specifies for "pip
4262: install software".
4263:
1.184 rillig 4264: If it is an application, include "../../lang/python/application.mk". In order
4265: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
4266: variable and set it to the list of files (paths relative to WRKSRC) that must
4267: be corrected. For example:
1.1 dsieger 4268:
1.184 rillig 4269: REPLACE_PYTHON= *.py
1.1 dsieger 4270:
1.219 nia 4271: 14.1.2. R packages
1.1 dsieger 4272:
1.184 rillig 4273: Simple R packages from CRAN are handled automatically by R2pkg, which is
4274: available in pkgtools/R2pkg. Individual packages (and optionally their
4275: dependencies) may be created and updated. R packages generally follow the same
4276: form, and most of the relevant information needed is contained in a DESCRIPTION
4277: file as part of each R package on CRAN. Consequently, R2pkg downloads that
4278: information and creates or updates a package in the canonical form. The
4279: resulting package should be reviewed for correctness.
1.1 dsieger 4280:
1.219 nia 4281: 14.1.3. TeXlive packages
1.1 dsieger 4282:
1.184 rillig 4283: TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
4284: available in pkgtools/texlive2pkg.
1.1 dsieger 4285:
1.184 rillig 4286: If the TeXlive package name is not known, it may be useful to search CTAN. A "
4287: Contained in" field on the package page typically identifies the basename of
4288: the package file in the TeXlive archive.
1.1 dsieger 4289:
1.184 rillig 4290: If the TeXlive package name is known, download the files from the TeXlive
4291: archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
4292: packages also have associated documentation packages, so download
4293: foo.doc.tar.xz at the same time. These files should be placed in the
4294: appropriate category directory, which is often but not always print. Then run
4295: the following command in the category directory.
1.1 dsieger 4296:
1.184 rillig 4297: texlive2pkg foo.tar.xz foo.doc.tar.xz
1.1 dsieger 4298:
1.184 rillig 4299: This will create two packages, tex-foo and tex-foo-doc. Be sure to check that
4300: both packages are correct.
1.1 dsieger 4301:
1.184 rillig 4302: Finally, CTAN currently does not include version information in package
4303: filenames and changes their contents periodically when updates occur.
4304: Consequently, pkgsrc avoids downloading distfiles directly from CTAN and
4305: instead relies on the pkgsrc archives. For each new or updated TeXlive package,
4306: e.g., the main one and the corresponding documentation, upload the distfiles
4307: with the following command in each package directory.
1.1 dsieger 4308:
1.184 rillig 4309: make upload-distfiles
1.117 sevan 4310:
1.184 rillig 4311: 14.2. Examples
1.117 sevan 4312:
1.184 rillig 4313: 14.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 4314:
1.184 rillig 4315: 14.2.1.1. The initial package
1.1 dsieger 4316:
1.184 rillig 4317: Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
4318: been imported into pkgsrc. As the description says it has to do with the web,
4319: the obvious choice for the category is "www".
1.1 dsieger 4320:
1.184 rillig 4321: $ mkdir www/nvu
4322: $ cd www/nvu
1.1 dsieger 4323:
1.184 rillig 4324: The web site says that the sources are available as a tar file, so I fed that
4325: URL to the url2pkg program:
1.1 dsieger 4326:
1.184 rillig 4327: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
1.1 dsieger 4328:
1.184 rillig 4329: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
4330: package name should not have the word "sources" in it. I also filled in the
4331: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
4332: that:
1.1 dsieger 4333:
1.184 rillig 4334: # $NetBSD $
4335: #
1.1 dsieger 4336:
1.184 rillig 4337: DISTNAME= nvu-1.0-sources
4338: PKGNAME= nvu-1.0
4339: CATEGORIES= www
4340: MASTER_SITES= http://cvs.nvu.com/download/
4341: EXTRACT_SUFX= .tar.bz2
1.1 dsieger 4342:
1.184 rillig 4343: MAINTAINER= rillig@NetBSD.org
4344: HOMEPAGE= http://cvs.nvu.com/
4345: COMMENT= Web Authoring System
1.1 dsieger 4346:
1.184 rillig 4347: # url2pkg-marker (please do not remove this line.)
4348: .include "../../mk/bsd.pkg.mk"
1.1 dsieger 4349:
1.184 rillig 4350: On the first line of output above, an artificial space has been added between
4351: NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
4352: the guide.
1.1 dsieger 4353:
1.184 rillig 4354: Then, I quit the editor and watched pkgsrc downloading a large source archive:
1.1 dsieger 4355:
1.184 rillig 4356: url2pkg> Running "make makesum" ...
4357: => Required installed package digest>=20010302: digest-20060826 found
4358: => Fetching nvu-1.0-sources.tar.bz2
4359: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
4360: 100% |*************************************| 28992 KB 150.77 KB/s00:00 ETA
4361: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
4362: url2pkg> Running "make extract" ...
4363: => Required installed package digest>=20010302: digest-20060826 found
4364: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
4365: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
4366: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
4367: ===> Installing dependencies for nvu-1.0
4368: ===> Overriding tools for nvu-1.0
4369: ===> Extracting for nvu-1.0
4370: url2pkg> Adjusting the Makefile.
1.1 dsieger 4371:
1.184 rillig 4372: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
1.1 dsieger 4373:
1.184 rillig 4374: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
1.1 dsieger 4375:
1.184 rillig 4376: 14.2.1.2. Fixing all kinds of problems to make the package work
1.1 dsieger 4377:
1.184 rillig 4378: Now that the package has been extracted, let's see what's inside it. The
4379: package has a README.txt, but that only says something about mozilla, so it's
4380: probably useless for seeing what dependencies this package has. But since there
4381: is a GNU configure script in the package, let's hope that it will complain
4382: about everything it needs.
1.1 dsieger 4383:
1.184 rillig 4384: $ bmake
4385: => Required installed package digest>=20010302: digest-20060826 found
4386: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
4387: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
4388: ===> Patching for nvu-1.0
4389: ===> Creating toolchain wrappers for nvu-1.0
4390: ===> Configuring for nvu-1.0
4391: [...]
4392: configure: error: Perl 5.004 or higher is required.
4393: [...]
4394: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
4395: [...]
1.1 dsieger 4396:
1.184 rillig 4397: That worked quite well. So I opened the package Makefile in my editor, and
4398: since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
4399: dependencies of the package have changed now, and since a perl wrapper is
4400: automatically installed in the "tools" phase, I need to build the package from
4401: scratch.
1.1 dsieger 4402:
1.184 rillig 4403: $ bmake clean
4404: ===> Cleaning for nvu-1.0
4405: $ bmake
4406: [...]
4407: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
4408: GNU Make. You will not be able to build Mozilla without GNU Make.
4409: [...]
1.1 dsieger 4410:
1.184 rillig 4411: So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
1.1 dsieger 4412:
1.184 rillig 4413: [...]
4414: checking for GTK - version >= 1.2.0... no
4415: *** Could not run GTK test program, checking why...
4416: [...]
1.1 dsieger 4417:
1.184 rillig 4418: Now to the other dependencies. The first question is: Where is the GTK package
4419: hidden in pkgsrc?
1.1 dsieger 4420:
1.184 rillig 4421: $ echo ../../*/gtk*
4422: [many packages ...]
4423: $ echo ../../*/gtk
4424: ../../x11/gtk
4425: $ echo ../../*/gtk2
4426: ../../x11/gtk2
4427: $ echo ../../*/gtk2/bui*
4428: ../../x11/gtk2/buildlink3.mk
1.1 dsieger 4429:
1.184 rillig 4430: The first try was definitely too broad. The second one had exactly one result,
4431: which is very good. But there is one pitfall with GNOME packages. Before GNOME
4432: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
4433: able to continue to use these packages, the GNOME 2 packages were imported as
4434: separate packages, and their names usually have a "2" appended. So I checked
4435: whether this was the case here, and indeed it was.
1.1 dsieger 4436:
1.184 rillig 4437: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
4438: easy. I just inserted an .include line before the last line of the package
4439: Makefile, so that it now looks like this:
1.1 dsieger 4440:
1.184 rillig 4441: [...]
4442: .include "../../x11/gtk2/buildlink3.mk"
4443: .include "../../mk/bsd.pkg.mk
1.1 dsieger 4444:
1.184 rillig 4445: After another bmake clean && bmake, the answer was:
1.108 rillig 4446:
1.184 rillig 4447: [...]
4448: checking for gtk-config... /home/roland/pkg/bin/gtk-config
4449: checking for GTK - version >= 1.2.0... no
4450: *** Could not run GTK test program, checking why...
4451: *** The test program failed to compile or link. See the file config.log for the
4452: *** exact error that occured. This usually means GTK was incorrectly installed
4453: *** or that you have moved GTK since it was installed. In the latter case, you
4454: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
4455: configure: error: Test for GTK failed.
4456: [...]
1.1 dsieger 4457:
1.184 rillig 4458: In this particular case, the assumption that "every package prefers GNOME 2"
4459: had been wrong. The first of the lines above told me that this package really
4460: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
4461: it would have looked for pkg-config instead of gtk-config. So I changed the x11
4462: /gtk2 to x11/gtk in the package Makefile, and tried again.
1.1 dsieger 4463:
1.184 rillig 4464: [...]
4465: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\" [...]
4466: In file included from xpidl.c:42:
4467: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
4468: In file included from xpidl.c:42:
4469: xpidl.h:132: error: parse error before "IDL_ns"
4470: [...]
1.1 dsieger 4471:
1.184 rillig 4472: The package still does not find all of its dependencies. Now the question is:
4473: Which package provides the libIDL/IDL.h header file?
1.1 dsieger 4474:
1.184 rillig 4475: $ echo ../../*/*idl*
4476: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
4477: $ echo ../../*/*IDL*
4478: ../../net/libIDL
1.1 dsieger 4479:
1.184 rillig 4480: Let's take the one from the second try. So I included the ../../net/libIDL/
4481: buildlink3.mk file and tried again. But the error didn't change. After digging
4482: through some of the code, I concluded that the build process of the package was
4483: broken and couldn't have ever worked, but since the Mozilla source tree is
4484: quite large, I didn't want to fix it. So I added the following to the package
4485: Makefile and tried again:
1.1 dsieger 4486:
1.184 rillig 4487: CPPFLAGS+= -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
4488: BUILDLINK_TRANSFORM+= l:IDL:IDL-2
1.1 dsieger 4489:
1.184 rillig 4490: The latter line is needed because the package expects the library libIDL.so,
4491: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
4492: that on the fly.
1.1 dsieger 4493:
1.184 rillig 4494: The next problem was related to a recent change of the FreeType interface. I
4495: looked up in www/seamonkey which patch files were relevant for this issue and
4496: copied them to the patches directory. Then I retried, fixed the patches so that
4497: they applied cleanly and retried again. This time, everything worked.
1.1 dsieger 4498:
1.184 rillig 4499: 14.2.1.3. Installing the package
1.1 dsieger 4500:
1.184 rillig 4501: $ bmake CHECK_FILES=no install
4502: [...]
4503: $ bmake print-PLIST >PLIST
4504: $ bmake deinstall
4505: $ bmake install
1.1 dsieger 4506:
1.184 rillig 4507: Chapter 15. Programming in Makefiles
1.1 dsieger 4508:
1.184 rillig 4509: Table of Contents
1.1 dsieger 4510:
1.184 rillig 4511: 15.1. Caveats
4512: 15.2. Makefile variables
4513: 15.2.1. Naming conventions
4514: 15.3. Code snippets
4515: 15.3.1. Adding things to a list
4516: 15.3.2. Echoing a string exactly as-is
4517: 15.3.3. Passing CFLAGS to GNU configure scripts
4518: 15.3.4. Handling possibly empty variables
1.229 gutterid 4519: 15.3.5. Testing yes/no variables in conditions
1.1 dsieger 4520:
1.184 rillig 4521: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
4522: part of the pkgsrc system. Using the make(1) system as a programming language
4523: for a big system like pkgsrc requires some discipline to keep the code correct
4524: and understandable.
1.1 dsieger 4525:
1.184 rillig 4526: The basic ingredients for Makefile programming are variables and shell
4527: commands. Among these shell commands may even be more complex ones like awk(1)
4528: programs. To make sure that every shell command runs as intended it is
4529: necessary to quote all variables correctly when they are used.
1.1 dsieger 4530:
1.184 rillig 4531: This chapter describes some patterns that appear quite often in Makefiles,
4532: including the pitfalls that come along with them.
1.1 dsieger 4533:
1.184 rillig 4534: 15.1. Caveats
1.1 dsieger 4535:
1.184 rillig 4536: * When you are creating a file as a target of a rule, always write the data
4537: to a temporary file first and finally rename that file. Otherwise there
4538: might occur an error in the middle of generating the file, and when the
4539: user runs make(1) for the second time, the file exists and will not be
4540: regenerated properly. Example:
1.1 dsieger 4541:
1.184 rillig 4542: wrong:
4543: @echo "line 1" > ${.TARGET}
4544: @echo "line 2" >> ${.TARGET}
4545: @false
1.1 dsieger 4546:
1.184 rillig 4547: correct:
4548: @echo "line 1" > ${.TARGET}.tmp
4549: @echo "line 2" >> ${.TARGET}.tmp
4550: @false
4551: @mv ${.TARGET}.tmp ${.TARGET}
1.1 dsieger 4552:
1.184 rillig 4553: When you run make wrong twice, the file wrong will exist, although there
4554: was an error message in the first run. On the other hand, running make
4555: correct gives an error message twice, as expected.
1.1 dsieger 4556:
1.184 rillig 4557: You might remember that make(1) sometimes removes ${.TARGET} in case of
4558: error, but this only happens when it is interrupted, for example by
4559: pressing Ctrl+C. This does not happen when one of the commands fails (like
4560: false(1) above).
1.1 dsieger 4561:
1.184 rillig 4562: 15.2. Makefile variables
1.1 dsieger 4563:
1.184 rillig 4564: Makefile variables contain strings that can be processed using the five
4565: operators =, +=, ?=, := and !=, which are described in the make(1) man page.
1.1 dsieger 4566:
1.184 rillig 4567: When a variable's value is parsed from a Makefile, the hash character # and the
4568: backslash character \ are handled specially. If a backslash is the last
4569: character in a line, that backslash is removed from the line and the line
4570: continues with the next line of the file.
1.1 dsieger 4571:
1.184 rillig 4572: The # character starts a comment that reaches until the end of the line. To get
4573: an actual # character, such as in a URL, write \# instead.
1.1 dsieger 4574:
1.184 rillig 4575: The evaluation of variables either happens immediately or lazy. It happens
4576: immediately when the variable occurs on the right-hand side of the := or the !=
4577: operator, in a .if condition or a .for loop. In the other cases, it is
4578: evaluated lazily.
1.1 dsieger 4579:
1.184 rillig 4580: Some of the modifiers split the string into words and then operate on the
4581: words, others operate on the string as a whole. When a string is split into
4582: words, double quotes and single quotes are interpreted as delimiters, just like
4583: in sh(1).
1.1 dsieger 4584:
1.184 rillig 4585: 15.2.1. Naming conventions
1.1 dsieger 4586:
1.184 rillig 4587: * All variable names starting with an underscore are reserved for use by the
4588: pkgsrc infrastructure. They shall not be used by packages.
1.1 dsieger 4589:
1.184 rillig 4590: * In .for loops you should use lowercase variable names for the iteration
4591: variables.
1.1 dsieger 4592:
1.184 rillig 4593: * All list variables should have a plural name, such as PKG_OPTIONS or
4594: DISTFILES.
1.1 dsieger 4595:
1.184 rillig 4596: 15.3. Code snippets
1.1 dsieger 4597:
1.184 rillig 4598: 15.3.1. Adding things to a list
1.1 dsieger 4599:
1.184 rillig 4600: When adding a string that possibly contains whitespace or quotes to a list
4601: (example 1), it must be quoted using the :Q modifier.
1.1 dsieger 4602:
1.184 rillig 4603: When adding another list to a list (example 2), it must not be quoted, since
4604: its elements are already quoted.
1.1 dsieger 4605:
1.184 rillig 4606: STRING= foo * bar `date`
4607: LIST= # empty
4608: ANOTHER_LIST= a=b c=d
1.1 dsieger 4609:
1.184 rillig 4610: LIST+= ${STRING:Q} # 1
4611: LIST+= ${ANOTHER_LIST} # 2
1.1 dsieger 4612:
1.184 rillig 4613: 15.3.2. Echoing a string exactly as-is
1.1 dsieger 4614:
1.184 rillig 4615: Echoing a string containing special characters needs special work.
1.1 dsieger 4616:
1.184 rillig 4617: STRING= foo bar < > * `date` $$HOME ' "
4618: EXAMPLE_ENV= string=${STRING:Q} x=multiple\ quoted\ words
1.1 dsieger 4619:
1.184 rillig 4620: all:
4621: echo ${STRING} # 1
4622: echo ${STRING:Q} # 2
4623: printf '%s\n' ${STRING:Q}'' # 3
4624: env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"' # 4
1.1 dsieger 4625:
1.184 rillig 4626: Example 1 leads to a syntax error in the shell, as the characters are just
4627: copied.
1.1 dsieger 4628:
1.184 rillig 4629: Example 2 quotes the string so that the shell interprets it correctly. But the
4630: echo command may additionally interpret strings with a leading dash or those
4631: containing backslashes.
1.1 dsieger 4632:
1.184 rillig 4633: Example 3 can handle arbitrary strings, since printf(1) only interprets the
4634: format string, but not the next argument. The trailing single quotes handle the
4635: case when the string is empty. In that case, the :Q modifier would result in an
4636: empty string too, which would then be skipped by the shell. For printf(1) this
4637: doesn't make a difference, but other programs may care.
1.1 dsieger 4638:
1.184 rillig 4639: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
4640: has already been done when adding elements to the list.
1.1 dsieger 4641:
1.184 rillig 4642: 15.3.3. Passing CFLAGS to GNU configure scripts
1.1 dsieger 4643:
1.184 rillig 4644: When passing CFLAGS or similar variables to a GNU-style configure script
4645: (especially those that call other configure scripts), it must not have leading
4646: or trailing whitespace, since otherwise the configure script gets confused. To
4647: trim leading and trailing whitespace, use the :M modifier, as in the following
4648: example:
1.1 dsieger 4649:
1.184 rillig 4650: CPPFLAGS= # empty
4651: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX}\"
4652: CPPFLAGS+= ${MY_CPPFLAGS}
1.1 dsieger 4653:
1.184 rillig 4654: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
1.1 dsieger 4655:
1.184 rillig 4656: all:
4657: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
4658: echo x${CONFIGURE_ARGS:Q}x # properly trimmed
1.1 dsieger 4659:
1.184 rillig 4660: In this example, CPPFLAGS has both leading and trailing whitespace because the
4661: += operator always adds a space.
1.1 dsieger 4662:
1.184 rillig 4663: 15.3.4. Handling possibly empty variables
1.1 dsieger 4664:
1.184 rillig 4665: When a possibly empty variable is used in a shell program, it may lead to a
4666: syntax error.
1.1 dsieger 4667:
1.184 rillig 4668: EGFILES= # empty
1.1 dsieger 4669:
1.184 rillig 4670: install-examples: # produces a syntax error in the shell
4671: for egfile in ${EGFILES}; do \
4672: echo "Installing $$egfile"; \
4673: done
1.1 dsieger 4674:
1.184 rillig 4675: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
4676: with an empty string by make(1). To fix this syntax error, use one of the
4677: snippets below.
1.1 dsieger 4678:
1.229 gutterid 4679: EGFILES= # empty
1.1 dsieger 4680:
1.184 rillig 4681: install-examples:
4682: for egfile in ${EGFILES} ""; do \
4683: [ -n "$$egfile" ] || continue; \
4684: echo "Installing $$egfile"; \
4685: done
1.1 dsieger 4686:
1.184 rillig 4687: In this case, an empty string is appended to the iteration list (to prevent the
4688: syntax error) and filtered out later.
1.1 dsieger 4689:
1.184 rillig 4690: EGFILES= # empty
1.1 dsieger 4691:
1.184 rillig 4692: install-examples:
4693: .for egfile in ${EGFILES}
4694: echo "Installing ${egfile}"
4695: .endfor
1.1 dsieger 4696:
1.184 rillig 4697: If one of the filenames contains special characters, it should be enclosed in
4698: single or double quotes.
1.1 dsieger 4699:
1.184 rillig 4700: To have a shell command test whether a make variable is empty, use the
4701: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1 dsieger 4702:
1.229 gutterid 4703: 15.3.5. Testing yes/no variables in conditions
4704:
4705: When a variable can have the values yes or no, use the following pattern to
4706: test the variable:
4707:
4708: .if ${VAR:U:tl} == "yes"
4709: # do something
4710: .endif
4711:
4712: The :U modifier is only necessary if the variable can be undefined. If the
4713: variable is guaranteed to be defined, the :U can be omitted.
4714:
4715: The :tl modifier converts the variable value to lowercase, allowing for the
4716: values yes, Yes, YES.
4717:
1.184 rillig 4718: Chapter 16. Options handling
1.1 dsieger 4719:
4720: Table of Contents
4721:
1.184 rillig 4722: 16.1. Global default options
4723: 16.2. Converting packages to use bsd.options.mk
4724: 16.3. Option Names
4725: 16.4. Determining the options of dependencies
1.1 dsieger 4726:
4727: Many packages have the ability to be built to support different sets of
4728: features. bsd.options.mk is a framework in pkgsrc that provides generic
4729: handling of those options that determine different ways in which the packages
4730: can be built. It's possible for the user to specify exactly which sets of
4731: options will be built into a package or to allow a set of global default
4732: options apply.
4733:
1.7 rillig 4734: There are two broad classes of behaviors that one might want to control via
4735: options. One is whether some particular feature is enabled in a program that
4736: will be built anyway, often by including or not including a dependency on some
4737: other package. The other is whether or not an additional program will be built
4738: as part of the package. Generally, it is better to make a split package for
4739: such additional programs instead of using options, because it enables binary
4740: packages to be built which can then be added separately. For example, the foo
4741: package might have minimal dependencies (those packages without which foo
4742: doesn't make sense), and then the foo-gfoo package might include the GTK
4743: frontend program gfoo. This is better than including a gtk option to foo that
4744: adds gfoo, because either that option is default, in which case binary users
4745: can't get foo without gfoo, or not default, in which case they can't get gfoo.
4746: With split packages, they can install foo without having GTK, and later decide
4747: to install gfoo (pulling in GTK at that time). This is an advantage to source
4748: users too, avoiding the need for rebuilds.
4749:
4750: Plugins with widely varying dependencies should usually be split instead of
4751: options.
4752:
4753: It is often more work to maintain split packages, especially if the upstream
4754: package does not support this. The decision of split vs. option should be made
4755: based on the likelihood that users will want or object to the various pieces,
4756: the size of the dependencies that are included, and the amount of work.
4757:
4758: A further consideration is licensing. Non-free parts, or parts that depend on
4759: non-free dependencies (especially plugins) should almost always be split if
4760: feasible.
4761:
1.184 rillig 4762: 16.1. Global default options
1.1 dsieger 4763:
4764: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
4765: the options that should be built into every package if that option is
1.4 rillig 4766: supported. This variable should be set in mk.conf.
1.1 dsieger 4767:
1.184 rillig 4768: 16.2. Converting packages to use bsd.options.mk
1.1 dsieger 4769:
4770: The following example shows how bsd.options.mk should be used by the
4771: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
4772: e.g. options.mk, that is included by the main package Makefile.
4773:
4774: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
4775: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
4776: PKG_OPTIONS_OPTIONAL_GROUPS= database
4777: PKG_OPTIONS_GROUP.database= mysql pgsql
4778: PKG_SUGGESTED_OPTIONS= wibble-foo
4779: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
4780: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
4781:
4782: .include "../../mk/bsd.prefs.mk"
4783:
4784: # this package was previously named wibble2
4785: .if defined(PKG_OPTIONS.wibble2)
4786: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
4787: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
4788: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
4789: .endif
4790:
4791: .include "../../mk/bsd.options.mk"
4792:
4793: # Package-specific option-handling
4794:
4795: ###
4796: ### FOO support
4797: ###
4798: .if !empty(PKG_OPTIONS:Mwibble-foo)
4799: CONFIGURE_ARGS+= --enable-foo
4800: .endif
4801:
4802: ###
4803: ### LDAP support
4804: ###
4805: .if !empty(PKG_OPTIONS:Mldap)
4806: . include "../../databases/openldap-client/buildlink3.mk"
4807: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
4808: .endif
4809:
4810: ###
4811: ### database support
4812: ###
4813: .if !empty(PKG_OPTIONS:Mmysql)
4814: . include "../../mk/mysql.buildlink3.mk"
4815: .endif
4816: .if !empty(PKG_OPTIONS:Mpgsql)
4817: . include "../../mk/pgsql.buildlink3.mk"
4818: .endif
4819:
4820: The first section contains the information about which build options are
4821: supported by the package, and any default options settings if needed.
4822:
4823: 1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
4824: to override the default options. It should be set to PKG_OPTIONS.pkgbase.
4825: Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
4826: the point where the options are processed.
4827:
4828: 2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
4829:
4830: 3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
4831: exclusive options. The options in each group are listed in
4832: PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
4833: the group takes precedence over all other options in the group. Options
4834: from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
4835:
4836: 4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
4837: building the packages will fail if no option from the group is selected.
4838:
4839: 5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
4840: one option from each set must be selected. The options in each set are
4841: listed in PKG_OPTIONS_SET.setname. Options from the sets will be
4842: automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
4843: fail if no option from the set is selected.
4844:
4845: 6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
4846: default.
4847:
4848: 7. PKG_OPTIONS_LEGACY_VARS is a list of "USE_VARIABLE:option" pairs that map
1.4 rillig 4849: legacy mk.conf variables to their option counterparts. Pairs should be
1.1 dsieger 4850: added with "+=" to keep the listing of global legacy variables. A warning
4851: will be issued if the user uses a legacy variable.
4852:
4853: 8. PKG_OPTIONS_LEGACY_OPTS is a list of "old-option:new-option" pairs that map
4854: options that have been renamed to their new counterparts. Pairs should be
4855: added with "+=" to keep the listing of global legacy options. A warning
4856: will be issued if the user uses a legacy option.
4857:
4858: 9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
4859: used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
4860: PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
4861:
4862: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
4863: variables or options used, and what to use instead.
4864:
4865: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
4866: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
4867: options, use PKG_SUGGESTED_OPTIONS.
4868:
4869: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
4870: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
4871: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
4872: options if none of them is supported on the current platform), PKG_OPTIONS is
4873: set to the empty list and the package is otherwise treated as not using the
4874: options framework.
4875:
4876: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
4877: list of selected build options, properly filtered to remove unsupported and
4878: duplicate options.
4879:
4880: The remaining sections contain the logic that is specific to each option. The
4881: correct way to check for an option is to check whether it is listed in
4882: PKG_OPTIONS:
4883:
4884: .if !empty(PKG_OPTIONS:Moption)
4885:
1.184 rillig 4886: 16.3. Option Names
1.1 dsieger 4887:
4888: Options that enable similar features in different packages (like optional
4889: support for a library) should use a common name in all packages that support it
4890: (like the name of the library). If another package already has an option with
4891: the same meaning, use the same name.
4892:
4893: Options that enable features specific to one package, where it's unlikely that
4894: another (unrelated) package has the same (or a similar) optional feature,
4895: should use a name prefixed with pkgname-.
4896:
4897: If a group of related packages share an optional feature specific to that
4898: group, prefix it with the name of the "main" package (e. g.
4899: djbware-errno-hack).
4900:
4901: For new options, add a line to mk/defaults/options.description. Lines have two
4902: fields, separated by tab. The first field is the option name, the second its
4903: description. The description should be a whole sentence (starting with an
4904: uppercase letter and ending with a period) that describes what enabling the
4905: option does. E. g. "Enable ispell support." The file is sorted by option names.
4906:
1.184 rillig 4907: 16.4. Determining the options of dependencies
1.7 rillig 4908:
4909: When writing buildlink3.mk files, it is often necessary to list different
4910: dependencies based on the options with which the package was built. For
4911: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
4912: A typical example looks like this:
4913:
4914: pkgbase := libpurple
4915: .include "../../mk/pkg-build-options.mk"
4916:
4917: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
4918: ...
4919: .endif
4920:
4921: Including pkg-build-options.mk here will set the variable
4922: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
4923: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
4924: pkg-build-options.mk for more details.
4925:
1.184 rillig 4926: Chapter 17. Tools needed for building or running
4927:
4928: Table of Contents
4929:
4930: 17.1. Tools for pkgsrc builds
4931: 17.2. Tools needed by packages
4932: 17.3. Tools provided by platforms
4933:
4934: The USE_TOOLS definition is used both internally by pkgsrc and also for
4935: individual packages to define what commands are needed for building a package
4936: (like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
4937: DEPENDS). If the native system provides an adequate tool, then in many cases, a
4938: pkgsrc package will not be used.
4939:
4940: When building a package, the replacement tools are made available in a
4941: directory (as symlinks or wrapper scripts) that is early in the executable
4942: search path. Just like the buildlink system, this helps with consistent builds.
4943:
4944: A tool may be needed to help build a specific package. For example, perl, GNU
4945: make (gmake) or yacc may be needed.
4946:
4947: Also a tool may be needed, for example, because the native system's supplied
4948: tool may be inefficient for building a package with pkgsrc. For example, a
4949: package may need GNU awk, bison (instead of yacc) or a better sed.
4950:
4951: The tools used by a package can be listed by running make show-tools.
4952:
4953: 17.1. Tools for pkgsrc builds
4954:
4955: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
4956: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
4957: seen by running: make show-var VARNAME=USE_TOOLS.
4958:
4959: If a package needs a specific program to build then the USE_TOOLS variable can
4960: be used to define the tools needed.
4961:
4962: 17.2. Tools needed by packages
4963:
4964: In the following examples, the :run means that it is needed at run-time (and
4965: becomes a DEPENDS). The default is a build dependency which can be set with
4966: :build. (So in this example, it is the same as gmake:build and
4967: pkg-config:build.)
4968:
4969: USE_TOOLS+= gmake perl:run pkg-config
4970:
4971: When using the tools framework, a TOOLS_PATH.foo variable is defined which
4972: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
4973: could be "/bin/bash" on Linux systems.
4974:
4975: If you always need a pkgsrc version of the tool at run-time, then just use
4976: DEPENDS instead.
4977:
4978: 17.3. Tools provided by platforms
4979:
4980: When improving or porting pkgsrc to a new platform, have a look at (or create)
4981: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
4982: tools.${OPSYS}.mk which defines the name of the common tools. For example:
4983:
4984: .if exists(/usr/bin/bzcat)
4985: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
4986: .elif exists(/usr/bin/bzip2)
4987: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
4988: .endif
4989:
4990: TOOLS_PLATFORM.true?= true # shell builtin
4991:
4992: Chapter 18. Buildlink methodology
1.1 dsieger 4993:
4994: Table of Contents
4995:
1.184 rillig 4996: 18.1. Converting packages to use buildlink3
4997: 18.2. Writing buildlink3.mk files
4998: 18.2.1. Anatomy of a buildlink3.mk file
4999: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.259 leot 5000: buildlink3.mk files
1.184 rillig 5001: 18.3. Writing builtin.mk files
5002: 18.3.1. Anatomy of a builtin.mk file
5003:
5004: Buildlink is a framework in pkgsrc that controls what headers and libraries are
5005: seen by a package's configure and build processes. This is implemented in a two
5006: step process:
5007:
5008: 1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
5009: default is a subdirectory of WRKDIR.
5010:
5011: 2. Create wrapper scripts that are used in place of the normal compiler tools
5012: that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
5013: references to BUILDLINK_DIR. The wrapper scripts also make native compiler
5014: on some operating systems look like GCC, so that packages that expect GCC
5015: won't require modifications to build with those native compilers.
5016:
5017: This normalizes the environment in which a package is built so that the package
5018: may be built consistently despite what other software may be installed. Please
5019: note that the normal system header and library paths, e.g. /usr/include, /usr/
5020: lib, etc., are always searched -- buildlink3 is designed to insulate the
5021: package build from non-system-supplied software.
5022:
5023: 18.1. Converting packages to use buildlink3
1.1 dsieger 5024:
1.184 rillig 5025: The process of converting packages to use the buildlink3 framework ("bl3ifying"
5026: ) is fairly straightforward. The things to keep in mind are:
1.1 dsieger 5027:
1.184 rillig 5028: 1. Ensure that the build always calls the wrapper scripts instead of the
5029: actual toolchain. Some packages are tricky, and the only way to know for
5030: sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
5031: invoked.
1.1 dsieger 5032:
1.184 rillig 5033: 2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
5034: standalone shells, etc., because the code to symlink files into $
5035: {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
1.1 dsieger 5036:
1.184 rillig 5037: 3. Remember that only the buildlink3.mk files that you list in a package's
5038: Makefile are added as dependencies for that package.
1.1 dsieger 5039:
1.184 rillig 5040: If a dependency on a particular package is required for its libraries and
5041: headers, then we replace:
1.1 dsieger 5042:
1.184 rillig 5043: DEPENDS+= foo>=1.1.0:../../category/foo
1.1 dsieger 5044:
1.184 rillig 5045: with
1.1 dsieger 5046:
1.184 rillig 5047: .include "../../category/foo/buildlink3.mk"
1.1 dsieger 5048:
1.184 rillig 5049: The buildlink3.mk files usually define the required dependencies. If you need a
5050: newer version of the dependency when using buildlink3.mk files, then you can
5051: define it in your Makefile; for example:
1.1 dsieger 5052:
1.184 rillig 5053: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
5054: .include "../../category/foo/buildlink3.mk"
1.1 dsieger 5055:
1.184 rillig 5056: There are several buildlink3.mk files in pkgsrc/mk that handle special package
5057: issues:
1.1 dsieger 5058:
1.184 rillig 5059: * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
5060: implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
1.1 dsieger 5061:
1.184 rillig 5062: * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
5063: this will take care to install the devel/ncurses package.
1.1 dsieger 5064:
1.184 rillig 5065: * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
5066: a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
5067: implementation.
1.1 dsieger 5068:
1.184 rillig 5069: * motif.buildlink3.mk checks for a system-provided Motif installation or adds
5070: a dependency on x11/lesstif or x11/motif. The user can set MOTIF_TYPE to "
5071: dt", "lesstif" or "motif" to choose which Motif version will be used.
1.1 dsieger 5072:
1.184 rillig 5073: * readline.buildlink3.mk checks for a system-provided GNU readline or
5074: editline (libedit) installation, or adds a dependency on devel/readline,
5075: devel/editline. The user can set READLINE_DEFAULT to choose readline
5076: implementation. If your package really needs GNU readline library, its
5077: Makefile should include devel/readline/buildlink3.mk instead of
5078: readline.buildlink3.mk.
1.1 dsieger 5079:
1.184 rillig 5080: * oss.buildlink3.mk defines several variables that may be used by packages
5081: that use the Open Sound System (OSS) API.
1.1 dsieger 5082:
1.184 rillig 5083: * pgsql.buildlink3.mk will accept any of the Postgres versions in the
5084: variable PGSQL_VERSIONS_ACCEPTED and default to the version
5085: PGSQL_VERSION_DEFAULT. See the file for more information.
1.1 dsieger 5086:
1.184 rillig 5087: * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
5088: pthreads or adds a dependency on devel/pth as needed.
1.1 dsieger 5089:
1.184 rillig 5090: * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
5091: widgets library.
1.1 dsieger 5092:
1.184 rillig 5093: The comments in those buildlink3.mk files provide a more complete description
5094: of how to use them properly.
1.1 dsieger 5095:
1.184 rillig 5096: 18.2. Writing buildlink3.mk files
1.1 dsieger 5097:
1.184 rillig 5098: A package's buildlink3.mk file is included by Makefiles to indicate the need to
5099: compile and link against header files and libraries provided by the package. A
5100: buildlink3.mk file should always provide enough information to add the correct
5101: type of dependency relationship and include any other buildlink3.mk files that
5102: it needs to find headers and libraries that it needs in turn.
1.1 dsieger 5103:
1.184 rillig 5104: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
5105: pkgtools/createbuildlink package is highly recommended. For most packages, the
5106: following command will generate a good starting point for buildlink3.mk files:
1.1 dsieger 5107:
1.184 rillig 5108: % cd pkgsrc/category/pkgdir
5109: % createbuildlink >buildlink3.mk
1.1 dsieger 5110:
5111:
1.184 rillig 5112: 18.2.1. Anatomy of a buildlink3.mk file
1.1 dsieger 5113:
1.184 rillig 5114: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
5115: tiff:
1.14 jmcneill 5116:
1.184 rillig 5117: BUILDLINK_TREE+= tiff
1.1 dsieger 5118:
1.184 rillig 5119: .if !defined(TIFF_BUILDLINK3_MK)
5120: TIFF_BUILDLINK3_MK:=
1.1 dsieger 5121:
1.184 rillig 5122: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
5123: BUILDLINK_ABI_DEPENDS.tiff+= tiff>=3.7.2nb1
5124: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
1.1 dsieger 5125:
1.184 rillig 5126: .include "../../devel/zlib/buildlink3.mk"
5127: .include "../../graphics/jpeg/buildlink3.mk"
5128: .endif # TIFF_BUILDLINK3_MK
1.1 dsieger 5129:
1.184 rillig 5130: BUILDLINK_TREE+= -tiff
1.1 dsieger 5131:
1.184 rillig 5132: The header and footer manipulate BUILDLINK_TREE, which is common across all
5133: buildlink3.mk files and is used to track the dependency tree.
1.1 dsieger 5134:
1.184 rillig 5135: The main section is protected from multiple inclusion and controls how the
5136: dependency on pkg is added. Several important variables are set in the section:
1.1 dsieger 5137:
1.185 wiz 5138: * BUILDLINK_API_DEPENDS.pkg is the dependency version recorded in the
1.184 rillig 5139: installed package; this should always be set using += to ensure that we're
5140: appending to any pre-existing list of values. This variable should be set
1.185 wiz 5141: to the last version of the package that had an backwards-incompatible API
1.184 rillig 5142: change.
1.1 dsieger 5143:
1.184 rillig 5144: * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
1.1 dsieger 5145:
1.184 rillig 5146: * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
1.236 gutterid 5147: BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
5148: is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
5149: full dependency is used.
1.1 dsieger 5150:
1.184 rillig 5151: * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
5152: of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
5153: library search paths. These default to "include" and "lib" respectively.
1.1 dsieger 5154:
1.184 rillig 5155: * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
5156: to add to CPPFLAGS, which are passed on to the configure and build phases.
5157: The "-I" option should be avoided and instead be handled using
5158: BUILDLINK_INCDIRS.pkg as above.
1.66 asau 5159:
1.184 rillig 5160: The following variables are all optionally defined within this second section
5161: (protected against multiple inclusion) and control which package files are
5162: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
5163: symlinking:
1.23 jakllsch 5164:
1.184 rillig 5165: * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
5166: {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
5167: *.h.
1.1 dsieger 5168:
1.184 rillig 5169: * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
5170: to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
5171: resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
5172: takes the +CONTENTS of a pkg and filters it through $
5173: {BUILDLINK_CONTENTS_FILTER.pkg}.
1.1 dsieger 5174:
1.184 rillig 5175: * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
5176: filters +CONTENTS input into a list of files relative to $
5177: {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
5178: outputs the contents of the include and lib directories in the package
5179: +CONTENTS.
1.1 dsieger 5180:
1.184 rillig 5181: * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
5182: used to transform the name of the source filename into a destination
5183: filename, e.g. -e "s|/curses.h|/ncurses.h|g".
1.1 dsieger 5184:
1.184 rillig 5185: This section can additionally include any buildlink3.mk needed for pkg's
5186: library dependencies. Including these buildlink3.mk files means that the
5187: headers and libraries for these dependencies are also symlinked into $
5188: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
5189: are only added for directly include buildlink3.mk files.
1.1 dsieger 5190:
1.184 rillig 5191: When providing a buildlink3.mk and including other buildlink3.mk files in it,
5192: please only add necessary ones, i.e., those whose libraries or header files are
5193: automatically exposed when the package is use.
1.1 dsieger 5194:
1.184 rillig 5195: In particular, if only an executable (bin/foo) is linked against a library,
5196: that library does not need to be propagated in the buildlink3.mk file.
1.1 dsieger 5197:
1.184 rillig 5198: The following steps should help you decide if a buildlink3.mk file needs to be
5199: included:
1.1 dsieger 5200:
1.184 rillig 5201: * Look at the installed header files: What headers do they include? The
5202: packages providing these files must be buildlinked.
1.1 dsieger 5203:
1.184 rillig 5204: * Run ldd on all installed libraries and look against what other libraries
5205: they link. Some of the packages providing these probably need to be
5206: buildlinked; however, it's not automatic, since e.g. GTK on some systems
5207: pulls in the X libraries, so they will show up in the ldd output, while on
5208: others (like OS X) it won't. ldd output can thus only be used as a hint.
1.1 dsieger 5209:
1.184 rillig 5210: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
5211: buildlink3.mk files
1.16 jnemeth 5212:
1.185 wiz 5213: Both variables set lower bounds for a version of this package. The two
5214: variables differ in that one describes source compatibility (API) and the other
5215: binary compatibility (ABI). The difference is that a change in the API breaks
5216: compilation of programs while changes in the ABI stop compiled programs from
5217: running.
5218:
5219: The BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk should be changed
5220: very rarely. (One possible scenario: If all packages using this package need a
5221: higher version than defined in the buildlink3.mk, BUILDLINK_API_DEPENDS.pkg
5222: could be updated to that higher version.)
5223:
5224: On the other hand, changes to BUILDLINK_ABI_DEPENDS.pkg are more common. The
5225: variable will need to be updated every time the major version of one of its
5226: shared libraries is changed, or any other change where a binary built against
5227: the previous version of the package will not run against the new version any
5228: longer.
5229:
5230: In such a case, the package's BUILDLINK_ABI_DEPENDS.pkg must be increased to
5231: require the new package version. Then the PKGREVISION of all packages foo that
5232: depend on this package need to be increased, and if they have buildlink3.mk
5233: files, BUILDLINK_ABI_DEPENDS.foo in their buildlink3.mk files must be increased
5234: to the new version as well. This is required so that a package will pull in the
5235: versions of the packages that use the new ABI and that the packages'
5236: PKGREVISIONs uniquely identify the packages built against the new ABI. The
5237: pkgtools/revbump package can help with these updates.
1.1 dsieger 5238:
1.184 rillig 5239: See Section 21.1.5, "Handling dependencies" for more information about
1.185 wiz 5240: dependencies on other packages, including the BUILDLINK_API_DEPENDS
5241: definitions.
1.1 dsieger 5242:
1.184 rillig 5243: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
1.185 wiz 5244: BUILDLINK_ABI_DEPENDS.pkg in a buildlink3.mk file as we don't want to cause
5245: unneeded package deletions and rebuilds. In many cases, new versions of
5246: packages work just fine with older dependencies.
1.1 dsieger 5247:
1.211 gutterid 5248: Also, it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
1.184 rillig 5249: BUILDLINK_API_DEPENDS.pkg.
1.1 dsieger 5250:
1.211 gutterid 5251: Note there is also the distinction that users are able to disable enforcement
5252: of ABI dependencies using the USE_ABI_DEPENDS variable, but there is no
5253: equivalent option for API dependencies.
5254:
1.184 rillig 5255: 18.3. Writing builtin.mk files
1.1 dsieger 5256:
1.184 rillig 5257: Some packages in pkgsrc install headers and libraries that coincide with
5258: headers and libraries present in the base system. Aside from a buildlink3.mk
5259: file, these packages should also include a builtin.mk file that includes the
5260: necessary checks to decide whether using the built-in software or the pkgsrc
5261: software is appropriate.
1.1 dsieger 5262:
1.184 rillig 5263: The only requirements of a builtin.mk file for pkg are:
1.1 dsieger 5264:
1.184 rillig 5265: 1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
1.1 dsieger 5266:
1.184 rillig 5267: 2. It should not override any USE_BUILTIN.pkg which is already set before the
5268: builtin.mk file is included.
1.1 dsieger 5269:
1.184 rillig 5270: 3. It should be written to allow multiple inclusion. This is very important
5271: and takes careful attention to Makefile coding.
1.1 dsieger 5272:
1.184 rillig 5273: 18.3.1. Anatomy of a builtin.mk file
1.1 dsieger 5274:
1.184 rillig 5275: The following is the recommended template for builtin.mk files:
1.1 dsieger 5276:
1.184 rillig 5277: .if !defined(IS_BUILTIN.foo)
5278: #
5279: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
5280: # genuinely exists in the system or not.
5281: #
5282: IS_BUILTIN.foo?= no
1.1 dsieger 5283:
1.184 rillig 5284: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
5285: # version can be determined.
5286: #
5287: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
5288: BUILTIN_PKG.foo?= foo-1.0
5289: . endif
5290: .endif # IS_BUILTIN.foo
1.1 dsieger 5291:
1.184 rillig 5292: .if !defined(USE_BUILTIN.foo)
5293: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
5294: . if defined(BUILTIN_PKG.foo)
5295: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
5296: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
5297: USE_BUILTIN.foo!= \
5298: ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo} \
5299: && ${ECHO} "yes" || ${ECHO} "no"
5300: . endif
5301: . endfor
5302: . endif
5303: .endif # USE_BUILTIN.foo
1.1 dsieger 5304:
1.184 rillig 5305: CHECK_BUILTIN.foo?= no
5306: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
5307: #
5308: # Here we place code that depends on whether USE_BUILTIN.foo is set to
5309: # "yes" or "no".
5310: #
5311: .endif # CHECK_BUILTIN.foo
1.1 dsieger 5312:
1.184 rillig 5313: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
5314: base system. This should not be a base system software with similar
5315: functionality to pkg; it should only be "yes" if the actual package is included
5316: as part of the base system. This variable is only used internally within the
5317: builtin.mk file.
1.1 dsieger 5318:
1.184 rillig 5319: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
5320: system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
5321: internally within the builtin.mk file.
1.1 dsieger 5322:
1.184 rillig 5323: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
5324: The code in this section must make the determination whether the built-in
5325: software is adequate to satisfy the dependencies listed in
5326: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
5327: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg
5328: must be set to the correct value by the end of the builtin.mk file. Note that
5329: USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
5330: the determination that the built-in version of the software is similar enough
5331: to be used as a replacement.
1.1 dsieger 5332:
1.184 rillig 5333: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
5334: the value of USE_BUILTIN.pkg set in the previous section. This typically
5335: includes, e.g., adding additional dependency restrictions and listing
5336: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
1.1 dsieger 5337:
1.184 rillig 5338: Chapter 19. PLIST issues
1.1 dsieger 5339:
1.184 rillig 5340: Table of Contents
1.1 dsieger 5341:
1.184 rillig 5342: 19.1. RCS ID
5343: 19.2. Semi-automatic PLIST generation
5344: 19.3. Tweaking output of make print-PLIST
5345: 19.4. Variable substitution in PLIST
5346: 19.5. Man page compression
5347: 19.6. Changing PLIST source with PLIST_SRC
5348: 19.7. Platform-specific and differing PLISTs
5349: 19.8. Build-specific PLISTs
5350: 19.9. Sharing directories between packages
1.1 dsieger 5351:
1.184 rillig 5352: The PLIST file contains a package's "packing list", i.e. a list of files that
5353: belong to the package (relative to the ${PREFIX} directory it's been installed
5354: in) plus some additional statements - see the pkg_create(1) man page for a full
5355: list. This chapter addresses some issues that need attention when dealing with
5356: the PLIST file (or files, see below!).
1.1 dsieger 5357:
1.184 rillig 5358: 19.1. RCS ID
1.1 dsieger 5359:
1.184 rillig 5360: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
1.1 dsieger 5361:
1.184 rillig 5362: @comment $NetBSD $
1.1 dsieger 5363:
1.184 rillig 5364: An artificial space has been added between NetBSD and $, this is a workaround
5365: here to prevent CVS expanding to the filename of the guide. When adding the RCS
5366: ID the space should be omitted.
1.38 wiz 5367:
1.184 rillig 5368: 19.2. Semi-automatic PLIST generation
1.1 dsieger 5369:
1.184 rillig 5370: You can use the make print-PLIST command to output a PLIST that matches any new
5371: files since the package was extracted. See Section 13.17, "Other helpful
5372: targets" for more information on this target.
1.11 rillig 5373:
1.184 rillig 5374: 19.3. Tweaking output of make print-PLIST
1.1 dsieger 5375:
1.184 rillig 5376: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
5377: used to filter the output of print-PLIST. You can append any chunk of AWK
5378: scripting you like to it, but be careful with quoting.
1.1 dsieger 5379:
1.184 rillig 5380: For example, to get all files inside the libdata/foo directory removed from the
5381: resulting PLIST:
1.1 dsieger 5382:
1.184 rillig 5383: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
1.1 dsieger 5384:
1.185 wiz 5385: The PRINT_PLIST_AWK transformations are evaluated after the file list and
5386: directory list are sorted. EARLY_PRINT_PLIST_AWK is like PRINT_PLIST_AWK except
5387: it operates before the file list and directory list are sorted.
5388:
1.184 rillig 5389: 19.4. Variable substitution in PLIST
1.1 dsieger 5390:
1.184 rillig 5391: A number of variables are substituted automatically in PLISTs when a package is
5392: installed on a system. This includes the following variables:
1.1 dsieger 5393:
1.184 rillig 5394: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
1.1 dsieger 5395:
1.184 rillig 5396: Some packages like emacs and perl embed information about which
5397: architecture they were built on into the pathnames where they install their
5398: files. To handle this case, PLIST will be preprocessed before actually
5399: used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
5400: gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
5401: PLIST somewhere - use this on packages that have GNU autoconf-created
5402: configure scripts.
1.1 dsieger 5403:
1.184 rillig 5404: Legacy note
1.1 dsieger 5405:
1.184 rillig 5406: There used to be a symbol "$ARCH" that was replaced by the output of uname
5407: -m, but that's no longer supported and has been removed.
1.1 dsieger 5408:
1.184 rillig 5409: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
1.1 dsieger 5410:
1.184 rillig 5411: Some packages want to embed the OS name and version into some paths. To do
5412: this, use these variables in the PLIST:
1.1 dsieger 5413:
1.259 leot 5414: + ${OPSYS} - output of "uname -s"
1.1 dsieger 5415:
1.259 leot 5416: + ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
1.1 dsieger 5417:
1.259 leot 5418: + ${OS_VERSION} - "uname -r"
1.1 dsieger 5419:
1.184 rillig 5420: For a list of values which are replaced by default, the output of make help
5421: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
5422: PLIST_SUBST should help.
1.1 dsieger 5423:
1.184 rillig 5424: If you want to change other variables not listed above, you can add variables
5425: and their expansions to this variable in the following way, similar to
5426: MESSAGE_SUBST (see Section 12.5, "Optional files"):
1.1 dsieger 5427:
1.184 rillig 5428: PLIST_SUBST+= SOMEVAR="somevalue"
1.1 dsieger 5429:
1.184 rillig 5430: This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
1.1 dsieger 5431:
1.184 rillig 5432: The PLIST_VARS variable can be used to simplify the common case of
5433: conditionally including some PLIST entries. It can be done by adding
5434: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
5435: entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
5436: either """" or ""@comment "". For example, in Makefile:
1.1 dsieger 5437:
1.184 rillig 5438: PLIST_VARS+= foo
5439: .if condition
5440: PLIST.foo= yes
5441: .else
1.1 dsieger 5442:
1.184 rillig 5443: And then in PLIST:
1.1 dsieger 5444:
1.184 rillig 5445: @comment $NetBSD $
5446: bin/bar
5447: man/man1/bar.1
5448: ${PLIST.foo}bin/foo
5449: ${PLIST.foo}man/man1/foo.1
5450: ${PLIST.foo}share/bar/foo.data
1.1 dsieger 5451:
1.184 rillig 5452: An artificial space has been added between NetBSD and $, this is a workaround
5453: here to prevent CVS expanding to the filename of the guide. When adding the RCS
1.195 gutterid 5454: ID the space should be omitted.
1.1 dsieger 5455:
1.184 rillig 5456: 19.5. Man page compression
1.1 dsieger 5457:
1.184 rillig 5458: Man pages should be installed in compressed form if MANZ is set (in
5459: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
5460: suffix ".gz" is appended/removed automatically for man pages according to MANZ
5461: and MANCOMPRESSED being set or not, see above for details. This modification of
5462: the PLIST file is done on a copy of it, not PLIST itself.
1.100 leot 5463:
1.184 rillig 5464: 19.6. Changing PLIST source with PLIST_SRC
1.100 leot 5465:
1.184 rillig 5466: To use one or more files as source for the PLIST used in generating the binary
5467: package, set the variable PLIST_SRC to the names of that file(s). The files are
5468: later concatenated using cat(1), and the order of things is important. The
5469: default for PLIST_SRC is ${PKGDIR}/PLIST.
1.1 dsieger 5470:
1.184 rillig 5471: 19.7. Platform-specific and differing PLISTs
1.1 dsieger 5472:
1.184 rillig 5473: Some packages decide to install a different set of files based on the operating
5474: system being used. These differences can be automatically handled by using the
5475: following files:
1.1 dsieger 5476:
1.184 rillig 5477: * PLIST.common
1.1 dsieger 5478:
1.184 rillig 5479: * PLIST.${OPSYS}
1.1 dsieger 5480:
1.184 rillig 5481: * PLIST.${MACHINE_ARCH}
1.1 dsieger 5482:
1.184 rillig 5483: * PLIST.${OPSYS}-${MACHINE_ARCH}
1.1 dsieger 5484:
1.184 rillig 5485: * PLIST.common_end
1.1 dsieger 5486:
1.184 rillig 5487: 19.8. Build-specific PLISTs
1.1 dsieger 5488:
1.184 rillig 5489: Some packages decide to generate hard-to-guess file names during installation
5490: that are hard to wire down.
1.1 dsieger 5491:
1.184 rillig 5492: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
5493: (with a semicolon) that will output PLIST entries which will be appended to the
5494: PLIST
1.1 dsieger 5495:
1.184 rillig 5496: You can find one example in editors/xemacs:
1.1 dsieger 5497:
1.184 rillig 5498: GENERATE_PLIST+= ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.1 dsieger 5499:
1.184 rillig 5500: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
1.1 dsieger 5501:
1.184 rillig 5502: 19.9. Sharing directories between packages
1.1 dsieger 5503:
1.184 rillig 5504: A "shared directory" is a directory where multiple (and unrelated) packages
5505: install files. These directories were problematic because you had to add
5506: special tricks in the PLIST to conditionally remove them, or have some
5507: centralized package handle them.
1.106 tnn 5508:
1.184 rillig 5509: In pkgsrc, it is now easy: Each package should create directories and install
5510: files as needed; pkg_delete will remove any directories left empty after
5511: uninstalling a package.
1.106 tnn 5512:
1.184 rillig 5513: If a package needs an empty directory to work, create the directory during
5514: installation as usual, and also add an entry to the PLIST:
1.1 dsieger 5515:
1.184 rillig 5516: @pkgdir path/to/empty/directory
1.1 dsieger 5517:
1.184 rillig 5518: or take a look at MAKE_DIRS and OWN_DIRS.
1.1 dsieger 5519:
1.184 rillig 5520: Chapter 20. The pkginstall framework
1.1 dsieger 5521:
1.184 rillig 5522: Table of Contents
1.1 dsieger 5523:
1.184 rillig 5524: 20.1. Files and directories outside the installation prefix
5525: 20.1.1. Directory manipulation
5526: 20.1.2. File manipulation
5527: 20.2. Configuration files
5528: 20.2.1. How PKG_SYSCONFDIR is set
5529: 20.2.2. Telling the software where configuration files are
1.239 dholland 5530: 20.2.3. Patching installation
5531: 20.2.4. Declaring configuration files
5532: 20.2.5. Disabling handling of configuration files
1.184 rillig 5533: 20.3. System startup scripts
5534: 20.3.1. Disabling handling of system startup scripts
5535: 20.4. System users and groups
5536: 20.5. System shells
5537: 20.5.1. Disabling shell registration
5538: 20.6. Fonts
5539: 20.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 5540:
1.184 rillig 5541: This chapter describes the framework known as pkginstall, whose key features
5542: are:
1.1 dsieger 5543:
1.184 rillig 5544: * Generic installation and manipulation of directories and files outside the
5545: pkgsrc-handled tree, LOCALBASE.
1.1 dsieger 5546:
1.184 rillig 5547: * Automatic handling of configuration files during installation, provided
5548: that packages are correctly designed.
1.1 dsieger 5549:
1.184 rillig 5550: * Generation and installation of system startup scripts.
1.1 dsieger 5551:
1.184 rillig 5552: * Registration of system users and groups.
1.1 dsieger 5553:
1.184 rillig 5554: * Registration of system shells.
1.1 dsieger 5555:
1.184 rillig 5556: * Automatic updating of fonts databases.
1.1 dsieger 5557:
1.184 rillig 5558: The following sections inspect each of the above points in detail.
1.1 dsieger 5559:
1.184 rillig 5560: You may be thinking that many of the things described here could be easily done
5561: with simple code in the package's post-installation target (post-install). This
5562: is incorrect, as the code in them is only executed when building from source.
5563: Machines using binary packages could not benefit from it at all (as the code
5564: itself could be unavailable). Therefore, the only way to achieve any of the
5565: items described above is by means of the installation scripts, which are
5566: automatically generated by pkginstall.
1.1 dsieger 5567:
1.184 rillig 5568: 20.1. Files and directories outside the installation prefix
1.95 wiz 5569:
1.184 rillig 5570: As you already know, the PLIST file holds a list of files and directories that
5571: belong to a package. The names used in it are relative to the installation
5572: prefix (${PREFIX}), which means that it cannot register files outside this
5573: directory (absolute path names are not allowed). Despite this restriction, some
5574: packages need to install files outside this location; e.g., under ${VARBASE} or
5575: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
5576: installation time by using installation scripts.
1.95 wiz 5577:
1.184 rillig 5578: The generic installation scripts are shell scripts that can contain arbitrary
5579: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
5580: which defaults to INSTALL. A similar variable exists for package removal
5581: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
5582: commands, so they have the potential to create and manage files anywhere in the
5583: file system.
1.95 wiz 5584:
1.184 rillig 5585: Using these general installation files is not recommended, but may be needed in
5586: some special cases. One reason for avoiding them is that the user has to trust
5587: the packager that there is no unwanted or simply erroneous code included in the
5588: installation script. Also, previously there were many similar scripts for the
5589: same functionality, and fixing a common error involved finding and changing all
5590: of them.
1.95 wiz 5591:
1.184 rillig 5592: The pkginstall framework offers another, standardized way. It provides generic
5593: scripts to abstract the manipulation of such files and directories based on
5594: variables set in the package's Makefile. The rest of this section describes
5595: these variables.
1.1 dsieger 5596:
1.184 rillig 5597: 20.1.1. Directory manipulation
1.1 dsieger 5598:
1.184 rillig 5599: The following variables can be set to request the creation of directories
5600: anywhere in the file system:
1.1 dsieger 5601:
1.184 rillig 5602: * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
5603: and should attempt to be destroyed by the installation scripts. The
5604: difference between the two is that the latter prompts the administrator to
5605: remove any directories that may be left after deinstallation (because they
5606: were not empty), while the former does not. Example:
1.1 dsieger 5607:
1.184 rillig 5608: MAKE_DIRS+= ${VARBASE}/foo/private
1.1 dsieger 5609:
1.184 rillig 5610: * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
5611: which directories should be created and should attempt to be destroyed by
5612: the installation scripts. Each tuple holds the following values, separated
5613: by spaces: the directory name, its owner, its group and its numerical mode.
5614: For example:
1.1 dsieger 5615:
1.184 rillig 5616: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private \
5617: ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1 dsieger 5618:
1.184 rillig 5619: The difference between the two is exactly the same as their non-PERMS
5620: counterparts.
1.1 dsieger 5621:
1.184 rillig 5622: 20.1.2. File manipulation
1.1 dsieger 5623:
1.184 rillig 5624: Creating non-empty files outside the installation prefix is tricky because the
5625: PLIST forces all files to be inside it. To overcome this problem, the only
1.239 dholland 5626: solution is to extract the file in a known place (i.e., inside the installation
5627: prefix) and copy it to the appropriate location during installation (done by
5628: the installation scripts generated by pkginstall). We will call the former the
5629: reference file in the following paragraphs, which describe the variables that
5630: can be used to automatically and consistently handle files outside the
5631: installation prefix:
5632:
5633: * REQD_FILES is a list of pairs of reference and target files. At
5634: installation time, the reference file is copied to the target if and only
5635: if the latter does not exist. Upon deinstallation, the reference file is
1.184 rillig 5636: removed provided that it was not modified by the installation.
1.1 dsieger 5637:
1.239 dholland 5638: * REQD_FILES_PERMS contains tuples describing reference files and targets,
5639: including owner, group, and numeric permissions that should be set. For
5640: example:
1.1 dsieger 5641:
1.184 rillig 5642: REQD_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile \
5643: ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1 dsieger 5644:
1.239 dholland 5645: * CONF_FILES and CONF_FILES_PERMS have the same syntax as REQD_FILES and
5646: REQD_FILES_PERMS respectively. The difference is that these variables are
5647: specifically intended for handling configuration files, for which
5648: additional conventions and constraints apply. See Section 20.2,
5649: "Configuration files" for further discussion. Note in particular that while
5650: handling of configuration files can be disabled by the user (see
5651: Section 20.2.5, "Disabling handling of configuration files"), this setting
5652: does not affect REQD_FILES and REQD_FILES_PERMS.
5653:
5654: To install an empty file, one can use these macros and /dev/null as the
5655: reference file.
1.1 dsieger 5656:
1.184 rillig 5657: 20.2. Configuration files
1.1 dsieger 5658:
1.239 dholland 5659: There are two principles that govern the handling of configuration files in
5660: pkgsrc: first, the user's configuration must not be lost or overwritten by
5661: upgrades or reinstallations; and second, the default configuration should
5662: always be available for reference. To that end, pkgsrc has a framework
5663: specifically for handling configuration files. In general, configuration files
5664: are installed into ${PREFIX}/share/examples, and copied from there to the
5665: pertinent etc directory as a separate step and only as needed.
5666:
5667: To make this work, there are three things that need to happen, any of which may
5668: require patching. First, the package must be told to read its configuration
5669: from the correct place at runtime; this place is ${PKG_SYSCONFDIR} (or possibly
5670: a subdirectory of it) which is often but not always ${PREFIX}/etc. Second, the
5671: package must be taught to install its default configuration files in ${PREFIX}/
5672: share/examples/${PKGBASE}; this is the point at which patching often becomes
5673: required because it is not the same place as the runtime location. Third, the
5674: configuration files need to be declared in the package makefile; this is the
5675: easy part.
5676:
5677: With those elements in place, the right things will happen: the package install
5678: phase and resulting binary package will not touch ${PKG_SYSCONFDIR}, and the
5679: default configuration will be copied into place by the pkgsrc framework only if
5680: not already present. Similarly, upon deinstall the configuration will not be
5681: removed if it has been modified. (This means that in the case of reinstallation
5682: and upgrades, unmodified configuration files are updated but modifications are
5683: never discarded.)
5684:
5685: The following sections describe how to make these things happen and document
5686: other relevant knobs available in the pkgsrc infrastructure.
1.1 dsieger 5687:
1.184 rillig 5688: 20.2.1. How PKG_SYSCONFDIR is set
1.1 dsieger 5689:
1.184 rillig 5690: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
5691: shall be installed. Its contents are set based upon the following variables:
1.1 dsieger 5692:
1.184 rillig 5693: * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
1.239 dholland 5694: etc although it may be overridden by the user to point to their preferred
1.184 rillig 5695: location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
1.1 dsieger 5696:
1.184 rillig 5697: * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
5698: configuration files for the package being built shall be installed. The
5699: definition of this variable only makes sense in the package's Makefile
5700: (i.e., it is not user-customizable).
1.1 dsieger 5701:
1.184 rillig 5702: As an example, consider the Apache package, www/apache24, which places its
5703: configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
5704: should be set in the package Makefile.
1.1 dsieger 5705:
1.184 rillig 5706: * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
5707: package's configuration directory (if different from PKG_SYSCONFBASE). It
5708: defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
1.1 dsieger 5709:
1.184 rillig 5710: * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
5711: configuration files for the package identified by PKG_SYSCONFVAR's shall be
5712: placed.
1.1 dsieger 5713:
1.184 rillig 5714: Based on the above variables, pkginstall determines the value of
1.239 dholland 5715: PKG_SYSCONFDIR, which is the only variable that may be used within a package to
1.184 rillig 5716: refer to its configuration directory. The algorithm used to set its value is
5717: basically the following:
1.1 dsieger 5718:
1.184 rillig 5719: 1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
1.1 dsieger 5720:
1.184 rillig 5721: 2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
5722: package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
5723: {PKG_SYSCONFSUBDIR}.
1.1 dsieger 5724:
1.184 rillig 5725: 3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
1.1 dsieger 5726:
1.184 rillig 5727: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
1.239 dholland 5728: OWN_DIRS. This causes it to be automatically created if needed. See
5729: Section 20.1.1, "Directory manipulation" for further details. This does not
5730: apply to subdirectories of ${PKG_SYSCONFDIR}; they must be manually created
5731: with OWN_DIRS or MAKE_DIRS.
1.1 dsieger 5732:
1.184 rillig 5733: 20.2.2. Telling the software where configuration files are
1.1 dsieger 5734:
1.184 rillig 5735: Given that pkgsrc (and users!) expect configuration files to be in a known
1.239 dholland 5736: place, you need to teach each package where to install its files. In some cases
5737: you will have to patch the package Makefiles to achieve it. If you are lucky,
5738: though, it may be as easy as passing an extra flag to the configuration script.
5739: This is the case for packages using GNU autoconf:
1.1 dsieger 5740:
1.184 rillig 5741: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1 dsieger 5742:
1.184 rillig 5743: Note that this specifies where the package has to look for its configuration
1.239 dholland 5744: files, not where they will be installed. Fortunately, there is a different way
1.240 gutterid 5745: to specify the latter, as seen in the next section, although the combination is
5746: rather confusing at first glance.
1.1 dsieger 5747:
1.239 dholland 5748: 20.2.3. Patching installation
1.1 dsieger 5749:
1.239 dholland 5750: As discussed above, packages themselves must not touch the contents of $
1.184 rillig 5751: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
5752: will, out of the box, mess with the contents of that directory. So what is the
5753: correct procedure to fix this issue?
1.1 dsieger 5754:
1.184 rillig 5755: You must teach the package (usually by manually patching it) to install any
5756: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
5757: This way, the PLIST registers them and the administrator always has the
5758: original copies available.
1.1 dsieger 5759:
1.239 dholland 5760: It turns out that for packages using GNU autoconf it is possible to create the
5761: desired effect by setting sysconfdir on the make command line at install time.
5762: Consider this example taken from mail/mutt:
5763:
5764: EGDIR= ${PREFIX}/share/examples/mutt
5765: INSTALL_MAKE_FLAGS= ${MAKE_FLAGS} sysconfdir=${EGDIR}
5766:
5767: Note that the EGDIR variable, though commonly used for this purpose, is local
5768: to that package and has no meaning outside it.
1.1 dsieger 5769:
1.239 dholland 5770: 20.2.4. Declaring configuration files
1.1 dsieger 5771:
1.239 dholland 5772: Once the required configuration files are in place (i.e., under the examples
5773: hierarchy), the pkginstall framework can use them as reference copies during
5774: the package installation to update what is in ${PKG_SYSCONFDIR}. To achieve
5775: this, the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
5776: Section 20.1.2, "File manipulation" for further information about their syntax
5777: and their purpose. Here is an example, taken from the mail/mutt package:
5778:
5779: EGDIR= ${PREFIX}/share/examples/mutt
5780: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
5781:
5782: Note that (as in the previous section's example) the EGDIR variable is specific
5783: to the package and has no meaning outside it.
5784:
5785: For reference, the complete example from Mutt is as follows:
5786:
5787: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
5788: EGDIR= ${PREFIX}/share/examples/mutt
5789: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
5790: INSTALLATION_DIRS+= ${EGDIR}
5791: INSTALL_MAKE_FLAGS= ${MAKE_FLAGS} sysconfdir=${EGDIR}
1.1 dsieger 5792:
1.239 dholland 5793: 20.2.5. Disabling handling of configuration files
1.1 dsieger 5794:
1.184 rillig 5795: The automatic copying of config files can be toggled by setting the environment
5796: variable PKG_CONFIG prior to package installation.
1.1 dsieger 5797:
1.184 rillig 5798: 20.3. System startup scripts
1.1 dsieger 5799:
1.184 rillig 5800: System startup scripts are special files because they must be installed in a
5801: place known by the underlying OS, usually outside the installation prefix.
5802: Therefore, the same rules described in Section 20.1, "Files and directories
5803: outside the installation prefix" apply, and the same solutions can be used.
5804: However, pkginstall provides a special mechanism to handle these files.
1.1 dsieger 5805:
1.184 rillig 5806: In order to provide system startup scripts, the package has to:
1.1 dsieger 5807:
1.184 rillig 5808: 1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
1.223 nia 5809: Considering the print/cups-base package as an example, it has a cupsd.sh in
5810: its files directory.
1.95 wiz 5811:
1.184 rillig 5812: 2. Tell pkginstall to handle it, appending the name of the script, without its
5813: extension, to the RCD_SCRIPTS variable. Continuing the previous example:
1.95 wiz 5814:
1.184 rillig 5815: RCD_SCRIPTS+= cupsd
1.95 wiz 5816:
1.184 rillig 5817: Once this is done, pkginstall will do the following steps for each script in an
5818: automated fashion:
1.95 wiz 5819:
1.184 rillig 5820: 1. Process the file found in the files directory applying all the
5821: substitutions described in the FILES_SUBST variable.
1.1 dsieger 5822:
1.184 rillig 5823: 2. Copy the script from the files directory to the examples hierarchy, $
1.239 dholland 5824: {PREFIX}/share/examples/rc.d/. Note that this reference file must be
1.184 rillig 5825: explicitly registered in the PLIST.
1.1 dsieger 5826:
1.184 rillig 5827: 3. Add code to the installation scripts to copy the startup script from the
5828: examples hierarchy into the system-wide startup scripts directory.
1.1 dsieger 5829:
1.184 rillig 5830: 20.3.1. Disabling handling of system startup scripts
1.1 dsieger 5831:
1.184 rillig 5832: The automatic copying of config files can be toggled by setting the environment
5833: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
5834: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
5835: rc.d/, no matter what the value of this variable is.
1.1 dsieger 5836:
1.184 rillig 5837: 20.4. System users and groups
1.1 dsieger 5838:
1.184 rillig 5839: If a package needs to create special users and/or groups during installation,
5840: it can do so by using the pkginstall framework.
1.1 dsieger 5841:
1.184 rillig 5842: Users can be created by adding entries to the PKG_USERS variable. Each entry
5843: has the following syntax:
1.1 dsieger 5844:
1.184 rillig 5845: user:group
1.1 dsieger 5846:
1.184 rillig 5847: Further specification of user details may be done by setting per-user
5848: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
5849: user's description or comment. PKG_HOME.user is the user's home directory, and
5850: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
5851: and defaults to /sbin/nologin if not specified.
1.1 dsieger 5852:
1.184 rillig 5853: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
5854: whose syntax is:
1.1 dsieger 5855:
1.184 rillig 5856: group
1.1 dsieger 5857:
1.184 rillig 5858: The numeric GID of the group may be set by defining PKG_GID.group.
1.1 dsieger 5859:
1.184 rillig 5860: If a package needs to create the users and groups at an earlier stage, then it
5861: can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
5862: the phase before which the users and groups are created. In this case, the
5863: numeric UIDs and GIDs of the created users and groups are automatically
5864: hardcoded into the final installation scripts.
1.1 dsieger 5865:
1.184 rillig 5866: 20.5. System shells
1.1 dsieger 5867:
1.184 rillig 5868: Packages that install system shells should register them in the shell database,
5869: /etc/shells, to make things easier to the administrator. This must be done from
5870: the installation scripts to keep binary packages working on any system.
5871: pkginstall provides an easy way to accomplish this task.
1.1 dsieger 5872:
1.184 rillig 5873: When a package provides a shell interpreter, it has to set the PKG_SHELL
5874: variable to its absolute file name. This will add some hooks to the
5875: installation scripts to handle it. Consider the following example, taken from
5876: shells/zsh:
1.1 dsieger 5877:
1.184 rillig 5878: PKG_SHELL= ${PREFIX}/bin/zsh
1.1 dsieger 5879:
1.184 rillig 5880: 20.5.1. Disabling shell registration
1.1 dsieger 5881:
1.184 rillig 5882: The automatic registration of shell interpreters can be disabled by the
5883: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
1.1 dsieger 5884:
1.184 rillig 5885: 20.6. Fonts
1.1 dsieger 5886:
1.184 rillig 5887: Packages that install X11 fonts should update the database files that index the
5888: fonts within each fonts directory. This can easily be accomplished within the
5889: pkginstall framework.
1.1 dsieger 5890:
1.184 rillig 5891: When a package installs X11 fonts, it must list the directories in which fonts
5892: are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
5893: "type1" or "x11". This will add hooks to the installation scripts to run the
5894: appropriate commands to update the fonts database files within each of those
5895: directories. For convenience, if the directory path is relative, it is taken to
5896: be relative to the package's installation prefix. Consider the following
5897: example, taken from fonts/dbz-ttf:
1.1 dsieger 5898:
1.184 rillig 5899: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1 dsieger 5900:
1.184 rillig 5901: 20.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 5902:
1.184 rillig 5903: The automatic update of fonts databases can be disabled by the administrator by
5904: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
1.1 dsieger 5905:
1.154 rillig 5906: Chapter 21. Making your package work
1.1 dsieger 5907:
5908: Table of Contents
5909:
1.154 rillig 5910: 21.1. General operation
5911: 21.1.1. How to pull in user-settable variables from mk.conf
5912: 21.1.2. User interaction
5913: 21.1.3. Handling licenses
5914: 21.1.4. Restricted packages
5915: 21.1.5. Handling dependencies
5916: 21.1.6. Handling conflicts with other packages
5917: 21.1.7. Packages that cannot or should not be built
5918: 21.1.8. Packages which should not be deleted, once installed
5919: 21.1.9. Handling packages with security problems
5920: 21.1.10. How to handle incrementing versions when fixing an existing
1.259 leot 5921: package
1.154 rillig 5922: 21.1.11. Substituting variable text in the package files (the SUBST
1.259 leot 5923: framework)
1.154 rillig 5924: 21.2. The fetch phase
5925: 21.2.1. Packages whose distfiles aren't available for plain downloading
5926: 21.2.2. How to handle modified distfiles with the 'old' name
5927: 21.2.3. Packages hosted on github.com
5928: 21.3. The configure phase
5929: 21.3.1. Shared libraries - libtool
5930: 21.3.2. Using libtool on GNU packages that already support libtool
5931: 21.3.3. GNU Autoconf/Automake
1.223 nia 5932: 21.3.4. Meson / ninja
1.260 wiz 5933: 21.3.5. Determining the endianness
1.154 rillig 5934: 21.4. Programming languages
5935: 21.4.1. C, C++, and Fortran
5936: 21.4.2. Java
1.205 wiz 5937: 21.4.3. Go
1.223 nia 5938: 21.4.4. Rust
5939: 21.4.5. Packages containing Perl scripts
5940: 21.4.6. Packages containing shell scripts
5941: 21.4.7. Other programming languages
1.154 rillig 5942: 21.5. The build phase
5943: 21.5.1. Compiling C and C++ code conditionally
5944: 21.5.2. How to handle compiler bugs
1.172 rillig 5945: 21.5.3. No such file or directory
5946: 21.5.4. Undefined reference to "..."
5947: 21.5.5. Running out of memory
1.154 rillig 5948: 21.6. The install phase
5949: 21.6.1. Creating needed directories
5950: 21.6.2. Where to install documentation
5951: 21.6.3. Installing highscore files
5952: 21.6.4. Adding DESTDIR support to packages
5953: 21.6.5. Packages with hardcoded paths to other interpreters
1.203 nia 5954: 21.6.6. Packages installing Perl modules
1.254 wiz 5955: 21.6.7. Packages installing pkg-config files
5956: 21.6.8. Packages installing info files
5957: 21.6.9. Packages installing man pages
5958: 21.6.10. Packages installing X11 fonts
5959: 21.6.11. Packages installing SGML or XML data
5960: 21.6.12. Packages installing extensions to the MIME database
5961: 21.6.13. Packages using intltool
5962: 21.6.14. Packages installing startup scripts
5963: 21.6.15. Packages installing TeX modules
5964: 21.6.16. Packages supporting running binaries in emulation
5965: 21.6.17. Packages installing hicolor icons
5966: 21.6.18. Packages installing desktop files
1.154 rillig 5967: 21.7. Marking packages as having problems
1.1 dsieger 5968:
1.154 rillig 5969: 21.1. General operation
1.1 dsieger 5970:
5971: One appealing feature of pkgsrc is that it runs on many different platforms. As
5972: a result, it is important to ensure, where possible, that packages in pkgsrc
5973: are portable. This chapter mentions some particular details you should pay
5974: attention to while working on pkgsrc.
5975:
1.154 rillig 5976: 21.1.1. How to pull in user-settable variables from mk.conf
1.1 dsieger 5977:
5978: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4 rillig 5979: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
5980: those variables in the preprocessor directives of make(1) (for example .if or
5981: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
5982: loads the user preferences.
1.1 dsieger 5983:
5984: But note that some variables may not be completely defined after ../../mk/
5985: bsd.prefs.mk has been included, as they may contain references to variables
1.108 rillig 5986: that are not yet defined. In shell commands (the lines in Makefile that are
5987: indented with a tab) this is no problem, since variables are only expanded when
5988: they are used. But in the preprocessor directives mentioned above and in
5989: dependency lines (of the form target: dependencies) the variables are expanded
5990: at load time.
1.1 dsieger 5991:
5992: Note
5993:
1.108 rillig 5994: To check whether a variable can be used at load time, run pkglint -Wall on your
5995: package.
1.1 dsieger 5996:
1.154 rillig 5997: 21.1.2. User interaction
1.1 dsieger 5998:
5999: Occasionally, packages require interaction from the user, and this can be in a
6000: number of ways:
6001:
6002: * When fetching the distfiles, some packages require user interaction such as
6003: entering username/password or accepting a license on a web page.
6004:
6005: * When extracting the distfiles, some packages may ask for passwords.
6006:
6007: * help to configure the package before it is built
6008:
6009: * help during the build process
6010:
6011: * help during the installation of a package
6012:
1.108 rillig 6013: A package can set the INTERACTIVE_STAGE variable to define which stages need
6014: interaction. This should be done in the package's Makefile, e.g.:
1.1 dsieger 6015:
6016: INTERACTIVE_STAGE= configure install
6017:
6018: The user can then decide to skip this package by setting the BATCH variable.
1.108 rillig 6019: Packages that require interaction are also excluded from bulk builds.
1.1 dsieger 6020:
1.154 rillig 6021: 21.1.3. Handling licenses
1.1 dsieger 6022:
6023: Authors of software can choose the licence under which software can be copied.
1.111 sevan 6024: The Free Software Foundation has declared some licenses "Free", and the Open
6025: Source Initiative has a definition of "Open Source".
6026:
6027: By default, pkgsrc allows packages with Free or Open Source licenses to be
6028: built. To allow packages with other licenses to be built as well, the pkgsrc
6029: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
6030: . Note that this variable only affects which packages may be built, while the
6031: license terms often also restrict the actual use of the package and its
6032: redistribution.
1.1 dsieger 6033:
6034: One might want to only install packages with a BSD license, or the GPL, and not
1.20 jnemeth 6035: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111 sevan 6036: variable. The pkgsrc user can override the default by setting the
6037: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
6038: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
6039: pkgsrc/mk/license.mk.
1.1 dsieger 6040:
6041: The license tag mechanism is intended to address copyright-related issues
6042: surrounding building, installing and using a package, and not to address
1.20 jnemeth 6043: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
6044: redistribution restrictions should set these tags.
1.1 dsieger 6045:
6046: Denoting that a package may be copied according to a particular license is done
6047: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
6048: string identifying the license, e.g. in graphics/xv:
6049:
6050: LICENSE= xv-license
6051:
6052: When trying to build, the user will get a notice that the package is covered by
6053: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
6054:
6055: % make
6056: ===> xv-3.10anb9 has an unacceptable license: xv-license.
6057: ===> To view the license, enter "/usr/bin/make show-license".
6058: ===> To indicate acceptance, add this line to your /etc/mk.conf:
6059: ===> ACCEPTABLE_LICENSES+=xv-license
6060: *** Error code 1
6061:
1.260 wiz 6062: In case a package requires multiple licenses, you can add all of them to the
6063: LICENSE variable, connected with the upper-case keyword AND. If the user has a
6064: choice between multiple licenses, you can add them connected with the
6065: upper-case keyword OR, for example:
6066:
6067: LICENSE= isc AND apache-2.0
6068: LICENSE= 2-clause-bsd OR ruby-license
6069:
1.1 dsieger 6070: The license can be viewed with make show-license, and if the user so chooses,
1.4 rillig 6071: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1 dsieger 6072: should not in the future fail because of that license:
6073:
6074: ACCEPTABLE_LICENSES+=xv-license
6075:
1.111 sevan 6076: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
6077: is deprecated because it does not crisply refer to a particular license text.
6078: Another problem with such usage is that it does not enable a user to tell
6079: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
6080: for all packages with that tag.
6081:
1.154 rillig 6082: 21.1.3.1. Adding a package with a new license
1.1 dsieger 6083:
1.49 rodent 6084: When adding a package with a new license, the following steps are required:
6085:
1.111 sevan 6086: 1. Check whether the license qualifies as Free or Open Source by referencing
6087: Various Licenses and Comments about Them and Licenses by Name | Open Source
6088: Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
6089: need the -license suffix, and the license name should be added to:
1.49 rodent 6090:
6091: + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
6092:
6093: + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
6094: license.c
6095:
6096: 2. The license text should be added to pkgsrc/licenses for displaying. A list
6097: of known licenses can be seen in this directory.
1.1 dsieger 6098:
1.154 rillig 6099: 21.1.3.2. Change to the license
1.1 dsieger 6100:
1.111 sevan 6101: When the license changes (in a way other than formatting), make sure that the
6102: new license has a different name (e.g., append the version number if it exists,
6103: or the date). Just because a user told pkgsrc to build programs under a
6104: previous version of a license does not mean that pkgsrc should build programs
6105: under the new licenses. The higher-level point is that pkgsrc does not evaluate
6106: licenses for reasonableness; the only test is a mechanistic test of whether a
6107: particular text has been approved by either of two bodies (FSF or OSI).
1.1 dsieger 6108:
1.154 rillig 6109: 21.1.4. Restricted packages
1.1 dsieger 6110:
1.111 sevan 6111: Some licenses restrict how software may be re-distributed. By declaring the
6112: restrictions, package tools can automatically refrain from e.g. placing binary
6113: packages on FTP sites.
6114:
6115: There are four possible restrictions, which are the cross product of sources
6116: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
6117: this is rarely the exact language in any license, and because non-Free licenses
6118: tend to be different from each other, pkgsrc adopts a definition of FTP and
6119: CD-ROM. "FTP" means making the source or binary file available over the
6120: Internet at no charge. "CD-ROM" means making the source or binary available on
6121: some kind of media, together with other source and binary packages, which is
6122: sold for a distribution charge.
1.1 dsieger 6123:
6124: In order to encode these restrictions, the package system defines five make
6125: variables that can be set to note these restrictions:
6126:
6127: * RESTRICTED
6128:
6129: This variable should be set whenever a restriction exists (regardless of
6130: its kind). Set this variable to a string containing the reason for the
6131: restriction. It should be understood that those wanting to understand the
6132: restriction will have to read the license, and perhaps seek advice of
6133: counsel.
6134:
6135: * NO_BIN_ON_CDROM
6136:
6137: Binaries may not be placed on CD-ROM containing other binary packages, for
6138: which a distribution charge may be made. In this case, set this variable to
6139: ${RESTRICTED}.
6140:
6141: * NO_BIN_ON_FTP
6142:
6143: Binaries may not made available on the Internet without charge. In this
6144: case, set this variable to ${RESTRICTED}. If this variable is set, binary
6145: packages will not be included on ftp.NetBSD.org.
6146:
6147: * NO_SRC_ON_CDROM
6148:
6149: Distfiles may not be placed on CD-ROM, together with other distfiles, for
6150: which a fee may be charged. In this case, set this variable to $
6151: {RESTRICTED}.
6152:
6153: * NO_SRC_ON_FTP
6154:
6155: Distfiles may not made available via FTP at no charge. In this case, set
6156: this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
6157: will not be mirrored on ftp.NetBSD.org.
6158:
1.111 sevan 6159: Please note that packages will be removed from pkgsrc when the distfiles are
1.33 wiz 6160: not distributable and cannot be obtained for a period of one full quarter
1.111 sevan 6161: branch. Packages with manual/interactive fetch must have a maintainer and it is
6162: his/her responsibility to ensure this.
1.33 wiz 6163:
1.154 rillig 6164: 21.1.5. Handling dependencies
1.1 dsieger 6165:
1.175 gutterid 6166: Your package may depend on some other package being present, and there are
6167: various ways of expressing this dependency. pkgsrc supports the DEPENDS,
6168: BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS definitions, the USE_TOOLS
6169: definition, as well as dependencies via buildlink3.mk, which is the preferred
6170: way to handle dependencies, and which uses the variables named above. See
1.184 rillig 6171: Chapter 18, Buildlink methodology for more information.
1.175 gutterid 6172:
6173: The basic difference is that the DEPENDS definition registers that
6174: pre-requisite in the binary package so it will be pulled in when the binary
6175: package is later installed, whilst the BUILD_DEPENDS, TOOL_DEPENDS, and
6176: TEST_DEPENDS definitions do not, marking a dependency that is only needed for
1.184 rillig 6177: building or testing the resulting package. See also Chapter 14, Creating a new
1.175 gutterid 6178: pkgsrc package from scratch for more information.
6179:
6180: This means that if you only need a package present whilst you are building or
6181: testing, it should be noted as a TOOL_DEPENDS, BUILD_DEPENDS, or TEST_DEPENDS.
6182: When cross-compiling, TOOL_DEPENDS are native packages, i.e. packages for the
6183: architecture where the package is built; BUILD_DEPENDS are target packages,
6184: i.e., packages for the architecture for which the package is built.
1.1 dsieger 6185:
1.175 gutterid 6186: The format for a DEPENDS, BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS
6187: definition is:
1.1 dsieger 6188:
6189: <pre-req-package-name>:../../<category>/<pre-req-package>
6190:
6191: Please note that the "pre-req-package-name" may include any of the wildcard
6192: version numbers recognized by pkg_info(1).
6193:
1.55 wiz 6194: 1. If your package needs another package's binaries or libraries to build and
1.1 dsieger 6195: run, and if that package has a buildlink3.mk file available, use it:
6196:
6197: .include "../../graphics/jpeg/buildlink3.mk"
6198:
1.55 wiz 6199: 2. If your package needs another package's binaries or libraries only for
6200: building, and if that package has a buildlink3.mk file available, use it:
6201:
6202: .include "../../graphics/jpeg/buildlink3.mk"
6203:
6204: but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
6205: This case is rather rare.
6206:
6207: 3. If your package needs binaries from another package to build, use the
1.156 leot 6208: TOOL_DEPENDS definition:
6209:
6210: TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool
1.1 dsieger 6211:
1.156 leot 6212: 4. If your package needs static libraries to link against, header files to
6213: include, etc. from another package to build, use the BUILD_DEPENDS
6214: definition.
1.1 dsieger 6215:
1.156 leot 6216: 5. If your package needs a library with which to link and there is no
1.26 spz 6217: buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
6218: because the include files and libraries will be hidden from the compiler.
1.1 dsieger 6219:
1.156 leot 6220: 6. If your package needs some executable to be able to run correctly and if
1.26 spz 6221: there's no buildlink3.mk file, this is specified using the DEPENDS
6222: variable. The print/lyx package needs to be able to execute the latex
1.129 wiz 6223: binary from the tex-latex-bin package when it runs, and that is specified:
1.1 dsieger 6224:
1.129 wiz 6225: DEPENDS+= tex-latex-bin-[0-9]*:../../print/tex-latex-bin
1.1 dsieger 6226:
1.175 gutterid 6227: 7. If your package includes a test suite that has extra dependencies only
6228: required for this purpose (frequently this can be run as a "make test"
6229: target), use the TEST_DEPENDS variable.
6230:
6231: 8. You can use wildcards in package dependencies. Note that such wildcard
1.26 spz 6232: dependencies are retained when creating binary packages. The dependency is
6233: checked when installing the binary package and any package which matches
6234: the pattern will be used. Wildcard dependencies should be used with care.
1.1 dsieger 6235:
6236: The "-[0-9]*" should be used instead of "-*" to avoid potentially ambiguous
6237: matches such as "tk-postgresql" matching a "tk-*" DEPENDS.
6238:
6239: Wildcards can also be used to specify that a package will only build
6240: against a certain minimum version of a pre-requisite:
6241:
1.26 spz 6242: DEPENDS+= ImageMagick>=6.0:../../graphics/ImageMagick
1.1 dsieger 6243:
1.26 spz 6244: This means that the package will build using version 6.0 of ImageMagick or
6245: newer. Such a dependency may be warranted if, for example, the command line
6246: options of an executable have changed.
6247:
1.183 wiz 6248: If you need to depend on minimum versions of libraries, set
6249: BUILDLINK_API_DEPENDS.pkg to the appropriate pattern before including its
6250: buildlink3.mk file, e.g.
6251:
6252: BUILDLINK_API_DEPENDS.jpeg+= jpeg>=9.0
6253: .include "../../graphics/jpeg/buildlink3.mk"
1.1 dsieger 6254:
6255: For security fixes, please update the package vulnerabilities file. See
1.154 rillig 6256: Section 21.1.9, "Handling packages with security problems" for more
1.1 dsieger 6257: information.
6258:
6259: If your package needs files from another package to build, add the relevant
6260: distribution files to DISTFILES, so they will be extracted automatically. See
6261: the print/ghostscript package for an example. (It relies on the jpeg sources
6262: being present in source form during the build.)
6263:
1.154 rillig 6264: 21.1.6. Handling conflicts with other packages
1.1 dsieger 6265:
1.226 gutterid 6266: Your package may conflict with other packages users might already have
6267: installed on their system, e.g., if your package installs the same set of files
1.227 wiz 6268: as another package in the pkgsrc tree.
1.1 dsieger 6269:
1.142 leot 6270: For example, x11/libXaw3d and x11/Xaw-Xpm install the same shared library, thus
6271: you set in pkgsrc/x11/libXaw3d/Makefile:
1.1 dsieger 6272:
1.142 leot 6273: CONFLICTS= Xaw-Xpm-[0-9]*
1.1 dsieger 6274:
1.142 leot 6275: and in pkgsrc/x11/Xaw-Xpm/Makefile:
1.1 dsieger 6276:
1.142 leot 6277: CONFLICTS= libXaw3d-[0-9]*
1.1 dsieger 6278:
1.142 leot 6279: pkg_add(1) is able to detect attempts to install packages that conflict with
6280: existing packages and abort. However, in many situations this is too late in
6281: the process. Binary package managers will not know about the conflict until
6282: they attempt to install the package after already downloading it and all its
6283: dependencies. Users may also waste time building a package and its dependencies
6284: only to find out at the end that it conflicts with another package they have
6285: installed.
6286:
6287: To avoid these issues CONFLICTS entries should be added in all cases where it
6288: is known that packages conflict with each other. These CONFLICTS entries are
6289: exported in pkg_summary(5) files and consumed by binary package managers to
6290: inform users that packages cannot be installed onto the target system.
1.1 dsieger 6291:
1.154 rillig 6292: 21.1.7. Packages that cannot or should not be built
1.1 dsieger 6293:
6294: There are several reasons why a package might be instructed to not build under
6295: certain circumstances. If the package builds and runs on most platforms, the
1.83 dholland 6296: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
6297: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
6298: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
6299: (OS-version-platform) that can use glob-style wildcards.
6300:
1.114 maya 6301: If a package is not appropriate for some platforms (as opposed to merely
1.83 dholland 6302: broken), a different set of variables should be used as this affects failure
6303: reporting and statistics. If the package is appropriate for most platforms, the
6304: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
6305: for only a small handful of platforms (often exactly one), set
6306: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
6307: triples (OS-version-platform) that can use glob-style wildcards.
1.1 dsieger 6308:
6309: Some packages are tightly bound to a specific version of an operating system,
6310: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
6311: with other versions of the OS, and should be uploaded to a version specific
6312: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
6313: to "yes". This variable is not currently used by any of the package system
6314: internals, but may be used in the future.
6315:
6316: If the package should be skipped (for example, because it provides
6317: functionality already provided by the system), set PKG_SKIP_REASON to a
6318: descriptive message. If the package should fail because some preconditions are
6319: not met, set PKG_FAIL_REASON to a descriptive message.
6320:
1.154 rillig 6321: 21.1.8. Packages which should not be deleted, once installed
1.1 dsieger 6322:
6323: To ensure that a package may not be deleted, once it has been installed, the
6324: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.25 wiz 6325: carried into any binary package that is made from this pkgsrc entry. A "
6326: preserved" package will not be deleted using pkg_delete(1) unless the "-f"
1.1 dsieger 6327: option is used.
6328:
1.154 rillig 6329: 21.1.9. Handling packages with security problems
1.1 dsieger 6330:
1.247 wiz 6331: When a vulnerability is found, this should be noted in pkgsrc/doc/
6332: pkg-vulnerabilities. Entries in that file consist of three parts:
1.205 wiz 6333:
6334: * package version pattern
6335:
6336: * type of vulnerability (please cut'n'paste an existing one where possible)
6337:
6338: * URL providing additional information about the issue
6339:
6340: For the package version pattern please always use `<' to mark an upper bound
6341: (not `<='!). This will avoid possible problems due unrelated PKGREVISION bumps
6342: not related to security fixes. Lower bounds can be added too, using '>' or '>=
1.206 wiz 6343: '. For example, "foo>=1<1.2" would mark versions 1.0 (included) to 1.2
1.205 wiz 6344: (excluded) of "foo" as affected by the security issue.
6345:
6346: Entries should always be added at the bottom of the file.
6347:
6348: When fixing packages, please modify the upper bound of the corresponding entry.
6349: To continue the previous example, if a fix was backported to version 1.1nb2,
1.206 wiz 6350: change the previous pattern to "foo>=1<1.1nb2".
1.205 wiz 6351:
6352: To locally test a package version pattern against a PKGNAME you can use the
6353: pkg_admin pmatch command.
6354:
6355: The URL should be as permanent as possible and provide as much information
6356: about the issue as possible. CVE entries are preferred.
6357:
6358: After committing that file, ask pkgsrc-security@NetBSD.org to update the file
6359: on ftp.NetBSD.org.
1.1 dsieger 6360:
6361: After fixing the vulnerability by a patch, its PKGREVISION should be increased
6362: (this is of course not necessary if the problem is fixed by using a newer
1.32 wiz 6363: release of the software), and the pattern in the pkg-vulnerabilities file must
6364: be updated.
1.1 dsieger 6365:
6366: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
6367: submit a pullup request!
6368:
6369: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
6370: a weekly cron job.
6371:
1.205 wiz 6372: In case a security issue is disputed, please contact
6373: pkgsrc-security@NetBSD.org.
6374:
1.154 rillig 6375: 21.1.10. How to handle incrementing versions when fixing an existing package
1.1 dsieger 6376:
6377: When making fixes to an existing package it can be useful to change the version
6378: number in PKGNAME. To avoid conflicting with future versions by the original
6379: author, a "nb1", "nb2", ... suffix can be used on package versions by setting
6380: PKGREVISION=1 (2, ...). The "nb" is treated like a "." by the package tools.
6381: e.g.
6382:
6383: DISTNAME= foo-17.42
6384: PKGREVISION= 9
6385:
6386: will result in a PKGNAME of "foo-17.42nb9". If you want to use the original
6387: value of PKGNAME without the "nbX" suffix, e.g. for setting DIST_SUBDIR, use
6388: PKGNAME_NOREV.
6389:
6390: When a new release of the package is released, the PKGREVISION should be
6391: removed, e.g. on a new minor release of the above package, things should be
6392: like:
6393:
6394: DISTNAME= foo-17.43
6395:
6396: PKGREVISION should be incremented for any non-trivial change in the resulting
6397: binary package. Without a PKGREVISION bump, someone with the previous version
6398: installed has no way of knowing that their package is out of date. Thus,
6399: changes without increasing PKGREVISION are essentially labeled "this is so
6400: trivial that no reasonable person would want to upgrade", and this is the rough
6401: test for when increasing PKGREVISION is appropriate. Examples of changes that
6402: do not merit increasing PKGREVISION are:
6403:
1.14 jmcneill 6404: * Changing HOMEPAGE, MAINTAINER, OWNER, or comments in Makefile.
1.1 dsieger 6405:
6406: * Changing build variables if the resulting binary package is the same.
6407:
6408: * Changing DESCR.
6409:
6410: * Adding PKG_OPTIONS if the default options don't change.
6411:
6412: Examples of changes that do merit an increase to PKGREVISION include:
6413:
6414: * Security fixes
6415:
6416: * Changes or additions to a patch file
6417:
6418: * Changes to the PLIST
6419:
1.12 weinem 6420: * A dependency is changed or renamed.
6421:
1.1 dsieger 6422: PKGREVISION must also be incremented when dependencies have ABI changes.
6423:
1.154 rillig 6424: 21.1.11. Substituting variable text in the package files (the SUBST framework)
1.1 dsieger 6425:
1.180 rillig 6426: When you want to replace the same text in multiple files, or multiple times in
6427: the same file, it is cumbersome to maintain a patch file for this. This is
6428: where the SUBST framework steps in. It provides an easy-to-use interface for
6429: replacing text in files. It just needs the following information:
1.172 rillig 6430:
1.180 rillig 6431: * In which phase of the package build cycle should the replacement happen?
1.172 rillig 6432:
1.180 rillig 6433: * In which files should the replacement happen?
1.172 rillig 6434:
6435: * Which text should be replaced with what?
6436:
1.180 rillig 6437: This information is encoded in a block of SUBST variables. A minimal example
6438: is:
6439:
6440: SUBST_CLASSES+= paths
6441: SUBST_STAGE.paths= pre-configure
6442: SUBST_FILES.paths= src/*.c
6443: SUBST_SED.paths= -e 's,/usr/local,${PREFIX},g'
6444:
6445: Translated into English, it means: In the pre-configure stage (that is, after
6446: applying the patches from the patches/ directory and before running the
6447: configure script and the portability check), replace the text /usr/local with
6448: the content of the variable PREFIX.
6449:
6450: Each SUBST block starts by appending an identifier to SUBST_CLASSES (note the +
6451: =). This identifier can be chosen freely by the package. If there should ever
6452: be duplicate identifiers, the pkgsrc infrastructure will catch this and fail
6453: early, so don't worry about name collisions.
6454:
6455: Except for SUBST_CLASSES, all variables in a SUBST block are parameterized
6456: using this identifier. In the remainder of this section, these parameterized
6457: variables are written as SUBST_STAGE.*.
6458:
6459: SUBST_CLASSES+= paths
6460: SUBST_STAGE.paths= pre-configure
6461: SUBST_MESSAGE.paths= Fixing absolute paths.
6462: SUBST_FILES.paths= src/*.c
6463: SUBST_FILES.paths+= scripts/*.sh
6464: SUBST_SED.paths= -e 's,"/usr/local,"${PREFIX},g'
6465: SUBST_SED.paths+= -e 's,"/var/log,"${VARBASE}/log,g'
6466: SUBST_VARS.paths= LOCALBASE PREFIX PKGVERSION
6467:
6468: To get a complete picture about the SUBST substitutions, run bmake
6469: show-all-subst. If something doesn't work as expected, run pkglint on the
6470: package, which detects several typical mistakes surrounding the SUBST blocks.
6471: For any questions that might remain after this, have a look at mk/subst.mk.
6472:
6473: 21.1.11.1. Choosing the time where the substitutions happen
6474:
6475: The SUBST_STAGE.* is one of {pre,do,post}-
6476: {extract,patch,configure,build,test,install}. Of these, pre-configure is used
6477: most often, by far. The most popular stages are, in chronological order:
6478:
6479: post-extract
6480:
6481: The substitutions are applied immediately after the distfiles are
6482: extracted. Running bmake extract on the package will leave no traces of the
6483: original files.
6484:
6485: When the substitution applies to files for which there is also a patch in
6486: the patches/ directory, this means that the patches will be computed based
6487: on the result of the substitution. When these patches are sent to the
6488: upstream maintainer later, to be fixed in the upstream package, these
6489: patches may no longer match what the upstream author is used to. Because of
6490: this, pre-configure is often a better choice.
6491:
6492: pre-configure
6493:
6494: The substitutions are applied after the patches from the patches/
6495: directory. This makes it possible to run bmake patch on the package, after
6496: which the patches can be edited using the tools pkgvi and mkpatches from
6497: the pkgtools/pkgdiff package.
6498:
6499: When updating the patches, it is helpful to explicitly separate the bmake
6500: patch from the bmake configure, and to only edit the patches between these
6501: commands. Otherwise the substitutions from the SUBST block will end up in
6502: the patch file. When this happens in really obvious ways, pkglint will
6503: complain about patches that contain a hard-coded /usr/pkg instead of the
6504: correct and intended @PREFIX@, but it can only detect these really obvious
6505: cases.
6506:
6507: do-configure
6508:
6509: This stage should only be used if the package defines a pre-configure
6510: action itself, and the substitution must happen after that. Typical
6511: examples are packages that use the pre-configure stage to regenerate the
6512: GNU configure script from configure.ac.
6513:
6514: post-configure
6515:
6516: This stage is used to fix up any mistakes by the configure stage.
6517:
6518: pre-build
6519:
6520: This stage should only be used for substitutions that are clearly related
6521: to building the package, not for fixing the configuration. Substitutions
6522: for pathnames (such as replacing /usr/local with ${PREFIX}) or user names
6523: (such as replacing @MY_USER@ with the actual username) belong in
6524: pre-configure or post-configure instead.
6525:
6526: post-build
6527:
6528: Just as with pre-build, this stage should only be used for substitutions
6529: that are clearly related to building the package, not for fixing the
6530: configuration. Substitutions for pathnames (such as replacing /usr/local
6531: with ${PREFIX}) or user names (such as replacing @MY_USER@ with the actual
6532: username) belong in pre-configure or post-configure instead.
6533:
6534: A typical use is to update pkg-config files to include the rpath compiler
6535: options.
6536:
6537: pre-install
6538:
6539: In general, the install phase should be as simple as possible. As with the
6540: pre-build and post-build stages, it should not be used to fix pathnames or
6541: user names, these belong in pre-configure instead. There are only few
6542: legitimate use cases for applying substitutions in this stage.
6543:
1.181 rillig 6544: 21.1.11.2. Choosing the files where the substitutions happen
1.180 rillig 6545:
6546: The SUBST_FILES.* variable contains a list of filename patterns. These patterns
6547: are relative to WRKSRC since that is where most substitutions happen. A typical
6548: example is:
6549:
6550: SUBST_FILES.path= Makefile */Makefile */*/Makefile *.[ch]
6551:
6552: The above patterns, especially the last, are quite broad. The SUBST
6553: implementation checks that each filename pattern that is mentioned here has an
6554: effect. For example, if none of the */*/Makefile files contains the patterns to
6555: be found and substituted, that filename pattern is redundant and should be left
1.181 rillig 6556: out. By default, the SUBST framework will complain with an error message. If
6557: the text to be substituted occurs in some of the files from a single pattern,
6558: but not in all of them, that is totally ok, and the SUBST framework will only
6559: print an INFO message for those files.
1.180 rillig 6560:
6561: If there is a good reason for having redundant filename patterns, set
1.181 rillig 6562: SUBST_NOOP_OK.* to yes.
1.180 rillig 6563:
6564: Another popular way of choosing the files for the substitutions is via a shell
6565: command, like this:
6566:
1.181 rillig 6567: C_FILES_CMD= cd ${WRKSRC} && ${FIND} . -name '*.c'
1.180 rillig 6568: SUBST_FILES.path= ${C_FILES_CMD:sh}
6569:
6570: The variable name C_FILES_CMD in this example is freely chosen and independent
6571: of the SUBST framework.
6572:
6573: In this variant, the SUBST_FILES.* variable lists each file individually.
6574: Thereby chances are higher that there are filename patterns in which no
6575: substitution happens. Since the SUBST framework cannot know whether the
6576: filename patterns in SUBST_FILES.* have been explicitly listed in the Makefile
6577: (where any redundant filename pattern would be suspicious) or been generated by
6578: a shell command (in which redundant filename patterns are more likely and to be
6579: expected), it will complain about these redundant filename patterns. Therefore,
6580: SUBST blocks that use a shell command to generate the list of filename patterns
6581: often need to set SUBST_NOOP_OK.* to yes.
6582:
6583: 21.1.11.3. Choosing what to substitute
6584:
6585: In most cases, the substitutions are given using one or more sed(1) commands,
6586: like this:
6587:
6588: SUBST_SED.path= -e 's|/usr/local|${PREFIX}|g'
6589:
6590: Each of the sed commands needs to be preceded by the -e option and should be
6591: specified on a line of its own, to avoid hiding short sed commands at the end
6592: of a line.
6593:
6594: Since the sed commands often contain shell metacharacters as the separator (the
6595: | in the above example), it is common to enclose them in single quotes.
6596:
6597: A common substitution is to replace placeholders of the form @VARNAME@ with
6598: their pkgsrc counterpart variable ${VARNAME}. A typical example is:
6599:
6600: SUBST_VARS.path= PREFIX
6601:
1.181 rillig 6602: This type of substitutions is typically done by the GNU configure scripts
6603: during the do-configure stage, but in some cases these need to be overridden.
6604: The same pattern is also used when a package defines patches that replace
6605: previously hard-coded paths like /usr/local with a @PREFIX@ placeholder first,
6606: which then gets substituted by the actual ${PREFIX} in the pre-configure stage.
6607: In many of these cases, it works equally well to just use the SUBST framework
6608: to directly replace /usr/local with ${PREFIX}, thereby omitting the
6609: intermediate patch file.
1.180 rillig 6610:
6611: If the above is not flexible enough, it is possible to not use sed at all for
6612: the substitution but to specify an entirely different command, like this:
6613:
6614: SUBST_FILTER_CMD.path= LC_ALL=C ${TR} -d '\r'
1.1 dsieger 6615:
1.180 rillig 6616: This is used for the few remaining packages in which the distributed files use
6617: Windows-style line endings that need to be converted to UNIX-style line
6618: endings.
1.1 dsieger 6619:
1.180 rillig 6620: 21.1.11.4. Other SUBST variables
1.172 rillig 6621:
1.180 rillig 6622: When a SUBST block is applied during a package build, a message is logged. The
6623: default message is fine for most purposes but can be overridden by setting
6624: SUBST_MESSAGE.* to an individual message.
1.1 dsieger 6625:
1.154 rillig 6626: 21.2. The fetch phase
1.1 dsieger 6627:
1.154 rillig 6628: 21.2.1. Packages whose distfiles aren't available for plain downloading
1.1 dsieger 6629:
6630: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
6631: a make fetch will call files/getsite.sh with the name of each file to download
6632: as an argument, expecting it to output the URL of the directory from which to
6633: download it. graphics/ns-cult3d is an example of this usage.
6634:
6635: If the download can't be automated, because the user must submit personal
6636: information to apply for a password, or must pay for the source, or whatever,
6637: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
6638: before aborting the build. Example:
6639:
6640: FETCH_MESSAGE= "Please download the files"
6641: FETCH_MESSAGE+= " "${DISTFILES:Q}
6642: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
6643:
1.154 rillig 6644: 21.2.2. How to handle modified distfiles with the 'old' name
1.1 dsieger 6645:
6646: Sometimes authors of a software package make some modifications after the
6647: software was released, and they put up a new distfile without changing the
6648: package's version number. If a package is already in pkgsrc at that time, the
6649: checksum will no longer match. The contents of the new distfile should be
6650: compared against the old one before changing anything, to make sure the
6651: distfile was really updated on purpose, and that no trojan horse or so crept
6652: in. Please mention that the distfiles were compared and what was found in your
1.54 rodent 6653: commit message.
6654:
6655: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109 wiz 6656: directory name, usually based on PKGNAME_NOREV (but take care with python or
6657: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
6658: PATCHFILES for this package will be put in that subdirectory of the local
1.154 rillig 6659: distfiles directory. (See Section 21.1.10, "How to handle incrementing versions
1.109 wiz 6660: when fixing an existing package" for more details.) In case this happens more
6661: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
6662: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54 rodent 6663:
6664: DIST_SUBDIR is also used when a distfile's name does not contain a version and
6665: the distfile is apt to change. In cases where the likelihood of this is very
6666: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
6667: removed unless the distfile name changes, even if a package is being moved or
6668: renamed.
6669:
6670: Do not forget regenerating the distinfo file after that, since it contains the
6671: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
6672: installed package is different. Furthermore, a mail to the package's authors
6673: seems appropriate telling them that changing distfiles after releases without
6674: changing the file names is not good practice.
1.1 dsieger 6675:
1.154 rillig 6676: 21.2.3. Packages hosted on github.com
1.88 tnn 6677:
1.90 tnn 6678: Helper methods exist for packages hosted on github.com which will often have
6679: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
6680: of the three recipes from below:
1.88 tnn 6681:
1.154 rillig 6682: 21.2.3.1. Fetch based on a tagged release
1.88 tnn 6683:
1.189 bacon 6684: If your distfile URL looks similar to https://github.com/username/example/
6685: archive/v1.0.zip, then you are packaging a tagged release.
1.88 tnn 6686:
1.189 bacon 6687: DISTNAME= example-1.0
1.90 tnn 6688: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1.189 bacon 6689: #GITHUB_PROJECT= example # can be omitted if same as DISTNAME
1.90 tnn 6690: GITHUB_TAG= v${PKGVERSION_NOREV}
1.88 tnn 6691: EXTRACT_SUFX= .zip
6692:
1.230 gutterid 6693: Here, DISTNAME combined with use of GITHUB_TAG leads the file fetching
6694: infrastructure to save the resulting file locally as example-1.0.zip.
6695:
1.189 bacon 6696: 21.2.3.2. Fetch based on a specific commit before the first release
6697:
6698: If your distfile looks similar to https://github.com/username/example/archive/
6699: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit before the first
6700: release, then set the package version to 0.0.0.N, where N is the number of
6701: commits to the repository, and set GITHUB_TAG to the commit hash. This will
6702: (almost) ensure that the first tagged release will have a version greater than
6703: this one so that package upgrades will function properly.
6704:
6705: DISTNAME= example-0.0.0.347
6706: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
6707: #GITHUB_PROJECT= example # can be omitted if same as DISTNAME
6708: GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
6709:
6710: 21.2.3.3. Fetch based on a specific commit after a release
1.88 tnn 6711:
1.189 bacon 6712: If your distfile looks similar to https://github.com/username/example/archive/
6713: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit after a release,
6714: then include the last release version and the commit count since that release
6715: in the package version and set GITHUB_TAG to the commit hash. The latest
6716: release and commit count are shown in the output of "git describe --tags":
6717:
6718: # git clone https://github.com/username/example
6719: # cd example
6720: # git describe --tags
6721: 1.2.3-5-g988881a
1.88 tnn 6722:
1.189 bacon 6723: DISTNAME= example-1.2.3.5
6724: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
6725: #GITHUB_PROJECT= example # can be omitted if same as DISTNAME
1.90 tnn 6726: GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88 tnn 6727:
1.189 bacon 6728: 21.2.3.4. Fetch based on release
1.88 tnn 6729:
1.189 bacon 6730: If your distfile URL looks similar to https://github.com/username/example/
6731: releases/download/rel-1.6/offensive-1.6.zip, then you are packaging a release.
1.88 tnn 6732:
1.90 tnn 6733: DISTNAME= offensive-1.6
1.88 tnn 6734: PKGNAME= ${DISTNAME:S/offensive/proper/}
1.90 tnn 6735: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1.189 bacon 6736: GITHUB_PROJECT= example
1.90 tnn 6737: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
6738: EXTRACT_SUFX= .zip
1.88 tnn 6739:
1.154 rillig 6740: 21.3. The configure phase
1.1 dsieger 6741:
1.154 rillig 6742: 21.3.1. Shared libraries - libtool
1.1 dsieger 6743:
6744: pkgsrc supports many different machines, with different object formats like
6745: a.out and ELF, and varying abilities to do shared library and dynamic loading
6746: at all. To accompany this, varying commands and options have to be passed to
6747: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
6748: especially if you don't have all the machines at your hand to test things. The
6749: devel/libtool pkg can help here, as it just "knows" how to build both static
6750: and dynamic libraries from a set of source files, thus being
6751: platform-independent.
6752:
6753: Here's how to use libtool in a package in seven simple steps:
6754:
6755: 1. Add USE_LIBTOOL=yes to the package Makefile.
6756:
6757: 2. For library objects, use "${LIBTOOL} --mode=compile ${CC}" in place of "$
6758: {CC}". You could even add it to the definition of CC, if only libraries are
6759: being built in a given Makefile. This one command will build both PIC and
6760: non-PIC library objects, so you need not have separate shared and
6761: non-shared library rules.
6762:
6763: 3. For the linking of the library, remove any "ar", "ranlib", and "ld
6764: -Bshareable" commands, and instead use:
6765:
6766: ${LIBTOOL} --mode=link \
6767: ${CC} -o ${.TARGET:.a=.la} \
6768: ${OBJS:.o=.lo} \
6769: -rpath ${PREFIX}/lib \
6770: -version-info major:minor
6771:
6772: Note that the library is changed to have a .la extension, and the objects
6773: are changed to have a .lo extension. Change OBJS as necessary. This
6774: automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
6775: necessary) in the build directory. Be sure to include "-version-info",
6776: especially when major and minor are zero, as libtool will otherwise strip
6777: off the shared library version.
6778:
6779: From the libtool manual:
6780:
6781: So, libtool library versions are described by three integers:
6782:
6783: CURRENT
6784: The most recent interface number that this library implements.
6785:
6786: REVISION
6787: The implementation number of the CURRENT interface.
6788:
6789: AGE
6790: The difference between the newest and oldest interfaces that
6791: this library implements. In other words, the library implements
6792: all the interface numbers in the range from number `CURRENT -
6793: AGE' to `CURRENT'.
6794:
6795: If two libraries have identical CURRENT and AGE numbers, then the
6796: dynamic linker chooses the library with the greater REVISION number.
6797:
6798: The "-release" option will produce different results for a.out and ELF
1.25 wiz 6799: (excluding symlinks) in only one case. An ELF library of the form "
6800: libfoo-release.so.x.y" will have a symlink of "libfoo.so.x.y" on an a.out
1.1 dsieger 6801: platform. This is handled automatically.
6802:
6803: The "-rpath argument" is the install directory of the library being built.
6804:
6805: In the PLIST, include only the .la file, the other files will be added
6806: automatically.
6807:
6808: 4. When linking shared object (.so) files, i.e. files that are loaded via
6809: dlopen(3), NOT shared libraries, use "-module -avoid-version" to prevent
6810: them getting version tacked on.
6811:
6812: The PLIST file gets the foo.so entry.
6813:
6814: 5. When linking programs that depend on these libraries before they are
6815: installed, preface the cc(1) or ld(1) line with "${LIBTOOL} --mode=link",
6816: and it will find the correct libraries (static or shared), but please be
6817: aware that libtool will not allow you to specify a relative path in -L
6818: (such as "-L../somelib"), because it expects you to change that argument to
6819: be the .la file. e.g.
6820:
6821: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
6822:
6823: should be changed to:
6824:
6825: ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
6826:
6827: and it will do the right thing with the libraries.
6828:
6829: 6. When installing libraries, preface the install(1) or cp(1) command with "$
6830: {LIBTOOL} --mode=install", and change the library name to .la. e.g.
6831:
1.23 jakllsch 6832: ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1 dsieger 6833:
6834: This will install the static .a, shared library, any needed symlinks, and
6835: run ldconfig(8).
6836:
6837: 7. In your PLIST, include only the .la file (this is a change from previous
6838: behaviour).
6839:
1.154 rillig 6840: 21.3.2. Using libtool on GNU packages that already support libtool
1.1 dsieger 6841:
6842: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
6843: own libtool in most cases. For older libtool using packages, libtool is made by
6844: ltconfig script during the do-configure step; you can check the libtool script
6845: location by doing make configure; find work*/ -name libtool.
6846:
6847: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
6848: override. By default, it is set to "libtool */libtool */*/libtool". If this
6849: does not match the location of the package's libtool script(s), set it as
6850: appropriate.
6851:
6852: If you do not need *.a static libraries built and installed, then use
6853: SHLIBTOOL_OVERRIDE instead.
6854:
6855: If your package makes use of the platform-independent library for loading
6856: dynamic shared objects, that comes with libtool (libltdl), you should include
6857: devel/libltdl/buildlink3.mk.
6858:
6859: Some packages use libtool incorrectly so that the package may not work or build
6860: in some circumstances. Some of the more common errors are:
6861:
6862: * The inclusion of a shared object (-module) as a dependent library in an
6863: executable or library. This in itself isn't a problem if one of two things
6864: has been done:
6865:
6866: 1. The shared object is named correctly, i.e. libfoo.la, not foo.la
6867:
6868: 2. The -dlopen option is used when linking an executable.
6869:
6870: * The use of libltdl without the correct calls to initialisation routines.
6871: The function lt_dlinit() should be called and the macro
6872: LTDL_SET_PRELOADED_SYMBOLS included in executables.
6873:
1.154 rillig 6874: 21.3.3. GNU Autoconf/Automake
1.1 dsieger 6875:
6876: If a package needs GNU autoconf or automake to be executed to regenerate the
1.223 nia 6877: configure script and Makefile.in makefile templates from configure.ac and
6878: Makefile.am, then they should be executed in a pre-configure target:
1.1 dsieger 6879:
1.223 nia 6880: USE_TOOLS+= autoconf automake autoreconf
6881: GNU_CONFIGURE= yes
1.1 dsieger 6882: ...
6883:
6884: pre-configure:
1.223 nia 6885: set -e; cd ${WRKSRC} && autoreconf -fi
1.1 dsieger 6886: ...
6887:
1.223 nia 6888: Packages which use GNU Automake will sometimes require GNU Make (gmake in
6889: USE_TOOLS), but not always. Note that autoreconf only needs to be executed if
6890: configure.ac or Makefiles are modified, or configure is not present.
1.1 dsieger 6891:
6892: There are times when the configure process makes additional changes to the
6893: generated files, which then causes the build process to try to re-execute the
6894: automake sequence. This is prevented by touching various files in the configure
6895: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
6896: NO in the package Makefile.
6897:
1.223 nia 6898: 21.3.4. Meson / ninja
6899:
6900: Packages using Meson to configure need to include:
6901:
6902: .include "../../devel/meson/build.mk"
6903:
6904: In nearly all cases (any program with dependencies), pkg-config needs to be
6905: added to USE_TOOLS. If the package installs translation files for non-English
6906: languages, also add msgfmt and xgettext:
6907:
6908: USE_TOOLS+= pkg-config msgfmt xgettext
6909:
6910: If any options need to be passed to Meson, use MESON_ARGS instead of
6911: CONFIGURE_ARGS:
6912:
6913: MESON_ARGS+= -Dx11=false
6914:
1.260 wiz 6915: 21.3.5. Determining the endianness
6916:
6917: To determine the endianness of the target platform, have a look at mk/
6918: endian.mk.
6919:
1.154 rillig 6920: 21.4. Programming languages
1.1 dsieger 6921:
1.154 rillig 6922: 21.4.1. C, C++, and Fortran
1.1 dsieger 6923:
1.244 gutterid 6924: Compilers for the C and C++ languages come with the NetBSD base system. By
1.223 nia 6925: default, pkgsrc assumes that a package is written in C and will hide all other
6926: compilers (via the wrapper framework, see Chapter 18, Buildlink methodology).
1.1 dsieger 6927:
1.243 gutterid 6928: To declare which languages should be made available through pkgsrc's compiler
6929: wrappers, use the USE_LANGUAGES variable. Allowed values currently are:
1.212 wiz 6930:
1.244 gutterid 6931: c, c++, fortran, fortran77, java, objc, obj-c++, and ada.
1.212 wiz 6932:
6933: (and any combination). The default is "c". Packages using GNU configure
6934: scripts, even if written in C++, usually need a C compiler for the configure
1.244 gutterid 6935: phase.
1.243 gutterid 6936:
1.250 jnemeth 6937: To declare which features a package requires from the compiler, set either
1.243 gutterid 6938: USE_CC_FEATURES or USE_CXX_FEATURES. Allowed values for USE_CC_FEATURES are
6939: currently:
6940:
6941: c11, c99, has_include
6942:
6943: Allowed values for USE_CXX_FEATURES are currently:
6944:
6945: c++11, c++14, c++17, c++20, has_include, regex, filesystem,
6946: charconv, parallelism_ts, unique_ptr, put_time,
6947: is_trivially_copy_constructible
1.1 dsieger 6948:
1.251 gutterid 6949: Note at present these variables only affect use of GCC, not other compilers.
6950:
1.244 gutterid 6951: Language variants like gnu99 and c++11 can be specified in FORCE_C_STD and
6952: FORCE_CXX_STD if the package does not explicitly set -std=... when compiling
6953: (i.e. the package assumes the compiler defaults to C++11 or some other
6954: standard). This is a common bug in upstream build systems.
6955:
6956: Allowed values for FORCE_C_STD are currently:
6957:
6958: c90, c99, c11, gnu90, gnu99, gnu11
6959:
6960: Allowed values for FORCE_CXX_STD are currently:
6961:
6962: c++03, c++11, c++14, c++17, c++20,
6963: gnu++03, gnu++11, gnu++14, gnu++17, gnu++20
6964:
1.251 gutterid 6965: Note at present these variables only affect use of GCC and Clang.
6966:
1.154 rillig 6967: 21.4.2. Java
1.1 dsieger 6968:
6969: If a program is written in Java, use the Java framework in pkgsrc. The package
6970: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
6971: variables:
6972:
6973: * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
6974: set to "run", then there is only a runtime dependency on the JDK. The
6975: default is "yes", which also adds a build dependency on the JDK.
6976:
6977: * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
6978: supported values are "yes", "1.4", and "1.5". "yes" accepts any Java2
6979: implementation, "1.4" insists on versions 1.4 or above, and "1.5" only
6980: accepts versions 1.5 or above. This variable is not set by default.
6981:
1.25 wiz 6982: * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
6983: implementation dependency. It may be used to set JAVA_HOME to a good value
6984: if the program needs this variable to be defined.
6985:
1.205 wiz 6986: 21.4.3. Go
6987:
6988: If a program is written in Go and has any dependencies on other Go modules,
6989: have the package include ../../lang/go/go-module.mk.
6990:
6991: 1. Generate a list of those dependencies with make clean && make patch && make
6992: show-go-modules > go-modules.mk.
6993:
1.223 nia 6994: 2. Prepend .include "go-modules.mk" to any other .includes.
6995:
6996: 3. Incorporate these modules in distinfo with make makesum.
1.205 wiz 6997:
1.223 nia 6998: 21.4.4. Rust
1.205 wiz 6999:
1.223 nia 7000: If a program is written in Rust and uses Cargo to build, have the package
7001: include ../../lang/rust/cargo.mk.
1.205 wiz 7002:
1.223 nia 7003: 1. Generate a list of those dependencies with make CARGO_ARGS="build
7004: --release" build && make print-cargo-depends > cargo-depends.mk.
1.205 wiz 7005:
1.223 nia 7006: 2. Prepend .include "cargo-depends.mk" to any other .includes.
1.205 wiz 7007:
7008: 3. Incorporate these modules in distinfo with make makesum.
7009:
1.223 nia 7010: 21.4.5. Packages containing Perl scripts
1.1 dsieger 7011:
1.203 nia 7012: If your package contains interpreted Perl scripts, add "perl" to the USE_TOOLS
1.1 dsieger 7013: variable and set REPLACE_PERL to ensure that the proper interpreter path is
7014: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74 wiz 7015: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
1.210 gutterid 7016: replaced with the full path to the Perl executable.
1.1 dsieger 7017:
1.210 gutterid 7018: If a particular version of Perl is needed, set the PERL5_REQD variable to the
1.1 dsieger 7019: version number. The default is "5.0".
7020:
1.203 nia 7021: See Section 21.6.6, "Packages installing Perl modules" for information about
1.210 gutterid 7022: handling Perl modules.
7023:
7024: There is also the REPLACE_PERL6 variable for the language now known as Raku.
1.1 dsieger 7025:
1.223 nia 7026: 21.4.6. Packages containing shell scripts
1.41 wiz 7027:
7028: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
1.225 gutterid 7029: shell she-bangs in files. Please use the appropriate one, preferring REPLACE_SH
7030: when this shell is sufficient. Each should contain a list of scripts, relative
7031: to WRKSRC, that you want adjusted. Every occurrence of the matching shell in a
7032: she-bang line will be replaced with the full path to the shell executable. When
7033: using REPLACE_BASH, don't forget to add bash to USE_TOOLS.
1.41 wiz 7034:
1.223 nia 7035: 21.4.7. Other programming languages
1.1 dsieger 7036:
1.210 gutterid 7037: There are further similar REPLACE variables available, e.g., REPLACE_AWK for
7038: packages containing awk scripts, and REPLACE_R for R. These two, like the
1.211 gutterid 7039: others noted above, have their actions defined centrally in mk/configure/
7040: replace-interpreter.mk. Other languages define the actions of these variables
7041: within their own dedicated part of the tree, e.g., REPLACE_PHP is actioned in
1.245 gutterid 7042: lang/php/replace.mk, and REPLACE_PYTHON is actioned in lang/python/
1.211 gutterid 7043: application.mk. For other languages, consult the mk files found within their
1.216 gutterid 7044: specific directories (the naming convention varies), or check the list found in
7045: Appendix E, Help topics.
1.210 gutterid 7046:
7047: Currently, special handling for other languages varies in pkgsrc. If a compiler
7048: package provides a buildlink3.mk file, include that, otherwise just add a
7049: (build) dependency on the appropriate compiler package.
1.1 dsieger 7050:
1.154 rillig 7051: 21.5. The build phase
1.1 dsieger 7052:
7053: The most common failures when building a package are that some platforms do not
7054: provide certain header files, functions or libraries, or they provide the
7055: functions in a library that the original package author didn't know. To work
7056: around this, you can rewrite the source code in most cases so that it does not
7057: use the missing functions or provides a replacement function.
7058:
1.154 rillig 7059: 21.5.1. Compiling C and C++ code conditionally
1.1 dsieger 7060:
7061: If a package already comes with a GNU configure script, the preferred way to
7062: fix the build failure is to change the configure script, not the code. In the
7063: other cases, you can utilize the C preprocessor, which defines certain macros
7064: depending on the operating system and hardware architecture it compiles for.
7065: These macros can be queried using for example #if defined(__i386). Almost every
7066: operating system, hardware architecture and compiler has its own macro. For
7067: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
7068: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
7069: GCC.
7070:
7071: The list of the following macros for hardware and operating system depends on
7072: the compiler that is used. For example, if you want to conditionally compile
7073: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
7074: Use __sun instead.
7075:
1.154 rillig 7076: 21.5.1.1. C preprocessor macros to identify the operating system
1.1 dsieger 7077:
1.223 nia 7078: To distinguish between specific NetBSD versions, you should use the following
7079: code.
7080:
7081: #ifdef __NetBSD__
7082: #include <sys/param.h>
7083: #if __NetBSD_Prereq__(9,99,17)
7084: /* use a newer feature */
7085: #else
7086: /* older code */
7087: #endif
7088: #endif
7089:
7090: #ifndef _WIN32
7091: /* Unix-like specific code */
7092: #endif
7093:
1.1 dsieger 7094: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
7095: should use the following code.
7096:
7097: #include <sys/param.h>
7098: #if (defined(BSD) && BSD >= 199306)
7099: /* BSD-specific code goes here */
7100: #else
7101: /* non-BSD-specific code goes here */
7102: #endif
7103:
1.223 nia 7104: You can also test for the following macros:
1.1 dsieger 7105:
1.46 obache 7106: Cygwin __CYGWIN__
7107: DragonFly __DragonFly__
1.1 dsieger 7108: FreeBSD __FreeBSD__
1.46 obache 7109: Haiku __HAIKU__
1.1 dsieger 7110: Interix __INTERIX
7111: IRIX __sgi (TODO: get a definite source for this)
1.223 nia 7112: Linux __linux
1.83 dholland 7113: Mac OS X __APPLE__
1.46 obache 7114: Minix3 __minix
1.1 dsieger 7115: NetBSD __NetBSD__
7116: OpenBSD __OpenBSD__
7117: Solaris sun, __sun
7118:
1.154 rillig 7119: 21.5.1.2. C preprocessor macros to identify the hardware architecture
1.1 dsieger 7120:
7121: i386 i386, __i386, __i386__
1.223 nia 7122: x86-64 __amd64__, __x86_64__
7123: ARM __arm__
1.1 dsieger 7124: MIPS __mips
7125: SPARC sparc, __sparc
1.223 nia 7126: PowerPC __powerpc
1.1 dsieger 7127:
1.154 rillig 7128: 21.5.1.3. C preprocessor macros to identify the compiler
1.1 dsieger 7129:
7130: GCC __GNUC__ (major version), __GNUC_MINOR__
7131: MIPSpro _COMPILER_VERSION (0x741 for MIPSpro 7.41)
7132: SunPro __SUNPRO_C (0x570 for Sun C 5.7)
7133: SunPro C++ __SUNPRO_CC (0x580 for Sun C++ 5.8)
7134:
1.154 rillig 7135: 21.5.2. How to handle compiler bugs
1.1 dsieger 7136:
7137: Some source files trigger bugs in the compiler, based on combinations of
7138: compiler version and architecture and almost always relation to optimisation
7139: being enabled. Common symptoms are gcc internal errors or never finishing
7140: compiling a file.
7141:
7142: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87 tnn 7143: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
7144:
7145: This used to be a big problem in the past, but is rarely needed now as compiler
7146: technology has matured. If you still need to add a compiler specific
7147: workaround, please do so in the file hacks.mk and describe the symptom and
7148: compiler version as detailed as possible.
1.1 dsieger 7149:
1.172 rillig 7150: 21.5.3. No such file or directory
7151:
7152: Compilation sometimes fails with an error message like this:
7153:
7154: .../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
7155: fatal error: pango/pango.h: No such file or directory
7156:
7157: The proper way to fix this problem depends on the type of the header, which is
7158: described in the following sections.
7159:
7160: 21.5.3.1. Headers from other packages
7161:
7162: If the header name looks like it comes from a different package, that other
7163: package should be included via the buildlink3 framework.
7164:
7165: First, look whether the header is somewhere in the buildlink3 directory below
7166: WRKDIR. In the above case of the missing Pango header:
7167:
7168: $ find work/.buildlink/ -print | grep -F pango/pango.h
7169:
7170: In the case of Pango, the output is:
7171:
7172: work/.buildlink/include/pango-1.0/pango/pango.h
7173:
7174: If the pango/pango.h file were placed directly in the .buildlink directory, it
7175: would have been found automatically. There is an extra pango-1.0 path component
7176: though, which means that the compiler command line must contain an option of
7177: the form -I${BUILDLINK3_PREFIX.pango}/include/pango-1.0. In most cases this
7178: option is generated by the configure script, which can be examined using:
7179:
7180: $ $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
7181: -I/usr/pkg/include/pango-1.0
7182: -I/usr/pkg/include/pango-1.0
7183: -I/usr/pkg/include/pango-1.0
7184: -I/usr/pkg/include/pango-1.0
7185: -I/usr/pkg/include/pango-1.0
7186:
7187: This looks good. These options are transformed by the buildlink wrapper to
7188: refer to the correct path inside work/.buildlink.
7189:
7190: Since the compilation fails though, examine the compiler command lines in work
7191: /.work.log to see whether the -I option is included in the particular command
7192: line.
7193:
7194: To further analyze the situation, run bmake build-env, which sets up an
7195: interactive, realistic environment including all the pkgsrc wrapper commands
7196: and environment variables. From there, try to compile some simple example
7197: programs that use the header.
7198:
7199: 21.5.3.2. Headers generated during the build
7200:
7201: If the name of the header seems to come from the package itself, and if the
7202: build is run with parallel jobs, the package may have some undeclared
7203: dependencies between the .c and the .h files, and a C file is compiled before
7204: its required header is generated.
7205:
7206: To see whether the build runs with parallel jobs, run bmake show-all-build |
7207: grep JOBS. Its output looks like this:
7208:
7209: usr MAKE_JOBS= 7
7210: pkg MAKE_JOBS_SAFE # undefined
7211: def _MAKE_JOBS_N= 7
7212:
7213: In this case the pkgsrc user has asked pkgsrc to build packages with 7 jobs in
7214: parallel (MAKE_JOBS). The package could have disabled parallel builds by
7215: setting MAKE_JOBS_SAFE to no, but in this case it hasn't.
7216:
7217: To see whether the build failure is caused by parallel builds, first save the
7218: exact error message and a bit of context, maybe you need it later for reporting
7219: a bug. Next, run:
7220:
7221: MAKE_JOBS_SAFE=no bmake clean build
7222:
7223: If that succeeds, file a bug report against the pkgsrc package, including the
7224: exact error message and the contents of your mk.conf file.
7225:
1.173 rillig 7226: 21.5.3.3. Symlinks
7227:
7228: Pkgsrc does not work reliably if any of LOCALBASE, VARBASE or WRKDIR contains a
7229: symlink. Since 2019Q2, the pkgsrc bootstrap program prevents installing pkgsrc
7230: in symlink-based directories. Existing pkgsrc installations are not checked for
7231: symlinks though.
7232:
7233: The "No such file or directory" error messages are a typical symptom of
7234: symlinks, and it's quite difficult to find out that this is the actual cause.
7235:
7236: 21.5.3.4. Stale working directories
7237:
7238: When building a hierarchy of packages, it may happen that one package is built
7239: and then pkgsrc is updated. This situation can provoke various hard to diagnose
7240: build errors. To clean up the situation:
7241:
1.223 nia 7242: $ (cd ../../ && cat mk/bsd.pkg.mk >/dev/null && rm -rf */*/work)
1.173 rillig 7243:
1.223 nia 7244: (The only purpose of the bsd.pkg.mk is to prevent running this command in the
7245: wrong directory.)
1.173 rillig 7246:
7247: If you have set WRKOBJDIR in mk.conf, remove that directory as well.
7248:
7249: 21.5.3.5. Other possible reasons
7250:
7251: On platforms other than BSD, third-party packages are installed in /usr/
7252: include, together with the base system. This means that pkgsrc cannot
7253: distinguish between headers provided by the base system (which it needs) and
7254: headers from third-party packages (which are often included in pkgsrc as well).
7255: This can lead to subtle version mismatches.
7256:
7257: In pkgsrc installations that have been active for several years, it may happen
7258: that some files are manually deleted. To exclude this unlikely reason, run
7259: pkg_admin check.
7260:
7261: It may help to run pkg_admin rebuild-tree to check/fix dependencies.
7262:
7263: If all of the above doesn't help, see Chapter 2, Getting help for contact
7264: information. Be prepared to describe what you have tried so far and what any
7265: error messages were.
7266:
1.172 rillig 7267: 21.5.4. Undefined reference to "..."
1.1 dsieger 7268:
7269: This error message often means that a package did not link to a shared library
7270: it needs. The following functions are known to cause this error message over
7271: and over.
7272:
7273: +-----------------------------------------------------+
7274: | Function |Library |Affected platforms|
7275: |-------------------------+--------+------------------|
7276: |accept, bind, connect |-lsocket|Solaris |
7277: |-------------------------+--------+------------------|
7278: |crypt |-lcrypt |DragonFly, NetBSD |
7279: |-------------------------+--------+------------------|
7280: |dlopen, dlsym |-ldl |Linux |
7281: |-------------------------+--------+------------------|
7282: |gethost* |-lnsl |Solaris |
7283: |-------------------------+--------+------------------|
7284: |inet_aton |-lresolv|Solaris |
7285: |-------------------------+--------+------------------|
7286: |nanosleep, sem_*, timer_*|-lrt |Solaris |
7287: |-------------------------+--------+------------------|
7288: |openpty |-lutil |Linux |
7289: +-----------------------------------------------------+
7290:
1.223 nia 7291: To fix these linker errors, it is often sufficient to add LIBS.OperatingSystem+
7292: = -lfoo to the package Makefile and then run bmake clean; bmake.
1.1 dsieger 7293:
1.223 nia 7294: 21.5.4.1. The SunPro compiler and inline functions
1.1 dsieger 7295:
7296: When you are using the SunPro compiler, there is another possibility. That
7297: compiler cannot handle the following code:
7298:
7299: extern int extern_func(int);
7300:
7301: static inline int
7302: inline_func(int x)
7303: {
7304: return extern_func(x);
7305: }
7306:
7307: int main(void)
7308: {
7309: return 0;
7310: }
7311:
7312: It generates the code for inline_func even if that function is never used. This
7313: code then refers to extern_func, which can usually not be resolved. To solve
7314: this problem you can try to tell the package to disable inlining of functions.
7315:
1.228 gutterid 7316: 21.5.4.2. Missing atomic functions
7317:
7318: When building for older machine architectures (e.g., i386, PowerPC), builds may
7319: fail because the package expects modern 64-bit atomic functions which the
7320: underlying hardware either doesn't support, or will only support with specific
7321: compiler flags. This is generally handled via inclusion of mk/atomic64.mk.
7322:
1.172 rillig 7323: 21.5.5. Running out of memory
1.1 dsieger 7324:
7325: Sometimes packages fail to build because the compiler runs into an operating
7326: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.223 nia 7327: told to unlimit the resources. The allowed values are any combination of "
7328: cputime", "datasize", "memorysize", "stacksize" and "virtualsize". Setting this
7329: variable is similar to running the shell builtin ulimit command to raise the
7330: maximum data segment size or maximum stack size of a process, respectively, to
7331: their hard limits.
1.1 dsieger 7332:
1.154 rillig 7333: 21.6. The install phase
1.1 dsieger 7334:
1.154 rillig 7335: 21.6.1. Creating needed directories
1.1 dsieger 7336:
7337: The BSD-compatible install supplied with some operating systems cannot create
7338: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
7339: like this:
7340:
7341: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
7342: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
7343:
1.223 nia 7344: Instead of running the install commands directly, you can also append "dir1
7345: dir2" to the INSTALLATION_DIRS variable, which will automatically do the right
7346: thing.
1.1 dsieger 7347:
1.154 rillig 7348: 21.6.2. Where to install documentation
1.1 dsieger 7349:
7350: In general, documentation should be installed into ${PREFIX}/share/doc/$
1.223 nia 7351: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME_NOREV} (the latter includes the
7352: version number of the package).
1.1 dsieger 7353:
7354: Many modern packages using GNU autoconf allow to set the directory where HTML
7355: documentation is installed with the "--with-html-dir" option. Sometimes using
7356: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
1.223 nia 7357: share/doc/html or other places. In pkgsrc, the HTML documentation should go
7358: into the package-specific directory, just like any other documentation.
1.1 dsieger 7359:
7360: An exception to the above is that library API documentation generated with the
7361: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
7362: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
7363: can be recognized from files ending in .devhelp or .devhelp2. (It is also
7364: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
7365: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
7366: then, no additional subdirectory level is allowed in this case. This is usually
7367: achieved by using "--with-html-dir=${PREFIX}/share/doc". ${PREFIX}/share/
7368: gtk-doc is preferred though.)
7369:
1.154 rillig 7370: 21.6.3. Installing highscore files
1.1 dsieger 7371:
7372: Certain packages, most of them in the games category, install a score file that
7373: allows all users on the system to record their highscores. In order for this to
7374: work, the binaries need to be installed setgid and the score files owned by the
1.36 wiz 7375: appropriate group and/or owner (traditionally the "games" user/group). Set
7376: USE_GAMESGROUP to yes to support this. The following variables, documented in
7377: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100 leot 7378: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
7379: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
7380:
7381: An example that illustrates some of the variables described above is games/
7382: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
7383: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
7384: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
7385: to install setgid the game binary:
7386:
7387: USE_GAMESGROUP= yes
7388:
7389: BUILD_DEFS+= VARBASE
7390:
7391: OWN_DIRS_PERMS+= ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
7392: REQD_FILES_PERMS+= /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
7393: SPECIAL_PERMS+= ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
7394:
7395: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
7396: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
7397: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1 dsieger 7398:
1.14 jmcneill 7399: A package should therefore never hard code file ownership or access permissions
1.100 leot 7400: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
7401: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1 dsieger 7402:
1.154 rillig 7403: 21.6.4. Adding DESTDIR support to packages
1.4 rillig 7404:
1.14 jmcneill 7405: DESTDIR support means that a package installs into a staging directory, not the
7406: final location of the files. Then a binary package is created which can be used
7407: for installation as usual. There are two ways: Either the package must install
1.25 wiz 7408: as root ("destdir") or the package can install as non-root user ("user-destdir"
7409: ).
1.14 jmcneill 7410:
1.113 leot 7411: * PKG_DESTDIR_SUPPORT has to be set to "destdir" or "user-destdir". By
7412: default PKG_DESTDIR_SUPPORT is set to "user-destdir" to help catching more
7413: potential packaging problems. If bsd.prefs.mk is included in the Makefile,
7414: PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14 jmcneill 7415:
1.4 rillig 7416: * All installation operations have to be prefixed with ${DESTDIR}.
7417:
7418: * automake gets this DESTDIR mostly right automatically. Many manual rules
7419: and pre/post-install often are incorrect; fix them.
7420:
1.17 imil 7421: * If files are installed with special owner/group use SPECIAL_PERMS.
1.4 rillig 7422:
7423: * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
7424:
1.154 rillig 7425: 21.6.5. Packages with hardcoded paths to other interpreters
1.1 dsieger 7426:
7427: Your package may also contain scripts with hardcoded paths to other
1.203 nia 7428: interpreters besides (or as well as) Perl. To correct the full pathname to the
1.1 dsieger 7429: script interpreter, you need to set the following definitions in your Makefile
7430: (we shall use tclsh in this example):
7431:
7432: REPLACE_INTERPRETER+= tcl
7433: REPLACE.tcl.old= .*/bin/tclsh
7434: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
7435: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
7436: # relative to ${WRKSRC}, just as in REPLACE_PERL
7437:
1.203 nia 7438: 21.6.6. Packages installing Perl modules
1.1 dsieger 7439:
7440: Makefiles of packages providing perl5 modules should include the Makefile
7441: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
7442: standard perl configuration for such modules as well as various hooks to tune
7443: this configuration. See comments in this file for details.
7444:
7445: Perl5 modules will install into different places depending on the version of
7446: perl used during the build process. To address this, pkgsrc will append lines
7447: to the PLIST corresponding to the files listed in the installed .packlist file
7448: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48 wiz 7449: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
7450: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1 dsieger 7451:
1.48 wiz 7452: PERL5_PACKLIST= auto/Pg/.packlist
1.1 dsieger 7453:
1.48 wiz 7454: The perl5 config variables installarchlib, installscript, installvendorbin,
7455: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
7456: and installvendorman3dir represent those locations in which components of perl5
7457: modules may be installed, provided as variable with uppercase and prefixed with
7458: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
7459: have a packlist. These variables are also substituted for in the PLIST as
7460: uppercase prefixed with PERL5_SUB_.
1.1 dsieger 7461:
1.254 wiz 7462: 21.6.7. Packages installing pkg-config files
7463:
7464: Some packages, usually those providing libraries, install pkg-config files so
7465: that their headers and libraries can easily be found. The file names end with
7466: .pc.
7467:
7468: Most of the time, these files only provide the linker flags for the library,
7469: but do not include the flags for setting the rpath so the libraries can also be
7470: found at runtime. Since this is so common, pkgsrc provides PKGCONFIG_OVERRIDE
7471: for this. Many packages generate the .pc from .pc.in, in that case add those
7472: files to the PKGCONFIG_OVERRIDE variable:
7473:
7474: PKGCONFIG_OVERRIDE+= foo.pc.in
7475:
7476:
7477: For packages using meson, the files are generated during build and you also
7478: need to change the phase in which the replacement is done. For example:
7479:
7480: PKGCONFIG_OVERRIDE+= output/meson-private/foo.pc
7481: PKGCONFIG_OVERRIDE_STAGE= post-build
7482:
7483:
7484: 21.6.8. Packages installing info files
1.1 dsieger 7485:
7486: Some packages install info files or use the "makeinfo" or "install-info"
7487: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
7488: and DEINSTALL scripts will be generated to handle registration of the info
7489: files in the Info directory file. The "install-info" command used for the info
7490: files registration is either provided by the system, or by a special purpose
7491: package automatically added as dependency if needed.
7492:
7493: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
7494: located. PKGINFODIR defaults to "info" and can be overridden by the user.
7495:
7496: The info files for the package should be listed in the package PLIST; however
7497: any split info files need not be listed.
7498:
7499: A package which needs the "makeinfo" command at build time must add "makeinfo"
7500: to USE_TOOLS in its Makefile. If a minimum version of the "makeinfo" command is
7501: needed it should be noted with the TEXINFO_REQD variable in the package
7502: Makefile. By default, a minimum version of 3.12 is required. If the system does
7503: not provide a makeinfo command or if it does not match the required minimum, a
7504: build dependency on the devel/gtexinfo package will be added automatically.
7505:
7506: The build and installation process of the software provided by the package
7507: should not use the install-info command as the registration of info files is
1.25 wiz 7508: the task of the package INSTALL script, and it must use the appropriate
1.1 dsieger 7509: makeinfo command.
7510:
7511: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
7512: the install-info and makeinfo commands in a directory listed early in PATH.
7513:
7514: The script overriding install-info has no effect except the logging of a
7515: message. The script overriding makeinfo logs a message and according to the
7516: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
7517: error.
7518:
1.254 wiz 7519: 21.6.9. Packages installing man pages
1.1 dsieger 7520:
7521: All packages that install manual pages should install them into the same
7522: directory, so that there is one common place to look for them. In pkgsrc, this
7523: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.25 wiz 7524: packages. The default for PKGMANDIR is "man". Another often-used value is "
7525: share/man".
1.1 dsieger 7526:
7527: Note
7528:
7529: The support for a custom PKGMANDIR is far from complete.
7530:
7531: The PLIST files can just use man/ as the top level directory for the man page
7532: file entries, and the pkgsrc framework will convert as needed. In all other
7533: places, the correct PKGMANDIR must be used.
7534:
7535: Packages that are configured with GNU_CONFIGURE set as "yes", by default will
7536: use the ./configure --mandir switch to set where the man pages should be
7537: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
7538: {PKGMANDIR}.
7539:
7540: Packages that use GNU_CONFIGURE but do not use --mandir, can set
7541: CONFIGURE_HAS_MANDIR to "no". Or if the ./configure script uses a non-standard
7542: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
7543:
1.184 rillig 7544: See Section 19.5, "Man page compression" for information on installation of
1.1 dsieger 7545: compressed manual pages.
7546:
1.254 wiz 7547: 21.6.10. Packages installing X11 fonts
1.1 dsieger 7548:
7549: If a package installs font files, you will need to rebuild the fonts database
7550: in the directory where they get installed at installation and deinstallation
7551: time. This can be automatically done by using the pkginstall framework.
7552:
7553: You can list the directories where fonts are installed in the FONTS_DIRS.type
7554: variables, where type can be one of "ttf", "type1" or "x11". Also make sure
7555: that the database file fonts.dir is not listed in the PLIST.
7556:
7557: Note that you should not create new directories for fonts; instead use the
7558: standard ones to avoid that the user needs to manually configure his X server
7559: to find them.
7560:
1.254 wiz 7561: 21.6.11. Packages installing SGML or XML data
1.1 dsieger 7562:
7563: If a package installs SGML or XML data files that need to be registered in
7564: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
7565: extra steps:
7566:
7567: 1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
7568: care of registering those files in system-wide catalogs at installation and
7569: deinstallation time.
7570:
7571: 2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
7572: package.
7573:
7574: 3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
7575: package.
7576:
7577: 4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
7578: These come in groups of three strings; see xmlcatmgr(1) for more
7579: information (specifically, arguments recognized by the 'add' action). Note
7580: that you will normally not use this variable.
7581:
7582: 5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
7583: come in groups of three strings; see xmlcatmgr(1) for more information
7584: (specifically, arguments recognized by the 'add' action). Note that you
7585: will normally not use this variable.
7586:
1.254 wiz 7587: 21.6.12. Packages installing extensions to the MIME database
1.1 dsieger 7588:
7589: If a package provides extensions to the MIME database by installing .xml files
7590: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
7591: ensure that the database is kept consistent with respect to these new files:
7592:
7593: 1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
7594: buildlink3.mk file from this same directory, which is reserved for
7595: inclusion from other buildlink3.mk files). It takes care of rebuilding the
7596: MIME database at installation and deinstallation time, and disallows any
7597: access to it directly from the package.
7598:
1.25 wiz 7599: 2. Check the PLIST and remove any entries under the share/mime directory,
1.1 dsieger 7600: except for files saved under share/mime/packages. The former are handled
7601: automatically by the update-mime-database program, but the latter are
7602: package-dependent and must be removed by the package that installed them in
7603: the first place.
7604:
7605: 3. Remove any share/mime/* directories from the PLIST. They will be handled by
7606: the shared-mime-info package.
7607:
1.254 wiz 7608: 21.6.13. Packages using intltool
1.1 dsieger 7609:
7610: If a package uses intltool during its build, add intltool to the USE_TOOLS,
7611: which forces it to use the intltool package provided by pkgsrc, instead of the
7612: one bundled with the distribution file.
7613:
7614: This tracks intltool's build-time dependencies and uses the latest available
7615: version; this way, the package benefits of any bug fixes that may have appeared
7616: since it was released.
7617:
1.254 wiz 7618: 21.6.14. Packages installing startup scripts
1.1 dsieger 7619:
1.256 wiz 7620: If a package contains an rc.d script, it won't be copied into the startup
7621: directory (/etc/rc.d) by default, but you can enable copying by setting the
7622: option PKG_RCD_SCRIPTS=YES in mk.conf. With PKG_RCD_SCRIPTS=YES, rc.d scripts
7623: will be copied into /etc/rc.d when a package is installed, but only if the
7624: target does not already exist. Copies in /etc/rc.d will be automatically
7625: removed only if they have not been modified.
7626:
7627: Note that this alone does not enable the service: It must still be added to /
7628: etc/rc.conf.
1.1 dsieger 7629:
1.254 wiz 7630: 21.6.15. Packages installing TeX modules
1.1 dsieger 7631:
7632: If a package installs TeX packages into the texmf tree, the ls-R database of
7633: the tree needs to be updated.
7634:
7635: Note
7636:
1.23 jakllsch 7637: Except the main TeX packages such as kpathsea, packages should install files
7638: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1 dsieger 7639:
1.23 jakllsch 7640: 1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
7641: ls-R database at installation and deinstallation time.
1.1 dsieger 7642:
1.23 jakllsch 7643: 2. If your package installs files into a texmf tree other than the one at $
7644: {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
7645: trees that need database update.
1.1 dsieger 7646:
7647: If your package also installs font map files that need to be registered
1.30 dholland 7648: using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
7649: and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then
7650: updmap will be run automatically at installation/deinstallation to enable/
7651: disable font map files for TeX output drivers.
1.1 dsieger 7652:
7653: 3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30 dholland 7654: be removed only by the kpathsea package.
1.1 dsieger 7655:
1.254 wiz 7656: 21.6.16. Packages supporting running binaries in emulation
1.1 dsieger 7657:
7658: There are some packages that provide libraries and executables for running
7659: binaries from a one operating system on a different one (if the latter supports
7660: it). One example is running Linux binaries on NetBSD.
7661:
7662: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
7663:
7664: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
7665: if all libraries for each installed executable can be found by the dynamic
7666: linker. Since the standard dynamic linker is run, this fails for emulation
7667: packages, because the libraries used by the emulation are not in the standard
7668: directories.
7669:
1.254 wiz 7670: 21.6.17. Packages installing hicolor icons
1.1 dsieger 7671:
7672: If a package installs images under the share/icons/hicolor and/or updates the
7673: share/icons/hicolor/icon-theme.cache database, you need to take some extra
7674: steps to make sure that the shared theme directory is handled appropriately and
7675: that the cache database is rebuilt:
7676:
7677: 1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
7678:
7679: 2. Check the PLIST and remove the entry that refers to the theme cache.
7680:
7681: 3. Ensure that the PLIST does not remove the shared icon directories from the
7682: share/icons/hicolor hierarchy because they will be handled automatically.
7683:
7684: The best way to verify that the PLIST is correct with respect to the last two
7685: points is to regenerate it using make print-PLIST.
7686:
1.254 wiz 7687: 21.6.18. Packages installing desktop files
1.1 dsieger 7688:
7689: If a package installs .desktop files under share/applications and these include
1.54 rodent 7690: MIME information (MimeType key), you need to take extra steps to ensure that
7691: they are registered into the MIME database:
1.1 dsieger 7692:
7693: 1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
7694:
7695: 2. Check the PLIST and remove the entry that refers to the share/applications/
7696: mimeinfo.cache file. It will be handled automatically.
7697:
7698: The best way to verify that the PLIST is correct with respect to the last point
7699: is to regenerate it using make print-PLIST.
7700:
1.154 rillig 7701: 21.7. Marking packages as having problems
1.1 dsieger 7702:
1.23 jakllsch 7703: In some cases one does not have the time to solve a problem immediately. In
7704: this case, one can plainly mark a package as broken. For this, one just sets
7705: the variable BROKEN to the reason why the package is broken (similar to the
1.162 rillig 7706: PKG_FAIL_REASON variable). A user trying to build the package will immediately
7707: be shown this message, and the build will not be even tried.
1.1 dsieger 7708:
1.23 jakllsch 7709: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1 dsieger 7710:
1.184 rillig 7711: Chapter 22. GNOME packaging and porting
7712:
7713: Table of Contents
7714:
7715: 22.1. Meta packages
7716: 22.2. Packaging a GNOME application
7717: 22.3. Updating GNOME to a newer version
7718: 22.4. Patching guidelines
7719:
7720: Quoting GNOME's web site:
7721:
7722: The GNOME project provides two things: The GNOME desktop environment, an
7723: intuitive and attractive desktop for users, and the GNOME development
7724: platform, an extensive framework for building applications that integrate
7725: into the rest of the desktop.
7726:
7727: pkgsrc provides a seamless way to automatically build and install a complete
7728: GNOME environment under many different platforms. We can say with confidence
7729: that pkgsrc is one of the most advanced build and packaging systems for GNOME
7730: due to its included technologies buildlink3, the wrappers and tools framework
7731: and automatic configuration file management. Lots of efforts are put into
7732: achieving a completely clean deinstallation of installed software components.
7733:
7734: Given that pkgsrc is NetBSD's official packaging system, the above also means
7735: that great efforts are put into making GNOME work under this operating system.
7736:
7737: This chapter is aimed at pkgsrc developers and other people interested in
7738: helping our GNOME porting and packaging efforts. It provides instructions on
7739: how to manage the existing packages and some important information regarding
7740: their internals.
7741:
7742: 22.1. Meta packages
7743:
7744: pkgsrc includes three GNOME-related meta packages:
7745:
7746: * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
7747: includes the necessary bits to get it to boot correctly, although it may
7748: lack important functionality for daily operation. The idea behind this
7749: package is to let end users build their own configurations on top of this
7750: one, first installing this meta package to achieve a functional setup and
7751: then adding individual applications.
7752:
7753: * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
7754: desktop as defined by the GNOME project; this is based on the components
7755: distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
7756: directories of the official FTP server. Developer-only tools found in those
7757: directories are not installed unless required by some other component to
7758: work properly. Similarly, packages from the bindings set (bindings/x.y/
7759: x.y.z/sources) are not pulled in unless required as a dependency for an
7760: end-user component. This package "extends" meta-pkgs/gnome-base.
7761:
7762: * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
7763: component when fetched from the CVS repository. These are required to let
7764: the autogen.sh scripts work appropriately.
7765:
7766: In all these packages, the DEPENDS lines are sorted in a way that eases
7767: updates: a package may depend on other packages listed before it but not on any
7768: listed after it. It is very important to keep this order to ease updates so...
7769: do not change it to alphabetical sorting!
7770:
7771: 22.2. Packaging a GNOME application
7772:
7773: Almost all GNOME applications are written in C and use a common set of tools as
7774: their build system. Things get different with the new bindings to other
7775: languages (such as Python), but the following will give you a general idea on
7776: the minimum required tools:
7777:
7778: * Almost all GNOME applications use the GNU Autotools as their build system.
7779: As a general rule you will need to tell this to your package:
7780:
1.223 nia 7781: GNU_CONFIGURE= yes
7782: USE_LIBTOOL= yes
7783: USE_TOOLS+= gmake
1.184 rillig 7784:
7785: * If the package uses pkg-config to detect dependencies, add this tool to the
7786: list of required utilities:
7787:
1.223 nia 7788: USE_TOOLS+= pkg-config
1.184 rillig 7789:
7790: Also use pkgtools/verifypc at the end of the build process to ensure that
7791: you did not miss to specify any dependency in your package and that the
7792: version requirements are all correct.
7793:
7794: * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
7795: handle dependencies and to force the package to use the latest available
7796: version.
7797:
7798: * If the package uses gtk-doc (a documentation generation utility), do not
7799: add a dependency on it. The tool is rather big and the distfile should come
7800: with pregenerated documentation anyway; if it does not, it is a bug that
7801: you ought to report. For such packages you should disable gtk-doc (unless
7802: it is the default):
7803:
1.223 nia 7804: CONFIGURE_ARGS+= --disable-gtk-doc
1.184 rillig 7805:
7806: The default location of installed HTML files (share/gtk-doc/<package-name>)
7807: is correct and should not be changed unless the package insists on
7808: installing them somewhere else. Otherwise programs as devhelp will not be
7809: able to open them. You can do that with an entry similar to:
1.1 dsieger 7810:
1.223 nia 7811: CONFIGURE_ARGS+= --with-html-dir=${PREFIX}/share/gtk-doc/...
1.1 dsieger 7812:
1.184 rillig 7813: GNOME uses multiple shared directories and files under the installation prefix
7814: to maintain databases. In this context, shared means that those exact same
7815: directories and files are used among several different packages, leading to
7816: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
7817: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
7818: your file lists and omitting shared files from them. If you find yourself doing
7819: those, your package is most likely incorrect.
1.1 dsieger 7820:
1.184 rillig 7821: The following table lists the common situations that result in using shared
7822: directories or files. For each of them, the appropriate solution is given.
7823: After applying the solution be sure to regenerate the package's file list with
7824: make print-PLIST and ensure it is correct.
1.1 dsieger 7825:
1.184 rillig 7826: Table 22.1. PLIST handling for GNOME packages
1.1 dsieger 7827:
1.184 rillig 7828: +-----------------------------------------------------------------------------+
7829: | If the package... | Then... |
7830: |-------------------------------------------+---------------------------------|
1.254 wiz 7831: |Installs icons under the share/icons/ |See Section 21.6.17, "Packages |
1.203 nia 7832: |hicolor hierarchy or updates share/icons/ |installing hicolor icons". |
1.184 rillig 7833: |hicolor/icon-theme.cache. | |
7834: |-------------------------------------------+---------------------------------|
1.254 wiz 7835: | |See Section 21.6.12, "Packages |
1.184 rillig 7836: |Installs files under share/mime/packages. |installing extensions to the MIME|
7837: | |database". |
7838: |-------------------------------------------+---------------------------------|
1.254 wiz 7839: |Installs .desktop files under share/ |See Section 21.6.18, "Packages |
1.184 rillig 7840: |applications and these include MIME |installing desktop files". |
7841: |information. | |
7842: +-----------------------------------------------------------------------------+
1.1 dsieger 7843:
7844:
1.184 rillig 7845: 22.3. Updating GNOME to a newer version
1.1 dsieger 7846:
1.184 rillig 7847: When seeing GNOME as a whole, there are two kinds of updates:
1.1 dsieger 7848:
1.184 rillig 7849: Major update
1.1 dsieger 7850:
1.184 rillig 7851: Given that there is still a very long way for GNOME 3 (if it ever appears),
7852: we consider a major update one that goes from a 2.X version to a 2.Y one,
7853: where Y is even and greater than X. These are hard to achieve because they
7854: introduce lots of changes in the components' code and almost all GNOME
7855: distfiles are updated to newer versions. Some of them can even break API
7856: and ABI compatibility with the previous major version series. As a result,
7857: the update needs to be done all at once to minimize breakage.
1.1 dsieger 7858:
1.184 rillig 7859: A major update typically consists of around 80 package updates and the
7860: addition of some new ones.
1.1 dsieger 7861:
1.184 rillig 7862: Minor update
1.1 dsieger 7863:
1.184 rillig 7864: We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
7865: one where Y is greater than X. These are easy to achieve because they do
7866: not update all GNOME components, can be done in an incremental way and do
7867: not break API nor ABI compatibility.
1.1 dsieger 7868:
1.184 rillig 7869: A minor update typically consists of around 50 package updates, although
7870: the numbers here may vary a lot.
1.1 dsieger 7871:
1.184 rillig 7872: In order to update the GNOME components in pkgsrc to a new stable release
7873: (either major or minor), the following steps should be followed:
1.1 dsieger 7874:
1.184 rillig 7875: 1. Get a list of all the tarballs that form the new release by using the
7876: following commands. These will leave the full list of the components'
7877: distfiles into the list.txt file:
1.1 dsieger 7878:
1.184 rillig 7879: % echo ls "*.tar.bz2" | \
7880: ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
7881: awk '{ print $9 }' >list.txt
7882: % echo ls "*.tar.bz2" | \
7883: ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
7884: awk '{ print $9 }' >>list.txt
1.1 dsieger 7885:
1.184 rillig 7886: 2. Open each meta package's Makefile and bump their version to the release you
7887: are updating them to. The three meta packages should be always consistent
7888: with versioning. Obviously remove any PKGREVISIONs that might be in them.
1.1 dsieger 7889:
1.184 rillig 7890: 3. For each meta package, update all its DEPENDS lines to match the latest
7891: versions as shown by the above commands. Do not list any newer version
7892: (even if found in the FTP) because the meta packages are supposed to list
7893: the exact versions that form a specific GNOME release. Exceptions are
7894: permitted here if a newer version solves a serious issue in the overall
7895: desktop experience; these typically come in the form of a revision bump in
7896: pkgsrc, not in newer versions from the developers.
1.1 dsieger 7897:
1.184 rillig 7898: Packages not listed in the list.txt file should be updated to the latest
7899: version available (if found in pkgsrc). This is the case, for example, of
7900: the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
7901: package.
1.1 dsieger 7902:
1.184 rillig 7903: 4. Generate a patch from the modified meta packages and extract the list of
7904: "new" lines. This will provide you an outline on what packages need to be
7905: updated in pkgsrc and in what order:
1.1 dsieger 7906:
1.184 rillig 7907: % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
1.1 dsieger 7908:
1.184 rillig 7909: 5. For major desktop updates it is recommended to zap all your installed
7910: packages and start over from scratch at this point.
1.1 dsieger 7911:
1.184 rillig 7912: 6. Now comes the longest step by far: iterate over the contents of todo.txt
7913: and update the packages listed in it in order. For major desktop updates
7914: none of these should be committed until the entire set is completed because
7915: there are chances of breaking not-yet-updated packages.
1.1 dsieger 7916:
1.184 rillig 7917: 7. Once the packages are up to date and working, commit them to the tree one
7918: by one with appropriate log messages. At the end, commit the three meta
7919: package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
7920: and pkgsrc/doc/TODO files.
1.1 dsieger 7921:
1.184 rillig 7922: 22.4. Patching guidelines
1.1 dsieger 7923:
1.184 rillig 7924: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
7925: it is very important that you always, always, always feed back any portability
7926: fixes you do to a GNOME package to the mainstream developers (see
7927: Section 12.3.5, "Feedback to the author"). This is the only way to get their
7928: attention on portability issues and to ensure that future versions can be built
7929: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
7930: updates are. Those developers in charge of issuing major GNOME updates will be
7931: grateful if you do that.
1.1 dsieger 7932:
1.200 cirnatda 7933: The most common places to report bugs are the GNOME's GitLab and the
7934: freedesktop.org's GitLab. Not all components use these to track bugs, but most
7935: of them do. Do not be short on your reports: always provide detailed
1.184 rillig 7936: explanations of the current failure, how it can be improved to achieve maximum
1.200 cirnatda 7937: portability and, if at all possible, provide a patch against the main Git
7938: branch. The more verbose you are, the higher chances of your patch being
7939: accepted.
1.1 dsieger 7940:
1.184 rillig 7941: Also, please avoid using preprocessor magic to fix portability issues. While
7942: the FreeBSD GNOME people are doing a great job in porting GNOME to their
7943: operating system, the official GNOME sources are now plagued by conditionals
7944: that check for __FreeBSD__ and similar macros. This hurts portability. Please
7945: see our patching guidelines (Section 12.3.4, "Patching guidelines") for more
7946: details.
1.1 dsieger 7947:
1.154 rillig 7948: Chapter 23. Submitting and Committing
1.1 dsieger 7949:
7950: Table of Contents
7951:
1.154 rillig 7952: 23.1. Submitting binary packages
7953: 23.2. Submitting source packages (for non-NetBSD-developers)
7954: 23.3. General notes when adding, updating, or removing packages
7955: 23.4. Commit Messages
7956: 23.5. Committing: Adding a package to CVS
7957: 23.6. Updating a package to a newer version
7958: 23.7. Renaming a package in pkgsrc
7959: 23.8. Moving a package in pkgsrc
1.1 dsieger 7960:
1.154 rillig 7961: 23.1. Submitting binary packages
1.1 dsieger 7962:
7963: Our policy is that we accept binaries only from pkgsrc developers to guarantee
7964: that the packages don't contain any trojan horses etc. This is not to annoy
7965: anyone but rather to protect our users! You're still free to put up your
7966: home-made binary packages and tell the world where to get them. NetBSD
1.154 rillig 7967: developers doing bulk builds and wanting to upload them please see Chapter 8,
1.66 asau 7968: Creating binary packages for everything in pkgsrc (bulk builds).
1.1 dsieger 7969:
1.154 rillig 7970: 23.2. Submitting source packages (for non-NetBSD-developers)
1.1 dsieger 7971:
1.218 nia 7972: Firstly, you can import new packages into pkgsrc-wip ("pkgsrc work-in-progress"
7973: ); see the homepage at https://pkgsrc.org/wip/ for details.
7974:
7975: Next, check that your package is complete, compiles and runs well; see
1.184 rillig 7976: Chapter 14, Creating a new pkgsrc package from scratch and the rest of this
1.218 nia 7977: document. Run the pkgtools/pkglint tool and fix any errors that appear.
7978:
7979: Finally, send a report to the pkgsrc bug tracking system, either with the
7980: send-pr(1) command, or if you don't have that, go to the web page https://
7981: www.NetBSD.org/support/send-pr.html, which contains some instructions and a
7982: link to a form where you can submit packages. The sysutils/gtk-send-pr package
7983: is also available as a substitute for either of the above two tools.
1.1 dsieger 7984:
7985: In the form of the problem report, the category should be "pkg", the synopsis
7986: should include the package name and version number, and the description field
7987: should contain a short description of your package (contents of the COMMENT
1.218 nia 7988: variable or DESCR file are OK).
1.1 dsieger 7989:
1.154 rillig 7990: 23.3. General notes when adding, updating, or removing packages
1.1 dsieger 7991:
7992: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
7993: CHANGES-YYYY. It's very important to keep this file up to date and conforming
7994: to the existing format, because it will be used by scripts to automatically
7995: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
7996: doc/TODO file and remove the entry for the package you updated or removed, in
7997: case it was mentioned there.
7998:
7999: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
8000: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
8001: that result from a dependency being updated should not be mentioned. In all
8002: other cases it's the developer's decision.
8003:
8004: There is a make target that helps in creating proper CHANGES-YYYY entries: make
8005: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
8006: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
8007: (to avoid having to resolve conflicts later-on) and then to cd to the package
8008: directory. For package updates, make changes-entry is enough. For new packages,
8009: or package moves or removals, set the CTYPE variable on the command line to
1.4 rillig 8010: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23 jakllsch 8011: your local login name is not the same as your NetBSD login name. The target
8012: also automatically removes possibly existing entries for the package in the
8013: TODO file. Don't forget to commit the changes, e.g. by using make
1.66 asau 8014: commit-changes-entry! If you are not using a checkout directly from
1.23 jakllsch 8015: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
8016: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1 dsieger 8017:
1.154 rillig 8018: 23.4. Commit Messages
1.130 wiz 8019:
8020: For several years, there have been mirrors of pkgsrc in fossil, git, and hg.
1.257 jkoshy 8021: Standard practice when using these tools is to make the first line of a commit
1.130 wiz 8022: message function as a summary that can be read without the rest, such as is
8023: commonly done with "git log --oneline". For this reason, we have the following
8024: guidelines for pkgsrc commit messages:
8025:
1.131 wiz 8026: * Start the commit message with a line that explains the big picture in 65
1.130 wiz 8027: characters or less. When a commit is for one package, include the name of
8028: the package. For updates, include the version to which it is updated.
8029:
8030: * Leave the next line empty.
8031:
8032: * Then come the details for the commit (changes in that package, reason for a
8033: change) and any relevant PRs. Wrap this section.
8034:
8035: Here is an example:
8036:
1.238 wiz 8037: libxslt: update to 1.0.30
1.130 wiz 8038:
1.238 wiz 8039: Changes since 1.0.29:
8040: ...
1.130 wiz 8041:
8042: Here is another example:
8043:
1.238 wiz 8044: mk/bsd.pkg.mk: enable SSP by default on NetBSD
1.130 wiz 8045:
1.238 wiz 8046: (rationale)
1.130 wiz 8047:
8048: Commit messages are final: no "cvs admin" is allowed on the pkgsrc repository
8049: to change commit messages.
8050:
1.154 rillig 8051: 23.5. Committing: Adding a package to CVS
1.1 dsieger 8052:
8053: This section is only of interest for pkgsrc developers with write access to the
1.34 wiz 8054: pkgsrc repository.
8055:
8056: When the package is finished, "cvs add" the files. Start by adding the
8057: directory and then files in the directory. Don't forget to add the new package
8058: to the category's Makefile. Make sure you don't forget any files; you can check
8059: by running "cvs status". An example:
8060:
8061: $ cd .../pkgsrc/category
8062: $ cvs add pkgname
8063: $ cd pkgname
8064: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
8065: $ cvs add patches/p*
8066: $ cvs status | less
1.35 wiz 8067: $ cvs commit
1.34 wiz 8068: $ cd ..
1.236 gutterid 8069: $ vi Makefile # add SUBDIR+=pkgname line
1.35 wiz 8070: $ cvs commit Makefile
1.66 asau 8071: $ cd pkgname
1.73 jnemeth 8072: $ make CTYPE=Added commit-changes-entry
1.1 dsieger 8073:
8074: The commit message of the initial import should include part of the DESCR file,
8075: so people reading the mailing lists know what the package is/does.
8076:
1.34 wiz 8077: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
8078:
8079: Previously, "cvs import" was suggested, but it was much easier to get wrong
8080: than "cvs add".
1.1 dsieger 8081:
1.154 rillig 8082: 23.6. Updating a package to a newer version
1.1 dsieger 8083:
8084: Please always put a concise, appropriate and relevant summary of the changes
8085: between old and new versions into the commit log when updating a package. There
8086: are various reasons for this:
8087:
8088: * A URL is volatile, and can change over time. It may go away completely or
8089: its information may be overwritten by newer information.
8090:
8091: * Having the change information between old and new versions in our CVS
8092: repository is very useful for people who use either cvs or anoncvs.
8093:
8094: * Having the change information between old and new versions in our CVS
8095: repository is very useful for people who read the pkgsrc-changes mailing
8096: list, so that they can make tactical decisions about when to upgrade the
8097: package.
8098:
8099: Please also recognize that, just because a new version of a package has been
8100: released, it should not automatically be upgraded in the CVS repository. We
8101: prefer to be conservative in the packages that are included in pkgsrc -
8102: development or beta packages are not really the best thing for most places in
8103: which pkgsrc is used. Please use your judgement about what should go into
8104: pkgsrc, and bear in mind that stability is to be preferred above new and
8105: possibly untested features.
8106:
1.154 rillig 8107: 23.7. Renaming a package in pkgsrc
1.21 snj 8108:
8109: Renaming packages is not recommended.
8110:
1.175 gutterid 8111: When renaming packages, be sure to fix any references to the old name in other
1.21 snj 8112: Makefiles, options, buildlink files, etc.
8113:
1.175 gutterid 8114: Also, when renaming a package, please add the package name and version pattern
1.167 leot 8115: (s) of the previous package to SUPERSEDES. This may be repeated for multiple
8116: renames. The new package would be an exact replacement. Example:
8117:
8118: SUPERSEDES+= p5-IO-Compress-Zlib<2.017
8119: SUPERSEDES+= optcomp-[0-9]*
1.21 snj 8120:
8121: Note that "successor" in the CHANGES-YYYY file doesn't necessarily mean that it
8122: supersedes, as that successor may not be an exact replacement but is a
8123: suggestion for the replaced functionality.
8124:
1.154 rillig 8125: 23.8. Moving a package in pkgsrc
1.21 snj 8126:
8127: It is preferred that packages are not renamed or moved, but if needed please
8128: follow these steps.
1.1 dsieger 8129:
8130: 1. Make a copy of the directory somewhere else.
8131:
8132: 2. Remove all CVS dirs.
8133:
8134: Alternatively to the first two steps you can also do:
8135:
8136: % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
8137:
8138: and use that for further work.
8139:
1.25 wiz 8140: 3. Fix CATEGORIES and any DEPENDS paths that just did "../package" instead of
1.1 dsieger 8141: "../../category/package".
8142:
1.21 snj 8143: 4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
8144: previous category/package pathname. The PREV_PKGPATH can be used by tools
8145: for doing an update using pkgsrc building; for example, it can search the
8146: pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
8147: the corresponding new PKGPATH for that moved package. Note that it may have
8148: multiple matches, so the tool should also check on the PKGBASE too. The
8149: PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
8150: PKGBASE stays the same.
8151:
1.237 gutterid 8152: 5. cvs add the modified package in the new place.
1.1 dsieger 8153:
1.21 snj 8154: 6. Check if any package depends on it:
1.1 dsieger 8155:
8156: % cd /usr/pkgsrc
8157: % grep /package */*/Makefile* */*/buildlink*
8158:
1.21 snj 8159: 7. Fix paths in packages from step 5 to point to new location.
1.1 dsieger 8160:
1.21 snj 8161: 8. cvs rm (-f) the package at the old location.
1.1 dsieger 8162:
1.21 snj 8163: 9. Remove from oldcategory/Makefile.
1.1 dsieger 8164:
1.21 snj 8165: 10. Add to newcategory/Makefile.
1.1 dsieger 8166:
1.21 snj 8167: 11. Commit the changed and removed files:
1.1 dsieger 8168:
8169: % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
8170:
8171: (and any packages from step 5, of course).
8172:
1.263 ! wiz 8173: Chapter 24. pkgsrc Policies
! 8174:
! 8175: Table of Contents
! 8176:
! 8177: 24.1. Packages for which updating is restricted
! 8178: 24.1.1. Limited Updates - ABI
! 8179: 24.1.2. Limited Updates - Bootstrap
! 8180:
! 8181: 24.1. Packages for which updating is restricted
! 8182:
! 8183: In the past, some packages have caused more package failures than others, and
! 8184: we'd like to reduce this in the future.
! 8185:
! 8186: For this reason, pkgsrc-pmc marks some packages with POLICY_UPDATE_LIMITED. The
! 8187: possible values currently are:
! 8188:
! 8189: * abi for packages where ABI/API changes often broke the packages depending
! 8190: on them
! 8191:
! 8192: * bootstrap for packages that are used during the pkgsrc bootstrap
! 8193:
! 8194: pkglint will warn when committing updates to these packages.
! 8195:
! 8196: 24.1.1. Limited Updates - ABI
! 8197:
! 8198: Before committing non-micro version updates to packages marked with
! 8199: POLICY_UPDATE_LIMITED=abi, a limited bulk build of meta-pkgs/bulk-test-$
! 8200: {PACKAGE} needs to be run and the result posted to the tech-pkg mailing list,
! 8201: highlighting what packages would stop building (if any).
! 8202:
! 8203: Depending on the result, pkgsrc-pmc then decides:
! 8204:
! 8205: * go ahead with the update
! 8206:
! 8207: * wait for packages X, Y, Z to be fixed (upstream or locally) with the
! 8208: updated version, which is put in wip in the meantime
! 8209:
! 8210: * In the second case, all pkgsrc developers are encouraged to work on fixing
! 8211: this - it is not only the updater's task to fix them.
! 8212:
! 8213: The decision to wait for packages can be revisited.
! 8214:
! 8215: 24.1.2. Limited Updates - Bootstrap
! 8216:
! 8217: When updating packages used in the bootstrap, i.e. marked with
! 8218: POLICY_UPDATE_LIMITED=bootstrap, test the bootstrap process and preferably some
! 8219: basic packages and send the patch to the tech-pkg mailing list so it can be
! 8220: tested on other platforms as well. Give at least two weeks for feedback and
! 8221: testing by others.
! 8222:
! 8223: Chapter 25. Frequently Asked Questions
1.1 dsieger 8224:
8225: This section contains the answers to questions that may arise when you are
8226: writing a package. If you don't find your question answered here, first have a
8227: look in the other chapters, and if you still don't have the answer, ask on the
8228: pkgsrc-users mailing list.
8229:
1.263 ! wiz 8230: 25.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
! 8231: 25.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
! 8232: 25.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
! 8233: 25.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
! 8234: 25.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.259 leot 8235: the := inside it.
1.263 ! wiz 8236: 25.6. Which mailing lists are there for package developers?
! 8237: 25.7. Where is the pkgsrc documentation?
! 8238: 25.8. I have a little time to kill. What shall I do?
1.1 dsieger 8239:
1.263 ! wiz 8240: 25.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1 dsieger 8241:
8242: MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
1.223 nia 8243: (1).
8244:
8245: MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM when
8246: building the package.
8247:
8248: .MAKEFLAGS is an internal variable of bmake and should not be used by
8249: packages.
1.1 dsieger 8250:
1.263 ! wiz 8251: 25.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1 dsieger 8252:
8253: MAKE is the path to the make(1) program that is used in the pkgsrc
1.223 nia 8254: infrastructure.
8255:
8256: GMAKE is the path to GNU Make, but you need to say USE_TOOLS+=gmake to
8257: use that.
8258:
8259: MAKE_PROGRAM is the path to the Make program that is used for building
8260: the package.
1.1 dsieger 8261:
1.263 ! wiz 8262: 25.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1 dsieger 8263:
8264: CC is the path to the real C compiler, which can be configured by the
1.223 nia 8265: pkgsrc user.
1.1 dsieger 8266:
1.223 nia 8267: PKG_CC is the path to the compiler wrapper.
1.1 dsieger 8268:
1.223 nia 8269: PKGSRC_COMPILER is not a path to a compiler, but the type of compiler
8270: that should be used. See mk/compiler.mk for more information about the
8271: latter variable.
1.1 dsieger 8272:
1.263 ! wiz 8273: 25.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1 dsieger 8274:
1.25 wiz 8275: For optimization reasons, some variables are only available in the "
8276: wrapper" phase and later. To "simulate" the wrapper phase, append
1.1 dsieger 8277: PKG_PHASE=wrapper to the above command.
8278:
1.263 ! wiz 8279: 25.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1 dsieger 8280: the := inside it.
8281:
1.223 nia 8282: The := is not an assignment operator, even though it may look like one.
1.108 rillig 8283: Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
8284: is documented in the make(1) man page and which is commonly used in the
8285: form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
8286: string and new_string is package/. That's where the : and the = fall
8287: together.
1.1 dsieger 8288:
1.263 ! wiz 8289: 25.6. Which mailing lists are there for package developers?
1.1 dsieger 8290:
8291: tech-pkg
8292:
8293: This is a list for technical discussions related to pkgsrc
8294: development, e.g. soliciting feedback for changes to pkgsrc
8295: infrastructure, proposed new features, questions related to porting
8296: pkgsrc to a new platform, advice for maintaining a package, patches
8297: that affect many packages, help requests moved from pkgsrc-users when
8298: an infrastructure bug is found, etc.
8299:
8300: pkgsrc-bugs
8301:
8302: All bug reports in category "pkg" sent with send-pr(1) appear here.
8303: Please do not report your bugs here directly; use one of the other
8304: mailing lists.
1.259 leot 8305:
1.263 ! wiz 8306: 25.7. Where is the pkgsrc documentation?
1.1 dsieger 8307:
8308: There are many places where you can find documentation about pkgsrc:
8309:
8310: * The pkgsrc guide (this document) is a collection of chapters that
8311: explain large parts of pkgsrc, but some chapters tend to be outdated.
8312: Which ones they are is hard to say.
8313:
1.174 leot 8314: * On the mailing list archives (see https://mail-index.NetBSD.org/),
8315: you can find discussions about certain features, announcements of new
1.1 dsieger 8316: parts of the pkgsrc infrastructure and sometimes even announcements
8317: that a certain feature has been marked as obsolete. The benefit here
8318: is that each message has a date appended to it.
8319:
8320: * Many of the files in the mk/ directory start with a comment that
8321: describes the purpose of the file and how it can be used by the
8322: pkgsrc user and package authors. An easy way to find this
8323: documentation is to run bmake help.
8324:
8325: * The CVS log messages are a rich source of information, but they tend
8326: to be highly abbreviated, especially for actions that occur often.
8327: Some contain a detailed description of what has changed, but they are
8328: geared towards the other pkgsrc developers, not towards an average
8329: pkgsrc user. They also only document changes, so if you don't know
8330: what has been before, these messages may not be worth too much to
8331: you.
8332:
8333: * Some parts of pkgsrc are only "implicitly documented", that is the
8334: documentation exists only in the mind of the developer who wrote the
8335: code. To get this information, use the cvs annotate command to see
8336: who has written it and ask on the tech-pkg mailing list, so that
8337: others can find your questions later (see above). To be sure that the
8338: developer in charge reads the mail, you may CC him or her.
8339:
1.263 ! wiz 8340: 25.8. I have a little time to kill. What shall I do?
1.1 dsieger 8341:
8342: This is not really an FAQ yet, but here's the answer anyway.
8343:
8344: * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
8345: about newer versions of installed packages that are available, but
8346: not yet updated in pkgsrc.
8347:
1.198 leot 8348: * Browse pkgsrc/doc/TODO -- it contains a list of suggested new
8349: packages and a list of cleanups and enhancements for pkgsrc that
8350: would be nice to have.
1.1 dsieger 8351:
1.71 wiz 8352: * Review packages for which review was requested on the tech-pkg
8353: mailing list.
1.1 dsieger 8354:
8355: Part III. The pkgsrc infrastructure internals
8356:
8357: This part of the guide deals with everything from the infrastructure that is
8358: behind the interfaces described in the developer's guide. A casual package
8359: maintainer should not need anything from this part.
8360:
8361: Table of Contents
8362:
1.263 ! wiz 8363: 26. Design of the pkgsrc infrastructure
! 8364: 26.1. The meaning of variable definitions
! 8365: 26.2. Avoiding problems before they arise
! 8366: 26.3. Variable evaluation
! 8367: 26.3.1. At load time
! 8368: 26.3.2. At runtime
! 8369: 26.4. How can variables be specified?
! 8370: 26.5. Designing interfaces for Makefile fragments
! 8371: 26.5.1. Procedures with parameters
! 8372: 26.5.2. Actions taken on behalf of parameters
! 8373: 26.6. The order in which files are loaded
! 8374: 26.6.1. The order in bsd.prefs.mk
! 8375: 26.6.2. The order in bsd.pkg.mk
! 8376: 27. Regression tests
! 8377: 27.1. Running the regression tests
! 8378: 27.2. Adding a new regression test
! 8379: 27.2.1. Overridable functions
! 8380: 27.2.2. Helper functions
! 8381: 28. Porting pkgsrc
! 8382: 28.1. Porting pkgsrc to a new operating system
1.1 dsieger 8383:
1.263 ! wiz 8384: Chapter 26. Design of the pkgsrc infrastructure
1.1 dsieger 8385:
8386: Table of Contents
8387:
1.263 ! wiz 8388: 26.1. The meaning of variable definitions
! 8389: 26.2. Avoiding problems before they arise
! 8390: 26.3. Variable evaluation
! 8391: 26.3.1. At load time
! 8392: 26.3.2. At runtime
! 8393: 26.4. How can variables be specified?
! 8394: 26.5. Designing interfaces for Makefile fragments
! 8395: 26.5.1. Procedures with parameters
! 8396: 26.5.2. Actions taken on behalf of parameters
! 8397: 26.6. The order in which files are loaded
! 8398: 26.6.1. The order in bsd.prefs.mk
! 8399: 26.6.2. The order in bsd.pkg.mk
1.1 dsieger 8400:
8401: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
8402: fragment needs a properly specified interface. This chapter explains how such
8403: an interface looks like.
8404:
1.263 ! wiz 8405: 26.1. The meaning of variable definitions
1.1 dsieger 8406:
8407: Whenever a variable is defined in the pkgsrc infrastructure, the location and
8408: the way of definition provide much information about the intended use of that
8409: variable. Additionally, more documentation may be found in a header comment or
8410: in this pkgsrc guide.
8411:
8412: A special file is mk/defaults/mk.conf, which lists all variables that are
8413: intended to be user-defined. They are either defined using the ?= operator or
8414: they are left undefined because defining them to anything would effectively
8415: mean "yes". All these variables may be overridden by the pkgsrc user in the
8416: MAKECONF file.
8417:
8418: Outside this file, the following conventions apply: Variables that are defined
8419: using the ?= operator may be overridden by a package.
8420:
8421: Variables that are defined using the = operator may be used read-only at
8422: run-time.
8423:
8424: Variables whose name starts with an underscore must not be accessed outside the
8425: pkgsrc infrastructure at all. They may change without further notice.
8426:
8427: Note
8428:
8429: These conventions are currently not applied consistently to the complete pkgsrc
8430: infrastructure.
8431:
1.263 ! wiz 8432: 26.2. Avoiding problems before they arise
1.1 dsieger 8433:
8434: All variables that contain lists of things should default to being empty. Two
8435: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
8436: variables cannot simply be modified using the += operator in package Makefiles
8437: (or other files included by them), since there is no guarantee whether the
8438: variable is already set or not, and what its value is. In the case of
8439: DISTFILES, the packages "know" the default value and just define it as in the
8440: following example.
8441:
8442: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
8443:
8444: Because of the selection of this default value, the same value appears in many
8445: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
8446: value ("c") is so short that it doesn't stand out. Nevertheless it is mentioned
8447: in many files.
8448:
1.263 ! wiz 8449: 26.3. Variable evaluation
1.1 dsieger 8450:
1.263 ! wiz 8451: 26.3.1. At load time
1.1 dsieger 8452:
8453: Variable evaluation takes place either at load time or at runtime, depending on
8454: the context in which they occur. The contexts where variables are evaluated at
8455: load time are:
8456:
8457: * The right hand side of the := and != operators,
8458:
8459: * Make directives like .if or .for,
8460:
8461: * Dependency lines.
8462:
8463: A special exception are references to the iteration variables of .for loops,
8464: which are expanded inline, no matter in which context they appear.
8465:
8466: As the values of variables may change during load time, care must be taken not
8467: to evaluate them by accident. Typical examples for variables that should not be
8468: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
8469: clear, here is an example:
8470:
8471: CONFIGURE_ARGS= # none
8472: CFLAGS= -O
8473: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
8474:
8475: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
8476:
8477: CFLAGS+= -Wall
8478:
8479: This code shows how the use of the := operator can quickly lead to unexpected
8480: results. The first paragraph is fairly common code. The second paragraph
8481: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
8482: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
8483: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
8484: typically occur in completely unrelated files.
8485:
1.263 ! wiz 8486: 26.3.2. At runtime
1.1 dsieger 8487:
8488: After all the files have been loaded, the values of the variables cannot be
8489: changed anymore. Variables that are used in the shell commands are expanded at
8490: this point.
8491:
1.263 ! wiz 8492: 26.4. How can variables be specified?
1.1 dsieger 8493:
8494: There are many ways in which the definition and use of a variable can be
8495: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108 rillig 8496: policies. A package can be checked with pkglint -Wall to see whether it meets
8497: these rules.
1.1 dsieger 8498:
1.263 ! wiz 8499: 26.5. Designing interfaces for Makefile fragments
1.1 dsieger 8500:
8501: Most of the .mk files fall into one of the following classes. Cases where a
8502: file falls into more than one class should be avoided as it often leads to
8503: subtle bugs.
8504:
1.263 ! wiz 8505: 26.5.1. Procedures with parameters
1.1 dsieger 8506:
8507: In a traditional imperative programming language some of the .mk files could be
1.198 leot 8508: described as procedures. They take some input parameters and--after
8509: inclusion--provide a result in output parameters. Since all variables in
1.23 jakllsch 8510: Makefiles have global scope care must be taken not to use parameter names that
8511: have already another meaning. For example, PKGNAME is a bad choice for a
8512: parameter name.
1.1 dsieger 8513:
8514: Procedures are completely evaluated at preprocessing time. That is, when
8515: calling a procedure all input parameters must be completely resolvable. For
8516: example, CONFIGURE_ARGS should never be an input parameter since it is very
8517: likely that further text will be added after calling the procedure, which would
8518: effectively apply the procedure to only a part of the variable. Also,
1.108 rillig 8519: references to other variables will be modified after calling the procedure.
1.1 dsieger 8520:
8521: A procedure can declare its output parameters either as suitable for use in
8522: preprocessing directives or as only available at runtime. The latter
8523: alternative is for variables that contain references to other runtime
8524: variables.
8525:
8526: Procedures shall be written such that it is possible to call the procedure more
8527: than once. That is, the file must not contain multiple-inclusion guards.
8528:
8529: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
8530: To express that the parameters are evaluated at load time, they should be
8531: assigned using the := operator, which should be used only for this purpose.
8532:
1.263 ! wiz 8533: 26.5.2. Actions taken on behalf of parameters
1.1 dsieger 8534:
8535: Action files take some input parameters and may define runtime variables. They
8536: shall not define loadtime variables. There are action files that are included
8537: implicitly by the pkgsrc infrastructure, while other must be included
8538: explicitly.
8539:
8540: An example for action files is mk/subst.mk.
8541:
1.263 ! wiz 8542: 26.6. The order in which files are loaded
1.1 dsieger 8543:
8544: Package Makefiles usually consist of a set of variable definitions, and include
8545: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
8546: include various other *.mk files if they need to query the availability of
8547: certain features like the type of compiler or the X11 implementation. Due to
8548: the heavy use of preprocessor directives like .if and .for, the order in which
8549: the files are loaded matters.
8550:
8551: This section describes at which point the various files are loaded and gives
8552: reasons for that order.
8553:
1.263 ! wiz 8554: 26.6.1. The order in bsd.prefs.mk
1.1 dsieger 8555:
8556: The very first action in bsd.prefs.mk is to define some essential variables
8557: like OPSYS, OS_VERSION and MACHINE_ARCH.
8558:
1.4 rillig 8559: Then, the user settings are loaded from the file specified in MAKECONF, which
8560: is usually mk.conf. After that, those variables that have not been overridden
8561: by the user are loaded from mk/defaults/mk.conf.
1.1 dsieger 8562:
8563: After the user settings, the system settings and platform settings are loaded,
8564: which may override the user settings.
8565:
8566: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
8567: This only happens when building a package, so the proper variables must be used
8568: instead of the direct tool names.
8569:
8570: As the last steps, some essential variables from the wrapper and the package
8571: system flavor are loaded, as well as the variables that have been cached in
8572: earlier phases of a package build.
8573:
1.263 ! wiz 8574: 26.6.2. The order in bsd.pkg.mk
1.1 dsieger 8575:
8576: First, bsd.prefs.mk is loaded.
8577:
8578: Then, the various *-vars.mk files are loaded, which fill default values for
8579: those variables that have not been defined by the package. These variables may
8580: later be used even in unrelated files.
8581:
8582: Then, the file bsd.pkg.error.mk provides the target error-check that is added
8583: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
8584: DELAYED_WARNING_MSG.
8585:
8586: Then, the package-specific hacks from hacks.mk are included.
8587:
8588: Then, various other files follow. Most of them don't have any dependencies on
8589: what they need to have included before or after them, though some do.
8590:
8591: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
8592: restricts the use of these variables to all the files that have been included
8593: before. Appearances in later files will be silently ignored.
8594:
8595: Then, the files for the main targets are included, in the order of later
8596: execution, though the actual order should not matter.
8597:
8598: At last, some more files are included that don't set any interesting variables
8599: but rather just define make targets to be executed.
8600:
1.263 ! wiz 8601: Chapter 27. Regression tests
1.1 dsieger 8602:
8603: Table of Contents
8604:
1.263 ! wiz 8605: 27.1. Running the regression tests
! 8606: 27.2. Adding a new regression test
! 8607: 27.2.1. Overridable functions
! 8608: 27.2.2. Helper functions
1.1 dsieger 8609:
8610: The pkgsrc infrastructure consists of a large codebase, and there are many
8611: corners where every little bit of a file is well thought out, making pkgsrc
8612: likely to fail as soon as anything is changed near those parts. To prevent most
8613: changes from breaking anything, a suite of regression tests should go along
8614: with every important part of the pkgsrc infrastructure. This chapter describes
8615: how regression tests work in pkgsrc and how you can add new tests.
8616:
1.263 ! wiz 8617: 27.1. Running the regression tests
1.1 dsieger 8618:
1.25 wiz 8619: You first need to install the pkgtools/pkg_regress package, which provides the
1.1 dsieger 8620: pkg_regress command. Then you can simply run that command, which will run all
1.168 rillig 8621: tests in the regress/ directory.
1.1 dsieger 8622:
1.263 ! wiz 8623: 27.2. Adding a new regression test
1.1 dsieger 8624:
1.168 rillig 8625: Every directory in the regress/ directory that contains a file called spec is
1.1 dsieger 8626: considered a regression test. This file is a shell program that is included by
8627: the pkg_regress command. The following functions can be overridden to suit your
8628: needs.
8629:
1.263 ! wiz 8630: 27.2.1. Overridable functions
1.1 dsieger 8631:
1.108 rillig 8632: These functions do not take any parameters. Although they are called in "set -e
1.168 rillig 8633: " mode, they don't stop at the first failing command. See this Stack Overflow
1.108 rillig 8634: question for details.
1.1 dsieger 8635:
1.108 rillig 8636: do_setup
1.1 dsieger 8637:
8638: This function prepares the environment for the test. By default it does
8639: nothing.
8640:
1.108 rillig 8641: do_test
1.1 dsieger 8642:
8643: This function runs the actual test. By default, it calls TEST_MAKE with the
8644: arguments MAKEARGS_TEST and writes its output including error messages into
8645: the file TEST_OUTFILE.
8646:
1.108 rillig 8647: When defining this function, make sure that all output that needs to be
8648: checked is written to the correct output file. Example:
8649:
8650: do_test() {
8651: echo "Example output"
8652: } 1>$TEST_OUTFILE 2>&1
8653:
8654: check_result
1.1 dsieger 8655:
8656: This function is run after the test and is typically used to compare the
8657: actual output from the one that is expected. It can make use of the various
1.108 rillig 8658: helper functions from the next section. Example:
8659:
8660: check_result() {
8661: exit_status 0
8662: output_require "Example"
8663: output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
8664: output_prohibit "no such file or directory"
1.169 rillig 8665: regress_fail "expected $expected but got $actual for input $input"
1.108 rillig 8666: }
1.1 dsieger 8667:
1.108 rillig 8668: do_cleanup
1.1 dsieger 8669:
8670: This function cleans everything up after the test has been run. By default
8671: it does nothing.
8672:
1.263 ! wiz 8673: 27.2.2. Helper functions
1.1 dsieger 8674:
1.168 rillig 8675: regress_fail message...
8676:
8677: This function makes the test fail with the given error message.
8678:
1.108 rillig 8679: exit_status expected
1.1 dsieger 8680:
1.108 rillig 8681: This function compares the exitcode of the do_test function with its first
8682: parameter. If they differ, the test will fail.
1.1 dsieger 8683:
1.108 rillig 8684: output_require regex...
1.1 dsieger 8685:
8686: This function checks for each of its parameters if the output from do_test
1.108 rillig 8687: matches the extended regular expression. If it does not, the test will
8688: fail. Example:
8689:
8690: output_require "looks fine"
8691: output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1 dsieger 8692:
1.177 leot 8693: output_prohibit regex...
1.1 dsieger 8694:
8695: This function checks for each of its parameters if the output from do_test
8696: () does not match the extended regular expression. If any of the regular
8697: expressions matches, the test will fail.
8698:
1.263 ! wiz 8699: Chapter 28. Porting pkgsrc
1.1 dsieger 8700:
8701: Table of Contents
8702:
1.263 ! wiz 8703: 28.1. Porting pkgsrc to a new operating system
1.1 dsieger 8704:
8705: The pkgsrc system has already been ported to many operating systems, hardware
8706: architectures and compilers. This chapter explains the necessary steps to make
8707: pkgsrc even more portable.
8708:
1.263 ! wiz 8709: 28.1. Porting pkgsrc to a new operating system
1.1 dsieger 8710:
8711: To port pkgsrc to a new operating system (called MyOS in this example), you
8712: need to touch the following files:
8713:
8714: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
8715:
8716: This file contains some basic definitions, for example the name of the C
8717: compiler.
8718:
8719: mk/bsd.prefs.mk
8720:
1.212 wiz 8721: Insert code that defines the variables OPSYS, OS_VERSION, OPSYS_VERSION,
1.1 dsieger 8722: LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
8723: that appear in this file.
8724:
8725: mk/platform/MyOS.mk
8726:
8727: This file contains the platform-specific definitions that are used by
8728: pkgsrc. Start by copying one of the other files and edit it to your needs.
8729:
8730: mk/tools/tools.MyOS.mk
8731:
8732: This file defines the paths to all the tools that are needed by one or the
8733: other package in pkgsrc, as well as by pkgsrc itself. Find out where these
8734: tools are on your platform and add them.
8735:
8736: Now, you should be able to build some basic packages, like lang/perl5, shells/
8737: bash.
8738:
8739: Appendix A. A simple example package: bison
8740:
8741: Table of Contents
8742:
8743: A.1. files
8744: A.1.1. Makefile
8745: A.1.2. DESCR
8746: A.1.3. PLIST
8747: A.1.4. Checking a package with pkglint
8748: A.2. Steps for building, installing, packaging
8749:
8750: We checked to find a piece of software that wasn't in the packages collection,
1.25 wiz 8751: and picked GNU bison. Quite why someone would want to have bison when Berkeley
1.1 dsieger 8752: yacc is already present in the tree is beyond us, but it's useful for the
8753: purposes of this exercise.
8754:
8755: A.1. files
8756:
8757: A.1.1. Makefile
8758:
1.2 rillig 8759: # $NetBSD$
1.1 dsieger 8760: #
8761:
8762: DISTNAME= bison-1.25
8763: CATEGORIES= devel
1.171 rillig 8764: MASTER_SITES= ${MASTER_SITE_GNU:=bison/}
1.1 dsieger 8765:
1.30 dholland 8766: MAINTAINER= pkgsrc-users@NetBSD.org
1.174 leot 8767: HOMEPAGE= https://www.gnu.org/software/bison/bison.html
1.1 dsieger 8768: COMMENT= GNU yacc clone
8769:
8770: GNU_CONFIGURE= yes
1.47 wiz 8771: INFO_FILES= yes
1.1 dsieger 8772:
8773: .include "../../mk/bsd.pkg.mk"
8774:
8775: A.1.2. DESCR
8776:
8777: GNU version of yacc. Can make re-entrant parsers, and numerous other
8778: improvements. Why you would want this when Berkeley yacc(1) is part
8779: of the NetBSD source tree is beyond me.
8780:
8781: A.1.3. PLIST
8782:
1.2 rillig 8783: @comment $NetBSD$
1.1 dsieger 8784: bin/bison
8785: man/man1/bison.1.gz
8786: share/bison.simple
8787: share/bison.hairy
8788:
8789: A.1.4. Checking a package with pkglint
8790:
8791: The NetBSD package system comes with pkgtools/pkglint which helps to check the
8792: contents of these files. After installation it is quite easy to use, just
1.171 rillig 8793: change to the directory of the package you wish to examine and run pkglint:
1.1 dsieger 8794:
8795: $ pkglint
1.171 rillig 8796: ERROR: Makefile: Each package must define its LICENSE.
8797: WARN: Makefile:9: HOMEPAGE should migrate from http to https.
8798: NOTE: PLIST:3: The .gz extension is unnecessary for manual pages.
8799: WARN: PLIST:5: "share/bison.hairy" should be sorted before "share/bison.simple".
8800: 1 error, 2 warnings and 1 note found.
8801: (Run "pkglint -e" to show explanations.)
8802: (Run "pkglint -fs" to show what can be fixed automatically.)
1.172 rillig 8803: (Run "pkglint -F" to automatically fix some issues.)
1.1 dsieger 8804:
8805: Depending on the supplied command line arguments (see pkglint(1)), more checks
1.170 rillig 8806: will be performed. Use e.g. pkglint -Wall for a very thorough check.
1.1 dsieger 8807:
8808: A.2. Steps for building, installing, packaging
8809:
8810: Create the directory where the package lives, plus any auxiliary directories:
8811:
8812: # cd /usr/pkgsrc/lang
8813: # mkdir bison
8814: # cd bison
8815: # mkdir patches
8816:
1.184 rillig 8817: Create Makefile, DESCR and PLIST (see Chapter 12, Package components - files,
1.1 dsieger 8818: directories and contents) then continue with fetching the distfile:
8819:
8820: # make fetch
8821: >> bison-1.25.tar.gz doesn't seem to exist on this system.
8822: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
8823: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8824: ftp: Error retrieving file: 500 Internal error
8825:
8826: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
8827: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8828: ftp: Error retrieving file: 500 Internal error
8829:
8830: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
8831: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8832: Successfully retrieved file.
8833:
8834: Generate the checksum of the distfile into distinfo:
8835:
8836: # make makedistinfo
8837:
8838: Now compile:
8839:
8840: # make
8841: >> Checksum OK for bison-1.25.tar.gz.
8842: ===> Extracting for bison-1.25
8843: ===> Patching for bison-1.25
8844: ===> Ignoring empty patch directory
8845: ===> Configuring for bison-1.25
8846: creating cache ./config.cache
8847: checking for gcc... cc
8848: checking whether we are using GNU C... yes
8849: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
8850: checking how to run the C preprocessor... cc -E
8851: checking for minix/config.h... no
8852: checking for POSIXized ISC... no
8853: checking whether cross-compiling... no
8854: checking for ANSI C header files... yes
8855: checking for string.h... yes
8856: checking for stdlib.h... yes
8857: checking for memory.h... yes
8858: checking for working const... yes
8859: checking for working alloca.h... no
8860: checking for alloca... yes
8861: checking for strerror... yes
8862: updating cache ./config.cache
8863: creating ./config.status
8864: creating Makefile
8865: ===> Building for bison-1.25
8866: 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
8867: 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
8868: 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
8869: 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
8870: 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
8871: 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
8872: 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
8873: 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
8874: 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
8875: 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
8876: 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
8877: 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
8878: 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
8879: 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
8880: 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
8881: 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
8882: 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
8883: 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
8884: 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
8885: 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
8886: 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
8887: 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
8888: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
8889: rm -f bison.s1
8890: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
8891:
8892: Everything seems OK, so install the files:
8893:
8894: # make install
8895: >> Checksum OK for bison-1.25.tar.gz.
8896: ===> Installing for bison-1.25
8897: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
8898: rm -f /usr/pkg/bin/bison
8899: cd /usr/pkg/share; rm -f bison.simple bison.hairy
8900: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
8901: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
8902: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
8903: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
8904: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
8905: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
8906: ===> Registering installation for bison-1.25
8907:
8908: You can now use bison, and also - if you decide so - remove it with pkg_delete
8909: bison. Should you decide that you want a binary package, do this now:
8910:
8911: # make package
8912: >> Checksum OK for bison-1.25.tar.gz.
8913: ===> Building package for bison-1.25
8914: Creating package bison-1.25.tgz
8915: Registering depends:.
8916: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
8917:
8918: Now that you don't need the source and object files any more, clean up:
8919:
8920: # make clean
8921: ===> Cleaning for bison-1.25
8922:
1.207 leot 8923: Appendix B. Security hardening
8924:
8925: Table of Contents
8926:
8927: B.1. Mechanisms
8928: B.1.1. Enabled by default
8929: B.1.2. Not enabled by default
8930: B.2. Caveats
8931: B.2.1. Problems with PKGSRC_MKPIE
8932: B.2.2. Problems with PKGSRC_USE_FORTIFY
8933: B.2.3. Problems with PKGSRC_USE_RELRO
8934: B.2.4. Problems with PKGSRC_USE_SSP
8935: B.3. Auditing the system
8936: B.3.1. Checking for PIE
8937: B.3.2. Checking for partial RELRO
8938: B.3.3. Checking for full RELRO
8939: B.3.4. Checking for SSP
8940:
8941: A number of mechanisms are available in pkgsrc to improve the security of the
8942: resulting system. This page describes the mechanisms, and gives hints about
8943: detecting and fixing problems.
8944:
8945: Mechanisms can be enabled individually in mk.conf, and are individually
8946: described below.
8947:
8948: Typically, a feature will cause some programs to fail to build or work when
8949: first enabled. This can be due to latent problems in the program, and can be
8950: due to other reasons. After enough testing to have confidence that user
8951: problems will be quite rare, individual mechanisms will be enabled by default.
8952:
8953: For each mechanism, see the Caveats section below for an explanation of what
8954: might go wrong at compile time and at run time, and how to notice and address
8955: these problems.
8956:
8957: B.1. Mechanisms
8958:
8959: B.1.1. Enabled by default
8960:
8961: B.1.1.1. PKGSRC_USE_FORTIFY
8962:
8963: This allows substitute wrappers to be used for some commonly used library
8964: functions that do not have built-in bounds checking - but could in some cases.
8965:
8966: Two mitigation levels are available:
8967:
8968: * "weak" only enables checks at compile-time.
8969:
8970: * "strong" enables checks at compile-time and runtime.
8971:
8972: "strong" has been enabled by default since pkgsrc-2017Q3.
8973:
8974: B.1.1.2. PKGSRC_USE_SSP
8975:
8976: This enables a stack-smashing protection mitigation. It is done by adding a
8977: guard variable to functions with vulnerable objects. The guards are initialized
8978: when a function is entered and then checked when the function exits. The guard
8979: check will fail and the program forcibly exited if the variable was modified in
8980: the meantime. This can happen in case of buffer overflows or memory corruption,
8981: and therefore exposing these bugs.
8982:
8983: Different mitigation levels are available:
8984:
8985: * "yes", which will only protect functions considered vulnerable by the
8986: compiler;
8987:
8988: * "all", which will protect every function;
8989:
8990: * "strong", the default, which will apply a better balance between the two
8991: settings above.
8992:
8993: This mitigation is supported by both GCC and clang. It may be supported in
8994: additional compilers, possibly under a different name. It is particularly
8995: useful for unsafe programming languages, such as C/C++.
8996:
8997: * "yes" is enabled by default where known supported since pkgsrc-2017Q3.
8998:
8999: * "strong" is enabled by default where known supported since pkgsrc-2021Q4.
9000:
9001: More details can be found here:
9002:
9003: * Buffer overflow protection on Wikipedia
9004:
9005: B.1.1.3. PKGSRC_MKPIE
9006:
9007: This requests the creation of PIE (Position Independent Executables) for all
9008: executables. The PIE mechanism is normally used for shared libraries, so that
9009: they can be loaded at differing addresses at runtime. PIE itself does not have
9010: useful security properties; however, it is necessary to fully leverage some,
9011: such as ASLR. Some operating systems support Address Space Layout Randomization
9012: (ASLR), which causes different addresses to be used each time a program is run.
9013: This makes it more difficult for an attacker to guess addresses and thus makes
9014: exploits harder to construct. With PIE, ASLR can really be applied to the
9015: entire program, instead of the stack and heap only.
9016:
9017: PIE executables will only be built for toolchains that are known to support
9018: PIE. Currently, this means NetBSD on x86, ARM, SPARC64, m68k, and MIPS.
9019:
9020: PKGSRC_MKPIE was enabled by default after the pkgsrc-2021Q3 branch.
9021:
1.219 nia 9022: B.1.1.4. PKGSRC_USE_RELRO
1.207 leot 9023:
9024: This also makes the exploitation of some security vulnerabilities more
9025: difficult in some cases.
9026:
9027: Two different mitigation levels are available:
9028:
1.219 nia 9029: * partial (the default): the ELF sections are reordered so that internal data
9030: sections precede the program's own data sections, and non-PLT GOT is
9031: read-only;
1.207 leot 9032:
9033: * full: in addition to partial RELRO, every relocation is performed
1.218 nia 9034: immediately when starting the program, allowing the entire GOT to be
9035: read-only. This can greatly slow down startup of large programs.
1.207 leot 9036:
9037: This is currently supported by GCC. Many software distributions now enable this
1.220 nia 9038: feature by default, at the "partial" level.
1.207 leot 9039:
9040: More details can be found here:
9041:
9042: * Hardening ELF binaries using Relocation Read-Only (RELRO)
9043:
1.219 nia 9044: B.1.2. Not enabled by default
9045:
9046: B.1.2.1. PKGSRC_MKREPRO
9047:
9048: With this option, pkgsrc will try to build packages reproducibly. This allows
9049: packages built from the same tree and with the same options, to produce
9050: identical results bit by bit. This option should be combined with ASLR and
9051: PKGSRC_MKPIE to avoid predictable address offsets for attackers attempting to
9052: exploit security vulnerabilities.
9053:
9054: More details can be found here:
9055:
9056: * Reproducible Builds - a set of software development practices that create
9057: an independently-verifiable path from source to binary code
9058:
9059: More work likely needs to be done before pkgsrc is fully reproducible.
9060:
9061: B.1.2.2. PKGSRC_USE_STACK_CHECK
1.207 leot 9062:
9063: This uses -fstack-check with GCC for another stack protection mitigation.
9064:
9065: It asks the compiler to generate code verifying that it does not corrupt the
9066: stack. According to GCC's manual page, this is really only useful for
9067: multi-threaded programs.
9068:
9069: B.2. Caveats
9070:
9071: B.2.1. Problems with PKGSRC_MKPIE
9072:
9073: B.2.1.1. Packages failing to build
9074:
9075: A number of packages may fail to build with this option enabled. The failures
9076: are often related to the absence of the -fPIC compilation flag when building
9077: libraries or executables (or ideally -fPIE in the latter case). This flag is
9078: added to the CFLAGS already, but requires the package to actually support it.
9079:
9080: B.2.1.1.1. How to fix
9081:
9082: These instructions are meant as a reference only; they likely need to be
9083: adapted for many packages individually.
9084:
9085: For packages using Makefiles:
9086:
9087: MAKE_FLAGS+= CFLAGS=${CFLAGS:Q}
9088: MAKE_FLAGS+= LDFLAGS=${LDFLAGS:Q}
9089:
9090: For packages using Imakefiles:
9091:
9092: MAKE_FLAGS+= CCOPTIONS=${CFLAGS:Q}
9093: MAKE_FLAGS+= LOCAL_LDFLAGS=${LDFLAGS:Q}
9094:
9095: B.2.1.2. Run-time crashes
9096:
9097: Some programs may fail to run, or crash at random times once built as PIE. Two
9098: scenarios are essentially possible. This is nearly always due to a bug in the
9099: program being exposed due to ASLR.
9100:
9101: B.2.1.3. Disabling PKGSRC_MKPIE on a per-package basis
9102:
9103: Ideally, packages should be fixed for compatibility with MKPIE. However, in
9104: some cases this is very difficult, due to complex build systems, packages using
9105: non-standard toolchains, or programming languages with odd bootstrapping
9106: mechanisms.
9107:
9108: To disable PKGSRC_MKPIE on a per-package basis, set MKPIE_SUPPORTED= no in the
9109: package's Makefile before bsd.prefs.mk is included.
9110:
9111: B.2.2. Problems with PKGSRC_USE_FORTIFY
9112:
9113: B.2.2.1. Packages failing to build
9114:
9115: This feature makes use of pre-processing directives to look for hardened,
9116: alternative implementations of essential library calls. Some programs may fail
9117: to build as a result; this usually happens for those trying too hard to be
9118: portable, or otherwise abusing definitions in the standard library.
9119:
9120: B.2.2.2. Run-time crashes
9121:
9122: This feature may cause some programs to crash, usually indicating an actual bug
9123: in the program. The fix will typically involve patching the original program's
9124: source code.
9125:
9126: B.2.2.3. Optimization is required
9127:
9128: At least in the case of GCC, FORTIFY will only be applied if optimization is
9129: applied while compiling. This means that the CFLAGS should also contain -O, -O2
9130: or another optimization level. This cannot easily be applied globally, as some
9131: packages may require specific optimization levels.
9132:
9133: B.2.2.4. Disabling FORTIFY on a per-package basis
9134:
9135: Note
9136:
9137: FORTIFY should not be disabled to work around runtime crashes in the program!
9138: This is a very bad idea and will expose you to security vulnerabilities.
9139:
9140: To disable FORTIFY on a per-package basis, set the following in the package's
9141: Makefile before bsd.prefs.mk is included:
9142:
9143: FORTIFY_SUPPORTED= no
9144:
9145: B.2.3. Problems with PKGSRC_USE_RELRO
9146:
9147: B.2.3.1. Performance impact
9148:
9149: For better protection, full RELRO requires every symbol to be resolved when the
9150: program starts, rather than simply when required at run-time. This will have
9151: more impact on programs using a lot of symbols, or linked to libraries exposing
9152: a lot of symbols. Therefore, daemons or programs otherwise running in
9153: background are affected only when started. Programs loading plug-ins at
9154: run-time are affected when loading the plug-ins.
9155:
9156: The impact is not expected to be noticeable on modern hardware, except in some
9157: cases for big programs.
9158:
9159: B.2.3.2. Run-time crashes
9160:
9161: Some programs handle plug-ins and dependencies in a way that conflicts with
9162: RELRO: for instance, with an initialization routine listing any other plug-in
9163: required. With full RELRO, the missing symbols are resolved before the
9164: initialization routine can run, and the dynamic loader will not be able to find
9165: them directly and abort as a result. Unfortunately, this is how Xorg loads its
9166: drivers. Partial RELRO can be applied instead in this case.
9167:
9168: B.2.3.3. Disabling RELRO on a per-package basis
9169:
9170: To disable RELRO on a per-package basis, set the following in the package's
9171: Makefile before bsd.prefs.mk is included:
9172:
9173: RELRO_SUPPORTED= no
9174:
1.209 nia 9175: It is also possible to at most enable partial RELRO, by setting RELRO_SUPPORTED
9176: to partial.
9177:
1.207 leot 9178: B.2.4. Problems with PKGSRC_USE_SSP
9179:
9180: B.2.4.1. Packages failing to build
9181:
9182: The stack-smashing protection provided by this option does not work for some
9183: programs. The most common situation in which this happens is when the program
9184: allocates variables on the stack, with the size determined at run-time.
9185:
9186: B.2.4.2. Run-time crashes
9187:
9188: Again, this feature may cause some programs to crash via a SIGABRT, usually
9189: indicating an actual bug in the program.
9190:
9191: On NetBSD LOG_CRIT level syslog messages are sent and - by default - appended
9192: to /var/log/messages, e.g.:
9193:
9194: Jan 6 15:42:51 hostname -: hostname program - - - buffer overflow detected; terminated
9195:
9196: (where hostname is the hostname(1) and program is the basename(1) of the
9197: program crashed).
9198:
9199: Patching the original program is then required.
9200:
9201: Rebuilding the package via:
9202:
9203: % env CFLAGS=-g INSTALL_UNSTRIPPED=yes make replace
9204:
9205: and inspecting the backtrace of the coredump via the debugger should point out
9206: the problematic call by inspecting the frame calling the _chk() (SSP) function.
9207:
9208: B.2.4.3. Performance impact
9209:
9210: The compiler emits extra code when using this feature: a check for buffer
9211: overflows is performed when entering and exiting functions, requiring an extra
9212: variable on the stack. The level of protection can otherwise be adjusted to
9213: affect only those functions considered more sensitive by the compiler (with
9214: -fstack-protector instead of -fstack-protector-all).
9215:
9216: The impact is not expected to be noticeable on modern hardware. However,
9217: programs with a hard requirement to run at the fastest possible speed should
9218: avoid using this feature, or using libraries built with this feature.
9219:
9220: B.2.4.4. Disabling SSP on a per-package basis
9221:
9222: Note
9223:
9224: SSP should not be disabled to work around runtime crashes in the program! This
9225: is a very bad idea and will expose you to security vulnerabilities.
9226:
9227: To disable SSP on a per-package basis, set the following in the package's
9228: Makefile before bsd.prefs.mk is included:
9229:
9230: SSP_SUPPORTED= no
9231:
9232: B.3. Auditing the system
9233:
9234: The illusion of security is worse than having no security at all. This section
9235: lists a number of ways to ensure the security features requested are actually
9236: effective.
9237:
9238: These instructions were obtained and tested on a system derived from NetBSD 7
9239: (amd64). YMMV.
9240:
9241: B.3.1. Checking for PIE
9242:
9243: The ELF executable type in use changes for binaries built as PIE; without:
9244:
9245: $ file /path/to/bin/ary
9246: /path/to/bin/ary: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for NetBSD 7.0, not stripped
9247:
9248: as opposed to the following binary, built as PIE:
9249:
9250: $ file /path/to/pie/bin/ary
9251: /path/to/pie/bin/ary: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for NetBSD 7.0, not stripped
9252:
9253: The latter result is then what is expected.
9254:
9255: B.3.2. Checking for partial RELRO
9256:
9257: The following command should list a section called RELRO:
9258:
9259: $ objdump -p /path/to/bin/ary
9260:
9261: /path/to/bin/ary: file format elf64-x86-64
9262:
9263: Program Header:
9264: [...]
9265: RELRO off 0x0000000000000d78 vaddr 0x0000000000600d78 paddr 0x0000000000600d78 align 2**0
9266:
9267: This check is now performed automatically if PKG_DEVELOPER is set and RELRO is
9268: enabled.
9269:
9270: B.3.3. Checking for full RELRO
9271:
9272: The dynamic loader will apply RELRO immediately when detecting the presence of
9273: the BIND_NOW flag:
9274:
9275: $ objdump -x /path/to/bin/ary
9276:
9277: /path/to/bin/ary: file format elf64-x86-64
9278:
9279: Dynamic Section:
9280: [...]
9281: BIND_NOW 0x0000000000000000
9282:
9283: This has to be combined with partial RELRO (see above) to be fully efficient.
9284:
9285: This check is now performed automatically (where supported) if PKG_DEVELOPER is
9286: set.
9287:
9288: B.3.4. Checking for SSP
9289:
1.208 nia 9290: Note
9291:
9292: Checking for SSP using this method only works where the operating system uses
9293: libssp. libssp is not used on recent NetBSD/FreeBSD/Linux versions.
9294:
1.207 leot 9295: Building objects, binaries and libraries with SSP will affect the presence of
9296: additional symbols in the resulting file:
9297:
9298: $ nm /path/to/bin/ary
9299: [...]
9300: U __stack_chk_fail
9301: 0000000000600ea0 B __stack_chk_guard
9302:
9303: This is an indicator that the program was indeed built with support for SSP.
9304:
9305: This check is now performed automatically (where supported) if PKG_DEVELOPER is
9306: set and SSP is enabled.
9307:
9308: Appendix C. Build logs
1.1 dsieger 9309:
9310: Table of Contents
9311:
1.207 leot 9312: C.1. Building figlet
9313: C.2. Packaging figlet
1.1 dsieger 9314:
1.207 leot 9315: C.1. Building figlet
1.1 dsieger 9316:
9317: # make
9318: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9319: => figlet221.tar.gz doesn't seem to exist on this system.
9320: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
9321: => [172219 bytes]
9322: Connected to ftp.plig.net.
9323: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
9324: 331 Guest login ok, send your complete e-mail address as password.
9325: 230-You are user #5 of 500 simultaneous users allowed.
9326: 230-
9327: 230- ___ _ _ _
9328: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
9329: 230- | _| _| . |_| . | | | . |_| . | _| . |
9330: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
9331: 230- |_| |_| |___| |___|
9332: 230-
9333: 230-** Welcome to ftp.plig.org **
9334: 230-
9335: 230-Please note that all transfers from this FTP site are logged. If you
9336: 230-do not like this, please disconnect now.
9337: 230-
1.19 snj 9338: 230-This archive is available via
1.1 dsieger 9339: 230-
9340: 230-HTTP: http://ftp.plig.org/
9341: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
9342: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
9343: 230-
9344: 230-Please email comments, bug reports and requests for packages to be
9345: 230-mirrored to ftp-admin@plig.org.
9346: 230-
9347: 230-
9348: 230 Logged in anonymously.
9349: Remote system type is UNIX.
9350: Using binary mode to transfer files.
9351: 200 Type okay.
9352: 250 "/pub" is new cwd.
9353: 250-"/pub/figlet" is new cwd.
9354: 250-
9355: 250-Welcome to the figlet archive at ftp.figlet.org
9356: 250-
9357: 250- ftp://ftp.figlet.org/pub/figlet/
9358: 250-
9359: 250-The official FIGlet web page is:
9360: 250- http://www.figlet.org/
9361: 250-
9362: 250-If you have questions, please mailto:info@figlet.org. If you want to
9363: 250-contribute a font or something else, you can email us.
9364: 250
9365: 250 "/pub/figlet/program" is new cwd.
9366: 250 "/pub/figlet/program/unix" is new cwd.
9367: local: figlet221.tar.gz remote: figlet221.tar.gz
9368: 502 Unimplemented command.
9369: 227 Entering Passive Mode (195,40,6,41,246,104)
9370: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
9371: 38% |************** | 65800 64.16 KB/s 00:01 ETA
9372: 226 Transfer completed.
9373: 172219 bytes received in 00:02 (75.99 KB/s)
9374: 221 Goodbye.
9375: => Checksum OK for figlet221.tar.gz.
9376: ===> Extracting for figlet-2.2.1nb2
9377: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
9378: ===> Patching for figlet-2.2.1nb2
9379: ===> Applying pkgsrc patches for figlet-2.2.1nb2
9380: ===> Overriding tools for figlet-2.2.1nb2
9381: ===> Creating toolchain wrappers for figlet-2.2.1nb2
9382: ===> Configuring for figlet-2.2.1nb2
9383: ===> Building for figlet-2.2.1nb2
9384: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
9385: chmod a+x figlet
9386: gcc -O2 -o chkfont chkfont.c
9387: => Unwrapping files-to-be-installed.
9388: #
9389: # make install
9390: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9391: ===> Installing for figlet-2.2.1nb2
9392: install -d -o root -g wheel -m 755 /usr/pkg/bin
9393: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
9394: mkdir -p /usr/pkg/share/figlet
9395: cp figlet /usr/pkg/bin
9396: cp chkfont /usr/pkg/bin
9397: chmod 555 figlist showfigfonts
9398: cp figlist /usr/pkg/bin
9399: cp showfigfonts /usr/pkg/bin
9400: cp fonts/*.flf /usr/pkg/share/figlet
9401: cp fonts/*.flc /usr/pkg/share/figlet
9402: cp figlet.6 /usr/pkg/man/man6
9403: ===> Registering installation for figlet-2.2.1nb2
9404: #
9405:
1.207 leot 9406: C.2. Packaging figlet
1.1 dsieger 9407:
9408: # make package
9409: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9410: ===> Packaging figlet-2.2.1nb2
9411: ===> Building binary package for figlet-2.2.1nb2
9412: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
9413: Using SrcDir value of /usr/pkg
9414: Registering depends:.
9415: #
9416:
1.207 leot 9417: Appendix D. Directory layout of the pkgsrc FTP server
1.1 dsieger 9418:
9419: Table of Contents
9420:
1.207 leot 9421: D.1. distfiles: The distributed source files
9422: D.2. misc: Miscellaneous things
9423: D.3. packages: Binary packages
9424: D.4. reports: Bulk build reports
9425: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1 dsieger 9426:
9427: As in other big projects, the directory layout of pkgsrc is quite complex for
9428: newbies. This chapter explains where you find things on the FTP server. The
9429: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
9430: different, but inside this directory, everything should look the same, no
9431: matter on which server you are. This directory contains some subdirectories,
9432: which are explained below.
9433:
1.207 leot 9434: D.1. distfiles: The distributed source files
1.1 dsieger 9435:
9436: The directory distfiles contains lots of archive files from all pkgsrc
9437: packages, which are mirrored here. The subdirectories are called after their
9438: package names and are used when the distributed files have names that don't
9439: explicitly contain a version number or are otherwise too generic (for example
9440: release.tar.gz).
9441:
1.207 leot 9442: D.2. misc: Miscellaneous things
1.1 dsieger 9443:
9444: This directory contains things that individual pkgsrc developers find worth
9445: publishing.
9446:
1.207 leot 9447: D.3. packages: Binary packages
1.1 dsieger 9448:
1.3 rillig 9449: This directory contains binary packages for the various platforms that are
9450: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
9451: The meaning of these variables is:
9452:
9453: * OPSYS is the name of the operating system for which the packages have been
1.9 rillig 9454: built. The name is taken from the output of the uname command, so it may
9455: differ from the one you are used to hear.
1.3 rillig 9456:
1.8 rillig 9457: * ARCH is the hardware architecture of the platform for which the packages
1.10 hubertf 9458: have been built. It also includes the ABI (Application Binary Interface)
9459: for platforms that have several of them.
1.3 rillig 9460:
1.255 wiz 9461: * OSVERSION is the version of the operating system. Typically it is the
9462: version defining an ABI, e.g. 9.0.
9463:
9464: * TAG is either 20YYQN for a stable branch, or current for packages built
9465: from the HEAD branch. The latter should only be used when the packages are
9466: updated on a regular basis.
9467:
9468: The rationale for this scheme is that users can first search by OPSYS and ARCH,
9469: since these are more or less unchangeable. After that, there is a management
9470: set of directories with OSVERSION and TAG.
9471:
9472: See also README.md in packages for more details, including about symlinks.
1.3 rillig 9473:
9474: In each of these directories, there is a whole binary packages collection for a
9475: specific platform. It has a directory called All which contains all binary
1.255 wiz 9476: packages.
1.1 dsieger 9477:
1.207 leot 9478: D.4. reports: Bulk build reports
1.8 rillig 9479:
9480: Here are the reports from bulk builds, for those who want to fix packages that
9481: didn't build on some of the platforms. The structure of subdirectories should
1.207 leot 9482: look like the one in Section D.3, "packages: Binary packages".
1.8 rillig 9483:
1.207 leot 9484: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1 dsieger 9485:
9486: These directories contain the "real" pkgsrc, that is the files that define how
9487: to create binary packages from source archives.
9488:
1.149 leot 9489: Each of the current, stable and pkgsrc-20xxQy directories share the same
9490: structure. They each contain a pkgsrc directory and pkgsrc.tar.{bz,gz,xz} file.
9491:
1.1 dsieger 9492: The directory pkgsrc contains a snapshot of the CVS repository, which is
1.149 leot 9493: updated regularly. The file pkgsrc.tar.{bz,gz,xz} contains the same as the
9494: directory, ready to be downloaded as a whole.
1.1 dsieger 9495:
1.149 leot 9496: The current directory contains files related to the HEAD branch of the CVS
9497: repository. In this directory there is an additional file called
9498: pkgsrc-readmes.tar.{bz,gz,xz} that contains all pkgsrc READMEs with information
9499: about categories and packages.
9500:
9501: The stable directory is a symlink to the latest pkgsrc-20xxQy.
9502:
9503: The pkgsrc-20xxQy. directories contain files related to the -20xxQy stable
9504: branch of the CVS repository. In these directories there is an additional file
9505: called pkgsrc-20xxQy.tar.{bz,gz,xz}, which contains the state of pkgsrc when it
9506: was branched.
1.148 leot 9507:
1.207 leot 9508: Appendix E. Help topics
1.154 rillig 9509:
9510: The following list contains all help topics that are available when running
9511: bmake help topic=:index.
9512:
1.263 ! wiz 9513: #! -lintl
! 9514: 32bit 64bit
! 9515: ABI ACCEPTABLE_LICENSES
! 9516: ACROREAD_FONTPATH ADDITIONAL
! 9517: AFAIK AIX
! 9518: ALLOW_NETWORK_ACCESS ALLOW_NEWER_COMPILER
! 9519: ALLOW_VULNERABLE_PACKAGES ALL_ENV
! 9520: ALSA_PC ALTERNATIVES_SRC
! 9521: AMANDA_TMP AMANDA_USER
! 9522: AMANDA_VAR APACHE_GROUP
! 9523: APACHE_MODULE_NAME APACHE_MODULE_SRC
! 9524: APACHE_MODULE_SRCDIR APACHE_PKG_PREFIX
! 9525: APACHE_SUEXEC_CONFIGURE_ARGS APACHE_SUEXEC_DOCROOT
! 9526: APACHE_USER ARGMAX_REQ
! 9527: ARG_MAX ARLA_CACHE
! 9528: AUDIT_PACKAGES_FLAGS AUTOCONF_REQD
! 9529: AUTOMAKE_OVERRIDE AUTOMAKE_REQD
! 9530: AUTO_MKDIRS AUX
! 9531: BDB185_DEFAULT BDBBASE
! 9532: BDB_ACCEPTED BDB_DEFAULT
! 9533: BDB_LIBS BDB_TYPE
! 9534: BINCIMAP_GROUP BINCIMAP_LOG_USER
! 9535: BINCIMAP_USER BIND_DIR
! 9536: BIND_GROUP BIND_USER
! 9537: BINOWN BINPKG_SITES
! 9538: BIN_INSTALL_FLAGS BISON_PKGDATADIR
! 9539: BLAS BLAS_ACCEPTED
! 9540: BLAS_C_INTERFACE BLAS_INCLUDES
! 9541: BLAS_INDEX64 BLAS_LIBS
! 9542: BLAS_PC BLAS_TYPE
! 9543: BOOTSTRAP_DEPENDS BROKEN
! 9544: BROKEN_EXCEPT_ON_PLATFORM BROKEN_ON_PLATFORM
! 9545: BSDSRCDIR BSDXSRCDIR
! 9546: BSD_MAKE_ENV BUILDLINK_AUTO_DIRS
! 9547: BUILDLINK_AUTO_VARS BUILDLINK_CFLAGS
! 9548: BUILDLINK_CONTENTS_FILTER BUILDLINK_CPPFLAGS
! 9549: BUILDLINK_DEPMETHOD BUILDLINK_FILES
! 9550: BUILDLINK_FILES_CMD BUILDLINK_FNAME_TRANSFORM
! 9551: BUILDLINK_LDFLAGS BUILDLINK_LIBS
! 9552: BUILDLINK_OPSYS_SUPPORT_PTHREAD BUILDLINK_PKGNAME
! 9553: BUILDLINK_PREFIX BUILDLINK_RPATHDIRS
! 9554: BUILDLINK_TREE BUILD_DEFS
! 9555: BUILD_DEFS_EFFECTS BUILD_DEPENDS
! 9556: BUILD_DIRS BUILD_ENV_SHELL
! 9557: BUILD_MAKE_CMD BUILD_MAKE_FLAGS
! 9558: BUILD_TARGET BUILTIN_FIND_FILES
! 9559: BUILTIN_FIND_FILES_VAR BUILTIN_FIND_GREP
! 9560: BUILTIN_FIND_HEADERS BUILTIN_FIND_HEADERS_VAR
! 9561: BUILTIN_FIND_PKGCONFIG BUILTIN_FIND_PKGCONFIG_VAR
! 9562: BUILTIN_PKG BUILTIN_TEST_CURSES_DEFINES
! 9563: BUILTIN_TEST_CURSES_FUNCS BUILTIN_VERSION_SCRIPT
! 9564: BUILTIN_X11_TYPE BUILTIN_X11_VERSION
! 9565: CACTI_GROUP CACTI_USER
! 9566: CANNA_GROUP CANNA_USER
! 9567: CAT CBLAS_LIBS
! 9568: CBLAS_PC CCACHE_BASE
! 9569: CCACHE_DIR CCACHE_LOGFILE
! 9570: CCACHE_RECACHE CC_VERSION
! 9571: CC_VERSION_STRING CDRECORD_CONF
! 9572: CDROM_PKG_URL_DIR CDROM_PKG_URL_HOST
! 9573: CHANGES CHECKOUT_DATE
! 9574: CHECK_COMPILER CHECK_FAKEHOME
! 9575: CHECK_FILES CHECK_FILES_ONLY_PREFIX
! 9576: CHECK_FILES_SKIP CHECK_FILES_STRICT
! 9577: CHECK_HEADERS CHECK_HEADERS_SKIP
! 9578: CHECK_INTERPRETER CHECK_INTERPRETER_SKIP
! 9579: CHECK_PERMS CHECK_PERMS_AUTOFIX
! 9580: CHECK_PERMS_SKIP CHECK_PIE
! 9581: CHECK_PIE_SKIP CHECK_PIE_SUPPORTED
! 9582: CHECK_PORTABILITY CHECK_PORTABILITY_EXPERIMENTAL
! 9583: CHECK_PORTABILITY_SKIP CHECK_RELRO
! 9584: CHECK_RELRO_SKIP CHECK_RELRO_SUPPORTED
! 9585: CHECK_SHLIBS CHECK_SHLIBS_SKIP
! 9586: CHECK_SHLIBS_SUPPORTED CHECK_SHLIBS_TOXIC
! 9587: CHECK_SSP CHECK_SSP_SKIP
! 9588: CHECK_SSP_SUPPORTED CHECK_STRIPPED
! 9589: CHECK_STRIPPED_SKIP CHECK_WRKREF
! 9590: CHECK_WRKREF_EXTRA_DIRS CHECK_WRKREF_SKIP
! 9591: CLAMAV_DBDIR CLAMAV_GROUP
! 9592: CLAMAV_USER CLANGBASE
! 9593: CLEANDEPENDS CLT
! 9594: CMAKE_DEPENDENCIES_REWRITE CMAKE_INSTALL_NAME_DIR
! 9595: CMAKE_INSTALL_PREFIX CMAKE_MODULE_PATH_OVERRIDE
! 9596: CMAKE_PKGSRC_BUILD_FLAGS CMAKE_PREFIX_PATH
! 9597: CMAKE_USE_GNU_INSTALL_DIRS COMMON_LISP_DOCFILES
! 9598: COMMON_LISP_EXAMPLES COMMON_LISP_EXTRAFILES
! 9599: COMMON_LISP_PACKAGES COMMON_LISP_SYSTEM
! 9600: COMPILER_RPATH_FLAG COMPILER_USE_SYMLINKS
! 9601: CONFIGURE_ARGS CONFIGURE_DIRS
! 9602: CONFIGURE_ENV CONFIGURE_ENV_SHELL
! 9603: CONFIGURE_HAS_INFODIR CONFIGURE_HAS_MANDIR
! 9604: CONFIGURE_SCRIPT CONFIG_SHELL
! 9605: CONFIG_SHELL_FLAGS CONF_FILES
! 9606: CONF_FILES_MODE CONF_FILES_PERMS
! 9607: CONSERVER_DEFAULTHOST CONSERVER_DEFAULTPORT
! 9608: CP CPE
! 9609: CPE_EDITION CPE_LANG
! 9610: CPE_OTHER CPE_PART
! 9611: CPE_PRODUCT CPE_SW_EDITION
! 9612: CPE_TARGET_HW CPE_TARGET_SW
! 9613: CPE_UPDATE CPE_URI
! 9614: CPE_VENDOR CPE_VERSION
! 9615: CPP CPP_PRECOMP_FLAGS
! 9616: CREATE_WRKDIR_SYMLINK CROSSBASE
! 9617: CTFCONVERT CTF_FILES_SKIP
! 9618: CTF_SUPPORTED CTYPE
! 9619: CUPS_GROUP CUPS_SYSTEM_GROUPS
! 9620: CUPS_USER CURSES_DEFAULT
! 9621: CURSES_TYPE CVS_EXTRACTDIR
! 9622: CVS_MODULE CVS_PROJECT
! 9623: CVS_REPOSITORIES CVS_ROOT
! 9624: CVS_ROOT_GNU CVS_ROOT_NONGNU
! 9625: CVS_ROOT_SOURCEFORGE CVS_TAG
! 9626: CYRUS_GROUP CYRUS_IDLE
! 9627: CYRUS_USER DAEMONTOOLS_GROUP
! 9628: DAEMONTOOLS_LOG_USER DARWIN_NO_SYSTEM_LIBS
! 9629: DARWIN_REQUIRES_FILTER DBUS_GROUP
! 9630: DBUS_USER DEFANG_GROUP
! 9631: DEFANG_USER DEFAULT_ACCEPTABLE_LICENSES
! 9632: DEFAULT_DISTFILES DEFAULT_IRC_SERVER
! 9633: DEFAULT_SERIAL_DEVICE DEF_UMASK
! 9634: DEINSTALLDEPENDS DEINSTALL_SRC
! 9635: DEINSTALL_TEMPLATES DELAYED_ERROR_MSG
! 9636: DELAYED_WARNING_MSG DEPENDS
! 9637: DEPENDS_TARGET DEPENDS_TYPE
! 9638: DESTDIR DESTDIR_VARNAME
! 9639: DIALER_GROUP DIGEST_REQD
! 9640: DISTDIR DISTFILES
! 9641: DISTINFO_FILE DISTNAME
! 9642: DIST_PATH DIST_SUBDIR
! 9643: DJBDNS_AXFR_USER DJBDNS_CACHE_USER
! 9644: DJBDNS_DJBDNS_GROUP DJBDNS_LOG_USER
! 9645: DJBDNS_RBL_USER DJBDNS_TINY_USER
! 9646: DLOPEN_REQUIRE_PTHREADS DL_AUTO_VARS
! 9647: DL_CFLAGS DL_LDFLAGS
! 9648: DL_LIBS DNS
! 9649: DOCOWN DOWNLOADED_DISTFILE
! 9650: DQCACHE_GROUP DQCACHE_USER
! 9651: DT_LAYOUT DYNAMIC_SITES_CMD
! 9652: DYNAMIC_SITES_SCRIPT ECHO
! 9653: ECHO_N ELK_GUI
! 9654: EMACS_TYPE EMULDIR
! 9655: EMULSUBDIR EMULSUBDIRSLASH
! 9656: EMUL_ARCH EMUL_DISTRO
! 9657: EMUL_EXEC_FMT EMUL_IS_NATIVE
! 9658: EMUL_MODULES EMUL_OPSYS
! 9659: EMUL_PKG_FMT EMUL_PLATFORM
! 9660: EMUL_PLATFORMS EMUL_PREFER
! 9661: EMUL_REQD EMUL_TYPE
! 9662: ERROR_MSG EXIM_GROUP
! 9663: EXIM_USER EXPORT_SYMBOLS_LDFLAGS
! 9664: EXTRACTOR EXTRACT_CMD
! 9665: EXTRACT_CMD_DEFAULT EXTRACT_DIR
! 9666: EXTRACT_ELEMENTS EXTRACT_ENV
! 9667: EXTRACT_ONLY EXTRACT_OPTS
! 9668: EXTRACT_SUFX EXTRACT_USING
! 9669: FAIL FAILOVER_FETCH
! 9670: FAIL_MSG FAKE_NCURSES
! 9671: FAM FAM_ACCEPTED
! 9672: FAM_DEFAULT FAM_SERVER
! 9673: FCPATH FETCH_AFTER_ARGS
! 9674: FETCH_BEFORE_ARGS FETCH_CMD
! 9675: FETCH_INSECURE FETCH_OUTPUT_ARGS
! 9676: FETCH_PROXY FETCH_RESUME_ARGS
! 9677: FETCH_TIMEOUT FETCH_USE_IPV4_ONLY
! 9678: FETCH_USING FILES_SUBST
! 9679: FILES_SUBST_SED FIX_SYSTEM_HEADERS
! 9680: FONTDIR FONTS_DIRS
! 9681: FONTS_VERBOSE FOO_HACKS_MK
! 9682: FORCE_CXX_STD FORCE_C_STD
! 9683: FOSSIL_EXTRACTDIR FOSSIL_REPO
! 9684: FOSSIL_REPOSITORIES FOSSIL_VERSION
! 9685: FOX_USE_XUNICODE FREEWNN_GROUP
! 9686: FREEWNN_USER FTP_PKG_URL_DIR
! 9687: FTP_PKG_URL_HOST GAMEDATAMODE
! 9688: GAMEDATA_PERMS GAMEDIRMODE
! 9689: GAMEDIR_PERMS GAMEGRP
! 9690: GAMEMODE GAMEOWN
! 9691: GAMES_GROUP GAMES_USER
! 9692: GCC GCCBASE
! 9693: GCC_REQD GCC_VERSION_SUFFIX
! 9694: GEM_BUILD GEM_CLEANBUILD
! 9695: GEM_CLEANBUILD_EXTENSIONS GEM_DOCDIR
! 9696: GEM_EXTSDIR GEM_HOME
! 9697: GEM_KEEPBUILD GEM_LIBDIR
! 9698: GEM_NAME GEM_PATH
! 9699: GEM_PLUGINSDIR GEM_SPECFILE
! 9700: GENERATE_PLIST GHC
! 9701: GHOSTSCRIPT_REQD GITHUB_PROJECT
! 9702: GITHUB_RELEASE GITHUB_SUBMODULES
! 9703: GITHUB_TAG GITHUB_TYPE
! 9704: GITLAB_PROJECT GITLAB_RELEASE
! 9705: GITLAB_SUBMODULES GITLAB_TAG
! 9706: GITLAB_TYPE GIT_BRANCH
! 9707: GIT_ENV GIT_EXTRACTDIR
! 9708: GIT_REPO GIT_REPOSITORIES
! 9709: GIT_REVISION GIT_TAG
! 9710: GNU GNU_CONFIGURE
! 9711: GNU_CONFIGURE_ICONV GNU_CONFIGURE_INFODIR
! 9712: GNU_CONFIGURE_MANDIR GNU_CONFIGURE_QUIET
! 9713: GNU_CONFIGURE_STRICT GODEP_REDIRECTS
! 9714: GO_BUILD_PATTERN GO_DEPS
! 9715: GO_DIST_BASE GO_EXTRA_MOD_DIRS
! 9716: GO_MODULE_EXTRACT GO_MODULE_FILES
! 9717: GO_SRCPATH GROUP_SPECIFIC_PKGS
! 9718: GRUB_NETWORK_CARDS GRUB_PRESET_COMMAND
! 9719: GRUB_SCAN_ARGS GZIP
! 9720: HASKELL_COMPILER HASKELL_DISABLE_EXECUTABLES
! 9721: HASKELL_DISABLE_LIBRARIES HASKELL_ENABLE_DYNAMIC_EXECUTABLE
! 9722: HASKELL_ENABLE_HADDOCK_DOCUMENTATION HASKELL_ENABLE_LIBRARY_PROFILING
! 9723: HASKELL_ENABLE_SHARED_LIBRARY HASKELL_ENABLE_TESTS
! 9724: HASKELL_OPTIMIZATION_LEVEL HASKELL_PKG_NAME
! 9725: HASKELL_UNRESTRICT_DEPENDENCIES HEADER_TEMPLATES
! 9726: HG_REPO HG_REPOSITORIES
! 9727: HG_TAG HOMEPAGE
! 9728: HOST_PKGTOOLS_ARGS HOST_SPECIFIC_PKGS
! 9729: HOWL_GROUP HOWL_USER
! 9730: ICCBASE ICECAST_CHROOTDIR
! 9731: ICON_THEMES IDOBASE
! 9732: IGNORE_CCACHE IGNORE_INFO_DIRS
! 9733: IGNORE_INTERACTIVE_FETCH IMAKE
! 9734: IMAKEOPTS IMAKE_MAKE
! 9735: IMAKE_MANINSTALL IMAP_UW_CCLIENT_MBOX_FMT
! 9736: IMDICTDIR INCOMPAT_CURSES
! 9737: INFO_DIR INFO_FILES
! 9738: INFO_MSG INIT_SYSTEM
! 9739: INN_DATA_DIR INN_GROUP
! 9740: INN_USER INSTALLATION_DIRS
! 9741: INSTALLATION_DIRS_FROM_PLIST INSTALL_ENV
! 9742: INSTALL_ENV_SHELL INSTALL_SH_OVERRIDE
! 9743: INSTALL_SRC INSTALL_TEMPLATES
! 9744: INSTALL_UNSTRIPPED IRCD_HYBRID_IRC_GROUP
! 9745: IRCD_HYBRID_IRC_USER IRCD_HYBRID_MAXCONN
! 9746: IRCD_HYBRID_NICLEN IRCD_HYBRID_SYSLOG_EVENTS
! 9747: IRCD_HYBRID_SYSLOG_FACILITY IRCD_HYBRID_TOPICLEN
! 9748: IRIX IRRD_USE_PGP
! 9749: JABBERD_GROUP JABBERD_LOGDIR
! 9750: JABBERD_PIDDIR JABBERD_SPOOLDIR
! 9751: JABBERD_USER JAVA_APP_PATH
! 9752: JAVA_APP_TARGETS JAVA_BINPREFIX
! 9753: JAVA_CLASSPATH JAVA_HOME
! 9754: JAVA_LD_LIBRARY_PATH JAVA_NAME
! 9755: JAVA_UNLIMIT JAVA_WRAPPERS
! 9756: JPEG_ACCEPTED JPEG_DEFAULT
! 9757: KERBEROS KERMIT_SUID_UUCP
! 9758: KJS_USE_PCRE KNEWS_DOMAIN_FILE
! 9759: KNEWS_DOMAIN_NAME KRB5_ACCEPTED
! 9760: KRB5_DEFAULT LANGUAGES
! 9761: LAPACKE_LIBS LAPACKE_PC
! 9762: LAPACK_LIBS LAPACK_PC
! 9763: LATEX2HTML_ICONPATH LDCONFIG_ADD_CMD
! 9764: LDCONFIG_REMOVE_CMD LDD
! 9765: LEAFNODE_DATA_DIR LEAFNODE_GROUP
! 9766: LEAFNODE_USER LIBDVDCSS_HOMEPAGE
! 9767: LIBDVDCSS_MASTER_SITES LIBIMAGEQUANT_TYPE
! 9768: LIBRSVG_TYPE LIBTOOL
! 9769: LIBTOOLIZE_PLIST LIBTOOL_M4_OVERRIDE
! 9770: LIBUSB_TYPE LICENSE
! 9771: LINKER_RPATH_FLAG LINK_RPATH_FLAG
! 9772: LINUX_BASE_NODEPS LINUX_BASE_PREFERRED
! 9773: LINUX_BASE_REQUIRED LINUX_LOCALES
! 9774: LOCALBASE LOCALBASE_LOCKTYPE
! 9775: LOCALPATCHES LOVE_DATA
! 9776: LOVE_GAME LOVE_VERSION
! 9777: LOWER_OPSYS LOWER_OPSYS_VERSUFFIX
! 9778: LOWER_VARIANT_VERSION LOWER_VENDOR
! 9779: LP32PLATFORMS LP64PLATFORMS
! 9780: LUA_BUSTED_ARGS LUA_CDIR
! 9781: LUA_COMPILER LUA_DOCDIR
! 9782: LUA_EXAMPLESDIR LUA_INCDIR
! 9783: LUA_INTERPRETER LUA_LDIR
! 9784: LUA_LINKER_MAGIC LUA_PKGPREFIX
! 9785: LUA_SELF_CONFLICT LUA_USE_BUSTED
! 9786: LUA_VERSIONS_ACCEPTED LUA_VERSIONS_INCOMPATIBLE
! 9787: LUA_VERSION_DEFAULT LUA_VERSION_REQD
! 9788: Lua MACHINE_PLATFORM
! 9789: MAILAGENT_DOMAIN MAILAGENT_EMAIL
! 9790: MAILAGENT_FQDN MAILAGENT_ORGANIZATION
! 9791: MAJORDOMO_HOMEDIR MAJOR_OS_VERSION
! 9792: MAKEINFO_ARGS MAKE_DIRS
! 9793: MAKE_DIRS_PERMS MAKE_ENV
! 9794: MAKE_FILE MAKE_FLAGS
! 9795: MAKE_JOBS MAKE_JOBS_SAFE
! 9796: MAKE_PROGRAM MANCOMPRESSED_IF_MANZ
! 9797: MANINSTALL MANZ
! 9798: MARIADB_VERSIONS_ALL MASTER_SITES
! 9799: MASTER_SITE_BACKUP MASTER_SITE_LOCAL
! 9800: MASTER_SITE_MOZILLA MASTER_SITE_OVERRIDE
! 9801: MASTER_SITE_PERL_CPAN MASTER_SORT
! 9802: MASTER_SORT_RANDOM MASTER_SORT_REGEX
! 9803: MECAB_CHARSET MEDIATOMB_GROUP
! 9804: MEDIATOMB_USER MIPSPROBASE
! 9805: MIREDO_GROUP MIREDO_USER
! 9806: MISSING_FEATURES MKDIR
! 9807: MKPIE_SUPPORTED MLDONKEY_GROUP
! 9808: MLDONKEY_HOME MLDONKEY_USER
! 9809: MONOTONE_GROUP MONOTONE_USER
! 9810: MOTIFBASE MOTIF_TYPE
! 9811: MOTIF_TYPE_DEFAULT MPI_TYPE
! 9812: MSGFMT_STRIP_MSGCTXT MSGFMT_STRIP_MSGID_PLURAL
! 9813: MTOOLS_ENABLE_FLOPPYD MUST
! 9814: MV MYSQL_CHARSET
! 9815: MYSQL_DATADIR MYSQL_EXTRA_CHARSET
! 9816: MYSQL_GROUP MYSQL_USER
! 9817: MYSQL_VERSION MYSQL_VERSIONS_ACCEPTED
! 9818: MYSQL_VERSION_DEFAULT NAGIOSCMD_GROUP
! 9819: NAGIOSDIR NAGIOS_GROUP
! 9820: NAGIOS_USER NATIVE_EXEC_FMT
! 9821: NATIVE_LOWER_OPSYS NATIVE_LOWER_VENDOR
! 9822: NATIVE_MACHINE_PLATFORM NATIVE_OBJECT_FMT
! 9823: NATIVE_OPSYS_VERSION NATIVE_OS_VARIANT
! 9824: NATIVE_OS_VERSION NBPAX_PROGRAM_PREFIX
! 9825: NETBSD_LOGIN_NAME NMH_EDITOR
! 9826: NMH_MTA NMH_PAGER
! 9827: NODE_VERSIONS_ACCEPTED NODE_VERSIONS_INCOMPATIBLE
! 9828: NODE_VERSION_DEFAULT NODE_VERSION_REQD
! 9829: NOLOGIN NOTE
! 9830: NOT_FOR_PLATFORM NOT_PAX_ASLR_SAFE
! 9831: NOT_PAX_MPROTECT_SAFE NO_BUILD
! 9832: NO_CHECKSUM NO_CONFIGURE
! 9833: NO_SKIP NSD_GROUP
! 9834: NSD_LOG_FACILITY NSD_USER
! 9835: NS_PREFERRED NULLMAILER_GROUP
! 9836: NULLMAILER_USER OBJECT_FMT
! 9837: OBJHOSTNAME OBJMACHINE
! 9838: OCAML_FINDLIB_DIRS OCAML_FINDLIB_REGISTER
! 9839: OCAML_FINDLIB_REGISTER_VERBOSE OCAML_SITELIBDIR
! 9840: OMF ONLY_FOR_COMPILER
! 9841: ONLY_FOR_PLATFORM OPENSSH_CHROOT
! 9842: OPENSSH_GROUP OPENSSH_USER
! 9843: OPSYS OPSYS_EMULDIR
! 9844: OPSYS_VERSION OS
! 9845: OSS_TYPE OSX
! 9846: OSX_PATH_TO_M4 OSX_PATH_TO_YACC
! 9847: OS_HAVE_ALSA OS_HAVE_RCD
! 9848: OS_VARIANT OS_VERSION
! 9849: OTF_FONTS_DIR OVERRIDE_DIRDEPTH
! 9850: OVERRIDE_GEMSPEC OVERRIDE_GNU_CONFIG_SCRIPTS
! 9851: OVERRIDE_ROCKSPEC OWN_DIRS
! 9852: OWN_DIRS_PERMS P4GROUP
! 9853: P4PORT P4ROOT
! 9854: P4USER PACKAGES
! 9855: PALMOS_DEFAULT_SDK PAMBASE
! 9856: PAM_DEFAULT PAPERSIZE
! 9857: PASSIVE_FETCH PATCHDIR
! 9858: PATCHFILES PATCH_ARGS
! 9859: PATCH_DEBUG PATCH_DIST_ARGS
! 9860: PATCH_DIST_CAT PATCH_DIST_STRIP
! 9861: PATCH_FUZZ_FACTOR PATCH_STRIP
! 9862: PATH PCCBASE
! 9863: PEAR PEAR_CHANNEL
! 9864: PEAR_CHANNEL_ALIAS PEAR_CHANNEL_VERSION
! 9865: PEAR_CMD PEAR_LIB
! 9866: PEAR_PACKAGE_XML PEP-518
! 9867: PERL5 PERL5_CONFIGURE
! 9868: PERL5_CONFIGURE_DIRS PERL5_LDFLAGS
! 9869: PERL5_LICENSE PERL5_MODULE_TYPE
! 9870: PERL5_PACKLIST PERL5_PACKLIST_DIR
! 9871: PERL5_PERLBASE PERL5_SITEBASE
! 9872: PERL5_USE_PACKLIST PERL5_VENDORBASE
! 9873: PFCTL PFVAR_H
! 9874: PF_VERSION PGGROUP
! 9875: PGHOME PGPKGSRCDIR
! 9876: PGSQL_TYPE PGSQL_VERSION
! 9877: PGSQL_VERSIONS_ACCEPTED PGSQL_VERSION_DEFAULT
! 9878: PGUSER PG_LIB_EXT
! 9879: PHP PHPCOMMON_MK
! 9880: PHPPKGSRCDIR PHP_BASE_VERS
! 9881: PHP_EGDIR PHP_EXTENSION_DIR
! 9882: PHP_INCDIR PHP_LIBDIR
! 9883: PHP_MAJOR_VERS PHP_MINIMUM_TEENY
! 9884: PHP_MINOR_VERS PHP_PKG_PREFIX
! 9885: PHP_SHAREDIR PHP_VER
! 9886: PHP_VERSION PHP_VERSIONS_ACCEPTED
! 9887: PHP_VERSIONS_INCOMPATIBLE PHP_VERSION_DEFAULT
! 9888: PHP_VERSION_REQD PILRC_USE_GTK
! 9889: PKGCONFIG_BASE PKGCONFIG_FILE
! 9890: PKGCONFIG_OVERRIDE PKGCONFIG_OVERRIDE_STAGE
! 9891: PKGDIR PKGGNUDIR
! 9892: PKGINFODIR PKGLOCALEDIR
! 9893: PKGMANDIR PKGNAME
! 9894: PKGNAME_REQD PKGPATH
! 9895: PKGREVISION PKGSRC_BLAS_TYPES
! 9896: PKGSRC_CHANGES PKGSRC_COMPILER
! 9897: PKGSRC_KEEP_BIN_PKGS PKGSRC_LOCKTYPE
! 9898: PKGSRC_MAKE_ENV PKGSRC_MESSAGE_RECIPIENTS
! 9899: PKGSRC_MKPIE PKGSRC_MKREPRO
! 9900: PKGSRC_OVERRIDE_MKPIE PKGSRC_RUN_TEST
! 9901: PKGSRC_SETENV PKGSRC_SLEEPSECS
! 9902: PKGSRC_TODO PKGSRC_USE_CTF
! 9903: PKGSRC_USE_FORTIFY PKGSRC_USE_MKTOOLS
! 9904: PKGSRC_USE_RELRO PKGSRC_USE_SSP
! 9905: PKGSRC_USE_STACK_CHECK PKGTASKS_DATAFILE
! 9906: PKGTOOLS_ARGS PKGTOOLS_ENV
! 9907: PKG_ALTERNATIVES PKG_APACHE
! 9908: PKG_APACHE_ACCEPTED PKG_APACHE_DEFAULT
! 9909: PKG_BEST_EXISTS PKG_BUILD_OPTIONS
! 9910: PKG_COMPRESSION PKG_CONFIG
! 9911: PKG_CONFIG_PERMS PKG_CREATE_USERGROUP
! 9912: PKG_DBDIR PKG_DB_TMPDIR
! 9913: PKG_DEBUG_LEVEL PKG_DEFAULT_OPTIONS
! 9914: PKG_DESTDIR_SUPPORT PKG_DEVELOPER
! 9915: PKG_DISABLED_OPTIONS PKG_FATAL_ERRORS
! 9916: PKG_FC PKG_FILELIST_CMD
! 9917: PKG_GECOS PKG_GID
! 9918: PKG_GROUPS PKG_GROUPS_VARS
! 9919: PKG_HOME PKG_INIT_SCRIPTS
! 9920: PKG_JAVA_HOME PKG_JVM
! 9921: PKG_JVMS_ACCEPTED PKG_JVM_DEFAULT
! 9922: PKG_LEGACY_OPTIONS PKG_LIBTOOL
! 9923: PKG_MKSYMLINKS PKG_OPTIONS
! 9924: PKG_OPTIONS_DEPRECATED_WARNINGS PKG_OPTIONS_LEGACY_OPTS
! 9925: PKG_OPTIONS_LEGACY_VARS PKG_OPTIONS_NONEMPTY_SETS
! 9926: PKG_OPTIONS_OPTIONAL_GROUPS PKG_OPTIONS_REQUIRED_GROUPS
! 9927: PKG_OPTIONS_VAR PKG_RCD_SCRIPTS
! 9928: PKG_REFCOUNT_DBDIR PKG_REGISTER_SHELLS
! 9929: PKG_RESUME_TRANSFERS PKG_SHELL
! 9930: PKG_SUGGESTED_OPTIONS PKG_SUPPORTED_OPTIONS
! 9931: PKG_SYSCONFBASE PKG_SYSCONFBASEDIR
! 9932: PKG_SYSCONFDIR PKG_SYSCONFDIR_PERMS
! 9933: PKG_SYSCONFSUBDIR PKG_SYSCONFVAR
! 9934: PKG_TOOLS_BIN PKG_UID
! 9935: PKG_UPDATE_FONTS_DB PKG_USERS
! 9936: PKG_USERS_VARS PKG_VERBOSE
! 9937: PLEASE PLIST
! 9938: PLIST_AWK PLIST_AWK_ENV
! 9939: PLIST_SRC PLIST_SUBST
! 9940: PLIST_TYPE PLIST_VARS
! 9941: POPTOP_USE_MPPE POSSIBLE_GFORTRAN_VERSION
! 9942: POST_FETCH_HOOK PREFER
! 9943: PREFER_NATIVE PREFER_NATIVE_PTHREADS
! 9944: PREFER_PKGSRC PREFIX
! 9945: PREPEND_PATH PRE_ROOT_CMD
! 9946: PRIVILEGED_STAGES PS
! 9947: PTHREAD_AUTO_VARS PTHREAD_CFLAGS
! 9948: PTHREAD_LDFLAGS PTHREAD_LIBS
! 9949: PTHREAD_OPTS PTHREAD_TYPE
! 9950: PVM_SSH PYPKGPREFIX
! 9951: PYTHON_FOR_BUILD_ONLY PYTHON_SELF_CONFLICT
! 9952: PYTHON_VERSION PYTHON_VERSIONED_DEPENDENCIES
! 9953: PYTHON_VERSIONS_ACCEPTED PYTHON_VERSIONS_INCOMPATIBLE
! 9954: PYTHON_VERSION_DEFAULT PYTHON_VERSION_REQD
! 9955: PYVERSSUFFIX QMAILDIR
! 9956: QMAIL_ALIAS_USER QMAIL_DAEMON_USER
! 9957: QMAIL_LOG_USER QMAIL_NOFILES_GROUP
! 9958: QMAIL_PASSWD_USER QMAIL_QMAIL_GROUP
! 9959: QMAIL_QUEUE_DIR QMAIL_QUEUE_EXTRA
! 9960: QMAIL_QUEUE_USER QMAIL_REMOTE_USER
! 9961: QMAIL_ROOT_USER QMAIL_SEND_USER
! 9962: QORE_LATEST_MODULE_API QORE_MODULE_API
! 9963: QORE_MODULE_DIR QORE_USER_MODULE_DIR
! 9964: QORE_VERSION QPOPPER_FAC
! 9965: QPOPPER_SPOOL_DIR QPOPPER_USER
! 9966: RAKE_NAME RASMOL_DEPTH
! 9967: RCD_DIR RCD_ORDER
! 9968: RCD_SCRIPTS RCD_SCRIPTS_DIR
! 9969: RCD_SCRIPTS_EXAMPLEDIR RCD_SCRIPTS_MODE
! 9970: RCD_SCRIPTS_SHELL RCD_SCRIPT_SRC
! 9971: RCD_SUBR RDOC
! 9972: READLINE_DEFAULT READLINE_TYPE
! 9973: REAL_ROOT_GROUP REAL_ROOT_USER
! 9974: RECURSIVE_MAKE RELAY_CTRL_DIR
! 9975: RELRO_SUPPORTED REPLACE_AWK
! 9976: REPLACE_BASH REPLACE_CSH
! 9977: REPLACE_KSH REPLACE_LUA
! 9978: REPLACE_NODEJS REPLACE_OCTAVE
! 9979: REPLACE_PERL REPLACE_PERL6
! 9980: REPLACE_PHP REPLACE_PYTHON
! 9981: REPLACE_QORE REPLACE_R
! 9982: REPLACE_RUBY REPLACE_RUBY_DIRS
! 9983: REPLACE_RUBY_PAT REPLACE_SH
! 9984: REPLACE_TEXLUA REPLACE_TOOL_PYTHON
! 9985: REPLACE_WISH REQD_DIRS
! 9986: REQD_DIRS_PERMS REQD_FILES
! 9987: REQD_FILES_MODE REQD_FILES_PERMS
! 9988: RESOLV_AUTO_VARS RESOLV_LDFLAGS
! 9989: RESOLV_LIBS RM
! 9990: ROCKSPEC_NAME ROCKSPEC_SPECFILE
! 9991: ROOT_CMD ROOT_GROUP
! 9992: ROOT_USER RPCGEN
! 9993: RPM RPM2PKG_PLIST
! 9994: RPM2PKG_PREFIX RPM2PKG_STAGE
! 9995: RPM2PKG_STRIP RPM2PKG_SUBPREFIX
! 9996: RPMFILES RPMIGNOREPATH
! 9997: RPM_DB_PREFIX RSSH_CVS_PATH
! 9998: RSSH_RDIST_PATH RSSH_RSYNC_PATH
! 9999: RSSH_SCP_PATH RSSH_SFTP_SERVER_PATH
! 10000: RUBY RUBYGEM
! 10001: RUBYGEM_MANPAGES RUBYGEM_NAME
! 10002: RUBYGEM_OPTIONS RUBYGEM_USE_MANPAGES
! 10003: RUBYGEM_VERBOSE RUBY_ABI_VERSION
! 10004: RUBY_ARCH RUBY_ARCHINC
! 10005: RUBY_ARCHLIB RUBY_BASE
! 10006: RUBY_BASERIDIR RUBY_BUILD_DOCUMENT
! 10007: RUBY_DLEXT RUBY_DOC
! 10008: RUBY_DYNAMIC_DIRS RUBY_EG
! 10009: RUBY_ENCODING_ARG RUBY_EXTCONF
! 10010: RUBY_EXTCONF_CHECK RUBY_EXTCONF_DEBUG
! 10011: RUBY_EXTCONF_MAKEFILE RUBY_GEM_ARCH
! 10012: RUBY_GEM_BASE RUBY_INC
! 10013: RUBY_LIB RUBY_LIB_BASE
! 10014: RUBY_NAME RUBY_NOVERSION
! 10015: RUBY_PKGPREFIX RUBY_RAILS
! 10016: RUBY_RAILS61_VERSION RUBY_RAILS70_VERSION
! 10017: RUBY_RAILS71_VERSION RUBY_RAILS72_VERSION
! 10018: RUBY_RAILS80_VERSION RUBY_RAILS_ACCEPTED
! 10019: RUBY_RAILS_DEFAULT RUBY_RAILS_REQD
! 10020: RUBY_RAILS_STRICT_DEP RUBY_RIDIR
! 10021: RUBY_SETUP RUBY_SHLIB
! 10022: RUBY_SHLIBALIAS RUBY_SHLIBVER
! 10023: RUBY_SIMPLE_INSTALL RUBY_SITEARCHLIB
! 10024: RUBY_SITELIB RUBY_SITELIB_BASE
! 10025: RUBY_SITERIDIR RUBY_SLEXT
! 10026: RUBY_SRCDIR RUBY_STATICLIB
! 10027: RUBY_SUFFIX RUBY_SYSRIDIR
! 10028: RUBY_USE_PTHREAD RUBY_VENDORARCHLIB
! 10029: RUBY_VENDORLIB RUBY_VENDORLIB_BASE
! 10030: RUBY_VER RUBY_VERSION
! 10031: RUBY_VERSIONS_ACCEPTED RUBY_VERSIONS_INCOMPATIBLE
! 10032: RUBY_VERSION_DEFAULT RUBY_VERSION_REQD
! 10033: RUBY_VER_DIR RUN
! 10034: RUN_LDCONFIG RUST_TYPE
! 10035: SCO SCREWS_GROUP
! 10036: SCREWS_USER SCRIPTS_ENV
! 10037: SCROLLKEEPER_DATADIR SCROLLKEEPER_REBUILDDB
! 10038: SCROLLKEEPER_UPDATEDB SDIST_PAWD
! 10039: SDL12_TYPE SERIAL_DEVICES
! 10040: SETGIDGAME SETGID_GAMES_PERMS
! 10041: SETUID_ROOT_PERMS SH
! 10042: SHLIB SHORTNAME
! 10043: SIGN_PACKAGES SILC_CLIENT_WITH_PERL
! 10044: SITE_SPECIFIC_PKGS SKIP_DEPENDS
! 10045: SMF_INSTANCES SMF_MANIFEST
! 10046: SMF_METHODS SMF_METHOD_SHELL
! 10047: SMF_METHOD_SRC SMF_NAME
! 10048: SMF_PREFIX SMF_SRCDIR
! 10049: SNIPROXY_GROUP SNIPROXY_USER
! 10050: SOURCE_BUFFSIZE SPECIAL_PERMS
! 10051: SPECIFIC_PKGS SSH_SUID
! 10052: SSLCERTBUNDLE SSLCERTS
! 10053: SSLDIR SSLKEYS
! 10054: SSP_SUPPORTED SSYNC_PAWD
! 10055: STEP_MSG STRIP
! 10056: STRIP_DBG STRIP_DEBUG
! 10057: STRIP_DEBUG_SUPPORTED STRIP_FILES_SKIP
! 10058: SU SUBDIR
! 10059: SUBST SUBST_CLASSES
! 10060: SUBST_FILES SUBST_FILTER_CMD
! 10061: SUBST_MESSAGE SUBST_NOOP_OK
! 10062: SUBST_SED SUBST_SHOW_DIFF
! 10063: SUBST_SKIP_TEXT_CHECK SUBST_STAGE
! 10064: SUBST_VARS SUNWSPROBASE
! 10065: SUSE_PREFER SU_CMD
! 10066: SVN_EXTRACTDIR SVN_REPO
! 10067: SVN_REPOSITORIES SVN_REVISION
! 10068: SYSCONFBASE TARGET_MACHINE_ARCH
! 10069: TBL TERMCAP_TYPE
! 10070: TERMINFO_DEFAULT TERMINFO_TYPE
! 10071: TEST TEST_DEPENDS
! 10072: TEST_DIRS TEST_ENV
! 10073: TEST_ENV_SHELL TEST_MAKE_CMD
! 10074: TEST_MAKE_FLAGS TEST_TARGET
! 10075: TEXLIVE_IGNORE_PATTERNS TEXLIVE_REV
! 10076: TEXLIVE_UNVERSIONED TEXMFSITE
! 10077: TEX_FORMATS TEX_HYPHEN_DAT
! 10078: TEX_HYPHEN_DEF TEX_TEXMF_DIRS
! 10079: THTTPD_LOG_FACILITY TINYDYN_USER
! 10080: TLS TLSWRAPPER_CHROOT
! 10081: TO TOOLDIR
! 10082: TOOLS_ALIASES TOOLS_ALWAYS_WRAP
! 10083: TOOLS_ARGS TOOLS_BROKEN
! 10084: TOOLS_CMD TOOLS_CMDLINE_SED
! 10085: TOOLS_CREATE TOOLS_CROSS_DESTDIR
! 10086: TOOLS_DIR TOOLS_FAIL
! 10087: TOOLS_GNU_MISSING TOOLS_LDCONFIG
! 10088: TOOLS_NOOP TOOLS_PATH
! 10089: TOOLS_SCRIPT TOOLS_USE_CROSS_COMPILE
! 10090: TOOL_DEPENDS TTF_FONTDIR
! 10091: TTF_FONTS_DIR TYPE
! 10092: UAC_REQD_EXECS UCSPI_SSL_GROUP
! 10093: UCSPI_SSL_USER UNBOUND_GROUP
! 10094: UNBOUND_LOG_FACILITY UNBOUND_USER
! 10095: UNLIMIT_RESOURCES UNPRIVILEGED
! 10096: UNPRIVILEGED_GROUP UNPRIVILEGED_GROUPS
! 10097: UNPRIVILEGED_USER UNWRAP_FILES
! 10098: UNWRAP_PATTERNS UPDATE_GEMSPEC
! 10099: UPDATE_TARGET URI
! 10100: USERGROUP_PHASE USERPPP_GROUP
! 10101: USER_SPECIFIC_PKGS USE_ABI_DEPENDS
! 10102: USE_APR USE_BSD_MAKEFILE
! 10103: USE_BUILTIN USE_CC_FEATURES
! 10104: USE_CROSS_COMPILE USE_CURSES
! 10105: USE_CWRAPPERS USE_CXX_FEATURES
! 10106: USE_DB185 USE_FEATURES
! 10107: USE_GAMESGROUP USE_GCC_RUNTIME
! 10108: USE_IMAKE USE_INDIRECT_DEPENDS
! 10109: USE_JAVA USE_JAVA2
! 10110: USE_LANGUAGES USE_LIBTOOL
! 10111: USE_NATIVE_GCC USE_NETBSD_REPO
! 10112: USE_PKGSRC_GCC USE_PKGSRC_GCC_RUNTIME
! 10113: USE_PKGTASKS USE_PKG_ADMIN_DIGEST
! 10114: USE_RUBY_EXTCONF USE_RUBY_INSTALL
! 10115: USE_RUBY_SETUP USE_RUBY_SETUP_PKG
! 10116: USE_TMPFILES USE_TOOLS
! 10117: UUCP_GROUP UUCP_USER
! 10118: VARBASE VARNAME
! 10119: VIM_EXTRA_OPTS WARNING_MSG
! 10120: WCALC_CGIDIR WCALC_CGIPATH
! 10121: WCALC_HTMLDIR WCALC_HTMLPATH
! 10122: WDM_MANAGERS WRAPPER_CC
! 10123: WRAPPER_REORDER_CMDS WRKDIR
! 10124: WRKDIR_BASENAME WRKDIR_LOCKTYPE
! 10125: WRKLOG WRKOBJDIR
! 10126: WRKSRC X10_PORT
! 10127: X11 X11BASE
! 10128: X11_PKGSRCDIR X11_TYPE
! 10129: X509_CERTIFICATE X509_KEY
! 10130: XAW_TYPE XLOCK_DEFAULT_MODE
! 10131: XMKMF XMKMF_FLAGS
! 10132: XXX XXXX
! 10133: YES ZSH_STATIC
! 10134: __stdc__ _vargroups
! 10135: accept acquire-localbase-lock
! 10136: acquire-lock add
! 10137: added administrator
! 10138: alloca alternatives
! 10139: aslr asprintf
! 10140: atlas autoconf
! 10141: automake autoreconf
! 10142: awk bash
! 10143: big-endian bin-install
! 10144: bind binpkg-list
! 10145: blas bootstrap-depends
! 10146: broken broken_on_platform
! 10147: bsd bsd.prog.mk
! 10148: build build-env
! 10149: buildlink-directories buildlink-oss-soundcard-h
! 10150: built-in builtin
! 10151: c c++
! 10152: ccache cce
! 10153: cdefs ceil
! 10154: changes changes-entry
! 10155: changes-entry-noupdate check
! 10156: check-clean check-files
! 10157: check-files-clean check-hackage
! 10158: check-vulnerable checksum
! 10159: checksum-phase clean
! 10160: clean-depends cleandir
! 10161: commit commit-changes-entry
! 10162: compact compiler
! 10163: conf config.guess
! 10164: config.sub configuration
! 10165: configure configure-env
! 10166: configure-help configure_args
! 10167: connect cos
! 10168: cpe cputime
! 10169: create-usergroup csh
! 10170: ctf cvs
! 10171: debug declaration
! 10172: declare defined
! 10173: depend dependencies
! 10174: depends depends-checksum
! 10175: depends-fetch deps
! 10176: describe destdir
! 10177: disable distclean
! 10178: distfiles distinfo
! 10179: dl dlopen
! 10180: do-buildlink do-clean
! 10181: do-configure do-configure-post-hook
! 10182: do-extract do-fetch
! 10183: do-install download
! 10184: emul emul-distinfo
! 10185: emul-fetch emulation
! 10186: emulator enable
! 10187: endian endif
! 10188: enomem ensurepip
! 10189: err errx
! 10190: etc exp
! 10191: extract-rpm fabs
! 10192: feature features
! 10193: fetch fetch-list
! 10194: follows forbids
! 10195: form format
! 10196: fortify fortify_source
! 10197: fossil friend
! 10198: fts fts_close
! 10199: fts_open fts_read
! 10200: fts_set gcc
! 10201: gethostbyaddr gethostbyname
! 10202: gethostbyname2 getopt_long
! 10203: getprogname getservbyname
! 10204: getservbyport getservent
! 10205: gettext git
! 10206: github gitlab
! 10207: glob gnu
! 10208: gnu_configure_strict go
! 10209: go-deps golang
! 10210: guess-license hashbang
! 10211: heimdal help
! 10212: hg imake
! 10213: in-tree increment
! 10214: indirect inet_aton
! 10215: install install-env
! 10216: interp interpreter
! 10217: intl ip4
! 10218: ip6 ipv4
! 10219: ipv6 iso
! 10220: kerberos krb
! 10221: krb5 ksh
! 10222: lapack latex
! 10223: libiconv libintl_bindtextdomain
! 10224: libintl_gettext libintl_textdomain
! 10225: libnbcompat libs
! 10226: libtool licence
! 10227: license lintl
! 10228: little-endian lock
! 10229: locking lua
! 10230: lvalue machine_endian
! 10231: make makedistinfo
! 10232: makepatchsum makesum
! 10233: mdi memory
! 10234: mercurial meta
! 10235: meta-package meta_package
! 10236: mit-krb5 mk.conf
! 10237: mkl mount
! 10238: move moved
! 10239: mprotect mps
! 10240: mremap native
! 10241: nb nbcompat
! 10242: netlib network
! 10243: node node.js
! 10244: nodejs obstack
! 10245: obstack_ptr_grow occurs
! 10246: only openblas
! 10247: options options.mk
! 10248: order override
! 10249: override-intltool override-message-intltool
! 10250: package parallel
! 10251: path pax
! 10252: paxctl pbulk-index
! 10253: pc perl
! 10254: perl5 perms
! 10255: php pkg-build-options
! 10256: pkg-config pkg_build_options
! 10257: pkgsrc platform
! 10258: plist post-extract
! 10259: post-fetch post-wrapper
! 10260: pre-build-checks-hook pre-configure-checks-hook
! 10261: pre-extract pre-fetch
! 10262: print-go-deps print-plist
! 10263: print-summary-data privileged-install-hook
! 10264: pypi python
! 10265: r readme-all
! 10266: recursive recv
! 10267: recvfrom regcomp
! 10268: release-localbase-lock release-lock
! 10269: relro remove
! 10270: removed rename
! 10271: renamed reorder
! 10272: replace replace_interpreter
! 10273: reproducible resolv
! 10274: root ruby
! 10275: send sendfile
! 10276: sendto setenv
! 10277: setgid setprogname
! 10278: setuid sh
! 10279: shebang show
! 10280: show-all show-build-defs
! 10281: show-depends show-depends-dirs
! 10282: show-depends-pkgpaths show-depends-recursive
! 10283: show-deps show-distfiles
! 10284: show-downlevel show-subdir-var
! 10285: show-tools show-var
! 10286: show-vars snprintf
! 10287: socket ssp
! 10288: st_mode stage-install
! 10289: strcasestr strict
! 10290: strip strndup
! 10291: strnlen strsep
! 10292: subst substitutions
! 10293: subversion sun
! 10294: sunpro sunwspro
! 10295: svn symlink
! 10296: test test-env
! 10297: tex texlive
! 10298: tmp todo
! 10299: tool tools
! 10300: tools-libtool-m4-override transitive
! 10301: type ulimit
! 10302: undefined undo-replace
! 10303: unlimit unprivileged
! 10304: unprivileged-install-hook unstripped
! 10305: update updated
! 10306: upload upload-distfiles
! 10307: use_tools user
! 10308: utimes vasprintf
! 10309: verbose vsnprintf
! 10310: warn warning
! 10311: warnings warnx
! 10312: wattr_off wattr_on
! 10313: work wrapper
! 10314: wrkdir
1.154 rillig 10315:
1.207 leot 10316: Appendix F. Editing guidelines for the pkgsrc guide
1.1 dsieger 10317:
10318: Table of Contents
10319:
1.207 leot 10320: F.1. Make targets
10321: F.2. Procedure
1.1 dsieger 10322:
10323: This section contains information on editing the pkgsrc guide itself.
10324:
1.207 leot 10325: F.1. Make targets
1.1 dsieger 10326:
10327: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
10328: files are created from it:
10329:
10330: * pkgsrc/doc/pkgsrc.txt
10331:
10332: * pkgsrc/doc/pkgsrc.html
10333:
1.174 leot 10334: * https://www.NetBSD.org/docs/pkgsrc/
1.1 dsieger 10335:
1.174 leot 10336: * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the
10337: pkgsrc guide.
1.1 dsieger 10338:
1.174 leot 10339: * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
1.2 rillig 10340: pkgsrc guide.
1.1 dsieger 10341:
1.207 leot 10342: F.2. Procedure
1.1 dsieger 10343:
10344: The procedure to edit the pkgsrc guide is:
10345:
1.190 bacon 10346: 1. Make sure you have checked out the htdocs repository into a sibling
10347: directory of your pkgsrc directory. You will need the ability to commit
10348: from both pkgsrc and htdocs.
10349:
10350: 2. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46 obache 10351: other XML-based NetBSD documentation) installed. These are automatically
10352: installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1 dsieger 10353:
1.190 bacon 10354: 3. Run cd doc/guide to get to the right directory. All further steps will take
1.1 dsieger 10355: place here.
10356:
1.190 bacon 10357: 4. Edit the XML file(s) in files/.
1.1 dsieger 10358:
1.190 bacon 10359: 5. Run bmake to check the pkgsrc guide for valid XML and to build the final
1.1 dsieger 10360: output files. If you get any errors at this stage, you can just edit the
10361: files, as there are only symbolic links in the working directory, pointing
10362: to the files in files/.
10363:
1.190 bacon 10364: 6. (cd files && cvs commit)
1.1 dsieger 10365:
1.190 bacon 10366: 7. Run bmake clean && bmake to regenerate the output files with the proper RCS
1.1 dsieger 10367: Ids.
10368:
1.190 bacon 10369: 8. Run bmake regen to install and commit the files in both pkgsrc/doc and
1.1 dsieger 10370: htdocs.
10371:
10372: Note
10373:
10374: If you have added, removed or renamed some chapters, you need to
10375: synchronize them using cvs add or cvs delete in the htdocs directory.
10376:
CVSweb <webmaster@jp.NetBSD.org>