Annotation of htdocs/docs/pkgsrc/pkgsrc.txt, revision 1.274
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.269 wiz 15: Copyright 1994-2026 The NetBSD Foundation, Inc
1.1 dsieger 16:
1.269 wiz 17: $NetBSD: pkgsrc.xml,v 1.46 2026/01/01 08:41:23 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.271 wiz 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
1.272 wiz 83: 8.3. Speeding up bulk build scans
84: 8.4. Requirements of a full bulk build
85: 8.5. Bulk build variants
86: 8.5.1. Detect unknown configure options
87: 8.5.2. Detect classes of bugs by forcing compiler warnings
88: 8.5.3. Force compiler options only in the build phase
89: 8.5.4. Use custom directories
90: 8.5.5. Turn warnings into errors
91: 8.5.6. Reject packages for which pkglint reports errors
92: 8.5.7. Reject packages that contain forbidden strings
93: 8.5.8. Reject packages whose self-test fails
94: 8.5.9. Reject packages that use undefined shell variables
95: 8.5.10. Turn off verbose logging
96: 8.6. Creating a multiple CD-ROM packages collection
97: 8.6.1. Example of cdpack
1.154 rillig 98: 9. Directory layout of the installed files
99: 9.1. File system layout in ${LOCALBASE}
100: 9.2. File system layout in ${VARBASE}
101: 10. Frequently Asked Questions
102: 10.1. Are there any mailing lists for pkg-related discussion?
103: 10.2. Utilities for package management (pkgtools)
104: 10.3. How to use pkgsrc as non-root
105: 10.4. How to resume transfers when fetching distfiles?
106: 10.5. How can I install/use modular X.org from pkgsrc?
107: 10.6. How to fetch files from behind a firewall
108: 10.7. How to fetch files from HTTPS sites
109: 10.8. How do I tell make fetch to do passive FTP?
110: 10.9. How to fetch all distfiles at once
1.266 martin 111: 10.10. What does Don't know how to make /usr/share/tmac/tmac.andoc
1.271 wiz 112: mean?
1.266 martin 113: 10.11. What does Could not find bsd.own.mk mean?
1.221 nia 114: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154 rillig 115: 10.13. How do I change the location of configuration files?
116: 10.14. Automated security checks
117: 10.15. Why do some packages ignore my CFLAGS?
118: 10.16. A package does not build. What shall I do?
1.266 martin 119: 10.17. What does Makefile appears to contain unresolved cvs/rcs/???
1.271 wiz 120: merge conflicts mean?
1.1 dsieger 121: II. The pkgsrc developer's guide
1.154 rillig 122: 11. Getting help
1.184 rillig 123: 12. Package components - files, directories and contents
124: 12.1. Makefile
125: 12.2. distinfo
126: 12.3. patches/*
127: 12.3.1. Structure of a single patch file
128: 12.3.2. Creating patch files
129: 12.3.3. Sources where the patch files come from
130: 12.3.4. Patching guidelines
131: 12.3.5. Feedback to the author
132: 12.4. Other mandatory files
133: 12.5. Optional files
134: 12.5.1. Files affecting the binary package
135: 12.5.2. Files affecting the build process
136: 12.5.3. Files affecting nothing at all
137: 12.6. work*
138: 12.7. files/*
139: 13. The build process
140: 13.1. Introduction
141: 13.2. Program location
142: 13.3. Directories used during the build process
143: 13.4. Running a phase
144: 13.5. The fetch phase
145: 13.5.1. What to fetch and where to get it from
146: 13.5.2. How are the files fetched?
147: 13.6. The checksum phase
148: 13.7. The extract phase
149: 13.8. The patch phase
150: 13.9. The tools phase
151: 13.10. The wrapper phase
152: 13.11. The configure phase
153: 13.12. The build phase
154: 13.13. The test phase
155: 13.14. The install phase
156: 13.15. The package phase
157: 13.16. Cleaning up
158: 13.17. Other helpful targets
159: 14. Creating a new pkgsrc package from scratch
160: 14.1. Common types of packages
1.219 nia 161: 14.1.1. Python modules and programs
162: 14.1.2. R packages
163: 14.1.3. TeXlive packages
1.184 rillig 164: 14.2. Examples
165: 14.2.1. How the www/nvu package came into pkgsrc
166: 15. Programming in Makefiles
167: 15.1. Caveats
168: 15.2. Makefile variables
169: 15.2.1. Naming conventions
170: 15.3. Code snippets
171: 15.3.1. Adding things to a list
172: 15.3.2. Echoing a string exactly as-is
173: 15.3.3. Passing CFLAGS to GNU configure scripts
174: 15.3.4. Handling possibly empty variables
1.229 gutterid 175: 15.3.5. Testing yes/no variables in conditions
1.184 rillig 176: 16. Options handling
177: 16.1. Global default options
178: 16.2. Converting packages to use bsd.options.mk
179: 16.3. Option Names
180: 16.4. Determining the options of dependencies
181: 17. Tools needed for building or running
182: 17.1. Tools for pkgsrc builds
183: 17.2. Tools needed by packages
184: 17.3. Tools provided by platforms
185: 18. Buildlink methodology
186: 18.1. Converting packages to use buildlink3
187: 18.2. Writing buildlink3.mk files
188: 18.2.1. Anatomy of a buildlink3.mk file
189: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
1.271 wiz 190: BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.184 rillig 191: 18.3. Writing builtin.mk files
192: 18.3.1. Anatomy of a builtin.mk file
193: 19. PLIST issues
194: 19.1. RCS ID
195: 19.2. Semi-automatic PLIST generation
196: 19.3. Tweaking output of make print-PLIST
197: 19.4. Variable substitution in PLIST
198: 19.5. Man page compression
199: 19.6. Changing PLIST source with PLIST_SRC
200: 19.7. Platform-specific and differing PLISTs
201: 19.8. Build-specific PLISTs
202: 19.9. Sharing directories between packages
203: 20. The pkginstall framework
204: 20.1. Files and directories outside the installation prefix
205: 20.1.1. Directory manipulation
206: 20.1.2. File manipulation
207: 20.2. Configuration files
208: 20.2.1. How PKG_SYSCONFDIR is set
209: 20.2.2. Telling the software where configuration files are
1.239 dholland 210: 20.2.3. Patching installation
211: 20.2.4. Declaring configuration files
212: 20.2.5. Disabling handling of configuration files
1.184 rillig 213: 20.3. System startup scripts
214: 20.3.1. Disabling handling of system startup scripts
215: 20.4. System users and groups
216: 20.5. System shells
217: 20.5.1. Disabling shell registration
218: 20.6. Fonts
219: 20.6.1. Disabling automatic update of the fonts databases
1.154 rillig 220: 21. Making your package work
221: 21.1. General operation
222: 21.1.1. How to pull in user-settable variables from mk.conf
223: 21.1.2. User interaction
224: 21.1.3. Handling licenses
225: 21.1.4. Restricted packages
226: 21.1.5. Handling dependencies
227: 21.1.6. Handling conflicts with other packages
228: 21.1.7. Packages that cannot or should not be built
229: 21.1.8. Packages which should not be deleted, once installed
230: 21.1.9. Handling packages with security problems
231: 21.1.10. How to handle incrementing versions when fixing an
1.271 wiz 232: existing package
1.154 rillig 233: 21.1.11. Substituting variable text in the package files (the SUBST
1.271 wiz 234: framework)
1.154 rillig 235: 21.2. The fetch phase
236: 21.2.1. Packages whose distfiles aren't available for plain
1.271 wiz 237: downloading
1.154 rillig 238: 21.2.2. How to handle modified distfiles with the 'old' name
239: 21.2.3. Packages hosted on github.com
240: 21.3. The configure phase
241: 21.3.1. Shared libraries - libtool
242: 21.3.2. Using libtool on GNU packages that already support libtool
243: 21.3.3. GNU Autoconf/Automake
1.223 nia 244: 21.3.4. Meson / ninja
1.260 wiz 245: 21.3.5. Determining the endianness
1.154 rillig 246: 21.4. Programming languages
247: 21.4.1. C, C++, and Fortran
248: 21.4.2. Java
1.205 wiz 249: 21.4.3. Go
1.223 nia 250: 21.4.4. Rust
251: 21.4.5. Packages containing Perl scripts
252: 21.4.6. Packages containing shell scripts
253: 21.4.7. Other programming languages
1.154 rillig 254: 21.5. The build phase
255: 21.5.1. Compiling C and C++ code conditionally
256: 21.5.2. How to handle compiler bugs
1.172 rillig 257: 21.5.3. No such file or directory
1.266 martin 258: 21.5.4. Undefined reference to ...
1.172 rillig 259: 21.5.5. Running out of memory
1.154 rillig 260: 21.6. The install phase
261: 21.6.1. Creating needed directories
262: 21.6.2. Where to install documentation
263: 21.6.3. Installing highscore files
264: 21.6.4. Adding DESTDIR support to packages
265: 21.6.5. Packages with hardcoded paths to other interpreters
1.203 nia 266: 21.6.6. Packages installing Perl modules
1.254 wiz 267: 21.6.7. Packages installing pkg-config files
268: 21.6.8. Packages installing info files
269: 21.6.9. Packages installing man pages
270: 21.6.10. Packages installing X11 fonts
271: 21.6.11. Packages installing SGML or XML data
272: 21.6.12. Packages installing extensions to the MIME database
273: 21.6.13. Packages using intltool
274: 21.6.14. Packages installing startup scripts
275: 21.6.15. Packages installing TeX modules
276: 21.6.16. Packages supporting running binaries in emulation
277: 21.6.17. Packages installing hicolor icons
278: 21.6.18. Packages installing desktop files
1.154 rillig 279: 21.7. Marking packages as having problems
1.184 rillig 280: 22. GNOME packaging and porting
281: 22.1. Meta packages
282: 22.2. Packaging a GNOME application
283: 22.3. Updating GNOME to a newer version
284: 22.4. Patching guidelines
1.154 rillig 285: 23. Submitting and Committing
286: 23.1. Submitting binary packages
287: 23.2. Submitting source packages (for non-NetBSD-developers)
288: 23.3. General notes when adding, updating, or removing packages
289: 23.4. Commit Messages
290: 23.5. Committing: Adding a package to CVS
291: 23.6. Updating a package to a newer version
292: 23.7. Renaming a package in pkgsrc
293: 23.8. Moving a package in pkgsrc
1.263 wiz 294: 24. pkgsrc Policies
295: 24.1. Packages for which updating is restricted
296: 24.1.1. Limited Updates - ABI
297: 24.1.2. Limited Updates - Bootstrap
298: 25. Frequently Asked Questions
1.1 dsieger 299: III. The pkgsrc infrastructure internals
1.263 wiz 300: 26. Design of the pkgsrc infrastructure
301: 26.1. The meaning of variable definitions
302: 26.2. Avoiding problems before they arise
303: 26.3. Variable evaluation
304: 26.3.1. At load time
305: 26.3.2. At runtime
306: 26.4. How can variables be specified?
307: 26.5. Designing interfaces for Makefile fragments
308: 26.5.1. Procedures with parameters
309: 26.5.2. Actions taken on behalf of parameters
310: 26.6. The order in which files are loaded
311: 26.6.1. The order in bsd.prefs.mk
312: 26.6.2. The order in bsd.pkg.mk
313: 27. Regression tests
314: 27.1. Running the regression tests
315: 27.2. Adding a new regression test
316: 27.2.1. Overridable functions
317: 27.2.2. Helper functions
318: 28. Porting pkgsrc
319: 28.1. Porting pkgsrc to a new operating system
1.1 dsieger 320: A. A simple example package: bison
321: A.1. files
322: A.1.1. Makefile
323: A.1.2. DESCR
324: A.1.3. PLIST
325: A.1.4. Checking a package with pkglint
326: A.2. Steps for building, installing, packaging
1.207 leot 327: B. Security hardening
328: B.1. Mechanisms
329: B.1.1. Enabled by default
330: B.1.2. Not enabled by default
331: B.2. Caveats
332: B.2.1. Problems with PKGSRC_MKPIE
333: B.2.2. Problems with PKGSRC_USE_FORTIFY
334: B.2.3. Problems with PKGSRC_USE_RELRO
335: B.2.4. Problems with PKGSRC_USE_SSP
336: B.3. Auditing the system
337: B.3.1. Checking for PIE
338: B.3.2. Checking for partial RELRO
339: B.3.3. Checking for full RELRO
340: B.3.4. Checking for SSP
341: C. Build logs
342: C.1. Building figlet
343: C.2. Packaging figlet
344: D. Directory layout of the pkgsrc FTP server
345: D.1. distfiles: The distributed source files
346: D.2. misc: Miscellaneous things
347: D.3. packages: Binary packages
348: D.4. reports: Bulk build reports
349: D.5. current, stable, pkgsrc-20xxQy: source packages
350: E. Help topics
351: F. Editing guidelines for the pkgsrc guide
352: F.1. Make targets
353: F.2. Procedure
1.1 dsieger 354:
355: List of Tables
356:
357: 1.1. Platforms supported by pkgsrc
1.184 rillig 358: 12.1. Patching examples
359: 22.1. PLIST handling for GNOME packages
1.1 dsieger 360:
1.266 martin 361: Chapter 1. What is pkgsrc?
1.1 dsieger 362:
363: Table of Contents
364:
365: 1.1. Introduction
366: 1.1.1. Why pkgsrc?
367: 1.1.2. Supported platforms
368: 1.2. Overview
369: 1.3. Terminology
370: 1.3.1. Roles involved in pkgsrc
371: 1.4. Typography
372:
1.266 martin 373: 1.1. Introduction
1.1 dsieger 374:
375: There is a lot of software freely available for Unix-based systems, which is
376: usually available in form of the source code. Before such software can be used,
377: it needs to be configured to the local system, compiled and installed, and this
378: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
379: some basic commands to handle binary packages, so that not every user has to
380: build the packages for himself, which is a time-costly task.
381:
382: pkgsrc currently contains several thousand packages, including:
383:
1.104 sevan 384: * www/apache24 - The Apache web server
1.1 dsieger 385:
386: * www/firefox - The Firefox web browser
387:
388: * meta-pkgs/gnome - The GNOME Desktop Environment
389:
1.102 ryoon 390: * meta-pkgs/kde4 - The K Desktop Environment
1.1 dsieger 391:
1.266 martin 392: just to name a few.
1.1 dsieger 393:
394: pkgsrc has built-in support for handling varying dependencies, such as pthreads
395: and X11, and extended features such as IPv6 support on a range of platforms.
396:
1.266 martin 397: 1.1.1. Why pkgsrc?
1.1 dsieger 398:
399: pkgsrc provides the following key features:
400:
401: * Easy building of software from source as well as the creation and
402: installation of binary packages. The source and latest patches are
403: retrieved from a master or mirror download site, checksum verified, then
404: built on your system. Support for binary-only distributions is available
405: for both native platforms and NetBSD emulated platforms.
406:
407: * All packages are installed in a consistent directory tree, including
408: binaries, libraries, man pages and other documentation.
409:
1.104 sevan 410: * Tracking of package dependencies automatically, including when performing
411: updates, to ensure required packages are installed. The configuration files
412: of various packages are handled automatically during updates, so local
413: changes are preserved.
1.1 dsieger 414:
415: * Like NetBSD, pkgsrc is designed with portability in mind and consists of
416: highly portable code. This allows the greatest speed of development when
1.26 spz 417: porting to a new platform. This portability also ensures that pkgsrc is
1.1 dsieger 418: consistent across all platforms.
419:
420: * The installation prefix, acceptable software licenses, international
421: encryption requirements and build-time options for a large number of
422: packages are all set in a simple, central configuration file.
423:
424: * The entire source (not including the distribution files) is freely
425: available under a BSD license, so you may extend and adapt pkgsrc to your
426: needs. Support for local packages and patches is available right out of the
427: box, so you can configure it specifically for your environment.
428:
429: The following principles are basic to pkgsrc:
430:
1.266 martin 431: * It should only work if it's right. That means, if a package contains
1.1 dsieger 432: bugs, it's better to find them and to complain about them rather than to
433: just install the package and hope that it works. There are numerous checks
1.175 gutterid 434: in pkgsrc that try to find such bugs: static analysis tools (pkgtools/
1.1 dsieger 435: pkglint), build-time checks (portability of shell scripts), and
436: post-installation checks (installed files, references to shared libraries,
437: script interpreters).
438:
1.266 martin 439: * If it works, it should work everywhere Like NetBSD has been ported to
1.1 dsieger 440: many hardware architectures, pkgsrc has been ported to many operating
441: systems. Care is taken that packages behave the same on all platforms.
442:
1.266 martin 443: 1.1.2. Supported platforms
1.1 dsieger 444:
445: pkgsrc consists of both a source distribution and a binary distribution for
446: these operating systems. After retrieving the required source or binaries, you
447: can be up and running with pkgsrc in just minutes!
448:
449: pkgsrc was derived from FreeBSD's ports system, and initially developed for
450: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
451: platforms:
452:
1.266 martin 453: Table 1.1. Platforms supported by pkgsrc
1.1 dsieger 454:
1.92 sevan 455: +-----------------------------------------------------------------------------+
1.229 gutterid 456: | Platform | Date Support | Notes |
457: | | Added | |
458: |-------------------------------------+---------------+-----------------------|
1.266 martin 459: |NetBSD | Aug 1997 | |
1.229 gutterid 460: |-------------------------------------+---------------+-----------------------|
461: |Solaris | Mar 1999 |README.Solaris |
462: |-------------------------------------+---------------+-----------------------|
463: |Linux | Jun 1999 |README.Linux |
464: |-------------------------------------+---------------+-----------------------|
465: |Darwin / Mac OS X / OS X / macOS | Oct 2001 |README.macOS |
466: |-------------------------------------+---------------+-----------------------|
467: |FreeBSD | Nov 2002 |README.FreeBSD |
468: |-------------------------------------+---------------+-----------------------|
469: |OpenBSD | Nov 2002 |README.OpenBSD |
470: |-------------------------------------+---------------+-----------------------|
471: |IRIX | Dec 2002 |README.IRIX |
472: |-------------------------------------+---------------+-----------------------|
1.262 dholland 473: |BSD/OS | Dec 2003 |Removed from pkgsrc Mar|
474: | | | 2025 |
1.229 gutterid 475: |-------------------------------------+---------------+-----------------------|
476: |AIX | Dec 2003 |README.AIX |
477: |-------------------------------------+---------------+-----------------------|
1.264 wiz 478: |Interix (Microsoft Windows Services | Mar 2004 |Removed from pkgsrc Apr|
479: |for Unix) | | 2025 |
1.229 gutterid 480: |-------------------------------------+---------------+-----------------------|
1.266 martin 481: |DragonFlyBSD | Oct 2004 | |
1.229 gutterid 482: |-------------------------------------+---------------+-----------------------|
483: |OSF/1 | Nov 2004 |README.OSF1 |
484: |-------------------------------------+---------------+-----------------------|
485: |HP-UX | Apr 2007 |README.HPUX |
486: |-------------------------------------+---------------+-----------------------|
487: |Haiku | Sep 2010 |README.Haiku |
488: |-------------------------------------+---------------+-----------------------|
1.262 dholland 489: |MirBSD | Jan 2011 |Removed from pkgsrc Mar|
490: | | | 2025 |
1.229 gutterid 491: |-------------------------------------+---------------+-----------------------|
492: |Minix3 | Nov 2011 |README.Minix3 |
493: |-------------------------------------+---------------+-----------------------|
494: |Cygwin | Mar 2013 |README.Cygwin |
495: |-------------------------------------+---------------+-----------------------|
1.261 maya 496: |GNU/kFreeBSD | Jul 2013 |Removed from pkgsrc Mar|
497: | | |2025 |
1.229 gutterid 498: |-------------------------------------+---------------+-----------------------|
499: |Bitrig | Jun 2014 |Removed from pkgsrc Sep|
500: | | |2022 |
1.92 sevan 501: +-----------------------------------------------------------------------------+
1.1 dsieger 502:
503:
1.266 martin 504: 1.2. Overview
1.1 dsieger 505:
506: This document is divided into three parts. The first, The pkgsrc user's guide,
507: describes how one can use one of the packages in the Package Collection, either
508: by installing a precompiled binary package, or by building one's own copy using
509: the NetBSD package system. The second part, The pkgsrc developer's guide,
510: explains how to prepare a package so it can be easily built by other NetBSD
511: users without knowing about the package's building details. The third part, The
512: pkgsrc infrastructure internals is intended for those who want to understand
513: how pkgsrc is implemented.
514:
515: This document is available in various formats: HTML, PDF, PS, TXT.
516:
1.266 martin 517: 1.3. Terminology
1.1 dsieger 518:
1.266 martin 519: There has been a lot of talk about ports , packages , etc. so far. Here is a
1.1 dsieger 520: description of all the terminology used within this document.
521:
522: Package
523:
524: A set of files and building instructions that describe what's necessary to
525: build a certain piece of software using pkgsrc. Packages are traditionally
1.123 wiz 526: stored under /usr/pkgsrc, but may be stored in any location, referred to as
527: PKGSRCDIR.
1.1 dsieger 528:
529: The NetBSD package system
530:
1.266 martin 531: This is the former name of pkgsrc . It is part of the NetBSD operating
1.1 dsieger 532: system and can be bootstrapped to run on non-NetBSD operating systems as
533: well. It handles building (compiling), installing, and removing of
534: packages.
535:
536: Distfile
537:
538: This term describes the file or files that are provided by the author of
539: the piece of software to distribute his work. All the changes necessary to
540: build on NetBSD are reflected in the corresponding package. Usually the
541: distfile is in the form of a compressed tar-archive, but other types are
542: possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
543:
544: Port
545:
546: This is the term used by FreeBSD and OpenBSD people for what we call a
1.266 martin 547: package. In NetBSD terminology, port refers to a different architecture.
1.1 dsieger 548:
549: Precompiled/binary package
550:
551: A set of binaries built with pkgsrc from a distfile and stuffed together in
552: a single .tgz file so it can be installed on machines of the same machine
553: architecture without the need to recompile. Packages are usually generated
554: in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
555:
1.266 martin 556: Sometimes, this is referred to by the term package too, especially in the
1.1 dsieger 557: context of precompiled packages.
558:
559: Program
560:
561: The piece of software to be installed which will be constructed from all
562: the files in the distfile by the actions defined in the corresponding
563: package.
564:
1.266 martin 565: 1.3.1. Roles involved in pkgsrc
1.1 dsieger 566:
567: pkgsrc users
568:
569: The pkgsrc users are people who use the packages provided by pkgsrc.
570: Typically they are system administrators. The people using the software
1.266 martin 571: that is inside the packages (maybe called end users ) are not covered by
1.1 dsieger 572: the pkgsrc guide.
573:
574: There are two kinds of pkgsrc users: Some only want to install pre-built
575: binary packages. Others build the pkgsrc packages from source, either for
576: installing them directly or for building binary packages themselves. For
1.266 martin 577: pkgsrc users Part I, The pkgsrc user's guide should provide all necessary
1.1 dsieger 578: documentation.
579:
580: package maintainers
581:
1.266 martin 582: A package maintainer creates packages as described in Part II, The pkgsrc
583: developer's guide .
1.1 dsieger 584:
585: infrastructure developers
586:
587: These people are involved in all those files that live in the mk/ directory
1.266 martin 588: and below. Only these people should need to read through Part III, The
589: pkgsrc infrastructure internals , though others might be curious, too.
1.1 dsieger 590:
1.266 martin 591: 1.4. Typography
1.1 dsieger 592:
593: When giving examples for commands, shell prompts are used to show if the
1.266 martin 594: command should/can be issued as root, or if normal user privileges are
1.115 sevan 595: sufficient. We use a # for root's shell prompt, a % for users' shell prompt,
1.229 gutterid 596: assuming they use the C-shell or tcsh and a $ for Bourne shell and derivatives.
1.1 dsieger 597:
1.266 martin 598: Part I. The pkgsrc user's guide
1.1 dsieger 599:
600: Table of Contents
601:
1.154 rillig 602: 2. Getting help
603: 3. Where to get pkgsrc and how to keep it up-to-date
604: 3.1. Getting pkgsrc for the first time
605: 3.1.1. As tar archive
606: 3.1.2. Via anonymous CVS
607: 3.2. Keeping pkgsrc up-to-date
608: 3.2.1. Via tar files
609: 3.2.2. Via CVS
610: 4. Using pkgsrc on systems other than NetBSD
611: 4.1. Binary distribution
612: 4.2. Bootstrapping pkgsrc
613: 5. Using pkgsrc
614: 5.1. Using binary packages
615: 5.1.1. Finding binary packages
616: 5.1.2. Installing binary packages
1.202 nia 617: 5.1.3. Updating packages
618: 5.1.4. Deinstalling packages
619: 5.1.5. Getting information about installed packages
620: 5.1.6. Checking for security vulnerabilities in installed packages
621: 5.1.7. Finding if newer versions of your installed packages are in
1.271 wiz 622: pkgsrc
1.202 nia 623: 5.1.8. Other administrative functions
1.154 rillig 624: 5.2. Building packages from source
625: 5.2.1. Requirements
626: 5.2.2. Fetching distfiles
627: 5.2.3. How to build and install
628: 6. Configuring pkgsrc
629: 6.1. General configuration
630: 6.2. Variables affecting the build process
1.241 rillig 631: 6.3. Preferences for native or pkgsrc software
632: 6.4. Variables affecting the installation process
633: 6.5. Selecting and configuring the compiler
634: 6.5.1. Selecting the compiler
635: 6.5.2. Additional flags to the compiler (CFLAGS)
636: 6.5.3. Additional flags to the linker (LDFLAGS)
637: 6.6. Developer/advanced settings
638: 6.7. Selecting Build Options
1.154 rillig 639: 7. Creating binary packages
640: 7.1. Building a single binary package
641: 7.2. Settings for creation of binary packages
642: 8. Creating binary packages for everything in pkgsrc (bulk builds)
643: 8.1. Preparations
1.180 rillig 644: 8.2. Running a bulk build
1.154 rillig 645: 8.2.1. Configuration
1.272 wiz 646: 8.3. Speeding up bulk build scans
647: 8.4. Requirements of a full bulk build
648: 8.5. Bulk build variants
649: 8.5.1. Detect unknown configure options
650: 8.5.2. Detect classes of bugs by forcing compiler warnings
651: 8.5.3. Force compiler options only in the build phase
652: 8.5.4. Use custom directories
653: 8.5.5. Turn warnings into errors
654: 8.5.6. Reject packages for which pkglint reports errors
655: 8.5.7. Reject packages that contain forbidden strings
656: 8.5.8. Reject packages whose self-test fails
657: 8.5.9. Reject packages that use undefined shell variables
658: 8.5.10. Turn off verbose logging
659: 8.6. Creating a multiple CD-ROM packages collection
660: 8.6.1. Example of cdpack
1.154 rillig 661: 9. Directory layout of the installed files
662: 9.1. File system layout in ${LOCALBASE}
663: 9.2. File system layout in ${VARBASE}
664: 10. Frequently Asked Questions
665: 10.1. Are there any mailing lists for pkg-related discussion?
666: 10.2. Utilities for package management (pkgtools)
667: 10.3. How to use pkgsrc as non-root
668: 10.4. How to resume transfers when fetching distfiles?
669: 10.5. How can I install/use modular X.org from pkgsrc?
670: 10.6. How to fetch files from behind a firewall
671: 10.7. How to fetch files from HTTPS sites
672: 10.8. How do I tell make fetch to do passive FTP?
673: 10.9. How to fetch all distfiles at once
1.266 martin 674: 10.10. What does Don't know how to make /usr/share/tmac/tmac.andoc mean?
675: 10.11. What does Could not find bsd.own.mk mean?
1.221 nia 676: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154 rillig 677: 10.13. How do I change the location of configuration files?
678: 10.14. Automated security checks
679: 10.15. Why do some packages ignore my CFLAGS?
680: 10.16. A package does not build. What shall I do?
1.266 martin 681: 10.17. What does Makefile appears to contain unresolved cvs/rcs/??? merge
1.271 wiz 682: conflicts mean?
1.1 dsieger 683:
1.266 martin 684: Chapter 2. Getting help
1.154 rillig 685:
686: To get help when using pkgsrc, the definitive source is this document, the
687: pkgsrc guide. If you don't find anything here, there are alternatives:
688:
689: * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
1.266 martin 690: Run bmake help topic= to get help for any topic, such as a variable name
1.154 rillig 691: like BUILD_DEFS, a make target like do-build, a missing C or C++ function
692: like strcasecmp or any other topic.
693:
1.266 martin 694: The available help topics are listed in Appendix E, Help topics.
1.154 rillig 695:
1.163 rillig 696: * To see the value of a single variable, run bmake show-var VARNAME=X.
697:
698: * To see the values of the most common variables, run bmake show-all. These
699: variables are grouped by topic. To see the variables for a single topic,
700: run bmake show-all-topic, for example bmake show-all-fetch.
701:
1.154 rillig 702: * The pkgsrc-users mailing list, to which you can subscribe and then ask your
703: questions.
704:
705: * The #pkgsrc IRC channel, which is accessible via a web browser or by using
706: a specialized chat program such as XChat. Pick any user name and join the
707: channel #pkgsrc.
708:
1.266 martin 709: Chapter 3. Where to get pkgsrc and how to keep it up-to-date
1.1 dsieger 710:
711: Table of Contents
712:
1.154 rillig 713: 3.1. Getting pkgsrc for the first time
714: 3.1.1. As tar archive
715: 3.1.2. Via anonymous CVS
716: 3.2. Keeping pkgsrc up-to-date
717: 3.2.1. Via tar files
718: 3.2.2. Via CVS
1.1 dsieger 719:
720: Before you download and extract the files, you need to decide where you want to
721: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
722: usr/pkgsrc. You are though free to install the sources and binary packages
723: wherever you want in your filesystem, provided that the pathname does not
724: contain white-space or other characters that are interpreted specially by the
725: shell and some other programs. A safe bet is to use only letters, digits,
726: underscores and dashes.
727:
1.266 martin 728: 3.1. Getting pkgsrc for the first time
1.1 dsieger 729:
1.25 wiz 730: Before you download any pkgsrc files, you should decide whether you want the
1.1 dsieger 731: current branch or the stable branch. The latter is forked on a quarterly basis
732: from the current branch and only gets modified for security updates. The names
733: of the stable branches are built from the year and the quarter, for example
1.267 leot 734: 2025Q4.
1.1 dsieger 735:
736: The second step is to decide how you want to download pkgsrc. You can get it as
1.24 wiz 737: a tar file or via CVS. Both ways are described here.
1.1 dsieger 738:
1.52 asau 739: Note that tar archive contains CVS working copy. Thus you can switch to using
740: CVS at any later time.
1.1 dsieger 741:
1.266 martin 742: 3.1.1. As tar archive
1.52 asau 743:
1.151 sevan 744: The primary download location for all pkgsrc files is https://cdn.NetBSD.org/
745: pub/pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same
746: location). There are a number of subdirectories for different purposes, which
1.266 martin 747: are described in detail in Appendix D, Directory layout of the pkgsrc FTP
1.151 sevan 748: server.
1.1 dsieger 749:
1.52 asau 750: The tar archive for the current branch is in the directory current and is
1.118 sevan 751: called pkgsrc.tar.gz. It is autogenerated weekly.
1.52 asau 752:
753: To save download time we provide bzip2- and xz-compressed archives which are
754: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
755:
756: You can fetch the same files using FTP.
1.1 dsieger 757:
1.267 leot 758: The tar file for the stable branch 2025Q4 is in the directory pkgsrc-2025Q4 and
1.59 jnemeth 759: is also called pkgsrc.tar.gz.
1.1 dsieger 760:
1.136 leot 761: To download the latest pkgsrc stable tarball, run:
1.12 weinem 762:
1.267 leot 763: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2025Q4/pkgsrc.tar.gz
1.12 weinem 764:
1.78 snj 765: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52 asau 766:
1.12 weinem 767: Then, extract it with:
768:
1.78 snj 769: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12 weinem 770:
771: This will create the directory pkgsrc/ in /usr/ and all the package source will
772: be stored under /usr/pkgsrc/.
773:
774: To download pkgsrc-current, run:
775:
776: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1 dsieger 777:
1.266 martin 778: 3.1.2. Via anonymous CVS
1.1 dsieger 779:
1.24 wiz 780: To fetch a specific pkgsrc stable branch, run:
1.1 dsieger 781:
1.267 leot 782: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2025Q4 -P pkgsrc
1.13 weinem 783:
1.24 wiz 784: This will create the directory pkgsrc/ in your /usr/ directory and all the
785: package source will be stored under /usr/pkgsrc/.
786:
787: To fetch the pkgsrc current branch, run:
1.1 dsieger 788:
1.40 wiz 789: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 790:
1.30 dholland 791: Refer to the list of available mirrors to choose a faster CVS mirror, if
792: needed.
1.1 dsieger 793:
1.24 wiz 794: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1 dsieger 795:
1.40 wiz 796: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 797:
1.24 wiz 798: Refer to documentation on your command shell how to set CVS_RSH=ssh
799: permanently. For Bourne shells, you can set it in your .profile or better
800: globally in /etc/profile:
801:
802: # set CVS remote shell command
803: CVS_RSH=ssh
804: export CVS_RSH
1.12 weinem 805:
1.13 weinem 806: By default, CVS doesn't do things like most people would expect it to do. But
807: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12 weinem 808: directory and saving the following lines to it. This file will save you lots of
809: headache and some bug reports, so we strongly recommend it. You can find an
810: explanation of this file in the CVS documentation.
1.2 rillig 811:
812: # recommended CVS configuration file from the pkgsrc guide
1.155 sevan 813: cvs -q
1.2 rillig 814: checkout -P
1.4 rillig 815: update -dP
816: diff -upN
1.2 rillig 817: rdiff -u
1.24 wiz 818: release -d
1.1 dsieger 819:
1.266 martin 820: 3.2. Keeping pkgsrc up-to-date
1.1 dsieger 821:
822: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
823: have first installed it via a tar file). It saves bandwidth and hard disk
824: activity, compared to downloading the tar file again.
825:
1.266 martin 826: 3.2.1. Via tar files
1.1 dsieger 827:
828: Warning
829:
830: When updating from a tar file, you first need to completely remove the old
831: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
832: the mean time will not be removed on your local disk, resulting in
833: inconsistencies. When removing the old files, any changes that you have done to
834: the pkgsrc files will be lost after updating. Therefore updating via CVS is
835: strongly recommended.
836:
837: Note that by default the distfiles and the binary packages are saved in the
838: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78 snj 839: configure pkgsrc to store distfiles and packages in directories outside the
1.266 martin 840: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter 6,
1.78 snj 841: Configuring pkgsrc for the details.
1.1 dsieger 842:
843: To update pkgsrc from a tar file, download the tar file as explained above.
844: Then, make sure that you have not made any changes to the files in the pkgsrc
845: directory. Remove the pkgsrc directory and extract the new tar file. Done.
846:
1.266 martin 847: 3.2.2. Via CVS
1.1 dsieger 848:
1.26 spz 849: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12 weinem 850:
1.26 spz 851: $ cd /usr/pkgsrc && cvs update -dP
852:
853: If you get error messages from rsh, you need to set CVS_RSH variable as
854: described above. E.g.:
855:
856: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1 dsieger 857:
1.266 martin 858: 3.2.2.1. Switching between different pkgsrc branches
1.1 dsieger 859:
860: When updating pkgsrc, the CVS program keeps track of the branch you selected.
861: But if you, for whatever reason, want to switch from the stable branch to the
1.266 martin 862: current one, you can do it by adding the option -A after the update
863: keyword. To switch from the current branch back to the stable branch, add the
1.267 leot 864: -rpkgsrc-2025Q4 option.
1.1 dsieger 865:
1.266 martin 866: 3.2.2.2. What happens to my changes when updating?
1.1 dsieger 867:
868: When you update pkgsrc, the CVS program will only touch those files that are
869: registered in the CVS repository. That means that any packages that you created
870: on your own will stay unmodified. If you change files that are managed by CVS,
871: later updates will try to merge your changes with those that have been done by
1.266 martin 872: others. See the CVS manual, chapter update for details.
1.1 dsieger 873:
1.266 martin 874: Chapter 4. Using pkgsrc on systems other than NetBSD
1.1 dsieger 875:
876: Table of Contents
877:
1.154 rillig 878: 4.1. Binary distribution
879: 4.2. Bootstrapping pkgsrc
1.1 dsieger 880:
1.266 martin 881: 4.1. Binary distribution
1.1 dsieger 882:
1.266 martin 883: See Section 5.1, Using binary packages .
1.1 dsieger 884:
1.266 martin 885: 4.2. Bootstrapping pkgsrc
1.1 dsieger 886:
1.44 asau 887: pkgsrc can be bootstrapped for use in two different modes: privileged and
888: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45 asau 889: programs are installed under one particular user and cannot utilise privileged
1.44 asau 890: operations (packages don't create special users and all special file
891: permissions like setuid are ignored).
892:
1.1 dsieger 893: Installing the bootstrap kit from source should be as simple as:
894:
1.60 asau 895: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 896: # cd pkgsrc/bootstrap
897: # ./bootstrap
898:
899:
1.266 martin 900: To bootstrap in unprivileged mode pass --unprivileged flag to bootstrap
1.44 asau 901:
902: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1.118 sevan 903: will be installed in, and /usr/pkg/pkgdb for the package database directory
904: where pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1.44 asau 905: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1.118 sevan 906: for prefix, ~/pkg/pkgdb for the package database, and ~/pkg/var for varbase.
1.44 asau 907:
1.266 martin 908: You can change default layout using command-line arguments. Run ./bootstrap
909: --help to get details.
1.1 dsieger 910:
911: Note
912:
913: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
1.266 martin 914: For examples in this guide, use bmake instead of make .
1.1 dsieger 915:
1.44 asau 916: Note
917:
918: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
919: directories. Use bmake corresponding to the installation you're working with to
920: build and install packages.
921:
1.266 martin 922: Chapter 5. Using pkgsrc
1.1 dsieger 923:
924: Table of Contents
925:
1.154 rillig 926: 5.1. Using binary packages
927: 5.1.1. Finding binary packages
928: 5.1.2. Installing binary packages
1.202 nia 929: 5.1.3. Updating packages
930: 5.1.4. Deinstalling packages
931: 5.1.5. Getting information about installed packages
932: 5.1.6. Checking for security vulnerabilities in installed packages
933: 5.1.7. Finding if newer versions of your installed packages are in pkgsrc
934: 5.1.8. Other administrative functions
1.154 rillig 935: 5.2. Building packages from source
936: 5.2.1. Requirements
937: 5.2.2. Fetching distfiles
938: 5.2.3. How to build and install
1.1 dsieger 939:
940: Basically, there are two ways of using pkgsrc. The first is to only install the
941: package tools and to use binary packages that someone else has prepared. This
1.266 martin 942: is the pkg in pkgsrc. The second way is to install the src of pkgsrc, too.
1.1 dsieger 943: Then you are able to build your own packages, and you can still use binary
944: packages from someone else.
945:
1.266 martin 946: 5.1. Using binary packages
1.1 dsieger 947:
1.151 sevan 948: On the cdn.NetBSD.org site and mirrors, there are collections of binary
1.9 rillig 949: packages, ready to be installed. These binary packages have been built using
950: the default settings for the directories, that is:
951:
952: * /usr/pkg for LOCALBASE, where most of the files are installed,
953:
954: * /usr/pkg/etc for configuration files,
955:
956: * /var for VARBASE, where those files are installed that may change after
957: installation.
958:
959: If you cannot use these directories for whatever reasons (maybe because you're
960: not root), you cannot use these binary packages, but have to build the packages
1.266 martin 961: yourself, which is explained in Section 4.2, Bootstrapping pkgsrc .
1.1 dsieger 962:
1.266 martin 963: 5.1.1. Finding binary packages
1.1 dsieger 964:
1.5 weinem 965: To install binary packages, you first need to know from where to get them. The
1.202 nia 966: first place where you should look is on the main pkgsrc CDN in the directory /
967: pub/pkgsrc/packages.
1.5 weinem 968:
969: This directory contains binary packages for multiple platforms. First, select
1.226 gutterid 970: your operating system. Then, select your hardware architecture, and in the
1.266 martin 971: third step, the OS version and the version of pkgsrc.
1.9 rillig 972:
1.226 gutterid 973: In this directory, you may find a file called bootstrap.tar.gz which contains
1.9 rillig 974: the package management tools. If the file is missing, it is likely that your
975: operating system already provides those tools. Download the file and extract it
976: in the / directory. It will create the directories /usr/pkg (containing the
1.118 sevan 977: tools for managing binary packages and the database of installed packages).
1.1 dsieger 978:
1.266 martin 979: 5.1.2. Installing binary packages
1.1 dsieger 980:
1.85 wiz 981: In the directory from the last section, there is a subdirectory called All/,
1.9 rillig 982: which contains all the binary packages that are available for the platform,
1.202 nia 983: excluding those that may not be distributed via HTTP or FTP.
1.9 rillig 984:
985: To install packages directly from an FTP or HTTP server, run the following
986: commands in a Bourne-compatible shell (be sure to su to root first):
987:
1.202 nia 988: # PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
989: # PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages"
1.169 rillig 990: # PKG_PATH="$PKG_PATH/OPSYS/ARCH/VERSIONS/All/"
1.9 rillig 991: # export PATH PKG_PATH
1.202 nia 992: # pkg_add pkgin
1.9 rillig 993:
994: Instead of URLs, you can also use local paths, for example if you are
995: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
996: to install packages from multiple sources, you can separate them by a semicolon
997: in PKG_PATH.
998:
999: After these preparations, installing a package is very easy:
1000:
1.202 nia 1001: # pkgin search nginx
1002: nginx-1.19.6 Lightweight HTTP server and mail proxy server
1003: nginx-1.18.0nb8 Lightweight HTTP server and mail proxy server
1004: # pkgin install zsh nginx-1.19.6 vim
1.1 dsieger 1005:
1.202 nia 1006: Note that pkgin is a user-friendly frontend to the pkg_* tools.
1.1 dsieger 1007:
1.202 nia 1008: Any prerequisite packages needed to run the package in question will be
1009: installed, too, assuming they are present in the repository.
1.1 dsieger 1010:
1011: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
1012: in your PATH so you can actually start the just installed program.
1013:
1.266 martin 1014: 5.1.3. Updating packages
1.1 dsieger 1015:
1.202 nia 1016: To update binary packages, it is recommended that you use pkgin upgrade. This
1017: will compare the remote package repository to your locally installed packages
1018: and safely replace any older packages.
1.1 dsieger 1019:
1.202 nia 1020: Note that pkgsrc is released as quarterly branches. If you are updating to a
1021: newer quarterly branch of pkgsrc, you may need to adjust the repository in /usr
1022: /pkg/etc/pkgin/repositories.conf.
1.1 dsieger 1023:
1.266 martin 1024: 5.1.4. Deinstalling packages
1.1 dsieger 1025:
1.202 nia 1026: To deinstall a package, it does not matter whether it was installed from source
1027: code or from a binary package. Neither the pkgin or the pkg_delete command need
1028: to know.
1.1 dsieger 1029:
1.202 nia 1030: To delete a package, you can just run pkgin remove package-name. The package
1031: name can be given with or without version number.
1.1 dsieger 1032:
1.266 martin 1033: 5.1.5. Getting information about installed packages
1.1 dsieger 1034:
1035: The pkg_info shows information about installed packages or binary package
1.202 nia 1036: files. As with other management tools, it works with packages installed from
1037: source or binaries.
1.1 dsieger 1038:
1.266 martin 1039: 5.1.6. Checking for security vulnerabilities in installed packages
1.1 dsieger 1040:
1.202 nia 1041: The pkgsrc Security Team and Packages Groups maintain a list of known
1.164 leot 1042: vulnerabilities to packages which are (or have been) included in pkgsrc. The
1.202 nia 1043: list is available from the NetBSD CDN at https://cdn.NetBSD.org/pub/NetBSD/
1.179 rillig 1044: packages/vulns/pkg-vulnerabilities.
1.1 dsieger 1045:
1.202 nia 1046: Please note that not every "vulnerability" with a CVE assignment is exploitable
1047: in every configuration. Some bugs are marked as active simply because an fix
1048: was not marked as such. Operating system specific hardening and mitigation
1049: features may also reduce the impact of bugs.
1050:
1.23 jakllsch 1051: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
1052: automatically, and a security audit of all packages installed on a system can
1053: take place.
1054:
1055: There are two components to auditing. The first step, pkg_admin
1056: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
1057: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
1058: your installed packages are vulnerable. If a package is vulnerable, you will
1059: see output similar to the following:
1.1 dsieger 1060:
1061: Package samba-2.0.9 has a local-root-shell vulnerability, see
1.174 leot 1062: https://www.samba.org/samba/whatsnew/macroexploit.html
1.1 dsieger 1063:
1.23 jakllsch 1064: You may wish to have the vulnerabilities file downloaded daily so that it
1065: remains current. This may be done by adding an appropriate entry to the root
1066: users crontab(5) entry. For example the entry
1067:
1.121 sevan 1068: # Download vulnerabilities file
1.118 sevan 1069: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.121 sevan 1070: # Audit the installed packages and email results to root
1071: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
1072: root >/dev/null 2>&1
1.118 sevan 1073:
1074:
1075: will update the vulnerability list every day at 3AM, followed by an audit at
1076: 3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
1077: accomplished instead by adding the following line to /etc/daily.conf:
1078:
1079: fetch_pkg_vulnerabilities=YES
1080:
1.23 jakllsch 1081:
1.118 sevan 1082: to fetch the vulnerability list from the daily security script. The system is
1083: set to audit the packages by default but can be set explicitly, if desired (not
1.123 wiz 1084: required), by adding the following line to /etc/security.conf:
1.23 jakllsch 1085:
1.118 sevan 1086: check_pkg_vulnerabilities=YES
1.23 jakllsch 1087:
1088:
1.118 sevan 1089: see daily.conf(5) and security.conf(5) for more details.
1.1 dsieger 1090:
1.266 martin 1091: 5.1.7. Finding if newer versions of your installed packages are in pkgsrc
1.1 dsieger 1092:
1.266 martin 1093: Install pkgtools/lintpkgsrc and run lintpkgsrc with the -i argument to check
1.202 nia 1094: if any packages are stale, e.g.
1.1 dsieger 1095:
1096: % lintpkgsrc -i
1097: ...
1098: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
1099:
1100:
1.266 martin 1101: 5.1.8. Other administrative functions
1.1 dsieger 1102:
1103: The pkg_admin executes various administrative functions on the package system.
1104:
1.266 martin 1105: 5.2. Building packages from source
1.1 dsieger 1106:
1107: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25 wiz 1108: organized into categories. You can browse the online index of packages, or run
1.1 dsieger 1109: make readme from the pkgsrc directory to build local README.html files for all
1110: packages, viewable with any web browser such as www/lynx or www/firefox.
1111:
1112: The default prefix for installed packages is /usr/pkg. If you wish to change
1113: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
1114: use multiple different LOCALBASE definitions on the same system (inside a
1115: chroot is an exception).
1116:
1117: The rest of this chapter assumes that the package is already in pkgsrc. If it
1.266 martin 1118: is not, see Part II, The pkgsrc developer's guide for instructions how to
1.1 dsieger 1119: create your own packages.
1120:
1.266 martin 1121: 5.2.1. Requirements
1.1 dsieger 1122:
1123: To build packages from source, you need a working C compiler. On NetBSD, you
1.266 martin 1124: need to install the comp and the text distribution sets. If you want to
1125: build X11-related packages, the xbase and xcomp distribution sets are
1.1 dsieger 1126: required, too.
1127:
1.266 martin 1128: 5.2.2. Fetching distfiles
1.1 dsieger 1129:
1130: The first step for building a package is downloading the distfiles (i.e. the
1131: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
1132: them automatically.
1133:
1134: If you have all files that you need in the distfiles directory, you don't need
1135: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
1136: and add:
1137:
1138: DISTDIR=/cdrom/pkgsrc/distfiles
1139:
1140: to your mk.conf.
1141:
1142: By default a list of distribution sites will be randomly intermixed to prevent
1143: huge load on servers which holding popular packages (for example,
1144: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
1145: distfile all the mirrors will be tried in new (random) order. You can turn this
1146: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
1147: disabled).
1148:
1149: You can overwrite some of the major distribution sites to fit to sites that are
1150: close to your own. By setting one or two variables you can modify the order in
1151: which the master sites are accessed. MASTER_SORT contains a whitespace
1152: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
1153: contains a whitespace delimited list of regular expressions. It has higher
1154: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
1155: some examples. This may save some of your bandwidth and time.
1156:
1157: You can change these settings either in your shell's environment, or, if you
1.4 rillig 1158: want to keep the settings, by editing the mk.conf file, and adding the
1.1 dsieger 1159: definitions there.
1160:
1.132 wiz 1161: If a package depends on many other packages (such as meta-pkgs/kde4), the build
1.1 dsieger 1162: process may alternate between periods of downloading source, and compiling. To
1163: ensure you have all the source downloaded initially you can run the command:
1164:
1165: % make fetch-list | sh
1166:
1167: which will output and run a set of shell commands to fetch the necessary files
1168: into the distfiles directory. You can also choose to download the files
1169: manually.
1170:
1.266 martin 1171: 5.2.3. How to build and install
1.1 dsieger 1172:
1173: Once the software has downloaded, any patches will be applied, then it will be
1174: compiled for you. This may take some time depending on your computer, and how
1175: many other packages the software depends on and their compile time.
1176:
1177: Note
1178:
1179: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
1.266 martin 1180: command instead of make in the examples in this guide.
1.1 dsieger 1181:
1182: For example, type
1183:
1184: % cd misc/figlet
1185: % make
1186:
1187:
1188: at the shell prompt to build the various components of the package.
1189:
1190: The next stage is to actually install the newly compiled program onto your
1191: system. Do this by entering:
1192:
1193: % make install
1194:
1195:
1196: while you are still in the directory for whatever package you are installing.
1197:
1198: Installing the package on your system may require you to be root. However,
1199: pkgsrc has a just-in-time-su feature, which allows you to only become root for
1200: the actual installation step.
1201:
1202: That's it, the software should now be installed and setup for use. You can now
1203: enter:
1204:
1205: % make clean
1206:
1207:
1208: to remove the compiled files in the work directory, as you shouldn't need them
1209: any more. If other packages were also added to your system (dependencies) to
1210: allow your program to compile, you can tidy these up also with the command:
1211:
1212: % make clean-depends
1213:
1214:
1215: Taking the figlet utility as an example, we can install it on our system by
1.266 martin 1216: building as shown in Appendix C, Build logs.
1.1 dsieger 1217:
1218: The program is installed under the default root of the packages tree - /usr/
1219: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
1220: environment, and it will use that value as the root of your packages tree. So,
1221: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
1222: that you should use a directory which is dedicated to packages and not shared
1223: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
1224: not try to add any of your own files or directories (such as src/, obj/, or
1225: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
1226: between programs and other files installed by the package system and whatever
1227: else may have been installed there.
1228:
1.4 rillig 1229: Some packages look in mk.conf to alter some configuration options at build
1.1 dsieger 1230: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
1231: be set there by default. Environment variables such as LOCALBASE can be set in
1.4 rillig 1232: mk.conf to save having to remember to set them each time you want to use
1.1 dsieger 1233: pkgsrc.
1234:
1.266 martin 1235: Occasionally, people want to look under the covers to see what is going on
1.1 dsieger 1236: when a package is building or being installed. This may be for debugging
1237: purposes, or out of simple curiosity. A number of utility values have been
1238: added to help with this.
1239:
1240: 1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
1241: amount of information will be displayed. For example,
1242:
1243: make patch PKG_DEBUG_LEVEL=2
1244:
1.266 martin 1245: will show all the commands that are invoked, up to and including the patch
1246: stage.
1.1 dsieger 1247:
1248: 2. If you want to know the value of a certain make(1) definition, then the
1249: VARNAME definition should be used, in conjunction with the show-var target.
1250: e.g. to show the expansion of the make(1) variable LOCALBASE:
1251:
1252: % make show-var VARNAME=LOCALBASE
1253: /usr/pkg
1254: %
1255:
1256:
1257: If you want to install a binary package that you've either created yourself
1258: (see next section), that you put into pkgsrc/packages manually or that is
1259: located on a remote FTP server, you can use the "bin-install" target. This
1260: target will install a binary package - if available - via pkg_add(1), else do a
1261: make package. The list of remote FTP sites searched is kept in the variable
1262: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
1263: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
1264: for more details.
1265:
1266: A final word of warning: If you set up a system that has a non-standard setting
1267: for LOCALBASE, be sure to set that before any packages are installed, as you
1268: cannot use several directories for the same purpose. Doing so will result in
1269: pkgsrc not being able to properly detect your installed packages, and fail
1270: miserably. Note also that precompiled binary packages are usually built with
1271: the default LOCALBASE of /usr/pkg, and that you should not install any if you
1272: use a non-standard LOCALBASE.
1273:
1.266 martin 1274: Chapter 6. Configuring pkgsrc
1.1 dsieger 1275:
1276: Table of Contents
1277:
1.154 rillig 1278: 6.1. General configuration
1279: 6.2. Variables affecting the build process
1.241 rillig 1280: 6.3. Preferences for native or pkgsrc software
1281: 6.4. Variables affecting the installation process
1282: 6.5. Selecting and configuring the compiler
1283: 6.5.1. Selecting the compiler
1284: 6.5.2. Additional flags to the compiler (CFLAGS)
1285: 6.5.3. Additional flags to the linker (LDFLAGS)
1286: 6.6. Developer/advanced settings
1287: 6.7. Selecting Build Options
1.1 dsieger 1288:
1289: The whole pkgsrc system is configured in a single file, usually called mk.conf.
1290: In which directory pkgsrc looks for that file depends on the installation. On
1291: NetBSD, when you use make(1) from the base system, it is in the directory /etc
1292: /. In all other cases the default location is ${PREFIX}/etc/, depending on
1293: where you told the bootstrap program to install the binary packages.
1294:
1295: The format of the configuration file is that of the usual BSD-style Makefiles.
1296: The whole pkgsrc configuration is done by setting variables in this file. Note
1297: that you can define all kinds of variables, and no special error checking (for
1.112 rillig 1298: example for spelling mistakes) takes place.
1.1 dsieger 1299:
1.266 martin 1300: 6.1. General configuration
1.1 dsieger 1301:
1.112 rillig 1302: The following variables apply to all pkgsrc packages. A complete list of the
1303: variables that can be configured by the user is available in mk/defaults/
1304: mk.conf, together with some comments that describe each variable's intent.
1.1 dsieger 1305:
1306: * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
1307: not mix binary packages with different LOCALBASEs!
1308:
1.266 martin 1309: * CROSSBASE: Where cross category packages will be installed. The default
1.1 dsieger 1310: is ${LOCALBASE}/cross.
1311:
1.84 wiz 1312: * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1 dsieger 1313:
1314: * DISTDIR: Where to store the downloaded copies of the original source
1315: distributions used for building pkgsrc packages. The default is $
1316: {PKGSRCDIR}/distfiles.
1317:
1318: * PKG_DBDIR: Where the database about installed packages is stored. The
1.118 sevan 1319: default is /usr/pkg/pkgdb.
1.1 dsieger 1320:
1321: * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
1322: value.
1323:
1324: * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
1325: files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.118 sevan 1326: respectively. The defaults is ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1.1 dsieger 1327: {DIST_SUBDIR}/.
1328:
1329: * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
1.266 martin 1330: with OS release ( 2.0 , etc.) and architecture ( mipsel , etc.).
1.1 dsieger 1331:
1.23 jakllsch 1332: * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
1333: case-sensitive. Whenever you try to build a package whose license is not in
1334: this list, you will get an error message. If the license condition is
1335: simple enough, the error message will include specific instructions on how
1336: to change this variable.
1.1 dsieger 1337:
1.266 martin 1338: 6.2. Variables affecting the build process
1.1 dsieger 1339:
1340: * PACKAGES: The top level directory for the binary packages. The default is $
1341: {PKGSRCDIR}/packages.
1342:
1343: * WRKOBJDIR: The top level directory where, if defined, the separate working
1344: directories will get created, and symbolically linked to from ${WRKDIR}
1345: (see below). This is useful for building packages on several architectures,
1346: then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
1347: architecture. (It should be noted that PKGSRCDIR should not be set by the
1.266 martin 1348: user it is an internal definition which refers to the root of the pkgsrc
1.1 dsieger 1349: tree. It is possible to have many pkgsrc tree instances.)
1350:
1351: * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.266 martin 1352: Section 12.3, patches/* for more information.
1.1 dsieger 1353:
1354: * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
1355: Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
1356: up settings used by builds in /usr/src.
1357:
1.266 martin 1358: 6.3. Preferences for native or pkgsrc software
1.241 rillig 1359:
1360: Whenever a package depends on a package that has a builtin.mk file, the
1361: dependent package can either use the built-in (native) version from the base
1362: system or the pkgsrc-provided version. This only affects dependencies, so it is
1363: still possible to build the pkgsrc package devel/pcre++ even when other
1364: packages depend on the native pcre++ version instead.
1365:
1.266 martin 1366: To force using the pkgsrc-provided version for a particular package, define
1367: PREFER_PKGSRC = package-ID in mk.conf. To force using the native package,
1368: define PREFER_NATIVE = package-ID . In both cases, the package-ID is the one
1.241 rillig 1369: from the buildlink3.mk of the package. In most cases, this ID is the same as
1370: the directory name of the package, but for example, devel/pcre++ has the
1.266 martin 1371: package ID pcrexx .
1.241 rillig 1372:
1373: For the packages that are not listed by their package ID, pkgsrc uses the
1.266 martin 1374: pkgsrc-provided version if PREFER_PKGSRC contains the word yes . Otherwise, if
1375: PREFER_NATIVE contains the word yes , pkgsrc uses the native version. For
1.241 rillig 1376: example, to require using the pkgsrc-provided versions for all but the most
1377: basic bits on a NetBSD system, you can set:
1378:
1379: PREFER_PKGSRC= yes
1380: PREFER_NATIVE= getopt skey tcp_wrappers
1381:
1382: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
1383: it is simply ignored in that list.
1384:
1385: PREFER_PKGSRC and PREFER_NATIVE should be set during bootstrap to ensure that
1386: the bootstrap process does not use inapropriate native tools as dependencies
1387: for core packages.
1388:
1389: # ./bootstrap --prefer-pkgsrc yes --prefer-native openssl
1390:
1391: Switching between settings globally at a later date can introduce complications
1392: with dependency resolution. This is caused by packages built with the opposite
1393: preference being installed alongside each other. Hence, when changing any of
1394: these variables after bootstrap, you need to rebuild all packages depending on
1395: those whose preference has been changed. This is not trivial and should be
1396: avoided.
1397:
1.266 martin 1398: When using pkgsrc on Linux systems, there is high risk of leakage , where
1.241 rillig 1399: programs installed by pkgsrc may inadvertently use a command or library not
1400: installed by pkgsrc, e.g. those installed by yum or apt. Such foreign
1401: dependencies may be installed, removed, or upgraded to a version incompatible
1402: with the pkgsrc package at any time, causing pkgsrc packages to subsequently
1403: malfunction. Pkgsrc cannot prevent this, as it has no control over other
1404: package managers. Another potential problem is that under Redhat Enterprise and
1405: related Linux systems, yum packages are only patched and never upgraded, so
1406: eventually they may become too outdated for use by pkgsrc. Even intentionally
1407: using foreign dependencies, not considered leakage, can lead to these problems,
1408: so it is generally discouraged. In order to minimize such problems,
1.266 martin 1409: PREFER_PKGSRC defaults to yes on Linux systems. This ensures that pkgsrc is
1.241 rillig 1410: aware of any changes to dependency packages and can rebuild or upgrade the
1411: entire dependency tree as needed. This default can be overridden by setting
1.266 martin 1412: --prefer-pkgsrc to a list of packages and --prefer-native to yes .
1.241 rillig 1413:
1.266 martin 1414: 6.4. Variables affecting the installation process
1.1 dsieger 1415:
1.198 leot 1416: * PKGSRC_KEEP_BIN_PKGS: By default, binary packages of built packages are
1.150 leot 1417: preserved in ${PACKAGES}/All. Setting this variable to "no" prevents this.
1.1 dsieger 1418:
1.107 jnemeth 1419: Packages have to support installation into a subdirectory of WRKDIR. This
1420: allows a package to be built, before the actual filesystem is touched. DESTDIR
1421: support exists in two variations:
1.4 rillig 1422:
1423: * Basic DESTDIR support means that the package installation and packaging is
1424: still run as root.
1425:
1426: * Full DESTDIR support can run the complete build, installation and packaging
1427: as normal user. Root privileges are only needed to add packages.
1428:
1429: With basic DESTDIR support, make clean needs to be run as root.
1430:
1.17 imil 1431: Considering the foo/bar package, DESTDIR full support can be tested using the
1432: following commands
1433:
1434: $ id
1435: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
1436: $ mkdir $HOME/packages
1437: $ cd $PKGSRCDIR/foo/bar
1438:
1439: Verify DESTDIR full support, no root privileges should be needed
1440:
1.66 asau 1441: $ make stage-install
1.17 imil 1442:
1443: Create a package without root privileges
1444:
1.66 asau 1445: $ make PACKAGES=$HOME/packages package
1.17 imil 1446:
1447: For the following command, you must be able to gain root privileges using su(1)
1448:
1.66 asau 1449: $ make PACKAGES=$HOME/packages install
1.17 imil 1450:
1451: Then, as a simple user
1452:
1453: $ make clean
1454:
1.266 martin 1455: 6.5. Selecting and configuring the compiler
1.4 rillig 1456:
1.266 martin 1457: 6.5.1. Selecting the compiler
1.1 dsieger 1458:
1459: By default, pkgsrc will use GCC to build packages. This may be overridden by
1460: setting the following variables in /etc/mk.conf:
1461:
1462: PKGSRC_COMPILER:
1463:
1464: This is a list of values specifying the chain of compilers to invoke when
1465: building packages. Valid values are:
1466:
1.271 wiz 1467: o ccc: Compaq C Compilers (Tru64)
1.66 asau 1468:
1.271 wiz 1469: o ccache: compiler cache (chainable)
1.66 asau 1470:
1.271 wiz 1471: o clang: Clang C and Objective-C compiler
1.66 asau 1472:
1.271 wiz 1473: o distcc: distributed C/C++ (chainable)
1.1 dsieger 1474:
1.271 wiz 1475: o f2c: Fortran 77 to C compiler (chainable)
1.66 asau 1476:
1.271 wiz 1477: o icc: Intel C++ Compiler (Linux)
1.66 asau 1478:
1.271 wiz 1479: o ido: SGI IRIS Development Option cc (IRIX 5)
1.1 dsieger 1480:
1.271 wiz 1481: o gcc: GNU C/C++ Compiler
1.1 dsieger 1482:
1.271 wiz 1483: o hp: HP-UX C/aC++ compilers
1.66 asau 1484:
1.271 wiz 1485: o mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1 dsieger 1486:
1.271 wiz 1487: o mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1 dsieger 1488:
1.271 wiz 1489: o sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1 dsieger 1490:
1.271 wiz 1491: o xlc: IBM's XL C/C++ compiler suite
1.66 asau 1492:
1.266 martin 1493: The default is gcc . You can use ccache and/or distcc with an appropriate
1494: PKGSRC_COMPILER setting, e.g. ccache gcc . This variable should always be
1.1 dsieger 1495: terminated with a value for a real compiler. Note that only one real
1.266 martin 1496: compiler should be listed (e.g. sunpro gcc is not allowed).
1.1 dsieger 1497:
1498: GCC_REQD:
1499:
1500: This specifies the minimum version of GCC to use when building packages. If
1501: the system GCC doesn't satisfy this requirement, then pkgsrc will build and
1502: install one of the GCC packages to use instead.
1503:
1.153 leot 1504: PYTHON_VERSION_DEFAULT:
1.114 maya 1505:
1506: Specifies which version of python to use when several options are
1507: available.
1508:
1509: PKGSRC_FORTRAN:
1510:
1.176 gutterid 1511: Specifies the Fortran compiler to use. The default is gfortran.
1.114 maya 1512:
1513: GFORTRAN_VERSION:
1514:
1515: If PKGSRC_FORTRAN= gfortran is used, this option specifies which version to
1516: use.
1517:
1.266 martin 1518: 6.5.2. Additional flags to the compiler (CFLAGS)
1.1 dsieger 1519:
1520: If you wish to set the CFLAGS variable, please make sure to use the += operator
1521: instead of the = operator:
1522:
1523: CFLAGS+= -your -flags
1524:
1.266 martin 1525: Using CFLAGS= (i.e. without the + ) may lead to problems with packages that
1.16 jnemeth 1526: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24 wiz 1527: package if you're interested in optimization specifically for the current CPU.
1.1 dsieger 1528:
1.266 martin 1529: 6.5.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 1530:
1531: If you want to pass flags to the linker, both in the configure step and the
1532: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
1533: difference between the two is that LIBS will be appended to the command line,
1534: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
1535: machines depending on the setting of USE_IMAKE or the inclusion of mk/
1536: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
1537: settings, use the += operator:
1538:
1539: LDFLAGS+= -your -linkerflags
1540:
1.266 martin 1541: 6.6. Developer/advanced settings
1.1 dsieger 1542:
1543: * PKG_DEVELOPER: Run some sanity checks that package developers want:
1544:
1.42 asau 1545: + make sure patches apply with zero fuzz
1.1 dsieger 1546:
1.42 asau 1547: + run check-shlibs to see that all binaries will find their shared libs.
1.1 dsieger 1548:
1.232 gutterid 1549: * CHECK_FILES_STRICT: Also check VARBASE and PKG_SYSCONFDIR values in PLIST
1550: entries.
1551:
1.1 dsieger 1552: * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
1553: making and installing the package. The default value for this is 0, which
1554: will not display the commands as they are executed (normal, default, quiet
1555: operation); the value 1 will display all shell commands before their
1556: invocation, and the value 2 will display both the shell commands before
1.112 rillig 1557: their invocation, as well as their actual execution progress with set -x.
1.1 dsieger 1558:
1.266 martin 1559: 6.7. Selecting Build Options
1.1 dsieger 1560:
1561: Some packages have build time options, usually to select between different
1562: dependencies, enable optional support for big dependencies or enable
1563: experimental features.
1564:
1565: To see which options, if any, a package supports, and which options are
1566: mutually exclusive, run make show-options, for example:
1567:
1568: The following options are supported by this package:
1569: ssl Enable SSL support.
1570: Exactly one of the following gecko options is required:
1571: firefox Use firefox as gecko rendering engine.
1572: mozilla Use mozilla as gecko rendering engine.
1573: At most one of the following database options may be selected:
1574: mysql Enable support for MySQL database.
1575: pgsql Enable support for PostgreSQL database.
1576:
1577: These options are enabled by default: firefox
1578: These options are currently enabled: mozilla ssl
1579:
1.4 rillig 1580: The following variables can be defined in mk.conf to select which options to
1581: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1 dsieger 1582: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
1583: which can be used to select or disable options specifically for package pkgbase
1.266 martin 1584: . Options listed in these variables are selected, options preceded by - are
1.1 dsieger 1585: disabled. A few examples:
1586:
1.4 rillig 1587: $ grep "PKG.*OPTION" mk.conf
1.1 dsieger 1588: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
1589: PKG_OPTIONS.kdebase= debug -sasl
1590: PKG_OPTIONS.apache= suexec
1591:
1.11 rillig 1592: It is important to note that options that were specifically suggested by the
1.19 snj 1593: package maintainer must be explicitly removed if you do not wish to include the
1594: option. If you are unsure you can view the current state with make show-options
1595: .
1.11 rillig 1596:
1.1 dsieger 1597: The following settings are consulted in the order given, and the last setting
1598: that selects or disables an option is used:
1599:
1600: 1. the default options as suggested by the package maintainer
1601:
1602: 2. the options implied by the settings of legacy variables (see below)
1603:
1604: 3. PKG_DEFAULT_OPTIONS
1605:
1606: 4. PKG_OPTIONS.pkgbase
1607:
1608: For groups of mutually exclusive options, the last option selected is used, all
1609: others are automatically disabled. If an option of the group is explicitly
1610: disabled, the previously selected option, if any, is used. It is an error if no
1611: option from a required group of options is selected, and building the package
1612: will fail.
1613:
1614: Before the options framework was introduced, build options were selected by
1.4 rillig 1615: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
1616: transition to the options framework for the user, these legacy variables are
1617: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
1618: automatically. A warning is issued to prompt the user to update mk.conf to use
1619: the options framework directly. Support for the legacy variables will be
1.1 dsieger 1620: removed eventually.
1621:
1.266 martin 1622: Chapter 7. Creating binary packages
1.1 dsieger 1623:
1624: Table of Contents
1625:
1.154 rillig 1626: 7.1. Building a single binary package
1627: 7.2. Settings for creation of binary packages
1.1 dsieger 1628:
1.266 martin 1629: 7.1. Building a single binary package
1.1 dsieger 1630:
1631: Once you have built and installed a package, you can create a binary package
1632: which can be installed on another system with pkg_add(1). This saves having to
1633: build the same package on a group of hosts and wasting CPU time. It also
1634: provides a simple means for others to install your package, should you
1635: distribute it.
1636:
1637: To create a binary package, change into the appropriate directory in pkgsrc,
1638: and run make package:
1639:
1.112 rillig 1640: $ cd misc/figlet
1641: $ make package
1.1 dsieger 1642:
1.242 gutterid 1643: This will build your package (if not already done) and package it into a binary
1644: package. You can then use the pkg_* tools to manipulate it. Binary packages are
1645: created in PACKAGES, which defaults to /usr/pkgsrc/packages, in the form of a
1.266 martin 1646: compressed tar file. See Section C.2, Packaging figlet for a continuation of
1.242 gutterid 1647: the above misc/figlet example.
1.1 dsieger 1648:
1.266 martin 1649: See Chapter 23, Submitting and Committing for information on how to submit such
1.1 dsieger 1650: a binary package.
1651:
1.266 martin 1652: 7.2. Settings for creation of binary packages
1.1 dsieger 1653:
1.266 martin 1654: See Section 13.17, Other helpful targets .
1.6 rillig 1655:
1.266 martin 1656: Chapter 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6 rillig 1657:
1658: Table of Contents
1659:
1.154 rillig 1660: 8.1. Preparations
1.180 rillig 1661: 8.2. Running a bulk build
1.154 rillig 1662: 8.2.1. Configuration
1.272 wiz 1663: 8.3. Speeding up bulk build scans
1664: 8.4. Requirements of a full bulk build
1665: 8.5. Bulk build variants
1666: 8.5.1. Detect unknown configure options
1667: 8.5.2. Detect classes of bugs by forcing compiler warnings
1668: 8.5.3. Force compiler options only in the build phase
1669: 8.5.4. Use custom directories
1670: 8.5.5. Turn warnings into errors
1671: 8.5.6. Reject packages for which pkglint reports errors
1672: 8.5.7. Reject packages that contain forbidden strings
1673: 8.5.8. Reject packages whose self-test fails
1674: 8.5.9. Reject packages that use undefined shell variables
1675: 8.5.10. Turn off verbose logging
1676: 8.6. Creating a multiple CD-ROM packages collection
1677: 8.6.1. Example of cdpack
1.6 rillig 1678:
1.175 gutterid 1679: For a number of reasons, you may want to build binary packages for a large
1680: selected set of packages in pkgsrc, or even for all pkgsrc packages. For
1.71 wiz 1681: instance, when you have multiple machines that should run the same software, it
1682: is wasted time if they all build their packages themselves from source. Or you
1683: may want to build a list of packages you want and check them before deploying
1.175 gutterid 1684: onto production systems. There is a way of getting a set of binary packages:
1685: the bulk build system, or pbulk ("p" stands for "parallel"). This chapter
1686: describes how to set it up.
1.71 wiz 1687:
1.266 martin 1688: 8.1. Preparations
1.71 wiz 1689:
1690: First of all, you have to decide whether you build all packages or a limited
1691: set of them. Full bulk builds usually consume a lot more resources, both space
1.175 gutterid 1692: and time, than builds for some practical sets of packages. A number of
1693: particularly heavy packages exist that are not actually interesting to a wide
1694: audience. (The approximate resource consumption for a full bulk build is given
1.272 wiz 1695: in section Section 8.4, Requirements of a full bulk build .) For limited bulk
1.175 gutterid 1696: builds you need to make a list of packages you want to build. Note that all
1697: their dependencies will be built, so you don't need to track them manually.
1.71 wiz 1698:
1699: During bulk builds various packages are installed and deinstalled in /usr/pkg
1700: (or whatever LOCALBASE is), so make sure that you don't need any package during
1.112 rillig 1701: the builds. Essentially, you should provide a fresh system, either a chroot
1.71 wiz 1702: environment or something even more restrictive, depending on what the operating
1703: system provides, or dedicate the whole physical machine. As a useful side
1704: effect this makes sure that bulk builds cannot break anything in your system.
1705: There have been numerous cases where certain packages tried to install files
1706: outside the LOCALBASE or wanted to edit some files in /etc.
1.6 rillig 1707:
1.266 martin 1708: 8.2. Running a bulk build
1.6 rillig 1709:
1.180 rillig 1710: Running a bulk build works roughly as follows:
1.15 rillig 1711:
1712: * First, build the pbulk infrastructure in a fresh pkgsrc location.
1713:
1714: * Then, build each of the packages from a clean installation directory using
1715: the infrastructure.
1716:
1.266 martin 1717: 8.2.1. Configuration
1.6 rillig 1718:
1.112 rillig 1719: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6 rillig 1720:
1.68 asau 1721: In order to use it, prepare a clear system (real one, chroot environment, jail,
1722: zone, virtual machine). Configure network access to fetch distribution files.
1.112 rillig 1723: Create a user with name "pbulk".
1.68 asau 1724:
1725: Fetch and extract pkgsrc. Use a command like one of these:
1726:
1.151 sevan 1727: # (cd /usr && ftp -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1728: # (cd /usr && fetch -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1.72 wiz 1729: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68 asau 1730:
1731: Or any other way that fits (e.g., curl, wget).
1732:
1733: Deploy and configure pbulk tools, e.g.:
1734:
1.118 sevan 1735: # sh pbulk.sh -n # use native make, no bootstrap kit needed (for use on NetBSD)
1.68 asau 1736: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
1737: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
1738:
1739: Note
1740:
1741: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
1742: to packages you build. For instance,
1743:
1.112 rillig 1744: PKG_DEVELOPER= yes # perform more checks
1745: X11_TYPE= modular # use pkgsrc X11
1746: SKIP_LICENSE_CHECK= yes # accept all licences (useful
1747: # when building all packages)
1.68 asau 1748:
1749: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112 rillig 1750: with your list of packages, one per line without empty lines or comments. E.g.:
1.68 asau 1751:
1752: www/firefox
1753: mail/thunderbird
1754: misc/libreoffice4
1755:
1.69 asau 1756: At this point you can also review configuration in /usr/pbulk/etc and make
1757: final amendments, if wanted.
1758:
1.68 asau 1759: Start it:
1760:
1761: # /usr/pbulk/bin/bulkbuild
1762:
1763: After it finishes, you'll have /mnt filled with distribution files, binary
1764: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
1765:
1766: Note
1767:
1768: The pbulk.sh script does not cover all possible use cases. While being ready to
1769: run, it serves as a good starting point to understand and build more complex
1770: setups. The script is kept small enough for better understanding.
1771:
1772: Note
1773:
1774: The pbulk.sh script supports running unprivileged bulk build and helps
1.205 wiz 1775: configuring distributed bulk builds. Distributed bulk builds support either
1776: building in worker chroots (each node is a path to a different chroot) that
1777: replicate the target system, including the pbulk prefix, or remote machines
1778: (each node is an IP address that must be accessible over SSH without a
1779: password).
1.15 rillig 1780:
1.272 wiz 1781: 8.3. Speeding up bulk build scans
1782:
1783: At the start of a bulk build. pkgsrc is scanned for details about the packages
1784: to build. This is needed e.g. to build a dependency graph for building the
1785: packages in the correct order.
1786:
1787: Basically, this calls make(1) once for each package. To speed this up, some
1788: variables can be pre-computed and others can be cached. This will greatly
1789: reduce the time needed for the scan part of a bulk build.
1790:
1791: The fake pkgtools/varcache package provides a Makefile target to precompute
1792: some often-used variables for the build system that shouldn't change during one
1793: build. Redirect its output to a file and include it from mk.conf; for example:
1794:
1795: $ cd pkgtools/varcache
1796: $ make show-varcache > /etc/varcache.mk
1797: $ echo .include "varcache.mk" >> /etc/mk.conf
1798:
1799:
1800: Some system information is needed quite early in the build and can not be
1801: cached this way. It must be set in the environment for the next speed-up:
1802:
1803: $ export HOST_MACHINE_ARCH=`uname -m`
1804: $ export NATIVE_OPSYS=`uname -s`
1805: $ export NATIVE_OPSYS_VERSION=`uname -r | awk -F. '{major=int($1); minor=int($2); if (minor>=100) minor=99; patch=int($3); if (patch>=100) patch=99; printf "%02d%02d%02d", major, minor, patch}'`
1806: $ export NATIVE_OS_VERSION=`uname -r`
1807:
1808:
1809: Some settings that also affect the scan time strongly can be set in mk.conf:
1810:
1811: NATIVE_PKG_TOOLS_BIN=/usr/sbin # location on NetBSD
1812: NO_PKGTOOLS_REQD_CHECK=yes # assume pkg tools are up-to-date
1813: SKIP_LICENSE_CHECK=yes # do not check license validity
1814: _SRC_TOP_= # bulk build is not running from inside /usr/src
1815: UNPRIVILEGED_USER=pbulk # use the appropriate user for your system
1816: UNPRIVILEGED_GROUP=builder # use the appropriate group for your system
1817: UNPRIVILEGED_GROUPS=builder # use the appropriate groups for your system
1818:
1819: Finally, some packages require information about build options of other
1820: packages. This information can be cached by setting PBULK_CACHE_DIRECTORY.
1821:
1822: PBULK_CACHE_DIRECTORY=/tmp/pbulk_cache
1823:
1824: For all of these: please make sure they are kept up-to-date for changes in your
1825: environment. The safest method is to re-create the varcache before each build,
1826: make sure the environment variables are still up-to-date, and to delete the
1827: PBULK_CACHE_DIRECTORY before builds.
1828:
1829: 8.4. Requirements of a full bulk build
1.71 wiz 1830:
1831: A complete bulk build requires lots of disk space. Some of the disk space can
1832: be read-only, some other must be writable. Some can be on remote filesystems
1833: (such as NFS) and some should be local. Some can be temporary filesystems,
1834: others must survive a sudden reboot.
1835:
1.205 wiz 1836: * 70 GB for the distfiles (read-write, remote, temporary)
1.71 wiz 1837:
1.205 wiz 1838: * 60 GB for the binary packages (read-write, remote, permanent)
1.71 wiz 1839:
1840: * 1 GB for the pkgsrc tree (read-only, remote, permanent)
1841:
1842: * 5 GB for LOCALBASE (read-write, local, temporary)
1843:
1844: * 10 GB for the log files (read-write, remote, permanent)
1845:
1846: * 5 GB for temporary files (read-write, local, temporary)
1847:
1.272 wiz 1848: 8.5. Bulk build variants
1.178 rillig 1849:
1850: To ensure that pkgsrc packages work in different configurations, it makes sense
1851: to run non-default bulk builds from time to time. This section lists some ideas
1852: for bulk builds that intentionally let packages fail if they don't follow the
1853: pkgsrc style.
1854:
1.272 wiz 1855: 8.5.1. Detect unknown configure options
1.178 rillig 1856:
1857: Add the following line to mk.conf.
1858:
1859: GNU_CONFIGURE_STRICT= yes
1860:
1861: When a package fails this additional check, the most common cause is that the
1862: configure option was valid for an older version of the package but does not
1863: apply anymore. In that case, just remove it.
1864:
1.272 wiz 1865: 8.5.2. Detect classes of bugs by forcing compiler warnings
1.178 rillig 1866:
1867: The job of a compiler is not restricted to producing executable code, most
1.179 rillig 1868: compilers also detect typical programming mistakes. The pkgsrc compiler
1869: wrappers make it easy to force compiler options when the package is built. This
1870: can be used to find typical bugs across all packages that are in pkgsrc. By
1871: reporting these bugs upstream, the packages will be more reliable with the next
1872: updates.
1.178 rillig 1873:
1.179 rillig 1874: Add some of the following lines to mk.conf:
1.178 rillig 1875:
1876: CFLAGS+= -Werror=char-subscripts
1.179 rillig 1877: CFLAGS+= -Werror=implicit-function-declaration
1.178 rillig 1878:
1.179 rillig 1879: When a package fails to build using these stricter compiler options, document
1880: the circumstances in which the compiler produced the error message. This
1881: includes:
1.178 rillig 1882:
1883: * The platform (MACHINE_PLATFORM)
1884:
1885: * The source file
1886:
1887: * An excerpt of the code. GCC and Clang already do this as part of the
1888: diagnostic.
1889:
1.179 rillig 1890: * The exact error message from the compiler.
1.178 rillig 1891:
1.179 rillig 1892: If a package produces these error messages, but the package is fine, record
1893: this in your local mk.conf, like this, to skip this check in the next builds:
1.178 rillig 1894:
1.179 rillig 1895: .if ${PKGPATH} == category/package
1.178 rillig 1896: # Version ${VERSION} failed on ${MACHINE_PLATFORM}:
1897: # error message
1898: # code
1.179 rillig 1899: # Reason why the code does not need to be fixed.
1.178 rillig 1900: BUILDLINK_TRANSFORM+= rm:-Werror=char-subscripts
1.179 rillig 1901: .endif
1.178 rillig 1902:
1903: If the error messages from the compiler are valid and the code needs to be
1.179 rillig 1904: fixed, prepare a local patch (see LOCALPATCHES) and report the bug to the
1905: upstream authors of the package, providing them with the information you
1906: collected above.
1.178 rillig 1907:
1.179 rillig 1908: Patches that are not essential for the package to work should only be reported
1909: upstream but not committed to pkgsrc, to make future updates easier.
1910:
1.272 wiz 1911: 8.5.3. Force compiler options only in the build phase
1.181 rillig 1912:
1913: When adding custom compiler flags via CFLAGS, these apply to all phases of the
1914: package build process. Especially in the configure phase, adding -Werror leads
1915: to wrong decisions. The GNU configure scripts feed many small test programs to
1916: the C compiler to see whether certain headers are available, functions are
1917: defined in a library and programs can be run. In many cases these programs
1918: would not survive a strict compiler run with -Wall -Wextra -Werror.
1919:
1920: The pkgsrc infrastructure is flexible enough to support compiler options being
1921: added between the configure and build phases. It's a little more complicated
1922: than the other examples in this section but still easy enough.
1923:
1924: The basic idea is to use the pkgsrc compiler wrapper to inject the desired
1925: compiler options. The compiler wrapper's original task is to hide unwanted
1926: directories of include files and to normalize compiler options. It does this by
1927: wrapping the compiler command and rewriting the command line. To see this in
1928: action, run bmake patch in a package directory and examine the work/.cwrappers/
1929: config directory. It contains individual configurations for the C compiler and
1930: the related tools. The plan is to find a hook between the configure and build
1931: phases, and to modify these configuration files at that point.
1932:
1933: To find this hook, have a look at mk/build/build.mk, which contains among
1934: others the pre-build-checks-hook. The word checks doesn't quite fit, but the
1935: pre-build-hook sounds good enough.
1936:
1937: The code to be included in mk.conf is:
1938:
1939: # Just a few example options.
1940: BUILD_ONLY_CFLAGS= -Wall -Werror -O2 -DTEMPDIR='"/tmp"'
1941:
1942: .if ${BUILD_ONLY_CFLAGS:U:M*}
1943: pre-build-checks-hook: add-build-only-cflags
1944:
1945: add-build-only-cflags: .PHONY
1946: ${RUN} cd ${CWRAPPERS_CONFIG_DIR}; \
1947: ${TEST} ! -f ${.TARGET} || exit 0; \
1948: for flag in ${BUILD_ONLY_CFLAGS}; do \
1949: ${ECHO} "append=$$flag" >> cc; \
1950: done; \
1951: > ${.TARGET}
1952: .endif
1953:
1954: (When editing the mk.conf, make sure that the commands of the
1955: add-build-only-cflags target are indented with a tab, not with spaces.)
1956:
1957: The condition in the .if statement contains the :U modifier to prevent parse
1958: errors if the variable should be undefined, possibly because it is only defined
1959: for a subset of the packages. The :M* modifier ensures that there is at least
1960: one compiler option, to prevent a syntax error in the shell parser.
1961:
1962: The code around the ${.TARGET} variable ensures that the additional compiler
1963: options are only appended once, even if bmake build is run multiple times. To
1964: do this, it creates a marker file.
1965:
1966: To verify that this setup works, run bmake configure in a package directory. Up
1967: to now, everything works as usual. Examine the directory work/.cwrappers/config
1968: to see that the compiler options from BUILD_ONLY_CFLAGS are not yet added to
1969: the file cc. Examine the tail of the work/.work.log file to see that the normal
1970: compiler options are used.
1971:
1972: Now run bmake build. This will append the options to the file cc and will
1973: create the marker file in the same directory. After that, the build starts as
1974: usual, but with the added compiler options. Examine the tail of the file work
1975: /.work.log to see that the lines starting with [*] don't contain the compiler
1976: options, but the corresponding lines starting with <.> do end with these
1977: options.
1978:
1979: Building packages using this setup variant and fixing the resulting bugs is the
1.272 wiz 1980: same as in Section 8.5.2, Detect classes of bugs by forcing compiler warnings
1.181 rillig 1981: .
1982:
1.272 wiz 1983: 8.5.4. Use custom directories
1.178 rillig 1984:
1985: Some directories like PREFIX, VARBASE, PKG_SYSCONFDIR, PKGMANDIR, PKG_INFODIR
1986: can be configured in pkgsrc. Set these to arbitrary paths during bootstrap or
1987: afterwards in mk.conf.
1988:
1989: PREFIX= /a-random-uuid
1990: PKG_SYSCONFDIR= /a-random-uuid
1991: VARBASE= /a-random-uuid
1992: PKGMANDIR= a-random-uuid
1993: PKG_INFODIR= a-random-uuid
1994:
1.272 wiz 1995: 8.5.5. Turn warnings into errors
1.178 rillig 1996:
1997: When building a package, warnings are typically ignored since they just flow by
1998: and do not cause the build to fail immediately. To find these warnings,
1999: redefine them to errors in mk.conf.
2000:
2001: DELAYED_WARNING_MSG= ${DELAYED_ERROR_MSG} "(was warning)"
2002: WARNING_MSG= ${FAIL_MSG} "(was warning)"
2003:
2004: (There are many more classes of warnings in pkgsrc, and most of them can be
2005: redefined with a simple definition like above.
2006:
1.179 rillig 2007: If a package suggests to add USE_TOOLS+=perl to the package Makefile, research
1.178 rillig 2008: whether the package actually needs Perl. If it does, add USE_TOOLS+=perl to the
2009: package Makefile, and if it doesn't, add TOOLS_BROKEN+=perl.
2010:
1.272 wiz 2011: 8.5.6. Reject packages for which pkglint reports errors
1.178 rillig 2012:
2013: Using pkglint as part of the regular build process is mostly a waste of time.
2014: If you want to fix some of the warnings, just run pkglint recursively on the
2015: whole pkgsrc tree. This will take a few minutes (up to 10), which is much
2016: faster than a complete bulk build.
2017:
1.272 wiz 2018: 8.5.7. Reject packages that contain forbidden strings
1.178 rillig 2019:
2020: To ensure that the binary packages don't contain references to the build
2021: directory, there is already CHECK_WRKREF. If that variable includes the item
2022: extra, it is possible to define additional patterns that must not appear in any
2023: installed file. This is specified in mk.conf.
2024:
2025: CHECK_WRKREF= extra
2026: CHECK_WRKREF_EXTRA_DIRS+= /usr/local
2027: CHECK_WRKREF_EXTRA_DIRS+= /usr/pkg
2028: CHECK_WRKREF_EXTRA_DIRS+= @[A-Z][A-Z]*@
2029:
2030: The above patterns will probably generate many false positives, therefore the
2031: results need to be taken with a grain of salt.
2032:
1.272 wiz 2033: 8.5.8. Reject packages whose self-test fails
1.178 rillig 2034:
2035: To run the test suites that come with each package, add this line to mk.conf.
2036:
2037: PKGSRC_RUN_TEST= yes
2038:
2039: Be prepared that even the most basic packages fail this test. When doing a bulk
2040: build with this, it will often abort in the early phase where the packages are
2041: scanned for their dependencies since there are cyclic dependencies. There is
2042: still a lot to do in this area.
2043:
1.272 wiz 2044: 8.5.9. Reject packages that use undefined shell variables
1.178 rillig 2045:
2046: To catch typos in the shell snippets from the Makefile fragments, add the -u
2047: flag to most of the commands by adding this line to mk.conf.
2048:
2049: RUN= @set -eu;
2050:
1.181 rillig 2051: After that, ensure that none of the bulk build log files (even those for
2052: successfully built packages) contains the string parameter not set or whatever
2053: error message the command sh -ceu '$undefined' outputs.
2054:
1.178 rillig 2055: See mk/misc/common.mk for the existing definition.
2056:
1.272 wiz 2057: 8.5.10. Turn off verbose logging
1.178 rillig 2058:
2059: The build logs of a package are often quite long. This allows error messages or
2060: other interesting details to hide between the noise. To make the actual error
2061: message stand out more, add these lines to mk.conf.
2062:
2063: GNU_CONFIGURE_QUIET= yes
2064: MAKE_FLAGS+= -s
2065:
2066: The -s option works for both GNU Make and BSD Make. On exotic platforms with
2067: their own make, it may be a little different.
2068:
1.272 wiz 2069: 8.6. Creating a multiple CD-ROM packages collection
1.1 dsieger 2070:
2071: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
2072: of the resulting binary packages to assist in installing packages on other
2073: machines. The pkgtools/cdpack package provides a simple tool for creating the
2074: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
2075: keeps all the dependencies for a given package on the same CD as that package.
2076:
1.272 wiz 2077: 8.6.1. Example of cdpack
1.1 dsieger 2078:
2079: Complete documentation for cdpack is found in the cdpack(1) man page. The
2080: following short example assumes that the binary packages are left in /usr/
2081: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
2082: ISO 9660 images.
2083:
2084: # mkdir /u2/images
2085: # pkg_add /usr/pkgsrc/packages/All/cdpack
2086: # cdpack /usr/pkgsrc/packages/All /u2/images
2087:
2088:
2089: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
2090: CD in the collection, then you need to create a directory which contains these
1.175 gutterid 2091: files, e.g.:
1.1 dsieger 2092:
2093: # mkdir /tmp/common
2094: # echo "This is a README" > /tmp/common/README
2095: # echo "Another file" > /tmp/common/COPYING
2096: # mkdir /tmp/common/bin
2097: # echo "#!/bin/sh" > /tmp/common/bin/myscript
2098: # echo "echo Hello world" >> /tmp/common/bin/myscript
2099: # chmod 755 /tmp/common/bin/myscript
2100:
2101:
2102: Now create the images:
2103:
2104: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
2105:
2106: Each image will contain README, COPYING, and bin/myscript in their root
2107: directories.
2108:
1.266 martin 2109: Chapter 9. Directory layout of the installed files
1.1 dsieger 2110:
2111: Table of Contents
2112:
1.154 rillig 2113: 9.1. File system layout in ${LOCALBASE}
2114: 9.2. File system layout in ${VARBASE}
1.1 dsieger 2115:
2116: The files that are installed by pkgsrc are organized in a way that is similar
2117: to what you find in the /usr directory of the base system. But some details are
2118: different. This is because pkgsrc initially came from FreeBSD and had adopted
2119: its file system hierarchy. Later it was largely influenced by NetBSD. But no
2120: matter which operating system you are using pkgsrc with, you can expect the
2121: same layout for pkgsrc.
2122:
2123: There are mainly four root directories for pkgsrc, which are all configurable
2124: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
2125: default locations are:
2126:
2127: LOCALBASE= /usr/pkg
2128: PKG_SYSCONFBASE= /usr/pkg/etc
2129: VARBASE= /var
1.119 sevan 2130: PKG_DBDIR= /usr/pkg/pkgdb
1.1 dsieger 2131:
2132: In unprivileged mode (when pkgsrc has been installed as any other user), the
2133: default locations are:
2134:
2135: LOCALBASE= ${HOME}/pkg
2136: PKG_SYSCONFBASE= ${HOME}/pkg/etc
2137: VARBASE= ${HOME}/pkg/var
1.119 sevan 2138: PKG_DBDIR= ${HOME}/pkg/pkgdb
1.1 dsieger 2139:
2140: What these four directories are for, and what they look like is explained
2141: below.
2142:
1.266 martin 2143: * LOCALBASE corresponds to the /usr directory in the base system. It is the
2144: main directory where the files are installed and contains the well-known
1.1 dsieger 2145: subdirectories like bin, include, lib, share and sbin.
2146:
2147: * VARBASE corresponds to /var in the base system. Some programs (especially
2148: games, network daemons) need write access to it during normal operation.
2149:
2150: * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
2151: configuration files of the packages, as well as pkgsrc's mk.conf itself.
2152:
1.266 martin 2153: 9.1. File system layout in ${LOCALBASE}
1.1 dsieger 2154:
2155: The following directories exist in a typical pkgsrc installation in $
2156: {LOCALBASE}.
2157:
2158: bin
2159:
2160: Contains executable programs that are intended to be directly used by the
2161: end user.
2162:
2163: emul
2164:
2165: Contains files for the emulation layers of various other operating systems,
2166: especially for NetBSD.
2167:
2168: etc (the usual location of ${PKG_SYSCONFDIR})
2169:
2170: Contains the configuration files.
2171:
2172: include
2173:
2174: Contains headers for the C and C++ programming languages.
2175:
2176: info
2177:
2178: Contains GNU info files of various packages.
2179:
2180: lib
2181:
2182: Contains shared and static libraries.
2183:
2184: libdata
2185:
2186: Contains data files that don't change after installation. Other data files
2187: belong into ${VARBASE}.
2188:
2189: libexec
2190:
2191: Contains programs that are not intended to be used by end users, such as
2192: helper programs or network daemons.
2193:
2194: libexec/cgi-bin
2195:
2196: Contains programs that are intended to be executed as CGI scripts by a web
2197: server.
2198:
2199: man (the usual value of ${PKGMANDIR})
2200:
2201: Contains brief documentation in form of manual pages.
2202:
2203: sbin
2204:
2205: Contains programs that are intended to be used only by the super-user.
2206:
2207: share
2208:
2209: Contains platform-independent data files that don't change after
2210: installation.
2211:
2212: share/doc
2213:
2214: Contains documentation files provided by the packages.
2215:
2216: share/examples
2217:
2218: Contains example files provided by the packages. Among others, the original
2219: configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
2220: installation.
2221:
2222: share/examples/rc.d
2223:
2224: Contains the original files for rc.d scripts.
2225:
2226: var (the usual location of ${VARBASE})
2227:
2228: Contains files that may be modified after installation.
2229:
1.266 martin 2230: 9.2. File system layout in ${VARBASE}
1.1 dsieger 2231:
2232: db/pkg (the usual location of ${PKG_DBDIR})
2233:
2234: Contains information about the currently installed packages.
2235:
2236: games
2237:
2238: Contains highscore files.
2239:
2240: log
2241:
2242: Contains log files.
2243:
2244: run
2245:
2246: Contains informational files about daemons that are currently running.
2247:
1.266 martin 2248: Chapter 10. Frequently Asked Questions
1.1 dsieger 2249:
2250: Table of Contents
2251:
1.154 rillig 2252: 10.1. Are there any mailing lists for pkg-related discussion?
2253: 10.2. Utilities for package management (pkgtools)
2254: 10.3. How to use pkgsrc as non-root
2255: 10.4. How to resume transfers when fetching distfiles?
2256: 10.5. How can I install/use modular X.org from pkgsrc?
2257: 10.6. How to fetch files from behind a firewall
2258: 10.7. How to fetch files from HTTPS sites
2259: 10.8. How do I tell make fetch to do passive FTP?
2260: 10.9. How to fetch all distfiles at once
1.266 martin 2261: 10.10. What does Don't know how to make /usr/share/tmac/tmac.andoc mean?
2262: 10.11. What does Could not find bsd.own.mk mean?
1.221 nia 2263: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154 rillig 2264: 10.13. How do I change the location of configuration files?
2265: 10.14. Automated security checks
2266: 10.15. Why do some packages ignore my CFLAGS?
2267: 10.16. A package does not build. What shall I do?
1.266 martin 2268: 10.17. What does Makefile appears to contain unresolved cvs/rcs/??? merge
1.271 wiz 2269: conflicts mean?
1.1 dsieger 2270:
2271: This section contains hints, tips & tricks on special things in pkgsrc that we
2272: didn't find a better place for in the previous chapters, and it contains items
2273: for both pkgsrc users and developers.
2274:
1.266 martin 2275: 10.1. Are there any mailing lists for pkg-related discussion?
1.1 dsieger 2276:
2277: The following mailing lists may be of interest to pkgsrc users:
2278:
2279: * pkgsrc-users: This is a general purpose list for most issues regarding
2280: pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
2281: configuration, unexpected build failures, using particular packages,
2282: upgrading pkgsrc installations, questions regarding the pkgsrc release
2283: branches, etc. General announcements or proposals for changes that impact
2284: the pkgsrc user community, e.g. major infrastructure changes, new features,
2285: package removals, etc., may also be posted.
2286:
2287: * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
2288: discussed.
2289:
2290: * pkgsrc-changes: This list is for those who are interested in getting a
2291: commit message for every change committed to pkgsrc. It is also available
2292: in digest form, meaning one daily message containing all commit messages
2293: for changes to the package source tree in that 24 hour period.
2294:
2295: To subscribe, do:
2296:
2297: % echo subscribe listname | mail majordomo@NetBSD.org
2298:
1.174 leot 2299: Archives for all these mailing lists are available from https://
1.1 dsieger 2300: mail-index.NetBSD.org/.
2301:
1.266 martin 2302: 10.2. Utilities for package management (pkgtools)
1.1 dsieger 2303:
2304: The directory pkgsrc/pkgtools contains a number of useful utilities for both
2305: users and developers of pkgsrc. This section attempts only to make the reader
1.121 sevan 2306: aware of some of the utilities and when they might be useful, and not to
2307: duplicate the documentation that comes with each package.
1.1 dsieger 2308:
2309: Utilities used by pkgsrc (automatically installed when needed):
2310:
2311: * pkgtools/x11-links: Symlinks for use by buildlink.
2312:
2313: OS tool augmentation (automatically installed when needed):
2314:
1.121 sevan 2315: * pkgtools/digest: Calculates various kinds of checksums (including SHA3).
1.1 dsieger 2316:
2317: * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
2318:
2319: * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
2320:
2321: * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
2322: for use on operating systems where pkg_install is not present.
2323:
2324: Utilities used by pkgsrc (not automatically installed):
2325:
2326: * pkgtools/pkg_tarup: Create a binary package from an already-installed
2327: package. Used by make replace to save the old package.
2328:
2329: * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
2330: distfiles from multiple locations. It currently supports the following
2331: methods: multiple CD-ROMs and network FTP/HTTP connections.
2332:
2333: * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24 wiz 2334: current CPU and compiler.
1.1 dsieger 2335:
2336: Utilities for keeping track of installed packages, being up to date, etc:
2337:
1.65 wiz 2338: * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
2339: and upgrade binary packages easily.
2340:
1.1 dsieger 2341: * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
2342: the latest pkgsrc entries.
2343:
2344: * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
2345: strategy for updating.
2346:
2347: * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
2348: graphviz).
2349:
1.12 weinem 2350: * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
2351:
2352: * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
2353: complete pkgsrc system.
1.1 dsieger 2354:
2355: * pkgtools/pkgsurvey: Report what packages you have installed.
2356:
2357: Utilities for people maintaining or creating individual packages:
2358:
2359: * pkgtools/pkgdiff: Automate making and maintaining patches for a package
2360: (includes pkgdiff, pkgvi, mkpatches, etc.).
2361:
1.65 wiz 2362: * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1 dsieger 2363:
2364: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
2365:
2366: * pkgtools/pkg_comp: Build packages in a chrooted area.
2367:
2368: * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
2369:
1.266 martin 2370: 10.3. How to use pkgsrc as non-root
1.1 dsieger 2371:
1.108 rillig 2372: To install packages from source as a non-root user, download pkgsrc as
1.266 martin 2373: described in Chapter 3, Where to get pkgsrc and how to keep it up-to-date, cd
1.108 rillig 2374: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
2375:
2376: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
2377: configuration mk.conf into ~/pkg/etc.
2378:
2379: For more details, see mk/unprivileged.mk.
1.1 dsieger 2380:
1.266 martin 2381: 10.4. How to resume transfers when fetching distfiles?
1.1 dsieger 2382:
2383: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4 rillig 2384: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
2385: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1 dsieger 2386:
1.61 wiz 2387: You can also use a different program than the platform default program by
2388: changing the FETCH_USING variable. You can specify the program by using of ftp,
2389: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
2390: manual. A value of custom disables the system defaults and dependency tracking
2391: for the fetch program. In that case you have to provide FETCH_CMD,
2392: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1 dsieger 2393:
1.16 jnemeth 2394: For example, if you want to use wget to download, you'll have to use something
2395: like:
1.1 dsieger 2396:
1.16 jnemeth 2397: FETCH_USING= wget
1.1 dsieger 2398:
1.266 martin 2399: 10.5. How can I install/use modular X.org from pkgsrc?
1.1 dsieger 2400:
1.4 rillig 2401: If you want to use modular X.org from pkgsrc instead of your system's own X11
2402: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1 dsieger 2403: mk.conf:
2404:
1.4 rillig 2405: X11_TYPE=modular
1.1 dsieger 2406:
1.266 martin 2407: 10.6. How to fetch files from behind a firewall
1.1 dsieger 2408:
2409: If you are sitting behind a firewall which does not allow direct connections to
2410: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
2411: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
1.266 martin 2412: machine orpheus.amdahl.com is one of the firewalls, and it uses port 80 as
1.1 dsieger 2413: the proxy port number. So the proxy environment variables are:
2414:
2415: ftp_proxy=ftp://orpheus.amdahl.com:80/
2416: http_proxy=http://orpheus.amdahl.com:80/
2417:
1.266 martin 2418: 10.7. How to fetch files from HTTPS sites
1.65 wiz 2419:
2420: Some fetch tools are not prepared to support HTTPS by default (for example, the
2421: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
2422: openssl dependency that low in the dependency graph).
2423:
1.266 martin 2424: Usually you won't notice, because distribution files are mirrored weekly to
2425: ftp.NetBSD.org , but that might not be often enough if you are following
2426: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to curl or
2427: wget , which are both compiled with HTTPS support by default. Of course, these
1.65 wiz 2428: tools need to be installed before you can use them this way.
2429:
1.266 martin 2430: 10.8. How do I tell make fetch to do passive FTP?
1.1 dsieger 2431:
2432: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
2433: FETCH_CMD is assigned the first available command from the following list:
2434:
2435: * ${LOCALBASE}/bin/ftp
2436:
2437: * /usr/bin/ftp
2438:
2439: On a default NetBSD installation, this will be /usr/bin/ftp, which
2440: automatically tries passive connections first, and falls back to active
2441: connections if the server refuses to do passive. For the other tools, add the
1.4 rillig 2442: following to your mk.conf file: PASSIVE_FETCH=1.
1.1 dsieger 2443:
2444: Having that option present will prevent /usr/bin/ftp from falling back to
2445: active transfers.
2446:
1.266 martin 2447: 10.9. How to fetch all distfiles at once
1.1 dsieger 2448:
2449: You would like to download all the distfiles in a single batch from work or
2450: university, where you can't run a make fetch. There is an archive of distfiles
2451: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
2452:
2453: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
2454: subdirectories, carry the resulting list to your machine at work/school and use
2455: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
2456: don't forget to set FETCH_CMD to something that fetches a URL:
2457:
2458: At home:
2459:
2460: % cd /usr/pkgsrc
2461: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
2462: % scp /tmp/fetch.sh work:/tmp
2463:
2464: At work:
2465:
2466: % sh /tmp/fetch.sh
2467:
2468: then tar up /tmp/distfiles and take it home.
2469:
2470: If you have a machine running NetBSD, and you want to get all distfiles (even
2471: ones that aren't for your machine architecture), you can do so by using the
2472: above-mentioned make fetch-list approach, or fetch the distfiles directly by
2473: running:
2474:
2475: % make mirror-distfiles
2476:
2477: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
2478: everything by running:
2479:
2480: % make fetch NO_SKIP=yes
2481:
1.266 martin 2482: 10.10. What does Don't know how to make /usr/share/tmac/tmac.andoc mean?
1.1 dsieger 2483:
2484: When compiling the pkgtools/pkg_install package, you get the error from make
2485: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
1.266 martin 2486: that you don't have installed the text set (nroff, ...) from the NetBSD base
1.1 dsieger 2487: distribution on your machine. It is recommended to do that to format man pages.
2488:
2489: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4 rillig 2490: NOMAN=YES either in the environment or in mk.conf.
1.1 dsieger 2491:
1.266 martin 2492: 10.11. What does Could not find bsd.own.mk mean?
1.1 dsieger 2493:
2494: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
2495: machine. Please get and install it, by extracting it in /:
2496:
2497: # cd /
2498: # tar --unlink -zxvpf .../comp.tgz
2499:
2500: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
2501: release (determine via uname -r).
2502:
1.266 martin 2503: 10.12. Using 'sudo' or `priv` with pkgsrc
1.1 dsieger 2504:
2505: When installing packages as non-root user and using the just-in-time su(1)
2506: feature of pkgsrc, it can become annoying to type in the root password for each
2507: required package installed. To avoid this, the sudo package can be used, which
1.221 nia 2508: does password caching over a limited time. To use it, install sudo or priv
2509: (either as binary package, from security/priv, or security/sudo) and then put
2510: the following into your mk.conf, somewhere after the definition of the
2511: LOCALBASE variable:
1.1 dsieger 2512:
2513: .if exists(${LOCALBASE}/bin/sudo)
1.260 wiz 2514: SU_CMD= ${LOCALBASE}/bin/sudo -E /bin/sh -c
1.1 dsieger 2515: .endif
2516:
1.260 wiz 2517: Note the -E flag; that tells sudo to preserve the environment. Without this,
2518: the bin-install target will fail when building a package with a non-default
2519: python version.
2520:
1.266 martin 2521: 10.13. How do I change the location of configuration files?
1.1 dsieger 2522:
2523: As the system administrator, you can choose where configuration files are
2524: installed. The default settings make all these files go into ${PREFIX}/etc or
2525: some of its subdirectories; this may be suboptimal depending on your
2526: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
2527: configuration of the provided packages).
2528:
2529: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4 rillig 2530: (in mk.conf) to point to your preferred configuration directory; some common
2531: examples include /etc or /etc/pkg.
1.1 dsieger 2532:
2533: Furthermore, you can change this value on a per-package basis by setting the
2534: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
2535: matches the name of the package you would like to modify, that is, the contents
2536: of PKGBASE.
2537:
2538: Note that after changing these settings, you must rebuild and reinstall any
2539: affected packages.
2540:
1.266 martin 2541: 10.14. Automated security checks
1.1 dsieger 2542:
2543: Please be aware that there can often be bugs in third-party software, and some
2544: of these bugs can leave a machine vulnerable to exploitation by attackers. In
2545: an effort to lessen the exposure, the NetBSD packages team maintains a database
2546: of known-exploits to packages which have at one time been included in pkgsrc.
2547: The database can be downloaded automatically, and a security audit of all
1.14 jmcneill 2548: packages installed on a system can take place. To do this, refer to the
2549: following two tools (installed as part of the pkgtools/pkg_install package):
1.1 dsieger 2550:
1.21 snj 2551: 1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
2552: security vulnerabilities information. This list is kept up to date by the
1.26 spz 2553: pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1 dsieger 2554:
1.177 leot 2555: https://ftp.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities
1.1 dsieger 2556:
1.21 snj 2557: 2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24 wiz 2558: known vulnerability. If a vulnerable package is installed, it will be shown
2559: by output to stdout, including a description of the type of vulnerability,
2560: and a URL containing more information.
1.1 dsieger 2561:
1.266 martin 2562: Use of these tools is strongly recommended! See Section 5.1.6, Checking for
2563: security vulnerabilities in installed packages for instructions on how to
1.121 sevan 2564: automate checking and reporting.
2565:
2566: If this database is installed, pkgsrc builds will use it to perform a security
2567: check before building any package.
1.1 dsieger 2568:
1.266 martin 2569: 10.15. Why do some packages ignore my CFLAGS?
1.1 dsieger 2570:
2571: When you add your own preferences to the CFLAGS variable in your mk.conf, these
2572: flags are passed in environment variables to the ./configure scripts and to
2573: make(1). Some package authors ignore the CFLAGS from the environment variable
2574: by overriding them in the Makefiles of their package.
2575:
2576: Currently there is no solution to this problem. If you really need the package
2577: to use your CFLAGS you should run make patch in the package directory and then
2578: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
1.266 martin 2579: Usually you can remove these lines. But be aware that some smart programmers
1.1 dsieger 2580: write so bad code that it only works for the specific combination of CFLAGS
2581: they have chosen.
2582:
1.172 rillig 2583: To find out where the CFLAGS are ignored, add the following lines to mk.conf:
2584:
2585: CPPFLAGS+= -Dpkgsrc___CPPFLAGS
2586: CFLAGS+= -Dpkgsrc___CFLAGS
2587: CXXFLAGS+= -Dpkgsrc___CXXFLAGS
2588:
2589: Then run bmake show-all-configure show-all-build to see whether the above flags
2590: are passed to the actual build commands in general.
2591:
2592: To find out whether the flags are passed to individual compiler commands, have
2593: a look at the file work/.work.log. In most cases, the flags from the original
2594: command lines (the lines starting with [*]) are passed unmodified to the actual
2595: compiler (the lines starting with <.>). If the flag is missing from the actual
2596: compiler command, it must have been removed by the pkgsrc compiler wrappers.
2597:
1.266 martin 2598: 10.16. A package does not build. What shall I do?
1.1 dsieger 2599:
2600: 1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
2601: is that people only update pkgsrc in parts, because of performance reasons.
2602: Since pkgsrc is one large system, not a collection of many small systems,
2603: there are sometimes changes that only work when the whole pkgsrc tree is
2604: updated.
2605:
1.266 martin 2606: 2. Make sure that you don't have any CVS conflicts. Search for <<<<<< or
2607: >>>>>> in all your pkgsrc files.
1.1 dsieger 2608:
1.25 wiz 2609: 3. Make sure that you don't have old copies of the packages extracted. Run
1.1 dsieger 2610: make clean clean-depends to verify this.
2611:
1.108 rillig 2612: 4. If you are a package developer who wants to invest some work, have a look
1.266 martin 2613: at Chapter 21, Making your package work.
1.108 rillig 2614:
2615: 5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1 dsieger 2616:
1.266 martin 2617: 10.17. What does Makefile appears to contain unresolved cvs/rcs/??? merge
2618: conflicts mean?
1.1 dsieger 2619:
2620: You have modified a file from pkgsrc, and someone else has modified that same
2621: file afterwards in the CVS repository. Both changes are in the same region of
2622: the file, so when you updated pkgsrc, the cvs command marked the conflicting
2623: changes in the file. Because of these markers, the file is no longer a valid
2624: Makefile.
2625:
2626: Have a look at that file, and if you don't need your local changes anymore, you
2627: can remove that file and run cvs -q update -dP in that directory to download
2628: the current version.
2629:
1.266 martin 2630: Part II. The pkgsrc developer's guide
1.1 dsieger 2631:
2632: This part of the book deals with creating and modifying packages. It starts
1.266 martin 2633: with a HOWTO -like guide on creating a new package. The remaining chapters are
1.1 dsieger 2634: more like a reference manual for pkgsrc.
2635:
2636: Table of Contents
2637:
1.154 rillig 2638: 11. Getting help
1.184 rillig 2639: 12. Package components - files, directories and contents
2640: 12.1. Makefile
2641: 12.2. distinfo
2642: 12.3. patches/*
2643: 12.3.1. Structure of a single patch file
2644: 12.3.2. Creating patch files
2645: 12.3.3. Sources where the patch files come from
2646: 12.3.4. Patching guidelines
2647: 12.3.5. Feedback to the author
2648: 12.4. Other mandatory files
2649: 12.5. Optional files
2650: 12.5.1. Files affecting the binary package
2651: 12.5.2. Files affecting the build process
2652: 12.5.3. Files affecting nothing at all
2653: 12.6. work*
2654: 12.7. files/*
2655: 13. The build process
2656: 13.1. Introduction
2657: 13.2. Program location
2658: 13.3. Directories used during the build process
2659: 13.4. Running a phase
2660: 13.5. The fetch phase
2661: 13.5.1. What to fetch and where to get it from
2662: 13.5.2. How are the files fetched?
2663: 13.6. The checksum phase
2664: 13.7. The extract phase
2665: 13.8. The patch phase
2666: 13.9. The tools phase
2667: 13.10. The wrapper phase
2668: 13.11. The configure phase
2669: 13.12. The build phase
2670: 13.13. The test phase
2671: 13.14. The install phase
2672: 13.15. The package phase
2673: 13.16. Cleaning up
2674: 13.17. Other helpful targets
2675: 14. Creating a new pkgsrc package from scratch
2676: 14.1. Common types of packages
1.219 nia 2677: 14.1.1. Python modules and programs
2678: 14.1.2. R packages
2679: 14.1.3. TeXlive packages
1.184 rillig 2680: 14.2. Examples
2681: 14.2.1. How the www/nvu package came into pkgsrc
2682: 15. Programming in Makefiles
2683: 15.1. Caveats
2684: 15.2. Makefile variables
2685: 15.2.1. Naming conventions
2686: 15.3. Code snippets
2687: 15.3.1. Adding things to a list
2688: 15.3.2. Echoing a string exactly as-is
2689: 15.3.3. Passing CFLAGS to GNU configure scripts
2690: 15.3.4. Handling possibly empty variables
1.229 gutterid 2691: 15.3.5. Testing yes/no variables in conditions
1.184 rillig 2692: 16. Options handling
2693: 16.1. Global default options
2694: 16.2. Converting packages to use bsd.options.mk
2695: 16.3. Option Names
2696: 16.4. Determining the options of dependencies
2697: 17. Tools needed for building or running
2698: 17.1. Tools for pkgsrc builds
2699: 17.2. Tools needed by packages
2700: 17.3. Tools provided by platforms
2701: 18. Buildlink methodology
2702: 18.1. Converting packages to use buildlink3
2703: 18.2. Writing buildlink3.mk files
2704: 18.2.1. Anatomy of a buildlink3.mk file
2705: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
1.271 wiz 2706: pkg in buildlink3.mk files
1.184 rillig 2707: 18.3. Writing builtin.mk files
2708: 18.3.1. Anatomy of a builtin.mk file
2709: 19. PLIST issues
2710: 19.1. RCS ID
2711: 19.2. Semi-automatic PLIST generation
2712: 19.3. Tweaking output of make print-PLIST
2713: 19.4. Variable substitution in PLIST
2714: 19.5. Man page compression
2715: 19.6. Changing PLIST source with PLIST_SRC
2716: 19.7. Platform-specific and differing PLISTs
2717: 19.8. Build-specific PLISTs
2718: 19.9. Sharing directories between packages
2719: 20. The pkginstall framework
2720: 20.1. Files and directories outside the installation prefix
2721: 20.1.1. Directory manipulation
2722: 20.1.2. File manipulation
2723: 20.2. Configuration files
2724: 20.2.1. How PKG_SYSCONFDIR is set
2725: 20.2.2. Telling the software where configuration files are
1.239 dholland 2726: 20.2.3. Patching installation
2727: 20.2.4. Declaring configuration files
2728: 20.2.5. Disabling handling of configuration files
1.184 rillig 2729: 20.3. System startup scripts
2730: 20.3.1. Disabling handling of system startup scripts
2731: 20.4. System users and groups
2732: 20.5. System shells
2733: 20.5.1. Disabling shell registration
2734: 20.6. Fonts
2735: 20.6.1. Disabling automatic update of the fonts databases
1.154 rillig 2736: 21. Making your package work
2737: 21.1. General operation
2738: 21.1.1. How to pull in user-settable variables from mk.conf
2739: 21.1.2. User interaction
2740: 21.1.3. Handling licenses
2741: 21.1.4. Restricted packages
2742: 21.1.5. Handling dependencies
2743: 21.1.6. Handling conflicts with other packages
2744: 21.1.7. Packages that cannot or should not be built
2745: 21.1.8. Packages which should not be deleted, once installed
2746: 21.1.9. Handling packages with security problems
2747: 21.1.10. How to handle incrementing versions when fixing an existing
1.271 wiz 2748: package
1.154 rillig 2749: 21.1.11. Substituting variable text in the package files (the SUBST
1.271 wiz 2750: framework)
1.154 rillig 2751: 21.2. The fetch phase
2752: 21.2.1. Packages whose distfiles aren't available for plain downloading
2753: 21.2.2. How to handle modified distfiles with the 'old' name
2754: 21.2.3. Packages hosted on github.com
2755: 21.3. The configure phase
2756: 21.3.1. Shared libraries - libtool
2757: 21.3.2. Using libtool on GNU packages that already support libtool
2758: 21.3.3. GNU Autoconf/Automake
1.223 nia 2759: 21.3.4. Meson / ninja
1.260 wiz 2760: 21.3.5. Determining the endianness
1.154 rillig 2761: 21.4. Programming languages
2762: 21.4.1. C, C++, and Fortran
2763: 21.4.2. Java
1.205 wiz 2764: 21.4.3. Go
1.223 nia 2765: 21.4.4. Rust
2766: 21.4.5. Packages containing Perl scripts
2767: 21.4.6. Packages containing shell scripts
2768: 21.4.7. Other programming languages
1.154 rillig 2769: 21.5. The build phase
2770: 21.5.1. Compiling C and C++ code conditionally
2771: 21.5.2. How to handle compiler bugs
1.172 rillig 2772: 21.5.3. No such file or directory
1.266 martin 2773: 21.5.4. Undefined reference to ...
1.172 rillig 2774: 21.5.5. Running out of memory
1.154 rillig 2775: 21.6. The install phase
2776: 21.6.1. Creating needed directories
2777: 21.6.2. Where to install documentation
2778: 21.6.3. Installing highscore files
2779: 21.6.4. Adding DESTDIR support to packages
2780: 21.6.5. Packages with hardcoded paths to other interpreters
1.203 nia 2781: 21.6.6. Packages installing Perl modules
1.254 wiz 2782: 21.6.7. Packages installing pkg-config files
2783: 21.6.8. Packages installing info files
2784: 21.6.9. Packages installing man pages
2785: 21.6.10. Packages installing X11 fonts
2786: 21.6.11. Packages installing SGML or XML data
2787: 21.6.12. Packages installing extensions to the MIME database
2788: 21.6.13. Packages using intltool
2789: 21.6.14. Packages installing startup scripts
2790: 21.6.15. Packages installing TeX modules
2791: 21.6.16. Packages supporting running binaries in emulation
2792: 21.6.17. Packages installing hicolor icons
2793: 21.6.18. Packages installing desktop files
1.154 rillig 2794: 21.7. Marking packages as having problems
1.184 rillig 2795: 22. GNOME packaging and porting
2796: 22.1. Meta packages
2797: 22.2. Packaging a GNOME application
2798: 22.3. Updating GNOME to a newer version
2799: 22.4. Patching guidelines
1.154 rillig 2800: 23. Submitting and Committing
2801: 23.1. Submitting binary packages
2802: 23.2. Submitting source packages (for non-NetBSD-developers)
2803: 23.3. General notes when adding, updating, or removing packages
2804: 23.4. Commit Messages
2805: 23.5. Committing: Adding a package to CVS
2806: 23.6. Updating a package to a newer version
2807: 23.7. Renaming a package in pkgsrc
2808: 23.8. Moving a package in pkgsrc
1.263 wiz 2809: 24. pkgsrc Policies
2810: 24.1. Packages for which updating is restricted
2811: 24.1.1. Limited Updates - ABI
2812: 24.1.2. Limited Updates - Bootstrap
2813: 25. Frequently Asked Questions
1.154 rillig 2814:
1.266 martin 2815: Chapter 11. Getting help
1.154 rillig 2816:
2817: To get help when developing pkgsrc, the definitive source is this document, the
2818: pkgsrc guide. If you don't find anything here, there are alternatives:
2819:
2820: * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
1.266 martin 2821: Run bmake help topic= to get help for any topic, such as a variable name
1.154 rillig 2822: like BUILD_DEFS, a make target like do-build, a missing C or C++ function
2823: like strcasecmp or any other topic.
2824:
1.266 martin 2825: The available help topics are listed in Appendix E, Help topics.
1.154 rillig 2826:
1.163 rillig 2827: * To see the value of a single variable, run bmake show-var VARNAME=X.
2828:
2829: * To see the values of the most common variables, run bmake show-all. These
2830: variables are grouped by topic. To see the variables for a single topic,
2831: run bmake show-all-topic, for example bmake show-all-fetch.
2832:
1.154 rillig 2833: * The tech-pkg mailing list, to which you can subscribe and then ask your
2834: questions.
2835:
2836: * The #pkgsrc IRC channel, which is accessible via a web browser or by using
2837: a specialized chat program such as XChat. Pick any user name and join the
2838: channel #pkgsrc.
1.1 dsieger 2839:
1.266 martin 2840: Chapter 12. Package components - files, directories and contents
1.1 dsieger 2841:
2842: Table of Contents
2843:
1.184 rillig 2844: 12.1. Makefile
2845: 12.2. distinfo
2846: 12.3. patches/*
2847: 12.3.1. Structure of a single patch file
2848: 12.3.2. Creating patch files
2849: 12.3.3. Sources where the patch files come from
2850: 12.3.4. Patching guidelines
2851: 12.3.5. Feedback to the author
2852: 12.4. Other mandatory files
2853: 12.5. Optional files
2854: 12.5.1. Files affecting the binary package
2855: 12.5.2. Files affecting the build process
2856: 12.5.3. Files affecting nothing at all
2857: 12.6. work*
2858: 12.7. files/*
1.1 dsieger 2859:
1.184 rillig 2860: Whenever you're preparing a package, there are a number of files involved which
2861: are described in the following sections.
1.1 dsieger 2862:
1.266 martin 2863: 12.1. Makefile
1.1 dsieger 2864:
1.184 rillig 2865: Building, installation and creation of a binary package are all controlled by
2866: the package's Makefile. The Makefile describes various things about a package,
2867: for example from where to get it, how to configure, build, and install it.
1.1 dsieger 2868:
1.184 rillig 2869: A package Makefile contains several sections that describe the package.
1.1 dsieger 2870:
1.184 rillig 2871: In the first section there are the following variables, which should appear
2872: exactly in the order given here. The order and grouping of the variables is
2873: mostly historical and has no further meaning.
1.1 dsieger 2874:
1.184 rillig 2875: * DISTNAME is the basename of the distribution file to be downloaded from the
2876: package's website.
1.1 dsieger 2877:
1.184 rillig 2878: * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
2879: it if DISTNAME (which is the default) is not a good name for the package in
2880: pkgsrc or DISTNAME is not provided (no distribution file is required).
2881: Usually it is the pkgsrc directory name together with the version number.
2882: It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
2883: is, it starts with a letter or digit, and contains only letters, digits,
1.204 nia 2884: dashes, underscores, dots and plus signs. New packages should have entirely
2885: lower-case names, with the exception of some that must follow pre-existing
2886: conventions (e.g. R packages begin with R-). You can use the :tl variable
2887: modifier to lower-case the package name.
1.26 spz 2888:
1.184 rillig 2889: * CATEGORIES is a list of categories which the package fits in. You can
2890: choose any of the top-level directories of pkgsrc for it.
1.1 dsieger 2891:
1.184 rillig 2892: Currently the following values are available for CATEGORIES. If more than
2893: one is used, they need to be separated by spaces:
1.1 dsieger 2894:
1.184 rillig 2895: archivers cross geography meta-pkgs security
2896: audio databases graphics misc shells
2897: benchmarks devel ham multimedia sysutils
2898: biology editors inputmethod net textproc
2899: cad emulators lang news time
2900: chat finance mail parallel wm
2901: comms fonts math pkgtools www
2902: converters games mbone print x11
1.1 dsieger 2903:
1.184 rillig 2904: * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
1.266 martin 2905: are discussed in detail in Section 13.5, The fetch phase .
1.1 dsieger 2906:
1.184 rillig 2907: The second section contains information about separately downloaded patches, if
2908: any.
1.1 dsieger 2909:
1.184 rillig 2910: * PATCHFILES: Name(s) of additional files that contain distribution patches.
2911: There is no default. pkgsrc will look for them at PATCH_SITES. They will
2912: automatically be uncompressed before patching if the names end with .gz or
2913: .Z.
1.1 dsieger 2914:
1.184 rillig 2915: * PATCH_SITES: Primary location(s) for distribution patch files (see
2916: PATCHFILES above) if not found locally.
1.1 dsieger 2917:
1.184 rillig 2918: * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
2919: count to help find the correct files to patch. It defaults to -p0.
1.1 dsieger 2920:
1.184 rillig 2921: The third section contains the following variables.
1.1 dsieger 2922:
1.253 gutterid 2923: * MAINTAINER is the email address of the person who is currently responsible
2924: for this package. In theory, the maintainer will be aware of upstream
2925: release, keep it updated, and generally resolve problems. Others
2926: contemplating significant changes should ask the maintainer for advice or
2927: review of a proposed change. This is not necessary for micro updates, bug
2928: fixes, pkgsrc-wide changes affecting many packages, and other things
2929: expected to be uncontroversial. It goes with this "should ask" that the
2930: maintainer should respond to inquiries reasonably promptly (most of the
2931: time), and either approve changes or provide reasons why not. Typically,
2932: when packaging a new program, set MAINTAINER to yourself. If you don't
2933: intend to maintain the package (especially if you feel you have no special
2934: insight), set it to <pkgsrc-users@NetBSD.org>. This special value is a code
1.274 ! wiz 2935: point indicating that there is no maintainer.
1.1 dsieger 2936:
1.184 rillig 2937: * HOMEPAGE is a URL where users can find more information about the package.
1.1 dsieger 2938:
1.184 rillig 2939: * COMMENT is a one-line description of the package (should not include the
2940: package name).
1.1 dsieger 2941:
1.184 rillig 2942: * LICENSE indicates the license(s) applicable for the package. See
1.266 martin 2943: Section 21.1.3, Handling licenses for further details.
1.1 dsieger 2944:
1.184 rillig 2945: Other variables that affect the build:
1.1 dsieger 2946:
1.184 rillig 2947: * WRKSRC: The directory where the interesting distribution files of the
2948: package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
2949: most packages.
1.1 dsieger 2950:
1.184 rillig 2951: If a package doesn't create a subdirectory for itself (most GNU software
2952: does, for instance), but extracts itself in the current directory, you
2953: should set WRKSRC=${WRKDIR}.
1.1 dsieger 2954:
1.184 rillig 2955: If a package doesn't create a subdirectory with the name of DISTNAME but
2956: some different name, set WRKSRC to point to the proper name in ${WRKDIR},
2957: for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
2958: other examples.
1.17 imil 2959:
1.184 rillig 2960: The name of the working directory created by pkgsrc is taken from the
2961: WRKDIR_BASENAME variable. By default, its value is work. If you want to use
2962: the same pkgsrc tree for building different kinds of binary packages, you
2963: can change the variable according to your needs. Two other variables handle
2964: common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
2965: defined in mk.conf, the first component of the host's name is attached to
2966: the directory name. If OBJMACHINE is defined, the platform name is
2967: attached, which might look like work.i386 or work.sparc.
1.17 imil 2968:
1.184 rillig 2969: Please pay attention to the following gotchas:
1.17 imil 2970:
1.184 rillig 2971: * Add MANCOMPRESSED if man pages are installed in compressed form by the
2972: package. For packages using BSD-style makefiles which honor MANZ, there is
2973: MANCOMPRESSED_IF_MANZ.
1.17 imil 2974:
1.266 martin 2975: * Replace /usr/local with ${PREFIX} in all files (see patches, below).
1.103 wiz 2976:
1.266 martin 2977: * If the package installs any info files, see Section 21.6.8, Packages
2978: installing info files .
1.103 wiz 2979:
1.266 martin 2980: 12.2. distinfo
1.17 imil 2981:
1.184 rillig 2982: The distinfo file contains the message digest, or checksum, of each distfile
2983: needed for the package. This ensures that the distfiles retrieved from the
2984: Internet have not been corrupted during transfer or altered by a malign force
2985: to introduce a security hole. To provide maximum security, all distfiles are
1.243 gutterid 2986: protected using two different message digest algorithms (BLAKE2s and SHA512),
2987: as well as the file size.
1.17 imil 2988:
1.184 rillig 2989: The distinfo file also contains the checksums for all the patches found in the
1.266 martin 2990: patches directory (see Section 12.3, patches/* ). These checksums ensure that
1.184 rillig 2991: patches are only applied intentionally and that they don't accidentally change,
2992: e.g. when merging different changes together. They also make sure that new
2993: patches are actually added to CVS and old ones are removed. Too see whether the
2994: patches and the distinfo file match, run pkglint after changing the patches.
1.17 imil 2995:
1.184 rillig 2996: To regenerate the distinfo file, use the make distinfo command.
1.17 imil 2997:
1.184 rillig 2998: Some packages have different sets of distfiles depending on the platform, for
2999: example lang/openjdk8. These are kept in the same distinfo file and care should
3000: be taken when upgrading such a package to ensure distfile information is not
3001: lost.
1.17 imil 3002:
1.266 martin 3003: 12.3. patches/*
1.63 wiz 3004:
1.184 rillig 3005: Some packages don't work out-of-the box on the various platforms that are
3006: supported by pkgsrc. These packages need to be patched to make them work. The
3007: patch files can be found in the patches/ directory.
1.17 imil 3008:
1.184 rillig 3009: In the patch phase, these patches are applied to the files in WRKSRC directory
3010: after extracting them, in alphabetic order.
1.160 brook 3011:
1.266 martin 3012: 12.3.1. Structure of a single patch file
1.160 brook 3013:
1.184 rillig 3014: The patch-* files should be in diff -bu format, and apply without a fuzz to
3015: avoid problems. (To force patches to apply with fuzz you can set
3016: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
3017: a single file, and no file should be patched by more than one patch file. This
3018: helps to keep future modifications simple.
1.160 brook 3019:
1.184 rillig 3020: Each patch file is structured as follows: In the first line, there is the RCS
3021: Id of the patch itself. The second line should be empty for aesthetic reasons.
3022: After that, there should be a comment for each change that the patch does.
3023: There are a number of standard cases:
1.160 brook 3024:
1.184 rillig 3025: * Patches for commonly known vulnerabilities should mention the vulnerability
3026: ID (CAN, CVE).
1.160 brook 3027:
1.184 rillig 3028: * Patches that change source code should mention the platform and other
3029: environment (for example, the compiler) that the patch is needed for.
1.160 brook 3030:
1.184 rillig 3031: The patch should be commented so that any developer who knows the code of the
3032: application can make some use of the patch. Special care should be taken for
3033: the upstream developers, since we generally want that they accept our patches,
3034: so we have less work in the future.
1.160 brook 3035:
1.266 martin 3036: 12.3.2. Creating patch files
1.160 brook 3037:
1.184 rillig 3038: One important thing to mention is to pay attention that no RCS IDs get stored
3039: in the patch files, as these will cause problems when later checked into the
3040: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
3041: avoid these problems.
1.160 brook 3042:
1.184 rillig 3043: For even more automation, we recommend using mkpatches from the same package to
1.222 gutterid 3044: make a whole set of patches. You just have to back up files before you edit
3045: them to filename.orig, e.g., with cp -p filename filename.orig or, easier, by
3046: using pkgvi again from the same package. If you upgrade a package this way, you
3047: can easily compare the new set of patches with the previously existing one with
1.184 rillig 3048: patchdiff. The files in patches are replaced by new files, so carefully check
3049: if you want to take all the changes.
1.160 brook 3050:
1.184 rillig 3051: When you have finished a package, remember to generate the checksums for the
1.266 martin 3052: patch files by using the make makepatchsum command, see Section 12.2,
3053: distinfo .
1.1 dsieger 3054:
1.184 rillig 3055: When adding a patch that corrects a problem in the distfile (rather than e.g.
3056: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
3057: report to the maintainer. This benefits non-pkgsrc users of the package, and
3058: usually makes it possible to remove the patch in future version.
1.1 dsieger 3059:
1.184 rillig 3060: The file names of the patch files are usually of the form patch-
3061: path_to_file__with__underscores.c. Many packages still use the previous
3062: convention patch-[a-z][a-z], but new patches should be of the form containing
3063: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
3064: automatically.
1.1 dsieger 3065:
1.222 gutterid 3066: When updating pre-existing patch files, if a file uses the old patch-[a-z][a-z]
3067: convention, it's best not to change it to the new form, as that will just cause
3068: churn that makes it harder to track changes to patching over time. Similarly,
3069: if a patch now applies at different line offsets, but still applies cleanly
3070: as-is, there's no need to update it, as that also unnecessarily complicates the
3071: patch history.
3072:
1.266 martin 3073: 12.3.3. Sources where the patch files come from
1.1 dsieger 3074:
1.184 rillig 3075: If you want to share patches between multiple packages in pkgsrc, e.g. because
3076: they use the same distfiles, set PATCHDIR to the path where the patch files can
3077: be found, e.g.:
1.1 dsieger 3078:
1.184 rillig 3079: PATCHDIR= ../../editors/xemacs/patches
1.1 dsieger 3080:
1.184 rillig 3081: Patch files that are distributed by the author or other maintainers can be
3082: listed in PATCHFILES.
1.1 dsieger 3083:
1.184 rillig 3084: If it is desired to store any patches that should not be committed into pkgsrc,
3085: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
1.266 martin 3086: directory tree there is expected to have the same category/package structure
1.184 rillig 3087: as pkgsrc, and patches are expected to be stored inside these dirs (also known
3088: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
3089: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
3090: files in the named directory are expected to be patch files, and they are
3091: applied after pkgsrc patches are applied.
1.1 dsieger 3092:
1.266 martin 3093: 12.3.4. Patching guidelines
1.1 dsieger 3094:
1.184 rillig 3095: When fixing a portability issue in the code do not use preprocessor magic to
3096: check for the current operating system nor platform. Doing so hurts portability
3097: to other platforms because the OS-specific details are not abstracted
3098: appropriately.
1.1 dsieger 3099:
1.184 rillig 3100: The general rule to follow is: instead of checking for the operating system the
3101: application is being built on, check for the specific features you need. For
3102: example, instead of assuming that kqueue is available under NetBSD and using
3103: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
1.266 martin 3104: kqueue itself yes, this generally involves patching the configure script.
1.184 rillig 3105: There is absolutely nothing that prevents some OSes from adopting interfaces
3106: from other OSes (e.g. Linux implementing kqueue), something that the above
3107: checks cannot take into account.
1.1 dsieger 3108:
1.184 rillig 3109: Of course, checking for features generally involves more work on the
3110: developer's side, but the resulting changes are cleaner and there are chances
3111: they will work on many other platforms. Not to mention that there are higher
3112: chances of being later integrated into the mainstream sources. Remember: It
3113: doesn't work unless it is right!
1.1 dsieger 3114:
1.184 rillig 3115: Some typical examples:
1.121 sevan 3116:
1.266 martin 3117: Table 12.1. Patching examples
1.1 dsieger 3118:
1.184 rillig 3119: +-------------------------------------------------------------------------------------------+
3120: | Where | Incorrect | Correct |
3121: |---------+--------------------------+------------------------------------------------------|
3122: | |case ${target_os} in | |
3123: |configure|netbsd*) have_kvm=yes ;; |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
3124: |script |*) have_kvm=no ;; | |
3125: | |esac | |
3126: |---------+--------------------------+------------------------------------------------------|
3127: |C source |#if defined(__NetBSD__) |#if defined(HAVE_SYS_EVENT_H) |
3128: |file |# include <sys/event.h> |# include <sys/event.h> |
3129: | |#endif |#endif |
3130: |---------+--------------------------+------------------------------------------------------|
3131: | |int |int |
3132: | |monitor_file(...) |monitor_file(...) |
3133: | |{ |{ |
3134: | |#if defined(__NetBSD__) |#if defined(HAVE_KQUEUE) |
3135: |C source | int fd = kqueue();| int fd = kqueue(); |
3136: |file | ... | ... |
3137: | |#else |#else |
3138: | | ... | ... |
3139: | |#endif |#endif |
3140: | |} |} |
3141: +-------------------------------------------------------------------------------------------+
1.1 dsieger 3142:
3143:
1.266 martin 3144: 12.3.5. Feedback to the author
1.1 dsieger 3145:
1.184 rillig 3146: Always, always, always feed back any portability fixes or improvements you do
3147: to a package to the mainstream developers. This is the only way to get their
3148: attention on portability issues and to ensure that future versions can be built
3149: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
3150: get the fixes straight from the packaged code.
1.1 dsieger 3151:
1.184 rillig 3152: This generally involves cleaning up the patches (because sometimes the patches
3153: that are added to pkgsrc are quick hacks), filing bug reports in the
3154: appropriate trackers for the projects and working with the mainstream authors
3155: to accept your changes. It is extremely important that you do it so that the
3156: packages in pkgsrc are kept simple and thus further changes can be done without
3157: much hassle.
1.1 dsieger 3158:
1.184 rillig 3159: When you have done this, please add a URL to the upstream bug report to the
3160: patch comment.
1.1 dsieger 3161:
1.184 rillig 3162: Support the idea of free software!
1.1 dsieger 3163:
1.266 martin 3164: 12.4. Other mandatory files
1.1 dsieger 3165:
1.184 rillig 3166: DESCR
1.1 dsieger 3167:
1.184 rillig 3168: A multi-line description of the piece of software. This should include any
3169: credits where they are due. Please bear in mind that others do not share
3170: your sense of humour (or spelling idiosyncrasies), and that others will
3171: read everything that you write here.
1.1 dsieger 3172:
1.184 rillig 3173: PLIST
1.1 dsieger 3174:
1.184 rillig 3175: This file governs the files that are installed on your system: all the
3176: binaries, manual pages, etc. There are other directives which may be
3177: entered in this file, to control the creation and deletion of directories,
1.266 martin 3178: and the location of inserted files. See Chapter 19, PLIST issues for more
1.184 rillig 3179: information.
1.1 dsieger 3180:
1.266 martin 3181: 12.5. Optional files
1.1 dsieger 3182:
1.266 martin 3183: 12.5.1. Files affecting the binary package
1.1 dsieger 3184:
1.184 rillig 3185: INSTALL
1.1 dsieger 3186:
1.184 rillig 3187: This shell script is invoked twice by pkg_add(1). First time after package
3188: extraction and before files are moved in place, the second time after the
3189: files to install are moved in place. This can be used to do any custom
3190: procedures not possible with @exec commands in PLIST. See pkg_add(1) and
1.266 martin 3191: pkg_create(1) for more information. See also Section 20.1, Files and
3192: directories outside the installation prefix . Please note that you can
1.184 rillig 3193: modify variables in it easily by using FILES_SUBST in the package's
3194: Makefile:
1.1 dsieger 3195:
1.184 rillig 3196: FILES_SUBST+= SOMEVAR="somevalue"
1.1 dsieger 3197:
1.266 martin 3198: replaces "@SOMEVAR@" with somevalue in the INSTALL. By default,
1.184 rillig 3199: substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
3200: few others, type make help topic=FILES_SUBST for a complete list.
1.1 dsieger 3201:
1.184 rillig 3202: DEINSTALL
1.1 dsieger 3203:
1.184 rillig 3204: This script is executed before and after any files are removed. It is this
3205: script's responsibility to clean up any additional messy details around the
3206: package's installation, since all pkg_delete knows is how to delete the
3207: files created in the original distribution. See pkg_delete(1) and
3208: pkg_create(1) for more information. The same methods to replace variables
3209: can be used as for the INSTALL file.
1.1 dsieger 3210:
1.184 rillig 3211: MESSAGE
1.1 dsieger 3212:
1.198 leot 3213: This file is displayed after installation of the package. While this was
3214: used often in the past, it has two problems: the display will be missed if
1.257 jkoshy 3215: many packages are installed at once, and the person installing the package
1.198 leot 3216: and the one using or configuring it may be different. It should therefore
3217: be used only in exceptional circumstances where lasting negative
3218: consequences would result from someone not reading it.
3219:
3220: MESSAGE should not be used for:
3221:
1.271 wiz 3222: o exhortations to read the documentation
1.198 leot 3223:
1.271 wiz 3224: o reminders to install rc.d files and set variables
1.198 leot 3225:
1.271 wiz 3226: o anything that should be explained in the installation/configuration
1.198 leot 3227: documentation that should come with the package
3228:
3229: If the documentation provided by upstream needs enhancing, create e.g.
3230: files/README.pkgsrc and install it in the package's documentation
3231: directory.
3232:
3233: Note that MESSAGE is shown for all operating systems and all init systems.
3234: If a MESSAGE is necessary, it should be narrowed to only those operating
3235: systems and init systems to which it applies.
3236:
3237: Note that you can modify variables in it easily by using MESSAGE_SUBST in
3238: the package's Makefile:
1.1 dsieger 3239:
1.184 rillig 3240: MESSAGE_SUBST+= SOMEVAR="somevalue"
1.1 dsieger 3241:
1.266 martin 3242: replaces "${SOMEVAR}" with somevalue in MESSAGE. By default, substitution
1.184 rillig 3243: is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
3244: PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1 dsieger 3245:
1.184 rillig 3246: You can display a different or additional files by setting the MESSAGE_SRC
3247: variable. Its default is MESSAGE, if the file exists.
1.1 dsieger 3248:
1.184 rillig 3249: ALTERNATIVES
1.1 dsieger 3250:
1.184 rillig 3251: This file is used by the alternatives framework. It creates, configures,
3252: and destroys generic wrappers used to run programs with similar interfaces.
3253: See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
3254: information.
1.1 dsieger 3255:
1.184 rillig 3256: Each line of the file contains two filenames, first the wrapper and then
3257: the alternative provided by the package. Both paths are relative to PREFIX.
1.1 dsieger 3258:
1.266 martin 3259: 12.5.2. Files affecting the build process
1.1 dsieger 3260:
1.184 rillig 3261: Makefile.common
1.1 dsieger 3262:
1.184 rillig 3263: This file contains arbitrary things that could also go into a Makefile, but
3264: its purpose is to be used by more than one package. This file should only
3265: be used when the packages that will use the file are known in advance. For
3266: other purposes it is often better to write a *.mk file and give it a good
3267: name that describes what it does.
1.1 dsieger 3268:
1.184 rillig 3269: buildlink3.mk
1.1 dsieger 3270:
1.184 rillig 3271: This file contains the dependency information for the buildlink3 framework
1.266 martin 3272: (see Chapter 18, Buildlink methodology).
1.1 dsieger 3273:
1.184 rillig 3274: hacks.mk
1.1 dsieger 3275:
1.184 rillig 3276: This file contains workarounds for compiler bugs and similar things. It is
3277: included automatically by the pkgsrc infrastructure, so you don't need an
3278: extra .include line for it.
1.1 dsieger 3279:
1.184 rillig 3280: options.mk
1.1 dsieger 3281:
1.184 rillig 3282: This file contains the code for the package-specific options (see
1.266 martin 3283: Chapter 16, Options handling) that can be selected by the user. If a
1.184 rillig 3284: package has only one or two options, it is equally acceptable to put the
3285: code directly into the Makefile.
1.1 dsieger 3286:
1.266 martin 3287: 12.5.3. Files affecting nothing at all
1.1 dsieger 3288:
1.184 rillig 3289: README*
1.1 dsieger 3290:
1.184 rillig 3291: These files do not take place in the creation of a package and thus are
3292: purely informative to the package developer.
1.1 dsieger 3293:
1.184 rillig 3294: TODO
1.1 dsieger 3295:
1.184 rillig 3296: This file contains things that need to be done to make the package even
3297: better.
1.1 dsieger 3298:
1.266 martin 3299: 12.6. work*
1.1 dsieger 3300:
1.184 rillig 3301: When you type make, the distribution files are unpacked into the directory
3302: denoted by WRKDIR. It can be removed by running make clean. Besides the
3303: sources, this directory is also used to keep various timestamp files. The
3304: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
3305: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
1.1 dsieger 3306:
1.266 martin 3307: 12.7. files/*
1.80 wiz 3308:
1.184 rillig 3309: If you have any files that you wish to be placed in the package prior to
3310: configuration or building, you can place these files here and use a ${CP}
1.266 martin 3311: command in the post-extract target to achieve this.
1.1 dsieger 3312:
1.184 rillig 3313: If you want to share files in this way with other packages, set the FILESDIR
3314: variable to point to the other package's files directory, e.g.:
1.1 dsieger 3315:
1.184 rillig 3316: FILESDIR= ../../editors/xemacs/files
1.14 jmcneill 3317:
1.266 martin 3318: Chapter 13. The build process
1.1 dsieger 3319:
1.184 rillig 3320: Table of Contents
1.1 dsieger 3321:
1.184 rillig 3322: 13.1. Introduction
3323: 13.2. Program location
3324: 13.3. Directories used during the build process
3325: 13.4. Running a phase
3326: 13.5. The fetch phase
3327: 13.5.1. What to fetch and where to get it from
3328: 13.5.2. How are the files fetched?
3329: 13.6. The checksum phase
3330: 13.7. The extract phase
3331: 13.8. The patch phase
3332: 13.9. The tools phase
3333: 13.10. The wrapper phase
3334: 13.11. The configure phase
3335: 13.12. The build phase
3336: 13.13. The test phase
3337: 13.14. The install phase
3338: 13.15. The package phase
3339: 13.16. Cleaning up
3340: 13.17. Other helpful targets
1.1 dsieger 3341:
1.266 martin 3342: 13.1. Introduction
1.122 leot 3343:
1.184 rillig 3344: This chapter gives a detailed description on how a package is built. Building a
3345: package is separated into different phases (for example fetch, build, install),
3346: all of which are described in the following sections. Each phase is split into
3347: so-called stages, which take the name of the containing phase, prefixed by one
3348: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
3349: actual work is done in the do-* stages.
1.1 dsieger 3350:
1.184 rillig 3351: Never override the regular targets (like fetch), if you have to, override the
3352: do-* ones instead.
1.1 dsieger 3353:
1.184 rillig 3354: The basic steps for building a program are always the same. First the program's
3355: source (distfile) must be brought to the local system and then extracted. After
3356: any pkgsrc-specific patches to compile properly are applied, the software can
3357: be configured, then built (usually by compiling), and finally the generated
3358: binaries, etc. can be put into place on the system.
1.1 dsieger 3359:
1.184 rillig 3360: To get more details about what is happening at each step, you can set the
3361: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
3362: more details about the patch step.
1.1 dsieger 3363:
1.266 martin 3364: 13.2. Program location
1.1 dsieger 3365:
1.184 rillig 3366: Before outlining the process performed by the NetBSD package system in the next
3367: section, here's a brief discussion on where programs are installed, and which
3368: variables influence this.
1.1 dsieger 3369:
1.184 rillig 3370: The automatic variable PREFIX indicates where all files of the final program
3371: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
3372: pkgs in the cross category. The value of PREFIX needs to be put into the
3373: various places in the program's source where paths to these files are encoded.
1.266 martin 3374: See Section 12.3, patches/* and Section 21.3.1, Shared libraries - libtool
1.184 rillig 3375: for more details.
1.1 dsieger 3376:
1.184 rillig 3377: When choosing which of these variables to use, follow the following rules:
1.1 dsieger 3378:
1.184 rillig 3379: * PREFIX always points to the location where the current pkg will be
1.266 martin 3380: installed. When referring to a pkg's own installation path, use ${PREFIX}
1.184 rillig 3381: .
1.1 dsieger 3382:
1.223 nia 3383: * LOCALBASE is where all pkgs are installed. If you need to construct a -I or
3384: -L argument to the compiler to find includes and libraries installed by
1.266 martin 3385: another pkg, use ${LOCALBASE} . The name LOCALBASE stems from FreeBSD,
1.223 nia 3386: which installed all packages in /usr/local. As pkgsrc leaves /usr/local for
3387: the system administrator, this variable is a misnomer.
1.1 dsieger 3388:
1.184 rillig 3389: * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
3390: installed. When looking for standard X11 includes (not those installed by a
1.266 martin 3391: package), use ${X11BASE} .
1.1 dsieger 3392:
1.184 rillig 3393: * X11-based packages using imake must set USE_IMAKE to be installed correctly
3394: under LOCALBASE.
1.1 dsieger 3395:
1.184 rillig 3396: * Within ${PREFIX}, packages should install files according to hier(7), with
3397: the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
3398: man.
1.1 dsieger 3399:
1.266 martin 3400: 13.3. Directories used during the build process
1.2 rillig 3401:
1.184 rillig 3402: When building a package, various directories are used to store source files,
3403: temporary files, pkgsrc-internal files, and so on. These directories are
3404: explained here.
1.1 dsieger 3405:
1.184 rillig 3406: Some of the directory variables contain relative pathnames. There are two
3407: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
3408: used for directories that are pkgsrc-specific. WRKSRC is used for directories
3409: inside the package itself.
1.1 dsieger 3410:
1.184 rillig 3411: PKGSRCDIR
1.1 dsieger 3412:
1.184 rillig 3413: This is an absolute pathname that points to the pkgsrc root directory.
3414: Generally, you don't need it.
1.1 dsieger 3415:
1.184 rillig 3416: PKGDIR
1.1 dsieger 3417:
1.184 rillig 3418: This is an absolute pathname that points to the current package.
1.1 dsieger 3419:
1.184 rillig 3420: PKGPATH
1.1 dsieger 3421:
1.184 rillig 3422: This is a pathname relative to PKGSRCDIR that points to the current
1.228 gutterid 3423: package. It is defined after including bsd.prefs.mk and can be used in
3424: makefile fragments that are used by several packages to distinguish between
3425: these packages. Other variables that would serve the same purpose are
3426: PKGBASE and PKGNAME, but these are only defined after including bsd.pkg.mk,
3427: which is too late.
3428:
3429: In mk.conf, the pkgsrc user can use PKGPATH to tweak variables like
3430: MAKE_JOBS and CFLAGS.
1.1 dsieger 3431:
1.184 rillig 3432: WRKDIR
1.1 dsieger 3433:
1.184 rillig 3434: This is an absolute pathname pointing to the directory where all work takes
3435: place. The distfiles are extracted to this directory. It also contains
3436: temporary directories and log files used by the various pkgsrc frameworks,
3437: like buildlink or the wrappers.
1.1 dsieger 3438:
1.184 rillig 3439: WRKSRC
1.1 dsieger 3440:
1.184 rillig 3441: This is an absolute pathname pointing to the directory where the distfiles
3442: are extracted. It is usually a direct subdirectory of WRKDIR, and often
3443: it's the only directory entry that isn't hidden. This variable may be
3444: changed by a package Makefile.
1.1 dsieger 3445:
1.184 rillig 3446: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
3447: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
3448: created in the pkgsrc entry's directory. If users would like to have their
3449: pkgsrc trees behave in a read-only manner, then the value of
3450: CREATE_WRKDIR_SYMLINK should be set to no.
1.1 dsieger 3451:
1.266 martin 3452: 13.4. Running a phase
1.1 dsieger 3453:
1.184 rillig 3454: You can run a particular phase by typing make phase, where phase is the name of
3455: the phase. This will automatically run all phases that are required for this
3456: phase. The default phase is build, that is, when you run make without
3457: parameters in a package directory, the package will be built, but not
3458: installed.
1.1 dsieger 3459:
1.266 martin 3460: 13.5. The fetch phase
1.1 dsieger 3461:
1.184 rillig 3462: The first step in building a package is to fetch the distribution files
3463: (distfiles) from the sites that are providing them. This is the task of the
3464: fetch phase.
1.25 wiz 3465:
1.266 martin 3466: 13.5.1. What to fetch and where to get it from
1.1 dsieger 3467:
1.184 rillig 3468: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
3469: name is derived from the DISTNAME variable, is fetched. The more complicated
3470: cases are described below.
1.1 dsieger 3471:
1.184 rillig 3472: The variable DISTFILES specifies the list of distfiles that have to be fetched.
3473: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
3474: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
3475: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
3476: your package requires additional distfiles to the default one, you cannot just
3477: append the additional filenames using the += operator, but you have write for
3478: example:
1.1 dsieger 3479:
1.184 rillig 3480: DISTFILES= ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1 dsieger 3481:
1.184 rillig 3482: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
3483: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
3484: can set SITES.distfile to the list of URLs where the file distfile (including
3485: the suffix) can be found.
1.1 dsieger 3486:
1.184 rillig 3487: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
3488: DISTFILES+= foo-file.tar.gz
3489: SITES.foo-file.tar.gz= \
3490: https://www.somewhere.com/somehow/ \
3491: https://www.somewhereelse.com/mirror/somehow/
1.1 dsieger 3492:
1.184 rillig 3493: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
3494: gets the name of each distfile appended to it, without an intermediate slash.
3495: Therefore, all site values have to end with a slash or other separator
3496: character. This allows for example to set MASTER_SITES to a URL of a CGI script
3497: that gets the name of the distfile as a parameter. In this case, the definition
3498: would look like:
1.1 dsieger 3499:
1.184 rillig 3500: MASTER_SITES= https://www.example.com/download.cgi?file=
1.1 dsieger 3501:
1.184 rillig 3502: The exception to this rule are URLs starting with a dash. In that case the URL
3503: is taken as is, fetched and the result stored under the name of the distfile.
3504: You can use this style for the case when the download URL style does not match
3505: the above common case. For example, if permanent download URL is a redirector
3506: to the real download URL, or the download file name is offered by an HTTP
3507: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
3508: created instead of the default v1.0.0.tar.gz.
1.1 dsieger 3509:
1.184 rillig 3510: DISTNAME= foo-1.0.0
3511: MASTER_SITES= -https://www.example.com/archive/v1.0.0.tar.gz
1.29 wiz 3512:
1.184 rillig 3513: There are some predefined values for MASTER_SITES, which can be used in
3514: packages. The names of the variables should speak for themselves.
1.29 wiz 3515:
1.260 wiz 3516: MASTER_SITE_APACHE MASTER_SITE_BACKUP
3517: MASTER_SITE_CRATESIO MASTER_SITE_CYGWIN
3518: MASTER_SITE_DEBIAN MASTER_SITE_FREEBSD
3519: MASTER_SITE_FREEBSD_LOCAL MASTER_SITE_GENTOO
3520: MASTER_SITE_GITHUB MASTER_SITE_GITLAB
3521: MASTER_SITE_GNOME MASTER_SITE_GNU
3522: MASTER_SITE_GNUPG MASTER_SITE_GNUSTEP
3523: MASTER_SITE_HASKELL_HACKAGE MASTER_SITE_IFARCHIVE
3524: MASTER_SITE_KDE MASTER_SITE_MOZILLA
3525: MASTER_SITE_MOZILLA_ALL MASTER_SITE_MYSQL
3526: MASTER_SITE_NETLIB MASTER_SITE_OPENBSD
3527: MASTER_SITE_OPENOFFICE MASTER_SITE_OSDN
3528: MASTER_SITE_PERL_CPAN MASTER_SITE_PGSQL
3529: MASTER_SITE_PYPI MASTER_SITE_RUBYGEMS
3530: MASTER_SITE_R_CRAN MASTER_SITE_SOURCEFORGE
3531: MASTER_SITE_SUNSITE MASTER_SITE_SUSE
3532: MASTER_SITE_TEX_CTAN MASTER_SITE_XCONTRIB
3533: MASTER_SITE_XEMACS MASTER_SITE_XORG
1.1 dsieger 3534:
1.184 rillig 3535: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
3536: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
3537: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
3538: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
3539: distfiles/LOCAL_PORTS/.
1.1 dsieger 3540:
1.184 rillig 3541: If you choose one of these predefined sites, you may want to specify a
3542: subdirectory of that site. Since these macros may expand to more than one
3543: actual site, you must use the following construct to specify a subdirectory:
1.1 dsieger 3544:
1.184 rillig 3545: MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/}
3546: MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1 dsieger 3547:
1.184 rillig 3548: Note the trailing slash after the subdirectory name.
1.1 dsieger 3549:
1.266 martin 3550: 13.5.2. How are the files fetched?
1.1 dsieger 3551:
1.184 rillig 3552: The fetch phase makes sure that all the distfiles exist in a local directory
3553: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
3554: are fetched using commands of the form
1.1 dsieger 3555:
1.184 rillig 3556: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
1.1 dsieger 3557:
1.184 rillig 3558: where ${site} varies through several possibilities in turn: first,
3559: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
3560: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
3561: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
3562: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
3563: MASTER_SORT_AWK or MASTER_SORT_REGEX.
1.1 dsieger 3564:
1.184 rillig 3565: The specific command and arguments used depend on the FETCH_USING parameter.
3566: The example above is for FETCH_USING=custom.
1.66 asau 3567:
1.184 rillig 3568: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
3569: target to mirror the distfiles, if they are freely distributable. Packages
1.266 martin 3570: setting NO_SRC_ON_FTP (usually to ${RESTRICTED} ) will not have their
1.184 rillig 3571: distfiles mirrored.
1.1 dsieger 3572:
1.266 martin 3573: 13.6. The checksum phase
1.1 dsieger 3574:
1.184 rillig 3575: After the distfile(s) are fetched, their checksum is generated and compared
3576: with the checksums stored in the distinfo file. If the checksums don't match,
3577: the build is aborted. This is to ensure the same distfile is used for building,
3578: and that the distfile wasn't changed, e.g. by some malign force, deliberately
3579: changed distfiles on the master distribution site or network lossage.
1.1 dsieger 3580:
1.266 martin 3581: 13.7. The extract phase
1.1 dsieger 3582:
1.184 rillig 3583: When the distfiles are present on the local system, they need to be extracted,
3584: as they usually come in the form of some compressed archive format.
1.1 dsieger 3585:
1.184 rillig 3586: By default, all DISTFILES are extracted. If you only need some of them, you can
3587: set the EXTRACT_ONLY variable to the list of those files.
1.1 dsieger 3588:
1.184 rillig 3589: Extracting the files is usually done by a little program, mk/extract/extract,
3590: which already knows how to extract various archive formats, so most likely you
3591: will not need to change anything here. But if you need, the following variables
3592: may help you:
1.1 dsieger 3593:
1.184 rillig 3594: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
1.1 dsieger 3595:
1.184 rillig 3596: Use these variables to override the default options for an extract command,
3597: which are defined in mk/extract/extract.
1.1 dsieger 3598:
1.184 rillig 3599: EXTRACT_USING
1.1 dsieger 3600:
1.184 rillig 3601: This variable can be set to bsdtar, gtar, nbtar (which is the default
3602: value), pax, or an absolute pathname pointing to the command with which tar
3603: archives should be extracted. It is preferred to choose bsdtar over gtar if
3604: NetBSD's pax-as-tar is not good enough.
1.1 dsieger 3605:
1.184 rillig 3606: If the extract program doesn't serve your needs, you can also override the
3607: EXTRACT_CMD variable, which holds the command used for extracting the files.
3608: This command is executed in the ${WRKSRC} directory. During execution of this
3609: command, the shell variable extract_file holds the absolute pathname of the
3610: file that is going to be extracted.
1.1 dsieger 3611:
1.184 rillig 3612: And if that still does not suffice, you can override the do-extract target in
3613: the package Makefile.
1.1 dsieger 3614:
1.266 martin 3615: 13.8. The patch phase
1.1 dsieger 3616:
1.184 rillig 3617: After extraction, all the patches named by the PATCHFILES, those present in the
3618: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
3619: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
3620: are uncompressed before they are applied, files ending in .orig or .rej are
3621: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
1.266 martin 3622: Section 12.3, patches/* for more details.
1.1 dsieger 3623:
1.184 rillig 3624: By default patch(1) is given special arguments to make it fail if the expected
3625: text from the patch context is not found in the patched file. If that happens,
3626: fix the patch file by comparing it with the actual text in the file to be
3627: patched.
1.1 dsieger 3628:
1.266 martin 3629: 13.9. The tools phase
1.1 dsieger 3630:
1.266 martin 3631: This is covered in Chapter 17, Tools needed for building or running.
1.1 dsieger 3632:
1.266 martin 3633: 13.10. The wrapper phase
1.1 dsieger 3634:
1.184 rillig 3635: This phase creates wrapper programs for the compilers and linkers. The
3636: following variables can be used to tweak the wrappers.
1.1 dsieger 3637:
1.184 rillig 3638: ECHO_WRAPPER_MSG
1.1 dsieger 3639:
1.184 rillig 3640: The command used to print progress messages. Does nothing by default. Set
3641: to ${ECHO} to see the progress messages.
1.1 dsieger 3642:
1.184 rillig 3643: WRAPPER_DEBUG
1.1 dsieger 3644:
1.184 rillig 3645: This variable can be set to yes (default) or no, depending on whether you
3646: want additional information in the wrapper log file.
1.1 dsieger 3647:
1.184 rillig 3648: WRAPPER_UPDATE_CACHE
1.1 dsieger 3649:
1.184 rillig 3650: This variable can be set to yes or no, depending on whether the wrapper
3651: should use its cache, which will improve the speed. The default value is
3652: yes, but is forced to no if the platform does not support it.
1.1 dsieger 3653:
1.184 rillig 3654: WRAPPER_REORDER_CMDS
1.1 dsieger 3655:
1.184 rillig 3656: A list of reordering commands. A reordering command has the form reorder:l:
3657: lib1:lib2. It ensures that that -llib1 occurs before -llib2.
1.1 dsieger 3658:
1.266 martin 3659: 13.11. The configure phase
1.1 dsieger 3660:
1.184 rillig 3661: Most pieces of software need information on the header files, system calls, and
3662: library routines which are available on the platform they run on. The process
3663: of determining this information is known as configuration, and is usually
3664: automated. In most cases, a script is supplied with the distfiles, and its
3665: invocation results in generation of header files, Makefiles, etc.
1.1 dsieger 3666:
1.184 rillig 3667: If the package contains a configure script, this can be invoked by setting
1.266 martin 3668: HAS_CONFIGURE to yes . If the configure script is a GNU autoconf script, you
3669: should set GNU_CONFIGURE to yes instead.
1.1 dsieger 3670:
1.187 rillig 3671: In the do-configure stage, a rough equivalent of the following command is run.
3672: See mk/configure/configure.mk, target do-configure-script for the exact
3673: definition.
3674:
3675: .for dir in ${CONFIGURE_DIRS}
3676: cd ${WRKSRC} && cd ${dir} \
3677: && env ${CONFIGURE_ENV} \
3678: ${CONFIG_SHELL} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
1.184 rillig 3679: .endfor
1.1 dsieger 3680:
1.266 martin 3681: CONFIGURE_DIRS (default: . ) is a list of pathnames relative to WRKSRC. In
1.184 rillig 3682: each of these directories, the configure script is run with the environment
3683: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
1.266 martin 3684: CONFIGURE_SCRIPT (default: ./configure ) and CONFIGURE_ARGS may all be changed
1.184 rillig 3685: by the package.
1.1 dsieger 3686:
1.184 rillig 3687: If the program uses the Perl way of configuration (mainly Perl modules, but not
3688: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
3689: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
3690: (e.g., MAKE_PARAMS+=foo=bar
1.1 dsieger 3691:
1.184 rillig 3692: If the program uses an Imakefile for configuration, the appropriate steps can
1.266 martin 3693: be invoked by setting USE_IMAKE to yes . If you only need xmkmf, add it to
1.184 rillig 3694: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
3695: SCRIPTS_ENV variable.
1.1 dsieger 3696:
1.184 rillig 3697: If the program uses cmake for configuration, the appropriate steps can be
1.233 wiz 3698: invoked by including ../../devel/cmake/build.mk. You can add variables to
3699: cmake's environment by adding them to the CONFIGURE_ENV variable and arguments
1.256 wiz 3700: to cmake by adding them to the CMAKE_CONFIGURE_ARGS variable. If you want to
3701: add arguments only for particular stages, you can use the CMAKE_CONFIGURE_ARGS,
1.233 wiz 3702: CMAKE_BUILD_ARGS, and CMAKE_INSTALL_ARGS variables. You can set the
3703: CONFIGURE_DIRS variable to the directories in which CMake should be run,
1.266 martin 3704: relative to WRKSRC. This defaults to to . .
1.1 dsieger 3705:
1.256 wiz 3706: Any package using the now-deprecated USE_CMAKE=yes should be converted.
3707: Essentially, replace with an include of ../../devel/cmake/build.mk, prune
3708: creation of a build directory and settings to use it, and check/fix settings
3709: that intend to perform the build in a subdirectory.
3710:
1.266 martin 3711: If there is no configure step at all, set NO_CONFIGURE to yes .
1.1 dsieger 3712:
1.266 martin 3713: 13.12. The build phase
1.1 dsieger 3714:
1.187 rillig 3715: For building a package, a rough equivalent of the following code is executed;
3716: see mk/build/build.mk, target do-build for the exact definition.
1.154 rillig 3717:
1.187 rillig 3718: .for dir in ${BUILD_DIRS}
3719: cd ${WRKSRC} && cd ${dir} \
1.184 rillig 3720: && env ${MAKE_ENV} \
1.187 rillig 3721: ${MAKE_PROGRAM} ${MAKE_FLAGS} ${BUILD_MAKE_FLAGS} \
1.184 rillig 3722: -f ${MAKE_FILE} \
3723: ${BUILD_TARGET}
3724: .endfor
1.1 dsieger 3725:
1.266 martin 3726: BUILD_DIRS (default: . ) is a list of pathnames relative to WRKSRC. In each of
1.184 rillig 3727: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
3728: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
3729: and BUILD_TARGET may all be changed by the package.
1.1 dsieger 3730:
1.266 martin 3731: The default value of MAKE_PROGRAM is gmake if USE_TOOLS contains gmake ,
3732: make otherwise. The default value of MAKE_FILE is Makefile , and BUILD_TARGET
3733: defaults to all .
1.1 dsieger 3734:
1.266 martin 3735: If there is no build step at all, set NO_BUILD to yes .
1.1 dsieger 3736:
1.266 martin 3737: 13.13. The test phase
1.1 dsieger 3738:
1.273 wiz 3739: The test phase is for running a program's self tests. Dependencies that are
3740: only required for testing can be specified using TEST_DEPENDS.
3741:
3742: For packages using make(1) for building, you can set TEST_TARGET. Often, the
3743: proper value is check or test . If more elaborate steps are needed, you can
3744: define a do-test target.
3745:
3746: To run the tests, call make test .
3747:
3748: When building a package, the tests are not run automatically, except if
3749: PKGSRC_RUN_TEST is set to yes .
1.1 dsieger 3750:
1.266 martin 3751: 13.14. The install phase
1.1 dsieger 3752:
1.184 rillig 3753: Once the build stage has completed, the final step is to install the software
3754: in public directories, so users can access the programs and files.
1.1 dsieger 3755:
1.187 rillig 3756: In the install phase, a rough equivalent of the following code is executed; see
3757: mk/install/install.mk, target do-install for the exact definition.
3758: Additionally, before and after this code, several consistency checks are run
3759: against the files-to-be-installed, see mk/check/*.mk for details.
3760:
3761: .for dir in ${INSTALL_DIRS}
3762: cd ${WRKSRC} && cd ${dir} \
3763: && env ${INSTALL_ENV} ${MAKE_ENV} \
3764: ${MAKE_PROGRAM} ${MAKE_FLAGS} ${INSTALL_MAKE_FLAGS} \
3765: -f ${MAKE_FILE} ${INSTALL_TARGET}
1.184 rillig 3766: .endfor
1.1 dsieger 3767:
1.184 rillig 3768: The variable's meanings are analogous to the ones in the build phase.
1.266 martin 3769: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is install by default,
3770: plus install.man if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
1.184 rillig 3771: defined.
1.1 dsieger 3772:
1.184 rillig 3773: In the install phase, the following variables are useful. They are all
3774: variations of the install(1) command that have the owner, group and permissions
3775: preset. INSTALL is the plain install command. The specialized variants,
3776: together with their intended use, are:
1.1 dsieger 3777:
1.184 rillig 3778: INSTALL_PROGRAM_DIR
1.1 dsieger 3779:
1.184 rillig 3780: directories that contain binaries
1.1 dsieger 3781:
1.184 rillig 3782: INSTALL_SCRIPT_DIR
1.1 dsieger 3783:
1.184 rillig 3784: directories that contain scripts
1.1 dsieger 3785:
1.184 rillig 3786: INSTALL_LIB_DIR
1.1 dsieger 3787:
1.184 rillig 3788: directories that contain shared and static libraries
1.1 dsieger 3789:
1.184 rillig 3790: INSTALL_DATA_DIR
1.108 rillig 3791:
1.184 rillig 3792: directories that contain data files
1.108 rillig 3793:
1.184 rillig 3794: INSTALL_MAN_DIR
1.108 rillig 3795:
1.184 rillig 3796: directories that contain man pages
1.108 rillig 3797:
1.184 rillig 3798: INSTALL_GAME_DIR
1.108 rillig 3799:
1.184 rillig 3800: directories that contain data files for games
1.108 rillig 3801:
1.184 rillig 3802: INSTALL_PROGRAM
1.108 rillig 3803:
1.184 rillig 3804: binaries that can be stripped from debugging symbols
1.108 rillig 3805:
1.184 rillig 3806: INSTALL_SCRIPT
1.108 rillig 3807:
1.184 rillig 3808: binaries that cannot be stripped
1.108 rillig 3809:
1.184 rillig 3810: INSTALL_GAME
1.108 rillig 3811:
1.184 rillig 3812: game binaries
1.108 rillig 3813:
1.184 rillig 3814: INSTALL_LIB
1.108 rillig 3815:
1.184 rillig 3816: shared and static libraries
1.108 rillig 3817:
1.184 rillig 3818: INSTALL_DATA
1.108 rillig 3819:
1.184 rillig 3820: data files
1.1 dsieger 3821:
1.184 rillig 3822: INSTALL_GAME_DATA
1.1 dsieger 3823:
1.184 rillig 3824: data files for games
1.108 rillig 3825:
1.184 rillig 3826: INSTALL_MAN
1.108 rillig 3827:
1.184 rillig 3828: man pages
1.1 dsieger 3829:
1.184 rillig 3830: Some other variables are:
1.1 dsieger 3831:
1.184 rillig 3832: INSTALL_UNSTRIPPED
1.1 dsieger 3833:
1.184 rillig 3834: If set to yes, do not run strip(1) when installing binaries. Any debugging
3835: sections and symbols present in binaries will be preserved.
1.1 dsieger 3836:
1.184 rillig 3837: INSTALLATION_DIRS
1.1 dsieger 3838:
1.184 rillig 3839: A list of directories relative to PREFIX that are created by pkgsrc at the
3840: beginning of the install phase. The package is supposed to create all
3841: needed directories itself before installing files to it and list all other
3842: directories here.
1.1 dsieger 3843:
1.184 rillig 3844: In the rare cases that a package shouldn't install anything, set NO_INSTALL to
1.266 martin 3845: yes . This is mostly relevant for packages in the regress category.
1.1 dsieger 3846:
1.266 martin 3847: 13.15. The package phase
1.121 sevan 3848:
1.184 rillig 3849: Once the install stage has completed, a binary package of the installed files
3850: can be built. These binary packages can be used for quick installation without
3851: previous compilation, e.g. by the make bin-install or by using pkg_add.
1.1 dsieger 3852:
1.184 rillig 3853: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
3854: created in ${PACKAGES}/category, one for each category in the CATEGORIES
3855: variable. PACKAGES defaults to pkgsrc/packages.
1.1 dsieger 3856:
1.266 martin 3857: 13.16. Cleaning up
1.1 dsieger 3858:
1.184 rillig 3859: Once you're finished with a package, you can clean the work directory by
3860: running make clean. If you want to clean the work directories of all
3861: dependencies too, use make clean-depends.
1.1 dsieger 3862:
1.266 martin 3863: 13.17. Other helpful targets
1.1 dsieger 3864:
1.184 rillig 3865: pre/post-*
1.1 dsieger 3866:
1.184 rillig 3867: For any of the main targets described in the previous section (configure,
1.266 martin 3868: build, install, etc.), two auxiliary targets exist with pre- and post-
1.184 rillig 3869: used as a prefix for the main target's name. These targets are invoked
3870: before and after the main target is called, allowing extra configuration or
3871: installation steps be performed from a package's Makefile, for example,
3872: which a program's configure script or install target omitted.
3873:
3874: About 5% of the pkgsrc packages define their custom post-extract target,
3875: another 5% define pre-configure, and 10% define post-install. The other pre
3876: /post-* targets are defined even less often.
1.1 dsieger 3877:
1.184 rillig 3878: do-*
1.182 leot 3879:
1.184 rillig 3880: Should one of the main targets do the wrong thing, and should there be no
3881: variable to fix this, you can redefine it with the do-* target. (Note that
3882: redefining the target itself instead of the do-* target is a bad idea, as
3883: the pre-* and post-* targets won't be called anymore, etc.)
1.1 dsieger 3884:
1.184 rillig 3885: About 15% of the pkgsrc packages override the default do-install, the other
3886: do-* targets are overridden even less often.
1.1 dsieger 3887:
1.184 rillig 3888: reinstall
1.1 dsieger 3889:
1.184 rillig 3890: If you did a make install and you noticed some file was not installed
3891: properly, you can repeat the installation with this target, which will
1.266 martin 3892: ignore the already installed flag.
1.1 dsieger 3893:
1.184 rillig 3894: This is the default value of DEPENDS_TARGET except in the case of make
1.266 martin 3895: update and make package, where the defaults are package and update ,
1.184 rillig 3896: respectively.
1.1 dsieger 3897:
1.184 rillig 3898: deinstall
1.1 dsieger 3899:
1.184 rillig 3900: This target does a pkg_delete(1) in the current directory, effectively
3901: de-installing the package. The following variables can be used to tune the
3902: behaviour:
1.1 dsieger 3903:
1.184 rillig 3904: PKG_VERBOSE
1.1 dsieger 3905:
1.184 rillig 3906: Add a "-v" to the pkg_delete(1) command.
1.1 dsieger 3907:
1.184 rillig 3908: DEINSTALLDEPENDS
1.1 dsieger 3909:
1.184 rillig 3910: Remove all packages that require (depend on) the given package. This
3911: can be used to remove any packages that may have been pulled in by a
3912: given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
1.266 martin 3913: pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding -R
3914: to the pkg_delete(1) command line.
1.1 dsieger 3915:
1.184 rillig 3916: bin-install
1.1 dsieger 3917:
1.184 rillig 3918: Install a binary package from local disk and via FTP from a list of sites
3919: (see the BINPKG_SITES variable), and do a make package if no binary package
3920: is available anywhere. The arguments given to pkg_add can be set via
3921: BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
1.1 dsieger 3922:
1.184 rillig 3923: install-clean
1.1 dsieger 3924:
1.184 rillig 3925: This target removes the state files for the "install" and later phases so
3926: that the "install" target may be re-invoked. This can be used after editing
3927: the PLIST to install the package without rebuilding it.
1.1 dsieger 3928:
1.184 rillig 3929: build-clean
1.18 mishka 3930:
1.184 rillig 3931: This target removes the state files for the "build" and later phases so
3932: that the "build" target may be re-invoked.
1.18 mishka 3933:
1.184 rillig 3934: update
1.18 mishka 3935:
1.184 rillig 3936: This target causes the current package to be updated to the latest version.
3937: The package and all depending packages first get de-installed, then current
3938: versions of the corresponding packages get compiled and installed. This is
3939: similar to manually noting which packages are currently installed, then
3940: performing a series of make deinstall and make install (or whatever
3941: UPDATE_TARGET is set to) for these packages.
1.18 mishka 3942:
1.266 martin 3943: You can use the update target to resume package updating in case a
1.184 rillig 3944: previous make update was interrupted for some reason. However, in this
3945: case, make sure you don't call make clean or otherwise remove the list of
3946: dependent packages in WRKDIR. Otherwise, you lose the ability to
3947: automatically update the current package along with the dependent packages
3948: you have installed.
1.121 sevan 3949:
1.184 rillig 3950: Resuming an interrupted make update will only work as long as the package
3951: tree remains unchanged. If the source code for one of the packages to be
3952: updated has been changed, resuming make update will most certainly fail!
1.1 dsieger 3953:
1.184 rillig 3954: The following variables can be used either on the command line or in
3955: mk.conf to alter the behaviour of make update:
1.1 dsieger 3956:
1.184 rillig 3957: UPDATE_TARGET
1.1 dsieger 3958:
1.184 rillig 3959: Install target to recursively use for the updated package and the
1.266 martin 3960: dependent packages. Defaults to DEPENDS_TARGET if set, install
3961: otherwise for make update. Other good targets are package or
3962: bin-install . Do not set this to update or you will get stuck in an
1.184 rillig 3963: endless loop!
1.1 dsieger 3964:
1.184 rillig 3965: NOCLEAN
1.1 dsieger 3966:
1.184 rillig 3967: Don't clean up after updating. Useful if you want to leave the work
3968: sources of the updated packages around for inspection or other
1.266 martin 3969: purposes. Be sure you eventually clean up the source tree (see the
3970: clean-update target below) or you may run into troubles with old
1.184 rillig 3971: source code still lying around on your next make or make update.
1.1 dsieger 3972:
1.184 rillig 3973: REINSTALL
1.1 dsieger 3974:
1.184 rillig 3975: Deinstall each package before installing (making DEPENDS_TARGET). This
1.266 martin 3976: may be necessary if the clean-update target (see below) was called
1.184 rillig 3977: after interrupting a running make update.
1.1 dsieger 3978:
1.184 rillig 3979: DEPENDS_TARGET
1.1 dsieger 3980:
1.184 rillig 3981: Allows you to disable recursion and hardcode the target for packages.
1.266 martin 3982: The default is update for the update target, facilitating a recursive
1.184 rillig 3983: update of prerequisite packages. Only set DEPENDS_TARGET if you want to
3984: disable recursive updates. Use UPDATE_TARGET instead to just set a
3985: specific target for each package to be installed during make update
3986: (see above).
1.1 dsieger 3987:
1.184 rillig 3988: clean-update
1.1 dsieger 3989:
1.184 rillig 3990: Clean the source tree for all packages that would get updated if make
3991: update was called from the current directory. This target should not be
3992: used if the current package (or any of its depending packages) have already
3993: been de-installed (e.g., after calling make update) or you may lose some
3994: packages you intended to update. As a rule of thumb: only use this target
3995: before the first time you run make update and only if you have a dirty
3996: package tree (e.g., if you used NOCLEAN).
1.86 wiz 3997:
1.184 rillig 3998: If you are unsure about whether your tree is clean, you can either perform
3999: a make clean at the top of the tree, or use the following sequence of
4000: commands from the directory of the package you want to update (before
4001: running make update for the first time, otherwise you lose all the packages
4002: you wanted to update!):
1.86 wiz 4003:
1.184 rillig 4004: # make clean-update
4005: # make clean CLEANDEPENDS=YES
4006: # make update
1.86 wiz 4007:
4008:
1.184 rillig 4009: The following variables can be used either on the command line or in
4010: mk.conf to alter the behaviour of make clean-update:
1.86 wiz 4011:
1.184 rillig 4012: CLEAR_DIRLIST
1.86 wiz 4013:
1.184 rillig 4014: After make clean, do not reconstruct the list of directories to update
4015: for this package. Only use this if make update successfully installed
4016: all packages you wanted to update. Normally, this is done automatically
4017: on make update, but may have been suppressed by the NOCLEAN variable
4018: (see above).
1.1 dsieger 4019:
1.184 rillig 4020: replace
1.1 dsieger 4021:
1.184 rillig 4022: Update the installation of the current package. This differs from update in
4023: that it does not replace dependent packages. You will need to install
4024: pkgtools/pkg_tarup for this target to work.
1.1 dsieger 4025:
1.184 rillig 4026: Be careful when using this target! There are no guarantees that dependent
4027: packages will still work, in particular they will most certainly break if
4028: you make replace a library package whose shared library major version
4029: changed between your installed version and the new one. For this reason,
4030: this target is not officially supported and only recommended for advanced
4031: users.
1.1 dsieger 4032:
1.184 rillig 4033: info
1.1 dsieger 4034:
1.184 rillig 4035: This target invokes pkg_info(1) for the current package. You can use this
4036: to check which version of a package is installed.
1.86 wiz 4037:
1.184 rillig 4038: index
1.1 dsieger 4039:
1.184 rillig 4040: This is a top-level command, i.e. it should be used in the pkgsrc
4041: directory. It creates a database of all packages in the local pkgsrc tree,
4042: including dependencies, comment, maintainer, and some other useful
4043: information. Individual entries are created by running make describe in the
4044: packages' directories. This index file is saved as pkgsrc/INDEX. It can be
4045: displayed in verbose format by running make print-index. You can search in
4046: it with make search key=something. You can extract a list of all packages
4047: that depend on a particular one by running make show-deps PKG=somepackage.
1.1 dsieger 4048:
1.184 rillig 4049: Running this command takes a very long time, some hours even on fast
4050: machines!
1.1 dsieger 4051:
1.184 rillig 4052: readme
1.1 dsieger 4053:
1.199 nia 4054: This target generates a index.html file, which can be viewed using a
1.184 rillig 4055: browser such as www/firefox or www/links. The generated files contain
4056: references to any packages which are in the PACKAGES directory on the local
4057: host. The generated files can be made to refer to URLs based on
4058: FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
1.199 nia 4059: index.html files which pointed to binary packages on the local machine, in
1.184 rillig 4060: the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
4061: FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
4062: subdirectories will be searched for all the binary packages.
1.1 dsieger 4063:
1.184 rillig 4064: The target can be run at the toplevel or in category directories, in which
4065: case it descends recursively.
1.1 dsieger 4066:
1.184 rillig 4067: readme-all
1.1 dsieger 4068:
1.184 rillig 4069: This is a top-level command, run it in pkgsrc. Use this target to create a
4070: file README-all.html which contains a list of all packages currently
4071: available in the NetBSD Packages Collection, together with the category
4072: they belong to and a short description. This file is compiled from the
1.199 nia 4073: pkgsrc/*/index.html files, so be sure to run this after a make readme.
1.1 dsieger 4074:
1.184 rillig 4075: cdrom-readme
1.1 dsieger 4076:
1.266 martin 4077: This is very much the same as the readme target (see above), but is to be
1.184 rillig 4078: used when generating a pkgsrc tree to be written to a CD-ROM. This target
1.199 nia 4079: also produces index.html files, and can be made to refer to URLs based on
1.184 rillig 4080: CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
1.1 dsieger 4081:
1.184 rillig 4082: show-distfiles
1.1 dsieger 4083:
1.184 rillig 4084: This target shows which distfiles and patchfiles are needed to build the
4085: package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
4086: patches/*).
1.1 dsieger 4087:
1.184 rillig 4088: show-downlevel
1.1 dsieger 4089:
1.184 rillig 4090: This target shows nothing if the package is not installed. If a version of
4091: this package is installed, but is not the version provided in this version
4092: of pkgsrc, then a warning message is displayed. This target can be used to
4093: show which of your installed packages are downlevel, and so the old
4094: versions can be deleted, and the current ones added.
1.1 dsieger 4095:
1.184 rillig 4096: show-pkgsrc-dir
1.1 dsieger 4097:
1.184 rillig 4098: This target shows the directory in the pkgsrc hierarchy from which the
4099: package can be built and installed. This may not be the same directory as
4100: the one from which the package was installed. This target is intended to be
4101: used by people who may wish to upgrade many packages on a single host, and
1.266 martin 4102: can be invoked from the top-level pkgsrc Makefile by using the
4103: show-host-specific-pkgs target.
1.1 dsieger 4104:
1.184 rillig 4105: show-installed-depends
1.1 dsieger 4106:
1.184 rillig 4107: This target shows which installed packages match the current package's
4108: DEPENDS. Useful if out of date dependencies are causing build problems.
1.1 dsieger 4109:
1.184 rillig 4110: print-build-depends-list
1.1 dsieger 4111:
1.184 rillig 4112: This target shows the list of packages that the current package depends on
4113: for building.
1.1 dsieger 4114:
1.184 rillig 4115: print-run-depends-list
1.1 dsieger 4116:
1.184 rillig 4117: This target shows the list of packages that the current package depends on
4118: for running.
1.1 dsieger 4119:
1.184 rillig 4120: check-shlibs
1.1 dsieger 4121:
1.184 rillig 4122: After a package is installed, check all its binaries and (on ELF platforms)
4123: shared libraries to see if they find the shared libs they need. Run by
4124: default if PKG_DEVELOPER is set in mk.conf.
1.1 dsieger 4125:
1.184 rillig 4126: print-PLIST
1.1 dsieger 4127:
1.266 martin 4128: After a make install from a new or upgraded pkg, this prints out an
1.184 rillig 4129: attempt to generate a new PLIST from a find -newer work/.extract_done. An
4130: attempt is made to care for shared libs etc., but it is strongly
4131: recommended to review the result before putting it into PLIST. On upgrades,
4132: it's useful to diff the output of this command against an already existing
4133: PLIST file.
1.1 dsieger 4134:
1.184 rillig 4135: If the package installs files via tar(1) or other methods that don't update
4136: file access times, be sure to add these files manually to your PLIST, as
1.266 martin 4137: the find -newer command used by this target won't catch them!
1.56 ryoon 4138:
1.266 martin 4139: See Section 19.3, Tweaking output of make print-PLIST for more
1.184 rillig 4140: information on this target.
1.1 dsieger 4141:
1.255 wiz 4142: rebuild
4143:
4144: If you did a make build and you noticed some further modifications of
4145: sources are needed, you can repeat the build with this target, which will
1.266 martin 4146: ignore the already built flag. This target is helpful while working with
1.255 wiz 4147: patches.
4148:
4149: repackage
4150:
4151: If you did a make package and you noticed some further modifications of
4152: sources are needed, you can repeat the package with this target, which will
1.266 martin 4153: ignore the already packaged flag. This target is helpful while working
1.255 wiz 4154: with patches, PLIST* files etc.
4155:
4156: retest
4157:
4158: If you did a make test and you noticed some further modifications of
4159: sources are needed, you can repeat the test with this target, which will
1.266 martin 4160: ignore the already tested flag. This target is helpful while working with
1.255 wiz 4161: patches.
4162:
1.266 martin 4163: Chapter 14. Creating a new pkgsrc package from scratch
1.1 dsieger 4164:
1.184 rillig 4165: Table of Contents
1.1 dsieger 4166:
1.184 rillig 4167: 14.1. Common types of packages
1.219 nia 4168: 14.1.1. Python modules and programs
4169: 14.1.2. R packages
4170: 14.1.3. TeXlive packages
1.184 rillig 4171: 14.2. Examples
4172: 14.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 4173:
1.184 rillig 4174: When you find a package that is not yet in pkgsrc, you most likely have a URL
4175: from where you can download the source code. Starting with this URL, creating a
4176: package involves only a few steps.
1.1 dsieger 4177:
1.184 rillig 4178: 1. In your mk.conf, set PKG_DEVELOPER=yes to enable the basic quality checks.
1.1 dsieger 4179:
1.184 rillig 4180: 2. Install the package meta-pkgs/pkg_developer, which among others will
4181: install the utilities url2pkg, pkglint, pkgvi and mkpatches:
1.1 dsieger 4182:
1.184 rillig 4183: $ cd /usr/pkgsrc
4184: $ (cd meta-pkgs/pkg_developer && bmake update)
1.1 dsieger 4185:
1.184 rillig 4186: 3. Choose one of the top-level directories as the category in which you want
4187: to place your package. You can also create a directory of your own (maybe
1.219 nia 4188: called local). Change into that category directory:
1.1 dsieger 4189:
1.219 nia 4190: $ cd category
1.1 dsieger 4191:
1.219 nia 4192: 4. Run the program url2pkg, passing as argument the URL of the distribution
4193: file (in most cases a .tar.gz file). This will download the distribution
4194: file and create the necessary files of the package, based on what's in the
4195: distribution file:
1.1 dsieger 4196:
1.184 rillig 4197: $ url2pkg https://www.example.org/packages/package-1.0.tar.gz
1.1 dsieger 4198:
1.184 rillig 4199: 5. Examine the extracted files to determine the dependencies of your package.
4200: Ideally, this is mentioned in some README file, but things may differ. For
4201: each of these dependencies, look where it exists in pkgsrc, and if there is
4202: a file called buildlink3.mk in that directory, add a line to your package
4203: Makefile which includes that file just before the last line. If the
4204: buildlink3.mk file does not exist, it must be created first. The
4205: buildlink3.mk file makes sure that the package's include files and
4206: libraries are provided.
1.1 dsieger 4207:
1.219 nia 4208: If you just need binaries from a dependent package, add a DEPENDS line to
4209: the Makefile, which specifies the version of the dependency and where it
4210: can be found in pkgsrc. This line should be placed in the third paragraph.
4211: If the dependency is only needed for building the package, but not when
4212: using it, use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The
4213: difference between TOOL_DEPENDS and BUILD_DEPENDS occurs when
4214: cross-compiling: TOOL_DEPENDS are native packages, i.e. packages for the
4215: platform where the package is built; BUILD_DEPENDS are target packages,
4216: i.e. packages for the platform for which the package is built. There is
4217: also TEST_DEPENDS, which specifies a dependency used only for testing the
4218: resulting package built, using the upstream project's included test suite,
4219: on the native platform. Your package may then look like this:
1.1 dsieger 4220:
1.184 rillig 4221: [...]
1.1 dsieger 4222:
1.184 rillig 4223: TOOL_DEPENDS+= libxslt-[0-9]*:../../textproc/libxslt
4224: DEPENDS+= screen-[0-9]*:../../misc/screen
4225: DEPENDS+= screen>=4.0:../../misc/screen
1.1 dsieger 4226:
1.184 rillig 4227: [...]
1.1 dsieger 4228:
1.184 rillig 4229: .include "../../category/package/buildlink3.mk"
4230: .include "../../devel/glib2/buildlink3.mk"
4231: .include "../../mk/bsd.pkg.mk"
1.1 dsieger 4232:
1.184 rillig 4233: 6. Run pkglint to see what things still need to be done to make your package a
1.266 martin 4234: good one. If you don't know what pkglint's warnings want to tell you, try
1.184 rillig 4235: pkglint --explain or pkglint -e, which outputs additional explanations.
1.1 dsieger 4236:
1.184 rillig 4237: 7. In many cases the package is not yet ready to build. You can find
1.266 martin 4238: instructions for the most common cases in the next section, Section 14.1,
4239: Common types of packages . After you have followed the instructions over
1.184 rillig 4240: there, you can hopefully continue here.
1.1 dsieger 4241:
1.184 rillig 4242: 8. Run bmake clean to clean the working directory from the extracted files.
1.219 nia 4243: Besides these files, a lot of cache files and other system information have
4244: been saved in the working directory, which may have become outdated after
4245: you edited the Makefile.
1.1 dsieger 4246:
1.184 rillig 4247: 9. Now, run bmake to build the package. For the various things that can go
1.266 martin 4248: wrong in this phase, consult Chapter 21, Making your package work.
1.1 dsieger 4249:
1.184 rillig 4250: If the extracted files from the package need to be fixed, run multiple
4251: rounds of these commands:
1.1 dsieger 4252:
1.219 nia 4253: $ bmake
1.184 rillig 4254: $ pkgvi ${WRKSRC}/some/file/that/does/not/compile
4255: $ mkpatches
1.219 nia 4256: $ bmake mps
4257: $ bmake clean
1.1 dsieger 4258:
1.184 rillig 4259: 10. When the package builds fine, the next step is to install the package. Run
4260: bmake install and hope that everything works.
1.1 dsieger 4261:
1.184 rillig 4262: 11. Up to now, the file PLIST, which contains a list of the files that are
4263: installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
4264: generate a probably correct list. Check the file using your preferred text
4265: editor to see if the list of files looks plausible.
1.1 dsieger 4266:
1.184 rillig 4267: 12. Run pkglint again to see if the generated PLIST contains garbage or not.
1.1 dsieger 4268:
1.184 rillig 4269: 13. When you ran bmake install, the package had been registered in the database
4270: of installed files, but with an empty list of files. To fix this, run bmake
4271: deinstall and bmake install again. Now the package is registered with the
4272: list of files from PLIST.
1.48 wiz 4273:
1.219 nia 4274: 14. Run bmake clean update to run everything from above again in a single step,
1.184 rillig 4275: making sure that the PLIST is correct and the whole package is created as
4276: intended.
1.48 wiz 4277:
1.219 nia 4278: 15. Run pkglint to see if there's anything left to do.
1.48 wiz 4279:
1.266 martin 4280: 16. Commit the package to pkgsrc-wip or main pkgsrc; see Chapter 23, Submitting
1.184 rillig 4281: and Committing.
1.50 wiz 4282:
1.266 martin 4283: 14.1. Common types of packages
1.1 dsieger 4284:
1.266 martin 4285: 14.1.1. Python modules and programs
1.1 dsieger 4286:
1.184 rillig 4287: Python modules and programs packages are easily created using a set of
4288: predefined variables.
1.1 dsieger 4289:
1.184 rillig 4290: If some Python versions are not supported by the software, set the
4291: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
4292: supported, e.g.
1.1 dsieger 4293:
1.184 rillig 4294: PYTHON_VERSIONS_INCOMPATIBLE= 27
1.1 dsieger 4295:
1.249 gutterid 4296: If the packaged software is a Python module, include ../../lang/python/
1.258 wiz 4297: wheel.mk. Note per PEP-518, the minimum and default requirement to create .whl
4298: files is devel/py-setuptools; however, there are various other possible tools
4299: that projects can use. Thus inclusion of wheel.mk does not imply these defaults
4300: are defined as TOOL_DEPENDS. Whatever the project specifically requires as
4301: packaging tools must be defined in the package Makefile.
1.1 dsieger 4302:
1.266 martin 4303: The package directory should be called py-software and PKGNAME should be set
4304: to ${PYPKGPREFIX}-${DISTNAME} , e.g.
1.1 dsieger 4305:
1.184 rillig 4306: DISTNAME= foopymodule-1.2.10
4307: PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
1.1 dsieger 4308:
1.226 gutterid 4309: For software in PyPi, the name should match what PyPi specifies for "pip
4310: install software".
4311:
1.266 martin 4312: If it is an application, include ../../lang/python/application.mk . In order
1.184 rillig 4313: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
4314: variable and set it to the list of files (paths relative to WRKSRC) that must
4315: be corrected. For example:
1.1 dsieger 4316:
1.184 rillig 4317: REPLACE_PYTHON= *.py
1.1 dsieger 4318:
1.266 martin 4319: 14.1.2. R packages
1.1 dsieger 4320:
1.184 rillig 4321: Simple R packages from CRAN are handled automatically by R2pkg, which is
4322: available in pkgtools/R2pkg. Individual packages (and optionally their
4323: dependencies) may be created and updated. R packages generally follow the same
4324: form, and most of the relevant information needed is contained in a DESCRIPTION
4325: file as part of each R package on CRAN. Consequently, R2pkg downloads that
4326: information and creates or updates a package in the canonical form. The
4327: resulting package should be reviewed for correctness.
1.1 dsieger 4328:
1.266 martin 4329: 14.1.3. TeXlive packages
1.1 dsieger 4330:
1.184 rillig 4331: TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
4332: available in pkgtools/texlive2pkg.
1.1 dsieger 4333:
1.266 martin 4334: If the TeXlive package name is not known, it may be useful to search CTAN. A
4335: Contained in field on the package page typically identifies the basename of
1.184 rillig 4336: the package file in the TeXlive archive.
1.1 dsieger 4337:
1.184 rillig 4338: If the TeXlive package name is known, download the files from the TeXlive
4339: archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
4340: packages also have associated documentation packages, so download
4341: foo.doc.tar.xz at the same time. These files should be placed in the
4342: appropriate category directory, which is often but not always print. Then run
4343: the following command in the category directory.
1.1 dsieger 4344:
1.184 rillig 4345: texlive2pkg foo.tar.xz foo.doc.tar.xz
1.1 dsieger 4346:
1.184 rillig 4347: This will create two packages, tex-foo and tex-foo-doc. Be sure to check that
4348: both packages are correct.
1.1 dsieger 4349:
1.184 rillig 4350: Finally, CTAN currently does not include version information in package
4351: filenames and changes their contents periodically when updates occur.
4352: Consequently, pkgsrc avoids downloading distfiles directly from CTAN and
4353: instead relies on the pkgsrc archives. For each new or updated TeXlive package,
4354: e.g., the main one and the corresponding documentation, upload the distfiles
4355: with the following command in each package directory.
1.1 dsieger 4356:
1.184 rillig 4357: make upload-distfiles
1.117 sevan 4358:
1.266 martin 4359: 14.2. Examples
1.117 sevan 4360:
1.266 martin 4361: 14.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 4362:
1.266 martin 4363: 14.2.1.1. The initial package
1.1 dsieger 4364:
1.266 martin 4365: Looking at the file pkgsrc/doc/TODO, I saw that the nvu package has not yet
1.184 rillig 4366: been imported into pkgsrc. As the description says it has to do with the web,
1.266 martin 4367: the obvious choice for the category is www .
1.1 dsieger 4368:
1.184 rillig 4369: $ mkdir www/nvu
4370: $ cd www/nvu
1.1 dsieger 4371:
1.184 rillig 4372: The web site says that the sources are available as a tar file, so I fed that
4373: URL to the url2pkg program:
1.1 dsieger 4374:
1.184 rillig 4375: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
1.1 dsieger 4376:
1.184 rillig 4377: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
1.266 martin 4378: package name should not have the word sources in it. I also filled in the
1.184 rillig 4379: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
4380: that:
1.1 dsieger 4381:
1.184 rillig 4382: # $NetBSD $
4383: #
1.1 dsieger 4384:
1.184 rillig 4385: DISTNAME= nvu-1.0-sources
4386: PKGNAME= nvu-1.0
4387: CATEGORIES= www
4388: MASTER_SITES= http://cvs.nvu.com/download/
4389: EXTRACT_SUFX= .tar.bz2
1.1 dsieger 4390:
1.184 rillig 4391: MAINTAINER= rillig@NetBSD.org
4392: HOMEPAGE= http://cvs.nvu.com/
4393: COMMENT= Web Authoring System
1.1 dsieger 4394:
1.184 rillig 4395: # url2pkg-marker (please do not remove this line.)
4396: .include "../../mk/bsd.pkg.mk"
1.1 dsieger 4397:
1.184 rillig 4398: On the first line of output above, an artificial space has been added between
4399: NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
4400: the guide.
1.1 dsieger 4401:
1.184 rillig 4402: Then, I quit the editor and watched pkgsrc downloading a large source archive:
1.1 dsieger 4403:
1.184 rillig 4404: url2pkg> Running "make makesum" ...
4405: => Required installed package digest>=20010302: digest-20060826 found
4406: => Fetching nvu-1.0-sources.tar.bz2
4407: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
4408: 100% |*************************************| 28992 KB 150.77 KB/s00:00 ETA
4409: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
4410: url2pkg> Running "make extract" ...
4411: => Required installed package digest>=20010302: digest-20060826 found
4412: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
4413: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
4414: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
4415: ===> Installing dependencies for nvu-1.0
4416: ===> Overriding tools for nvu-1.0
4417: ===> Extracting for nvu-1.0
4418: url2pkg> Adjusting the Makefile.
1.1 dsieger 4419:
1.184 rillig 4420: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
1.1 dsieger 4421:
1.184 rillig 4422: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
1.1 dsieger 4423:
1.266 martin 4424: 14.2.1.2. Fixing all kinds of problems to make the package work
1.1 dsieger 4425:
1.184 rillig 4426: Now that the package has been extracted, let's see what's inside it. The
4427: package has a README.txt, but that only says something about mozilla, so it's
4428: probably useless for seeing what dependencies this package has. But since there
4429: is a GNU configure script in the package, let's hope that it will complain
4430: about everything it needs.
1.1 dsieger 4431:
1.184 rillig 4432: $ bmake
4433: => Required installed package digest>=20010302: digest-20060826 found
4434: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
4435: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
4436: ===> Patching for nvu-1.0
4437: ===> Creating toolchain wrappers for nvu-1.0
4438: ===> Configuring for nvu-1.0
4439: [...]
4440: configure: error: Perl 5.004 or higher is required.
4441: [...]
4442: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
4443: [...]
1.1 dsieger 4444:
1.184 rillig 4445: That worked quite well. So I opened the package Makefile in my editor, and
1.266 martin 4446: since it already has a USE_TOOLS line, I just appended perl to it. Since the
1.184 rillig 4447: dependencies of the package have changed now, and since a perl wrapper is
1.266 martin 4448: automatically installed in the tools phase, I need to build the package from
1.184 rillig 4449: scratch.
1.1 dsieger 4450:
1.184 rillig 4451: $ bmake clean
4452: ===> Cleaning for nvu-1.0
4453: $ bmake
4454: [...]
4455: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
4456: GNU Make. You will not be able to build Mozilla without GNU Make.
4457: [...]
1.1 dsieger 4458:
1.266 martin 4459: So I added gmake to the USE_TOOLS line and tried again (from scratch).
1.1 dsieger 4460:
1.184 rillig 4461: [...]
4462: checking for GTK - version >= 1.2.0... no
4463: *** Could not run GTK test program, checking why...
4464: [...]
1.1 dsieger 4465:
1.184 rillig 4466: Now to the other dependencies. The first question is: Where is the GTK package
4467: hidden in pkgsrc?
1.1 dsieger 4468:
1.184 rillig 4469: $ echo ../../*/gtk*
4470: [many packages ...]
4471: $ echo ../../*/gtk
4472: ../../x11/gtk
4473: $ echo ../../*/gtk2
4474: ../../x11/gtk2
4475: $ echo ../../*/gtk2/bui*
4476: ../../x11/gtk2/buildlink3.mk
1.1 dsieger 4477:
1.184 rillig 4478: The first try was definitely too broad. The second one had exactly one result,
4479: which is very good. But there is one pitfall with GNOME packages. Before GNOME
4480: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
4481: able to continue to use these packages, the GNOME 2 packages were imported as
1.266 martin 4482: separate packages, and their names usually have a 2 appended. So I checked
1.184 rillig 4483: whether this was the case here, and indeed it was.
1.1 dsieger 4484:
1.184 rillig 4485: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
4486: easy. I just inserted an .include line before the last line of the package
4487: Makefile, so that it now looks like this:
1.1 dsieger 4488:
1.184 rillig 4489: [...]
4490: .include "../../x11/gtk2/buildlink3.mk"
4491: .include "../../mk/bsd.pkg.mk
1.1 dsieger 4492:
1.184 rillig 4493: After another bmake clean && bmake, the answer was:
1.108 rillig 4494:
1.184 rillig 4495: [...]
4496: checking for gtk-config... /home/roland/pkg/bin/gtk-config
4497: checking for GTK - version >= 1.2.0... no
4498: *** Could not run GTK test program, checking why...
4499: *** The test program failed to compile or link. See the file config.log for the
4500: *** exact error that occured. This usually means GTK was incorrectly installed
4501: *** or that you have moved GTK since it was installed. In the latter case, you
4502: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
4503: configure: error: Test for GTK failed.
4504: [...]
1.1 dsieger 4505:
1.266 martin 4506: In this particular case, the assumption that every package prefers GNOME 2
1.184 rillig 4507: had been wrong. The first of the lines above told me that this package really
4508: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
4509: it would have looked for pkg-config instead of gtk-config. So I changed the x11
4510: /gtk2 to x11/gtk in the package Makefile, and tried again.
1.1 dsieger 4511:
1.184 rillig 4512: [...]
4513: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\" [...]
4514: In file included from xpidl.c:42:
4515: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
4516: In file included from xpidl.c:42:
4517: xpidl.h:132: error: parse error before "IDL_ns"
4518: [...]
1.1 dsieger 4519:
1.184 rillig 4520: The package still does not find all of its dependencies. Now the question is:
4521: Which package provides the libIDL/IDL.h header file?
1.1 dsieger 4522:
1.184 rillig 4523: $ echo ../../*/*idl*
4524: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
4525: $ echo ../../*/*IDL*
4526: ../../net/libIDL
1.1 dsieger 4527:
1.184 rillig 4528: Let's take the one from the second try. So I included the ../../net/libIDL/
4529: buildlink3.mk file and tried again. But the error didn't change. After digging
4530: through some of the code, I concluded that the build process of the package was
4531: broken and couldn't have ever worked, but since the Mozilla source tree is
4532: quite large, I didn't want to fix it. So I added the following to the package
4533: Makefile and tried again:
1.1 dsieger 4534:
1.184 rillig 4535: CPPFLAGS+= -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
4536: BUILDLINK_TRANSFORM+= l:IDL:IDL-2
1.1 dsieger 4537:
1.184 rillig 4538: The latter line is needed because the package expects the library libIDL.so,
4539: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
4540: that on the fly.
1.1 dsieger 4541:
1.184 rillig 4542: The next problem was related to a recent change of the FreeType interface. I
4543: looked up in www/seamonkey which patch files were relevant for this issue and
4544: copied them to the patches directory. Then I retried, fixed the patches so that
4545: they applied cleanly and retried again. This time, everything worked.
1.1 dsieger 4546:
1.266 martin 4547: 14.2.1.3. Installing the package
1.1 dsieger 4548:
1.184 rillig 4549: $ bmake CHECK_FILES=no install
4550: [...]
4551: $ bmake print-PLIST >PLIST
4552: $ bmake deinstall
4553: $ bmake install
1.1 dsieger 4554:
1.266 martin 4555: Chapter 15. Programming in Makefiles
1.1 dsieger 4556:
1.184 rillig 4557: Table of Contents
1.1 dsieger 4558:
1.184 rillig 4559: 15.1. Caveats
4560: 15.2. Makefile variables
4561: 15.2.1. Naming conventions
4562: 15.3. Code snippets
4563: 15.3.1. Adding things to a list
4564: 15.3.2. Echoing a string exactly as-is
4565: 15.3.3. Passing CFLAGS to GNU configure scripts
4566: 15.3.4. Handling possibly empty variables
1.229 gutterid 4567: 15.3.5. Testing yes/no variables in conditions
1.1 dsieger 4568:
1.184 rillig 4569: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
4570: part of the pkgsrc system. Using the make(1) system as a programming language
4571: for a big system like pkgsrc requires some discipline to keep the code correct
4572: and understandable.
1.1 dsieger 4573:
1.184 rillig 4574: The basic ingredients for Makefile programming are variables and shell
4575: commands. Among these shell commands may even be more complex ones like awk(1)
4576: programs. To make sure that every shell command runs as intended it is
4577: necessary to quote all variables correctly when they are used.
1.1 dsieger 4578:
1.184 rillig 4579: This chapter describes some patterns that appear quite often in Makefiles,
4580: including the pitfalls that come along with them.
1.1 dsieger 4581:
1.266 martin 4582: 15.1. Caveats
1.1 dsieger 4583:
1.184 rillig 4584: * When you are creating a file as a target of a rule, always write the data
4585: to a temporary file first and finally rename that file. Otherwise there
4586: might occur an error in the middle of generating the file, and when the
4587: user runs make(1) for the second time, the file exists and will not be
4588: regenerated properly. Example:
1.1 dsieger 4589:
1.184 rillig 4590: wrong:
4591: @echo "line 1" > ${.TARGET}
4592: @echo "line 2" >> ${.TARGET}
4593: @false
1.1 dsieger 4594:
1.184 rillig 4595: correct:
4596: @echo "line 1" > ${.TARGET}.tmp
4597: @echo "line 2" >> ${.TARGET}.tmp
4598: @false
4599: @mv ${.TARGET}.tmp ${.TARGET}
1.1 dsieger 4600:
1.184 rillig 4601: When you run make wrong twice, the file wrong will exist, although there
4602: was an error message in the first run. On the other hand, running make
4603: correct gives an error message twice, as expected.
1.1 dsieger 4604:
1.184 rillig 4605: You might remember that make(1) sometimes removes ${.TARGET} in case of
4606: error, but this only happens when it is interrupted, for example by
4607: pressing Ctrl+C. This does not happen when one of the commands fails (like
4608: false(1) above).
1.1 dsieger 4609:
1.266 martin 4610: 15.2. Makefile variables
1.1 dsieger 4611:
1.184 rillig 4612: Makefile variables contain strings that can be processed using the five
4613: operators =, +=, ?=, := and !=, which are described in the make(1) man page.
1.1 dsieger 4614:
1.184 rillig 4615: When a variable's value is parsed from a Makefile, the hash character # and the
4616: backslash character \ are handled specially. If a backslash is the last
4617: character in a line, that backslash is removed from the line and the line
4618: continues with the next line of the file.
1.1 dsieger 4619:
1.184 rillig 4620: The # character starts a comment that reaches until the end of the line. To get
4621: an actual # character, such as in a URL, write \# instead.
1.1 dsieger 4622:
1.184 rillig 4623: The evaluation of variables either happens immediately or lazy. It happens
4624: immediately when the variable occurs on the right-hand side of the := or the !=
4625: operator, in a .if condition or a .for loop. In the other cases, it is
4626: evaluated lazily.
1.1 dsieger 4627:
1.184 rillig 4628: Some of the modifiers split the string into words and then operate on the
4629: words, others operate on the string as a whole. When a string is split into
4630: words, double quotes and single quotes are interpreted as delimiters, just like
4631: in sh(1).
1.1 dsieger 4632:
1.266 martin 4633: 15.2.1. Naming conventions
1.1 dsieger 4634:
1.184 rillig 4635: * All variable names starting with an underscore are reserved for use by the
4636: pkgsrc infrastructure. They shall not be used by packages.
1.1 dsieger 4637:
1.184 rillig 4638: * In .for loops you should use lowercase variable names for the iteration
4639: variables.
1.1 dsieger 4640:
1.184 rillig 4641: * All list variables should have a plural name, such as PKG_OPTIONS or
4642: DISTFILES.
1.1 dsieger 4643:
1.266 martin 4644: 15.3. Code snippets
1.1 dsieger 4645:
1.266 martin 4646: 15.3.1. Adding things to a list
1.1 dsieger 4647:
1.184 rillig 4648: When adding a string that possibly contains whitespace or quotes to a list
4649: (example 1), it must be quoted using the :Q modifier.
1.1 dsieger 4650:
1.184 rillig 4651: When adding another list to a list (example 2), it must not be quoted, since
4652: its elements are already quoted.
1.1 dsieger 4653:
1.184 rillig 4654: STRING= foo * bar `date`
4655: LIST= # empty
4656: ANOTHER_LIST= a=b c=d
1.1 dsieger 4657:
1.184 rillig 4658: LIST+= ${STRING:Q} # 1
4659: LIST+= ${ANOTHER_LIST} # 2
1.1 dsieger 4660:
1.266 martin 4661: 15.3.2. Echoing a string exactly as-is
1.1 dsieger 4662:
1.184 rillig 4663: Echoing a string containing special characters needs special work.
1.1 dsieger 4664:
1.184 rillig 4665: STRING= foo bar < > * `date` $$HOME ' "
4666: EXAMPLE_ENV= string=${STRING:Q} x=multiple\ quoted\ words
1.1 dsieger 4667:
1.184 rillig 4668: all:
4669: echo ${STRING} # 1
4670: echo ${STRING:Q} # 2
4671: printf '%s\n' ${STRING:Q}'' # 3
4672: env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"' # 4
1.1 dsieger 4673:
1.184 rillig 4674: Example 1 leads to a syntax error in the shell, as the characters are just
4675: copied.
1.1 dsieger 4676:
1.184 rillig 4677: Example 2 quotes the string so that the shell interprets it correctly. But the
4678: echo command may additionally interpret strings with a leading dash or those
4679: containing backslashes.
1.1 dsieger 4680:
1.184 rillig 4681: Example 3 can handle arbitrary strings, since printf(1) only interprets the
4682: format string, but not the next argument. The trailing single quotes handle the
4683: case when the string is empty. In that case, the :Q modifier would result in an
4684: empty string too, which would then be skipped by the shell. For printf(1) this
4685: doesn't make a difference, but other programs may care.
1.1 dsieger 4686:
1.184 rillig 4687: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
4688: has already been done when adding elements to the list.
1.1 dsieger 4689:
1.266 martin 4690: 15.3.3. Passing CFLAGS to GNU configure scripts
1.1 dsieger 4691:
1.184 rillig 4692: When passing CFLAGS or similar variables to a GNU-style configure script
4693: (especially those that call other configure scripts), it must not have leading
4694: or trailing whitespace, since otherwise the configure script gets confused. To
4695: trim leading and trailing whitespace, use the :M modifier, as in the following
4696: example:
1.1 dsieger 4697:
1.184 rillig 4698: CPPFLAGS= # empty
4699: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX}\"
4700: CPPFLAGS+= ${MY_CPPFLAGS}
1.1 dsieger 4701:
1.184 rillig 4702: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
1.1 dsieger 4703:
1.184 rillig 4704: all:
4705: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
4706: echo x${CONFIGURE_ARGS:Q}x # properly trimmed
1.1 dsieger 4707:
1.184 rillig 4708: In this example, CPPFLAGS has both leading and trailing whitespace because the
4709: += operator always adds a space.
1.1 dsieger 4710:
1.266 martin 4711: 15.3.4. Handling possibly empty variables
1.1 dsieger 4712:
1.184 rillig 4713: When a possibly empty variable is used in a shell program, it may lead to a
4714: syntax error.
1.1 dsieger 4715:
1.184 rillig 4716: EGFILES= # empty
1.1 dsieger 4717:
1.184 rillig 4718: install-examples: # produces a syntax error in the shell
4719: for egfile in ${EGFILES}; do \
4720: echo "Installing $$egfile"; \
4721: done
1.1 dsieger 4722:
1.184 rillig 4723: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
4724: with an empty string by make(1). To fix this syntax error, use one of the
4725: snippets below.
1.1 dsieger 4726:
1.229 gutterid 4727: EGFILES= # empty
1.1 dsieger 4728:
1.184 rillig 4729: install-examples:
4730: for egfile in ${EGFILES} ""; do \
4731: [ -n "$$egfile" ] || continue; \
4732: echo "Installing $$egfile"; \
4733: done
1.1 dsieger 4734:
1.184 rillig 4735: In this case, an empty string is appended to the iteration list (to prevent the
4736: syntax error) and filtered out later.
1.1 dsieger 4737:
1.184 rillig 4738: EGFILES= # empty
1.1 dsieger 4739:
1.184 rillig 4740: install-examples:
4741: .for egfile in ${EGFILES}
4742: echo "Installing ${egfile}"
4743: .endfor
1.1 dsieger 4744:
1.184 rillig 4745: If one of the filenames contains special characters, it should be enclosed in
4746: single or double quotes.
1.1 dsieger 4747:
1.184 rillig 4748: To have a shell command test whether a make variable is empty, use the
4749: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1 dsieger 4750:
1.266 martin 4751: 15.3.5. Testing yes/no variables in conditions
1.229 gutterid 4752:
4753: When a variable can have the values yes or no, use the following pattern to
4754: test the variable:
4755:
4756: .if ${VAR:U:tl} == "yes"
4757: # do something
4758: .endif
4759:
4760: The :U modifier is only necessary if the variable can be undefined. If the
4761: variable is guaranteed to be defined, the :U can be omitted.
4762:
4763: The :tl modifier converts the variable value to lowercase, allowing for the
4764: values yes, Yes, YES.
4765:
1.266 martin 4766: Chapter 16. Options handling
1.1 dsieger 4767:
4768: Table of Contents
4769:
1.184 rillig 4770: 16.1. Global default options
4771: 16.2. Converting packages to use bsd.options.mk
4772: 16.3. Option Names
4773: 16.4. Determining the options of dependencies
1.1 dsieger 4774:
4775: Many packages have the ability to be built to support different sets of
4776: features. bsd.options.mk is a framework in pkgsrc that provides generic
4777: handling of those options that determine different ways in which the packages
4778: can be built. It's possible for the user to specify exactly which sets of
4779: options will be built into a package or to allow a set of global default
4780: options apply.
4781:
1.7 rillig 4782: There are two broad classes of behaviors that one might want to control via
4783: options. One is whether some particular feature is enabled in a program that
4784: will be built anyway, often by including or not including a dependency on some
4785: other package. The other is whether or not an additional program will be built
4786: as part of the package. Generally, it is better to make a split package for
4787: such additional programs instead of using options, because it enables binary
4788: packages to be built which can then be added separately. For example, the foo
4789: package might have minimal dependencies (those packages without which foo
4790: doesn't make sense), and then the foo-gfoo package might include the GTK
4791: frontend program gfoo. This is better than including a gtk option to foo that
4792: adds gfoo, because either that option is default, in which case binary users
4793: can't get foo without gfoo, or not default, in which case they can't get gfoo.
4794: With split packages, they can install foo without having GTK, and later decide
4795: to install gfoo (pulling in GTK at that time). This is an advantage to source
4796: users too, avoiding the need for rebuilds.
4797:
4798: Plugins with widely varying dependencies should usually be split instead of
4799: options.
4800:
4801: It is often more work to maintain split packages, especially if the upstream
4802: package does not support this. The decision of split vs. option should be made
4803: based on the likelihood that users will want or object to the various pieces,
4804: the size of the dependencies that are included, and the amount of work.
4805:
4806: A further consideration is licensing. Non-free parts, or parts that depend on
4807: non-free dependencies (especially plugins) should almost always be split if
4808: feasible.
4809:
1.266 martin 4810: 16.1. Global default options
1.1 dsieger 4811:
4812: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
4813: the options that should be built into every package if that option is
1.4 rillig 4814: supported. This variable should be set in mk.conf.
1.1 dsieger 4815:
1.266 martin 4816: 16.2. Converting packages to use bsd.options.mk
1.1 dsieger 4817:
4818: The following example shows how bsd.options.mk should be used by the
4819: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
4820: e.g. options.mk, that is included by the main package Makefile.
4821:
4822: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
4823: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
4824: PKG_OPTIONS_OPTIONAL_GROUPS= database
4825: PKG_OPTIONS_GROUP.database= mysql pgsql
4826: PKG_SUGGESTED_OPTIONS= wibble-foo
4827: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
4828: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
4829:
4830: .include "../../mk/bsd.prefs.mk"
4831:
4832: # this package was previously named wibble2
4833: .if defined(PKG_OPTIONS.wibble2)
4834: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
4835: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
4836: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
4837: .endif
4838:
4839: .include "../../mk/bsd.options.mk"
4840:
4841: # Package-specific option-handling
4842:
4843: ###
4844: ### FOO support
4845: ###
4846: .if !empty(PKG_OPTIONS:Mwibble-foo)
4847: CONFIGURE_ARGS+= --enable-foo
4848: .endif
4849:
4850: ###
4851: ### LDAP support
4852: ###
4853: .if !empty(PKG_OPTIONS:Mldap)
4854: . include "../../databases/openldap-client/buildlink3.mk"
4855: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
4856: .endif
4857:
4858: ###
4859: ### database support
4860: ###
4861: .if !empty(PKG_OPTIONS:Mmysql)
4862: . include "../../mk/mysql.buildlink3.mk"
4863: .endif
4864: .if !empty(PKG_OPTIONS:Mpgsql)
4865: . include "../../mk/pgsql.buildlink3.mk"
4866: .endif
4867:
4868: The first section contains the information about which build options are
4869: supported by the package, and any default options settings if needed.
4870:
4871: 1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
4872: to override the default options. It should be set to PKG_OPTIONS.pkgbase.
4873: Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
4874: the point where the options are processed.
4875:
4876: 2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
4877:
4878: 3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
4879: exclusive options. The options in each group are listed in
4880: PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
4881: the group takes precedence over all other options in the group. Options
4882: from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
4883:
4884: 4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
4885: building the packages will fail if no option from the group is selected.
4886:
4887: 5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
4888: one option from each set must be selected. The options in each set are
4889: listed in PKG_OPTIONS_SET.setname. Options from the sets will be
4890: automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
4891: fail if no option from the set is selected.
4892:
4893: 6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
4894: default.
4895:
1.266 martin 4896: 7. PKG_OPTIONS_LEGACY_VARS is a list of USE_VARIABLE:option pairs that map
1.4 rillig 4897: legacy mk.conf variables to their option counterparts. Pairs should be
1.266 martin 4898: added with += to keep the listing of global legacy variables. A warning
1.1 dsieger 4899: will be issued if the user uses a legacy variable.
4900:
1.266 martin 4901: 8. PKG_OPTIONS_LEGACY_OPTS is a list of old-option:new-option pairs that map
1.1 dsieger 4902: options that have been renamed to their new counterparts. Pairs should be
1.266 martin 4903: added with += to keep the listing of global legacy options. A warning
1.1 dsieger 4904: will be issued if the user uses a legacy option.
4905:
4906: 9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
4907: used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
4908: PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
4909:
4910: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
4911: variables or options used, and what to use instead.
4912:
4913: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
4914: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
4915: options, use PKG_SUGGESTED_OPTIONS.
4916:
4917: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
4918: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
4919: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
4920: options if none of them is supported on the current platform), PKG_OPTIONS is
4921: set to the empty list and the package is otherwise treated as not using the
4922: options framework.
4923:
4924: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
4925: list of selected build options, properly filtered to remove unsupported and
4926: duplicate options.
4927:
4928: The remaining sections contain the logic that is specific to each option. The
4929: correct way to check for an option is to check whether it is listed in
4930: PKG_OPTIONS:
4931:
4932: .if !empty(PKG_OPTIONS:Moption)
4933:
1.266 martin 4934: 16.3. Option Names
1.1 dsieger 4935:
4936: Options that enable similar features in different packages (like optional
4937: support for a library) should use a common name in all packages that support it
4938: (like the name of the library). If another package already has an option with
4939: the same meaning, use the same name.
4940:
4941: Options that enable features specific to one package, where it's unlikely that
4942: another (unrelated) package has the same (or a similar) optional feature,
4943: should use a name prefixed with pkgname-.
4944:
4945: If a group of related packages share an optional feature specific to that
1.266 martin 4946: group, prefix it with the name of the main package (e. g.
1.1 dsieger 4947: djbware-errno-hack).
4948:
4949: For new options, add a line to mk/defaults/options.description. Lines have two
4950: fields, separated by tab. The first field is the option name, the second its
4951: description. The description should be a whole sentence (starting with an
4952: uppercase letter and ending with a period) that describes what enabling the
1.266 martin 4953: option does. E. g. Enable ispell support. The file is sorted by option names.
1.1 dsieger 4954:
1.266 martin 4955: 16.4. Determining the options of dependencies
1.7 rillig 4956:
4957: When writing buildlink3.mk files, it is often necessary to list different
4958: dependencies based on the options with which the package was built. For
4959: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
4960: A typical example looks like this:
4961:
4962: pkgbase := libpurple
4963: .include "../../mk/pkg-build-options.mk"
4964:
4965: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
4966: ...
4967: .endif
4968:
4969: Including pkg-build-options.mk here will set the variable
4970: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
4971: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
4972: pkg-build-options.mk for more details.
4973:
1.266 martin 4974: Chapter 17. Tools needed for building or running
1.184 rillig 4975:
4976: Table of Contents
4977:
4978: 17.1. Tools for pkgsrc builds
4979: 17.2. Tools needed by packages
4980: 17.3. Tools provided by platforms
4981:
4982: The USE_TOOLS definition is used both internally by pkgsrc and also for
4983: individual packages to define what commands are needed for building a package
4984: (like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
4985: DEPENDS). If the native system provides an adequate tool, then in many cases, a
4986: pkgsrc package will not be used.
4987:
4988: When building a package, the replacement tools are made available in a
4989: directory (as symlinks or wrapper scripts) that is early in the executable
4990: search path. Just like the buildlink system, this helps with consistent builds.
4991:
4992: A tool may be needed to help build a specific package. For example, perl, GNU
4993: make (gmake) or yacc may be needed.
4994:
4995: Also a tool may be needed, for example, because the native system's supplied
4996: tool may be inefficient for building a package with pkgsrc. For example, a
4997: package may need GNU awk, bison (instead of yacc) or a better sed.
4998:
4999: The tools used by a package can be listed by running make show-tools.
5000:
1.266 martin 5001: 17.1. Tools for pkgsrc builds
1.184 rillig 5002:
5003: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
5004: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
5005: seen by running: make show-var VARNAME=USE_TOOLS.
5006:
5007: If a package needs a specific program to build then the USE_TOOLS variable can
5008: be used to define the tools needed.
5009:
1.266 martin 5010: 17.2. Tools needed by packages
1.184 rillig 5011:
5012: In the following examples, the :run means that it is needed at run-time (and
5013: becomes a DEPENDS). The default is a build dependency which can be set with
5014: :build. (So in this example, it is the same as gmake:build and
5015: pkg-config:build.)
5016:
5017: USE_TOOLS+= gmake perl:run pkg-config
5018:
5019: When using the tools framework, a TOOLS_PATH.foo variable is defined which
5020: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
1.266 martin 5021: could be /bin/bash on Linux systems.
1.184 rillig 5022:
5023: If you always need a pkgsrc version of the tool at run-time, then just use
5024: DEPENDS instead.
5025:
1.266 martin 5026: 17.3. Tools provided by platforms
1.184 rillig 5027:
5028: When improving or porting pkgsrc to a new platform, have a look at (or create)
5029: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
5030: tools.${OPSYS}.mk which defines the name of the common tools. For example:
5031:
5032: .if exists(/usr/bin/bzcat)
5033: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
5034: .elif exists(/usr/bin/bzip2)
5035: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
5036: .endif
5037:
5038: TOOLS_PLATFORM.true?= true # shell builtin
5039:
1.266 martin 5040: Chapter 18. Buildlink methodology
1.1 dsieger 5041:
5042: Table of Contents
5043:
1.184 rillig 5044: 18.1. Converting packages to use buildlink3
5045: 18.2. Writing buildlink3.mk files
5046: 18.2.1. Anatomy of a buildlink3.mk file
5047: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.271 wiz 5048: buildlink3.mk files
1.184 rillig 5049: 18.3. Writing builtin.mk files
5050: 18.3.1. Anatomy of a builtin.mk file
5051:
5052: Buildlink is a framework in pkgsrc that controls what headers and libraries are
5053: seen by a package's configure and build processes. This is implemented in a two
5054: step process:
5055:
5056: 1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
5057: default is a subdirectory of WRKDIR.
5058:
5059: 2. Create wrapper scripts that are used in place of the normal compiler tools
5060: that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
5061: references to BUILDLINK_DIR. The wrapper scripts also make native compiler
5062: on some operating systems look like GCC, so that packages that expect GCC
5063: won't require modifications to build with those native compilers.
5064:
5065: This normalizes the environment in which a package is built so that the package
5066: may be built consistently despite what other software may be installed. Please
5067: note that the normal system header and library paths, e.g. /usr/include, /usr/
5068: lib, etc., are always searched -- buildlink3 is designed to insulate the
5069: package build from non-system-supplied software.
5070:
1.266 martin 5071: 18.1. Converting packages to use buildlink3
1.1 dsieger 5072:
1.266 martin 5073: The process of converting packages to use the buildlink3 framework ( bl3ifying
1.184 rillig 5074: ) is fairly straightforward. The things to keep in mind are:
1.1 dsieger 5075:
1.184 rillig 5076: 1. Ensure that the build always calls the wrapper scripts instead of the
5077: actual toolchain. Some packages are tricky, and the only way to know for
5078: sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
5079: invoked.
1.1 dsieger 5080:
1.184 rillig 5081: 2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
5082: standalone shells, etc., because the code to symlink files into $
1.266 martin 5083: {BUILDLINK_DIR} looks for files relative to pkg_info -qp pkgname .
1.1 dsieger 5084:
1.184 rillig 5085: 3. Remember that only the buildlink3.mk files that you list in a package's
5086: Makefile are added as dependencies for that package.
1.1 dsieger 5087:
1.184 rillig 5088: If a dependency on a particular package is required for its libraries and
5089: headers, then we replace:
1.1 dsieger 5090:
1.184 rillig 5091: DEPENDS+= foo>=1.1.0:../../category/foo
1.1 dsieger 5092:
1.184 rillig 5093: with
1.1 dsieger 5094:
1.184 rillig 5095: .include "../../category/foo/buildlink3.mk"
1.1 dsieger 5096:
1.184 rillig 5097: The buildlink3.mk files usually define the required dependencies. If you need a
5098: newer version of the dependency when using buildlink3.mk files, then you can
5099: define it in your Makefile; for example:
1.1 dsieger 5100:
1.184 rillig 5101: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
5102: .include "../../category/foo/buildlink3.mk"
1.1 dsieger 5103:
1.184 rillig 5104: There are several buildlink3.mk files in pkgsrc/mk that handle special package
5105: issues:
1.1 dsieger 5106:
1.184 rillig 5107: * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
5108: implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
1.1 dsieger 5109:
1.184 rillig 5110: * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
5111: this will take care to install the devel/ncurses package.
1.1 dsieger 5112:
1.184 rillig 5113: * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
5114: a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
5115: implementation.
1.1 dsieger 5116:
1.184 rillig 5117: * motif.buildlink3.mk checks for a system-provided Motif installation or adds
1.270 wiz 5118: a dependency on x11/motif. The user can set MOTIF_TYPE to dt or motif
5119: to choose which Motif version will be used.
1.1 dsieger 5120:
1.184 rillig 5121: * readline.buildlink3.mk checks for a system-provided GNU readline or
5122: editline (libedit) installation, or adds a dependency on devel/readline,
5123: devel/editline. The user can set READLINE_DEFAULT to choose readline
5124: implementation. If your package really needs GNU readline library, its
5125: Makefile should include devel/readline/buildlink3.mk instead of
5126: readline.buildlink3.mk.
1.1 dsieger 5127:
1.184 rillig 5128: * oss.buildlink3.mk defines several variables that may be used by packages
5129: that use the Open Sound System (OSS) API.
1.1 dsieger 5130:
1.184 rillig 5131: * pgsql.buildlink3.mk will accept any of the Postgres versions in the
5132: variable PGSQL_VERSIONS_ACCEPTED and default to the version
5133: PGSQL_VERSION_DEFAULT. See the file for more information.
1.1 dsieger 5134:
1.184 rillig 5135: * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
5136: pthreads or adds a dependency on devel/pth as needed.
1.1 dsieger 5137:
1.184 rillig 5138: * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
5139: widgets library.
1.1 dsieger 5140:
1.184 rillig 5141: The comments in those buildlink3.mk files provide a more complete description
5142: of how to use them properly.
1.1 dsieger 5143:
1.266 martin 5144: 18.2. Writing buildlink3.mk files
1.1 dsieger 5145:
1.184 rillig 5146: A package's buildlink3.mk file is included by Makefiles to indicate the need to
5147: compile and link against header files and libraries provided by the package. A
5148: buildlink3.mk file should always provide enough information to add the correct
5149: type of dependency relationship and include any other buildlink3.mk files that
5150: it needs to find headers and libraries that it needs in turn.
1.1 dsieger 5151:
1.184 rillig 5152: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
5153: pkgtools/createbuildlink package is highly recommended. For most packages, the
5154: following command will generate a good starting point for buildlink3.mk files:
1.1 dsieger 5155:
1.184 rillig 5156: % cd pkgsrc/category/pkgdir
5157: % createbuildlink >buildlink3.mk
1.1 dsieger 5158:
5159:
1.266 martin 5160: 18.2.1. Anatomy of a buildlink3.mk file
1.1 dsieger 5161:
1.184 rillig 5162: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
5163: tiff:
1.14 jmcneill 5164:
1.184 rillig 5165: BUILDLINK_TREE+= tiff
1.1 dsieger 5166:
1.184 rillig 5167: .if !defined(TIFF_BUILDLINK3_MK)
5168: TIFF_BUILDLINK3_MK:=
1.1 dsieger 5169:
1.184 rillig 5170: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
5171: BUILDLINK_ABI_DEPENDS.tiff+= tiff>=3.7.2nb1
5172: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
1.1 dsieger 5173:
1.184 rillig 5174: .include "../../devel/zlib/buildlink3.mk"
5175: .include "../../graphics/jpeg/buildlink3.mk"
5176: .endif # TIFF_BUILDLINK3_MK
1.1 dsieger 5177:
1.184 rillig 5178: BUILDLINK_TREE+= -tiff
1.1 dsieger 5179:
1.184 rillig 5180: The header and footer manipulate BUILDLINK_TREE, which is common across all
5181: buildlink3.mk files and is used to track the dependency tree.
1.1 dsieger 5182:
1.184 rillig 5183: The main section is protected from multiple inclusion and controls how the
5184: dependency on pkg is added. Several important variables are set in the section:
1.1 dsieger 5185:
1.185 wiz 5186: * BUILDLINK_API_DEPENDS.pkg is the dependency version recorded in the
1.184 rillig 5187: installed package; this should always be set using += to ensure that we're
5188: appending to any pre-existing list of values. This variable should be set
1.185 wiz 5189: to the last version of the package that had an backwards-incompatible API
1.184 rillig 5190: change.
1.1 dsieger 5191:
1.184 rillig 5192: * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
1.1 dsieger 5193:
1.184 rillig 5194: * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
1.236 gutterid 5195: BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
1.266 martin 5196: is selected by setting BUILDLINK_DEPMETHOD.pkg to build . By default, the
1.236 gutterid 5197: full dependency is used.
1.1 dsieger 5198:
1.184 rillig 5199: * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
5200: of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
1.266 martin 5201: library search paths. These default to include and lib respectively.
1.1 dsieger 5202:
1.184 rillig 5203: * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
5204: to add to CPPFLAGS, which are passed on to the configure and build phases.
1.266 martin 5205: The -I option should be avoided and instead be handled using
1.184 rillig 5206: BUILDLINK_INCDIRS.pkg as above.
1.66 asau 5207:
1.184 rillig 5208: The following variables are all optionally defined within this second section
5209: (protected against multiple inclusion) and control which package files are
5210: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
5211: symlinking:
1.23 jakllsch 5212:
1.184 rillig 5213: * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
5214: {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
5215: *.h.
1.1 dsieger 5216:
1.184 rillig 5217: * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
5218: to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
5219: resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
5220: takes the +CONTENTS of a pkg and filters it through $
5221: {BUILDLINK_CONTENTS_FILTER.pkg}.
1.1 dsieger 5222:
1.184 rillig 5223: * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
5224: filters +CONTENTS input into a list of files relative to $
5225: {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
5226: outputs the contents of the include and lib directories in the package
5227: +CONTENTS.
1.1 dsieger 5228:
1.184 rillig 5229: * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
5230: used to transform the name of the source filename into a destination
5231: filename, e.g. -e "s|/curses.h|/ncurses.h|g".
1.1 dsieger 5232:
1.184 rillig 5233: This section can additionally include any buildlink3.mk needed for pkg's
5234: library dependencies. Including these buildlink3.mk files means that the
5235: headers and libraries for these dependencies are also symlinked into $
5236: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
5237: are only added for directly include buildlink3.mk files.
1.1 dsieger 5238:
1.184 rillig 5239: When providing a buildlink3.mk and including other buildlink3.mk files in it,
5240: please only add necessary ones, i.e., those whose libraries or header files are
5241: automatically exposed when the package is use.
1.1 dsieger 5242:
1.184 rillig 5243: In particular, if only an executable (bin/foo) is linked against a library,
5244: that library does not need to be propagated in the buildlink3.mk file.
1.1 dsieger 5245:
1.184 rillig 5246: The following steps should help you decide if a buildlink3.mk file needs to be
5247: included:
1.1 dsieger 5248:
1.184 rillig 5249: * Look at the installed header files: What headers do they include? The
5250: packages providing these files must be buildlinked.
1.1 dsieger 5251:
1.184 rillig 5252: * Run ldd on all installed libraries and look against what other libraries
5253: they link. Some of the packages providing these probably need to be
5254: buildlinked; however, it's not automatic, since e.g. GTK on some systems
5255: pulls in the X libraries, so they will show up in the ldd output, while on
5256: others (like OS X) it won't. ldd output can thus only be used as a hint.
1.1 dsieger 5257:
1.266 martin 5258: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.184 rillig 5259: buildlink3.mk files
1.16 jnemeth 5260:
1.185 wiz 5261: Both variables set lower bounds for a version of this package. The two
5262: variables differ in that one describes source compatibility (API) and the other
5263: binary compatibility (ABI). The difference is that a change in the API breaks
5264: compilation of programs while changes in the ABI stop compiled programs from
5265: running.
5266:
5267: The BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk should be changed
5268: very rarely. (One possible scenario: If all packages using this package need a
5269: higher version than defined in the buildlink3.mk, BUILDLINK_API_DEPENDS.pkg
5270: could be updated to that higher version.)
5271:
5272: On the other hand, changes to BUILDLINK_ABI_DEPENDS.pkg are more common. The
5273: variable will need to be updated every time the major version of one of its
5274: shared libraries is changed, or any other change where a binary built against
5275: the previous version of the package will not run against the new version any
5276: longer.
5277:
5278: In such a case, the package's BUILDLINK_ABI_DEPENDS.pkg must be increased to
5279: require the new package version. Then the PKGREVISION of all packages foo that
5280: depend on this package need to be increased, and if they have buildlink3.mk
5281: files, BUILDLINK_ABI_DEPENDS.foo in their buildlink3.mk files must be increased
5282: to the new version as well. This is required so that a package will pull in the
5283: versions of the packages that use the new ABI and that the packages'
5284: PKGREVISIONs uniquely identify the packages built against the new ABI. The
5285: pkgtools/revbump package can help with these updates.
1.1 dsieger 5286:
1.266 martin 5287: See Section 21.1.5, Handling dependencies for more information about
1.185 wiz 5288: dependencies on other packages, including the BUILDLINK_API_DEPENDS
5289: definitions.
1.1 dsieger 5290:
1.184 rillig 5291: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
1.185 wiz 5292: BUILDLINK_ABI_DEPENDS.pkg in a buildlink3.mk file as we don't want to cause
5293: unneeded package deletions and rebuilds. In many cases, new versions of
5294: packages work just fine with older dependencies.
1.1 dsieger 5295:
1.211 gutterid 5296: Also, it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
1.184 rillig 5297: BUILDLINK_API_DEPENDS.pkg.
1.1 dsieger 5298:
1.211 gutterid 5299: Note there is also the distinction that users are able to disable enforcement
5300: of ABI dependencies using the USE_ABI_DEPENDS variable, but there is no
5301: equivalent option for API dependencies.
5302:
1.266 martin 5303: 18.3. Writing builtin.mk files
1.1 dsieger 5304:
1.184 rillig 5305: Some packages in pkgsrc install headers and libraries that coincide with
5306: headers and libraries present in the base system. Aside from a buildlink3.mk
5307: file, these packages should also include a builtin.mk file that includes the
5308: necessary checks to decide whether using the built-in software or the pkgsrc
5309: software is appropriate.
1.1 dsieger 5310:
1.184 rillig 5311: The only requirements of a builtin.mk file for pkg are:
1.1 dsieger 5312:
1.266 martin 5313: 1. It should set USE_BUILTIN.pkg to either yes or no after it is included.
1.1 dsieger 5314:
1.184 rillig 5315: 2. It should not override any USE_BUILTIN.pkg which is already set before the
5316: builtin.mk file is included.
1.1 dsieger 5317:
1.184 rillig 5318: 3. It should be written to allow multiple inclusion. This is very important
5319: and takes careful attention to Makefile coding.
1.1 dsieger 5320:
1.266 martin 5321: 18.3.1. Anatomy of a builtin.mk file
1.1 dsieger 5322:
1.184 rillig 5323: The following is the recommended template for builtin.mk files:
1.1 dsieger 5324:
1.184 rillig 5325: .if !defined(IS_BUILTIN.foo)
5326: #
5327: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
5328: # genuinely exists in the system or not.
5329: #
5330: IS_BUILTIN.foo?= no
1.1 dsieger 5331:
1.184 rillig 5332: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
5333: # version can be determined.
5334: #
5335: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
5336: BUILTIN_PKG.foo?= foo-1.0
5337: . endif
5338: .endif # IS_BUILTIN.foo
1.1 dsieger 5339:
1.184 rillig 5340: .if !defined(USE_BUILTIN.foo)
5341: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
5342: . if defined(BUILTIN_PKG.foo)
5343: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
5344: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
5345: USE_BUILTIN.foo!= \
5346: ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo} \
5347: && ${ECHO} "yes" || ${ECHO} "no"
5348: . endif
5349: . endfor
5350: . endif
5351: .endif # USE_BUILTIN.foo
1.1 dsieger 5352:
1.184 rillig 5353: CHECK_BUILTIN.foo?= no
5354: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
5355: #
5356: # Here we place code that depends on whether USE_BUILTIN.foo is set to
5357: # "yes" or "no".
5358: #
5359: .endif # CHECK_BUILTIN.foo
1.1 dsieger 5360:
1.184 rillig 5361: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
5362: base system. This should not be a base system software with similar
1.266 martin 5363: functionality to pkg; it should only be yes if the actual package is included
1.184 rillig 5364: as part of the base system. This variable is only used internally within the
5365: builtin.mk file.
1.1 dsieger 5366:
1.184 rillig 5367: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
1.266 martin 5368: system if it exists (if IS_BUILTIN.pkg is yes ). This variable is only used
1.184 rillig 5369: internally within the builtin.mk file.
1.1 dsieger 5370:
1.184 rillig 5371: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
5372: The code in this section must make the determination whether the built-in
5373: software is adequate to satisfy the dependencies listed in
5374: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
5375: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg
5376: must be set to the correct value by the end of the builtin.mk file. Note that
1.266 martin 5377: USE_BUILTIN.pkg may be yes even if IS_BUILTIN.pkg is no because we may make
1.184 rillig 5378: the determination that the built-in version of the software is similar enough
5379: to be used as a replacement.
1.1 dsieger 5380:
1.184 rillig 5381: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
5382: the value of USE_BUILTIN.pkg set in the previous section. This typically
5383: includes, e.g., adding additional dependency restrictions and listing
5384: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
1.1 dsieger 5385:
1.266 martin 5386: Chapter 19. PLIST issues
1.1 dsieger 5387:
1.184 rillig 5388: Table of Contents
1.1 dsieger 5389:
1.184 rillig 5390: 19.1. RCS ID
5391: 19.2. Semi-automatic PLIST generation
5392: 19.3. Tweaking output of make print-PLIST
5393: 19.4. Variable substitution in PLIST
5394: 19.5. Man page compression
5395: 19.6. Changing PLIST source with PLIST_SRC
5396: 19.7. Platform-specific and differing PLISTs
5397: 19.8. Build-specific PLISTs
5398: 19.9. Sharing directories between packages
1.1 dsieger 5399:
1.266 martin 5400: The PLIST file contains a package's packing list , i.e. a list of files that
1.184 rillig 5401: belong to the package (relative to the ${PREFIX} directory it's been installed
5402: in) plus some additional statements - see the pkg_create(1) man page for a full
5403: list. This chapter addresses some issues that need attention when dealing with
5404: the PLIST file (or files, see below!).
1.1 dsieger 5405:
1.266 martin 5406: 19.1. RCS ID
1.1 dsieger 5407:
1.184 rillig 5408: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
1.1 dsieger 5409:
1.184 rillig 5410: @comment $NetBSD $
1.1 dsieger 5411:
1.184 rillig 5412: An artificial space has been added between NetBSD and $, this is a workaround
5413: here to prevent CVS expanding to the filename of the guide. When adding the RCS
5414: ID the space should be omitted.
1.38 wiz 5415:
1.266 martin 5416: 19.2. Semi-automatic PLIST generation
1.1 dsieger 5417:
1.184 rillig 5418: You can use the make print-PLIST command to output a PLIST that matches any new
1.266 martin 5419: files since the package was extracted. See Section 13.17, Other helpful
5420: targets for more information on this target.
1.11 rillig 5421:
1.266 martin 5422: 19.3. Tweaking output of make print-PLIST
1.1 dsieger 5423:
1.184 rillig 5424: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
5425: used to filter the output of print-PLIST. You can append any chunk of AWK
5426: scripting you like to it, but be careful with quoting.
1.1 dsieger 5427:
1.184 rillig 5428: For example, to get all files inside the libdata/foo directory removed from the
5429: resulting PLIST:
1.1 dsieger 5430:
1.184 rillig 5431: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
1.1 dsieger 5432:
1.185 wiz 5433: The PRINT_PLIST_AWK transformations are evaluated after the file list and
5434: directory list are sorted. EARLY_PRINT_PLIST_AWK is like PRINT_PLIST_AWK except
5435: it operates before the file list and directory list are sorted.
5436:
1.266 martin 5437: 19.4. Variable substitution in PLIST
1.1 dsieger 5438:
1.184 rillig 5439: A number of variables are substituted automatically in PLISTs when a package is
5440: installed on a system. This includes the following variables:
1.1 dsieger 5441:
1.184 rillig 5442: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
1.1 dsieger 5443:
1.184 rillig 5444: Some packages like emacs and perl embed information about which
5445: architecture they were built on into the pathnames where they install their
5446: files. To handle this case, PLIST will be preprocessed before actually
1.266 martin 5447: used, and the symbol ${MACHINE_ARCH} will be replaced by what uname -p
1.184 rillig 5448: gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
5449: PLIST somewhere - use this on packages that have GNU autoconf-created
5450: configure scripts.
1.1 dsieger 5451:
1.184 rillig 5452: Legacy note
1.1 dsieger 5453:
1.266 martin 5454: There used to be a symbol $ARCH that was replaced by the output of uname
1.184 rillig 5455: -m, but that's no longer supported and has been removed.
1.1 dsieger 5456:
1.184 rillig 5457: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
1.1 dsieger 5458:
1.184 rillig 5459: Some packages want to embed the OS name and version into some paths. To do
5460: this, use these variables in the PLIST:
1.1 dsieger 5461:
1.271 wiz 5462: o ${OPSYS} - output of uname -s
1.1 dsieger 5463:
1.271 wiz 5464: o ${LOWER_OPSYS} - lowercase common name (eg. solaris )
1.1 dsieger 5465:
1.271 wiz 5466: o ${OS_VERSION} - uname -r
1.1 dsieger 5467:
1.184 rillig 5468: For a list of values which are replaced by default, the output of make help
5469: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
5470: PLIST_SUBST should help.
1.1 dsieger 5471:
1.184 rillig 5472: If you want to change other variables not listed above, you can add variables
5473: and their expansions to this variable in the following way, similar to
1.266 martin 5474: MESSAGE_SUBST (see Section 12.5, Optional files ):
1.1 dsieger 5475:
1.184 rillig 5476: PLIST_SUBST+= SOMEVAR="somevalue"
1.1 dsieger 5477:
1.266 martin 5478: This replaces all occurrences of ${SOMEVAR} in the PLIST with somevalue .
1.1 dsieger 5479:
1.184 rillig 5480: The PLIST_VARS variable can be used to simplify the common case of
5481: conditionally including some PLIST entries. It can be done by adding
5482: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
1.266 martin 5483: entry should be included. This will substitute ${PLIST.foo} in the PLIST with
5484: either "" or "@comment " . For example, in Makefile:
1.1 dsieger 5485:
1.184 rillig 5486: PLIST_VARS+= foo
5487: .if condition
5488: PLIST.foo= yes
5489: .else
1.1 dsieger 5490:
1.184 rillig 5491: And then in PLIST:
1.1 dsieger 5492:
1.184 rillig 5493: @comment $NetBSD $
5494: bin/bar
5495: man/man1/bar.1
5496: ${PLIST.foo}bin/foo
5497: ${PLIST.foo}man/man1/foo.1
5498: ${PLIST.foo}share/bar/foo.data
1.1 dsieger 5499:
1.184 rillig 5500: An artificial space has been added between NetBSD and $, this is a workaround
5501: here to prevent CVS expanding to the filename of the guide. When adding the RCS
1.195 gutterid 5502: ID the space should be omitted.
1.1 dsieger 5503:
1.266 martin 5504: 19.5. Man page compression
1.1 dsieger 5505:
1.184 rillig 5506: Man pages should be installed in compressed form if MANZ is set (in
5507: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
1.266 martin 5508: suffix .gz is appended/removed automatically for man pages according to MANZ
1.184 rillig 5509: and MANCOMPRESSED being set or not, see above for details. This modification of
5510: the PLIST file is done on a copy of it, not PLIST itself.
1.100 leot 5511:
1.266 martin 5512: 19.6. Changing PLIST source with PLIST_SRC
1.100 leot 5513:
1.184 rillig 5514: To use one or more files as source for the PLIST used in generating the binary
5515: package, set the variable PLIST_SRC to the names of that file(s). The files are
5516: later concatenated using cat(1), and the order of things is important. The
5517: default for PLIST_SRC is ${PKGDIR}/PLIST.
1.1 dsieger 5518:
1.266 martin 5519: 19.7. Platform-specific and differing PLISTs
1.1 dsieger 5520:
1.184 rillig 5521: Some packages decide to install a different set of files based on the operating
5522: system being used. These differences can be automatically handled by using the
5523: following files:
1.1 dsieger 5524:
1.184 rillig 5525: * PLIST.common
1.1 dsieger 5526:
1.184 rillig 5527: * PLIST.${OPSYS}
1.1 dsieger 5528:
1.184 rillig 5529: * PLIST.${MACHINE_ARCH}
1.1 dsieger 5530:
1.184 rillig 5531: * PLIST.${OPSYS}-${MACHINE_ARCH}
1.1 dsieger 5532:
1.184 rillig 5533: * PLIST.common_end
1.1 dsieger 5534:
1.266 martin 5535: 19.8. Build-specific PLISTs
1.1 dsieger 5536:
1.184 rillig 5537: Some packages decide to generate hard-to-guess file names during installation
5538: that are hard to wire down.
1.1 dsieger 5539:
1.184 rillig 5540: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
5541: (with a semicolon) that will output PLIST entries which will be appended to the
5542: PLIST
1.1 dsieger 5543:
1.184 rillig 5544: You can find one example in editors/xemacs:
1.1 dsieger 5545:
1.184 rillig 5546: GENERATE_PLIST+= ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.1 dsieger 5547:
1.184 rillig 5548: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
1.1 dsieger 5549:
1.266 martin 5550: 19.9. Sharing directories between packages
1.1 dsieger 5551:
1.266 martin 5552: A shared directory is a directory where multiple (and unrelated) packages
1.184 rillig 5553: install files. These directories were problematic because you had to add
5554: special tricks in the PLIST to conditionally remove them, or have some
5555: centralized package handle them.
1.106 tnn 5556:
1.184 rillig 5557: In pkgsrc, it is now easy: Each package should create directories and install
5558: files as needed; pkg_delete will remove any directories left empty after
5559: uninstalling a package.
1.106 tnn 5560:
1.184 rillig 5561: If a package needs an empty directory to work, create the directory during
5562: installation as usual, and also add an entry to the PLIST:
1.1 dsieger 5563:
1.184 rillig 5564: @pkgdir path/to/empty/directory
1.1 dsieger 5565:
1.184 rillig 5566: or take a look at MAKE_DIRS and OWN_DIRS.
1.1 dsieger 5567:
1.266 martin 5568: Chapter 20. The pkginstall framework
1.1 dsieger 5569:
1.184 rillig 5570: Table of Contents
1.1 dsieger 5571:
1.184 rillig 5572: 20.1. Files and directories outside the installation prefix
5573: 20.1.1. Directory manipulation
5574: 20.1.2. File manipulation
5575: 20.2. Configuration files
5576: 20.2.1. How PKG_SYSCONFDIR is set
5577: 20.2.2. Telling the software where configuration files are
1.239 dholland 5578: 20.2.3. Patching installation
5579: 20.2.4. Declaring configuration files
5580: 20.2.5. Disabling handling of configuration files
1.184 rillig 5581: 20.3. System startup scripts
5582: 20.3.1. Disabling handling of system startup scripts
5583: 20.4. System users and groups
5584: 20.5. System shells
5585: 20.5.1. Disabling shell registration
5586: 20.6. Fonts
5587: 20.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 5588:
1.184 rillig 5589: This chapter describes the framework known as pkginstall, whose key features
5590: are:
1.1 dsieger 5591:
1.184 rillig 5592: * Generic installation and manipulation of directories and files outside the
5593: pkgsrc-handled tree, LOCALBASE.
1.1 dsieger 5594:
1.184 rillig 5595: * Automatic handling of configuration files during installation, provided
5596: that packages are correctly designed.
1.1 dsieger 5597:
1.184 rillig 5598: * Generation and installation of system startup scripts.
1.1 dsieger 5599:
1.184 rillig 5600: * Registration of system users and groups.
1.1 dsieger 5601:
1.184 rillig 5602: * Registration of system shells.
1.1 dsieger 5603:
1.184 rillig 5604: * Automatic updating of fonts databases.
1.1 dsieger 5605:
1.184 rillig 5606: The following sections inspect each of the above points in detail.
1.1 dsieger 5607:
1.184 rillig 5608: You may be thinking that many of the things described here could be easily done
5609: with simple code in the package's post-installation target (post-install). This
5610: is incorrect, as the code in them is only executed when building from source.
5611: Machines using binary packages could not benefit from it at all (as the code
5612: itself could be unavailable). Therefore, the only way to achieve any of the
5613: items described above is by means of the installation scripts, which are
5614: automatically generated by pkginstall.
1.1 dsieger 5615:
1.266 martin 5616: 20.1. Files and directories outside the installation prefix
1.95 wiz 5617:
1.184 rillig 5618: As you already know, the PLIST file holds a list of files and directories that
5619: belong to a package. The names used in it are relative to the installation
5620: prefix (${PREFIX}), which means that it cannot register files outside this
5621: directory (absolute path names are not allowed). Despite this restriction, some
5622: packages need to install files outside this location; e.g., under ${VARBASE} or
5623: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
5624: installation time by using installation scripts.
1.95 wiz 5625:
1.184 rillig 5626: The generic installation scripts are shell scripts that can contain arbitrary
5627: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
5628: which defaults to INSTALL. A similar variable exists for package removal
5629: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
5630: commands, so they have the potential to create and manage files anywhere in the
5631: file system.
1.95 wiz 5632:
1.184 rillig 5633: Using these general installation files is not recommended, but may be needed in
5634: some special cases. One reason for avoiding them is that the user has to trust
5635: the packager that there is no unwanted or simply erroneous code included in the
5636: installation script. Also, previously there were many similar scripts for the
5637: same functionality, and fixing a common error involved finding and changing all
5638: of them.
1.95 wiz 5639:
1.184 rillig 5640: The pkginstall framework offers another, standardized way. It provides generic
5641: scripts to abstract the manipulation of such files and directories based on
5642: variables set in the package's Makefile. The rest of this section describes
5643: these variables.
1.1 dsieger 5644:
1.266 martin 5645: 20.1.1. Directory manipulation
1.1 dsieger 5646:
1.184 rillig 5647: The following variables can be set to request the creation of directories
5648: anywhere in the file system:
1.1 dsieger 5649:
1.184 rillig 5650: * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
5651: and should attempt to be destroyed by the installation scripts. The
5652: difference between the two is that the latter prompts the administrator to
5653: remove any directories that may be left after deinstallation (because they
5654: were not empty), while the former does not. Example:
1.1 dsieger 5655:
1.184 rillig 5656: MAKE_DIRS+= ${VARBASE}/foo/private
1.1 dsieger 5657:
1.184 rillig 5658: * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
5659: which directories should be created and should attempt to be destroyed by
5660: the installation scripts. Each tuple holds the following values, separated
5661: by spaces: the directory name, its owner, its group and its numerical mode.
5662: For example:
1.1 dsieger 5663:
1.184 rillig 5664: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private \
5665: ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1 dsieger 5666:
1.184 rillig 5667: The difference between the two is exactly the same as their non-PERMS
5668: counterparts.
1.1 dsieger 5669:
1.266 martin 5670: 20.1.2. File manipulation
1.1 dsieger 5671:
1.184 rillig 5672: Creating non-empty files outside the installation prefix is tricky because the
5673: PLIST forces all files to be inside it. To overcome this problem, the only
1.239 dholland 5674: solution is to extract the file in a known place (i.e., inside the installation
5675: prefix) and copy it to the appropriate location during installation (done by
5676: the installation scripts generated by pkginstall). We will call the former the
5677: reference file in the following paragraphs, which describe the variables that
5678: can be used to automatically and consistently handle files outside the
5679: installation prefix:
5680:
5681: * REQD_FILES is a list of pairs of reference and target files. At
5682: installation time, the reference file is copied to the target if and only
5683: if the latter does not exist. Upon deinstallation, the reference file is
1.184 rillig 5684: removed provided that it was not modified by the installation.
1.1 dsieger 5685:
1.239 dholland 5686: * REQD_FILES_PERMS contains tuples describing reference files and targets,
5687: including owner, group, and numeric permissions that should be set. For
5688: example:
1.1 dsieger 5689:
1.184 rillig 5690: REQD_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile \
5691: ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1 dsieger 5692:
1.239 dholland 5693: * CONF_FILES and CONF_FILES_PERMS have the same syntax as REQD_FILES and
5694: REQD_FILES_PERMS respectively. The difference is that these variables are
5695: specifically intended for handling configuration files, for which
1.266 martin 5696: additional conventions and constraints apply. See Section 20.2,
5697: Configuration files for further discussion. Note in particular that while
1.239 dholland 5698: handling of configuration files can be disabled by the user (see
1.266 martin 5699: Section 20.2.5, Disabling handling of configuration files ), this setting
1.239 dholland 5700: does not affect REQD_FILES and REQD_FILES_PERMS.
5701:
5702: To install an empty file, one can use these macros and /dev/null as the
5703: reference file.
1.1 dsieger 5704:
1.266 martin 5705: 20.2. Configuration files
1.1 dsieger 5706:
1.239 dholland 5707: There are two principles that govern the handling of configuration files in
5708: pkgsrc: first, the user's configuration must not be lost or overwritten by
5709: upgrades or reinstallations; and second, the default configuration should
5710: always be available for reference. To that end, pkgsrc has a framework
5711: specifically for handling configuration files. In general, configuration files
5712: are installed into ${PREFIX}/share/examples, and copied from there to the
5713: pertinent etc directory as a separate step and only as needed.
5714:
5715: To make this work, there are three things that need to happen, any of which may
5716: require patching. First, the package must be told to read its configuration
5717: from the correct place at runtime; this place is ${PKG_SYSCONFDIR} (or possibly
5718: a subdirectory of it) which is often but not always ${PREFIX}/etc. Second, the
5719: package must be taught to install its default configuration files in ${PREFIX}/
5720: share/examples/${PKGBASE}; this is the point at which patching often becomes
5721: required because it is not the same place as the runtime location. Third, the
5722: configuration files need to be declared in the package makefile; this is the
5723: easy part.
5724:
5725: With those elements in place, the right things will happen: the package install
5726: phase and resulting binary package will not touch ${PKG_SYSCONFDIR}, and the
5727: default configuration will be copied into place by the pkgsrc framework only if
5728: not already present. Similarly, upon deinstall the configuration will not be
5729: removed if it has been modified. (This means that in the case of reinstallation
5730: and upgrades, unmodified configuration files are updated but modifications are
5731: never discarded.)
5732:
5733: The following sections describe how to make these things happen and document
5734: other relevant knobs available in the pkgsrc infrastructure.
1.1 dsieger 5735:
1.266 martin 5736: 20.2.1. How PKG_SYSCONFDIR is set
1.1 dsieger 5737:
1.184 rillig 5738: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
5739: shall be installed. Its contents are set based upon the following variables:
1.1 dsieger 5740:
1.184 rillig 5741: * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
1.239 dholland 5742: etc although it may be overridden by the user to point to their preferred
1.184 rillig 5743: location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
1.1 dsieger 5744:
1.184 rillig 5745: * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
5746: configuration files for the package being built shall be installed. The
5747: definition of this variable only makes sense in the package's Makefile
5748: (i.e., it is not user-customizable).
1.1 dsieger 5749:
1.184 rillig 5750: As an example, consider the Apache package, www/apache24, which places its
5751: configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
5752: should be set in the package Makefile.
1.1 dsieger 5753:
1.184 rillig 5754: * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
5755: package's configuration directory (if different from PKG_SYSCONFBASE). It
5756: defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
1.1 dsieger 5757:
1.184 rillig 5758: * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
5759: configuration files for the package identified by PKG_SYSCONFVAR's shall be
5760: placed.
1.1 dsieger 5761:
1.184 rillig 5762: Based on the above variables, pkginstall determines the value of
1.239 dholland 5763: PKG_SYSCONFDIR, which is the only variable that may be used within a package to
1.184 rillig 5764: refer to its configuration directory. The algorithm used to set its value is
5765: basically the following:
1.1 dsieger 5766:
1.184 rillig 5767: 1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
1.1 dsieger 5768:
1.184 rillig 5769: 2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
5770: package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
5771: {PKG_SYSCONFSUBDIR}.
1.1 dsieger 5772:
1.184 rillig 5773: 3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
1.1 dsieger 5774:
1.184 rillig 5775: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
1.239 dholland 5776: OWN_DIRS. This causes it to be automatically created if needed. See
1.266 martin 5777: Section 20.1.1, Directory manipulation for further details. This does not
1.239 dholland 5778: apply to subdirectories of ${PKG_SYSCONFDIR}; they must be manually created
5779: with OWN_DIRS or MAKE_DIRS.
1.1 dsieger 5780:
1.266 martin 5781: 20.2.2. Telling the software where configuration files are
1.1 dsieger 5782:
1.184 rillig 5783: Given that pkgsrc (and users!) expect configuration files to be in a known
1.239 dholland 5784: place, you need to teach each package where to install its files. In some cases
5785: you will have to patch the package Makefiles to achieve it. If you are lucky,
5786: though, it may be as easy as passing an extra flag to the configuration script.
5787: This is the case for packages using GNU autoconf:
1.1 dsieger 5788:
1.184 rillig 5789: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1 dsieger 5790:
1.184 rillig 5791: Note that this specifies where the package has to look for its configuration
1.239 dholland 5792: files, not where they will be installed. Fortunately, there is a different way
1.240 gutterid 5793: to specify the latter, as seen in the next section, although the combination is
5794: rather confusing at first glance.
1.1 dsieger 5795:
1.266 martin 5796: 20.2.3. Patching installation
1.1 dsieger 5797:
1.239 dholland 5798: As discussed above, packages themselves must not touch the contents of $
1.184 rillig 5799: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
5800: will, out of the box, mess with the contents of that directory. So what is the
5801: correct procedure to fix this issue?
1.1 dsieger 5802:
1.184 rillig 5803: You must teach the package (usually by manually patching it) to install any
5804: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
5805: This way, the PLIST registers them and the administrator always has the
5806: original copies available.
1.1 dsieger 5807:
1.239 dholland 5808: It turns out that for packages using GNU autoconf it is possible to create the
5809: desired effect by setting sysconfdir on the make command line at install time.
5810: Consider this example taken from mail/mutt:
5811:
5812: EGDIR= ${PREFIX}/share/examples/mutt
5813: INSTALL_MAKE_FLAGS= ${MAKE_FLAGS} sysconfdir=${EGDIR}
5814:
5815: Note that the EGDIR variable, though commonly used for this purpose, is local
5816: to that package and has no meaning outside it.
1.1 dsieger 5817:
1.266 martin 5818: 20.2.4. Declaring configuration files
1.1 dsieger 5819:
1.239 dholland 5820: Once the required configuration files are in place (i.e., under the examples
5821: hierarchy), the pkginstall framework can use them as reference copies during
5822: the package installation to update what is in ${PKG_SYSCONFDIR}. To achieve
5823: this, the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
1.266 martin 5824: Section 20.1.2, File manipulation for further information about their syntax
1.239 dholland 5825: and their purpose. Here is an example, taken from the mail/mutt package:
5826:
5827: EGDIR= ${PREFIX}/share/examples/mutt
5828: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
5829:
5830: Note that (as in the previous section's example) the EGDIR variable is specific
5831: to the package and has no meaning outside it.
5832:
5833: For reference, the complete example from Mutt is as follows:
5834:
5835: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
5836: EGDIR= ${PREFIX}/share/examples/mutt
5837: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
5838: INSTALLATION_DIRS+= ${EGDIR}
5839: INSTALL_MAKE_FLAGS= ${MAKE_FLAGS} sysconfdir=${EGDIR}
1.1 dsieger 5840:
1.266 martin 5841: 20.2.5. Disabling handling of configuration files
1.1 dsieger 5842:
1.184 rillig 5843: The automatic copying of config files can be toggled by setting the environment
5844: variable PKG_CONFIG prior to package installation.
1.1 dsieger 5845:
1.266 martin 5846: 20.3. System startup scripts
1.1 dsieger 5847:
1.184 rillig 5848: System startup scripts are special files because they must be installed in a
5849: place known by the underlying OS, usually outside the installation prefix.
1.266 martin 5850: Therefore, the same rules described in Section 20.1, Files and directories
5851: outside the installation prefix apply, and the same solutions can be used.
1.184 rillig 5852: However, pkginstall provides a special mechanism to handle these files.
1.1 dsieger 5853:
1.184 rillig 5854: In order to provide system startup scripts, the package has to:
1.1 dsieger 5855:
1.184 rillig 5856: 1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
1.223 nia 5857: Considering the print/cups-base package as an example, it has a cupsd.sh in
5858: its files directory.
1.95 wiz 5859:
1.184 rillig 5860: 2. Tell pkginstall to handle it, appending the name of the script, without its
5861: extension, to the RCD_SCRIPTS variable. Continuing the previous example:
1.95 wiz 5862:
1.184 rillig 5863: RCD_SCRIPTS+= cupsd
1.95 wiz 5864:
1.184 rillig 5865: Once this is done, pkginstall will do the following steps for each script in an
5866: automated fashion:
1.95 wiz 5867:
1.184 rillig 5868: 1. Process the file found in the files directory applying all the
5869: substitutions described in the FILES_SUBST variable.
1.1 dsieger 5870:
1.184 rillig 5871: 2. Copy the script from the files directory to the examples hierarchy, $
1.239 dholland 5872: {PREFIX}/share/examples/rc.d/. Note that this reference file must be
1.184 rillig 5873: explicitly registered in the PLIST.
1.1 dsieger 5874:
1.184 rillig 5875: 3. Add code to the installation scripts to copy the startup script from the
5876: examples hierarchy into the system-wide startup scripts directory.
1.1 dsieger 5877:
1.266 martin 5878: 20.3.1. Disabling handling of system startup scripts
1.1 dsieger 5879:
1.184 rillig 5880: The automatic copying of config files can be toggled by setting the environment
5881: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
5882: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
5883: rc.d/, no matter what the value of this variable is.
1.1 dsieger 5884:
1.266 martin 5885: 20.4. System users and groups
1.1 dsieger 5886:
1.184 rillig 5887: If a package needs to create special users and/or groups during installation,
5888: it can do so by using the pkginstall framework.
1.1 dsieger 5889:
1.184 rillig 5890: Users can be created by adding entries to the PKG_USERS variable. Each entry
5891: has the following syntax:
1.1 dsieger 5892:
1.184 rillig 5893: user:group
1.1 dsieger 5894:
1.184 rillig 5895: Further specification of user details may be done by setting per-user
5896: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
5897: user's description or comment. PKG_HOME.user is the user's home directory, and
5898: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
5899: and defaults to /sbin/nologin if not specified.
1.1 dsieger 5900:
1.184 rillig 5901: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
5902: whose syntax is:
1.1 dsieger 5903:
1.184 rillig 5904: group
1.1 dsieger 5905:
1.184 rillig 5906: The numeric GID of the group may be set by defining PKG_GID.group.
1.1 dsieger 5907:
1.184 rillig 5908: If a package needs to create the users and groups at an earlier stage, then it
5909: can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
5910: the phase before which the users and groups are created. In this case, the
5911: numeric UIDs and GIDs of the created users and groups are automatically
5912: hardcoded into the final installation scripts.
1.1 dsieger 5913:
1.266 martin 5914: 20.5. System shells
1.1 dsieger 5915:
1.184 rillig 5916: Packages that install system shells should register them in the shell database,
5917: /etc/shells, to make things easier to the administrator. This must be done from
5918: the installation scripts to keep binary packages working on any system.
5919: pkginstall provides an easy way to accomplish this task.
1.1 dsieger 5920:
1.184 rillig 5921: When a package provides a shell interpreter, it has to set the PKG_SHELL
5922: variable to its absolute file name. This will add some hooks to the
5923: installation scripts to handle it. Consider the following example, taken from
5924: shells/zsh:
1.1 dsieger 5925:
1.184 rillig 5926: PKG_SHELL= ${PREFIX}/bin/zsh
1.1 dsieger 5927:
1.266 martin 5928: 20.5.1. Disabling shell registration
1.1 dsieger 5929:
1.184 rillig 5930: The automatic registration of shell interpreters can be disabled by the
5931: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
1.1 dsieger 5932:
1.266 martin 5933: 20.6. Fonts
1.1 dsieger 5934:
1.184 rillig 5935: Packages that install X11 fonts should update the database files that index the
5936: fonts within each fonts directory. This can easily be accomplished within the
5937: pkginstall framework.
1.1 dsieger 5938:
1.184 rillig 5939: When a package installs X11 fonts, it must list the directories in which fonts
1.266 martin 5940: are installed in the FONTS_DIRS.type variables, where type can be one of ttf ,
5941: type1 or x11 . This will add hooks to the installation scripts to run the
1.184 rillig 5942: appropriate commands to update the fonts database files within each of those
5943: directories. For convenience, if the directory path is relative, it is taken to
5944: be relative to the package's installation prefix. Consider the following
5945: example, taken from fonts/dbz-ttf:
1.1 dsieger 5946:
1.184 rillig 5947: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1 dsieger 5948:
1.266 martin 5949: 20.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 5950:
1.184 rillig 5951: The automatic update of fonts databases can be disabled by the administrator by
5952: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
1.1 dsieger 5953:
1.266 martin 5954: Chapter 21. Making your package work
1.1 dsieger 5955:
5956: Table of Contents
5957:
1.154 rillig 5958: 21.1. General operation
5959: 21.1.1. How to pull in user-settable variables from mk.conf
5960: 21.1.2. User interaction
5961: 21.1.3. Handling licenses
5962: 21.1.4. Restricted packages
5963: 21.1.5. Handling dependencies
5964: 21.1.6. Handling conflicts with other packages
5965: 21.1.7. Packages that cannot or should not be built
5966: 21.1.8. Packages which should not be deleted, once installed
5967: 21.1.9. Handling packages with security problems
5968: 21.1.10. How to handle incrementing versions when fixing an existing
1.271 wiz 5969: package
1.154 rillig 5970: 21.1.11. Substituting variable text in the package files (the SUBST
1.271 wiz 5971: framework)
1.154 rillig 5972: 21.2. The fetch phase
5973: 21.2.1. Packages whose distfiles aren't available for plain downloading
5974: 21.2.2. How to handle modified distfiles with the 'old' name
5975: 21.2.3. Packages hosted on github.com
5976: 21.3. The configure phase
5977: 21.3.1. Shared libraries - libtool
5978: 21.3.2. Using libtool on GNU packages that already support libtool
5979: 21.3.3. GNU Autoconf/Automake
1.223 nia 5980: 21.3.4. Meson / ninja
1.260 wiz 5981: 21.3.5. Determining the endianness
1.154 rillig 5982: 21.4. Programming languages
5983: 21.4.1. C, C++, and Fortran
5984: 21.4.2. Java
1.205 wiz 5985: 21.4.3. Go
1.223 nia 5986: 21.4.4. Rust
5987: 21.4.5. Packages containing Perl scripts
5988: 21.4.6. Packages containing shell scripts
5989: 21.4.7. Other programming languages
1.154 rillig 5990: 21.5. The build phase
5991: 21.5.1. Compiling C and C++ code conditionally
5992: 21.5.2. How to handle compiler bugs
1.172 rillig 5993: 21.5.3. No such file or directory
1.266 martin 5994: 21.5.4. Undefined reference to ...
1.172 rillig 5995: 21.5.5. Running out of memory
1.154 rillig 5996: 21.6. The install phase
5997: 21.6.1. Creating needed directories
5998: 21.6.2. Where to install documentation
5999: 21.6.3. Installing highscore files
6000: 21.6.4. Adding DESTDIR support to packages
6001: 21.6.5. Packages with hardcoded paths to other interpreters
1.203 nia 6002: 21.6.6. Packages installing Perl modules
1.254 wiz 6003: 21.6.7. Packages installing pkg-config files
6004: 21.6.8. Packages installing info files
6005: 21.6.9. Packages installing man pages
6006: 21.6.10. Packages installing X11 fonts
6007: 21.6.11. Packages installing SGML or XML data
6008: 21.6.12. Packages installing extensions to the MIME database
6009: 21.6.13. Packages using intltool
6010: 21.6.14. Packages installing startup scripts
6011: 21.6.15. Packages installing TeX modules
6012: 21.6.16. Packages supporting running binaries in emulation
6013: 21.6.17. Packages installing hicolor icons
6014: 21.6.18. Packages installing desktop files
1.154 rillig 6015: 21.7. Marking packages as having problems
1.1 dsieger 6016:
1.266 martin 6017: 21.1. General operation
1.1 dsieger 6018:
6019: One appealing feature of pkgsrc is that it runs on many different platforms. As
6020: a result, it is important to ensure, where possible, that packages in pkgsrc
6021: are portable. This chapter mentions some particular details you should pay
6022: attention to while working on pkgsrc.
6023:
1.266 martin 6024: 21.1.1. How to pull in user-settable variables from mk.conf
1.1 dsieger 6025:
6026: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4 rillig 6027: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
6028: those variables in the preprocessor directives of make(1) (for example .if or
6029: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
6030: loads the user preferences.
1.1 dsieger 6031:
6032: But note that some variables may not be completely defined after ../../mk/
6033: bsd.prefs.mk has been included, as they may contain references to variables
1.108 rillig 6034: that are not yet defined. In shell commands (the lines in Makefile that are
6035: indented with a tab) this is no problem, since variables are only expanded when
6036: they are used. But in the preprocessor directives mentioned above and in
6037: dependency lines (of the form target: dependencies) the variables are expanded
6038: at load time.
1.1 dsieger 6039:
6040: Note
6041:
1.108 rillig 6042: To check whether a variable can be used at load time, run pkglint -Wall on your
6043: package.
1.1 dsieger 6044:
1.266 martin 6045: 21.1.2. User interaction
1.1 dsieger 6046:
6047: Occasionally, packages require interaction from the user, and this can be in a
6048: number of ways:
6049:
6050: * When fetching the distfiles, some packages require user interaction such as
6051: entering username/password or accepting a license on a web page.
6052:
6053: * When extracting the distfiles, some packages may ask for passwords.
6054:
6055: * help to configure the package before it is built
6056:
6057: * help during the build process
6058:
6059: * help during the installation of a package
6060:
1.108 rillig 6061: A package can set the INTERACTIVE_STAGE variable to define which stages need
6062: interaction. This should be done in the package's Makefile, e.g.:
1.1 dsieger 6063:
6064: INTERACTIVE_STAGE= configure install
6065:
6066: The user can then decide to skip this package by setting the BATCH variable.
1.108 rillig 6067: Packages that require interaction are also excluded from bulk builds.
1.1 dsieger 6068:
1.266 martin 6069: 21.1.3. Handling licenses
1.1 dsieger 6070:
6071: Authors of software can choose the licence under which software can be copied.
1.111 sevan 6072: The Free Software Foundation has declared some licenses "Free", and the Open
6073: Source Initiative has a definition of "Open Source".
6074:
6075: By default, pkgsrc allows packages with Free or Open Source licenses to be
6076: built. To allow packages with other licenses to be built as well, the pkgsrc
6077: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
6078: . Note that this variable only affects which packages may be built, while the
6079: license terms often also restrict the actual use of the package and its
6080: redistribution.
1.1 dsieger 6081:
6082: One might want to only install packages with a BSD license, or the GPL, and not
1.20 jnemeth 6083: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111 sevan 6084: variable. The pkgsrc user can override the default by setting the
6085: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
6086: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
6087: pkgsrc/mk/license.mk.
1.1 dsieger 6088:
6089: The license tag mechanism is intended to address copyright-related issues
6090: surrounding building, installing and using a package, and not to address
1.20 jnemeth 6091: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
6092: redistribution restrictions should set these tags.
1.1 dsieger 6093:
6094: Denoting that a package may be copied according to a particular license is done
6095: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
6096: string identifying the license, e.g. in graphics/xv:
6097:
6098: LICENSE= xv-license
6099:
6100: When trying to build, the user will get a notice that the package is covered by
6101: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
6102:
6103: % make
6104: ===> xv-3.10anb9 has an unacceptable license: xv-license.
6105: ===> To view the license, enter "/usr/bin/make show-license".
6106: ===> To indicate acceptance, add this line to your /etc/mk.conf:
6107: ===> ACCEPTABLE_LICENSES+=xv-license
6108: *** Error code 1
6109:
1.260 wiz 6110: In case a package requires multiple licenses, you can add all of them to the
6111: LICENSE variable, connected with the upper-case keyword AND. If the user has a
6112: choice between multiple licenses, you can add them connected with the
6113: upper-case keyword OR, for example:
6114:
6115: LICENSE= isc AND apache-2.0
6116: LICENSE= 2-clause-bsd OR ruby-license
6117:
1.1 dsieger 6118: The license can be viewed with make show-license, and if the user so chooses,
1.4 rillig 6119: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1 dsieger 6120: should not in the future fail because of that license:
6121:
6122: ACCEPTABLE_LICENSES+=xv-license
6123:
1.111 sevan 6124: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
6125: is deprecated because it does not crisply refer to a particular license text.
6126: Another problem with such usage is that it does not enable a user to tell
6127: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
6128: for all packages with that tag.
6129:
1.266 martin 6130: 21.1.3.1. Adding a package with a new license
1.1 dsieger 6131:
1.49 rodent 6132: When adding a package with a new license, the following steps are required:
6133:
1.111 sevan 6134: 1. Check whether the license qualifies as Free or Open Source by referencing
6135: Various Licenses and Comments about Them and Licenses by Name | Open Source
6136: Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
6137: need the -license suffix, and the license name should be added to:
1.49 rodent 6138:
6139: + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
6140:
6141: + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
6142: license.c
6143:
6144: 2. The license text should be added to pkgsrc/licenses for displaying. A list
6145: of known licenses can be seen in this directory.
1.1 dsieger 6146:
1.266 martin 6147: 21.1.3.2. Change to the license
1.1 dsieger 6148:
1.111 sevan 6149: When the license changes (in a way other than formatting), make sure that the
6150: new license has a different name (e.g., append the version number if it exists,
6151: or the date). Just because a user told pkgsrc to build programs under a
6152: previous version of a license does not mean that pkgsrc should build programs
6153: under the new licenses. The higher-level point is that pkgsrc does not evaluate
6154: licenses for reasonableness; the only test is a mechanistic test of whether a
6155: particular text has been approved by either of two bodies (FSF or OSI).
1.1 dsieger 6156:
1.266 martin 6157: 21.1.4. Restricted packages
1.1 dsieger 6158:
1.111 sevan 6159: Some licenses restrict how software may be re-distributed. By declaring the
6160: restrictions, package tools can automatically refrain from e.g. placing binary
6161: packages on FTP sites.
6162:
6163: There are four possible restrictions, which are the cross product of sources
6164: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
6165: this is rarely the exact language in any license, and because non-Free licenses
6166: tend to be different from each other, pkgsrc adopts a definition of FTP and
6167: CD-ROM. "FTP" means making the source or binary file available over the
6168: Internet at no charge. "CD-ROM" means making the source or binary available on
6169: some kind of media, together with other source and binary packages, which is
6170: sold for a distribution charge.
1.1 dsieger 6171:
6172: In order to encode these restrictions, the package system defines five make
6173: variables that can be set to note these restrictions:
6174:
6175: * RESTRICTED
6176:
6177: This variable should be set whenever a restriction exists (regardless of
6178: its kind). Set this variable to a string containing the reason for the
6179: restriction. It should be understood that those wanting to understand the
6180: restriction will have to read the license, and perhaps seek advice of
6181: counsel.
6182:
6183: * NO_BIN_ON_CDROM
6184:
6185: Binaries may not be placed on CD-ROM containing other binary packages, for
6186: which a distribution charge may be made. In this case, set this variable to
6187: ${RESTRICTED}.
6188:
6189: * NO_BIN_ON_FTP
6190:
6191: Binaries may not made available on the Internet without charge. In this
6192: case, set this variable to ${RESTRICTED}. If this variable is set, binary
6193: packages will not be included on ftp.NetBSD.org.
6194:
6195: * NO_SRC_ON_CDROM
6196:
6197: Distfiles may not be placed on CD-ROM, together with other distfiles, for
6198: which a fee may be charged. In this case, set this variable to $
6199: {RESTRICTED}.
6200:
6201: * NO_SRC_ON_FTP
6202:
6203: Distfiles may not made available via FTP at no charge. In this case, set
6204: this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
6205: will not be mirrored on ftp.NetBSD.org.
6206:
1.111 sevan 6207: Please note that packages will be removed from pkgsrc when the distfiles are
1.33 wiz 6208: not distributable and cannot be obtained for a period of one full quarter
1.111 sevan 6209: branch. Packages with manual/interactive fetch must have a maintainer and it is
6210: his/her responsibility to ensure this.
1.33 wiz 6211:
1.266 martin 6212: 21.1.5. Handling dependencies
1.1 dsieger 6213:
1.175 gutterid 6214: Your package may depend on some other package being present, and there are
6215: various ways of expressing this dependency. pkgsrc supports the DEPENDS,
6216: BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS definitions, the USE_TOOLS
6217: definition, as well as dependencies via buildlink3.mk, which is the preferred
6218: way to handle dependencies, and which uses the variables named above. See
1.266 martin 6219: Chapter 18, Buildlink methodology for more information.
1.175 gutterid 6220:
6221: The basic difference is that the DEPENDS definition registers that
6222: pre-requisite in the binary package so it will be pulled in when the binary
6223: package is later installed, whilst the BUILD_DEPENDS, TOOL_DEPENDS, and
6224: TEST_DEPENDS definitions do not, marking a dependency that is only needed for
1.266 martin 6225: building or testing the resulting package. See also Chapter 14, Creating a new
1.175 gutterid 6226: pkgsrc package from scratch for more information.
6227:
6228: This means that if you only need a package present whilst you are building or
6229: testing, it should be noted as a TOOL_DEPENDS, BUILD_DEPENDS, or TEST_DEPENDS.
6230: When cross-compiling, TOOL_DEPENDS are native packages, i.e. packages for the
6231: architecture where the package is built; BUILD_DEPENDS are target packages,
6232: i.e., packages for the architecture for which the package is built.
1.1 dsieger 6233:
1.175 gutterid 6234: The format for a DEPENDS, BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS
6235: definition is:
1.1 dsieger 6236:
6237: <pre-req-package-name>:../../<category>/<pre-req-package>
6238:
1.266 martin 6239: Please note that the pre-req-package-name may include any of the wildcard
1.1 dsieger 6240: version numbers recognized by pkg_info(1).
6241:
1.55 wiz 6242: 1. If your package needs another package's binaries or libraries to build and
1.1 dsieger 6243: run, and if that package has a buildlink3.mk file available, use it:
6244:
6245: .include "../../graphics/jpeg/buildlink3.mk"
6246:
1.55 wiz 6247: 2. If your package needs another package's binaries or libraries only for
6248: building, and if that package has a buildlink3.mk file available, use it:
6249:
6250: .include "../../graphics/jpeg/buildlink3.mk"
6251:
6252: but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
6253: This case is rather rare.
6254:
6255: 3. If your package needs binaries from another package to build, use the
1.156 leot 6256: TOOL_DEPENDS definition:
6257:
6258: TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool
1.1 dsieger 6259:
1.156 leot 6260: 4. If your package needs static libraries to link against, header files to
6261: include, etc. from another package to build, use the BUILD_DEPENDS
6262: definition.
1.1 dsieger 6263:
1.156 leot 6264: 5. If your package needs a library with which to link and there is no
1.26 spz 6265: buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
6266: because the include files and libraries will be hidden from the compiler.
1.1 dsieger 6267:
1.156 leot 6268: 6. If your package needs some executable to be able to run correctly and if
1.26 spz 6269: there's no buildlink3.mk file, this is specified using the DEPENDS
6270: variable. The print/lyx package needs to be able to execute the latex
1.129 wiz 6271: binary from the tex-latex-bin package when it runs, and that is specified:
1.1 dsieger 6272:
1.129 wiz 6273: DEPENDS+= tex-latex-bin-[0-9]*:../../print/tex-latex-bin
1.1 dsieger 6274:
1.175 gutterid 6275: 7. If your package includes a test suite that has extra dependencies only
1.266 martin 6276: required for this purpose (frequently this can be run as a make test
1.175 gutterid 6277: target), use the TEST_DEPENDS variable.
6278:
6279: 8. You can use wildcards in package dependencies. Note that such wildcard
1.26 spz 6280: dependencies are retained when creating binary packages. The dependency is
6281: checked when installing the binary package and any package which matches
6282: the pattern will be used. Wildcard dependencies should be used with care.
1.1 dsieger 6283:
1.266 martin 6284: The -[0-9]* should be used instead of -* to avoid potentially ambiguous
6285: matches such as tk-postgresql matching a tk-* DEPENDS.
1.1 dsieger 6286:
6287: Wildcards can also be used to specify that a package will only build
6288: against a certain minimum version of a pre-requisite:
6289:
1.26 spz 6290: DEPENDS+= ImageMagick>=6.0:../../graphics/ImageMagick
1.1 dsieger 6291:
1.26 spz 6292: This means that the package will build using version 6.0 of ImageMagick or
6293: newer. Such a dependency may be warranted if, for example, the command line
6294: options of an executable have changed.
6295:
1.183 wiz 6296: If you need to depend on minimum versions of libraries, set
6297: BUILDLINK_API_DEPENDS.pkg to the appropriate pattern before including its
6298: buildlink3.mk file, e.g.
6299:
6300: BUILDLINK_API_DEPENDS.jpeg+= jpeg>=9.0
6301: .include "../../graphics/jpeg/buildlink3.mk"
1.1 dsieger 6302:
6303: For security fixes, please update the package vulnerabilities file. See
1.266 martin 6304: Section 21.1.9, Handling packages with security problems for more
1.1 dsieger 6305: information.
6306:
6307: If your package needs files from another package to build, add the relevant
6308: distribution files to DISTFILES, so they will be extracted automatically. See
6309: the print/ghostscript package for an example. (It relies on the jpeg sources
6310: being present in source form during the build.)
6311:
1.266 martin 6312: 21.1.6. Handling conflicts with other packages
1.1 dsieger 6313:
1.226 gutterid 6314: Your package may conflict with other packages users might already have
6315: installed on their system, e.g., if your package installs the same set of files
1.227 wiz 6316: as another package in the pkgsrc tree.
1.1 dsieger 6317:
1.142 leot 6318: For example, x11/libXaw3d and x11/Xaw-Xpm install the same shared library, thus
6319: you set in pkgsrc/x11/libXaw3d/Makefile:
1.1 dsieger 6320:
1.142 leot 6321: CONFLICTS= Xaw-Xpm-[0-9]*
1.1 dsieger 6322:
1.142 leot 6323: and in pkgsrc/x11/Xaw-Xpm/Makefile:
1.1 dsieger 6324:
1.142 leot 6325: CONFLICTS= libXaw3d-[0-9]*
1.1 dsieger 6326:
1.142 leot 6327: pkg_add(1) is able to detect attempts to install packages that conflict with
6328: existing packages and abort. However, in many situations this is too late in
6329: the process. Binary package managers will not know about the conflict until
6330: they attempt to install the package after already downloading it and all its
6331: dependencies. Users may also waste time building a package and its dependencies
6332: only to find out at the end that it conflicts with another package they have
6333: installed.
6334:
6335: To avoid these issues CONFLICTS entries should be added in all cases where it
6336: is known that packages conflict with each other. These CONFLICTS entries are
6337: exported in pkg_summary(5) files and consumed by binary package managers to
6338: inform users that packages cannot be installed onto the target system.
1.1 dsieger 6339:
1.266 martin 6340: 21.1.7. Packages that cannot or should not be built
1.1 dsieger 6341:
6342: There are several reasons why a package might be instructed to not build under
6343: certain circumstances. If the package builds and runs on most platforms, the
1.83 dholland 6344: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
6345: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
6346: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
6347: (OS-version-platform) that can use glob-style wildcards.
6348:
1.114 maya 6349: If a package is not appropriate for some platforms (as opposed to merely
1.83 dholland 6350: broken), a different set of variables should be used as this affects failure
6351: reporting and statistics. If the package is appropriate for most platforms, the
6352: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
6353: for only a small handful of platforms (often exactly one), set
6354: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
6355: triples (OS-version-platform) that can use glob-style wildcards.
1.1 dsieger 6356:
6357: Some packages are tightly bound to a specific version of an operating system,
6358: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
6359: with other versions of the OS, and should be uploaded to a version specific
6360: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
1.266 martin 6361: to yes . This variable is not currently used by any of the package system
1.1 dsieger 6362: internals, but may be used in the future.
6363:
6364: If the package should be skipped (for example, because it provides
6365: functionality already provided by the system), set PKG_SKIP_REASON to a
6366: descriptive message. If the package should fail because some preconditions are
6367: not met, set PKG_FAIL_REASON to a descriptive message.
6368:
1.266 martin 6369: 21.1.8. Packages which should not be deleted, once installed
1.1 dsieger 6370:
6371: To ensure that a package may not be deleted, once it has been installed, the
6372: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.266 martin 6373: carried into any binary package that is made from this pkgsrc entry. A
6374: preserved package will not be deleted using pkg_delete(1) unless the -f
1.1 dsieger 6375: option is used.
6376:
1.266 martin 6377: 21.1.9. Handling packages with security problems
1.1 dsieger 6378:
1.247 wiz 6379: When a vulnerability is found, this should be noted in pkgsrc/doc/
6380: pkg-vulnerabilities. Entries in that file consist of three parts:
1.205 wiz 6381:
6382: * package version pattern
6383:
6384: * type of vulnerability (please cut'n'paste an existing one where possible)
6385:
6386: * URL providing additional information about the issue
6387:
6388: For the package version pattern please always use `<' to mark an upper bound
6389: (not `<='!). This will avoid possible problems due unrelated PKGREVISION bumps
6390: not related to security fixes. Lower bounds can be added too, using '>' or '>=
1.266 martin 6391: '. For example, foo>=1<1.2 would mark versions 1.0 (included) to 1.2
6392: (excluded) of foo as affected by the security issue.
1.205 wiz 6393:
6394: Entries should always be added at the bottom of the file.
6395:
6396: When fixing packages, please modify the upper bound of the corresponding entry.
6397: To continue the previous example, if a fix was backported to version 1.1nb2,
1.266 martin 6398: change the previous pattern to foo>=1<1.1nb2 .
1.205 wiz 6399:
6400: To locally test a package version pattern against a PKGNAME you can use the
6401: pkg_admin pmatch command.
6402:
6403: The URL should be as permanent as possible and provide as much information
6404: about the issue as possible. CVE entries are preferred.
6405:
6406: After committing that file, ask pkgsrc-security@NetBSD.org to update the file
6407: on ftp.NetBSD.org.
1.1 dsieger 6408:
6409: After fixing the vulnerability by a patch, its PKGREVISION should be increased
6410: (this is of course not necessary if the problem is fixed by using a newer
1.32 wiz 6411: release of the software), and the pattern in the pkg-vulnerabilities file must
6412: be updated.
1.1 dsieger 6413:
6414: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
6415: submit a pullup request!
6416:
6417: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
6418: a weekly cron job.
6419:
1.205 wiz 6420: In case a security issue is disputed, please contact
6421: pkgsrc-security@NetBSD.org.
6422:
1.266 martin 6423: 21.1.10. How to handle incrementing versions when fixing an existing package
1.1 dsieger 6424:
6425: When making fixes to an existing package it can be useful to change the version
6426: number in PKGNAME. To avoid conflicting with future versions by the original
1.266 martin 6427: author, a nb1 , nb2 , ... suffix can be used on package versions by setting
6428: PKGREVISION=1 (2, ...). The nb is treated like a . by the package tools.
1.1 dsieger 6429: e.g.
6430:
6431: DISTNAME= foo-17.42
6432: PKGREVISION= 9
6433:
1.266 martin 6434: will result in a PKGNAME of foo-17.42nb9 . If you want to use the original
6435: value of PKGNAME without the nbX suffix, e.g. for setting DIST_SUBDIR, use
1.1 dsieger 6436: PKGNAME_NOREV.
6437:
6438: When a new release of the package is released, the PKGREVISION should be
6439: removed, e.g. on a new minor release of the above package, things should be
6440: like:
6441:
6442: DISTNAME= foo-17.43
6443:
6444: PKGREVISION should be incremented for any non-trivial change in the resulting
6445: binary package. Without a PKGREVISION bump, someone with the previous version
6446: installed has no way of knowing that their package is out of date. Thus,
6447: changes without increasing PKGREVISION are essentially labeled "this is so
6448: trivial that no reasonable person would want to upgrade", and this is the rough
6449: test for when increasing PKGREVISION is appropriate. Examples of changes that
6450: do not merit increasing PKGREVISION are:
6451:
1.274 ! wiz 6452: * Changing HOMEPAGE, MAINTAINER, or comments in Makefile.
1.1 dsieger 6453:
6454: * Changing build variables if the resulting binary package is the same.
6455:
6456: * Changing DESCR.
6457:
6458: * Adding PKG_OPTIONS if the default options don't change.
6459:
6460: Examples of changes that do merit an increase to PKGREVISION include:
6461:
6462: * Security fixes
6463:
6464: * Changes or additions to a patch file
6465:
6466: * Changes to the PLIST
6467:
1.12 weinem 6468: * A dependency is changed or renamed.
6469:
1.1 dsieger 6470: PKGREVISION must also be incremented when dependencies have ABI changes.
6471:
1.266 martin 6472: 21.1.11. Substituting variable text in the package files (the SUBST framework)
1.1 dsieger 6473:
1.180 rillig 6474: When you want to replace the same text in multiple files, or multiple times in
6475: the same file, it is cumbersome to maintain a patch file for this. This is
6476: where the SUBST framework steps in. It provides an easy-to-use interface for
6477: replacing text in files. It just needs the following information:
1.172 rillig 6478:
1.180 rillig 6479: * In which phase of the package build cycle should the replacement happen?
1.172 rillig 6480:
1.180 rillig 6481: * In which files should the replacement happen?
1.172 rillig 6482:
6483: * Which text should be replaced with what?
6484:
1.180 rillig 6485: This information is encoded in a block of SUBST variables. A minimal example
6486: is:
6487:
6488: SUBST_CLASSES+= paths
6489: SUBST_STAGE.paths= pre-configure
6490: SUBST_FILES.paths= src/*.c
6491: SUBST_SED.paths= -e 's,/usr/local,${PREFIX},g'
6492:
6493: Translated into English, it means: In the pre-configure stage (that is, after
6494: applying the patches from the patches/ directory and before running the
6495: configure script and the portability check), replace the text /usr/local with
6496: the content of the variable PREFIX.
6497:
6498: Each SUBST block starts by appending an identifier to SUBST_CLASSES (note the +
6499: =). This identifier can be chosen freely by the package. If there should ever
6500: be duplicate identifiers, the pkgsrc infrastructure will catch this and fail
6501: early, so don't worry about name collisions.
6502:
6503: Except for SUBST_CLASSES, all variables in a SUBST block are parameterized
6504: using this identifier. In the remainder of this section, these parameterized
6505: variables are written as SUBST_STAGE.*.
6506:
6507: SUBST_CLASSES+= paths
6508: SUBST_STAGE.paths= pre-configure
6509: SUBST_MESSAGE.paths= Fixing absolute paths.
6510: SUBST_FILES.paths= src/*.c
6511: SUBST_FILES.paths+= scripts/*.sh
6512: SUBST_SED.paths= -e 's,"/usr/local,"${PREFIX},g'
6513: SUBST_SED.paths+= -e 's,"/var/log,"${VARBASE}/log,g'
6514: SUBST_VARS.paths= LOCALBASE PREFIX PKGVERSION
6515:
6516: To get a complete picture about the SUBST substitutions, run bmake
6517: show-all-subst. If something doesn't work as expected, run pkglint on the
6518: package, which detects several typical mistakes surrounding the SUBST blocks.
6519: For any questions that might remain after this, have a look at mk/subst.mk.
6520:
1.266 martin 6521: 21.1.11.1. Choosing the time where the substitutions happen
1.180 rillig 6522:
6523: The SUBST_STAGE.* is one of {pre,do,post}-
6524: {extract,patch,configure,build,test,install}. Of these, pre-configure is used
6525: most often, by far. The most popular stages are, in chronological order:
6526:
6527: post-extract
6528:
6529: The substitutions are applied immediately after the distfiles are
6530: extracted. Running bmake extract on the package will leave no traces of the
6531: original files.
6532:
6533: When the substitution applies to files for which there is also a patch in
6534: the patches/ directory, this means that the patches will be computed based
6535: on the result of the substitution. When these patches are sent to the
6536: upstream maintainer later, to be fixed in the upstream package, these
6537: patches may no longer match what the upstream author is used to. Because of
6538: this, pre-configure is often a better choice.
6539:
6540: pre-configure
6541:
6542: The substitutions are applied after the patches from the patches/
6543: directory. This makes it possible to run bmake patch on the package, after
6544: which the patches can be edited using the tools pkgvi and mkpatches from
6545: the pkgtools/pkgdiff package.
6546:
6547: When updating the patches, it is helpful to explicitly separate the bmake
6548: patch from the bmake configure, and to only edit the patches between these
6549: commands. Otherwise the substitutions from the SUBST block will end up in
6550: the patch file. When this happens in really obvious ways, pkglint will
6551: complain about patches that contain a hard-coded /usr/pkg instead of the
6552: correct and intended @PREFIX@, but it can only detect these really obvious
6553: cases.
6554:
6555: do-configure
6556:
6557: This stage should only be used if the package defines a pre-configure
6558: action itself, and the substitution must happen after that. Typical
6559: examples are packages that use the pre-configure stage to regenerate the
6560: GNU configure script from configure.ac.
6561:
6562: post-configure
6563:
6564: This stage is used to fix up any mistakes by the configure stage.
6565:
6566: pre-build
6567:
6568: This stage should only be used for substitutions that are clearly related
6569: to building the package, not for fixing the configuration. Substitutions
6570: for pathnames (such as replacing /usr/local with ${PREFIX}) or user names
6571: (such as replacing @MY_USER@ with the actual username) belong in
6572: pre-configure or post-configure instead.
6573:
6574: post-build
6575:
6576: Just as with pre-build, this stage should only be used for substitutions
6577: that are clearly related to building the package, not for fixing the
6578: configuration. Substitutions for pathnames (such as replacing /usr/local
6579: with ${PREFIX}) or user names (such as replacing @MY_USER@ with the actual
6580: username) belong in pre-configure or post-configure instead.
6581:
6582: A typical use is to update pkg-config files to include the rpath compiler
6583: options.
6584:
6585: pre-install
6586:
6587: In general, the install phase should be as simple as possible. As with the
6588: pre-build and post-build stages, it should not be used to fix pathnames or
6589: user names, these belong in pre-configure instead. There are only few
6590: legitimate use cases for applying substitutions in this stage.
6591:
1.266 martin 6592: 21.1.11.2. Choosing the files where the substitutions happen
1.180 rillig 6593:
6594: The SUBST_FILES.* variable contains a list of filename patterns. These patterns
6595: are relative to WRKSRC since that is where most substitutions happen. A typical
6596: example is:
6597:
6598: SUBST_FILES.path= Makefile */Makefile */*/Makefile *.[ch]
6599:
6600: The above patterns, especially the last, are quite broad. The SUBST
6601: implementation checks that each filename pattern that is mentioned here has an
6602: effect. For example, if none of the */*/Makefile files contains the patterns to
6603: be found and substituted, that filename pattern is redundant and should be left
1.181 rillig 6604: out. By default, the SUBST framework will complain with an error message. If
6605: the text to be substituted occurs in some of the files from a single pattern,
6606: but not in all of them, that is totally ok, and the SUBST framework will only
6607: print an INFO message for those files.
1.180 rillig 6608:
6609: If there is a good reason for having redundant filename patterns, set
1.181 rillig 6610: SUBST_NOOP_OK.* to yes.
1.180 rillig 6611:
6612: Another popular way of choosing the files for the substitutions is via a shell
6613: command, like this:
6614:
1.181 rillig 6615: C_FILES_CMD= cd ${WRKSRC} && ${FIND} . -name '*.c'
1.180 rillig 6616: SUBST_FILES.path= ${C_FILES_CMD:sh}
6617:
6618: The variable name C_FILES_CMD in this example is freely chosen and independent
6619: of the SUBST framework.
6620:
6621: In this variant, the SUBST_FILES.* variable lists each file individually.
6622: Thereby chances are higher that there are filename patterns in which no
6623: substitution happens. Since the SUBST framework cannot know whether the
6624: filename patterns in SUBST_FILES.* have been explicitly listed in the Makefile
6625: (where any redundant filename pattern would be suspicious) or been generated by
6626: a shell command (in which redundant filename patterns are more likely and to be
6627: expected), it will complain about these redundant filename patterns. Therefore,
6628: SUBST blocks that use a shell command to generate the list of filename patterns
6629: often need to set SUBST_NOOP_OK.* to yes.
6630:
1.266 martin 6631: 21.1.11.3. Choosing what to substitute
1.180 rillig 6632:
6633: In most cases, the substitutions are given using one or more sed(1) commands,
6634: like this:
6635:
6636: SUBST_SED.path= -e 's|/usr/local|${PREFIX}|g'
6637:
6638: Each of the sed commands needs to be preceded by the -e option and should be
6639: specified on a line of its own, to avoid hiding short sed commands at the end
6640: of a line.
6641:
6642: Since the sed commands often contain shell metacharacters as the separator (the
6643: | in the above example), it is common to enclose them in single quotes.
6644:
6645: A common substitution is to replace placeholders of the form @VARNAME@ with
6646: their pkgsrc counterpart variable ${VARNAME}. A typical example is:
6647:
6648: SUBST_VARS.path= PREFIX
6649:
1.181 rillig 6650: This type of substitutions is typically done by the GNU configure scripts
6651: during the do-configure stage, but in some cases these need to be overridden.
6652: The same pattern is also used when a package defines patches that replace
6653: previously hard-coded paths like /usr/local with a @PREFIX@ placeholder first,
6654: which then gets substituted by the actual ${PREFIX} in the pre-configure stage.
6655: In many of these cases, it works equally well to just use the SUBST framework
6656: to directly replace /usr/local with ${PREFIX}, thereby omitting the
6657: intermediate patch file.
1.180 rillig 6658:
6659: If the above is not flexible enough, it is possible to not use sed at all for
6660: the substitution but to specify an entirely different command, like this:
6661:
6662: SUBST_FILTER_CMD.path= LC_ALL=C ${TR} -d '\r'
1.1 dsieger 6663:
1.180 rillig 6664: This is used for the few remaining packages in which the distributed files use
6665: Windows-style line endings that need to be converted to UNIX-style line
6666: endings.
1.1 dsieger 6667:
1.266 martin 6668: 21.1.11.4. Other SUBST variables
1.172 rillig 6669:
1.180 rillig 6670: When a SUBST block is applied during a package build, a message is logged. The
6671: default message is fine for most purposes but can be overridden by setting
6672: SUBST_MESSAGE.* to an individual message.
1.1 dsieger 6673:
1.266 martin 6674: 21.2. The fetch phase
1.1 dsieger 6675:
1.266 martin 6676: 21.2.1. Packages whose distfiles aren't available for plain downloading
1.1 dsieger 6677:
6678: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
6679: a make fetch will call files/getsite.sh with the name of each file to download
6680: as an argument, expecting it to output the URL of the directory from which to
6681: download it. graphics/ns-cult3d is an example of this usage.
6682:
6683: If the download can't be automated, because the user must submit personal
6684: information to apply for a password, or must pay for the source, or whatever,
6685: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
6686: before aborting the build. Example:
6687:
6688: FETCH_MESSAGE= "Please download the files"
6689: FETCH_MESSAGE+= " "${DISTFILES:Q}
6690: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
6691:
1.266 martin 6692: 21.2.2. How to handle modified distfiles with the 'old' name
1.1 dsieger 6693:
6694: Sometimes authors of a software package make some modifications after the
6695: software was released, and they put up a new distfile without changing the
6696: package's version number. If a package is already in pkgsrc at that time, the
6697: checksum will no longer match. The contents of the new distfile should be
6698: compared against the old one before changing anything, to make sure the
6699: distfile was really updated on purpose, and that no trojan horse or so crept
6700: in. Please mention that the distfiles were compared and what was found in your
1.54 rodent 6701: commit message.
6702:
6703: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109 wiz 6704: directory name, usually based on PKGNAME_NOREV (but take care with python or
6705: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
6706: PATCHFILES for this package will be put in that subdirectory of the local
1.266 martin 6707: distfiles directory. (See Section 21.1.10, How to handle incrementing versions
6708: when fixing an existing package for more details.) In case this happens more
1.109 wiz 6709: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
6710: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54 rodent 6711:
6712: DIST_SUBDIR is also used when a distfile's name does not contain a version and
6713: the distfile is apt to change. In cases where the likelihood of this is very
6714: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
6715: removed unless the distfile name changes, even if a package is being moved or
6716: renamed.
6717:
6718: Do not forget regenerating the distinfo file after that, since it contains the
6719: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
6720: installed package is different. Furthermore, a mail to the package's authors
6721: seems appropriate telling them that changing distfiles after releases without
6722: changing the file names is not good practice.
1.1 dsieger 6723:
1.266 martin 6724: 21.2.3. Packages hosted on github.com
1.88 tnn 6725:
1.90 tnn 6726: Helper methods exist for packages hosted on github.com which will often have
6727: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
6728: of the three recipes from below:
1.88 tnn 6729:
1.266 martin 6730: 21.2.3.1. Fetch based on a tagged release
1.88 tnn 6731:
1.189 bacon 6732: If your distfile URL looks similar to https://github.com/username/example/
6733: archive/v1.0.zip, then you are packaging a tagged release.
1.88 tnn 6734:
1.189 bacon 6735: DISTNAME= example-1.0
1.90 tnn 6736: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1.189 bacon 6737: #GITHUB_PROJECT= example # can be omitted if same as DISTNAME
1.90 tnn 6738: GITHUB_TAG= v${PKGVERSION_NOREV}
1.88 tnn 6739: EXTRACT_SUFX= .zip
6740:
1.230 gutterid 6741: Here, DISTNAME combined with use of GITHUB_TAG leads the file fetching
6742: infrastructure to save the resulting file locally as example-1.0.zip.
6743:
1.266 martin 6744: 21.2.3.2. Fetch based on a specific commit before the first release
1.189 bacon 6745:
6746: If your distfile looks similar to https://github.com/username/example/archive/
6747: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit before the first
6748: release, then set the package version to 0.0.0.N, where N is the number of
6749: commits to the repository, and set GITHUB_TAG to the commit hash. This will
6750: (almost) ensure that the first tagged release will have a version greater than
6751: this one so that package upgrades will function properly.
6752:
6753: DISTNAME= example-0.0.0.347
6754: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
6755: #GITHUB_PROJECT= example # can be omitted if same as DISTNAME
6756: GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
6757:
1.266 martin 6758: 21.2.3.3. Fetch based on a specific commit after a release
1.88 tnn 6759:
1.189 bacon 6760: If your distfile looks similar to https://github.com/username/example/archive/
6761: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit after a release,
6762: then include the last release version and the commit count since that release
6763: in the package version and set GITHUB_TAG to the commit hash. The latest
6764: release and commit count are shown in the output of "git describe --tags":
6765:
6766: # git clone https://github.com/username/example
6767: # cd example
6768: # git describe --tags
6769: 1.2.3-5-g988881a
1.88 tnn 6770:
1.189 bacon 6771: DISTNAME= example-1.2.3.5
6772: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
6773: #GITHUB_PROJECT= example # can be omitted if same as DISTNAME
1.90 tnn 6774: GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88 tnn 6775:
1.266 martin 6776: 21.2.3.4. Fetch based on release
1.88 tnn 6777:
1.189 bacon 6778: If your distfile URL looks similar to https://github.com/username/example/
6779: releases/download/rel-1.6/offensive-1.6.zip, then you are packaging a release.
1.88 tnn 6780:
1.90 tnn 6781: DISTNAME= offensive-1.6
1.88 tnn 6782: PKGNAME= ${DISTNAME:S/offensive/proper/}
1.90 tnn 6783: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1.189 bacon 6784: GITHUB_PROJECT= example
1.90 tnn 6785: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
6786: EXTRACT_SUFX= .zip
1.88 tnn 6787:
1.266 martin 6788: 21.3. The configure phase
1.1 dsieger 6789:
1.266 martin 6790: 21.3.1. Shared libraries - libtool
1.1 dsieger 6791:
6792: pkgsrc supports many different machines, with different object formats like
6793: a.out and ELF, and varying abilities to do shared library and dynamic loading
6794: at all. To accompany this, varying commands and options have to be passed to
6795: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
6796: especially if you don't have all the machines at your hand to test things. The
1.266 martin 6797: devel/libtool pkg can help here, as it just knows how to build both static
1.1 dsieger 6798: and dynamic libraries from a set of source files, thus being
6799: platform-independent.
6800:
6801: Here's how to use libtool in a package in seven simple steps:
6802:
6803: 1. Add USE_LIBTOOL=yes to the package Makefile.
6804:
1.266 martin 6805: 2. For library objects, use ${LIBTOOL} --mode=compile ${CC} in place of $
6806: {CC} . You could even add it to the definition of CC, if only libraries are
1.1 dsieger 6807: being built in a given Makefile. This one command will build both PIC and
6808: non-PIC library objects, so you need not have separate shared and
6809: non-shared library rules.
6810:
1.266 martin 6811: 3. For the linking of the library, remove any ar , ranlib , and ld
6812: -Bshareable commands, and instead use:
1.1 dsieger 6813:
6814: ${LIBTOOL} --mode=link \
6815: ${CC} -o ${.TARGET:.a=.la} \
6816: ${OBJS:.o=.lo} \
6817: -rpath ${PREFIX}/lib \
6818: -version-info major:minor
6819:
6820: Note that the library is changed to have a .la extension, and the objects
6821: are changed to have a .lo extension. Change OBJS as necessary. This
6822: automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
1.266 martin 6823: necessary) in the build directory. Be sure to include -version-info ,
1.1 dsieger 6824: especially when major and minor are zero, as libtool will otherwise strip
6825: off the shared library version.
6826:
6827: From the libtool manual:
6828:
6829: So, libtool library versions are described by three integers:
6830:
6831: CURRENT
6832: The most recent interface number that this library implements.
6833:
6834: REVISION
6835: The implementation number of the CURRENT interface.
6836:
6837: AGE
6838: The difference between the newest and oldest interfaces that
6839: this library implements. In other words, the library implements
6840: all the interface numbers in the range from number `CURRENT -
6841: AGE' to `CURRENT'.
6842:
6843: If two libraries have identical CURRENT and AGE numbers, then the
6844: dynamic linker chooses the library with the greater REVISION number.
6845:
1.266 martin 6846: The -release option will produce different results for a.out and ELF
6847: (excluding symlinks) in only one case. An ELF library of the form
6848: libfoo-release.so.x.y will have a symlink of libfoo.so.x.y on an a.out
1.1 dsieger 6849: platform. This is handled automatically.
6850:
1.266 martin 6851: The -rpath argument is the install directory of the library being built.
1.1 dsieger 6852:
6853: In the PLIST, include only the .la file, the other files will be added
6854: automatically.
6855:
6856: 4. When linking shared object (.so) files, i.e. files that are loaded via
1.266 martin 6857: dlopen(3), NOT shared libraries, use -module -avoid-version to prevent
1.1 dsieger 6858: them getting version tacked on.
6859:
6860: The PLIST file gets the foo.so entry.
6861:
6862: 5. When linking programs that depend on these libraries before they are
1.266 martin 6863: installed, preface the cc(1) or ld(1) line with ${LIBTOOL} --mode=link ,
1.1 dsieger 6864: and it will find the correct libraries (static or shared), but please be
6865: aware that libtool will not allow you to specify a relative path in -L
1.266 martin 6866: (such as -L../somelib ), because it expects you to change that argument to
1.1 dsieger 6867: be the .la file. e.g.
6868:
6869: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
6870:
6871: should be changed to:
6872:
6873: ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
6874:
6875: and it will do the right thing with the libraries.
6876:
1.266 martin 6877: 6. When installing libraries, preface the install(1) or cp(1) command with $
6878: {LIBTOOL} --mode=install , and change the library name to .la. e.g.
1.1 dsieger 6879:
1.23 jakllsch 6880: ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1 dsieger 6881:
6882: This will install the static .a, shared library, any needed symlinks, and
6883: run ldconfig(8).
6884:
6885: 7. In your PLIST, include only the .la file (this is a change from previous
6886: behaviour).
6887:
1.266 martin 6888: 21.3.2. Using libtool on GNU packages that already support libtool
1.1 dsieger 6889:
6890: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
6891: own libtool in most cases. For older libtool using packages, libtool is made by
6892: ltconfig script during the do-configure step; you can check the libtool script
6893: location by doing make configure; find work*/ -name libtool.
6894:
6895: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
1.266 martin 6896: override. By default, it is set to libtool */libtool */*/libtool . If this
1.1 dsieger 6897: does not match the location of the package's libtool script(s), set it as
6898: appropriate.
6899:
6900: If you do not need *.a static libraries built and installed, then use
6901: SHLIBTOOL_OVERRIDE instead.
6902:
6903: If your package makes use of the platform-independent library for loading
6904: dynamic shared objects, that comes with libtool (libltdl), you should include
6905: devel/libltdl/buildlink3.mk.
6906:
6907: Some packages use libtool incorrectly so that the package may not work or build
6908: in some circumstances. Some of the more common errors are:
6909:
6910: * The inclusion of a shared object (-module) as a dependent library in an
6911: executable or library. This in itself isn't a problem if one of two things
6912: has been done:
6913:
6914: 1. The shared object is named correctly, i.e. libfoo.la, not foo.la
6915:
6916: 2. The -dlopen option is used when linking an executable.
6917:
6918: * The use of libltdl without the correct calls to initialisation routines.
6919: The function lt_dlinit() should be called and the macro
6920: LTDL_SET_PRELOADED_SYMBOLS included in executables.
6921:
1.266 martin 6922: 21.3.3. GNU Autoconf/Automake
1.1 dsieger 6923:
6924: If a package needs GNU autoconf or automake to be executed to regenerate the
1.223 nia 6925: configure script and Makefile.in makefile templates from configure.ac and
6926: Makefile.am, then they should be executed in a pre-configure target:
1.1 dsieger 6927:
1.223 nia 6928: USE_TOOLS+= autoconf automake autoreconf
6929: GNU_CONFIGURE= yes
1.1 dsieger 6930: ...
6931:
6932: pre-configure:
1.223 nia 6933: set -e; cd ${WRKSRC} && autoreconf -fi
1.1 dsieger 6934: ...
6935:
1.223 nia 6936: Packages which use GNU Automake will sometimes require GNU Make (gmake in
6937: USE_TOOLS), but not always. Note that autoreconf only needs to be executed if
6938: configure.ac or Makefiles are modified, or configure is not present.
1.1 dsieger 6939:
6940: There are times when the configure process makes additional changes to the
6941: generated files, which then causes the build process to try to re-execute the
6942: automake sequence. This is prevented by touching various files in the configure
6943: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
6944: NO in the package Makefile.
6945:
1.266 martin 6946: 21.3.4. Meson / ninja
1.223 nia 6947:
6948: Packages using Meson to configure need to include:
6949:
6950: .include "../../devel/meson/build.mk"
6951:
6952: In nearly all cases (any program with dependencies), pkg-config needs to be
6953: added to USE_TOOLS. If the package installs translation files for non-English
6954: languages, also add msgfmt and xgettext:
6955:
6956: USE_TOOLS+= pkg-config msgfmt xgettext
6957:
6958: If any options need to be passed to Meson, use MESON_ARGS instead of
6959: CONFIGURE_ARGS:
6960:
6961: MESON_ARGS+= -Dx11=false
6962:
1.266 martin 6963: 21.3.5. Determining the endianness
1.260 wiz 6964:
6965: To determine the endianness of the target platform, have a look at mk/
6966: endian.mk.
6967:
1.266 martin 6968: 21.4. Programming languages
1.1 dsieger 6969:
1.266 martin 6970: 21.4.1. C, C++, and Fortran
1.1 dsieger 6971:
1.244 gutterid 6972: Compilers for the C and C++ languages come with the NetBSD base system. By
1.223 nia 6973: default, pkgsrc assumes that a package is written in C and will hide all other
1.266 martin 6974: compilers (via the wrapper framework, see Chapter 18, Buildlink methodology).
1.1 dsieger 6975:
1.243 gutterid 6976: To declare which languages should be made available through pkgsrc's compiler
6977: wrappers, use the USE_LANGUAGES variable. Allowed values currently are:
1.212 wiz 6978:
1.244 gutterid 6979: c, c++, fortran, fortran77, java, objc, obj-c++, and ada.
1.212 wiz 6980:
1.266 martin 6981: (and any combination). The default is c . Packages using GNU configure
1.212 wiz 6982: scripts, even if written in C++, usually need a C compiler for the configure
1.244 gutterid 6983: phase.
1.243 gutterid 6984:
1.250 jnemeth 6985: To declare which features a package requires from the compiler, set either
1.243 gutterid 6986: USE_CC_FEATURES or USE_CXX_FEATURES. Allowed values for USE_CC_FEATURES are
6987: currently:
6988:
6989: c11, c99, has_include
6990:
6991: Allowed values for USE_CXX_FEATURES are currently:
6992:
6993: c++11, c++14, c++17, c++20, has_include, regex, filesystem,
6994: charconv, parallelism_ts, unique_ptr, put_time,
6995: is_trivially_copy_constructible
1.1 dsieger 6996:
1.251 gutterid 6997: Note at present these variables only affect use of GCC, not other compilers.
6998:
1.244 gutterid 6999: Language variants like gnu99 and c++11 can be specified in FORCE_C_STD and
7000: FORCE_CXX_STD if the package does not explicitly set -std=... when compiling
7001: (i.e. the package assumes the compiler defaults to C++11 or some other
7002: standard). This is a common bug in upstream build systems.
7003:
7004: Allowed values for FORCE_C_STD are currently:
7005:
7006: c90, c99, c11, gnu90, gnu99, gnu11
7007:
7008: Allowed values for FORCE_CXX_STD are currently:
7009:
7010: c++03, c++11, c++14, c++17, c++20,
7011: gnu++03, gnu++11, gnu++14, gnu++17, gnu++20
7012:
1.251 gutterid 7013: Note at present these variables only affect use of GCC and Clang.
7014:
1.266 martin 7015: 21.4.2. Java
1.1 dsieger 7016:
7017: If a program is written in Java, use the Java framework in pkgsrc. The package
7018: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
7019: variables:
7020:
7021: * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
1.266 martin 7022: set to run , then there is only a runtime dependency on the JDK. The
7023: default is yes , which also adds a build dependency on the JDK.
1.1 dsieger 7024:
7025: * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
1.266 martin 7026: supported values are yes , 1.4 , and 1.5 . yes accepts any Java2
7027: implementation, 1.4 insists on versions 1.4 or above, and 1.5 only
1.1 dsieger 7028: accepts versions 1.5 or above. This variable is not set by default.
7029:
1.25 wiz 7030: * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
7031: implementation dependency. It may be used to set JAVA_HOME to a good value
7032: if the program needs this variable to be defined.
7033:
1.266 martin 7034: 21.4.3. Go
1.205 wiz 7035:
7036: If a program is written in Go and has any dependencies on other Go modules,
7037: have the package include ../../lang/go/go-module.mk.
7038:
7039: 1. Generate a list of those dependencies with make clean && make patch && make
7040: show-go-modules > go-modules.mk.
7041:
1.223 nia 7042: 2. Prepend .include "go-modules.mk" to any other .includes.
7043:
7044: 3. Incorporate these modules in distinfo with make makesum.
1.205 wiz 7045:
1.266 martin 7046: 21.4.4. Rust
1.205 wiz 7047:
1.223 nia 7048: If a program is written in Rust and uses Cargo to build, have the package
7049: include ../../lang/rust/cargo.mk.
1.205 wiz 7050:
1.223 nia 7051: 1. Generate a list of those dependencies with make CARGO_ARGS="build
7052: --release" build && make print-cargo-depends > cargo-depends.mk.
1.205 wiz 7053:
1.223 nia 7054: 2. Prepend .include "cargo-depends.mk" to any other .includes.
1.205 wiz 7055:
7056: 3. Incorporate these modules in distinfo with make makesum.
7057:
1.266 martin 7058: 21.4.5. Packages containing Perl scripts
1.1 dsieger 7059:
1.266 martin 7060: If your package contains interpreted Perl scripts, add perl to the USE_TOOLS
1.1 dsieger 7061: variable and set REPLACE_PERL to ensure that the proper interpreter path is
7062: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74 wiz 7063: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
1.210 gutterid 7064: replaced with the full path to the Perl executable.
1.1 dsieger 7065:
1.210 gutterid 7066: If a particular version of Perl is needed, set the PERL5_REQD variable to the
1.266 martin 7067: version number. The default is 5.0 .
1.1 dsieger 7068:
1.266 martin 7069: See Section 21.6.6, Packages installing Perl modules for information about
1.210 gutterid 7070: handling Perl modules.
7071:
7072: There is also the REPLACE_PERL6 variable for the language now known as Raku.
1.1 dsieger 7073:
1.266 martin 7074: 21.4.6. Packages containing shell scripts
1.41 wiz 7075:
7076: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
1.225 gutterid 7077: shell she-bangs in files. Please use the appropriate one, preferring REPLACE_SH
7078: when this shell is sufficient. Each should contain a list of scripts, relative
7079: to WRKSRC, that you want adjusted. Every occurrence of the matching shell in a
7080: she-bang line will be replaced with the full path to the shell executable. When
7081: using REPLACE_BASH, don't forget to add bash to USE_TOOLS.
1.41 wiz 7082:
1.266 martin 7083: 21.4.7. Other programming languages
1.1 dsieger 7084:
1.210 gutterid 7085: There are further similar REPLACE variables available, e.g., REPLACE_AWK for
7086: packages containing awk scripts, and REPLACE_R for R. These two, like the
1.211 gutterid 7087: others noted above, have their actions defined centrally in mk/configure/
7088: replace-interpreter.mk. Other languages define the actions of these variables
7089: within their own dedicated part of the tree, e.g., REPLACE_PHP is actioned in
1.245 gutterid 7090: lang/php/replace.mk, and REPLACE_PYTHON is actioned in lang/python/
1.211 gutterid 7091: application.mk. For other languages, consult the mk files found within their
1.216 gutterid 7092: specific directories (the naming convention varies), or check the list found in
1.266 martin 7093: Appendix E, Help topics.
1.210 gutterid 7094:
7095: Currently, special handling for other languages varies in pkgsrc. If a compiler
7096: package provides a buildlink3.mk file, include that, otherwise just add a
7097: (build) dependency on the appropriate compiler package.
1.1 dsieger 7098:
1.266 martin 7099: 21.5. The build phase
1.1 dsieger 7100:
7101: The most common failures when building a package are that some platforms do not
7102: provide certain header files, functions or libraries, or they provide the
7103: functions in a library that the original package author didn't know. To work
7104: around this, you can rewrite the source code in most cases so that it does not
7105: use the missing functions or provides a replacement function.
7106:
1.266 martin 7107: 21.5.1. Compiling C and C++ code conditionally
1.1 dsieger 7108:
7109: If a package already comes with a GNU configure script, the preferred way to
7110: fix the build failure is to change the configure script, not the code. In the
7111: other cases, you can utilize the C preprocessor, which defines certain macros
7112: depending on the operating system and hardware architecture it compiles for.
7113: These macros can be queried using for example #if defined(__i386). Almost every
7114: operating system, hardware architecture and compiler has its own macro. For
7115: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
7116: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
7117: GCC.
7118:
7119: The list of the following macros for hardware and operating system depends on
7120: the compiler that is used. For example, if you want to conditionally compile
7121: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
7122: Use __sun instead.
7123:
1.266 martin 7124: 21.5.1.1. C preprocessor macros to identify the operating system
1.1 dsieger 7125:
1.223 nia 7126: To distinguish between specific NetBSD versions, you should use the following
7127: code.
7128:
7129: #ifdef __NetBSD__
7130: #include <sys/param.h>
7131: #if __NetBSD_Prereq__(9,99,17)
7132: /* use a newer feature */
7133: #else
7134: /* older code */
7135: #endif
7136: #endif
7137:
7138: #ifndef _WIN32
7139: /* Unix-like specific code */
7140: #endif
7141:
1.1 dsieger 7142: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
7143: should use the following code.
7144:
7145: #include <sys/param.h>
7146: #if (defined(BSD) && BSD >= 199306)
7147: /* BSD-specific code goes here */
7148: #else
7149: /* non-BSD-specific code goes here */
7150: #endif
7151:
1.223 nia 7152: You can also test for the following macros:
1.1 dsieger 7153:
1.46 obache 7154: Cygwin __CYGWIN__
7155: DragonFly __DragonFly__
1.1 dsieger 7156: FreeBSD __FreeBSD__
1.46 obache 7157: Haiku __HAIKU__
1.1 dsieger 7158: IRIX __sgi (TODO: get a definite source for this)
1.223 nia 7159: Linux __linux
1.83 dholland 7160: Mac OS X __APPLE__
1.46 obache 7161: Minix3 __minix
1.1 dsieger 7162: NetBSD __NetBSD__
7163: OpenBSD __OpenBSD__
7164: Solaris sun, __sun
7165:
1.266 martin 7166: 21.5.1.2. C preprocessor macros to identify the hardware architecture
1.1 dsieger 7167:
7168: i386 i386, __i386, __i386__
1.223 nia 7169: x86-64 __amd64__, __x86_64__
7170: ARM __arm__
1.1 dsieger 7171: MIPS __mips
7172: SPARC sparc, __sparc
1.223 nia 7173: PowerPC __powerpc
1.1 dsieger 7174:
1.266 martin 7175: 21.5.1.3. C preprocessor macros to identify the compiler
1.1 dsieger 7176:
7177: GCC __GNUC__ (major version), __GNUC_MINOR__
7178: MIPSpro _COMPILER_VERSION (0x741 for MIPSpro 7.41)
7179: SunPro __SUNPRO_C (0x570 for Sun C 5.7)
7180: SunPro C++ __SUNPRO_CC (0x580 for Sun C++ 5.8)
7181:
1.266 martin 7182: 21.5.2. How to handle compiler bugs
1.1 dsieger 7183:
7184: Some source files trigger bugs in the compiler, based on combinations of
7185: compiler version and architecture and almost always relation to optimisation
7186: being enabled. Common symptoms are gcc internal errors or never finishing
7187: compiling a file.
7188:
7189: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87 tnn 7190: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
7191:
7192: This used to be a big problem in the past, but is rarely needed now as compiler
7193: technology has matured. If you still need to add a compiler specific
7194: workaround, please do so in the file hacks.mk and describe the symptom and
7195: compiler version as detailed as possible.
1.1 dsieger 7196:
1.266 martin 7197: 21.5.3. No such file or directory
1.172 rillig 7198:
7199: Compilation sometimes fails with an error message like this:
7200:
7201: .../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
7202: fatal error: pango/pango.h: No such file or directory
7203:
7204: The proper way to fix this problem depends on the type of the header, which is
7205: described in the following sections.
7206:
1.266 martin 7207: 21.5.3.1. Headers from other packages
1.172 rillig 7208:
7209: If the header name looks like it comes from a different package, that other
7210: package should be included via the buildlink3 framework.
7211:
7212: First, look whether the header is somewhere in the buildlink3 directory below
7213: WRKDIR. In the above case of the missing Pango header:
7214:
7215: $ find work/.buildlink/ -print | grep -F pango/pango.h
7216:
7217: In the case of Pango, the output is:
7218:
7219: work/.buildlink/include/pango-1.0/pango/pango.h
7220:
7221: If the pango/pango.h file were placed directly in the .buildlink directory, it
7222: would have been found automatically. There is an extra pango-1.0 path component
7223: though, which means that the compiler command line must contain an option of
7224: the form -I${BUILDLINK3_PREFIX.pango}/include/pango-1.0. In most cases this
7225: option is generated by the configure script, which can be examined using:
7226:
7227: $ $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
7228: -I/usr/pkg/include/pango-1.0
7229: -I/usr/pkg/include/pango-1.0
7230: -I/usr/pkg/include/pango-1.0
7231: -I/usr/pkg/include/pango-1.0
7232: -I/usr/pkg/include/pango-1.0
7233:
7234: This looks good. These options are transformed by the buildlink wrapper to
7235: refer to the correct path inside work/.buildlink.
7236:
7237: Since the compilation fails though, examine the compiler command lines in work
7238: /.work.log to see whether the -I option is included in the particular command
7239: line.
7240:
7241: To further analyze the situation, run bmake build-env, which sets up an
7242: interactive, realistic environment including all the pkgsrc wrapper commands
7243: and environment variables. From there, try to compile some simple example
7244: programs that use the header.
7245:
1.266 martin 7246: 21.5.3.2. Headers generated during the build
1.172 rillig 7247:
7248: If the name of the header seems to come from the package itself, and if the
7249: build is run with parallel jobs, the package may have some undeclared
7250: dependencies between the .c and the .h files, and a C file is compiled before
7251: its required header is generated.
7252:
7253: To see whether the build runs with parallel jobs, run bmake show-all-build |
7254: grep JOBS. Its output looks like this:
7255:
7256: usr MAKE_JOBS= 7
7257: pkg MAKE_JOBS_SAFE # undefined
7258: def _MAKE_JOBS_N= 7
7259:
7260: In this case the pkgsrc user has asked pkgsrc to build packages with 7 jobs in
7261: parallel (MAKE_JOBS). The package could have disabled parallel builds by
7262: setting MAKE_JOBS_SAFE to no, but in this case it hasn't.
7263:
7264: To see whether the build failure is caused by parallel builds, first save the
7265: exact error message and a bit of context, maybe you need it later for reporting
7266: a bug. Next, run:
7267:
7268: MAKE_JOBS_SAFE=no bmake clean build
7269:
7270: If that succeeds, file a bug report against the pkgsrc package, including the
7271: exact error message and the contents of your mk.conf file.
7272:
1.266 martin 7273: 21.5.3.3. Symlinks
1.173 rillig 7274:
7275: Pkgsrc does not work reliably if any of LOCALBASE, VARBASE or WRKDIR contains a
7276: symlink. Since 2019Q2, the pkgsrc bootstrap program prevents installing pkgsrc
7277: in symlink-based directories. Existing pkgsrc installations are not checked for
7278: symlinks though.
7279:
7280: The "No such file or directory" error messages are a typical symptom of
7281: symlinks, and it's quite difficult to find out that this is the actual cause.
7282:
1.266 martin 7283: 21.5.3.4. Stale working directories
1.173 rillig 7284:
7285: When building a hierarchy of packages, it may happen that one package is built
7286: and then pkgsrc is updated. This situation can provoke various hard to diagnose
7287: build errors. To clean up the situation:
7288:
1.223 nia 7289: $ (cd ../../ && cat mk/bsd.pkg.mk >/dev/null && rm -rf */*/work)
1.173 rillig 7290:
1.223 nia 7291: (The only purpose of the bsd.pkg.mk is to prevent running this command in the
7292: wrong directory.)
1.173 rillig 7293:
7294: If you have set WRKOBJDIR in mk.conf, remove that directory as well.
7295:
1.266 martin 7296: 21.5.3.5. Other possible reasons
1.173 rillig 7297:
7298: On platforms other than BSD, third-party packages are installed in /usr/
7299: include, together with the base system. This means that pkgsrc cannot
7300: distinguish between headers provided by the base system (which it needs) and
7301: headers from third-party packages (which are often included in pkgsrc as well).
7302: This can lead to subtle version mismatches.
7303:
7304: In pkgsrc installations that have been active for several years, it may happen
7305: that some files are manually deleted. To exclude this unlikely reason, run
7306: pkg_admin check.
7307:
7308: It may help to run pkg_admin rebuild-tree to check/fix dependencies.
7309:
1.266 martin 7310: If all of the above doesn't help, see Chapter 2, Getting help for contact
1.173 rillig 7311: information. Be prepared to describe what you have tried so far and what any
7312: error messages were.
7313:
1.266 martin 7314: 21.5.4. Undefined reference to ...
1.1 dsieger 7315:
7316: This error message often means that a package did not link to a shared library
7317: it needs. The following functions are known to cause this error message over
7318: and over.
7319:
7320: +-----------------------------------------------------+
7321: | Function |Library |Affected platforms|
7322: |-------------------------+--------+------------------|
7323: |accept, bind, connect |-lsocket|Solaris |
7324: |-------------------------+--------+------------------|
7325: |crypt |-lcrypt |DragonFly, NetBSD |
7326: |-------------------------+--------+------------------|
7327: |dlopen, dlsym |-ldl |Linux |
7328: |-------------------------+--------+------------------|
7329: |gethost* |-lnsl |Solaris |
7330: |-------------------------+--------+------------------|
7331: |inet_aton |-lresolv|Solaris |
7332: |-------------------------+--------+------------------|
7333: |nanosleep, sem_*, timer_*|-lrt |Solaris |
7334: |-------------------------+--------+------------------|
7335: |openpty |-lutil |Linux |
7336: +-----------------------------------------------------+
7337:
1.223 nia 7338: To fix these linker errors, it is often sufficient to add LIBS.OperatingSystem+
7339: = -lfoo to the package Makefile and then run bmake clean; bmake.
1.1 dsieger 7340:
1.266 martin 7341: 21.5.4.1. The SunPro compiler and inline functions
1.1 dsieger 7342:
7343: When you are using the SunPro compiler, there is another possibility. That
7344: compiler cannot handle the following code:
7345:
7346: extern int extern_func(int);
7347:
7348: static inline int
7349: inline_func(int x)
7350: {
7351: return extern_func(x);
7352: }
7353:
7354: int main(void)
7355: {
7356: return 0;
7357: }
7358:
7359: It generates the code for inline_func even if that function is never used. This
7360: code then refers to extern_func, which can usually not be resolved. To solve
7361: this problem you can try to tell the package to disable inlining of functions.
7362:
1.266 martin 7363: 21.5.4.2. Missing atomic functions
1.228 gutterid 7364:
7365: When building for older machine architectures (e.g., i386, PowerPC), builds may
7366: fail because the package expects modern 64-bit atomic functions which the
7367: underlying hardware either doesn't support, or will only support with specific
7368: compiler flags. This is generally handled via inclusion of mk/atomic64.mk.
7369:
1.266 martin 7370: 21.5.5. Running out of memory
1.1 dsieger 7371:
7372: Sometimes packages fail to build because the compiler runs into an operating
7373: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.266 martin 7374: told to unlimit the resources. The allowed values are any combination of
7375: cputime , datasize , memorysize , stacksize and virtualsize . Setting this
1.223 nia 7376: variable is similar to running the shell builtin ulimit command to raise the
7377: maximum data segment size or maximum stack size of a process, respectively, to
7378: their hard limits.
1.1 dsieger 7379:
1.266 martin 7380: 21.6. The install phase
1.1 dsieger 7381:
1.266 martin 7382: 21.6.1. Creating needed directories
1.1 dsieger 7383:
7384: The BSD-compatible install supplied with some operating systems cannot create
7385: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
7386: like this:
7387:
7388: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
7389: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
7390:
1.266 martin 7391: Instead of running the install commands directly, you can also append dir1
7392: dir2 to the INSTALLATION_DIRS variable, which will automatically do the right
1.223 nia 7393: thing.
1.1 dsieger 7394:
1.266 martin 7395: 21.6.2. Where to install documentation
1.1 dsieger 7396:
7397: In general, documentation should be installed into ${PREFIX}/share/doc/$
1.223 nia 7398: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME_NOREV} (the latter includes the
7399: version number of the package).
1.1 dsieger 7400:
7401: Many modern packages using GNU autoconf allow to set the directory where HTML
1.266 martin 7402: documentation is installed with the --with-html-dir option. Sometimes using
1.1 dsieger 7403: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
1.223 nia 7404: share/doc/html or other places. In pkgsrc, the HTML documentation should go
7405: into the package-specific directory, just like any other documentation.
1.1 dsieger 7406:
7407: An exception to the above is that library API documentation generated with the
7408: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
7409: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
7410: can be recognized from files ending in .devhelp or .devhelp2. (It is also
7411: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
7412: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
7413: then, no additional subdirectory level is allowed in this case. This is usually
1.266 martin 7414: achieved by using --with-html-dir=${PREFIX}/share/doc . ${PREFIX}/share/
1.1 dsieger 7415: gtk-doc is preferred though.)
7416:
1.266 martin 7417: 21.6.3. Installing highscore files
1.1 dsieger 7418:
7419: Certain packages, most of them in the games category, install a score file that
7420: allows all users on the system to record their highscores. In order for this to
7421: work, the binaries need to be installed setgid and the score files owned by the
1.36 wiz 7422: appropriate group and/or owner (traditionally the "games" user/group). Set
7423: USE_GAMESGROUP to yes to support this. The following variables, documented in
7424: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100 leot 7425: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
7426: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
7427:
7428: An example that illustrates some of the variables described above is games/
7429: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
7430: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
7431: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
7432: to install setgid the game binary:
7433:
7434: USE_GAMESGROUP= yes
7435:
7436: BUILD_DEFS+= VARBASE
7437:
7438: OWN_DIRS_PERMS+= ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
7439: REQD_FILES_PERMS+= /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
7440: SPECIAL_PERMS+= ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
7441:
7442: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
7443: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
7444: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1 dsieger 7445:
1.14 jmcneill 7446: A package should therefore never hard code file ownership or access permissions
1.100 leot 7447: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
7448: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1 dsieger 7449:
1.266 martin 7450: 21.6.4. Adding DESTDIR support to packages
1.4 rillig 7451:
1.14 jmcneill 7452: DESTDIR support means that a package installs into a staging directory, not the
7453: final location of the files. Then a binary package is created which can be used
7454: for installation as usual. There are two ways: Either the package must install
1.266 martin 7455: as root ( destdir ) or the package can install as non-root user ( user-destdir
1.25 wiz 7456: ).
1.14 jmcneill 7457:
1.266 martin 7458: * PKG_DESTDIR_SUPPORT has to be set to destdir or user-destdir . By
7459: default PKG_DESTDIR_SUPPORT is set to user-destdir to help catching more
1.113 leot 7460: potential packaging problems. If bsd.prefs.mk is included in the Makefile,
7461: PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14 jmcneill 7462:
1.4 rillig 7463: * All installation operations have to be prefixed with ${DESTDIR}.
7464:
7465: * automake gets this DESTDIR mostly right automatically. Many manual rules
7466: and pre/post-install often are incorrect; fix them.
7467:
1.17 imil 7468: * If files are installed with special owner/group use SPECIAL_PERMS.
1.4 rillig 7469:
7470: * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
7471:
1.266 martin 7472: 21.6.5. Packages with hardcoded paths to other interpreters
1.1 dsieger 7473:
7474: Your package may also contain scripts with hardcoded paths to other
1.203 nia 7475: interpreters besides (or as well as) Perl. To correct the full pathname to the
1.1 dsieger 7476: script interpreter, you need to set the following definitions in your Makefile
7477: (we shall use tclsh in this example):
7478:
7479: REPLACE_INTERPRETER+= tcl
7480: REPLACE.tcl.old= .*/bin/tclsh
7481: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
7482: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
7483: # relative to ${WRKSRC}, just as in REPLACE_PERL
7484:
1.266 martin 7485: 21.6.6. Packages installing Perl modules
1.1 dsieger 7486:
7487: Makefiles of packages providing perl5 modules should include the Makefile
7488: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
7489: standard perl configuration for such modules as well as various hooks to tune
7490: this configuration. See comments in this file for details.
7491:
7492: Perl5 modules will install into different places depending on the version of
7493: perl used during the build process. To address this, pkgsrc will append lines
7494: to the PLIST corresponding to the files listed in the installed .packlist file
7495: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48 wiz 7496: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
7497: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1 dsieger 7498:
1.48 wiz 7499: PERL5_PACKLIST= auto/Pg/.packlist
1.1 dsieger 7500:
1.48 wiz 7501: The perl5 config variables installarchlib, installscript, installvendorbin,
7502: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
7503: and installvendorman3dir represent those locations in which components of perl5
7504: modules may be installed, provided as variable with uppercase and prefixed with
7505: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
7506: have a packlist. These variables are also substituted for in the PLIST as
7507: uppercase prefixed with PERL5_SUB_.
1.1 dsieger 7508:
1.266 martin 7509: 21.6.7. Packages installing pkg-config files
1.254 wiz 7510:
7511: Some packages, usually those providing libraries, install pkg-config files so
7512: that their headers and libraries can easily be found. The file names end with
7513: .pc.
7514:
7515: Most of the time, these files only provide the linker flags for the library,
7516: but do not include the flags for setting the rpath so the libraries can also be
7517: found at runtime. Since this is so common, pkgsrc provides PKGCONFIG_OVERRIDE
7518: for this. Many packages generate the .pc from .pc.in, in that case add those
7519: files to the PKGCONFIG_OVERRIDE variable:
7520:
7521: PKGCONFIG_OVERRIDE+= foo.pc.in
7522:
7523:
7524: For packages using meson, the files are generated during build and you also
7525: need to change the phase in which the replacement is done. For example:
7526:
7527: PKGCONFIG_OVERRIDE+= output/meson-private/foo.pc
7528: PKGCONFIG_OVERRIDE_STAGE= post-build
7529:
7530:
1.266 martin 7531: 21.6.8. Packages installing info files
1.1 dsieger 7532:
1.266 martin 7533: Some packages install info files or use the makeinfo or install-info
1.1 dsieger 7534: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
7535: and DEINSTALL scripts will be generated to handle registration of the info
1.266 martin 7536: files in the Info directory file. The install-info command used for the info
1.1 dsieger 7537: files registration is either provided by the system, or by a special purpose
7538: package automatically added as dependency if needed.
7539:
7540: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
1.266 martin 7541: located. PKGINFODIR defaults to info and can be overridden by the user.
1.1 dsieger 7542:
7543: The info files for the package should be listed in the package PLIST; however
7544: any split info files need not be listed.
7545:
1.266 martin 7546: A package which needs the makeinfo command at build time must add makeinfo
7547: to USE_TOOLS in its Makefile. If a minimum version of the makeinfo command is
1.1 dsieger 7548: needed it should be noted with the TEXINFO_REQD variable in the package
7549: Makefile. By default, a minimum version of 3.12 is required. If the system does
7550: not provide a makeinfo command or if it does not match the required minimum, a
7551: build dependency on the devel/gtexinfo package will be added automatically.
7552:
7553: The build and installation process of the software provided by the package
7554: should not use the install-info command as the registration of info files is
1.25 wiz 7555: the task of the package INSTALL script, and it must use the appropriate
1.1 dsieger 7556: makeinfo command.
7557:
7558: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
7559: the install-info and makeinfo commands in a directory listed early in PATH.
7560:
7561: The script overriding install-info has no effect except the logging of a
7562: message. The script overriding makeinfo logs a message and according to the
7563: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
7564: error.
7565:
1.266 martin 7566: 21.6.9. Packages installing man pages
1.1 dsieger 7567:
7568: All packages that install manual pages should install them into the same
7569: directory, so that there is one common place to look for them. In pkgsrc, this
7570: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.266 martin 7571: packages. The default for PKGMANDIR is man . Another often-used value is
7572: share/man .
1.1 dsieger 7573:
7574: Note
7575:
7576: The support for a custom PKGMANDIR is far from complete.
7577:
7578: The PLIST files can just use man/ as the top level directory for the man page
7579: file entries, and the pkgsrc framework will convert as needed. In all other
7580: places, the correct PKGMANDIR must be used.
7581:
1.266 martin 7582: Packages that are configured with GNU_CONFIGURE set as yes , by default will
1.1 dsieger 7583: use the ./configure --mandir switch to set where the man pages should be
7584: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
7585: {PKGMANDIR}.
7586:
7587: Packages that use GNU_CONFIGURE but do not use --mandir, can set
1.266 martin 7588: CONFIGURE_HAS_MANDIR to no . Or if the ./configure script uses a non-standard
1.1 dsieger 7589: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
7590:
1.266 martin 7591: See Section 19.5, Man page compression for information on installation of
1.1 dsieger 7592: compressed manual pages.
7593:
1.266 martin 7594: 21.6.10. Packages installing X11 fonts
1.1 dsieger 7595:
7596: If a package installs font files, you will need to rebuild the fonts database
7597: in the directory where they get installed at installation and deinstallation
7598: time. This can be automatically done by using the pkginstall framework.
7599:
7600: You can list the directories where fonts are installed in the FONTS_DIRS.type
1.266 martin 7601: variables, where type can be one of ttf , type1 or x11 . Also make sure
1.1 dsieger 7602: that the database file fonts.dir is not listed in the PLIST.
7603:
7604: Note that you should not create new directories for fonts; instead use the
7605: standard ones to avoid that the user needs to manually configure his X server
7606: to find them.
7607:
1.266 martin 7608: 21.6.11. Packages installing SGML or XML data
1.1 dsieger 7609:
7610: If a package installs SGML or XML data files that need to be registered in
7611: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
7612: extra steps:
7613:
7614: 1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
7615: care of registering those files in system-wide catalogs at installation and
7616: deinstallation time.
7617:
7618: 2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
7619: package.
7620:
7621: 3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
7622: package.
7623:
7624: 4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
7625: These come in groups of three strings; see xmlcatmgr(1) for more
7626: information (specifically, arguments recognized by the 'add' action). Note
7627: that you will normally not use this variable.
7628:
7629: 5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
7630: come in groups of three strings; see xmlcatmgr(1) for more information
7631: (specifically, arguments recognized by the 'add' action). Note that you
7632: will normally not use this variable.
7633:
1.266 martin 7634: 21.6.12. Packages installing extensions to the MIME database
1.1 dsieger 7635:
7636: If a package provides extensions to the MIME database by installing .xml files
7637: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
7638: ensure that the database is kept consistent with respect to these new files:
7639:
7640: 1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
7641: buildlink3.mk file from this same directory, which is reserved for
7642: inclusion from other buildlink3.mk files). It takes care of rebuilding the
7643: MIME database at installation and deinstallation time, and disallows any
7644: access to it directly from the package.
7645:
1.25 wiz 7646: 2. Check the PLIST and remove any entries under the share/mime directory,
1.1 dsieger 7647: except for files saved under share/mime/packages. The former are handled
7648: automatically by the update-mime-database program, but the latter are
7649: package-dependent and must be removed by the package that installed them in
7650: the first place.
7651:
7652: 3. Remove any share/mime/* directories from the PLIST. They will be handled by
7653: the shared-mime-info package.
7654:
1.266 martin 7655: 21.6.13. Packages using intltool
1.1 dsieger 7656:
7657: If a package uses intltool during its build, add intltool to the USE_TOOLS,
7658: which forces it to use the intltool package provided by pkgsrc, instead of the
7659: one bundled with the distribution file.
7660:
7661: This tracks intltool's build-time dependencies and uses the latest available
7662: version; this way, the package benefits of any bug fixes that may have appeared
7663: since it was released.
7664:
1.266 martin 7665: 21.6.14. Packages installing startup scripts
1.1 dsieger 7666:
1.256 wiz 7667: If a package contains an rc.d script, it won't be copied into the startup
7668: directory (/etc/rc.d) by default, but you can enable copying by setting the
7669: option PKG_RCD_SCRIPTS=YES in mk.conf. With PKG_RCD_SCRIPTS=YES, rc.d scripts
7670: will be copied into /etc/rc.d when a package is installed, but only if the
7671: target does not already exist. Copies in /etc/rc.d will be automatically
7672: removed only if they have not been modified.
7673:
7674: Note that this alone does not enable the service: It must still be added to /
7675: etc/rc.conf.
1.1 dsieger 7676:
1.266 martin 7677: 21.6.15. Packages installing TeX modules
1.1 dsieger 7678:
7679: If a package installs TeX packages into the texmf tree, the ls-R database of
7680: the tree needs to be updated.
7681:
7682: Note
7683:
1.23 jakllsch 7684: Except the main TeX packages such as kpathsea, packages should install files
7685: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1 dsieger 7686:
1.23 jakllsch 7687: 1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
7688: ls-R database at installation and deinstallation time.
1.1 dsieger 7689:
1.23 jakllsch 7690: 2. If your package installs files into a texmf tree other than the one at $
7691: {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
7692: trees that need database update.
1.1 dsieger 7693:
7694: If your package also installs font map files that need to be registered
1.30 dholland 7695: using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
7696: and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then
7697: updmap will be run automatically at installation/deinstallation to enable/
7698: disable font map files for TeX output drivers.
1.1 dsieger 7699:
7700: 3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30 dholland 7701: be removed only by the kpathsea package.
1.1 dsieger 7702:
1.266 martin 7703: 21.6.16. Packages supporting running binaries in emulation
1.1 dsieger 7704:
7705: There are some packages that provide libraries and executables for running
7706: binaries from a one operating system on a different one (if the latter supports
7707: it). One example is running Linux binaries on NetBSD.
7708:
7709: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
7710:
7711: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
7712: if all libraries for each installed executable can be found by the dynamic
7713: linker. Since the standard dynamic linker is run, this fails for emulation
7714: packages, because the libraries used by the emulation are not in the standard
7715: directories.
7716:
1.266 martin 7717: 21.6.17. Packages installing hicolor icons
1.1 dsieger 7718:
7719: If a package installs images under the share/icons/hicolor and/or updates the
7720: share/icons/hicolor/icon-theme.cache database, you need to take some extra
7721: steps to make sure that the shared theme directory is handled appropriately and
7722: that the cache database is rebuilt:
7723:
7724: 1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
7725:
7726: 2. Check the PLIST and remove the entry that refers to the theme cache.
7727:
7728: 3. Ensure that the PLIST does not remove the shared icon directories from the
7729: share/icons/hicolor hierarchy because they will be handled automatically.
7730:
7731: The best way to verify that the PLIST is correct with respect to the last two
7732: points is to regenerate it using make print-PLIST.
7733:
1.266 martin 7734: 21.6.18. Packages installing desktop files
1.1 dsieger 7735:
7736: If a package installs .desktop files under share/applications and these include
1.54 rodent 7737: MIME information (MimeType key), you need to take extra steps to ensure that
7738: they are registered into the MIME database:
1.1 dsieger 7739:
7740: 1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
7741:
7742: 2. Check the PLIST and remove the entry that refers to the share/applications/
7743: mimeinfo.cache file. It will be handled automatically.
7744:
7745: The best way to verify that the PLIST is correct with respect to the last point
7746: is to regenerate it using make print-PLIST.
7747:
1.266 martin 7748: 21.7. Marking packages as having problems
1.1 dsieger 7749:
1.23 jakllsch 7750: In some cases one does not have the time to solve a problem immediately. In
7751: this case, one can plainly mark a package as broken. For this, one just sets
7752: the variable BROKEN to the reason why the package is broken (similar to the
1.162 rillig 7753: PKG_FAIL_REASON variable). A user trying to build the package will immediately
7754: be shown this message, and the build will not be even tried.
1.1 dsieger 7755:
1.23 jakllsch 7756: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1 dsieger 7757:
1.266 martin 7758: Chapter 22. GNOME packaging and porting
1.184 rillig 7759:
7760: Table of Contents
7761:
7762: 22.1. Meta packages
7763: 22.2. Packaging a GNOME application
7764: 22.3. Updating GNOME to a newer version
7765: 22.4. Patching guidelines
7766:
7767: Quoting GNOME's web site:
7768:
7769: The GNOME project provides two things: The GNOME desktop environment, an
7770: intuitive and attractive desktop for users, and the GNOME development
7771: platform, an extensive framework for building applications that integrate
7772: into the rest of the desktop.
7773:
7774: pkgsrc provides a seamless way to automatically build and install a complete
7775: GNOME environment under many different platforms. We can say with confidence
7776: that pkgsrc is one of the most advanced build and packaging systems for GNOME
7777: due to its included technologies buildlink3, the wrappers and tools framework
7778: and automatic configuration file management. Lots of efforts are put into
7779: achieving a completely clean deinstallation of installed software components.
7780:
7781: Given that pkgsrc is NetBSD's official packaging system, the above also means
7782: that great efforts are put into making GNOME work under this operating system.
7783:
7784: This chapter is aimed at pkgsrc developers and other people interested in
7785: helping our GNOME porting and packaging efforts. It provides instructions on
7786: how to manage the existing packages and some important information regarding
7787: their internals.
7788:
1.266 martin 7789: 22.1. Meta packages
1.184 rillig 7790:
7791: pkgsrc includes three GNOME-related meta packages:
7792:
7793: * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
7794: includes the necessary bits to get it to boot correctly, although it may
7795: lack important functionality for daily operation. The idea behind this
7796: package is to let end users build their own configurations on top of this
7797: one, first installing this meta package to achieve a functional setup and
7798: then adding individual applications.
7799:
7800: * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
7801: desktop as defined by the GNOME project; this is based on the components
7802: distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
7803: directories of the official FTP server. Developer-only tools found in those
7804: directories are not installed unless required by some other component to
7805: work properly. Similarly, packages from the bindings set (bindings/x.y/
7806: x.y.z/sources) are not pulled in unless required as a dependency for an
7807: end-user component. This package "extends" meta-pkgs/gnome-base.
7808:
7809: * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
7810: component when fetched from the CVS repository. These are required to let
7811: the autogen.sh scripts work appropriately.
7812:
7813: In all these packages, the DEPENDS lines are sorted in a way that eases
7814: updates: a package may depend on other packages listed before it but not on any
7815: listed after it. It is very important to keep this order to ease updates so...
7816: do not change it to alphabetical sorting!
7817:
1.266 martin 7818: 22.2. Packaging a GNOME application
1.184 rillig 7819:
7820: Almost all GNOME applications are written in C and use a common set of tools as
7821: their build system. Things get different with the new bindings to other
7822: languages (such as Python), but the following will give you a general idea on
7823: the minimum required tools:
7824:
7825: * Almost all GNOME applications use the GNU Autotools as their build system.
7826: As a general rule you will need to tell this to your package:
7827:
1.223 nia 7828: GNU_CONFIGURE= yes
7829: USE_LIBTOOL= yes
7830: USE_TOOLS+= gmake
1.184 rillig 7831:
7832: * If the package uses pkg-config to detect dependencies, add this tool to the
7833: list of required utilities:
7834:
1.223 nia 7835: USE_TOOLS+= pkg-config
1.184 rillig 7836:
7837: Also use pkgtools/verifypc at the end of the build process to ensure that
7838: you did not miss to specify any dependency in your package and that the
7839: version requirements are all correct.
7840:
7841: * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
7842: handle dependencies and to force the package to use the latest available
7843: version.
7844:
7845: * If the package uses gtk-doc (a documentation generation utility), do not
7846: add a dependency on it. The tool is rather big and the distfile should come
7847: with pregenerated documentation anyway; if it does not, it is a bug that
7848: you ought to report. For such packages you should disable gtk-doc (unless
7849: it is the default):
7850:
1.223 nia 7851: CONFIGURE_ARGS+= --disable-gtk-doc
1.184 rillig 7852:
7853: The default location of installed HTML files (share/gtk-doc/<package-name>)
7854: is correct and should not be changed unless the package insists on
7855: installing them somewhere else. Otherwise programs as devhelp will not be
7856: able to open them. You can do that with an entry similar to:
1.1 dsieger 7857:
1.223 nia 7858: CONFIGURE_ARGS+= --with-html-dir=${PREFIX}/share/gtk-doc/...
1.1 dsieger 7859:
1.184 rillig 7860: GNOME uses multiple shared directories and files under the installation prefix
7861: to maintain databases. In this context, shared means that those exact same
7862: directories and files are used among several different packages, leading to
7863: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
7864: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
7865: your file lists and omitting shared files from them. If you find yourself doing
7866: those, your package is most likely incorrect.
1.1 dsieger 7867:
1.184 rillig 7868: The following table lists the common situations that result in using shared
7869: directories or files. For each of them, the appropriate solution is given.
7870: After applying the solution be sure to regenerate the package's file list with
7871: make print-PLIST and ensure it is correct.
1.1 dsieger 7872:
1.266 martin 7873: Table 22.1. PLIST handling for GNOME packages
1.1 dsieger 7874:
1.184 rillig 7875: +-----------------------------------------------------------------------------+
7876: | If the package... | Then... |
7877: |-------------------------------------------+---------------------------------|
1.266 martin 7878: |Installs icons under the share/icons/ |See Section 21.6.17, Packages |
7879: |hicolor hierarchy or updates share/icons/ |installing hicolor icons . |
1.184 rillig 7880: |hicolor/icon-theme.cache. | |
7881: |-------------------------------------------+---------------------------------|
1.266 martin 7882: | |See Section 21.6.12, Packages |
1.184 rillig 7883: |Installs files under share/mime/packages. |installing extensions to the MIME|
1.266 martin 7884: | |database . |
1.184 rillig 7885: |-------------------------------------------+---------------------------------|
1.266 martin 7886: |Installs .desktop files under share/ |See Section 21.6.18, Packages |
7887: |applications and these include MIME |installing desktop files . |
1.184 rillig 7888: |information. | |
7889: +-----------------------------------------------------------------------------+
1.1 dsieger 7890:
7891:
1.266 martin 7892: 22.3. Updating GNOME to a newer version
1.1 dsieger 7893:
1.184 rillig 7894: When seeing GNOME as a whole, there are two kinds of updates:
1.1 dsieger 7895:
1.184 rillig 7896: Major update
1.1 dsieger 7897:
1.184 rillig 7898: Given that there is still a very long way for GNOME 3 (if it ever appears),
7899: we consider a major update one that goes from a 2.X version to a 2.Y one,
7900: where Y is even and greater than X. These are hard to achieve because they
7901: introduce lots of changes in the components' code and almost all GNOME
7902: distfiles are updated to newer versions. Some of them can even break API
7903: and ABI compatibility with the previous major version series. As a result,
7904: the update needs to be done all at once to minimize breakage.
1.1 dsieger 7905:
1.184 rillig 7906: A major update typically consists of around 80 package updates and the
7907: addition of some new ones.
1.1 dsieger 7908:
1.184 rillig 7909: Minor update
1.1 dsieger 7910:
1.184 rillig 7911: We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
7912: one where Y is greater than X. These are easy to achieve because they do
7913: not update all GNOME components, can be done in an incremental way and do
7914: not break API nor ABI compatibility.
1.1 dsieger 7915:
1.184 rillig 7916: A minor update typically consists of around 50 package updates, although
7917: the numbers here may vary a lot.
1.1 dsieger 7918:
1.184 rillig 7919: In order to update the GNOME components in pkgsrc to a new stable release
7920: (either major or minor), the following steps should be followed:
1.1 dsieger 7921:
1.184 rillig 7922: 1. Get a list of all the tarballs that form the new release by using the
7923: following commands. These will leave the full list of the components'
7924: distfiles into the list.txt file:
1.1 dsieger 7925:
1.184 rillig 7926: % echo ls "*.tar.bz2" | \
7927: ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
7928: awk '{ print $9 }' >list.txt
7929: % echo ls "*.tar.bz2" | \
7930: ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
7931: awk '{ print $9 }' >>list.txt
1.1 dsieger 7932:
1.184 rillig 7933: 2. Open each meta package's Makefile and bump their version to the release you
7934: are updating them to. The three meta packages should be always consistent
7935: with versioning. Obviously remove any PKGREVISIONs that might be in them.
1.1 dsieger 7936:
1.184 rillig 7937: 3. For each meta package, update all its DEPENDS lines to match the latest
7938: versions as shown by the above commands. Do not list any newer version
7939: (even if found in the FTP) because the meta packages are supposed to list
7940: the exact versions that form a specific GNOME release. Exceptions are
7941: permitted here if a newer version solves a serious issue in the overall
7942: desktop experience; these typically come in the form of a revision bump in
7943: pkgsrc, not in newer versions from the developers.
1.1 dsieger 7944:
1.184 rillig 7945: Packages not listed in the list.txt file should be updated to the latest
7946: version available (if found in pkgsrc). This is the case, for example, of
7947: the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
7948: package.
1.1 dsieger 7949:
1.184 rillig 7950: 4. Generate a patch from the modified meta packages and extract the list of
7951: "new" lines. This will provide you an outline on what packages need to be
7952: updated in pkgsrc and in what order:
1.1 dsieger 7953:
1.184 rillig 7954: % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
1.1 dsieger 7955:
1.184 rillig 7956: 5. For major desktop updates it is recommended to zap all your installed
7957: packages and start over from scratch at this point.
1.1 dsieger 7958:
1.184 rillig 7959: 6. Now comes the longest step by far: iterate over the contents of todo.txt
7960: and update the packages listed in it in order. For major desktop updates
7961: none of these should be committed until the entire set is completed because
7962: there are chances of breaking not-yet-updated packages.
1.1 dsieger 7963:
1.184 rillig 7964: 7. Once the packages are up to date and working, commit them to the tree one
7965: by one with appropriate log messages. At the end, commit the three meta
7966: package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
7967: and pkgsrc/doc/TODO files.
1.1 dsieger 7968:
1.266 martin 7969: 22.4. Patching guidelines
1.1 dsieger 7970:
1.184 rillig 7971: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
7972: it is very important that you always, always, always feed back any portability
7973: fixes you do to a GNOME package to the mainstream developers (see
1.266 martin 7974: Section 12.3.5, Feedback to the author ). This is the only way to get their
1.184 rillig 7975: attention on portability issues and to ensure that future versions can be built
7976: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
7977: updates are. Those developers in charge of issuing major GNOME updates will be
7978: grateful if you do that.
1.1 dsieger 7979:
1.200 cirnatda 7980: The most common places to report bugs are the GNOME's GitLab and the
7981: freedesktop.org's GitLab. Not all components use these to track bugs, but most
7982: of them do. Do not be short on your reports: always provide detailed
1.184 rillig 7983: explanations of the current failure, how it can be improved to achieve maximum
1.200 cirnatda 7984: portability and, if at all possible, provide a patch against the main Git
7985: branch. The more verbose you are, the higher chances of your patch being
7986: accepted.
1.1 dsieger 7987:
1.184 rillig 7988: Also, please avoid using preprocessor magic to fix portability issues. While
7989: the FreeBSD GNOME people are doing a great job in porting GNOME to their
7990: operating system, the official GNOME sources are now plagued by conditionals
7991: that check for __FreeBSD__ and similar macros. This hurts portability. Please
1.266 martin 7992: see our patching guidelines (Section 12.3.4, Patching guidelines ) for more
1.184 rillig 7993: details.
1.1 dsieger 7994:
1.266 martin 7995: Chapter 23. Submitting and Committing
1.1 dsieger 7996:
7997: Table of Contents
7998:
1.154 rillig 7999: 23.1. Submitting binary packages
8000: 23.2. Submitting source packages (for non-NetBSD-developers)
8001: 23.3. General notes when adding, updating, or removing packages
8002: 23.4. Commit Messages
8003: 23.5. Committing: Adding a package to CVS
8004: 23.6. Updating a package to a newer version
8005: 23.7. Renaming a package in pkgsrc
8006: 23.8. Moving a package in pkgsrc
1.1 dsieger 8007:
1.266 martin 8008: 23.1. Submitting binary packages
1.1 dsieger 8009:
8010: Our policy is that we accept binaries only from pkgsrc developers to guarantee
8011: that the packages don't contain any trojan horses etc. This is not to annoy
8012: anyone but rather to protect our users! You're still free to put up your
8013: home-made binary packages and tell the world where to get them. NetBSD
1.266 martin 8014: developers doing bulk builds and wanting to upload them please see Chapter 8,
1.66 asau 8015: Creating binary packages for everything in pkgsrc (bulk builds).
1.1 dsieger 8016:
1.266 martin 8017: 23.2. Submitting source packages (for non-NetBSD-developers)
1.1 dsieger 8018:
1.266 martin 8019: Firstly, you can import new packages into pkgsrc-wip ( pkgsrc work-in-progress
1.218 nia 8020: ); see the homepage at https://pkgsrc.org/wip/ for details.
8021:
8022: Next, check that your package is complete, compiles and runs well; see
1.266 martin 8023: Chapter 14, Creating a new pkgsrc package from scratch and the rest of this
1.218 nia 8024: document. Run the pkgtools/pkglint tool and fix any errors that appear.
8025:
8026: Finally, send a report to the pkgsrc bug tracking system, either with the
8027: send-pr(1) command, or if you don't have that, go to the web page https://
8028: www.NetBSD.org/support/send-pr.html, which contains some instructions and a
8029: link to a form where you can submit packages. The sysutils/gtk-send-pr package
8030: is also available as a substitute for either of the above two tools.
1.1 dsieger 8031:
1.266 martin 8032: In the form of the problem report, the category should be pkg , the synopsis
1.1 dsieger 8033: should include the package name and version number, and the description field
8034: should contain a short description of your package (contents of the COMMENT
1.218 nia 8035: variable or DESCR file are OK).
1.1 dsieger 8036:
1.266 martin 8037: 23.3. General notes when adding, updating, or removing packages
1.1 dsieger 8038:
8039: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
8040: CHANGES-YYYY. It's very important to keep this file up to date and conforming
8041: to the existing format, because it will be used by scripts to automatically
8042: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
8043: doc/TODO file and remove the entry for the package you updated or removed, in
8044: case it was mentioned there.
8045:
8046: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
8047: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
8048: that result from a dependency being updated should not be mentioned. In all
8049: other cases it's the developer's decision.
8050:
8051: There is a make target that helps in creating proper CHANGES-YYYY entries: make
8052: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
8053: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
8054: (to avoid having to resolve conflicts later-on) and then to cd to the package
8055: directory. For package updates, make changes-entry is enough. For new packages,
8056: or package moves or removals, set the CTYPE variable on the command line to
1.4 rillig 8057: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23 jakllsch 8058: your local login name is not the same as your NetBSD login name. The target
8059: also automatically removes possibly existing entries for the package in the
8060: TODO file. Don't forget to commit the changes, e.g. by using make
1.66 asau 8061: commit-changes-entry! If you are not using a checkout directly from
1.23 jakllsch 8062: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
8063: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1 dsieger 8064:
1.266 martin 8065: 23.4. Commit Messages
1.130 wiz 8066:
8067: For several years, there have been mirrors of pkgsrc in fossil, git, and hg.
1.257 jkoshy 8068: Standard practice when using these tools is to make the first line of a commit
1.130 wiz 8069: message function as a summary that can be read without the rest, such as is
8070: commonly done with "git log --oneline". For this reason, we have the following
8071: guidelines for pkgsrc commit messages:
8072:
1.131 wiz 8073: * Start the commit message with a line that explains the big picture in 65
1.130 wiz 8074: characters or less. When a commit is for one package, include the name of
8075: the package. For updates, include the version to which it is updated.
8076:
8077: * Leave the next line empty.
8078:
8079: * Then come the details for the commit (changes in that package, reason for a
8080: change) and any relevant PRs. Wrap this section.
8081:
8082: Here is an example:
8083:
1.238 wiz 8084: libxslt: update to 1.0.30
1.130 wiz 8085:
1.238 wiz 8086: Changes since 1.0.29:
8087: ...
1.130 wiz 8088:
8089: Here is another example:
8090:
1.238 wiz 8091: mk/bsd.pkg.mk: enable SSP by default on NetBSD
1.130 wiz 8092:
1.238 wiz 8093: (rationale)
1.130 wiz 8094:
1.266 martin 8095: Commit messages are final: no cvs admin is allowed on the pkgsrc repository
1.130 wiz 8096: to change commit messages.
8097:
1.266 martin 8098: 23.5. Committing: Adding a package to CVS
1.1 dsieger 8099:
8100: This section is only of interest for pkgsrc developers with write access to the
1.34 wiz 8101: pkgsrc repository.
8102:
1.266 martin 8103: When the package is finished, cvs add the files. Start by adding the
1.34 wiz 8104: directory and then files in the directory. Don't forget to add the new package
8105: to the category's Makefile. Make sure you don't forget any files; you can check
1.266 martin 8106: by running cvs status . An example:
1.34 wiz 8107:
8108: $ cd .../pkgsrc/category
8109: $ cvs add pkgname
8110: $ cd pkgname
8111: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
8112: $ cvs add patches/p*
8113: $ cvs status | less
1.35 wiz 8114: $ cvs commit
1.34 wiz 8115: $ cd ..
1.236 gutterid 8116: $ vi Makefile # add SUBDIR+=pkgname line
1.35 wiz 8117: $ cvs commit Makefile
1.66 asau 8118: $ cd pkgname
1.73 jnemeth 8119: $ make CTYPE=Added commit-changes-entry
1.1 dsieger 8120:
8121: The commit message of the initial import should include part of the DESCR file,
8122: so people reading the mailing lists know what the package is/does.
8123:
1.34 wiz 8124: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
8125:
1.266 martin 8126: Previously, cvs import was suggested, but it was much easier to get wrong
8127: than cvs add .
1.1 dsieger 8128:
1.266 martin 8129: 23.6. Updating a package to a newer version
1.1 dsieger 8130:
8131: Please always put a concise, appropriate and relevant summary of the changes
8132: between old and new versions into the commit log when updating a package. There
8133: are various reasons for this:
8134:
8135: * A URL is volatile, and can change over time. It may go away completely or
8136: its information may be overwritten by newer information.
8137:
8138: * Having the change information between old and new versions in our CVS
8139: repository is very useful for people who use either cvs or anoncvs.
8140:
8141: * Having the change information between old and new versions in our CVS
8142: repository is very useful for people who read the pkgsrc-changes mailing
8143: list, so that they can make tactical decisions about when to upgrade the
8144: package.
8145:
8146: Please also recognize that, just because a new version of a package has been
8147: released, it should not automatically be upgraded in the CVS repository. We
8148: prefer to be conservative in the packages that are included in pkgsrc -
8149: development or beta packages are not really the best thing for most places in
8150: which pkgsrc is used. Please use your judgement about what should go into
8151: pkgsrc, and bear in mind that stability is to be preferred above new and
8152: possibly untested features.
8153:
1.266 martin 8154: 23.7. Renaming a package in pkgsrc
1.21 snj 8155:
8156: Renaming packages is not recommended.
8157:
1.175 gutterid 8158: When renaming packages, be sure to fix any references to the old name in other
1.21 snj 8159: Makefiles, options, buildlink files, etc.
8160:
1.175 gutterid 8161: Also, when renaming a package, please add the package name and version pattern
1.167 leot 8162: (s) of the previous package to SUPERSEDES. This may be repeated for multiple
8163: renames. The new package would be an exact replacement. Example:
8164:
8165: SUPERSEDES+= p5-IO-Compress-Zlib<2.017
8166: SUPERSEDES+= optcomp-[0-9]*
1.21 snj 8167:
1.266 martin 8168: Note that successor in the CHANGES-YYYY file doesn't necessarily mean that it
1.21 snj 8169: supersedes, as that successor may not be an exact replacement but is a
8170: suggestion for the replaced functionality.
8171:
1.266 martin 8172: 23.8. Moving a package in pkgsrc
1.21 snj 8173:
8174: It is preferred that packages are not renamed or moved, but if needed please
8175: follow these steps.
1.1 dsieger 8176:
8177: 1. Make a copy of the directory somewhere else.
8178:
8179: 2. Remove all CVS dirs.
8180:
8181: Alternatively to the first two steps you can also do:
8182:
8183: % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
8184:
8185: and use that for further work.
8186:
1.266 martin 8187: 3. Fix CATEGORIES and any DEPENDS paths that just did ../package instead of
8188: ../../category/package .
1.1 dsieger 8189:
1.21 snj 8190: 4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
8191: previous category/package pathname. The PREV_PKGPATH can be used by tools
8192: for doing an update using pkgsrc building; for example, it can search the
8193: pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
8194: the corresponding new PKGPATH for that moved package. Note that it may have
8195: multiple matches, so the tool should also check on the PKGBASE too. The
8196: PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
8197: PKGBASE stays the same.
8198:
1.237 gutterid 8199: 5. cvs add the modified package in the new place.
1.1 dsieger 8200:
1.21 snj 8201: 6. Check if any package depends on it:
1.1 dsieger 8202:
8203: % cd /usr/pkgsrc
8204: % grep /package */*/Makefile* */*/buildlink*
8205:
1.21 snj 8206: 7. Fix paths in packages from step 5 to point to new location.
1.1 dsieger 8207:
1.21 snj 8208: 8. cvs rm (-f) the package at the old location.
1.1 dsieger 8209:
1.21 snj 8210: 9. Remove from oldcategory/Makefile.
1.1 dsieger 8211:
1.21 snj 8212: 10. Add to newcategory/Makefile.
1.1 dsieger 8213:
1.21 snj 8214: 11. Commit the changed and removed files:
1.1 dsieger 8215:
8216: % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
8217:
8218: (and any packages from step 5, of course).
8219:
1.266 martin 8220: Chapter 24. pkgsrc Policies
1.263 wiz 8221:
8222: Table of Contents
8223:
8224: 24.1. Packages for which updating is restricted
8225: 24.1.1. Limited Updates - ABI
8226: 24.1.2. Limited Updates - Bootstrap
8227:
1.266 martin 8228: 24.1. Packages for which updating is restricted
1.263 wiz 8229:
8230: In the past, some packages have caused more package failures than others, and
8231: we'd like to reduce this in the future.
8232:
8233: For this reason, pkgsrc-pmc marks some packages with POLICY_UPDATE_LIMITED. The
8234: possible values currently are:
8235:
8236: * abi for packages where ABI/API changes often broke the packages depending
8237: on them
8238:
8239: * bootstrap for packages that are used during the pkgsrc bootstrap
8240:
8241: pkglint will warn when committing updates to these packages.
8242:
1.266 martin 8243: 24.1.1. Limited Updates - ABI
1.263 wiz 8244:
8245: Before committing non-micro version updates to packages marked with
8246: POLICY_UPDATE_LIMITED=abi, a limited bulk build of meta-pkgs/bulk-test-$
8247: {PACKAGE} needs to be run and the result posted to the tech-pkg mailing list,
8248: highlighting what packages would stop building (if any).
8249:
8250: Depending on the result, pkgsrc-pmc then decides:
8251:
8252: * go ahead with the update
8253:
8254: * wait for packages X, Y, Z to be fixed (upstream or locally) with the
8255: updated version, which is put in wip in the meantime
8256:
8257: * In the second case, all pkgsrc developers are encouraged to work on fixing
8258: this - it is not only the updater's task to fix them.
8259:
8260: The decision to wait for packages can be revisited.
8261:
1.266 martin 8262: 24.1.2. Limited Updates - Bootstrap
1.263 wiz 8263:
8264: When updating packages used in the bootstrap, i.e. marked with
8265: POLICY_UPDATE_LIMITED=bootstrap, test the bootstrap process and preferably some
8266: basic packages and send the patch to the tech-pkg mailing list so it can be
8267: tested on other platforms as well. Give at least two weeks for feedback and
8268: testing by others.
8269:
1.266 martin 8270: Chapter 25. Frequently Asked Questions
1.1 dsieger 8271:
8272: This section contains the answers to questions that may arise when you are
8273: writing a package. If you don't find your question answered here, first have a
8274: look in the other chapters, and if you still don't have the answer, ask on the
8275: pkgsrc-users mailing list.
8276:
1.263 wiz 8277: 25.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
8278: 25.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
8279: 25.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
8280: 25.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
8281: 25.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.271 wiz 8282: the := inside it.
1.263 wiz 8283: 25.6. Which mailing lists are there for package developers?
8284: 25.7. Where is the pkgsrc documentation?
8285: 25.8. I have a little time to kill. What shall I do?
1.1 dsieger 8286:
1.263 wiz 8287: 25.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1 dsieger 8288:
8289: MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
1.223 nia 8290: (1).
8291:
8292: MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM when
8293: building the package.
8294:
8295: .MAKEFLAGS is an internal variable of bmake and should not be used by
8296: packages.
1.1 dsieger 8297:
1.263 wiz 8298: 25.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1 dsieger 8299:
8300: MAKE is the path to the make(1) program that is used in the pkgsrc
1.223 nia 8301: infrastructure.
8302:
8303: GMAKE is the path to GNU Make, but you need to say USE_TOOLS+=gmake to
8304: use that.
8305:
8306: MAKE_PROGRAM is the path to the Make program that is used for building
8307: the package.
1.1 dsieger 8308:
1.263 wiz 8309: 25.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1 dsieger 8310:
8311: CC is the path to the real C compiler, which can be configured by the
1.223 nia 8312: pkgsrc user.
1.1 dsieger 8313:
1.223 nia 8314: PKG_CC is the path to the compiler wrapper.
1.1 dsieger 8315:
1.223 nia 8316: PKGSRC_COMPILER is not a path to a compiler, but the type of compiler
8317: that should be used. See mk/compiler.mk for more information about the
8318: latter variable.
1.1 dsieger 8319:
1.263 wiz 8320: 25.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1 dsieger 8321:
1.266 martin 8322: For optimization reasons, some variables are only available in the
8323: wrapper phase and later. To simulate the wrapper phase, append
1.1 dsieger 8324: PKG_PHASE=wrapper to the above command.
8325:
1.263 wiz 8326: 25.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1 dsieger 8327: the := inside it.
8328:
1.223 nia 8329: The := is not an assignment operator, even though it may look like one.
1.108 rillig 8330: Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
8331: is documented in the make(1) man page and which is commonly used in the
8332: form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
8333: string and new_string is package/. That's where the : and the = fall
8334: together.
1.1 dsieger 8335:
1.263 wiz 8336: 25.6. Which mailing lists are there for package developers?
1.1 dsieger 8337:
8338: tech-pkg
8339:
8340: This is a list for technical discussions related to pkgsrc
8341: development, e.g. soliciting feedback for changes to pkgsrc
8342: infrastructure, proposed new features, questions related to porting
8343: pkgsrc to a new platform, advice for maintaining a package, patches
8344: that affect many packages, help requests moved from pkgsrc-users when
8345: an infrastructure bug is found, etc.
8346:
8347: pkgsrc-bugs
8348:
8349: All bug reports in category "pkg" sent with send-pr(1) appear here.
8350: Please do not report your bugs here directly; use one of the other
8351: mailing lists.
1.271 wiz 8352:
1.263 wiz 8353: 25.7. Where is the pkgsrc documentation?
1.1 dsieger 8354:
8355: There are many places where you can find documentation about pkgsrc:
8356:
8357: * The pkgsrc guide (this document) is a collection of chapters that
8358: explain large parts of pkgsrc, but some chapters tend to be outdated.
8359: Which ones they are is hard to say.
8360:
1.174 leot 8361: * On the mailing list archives (see https://mail-index.NetBSD.org/),
8362: you can find discussions about certain features, announcements of new
1.1 dsieger 8363: parts of the pkgsrc infrastructure and sometimes even announcements
8364: that a certain feature has been marked as obsolete. The benefit here
8365: is that each message has a date appended to it.
8366:
8367: * Many of the files in the mk/ directory start with a comment that
8368: describes the purpose of the file and how it can be used by the
8369: pkgsrc user and package authors. An easy way to find this
8370: documentation is to run bmake help.
8371:
8372: * The CVS log messages are a rich source of information, but they tend
8373: to be highly abbreviated, especially for actions that occur often.
8374: Some contain a detailed description of what has changed, but they are
8375: geared towards the other pkgsrc developers, not towards an average
8376: pkgsrc user. They also only document changes, so if you don't know
8377: what has been before, these messages may not be worth too much to
8378: you.
8379:
1.266 martin 8380: * Some parts of pkgsrc are only implicitly documented , that is the
1.1 dsieger 8381: documentation exists only in the mind of the developer who wrote the
8382: code. To get this information, use the cvs annotate command to see
8383: who has written it and ask on the tech-pkg mailing list, so that
8384: others can find your questions later (see above). To be sure that the
8385: developer in charge reads the mail, you may CC him or her.
8386:
1.263 wiz 8387: 25.8. I have a little time to kill. What shall I do?
1.1 dsieger 8388:
8389: This is not really an FAQ yet, but here's the answer anyway.
8390:
8391: * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
8392: about newer versions of installed packages that are available, but
8393: not yet updated in pkgsrc.
8394:
1.266 martin 8395: * Browse pkgsrc/doc/TODO it contains a list of suggested new packages
8396: and a list of cleanups and enhancements for pkgsrc that would be nice
8397: to have.
1.1 dsieger 8398:
1.71 wiz 8399: * Review packages for which review was requested on the tech-pkg
8400: mailing list.
1.1 dsieger 8401:
1.266 martin 8402: Part III. The pkgsrc infrastructure internals
1.1 dsieger 8403:
8404: This part of the guide deals with everything from the infrastructure that is
8405: behind the interfaces described in the developer's guide. A casual package
8406: maintainer should not need anything from this part.
8407:
8408: Table of Contents
8409:
1.263 wiz 8410: 26. Design of the pkgsrc infrastructure
8411: 26.1. The meaning of variable definitions
8412: 26.2. Avoiding problems before they arise
8413: 26.3. Variable evaluation
8414: 26.3.1. At load time
8415: 26.3.2. At runtime
8416: 26.4. How can variables be specified?
8417: 26.5. Designing interfaces for Makefile fragments
8418: 26.5.1. Procedures with parameters
8419: 26.5.2. Actions taken on behalf of parameters
8420: 26.6. The order in which files are loaded
8421: 26.6.1. The order in bsd.prefs.mk
8422: 26.6.2. The order in bsd.pkg.mk
8423: 27. Regression tests
8424: 27.1. Running the regression tests
8425: 27.2. Adding a new regression test
8426: 27.2.1. Overridable functions
8427: 27.2.2. Helper functions
8428: 28. Porting pkgsrc
8429: 28.1. Porting pkgsrc to a new operating system
1.1 dsieger 8430:
1.266 martin 8431: Chapter 26. Design of the pkgsrc infrastructure
1.1 dsieger 8432:
8433: Table of Contents
8434:
1.263 wiz 8435: 26.1. The meaning of variable definitions
8436: 26.2. Avoiding problems before they arise
8437: 26.3. Variable evaluation
8438: 26.3.1. At load time
8439: 26.3.2. At runtime
8440: 26.4. How can variables be specified?
8441: 26.5. Designing interfaces for Makefile fragments
8442: 26.5.1. Procedures with parameters
8443: 26.5.2. Actions taken on behalf of parameters
8444: 26.6. The order in which files are loaded
8445: 26.6.1. The order in bsd.prefs.mk
8446: 26.6.2. The order in bsd.pkg.mk
1.1 dsieger 8447:
8448: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
8449: fragment needs a properly specified interface. This chapter explains how such
8450: an interface looks like.
8451:
1.266 martin 8452: 26.1. The meaning of variable definitions
1.1 dsieger 8453:
8454: Whenever a variable is defined in the pkgsrc infrastructure, the location and
8455: the way of definition provide much information about the intended use of that
8456: variable. Additionally, more documentation may be found in a header comment or
8457: in this pkgsrc guide.
8458:
8459: A special file is mk/defaults/mk.conf, which lists all variables that are
8460: intended to be user-defined. They are either defined using the ?= operator or
8461: they are left undefined because defining them to anything would effectively
1.266 martin 8462: mean yes . All these variables may be overridden by the pkgsrc user in the
1.1 dsieger 8463: MAKECONF file.
8464:
8465: Outside this file, the following conventions apply: Variables that are defined
8466: using the ?= operator may be overridden by a package.
8467:
8468: Variables that are defined using the = operator may be used read-only at
8469: run-time.
8470:
8471: Variables whose name starts with an underscore must not be accessed outside the
8472: pkgsrc infrastructure at all. They may change without further notice.
8473:
8474: Note
8475:
8476: These conventions are currently not applied consistently to the complete pkgsrc
8477: infrastructure.
8478:
1.266 martin 8479: 26.2. Avoiding problems before they arise
1.1 dsieger 8480:
8481: All variables that contain lists of things should default to being empty. Two
8482: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
8483: variables cannot simply be modified using the += operator in package Makefiles
8484: (or other files included by them), since there is no guarantee whether the
8485: variable is already set or not, and what its value is. In the case of
1.266 martin 8486: DISTFILES, the packages know the default value and just define it as in the
1.1 dsieger 8487: following example.
8488:
8489: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
8490:
8491: Because of the selection of this default value, the same value appears in many
8492: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
1.266 martin 8493: value ( c ) is so short that it doesn't stand out. Nevertheless it is mentioned
1.1 dsieger 8494: in many files.
8495:
1.266 martin 8496: 26.3. Variable evaluation
1.1 dsieger 8497:
1.266 martin 8498: 26.3.1. At load time
1.1 dsieger 8499:
8500: Variable evaluation takes place either at load time or at runtime, depending on
8501: the context in which they occur. The contexts where variables are evaluated at
8502: load time are:
8503:
8504: * The right hand side of the := and != operators,
8505:
8506: * Make directives like .if or .for,
8507:
8508: * Dependency lines.
8509:
8510: A special exception are references to the iteration variables of .for loops,
8511: which are expanded inline, no matter in which context they appear.
8512:
8513: As the values of variables may change during load time, care must be taken not
8514: to evaluate them by accident. Typical examples for variables that should not be
8515: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
8516: clear, here is an example:
8517:
8518: CONFIGURE_ARGS= # none
8519: CFLAGS= -O
8520: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
8521:
8522: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
8523:
8524: CFLAGS+= -Wall
8525:
8526: This code shows how the use of the := operator can quickly lead to unexpected
8527: results. The first paragraph is fairly common code. The second paragraph
8528: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
8529: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
8530: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
8531: typically occur in completely unrelated files.
8532:
1.266 martin 8533: 26.3.2. At runtime
1.1 dsieger 8534:
8535: After all the files have been loaded, the values of the variables cannot be
8536: changed anymore. Variables that are used in the shell commands are expanded at
8537: this point.
8538:
1.266 martin 8539: 26.4. How can variables be specified?
1.1 dsieger 8540:
8541: There are many ways in which the definition and use of a variable can be
8542: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108 rillig 8543: policies. A package can be checked with pkglint -Wall to see whether it meets
8544: these rules.
1.1 dsieger 8545:
1.266 martin 8546: 26.5. Designing interfaces for Makefile fragments
1.1 dsieger 8547:
8548: Most of the .mk files fall into one of the following classes. Cases where a
8549: file falls into more than one class should be avoided as it often leads to
8550: subtle bugs.
8551:
1.266 martin 8552: 26.5.1. Procedures with parameters
1.1 dsieger 8553:
8554: In a traditional imperative programming language some of the .mk files could be
1.266 martin 8555: described as procedures. They take some input parameters and after
8556: inclusion provide a result in output parameters. Since all variables in
1.23 jakllsch 8557: Makefiles have global scope care must be taken not to use parameter names that
8558: have already another meaning. For example, PKGNAME is a bad choice for a
8559: parameter name.
1.1 dsieger 8560:
8561: Procedures are completely evaluated at preprocessing time. That is, when
8562: calling a procedure all input parameters must be completely resolvable. For
8563: example, CONFIGURE_ARGS should never be an input parameter since it is very
8564: likely that further text will be added after calling the procedure, which would
8565: effectively apply the procedure to only a part of the variable. Also,
1.108 rillig 8566: references to other variables will be modified after calling the procedure.
1.1 dsieger 8567:
8568: A procedure can declare its output parameters either as suitable for use in
8569: preprocessing directives or as only available at runtime. The latter
8570: alternative is for variables that contain references to other runtime
8571: variables.
8572:
8573: Procedures shall be written such that it is possible to call the procedure more
8574: than once. That is, the file must not contain multiple-inclusion guards.
8575:
8576: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
8577: To express that the parameters are evaluated at load time, they should be
8578: assigned using the := operator, which should be used only for this purpose.
8579:
1.266 martin 8580: 26.5.2. Actions taken on behalf of parameters
1.1 dsieger 8581:
8582: Action files take some input parameters and may define runtime variables. They
8583: shall not define loadtime variables. There are action files that are included
8584: implicitly by the pkgsrc infrastructure, while other must be included
8585: explicitly.
8586:
8587: An example for action files is mk/subst.mk.
8588:
1.266 martin 8589: 26.6. The order in which files are loaded
1.1 dsieger 8590:
8591: Package Makefiles usually consist of a set of variable definitions, and include
8592: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
8593: include various other *.mk files if they need to query the availability of
8594: certain features like the type of compiler or the X11 implementation. Due to
8595: the heavy use of preprocessor directives like .if and .for, the order in which
8596: the files are loaded matters.
8597:
8598: This section describes at which point the various files are loaded and gives
8599: reasons for that order.
8600:
1.266 martin 8601: 26.6.1. The order in bsd.prefs.mk
1.1 dsieger 8602:
8603: The very first action in bsd.prefs.mk is to define some essential variables
8604: like OPSYS, OS_VERSION and MACHINE_ARCH.
8605:
1.4 rillig 8606: Then, the user settings are loaded from the file specified in MAKECONF, which
8607: is usually mk.conf. After that, those variables that have not been overridden
8608: by the user are loaded from mk/defaults/mk.conf.
1.1 dsieger 8609:
8610: After the user settings, the system settings and platform settings are loaded,
8611: which may override the user settings.
8612:
8613: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
8614: This only happens when building a package, so the proper variables must be used
8615: instead of the direct tool names.
8616:
8617: As the last steps, some essential variables from the wrapper and the package
8618: system flavor are loaded, as well as the variables that have been cached in
8619: earlier phases of a package build.
8620:
1.266 martin 8621: 26.6.2. The order in bsd.pkg.mk
1.1 dsieger 8622:
8623: First, bsd.prefs.mk is loaded.
8624:
8625: Then, the various *-vars.mk files are loaded, which fill default values for
8626: those variables that have not been defined by the package. These variables may
8627: later be used even in unrelated files.
8628:
8629: Then, the file bsd.pkg.error.mk provides the target error-check that is added
8630: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
8631: DELAYED_WARNING_MSG.
8632:
8633: Then, the package-specific hacks from hacks.mk are included.
8634:
8635: Then, various other files follow. Most of them don't have any dependencies on
8636: what they need to have included before or after them, though some do.
8637:
8638: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
8639: restricts the use of these variables to all the files that have been included
8640: before. Appearances in later files will be silently ignored.
8641:
8642: Then, the files for the main targets are included, in the order of later
8643: execution, though the actual order should not matter.
8644:
8645: At last, some more files are included that don't set any interesting variables
8646: but rather just define make targets to be executed.
8647:
1.266 martin 8648: Chapter 27. Regression tests
1.1 dsieger 8649:
8650: Table of Contents
8651:
1.263 wiz 8652: 27.1. Running the regression tests
8653: 27.2. Adding a new regression test
8654: 27.2.1. Overridable functions
8655: 27.2.2. Helper functions
1.1 dsieger 8656:
8657: The pkgsrc infrastructure consists of a large codebase, and there are many
8658: corners where every little bit of a file is well thought out, making pkgsrc
8659: likely to fail as soon as anything is changed near those parts. To prevent most
8660: changes from breaking anything, a suite of regression tests should go along
8661: with every important part of the pkgsrc infrastructure. This chapter describes
8662: how regression tests work in pkgsrc and how you can add new tests.
8663:
1.266 martin 8664: 27.1. Running the regression tests
1.1 dsieger 8665:
1.25 wiz 8666: You first need to install the pkgtools/pkg_regress package, which provides the
1.1 dsieger 8667: pkg_regress command. Then you can simply run that command, which will run all
1.168 rillig 8668: tests in the regress/ directory.
1.1 dsieger 8669:
1.266 martin 8670: 27.2. Adding a new regression test
1.1 dsieger 8671:
1.168 rillig 8672: Every directory in the regress/ directory that contains a file called spec is
1.1 dsieger 8673: considered a regression test. This file is a shell program that is included by
8674: the pkg_regress command. The following functions can be overridden to suit your
8675: needs.
8676:
1.266 martin 8677: 27.2.1. Overridable functions
1.1 dsieger 8678:
1.266 martin 8679: These functions do not take any parameters. Although they are called in set -e
8680: mode, they don't stop at the first failing command. See this Stack Overflow
1.108 rillig 8681: question for details.
1.1 dsieger 8682:
1.108 rillig 8683: do_setup
1.1 dsieger 8684:
8685: This function prepares the environment for the test. By default it does
8686: nothing.
8687:
1.108 rillig 8688: do_test
1.1 dsieger 8689:
8690: This function runs the actual test. By default, it calls TEST_MAKE with the
8691: arguments MAKEARGS_TEST and writes its output including error messages into
8692: the file TEST_OUTFILE.
8693:
1.108 rillig 8694: When defining this function, make sure that all output that needs to be
8695: checked is written to the correct output file. Example:
8696:
8697: do_test() {
8698: echo "Example output"
8699: } 1>$TEST_OUTFILE 2>&1
8700:
8701: check_result
1.1 dsieger 8702:
8703: This function is run after the test and is typically used to compare the
8704: actual output from the one that is expected. It can make use of the various
1.108 rillig 8705: helper functions from the next section. Example:
8706:
8707: check_result() {
8708: exit_status 0
8709: output_require "Example"
8710: output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
8711: output_prohibit "no such file or directory"
1.169 rillig 8712: regress_fail "expected $expected but got $actual for input $input"
1.108 rillig 8713: }
1.1 dsieger 8714:
1.108 rillig 8715: do_cleanup
1.1 dsieger 8716:
8717: This function cleans everything up after the test has been run. By default
8718: it does nothing.
8719:
1.266 martin 8720: 27.2.2. Helper functions
1.1 dsieger 8721:
1.168 rillig 8722: regress_fail message...
8723:
8724: This function makes the test fail with the given error message.
8725:
1.108 rillig 8726: exit_status expected
1.1 dsieger 8727:
1.108 rillig 8728: This function compares the exitcode of the do_test function with its first
8729: parameter. If they differ, the test will fail.
1.1 dsieger 8730:
1.108 rillig 8731: output_require regex...
1.1 dsieger 8732:
8733: This function checks for each of its parameters if the output from do_test
1.108 rillig 8734: matches the extended regular expression. If it does not, the test will
8735: fail. Example:
8736:
8737: output_require "looks fine"
8738: output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1 dsieger 8739:
1.177 leot 8740: output_prohibit regex...
1.1 dsieger 8741:
8742: This function checks for each of its parameters if the output from do_test
8743: () does not match the extended regular expression. If any of the regular
8744: expressions matches, the test will fail.
8745:
1.266 martin 8746: Chapter 28. Porting pkgsrc
1.1 dsieger 8747:
8748: Table of Contents
8749:
1.263 wiz 8750: 28.1. Porting pkgsrc to a new operating system
1.1 dsieger 8751:
8752: The pkgsrc system has already been ported to many operating systems, hardware
8753: architectures and compilers. This chapter explains the necessary steps to make
8754: pkgsrc even more portable.
8755:
1.266 martin 8756: 28.1. Porting pkgsrc to a new operating system
1.1 dsieger 8757:
8758: To port pkgsrc to a new operating system (called MyOS in this example), you
8759: need to touch the following files:
8760:
8761: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
8762:
8763: This file contains some basic definitions, for example the name of the C
8764: compiler.
8765:
8766: mk/bsd.prefs.mk
8767:
1.212 wiz 8768: Insert code that defines the variables OPSYS, OS_VERSION, OPSYS_VERSION,
1.1 dsieger 8769: LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
8770: that appear in this file.
8771:
8772: mk/platform/MyOS.mk
8773:
8774: This file contains the platform-specific definitions that are used by
8775: pkgsrc. Start by copying one of the other files and edit it to your needs.
8776:
8777: mk/tools/tools.MyOS.mk
8778:
8779: This file defines the paths to all the tools that are needed by one or the
8780: other package in pkgsrc, as well as by pkgsrc itself. Find out where these
8781: tools are on your platform and add them.
8782:
8783: Now, you should be able to build some basic packages, like lang/perl5, shells/
8784: bash.
8785:
1.266 martin 8786: Appendix A. A simple example package: bison
1.1 dsieger 8787:
8788: Table of Contents
8789:
8790: A.1. files
8791: A.1.1. Makefile
8792: A.1.2. DESCR
8793: A.1.3. PLIST
8794: A.1.4. Checking a package with pkglint
8795: A.2. Steps for building, installing, packaging
8796:
8797: We checked to find a piece of software that wasn't in the packages collection,
1.25 wiz 8798: and picked GNU bison. Quite why someone would want to have bison when Berkeley
1.1 dsieger 8799: yacc is already present in the tree is beyond us, but it's useful for the
8800: purposes of this exercise.
8801:
1.266 martin 8802: A.1. files
1.1 dsieger 8803:
1.266 martin 8804: A.1.1. Makefile
1.1 dsieger 8805:
1.2 rillig 8806: # $NetBSD$
1.1 dsieger 8807: #
8808:
8809: DISTNAME= bison-1.25
8810: CATEGORIES= devel
1.171 rillig 8811: MASTER_SITES= ${MASTER_SITE_GNU:=bison/}
1.1 dsieger 8812:
1.30 dholland 8813: MAINTAINER= pkgsrc-users@NetBSD.org
1.174 leot 8814: HOMEPAGE= https://www.gnu.org/software/bison/bison.html
1.1 dsieger 8815: COMMENT= GNU yacc clone
8816:
8817: GNU_CONFIGURE= yes
1.47 wiz 8818: INFO_FILES= yes
1.1 dsieger 8819:
8820: .include "../../mk/bsd.pkg.mk"
8821:
1.266 martin 8822: A.1.2. DESCR
1.1 dsieger 8823:
8824: GNU version of yacc. Can make re-entrant parsers, and numerous other
8825: improvements. Why you would want this when Berkeley yacc(1) is part
8826: of the NetBSD source tree is beyond me.
8827:
1.266 martin 8828: A.1.3. PLIST
1.1 dsieger 8829:
1.2 rillig 8830: @comment $NetBSD$
1.1 dsieger 8831: bin/bison
8832: man/man1/bison.1.gz
8833: share/bison.simple
8834: share/bison.hairy
8835:
1.266 martin 8836: A.1.4. Checking a package with pkglint
1.1 dsieger 8837:
8838: The NetBSD package system comes with pkgtools/pkglint which helps to check the
8839: contents of these files. After installation it is quite easy to use, just
1.171 rillig 8840: change to the directory of the package you wish to examine and run pkglint:
1.1 dsieger 8841:
8842: $ pkglint
1.171 rillig 8843: ERROR: Makefile: Each package must define its LICENSE.
8844: WARN: Makefile:9: HOMEPAGE should migrate from http to https.
8845: NOTE: PLIST:3: The .gz extension is unnecessary for manual pages.
8846: WARN: PLIST:5: "share/bison.hairy" should be sorted before "share/bison.simple".
8847: 1 error, 2 warnings and 1 note found.
8848: (Run "pkglint -e" to show explanations.)
8849: (Run "pkglint -fs" to show what can be fixed automatically.)
1.172 rillig 8850: (Run "pkglint -F" to automatically fix some issues.)
1.1 dsieger 8851:
8852: Depending on the supplied command line arguments (see pkglint(1)), more checks
1.170 rillig 8853: will be performed. Use e.g. pkglint -Wall for a very thorough check.
1.1 dsieger 8854:
1.266 martin 8855: A.2. Steps for building, installing, packaging
1.1 dsieger 8856:
8857: Create the directory where the package lives, plus any auxiliary directories:
8858:
8859: # cd /usr/pkgsrc/lang
8860: # mkdir bison
8861: # cd bison
8862: # mkdir patches
8863:
1.266 martin 8864: Create Makefile, DESCR and PLIST (see Chapter 12, Package components - files,
1.1 dsieger 8865: directories and contents) then continue with fetching the distfile:
8866:
8867: # make fetch
8868: >> bison-1.25.tar.gz doesn't seem to exist on this system.
8869: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
8870: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8871: ftp: Error retrieving file: 500 Internal error
8872:
8873: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
8874: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8875: ftp: Error retrieving file: 500 Internal error
8876:
8877: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
8878: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8879: Successfully retrieved file.
8880:
8881: Generate the checksum of the distfile into distinfo:
8882:
8883: # make makedistinfo
8884:
8885: Now compile:
8886:
8887: # make
8888: >> Checksum OK for bison-1.25.tar.gz.
8889: ===> Extracting for bison-1.25
8890: ===> Patching for bison-1.25
8891: ===> Ignoring empty patch directory
8892: ===> Configuring for bison-1.25
8893: creating cache ./config.cache
8894: checking for gcc... cc
8895: checking whether we are using GNU C... yes
8896: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
8897: checking how to run the C preprocessor... cc -E
8898: checking for minix/config.h... no
8899: checking for POSIXized ISC... no
8900: checking whether cross-compiling... no
8901: checking for ANSI C header files... yes
8902: checking for string.h... yes
8903: checking for stdlib.h... yes
8904: checking for memory.h... yes
8905: checking for working const... yes
8906: checking for working alloca.h... no
8907: checking for alloca... yes
8908: checking for strerror... yes
8909: updating cache ./config.cache
8910: creating ./config.status
8911: creating Makefile
8912: ===> Building for bison-1.25
8913: 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
8914: 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
8915: 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
8916: 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
8917: 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
8918: 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
8919: 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
8920: 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
8921: 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
8922: 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
8923: 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
8924: 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
8925: 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
8926: 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
8927: 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
8928: 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
8929: 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
8930: 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
8931: 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
8932: 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
8933: 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
8934: 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
8935: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
8936: rm -f bison.s1
8937: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
8938:
8939: Everything seems OK, so install the files:
8940:
8941: # make install
8942: >> Checksum OK for bison-1.25.tar.gz.
8943: ===> Installing for bison-1.25
8944: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
8945: rm -f /usr/pkg/bin/bison
8946: cd /usr/pkg/share; rm -f bison.simple bison.hairy
8947: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
8948: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
8949: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
8950: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
8951: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
8952: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
8953: ===> Registering installation for bison-1.25
8954:
8955: You can now use bison, and also - if you decide so - remove it with pkg_delete
8956: bison. Should you decide that you want a binary package, do this now:
8957:
8958: # make package
8959: >> Checksum OK for bison-1.25.tar.gz.
8960: ===> Building package for bison-1.25
8961: Creating package bison-1.25.tgz
8962: Registering depends:.
8963: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
8964:
8965: Now that you don't need the source and object files any more, clean up:
8966:
8967: # make clean
8968: ===> Cleaning for bison-1.25
8969:
1.266 martin 8970: Appendix B. Security hardening
1.207 leot 8971:
8972: Table of Contents
8973:
8974: B.1. Mechanisms
8975: B.1.1. Enabled by default
8976: B.1.2. Not enabled by default
8977: B.2. Caveats
8978: B.2.1. Problems with PKGSRC_MKPIE
8979: B.2.2. Problems with PKGSRC_USE_FORTIFY
8980: B.2.3. Problems with PKGSRC_USE_RELRO
8981: B.2.4. Problems with PKGSRC_USE_SSP
8982: B.3. Auditing the system
8983: B.3.1. Checking for PIE
8984: B.3.2. Checking for partial RELRO
8985: B.3.3. Checking for full RELRO
8986: B.3.4. Checking for SSP
8987:
8988: A number of mechanisms are available in pkgsrc to improve the security of the
8989: resulting system. This page describes the mechanisms, and gives hints about
8990: detecting and fixing problems.
8991:
8992: Mechanisms can be enabled individually in mk.conf, and are individually
8993: described below.
8994:
8995: Typically, a feature will cause some programs to fail to build or work when
8996: first enabled. This can be due to latent problems in the program, and can be
8997: due to other reasons. After enough testing to have confidence that user
8998: problems will be quite rare, individual mechanisms will be enabled by default.
8999:
9000: For each mechanism, see the Caveats section below for an explanation of what
9001: might go wrong at compile time and at run time, and how to notice and address
9002: these problems.
9003:
1.266 martin 9004: B.1. Mechanisms
1.207 leot 9005:
1.266 martin 9006: B.1.1. Enabled by default
1.207 leot 9007:
1.266 martin 9008: B.1.1.1. PKGSRC_USE_FORTIFY
1.207 leot 9009:
9010: This allows substitute wrappers to be used for some commonly used library
9011: functions that do not have built-in bounds checking - but could in some cases.
9012:
9013: Two mitigation levels are available:
9014:
9015: * "weak" only enables checks at compile-time.
9016:
9017: * "strong" enables checks at compile-time and runtime.
9018:
9019: "strong" has been enabled by default since pkgsrc-2017Q3.
9020:
1.266 martin 9021: B.1.1.2. PKGSRC_USE_SSP
1.207 leot 9022:
9023: This enables a stack-smashing protection mitigation. It is done by adding a
9024: guard variable to functions with vulnerable objects. The guards are initialized
9025: when a function is entered and then checked when the function exits. The guard
9026: check will fail and the program forcibly exited if the variable was modified in
9027: the meantime. This can happen in case of buffer overflows or memory corruption,
9028: and therefore exposing these bugs.
9029:
9030: Different mitigation levels are available:
9031:
9032: * "yes", which will only protect functions considered vulnerable by the
9033: compiler;
9034:
9035: * "all", which will protect every function;
9036:
9037: * "strong", the default, which will apply a better balance between the two
9038: settings above.
9039:
9040: This mitigation is supported by both GCC and clang. It may be supported in
9041: additional compilers, possibly under a different name. It is particularly
9042: useful for unsafe programming languages, such as C/C++.
9043:
9044: * "yes" is enabled by default where known supported since pkgsrc-2017Q3.
9045:
9046: * "strong" is enabled by default where known supported since pkgsrc-2021Q4.
9047:
9048: More details can be found here:
9049:
9050: * Buffer overflow protection on Wikipedia
9051:
1.266 martin 9052: B.1.1.3. PKGSRC_MKPIE
1.207 leot 9053:
9054: This requests the creation of PIE (Position Independent Executables) for all
9055: executables. The PIE mechanism is normally used for shared libraries, so that
9056: they can be loaded at differing addresses at runtime. PIE itself does not have
9057: useful security properties; however, it is necessary to fully leverage some,
9058: such as ASLR. Some operating systems support Address Space Layout Randomization
9059: (ASLR), which causes different addresses to be used each time a program is run.
9060: This makes it more difficult for an attacker to guess addresses and thus makes
9061: exploits harder to construct. With PIE, ASLR can really be applied to the
9062: entire program, instead of the stack and heap only.
9063:
9064: PIE executables will only be built for toolchains that are known to support
9065: PIE. Currently, this means NetBSD on x86, ARM, SPARC64, m68k, and MIPS.
9066:
9067: PKGSRC_MKPIE was enabled by default after the pkgsrc-2021Q3 branch.
9068:
1.266 martin 9069: B.1.1.4. PKGSRC_USE_RELRO
1.207 leot 9070:
9071: This also makes the exploitation of some security vulnerabilities more
9072: difficult in some cases.
9073:
9074: Two different mitigation levels are available:
9075:
1.219 nia 9076: * partial (the default): the ELF sections are reordered so that internal data
9077: sections precede the program's own data sections, and non-PLT GOT is
9078: read-only;
1.207 leot 9079:
9080: * full: in addition to partial RELRO, every relocation is performed
1.218 nia 9081: immediately when starting the program, allowing the entire GOT to be
9082: read-only. This can greatly slow down startup of large programs.
1.207 leot 9083:
9084: This is currently supported by GCC. Many software distributions now enable this
1.220 nia 9085: feature by default, at the "partial" level.
1.207 leot 9086:
9087: More details can be found here:
9088:
9089: * Hardening ELF binaries using Relocation Read-Only (RELRO)
9090:
1.266 martin 9091: B.1.2. Not enabled by default
1.219 nia 9092:
1.266 martin 9093: B.1.2.1. PKGSRC_MKREPRO
1.219 nia 9094:
9095: With this option, pkgsrc will try to build packages reproducibly. This allows
9096: packages built from the same tree and with the same options, to produce
9097: identical results bit by bit. This option should be combined with ASLR and
9098: PKGSRC_MKPIE to avoid predictable address offsets for attackers attempting to
9099: exploit security vulnerabilities.
9100:
9101: More details can be found here:
9102:
9103: * Reproducible Builds - a set of software development practices that create
9104: an independently-verifiable path from source to binary code
9105:
9106: More work likely needs to be done before pkgsrc is fully reproducible.
9107:
1.266 martin 9108: B.1.2.2. PKGSRC_USE_STACK_CHECK
1.207 leot 9109:
9110: This uses -fstack-check with GCC for another stack protection mitigation.
9111:
9112: It asks the compiler to generate code verifying that it does not corrupt the
9113: stack. According to GCC's manual page, this is really only useful for
9114: multi-threaded programs.
9115:
1.266 martin 9116: B.2. Caveats
1.207 leot 9117:
1.266 martin 9118: B.2.1. Problems with PKGSRC_MKPIE
1.207 leot 9119:
1.266 martin 9120: B.2.1.1. Packages failing to build
1.207 leot 9121:
9122: A number of packages may fail to build with this option enabled. The failures
9123: are often related to the absence of the -fPIC compilation flag when building
9124: libraries or executables (or ideally -fPIE in the latter case). This flag is
9125: added to the CFLAGS already, but requires the package to actually support it.
9126:
1.266 martin 9127: B.2.1.1.1. How to fix
1.207 leot 9128:
9129: These instructions are meant as a reference only; they likely need to be
9130: adapted for many packages individually.
9131:
9132: For packages using Makefiles:
9133:
9134: MAKE_FLAGS+= CFLAGS=${CFLAGS:Q}
9135: MAKE_FLAGS+= LDFLAGS=${LDFLAGS:Q}
9136:
9137: For packages using Imakefiles:
9138:
9139: MAKE_FLAGS+= CCOPTIONS=${CFLAGS:Q}
9140: MAKE_FLAGS+= LOCAL_LDFLAGS=${LDFLAGS:Q}
9141:
1.266 martin 9142: B.2.1.2. Run-time crashes
1.207 leot 9143:
9144: Some programs may fail to run, or crash at random times once built as PIE. Two
9145: scenarios are essentially possible. This is nearly always due to a bug in the
9146: program being exposed due to ASLR.
9147:
1.266 martin 9148: B.2.1.3. Disabling PKGSRC_MKPIE on a per-package basis
1.207 leot 9149:
9150: Ideally, packages should be fixed for compatibility with MKPIE. However, in
9151: some cases this is very difficult, due to complex build systems, packages using
9152: non-standard toolchains, or programming languages with odd bootstrapping
9153: mechanisms.
9154:
9155: To disable PKGSRC_MKPIE on a per-package basis, set MKPIE_SUPPORTED= no in the
9156: package's Makefile before bsd.prefs.mk is included.
9157:
1.266 martin 9158: B.2.2. Problems with PKGSRC_USE_FORTIFY
1.207 leot 9159:
1.266 martin 9160: B.2.2.1. Packages failing to build
1.207 leot 9161:
9162: This feature makes use of pre-processing directives to look for hardened,
9163: alternative implementations of essential library calls. Some programs may fail
9164: to build as a result; this usually happens for those trying too hard to be
9165: portable, or otherwise abusing definitions in the standard library.
9166:
1.266 martin 9167: B.2.2.2. Run-time crashes
1.207 leot 9168:
9169: This feature may cause some programs to crash, usually indicating an actual bug
9170: in the program. The fix will typically involve patching the original program's
9171: source code.
9172:
1.266 martin 9173: B.2.2.3. Optimization is required
1.207 leot 9174:
9175: At least in the case of GCC, FORTIFY will only be applied if optimization is
9176: applied while compiling. This means that the CFLAGS should also contain -O, -O2
9177: or another optimization level. This cannot easily be applied globally, as some
9178: packages may require specific optimization levels.
9179:
1.266 martin 9180: B.2.2.4. Disabling FORTIFY on a per-package basis
1.207 leot 9181:
9182: Note
9183:
9184: FORTIFY should not be disabled to work around runtime crashes in the program!
9185: This is a very bad idea and will expose you to security vulnerabilities.
9186:
9187: To disable FORTIFY on a per-package basis, set the following in the package's
9188: Makefile before bsd.prefs.mk is included:
9189:
9190: FORTIFY_SUPPORTED= no
9191:
1.266 martin 9192: B.2.3. Problems with PKGSRC_USE_RELRO
1.207 leot 9193:
1.266 martin 9194: B.2.3.1. Performance impact
1.207 leot 9195:
9196: For better protection, full RELRO requires every symbol to be resolved when the
9197: program starts, rather than simply when required at run-time. This will have
9198: more impact on programs using a lot of symbols, or linked to libraries exposing
9199: a lot of symbols. Therefore, daemons or programs otherwise running in
9200: background are affected only when started. Programs loading plug-ins at
9201: run-time are affected when loading the plug-ins.
9202:
9203: The impact is not expected to be noticeable on modern hardware, except in some
9204: cases for big programs.
9205:
1.266 martin 9206: B.2.3.2. Run-time crashes
1.207 leot 9207:
9208: Some programs handle plug-ins and dependencies in a way that conflicts with
9209: RELRO: for instance, with an initialization routine listing any other plug-in
9210: required. With full RELRO, the missing symbols are resolved before the
9211: initialization routine can run, and the dynamic loader will not be able to find
9212: them directly and abort as a result. Unfortunately, this is how Xorg loads its
9213: drivers. Partial RELRO can be applied instead in this case.
9214:
1.266 martin 9215: B.2.3.3. Disabling RELRO on a per-package basis
1.207 leot 9216:
9217: To disable RELRO on a per-package basis, set the following in the package's
9218: Makefile before bsd.prefs.mk is included:
9219:
9220: RELRO_SUPPORTED= no
9221:
1.209 nia 9222: It is also possible to at most enable partial RELRO, by setting RELRO_SUPPORTED
9223: to partial.
9224:
1.266 martin 9225: B.2.4. Problems with PKGSRC_USE_SSP
1.207 leot 9226:
1.266 martin 9227: B.2.4.1. Packages failing to build
1.207 leot 9228:
9229: The stack-smashing protection provided by this option does not work for some
9230: programs. The most common situation in which this happens is when the program
9231: allocates variables on the stack, with the size determined at run-time.
9232:
1.266 martin 9233: B.2.4.2. Run-time crashes
1.207 leot 9234:
9235: Again, this feature may cause some programs to crash via a SIGABRT, usually
9236: indicating an actual bug in the program.
9237:
9238: On NetBSD LOG_CRIT level syslog messages are sent and - by default - appended
9239: to /var/log/messages, e.g.:
9240:
9241: Jan 6 15:42:51 hostname -: hostname program - - - buffer overflow detected; terminated
9242:
9243: (where hostname is the hostname(1) and program is the basename(1) of the
9244: program crashed).
9245:
9246: Patching the original program is then required.
9247:
9248: Rebuilding the package via:
9249:
9250: % env CFLAGS=-g INSTALL_UNSTRIPPED=yes make replace
9251:
9252: and inspecting the backtrace of the coredump via the debugger should point out
9253: the problematic call by inspecting the frame calling the _chk() (SSP) function.
9254:
1.266 martin 9255: B.2.4.3. Performance impact
1.207 leot 9256:
9257: The compiler emits extra code when using this feature: a check for buffer
9258: overflows is performed when entering and exiting functions, requiring an extra
9259: variable on the stack. The level of protection can otherwise be adjusted to
9260: affect only those functions considered more sensitive by the compiler (with
9261: -fstack-protector instead of -fstack-protector-all).
9262:
9263: The impact is not expected to be noticeable on modern hardware. However,
9264: programs with a hard requirement to run at the fastest possible speed should
9265: avoid using this feature, or using libraries built with this feature.
9266:
1.266 martin 9267: B.2.4.4. Disabling SSP on a per-package basis
1.207 leot 9268:
9269: Note
9270:
9271: SSP should not be disabled to work around runtime crashes in the program! This
9272: is a very bad idea and will expose you to security vulnerabilities.
9273:
9274: To disable SSP on a per-package basis, set the following in the package's
9275: Makefile before bsd.prefs.mk is included:
9276:
9277: SSP_SUPPORTED= no
9278:
1.266 martin 9279: B.3. Auditing the system
1.207 leot 9280:
9281: The illusion of security is worse than having no security at all. This section
9282: lists a number of ways to ensure the security features requested are actually
9283: effective.
9284:
9285: These instructions were obtained and tested on a system derived from NetBSD 7
9286: (amd64). YMMV.
9287:
1.266 martin 9288: B.3.1. Checking for PIE
1.207 leot 9289:
9290: The ELF executable type in use changes for binaries built as PIE; without:
9291:
9292: $ file /path/to/bin/ary
9293: /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
9294:
9295: as opposed to the following binary, built as PIE:
9296:
9297: $ file /path/to/pie/bin/ary
9298: /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
9299:
9300: The latter result is then what is expected.
9301:
1.266 martin 9302: B.3.2. Checking for partial RELRO
1.207 leot 9303:
9304: The following command should list a section called RELRO:
9305:
9306: $ objdump -p /path/to/bin/ary
9307:
9308: /path/to/bin/ary: file format elf64-x86-64
9309:
9310: Program Header:
9311: [...]
9312: RELRO off 0x0000000000000d78 vaddr 0x0000000000600d78 paddr 0x0000000000600d78 align 2**0
9313:
9314: This check is now performed automatically if PKG_DEVELOPER is set and RELRO is
9315: enabled.
9316:
1.266 martin 9317: B.3.3. Checking for full RELRO
1.207 leot 9318:
9319: The dynamic loader will apply RELRO immediately when detecting the presence of
9320: the BIND_NOW flag:
9321:
9322: $ objdump -x /path/to/bin/ary
9323:
9324: /path/to/bin/ary: file format elf64-x86-64
9325:
9326: Dynamic Section:
9327: [...]
9328: BIND_NOW 0x0000000000000000
9329:
9330: This has to be combined with partial RELRO (see above) to be fully efficient.
9331:
9332: This check is now performed automatically (where supported) if PKG_DEVELOPER is
9333: set.
9334:
1.266 martin 9335: B.3.4. Checking for SSP
1.207 leot 9336:
1.208 nia 9337: Note
9338:
9339: Checking for SSP using this method only works where the operating system uses
9340: libssp. libssp is not used on recent NetBSD/FreeBSD/Linux versions.
9341:
1.207 leot 9342: Building objects, binaries and libraries with SSP will affect the presence of
9343: additional symbols in the resulting file:
9344:
9345: $ nm /path/to/bin/ary
9346: [...]
9347: U __stack_chk_fail
9348: 0000000000600ea0 B __stack_chk_guard
9349:
9350: This is an indicator that the program was indeed built with support for SSP.
9351:
9352: This check is now performed automatically (where supported) if PKG_DEVELOPER is
9353: set and SSP is enabled.
9354:
1.266 martin 9355: Appendix C. Build logs
1.1 dsieger 9356:
9357: Table of Contents
9358:
1.207 leot 9359: C.1. Building figlet
9360: C.2. Packaging figlet
1.1 dsieger 9361:
1.266 martin 9362: C.1. Building figlet
1.1 dsieger 9363:
9364: # make
9365: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9366: => figlet221.tar.gz doesn't seem to exist on this system.
9367: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
9368: => [172219 bytes]
9369: Connected to ftp.plig.net.
9370: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
9371: 331 Guest login ok, send your complete e-mail address as password.
9372: 230-You are user #5 of 500 simultaneous users allowed.
9373: 230-
9374: 230- ___ _ _ _
9375: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
9376: 230- | _| _| . |_| . | | | . |_| . | _| . |
9377: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
9378: 230- |_| |_| |___| |___|
9379: 230-
9380: 230-** Welcome to ftp.plig.org **
9381: 230-
9382: 230-Please note that all transfers from this FTP site are logged. If you
9383: 230-do not like this, please disconnect now.
9384: 230-
1.19 snj 9385: 230-This archive is available via
1.1 dsieger 9386: 230-
9387: 230-HTTP: http://ftp.plig.org/
9388: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
9389: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
9390: 230-
9391: 230-Please email comments, bug reports and requests for packages to be
9392: 230-mirrored to ftp-admin@plig.org.
9393: 230-
9394: 230-
9395: 230 Logged in anonymously.
9396: Remote system type is UNIX.
9397: Using binary mode to transfer files.
9398: 200 Type okay.
9399: 250 "/pub" is new cwd.
9400: 250-"/pub/figlet" is new cwd.
9401: 250-
9402: 250-Welcome to the figlet archive at ftp.figlet.org
9403: 250-
9404: 250- ftp://ftp.figlet.org/pub/figlet/
9405: 250-
9406: 250-The official FIGlet web page is:
9407: 250- http://www.figlet.org/
9408: 250-
9409: 250-If you have questions, please mailto:info@figlet.org. If you want to
9410: 250-contribute a font or something else, you can email us.
9411: 250
9412: 250 "/pub/figlet/program" is new cwd.
9413: 250 "/pub/figlet/program/unix" is new cwd.
9414: local: figlet221.tar.gz remote: figlet221.tar.gz
9415: 502 Unimplemented command.
9416: 227 Entering Passive Mode (195,40,6,41,246,104)
9417: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
9418: 38% |************** | 65800 64.16 KB/s 00:01 ETA
9419: 226 Transfer completed.
9420: 172219 bytes received in 00:02 (75.99 KB/s)
9421: 221 Goodbye.
9422: => Checksum OK for figlet221.tar.gz.
9423: ===> Extracting for figlet-2.2.1nb2
9424: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
9425: ===> Patching for figlet-2.2.1nb2
9426: ===> Applying pkgsrc patches for figlet-2.2.1nb2
9427: ===> Overriding tools for figlet-2.2.1nb2
9428: ===> Creating toolchain wrappers for figlet-2.2.1nb2
9429: ===> Configuring for figlet-2.2.1nb2
9430: ===> Building for figlet-2.2.1nb2
9431: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
9432: chmod a+x figlet
9433: gcc -O2 -o chkfont chkfont.c
9434: => Unwrapping files-to-be-installed.
9435: #
9436: # make install
9437: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9438: ===> Installing for figlet-2.2.1nb2
9439: install -d -o root -g wheel -m 755 /usr/pkg/bin
9440: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
9441: mkdir -p /usr/pkg/share/figlet
9442: cp figlet /usr/pkg/bin
9443: cp chkfont /usr/pkg/bin
9444: chmod 555 figlist showfigfonts
9445: cp figlist /usr/pkg/bin
9446: cp showfigfonts /usr/pkg/bin
9447: cp fonts/*.flf /usr/pkg/share/figlet
9448: cp fonts/*.flc /usr/pkg/share/figlet
9449: cp figlet.6 /usr/pkg/man/man6
9450: ===> Registering installation for figlet-2.2.1nb2
9451: #
9452:
1.266 martin 9453: C.2. Packaging figlet
1.1 dsieger 9454:
9455: # make package
9456: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9457: ===> Packaging figlet-2.2.1nb2
9458: ===> Building binary package for figlet-2.2.1nb2
9459: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
9460: Using SrcDir value of /usr/pkg
9461: Registering depends:.
9462: #
9463:
1.266 martin 9464: Appendix D. Directory layout of the pkgsrc FTP server
1.1 dsieger 9465:
9466: Table of Contents
9467:
1.207 leot 9468: D.1. distfiles: The distributed source files
9469: D.2. misc: Miscellaneous things
9470: D.3. packages: Binary packages
9471: D.4. reports: Bulk build reports
9472: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1 dsieger 9473:
9474: As in other big projects, the directory layout of pkgsrc is quite complex for
9475: newbies. This chapter explains where you find things on the FTP server. The
9476: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
9477: different, but inside this directory, everything should look the same, no
9478: matter on which server you are. This directory contains some subdirectories,
9479: which are explained below.
9480:
1.266 martin 9481: D.1. distfiles: The distributed source files
1.1 dsieger 9482:
9483: The directory distfiles contains lots of archive files from all pkgsrc
9484: packages, which are mirrored here. The subdirectories are called after their
9485: package names and are used when the distributed files have names that don't
9486: explicitly contain a version number or are otherwise too generic (for example
9487: release.tar.gz).
9488:
1.266 martin 9489: D.2. misc: Miscellaneous things
1.1 dsieger 9490:
9491: This directory contains things that individual pkgsrc developers find worth
9492: publishing.
9493:
1.266 martin 9494: D.3. packages: Binary packages
1.1 dsieger 9495:
1.3 rillig 9496: This directory contains binary packages for the various platforms that are
9497: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
9498: The meaning of these variables is:
9499:
9500: * OPSYS is the name of the operating system for which the packages have been
1.9 rillig 9501: built. The name is taken from the output of the uname command, so it may
9502: differ from the one you are used to hear.
1.3 rillig 9503:
1.8 rillig 9504: * ARCH is the hardware architecture of the platform for which the packages
1.10 hubertf 9505: have been built. It also includes the ABI (Application Binary Interface)
9506: for platforms that have several of them.
1.3 rillig 9507:
1.255 wiz 9508: * OSVERSION is the version of the operating system. Typically it is the
9509: version defining an ABI, e.g. 9.0.
9510:
9511: * TAG is either 20YYQN for a stable branch, or current for packages built
9512: from the HEAD branch. The latter should only be used when the packages are
9513: updated on a regular basis.
9514:
9515: The rationale for this scheme is that users can first search by OPSYS and ARCH,
9516: since these are more or less unchangeable. After that, there is a management
9517: set of directories with OSVERSION and TAG.
9518:
9519: See also README.md in packages for more details, including about symlinks.
1.3 rillig 9520:
9521: In each of these directories, there is a whole binary packages collection for a
9522: specific platform. It has a directory called All which contains all binary
1.255 wiz 9523: packages.
1.1 dsieger 9524:
1.266 martin 9525: D.4. reports: Bulk build reports
1.8 rillig 9526:
9527: Here are the reports from bulk builds, for those who want to fix packages that
9528: didn't build on some of the platforms. The structure of subdirectories should
1.266 martin 9529: look like the one in Section D.3, packages: Binary packages .
1.8 rillig 9530:
1.266 martin 9531: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1 dsieger 9532:
1.266 martin 9533: These directories contain the real pkgsrc, that is the files that define how
1.1 dsieger 9534: to create binary packages from source archives.
9535:
1.149 leot 9536: Each of the current, stable and pkgsrc-20xxQy directories share the same
9537: structure. They each contain a pkgsrc directory and pkgsrc.tar.{bz,gz,xz} file.
9538:
1.1 dsieger 9539: The directory pkgsrc contains a snapshot of the CVS repository, which is
1.149 leot 9540: updated regularly. The file pkgsrc.tar.{bz,gz,xz} contains the same as the
9541: directory, ready to be downloaded as a whole.
1.1 dsieger 9542:
1.149 leot 9543: The current directory contains files related to the HEAD branch of the CVS
9544: repository. In this directory there is an additional file called
9545: pkgsrc-readmes.tar.{bz,gz,xz} that contains all pkgsrc READMEs with information
9546: about categories and packages.
9547:
9548: The stable directory is a symlink to the latest pkgsrc-20xxQy.
9549:
9550: The pkgsrc-20xxQy. directories contain files related to the -20xxQy stable
9551: branch of the CVS repository. In these directories there is an additional file
9552: called pkgsrc-20xxQy.tar.{bz,gz,xz}, which contains the state of pkgsrc when it
9553: was branched.
1.148 leot 9554:
1.266 martin 9555: Appendix E. Help topics
1.154 rillig 9556:
9557: The following list contains all help topics that are available when running
9558: bmake help topic=:index.
9559:
1.273 wiz 9560: #! -lintl
9561: 32bit 64bit
9562: ABI ACCEPTABLE_LICENSES
9563: ACROREAD_FONTPATH AFAIK
9564: AIX ALLOW_NETWORK_ACCESS
9565: ALLOW_NEWER_COMPILER ALLOW_VULNERABLE_PACKAGES
9566: ALL_ENV ALSA_PC
9567: ALTERNATIVES_SRC AMANDA_TMP
9568: AMANDA_USER AMANDA_VAR
9569: APACHE_GROUP APACHE_MODULE_NAME
9570: APACHE_MODULE_SRC APACHE_MODULE_SRCDIR
9571: APACHE_PKG_PREFIX APACHE_SUEXEC_CONFIGURE_ARGS
9572: APACHE_SUEXEC_DOCROOT APACHE_USER
9573: ARGMAX_REQ ARG_MAX
9574: ARLA_CACHE AUDIT_PACKAGES_FLAGS
9575: AUTOCONF_REQD AUTOMAKE_OVERRIDE
9576: AUTOMAKE_REQD AUTO_MKDIRS
9577: AUX BDB185_DEFAULT
9578: BDBBASE BDB_ACCEPTED
9579: BDB_DEFAULT BDB_LIBS
9580: BDB_TYPE BINCIMAP_GROUP
9581: BINCIMAP_LOG_USER BINCIMAP_USER
9582: BIND_DIR BIND_GROUP
9583: BIND_USER BINOWN
9584: BINPKG_SITES BIN_INSTALL_FLAGS
9585: BISON_PKGDATADIR BLAS
9586: BLAS_ACCEPTED BLAS_C_INTERFACE
9587: BLAS_INCLUDES BLAS_INDEX64
9588: BLAS_LIBS BLAS_PC
9589: BLAS_TYPE BOOTSTRAP_DEPENDS
9590: BROKEN BROKEN_EXCEPT_ON_PLATFORM
9591: BROKEN_ON_PLATFORM BSDSRCDIR
9592: BSD_MAKE_ENV BUILDLINK_AUTO_DIRS
9593: BUILDLINK_AUTO_VARS BUILDLINK_CFLAGS
9594: BUILDLINK_CONTENTS_FILTER BUILDLINK_CPPFLAGS
9595: BUILDLINK_DEPMETHOD BUILDLINK_FILES
9596: BUILDLINK_FILES_CMD BUILDLINK_FNAME_TRANSFORM
9597: BUILDLINK_LDFLAGS BUILDLINK_LIBS
9598: BUILDLINK_OPSYS_SUPPORT_PTHREAD BUILDLINK_PKGNAME
9599: BUILDLINK_PREFIX BUILDLINK_RPATHDIRS
9600: BUILDLINK_TREE BUILD_DEFS
9601: BUILD_DEFS_EFFECTS BUILD_DEPENDS
9602: BUILD_DIRS BUILD_ENV_SHELL
9603: BUILD_MAKE_CMD BUILD_MAKE_FLAGS
9604: BUILD_TARGET BUILTIN_FIND_FILES
9605: BUILTIN_FIND_FILES_VAR BUILTIN_FIND_GREP
9606: BUILTIN_FIND_HEADERS BUILTIN_FIND_HEADERS_VAR
9607: BUILTIN_FIND_PKGCONFIG BUILTIN_FIND_PKGCONFIG_VAR
9608: BUILTIN_PKG BUILTIN_TEST_CURSES_DEFINES
9609: BUILTIN_TEST_CURSES_FUNCS BUILTIN_VERSION_SCRIPT
9610: BUILTIN_X11_TYPE BUILTIN_X11_VERSION
9611: CACTI_GROUP CACTI_USER
9612: CANNA_GROUP CANNA_USER
9613: CAT CBLAS_LIBS
9614: CBLAS_PC CCACHE_BASE
9615: CCACHE_DIR CCACHE_LOGFILE
9616: CCACHE_RECACHE CC_VERSION
9617: CDRECORD_CONF CDROM_PKG_URL_DIR
9618: CDROM_PKG_URL_HOST CHANGES
9619: CHECKOUT_DATE CHECK_COMPILER
9620: CHECK_FAKEHOME CHECK_FILES
9621: CHECK_FILES_ONLY_PREFIX CHECK_FILES_SKIP
9622: CHECK_FILES_STRICT CHECK_HEADERS
9623: CHECK_HEADERS_SKIP CHECK_INTERPRETER
9624: CHECK_INTERPRETER_SKIP CHECK_PERMS
9625: CHECK_PERMS_AUTOFIX CHECK_PERMS_SKIP
9626: CHECK_PIE CHECK_PIE_SKIP
9627: CHECK_PIE_SUPPORTED CHECK_PORTABILITY
9628: CHECK_PORTABILITY_EXPERIMENTAL CHECK_PORTABILITY_SKIP
9629: CHECK_RELRO CHECK_RELRO_SKIP
9630: CHECK_RELRO_SUPPORTED CHECK_SHLIBS
9631: CHECK_SHLIBS_SKIP CHECK_SHLIBS_SUPPORTED
9632: CHECK_SHLIBS_TOXIC CHECK_SSP
9633: CHECK_SSP_SKIP CHECK_SSP_SUPPORTED
9634: CHECK_STRIPPED CHECK_STRIPPED_SKIP
9635: CHECK_WRKREF CHECK_WRKREF_EXTRA_DIRS
9636: CHECK_WRKREF_SKIP CLAMAV_DBDIR
9637: CLAMAV_GROUP CLAMAV_USER
9638: CLANGBASE CLEANDEPENDS
9639: CLT CMAKE_DEPENDENCIES_REWRITE
9640: CMAKE_INSTALL_NAME_DIR CMAKE_INSTALL_PREFIX
9641: CMAKE_MODULE_PATH_OVERRIDE CMAKE_PKGSRC_BUILD_FLAGS
9642: CMAKE_PREFIX_PATH CMAKE_USE_GNU_INSTALL_DIRS
9643: COMMON_LISP_DOCFILES COMMON_LISP_EXAMPLES
9644: COMMON_LISP_EXTRAFILES COMMON_LISP_PACKAGES
9645: COMMON_LISP_SYSTEM COMPILER_RPATH_FLAG
9646: COMPILER_USE_SYMLINKS CONFIGURE_ARGS
9647: CONFIGURE_DIRS CONFIGURE_ENV
9648: CONFIGURE_ENV_SHELL CONFIGURE_HAS_INFODIR
9649: CONFIGURE_HAS_MANDIR CONFIGURE_SCRIPT
9650: CONFIG_SHELL CONFIG_SHELL_FLAGS
9651: CONF_FILES CONF_FILES_MODE
9652: CONF_FILES_PERMS CONSERVER_DEFAULTHOST
9653: CONSERVER_DEFAULTPORT CP
9654: CPE CPE_EDITION
9655: CPE_LANG CPE_OTHER
9656: CPE_PART CPE_PRODUCT
9657: CPE_SW_EDITION CPE_TARGET_HW
9658: CPE_TARGET_SW CPE_UPDATE
9659: CPE_URI CPE_VENDOR
9660: CPE_VERSION CPP
9661: CPP_PRECOMP_FLAGS CREATE_WRKDIR_SYMLINK
9662: CROSSBASE CTFCONVERT
9663: CTF_FILES_SKIP CTF_SUPPORTED
9664: CTYPE CUPS_GROUP
9665: CUPS_SYSTEM_GROUPS CUPS_USER
9666: CURSES_DEFAULT CURSES_TYPE
9667: CVS_EXTRACTDIR CVS_MODULE
9668: CVS_PROJECT CVS_REPOSITORIES
9669: CVS_ROOT CVS_ROOT_GNU
9670: CVS_ROOT_NONGNU CVS_ROOT_SOURCEFORGE
9671: CVS_TAG CYRUS_GROUP
9672: CYRUS_IDLE CYRUS_USER
9673: DAEMONTOOLS_GROUP DAEMONTOOLS_LOG_USER
9674: DARWIN_NO_SYSTEM_LIBS DARWIN_REQUIRES_FILTER
9675: DBUS_GROUP DBUS_USER
9676: DEFANG_GROUP DEFANG_USER
9677: DEFAULT_ACCEPTABLE_LICENSES DEFAULT_DISTFILES
9678: DEFAULT_IRC_SERVER DEFAULT_SERIAL_DEVICE
9679: DEF_UMASK DEINSTALLDEPENDS
9680: DEINSTALL_SRC DEINSTALL_TEMPLATES
9681: DELAYED_ERROR_MSG DELAYED_WARNING_MSG
9682: DEPENDS DEPENDS_TARGET
9683: DEPENDS_TYPE DESTDIR
9684: DESTDIR_VARNAME DIALER_GROUP
9685: DIGEST_REQD DISTDIR
9686: DISTFILES DISTINFO_FILE
9687: DISTNAME DIST_PATH
9688: DIST_SUBDIR DJBDNS_AXFR_USER
9689: DJBDNS_CACHE_USER DJBDNS_DJBDNS_GROUP
9690: DJBDNS_LOG_USER DJBDNS_RBL_USER
9691: DJBDNS_TINY_USER DLOPEN_REQUIRE_PTHREADS
9692: DL_AUTO_VARS DL_CFLAGS
9693: DL_LDFLAGS DL_LIBS
9694: DNS DOCOWN
9695: DOWNLOADED_DISTFILE DQCACHE_GROUP
9696: DQCACHE_USER DT_LAYOUT
9697: DYNAMIC_SITES_CMD DYNAMIC_SITES_SCRIPT
9698: ECHO ECHO_N
9699: ELK_GUI EMACS_TYPE
9700: EMULDIR EMULSUBDIR
9701: EMULSUBDIRSLASH EMUL_ARCH
9702: EMUL_DISTRO EMUL_EXEC_FMT
9703: EMUL_IS_NATIVE EMUL_MODULES
9704: EMUL_OPSYS EMUL_PKG_FMT
9705: EMUL_PLATFORM EMUL_PLATFORMS
9706: EMUL_PREFER EMUL_REQD
9707: EMUL_TYPE ERROR_MSG
9708: EXIM_GROUP EXIM_USER
9709: EXPORT_SYMBOLS_LDFLAGS EXTRACTOR
9710: EXTRACT_CMD EXTRACT_CMD_DEFAULT
9711: EXTRACT_DIR EXTRACT_ELEMENTS
9712: EXTRACT_ENV EXTRACT_ONLY
9713: EXTRACT_OPTS EXTRACT_SUFX
9714: EXTRACT_USING FAIL
9715: FAILOVER_FETCH FAIL_MSG
9716: FAKE_NCURSES FAM
9717: FAM_ACCEPTED FAM_DEFAULT
9718: FAM_SERVER FCPATH
9719: FETCH_AFTER_ARGS FETCH_BEFORE_ARGS
9720: FETCH_CMD FETCH_INSECURE
9721: FETCH_OUTPUT_ARGS FETCH_PROXY
9722: FETCH_RESUME_ARGS FETCH_TIMEOUT
9723: FETCH_USE_IPV4_ONLY FETCH_USING
9724: FILES_SUBST FILES_SUBST_SED
9725: FIX_SYSTEM_HEADERS FONTDIR
9726: FONTS_DIRS FONTS_VERBOSE
9727: FOO_HACKS_MK FORCE_CXX_STD
9728: FORCE_C_STD FOSSIL_EXTRACTDIR
9729: FOSSIL_REPO FOSSIL_REPOSITORIES
9730: FOSSIL_VERSION FOX_USE_XUNICODE
9731: FREEWNN_GROUP FREEWNN_USER
9732: FTP_PKG_URL_DIR FTP_PKG_URL_HOST
9733: GAMEDATAMODE GAMEDATA_PERMS
9734: GAMEDIRMODE GAMEDIR_PERMS
9735: GAMEGRP GAMEMODE
9736: GAMEOWN GAMES_GROUP
9737: GAMES_USER GCC
9738: GCCBASE GCC_REQD
9739: GCC_VERSION_SUFFIX GEM_BUILD
9740: GEM_CLEANBUILD GEM_CLEANBUILD_EXTENSIONS
9741: GEM_DOCDIR GEM_EXTSDIR
9742: GEM_HOME GEM_KEEPBUILD
9743: GEM_LIBDIR GEM_NAME
9744: GEM_PATH GEM_PLUGINSDIR
9745: GEM_SPECFILE GENERATE_PLIST
9746: GHC GHOSTSCRIPT_REQD
9747: GITHUB_PROJECT GITHUB_RELEASE
9748: GITHUB_SUBMODULES GITHUB_TAG
9749: GITHUB_TYPE GITLAB_PROJECT
9750: GITLAB_RELEASE GITLAB_SUBMODULES
9751: GITLAB_TAG GITLAB_TYPE
9752: GIT_BRANCH GIT_ENV
9753: GIT_EXTRACTDIR GIT_REPO
9754: GIT_REPOSITORIES GIT_REVISION
9755: GIT_TAG GNAT
9756: GNU GNU_CONFIGURE
9757: GNU_CONFIGURE_ICONV GNU_CONFIGURE_INFODIR
9758: GNU_CONFIGURE_MANDIR GNU_CONFIGURE_QUIET
9759: GNU_CONFIGURE_STRICT GOFLAGS
9760: GO_BUILD_PATTERN GO_DIST_BASE
9761: GO_EXTRA_MOD_DIRS GO_MODULE_EXTRACT
9762: GO_MODULE_FILES GO_SRCPATH
9763: GROUP_SPECIFIC_PKGS GRUB_NETWORK_CARDS
9764: GRUB_PRESET_COMMAND GRUB_SCAN_ARGS
9765: GZIP HASKELL_COMPILER
9766: HASKELL_DISABLE_EXECUTABLES HASKELL_DISABLE_LIBRARIES
9767: HASKELL_ENABLE_DYNAMIC_EXECUTABLE HASKELL_ENABLE_HADDOCK_DOCUMENTATION
9768: HASKELL_ENABLE_LIBRARY_PROFILING HASKELL_ENABLE_SHARED_LIBRARY
9769: HASKELL_ENABLE_TESTS HASKELL_OPTIMIZATION_LEVEL
9770: HASKELL_PKG_NAME HASKELL_UNRESTRICT_DEPENDENCIES
9771: HEADER_TEMPLATES HG_REPO
9772: HG_REPOSITORIES HG_TAG
9773: HOMEPAGE HOST_PKGTOOLS_ARGS
9774: HOST_SPECIFIC_PKGS HOWL_GROUP
9775: HOWL_USER ICCBASE
9776: ICECAST_CHROOTDIR ICON_THEMES
9777: IDOBASE IGNORE_CCACHE
9778: IGNORE_INFO_DIRS IGNORE_INTERACTIVE_FETCH
9779: IMAKE IMAKEOPTS
9780: IMAKE_MAKE IMAKE_MANINSTALL
9781: IMAP_UW_CCLIENT_MBOX_FMT IMDICTDIR
9782: INCOMPAT_CURSES INFO_DIR
9783: INFO_FILES INFO_MSG
9784: INIT_SYSTEM INN_DATA_DIR
9785: INN_GROUP INN_USER
9786: INSTALLATION_DIRS INSTALLATION_DIRS_FROM_PLIST
9787: INSTALL_ENV INSTALL_ENV_SHELL
9788: INSTALL_SH_OVERRIDE INSTALL_SRC
9789: INSTALL_TEMPLATES INSTALL_UNSTRIPPED
9790: IRCD_HYBRID_IRC_GROUP IRCD_HYBRID_IRC_USER
9791: IRCD_HYBRID_MAXCONN IRCD_HYBRID_NICLEN
9792: IRCD_HYBRID_SYSLOG_EVENTS IRCD_HYBRID_SYSLOG_FACILITY
9793: IRCD_HYBRID_TOPICLEN IRIX
9794: IRRD_USE_PGP JABBERD_GROUP
9795: JABBERD_LOGDIR JABBERD_PIDDIR
9796: JABBERD_SPOOLDIR JABBERD_USER
9797: JAVA_APP_PATH JAVA_APP_TARGETS
9798: JAVA_BINPREFIX JAVA_CLASSPATH
9799: JAVA_HOME JAVA_LD_LIBRARY_PATH
9800: JAVA_NAME JAVA_UNLIMIT
9801: JAVA_WRAPPERS JPEG_ACCEPTED
9802: JPEG_DEFAULT KERBEROS
9803: KERMIT_SUID_UUCP KJS_USE_PCRE
9804: KNEWS_DOMAIN_FILE KNEWS_DOMAIN_NAME
9805: KRB5_ACCEPTED KRB5_DEFAULT
9806: LANGUAGES LAPACKE_LIBS
9807: LAPACKE_PC LAPACK_LIBS
9808: LAPACK_PC LATEX2HTML_ICONPATH
9809: LDCONFIG_ADD_CMD LDCONFIG_REMOVE_CMD
9810: LDD LEAFNODE_DATA_DIR
9811: LEAFNODE_GROUP LEAFNODE_USER
9812: LIBDVDCSS_HOMEPAGE LIBDVDCSS_MASTER_SITES
9813: LIBIMAGEQUANT_TYPE LIBRSVG_TYPE
9814: LIBTOOL LIBTOOLIZE_PLIST
9815: LIBTOOL_M4_OVERRIDE LIBUSB_TYPE
9816: LICENSE LINKER_RPATH_FLAG
9817: LINK_RPATH_FLAG LINUX_BASE_NODEPS
9818: LINUX_BASE_PREFERRED LINUX_BASE_REQUIRED
9819: LINUX_LOCALES LOCALBASE
9820: LOCALBASE_LOCKTYPE LOCALPATCHES
9821: LOVE_DATA LOVE_GAME
9822: LOVE_VERSION LOWER_OPSYS
9823: LOWER_OPSYS_VERSUFFIX LOWER_VARIANT_VERSION
9824: LOWER_VENDOR LP32PLATFORMS
9825: LP64PLATFORMS LUA_BUSTED_ARGS
9826: LUA_CDIR LUA_COMPILER
9827: LUA_DOCDIR LUA_EXAMPLESDIR
9828: LUA_INCDIR LUA_INTERPRETER
9829: LUA_LDIR LUA_LINKER_MAGIC
9830: LUA_PKGPREFIX LUA_SELF_CONFLICT
9831: LUA_USE_BUSTED LUA_VERSIONS_ACCEPTED
9832: LUA_VERSIONS_INCOMPATIBLE LUA_VERSION_DEFAULT
9833: LUA_VERSION_REQD Lua
9834: MACHINE_PLATFORM MAILAGENT_DOMAIN
9835: MAILAGENT_EMAIL MAILAGENT_FQDN
9836: MAILAGENT_ORGANIZATION MAJORDOMO_HOMEDIR
9837: MAJOR_OS_VERSION MAKEINFO_ARGS
9838: MAKE_DIRS MAKE_DIRS_PERMS
9839: MAKE_ENV MAKE_FILE
9840: MAKE_FLAGS MAKE_JOBS
9841: MAKE_JOBS_SAFE MAKE_PROGRAM
9842: MANCOMPRESSED_IF_MANZ MANINSTALL
9843: MANZ MARIADB_VERSIONS_ALL
9844: MASTER_SITES MASTER_SITE_BACKUP
9845: MASTER_SITE_LOCAL MASTER_SITE_MOZILLA
9846: MASTER_SITE_OVERRIDE MASTER_SITE_PERL_CPAN
9847: MASTER_SORT MASTER_SORT_RANDOM
9848: MASTER_SORT_REGEX MECAB_CHARSET
9849: MEDIATOMB_GROUP MEDIATOMB_USER
9850: MIPSPROBASE MIREDO_GROUP
9851: MIREDO_USER MISSING_FEATURES
9852: MKDIR MKPIE_SUPPORTED
9853: MLDONKEY_GROUP MLDONKEY_HOME
9854: MLDONKEY_USER MONOTONE_GROUP
9855: MONOTONE_USER MOTIFBASE
9856: MOTIF_TYPE MOTIF_TYPE_DEFAULT
9857: MPI_TYPE MSGFMT_STRIP_MSGCTXT
9858: MSGFMT_STRIP_MSGID_PLURAL MTOOLS_ENABLE_FLOPPYD
9859: MUST MV
9860: MYSQL_CHARSET MYSQL_DATADIR
9861: MYSQL_EXTRA_CHARSET MYSQL_GROUP
9862: MYSQL_USER MYSQL_VERSION
9863: MYSQL_VERSIONS_ACCEPTED MYSQL_VERSION_DEFAULT
9864: NAGIOSCMD_GROUP NAGIOSDIR
9865: NAGIOS_GROUP NAGIOS_USER
9866: NATIVE_EXEC_FMT NATIVE_LOWER_OPSYS
9867: NATIVE_LOWER_VENDOR NATIVE_MACHINE_PLATFORM
9868: NATIVE_OBJECT_FMT NATIVE_OPSYS_VERSION
9869: NATIVE_OS_VARIANT NATIVE_OS_VERSION
9870: NBPAX_PROGRAM_PREFIX NETBSD_LOGIN_NAME
9871: NMH_EDITOR NMH_MTA
9872: NMH_PAGER NODE_VERSIONS_ACCEPTED
9873: NODE_VERSIONS_INCOMPATIBLE NODE_VERSION_DEFAULT
9874: NODE_VERSION_REQD NOLOGIN
9875: NOTE NOT_FOR_PLATFORM
9876: NOT_PAX_ASLR_SAFE NOT_PAX_MPROTECT_SAFE
9877: NO_BUILD NO_CHECKSUM
9878: NO_CONFIGURE NO_SKIP
9879: NSD_GROUP NSD_LOG_FACILITY
9880: NSD_USER NS_PREFERRED
9881: NULLMAILER_GROUP NULLMAILER_USER
9882: OBJECT_FMT OBJHOSTNAME
9883: OBJMACHINE OCAML_FINDLIB_DIRS
9884: OCAML_FINDLIB_REGISTER OCAML_FINDLIB_REGISTER_VERBOSE
9885: OCAML_SITELIBDIR OMF
9886: ONLY_FOR_COMPILER ONLY_FOR_PLATFORM
9887: OPENSSH_CHROOT OPENSSH_GROUP
9888: OPENSSH_USER OPSYS
9889: OPSYS_EMULDIR OPSYS_VERSION
9890: OS OSS_TYPE
9891: OSX OSX_PATH_TO_M4
9892: OSX_PATH_TO_YACC OS_HAVE_ALSA
9893: OS_HAVE_RCD OS_VARIANT
9894: OS_VERSION OTF_FONTS_DIR
9895: OVERRIDE_DIRDEPTH OVERRIDE_GEMSPEC
9896: OVERRIDE_GNU_CONFIG_SCRIPTS OVERRIDE_ROCKSPEC
9897: OWN_DIRS OWN_DIRS_PERMS
9898: P4GROUP P4PORT
9899: P4ROOT P4USER
9900: PACKAGES PALMOS_DEFAULT_SDK
9901: PAMBASE PAM_DEFAULT
9902: PAPERSIZE PASSIVE_FETCH
9903: PATCHDIR PATCHFILES
9904: PATCH_ARGS PATCH_DEBUG
9905: PATCH_DIST_ARGS PATCH_DIST_CAT
9906: PATCH_DIST_STRIP PATCH_FUZZ_FACTOR
9907: PATCH_STRIP PATH
9908: PCCBASE PEAR
9909: PEAR_CHANNEL PEAR_CHANNEL_ALIAS
9910: PEAR_CHANNEL_VERSION PEAR_CMD
9911: PEAR_LIB PEAR_PACKAGE_XML
9912: PEP-518 PERL5
9913: PERL5_CONFIGURE PERL5_CONFIGURE_DIRS
9914: PERL5_LDFLAGS PERL5_LICENSE
9915: PERL5_MODULE_TYPE PERL5_PACKLIST
9916: PERL5_PACKLIST_DIR PERL5_PERLBASE
9917: PERL5_SITEBASE PERL5_USE_PACKLIST
9918: PERL5_VENDORBASE PFCTL
9919: PFVAR_H PF_VERSION
9920: PGGROUP PGHOME
9921: PGPKGSRCDIR PGSQL_TYPE
9922: PGSQL_VERSION PGSQL_VERSIONS_ACCEPTED
9923: PGSQL_VERSION_DEFAULT PGUSER
9924: PG_LIB_EXT PHP
9925: PHPCOMMON_MK PHPPKGSRCDIR
9926: PHP_BASE_VERS PHP_EGDIR
9927: PHP_EXTENSION_DIR PHP_INCDIR
9928: PHP_LIBDIR PHP_MAJOR_VERS
9929: PHP_MINIMUM_TEENY PHP_MINOR_VERS
9930: PHP_PKG_PREFIX PHP_SHAREDIR
9931: PHP_VER PHP_VERSION
9932: PHP_VERSIONS_ACCEPTED PHP_VERSIONS_INCOMPATIBLE
9933: PHP_VERSION_DEFAULT PHP_VERSION_REQD
9934: PILRC_USE_GTK PKGCONFIG_BASE
9935: PKGCONFIG_FILE PKGCONFIG_OVERRIDE
9936: PKGCONFIG_OVERRIDE_STAGE PKGDIR
9937: PKGGNUDIR PKGINFODIR
9938: PKGLOCALEDIR PKGMANDIR
9939: PKGNAME PKGNAME_REQD
9940: PKGPATH PKGREVISION
9941: PKGSRC_BLAS_TYPES PKGSRC_CHANGES
9942: PKGSRC_COMPILER PKGSRC_KEEP_BIN_PKGS
9943: PKGSRC_LOCKTYPE PKGSRC_MAKE_ENV
9944: PKGSRC_MESSAGE_RECIPIENTS PKGSRC_MKPIE
9945: PKGSRC_MKREPRO PKGSRC_OVERRIDE_MKPIE
9946: PKGSRC_RUN_TEST PKGSRC_SETENV
9947: PKGSRC_SLEEPSECS PKGSRC_TODO
9948: PKGSRC_USE_CTF PKGSRC_USE_FORTIFY
9949: PKGSRC_USE_MKTOOLS PKGSRC_USE_RELRO
9950: PKGSRC_USE_SSP PKGSRC_USE_STACK_CHECK
9951: PKGTASKS_DATAFILE PKGTOOLS_ARGS
9952: PKGTOOLS_ENV PKG_ALTERNATIVES
9953: PKG_APACHE PKG_APACHE_ACCEPTED
9954: PKG_APACHE_DEFAULT PKG_BEST_EXISTS
9955: PKG_BUILD_OPTIONS PKG_COMPRESSION
9956: PKG_CONFIG PKG_CONFIG_PERMS
9957: PKG_CREATE_USERGROUP PKG_DBDIR
9958: PKG_DB_TMPDIR PKG_DEBUG_LEVEL
9959: PKG_DEFAULT_OPTIONS PKG_DESTDIR_SUPPORT
9960: PKG_DEVELOPER PKG_DISABLED_OPTIONS
9961: PKG_FATAL_ERRORS PKG_FC
9962: PKG_FILELIST_CMD PKG_GECOS
9963: PKG_GID PKG_GROUPS
9964: PKG_GROUPS_VARS PKG_HOME
9965: PKG_INIT_SCRIPTS PKG_JAVA_HOME
9966: PKG_JVM PKG_JVMS_ACCEPTED
9967: PKG_JVM_DEFAULT PKG_LEGACY_OPTIONS
9968: PKG_LIBTOOL PKG_MKSYMLINKS
9969: PKG_OPTIONS PKG_OPTIONS_DEPRECATED_WARNINGS
9970: PKG_OPTIONS_LEGACY_OPTS PKG_OPTIONS_LEGACY_VARS
9971: PKG_OPTIONS_NONEMPTY_SETS PKG_OPTIONS_OPTIONAL_GROUPS
9972: PKG_OPTIONS_REQUIRED_GROUPS PKG_OPTIONS_VAR
9973: PKG_RCD_SCRIPTS PKG_REFCOUNT_DBDIR
9974: PKG_REGISTER_SHELLS PKG_RESUME_TRANSFERS
9975: PKG_SHELL PKG_SUGGESTED_OPTIONS
9976: PKG_SUPPORTED_OPTIONS PKG_SYSCONFBASE
9977: PKG_SYSCONFBASEDIR PKG_SYSCONFDIR
9978: PKG_SYSCONFDIR_PERMS PKG_SYSCONFSUBDIR
9979: PKG_SYSCONFVAR PKG_TOOLS_BIN
9980: PKG_UID PKG_UPDATE_FONTS_DB
9981: PKG_USERS PKG_USERS_VARS
9982: PKG_VERBOSE PLEASE
9983: PLIST PLIST_AWK
9984: PLIST_AWK_ENV PLIST_SRC
9985: PLIST_SUBST PLIST_TYPE
9986: PLIST_VARS POPTOP_USE_MPPE
9987: POSSIBLE_GFORTRAN_VERSION POST_FETCH_HOOK
9988: PREFER PREFER_NATIVE
9989: PREFER_NATIVE_PTHREADS PREFER_PKGSRC
9990: PREFIX PREPEND_PATH
9991: PRE_ROOT_CMD PRIVILEGED_STAGES
9992: PS PTHREAD_AUTO_VARS
9993: PTHREAD_CFLAGS PTHREAD_LDFLAGS
9994: PTHREAD_LIBS PTHREAD_OPTS
9995: PTHREAD_TYPE PVM_SSH
9996: PYPKGPREFIX PYSOABISUFFIX
9997: PYTHON_27_ACCEPTED PYTHON_FOR_BUILD_ONLY
9998: PYTHON_SELF_CONFLICT PYTHON_VERSION
9999: PYTHON_VERSIONED_DEPENDENCIES PYTHON_VERSIONS_ACCEPTED
10000: PYTHON_VERSIONS_INCOMPATIBLE PYTHON_VERSION_DEFAULT
10001: PYTHON_VERSION_REQD PYVERSSUFFIX
10002: QMAILDIR QMAIL_ALIAS_USER
10003: QMAIL_DAEMON_USER QMAIL_LOG_USER
10004: QMAIL_NOFILES_GROUP QMAIL_PASSWD_USER
10005: QMAIL_QMAIL_GROUP QMAIL_QUEUE_DIR
10006: QMAIL_QUEUE_EXTRA QMAIL_QUEUE_USER
10007: QMAIL_REMOTE_USER QMAIL_ROOT_USER
10008: QMAIL_SEND_USER QORE_LATEST_MODULE_API
10009: QORE_MODULE_API QORE_MODULE_DIR
10010: QORE_USER_MODULE_DIR QORE_VERSION
10011: QPOPPER_FAC QPOPPER_SPOOL_DIR
10012: QPOPPER_USER RAKE_NAME
10013: RASMOL_DEPTH RCD_DIR
10014: RCD_ORDER RCD_SCRIPTS
10015: RCD_SCRIPTS_DIR RCD_SCRIPTS_EXAMPLEDIR
10016: RCD_SCRIPTS_MODE RCD_SCRIPTS_SHELL
10017: RCD_SCRIPT_SRC RCD_SUBR
10018: RDOC READLINE_DEFAULT
10019: READLINE_TYPE REAL_ROOT_GROUP
10020: REAL_ROOT_USER RECURSIVE_MAKE
10021: RELAY_CTRL_DIR RELRO_SUPPORTED
10022: REPLACE_AWK REPLACE_BASH
10023: REPLACE_CSH REPLACE_KSH
10024: REPLACE_LUA REPLACE_NODEJS
10025: REPLACE_OCTAVE REPLACE_PERL
10026: REPLACE_PERL6 REPLACE_PHP
10027: REPLACE_PYTHON REPLACE_QORE
10028: REPLACE_R REPLACE_RUBY
10029: REPLACE_RUBY_DIRS REPLACE_RUBY_PAT
10030: REPLACE_SH REPLACE_TEXLUA
10031: REPLACE_TOOL_PYTHON REPLACE_WISH
10032: REQD_DIRS REQD_DIRS_PERMS
10033: REQD_FILES REQD_FILES_MODE
10034: REQD_FILES_PERMS RESOLV_AUTO_VARS
10035: RESOLV_LDFLAGS RESOLV_LIBS
10036: RM ROCKSPEC_NAME
10037: ROCKSPEC_SPECFILE ROOT_CMD
10038: ROOT_GROUP ROOT_USER
10039: RPCGEN RPM
10040: RPM2PKG_PLIST RPM2PKG_PREFIX
10041: RPM2PKG_STAGE RPM2PKG_STRIP
10042: RPM2PKG_SUBPREFIX RPMFILES
10043: RPMIGNOREPATH RPM_DB_PREFIX
10044: RSSH_CVS_PATH RSSH_RDIST_PATH
10045: RSSH_RSYNC_PATH RSSH_SCP_PATH
10046: RSSH_SFTP_SERVER_PATH RUBY
10047: RUBYGEM RUBYGEM_MANPAGES
10048: RUBYGEM_NAME RUBYGEM_OPTIONS
10049: RUBYGEM_USE_MANPAGES RUBYGEM_VERBOSE
10050: RUBY_ABI_VERSION RUBY_ALLOW_HAS_RDOC
10051: RUBY_ARCH RUBY_ARCHINC
10052: RUBY_ARCHLIB RUBY_BASE
10053: RUBY_BASERIDIR RUBY_BUILD_DOCUMENT
10054: RUBY_DLEXT RUBY_DOC
10055: RUBY_DYNAMIC_DIRS RUBY_EG
10056: RUBY_EXTCONF RUBY_EXTCONF_CHECK
10057: RUBY_EXTCONF_DEBUG RUBY_EXTCONF_MAKEFILE
10058: RUBY_GEM_ARCH RUBY_GEM_BASE
10059: RUBY_INC RUBY_LIB
10060: RUBY_LIB_BASE RUBY_NAME
10061: RUBY_NOVERSION RUBY_PKGPREFIX
10062: RUBY_RAILS RUBY_RAILS61_VERSION
10063: RUBY_RAILS72_VERSION RUBY_RAILS80_VERSION
10064: RUBY_RAILS_ACCEPTED RUBY_RAILS_DEFAULT
10065: RUBY_RAILS_REQD RUBY_RAILS_STRICT_DEP
10066: RUBY_RIDIR RUBY_SETUP
10067: RUBY_SHLIB RUBY_SHLIBALIAS
10068: RUBY_SHLIBVER RUBY_SIMPLE_INSTALL
10069: RUBY_SITEARCHLIB RUBY_SITELIB
10070: RUBY_SITELIB_BASE RUBY_SITERIDIR
10071: RUBY_SLEXT RUBY_SRCDIR
10072: RUBY_STATICLIB RUBY_SUFFIX
10073: RUBY_SYSRIDIR RUBY_USE_PTHREAD
10074: RUBY_VENDORARCHLIB RUBY_VENDORLIB
10075: RUBY_VENDORLIB_BASE RUBY_VER
10076: RUBY_VERSION RUBY_VERSIONS_ACCEPTED
10077: RUBY_VERSIONS_INCOMPATIBLE RUBY_VERSION_DEFAULT
10078: RUBY_VERSION_REQD RUBY_VER_DIR
10079: RUN RUN_LDCONFIG
10080: RUST_TYPE SCO
10081: SCREWS_GROUP SCREWS_USER
10082: SCRIPTS_ENV SCROLLKEEPER_DATADIR
10083: SCROLLKEEPER_REBUILDDB SCROLLKEEPER_UPDATEDB
10084: SDIST_PAWD SDL12_TYPE
10085: SERIAL_DEVICES SETGIDGAME
10086: SETGID_GAMES_PERMS SETUID_ROOT_PERMS
10087: SH SHAIRPORT_GROUP
10088: SHAIRPORT_USER SHLIB_EXT
10089: SHORTNAME SIGN_PACKAGES
10090: SILC_CLIENT_WITH_PERL SITE_SPECIFIC_PKGS
10091: SKIP_DEPENDS SMF_INSTANCES
10092: SMF_MANIFEST SMF_METHODS
10093: SMF_METHOD_SHELL SMF_METHOD_SRC
10094: SMF_NAME SMF_PREFIX
10095: SMF_SRCDIR SNIPROXY_GROUP
10096: SNIPROXY_USER SOURCE_BUFFSIZE
10097: SPECIAL_PERMS SPECIFIC_PKGS
10098: SSH_SUID SSLCERTBUNDLE
10099: SSLCERTS SSLDIR
10100: SSLKEYS SSP_SUPPORTED
10101: SSYNC_PAWD STEP_MSG
10102: STRIP STRIP_DBG
10103: STRIP_DEBUG STRIP_DEBUG_SUPPORTED
10104: STRIP_FILES_SKIP SU
10105: SUBDIR SUBST
10106: SUBST_CLASSES SUBST_FILES
10107: SUBST_FILTER_CMD SUBST_MESSAGE
10108: SUBST_NOOP_OK SUBST_SED
10109: SUBST_SHOW_DIFF SUBST_SKIP_TEXT_CHECK
10110: SUBST_STAGE SUBST_VARS
10111: SUNWSPROBASE SUSE_PREFER
10112: SU_CMD SVN_EXTRACTDIR
10113: SVN_REPO SVN_REPOSITORIES
10114: SVN_REVISION SYSCONFBASE
10115: TARGET_MACHINE_ARCH TBL
10116: TERMCAP_TYPE TERMINFO_DEFAULT
10117: TERMINFO_TYPE TEST
10118: TEST_DEPENDS TEST_DIRS
10119: TEST_ENV TEST_ENV_SHELL
10120: TEST_MAKE_CMD TEST_MAKE_FLAGS
10121: TEST_TARGET TEXLIVE_IGNORE_PATTERNS
10122: TEXLIVE_REV TEXLIVE_UNVERSIONED
10123: TEXMFSITE TEX_FORMATS
10124: TEX_HYPHEN_DAT TEX_HYPHEN_DEF
10125: TEX_TEXMF_DIRS THTTPD_LOG_FACILITY
10126: TINYDYN_USER TLS
10127: TLSWRAPPER_CHROOT TO
10128: TOOLDIR TOOLS_ALIASES
10129: TOOLS_ALWAYS_WRAP TOOLS_ARGS
10130: TOOLS_BROKEN TOOLS_CMD
10131: TOOLS_CMDLINE_SED TOOLS_CREATE
10132: TOOLS_CROSS_DESTDIR TOOLS_DIR
10133: TOOLS_FAIL TOOLS_GNU_MISSING
10134: TOOLS_LDCONFIG TOOLS_NOOP
10135: TOOLS_PATH TOOLS_SCRIPT
10136: TOOLS_USE_CROSS_COMPILE TOOL_DEPENDS
10137: TTF_FONTDIR TTF_FONTS_DIR
10138: TYPE UAC_REQD_EXECS
10139: UCSPI_SSL_GROUP UCSPI_SSL_USER
10140: UNBOUND_GROUP UNBOUND_LOG_FACILITY
10141: UNBOUND_USER UNLIMIT_RESOURCES
10142: UNPRIVILEGED UNPRIVILEGED_GROUP
10143: UNPRIVILEGED_GROUPS UNPRIVILEGED_USER
10144: UNWRAP_FILES UNWRAP_PATTERNS
10145: UPDATE_GEMSPEC UPDATE_TARGET
10146: URI USERGROUP_PHASE
10147: USERPPP_GROUP USER_SPECIFIC_PKGS
10148: USE_ABI_DEPENDS USE_ADA_FEATURES
10149: USE_APR USE_BSD_MAKEFILE
10150: USE_BUILTIN USE_CC_FEATURES
10151: USE_CROSS_COMPILE USE_CURSES
10152: USE_CWRAPPERS USE_CXX_FEATURES
10153: USE_DB185 USE_FEATURES
10154: USE_GAMESGROUP USE_GCC_RUNTIME
10155: USE_IMAKE USE_INDIRECT_DEPENDS
10156: USE_JAVA USE_JAVA2
10157: USE_LANGUAGES USE_LIBTOOL
10158: USE_NATIVE_GCC USE_NETBSD_REPO
10159: USE_PKGSRC_GCC USE_PKGSRC_GCC_RUNTIME
10160: USE_PKGTASKS USE_PKG_ADMIN_DIGEST
10161: USE_RUBY_EXTCONF USE_RUBY_INSTALL
10162: USE_RUBY_SETUP USE_RUBY_SETUP_PKG
10163: USE_TMPFILES USE_TOOLS
10164: UUCP_GROUP UUCP_USER
10165: VARBASE VARNAME
10166: VIM_EXTRA_OPTS WARNING_MSG
10167: WCALC_CGIDIR WCALC_CGIPATH
10168: WCALC_HTMLDIR WCALC_HTMLPATH
10169: WDM_MANAGERS WRAPPER_CC
10170: WRAPPER_REORDER_CMDS WRKDIR
10171: WRKDIR_BASENAME WRKDIR_LOCKTYPE
10172: WRKLOG WRKOBJDIR
10173: WRKSRC X10_PORT
10174: X11 X11BASE
10175: X11_PKGSRCDIR X11_TYPE
10176: X509_CERTIFICATE X509_KEY
10177: XAW_TYPE XLOCK_DEFAULT_MODE
10178: XMKMF XMKMF_FLAGS
10179: XXX XXXX
10180: YES ZSH_STATIC
10181: __stdc__ _vargroups
10182: accept acquire-localbase-lock
10183: acquire-lock add
10184: added administrator
10185: alloca alternatives
10186: aslr asprintf
10187: atlas autoconf
10188: automake autoreconf
10189: awk barrier
10190: bash big-endian
10191: bin-install bind
10192: binpkg-list blas
10193: bootstrap-depends broken
10194: broken_on_platform bsd
10195: bsd.prog.mk build
10196: build-env buildlink-directories
10197: buildlink-oss-soundcard-h built-in
10198: builtin c
10199: c++ ccache
10200: cce cdefs
10201: ceil changes
10202: changes-entry changes-entry-noupdate
10203: check check-clean
10204: check-files check-files-clean
10205: check-hackage check-vulnerable
10206: checksum checksum-phase
10207: clean clean-depends
10208: cleandir commit
10209: commit-changes-entry compact
10210: compiler conf
10211: config.guess config.sub
10212: configuration configure
10213: configure-env configure-help
10214: configure_args connect
10215: cos cpe
10216: cputime create-usergroup
10217: csh ctf
10218: cvs debug
10219: debug-barrier declaration
10220: declare defined
10221: depend dependencies
10222: depends depends-checksum
10223: depends-fetch describe
10224: destdir disable
10225: distclean distfiles
10226: distinfo dl
10227: dlopen do-buildlink
10228: do-clean do-configure
10229: do-configure-post-hook do-extract
10230: do-fetch do-install
10231: download emul
10232: emul-distinfo emul-fetch
10233: emulation emulator
10234: enable endian
10235: endif enomem
10236: ensurepip err
10237: errx etc
10238: exp extract-rpm
10239: fabs feature
10240: features fetch
10241: fetch-list follows
10242: forbids form
10243: format fortify
10244: fortify_source fossil
10245: friend fts
10246: fts_close fts_open
10247: fts_read fts_set
10248: gcc gethostbyaddr
10249: gethostbyname gethostbyname2
10250: getopt_long getprogname
10251: getservbyname getservbyport
10252: getservent gettext
10253: git github
10254: gitlab glob
10255: gnu gnu_configure_strict
10256: go golang
10257: guess-license hashbang
10258: heimdal help
10259: hg imake
10260: in-tree increment
10261: indirect inet_aton
10262: install install-env
10263: interp interpreter
10264: intl ip4
10265: ip6 ipv4
10266: ipv6 iso
10267: kerberos krb
10268: krb5 ksh
10269: lapack latex
10270: libiconv libintl_bindtextdomain
10271: libintl_gettext libintl_textdomain
10272: libnbcompat libs
10273: libtool licence
10274: license lintl
10275: little-endian lock
10276: locking lua
10277: lvalue machine_endian
10278: make makedistinfo
10279: makepatchsum makesum
10280: mdi memory
10281: mercurial meta
10282: meta-package meta_package
10283: mit-krb5 mk.conf
10284: mkl mount
10285: move moved
10286: mprotect mps
10287: mremap native
10288: nb nbcompat
10289: netlib network
10290: node node.js
10291: nodejs obstack
10292: obstack_ptr_grow occurs
10293: only openblas
10294: options options.mk
10295: order override
10296: override-intltool override-message-intltool
10297: package parallel
10298: path pax
10299: paxctl pbulk-index
10300: pc perl
10301: perl5 perms
10302: php pkg-build-options
10303: pkg-config pkg_build_options
10304: pkgsrc platform
10305: plist post-extract
10306: post-fetch post-wrapper
10307: pre-build-checks-hook pre-configure-checks-hook
10308: pre-extract pre-fetch
10309: print-plist print-summary-data
10310: privileged-install-hook pypi
10311: python r
10312: readme-all recursive
10313: recv recvfrom
10314: regcomp release-localbase-lock
10315: release-lock relro
10316: remove removed
10317: rename renamed
10318: reorder replace
10319: replace_interpreter reproducible
10320: resolv root
10321: ruby send
10322: sendfile sendto
10323: setenv setgid
10324: setprogname setuid
10325: sh shebang
10326: show show-all
10327: show-build-defs show-depends
10328: show-depends-dirs show-depends-pkgpaths
10329: show-depends-recursive show-deps
10330: show-distfiles show-downlevel
10331: show-subdir-var show-tools
10332: show-var show-vars
10333: snprintf socket
10334: ssp st_mode
10335: stage-install strcasestr
10336: strict strip
10337: strndup strnlen
10338: strsep subst
10339: substitutions subversion
10340: sun sunpro
10341: sunwspro svn
10342: symlink test
10343: test-env tex
10344: texlive tmp
10345: todo tool
10346: tools tools-libtool-m4-override
10347: transitive type
10348: ulimit undefined
10349: undo-replace unlimit
10350: unprivileged unprivileged-install-hook
10351: unstripped update
10352: updated upload
10353: upload-distfiles use_tools
10354: user utimes
10355: vasprintf verbose
10356: vsnprintf warn
10357: warning warnings
10358: warnx wattr_off
10359: wattr_on work
10360: wrapper wrkdir
1.154 rillig 10361:
1.266 martin 10362: Appendix F. Editing guidelines for the pkgsrc guide
1.1 dsieger 10363:
10364: Table of Contents
10365:
1.207 leot 10366: F.1. Make targets
10367: F.2. Procedure
1.1 dsieger 10368:
10369: This section contains information on editing the pkgsrc guide itself.
10370:
1.266 martin 10371: F.1. Make targets
1.1 dsieger 10372:
10373: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
10374: files are created from it:
10375:
10376: * pkgsrc/doc/pkgsrc.txt
10377:
10378: * pkgsrc/doc/pkgsrc.html
10379:
1.174 leot 10380: * https://www.NetBSD.org/docs/pkgsrc/
1.1 dsieger 10381:
1.174 leot 10382: * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the
10383: pkgsrc guide.
1.1 dsieger 10384:
1.174 leot 10385: * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
1.2 rillig 10386: pkgsrc guide.
1.1 dsieger 10387:
1.266 martin 10388: F.2. Procedure
1.1 dsieger 10389:
10390: The procedure to edit the pkgsrc guide is:
10391:
1.190 bacon 10392: 1. Make sure you have checked out the htdocs repository into a sibling
10393: directory of your pkgsrc directory. You will need the ability to commit
10394: from both pkgsrc and htdocs.
10395:
10396: 2. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46 obache 10397: other XML-based NetBSD documentation) installed. These are automatically
10398: installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1 dsieger 10399:
1.190 bacon 10400: 3. Run cd doc/guide to get to the right directory. All further steps will take
1.1 dsieger 10401: place here.
10402:
1.190 bacon 10403: 4. Edit the XML file(s) in files/.
1.1 dsieger 10404:
1.190 bacon 10405: 5. Run bmake to check the pkgsrc guide for valid XML and to build the final
1.1 dsieger 10406: output files. If you get any errors at this stage, you can just edit the
10407: files, as there are only symbolic links in the working directory, pointing
10408: to the files in files/.
10409:
1.190 bacon 10410: 6. (cd files && cvs commit)
1.1 dsieger 10411:
1.190 bacon 10412: 7. Run bmake clean && bmake to regenerate the output files with the proper RCS
1.1 dsieger 10413: Ids.
10414:
1.190 bacon 10415: 8. Run bmake regen to install and commit the files in both pkgsrc/doc and
1.1 dsieger 10416: htdocs.
10417:
10418: Note
10419:
10420: If you have added, removed or renamed some chapters, you need to
10421: synchronize them using cvs add or cvs delete in the htdocs directory.
10422:
CVSweb <webmaster@jp.NetBSD.org>