Annotation of htdocs/docs/pkgsrc/pkgsrc.txt, revision 1.276
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.276 ! wiz 81: 8.2. Running a pbulk build
1.154 rillig 82: 8.2.1. Configuration
1.276 ! wiz 83: 8.3. Running a bob build
! 84: 8.4. Speeding up bulk build scans
! 85: 8.5. Requirements of a full bulk build
! 86: 8.6. Bulk build variants
! 87: 8.6.1. Detect unknown configure options
! 88: 8.6.2. Detect classes of bugs by forcing compiler warnings
! 89: 8.6.3. Force compiler options only in the build phase
! 90: 8.6.4. Use custom directories
! 91: 8.6.5. Turn warnings into errors
! 92: 8.6.6. Reject packages for which pkglint reports errors
! 93: 8.6.7. Reject packages that contain forbidden strings
! 94: 8.6.8. Reject packages whose self-test fails
! 95: 8.6.9. Reject packages that use undefined shell variables
! 96: 8.6.10. Turn off verbose logging
! 97: 8.7. Creating a multiple CD-ROM packages collection
! 98: 8.7.1. Example of cdpack
1.154 rillig 99: 9. Directory layout of the installed files
100: 9.1. File system layout in ${LOCALBASE}
101: 9.2. File system layout in ${VARBASE}
102: 10. Frequently Asked Questions
103: 10.1. Are there any mailing lists for pkg-related discussion?
104: 10.2. Utilities for package management (pkgtools)
105: 10.3. How to use pkgsrc as non-root
106: 10.4. How to resume transfers when fetching distfiles?
107: 10.5. How can I install/use modular X.org from pkgsrc?
108: 10.6. How to fetch files from behind a firewall
109: 10.7. How to fetch files from HTTPS sites
110: 10.8. How do I tell make fetch to do passive FTP?
111: 10.9. How to fetch all distfiles at once
1.266 martin 112: 10.10. What does Don't know how to make /usr/share/tmac/tmac.andoc
1.271 wiz 113: mean?
1.266 martin 114: 10.11. What does Could not find bsd.own.mk mean?
1.221 nia 115: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154 rillig 116: 10.13. How do I change the location of configuration files?
117: 10.14. Automated security checks
118: 10.15. Why do some packages ignore my CFLAGS?
119: 10.16. A package does not build. What shall I do?
1.266 martin 120: 10.17. What does Makefile appears to contain unresolved cvs/rcs/???
1.271 wiz 121: merge conflicts mean?
1.1 dsieger 122: II. The pkgsrc developer's guide
1.154 rillig 123: 11. Getting help
1.184 rillig 124: 12. Package components - files, directories and contents
125: 12.1. Makefile
126: 12.2. distinfo
127: 12.3. patches/*
128: 12.3.1. Structure of a single patch file
129: 12.3.2. Creating patch files
130: 12.3.3. Sources where the patch files come from
131: 12.3.4. Patching guidelines
132: 12.3.5. Feedback to the author
133: 12.4. Other mandatory files
134: 12.5. Optional files
135: 12.5.1. Files affecting the binary package
136: 12.5.2. Files affecting the build process
137: 12.5.3. Files affecting nothing at all
138: 12.6. work*
139: 12.7. files/*
140: 13. The build process
141: 13.1. Introduction
142: 13.2. Program location
143: 13.3. Directories used during the build process
144: 13.4. Running a phase
145: 13.5. The fetch phase
146: 13.5.1. What to fetch and where to get it from
147: 13.5.2. How are the files fetched?
148: 13.6. The checksum phase
149: 13.7. The extract phase
150: 13.8. The patch phase
151: 13.9. The tools phase
152: 13.10. The wrapper phase
153: 13.11. The configure phase
154: 13.12. The build phase
155: 13.13. The test phase
156: 13.14. The install phase
157: 13.15. The package phase
158: 13.16. Cleaning up
159: 13.17. Other helpful targets
160: 14. Creating a new pkgsrc package from scratch
161: 14.1. Common types of packages
1.219 nia 162: 14.1.1. Python modules and programs
163: 14.1.2. R packages
164: 14.1.3. TeXlive packages
1.184 rillig 165: 14.2. Examples
166: 14.2.1. How the www/nvu package came into pkgsrc
167: 15. Programming in Makefiles
168: 15.1. Caveats
169: 15.2. Makefile variables
170: 15.2.1. Naming conventions
171: 15.3. Code snippets
172: 15.3.1. Adding things to a list
173: 15.3.2. Echoing a string exactly as-is
174: 15.3.3. Passing CFLAGS to GNU configure scripts
175: 15.3.4. Handling possibly empty variables
1.229 gutterid 176: 15.3.5. Testing yes/no variables in conditions
1.184 rillig 177: 16. Options handling
178: 16.1. Global default options
179: 16.2. Converting packages to use bsd.options.mk
180: 16.3. Option Names
181: 16.4. Determining the options of dependencies
182: 17. Tools needed for building or running
183: 17.1. Tools for pkgsrc builds
184: 17.2. Tools needed by packages
185: 17.3. Tools provided by platforms
186: 18. Buildlink methodology
187: 18.1. Converting packages to use buildlink3
188: 18.2. Writing buildlink3.mk files
189: 18.2.1. Anatomy of a buildlink3.mk file
190: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
1.271 wiz 191: BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.184 rillig 192: 18.3. Writing builtin.mk files
193: 18.3.1. Anatomy of a builtin.mk file
194: 19. PLIST issues
195: 19.1. RCS ID
196: 19.2. Semi-automatic PLIST generation
197: 19.3. Tweaking output of make print-PLIST
198: 19.4. Variable substitution in PLIST
199: 19.5. Man page compression
200: 19.6. Changing PLIST source with PLIST_SRC
201: 19.7. Platform-specific and differing PLISTs
202: 19.8. Build-specific PLISTs
203: 19.9. Sharing directories between packages
204: 20. The pkginstall framework
205: 20.1. Files and directories outside the installation prefix
206: 20.1.1. Directory manipulation
207: 20.1.2. File manipulation
208: 20.2. Configuration files
209: 20.2.1. How PKG_SYSCONFDIR is set
210: 20.2.2. Telling the software where configuration files are
1.239 dholland 211: 20.2.3. Patching installation
212: 20.2.4. Declaring configuration files
213: 20.2.5. Disabling handling of configuration files
1.184 rillig 214: 20.3. System startup scripts
215: 20.3.1. Disabling handling of system startup scripts
216: 20.4. System users and groups
217: 20.5. System shells
218: 20.5.1. Disabling shell registration
219: 20.6. Fonts
220: 20.6.1. Disabling automatic update of the fonts databases
1.154 rillig 221: 21. Making your package work
222: 21.1. General operation
223: 21.1.1. How to pull in user-settable variables from mk.conf
224: 21.1.2. User interaction
225: 21.1.3. Handling licenses
226: 21.1.4. Restricted packages
227: 21.1.5. Handling dependencies
228: 21.1.6. Handling conflicts with other packages
229: 21.1.7. Packages that cannot or should not be built
230: 21.1.8. Packages which should not be deleted, once installed
231: 21.1.9. Handling packages with security problems
232: 21.1.10. How to handle incrementing versions when fixing an
1.271 wiz 233: existing package
1.154 rillig 234: 21.1.11. Substituting variable text in the package files (the SUBST
1.271 wiz 235: framework)
1.154 rillig 236: 21.2. The fetch phase
237: 21.2.1. Packages whose distfiles aren't available for plain
1.271 wiz 238: downloading
1.154 rillig 239: 21.2.2. How to handle modified distfiles with the 'old' name
240: 21.2.3. Packages hosted on github.com
241: 21.3. The configure phase
242: 21.3.1. Shared libraries - libtool
243: 21.3.2. Using libtool on GNU packages that already support libtool
244: 21.3.3. GNU Autoconf/Automake
1.223 nia 245: 21.3.4. Meson / ninja
1.260 wiz 246: 21.3.5. Determining the endianness
1.154 rillig 247: 21.4. Programming languages
248: 21.4.1. C, C++, and Fortran
249: 21.4.2. Java
1.205 wiz 250: 21.4.3. Go
1.223 nia 251: 21.4.4. Rust
252: 21.4.5. Packages containing Perl scripts
253: 21.4.6. Packages containing shell scripts
254: 21.4.7. Other programming languages
1.154 rillig 255: 21.5. The build phase
256: 21.5.1. Compiling C and C++ code conditionally
257: 21.5.2. How to handle compiler bugs
1.172 rillig 258: 21.5.3. No such file or directory
1.266 martin 259: 21.5.4. Undefined reference to ...
1.172 rillig 260: 21.5.5. Running out of memory
1.154 rillig 261: 21.6. The install phase
262: 21.6.1. Creating needed directories
263: 21.6.2. Where to install documentation
264: 21.6.3. Installing highscore files
265: 21.6.4. Adding DESTDIR support to packages
266: 21.6.5. Packages with hardcoded paths to other interpreters
1.203 nia 267: 21.6.6. Packages installing Perl modules
1.254 wiz 268: 21.6.7. Packages installing pkg-config files
269: 21.6.8. Packages installing info files
270: 21.6.9. Packages installing man pages
271: 21.6.10. Packages installing X11 fonts
272: 21.6.11. Packages installing SGML or XML data
273: 21.6.12. Packages installing extensions to the MIME database
274: 21.6.13. Packages using intltool
275: 21.6.14. Packages installing startup scripts
276: 21.6.15. Packages installing TeX modules
277: 21.6.16. Packages supporting running binaries in emulation
278: 21.6.17. Packages installing hicolor icons
279: 21.6.18. Packages installing desktop files
1.154 rillig 280: 21.7. Marking packages as having problems
1.184 rillig 281: 22. GNOME packaging and porting
282: 22.1. Meta packages
283: 22.2. Packaging a GNOME application
284: 22.3. Updating GNOME to a newer version
285: 22.4. Patching guidelines
1.154 rillig 286: 23. Submitting and Committing
287: 23.1. Submitting binary packages
288: 23.2. Submitting source packages (for non-NetBSD-developers)
289: 23.3. General notes when adding, updating, or removing packages
290: 23.4. Commit Messages
291: 23.5. Committing: Adding a package to CVS
292: 23.6. Updating a package to a newer version
293: 23.7. Renaming a package in pkgsrc
294: 23.8. Moving a package in pkgsrc
1.263 wiz 295: 24. pkgsrc Policies
296: 24.1. Packages for which updating is restricted
297: 24.1.1. Limited Updates - ABI
298: 24.1.2. Limited Updates - Bootstrap
299: 25. Frequently Asked Questions
1.1 dsieger 300: III. The pkgsrc infrastructure internals
1.263 wiz 301: 26. Design of the pkgsrc infrastructure
302: 26.1. The meaning of variable definitions
303: 26.2. Avoiding problems before they arise
304: 26.3. Variable evaluation
305: 26.3.1. At load time
306: 26.3.2. At runtime
307: 26.4. How can variables be specified?
308: 26.5. Designing interfaces for Makefile fragments
309: 26.5.1. Procedures with parameters
310: 26.5.2. Actions taken on behalf of parameters
311: 26.6. The order in which files are loaded
312: 26.6.1. The order in bsd.prefs.mk
313: 26.6.2. The order in bsd.pkg.mk
314: 27. Regression tests
315: 27.1. Running the regression tests
316: 27.2. Adding a new regression test
317: 27.2.1. Overridable functions
318: 27.2.2. Helper functions
319: 28. Porting pkgsrc
320: 28.1. Porting pkgsrc to a new operating system
1.1 dsieger 321: A. A simple example package: bison
322: A.1. files
323: A.1.1. Makefile
324: A.1.2. DESCR
325: A.1.3. PLIST
326: A.1.4. Checking a package with pkglint
327: A.2. Steps for building, installing, packaging
1.207 leot 328: B. Security hardening
329: B.1. Mechanisms
330: B.1.1. Enabled by default
331: B.1.2. Not enabled by default
332: B.2. Caveats
333: B.2.1. Problems with PKGSRC_MKPIE
334: B.2.2. Problems with PKGSRC_USE_FORTIFY
335: B.2.3. Problems with PKGSRC_USE_RELRO
336: B.2.4. Problems with PKGSRC_USE_SSP
337: B.3. Auditing the system
338: B.3.1. Checking for PIE
339: B.3.2. Checking for partial RELRO
340: B.3.3. Checking for full RELRO
341: B.3.4. Checking for SSP
342: C. Build logs
343: C.1. Building figlet
344: C.2. Packaging figlet
345: D. Directory layout of the pkgsrc FTP server
346: D.1. distfiles: The distributed source files
347: D.2. misc: Miscellaneous things
348: D.3. packages: Binary packages
349: D.4. reports: Bulk build reports
350: D.5. current, stable, pkgsrc-20xxQy: source packages
351: E. Help topics
352: F. Editing guidelines for the pkgsrc guide
353: F.1. Make targets
354: F.2. Procedure
1.1 dsieger 355:
356: List of Tables
357:
358: 1.1. Platforms supported by pkgsrc
1.184 rillig 359: 12.1. Patching examples
360: 22.1. PLIST handling for GNOME packages
1.1 dsieger 361:
1.266 martin 362: Chapter 1. What is pkgsrc?
1.1 dsieger 363:
364: Table of Contents
365:
366: 1.1. Introduction
367: 1.1.1. Why pkgsrc?
368: 1.1.2. Supported platforms
369: 1.2. Overview
370: 1.3. Terminology
371: 1.3.1. Roles involved in pkgsrc
372: 1.4. Typography
373:
1.266 martin 374: 1.1. Introduction
1.1 dsieger 375:
376: There is a lot of software freely available for Unix-based systems, which is
377: usually available in form of the source code. Before such software can be used,
378: it needs to be configured to the local system, compiled and installed, and this
379: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
380: some basic commands to handle binary packages, so that not every user has to
381: build the packages for himself, which is a time-costly task.
382:
383: pkgsrc currently contains several thousand packages, including:
384:
1.104 sevan 385: * www/apache24 - The Apache web server
1.1 dsieger 386:
387: * www/firefox - The Firefox web browser
388:
389: * meta-pkgs/gnome - The GNOME Desktop Environment
390:
1.102 ryoon 391: * meta-pkgs/kde4 - The K Desktop Environment
1.1 dsieger 392:
1.266 martin 393: just to name a few.
1.1 dsieger 394:
395: pkgsrc has built-in support for handling varying dependencies, such as pthreads
396: and X11, and extended features such as IPv6 support on a range of platforms.
397:
1.266 martin 398: 1.1.1. Why pkgsrc?
1.1 dsieger 399:
400: pkgsrc provides the following key features:
401:
402: * Easy building of software from source as well as the creation and
403: installation of binary packages. The source and latest patches are
404: retrieved from a master or mirror download site, checksum verified, then
405: built on your system. Support for binary-only distributions is available
406: for both native platforms and NetBSD emulated platforms.
407:
408: * All packages are installed in a consistent directory tree, including
409: binaries, libraries, man pages and other documentation.
410:
1.104 sevan 411: * Tracking of package dependencies automatically, including when performing
412: updates, to ensure required packages are installed. The configuration files
413: of various packages are handled automatically during updates, so local
414: changes are preserved.
1.1 dsieger 415:
416: * Like NetBSD, pkgsrc is designed with portability in mind and consists of
417: highly portable code. This allows the greatest speed of development when
1.26 spz 418: porting to a new platform. This portability also ensures that pkgsrc is
1.1 dsieger 419: consistent across all platforms.
420:
421: * The installation prefix, acceptable software licenses, international
422: encryption requirements and build-time options for a large number of
423: packages are all set in a simple, central configuration file.
424:
425: * The entire source (not including the distribution files) is freely
426: available under a BSD license, so you may extend and adapt pkgsrc to your
427: needs. Support for local packages and patches is available right out of the
428: box, so you can configure it specifically for your environment.
429:
430: The following principles are basic to pkgsrc:
431:
1.266 martin 432: * It should only work if it's right. That means, if a package contains
1.1 dsieger 433: bugs, it's better to find them and to complain about them rather than to
434: just install the package and hope that it works. There are numerous checks
1.175 gutterid 435: in pkgsrc that try to find such bugs: static analysis tools (pkgtools/
1.1 dsieger 436: pkglint), build-time checks (portability of shell scripts), and
437: post-installation checks (installed files, references to shared libraries,
438: script interpreters).
439:
1.266 martin 440: * If it works, it should work everywhere Like NetBSD has been ported to
1.1 dsieger 441: many hardware architectures, pkgsrc has been ported to many operating
442: systems. Care is taken that packages behave the same on all platforms.
443:
1.266 martin 444: 1.1.2. Supported platforms
1.1 dsieger 445:
446: pkgsrc consists of both a source distribution and a binary distribution for
447: these operating systems. After retrieving the required source or binaries, you
448: can be up and running with pkgsrc in just minutes!
449:
450: pkgsrc was derived from FreeBSD's ports system, and initially developed for
451: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
452: platforms:
453:
1.266 martin 454: Table 1.1. Platforms supported by pkgsrc
1.1 dsieger 455:
1.92 sevan 456: +-----------------------------------------------------------------------------+
1.229 gutterid 457: | Platform | Date Support | Notes |
458: | | Added | |
459: |-------------------------------------+---------------+-----------------------|
1.266 martin 460: |NetBSD | Aug 1997 | |
1.229 gutterid 461: |-------------------------------------+---------------+-----------------------|
462: |Solaris | Mar 1999 |README.Solaris |
463: |-------------------------------------+---------------+-----------------------|
464: |Linux | Jun 1999 |README.Linux |
465: |-------------------------------------+---------------+-----------------------|
466: |Darwin / Mac OS X / OS X / macOS | Oct 2001 |README.macOS |
467: |-------------------------------------+---------------+-----------------------|
468: |FreeBSD | Nov 2002 |README.FreeBSD |
469: |-------------------------------------+---------------+-----------------------|
470: |OpenBSD | Nov 2002 |README.OpenBSD |
471: |-------------------------------------+---------------+-----------------------|
472: |IRIX | Dec 2002 |README.IRIX |
473: |-------------------------------------+---------------+-----------------------|
1.262 dholland 474: |BSD/OS | Dec 2003 |Removed from pkgsrc Mar|
475: | | | 2025 |
1.229 gutterid 476: |-------------------------------------+---------------+-----------------------|
477: |AIX | Dec 2003 |README.AIX |
478: |-------------------------------------+---------------+-----------------------|
1.264 wiz 479: |Interix (Microsoft Windows Services | Mar 2004 |Removed from pkgsrc Apr|
480: |for Unix) | | 2025 |
1.229 gutterid 481: |-------------------------------------+---------------+-----------------------|
1.266 martin 482: |DragonFlyBSD | Oct 2004 | |
1.229 gutterid 483: |-------------------------------------+---------------+-----------------------|
484: |OSF/1 | Nov 2004 |README.OSF1 |
485: |-------------------------------------+---------------+-----------------------|
486: |HP-UX | Apr 2007 |README.HPUX |
487: |-------------------------------------+---------------+-----------------------|
488: |Haiku | Sep 2010 |README.Haiku |
489: |-------------------------------------+---------------+-----------------------|
1.262 dholland 490: |MirBSD | Jan 2011 |Removed from pkgsrc Mar|
491: | | | 2025 |
1.229 gutterid 492: |-------------------------------------+---------------+-----------------------|
493: |Minix3 | Nov 2011 |README.Minix3 |
494: |-------------------------------------+---------------+-----------------------|
495: |Cygwin | Mar 2013 |README.Cygwin |
496: |-------------------------------------+---------------+-----------------------|
1.261 maya 497: |GNU/kFreeBSD | Jul 2013 |Removed from pkgsrc Mar|
498: | | |2025 |
1.229 gutterid 499: |-------------------------------------+---------------+-----------------------|
500: |Bitrig | Jun 2014 |Removed from pkgsrc Sep|
501: | | |2022 |
1.92 sevan 502: +-----------------------------------------------------------------------------+
1.1 dsieger 503:
504:
1.266 martin 505: 1.2. Overview
1.1 dsieger 506:
507: This document is divided into three parts. The first, The pkgsrc user's guide,
508: describes how one can use one of the packages in the Package Collection, either
509: by installing a precompiled binary package, or by building one's own copy using
510: the NetBSD package system. The second part, The pkgsrc developer's guide,
511: explains how to prepare a package so it can be easily built by other NetBSD
512: users without knowing about the package's building details. The third part, The
513: pkgsrc infrastructure internals is intended for those who want to understand
514: how pkgsrc is implemented.
515:
516: This document is available in various formats: HTML, PDF, PS, TXT.
517:
1.266 martin 518: 1.3. Terminology
1.1 dsieger 519:
1.266 martin 520: There has been a lot of talk about ports , packages , etc. so far. Here is a
1.1 dsieger 521: description of all the terminology used within this document.
522:
523: Package
524:
525: A set of files and building instructions that describe what's necessary to
526: build a certain piece of software using pkgsrc. Packages are traditionally
1.123 wiz 527: stored under /usr/pkgsrc, but may be stored in any location, referred to as
528: PKGSRCDIR.
1.1 dsieger 529:
530: The NetBSD package system
531:
1.266 martin 532: This is the former name of pkgsrc . It is part of the NetBSD operating
1.1 dsieger 533: system and can be bootstrapped to run on non-NetBSD operating systems as
534: well. It handles building (compiling), installing, and removing of
535: packages.
536:
537: Distfile
538:
539: This term describes the file or files that are provided by the author of
540: the piece of software to distribute his work. All the changes necessary to
541: build on NetBSD are reflected in the corresponding package. Usually the
542: distfile is in the form of a compressed tar-archive, but other types are
543: possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
544:
545: Port
546:
547: This is the term used by FreeBSD and OpenBSD people for what we call a
1.266 martin 548: package. In NetBSD terminology, port refers to a different architecture.
1.1 dsieger 549:
550: Precompiled/binary package
551:
552: A set of binaries built with pkgsrc from a distfile and stuffed together in
553: a single .tgz file so it can be installed on machines of the same machine
554: architecture without the need to recompile. Packages are usually generated
555: in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
556:
1.266 martin 557: Sometimes, this is referred to by the term package too, especially in the
1.1 dsieger 558: context of precompiled packages.
559:
560: Program
561:
562: The piece of software to be installed which will be constructed from all
563: the files in the distfile by the actions defined in the corresponding
564: package.
565:
1.266 martin 566: 1.3.1. Roles involved in pkgsrc
1.1 dsieger 567:
568: pkgsrc users
569:
570: The pkgsrc users are people who use the packages provided by pkgsrc.
571: Typically they are system administrators. The people using the software
1.266 martin 572: that is inside the packages (maybe called end users ) are not covered by
1.1 dsieger 573: the pkgsrc guide.
574:
575: There are two kinds of pkgsrc users: Some only want to install pre-built
576: binary packages. Others build the pkgsrc packages from source, either for
577: installing them directly or for building binary packages themselves. For
1.266 martin 578: pkgsrc users Part I, The pkgsrc user's guide should provide all necessary
1.1 dsieger 579: documentation.
580:
581: package maintainers
582:
1.266 martin 583: A package maintainer creates packages as described in Part II, The pkgsrc
584: developer's guide .
1.1 dsieger 585:
586: infrastructure developers
587:
588: These people are involved in all those files that live in the mk/ directory
1.266 martin 589: and below. Only these people should need to read through Part III, The
590: pkgsrc infrastructure internals , though others might be curious, too.
1.1 dsieger 591:
1.266 martin 592: 1.4. Typography
1.1 dsieger 593:
594: When giving examples for commands, shell prompts are used to show if the
1.266 martin 595: command should/can be issued as root, or if normal user privileges are
1.115 sevan 596: sufficient. We use a # for root's shell prompt, a % for users' shell prompt,
1.229 gutterid 597: assuming they use the C-shell or tcsh and a $ for Bourne shell and derivatives.
1.1 dsieger 598:
1.266 martin 599: Part I. The pkgsrc user's guide
1.1 dsieger 600:
601: Table of Contents
602:
1.154 rillig 603: 2. Getting help
604: 3. Where to get pkgsrc and how to keep it up-to-date
605: 3.1. Getting pkgsrc for the first time
606: 3.1.1. As tar archive
607: 3.1.2. Via anonymous CVS
608: 3.2. Keeping pkgsrc up-to-date
609: 3.2.1. Via tar files
610: 3.2.2. Via CVS
611: 4. Using pkgsrc on systems other than NetBSD
612: 4.1. Binary distribution
613: 4.2. Bootstrapping pkgsrc
614: 5. Using pkgsrc
615: 5.1. Using binary packages
616: 5.1.1. Finding binary packages
617: 5.1.2. Installing binary packages
1.202 nia 618: 5.1.3. Updating packages
619: 5.1.4. Deinstalling packages
620: 5.1.5. Getting information about installed packages
621: 5.1.6. Checking for security vulnerabilities in installed packages
622: 5.1.7. Finding if newer versions of your installed packages are in
1.271 wiz 623: pkgsrc
1.202 nia 624: 5.1.8. Other administrative functions
1.154 rillig 625: 5.2. Building packages from source
626: 5.2.1. Requirements
627: 5.2.2. Fetching distfiles
628: 5.2.3. How to build and install
629: 6. Configuring pkgsrc
630: 6.1. General configuration
631: 6.2. Variables affecting the build process
1.241 rillig 632: 6.3. Preferences for native or pkgsrc software
633: 6.4. Variables affecting the installation process
634: 6.5. Selecting and configuring the compiler
635: 6.5.1. Selecting the compiler
636: 6.5.2. Additional flags to the compiler (CFLAGS)
637: 6.5.3. Additional flags to the linker (LDFLAGS)
638: 6.6. Developer/advanced settings
639: 6.7. Selecting Build Options
1.154 rillig 640: 7. Creating binary packages
641: 7.1. Building a single binary package
642: 7.2. Settings for creation of binary packages
643: 8. Creating binary packages for everything in pkgsrc (bulk builds)
644: 8.1. Preparations
1.276 ! wiz 645: 8.2. Running a pbulk build
1.154 rillig 646: 8.2.1. Configuration
1.276 ! wiz 647: 8.3. Running a bob build
! 648: 8.4. Speeding up bulk build scans
! 649: 8.5. Requirements of a full bulk build
! 650: 8.6. Bulk build variants
! 651: 8.6.1. Detect unknown configure options
! 652: 8.6.2. Detect classes of bugs by forcing compiler warnings
! 653: 8.6.3. Force compiler options only in the build phase
! 654: 8.6.4. Use custom directories
! 655: 8.6.5. Turn warnings into errors
! 656: 8.6.6. Reject packages for which pkglint reports errors
! 657: 8.6.7. Reject packages that contain forbidden strings
! 658: 8.6.8. Reject packages whose self-test fails
! 659: 8.6.9. Reject packages that use undefined shell variables
! 660: 8.6.10. Turn off verbose logging
! 661: 8.7. Creating a multiple CD-ROM packages collection
! 662: 8.7.1. Example of cdpack
1.154 rillig 663: 9. Directory layout of the installed files
664: 9.1. File system layout in ${LOCALBASE}
665: 9.2. File system layout in ${VARBASE}
666: 10. Frequently Asked Questions
667: 10.1. Are there any mailing lists for pkg-related discussion?
668: 10.2. Utilities for package management (pkgtools)
669: 10.3. How to use pkgsrc as non-root
670: 10.4. How to resume transfers when fetching distfiles?
671: 10.5. How can I install/use modular X.org from pkgsrc?
672: 10.6. How to fetch files from behind a firewall
673: 10.7. How to fetch files from HTTPS sites
674: 10.8. How do I tell make fetch to do passive FTP?
675: 10.9. How to fetch all distfiles at once
1.266 martin 676: 10.10. What does Don't know how to make /usr/share/tmac/tmac.andoc mean?
677: 10.11. What does Could not find bsd.own.mk mean?
1.221 nia 678: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154 rillig 679: 10.13. How do I change the location of configuration files?
680: 10.14. Automated security checks
681: 10.15. Why do some packages ignore my CFLAGS?
682: 10.16. A package does not build. What shall I do?
1.266 martin 683: 10.17. What does Makefile appears to contain unresolved cvs/rcs/??? merge
1.271 wiz 684: conflicts mean?
1.1 dsieger 685:
1.266 martin 686: Chapter 2. Getting help
1.154 rillig 687:
688: To get help when using pkgsrc, the definitive source is this document, the
689: pkgsrc guide. If you don't find anything here, there are alternatives:
690:
691: * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
1.266 martin 692: Run bmake help topic= to get help for any topic, such as a variable name
1.154 rillig 693: like BUILD_DEFS, a make target like do-build, a missing C or C++ function
694: like strcasecmp or any other topic.
695:
1.266 martin 696: The available help topics are listed in Appendix E, Help topics.
1.154 rillig 697:
1.163 rillig 698: * To see the value of a single variable, run bmake show-var VARNAME=X.
699:
700: * To see the values of the most common variables, run bmake show-all. These
701: variables are grouped by topic. To see the variables for a single topic,
702: run bmake show-all-topic, for example bmake show-all-fetch.
703:
1.154 rillig 704: * The pkgsrc-users mailing list, to which you can subscribe and then ask your
705: questions.
706:
707: * The #pkgsrc IRC channel, which is accessible via a web browser or by using
708: a specialized chat program such as XChat. Pick any user name and join the
709: channel #pkgsrc.
710:
1.266 martin 711: Chapter 3. Where to get pkgsrc and how to keep it up-to-date
1.1 dsieger 712:
713: Table of Contents
714:
1.154 rillig 715: 3.1. Getting pkgsrc for the first time
716: 3.1.1. As tar archive
717: 3.1.2. Via anonymous CVS
718: 3.2. Keeping pkgsrc up-to-date
719: 3.2.1. Via tar files
720: 3.2.2. Via CVS
1.1 dsieger 721:
722: Before you download and extract the files, you need to decide where you want to
723: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
724: usr/pkgsrc. You are though free to install the sources and binary packages
725: wherever you want in your filesystem, provided that the pathname does not
726: contain white-space or other characters that are interpreted specially by the
727: shell and some other programs. A safe bet is to use only letters, digits,
728: underscores and dashes.
729:
1.266 martin 730: 3.1. Getting pkgsrc for the first time
1.1 dsieger 731:
1.25 wiz 732: Before you download any pkgsrc files, you should decide whether you want the
1.1 dsieger 733: current branch or the stable branch. The latter is forked on a quarterly basis
734: from the current branch and only gets modified for security updates. The names
735: of the stable branches are built from the year and the quarter, for example
1.267 leot 736: 2025Q4.
1.1 dsieger 737:
738: The second step is to decide how you want to download pkgsrc. You can get it as
1.24 wiz 739: a tar file or via CVS. Both ways are described here.
1.1 dsieger 740:
1.52 asau 741: Note that tar archive contains CVS working copy. Thus you can switch to using
742: CVS at any later time.
1.1 dsieger 743:
1.266 martin 744: 3.1.1. As tar archive
1.52 asau 745:
1.151 sevan 746: The primary download location for all pkgsrc files is https://cdn.NetBSD.org/
747: pub/pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same
748: location). There are a number of subdirectories for different purposes, which
1.266 martin 749: are described in detail in Appendix D, Directory layout of the pkgsrc FTP
1.151 sevan 750: server.
1.1 dsieger 751:
1.52 asau 752: The tar archive for the current branch is in the directory current and is
1.118 sevan 753: called pkgsrc.tar.gz. It is autogenerated weekly.
1.52 asau 754:
755: To save download time we provide bzip2- and xz-compressed archives which are
756: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
757:
758: You can fetch the same files using FTP.
1.1 dsieger 759:
1.267 leot 760: The tar file for the stable branch 2025Q4 is in the directory pkgsrc-2025Q4 and
1.59 jnemeth 761: is also called pkgsrc.tar.gz.
1.1 dsieger 762:
1.136 leot 763: To download the latest pkgsrc stable tarball, run:
1.12 weinem 764:
1.267 leot 765: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2025Q4/pkgsrc.tar.gz
1.12 weinem 766:
1.78 snj 767: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52 asau 768:
1.12 weinem 769: Then, extract it with:
770:
1.78 snj 771: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12 weinem 772:
773: This will create the directory pkgsrc/ in /usr/ and all the package source will
774: be stored under /usr/pkgsrc/.
775:
776: To download pkgsrc-current, run:
777:
778: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1 dsieger 779:
1.266 martin 780: 3.1.2. Via anonymous CVS
1.1 dsieger 781:
1.24 wiz 782: To fetch a specific pkgsrc stable branch, run:
1.1 dsieger 783:
1.267 leot 784: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2025Q4 -P pkgsrc
1.13 weinem 785:
1.24 wiz 786: This will create the directory pkgsrc/ in your /usr/ directory and all the
787: package source will be stored under /usr/pkgsrc/.
788:
789: To fetch the pkgsrc current branch, run:
1.1 dsieger 790:
1.40 wiz 791: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 792:
1.30 dholland 793: Refer to the list of available mirrors to choose a faster CVS mirror, if
794: needed.
1.1 dsieger 795:
1.24 wiz 796: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1 dsieger 797:
1.40 wiz 798: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 799:
1.24 wiz 800: Refer to documentation on your command shell how to set CVS_RSH=ssh
801: permanently. For Bourne shells, you can set it in your .profile or better
802: globally in /etc/profile:
803:
804: # set CVS remote shell command
805: CVS_RSH=ssh
806: export CVS_RSH
1.12 weinem 807:
1.13 weinem 808: By default, CVS doesn't do things like most people would expect it to do. But
809: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12 weinem 810: directory and saving the following lines to it. This file will save you lots of
811: headache and some bug reports, so we strongly recommend it. You can find an
812: explanation of this file in the CVS documentation.
1.2 rillig 813:
814: # recommended CVS configuration file from the pkgsrc guide
1.155 sevan 815: cvs -q
1.2 rillig 816: checkout -P
1.4 rillig 817: update -dP
818: diff -upN
1.2 rillig 819: rdiff -u
1.24 wiz 820: release -d
1.1 dsieger 821:
1.266 martin 822: 3.2. Keeping pkgsrc up-to-date
1.1 dsieger 823:
824: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
825: have first installed it via a tar file). It saves bandwidth and hard disk
826: activity, compared to downloading the tar file again.
827:
1.266 martin 828: 3.2.1. Via tar files
1.1 dsieger 829:
830: Warning
831:
832: When updating from a tar file, you first need to completely remove the old
833: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
834: the mean time will not be removed on your local disk, resulting in
835: inconsistencies. When removing the old files, any changes that you have done to
836: the pkgsrc files will be lost after updating. Therefore updating via CVS is
837: strongly recommended.
838:
839: Note that by default the distfiles and the binary packages are saved in the
840: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78 snj 841: configure pkgsrc to store distfiles and packages in directories outside the
1.266 martin 842: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter 6,
1.78 snj 843: Configuring pkgsrc for the details.
1.1 dsieger 844:
845: To update pkgsrc from a tar file, download the tar file as explained above.
846: Then, make sure that you have not made any changes to the files in the pkgsrc
847: directory. Remove the pkgsrc directory and extract the new tar file. Done.
848:
1.266 martin 849: 3.2.2. Via CVS
1.1 dsieger 850:
1.26 spz 851: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12 weinem 852:
1.26 spz 853: $ cd /usr/pkgsrc && cvs update -dP
854:
855: If you get error messages from rsh, you need to set CVS_RSH variable as
856: described above. E.g.:
857:
858: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1 dsieger 859:
1.266 martin 860: 3.2.2.1. Switching between different pkgsrc branches
1.1 dsieger 861:
862: When updating pkgsrc, the CVS program keeps track of the branch you selected.
863: But if you, for whatever reason, want to switch from the stable branch to the
1.266 martin 864: current one, you can do it by adding the option -A after the update
865: keyword. To switch from the current branch back to the stable branch, add the
1.267 leot 866: -rpkgsrc-2025Q4 option.
1.1 dsieger 867:
1.266 martin 868: 3.2.2.2. What happens to my changes when updating?
1.1 dsieger 869:
870: When you update pkgsrc, the CVS program will only touch those files that are
871: registered in the CVS repository. That means that any packages that you created
872: on your own will stay unmodified. If you change files that are managed by CVS,
873: later updates will try to merge your changes with those that have been done by
1.266 martin 874: others. See the CVS manual, chapter update for details.
1.1 dsieger 875:
1.266 martin 876: Chapter 4. Using pkgsrc on systems other than NetBSD
1.1 dsieger 877:
878: Table of Contents
879:
1.154 rillig 880: 4.1. Binary distribution
881: 4.2. Bootstrapping pkgsrc
1.1 dsieger 882:
1.266 martin 883: 4.1. Binary distribution
1.1 dsieger 884:
1.266 martin 885: See Section 5.1, Using binary packages .
1.1 dsieger 886:
1.266 martin 887: 4.2. Bootstrapping pkgsrc
1.1 dsieger 888:
1.44 asau 889: pkgsrc can be bootstrapped for use in two different modes: privileged and
890: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45 asau 891: programs are installed under one particular user and cannot utilise privileged
1.44 asau 892: operations (packages don't create special users and all special file
893: permissions like setuid are ignored).
894:
1.1 dsieger 895: Installing the bootstrap kit from source should be as simple as:
896:
1.60 asau 897: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 898: # cd pkgsrc/bootstrap
899: # ./bootstrap
900:
901:
1.266 martin 902: To bootstrap in unprivileged mode pass --unprivileged flag to bootstrap
1.44 asau 903:
904: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1.118 sevan 905: will be installed in, and /usr/pkg/pkgdb for the package database directory
906: where pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1.44 asau 907: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1.118 sevan 908: for prefix, ~/pkg/pkgdb for the package database, and ~/pkg/var for varbase.
1.44 asau 909:
1.266 martin 910: You can change default layout using command-line arguments. Run ./bootstrap
911: --help to get details.
1.1 dsieger 912:
913: Note
914:
915: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
1.266 martin 916: For examples in this guide, use bmake instead of make .
1.1 dsieger 917:
1.44 asau 918: Note
919:
920: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
921: directories. Use bmake corresponding to the installation you're working with to
922: build and install packages.
923:
1.266 martin 924: Chapter 5. Using pkgsrc
1.1 dsieger 925:
926: Table of Contents
927:
1.154 rillig 928: 5.1. Using binary packages
929: 5.1.1. Finding binary packages
930: 5.1.2. Installing binary packages
1.202 nia 931: 5.1.3. Updating packages
932: 5.1.4. Deinstalling packages
933: 5.1.5. Getting information about installed packages
934: 5.1.6. Checking for security vulnerabilities in installed packages
935: 5.1.7. Finding if newer versions of your installed packages are in pkgsrc
936: 5.1.8. Other administrative functions
1.154 rillig 937: 5.2. Building packages from source
938: 5.2.1. Requirements
939: 5.2.2. Fetching distfiles
940: 5.2.3. How to build and install
1.1 dsieger 941:
942: Basically, there are two ways of using pkgsrc. The first is to only install the
943: package tools and to use binary packages that someone else has prepared. This
1.266 martin 944: is the pkg in pkgsrc. The second way is to install the src of pkgsrc, too.
1.1 dsieger 945: Then you are able to build your own packages, and you can still use binary
946: packages from someone else.
947:
1.266 martin 948: 5.1. Using binary packages
1.1 dsieger 949:
1.151 sevan 950: On the cdn.NetBSD.org site and mirrors, there are collections of binary
1.9 rillig 951: packages, ready to be installed. These binary packages have been built using
952: the default settings for the directories, that is:
953:
954: * /usr/pkg for LOCALBASE, where most of the files are installed,
955:
956: * /usr/pkg/etc for configuration files,
957:
958: * /var for VARBASE, where those files are installed that may change after
959: installation.
960:
961: If you cannot use these directories for whatever reasons (maybe because you're
962: not root), you cannot use these binary packages, but have to build the packages
1.266 martin 963: yourself, which is explained in Section 4.2, Bootstrapping pkgsrc .
1.1 dsieger 964:
1.266 martin 965: 5.1.1. Finding binary packages
1.1 dsieger 966:
1.5 weinem 967: To install binary packages, you first need to know from where to get them. The
1.202 nia 968: first place where you should look is on the main pkgsrc CDN in the directory /
969: pub/pkgsrc/packages.
1.5 weinem 970:
971: This directory contains binary packages for multiple platforms. First, select
1.226 gutterid 972: your operating system. Then, select your hardware architecture, and in the
1.266 martin 973: third step, the OS version and the version of pkgsrc.
1.9 rillig 974:
1.226 gutterid 975: In this directory, you may find a file called bootstrap.tar.gz which contains
1.9 rillig 976: the package management tools. If the file is missing, it is likely that your
977: operating system already provides those tools. Download the file and extract it
978: in the / directory. It will create the directories /usr/pkg (containing the
1.118 sevan 979: tools for managing binary packages and the database of installed packages).
1.1 dsieger 980:
1.266 martin 981: 5.1.2. Installing binary packages
1.1 dsieger 982:
1.85 wiz 983: In the directory from the last section, there is a subdirectory called All/,
1.9 rillig 984: which contains all the binary packages that are available for the platform,
1.202 nia 985: excluding those that may not be distributed via HTTP or FTP.
1.9 rillig 986:
987: To install packages directly from an FTP or HTTP server, run the following
988: commands in a Bourne-compatible shell (be sure to su to root first):
989:
1.202 nia 990: # PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
991: # PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages"
1.169 rillig 992: # PKG_PATH="$PKG_PATH/OPSYS/ARCH/VERSIONS/All/"
1.9 rillig 993: # export PATH PKG_PATH
1.202 nia 994: # pkg_add pkgin
1.9 rillig 995:
996: Instead of URLs, you can also use local paths, for example if you are
997: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
998: to install packages from multiple sources, you can separate them by a semicolon
999: in PKG_PATH.
1000:
1001: After these preparations, installing a package is very easy:
1002:
1.202 nia 1003: # pkgin search nginx
1004: nginx-1.19.6 Lightweight HTTP server and mail proxy server
1005: nginx-1.18.0nb8 Lightweight HTTP server and mail proxy server
1006: # pkgin install zsh nginx-1.19.6 vim
1.1 dsieger 1007:
1.202 nia 1008: Note that pkgin is a user-friendly frontend to the pkg_* tools.
1.1 dsieger 1009:
1.202 nia 1010: Any prerequisite packages needed to run the package in question will be
1011: installed, too, assuming they are present in the repository.
1.1 dsieger 1012:
1013: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
1014: in your PATH so you can actually start the just installed program.
1015:
1.266 martin 1016: 5.1.3. Updating packages
1.1 dsieger 1017:
1.202 nia 1018: To update binary packages, it is recommended that you use pkgin upgrade. This
1019: will compare the remote package repository to your locally installed packages
1020: and safely replace any older packages.
1.1 dsieger 1021:
1.202 nia 1022: Note that pkgsrc is released as quarterly branches. If you are updating to a
1023: newer quarterly branch of pkgsrc, you may need to adjust the repository in /usr
1024: /pkg/etc/pkgin/repositories.conf.
1.1 dsieger 1025:
1.266 martin 1026: 5.1.4. Deinstalling packages
1.1 dsieger 1027:
1.202 nia 1028: To deinstall a package, it does not matter whether it was installed from source
1029: code or from a binary package. Neither the pkgin or the pkg_delete command need
1030: to know.
1.1 dsieger 1031:
1.202 nia 1032: To delete a package, you can just run pkgin remove package-name. The package
1033: name can be given with or without version number.
1.1 dsieger 1034:
1.266 martin 1035: 5.1.5. Getting information about installed packages
1.1 dsieger 1036:
1037: The pkg_info shows information about installed packages or binary package
1.202 nia 1038: files. As with other management tools, it works with packages installed from
1039: source or binaries.
1.1 dsieger 1040:
1.266 martin 1041: 5.1.6. Checking for security vulnerabilities in installed packages
1.1 dsieger 1042:
1.202 nia 1043: The pkgsrc Security Team and Packages Groups maintain a list of known
1.164 leot 1044: vulnerabilities to packages which are (or have been) included in pkgsrc. The
1.202 nia 1045: list is available from the NetBSD CDN at https://cdn.NetBSD.org/pub/NetBSD/
1.179 rillig 1046: packages/vulns/pkg-vulnerabilities.
1.1 dsieger 1047:
1.202 nia 1048: Please note that not every "vulnerability" with a CVE assignment is exploitable
1049: in every configuration. Some bugs are marked as active simply because an fix
1050: was not marked as such. Operating system specific hardening and mitigation
1051: features may also reduce the impact of bugs.
1052:
1.23 jakllsch 1053: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
1054: automatically, and a security audit of all packages installed on a system can
1055: take place.
1056:
1057: There are two components to auditing. The first step, pkg_admin
1058: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
1059: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
1060: your installed packages are vulnerable. If a package is vulnerable, you will
1061: see output similar to the following:
1.1 dsieger 1062:
1063: Package samba-2.0.9 has a local-root-shell vulnerability, see
1.174 leot 1064: https://www.samba.org/samba/whatsnew/macroexploit.html
1.1 dsieger 1065:
1.23 jakllsch 1066: You may wish to have the vulnerabilities file downloaded daily so that it
1067: remains current. This may be done by adding an appropriate entry to the root
1068: users crontab(5) entry. For example the entry
1069:
1.121 sevan 1070: # Download vulnerabilities file
1.118 sevan 1071: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.121 sevan 1072: # Audit the installed packages and email results to root
1073: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
1074: root >/dev/null 2>&1
1.118 sevan 1075:
1076:
1077: will update the vulnerability list every day at 3AM, followed by an audit at
1078: 3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
1079: accomplished instead by adding the following line to /etc/daily.conf:
1080:
1081: fetch_pkg_vulnerabilities=YES
1082:
1.23 jakllsch 1083:
1.118 sevan 1084: to fetch the vulnerability list from the daily security script. The system is
1085: set to audit the packages by default but can be set explicitly, if desired (not
1.123 wiz 1086: required), by adding the following line to /etc/security.conf:
1.23 jakllsch 1087:
1.118 sevan 1088: check_pkg_vulnerabilities=YES
1.23 jakllsch 1089:
1090:
1.118 sevan 1091: see daily.conf(5) and security.conf(5) for more details.
1.1 dsieger 1092:
1.266 martin 1093: 5.1.7. Finding if newer versions of your installed packages are in pkgsrc
1.1 dsieger 1094:
1.266 martin 1095: Install pkgtools/lintpkgsrc and run lintpkgsrc with the -i argument to check
1.202 nia 1096: if any packages are stale, e.g.
1.1 dsieger 1097:
1098: % lintpkgsrc -i
1099: ...
1100: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
1101:
1102:
1.266 martin 1103: 5.1.8. Other administrative functions
1.1 dsieger 1104:
1105: The pkg_admin executes various administrative functions on the package system.
1106:
1.266 martin 1107: 5.2. Building packages from source
1.1 dsieger 1108:
1109: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25 wiz 1110: organized into categories. You can browse the online index of packages, or run
1.1 dsieger 1111: make readme from the pkgsrc directory to build local README.html files for all
1112: packages, viewable with any web browser such as www/lynx or www/firefox.
1113:
1114: The default prefix for installed packages is /usr/pkg. If you wish to change
1115: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
1116: use multiple different LOCALBASE definitions on the same system (inside a
1117: chroot is an exception).
1118:
1119: The rest of this chapter assumes that the package is already in pkgsrc. If it
1.266 martin 1120: is not, see Part II, The pkgsrc developer's guide for instructions how to
1.1 dsieger 1121: create your own packages.
1122:
1.266 martin 1123: 5.2.1. Requirements
1.1 dsieger 1124:
1125: To build packages from source, you need a working C compiler. On NetBSD, you
1.266 martin 1126: need to install the comp and the text distribution sets. If you want to
1127: build X11-related packages, the xbase and xcomp distribution sets are
1.1 dsieger 1128: required, too.
1129:
1.266 martin 1130: 5.2.2. Fetching distfiles
1.1 dsieger 1131:
1132: The first step for building a package is downloading the distfiles (i.e. the
1133: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
1134: them automatically.
1135:
1136: If you have all files that you need in the distfiles directory, you don't need
1137: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
1138: and add:
1139:
1140: DISTDIR=/cdrom/pkgsrc/distfiles
1141:
1142: to your mk.conf.
1143:
1144: By default a list of distribution sites will be randomly intermixed to prevent
1145: huge load on servers which holding popular packages (for example,
1146: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
1147: distfile all the mirrors will be tried in new (random) order. You can turn this
1148: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
1149: disabled).
1150:
1151: You can overwrite some of the major distribution sites to fit to sites that are
1152: close to your own. By setting one or two variables you can modify the order in
1153: which the master sites are accessed. MASTER_SORT contains a whitespace
1154: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
1155: contains a whitespace delimited list of regular expressions. It has higher
1156: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
1157: some examples. This may save some of your bandwidth and time.
1158:
1159: You can change these settings either in your shell's environment, or, if you
1.4 rillig 1160: want to keep the settings, by editing the mk.conf file, and adding the
1.1 dsieger 1161: definitions there.
1162:
1.132 wiz 1163: If a package depends on many other packages (such as meta-pkgs/kde4), the build
1.1 dsieger 1164: process may alternate between periods of downloading source, and compiling. To
1165: ensure you have all the source downloaded initially you can run the command:
1166:
1167: % make fetch-list | sh
1168:
1169: which will output and run a set of shell commands to fetch the necessary files
1170: into the distfiles directory. You can also choose to download the files
1171: manually.
1172:
1.266 martin 1173: 5.2.3. How to build and install
1.1 dsieger 1174:
1175: Once the software has downloaded, any patches will be applied, then it will be
1176: compiled for you. This may take some time depending on your computer, and how
1177: many other packages the software depends on and their compile time.
1178:
1179: Note
1180:
1181: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
1.266 martin 1182: command instead of make in the examples in this guide.
1.1 dsieger 1183:
1184: For example, type
1185:
1186: % cd misc/figlet
1187: % make
1188:
1189:
1190: at the shell prompt to build the various components of the package.
1191:
1192: The next stage is to actually install the newly compiled program onto your
1193: system. Do this by entering:
1194:
1195: % make install
1196:
1197:
1198: while you are still in the directory for whatever package you are installing.
1199:
1200: Installing the package on your system may require you to be root. However,
1201: pkgsrc has a just-in-time-su feature, which allows you to only become root for
1202: the actual installation step.
1203:
1204: That's it, the software should now be installed and setup for use. You can now
1205: enter:
1206:
1207: % make clean
1208:
1209:
1210: to remove the compiled files in the work directory, as you shouldn't need them
1211: any more. If other packages were also added to your system (dependencies) to
1212: allow your program to compile, you can tidy these up also with the command:
1213:
1214: % make clean-depends
1215:
1216:
1217: Taking the figlet utility as an example, we can install it on our system by
1.266 martin 1218: building as shown in Appendix C, Build logs.
1.1 dsieger 1219:
1220: The program is installed under the default root of the packages tree - /usr/
1221: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
1222: environment, and it will use that value as the root of your packages tree. So,
1223: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
1224: that you should use a directory which is dedicated to packages and not shared
1225: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
1226: not try to add any of your own files or directories (such as src/, obj/, or
1227: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
1228: between programs and other files installed by the package system and whatever
1229: else may have been installed there.
1230:
1.4 rillig 1231: Some packages look in mk.conf to alter some configuration options at build
1.1 dsieger 1232: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
1233: be set there by default. Environment variables such as LOCALBASE can be set in
1.4 rillig 1234: mk.conf to save having to remember to set them each time you want to use
1.1 dsieger 1235: pkgsrc.
1236:
1.266 martin 1237: Occasionally, people want to look under the covers to see what is going on
1.1 dsieger 1238: when a package is building or being installed. This may be for debugging
1239: purposes, or out of simple curiosity. A number of utility values have been
1240: added to help with this.
1241:
1242: 1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
1243: amount of information will be displayed. For example,
1244:
1245: make patch PKG_DEBUG_LEVEL=2
1246:
1.266 martin 1247: will show all the commands that are invoked, up to and including the patch
1248: stage.
1.1 dsieger 1249:
1250: 2. If you want to know the value of a certain make(1) definition, then the
1251: VARNAME definition should be used, in conjunction with the show-var target.
1252: e.g. to show the expansion of the make(1) variable LOCALBASE:
1253:
1254: % make show-var VARNAME=LOCALBASE
1255: /usr/pkg
1256: %
1257:
1258:
1259: If you want to install a binary package that you've either created yourself
1260: (see next section), that you put into pkgsrc/packages manually or that is
1261: located on a remote FTP server, you can use the "bin-install" target. This
1262: target will install a binary package - if available - via pkg_add(1), else do a
1263: make package. The list of remote FTP sites searched is kept in the variable
1264: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
1265: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
1266: for more details.
1267:
1268: A final word of warning: If you set up a system that has a non-standard setting
1269: for LOCALBASE, be sure to set that before any packages are installed, as you
1270: cannot use several directories for the same purpose. Doing so will result in
1271: pkgsrc not being able to properly detect your installed packages, and fail
1272: miserably. Note also that precompiled binary packages are usually built with
1273: the default LOCALBASE of /usr/pkg, and that you should not install any if you
1274: use a non-standard LOCALBASE.
1275:
1.266 martin 1276: Chapter 6. Configuring pkgsrc
1.1 dsieger 1277:
1278: Table of Contents
1279:
1.154 rillig 1280: 6.1. General configuration
1281: 6.2. Variables affecting the build process
1.241 rillig 1282: 6.3. Preferences for native or pkgsrc software
1283: 6.4. Variables affecting the installation process
1284: 6.5. Selecting and configuring the compiler
1285: 6.5.1. Selecting the compiler
1286: 6.5.2. Additional flags to the compiler (CFLAGS)
1287: 6.5.3. Additional flags to the linker (LDFLAGS)
1288: 6.6. Developer/advanced settings
1289: 6.7. Selecting Build Options
1.1 dsieger 1290:
1291: The whole pkgsrc system is configured in a single file, usually called mk.conf.
1292: In which directory pkgsrc looks for that file depends on the installation. On
1293: NetBSD, when you use make(1) from the base system, it is in the directory /etc
1294: /. In all other cases the default location is ${PREFIX}/etc/, depending on
1295: where you told the bootstrap program to install the binary packages.
1296:
1297: The format of the configuration file is that of the usual BSD-style Makefiles.
1298: The whole pkgsrc configuration is done by setting variables in this file. Note
1299: that you can define all kinds of variables, and no special error checking (for
1.112 rillig 1300: example for spelling mistakes) takes place.
1.1 dsieger 1301:
1.266 martin 1302: 6.1. General configuration
1.1 dsieger 1303:
1.112 rillig 1304: The following variables apply to all pkgsrc packages. A complete list of the
1305: variables that can be configured by the user is available in mk/defaults/
1306: mk.conf, together with some comments that describe each variable's intent.
1.1 dsieger 1307:
1308: * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
1309: not mix binary packages with different LOCALBASEs!
1310:
1.266 martin 1311: * CROSSBASE: Where cross category packages will be installed. The default
1.1 dsieger 1312: is ${LOCALBASE}/cross.
1313:
1.84 wiz 1314: * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1 dsieger 1315:
1316: * DISTDIR: Where to store the downloaded copies of the original source
1317: distributions used for building pkgsrc packages. The default is $
1318: {PKGSRCDIR}/distfiles.
1319:
1320: * PKG_DBDIR: Where the database about installed packages is stored. The
1.118 sevan 1321: default is /usr/pkg/pkgdb.
1.1 dsieger 1322:
1323: * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
1324: value.
1325:
1326: * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
1327: files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.118 sevan 1328: respectively. The defaults is ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1.1 dsieger 1329: {DIST_SUBDIR}/.
1330:
1331: * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
1.266 martin 1332: with OS release ( 2.0 , etc.) and architecture ( mipsel , etc.).
1.1 dsieger 1333:
1.23 jakllsch 1334: * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
1335: case-sensitive. Whenever you try to build a package whose license is not in
1336: this list, you will get an error message. If the license condition is
1337: simple enough, the error message will include specific instructions on how
1338: to change this variable.
1.1 dsieger 1339:
1.266 martin 1340: 6.2. Variables affecting the build process
1.1 dsieger 1341:
1342: * PACKAGES: The top level directory for the binary packages. The default is $
1343: {PKGSRCDIR}/packages.
1344:
1345: * WRKOBJDIR: The top level directory where, if defined, the separate working
1346: directories will get created, and symbolically linked to from ${WRKDIR}
1347: (see below). This is useful for building packages on several architectures,
1348: then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
1349: architecture. (It should be noted that PKGSRCDIR should not be set by the
1.266 martin 1350: user it is an internal definition which refers to the root of the pkgsrc
1.1 dsieger 1351: tree. It is possible to have many pkgsrc tree instances.)
1352:
1353: * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.266 martin 1354: Section 12.3, patches/* for more information.
1.1 dsieger 1355:
1356: * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
1357: Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
1358: up settings used by builds in /usr/src.
1359:
1.266 martin 1360: 6.3. Preferences for native or pkgsrc software
1.241 rillig 1361:
1362: Whenever a package depends on a package that has a builtin.mk file, the
1363: dependent package can either use the built-in (native) version from the base
1364: system or the pkgsrc-provided version. This only affects dependencies, so it is
1365: still possible to build the pkgsrc package devel/pcre++ even when other
1366: packages depend on the native pcre++ version instead.
1367:
1.266 martin 1368: To force using the pkgsrc-provided version for a particular package, define
1369: PREFER_PKGSRC = package-ID in mk.conf. To force using the native package,
1370: define PREFER_NATIVE = package-ID . In both cases, the package-ID is the one
1.241 rillig 1371: from the buildlink3.mk of the package. In most cases, this ID is the same as
1372: the directory name of the package, but for example, devel/pcre++ has the
1.266 martin 1373: package ID pcrexx .
1.241 rillig 1374:
1375: For the packages that are not listed by their package ID, pkgsrc uses the
1.266 martin 1376: pkgsrc-provided version if PREFER_PKGSRC contains the word yes . Otherwise, if
1377: PREFER_NATIVE contains the word yes , pkgsrc uses the native version. For
1.241 rillig 1378: example, to require using the pkgsrc-provided versions for all but the most
1379: basic bits on a NetBSD system, you can set:
1380:
1381: PREFER_PKGSRC= yes
1382: PREFER_NATIVE= getopt skey tcp_wrappers
1383:
1384: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
1385: it is simply ignored in that list.
1386:
1387: PREFER_PKGSRC and PREFER_NATIVE should be set during bootstrap to ensure that
1388: the bootstrap process does not use inapropriate native tools as dependencies
1389: for core packages.
1390:
1391: # ./bootstrap --prefer-pkgsrc yes --prefer-native openssl
1392:
1393: Switching between settings globally at a later date can introduce complications
1394: with dependency resolution. This is caused by packages built with the opposite
1395: preference being installed alongside each other. Hence, when changing any of
1396: these variables after bootstrap, you need to rebuild all packages depending on
1397: those whose preference has been changed. This is not trivial and should be
1398: avoided.
1399:
1.266 martin 1400: When using pkgsrc on Linux systems, there is high risk of leakage , where
1.241 rillig 1401: programs installed by pkgsrc may inadvertently use a command or library not
1402: installed by pkgsrc, e.g. those installed by yum or apt. Such foreign
1403: dependencies may be installed, removed, or upgraded to a version incompatible
1404: with the pkgsrc package at any time, causing pkgsrc packages to subsequently
1405: malfunction. Pkgsrc cannot prevent this, as it has no control over other
1406: package managers. Another potential problem is that under Redhat Enterprise and
1407: related Linux systems, yum packages are only patched and never upgraded, so
1408: eventually they may become too outdated for use by pkgsrc. Even intentionally
1409: using foreign dependencies, not considered leakage, can lead to these problems,
1410: so it is generally discouraged. In order to minimize such problems,
1.266 martin 1411: PREFER_PKGSRC defaults to yes on Linux systems. This ensures that pkgsrc is
1.241 rillig 1412: aware of any changes to dependency packages and can rebuild or upgrade the
1413: entire dependency tree as needed. This default can be overridden by setting
1.266 martin 1414: --prefer-pkgsrc to a list of packages and --prefer-native to yes .
1.241 rillig 1415:
1.266 martin 1416: 6.4. Variables affecting the installation process
1.1 dsieger 1417:
1.198 leot 1418: * PKGSRC_KEEP_BIN_PKGS: By default, binary packages of built packages are
1.150 leot 1419: preserved in ${PACKAGES}/All. Setting this variable to "no" prevents this.
1.1 dsieger 1420:
1.107 jnemeth 1421: Packages have to support installation into a subdirectory of WRKDIR. This
1422: allows a package to be built, before the actual filesystem is touched. DESTDIR
1423: support exists in two variations:
1.4 rillig 1424:
1425: * Basic DESTDIR support means that the package installation and packaging is
1426: still run as root.
1427:
1428: * Full DESTDIR support can run the complete build, installation and packaging
1429: as normal user. Root privileges are only needed to add packages.
1430:
1431: With basic DESTDIR support, make clean needs to be run as root.
1432:
1.17 imil 1433: Considering the foo/bar package, DESTDIR full support can be tested using the
1434: following commands
1435:
1436: $ id
1437: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
1438: $ mkdir $HOME/packages
1439: $ cd $PKGSRCDIR/foo/bar
1440:
1441: Verify DESTDIR full support, no root privileges should be needed
1442:
1.66 asau 1443: $ make stage-install
1.17 imil 1444:
1445: Create a package without root privileges
1446:
1.66 asau 1447: $ make PACKAGES=$HOME/packages package
1.17 imil 1448:
1449: For the following command, you must be able to gain root privileges using su(1)
1450:
1.66 asau 1451: $ make PACKAGES=$HOME/packages install
1.17 imil 1452:
1453: Then, as a simple user
1454:
1455: $ make clean
1456:
1.266 martin 1457: 6.5. Selecting and configuring the compiler
1.4 rillig 1458:
1.266 martin 1459: 6.5.1. Selecting the compiler
1.1 dsieger 1460:
1461: By default, pkgsrc will use GCC to build packages. This may be overridden by
1462: setting the following variables in /etc/mk.conf:
1463:
1464: PKGSRC_COMPILER:
1465:
1466: This is a list of values specifying the chain of compilers to invoke when
1467: building packages. Valid values are:
1468:
1.271 wiz 1469: o ccc: Compaq C Compilers (Tru64)
1.66 asau 1470:
1.271 wiz 1471: o ccache: compiler cache (chainable)
1.66 asau 1472:
1.271 wiz 1473: o clang: Clang C and Objective-C compiler
1.66 asau 1474:
1.271 wiz 1475: o distcc: distributed C/C++ (chainable)
1.1 dsieger 1476:
1.271 wiz 1477: o f2c: Fortran 77 to C compiler (chainable)
1.66 asau 1478:
1.271 wiz 1479: o icc: Intel C++ Compiler (Linux)
1.66 asau 1480:
1.271 wiz 1481: o ido: SGI IRIS Development Option cc (IRIX 5)
1.1 dsieger 1482:
1.271 wiz 1483: o gcc: GNU C/C++ Compiler
1.1 dsieger 1484:
1.271 wiz 1485: o hp: HP-UX C/aC++ compilers
1.66 asau 1486:
1.271 wiz 1487: o mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1 dsieger 1488:
1.271 wiz 1489: o mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1 dsieger 1490:
1.271 wiz 1491: o sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1 dsieger 1492:
1.271 wiz 1493: o xlc: IBM's XL C/C++ compiler suite
1.66 asau 1494:
1.266 martin 1495: The default is gcc . You can use ccache and/or distcc with an appropriate
1496: PKGSRC_COMPILER setting, e.g. ccache gcc . This variable should always be
1.1 dsieger 1497: terminated with a value for a real compiler. Note that only one real
1.266 martin 1498: compiler should be listed (e.g. sunpro gcc is not allowed).
1.1 dsieger 1499:
1500: GCC_REQD:
1501:
1502: This specifies the minimum version of GCC to use when building packages. If
1503: the system GCC doesn't satisfy this requirement, then pkgsrc will build and
1504: install one of the GCC packages to use instead.
1505:
1.153 leot 1506: PYTHON_VERSION_DEFAULT:
1.114 maya 1507:
1508: Specifies which version of python to use when several options are
1509: available.
1510:
1511: PKGSRC_FORTRAN:
1512:
1.176 gutterid 1513: Specifies the Fortran compiler to use. The default is gfortran.
1.114 maya 1514:
1515: GFORTRAN_VERSION:
1516:
1517: If PKGSRC_FORTRAN= gfortran is used, this option specifies which version to
1518: use.
1519:
1.266 martin 1520: 6.5.2. Additional flags to the compiler (CFLAGS)
1.1 dsieger 1521:
1522: If you wish to set the CFLAGS variable, please make sure to use the += operator
1523: instead of the = operator:
1524:
1525: CFLAGS+= -your -flags
1526:
1.266 martin 1527: Using CFLAGS= (i.e. without the + ) may lead to problems with packages that
1.16 jnemeth 1528: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24 wiz 1529: package if you're interested in optimization specifically for the current CPU.
1.1 dsieger 1530:
1.266 martin 1531: 6.5.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 1532:
1533: If you want to pass flags to the linker, both in the configure step and the
1534: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
1535: difference between the two is that LIBS will be appended to the command line,
1536: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
1537: machines depending on the setting of USE_IMAKE or the inclusion of mk/
1538: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
1539: settings, use the += operator:
1540:
1541: LDFLAGS+= -your -linkerflags
1542:
1.266 martin 1543: 6.6. Developer/advanced settings
1.1 dsieger 1544:
1545: * PKG_DEVELOPER: Run some sanity checks that package developers want:
1546:
1.42 asau 1547: + make sure patches apply with zero fuzz
1.1 dsieger 1548:
1.42 asau 1549: + run check-shlibs to see that all binaries will find their shared libs.
1.1 dsieger 1550:
1.232 gutterid 1551: * CHECK_FILES_STRICT: Also check VARBASE and PKG_SYSCONFDIR values in PLIST
1552: entries.
1553:
1.1 dsieger 1554: * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
1555: making and installing the package. The default value for this is 0, which
1556: will not display the commands as they are executed (normal, default, quiet
1557: operation); the value 1 will display all shell commands before their
1558: invocation, and the value 2 will display both the shell commands before
1.112 rillig 1559: their invocation, as well as their actual execution progress with set -x.
1.1 dsieger 1560:
1.266 martin 1561: 6.7. Selecting Build Options
1.1 dsieger 1562:
1563: Some packages have build time options, usually to select between different
1564: dependencies, enable optional support for big dependencies or enable
1565: experimental features.
1566:
1567: To see which options, if any, a package supports, and which options are
1568: mutually exclusive, run make show-options, for example:
1569:
1570: The following options are supported by this package:
1571: ssl Enable SSL support.
1572: Exactly one of the following gecko options is required:
1573: firefox Use firefox as gecko rendering engine.
1574: mozilla Use mozilla as gecko rendering engine.
1575: At most one of the following database options may be selected:
1576: mysql Enable support for MySQL database.
1577: pgsql Enable support for PostgreSQL database.
1578:
1579: These options are enabled by default: firefox
1580: These options are currently enabled: mozilla ssl
1581:
1.4 rillig 1582: The following variables can be defined in mk.conf to select which options to
1583: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1 dsieger 1584: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
1585: which can be used to select or disable options specifically for package pkgbase
1.266 martin 1586: . Options listed in these variables are selected, options preceded by - are
1.1 dsieger 1587: disabled. A few examples:
1588:
1.4 rillig 1589: $ grep "PKG.*OPTION" mk.conf
1.1 dsieger 1590: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
1591: PKG_OPTIONS.kdebase= debug -sasl
1592: PKG_OPTIONS.apache= suexec
1593:
1.11 rillig 1594: It is important to note that options that were specifically suggested by the
1.19 snj 1595: package maintainer must be explicitly removed if you do not wish to include the
1596: option. If you are unsure you can view the current state with make show-options
1597: .
1.11 rillig 1598:
1.1 dsieger 1599: The following settings are consulted in the order given, and the last setting
1600: that selects or disables an option is used:
1601:
1602: 1. the default options as suggested by the package maintainer
1603:
1604: 2. the options implied by the settings of legacy variables (see below)
1605:
1606: 3. PKG_DEFAULT_OPTIONS
1607:
1608: 4. PKG_OPTIONS.pkgbase
1609:
1610: For groups of mutually exclusive options, the last option selected is used, all
1611: others are automatically disabled. If an option of the group is explicitly
1612: disabled, the previously selected option, if any, is used. It is an error if no
1613: option from a required group of options is selected, and building the package
1614: will fail.
1615:
1616: Before the options framework was introduced, build options were selected by
1.4 rillig 1617: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
1618: transition to the options framework for the user, these legacy variables are
1619: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
1620: automatically. A warning is issued to prompt the user to update mk.conf to use
1621: the options framework directly. Support for the legacy variables will be
1.1 dsieger 1622: removed eventually.
1623:
1.266 martin 1624: Chapter 7. Creating binary packages
1.1 dsieger 1625:
1626: Table of Contents
1627:
1.154 rillig 1628: 7.1. Building a single binary package
1629: 7.2. Settings for creation of binary packages
1.1 dsieger 1630:
1.266 martin 1631: 7.1. Building a single binary package
1.1 dsieger 1632:
1633: Once you have built and installed a package, you can create a binary package
1634: which can be installed on another system with pkg_add(1). This saves having to
1635: build the same package on a group of hosts and wasting CPU time. It also
1636: provides a simple means for others to install your package, should you
1637: distribute it.
1638:
1639: To create a binary package, change into the appropriate directory in pkgsrc,
1640: and run make package:
1641:
1.112 rillig 1642: $ cd misc/figlet
1643: $ make package
1.1 dsieger 1644:
1.242 gutterid 1645: This will build your package (if not already done) and package it into a binary
1646: package. You can then use the pkg_* tools to manipulate it. Binary packages are
1647: created in PACKAGES, which defaults to /usr/pkgsrc/packages, in the form of a
1.266 martin 1648: compressed tar file. See Section C.2, Packaging figlet for a continuation of
1.242 gutterid 1649: the above misc/figlet example.
1.1 dsieger 1650:
1.266 martin 1651: See Chapter 23, Submitting and Committing for information on how to submit such
1.1 dsieger 1652: a binary package.
1653:
1.266 martin 1654: 7.2. Settings for creation of binary packages
1.1 dsieger 1655:
1.266 martin 1656: See Section 13.17, Other helpful targets .
1.6 rillig 1657:
1.266 martin 1658: Chapter 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6 rillig 1659:
1660: Table of Contents
1661:
1.154 rillig 1662: 8.1. Preparations
1.276 ! wiz 1663: 8.2. Running a pbulk build
1.154 rillig 1664: 8.2.1. Configuration
1.276 ! wiz 1665: 8.3. Running a bob build
! 1666: 8.4. Speeding up bulk build scans
! 1667: 8.5. Requirements of a full bulk build
! 1668: 8.6. Bulk build variants
! 1669: 8.6.1. Detect unknown configure options
! 1670: 8.6.2. Detect classes of bugs by forcing compiler warnings
! 1671: 8.6.3. Force compiler options only in the build phase
! 1672: 8.6.4. Use custom directories
! 1673: 8.6.5. Turn warnings into errors
! 1674: 8.6.6. Reject packages for which pkglint reports errors
! 1675: 8.6.7. Reject packages that contain forbidden strings
! 1676: 8.6.8. Reject packages whose self-test fails
! 1677: 8.6.9. Reject packages that use undefined shell variables
! 1678: 8.6.10. Turn off verbose logging
! 1679: 8.7. Creating a multiple CD-ROM packages collection
! 1680: 8.7.1. Example of cdpack
1.6 rillig 1681:
1.175 gutterid 1682: For a number of reasons, you may want to build binary packages for a large
1683: selected set of packages in pkgsrc, or even for all pkgsrc packages. For
1.71 wiz 1684: instance, when you have multiple machines that should run the same software, it
1685: is wasted time if they all build their packages themselves from source. Or you
1686: may want to build a list of packages you want and check them before deploying
1.276 ! wiz 1687: onto production systems. There is a way of getting a set of binary packages
! 1688: using a bulk build system, for example pbulk ("p" stands for "parallel") or
! 1689: bob. This chapter describes how to set them up.
1.71 wiz 1690:
1.266 martin 1691: 8.1. Preparations
1.71 wiz 1692:
1693: First of all, you have to decide whether you build all packages or a limited
1694: set of them. Full bulk builds usually consume a lot more resources, both space
1.175 gutterid 1695: and time, than builds for some practical sets of packages. A number of
1696: particularly heavy packages exist that are not actually interesting to a wide
1697: audience. (The approximate resource consumption for a full bulk build is given
1.276 ! wiz 1698: in section Section 8.5, Requirements of a full bulk build .) For limited bulk
1.175 gutterid 1699: builds you need to make a list of packages you want to build. Note that all
1700: their dependencies will be built, so you don't need to track them manually.
1.71 wiz 1701:
1.276 ! wiz 1702: During pbulk (but not bob) builds various packages are installed and
! 1703: deinstalled in /usr/pkg (or whatever LOCALBASE is), so make sure that you don't
! 1704: need any package during the builds. Essentially, you should provide a fresh
! 1705: system, either a chroot environment or something even more restrictive,
! 1706: depending on what the operating system provides, or dedicate the whole physical
! 1707: machine. As a useful side effect this makes sure that bulk builds cannot break
! 1708: anything in your system. There have been numerous cases where certain packages
! 1709: tried to install files outside the LOCALBASE or wanted to edit some files in /
! 1710: etc.
1.6 rillig 1711:
1.276 ! wiz 1712: 8.2. Running a pbulk build
1.6 rillig 1713:
1.276 ! wiz 1714: Running a pbulk build works roughly as follows:
1.15 rillig 1715:
1716: * First, build the pbulk infrastructure in a fresh pkgsrc location.
1717:
1718: * Then, build each of the packages from a clean installation directory using
1719: the infrastructure.
1720:
1.266 martin 1721: 8.2.1. Configuration
1.6 rillig 1722:
1.112 rillig 1723: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6 rillig 1724:
1.68 asau 1725: In order to use it, prepare a clear system (real one, chroot environment, jail,
1726: zone, virtual machine). Configure network access to fetch distribution files.
1.112 rillig 1727: Create a user with name "pbulk".
1.68 asau 1728:
1729: Fetch and extract pkgsrc. Use a command like one of these:
1730:
1.151 sevan 1731: # (cd /usr && ftp -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1732: # (cd /usr && fetch -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1.72 wiz 1733: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68 asau 1734:
1735: Or any other way that fits (e.g., curl, wget).
1736:
1737: Deploy and configure pbulk tools, e.g.:
1738:
1.118 sevan 1739: # sh pbulk.sh -n # use native make, no bootstrap kit needed (for use on NetBSD)
1.68 asau 1740: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
1741: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
1742:
1743: Note
1744:
1745: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
1746: to packages you build. For instance,
1747:
1.112 rillig 1748: PKG_DEVELOPER= yes # perform more checks
1749: X11_TYPE= modular # use pkgsrc X11
1750: SKIP_LICENSE_CHECK= yes # accept all licences (useful
1751: # when building all packages)
1.68 asau 1752:
1753: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112 rillig 1754: with your list of packages, one per line without empty lines or comments. E.g.:
1.68 asau 1755:
1756: www/firefox
1757: mail/thunderbird
1758: misc/libreoffice4
1759:
1.69 asau 1760: At this point you can also review configuration in /usr/pbulk/etc and make
1761: final amendments, if wanted.
1762:
1.68 asau 1763: Start it:
1764:
1765: # /usr/pbulk/bin/bulkbuild
1766:
1767: After it finishes, you'll have /mnt filled with distribution files, binary
1768: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
1769:
1770: Note
1771:
1772: The pbulk.sh script does not cover all possible use cases. While being ready to
1773: run, it serves as a good starting point to understand and build more complex
1774: setups. The script is kept small enough for better understanding.
1775:
1776: Note
1777:
1778: The pbulk.sh script supports running unprivileged bulk build and helps
1.205 wiz 1779: configuring distributed bulk builds. Distributed bulk builds support either
1780: building in worker chroots (each node is a path to a different chroot) that
1781: replicate the target system, including the pbulk prefix, or remote machines
1782: (each node is an IP address that must be accessible over SSH without a
1783: password).
1.15 rillig 1784:
1.276 ! wiz 1785: 8.3. Running a bob build
! 1786:
! 1787: Bob is designed to be a simpler and more powerful alternative to pbulk. To get
! 1788: started, install the pkgtools/bob package, modify ${PKG_SYSCONFBASE}/bob/
! 1789: config.lua to customize the packages you wish to build and tune the settings
! 1790: for your system, then run
! 1791:
! 1792: # bob build
! 1793:
! 1794: This will build all of the packages you have selected inside clean sandboxes,
! 1795: and produce a pkg_summary file at the end, ready for pkgtools/pkgin to upgrade
! 1796: the system.
! 1797:
! 1798: Any time you update your pkgsrc checkout, first run
! 1799:
! 1800: # bob clean
! 1801:
! 1802: to remove the existing build metadata before starting a new build.
! 1803:
! 1804: Some other useful features include being able to run a scan separately first,
! 1805: so that you can see what packages will be built:
! 1806:
! 1807: # bob scan
! 1808: # bob status
! 1809:
! 1810: You can also add arbitrary packages to the current build by providing a PKGPATH
! 1811: as an argument:
! 1812:
! 1813: # bob build graphics/png
! 1814:
! 1815: If a package fails to build you can view the log file:
! 1816:
! 1817: # bob log png
! 1818:
! 1819: If you fix an issue and you only want to rebuild the previously failed packages
! 1820: without starting from scratch, you can run:
! 1821:
! 1822: # bob rebuild -a
! 1823:
! 1824: Other useful commands:
! 1825:
! 1826: # bob dev # run an interactive sandbox for development work
! 1827: # bob history # show package build history
! 1828: # bob publish # generate build reports, emails, and publish packages
! 1829:
! 1830: For more details, please see https://docs.rs/bob/latest/bob/.
! 1831:
! 1832: 8.4. Speeding up bulk build scans
1.272 wiz 1833:
1834: At the start of a bulk build. pkgsrc is scanned for details about the packages
1835: to build. This is needed e.g. to build a dependency graph for building the
1836: packages in the correct order.
1837:
1838: Basically, this calls make(1) once for each package. To speed this up, some
1839: variables can be pre-computed and others can be cached. This will greatly
1840: reduce the time needed for the scan part of a bulk build.
1841:
1842: The fake pkgtools/varcache package provides a Makefile target to precompute
1843: some often-used variables for the build system that shouldn't change during one
1844: build. Redirect its output to a file and include it from mk.conf; for example:
1845:
1846: $ cd pkgtools/varcache
1847: $ make show-varcache > /etc/varcache.mk
1848: $ echo .include "varcache.mk" >> /etc/mk.conf
1849:
1850:
1851: Some system information is needed quite early in the build and can not be
1852: cached this way. It must be set in the environment for the next speed-up:
1853:
1854: $ export HOST_MACHINE_ARCH=`uname -m`
1855: $ export NATIVE_OPSYS=`uname -s`
1856: $ 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}'`
1857: $ export NATIVE_OS_VERSION=`uname -r`
1858:
1859:
1860: Some settings that also affect the scan time strongly can be set in mk.conf:
1861:
1862: NATIVE_PKG_TOOLS_BIN=/usr/sbin # location on NetBSD
1863: NO_PKGTOOLS_REQD_CHECK=yes # assume pkg tools are up-to-date
1864: SKIP_LICENSE_CHECK=yes # do not check license validity
1865: _SRC_TOP_= # bulk build is not running from inside /usr/src
1866: UNPRIVILEGED_USER=pbulk # use the appropriate user for your system
1867: UNPRIVILEGED_GROUP=builder # use the appropriate group for your system
1868: UNPRIVILEGED_GROUPS=builder # use the appropriate groups for your system
1869:
1870: Finally, some packages require information about build options of other
1871: packages. This information can be cached by setting PBULK_CACHE_DIRECTORY.
1872:
1873: PBULK_CACHE_DIRECTORY=/tmp/pbulk_cache
1874:
1875: For all of these: please make sure they are kept up-to-date for changes in your
1876: environment. The safest method is to re-create the varcache before each build,
1877: make sure the environment variables are still up-to-date, and to delete the
1878: PBULK_CACHE_DIRECTORY before builds.
1879:
1.276 ! wiz 1880: 8.5. Requirements of a full bulk build
1.71 wiz 1881:
1882: A complete bulk build requires lots of disk space. Some of the disk space can
1883: be read-only, some other must be writable. Some can be on remote filesystems
1884: (such as NFS) and some should be local. Some can be temporary filesystems,
1885: others must survive a sudden reboot.
1886:
1.205 wiz 1887: * 70 GB for the distfiles (read-write, remote, temporary)
1.71 wiz 1888:
1.205 wiz 1889: * 60 GB for the binary packages (read-write, remote, permanent)
1.71 wiz 1890:
1891: * 1 GB for the pkgsrc tree (read-only, remote, permanent)
1892:
1893: * 5 GB for LOCALBASE (read-write, local, temporary)
1894:
1895: * 10 GB for the log files (read-write, remote, permanent)
1896:
1897: * 5 GB for temporary files (read-write, local, temporary)
1898:
1.276 ! wiz 1899: 8.6. Bulk build variants
1.178 rillig 1900:
1901: To ensure that pkgsrc packages work in different configurations, it makes sense
1902: to run non-default bulk builds from time to time. This section lists some ideas
1903: for bulk builds that intentionally let packages fail if they don't follow the
1904: pkgsrc style.
1905:
1.276 ! wiz 1906: 8.6.1. Detect unknown configure options
1.178 rillig 1907:
1908: Add the following line to mk.conf.
1909:
1910: GNU_CONFIGURE_STRICT= yes
1911:
1912: When a package fails this additional check, the most common cause is that the
1913: configure option was valid for an older version of the package but does not
1914: apply anymore. In that case, just remove it.
1915:
1.276 ! wiz 1916: 8.6.2. Detect classes of bugs by forcing compiler warnings
1.178 rillig 1917:
1918: The job of a compiler is not restricted to producing executable code, most
1.179 rillig 1919: compilers also detect typical programming mistakes. The pkgsrc compiler
1920: wrappers make it easy to force compiler options when the package is built. This
1921: can be used to find typical bugs across all packages that are in pkgsrc. By
1922: reporting these bugs upstream, the packages will be more reliable with the next
1923: updates.
1.178 rillig 1924:
1.179 rillig 1925: Add some of the following lines to mk.conf:
1.178 rillig 1926:
1927: CFLAGS+= -Werror=char-subscripts
1.179 rillig 1928: CFLAGS+= -Werror=implicit-function-declaration
1.178 rillig 1929:
1.179 rillig 1930: When a package fails to build using these stricter compiler options, document
1931: the circumstances in which the compiler produced the error message. This
1932: includes:
1.178 rillig 1933:
1934: * The platform (MACHINE_PLATFORM)
1935:
1936: * The source file
1937:
1938: * An excerpt of the code. GCC and Clang already do this as part of the
1939: diagnostic.
1940:
1.179 rillig 1941: * The exact error message from the compiler.
1.178 rillig 1942:
1.179 rillig 1943: If a package produces these error messages, but the package is fine, record
1944: this in your local mk.conf, like this, to skip this check in the next builds:
1.178 rillig 1945:
1.179 rillig 1946: .if ${PKGPATH} == category/package
1.178 rillig 1947: # Version ${VERSION} failed on ${MACHINE_PLATFORM}:
1948: # error message
1949: # code
1.179 rillig 1950: # Reason why the code does not need to be fixed.
1.178 rillig 1951: BUILDLINK_TRANSFORM+= rm:-Werror=char-subscripts
1.179 rillig 1952: .endif
1.178 rillig 1953:
1954: If the error messages from the compiler are valid and the code needs to be
1.179 rillig 1955: fixed, prepare a local patch (see LOCALPATCHES) and report the bug to the
1956: upstream authors of the package, providing them with the information you
1957: collected above.
1.178 rillig 1958:
1.179 rillig 1959: Patches that are not essential for the package to work should only be reported
1960: upstream but not committed to pkgsrc, to make future updates easier.
1961:
1.276 ! wiz 1962: 8.6.3. Force compiler options only in the build phase
1.181 rillig 1963:
1964: When adding custom compiler flags via CFLAGS, these apply to all phases of the
1965: package build process. Especially in the configure phase, adding -Werror leads
1966: to wrong decisions. The GNU configure scripts feed many small test programs to
1967: the C compiler to see whether certain headers are available, functions are
1968: defined in a library and programs can be run. In many cases these programs
1969: would not survive a strict compiler run with -Wall -Wextra -Werror.
1970:
1971: The pkgsrc infrastructure is flexible enough to support compiler options being
1972: added between the configure and build phases. It's a little more complicated
1973: than the other examples in this section but still easy enough.
1974:
1975: The basic idea is to use the pkgsrc compiler wrapper to inject the desired
1976: compiler options. The compiler wrapper's original task is to hide unwanted
1977: directories of include files and to normalize compiler options. It does this by
1978: wrapping the compiler command and rewriting the command line. To see this in
1979: action, run bmake patch in a package directory and examine the work/.cwrappers/
1980: config directory. It contains individual configurations for the C compiler and
1981: the related tools. The plan is to find a hook between the configure and build
1982: phases, and to modify these configuration files at that point.
1983:
1984: To find this hook, have a look at mk/build/build.mk, which contains among
1985: others the pre-build-checks-hook. The word checks doesn't quite fit, but the
1986: pre-build-hook sounds good enough.
1987:
1988: The code to be included in mk.conf is:
1989:
1990: # Just a few example options.
1991: BUILD_ONLY_CFLAGS= -Wall -Werror -O2 -DTEMPDIR='"/tmp"'
1992:
1993: .if ${BUILD_ONLY_CFLAGS:U:M*}
1994: pre-build-checks-hook: add-build-only-cflags
1995:
1996: add-build-only-cflags: .PHONY
1997: ${RUN} cd ${CWRAPPERS_CONFIG_DIR}; \
1998: ${TEST} ! -f ${.TARGET} || exit 0; \
1999: for flag in ${BUILD_ONLY_CFLAGS}; do \
2000: ${ECHO} "append=$$flag" >> cc; \
2001: done; \
2002: > ${.TARGET}
2003: .endif
2004:
2005: (When editing the mk.conf, make sure that the commands of the
2006: add-build-only-cflags target are indented with a tab, not with spaces.)
2007:
2008: The condition in the .if statement contains the :U modifier to prevent parse
2009: errors if the variable should be undefined, possibly because it is only defined
2010: for a subset of the packages. The :M* modifier ensures that there is at least
2011: one compiler option, to prevent a syntax error in the shell parser.
2012:
2013: The code around the ${.TARGET} variable ensures that the additional compiler
2014: options are only appended once, even if bmake build is run multiple times. To
2015: do this, it creates a marker file.
2016:
2017: To verify that this setup works, run bmake configure in a package directory. Up
2018: to now, everything works as usual. Examine the directory work/.cwrappers/config
2019: to see that the compiler options from BUILD_ONLY_CFLAGS are not yet added to
2020: the file cc. Examine the tail of the work/.work.log file to see that the normal
2021: compiler options are used.
2022:
2023: Now run bmake build. This will append the options to the file cc and will
2024: create the marker file in the same directory. After that, the build starts as
2025: usual, but with the added compiler options. Examine the tail of the file work
2026: /.work.log to see that the lines starting with [*] don't contain the compiler
2027: options, but the corresponding lines starting with <.> do end with these
2028: options.
2029:
2030: Building packages using this setup variant and fixing the resulting bugs is the
1.276 ! wiz 2031: same as in Section 8.6.2, Detect classes of bugs by forcing compiler warnings
1.181 rillig 2032: .
2033:
1.276 ! wiz 2034: 8.6.4. Use custom directories
1.178 rillig 2035:
2036: Some directories like PREFIX, VARBASE, PKG_SYSCONFDIR, PKGMANDIR, PKG_INFODIR
2037: can be configured in pkgsrc. Set these to arbitrary paths during bootstrap or
2038: afterwards in mk.conf.
2039:
2040: PREFIX= /a-random-uuid
2041: PKG_SYSCONFDIR= /a-random-uuid
2042: VARBASE= /a-random-uuid
2043: PKGMANDIR= a-random-uuid
2044: PKG_INFODIR= a-random-uuid
2045:
1.276 ! wiz 2046: 8.6.5. Turn warnings into errors
1.178 rillig 2047:
2048: When building a package, warnings are typically ignored since they just flow by
2049: and do not cause the build to fail immediately. To find these warnings,
2050: redefine them to errors in mk.conf.
2051:
2052: DELAYED_WARNING_MSG= ${DELAYED_ERROR_MSG} "(was warning)"
2053: WARNING_MSG= ${FAIL_MSG} "(was warning)"
2054:
2055: (There are many more classes of warnings in pkgsrc, and most of them can be
2056: redefined with a simple definition like above.
2057:
1.179 rillig 2058: If a package suggests to add USE_TOOLS+=perl to the package Makefile, research
1.178 rillig 2059: whether the package actually needs Perl. If it does, add USE_TOOLS+=perl to the
2060: package Makefile, and if it doesn't, add TOOLS_BROKEN+=perl.
2061:
1.276 ! wiz 2062: 8.6.6. Reject packages for which pkglint reports errors
1.178 rillig 2063:
2064: Using pkglint as part of the regular build process is mostly a waste of time.
2065: If you want to fix some of the warnings, just run pkglint recursively on the
2066: whole pkgsrc tree. This will take a few minutes (up to 10), which is much
2067: faster than a complete bulk build.
2068:
1.276 ! wiz 2069: 8.6.7. Reject packages that contain forbidden strings
1.178 rillig 2070:
2071: To ensure that the binary packages don't contain references to the build
2072: directory, there is already CHECK_WRKREF. If that variable includes the item
2073: extra, it is possible to define additional patterns that must not appear in any
2074: installed file. This is specified in mk.conf.
2075:
2076: CHECK_WRKREF= extra
2077: CHECK_WRKREF_EXTRA_DIRS+= /usr/local
2078: CHECK_WRKREF_EXTRA_DIRS+= /usr/pkg
2079: CHECK_WRKREF_EXTRA_DIRS+= @[A-Z][A-Z]*@
2080:
2081: The above patterns will probably generate many false positives, therefore the
2082: results need to be taken with a grain of salt.
2083:
1.276 ! wiz 2084: 8.6.8. Reject packages whose self-test fails
1.178 rillig 2085:
2086: To run the test suites that come with each package, add this line to mk.conf.
2087:
2088: PKGSRC_RUN_TEST= yes
2089:
2090: Be prepared that even the most basic packages fail this test. When doing a bulk
2091: build with this, it will often abort in the early phase where the packages are
2092: scanned for their dependencies since there are cyclic dependencies. There is
2093: still a lot to do in this area.
2094:
1.276 ! wiz 2095: 8.6.9. Reject packages that use undefined shell variables
1.178 rillig 2096:
2097: To catch typos in the shell snippets from the Makefile fragments, add the -u
2098: flag to most of the commands by adding this line to mk.conf.
2099:
2100: RUN= @set -eu;
2101:
1.181 rillig 2102: After that, ensure that none of the bulk build log files (even those for
2103: successfully built packages) contains the string parameter not set or whatever
2104: error message the command sh -ceu '$undefined' outputs.
2105:
1.178 rillig 2106: See mk/misc/common.mk for the existing definition.
2107:
1.276 ! wiz 2108: 8.6.10. Turn off verbose logging
1.178 rillig 2109:
2110: The build logs of a package are often quite long. This allows error messages or
2111: other interesting details to hide between the noise. To make the actual error
2112: message stand out more, add these lines to mk.conf.
2113:
2114: GNU_CONFIGURE_QUIET= yes
2115: MAKE_FLAGS+= -s
2116:
2117: The -s option works for both GNU Make and BSD Make. On exotic platforms with
2118: their own make, it may be a little different.
2119:
1.276 ! wiz 2120: 8.7. Creating a multiple CD-ROM packages collection
1.1 dsieger 2121:
2122: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
2123: of the resulting binary packages to assist in installing packages on other
2124: machines. The pkgtools/cdpack package provides a simple tool for creating the
2125: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
2126: keeps all the dependencies for a given package on the same CD as that package.
2127:
1.276 ! wiz 2128: 8.7.1. Example of cdpack
1.1 dsieger 2129:
2130: Complete documentation for cdpack is found in the cdpack(1) man page. The
2131: following short example assumes that the binary packages are left in /usr/
2132: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
2133: ISO 9660 images.
2134:
2135: # mkdir /u2/images
2136: # pkg_add /usr/pkgsrc/packages/All/cdpack
2137: # cdpack /usr/pkgsrc/packages/All /u2/images
2138:
2139:
2140: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
2141: CD in the collection, then you need to create a directory which contains these
1.175 gutterid 2142: files, e.g.:
1.1 dsieger 2143:
2144: # mkdir /tmp/common
2145: # echo "This is a README" > /tmp/common/README
2146: # echo "Another file" > /tmp/common/COPYING
2147: # mkdir /tmp/common/bin
2148: # echo "#!/bin/sh" > /tmp/common/bin/myscript
2149: # echo "echo Hello world" >> /tmp/common/bin/myscript
2150: # chmod 755 /tmp/common/bin/myscript
2151:
2152:
2153: Now create the images:
2154:
2155: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
2156:
2157: Each image will contain README, COPYING, and bin/myscript in their root
2158: directories.
2159:
1.266 martin 2160: Chapter 9. Directory layout of the installed files
1.1 dsieger 2161:
2162: Table of Contents
2163:
1.154 rillig 2164: 9.1. File system layout in ${LOCALBASE}
2165: 9.2. File system layout in ${VARBASE}
1.1 dsieger 2166:
2167: The files that are installed by pkgsrc are organized in a way that is similar
2168: to what you find in the /usr directory of the base system. But some details are
2169: different. This is because pkgsrc initially came from FreeBSD and had adopted
2170: its file system hierarchy. Later it was largely influenced by NetBSD. But no
2171: matter which operating system you are using pkgsrc with, you can expect the
2172: same layout for pkgsrc.
2173:
2174: There are mainly four root directories for pkgsrc, which are all configurable
2175: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
2176: default locations are:
2177:
2178: LOCALBASE= /usr/pkg
2179: PKG_SYSCONFBASE= /usr/pkg/etc
2180: VARBASE= /var
1.119 sevan 2181: PKG_DBDIR= /usr/pkg/pkgdb
1.1 dsieger 2182:
2183: In unprivileged mode (when pkgsrc has been installed as any other user), the
2184: default locations are:
2185:
2186: LOCALBASE= ${HOME}/pkg
2187: PKG_SYSCONFBASE= ${HOME}/pkg/etc
2188: VARBASE= ${HOME}/pkg/var
1.119 sevan 2189: PKG_DBDIR= ${HOME}/pkg/pkgdb
1.1 dsieger 2190:
2191: What these four directories are for, and what they look like is explained
2192: below.
2193:
1.266 martin 2194: * LOCALBASE corresponds to the /usr directory in the base system. It is the
2195: main directory where the files are installed and contains the well-known
1.1 dsieger 2196: subdirectories like bin, include, lib, share and sbin.
2197:
2198: * VARBASE corresponds to /var in the base system. Some programs (especially
2199: games, network daemons) need write access to it during normal operation.
2200:
2201: * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
2202: configuration files of the packages, as well as pkgsrc's mk.conf itself.
2203:
1.266 martin 2204: 9.1. File system layout in ${LOCALBASE}
1.1 dsieger 2205:
2206: The following directories exist in a typical pkgsrc installation in $
2207: {LOCALBASE}.
2208:
2209: bin
2210:
2211: Contains executable programs that are intended to be directly used by the
2212: end user.
2213:
2214: emul
2215:
2216: Contains files for the emulation layers of various other operating systems,
2217: especially for NetBSD.
2218:
2219: etc (the usual location of ${PKG_SYSCONFDIR})
2220:
2221: Contains the configuration files.
2222:
2223: include
2224:
2225: Contains headers for the C and C++ programming languages.
2226:
2227: info
2228:
2229: Contains GNU info files of various packages.
2230:
2231: lib
2232:
2233: Contains shared and static libraries.
2234:
2235: libdata
2236:
2237: Contains data files that don't change after installation. Other data files
2238: belong into ${VARBASE}.
2239:
2240: libexec
2241:
2242: Contains programs that are not intended to be used by end users, such as
2243: helper programs or network daemons.
2244:
2245: libexec/cgi-bin
2246:
2247: Contains programs that are intended to be executed as CGI scripts by a web
2248: server.
2249:
2250: man (the usual value of ${PKGMANDIR})
2251:
2252: Contains brief documentation in form of manual pages.
2253:
2254: sbin
2255:
2256: Contains programs that are intended to be used only by the super-user.
2257:
2258: share
2259:
2260: Contains platform-independent data files that don't change after
2261: installation.
2262:
2263: share/doc
2264:
2265: Contains documentation files provided by the packages.
2266:
2267: share/examples
2268:
2269: Contains example files provided by the packages. Among others, the original
2270: configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
2271: installation.
2272:
2273: share/examples/rc.d
2274:
2275: Contains the original files for rc.d scripts.
2276:
2277: var (the usual location of ${VARBASE})
2278:
2279: Contains files that may be modified after installation.
2280:
1.266 martin 2281: 9.2. File system layout in ${VARBASE}
1.1 dsieger 2282:
2283: db/pkg (the usual location of ${PKG_DBDIR})
2284:
2285: Contains information about the currently installed packages.
2286:
2287: games
2288:
2289: Contains highscore files.
2290:
2291: log
2292:
2293: Contains log files.
2294:
2295: run
2296:
2297: Contains informational files about daemons that are currently running.
2298:
1.266 martin 2299: Chapter 10. Frequently Asked Questions
1.1 dsieger 2300:
2301: Table of Contents
2302:
1.154 rillig 2303: 10.1. Are there any mailing lists for pkg-related discussion?
2304: 10.2. Utilities for package management (pkgtools)
2305: 10.3. How to use pkgsrc as non-root
2306: 10.4. How to resume transfers when fetching distfiles?
2307: 10.5. How can I install/use modular X.org from pkgsrc?
2308: 10.6. How to fetch files from behind a firewall
2309: 10.7. How to fetch files from HTTPS sites
2310: 10.8. How do I tell make fetch to do passive FTP?
2311: 10.9. How to fetch all distfiles at once
1.266 martin 2312: 10.10. What does Don't know how to make /usr/share/tmac/tmac.andoc mean?
2313: 10.11. What does Could not find bsd.own.mk mean?
1.221 nia 2314: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154 rillig 2315: 10.13. How do I change the location of configuration files?
2316: 10.14. Automated security checks
2317: 10.15. Why do some packages ignore my CFLAGS?
2318: 10.16. A package does not build. What shall I do?
1.266 martin 2319: 10.17. What does Makefile appears to contain unresolved cvs/rcs/??? merge
1.271 wiz 2320: conflicts mean?
1.1 dsieger 2321:
2322: This section contains hints, tips & tricks on special things in pkgsrc that we
2323: didn't find a better place for in the previous chapters, and it contains items
2324: for both pkgsrc users and developers.
2325:
1.266 martin 2326: 10.1. Are there any mailing lists for pkg-related discussion?
1.1 dsieger 2327:
2328: The following mailing lists may be of interest to pkgsrc users:
2329:
2330: * pkgsrc-users: This is a general purpose list for most issues regarding
2331: pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
2332: configuration, unexpected build failures, using particular packages,
2333: upgrading pkgsrc installations, questions regarding the pkgsrc release
2334: branches, etc. General announcements or proposals for changes that impact
2335: the pkgsrc user community, e.g. major infrastructure changes, new features,
2336: package removals, etc., may also be posted.
2337:
2338: * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
2339: discussed.
2340:
2341: * pkgsrc-changes: This list is for those who are interested in getting a
2342: commit message for every change committed to pkgsrc. It is also available
2343: in digest form, meaning one daily message containing all commit messages
2344: for changes to the package source tree in that 24 hour period.
2345:
2346: To subscribe, do:
2347:
2348: % echo subscribe listname | mail majordomo@NetBSD.org
2349:
1.174 leot 2350: Archives for all these mailing lists are available from https://
1.1 dsieger 2351: mail-index.NetBSD.org/.
2352:
1.266 martin 2353: 10.2. Utilities for package management (pkgtools)
1.1 dsieger 2354:
2355: The directory pkgsrc/pkgtools contains a number of useful utilities for both
2356: users and developers of pkgsrc. This section attempts only to make the reader
1.121 sevan 2357: aware of some of the utilities and when they might be useful, and not to
2358: duplicate the documentation that comes with each package.
1.1 dsieger 2359:
2360: Utilities used by pkgsrc (automatically installed when needed):
2361:
2362: * pkgtools/x11-links: Symlinks for use by buildlink.
2363:
2364: OS tool augmentation (automatically installed when needed):
2365:
1.121 sevan 2366: * pkgtools/digest: Calculates various kinds of checksums (including SHA3).
1.1 dsieger 2367:
2368: * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
2369:
2370: * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
2371:
2372: * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
2373: for use on operating systems where pkg_install is not present.
2374:
2375: Utilities used by pkgsrc (not automatically installed):
2376:
2377: * pkgtools/pkg_tarup: Create a binary package from an already-installed
2378: package. Used by make replace to save the old package.
2379:
2380: * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
2381: distfiles from multiple locations. It currently supports the following
2382: methods: multiple CD-ROMs and network FTP/HTTP connections.
2383:
2384: * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24 wiz 2385: current CPU and compiler.
1.1 dsieger 2386:
2387: Utilities for keeping track of installed packages, being up to date, etc:
2388:
1.65 wiz 2389: * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
2390: and upgrade binary packages easily.
2391:
1.1 dsieger 2392: * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
2393: the latest pkgsrc entries.
2394:
2395: * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
2396: strategy for updating.
2397:
2398: * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
2399: graphviz).
2400:
1.12 weinem 2401: * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
2402:
2403: * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
2404: complete pkgsrc system.
1.1 dsieger 2405:
2406: * pkgtools/pkgsurvey: Report what packages you have installed.
2407:
2408: Utilities for people maintaining or creating individual packages:
2409:
2410: * pkgtools/pkgdiff: Automate making and maintaining patches for a package
2411: (includes pkgdiff, pkgvi, mkpatches, etc.).
2412:
1.65 wiz 2413: * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1 dsieger 2414:
2415: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
2416:
2417: * pkgtools/pkg_comp: Build packages in a chrooted area.
2418:
2419: * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
2420:
1.266 martin 2421: 10.3. How to use pkgsrc as non-root
1.1 dsieger 2422:
1.108 rillig 2423: To install packages from source as a non-root user, download pkgsrc as
1.266 martin 2424: described in Chapter 3, Where to get pkgsrc and how to keep it up-to-date, cd
1.108 rillig 2425: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
2426:
2427: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
2428: configuration mk.conf into ~/pkg/etc.
2429:
2430: For more details, see mk/unprivileged.mk.
1.1 dsieger 2431:
1.266 martin 2432: 10.4. How to resume transfers when fetching distfiles?
1.1 dsieger 2433:
2434: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4 rillig 2435: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
2436: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1 dsieger 2437:
1.61 wiz 2438: You can also use a different program than the platform default program by
2439: changing the FETCH_USING variable. You can specify the program by using of ftp,
2440: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
2441: manual. A value of custom disables the system defaults and dependency tracking
2442: for the fetch program. In that case you have to provide FETCH_CMD,
2443: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1 dsieger 2444:
1.16 jnemeth 2445: For example, if you want to use wget to download, you'll have to use something
2446: like:
1.1 dsieger 2447:
1.16 jnemeth 2448: FETCH_USING= wget
1.1 dsieger 2449:
1.266 martin 2450: 10.5. How can I install/use modular X.org from pkgsrc?
1.1 dsieger 2451:
1.4 rillig 2452: If you want to use modular X.org from pkgsrc instead of your system's own X11
2453: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1 dsieger 2454: mk.conf:
2455:
1.4 rillig 2456: X11_TYPE=modular
1.1 dsieger 2457:
1.266 martin 2458: 10.6. How to fetch files from behind a firewall
1.1 dsieger 2459:
2460: If you are sitting behind a firewall which does not allow direct connections to
2461: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
2462: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
1.266 martin 2463: machine orpheus.amdahl.com is one of the firewalls, and it uses port 80 as
1.1 dsieger 2464: the proxy port number. So the proxy environment variables are:
2465:
2466: ftp_proxy=ftp://orpheus.amdahl.com:80/
2467: http_proxy=http://orpheus.amdahl.com:80/
2468:
1.266 martin 2469: 10.7. How to fetch files from HTTPS sites
1.65 wiz 2470:
2471: Some fetch tools are not prepared to support HTTPS by default (for example, the
2472: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
2473: openssl dependency that low in the dependency graph).
2474:
1.266 martin 2475: Usually you won't notice, because distribution files are mirrored weekly to
2476: ftp.NetBSD.org , but that might not be often enough if you are following
2477: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to curl or
2478: wget , which are both compiled with HTTPS support by default. Of course, these
1.65 wiz 2479: tools need to be installed before you can use them this way.
2480:
1.266 martin 2481: 10.8. How do I tell make fetch to do passive FTP?
1.1 dsieger 2482:
2483: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
2484: FETCH_CMD is assigned the first available command from the following list:
2485:
2486: * ${LOCALBASE}/bin/ftp
2487:
2488: * /usr/bin/ftp
2489:
2490: On a default NetBSD installation, this will be /usr/bin/ftp, which
2491: automatically tries passive connections first, and falls back to active
2492: connections if the server refuses to do passive. For the other tools, add the
1.4 rillig 2493: following to your mk.conf file: PASSIVE_FETCH=1.
1.1 dsieger 2494:
2495: Having that option present will prevent /usr/bin/ftp from falling back to
2496: active transfers.
2497:
1.266 martin 2498: 10.9. How to fetch all distfiles at once
1.1 dsieger 2499:
2500: You would like to download all the distfiles in a single batch from work or
2501: university, where you can't run a make fetch. There is an archive of distfiles
2502: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
2503:
2504: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
2505: subdirectories, carry the resulting list to your machine at work/school and use
2506: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
2507: don't forget to set FETCH_CMD to something that fetches a URL:
2508:
2509: At home:
2510:
2511: % cd /usr/pkgsrc
2512: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
2513: % scp /tmp/fetch.sh work:/tmp
2514:
2515: At work:
2516:
2517: % sh /tmp/fetch.sh
2518:
2519: then tar up /tmp/distfiles and take it home.
2520:
2521: If you have a machine running NetBSD, and you want to get all distfiles (even
2522: ones that aren't for your machine architecture), you can do so by using the
2523: above-mentioned make fetch-list approach, or fetch the distfiles directly by
2524: running:
2525:
2526: % make mirror-distfiles
2527:
2528: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
2529: everything by running:
2530:
2531: % make fetch NO_SKIP=yes
2532:
1.266 martin 2533: 10.10. What does Don't know how to make /usr/share/tmac/tmac.andoc mean?
1.1 dsieger 2534:
2535: When compiling the pkgtools/pkg_install package, you get the error from make
2536: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
1.266 martin 2537: that you don't have installed the text set (nroff, ...) from the NetBSD base
1.1 dsieger 2538: distribution on your machine. It is recommended to do that to format man pages.
2539:
2540: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4 rillig 2541: NOMAN=YES either in the environment or in mk.conf.
1.1 dsieger 2542:
1.266 martin 2543: 10.11. What does Could not find bsd.own.mk mean?
1.1 dsieger 2544:
2545: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
2546: machine. Please get and install it, by extracting it in /:
2547:
2548: # cd /
2549: # tar --unlink -zxvpf .../comp.tgz
2550:
2551: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
2552: release (determine via uname -r).
2553:
1.266 martin 2554: 10.12. Using 'sudo' or `priv` with pkgsrc
1.1 dsieger 2555:
2556: When installing packages as non-root user and using the just-in-time su(1)
2557: feature of pkgsrc, it can become annoying to type in the root password for each
2558: required package installed. To avoid this, the sudo package can be used, which
1.221 nia 2559: does password caching over a limited time. To use it, install sudo or priv
2560: (either as binary package, from security/priv, or security/sudo) and then put
2561: the following into your mk.conf, somewhere after the definition of the
2562: LOCALBASE variable:
1.1 dsieger 2563:
2564: .if exists(${LOCALBASE}/bin/sudo)
1.260 wiz 2565: SU_CMD= ${LOCALBASE}/bin/sudo -E /bin/sh -c
1.1 dsieger 2566: .endif
2567:
1.260 wiz 2568: Note the -E flag; that tells sudo to preserve the environment. Without this,
2569: the bin-install target will fail when building a package with a non-default
2570: python version.
2571:
1.266 martin 2572: 10.13. How do I change the location of configuration files?
1.1 dsieger 2573:
2574: As the system administrator, you can choose where configuration files are
2575: installed. The default settings make all these files go into ${PREFIX}/etc or
2576: some of its subdirectories; this may be suboptimal depending on your
2577: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
2578: configuration of the provided packages).
2579:
2580: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4 rillig 2581: (in mk.conf) to point to your preferred configuration directory; some common
2582: examples include /etc or /etc/pkg.
1.1 dsieger 2583:
2584: Furthermore, you can change this value on a per-package basis by setting the
2585: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
2586: matches the name of the package you would like to modify, that is, the contents
2587: of PKGBASE.
2588:
2589: Note that after changing these settings, you must rebuild and reinstall any
2590: affected packages.
2591:
1.266 martin 2592: 10.14. Automated security checks
1.1 dsieger 2593:
2594: Please be aware that there can often be bugs in third-party software, and some
2595: of these bugs can leave a machine vulnerable to exploitation by attackers. In
2596: an effort to lessen the exposure, the NetBSD packages team maintains a database
2597: of known-exploits to packages which have at one time been included in pkgsrc.
2598: The database can be downloaded automatically, and a security audit of all
1.14 jmcneill 2599: packages installed on a system can take place. To do this, refer to the
2600: following two tools (installed as part of the pkgtools/pkg_install package):
1.1 dsieger 2601:
1.21 snj 2602: 1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
2603: security vulnerabilities information. This list is kept up to date by the
1.26 spz 2604: pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1 dsieger 2605:
1.177 leot 2606: https://ftp.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities
1.1 dsieger 2607:
1.21 snj 2608: 2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24 wiz 2609: known vulnerability. If a vulnerable package is installed, it will be shown
2610: by output to stdout, including a description of the type of vulnerability,
2611: and a URL containing more information.
1.1 dsieger 2612:
1.266 martin 2613: Use of these tools is strongly recommended! See Section 5.1.6, Checking for
2614: security vulnerabilities in installed packages for instructions on how to
1.121 sevan 2615: automate checking and reporting.
2616:
2617: If this database is installed, pkgsrc builds will use it to perform a security
2618: check before building any package.
1.1 dsieger 2619:
1.266 martin 2620: 10.15. Why do some packages ignore my CFLAGS?
1.1 dsieger 2621:
2622: When you add your own preferences to the CFLAGS variable in your mk.conf, these
2623: flags are passed in environment variables to the ./configure scripts and to
2624: make(1). Some package authors ignore the CFLAGS from the environment variable
2625: by overriding them in the Makefiles of their package.
2626:
2627: Currently there is no solution to this problem. If you really need the package
2628: to use your CFLAGS you should run make patch in the package directory and then
2629: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
1.266 martin 2630: Usually you can remove these lines. But be aware that some smart programmers
1.1 dsieger 2631: write so bad code that it only works for the specific combination of CFLAGS
2632: they have chosen.
2633:
1.172 rillig 2634: To find out where the CFLAGS are ignored, add the following lines to mk.conf:
2635:
2636: CPPFLAGS+= -Dpkgsrc___CPPFLAGS
2637: CFLAGS+= -Dpkgsrc___CFLAGS
2638: CXXFLAGS+= -Dpkgsrc___CXXFLAGS
2639:
2640: Then run bmake show-all-configure show-all-build to see whether the above flags
2641: are passed to the actual build commands in general.
2642:
2643: To find out whether the flags are passed to individual compiler commands, have
2644: a look at the file work/.work.log. In most cases, the flags from the original
2645: command lines (the lines starting with [*]) are passed unmodified to the actual
2646: compiler (the lines starting with <.>). If the flag is missing from the actual
2647: compiler command, it must have been removed by the pkgsrc compiler wrappers.
2648:
1.266 martin 2649: 10.16. A package does not build. What shall I do?
1.1 dsieger 2650:
2651: 1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
2652: is that people only update pkgsrc in parts, because of performance reasons.
2653: Since pkgsrc is one large system, not a collection of many small systems,
2654: there are sometimes changes that only work when the whole pkgsrc tree is
2655: updated.
2656:
1.266 martin 2657: 2. Make sure that you don't have any CVS conflicts. Search for <<<<<< or
2658: >>>>>> in all your pkgsrc files.
1.1 dsieger 2659:
1.25 wiz 2660: 3. Make sure that you don't have old copies of the packages extracted. Run
1.1 dsieger 2661: make clean clean-depends to verify this.
2662:
1.108 rillig 2663: 4. If you are a package developer who wants to invest some work, have a look
1.266 martin 2664: at Chapter 21, Making your package work.
1.108 rillig 2665:
2666: 5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1 dsieger 2667:
1.266 martin 2668: 10.17. What does Makefile appears to contain unresolved cvs/rcs/??? merge
2669: conflicts mean?
1.1 dsieger 2670:
2671: You have modified a file from pkgsrc, and someone else has modified that same
2672: file afterwards in the CVS repository. Both changes are in the same region of
2673: the file, so when you updated pkgsrc, the cvs command marked the conflicting
2674: changes in the file. Because of these markers, the file is no longer a valid
2675: Makefile.
2676:
2677: Have a look at that file, and if you don't need your local changes anymore, you
2678: can remove that file and run cvs -q update -dP in that directory to download
2679: the current version.
2680:
1.266 martin 2681: Part II. The pkgsrc developer's guide
1.1 dsieger 2682:
2683: This part of the book deals with creating and modifying packages. It starts
1.266 martin 2684: with a HOWTO -like guide on creating a new package. The remaining chapters are
1.1 dsieger 2685: more like a reference manual for pkgsrc.
2686:
2687: Table of Contents
2688:
1.154 rillig 2689: 11. Getting help
1.184 rillig 2690: 12. Package components - files, directories and contents
2691: 12.1. Makefile
2692: 12.2. distinfo
2693: 12.3. patches/*
2694: 12.3.1. Structure of a single patch file
2695: 12.3.2. Creating patch files
2696: 12.3.3. Sources where the patch files come from
2697: 12.3.4. Patching guidelines
2698: 12.3.5. Feedback to the author
2699: 12.4. Other mandatory files
2700: 12.5. Optional files
2701: 12.5.1. Files affecting the binary package
2702: 12.5.2. Files affecting the build process
2703: 12.5.3. Files affecting nothing at all
2704: 12.6. work*
2705: 12.7. files/*
2706: 13. The build process
2707: 13.1. Introduction
2708: 13.2. Program location
2709: 13.3. Directories used during the build process
2710: 13.4. Running a phase
2711: 13.5. The fetch phase
2712: 13.5.1. What to fetch and where to get it from
2713: 13.5.2. How are the files fetched?
2714: 13.6. The checksum phase
2715: 13.7. The extract phase
2716: 13.8. The patch phase
2717: 13.9. The tools phase
2718: 13.10. The wrapper phase
2719: 13.11. The configure phase
2720: 13.12. The build phase
2721: 13.13. The test phase
2722: 13.14. The install phase
2723: 13.15. The package phase
2724: 13.16. Cleaning up
2725: 13.17. Other helpful targets
2726: 14. Creating a new pkgsrc package from scratch
2727: 14.1. Common types of packages
1.219 nia 2728: 14.1.1. Python modules and programs
2729: 14.1.2. R packages
2730: 14.1.3. TeXlive packages
1.184 rillig 2731: 14.2. Examples
2732: 14.2.1. How the www/nvu package came into pkgsrc
2733: 15. Programming in Makefiles
2734: 15.1. Caveats
2735: 15.2. Makefile variables
2736: 15.2.1. Naming conventions
2737: 15.3. Code snippets
2738: 15.3.1. Adding things to a list
2739: 15.3.2. Echoing a string exactly as-is
2740: 15.3.3. Passing CFLAGS to GNU configure scripts
2741: 15.3.4. Handling possibly empty variables
1.229 gutterid 2742: 15.3.5. Testing yes/no variables in conditions
1.184 rillig 2743: 16. Options handling
2744: 16.1. Global default options
2745: 16.2. Converting packages to use bsd.options.mk
2746: 16.3. Option Names
2747: 16.4. Determining the options of dependencies
2748: 17. Tools needed for building or running
2749: 17.1. Tools for pkgsrc builds
2750: 17.2. Tools needed by packages
2751: 17.3. Tools provided by platforms
2752: 18. Buildlink methodology
2753: 18.1. Converting packages to use buildlink3
2754: 18.2. Writing buildlink3.mk files
2755: 18.2.1. Anatomy of a buildlink3.mk file
2756: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
1.271 wiz 2757: pkg in buildlink3.mk files
1.184 rillig 2758: 18.3. Writing builtin.mk files
2759: 18.3.1. Anatomy of a builtin.mk file
2760: 19. PLIST issues
2761: 19.1. RCS ID
2762: 19.2. Semi-automatic PLIST generation
2763: 19.3. Tweaking output of make print-PLIST
2764: 19.4. Variable substitution in PLIST
2765: 19.5. Man page compression
2766: 19.6. Changing PLIST source with PLIST_SRC
2767: 19.7. Platform-specific and differing PLISTs
2768: 19.8. Build-specific PLISTs
2769: 19.9. Sharing directories between packages
2770: 20. The pkginstall framework
2771: 20.1. Files and directories outside the installation prefix
2772: 20.1.1. Directory manipulation
2773: 20.1.2. File manipulation
2774: 20.2. Configuration files
2775: 20.2.1. How PKG_SYSCONFDIR is set
2776: 20.2.2. Telling the software where configuration files are
1.239 dholland 2777: 20.2.3. Patching installation
2778: 20.2.4. Declaring configuration files
2779: 20.2.5. Disabling handling of configuration files
1.184 rillig 2780: 20.3. System startup scripts
2781: 20.3.1. Disabling handling of system startup scripts
2782: 20.4. System users and groups
2783: 20.5. System shells
2784: 20.5.1. Disabling shell registration
2785: 20.6. Fonts
2786: 20.6.1. Disabling automatic update of the fonts databases
1.154 rillig 2787: 21. Making your package work
2788: 21.1. General operation
2789: 21.1.1. How to pull in user-settable variables from mk.conf
2790: 21.1.2. User interaction
2791: 21.1.3. Handling licenses
2792: 21.1.4. Restricted packages
2793: 21.1.5. Handling dependencies
2794: 21.1.6. Handling conflicts with other packages
2795: 21.1.7. Packages that cannot or should not be built
2796: 21.1.8. Packages which should not be deleted, once installed
2797: 21.1.9. Handling packages with security problems
2798: 21.1.10. How to handle incrementing versions when fixing an existing
1.271 wiz 2799: package
1.154 rillig 2800: 21.1.11. Substituting variable text in the package files (the SUBST
1.271 wiz 2801: framework)
1.154 rillig 2802: 21.2. The fetch phase
2803: 21.2.1. Packages whose distfiles aren't available for plain downloading
2804: 21.2.2. How to handle modified distfiles with the 'old' name
2805: 21.2.3. Packages hosted on github.com
2806: 21.3. The configure phase
2807: 21.3.1. Shared libraries - libtool
2808: 21.3.2. Using libtool on GNU packages that already support libtool
2809: 21.3.3. GNU Autoconf/Automake
1.223 nia 2810: 21.3.4. Meson / ninja
1.260 wiz 2811: 21.3.5. Determining the endianness
1.154 rillig 2812: 21.4. Programming languages
2813: 21.4.1. C, C++, and Fortran
2814: 21.4.2. Java
1.205 wiz 2815: 21.4.3. Go
1.223 nia 2816: 21.4.4. Rust
2817: 21.4.5. Packages containing Perl scripts
2818: 21.4.6. Packages containing shell scripts
2819: 21.4.7. Other programming languages
1.154 rillig 2820: 21.5. The build phase
2821: 21.5.1. Compiling C and C++ code conditionally
2822: 21.5.2. How to handle compiler bugs
1.172 rillig 2823: 21.5.3. No such file or directory
1.266 martin 2824: 21.5.4. Undefined reference to ...
1.172 rillig 2825: 21.5.5. Running out of memory
1.154 rillig 2826: 21.6. The install phase
2827: 21.6.1. Creating needed directories
2828: 21.6.2. Where to install documentation
2829: 21.6.3. Installing highscore files
2830: 21.6.4. Adding DESTDIR support to packages
2831: 21.6.5. Packages with hardcoded paths to other interpreters
1.203 nia 2832: 21.6.6. Packages installing Perl modules
1.254 wiz 2833: 21.6.7. Packages installing pkg-config files
2834: 21.6.8. Packages installing info files
2835: 21.6.9. Packages installing man pages
2836: 21.6.10. Packages installing X11 fonts
2837: 21.6.11. Packages installing SGML or XML data
2838: 21.6.12. Packages installing extensions to the MIME database
2839: 21.6.13. Packages using intltool
2840: 21.6.14. Packages installing startup scripts
2841: 21.6.15. Packages installing TeX modules
2842: 21.6.16. Packages supporting running binaries in emulation
2843: 21.6.17. Packages installing hicolor icons
2844: 21.6.18. Packages installing desktop files
1.154 rillig 2845: 21.7. Marking packages as having problems
1.184 rillig 2846: 22. GNOME packaging and porting
2847: 22.1. Meta packages
2848: 22.2. Packaging a GNOME application
2849: 22.3. Updating GNOME to a newer version
2850: 22.4. Patching guidelines
1.154 rillig 2851: 23. Submitting and Committing
2852: 23.1. Submitting binary packages
2853: 23.2. Submitting source packages (for non-NetBSD-developers)
2854: 23.3. General notes when adding, updating, or removing packages
2855: 23.4. Commit Messages
2856: 23.5. Committing: Adding a package to CVS
2857: 23.6. Updating a package to a newer version
2858: 23.7. Renaming a package in pkgsrc
2859: 23.8. Moving a package in pkgsrc
1.263 wiz 2860: 24. pkgsrc Policies
2861: 24.1. Packages for which updating is restricted
2862: 24.1.1. Limited Updates - ABI
2863: 24.1.2. Limited Updates - Bootstrap
2864: 25. Frequently Asked Questions
1.154 rillig 2865:
1.266 martin 2866: Chapter 11. Getting help
1.154 rillig 2867:
2868: To get help when developing pkgsrc, the definitive source is this document, the
2869: pkgsrc guide. If you don't find anything here, there are alternatives:
2870:
2871: * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
1.266 martin 2872: Run bmake help topic= to get help for any topic, such as a variable name
1.154 rillig 2873: like BUILD_DEFS, a make target like do-build, a missing C or C++ function
2874: like strcasecmp or any other topic.
2875:
1.266 martin 2876: The available help topics are listed in Appendix E, Help topics.
1.154 rillig 2877:
1.163 rillig 2878: * To see the value of a single variable, run bmake show-var VARNAME=X.
2879:
2880: * To see the values of the most common variables, run bmake show-all. These
2881: variables are grouped by topic. To see the variables for a single topic,
2882: run bmake show-all-topic, for example bmake show-all-fetch.
2883:
1.154 rillig 2884: * The tech-pkg mailing list, to which you can subscribe and then ask your
2885: questions.
2886:
2887: * The #pkgsrc IRC channel, which is accessible via a web browser or by using
2888: a specialized chat program such as XChat. Pick any user name and join the
2889: channel #pkgsrc.
1.1 dsieger 2890:
1.266 martin 2891: Chapter 12. Package components - files, directories and contents
1.1 dsieger 2892:
2893: Table of Contents
2894:
1.184 rillig 2895: 12.1. Makefile
2896: 12.2. distinfo
2897: 12.3. patches/*
2898: 12.3.1. Structure of a single patch file
2899: 12.3.2. Creating patch files
2900: 12.3.3. Sources where the patch files come from
2901: 12.3.4. Patching guidelines
2902: 12.3.5. Feedback to the author
2903: 12.4. Other mandatory files
2904: 12.5. Optional files
2905: 12.5.1. Files affecting the binary package
2906: 12.5.2. Files affecting the build process
2907: 12.5.3. Files affecting nothing at all
2908: 12.6. work*
2909: 12.7. files/*
1.1 dsieger 2910:
1.184 rillig 2911: Whenever you're preparing a package, there are a number of files involved which
2912: are described in the following sections.
1.1 dsieger 2913:
1.266 martin 2914: 12.1. Makefile
1.1 dsieger 2915:
1.184 rillig 2916: Building, installation and creation of a binary package are all controlled by
2917: the package's Makefile. The Makefile describes various things about a package,
2918: for example from where to get it, how to configure, build, and install it.
1.1 dsieger 2919:
1.184 rillig 2920: A package Makefile contains several sections that describe the package.
1.1 dsieger 2921:
1.184 rillig 2922: In the first section there are the following variables, which should appear
2923: exactly in the order given here. The order and grouping of the variables is
2924: mostly historical and has no further meaning.
1.1 dsieger 2925:
1.184 rillig 2926: * DISTNAME is the basename of the distribution file to be downloaded from the
2927: package's website.
1.1 dsieger 2928:
1.184 rillig 2929: * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
2930: it if DISTNAME (which is the default) is not a good name for the package in
2931: pkgsrc or DISTNAME is not provided (no distribution file is required).
2932: Usually it is the pkgsrc directory name together with the version number.
2933: It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
2934: is, it starts with a letter or digit, and contains only letters, digits,
1.204 nia 2935: dashes, underscores, dots and plus signs. New packages should have entirely
2936: lower-case names, with the exception of some that must follow pre-existing
2937: conventions (e.g. R packages begin with R-). You can use the :tl variable
2938: modifier to lower-case the package name.
1.26 spz 2939:
1.184 rillig 2940: * CATEGORIES is a list of categories which the package fits in. You can
2941: choose any of the top-level directories of pkgsrc for it.
1.1 dsieger 2942:
1.184 rillig 2943: Currently the following values are available for CATEGORIES. If more than
2944: one is used, they need to be separated by spaces:
1.1 dsieger 2945:
1.184 rillig 2946: archivers cross geography meta-pkgs security
2947: audio databases graphics misc shells
2948: benchmarks devel ham multimedia sysutils
2949: biology editors inputmethod net textproc
2950: cad emulators lang news time
2951: chat finance mail parallel wm
2952: comms fonts math pkgtools www
2953: converters games mbone print x11
1.1 dsieger 2954:
1.184 rillig 2955: * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
1.266 martin 2956: are discussed in detail in Section 13.5, The fetch phase .
1.1 dsieger 2957:
1.184 rillig 2958: The second section contains information about separately downloaded patches, if
2959: any.
1.1 dsieger 2960:
1.184 rillig 2961: * PATCHFILES: Name(s) of additional files that contain distribution patches.
2962: There is no default. pkgsrc will look for them at PATCH_SITES. They will
2963: automatically be uncompressed before patching if the names end with .gz or
2964: .Z.
1.1 dsieger 2965:
1.184 rillig 2966: * PATCH_SITES: Primary location(s) for distribution patch files (see
2967: PATCHFILES above) if not found locally.
1.1 dsieger 2968:
1.184 rillig 2969: * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
2970: count to help find the correct files to patch. It defaults to -p0.
1.1 dsieger 2971:
1.184 rillig 2972: The third section contains the following variables.
1.1 dsieger 2973:
1.253 gutterid 2974: * MAINTAINER is the email address of the person who is currently responsible
2975: for this package. In theory, the maintainer will be aware of upstream
2976: release, keep it updated, and generally resolve problems. Others
2977: contemplating significant changes should ask the maintainer for advice or
2978: review of a proposed change. This is not necessary for micro updates, bug
2979: fixes, pkgsrc-wide changes affecting many packages, and other things
2980: expected to be uncontroversial. It goes with this "should ask" that the
2981: maintainer should respond to inquiries reasonably promptly (most of the
2982: time), and either approve changes or provide reasons why not. Typically,
2983: when packaging a new program, set MAINTAINER to yourself. If you don't
2984: intend to maintain the package (especially if you feel you have no special
2985: insight), set it to <pkgsrc-users@NetBSD.org>. This special value is a code
1.274 wiz 2986: point indicating that there is no maintainer.
1.1 dsieger 2987:
1.184 rillig 2988: * HOMEPAGE is a URL where users can find more information about the package.
1.1 dsieger 2989:
1.184 rillig 2990: * COMMENT is a one-line description of the package (should not include the
2991: package name).
1.1 dsieger 2992:
1.184 rillig 2993: * LICENSE indicates the license(s) applicable for the package. See
1.266 martin 2994: Section 21.1.3, Handling licenses for further details.
1.1 dsieger 2995:
1.184 rillig 2996: Other variables that affect the build:
1.1 dsieger 2997:
1.184 rillig 2998: * WRKSRC: The directory where the interesting distribution files of the
2999: package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
3000: most packages.
1.1 dsieger 3001:
1.184 rillig 3002: If a package doesn't create a subdirectory for itself (most GNU software
3003: does, for instance), but extracts itself in the current directory, you
3004: should set WRKSRC=${WRKDIR}.
1.1 dsieger 3005:
1.184 rillig 3006: If a package doesn't create a subdirectory with the name of DISTNAME but
3007: some different name, set WRKSRC to point to the proper name in ${WRKDIR},
3008: for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
3009: other examples.
1.17 imil 3010:
1.184 rillig 3011: The name of the working directory created by pkgsrc is taken from the
3012: WRKDIR_BASENAME variable. By default, its value is work. If you want to use
3013: the same pkgsrc tree for building different kinds of binary packages, you
3014: can change the variable according to your needs. Two other variables handle
3015: common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
3016: defined in mk.conf, the first component of the host's name is attached to
3017: the directory name. If OBJMACHINE is defined, the platform name is
3018: attached, which might look like work.i386 or work.sparc.
1.17 imil 3019:
1.184 rillig 3020: Please pay attention to the following gotchas:
1.17 imil 3021:
1.184 rillig 3022: * Add MANCOMPRESSED if man pages are installed in compressed form by the
3023: package. For packages using BSD-style makefiles which honor MANZ, there is
3024: MANCOMPRESSED_IF_MANZ.
1.17 imil 3025:
1.266 martin 3026: * Replace /usr/local with ${PREFIX} in all files (see patches, below).
1.103 wiz 3027:
1.266 martin 3028: * If the package installs any info files, see Section 21.6.8, Packages
3029: installing info files .
1.103 wiz 3030:
1.266 martin 3031: 12.2. distinfo
1.17 imil 3032:
1.184 rillig 3033: The distinfo file contains the message digest, or checksum, of each distfile
3034: needed for the package. This ensures that the distfiles retrieved from the
3035: Internet have not been corrupted during transfer or altered by a malign force
3036: to introduce a security hole. To provide maximum security, all distfiles are
1.243 gutterid 3037: protected using two different message digest algorithms (BLAKE2s and SHA512),
3038: as well as the file size.
1.17 imil 3039:
1.184 rillig 3040: The distinfo file also contains the checksums for all the patches found in the
1.266 martin 3041: patches directory (see Section 12.3, patches/* ). These checksums ensure that
1.184 rillig 3042: patches are only applied intentionally and that they don't accidentally change,
3043: e.g. when merging different changes together. They also make sure that new
3044: patches are actually added to CVS and old ones are removed. Too see whether the
3045: patches and the distinfo file match, run pkglint after changing the patches.
1.17 imil 3046:
1.184 rillig 3047: To regenerate the distinfo file, use the make distinfo command.
1.17 imil 3048:
1.184 rillig 3049: Some packages have different sets of distfiles depending on the platform, for
3050: example lang/openjdk8. These are kept in the same distinfo file and care should
3051: be taken when upgrading such a package to ensure distfile information is not
3052: lost.
1.17 imil 3053:
1.266 martin 3054: 12.3. patches/*
1.63 wiz 3055:
1.184 rillig 3056: Some packages don't work out-of-the box on the various platforms that are
3057: supported by pkgsrc. These packages need to be patched to make them work. The
3058: patch files can be found in the patches/ directory.
1.17 imil 3059:
1.184 rillig 3060: In the patch phase, these patches are applied to the files in WRKSRC directory
3061: after extracting them, in alphabetic order.
1.160 brook 3062:
1.266 martin 3063: 12.3.1. Structure of a single patch file
1.160 brook 3064:
1.184 rillig 3065: The patch-* files should be in diff -bu format, and apply without a fuzz to
3066: avoid problems. (To force patches to apply with fuzz you can set
3067: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
3068: a single file, and no file should be patched by more than one patch file. This
3069: helps to keep future modifications simple.
1.160 brook 3070:
1.184 rillig 3071: Each patch file is structured as follows: In the first line, there is the RCS
3072: Id of the patch itself. The second line should be empty for aesthetic reasons.
3073: After that, there should be a comment for each change that the patch does.
3074: There are a number of standard cases:
1.160 brook 3075:
1.184 rillig 3076: * Patches for commonly known vulnerabilities should mention the vulnerability
3077: ID (CAN, CVE).
1.160 brook 3078:
1.184 rillig 3079: * Patches that change source code should mention the platform and other
3080: environment (for example, the compiler) that the patch is needed for.
1.160 brook 3081:
1.184 rillig 3082: The patch should be commented so that any developer who knows the code of the
3083: application can make some use of the patch. Special care should be taken for
3084: the upstream developers, since we generally want that they accept our patches,
3085: so we have less work in the future.
1.160 brook 3086:
1.266 martin 3087: 12.3.2. Creating patch files
1.160 brook 3088:
1.184 rillig 3089: One important thing to mention is to pay attention that no RCS IDs get stored
3090: in the patch files, as these will cause problems when later checked into the
3091: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
3092: avoid these problems.
1.160 brook 3093:
1.184 rillig 3094: For even more automation, we recommend using mkpatches from the same package to
1.222 gutterid 3095: make a whole set of patches. You just have to back up files before you edit
3096: them to filename.orig, e.g., with cp -p filename filename.orig or, easier, by
3097: using pkgvi again from the same package. If you upgrade a package this way, you
3098: can easily compare the new set of patches with the previously existing one with
1.184 rillig 3099: patchdiff. The files in patches are replaced by new files, so carefully check
3100: if you want to take all the changes.
1.160 brook 3101:
1.184 rillig 3102: When you have finished a package, remember to generate the checksums for the
1.266 martin 3103: patch files by using the make makepatchsum command, see Section 12.2,
3104: distinfo .
1.1 dsieger 3105:
1.184 rillig 3106: When adding a patch that corrects a problem in the distfile (rather than e.g.
3107: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
3108: report to the maintainer. This benefits non-pkgsrc users of the package, and
3109: usually makes it possible to remove the patch in future version.
1.1 dsieger 3110:
1.184 rillig 3111: The file names of the patch files are usually of the form patch-
3112: path_to_file__with__underscores.c. Many packages still use the previous
3113: convention patch-[a-z][a-z], but new patches should be of the form containing
3114: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
3115: automatically.
1.1 dsieger 3116:
1.222 gutterid 3117: When updating pre-existing patch files, if a file uses the old patch-[a-z][a-z]
3118: convention, it's best not to change it to the new form, as that will just cause
3119: churn that makes it harder to track changes to patching over time. Similarly,
3120: if a patch now applies at different line offsets, but still applies cleanly
3121: as-is, there's no need to update it, as that also unnecessarily complicates the
3122: patch history.
3123:
1.266 martin 3124: 12.3.3. Sources where the patch files come from
1.1 dsieger 3125:
1.184 rillig 3126: If you want to share patches between multiple packages in pkgsrc, e.g. because
3127: they use the same distfiles, set PATCHDIR to the path where the patch files can
3128: be found, e.g.:
1.1 dsieger 3129:
1.184 rillig 3130: PATCHDIR= ../../editors/xemacs/patches
1.1 dsieger 3131:
1.184 rillig 3132: Patch files that are distributed by the author or other maintainers can be
3133: listed in PATCHFILES.
1.1 dsieger 3134:
1.184 rillig 3135: If it is desired to store any patches that should not be committed into pkgsrc,
3136: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
1.266 martin 3137: directory tree there is expected to have the same category/package structure
1.184 rillig 3138: as pkgsrc, and patches are expected to be stored inside these dirs (also known
3139: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
3140: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
3141: files in the named directory are expected to be patch files, and they are
3142: applied after pkgsrc patches are applied.
1.1 dsieger 3143:
1.266 martin 3144: 12.3.4. Patching guidelines
1.1 dsieger 3145:
1.184 rillig 3146: When fixing a portability issue in the code do not use preprocessor magic to
3147: check for the current operating system nor platform. Doing so hurts portability
3148: to other platforms because the OS-specific details are not abstracted
3149: appropriately.
1.1 dsieger 3150:
1.184 rillig 3151: The general rule to follow is: instead of checking for the operating system the
3152: application is being built on, check for the specific features you need. For
3153: example, instead of assuming that kqueue is available under NetBSD and using
3154: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
1.266 martin 3155: kqueue itself yes, this generally involves patching the configure script.
1.184 rillig 3156: There is absolutely nothing that prevents some OSes from adopting interfaces
3157: from other OSes (e.g. Linux implementing kqueue), something that the above
3158: checks cannot take into account.
1.1 dsieger 3159:
1.184 rillig 3160: Of course, checking for features generally involves more work on the
3161: developer's side, but the resulting changes are cleaner and there are chances
3162: they will work on many other platforms. Not to mention that there are higher
3163: chances of being later integrated into the mainstream sources. Remember: It
3164: doesn't work unless it is right!
1.1 dsieger 3165:
1.184 rillig 3166: Some typical examples:
1.121 sevan 3167:
1.266 martin 3168: Table 12.1. Patching examples
1.1 dsieger 3169:
1.184 rillig 3170: +-------------------------------------------------------------------------------------------+
3171: | Where | Incorrect | Correct |
3172: |---------+--------------------------+------------------------------------------------------|
3173: | |case ${target_os} in | |
3174: |configure|netbsd*) have_kvm=yes ;; |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
3175: |script |*) have_kvm=no ;; | |
3176: | |esac | |
3177: |---------+--------------------------+------------------------------------------------------|
3178: |C source |#if defined(__NetBSD__) |#if defined(HAVE_SYS_EVENT_H) |
3179: |file |# include <sys/event.h> |# include <sys/event.h> |
3180: | |#endif |#endif |
3181: |---------+--------------------------+------------------------------------------------------|
3182: | |int |int |
3183: | |monitor_file(...) |monitor_file(...) |
3184: | |{ |{ |
3185: | |#if defined(__NetBSD__) |#if defined(HAVE_KQUEUE) |
3186: |C source | int fd = kqueue();| int fd = kqueue(); |
3187: |file | ... | ... |
3188: | |#else |#else |
3189: | | ... | ... |
3190: | |#endif |#endif |
3191: | |} |} |
3192: +-------------------------------------------------------------------------------------------+
1.1 dsieger 3193:
3194:
1.266 martin 3195: 12.3.5. Feedback to the author
1.1 dsieger 3196:
1.184 rillig 3197: Always, always, always feed back any portability fixes or improvements you do
3198: to a package to the mainstream developers. This is the only way to get their
3199: attention on portability issues and to ensure that future versions can be built
3200: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
3201: get the fixes straight from the packaged code.
1.1 dsieger 3202:
1.184 rillig 3203: This generally involves cleaning up the patches (because sometimes the patches
3204: that are added to pkgsrc are quick hacks), filing bug reports in the
3205: appropriate trackers for the projects and working with the mainstream authors
3206: to accept your changes. It is extremely important that you do it so that the
3207: packages in pkgsrc are kept simple and thus further changes can be done without
3208: much hassle.
1.1 dsieger 3209:
1.184 rillig 3210: When you have done this, please add a URL to the upstream bug report to the
3211: patch comment.
1.1 dsieger 3212:
1.184 rillig 3213: Support the idea of free software!
1.1 dsieger 3214:
1.266 martin 3215: 12.4. Other mandatory files
1.1 dsieger 3216:
1.184 rillig 3217: DESCR
1.1 dsieger 3218:
1.184 rillig 3219: A multi-line description of the piece of software. This should include any
3220: credits where they are due. Please bear in mind that others do not share
3221: your sense of humour (or spelling idiosyncrasies), and that others will
3222: read everything that you write here.
1.1 dsieger 3223:
1.184 rillig 3224: PLIST
1.1 dsieger 3225:
1.184 rillig 3226: This file governs the files that are installed on your system: all the
3227: binaries, manual pages, etc. There are other directives which may be
3228: entered in this file, to control the creation and deletion of directories,
1.266 martin 3229: and the location of inserted files. See Chapter 19, PLIST issues for more
1.184 rillig 3230: information.
1.1 dsieger 3231:
1.266 martin 3232: 12.5. Optional files
1.1 dsieger 3233:
1.266 martin 3234: 12.5.1. Files affecting the binary package
1.1 dsieger 3235:
1.184 rillig 3236: INSTALL
1.1 dsieger 3237:
1.184 rillig 3238: This shell script is invoked twice by pkg_add(1). First time after package
3239: extraction and before files are moved in place, the second time after the
3240: files to install are moved in place. This can be used to do any custom
3241: procedures not possible with @exec commands in PLIST. See pkg_add(1) and
1.266 martin 3242: pkg_create(1) for more information. See also Section 20.1, Files and
3243: directories outside the installation prefix . Please note that you can
1.184 rillig 3244: modify variables in it easily by using FILES_SUBST in the package's
3245: Makefile:
1.1 dsieger 3246:
1.184 rillig 3247: FILES_SUBST+= SOMEVAR="somevalue"
1.1 dsieger 3248:
1.266 martin 3249: replaces "@SOMEVAR@" with somevalue in the INSTALL. By default,
1.184 rillig 3250: substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
3251: few others, type make help topic=FILES_SUBST for a complete list.
1.1 dsieger 3252:
1.184 rillig 3253: DEINSTALL
1.1 dsieger 3254:
1.184 rillig 3255: This script is executed before and after any files are removed. It is this
3256: script's responsibility to clean up any additional messy details around the
3257: package's installation, since all pkg_delete knows is how to delete the
3258: files created in the original distribution. See pkg_delete(1) and
3259: pkg_create(1) for more information. The same methods to replace variables
3260: can be used as for the INSTALL file.
1.1 dsieger 3261:
1.184 rillig 3262: MESSAGE
1.1 dsieger 3263:
1.198 leot 3264: This file is displayed after installation of the package. While this was
3265: used often in the past, it has two problems: the display will be missed if
1.257 jkoshy 3266: many packages are installed at once, and the person installing the package
1.198 leot 3267: and the one using or configuring it may be different. It should therefore
3268: be used only in exceptional circumstances where lasting negative
3269: consequences would result from someone not reading it.
3270:
3271: MESSAGE should not be used for:
3272:
1.271 wiz 3273: o exhortations to read the documentation
1.198 leot 3274:
1.271 wiz 3275: o reminders to install rc.d files and set variables
1.198 leot 3276:
1.271 wiz 3277: o anything that should be explained in the installation/configuration
1.198 leot 3278: documentation that should come with the package
3279:
3280: If the documentation provided by upstream needs enhancing, create e.g.
3281: files/README.pkgsrc and install it in the package's documentation
3282: directory.
3283:
3284: Note that MESSAGE is shown for all operating systems and all init systems.
3285: If a MESSAGE is necessary, it should be narrowed to only those operating
3286: systems and init systems to which it applies.
3287:
3288: Note that you can modify variables in it easily by using MESSAGE_SUBST in
3289: the package's Makefile:
1.1 dsieger 3290:
1.184 rillig 3291: MESSAGE_SUBST+= SOMEVAR="somevalue"
1.1 dsieger 3292:
1.266 martin 3293: replaces "${SOMEVAR}" with somevalue in MESSAGE. By default, substitution
1.184 rillig 3294: is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
3295: PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1 dsieger 3296:
1.184 rillig 3297: You can display a different or additional files by setting the MESSAGE_SRC
3298: variable. Its default is MESSAGE, if the file exists.
1.1 dsieger 3299:
1.184 rillig 3300: ALTERNATIVES
1.1 dsieger 3301:
1.184 rillig 3302: This file is used by the alternatives framework. It creates, configures,
3303: and destroys generic wrappers used to run programs with similar interfaces.
3304: See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
3305: information.
1.1 dsieger 3306:
1.184 rillig 3307: Each line of the file contains two filenames, first the wrapper and then
3308: the alternative provided by the package. Both paths are relative to PREFIX.
1.1 dsieger 3309:
1.266 martin 3310: 12.5.2. Files affecting the build process
1.1 dsieger 3311:
1.184 rillig 3312: Makefile.common
1.1 dsieger 3313:
1.184 rillig 3314: This file contains arbitrary things that could also go into a Makefile, but
3315: its purpose is to be used by more than one package. This file should only
3316: be used when the packages that will use the file are known in advance. For
3317: other purposes it is often better to write a *.mk file and give it a good
3318: name that describes what it does.
1.1 dsieger 3319:
1.184 rillig 3320: buildlink3.mk
1.1 dsieger 3321:
1.184 rillig 3322: This file contains the dependency information for the buildlink3 framework
1.266 martin 3323: (see Chapter 18, Buildlink methodology).
1.1 dsieger 3324:
1.184 rillig 3325: hacks.mk
1.1 dsieger 3326:
1.184 rillig 3327: This file contains workarounds for compiler bugs and similar things. It is
3328: included automatically by the pkgsrc infrastructure, so you don't need an
3329: extra .include line for it.
1.1 dsieger 3330:
1.184 rillig 3331: options.mk
1.1 dsieger 3332:
1.184 rillig 3333: This file contains the code for the package-specific options (see
1.266 martin 3334: Chapter 16, Options handling) that can be selected by the user. If a
1.184 rillig 3335: package has only one or two options, it is equally acceptable to put the
3336: code directly into the Makefile.
1.1 dsieger 3337:
1.266 martin 3338: 12.5.3. Files affecting nothing at all
1.1 dsieger 3339:
1.184 rillig 3340: README*
1.1 dsieger 3341:
1.184 rillig 3342: These files do not take place in the creation of a package and thus are
3343: purely informative to the package developer.
1.1 dsieger 3344:
1.184 rillig 3345: TODO
1.1 dsieger 3346:
1.184 rillig 3347: This file contains things that need to be done to make the package even
3348: better.
1.1 dsieger 3349:
1.266 martin 3350: 12.6. work*
1.1 dsieger 3351:
1.184 rillig 3352: When you type make, the distribution files are unpacked into the directory
3353: denoted by WRKDIR. It can be removed by running make clean. Besides the
3354: sources, this directory is also used to keep various timestamp files. The
3355: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
3356: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
1.1 dsieger 3357:
1.266 martin 3358: 12.7. files/*
1.80 wiz 3359:
1.184 rillig 3360: If you have any files that you wish to be placed in the package prior to
3361: configuration or building, you can place these files here and use a ${CP}
1.266 martin 3362: command in the post-extract target to achieve this.
1.1 dsieger 3363:
1.184 rillig 3364: If you want to share files in this way with other packages, set the FILESDIR
3365: variable to point to the other package's files directory, e.g.:
1.1 dsieger 3366:
1.184 rillig 3367: FILESDIR= ../../editors/xemacs/files
1.14 jmcneill 3368:
1.266 martin 3369: Chapter 13. The build process
1.1 dsieger 3370:
1.184 rillig 3371: Table of Contents
1.1 dsieger 3372:
1.184 rillig 3373: 13.1. Introduction
3374: 13.2. Program location
3375: 13.3. Directories used during the build process
3376: 13.4. Running a phase
3377: 13.5. The fetch phase
3378: 13.5.1. What to fetch and where to get it from
3379: 13.5.2. How are the files fetched?
3380: 13.6. The checksum phase
3381: 13.7. The extract phase
3382: 13.8. The patch phase
3383: 13.9. The tools phase
3384: 13.10. The wrapper phase
3385: 13.11. The configure phase
3386: 13.12. The build phase
3387: 13.13. The test phase
3388: 13.14. The install phase
3389: 13.15. The package phase
3390: 13.16. Cleaning up
3391: 13.17. Other helpful targets
1.1 dsieger 3392:
1.266 martin 3393: 13.1. Introduction
1.122 leot 3394:
1.184 rillig 3395: This chapter gives a detailed description on how a package is built. Building a
3396: package is separated into different phases (for example fetch, build, install),
3397: all of which are described in the following sections. Each phase is split into
3398: so-called stages, which take the name of the containing phase, prefixed by one
3399: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
3400: actual work is done in the do-* stages.
1.1 dsieger 3401:
1.184 rillig 3402: Never override the regular targets (like fetch), if you have to, override the
3403: do-* ones instead.
1.1 dsieger 3404:
1.184 rillig 3405: The basic steps for building a program are always the same. First the program's
3406: source (distfile) must be brought to the local system and then extracted. After
3407: any pkgsrc-specific patches to compile properly are applied, the software can
3408: be configured, then built (usually by compiling), and finally the generated
3409: binaries, etc. can be put into place on the system.
1.1 dsieger 3410:
1.184 rillig 3411: To get more details about what is happening at each step, you can set the
3412: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
3413: more details about the patch step.
1.1 dsieger 3414:
1.266 martin 3415: 13.2. Program location
1.1 dsieger 3416:
1.184 rillig 3417: Before outlining the process performed by the NetBSD package system in the next
3418: section, here's a brief discussion on where programs are installed, and which
3419: variables influence this.
1.1 dsieger 3420:
1.184 rillig 3421: The automatic variable PREFIX indicates where all files of the final program
3422: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
3423: pkgs in the cross category. The value of PREFIX needs to be put into the
3424: various places in the program's source where paths to these files are encoded.
1.266 martin 3425: See Section 12.3, patches/* and Section 21.3.1, Shared libraries - libtool
1.184 rillig 3426: for more details.
1.1 dsieger 3427:
1.184 rillig 3428: When choosing which of these variables to use, follow the following rules:
1.1 dsieger 3429:
1.184 rillig 3430: * PREFIX always points to the location where the current pkg will be
1.266 martin 3431: installed. When referring to a pkg's own installation path, use ${PREFIX}
1.184 rillig 3432: .
1.1 dsieger 3433:
1.223 nia 3434: * LOCALBASE is where all pkgs are installed. If you need to construct a -I or
3435: -L argument to the compiler to find includes and libraries installed by
1.266 martin 3436: another pkg, use ${LOCALBASE} . The name LOCALBASE stems from FreeBSD,
1.223 nia 3437: which installed all packages in /usr/local. As pkgsrc leaves /usr/local for
3438: the system administrator, this variable is a misnomer.
1.1 dsieger 3439:
1.184 rillig 3440: * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
3441: installed. When looking for standard X11 includes (not those installed by a
1.266 martin 3442: package), use ${X11BASE} .
1.1 dsieger 3443:
1.184 rillig 3444: * X11-based packages using imake must set USE_IMAKE to be installed correctly
3445: under LOCALBASE.
1.1 dsieger 3446:
1.184 rillig 3447: * Within ${PREFIX}, packages should install files according to hier(7), with
3448: the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
3449: man.
1.1 dsieger 3450:
1.266 martin 3451: 13.3. Directories used during the build process
1.2 rillig 3452:
1.184 rillig 3453: When building a package, various directories are used to store source files,
3454: temporary files, pkgsrc-internal files, and so on. These directories are
3455: explained here.
1.1 dsieger 3456:
1.184 rillig 3457: Some of the directory variables contain relative pathnames. There are two
3458: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
3459: used for directories that are pkgsrc-specific. WRKSRC is used for directories
3460: inside the package itself.
1.1 dsieger 3461:
1.184 rillig 3462: PKGSRCDIR
1.1 dsieger 3463:
1.184 rillig 3464: This is an absolute pathname that points to the pkgsrc root directory.
3465: Generally, you don't need it.
1.1 dsieger 3466:
1.184 rillig 3467: PKGDIR
1.1 dsieger 3468:
1.184 rillig 3469: This is an absolute pathname that points to the current package.
1.1 dsieger 3470:
1.184 rillig 3471: PKGPATH
1.1 dsieger 3472:
1.184 rillig 3473: This is a pathname relative to PKGSRCDIR that points to the current
1.228 gutterid 3474: package. It is defined after including bsd.prefs.mk and can be used in
3475: makefile fragments that are used by several packages to distinguish between
3476: these packages. Other variables that would serve the same purpose are
3477: PKGBASE and PKGNAME, but these are only defined after including bsd.pkg.mk,
3478: which is too late.
3479:
3480: In mk.conf, the pkgsrc user can use PKGPATH to tweak variables like
3481: MAKE_JOBS and CFLAGS.
1.1 dsieger 3482:
1.184 rillig 3483: WRKDIR
1.1 dsieger 3484:
1.184 rillig 3485: This is an absolute pathname pointing to the directory where all work takes
3486: place. The distfiles are extracted to this directory. It also contains
3487: temporary directories and log files used by the various pkgsrc frameworks,
3488: like buildlink or the wrappers.
1.1 dsieger 3489:
1.184 rillig 3490: WRKSRC
1.1 dsieger 3491:
1.184 rillig 3492: This is an absolute pathname pointing to the directory where the distfiles
3493: are extracted. It is usually a direct subdirectory of WRKDIR, and often
3494: it's the only directory entry that isn't hidden. This variable may be
3495: changed by a package Makefile.
1.1 dsieger 3496:
1.184 rillig 3497: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
3498: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
3499: created in the pkgsrc entry's directory. If users would like to have their
3500: pkgsrc trees behave in a read-only manner, then the value of
3501: CREATE_WRKDIR_SYMLINK should be set to no.
1.1 dsieger 3502:
1.266 martin 3503: 13.4. Running a phase
1.1 dsieger 3504:
1.184 rillig 3505: You can run a particular phase by typing make phase, where phase is the name of
3506: the phase. This will automatically run all phases that are required for this
3507: phase. The default phase is build, that is, when you run make without
3508: parameters in a package directory, the package will be built, but not
3509: installed.
1.1 dsieger 3510:
1.266 martin 3511: 13.5. The fetch phase
1.1 dsieger 3512:
1.184 rillig 3513: The first step in building a package is to fetch the distribution files
3514: (distfiles) from the sites that are providing them. This is the task of the
3515: fetch phase.
1.25 wiz 3516:
1.266 martin 3517: 13.5.1. What to fetch and where to get it from
1.1 dsieger 3518:
1.184 rillig 3519: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
3520: name is derived from the DISTNAME variable, is fetched. The more complicated
3521: cases are described below.
1.1 dsieger 3522:
1.184 rillig 3523: The variable DISTFILES specifies the list of distfiles that have to be fetched.
3524: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
3525: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
3526: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
3527: your package requires additional distfiles to the default one, you cannot just
3528: append the additional filenames using the += operator, but you have write for
3529: example:
1.1 dsieger 3530:
1.184 rillig 3531: DISTFILES= ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1 dsieger 3532:
1.184 rillig 3533: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
3534: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
3535: can set SITES.distfile to the list of URLs where the file distfile (including
3536: the suffix) can be found.
1.1 dsieger 3537:
1.184 rillig 3538: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
3539: DISTFILES+= foo-file.tar.gz
3540: SITES.foo-file.tar.gz= \
3541: https://www.somewhere.com/somehow/ \
3542: https://www.somewhereelse.com/mirror/somehow/
1.1 dsieger 3543:
1.184 rillig 3544: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
3545: gets the name of each distfile appended to it, without an intermediate slash.
3546: Therefore, all site values have to end with a slash or other separator
3547: character. This allows for example to set MASTER_SITES to a URL of a CGI script
3548: that gets the name of the distfile as a parameter. In this case, the definition
3549: would look like:
1.1 dsieger 3550:
1.184 rillig 3551: MASTER_SITES= https://www.example.com/download.cgi?file=
1.1 dsieger 3552:
1.184 rillig 3553: The exception to this rule are URLs starting with a dash. In that case the URL
3554: is taken as is, fetched and the result stored under the name of the distfile.
3555: You can use this style for the case when the download URL style does not match
3556: the above common case. For example, if permanent download URL is a redirector
3557: to the real download URL, or the download file name is offered by an HTTP
3558: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
3559: created instead of the default v1.0.0.tar.gz.
1.1 dsieger 3560:
1.184 rillig 3561: DISTNAME= foo-1.0.0
3562: MASTER_SITES= -https://www.example.com/archive/v1.0.0.tar.gz
1.29 wiz 3563:
1.184 rillig 3564: There are some predefined values for MASTER_SITES, which can be used in
3565: packages. The names of the variables should speak for themselves.
1.29 wiz 3566:
1.260 wiz 3567: MASTER_SITE_APACHE MASTER_SITE_BACKUP
3568: MASTER_SITE_CRATESIO MASTER_SITE_CYGWIN
3569: MASTER_SITE_DEBIAN MASTER_SITE_FREEBSD
3570: MASTER_SITE_FREEBSD_LOCAL MASTER_SITE_GENTOO
3571: MASTER_SITE_GITHUB MASTER_SITE_GITLAB
3572: MASTER_SITE_GNOME MASTER_SITE_GNU
3573: MASTER_SITE_GNUPG MASTER_SITE_GNUSTEP
3574: MASTER_SITE_HASKELL_HACKAGE MASTER_SITE_IFARCHIVE
3575: MASTER_SITE_KDE MASTER_SITE_MOZILLA
3576: MASTER_SITE_MOZILLA_ALL MASTER_SITE_MYSQL
3577: MASTER_SITE_NETLIB MASTER_SITE_OPENBSD
3578: MASTER_SITE_OPENOFFICE MASTER_SITE_OSDN
3579: MASTER_SITE_PERL_CPAN MASTER_SITE_PGSQL
3580: MASTER_SITE_PYPI MASTER_SITE_RUBYGEMS
3581: MASTER_SITE_R_CRAN MASTER_SITE_SOURCEFORGE
3582: MASTER_SITE_SUNSITE MASTER_SITE_SUSE
3583: MASTER_SITE_TEX_CTAN MASTER_SITE_XCONTRIB
3584: MASTER_SITE_XEMACS MASTER_SITE_XORG
1.1 dsieger 3585:
1.184 rillig 3586: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
3587: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
3588: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
3589: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
3590: distfiles/LOCAL_PORTS/.
1.1 dsieger 3591:
1.184 rillig 3592: If you choose one of these predefined sites, you may want to specify a
3593: subdirectory of that site. Since these macros may expand to more than one
3594: actual site, you must use the following construct to specify a subdirectory:
1.1 dsieger 3595:
1.184 rillig 3596: MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/}
3597: MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1 dsieger 3598:
1.184 rillig 3599: Note the trailing slash after the subdirectory name.
1.1 dsieger 3600:
1.266 martin 3601: 13.5.2. How are the files fetched?
1.1 dsieger 3602:
1.184 rillig 3603: The fetch phase makes sure that all the distfiles exist in a local directory
3604: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
3605: are fetched using commands of the form
1.1 dsieger 3606:
1.184 rillig 3607: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
1.1 dsieger 3608:
1.184 rillig 3609: where ${site} varies through several possibilities in turn: first,
3610: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
3611: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
3612: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
3613: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
3614: MASTER_SORT_AWK or MASTER_SORT_REGEX.
1.1 dsieger 3615:
1.184 rillig 3616: The specific command and arguments used depend on the FETCH_USING parameter.
3617: The example above is for FETCH_USING=custom.
1.66 asau 3618:
1.184 rillig 3619: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
3620: target to mirror the distfiles, if they are freely distributable. Packages
1.266 martin 3621: setting NO_SRC_ON_FTP (usually to ${RESTRICTED} ) will not have their
1.184 rillig 3622: distfiles mirrored.
1.1 dsieger 3623:
1.266 martin 3624: 13.6. The checksum phase
1.1 dsieger 3625:
1.184 rillig 3626: After the distfile(s) are fetched, their checksum is generated and compared
3627: with the checksums stored in the distinfo file. If the checksums don't match,
3628: the build is aborted. This is to ensure the same distfile is used for building,
3629: and that the distfile wasn't changed, e.g. by some malign force, deliberately
3630: changed distfiles on the master distribution site or network lossage.
1.1 dsieger 3631:
1.266 martin 3632: 13.7. The extract phase
1.1 dsieger 3633:
1.184 rillig 3634: When the distfiles are present on the local system, they need to be extracted,
3635: as they usually come in the form of some compressed archive format.
1.1 dsieger 3636:
1.184 rillig 3637: By default, all DISTFILES are extracted. If you only need some of them, you can
3638: set the EXTRACT_ONLY variable to the list of those files.
1.1 dsieger 3639:
1.184 rillig 3640: Extracting the files is usually done by a little program, mk/extract/extract,
3641: which already knows how to extract various archive formats, so most likely you
3642: will not need to change anything here. But if you need, the following variables
3643: may help you:
1.1 dsieger 3644:
1.184 rillig 3645: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
1.1 dsieger 3646:
1.184 rillig 3647: Use these variables to override the default options for an extract command,
3648: which are defined in mk/extract/extract.
1.1 dsieger 3649:
1.184 rillig 3650: EXTRACT_USING
1.1 dsieger 3651:
1.184 rillig 3652: This variable can be set to bsdtar, gtar, nbtar (which is the default
3653: value), pax, or an absolute pathname pointing to the command with which tar
3654: archives should be extracted. It is preferred to choose bsdtar over gtar if
3655: NetBSD's pax-as-tar is not good enough.
1.1 dsieger 3656:
1.184 rillig 3657: If the extract program doesn't serve your needs, you can also override the
3658: EXTRACT_CMD variable, which holds the command used for extracting the files.
3659: This command is executed in the ${WRKSRC} directory. During execution of this
3660: command, the shell variable extract_file holds the absolute pathname of the
3661: file that is going to be extracted.
1.1 dsieger 3662:
1.184 rillig 3663: And if that still does not suffice, you can override the do-extract target in
3664: the package Makefile.
1.1 dsieger 3665:
1.266 martin 3666: 13.8. The patch phase
1.1 dsieger 3667:
1.184 rillig 3668: After extraction, all the patches named by the PATCHFILES, those present in the
3669: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
3670: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
3671: are uncompressed before they are applied, files ending in .orig or .rej are
3672: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
1.266 martin 3673: Section 12.3, patches/* for more details.
1.1 dsieger 3674:
1.184 rillig 3675: By default patch(1) is given special arguments to make it fail if the expected
3676: text from the patch context is not found in the patched file. If that happens,
3677: fix the patch file by comparing it with the actual text in the file to be
3678: patched.
1.1 dsieger 3679:
1.266 martin 3680: 13.9. The tools phase
1.1 dsieger 3681:
1.266 martin 3682: This is covered in Chapter 17, Tools needed for building or running.
1.1 dsieger 3683:
1.266 martin 3684: 13.10. The wrapper phase
1.1 dsieger 3685:
1.184 rillig 3686: This phase creates wrapper programs for the compilers and linkers. The
3687: following variables can be used to tweak the wrappers.
1.1 dsieger 3688:
1.184 rillig 3689: ECHO_WRAPPER_MSG
1.1 dsieger 3690:
1.184 rillig 3691: The command used to print progress messages. Does nothing by default. Set
3692: to ${ECHO} to see the progress messages.
1.1 dsieger 3693:
1.184 rillig 3694: WRAPPER_DEBUG
1.1 dsieger 3695:
1.184 rillig 3696: This variable can be set to yes (default) or no, depending on whether you
3697: want additional information in the wrapper log file.
1.1 dsieger 3698:
1.184 rillig 3699: WRAPPER_UPDATE_CACHE
1.1 dsieger 3700:
1.184 rillig 3701: This variable can be set to yes or no, depending on whether the wrapper
3702: should use its cache, which will improve the speed. The default value is
3703: yes, but is forced to no if the platform does not support it.
1.1 dsieger 3704:
1.184 rillig 3705: WRAPPER_REORDER_CMDS
1.1 dsieger 3706:
1.184 rillig 3707: A list of reordering commands. A reordering command has the form reorder:l:
3708: lib1:lib2. It ensures that that -llib1 occurs before -llib2.
1.1 dsieger 3709:
1.266 martin 3710: 13.11. The configure phase
1.1 dsieger 3711:
1.184 rillig 3712: Most pieces of software need information on the header files, system calls, and
3713: library routines which are available on the platform they run on. The process
3714: of determining this information is known as configuration, and is usually
3715: automated. In most cases, a script is supplied with the distfiles, and its
3716: invocation results in generation of header files, Makefiles, etc.
1.1 dsieger 3717:
1.184 rillig 3718: If the package contains a configure script, this can be invoked by setting
1.266 martin 3719: HAS_CONFIGURE to yes . If the configure script is a GNU autoconf script, you
3720: should set GNU_CONFIGURE to yes instead.
1.1 dsieger 3721:
1.187 rillig 3722: In the do-configure stage, a rough equivalent of the following command is run.
3723: See mk/configure/configure.mk, target do-configure-script for the exact
3724: definition.
3725:
3726: .for dir in ${CONFIGURE_DIRS}
3727: cd ${WRKSRC} && cd ${dir} \
3728: && env ${CONFIGURE_ENV} \
3729: ${CONFIG_SHELL} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
1.184 rillig 3730: .endfor
1.1 dsieger 3731:
1.266 martin 3732: CONFIGURE_DIRS (default: . ) is a list of pathnames relative to WRKSRC. In
1.184 rillig 3733: each of these directories, the configure script is run with the environment
3734: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
1.266 martin 3735: CONFIGURE_SCRIPT (default: ./configure ) and CONFIGURE_ARGS may all be changed
1.184 rillig 3736: by the package.
1.1 dsieger 3737:
1.184 rillig 3738: If the program uses the Perl way of configuration (mainly Perl modules, but not
3739: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
3740: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
3741: (e.g., MAKE_PARAMS+=foo=bar
1.1 dsieger 3742:
1.184 rillig 3743: If the program uses an Imakefile for configuration, the appropriate steps can
1.266 martin 3744: be invoked by setting USE_IMAKE to yes . If you only need xmkmf, add it to
1.184 rillig 3745: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
3746: SCRIPTS_ENV variable.
1.1 dsieger 3747:
1.184 rillig 3748: If the program uses cmake for configuration, the appropriate steps can be
1.233 wiz 3749: invoked by including ../../devel/cmake/build.mk. You can add variables to
3750: cmake's environment by adding them to the CONFIGURE_ENV variable and arguments
1.256 wiz 3751: to cmake by adding them to the CMAKE_CONFIGURE_ARGS variable. If you want to
3752: add arguments only for particular stages, you can use the CMAKE_CONFIGURE_ARGS,
1.233 wiz 3753: CMAKE_BUILD_ARGS, and CMAKE_INSTALL_ARGS variables. You can set the
3754: CONFIGURE_DIRS variable to the directories in which CMake should be run,
1.266 martin 3755: relative to WRKSRC. This defaults to to . .
1.1 dsieger 3756:
1.256 wiz 3757: Any package using the now-deprecated USE_CMAKE=yes should be converted.
3758: Essentially, replace with an include of ../../devel/cmake/build.mk, prune
3759: creation of a build directory and settings to use it, and check/fix settings
3760: that intend to perform the build in a subdirectory.
3761:
1.266 martin 3762: If there is no configure step at all, set NO_CONFIGURE to yes .
1.1 dsieger 3763:
1.266 martin 3764: 13.12. The build phase
1.1 dsieger 3765:
1.187 rillig 3766: For building a package, a rough equivalent of the following code is executed;
3767: see mk/build/build.mk, target do-build for the exact definition.
1.154 rillig 3768:
1.187 rillig 3769: .for dir in ${BUILD_DIRS}
3770: cd ${WRKSRC} && cd ${dir} \
1.184 rillig 3771: && env ${MAKE_ENV} \
1.187 rillig 3772: ${MAKE_PROGRAM} ${MAKE_FLAGS} ${BUILD_MAKE_FLAGS} \
1.184 rillig 3773: -f ${MAKE_FILE} \
3774: ${BUILD_TARGET}
3775: .endfor
1.1 dsieger 3776:
1.266 martin 3777: BUILD_DIRS (default: . ) is a list of pathnames relative to WRKSRC. In each of
1.184 rillig 3778: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
3779: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
3780: and BUILD_TARGET may all be changed by the package.
1.1 dsieger 3781:
1.266 martin 3782: The default value of MAKE_PROGRAM is gmake if USE_TOOLS contains gmake ,
3783: make otherwise. The default value of MAKE_FILE is Makefile , and BUILD_TARGET
3784: defaults to all .
1.1 dsieger 3785:
1.266 martin 3786: If there is no build step at all, set NO_BUILD to yes .
1.1 dsieger 3787:
1.266 martin 3788: 13.13. The test phase
1.1 dsieger 3789:
1.273 wiz 3790: The test phase is for running a program's self tests. Dependencies that are
3791: only required for testing can be specified using TEST_DEPENDS.
3792:
3793: For packages using make(1) for building, you can set TEST_TARGET. Often, the
3794: proper value is check or test . If more elaborate steps are needed, you can
3795: define a do-test target.
3796:
3797: To run the tests, call make test .
3798:
3799: When building a package, the tests are not run automatically, except if
3800: PKGSRC_RUN_TEST is set to yes .
1.1 dsieger 3801:
1.266 martin 3802: 13.14. The install phase
1.1 dsieger 3803:
1.184 rillig 3804: Once the build stage has completed, the final step is to install the software
3805: in public directories, so users can access the programs and files.
1.1 dsieger 3806:
1.187 rillig 3807: In the install phase, a rough equivalent of the following code is executed; see
3808: mk/install/install.mk, target do-install for the exact definition.
3809: Additionally, before and after this code, several consistency checks are run
3810: against the files-to-be-installed, see mk/check/*.mk for details.
3811:
3812: .for dir in ${INSTALL_DIRS}
3813: cd ${WRKSRC} && cd ${dir} \
3814: && env ${INSTALL_ENV} ${MAKE_ENV} \
3815: ${MAKE_PROGRAM} ${MAKE_FLAGS} ${INSTALL_MAKE_FLAGS} \
3816: -f ${MAKE_FILE} ${INSTALL_TARGET}
1.184 rillig 3817: .endfor
1.1 dsieger 3818:
1.184 rillig 3819: The variable's meanings are analogous to the ones in the build phase.
1.266 martin 3820: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is install by default,
3821: plus install.man if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
1.184 rillig 3822: defined.
1.1 dsieger 3823:
1.184 rillig 3824: In the install phase, the following variables are useful. They are all
3825: variations of the install(1) command that have the owner, group and permissions
3826: preset. INSTALL is the plain install command. The specialized variants,
3827: together with their intended use, are:
1.1 dsieger 3828:
1.184 rillig 3829: INSTALL_PROGRAM_DIR
1.1 dsieger 3830:
1.184 rillig 3831: directories that contain binaries
1.1 dsieger 3832:
1.184 rillig 3833: INSTALL_SCRIPT_DIR
1.1 dsieger 3834:
1.184 rillig 3835: directories that contain scripts
1.1 dsieger 3836:
1.184 rillig 3837: INSTALL_LIB_DIR
1.1 dsieger 3838:
1.184 rillig 3839: directories that contain shared and static libraries
1.1 dsieger 3840:
1.184 rillig 3841: INSTALL_DATA_DIR
1.108 rillig 3842:
1.184 rillig 3843: directories that contain data files
1.108 rillig 3844:
1.184 rillig 3845: INSTALL_MAN_DIR
1.108 rillig 3846:
1.184 rillig 3847: directories that contain man pages
1.108 rillig 3848:
1.184 rillig 3849: INSTALL_GAME_DIR
1.108 rillig 3850:
1.184 rillig 3851: directories that contain data files for games
1.108 rillig 3852:
1.184 rillig 3853: INSTALL_PROGRAM
1.108 rillig 3854:
1.184 rillig 3855: binaries that can be stripped from debugging symbols
1.108 rillig 3856:
1.184 rillig 3857: INSTALL_SCRIPT
1.108 rillig 3858:
1.184 rillig 3859: binaries that cannot be stripped
1.108 rillig 3860:
1.184 rillig 3861: INSTALL_GAME
1.108 rillig 3862:
1.184 rillig 3863: game binaries
1.108 rillig 3864:
1.184 rillig 3865: INSTALL_LIB
1.108 rillig 3866:
1.184 rillig 3867: shared and static libraries
1.108 rillig 3868:
1.184 rillig 3869: INSTALL_DATA
1.108 rillig 3870:
1.184 rillig 3871: data files
1.1 dsieger 3872:
1.184 rillig 3873: INSTALL_GAME_DATA
1.1 dsieger 3874:
1.184 rillig 3875: data files for games
1.108 rillig 3876:
1.184 rillig 3877: INSTALL_MAN
1.108 rillig 3878:
1.184 rillig 3879: man pages
1.1 dsieger 3880:
1.184 rillig 3881: Some other variables are:
1.1 dsieger 3882:
1.184 rillig 3883: INSTALL_UNSTRIPPED
1.1 dsieger 3884:
1.184 rillig 3885: If set to yes, do not run strip(1) when installing binaries. Any debugging
3886: sections and symbols present in binaries will be preserved.
1.1 dsieger 3887:
1.184 rillig 3888: INSTALLATION_DIRS
1.1 dsieger 3889:
1.184 rillig 3890: A list of directories relative to PREFIX that are created by pkgsrc at the
3891: beginning of the install phase. The package is supposed to create all
3892: needed directories itself before installing files to it and list all other
3893: directories here.
1.1 dsieger 3894:
1.184 rillig 3895: In the rare cases that a package shouldn't install anything, set NO_INSTALL to
1.266 martin 3896: yes . This is mostly relevant for packages in the regress category.
1.1 dsieger 3897:
1.266 martin 3898: 13.15. The package phase
1.121 sevan 3899:
1.184 rillig 3900: Once the install stage has completed, a binary package of the installed files
3901: can be built. These binary packages can be used for quick installation without
3902: previous compilation, e.g. by the make bin-install or by using pkg_add.
1.1 dsieger 3903:
1.184 rillig 3904: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
3905: created in ${PACKAGES}/category, one for each category in the CATEGORIES
3906: variable. PACKAGES defaults to pkgsrc/packages.
1.1 dsieger 3907:
1.266 martin 3908: 13.16. Cleaning up
1.1 dsieger 3909:
1.184 rillig 3910: Once you're finished with a package, you can clean the work directory by
3911: running make clean. If you want to clean the work directories of all
3912: dependencies too, use make clean-depends.
1.1 dsieger 3913:
1.266 martin 3914: 13.17. Other helpful targets
1.1 dsieger 3915:
1.184 rillig 3916: pre/post-*
1.1 dsieger 3917:
1.184 rillig 3918: For any of the main targets described in the previous section (configure,
1.266 martin 3919: build, install, etc.), two auxiliary targets exist with pre- and post-
1.184 rillig 3920: used as a prefix for the main target's name. These targets are invoked
3921: before and after the main target is called, allowing extra configuration or
3922: installation steps be performed from a package's Makefile, for example,
3923: which a program's configure script or install target omitted.
3924:
3925: About 5% of the pkgsrc packages define their custom post-extract target,
3926: another 5% define pre-configure, and 10% define post-install. The other pre
3927: /post-* targets are defined even less often.
1.1 dsieger 3928:
1.184 rillig 3929: do-*
1.182 leot 3930:
1.184 rillig 3931: Should one of the main targets do the wrong thing, and should there be no
3932: variable to fix this, you can redefine it with the do-* target. (Note that
3933: redefining the target itself instead of the do-* target is a bad idea, as
3934: the pre-* and post-* targets won't be called anymore, etc.)
1.1 dsieger 3935:
1.184 rillig 3936: About 15% of the pkgsrc packages override the default do-install, the other
3937: do-* targets are overridden even less often.
1.1 dsieger 3938:
1.184 rillig 3939: reinstall
1.1 dsieger 3940:
1.184 rillig 3941: If you did a make install and you noticed some file was not installed
3942: properly, you can repeat the installation with this target, which will
1.266 martin 3943: ignore the already installed flag.
1.1 dsieger 3944:
1.184 rillig 3945: This is the default value of DEPENDS_TARGET except in the case of make
1.266 martin 3946: update and make package, where the defaults are package and update ,
1.184 rillig 3947: respectively.
1.1 dsieger 3948:
1.184 rillig 3949: deinstall
1.1 dsieger 3950:
1.184 rillig 3951: This target does a pkg_delete(1) in the current directory, effectively
3952: de-installing the package. The following variables can be used to tune the
3953: behaviour:
1.1 dsieger 3954:
1.184 rillig 3955: PKG_VERBOSE
1.1 dsieger 3956:
1.184 rillig 3957: Add a "-v" to the pkg_delete(1) command.
1.1 dsieger 3958:
1.184 rillig 3959: DEINSTALLDEPENDS
1.1 dsieger 3960:
1.184 rillig 3961: Remove all packages that require (depend on) the given package. This
3962: can be used to remove any packages that may have been pulled in by a
3963: given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
1.266 martin 3964: pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding -R
3965: to the pkg_delete(1) command line.
1.1 dsieger 3966:
1.184 rillig 3967: bin-install
1.1 dsieger 3968:
1.184 rillig 3969: Install a binary package from local disk and via FTP from a list of sites
3970: (see the BINPKG_SITES variable), and do a make package if no binary package
3971: is available anywhere. The arguments given to pkg_add can be set via
3972: BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
1.1 dsieger 3973:
1.184 rillig 3974: install-clean
1.1 dsieger 3975:
1.184 rillig 3976: This target removes the state files for the "install" and later phases so
3977: that the "install" target may be re-invoked. This can be used after editing
3978: the PLIST to install the package without rebuilding it.
1.1 dsieger 3979:
1.184 rillig 3980: build-clean
1.18 mishka 3981:
1.184 rillig 3982: This target removes the state files for the "build" and later phases so
3983: that the "build" target may be re-invoked.
1.18 mishka 3984:
1.184 rillig 3985: update
1.18 mishka 3986:
1.184 rillig 3987: This target causes the current package to be updated to the latest version.
3988: The package and all depending packages first get de-installed, then current
3989: versions of the corresponding packages get compiled and installed. This is
3990: similar to manually noting which packages are currently installed, then
3991: performing a series of make deinstall and make install (or whatever
3992: UPDATE_TARGET is set to) for these packages.
1.18 mishka 3993:
1.266 martin 3994: You can use the update target to resume package updating in case a
1.184 rillig 3995: previous make update was interrupted for some reason. However, in this
3996: case, make sure you don't call make clean or otherwise remove the list of
3997: dependent packages in WRKDIR. Otherwise, you lose the ability to
3998: automatically update the current package along with the dependent packages
3999: you have installed.
1.121 sevan 4000:
1.184 rillig 4001: Resuming an interrupted make update will only work as long as the package
4002: tree remains unchanged. If the source code for one of the packages to be
4003: updated has been changed, resuming make update will most certainly fail!
1.1 dsieger 4004:
1.184 rillig 4005: The following variables can be used either on the command line or in
4006: mk.conf to alter the behaviour of make update:
1.1 dsieger 4007:
1.184 rillig 4008: UPDATE_TARGET
1.1 dsieger 4009:
1.184 rillig 4010: Install target to recursively use for the updated package and the
1.266 martin 4011: dependent packages. Defaults to DEPENDS_TARGET if set, install
4012: otherwise for make update. Other good targets are package or
4013: bin-install . Do not set this to update or you will get stuck in an
1.184 rillig 4014: endless loop!
1.1 dsieger 4015:
1.184 rillig 4016: NOCLEAN
1.1 dsieger 4017:
1.184 rillig 4018: Don't clean up after updating. Useful if you want to leave the work
4019: sources of the updated packages around for inspection or other
1.266 martin 4020: purposes. Be sure you eventually clean up the source tree (see the
4021: clean-update target below) or you may run into troubles with old
1.184 rillig 4022: source code still lying around on your next make or make update.
1.1 dsieger 4023:
1.184 rillig 4024: REINSTALL
1.1 dsieger 4025:
1.184 rillig 4026: Deinstall each package before installing (making DEPENDS_TARGET). This
1.266 martin 4027: may be necessary if the clean-update target (see below) was called
1.184 rillig 4028: after interrupting a running make update.
1.1 dsieger 4029:
1.184 rillig 4030: DEPENDS_TARGET
1.1 dsieger 4031:
1.184 rillig 4032: Allows you to disable recursion and hardcode the target for packages.
1.266 martin 4033: The default is update for the update target, facilitating a recursive
1.184 rillig 4034: update of prerequisite packages. Only set DEPENDS_TARGET if you want to
4035: disable recursive updates. Use UPDATE_TARGET instead to just set a
4036: specific target for each package to be installed during make update
4037: (see above).
1.1 dsieger 4038:
1.184 rillig 4039: clean-update
1.1 dsieger 4040:
1.184 rillig 4041: Clean the source tree for all packages that would get updated if make
4042: update was called from the current directory. This target should not be
4043: used if the current package (or any of its depending packages) have already
4044: been de-installed (e.g., after calling make update) or you may lose some
4045: packages you intended to update. As a rule of thumb: only use this target
4046: before the first time you run make update and only if you have a dirty
4047: package tree (e.g., if you used NOCLEAN).
1.86 wiz 4048:
1.184 rillig 4049: If you are unsure about whether your tree is clean, you can either perform
4050: a make clean at the top of the tree, or use the following sequence of
4051: commands from the directory of the package you want to update (before
4052: running make update for the first time, otherwise you lose all the packages
4053: you wanted to update!):
1.86 wiz 4054:
1.184 rillig 4055: # make clean-update
4056: # make clean CLEANDEPENDS=YES
4057: # make update
1.86 wiz 4058:
4059:
1.184 rillig 4060: The following variables can be used either on the command line or in
4061: mk.conf to alter the behaviour of make clean-update:
1.86 wiz 4062:
1.184 rillig 4063: CLEAR_DIRLIST
1.86 wiz 4064:
1.184 rillig 4065: After make clean, do not reconstruct the list of directories to update
4066: for this package. Only use this if make update successfully installed
4067: all packages you wanted to update. Normally, this is done automatically
4068: on make update, but may have been suppressed by the NOCLEAN variable
4069: (see above).
1.1 dsieger 4070:
1.184 rillig 4071: replace
1.1 dsieger 4072:
1.184 rillig 4073: Update the installation of the current package. This differs from update in
4074: that it does not replace dependent packages. You will need to install
4075: pkgtools/pkg_tarup for this target to work.
1.1 dsieger 4076:
1.184 rillig 4077: Be careful when using this target! There are no guarantees that dependent
4078: packages will still work, in particular they will most certainly break if
4079: you make replace a library package whose shared library major version
4080: changed between your installed version and the new one. For this reason,
4081: this target is not officially supported and only recommended for advanced
4082: users.
1.1 dsieger 4083:
1.184 rillig 4084: info
1.1 dsieger 4085:
1.184 rillig 4086: This target invokes pkg_info(1) for the current package. You can use this
4087: to check which version of a package is installed.
1.86 wiz 4088:
1.184 rillig 4089: index
1.1 dsieger 4090:
1.184 rillig 4091: This is a top-level command, i.e. it should be used in the pkgsrc
4092: directory. It creates a database of all packages in the local pkgsrc tree,
4093: including dependencies, comment, maintainer, and some other useful
4094: information. Individual entries are created by running make describe in the
4095: packages' directories. This index file is saved as pkgsrc/INDEX. It can be
4096: displayed in verbose format by running make print-index. You can search in
4097: it with make search key=something. You can extract a list of all packages
4098: that depend on a particular one by running make show-deps PKG=somepackage.
1.1 dsieger 4099:
1.184 rillig 4100: Running this command takes a very long time, some hours even on fast
4101: machines!
1.1 dsieger 4102:
1.184 rillig 4103: readme
1.1 dsieger 4104:
1.199 nia 4105: This target generates a index.html file, which can be viewed using a
1.184 rillig 4106: browser such as www/firefox or www/links. The generated files contain
4107: references to any packages which are in the PACKAGES directory on the local
4108: host. The generated files can be made to refer to URLs based on
4109: FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
1.199 nia 4110: index.html files which pointed to binary packages on the local machine, in
1.184 rillig 4111: the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
4112: FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
4113: subdirectories will be searched for all the binary packages.
1.1 dsieger 4114:
1.184 rillig 4115: The target can be run at the toplevel or in category directories, in which
4116: case it descends recursively.
1.1 dsieger 4117:
1.184 rillig 4118: readme-all
1.1 dsieger 4119:
1.184 rillig 4120: This is a top-level command, run it in pkgsrc. Use this target to create a
4121: file README-all.html which contains a list of all packages currently
4122: available in the NetBSD Packages Collection, together with the category
4123: they belong to and a short description. This file is compiled from the
1.199 nia 4124: pkgsrc/*/index.html files, so be sure to run this after a make readme.
1.1 dsieger 4125:
1.184 rillig 4126: cdrom-readme
1.1 dsieger 4127:
1.266 martin 4128: This is very much the same as the readme target (see above), but is to be
1.184 rillig 4129: used when generating a pkgsrc tree to be written to a CD-ROM. This target
1.199 nia 4130: also produces index.html files, and can be made to refer to URLs based on
1.184 rillig 4131: CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
1.1 dsieger 4132:
1.184 rillig 4133: show-distfiles
1.1 dsieger 4134:
1.184 rillig 4135: This target shows which distfiles and patchfiles are needed to build the
4136: package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
4137: patches/*).
1.1 dsieger 4138:
1.184 rillig 4139: show-downlevel
1.1 dsieger 4140:
1.184 rillig 4141: This target shows nothing if the package is not installed. If a version of
4142: this package is installed, but is not the version provided in this version
4143: of pkgsrc, then a warning message is displayed. This target can be used to
4144: show which of your installed packages are downlevel, and so the old
4145: versions can be deleted, and the current ones added.
1.1 dsieger 4146:
1.184 rillig 4147: show-pkgsrc-dir
1.1 dsieger 4148:
1.184 rillig 4149: This target shows the directory in the pkgsrc hierarchy from which the
4150: package can be built and installed. This may not be the same directory as
4151: the one from which the package was installed. This target is intended to be
4152: used by people who may wish to upgrade many packages on a single host, and
1.266 martin 4153: can be invoked from the top-level pkgsrc Makefile by using the
4154: show-host-specific-pkgs target.
1.1 dsieger 4155:
1.184 rillig 4156: show-installed-depends
1.1 dsieger 4157:
1.184 rillig 4158: This target shows which installed packages match the current package's
4159: DEPENDS. Useful if out of date dependencies are causing build problems.
1.1 dsieger 4160:
1.184 rillig 4161: print-build-depends-list
1.1 dsieger 4162:
1.184 rillig 4163: This target shows the list of packages that the current package depends on
4164: for building.
1.1 dsieger 4165:
1.184 rillig 4166: print-run-depends-list
1.1 dsieger 4167:
1.184 rillig 4168: This target shows the list of packages that the current package depends on
4169: for running.
1.1 dsieger 4170:
1.184 rillig 4171: check-shlibs
1.1 dsieger 4172:
1.184 rillig 4173: After a package is installed, check all its binaries and (on ELF platforms)
4174: shared libraries to see if they find the shared libs they need. Run by
4175: default if PKG_DEVELOPER is set in mk.conf.
1.1 dsieger 4176:
1.184 rillig 4177: print-PLIST
1.1 dsieger 4178:
1.266 martin 4179: After a make install from a new or upgraded pkg, this prints out an
1.184 rillig 4180: attempt to generate a new PLIST from a find -newer work/.extract_done. An
4181: attempt is made to care for shared libs etc., but it is strongly
4182: recommended to review the result before putting it into PLIST. On upgrades,
4183: it's useful to diff the output of this command against an already existing
4184: PLIST file.
1.1 dsieger 4185:
1.184 rillig 4186: If the package installs files via tar(1) or other methods that don't update
4187: file access times, be sure to add these files manually to your PLIST, as
1.266 martin 4188: the find -newer command used by this target won't catch them!
1.56 ryoon 4189:
1.266 martin 4190: See Section 19.3, Tweaking output of make print-PLIST for more
1.184 rillig 4191: information on this target.
1.1 dsieger 4192:
1.255 wiz 4193: rebuild
4194:
4195: If you did a make build and you noticed some further modifications of
4196: sources are needed, you can repeat the build with this target, which will
1.266 martin 4197: ignore the already built flag. This target is helpful while working with
1.255 wiz 4198: patches.
4199:
4200: repackage
4201:
4202: If you did a make package and you noticed some further modifications of
4203: sources are needed, you can repeat the package with this target, which will
1.266 martin 4204: ignore the already packaged flag. This target is helpful while working
1.255 wiz 4205: with patches, PLIST* files etc.
4206:
4207: retest
4208:
4209: If you did a make test and you noticed some further modifications of
4210: sources are needed, you can repeat the test with this target, which will
1.266 martin 4211: ignore the already tested flag. This target is helpful while working with
1.255 wiz 4212: patches.
4213:
1.266 martin 4214: Chapter 14. Creating a new pkgsrc package from scratch
1.1 dsieger 4215:
1.184 rillig 4216: Table of Contents
1.1 dsieger 4217:
1.184 rillig 4218: 14.1. Common types of packages
1.219 nia 4219: 14.1.1. Python modules and programs
4220: 14.1.2. R packages
4221: 14.1.3. TeXlive packages
1.184 rillig 4222: 14.2. Examples
4223: 14.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 4224:
1.184 rillig 4225: When you find a package that is not yet in pkgsrc, you most likely have a URL
4226: from where you can download the source code. Starting with this URL, creating a
4227: package involves only a few steps.
1.1 dsieger 4228:
1.184 rillig 4229: 1. In your mk.conf, set PKG_DEVELOPER=yes to enable the basic quality checks.
1.1 dsieger 4230:
1.184 rillig 4231: 2. Install the package meta-pkgs/pkg_developer, which among others will
4232: install the utilities url2pkg, pkglint, pkgvi and mkpatches:
1.1 dsieger 4233:
1.184 rillig 4234: $ cd /usr/pkgsrc
4235: $ (cd meta-pkgs/pkg_developer && bmake update)
1.1 dsieger 4236:
1.184 rillig 4237: 3. Choose one of the top-level directories as the category in which you want
4238: to place your package. You can also create a directory of your own (maybe
1.219 nia 4239: called local). Change into that category directory:
1.1 dsieger 4240:
1.219 nia 4241: $ cd category
1.1 dsieger 4242:
1.219 nia 4243: 4. Run the program url2pkg, passing as argument the URL of the distribution
4244: file (in most cases a .tar.gz file). This will download the distribution
4245: file and create the necessary files of the package, based on what's in the
4246: distribution file:
1.1 dsieger 4247:
1.184 rillig 4248: $ url2pkg https://www.example.org/packages/package-1.0.tar.gz
1.1 dsieger 4249:
1.184 rillig 4250: 5. Examine the extracted files to determine the dependencies of your package.
4251: Ideally, this is mentioned in some README file, but things may differ. For
4252: each of these dependencies, look where it exists in pkgsrc, and if there is
4253: a file called buildlink3.mk in that directory, add a line to your package
4254: Makefile which includes that file just before the last line. If the
4255: buildlink3.mk file does not exist, it must be created first. The
4256: buildlink3.mk file makes sure that the package's include files and
4257: libraries are provided.
1.1 dsieger 4258:
1.219 nia 4259: If you just need binaries from a dependent package, add a DEPENDS line to
4260: the Makefile, which specifies the version of the dependency and where it
4261: can be found in pkgsrc. This line should be placed in the third paragraph.
4262: If the dependency is only needed for building the package, but not when
4263: using it, use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The
4264: difference between TOOL_DEPENDS and BUILD_DEPENDS occurs when
4265: cross-compiling: TOOL_DEPENDS are native packages, i.e. packages for the
4266: platform where the package is built; BUILD_DEPENDS are target packages,
4267: i.e. packages for the platform for which the package is built. There is
4268: also TEST_DEPENDS, which specifies a dependency used only for testing the
4269: resulting package built, using the upstream project's included test suite,
4270: on the native platform. Your package may then look like this:
1.1 dsieger 4271:
1.184 rillig 4272: [...]
1.1 dsieger 4273:
1.184 rillig 4274: TOOL_DEPENDS+= libxslt-[0-9]*:../../textproc/libxslt
4275: DEPENDS+= screen-[0-9]*:../../misc/screen
4276: DEPENDS+= screen>=4.0:../../misc/screen
1.1 dsieger 4277:
1.184 rillig 4278: [...]
1.1 dsieger 4279:
1.184 rillig 4280: .include "../../category/package/buildlink3.mk"
4281: .include "../../devel/glib2/buildlink3.mk"
4282: .include "../../mk/bsd.pkg.mk"
1.1 dsieger 4283:
1.184 rillig 4284: 6. Run pkglint to see what things still need to be done to make your package a
1.266 martin 4285: good one. If you don't know what pkglint's warnings want to tell you, try
1.184 rillig 4286: pkglint --explain or pkglint -e, which outputs additional explanations.
1.1 dsieger 4287:
1.184 rillig 4288: 7. In many cases the package is not yet ready to build. You can find
1.266 martin 4289: instructions for the most common cases in the next section, Section 14.1,
4290: Common types of packages . After you have followed the instructions over
1.184 rillig 4291: there, you can hopefully continue here.
1.1 dsieger 4292:
1.184 rillig 4293: 8. Run bmake clean to clean the working directory from the extracted files.
1.219 nia 4294: Besides these files, a lot of cache files and other system information have
4295: been saved in the working directory, which may have become outdated after
4296: you edited the Makefile.
1.1 dsieger 4297:
1.184 rillig 4298: 9. Now, run bmake to build the package. For the various things that can go
1.266 martin 4299: wrong in this phase, consult Chapter 21, Making your package work.
1.1 dsieger 4300:
1.184 rillig 4301: If the extracted files from the package need to be fixed, run multiple
4302: rounds of these commands:
1.1 dsieger 4303:
1.219 nia 4304: $ bmake
1.184 rillig 4305: $ pkgvi ${WRKSRC}/some/file/that/does/not/compile
4306: $ mkpatches
1.219 nia 4307: $ bmake mps
4308: $ bmake clean
1.1 dsieger 4309:
1.184 rillig 4310: 10. When the package builds fine, the next step is to install the package. Run
4311: bmake install and hope that everything works.
1.1 dsieger 4312:
1.184 rillig 4313: 11. Up to now, the file PLIST, which contains a list of the files that are
4314: installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
4315: generate a probably correct list. Check the file using your preferred text
4316: editor to see if the list of files looks plausible.
1.1 dsieger 4317:
1.184 rillig 4318: 12. Run pkglint again to see if the generated PLIST contains garbage or not.
1.1 dsieger 4319:
1.184 rillig 4320: 13. When you ran bmake install, the package had been registered in the database
4321: of installed files, but with an empty list of files. To fix this, run bmake
4322: deinstall and bmake install again. Now the package is registered with the
4323: list of files from PLIST.
1.48 wiz 4324:
1.219 nia 4325: 14. Run bmake clean update to run everything from above again in a single step,
1.184 rillig 4326: making sure that the PLIST is correct and the whole package is created as
4327: intended.
1.48 wiz 4328:
1.219 nia 4329: 15. Run pkglint to see if there's anything left to do.
1.48 wiz 4330:
1.266 martin 4331: 16. Commit the package to pkgsrc-wip or main pkgsrc; see Chapter 23, Submitting
1.184 rillig 4332: and Committing.
1.50 wiz 4333:
1.266 martin 4334: 14.1. Common types of packages
1.1 dsieger 4335:
1.266 martin 4336: 14.1.1. Python modules and programs
1.1 dsieger 4337:
1.184 rillig 4338: Python modules and programs packages are easily created using a set of
4339: predefined variables.
1.1 dsieger 4340:
1.184 rillig 4341: If some Python versions are not supported by the software, set the
4342: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
4343: supported, e.g.
1.1 dsieger 4344:
1.184 rillig 4345: PYTHON_VERSIONS_INCOMPATIBLE= 27
1.1 dsieger 4346:
1.249 gutterid 4347: If the packaged software is a Python module, include ../../lang/python/
1.258 wiz 4348: wheel.mk. Note per PEP-518, the minimum and default requirement to create .whl
4349: files is devel/py-setuptools; however, there are various other possible tools
4350: that projects can use. Thus inclusion of wheel.mk does not imply these defaults
4351: are defined as TOOL_DEPENDS. Whatever the project specifically requires as
4352: packaging tools must be defined in the package Makefile.
1.1 dsieger 4353:
1.266 martin 4354: The package directory should be called py-software and PKGNAME should be set
4355: to ${PYPKGPREFIX}-${DISTNAME} , e.g.
1.1 dsieger 4356:
1.184 rillig 4357: DISTNAME= foopymodule-1.2.10
4358: PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
1.1 dsieger 4359:
1.226 gutterid 4360: For software in PyPi, the name should match what PyPi specifies for "pip
4361: install software".
4362:
1.266 martin 4363: If it is an application, include ../../lang/python/application.mk . In order
1.184 rillig 4364: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
4365: variable and set it to the list of files (paths relative to WRKSRC) that must
4366: be corrected. For example:
1.1 dsieger 4367:
1.184 rillig 4368: REPLACE_PYTHON= *.py
1.1 dsieger 4369:
1.266 martin 4370: 14.1.2. R packages
1.1 dsieger 4371:
1.184 rillig 4372: Simple R packages from CRAN are handled automatically by R2pkg, which is
4373: available in pkgtools/R2pkg. Individual packages (and optionally their
4374: dependencies) may be created and updated. R packages generally follow the same
4375: form, and most of the relevant information needed is contained in a DESCRIPTION
4376: file as part of each R package on CRAN. Consequently, R2pkg downloads that
4377: information and creates or updates a package in the canonical form. The
4378: resulting package should be reviewed for correctness.
1.1 dsieger 4379:
1.266 martin 4380: 14.1.3. TeXlive packages
1.1 dsieger 4381:
1.184 rillig 4382: TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
4383: available in pkgtools/texlive2pkg.
1.1 dsieger 4384:
1.266 martin 4385: If the TeXlive package name is not known, it may be useful to search CTAN. A
4386: Contained in field on the package page typically identifies the basename of
1.184 rillig 4387: the package file in the TeXlive archive.
1.1 dsieger 4388:
1.184 rillig 4389: If the TeXlive package name is known, download the files from the TeXlive
4390: archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
4391: packages also have associated documentation packages, so download
4392: foo.doc.tar.xz at the same time. These files should be placed in the
4393: appropriate category directory, which is often but not always print. Then run
4394: the following command in the category directory.
1.1 dsieger 4395:
1.184 rillig 4396: texlive2pkg foo.tar.xz foo.doc.tar.xz
1.1 dsieger 4397:
1.184 rillig 4398: This will create two packages, tex-foo and tex-foo-doc. Be sure to check that
4399: both packages are correct.
1.1 dsieger 4400:
1.184 rillig 4401: Finally, CTAN currently does not include version information in package
4402: filenames and changes their contents periodically when updates occur.
4403: Consequently, pkgsrc avoids downloading distfiles directly from CTAN and
4404: instead relies on the pkgsrc archives. For each new or updated TeXlive package,
4405: e.g., the main one and the corresponding documentation, upload the distfiles
4406: with the following command in each package directory.
1.1 dsieger 4407:
1.184 rillig 4408: make upload-distfiles
1.117 sevan 4409:
1.266 martin 4410: 14.2. Examples
1.117 sevan 4411:
1.266 martin 4412: 14.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 4413:
1.266 martin 4414: 14.2.1.1. The initial package
1.1 dsieger 4415:
1.266 martin 4416: Looking at the file pkgsrc/doc/TODO, I saw that the nvu package has not yet
1.184 rillig 4417: been imported into pkgsrc. As the description says it has to do with the web,
1.266 martin 4418: the obvious choice for the category is www .
1.1 dsieger 4419:
1.184 rillig 4420: $ mkdir www/nvu
4421: $ cd www/nvu
1.1 dsieger 4422:
1.184 rillig 4423: The web site says that the sources are available as a tar file, so I fed that
4424: URL to the url2pkg program:
1.1 dsieger 4425:
1.184 rillig 4426: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
1.1 dsieger 4427:
1.184 rillig 4428: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
1.266 martin 4429: package name should not have the word sources in it. I also filled in the
1.184 rillig 4430: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
4431: that:
1.1 dsieger 4432:
1.184 rillig 4433: # $NetBSD $
4434: #
1.1 dsieger 4435:
1.184 rillig 4436: DISTNAME= nvu-1.0-sources
4437: PKGNAME= nvu-1.0
4438: CATEGORIES= www
4439: MASTER_SITES= http://cvs.nvu.com/download/
4440: EXTRACT_SUFX= .tar.bz2
1.1 dsieger 4441:
1.184 rillig 4442: MAINTAINER= rillig@NetBSD.org
4443: HOMEPAGE= http://cvs.nvu.com/
4444: COMMENT= Web Authoring System
1.1 dsieger 4445:
1.184 rillig 4446: # url2pkg-marker (please do not remove this line.)
4447: .include "../../mk/bsd.pkg.mk"
1.1 dsieger 4448:
1.184 rillig 4449: On the first line of output above, an artificial space has been added between
4450: NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
4451: the guide.
1.1 dsieger 4452:
1.184 rillig 4453: Then, I quit the editor and watched pkgsrc downloading a large source archive:
1.1 dsieger 4454:
1.184 rillig 4455: url2pkg> Running "make makesum" ...
4456: => Required installed package digest>=20010302: digest-20060826 found
4457: => Fetching nvu-1.0-sources.tar.bz2
4458: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
4459: 100% |*************************************| 28992 KB 150.77 KB/s00:00 ETA
4460: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
4461: url2pkg> Running "make extract" ...
4462: => Required installed package digest>=20010302: digest-20060826 found
4463: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
4464: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
4465: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
4466: ===> Installing dependencies for nvu-1.0
4467: ===> Overriding tools for nvu-1.0
4468: ===> Extracting for nvu-1.0
4469: url2pkg> Adjusting the Makefile.
1.1 dsieger 4470:
1.184 rillig 4471: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
1.1 dsieger 4472:
1.184 rillig 4473: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
1.1 dsieger 4474:
1.266 martin 4475: 14.2.1.2. Fixing all kinds of problems to make the package work
1.1 dsieger 4476:
1.184 rillig 4477: Now that the package has been extracted, let's see what's inside it. The
4478: package has a README.txt, but that only says something about mozilla, so it's
4479: probably useless for seeing what dependencies this package has. But since there
4480: is a GNU configure script in the package, let's hope that it will complain
4481: about everything it needs.
1.1 dsieger 4482:
1.184 rillig 4483: $ bmake
4484: => Required installed package digest>=20010302: digest-20060826 found
4485: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
4486: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
4487: ===> Patching for nvu-1.0
4488: ===> Creating toolchain wrappers for nvu-1.0
4489: ===> Configuring for nvu-1.0
4490: [...]
4491: configure: error: Perl 5.004 or higher is required.
4492: [...]
4493: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
4494: [...]
1.1 dsieger 4495:
1.184 rillig 4496: That worked quite well. So I opened the package Makefile in my editor, and
1.266 martin 4497: since it already has a USE_TOOLS line, I just appended perl to it. Since the
1.184 rillig 4498: dependencies of the package have changed now, and since a perl wrapper is
1.266 martin 4499: automatically installed in the tools phase, I need to build the package from
1.184 rillig 4500: scratch.
1.1 dsieger 4501:
1.184 rillig 4502: $ bmake clean
4503: ===> Cleaning for nvu-1.0
4504: $ bmake
4505: [...]
4506: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
4507: GNU Make. You will not be able to build Mozilla without GNU Make.
4508: [...]
1.1 dsieger 4509:
1.266 martin 4510: So I added gmake to the USE_TOOLS line and tried again (from scratch).
1.1 dsieger 4511:
1.184 rillig 4512: [...]
4513: checking for GTK - version >= 1.2.0... no
4514: *** Could not run GTK test program, checking why...
4515: [...]
1.1 dsieger 4516:
1.184 rillig 4517: Now to the other dependencies. The first question is: Where is the GTK package
4518: hidden in pkgsrc?
1.1 dsieger 4519:
1.184 rillig 4520: $ echo ../../*/gtk*
4521: [many packages ...]
4522: $ echo ../../*/gtk
4523: ../../x11/gtk
4524: $ echo ../../*/gtk2
4525: ../../x11/gtk2
4526: $ echo ../../*/gtk2/bui*
4527: ../../x11/gtk2/buildlink3.mk
1.1 dsieger 4528:
1.184 rillig 4529: The first try was definitely too broad. The second one had exactly one result,
4530: which is very good. But there is one pitfall with GNOME packages. Before GNOME
4531: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
4532: able to continue to use these packages, the GNOME 2 packages were imported as
1.266 martin 4533: separate packages, and their names usually have a 2 appended. So I checked
1.184 rillig 4534: whether this was the case here, and indeed it was.
1.1 dsieger 4535:
1.184 rillig 4536: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
4537: easy. I just inserted an .include line before the last line of the package
4538: Makefile, so that it now looks like this:
1.1 dsieger 4539:
1.184 rillig 4540: [...]
4541: .include "../../x11/gtk2/buildlink3.mk"
4542: .include "../../mk/bsd.pkg.mk
1.1 dsieger 4543:
1.184 rillig 4544: After another bmake clean && bmake, the answer was:
1.108 rillig 4545:
1.184 rillig 4546: [...]
4547: checking for gtk-config... /home/roland/pkg/bin/gtk-config
4548: checking for GTK - version >= 1.2.0... no
4549: *** Could not run GTK test program, checking why...
4550: *** The test program failed to compile or link. See the file config.log for the
4551: *** exact error that occured. This usually means GTK was incorrectly installed
4552: *** or that you have moved GTK since it was installed. In the latter case, you
4553: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
4554: configure: error: Test for GTK failed.
4555: [...]
1.1 dsieger 4556:
1.266 martin 4557: In this particular case, the assumption that every package prefers GNOME 2
1.184 rillig 4558: had been wrong. The first of the lines above told me that this package really
4559: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
4560: it would have looked for pkg-config instead of gtk-config. So I changed the x11
4561: /gtk2 to x11/gtk in the package Makefile, and tried again.
1.1 dsieger 4562:
1.184 rillig 4563: [...]
4564: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\" [...]
4565: In file included from xpidl.c:42:
4566: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
4567: In file included from xpidl.c:42:
4568: xpidl.h:132: error: parse error before "IDL_ns"
4569: [...]
1.1 dsieger 4570:
1.184 rillig 4571: The package still does not find all of its dependencies. Now the question is:
4572: Which package provides the libIDL/IDL.h header file?
1.1 dsieger 4573:
1.184 rillig 4574: $ echo ../../*/*idl*
4575: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
4576: $ echo ../../*/*IDL*
4577: ../../net/libIDL
1.1 dsieger 4578:
1.184 rillig 4579: Let's take the one from the second try. So I included the ../../net/libIDL/
4580: buildlink3.mk file and tried again. But the error didn't change. After digging
4581: through some of the code, I concluded that the build process of the package was
4582: broken and couldn't have ever worked, but since the Mozilla source tree is
4583: quite large, I didn't want to fix it. So I added the following to the package
4584: Makefile and tried again:
1.1 dsieger 4585:
1.184 rillig 4586: CPPFLAGS+= -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
4587: BUILDLINK_TRANSFORM+= l:IDL:IDL-2
1.1 dsieger 4588:
1.184 rillig 4589: The latter line is needed because the package expects the library libIDL.so,
4590: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
4591: that on the fly.
1.1 dsieger 4592:
1.184 rillig 4593: The next problem was related to a recent change of the FreeType interface. I
4594: looked up in www/seamonkey which patch files were relevant for this issue and
4595: copied them to the patches directory. Then I retried, fixed the patches so that
4596: they applied cleanly and retried again. This time, everything worked.
1.1 dsieger 4597:
1.266 martin 4598: 14.2.1.3. Installing the package
1.1 dsieger 4599:
1.184 rillig 4600: $ bmake CHECK_FILES=no install
4601: [...]
4602: $ bmake print-PLIST >PLIST
4603: $ bmake deinstall
4604: $ bmake install
1.1 dsieger 4605:
1.266 martin 4606: Chapter 15. Programming in Makefiles
1.1 dsieger 4607:
1.184 rillig 4608: Table of Contents
1.1 dsieger 4609:
1.184 rillig 4610: 15.1. Caveats
4611: 15.2. Makefile variables
4612: 15.2.1. Naming conventions
4613: 15.3. Code snippets
4614: 15.3.1. Adding things to a list
4615: 15.3.2. Echoing a string exactly as-is
4616: 15.3.3. Passing CFLAGS to GNU configure scripts
4617: 15.3.4. Handling possibly empty variables
1.229 gutterid 4618: 15.3.5. Testing yes/no variables in conditions
1.1 dsieger 4619:
1.184 rillig 4620: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
4621: part of the pkgsrc system. Using the make(1) system as a programming language
4622: for a big system like pkgsrc requires some discipline to keep the code correct
4623: and understandable.
1.1 dsieger 4624:
1.184 rillig 4625: The basic ingredients for Makefile programming are variables and shell
4626: commands. Among these shell commands may even be more complex ones like awk(1)
4627: programs. To make sure that every shell command runs as intended it is
4628: necessary to quote all variables correctly when they are used.
1.1 dsieger 4629:
1.184 rillig 4630: This chapter describes some patterns that appear quite often in Makefiles,
4631: including the pitfalls that come along with them.
1.1 dsieger 4632:
1.266 martin 4633: 15.1. Caveats
1.1 dsieger 4634:
1.184 rillig 4635: * When you are creating a file as a target of a rule, always write the data
4636: to a temporary file first and finally rename that file. Otherwise there
4637: might occur an error in the middle of generating the file, and when the
4638: user runs make(1) for the second time, the file exists and will not be
4639: regenerated properly. Example:
1.1 dsieger 4640:
1.184 rillig 4641: wrong:
4642: @echo "line 1" > ${.TARGET}
4643: @echo "line 2" >> ${.TARGET}
4644: @false
1.1 dsieger 4645:
1.184 rillig 4646: correct:
4647: @echo "line 1" > ${.TARGET}.tmp
4648: @echo "line 2" >> ${.TARGET}.tmp
4649: @false
4650: @mv ${.TARGET}.tmp ${.TARGET}
1.1 dsieger 4651:
1.184 rillig 4652: When you run make wrong twice, the file wrong will exist, although there
4653: was an error message in the first run. On the other hand, running make
4654: correct gives an error message twice, as expected.
1.1 dsieger 4655:
1.184 rillig 4656: You might remember that make(1) sometimes removes ${.TARGET} in case of
4657: error, but this only happens when it is interrupted, for example by
4658: pressing Ctrl+C. This does not happen when one of the commands fails (like
4659: false(1) above).
1.1 dsieger 4660:
1.266 martin 4661: 15.2. Makefile variables
1.1 dsieger 4662:
1.184 rillig 4663: Makefile variables contain strings that can be processed using the five
4664: operators =, +=, ?=, := and !=, which are described in the make(1) man page.
1.1 dsieger 4665:
1.184 rillig 4666: When a variable's value is parsed from a Makefile, the hash character # and the
4667: backslash character \ are handled specially. If a backslash is the last
4668: character in a line, that backslash is removed from the line and the line
4669: continues with the next line of the file.
1.1 dsieger 4670:
1.184 rillig 4671: The # character starts a comment that reaches until the end of the line. To get
4672: an actual # character, such as in a URL, write \# instead.
1.1 dsieger 4673:
1.184 rillig 4674: The evaluation of variables either happens immediately or lazy. It happens
4675: immediately when the variable occurs on the right-hand side of the := or the !=
4676: operator, in a .if condition or a .for loop. In the other cases, it is
4677: evaluated lazily.
1.1 dsieger 4678:
1.184 rillig 4679: Some of the modifiers split the string into words and then operate on the
4680: words, others operate on the string as a whole. When a string is split into
4681: words, double quotes and single quotes are interpreted as delimiters, just like
4682: in sh(1).
1.1 dsieger 4683:
1.266 martin 4684: 15.2.1. Naming conventions
1.1 dsieger 4685:
1.184 rillig 4686: * All variable names starting with an underscore are reserved for use by the
4687: pkgsrc infrastructure. They shall not be used by packages.
1.1 dsieger 4688:
1.184 rillig 4689: * In .for loops you should use lowercase variable names for the iteration
4690: variables.
1.1 dsieger 4691:
1.184 rillig 4692: * All list variables should have a plural name, such as PKG_OPTIONS or
4693: DISTFILES.
1.1 dsieger 4694:
1.266 martin 4695: 15.3. Code snippets
1.1 dsieger 4696:
1.266 martin 4697: 15.3.1. Adding things to a list
1.1 dsieger 4698:
1.184 rillig 4699: When adding a string that possibly contains whitespace or quotes to a list
4700: (example 1), it must be quoted using the :Q modifier.
1.1 dsieger 4701:
1.184 rillig 4702: When adding another list to a list (example 2), it must not be quoted, since
4703: its elements are already quoted.
1.1 dsieger 4704:
1.184 rillig 4705: STRING= foo * bar `date`
4706: LIST= # empty
4707: ANOTHER_LIST= a=b c=d
1.1 dsieger 4708:
1.184 rillig 4709: LIST+= ${STRING:Q} # 1
4710: LIST+= ${ANOTHER_LIST} # 2
1.1 dsieger 4711:
1.266 martin 4712: 15.3.2. Echoing a string exactly as-is
1.1 dsieger 4713:
1.184 rillig 4714: Echoing a string containing special characters needs special work.
1.1 dsieger 4715:
1.184 rillig 4716: STRING= foo bar < > * `date` $$HOME ' "
4717: EXAMPLE_ENV= string=${STRING:Q} x=multiple\ quoted\ words
1.1 dsieger 4718:
1.184 rillig 4719: all:
4720: echo ${STRING} # 1
4721: echo ${STRING:Q} # 2
4722: printf '%s\n' ${STRING:Q}'' # 3
4723: env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"' # 4
1.1 dsieger 4724:
1.184 rillig 4725: Example 1 leads to a syntax error in the shell, as the characters are just
4726: copied.
1.1 dsieger 4727:
1.184 rillig 4728: Example 2 quotes the string so that the shell interprets it correctly. But the
4729: echo command may additionally interpret strings with a leading dash or those
4730: containing backslashes.
1.1 dsieger 4731:
1.184 rillig 4732: Example 3 can handle arbitrary strings, since printf(1) only interprets the
4733: format string, but not the next argument. The trailing single quotes handle the
4734: case when the string is empty. In that case, the :Q modifier would result in an
4735: empty string too, which would then be skipped by the shell. For printf(1) this
4736: doesn't make a difference, but other programs may care.
1.1 dsieger 4737:
1.184 rillig 4738: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
4739: has already been done when adding elements to the list.
1.1 dsieger 4740:
1.266 martin 4741: 15.3.3. Passing CFLAGS to GNU configure scripts
1.1 dsieger 4742:
1.184 rillig 4743: When passing CFLAGS or similar variables to a GNU-style configure script
4744: (especially those that call other configure scripts), it must not have leading
4745: or trailing whitespace, since otherwise the configure script gets confused. To
4746: trim leading and trailing whitespace, use the :M modifier, as in the following
4747: example:
1.1 dsieger 4748:
1.184 rillig 4749: CPPFLAGS= # empty
4750: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX}\"
4751: CPPFLAGS+= ${MY_CPPFLAGS}
1.1 dsieger 4752:
1.184 rillig 4753: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
1.1 dsieger 4754:
1.184 rillig 4755: all:
4756: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
4757: echo x${CONFIGURE_ARGS:Q}x # properly trimmed
1.1 dsieger 4758:
1.184 rillig 4759: In this example, CPPFLAGS has both leading and trailing whitespace because the
4760: += operator always adds a space.
1.1 dsieger 4761:
1.266 martin 4762: 15.3.4. Handling possibly empty variables
1.1 dsieger 4763:
1.184 rillig 4764: When a possibly empty variable is used in a shell program, it may lead to a
4765: syntax error.
1.1 dsieger 4766:
1.184 rillig 4767: EGFILES= # empty
1.1 dsieger 4768:
1.184 rillig 4769: install-examples: # produces a syntax error in the shell
4770: for egfile in ${EGFILES}; do \
4771: echo "Installing $$egfile"; \
4772: done
1.1 dsieger 4773:
1.184 rillig 4774: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
4775: with an empty string by make(1). To fix this syntax error, use one of the
4776: snippets below.
1.1 dsieger 4777:
1.229 gutterid 4778: EGFILES= # empty
1.1 dsieger 4779:
1.184 rillig 4780: install-examples:
4781: for egfile in ${EGFILES} ""; do \
4782: [ -n "$$egfile" ] || continue; \
4783: echo "Installing $$egfile"; \
4784: done
1.1 dsieger 4785:
1.184 rillig 4786: In this case, an empty string is appended to the iteration list (to prevent the
4787: syntax error) and filtered out later.
1.1 dsieger 4788:
1.184 rillig 4789: EGFILES= # empty
1.1 dsieger 4790:
1.184 rillig 4791: install-examples:
4792: .for egfile in ${EGFILES}
4793: echo "Installing ${egfile}"
4794: .endfor
1.1 dsieger 4795:
1.184 rillig 4796: If one of the filenames contains special characters, it should be enclosed in
4797: single or double quotes.
1.1 dsieger 4798:
1.184 rillig 4799: To have a shell command test whether a make variable is empty, use the
4800: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1 dsieger 4801:
1.266 martin 4802: 15.3.5. Testing yes/no variables in conditions
1.229 gutterid 4803:
4804: When a variable can have the values yes or no, use the following pattern to
4805: test the variable:
4806:
4807: .if ${VAR:U:tl} == "yes"
4808: # do something
4809: .endif
4810:
4811: The :U modifier is only necessary if the variable can be undefined. If the
4812: variable is guaranteed to be defined, the :U can be omitted.
4813:
4814: The :tl modifier converts the variable value to lowercase, allowing for the
4815: values yes, Yes, YES.
4816:
1.266 martin 4817: Chapter 16. Options handling
1.1 dsieger 4818:
4819: Table of Contents
4820:
1.184 rillig 4821: 16.1. Global default options
4822: 16.2. Converting packages to use bsd.options.mk
4823: 16.3. Option Names
4824: 16.4. Determining the options of dependencies
1.1 dsieger 4825:
4826: Many packages have the ability to be built to support different sets of
4827: features. bsd.options.mk is a framework in pkgsrc that provides generic
4828: handling of those options that determine different ways in which the packages
4829: can be built. It's possible for the user to specify exactly which sets of
4830: options will be built into a package or to allow a set of global default
4831: options apply.
4832:
1.7 rillig 4833: There are two broad classes of behaviors that one might want to control via
4834: options. One is whether some particular feature is enabled in a program that
4835: will be built anyway, often by including or not including a dependency on some
4836: other package. The other is whether or not an additional program will be built
4837: as part of the package. Generally, it is better to make a split package for
4838: such additional programs instead of using options, because it enables binary
4839: packages to be built which can then be added separately. For example, the foo
4840: package might have minimal dependencies (those packages without which foo
4841: doesn't make sense), and then the foo-gfoo package might include the GTK
4842: frontend program gfoo. This is better than including a gtk option to foo that
4843: adds gfoo, because either that option is default, in which case binary users
4844: can't get foo without gfoo, or not default, in which case they can't get gfoo.
4845: With split packages, they can install foo without having GTK, and later decide
4846: to install gfoo (pulling in GTK at that time). This is an advantage to source
4847: users too, avoiding the need for rebuilds.
4848:
4849: Plugins with widely varying dependencies should usually be split instead of
4850: options.
4851:
4852: It is often more work to maintain split packages, especially if the upstream
4853: package does not support this. The decision of split vs. option should be made
4854: based on the likelihood that users will want or object to the various pieces,
4855: the size of the dependencies that are included, and the amount of work.
4856:
4857: A further consideration is licensing. Non-free parts, or parts that depend on
4858: non-free dependencies (especially plugins) should almost always be split if
4859: feasible.
4860:
1.266 martin 4861: 16.1. Global default options
1.1 dsieger 4862:
4863: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
4864: the options that should be built into every package if that option is
1.4 rillig 4865: supported. This variable should be set in mk.conf.
1.1 dsieger 4866:
1.266 martin 4867: 16.2. Converting packages to use bsd.options.mk
1.1 dsieger 4868:
4869: The following example shows how bsd.options.mk should be used by the
4870: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
4871: e.g. options.mk, that is included by the main package Makefile.
4872:
4873: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
4874: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
4875: PKG_OPTIONS_OPTIONAL_GROUPS= database
4876: PKG_OPTIONS_GROUP.database= mysql pgsql
4877: PKG_SUGGESTED_OPTIONS= wibble-foo
4878: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
4879: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
4880:
4881: .include "../../mk/bsd.prefs.mk"
4882:
4883: # this package was previously named wibble2
4884: .if defined(PKG_OPTIONS.wibble2)
4885: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
4886: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
4887: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
4888: .endif
4889:
4890: .include "../../mk/bsd.options.mk"
4891:
4892: # Package-specific option-handling
4893:
4894: ###
4895: ### FOO support
4896: ###
4897: .if !empty(PKG_OPTIONS:Mwibble-foo)
4898: CONFIGURE_ARGS+= --enable-foo
4899: .endif
4900:
4901: ###
4902: ### LDAP support
4903: ###
4904: .if !empty(PKG_OPTIONS:Mldap)
4905: . include "../../databases/openldap-client/buildlink3.mk"
4906: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
4907: .endif
4908:
4909: ###
4910: ### database support
4911: ###
4912: .if !empty(PKG_OPTIONS:Mmysql)
4913: . include "../../mk/mysql.buildlink3.mk"
4914: .endif
4915: .if !empty(PKG_OPTIONS:Mpgsql)
4916: . include "../../mk/pgsql.buildlink3.mk"
4917: .endif
4918:
4919: The first section contains the information about which build options are
4920: supported by the package, and any default options settings if needed.
4921:
4922: 1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
4923: to override the default options. It should be set to PKG_OPTIONS.pkgbase.
4924: Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
4925: the point where the options are processed.
4926:
4927: 2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
4928:
4929: 3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
4930: exclusive options. The options in each group are listed in
4931: PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
4932: the group takes precedence over all other options in the group. Options
4933: from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
4934:
4935: 4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
4936: building the packages will fail if no option from the group is selected.
4937:
4938: 5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
4939: one option from each set must be selected. The options in each set are
4940: listed in PKG_OPTIONS_SET.setname. Options from the sets will be
4941: automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
4942: fail if no option from the set is selected.
4943:
4944: 6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
4945: default.
4946:
1.266 martin 4947: 7. PKG_OPTIONS_LEGACY_VARS is a list of USE_VARIABLE:option pairs that map
1.4 rillig 4948: legacy mk.conf variables to their option counterparts. Pairs should be
1.266 martin 4949: added with += to keep the listing of global legacy variables. A warning
1.1 dsieger 4950: will be issued if the user uses a legacy variable.
4951:
1.266 martin 4952: 8. PKG_OPTIONS_LEGACY_OPTS is a list of old-option:new-option pairs that map
1.1 dsieger 4953: options that have been renamed to their new counterparts. Pairs should be
1.266 martin 4954: added with += to keep the listing of global legacy options. A warning
1.1 dsieger 4955: will be issued if the user uses a legacy option.
4956:
4957: 9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
4958: used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
4959: PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
4960:
4961: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
4962: variables or options used, and what to use instead.
4963:
4964: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
4965: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
4966: options, use PKG_SUGGESTED_OPTIONS.
4967:
4968: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
4969: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
4970: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
4971: options if none of them is supported on the current platform), PKG_OPTIONS is
4972: set to the empty list and the package is otherwise treated as not using the
4973: options framework.
4974:
4975: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
4976: list of selected build options, properly filtered to remove unsupported and
4977: duplicate options.
4978:
4979: The remaining sections contain the logic that is specific to each option. The
4980: correct way to check for an option is to check whether it is listed in
4981: PKG_OPTIONS:
4982:
4983: .if !empty(PKG_OPTIONS:Moption)
4984:
1.266 martin 4985: 16.3. Option Names
1.1 dsieger 4986:
4987: Options that enable similar features in different packages (like optional
4988: support for a library) should use a common name in all packages that support it
4989: (like the name of the library). If another package already has an option with
4990: the same meaning, use the same name.
4991:
4992: Options that enable features specific to one package, where it's unlikely that
4993: another (unrelated) package has the same (or a similar) optional feature,
4994: should use a name prefixed with pkgname-.
4995:
4996: If a group of related packages share an optional feature specific to that
1.266 martin 4997: group, prefix it with the name of the main package (e. g.
1.1 dsieger 4998: djbware-errno-hack).
4999:
5000: For new options, add a line to mk/defaults/options.description. Lines have two
5001: fields, separated by tab. The first field is the option name, the second its
5002: description. The description should be a whole sentence (starting with an
5003: uppercase letter and ending with a period) that describes what enabling the
1.266 martin 5004: option does. E. g. Enable ispell support. The file is sorted by option names.
1.1 dsieger 5005:
1.266 martin 5006: 16.4. Determining the options of dependencies
1.7 rillig 5007:
5008: When writing buildlink3.mk files, it is often necessary to list different
5009: dependencies based on the options with which the package was built. For
5010: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
5011: A typical example looks like this:
5012:
5013: pkgbase := libpurple
5014: .include "../../mk/pkg-build-options.mk"
5015:
5016: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
5017: ...
5018: .endif
5019:
5020: Including pkg-build-options.mk here will set the variable
5021: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
5022: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
5023: pkg-build-options.mk for more details.
5024:
1.266 martin 5025: Chapter 17. Tools needed for building or running
1.184 rillig 5026:
5027: Table of Contents
5028:
5029: 17.1. Tools for pkgsrc builds
5030: 17.2. Tools needed by packages
5031: 17.3. Tools provided by platforms
5032:
5033: The USE_TOOLS definition is used both internally by pkgsrc and also for
5034: individual packages to define what commands are needed for building a package
5035: (like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
5036: DEPENDS). If the native system provides an adequate tool, then in many cases, a
5037: pkgsrc package will not be used.
5038:
5039: When building a package, the replacement tools are made available in a
5040: directory (as symlinks or wrapper scripts) that is early in the executable
5041: search path. Just like the buildlink system, this helps with consistent builds.
5042:
5043: A tool may be needed to help build a specific package. For example, perl, GNU
5044: make (gmake) or yacc may be needed.
5045:
5046: Also a tool may be needed, for example, because the native system's supplied
5047: tool may be inefficient for building a package with pkgsrc. For example, a
5048: package may need GNU awk, bison (instead of yacc) or a better sed.
5049:
5050: The tools used by a package can be listed by running make show-tools.
5051:
1.266 martin 5052: 17.1. Tools for pkgsrc builds
1.184 rillig 5053:
5054: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
5055: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
5056: seen by running: make show-var VARNAME=USE_TOOLS.
5057:
5058: If a package needs a specific program to build then the USE_TOOLS variable can
5059: be used to define the tools needed.
5060:
1.266 martin 5061: 17.2. Tools needed by packages
1.184 rillig 5062:
5063: In the following examples, the :run means that it is needed at run-time (and
5064: becomes a DEPENDS). The default is a build dependency which can be set with
5065: :build. (So in this example, it is the same as gmake:build and
5066: pkg-config:build.)
5067:
5068: USE_TOOLS+= gmake perl:run pkg-config
5069:
5070: When using the tools framework, a TOOLS_PATH.foo variable is defined which
5071: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
1.266 martin 5072: could be /bin/bash on Linux systems.
1.184 rillig 5073:
5074: If you always need a pkgsrc version of the tool at run-time, then just use
5075: DEPENDS instead.
5076:
1.266 martin 5077: 17.3. Tools provided by platforms
1.184 rillig 5078:
5079: When improving or porting pkgsrc to a new platform, have a look at (or create)
5080: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
5081: tools.${OPSYS}.mk which defines the name of the common tools. For example:
5082:
5083: .if exists(/usr/bin/bzcat)
5084: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
5085: .elif exists(/usr/bin/bzip2)
5086: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
5087: .endif
5088:
5089: TOOLS_PLATFORM.true?= true # shell builtin
5090:
1.266 martin 5091: Chapter 18. Buildlink methodology
1.1 dsieger 5092:
5093: Table of Contents
5094:
1.184 rillig 5095: 18.1. Converting packages to use buildlink3
5096: 18.2. Writing buildlink3.mk files
5097: 18.2.1. Anatomy of a buildlink3.mk file
5098: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.271 wiz 5099: buildlink3.mk files
1.184 rillig 5100: 18.3. Writing builtin.mk files
5101: 18.3.1. Anatomy of a builtin.mk file
5102:
5103: Buildlink is a framework in pkgsrc that controls what headers and libraries are
5104: seen by a package's configure and build processes. This is implemented in a two
5105: step process:
5106:
5107: 1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
5108: default is a subdirectory of WRKDIR.
5109:
5110: 2. Create wrapper scripts that are used in place of the normal compiler tools
5111: that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
5112: references to BUILDLINK_DIR. The wrapper scripts also make native compiler
5113: on some operating systems look like GCC, so that packages that expect GCC
5114: won't require modifications to build with those native compilers.
5115:
5116: This normalizes the environment in which a package is built so that the package
5117: may be built consistently despite what other software may be installed. Please
5118: note that the normal system header and library paths, e.g. /usr/include, /usr/
5119: lib, etc., are always searched -- buildlink3 is designed to insulate the
5120: package build from non-system-supplied software.
5121:
1.266 martin 5122: 18.1. Converting packages to use buildlink3
1.1 dsieger 5123:
1.266 martin 5124: The process of converting packages to use the buildlink3 framework ( bl3ifying
1.184 rillig 5125: ) is fairly straightforward. The things to keep in mind are:
1.1 dsieger 5126:
1.184 rillig 5127: 1. Ensure that the build always calls the wrapper scripts instead of the
5128: actual toolchain. Some packages are tricky, and the only way to know for
5129: sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
5130: invoked.
1.1 dsieger 5131:
1.184 rillig 5132: 2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
5133: standalone shells, etc., because the code to symlink files into $
1.266 martin 5134: {BUILDLINK_DIR} looks for files relative to pkg_info -qp pkgname .
1.1 dsieger 5135:
1.184 rillig 5136: 3. Remember that only the buildlink3.mk files that you list in a package's
5137: Makefile are added as dependencies for that package.
1.1 dsieger 5138:
1.184 rillig 5139: If a dependency on a particular package is required for its libraries and
5140: headers, then we replace:
1.1 dsieger 5141:
1.184 rillig 5142: DEPENDS+= foo>=1.1.0:../../category/foo
1.1 dsieger 5143:
1.184 rillig 5144: with
1.1 dsieger 5145:
1.184 rillig 5146: .include "../../category/foo/buildlink3.mk"
1.1 dsieger 5147:
1.184 rillig 5148: The buildlink3.mk files usually define the required dependencies. If you need a
5149: newer version of the dependency when using buildlink3.mk files, then you can
5150: define it in your Makefile; for example:
1.1 dsieger 5151:
1.184 rillig 5152: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
5153: .include "../../category/foo/buildlink3.mk"
1.1 dsieger 5154:
1.184 rillig 5155: There are several buildlink3.mk files in pkgsrc/mk that handle special package
5156: issues:
1.1 dsieger 5157:
1.184 rillig 5158: * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
5159: implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
1.1 dsieger 5160:
1.184 rillig 5161: * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
5162: this will take care to install the devel/ncurses package.
1.1 dsieger 5163:
1.184 rillig 5164: * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
5165: a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
5166: implementation.
1.1 dsieger 5167:
1.184 rillig 5168: * motif.buildlink3.mk checks for a system-provided Motif installation or adds
1.270 wiz 5169: a dependency on x11/motif. The user can set MOTIF_TYPE to dt or motif
5170: to choose which Motif version will be used.
1.1 dsieger 5171:
1.184 rillig 5172: * readline.buildlink3.mk checks for a system-provided GNU readline or
5173: editline (libedit) installation, or adds a dependency on devel/readline,
5174: devel/editline. The user can set READLINE_DEFAULT to choose readline
5175: implementation. If your package really needs GNU readline library, its
5176: Makefile should include devel/readline/buildlink3.mk instead of
5177: readline.buildlink3.mk.
1.1 dsieger 5178:
1.184 rillig 5179: * oss.buildlink3.mk defines several variables that may be used by packages
5180: that use the Open Sound System (OSS) API.
1.1 dsieger 5181:
1.184 rillig 5182: * pgsql.buildlink3.mk will accept any of the Postgres versions in the
5183: variable PGSQL_VERSIONS_ACCEPTED and default to the version
5184: PGSQL_VERSION_DEFAULT. See the file for more information.
1.1 dsieger 5185:
1.184 rillig 5186: * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
5187: pthreads or adds a dependency on devel/pth as needed.
1.1 dsieger 5188:
1.184 rillig 5189: * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
5190: widgets library.
1.1 dsieger 5191:
1.184 rillig 5192: The comments in those buildlink3.mk files provide a more complete description
5193: of how to use them properly.
1.1 dsieger 5194:
1.266 martin 5195: 18.2. Writing buildlink3.mk files
1.1 dsieger 5196:
1.184 rillig 5197: A package's buildlink3.mk file is included by Makefiles to indicate the need to
5198: compile and link against header files and libraries provided by the package. A
5199: buildlink3.mk file should always provide enough information to add the correct
5200: type of dependency relationship and include any other buildlink3.mk files that
5201: it needs to find headers and libraries that it needs in turn.
1.1 dsieger 5202:
1.184 rillig 5203: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
5204: pkgtools/createbuildlink package is highly recommended. For most packages, the
5205: following command will generate a good starting point for buildlink3.mk files:
1.1 dsieger 5206:
1.184 rillig 5207: % cd pkgsrc/category/pkgdir
5208: % createbuildlink >buildlink3.mk
1.1 dsieger 5209:
5210:
1.266 martin 5211: 18.2.1. Anatomy of a buildlink3.mk file
1.1 dsieger 5212:
1.184 rillig 5213: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
5214: tiff:
1.14 jmcneill 5215:
1.184 rillig 5216: BUILDLINK_TREE+= tiff
1.1 dsieger 5217:
1.184 rillig 5218: .if !defined(TIFF_BUILDLINK3_MK)
5219: TIFF_BUILDLINK3_MK:=
1.1 dsieger 5220:
1.184 rillig 5221: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
5222: BUILDLINK_ABI_DEPENDS.tiff+= tiff>=3.7.2nb1
5223: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
1.1 dsieger 5224:
1.184 rillig 5225: .include "../../devel/zlib/buildlink3.mk"
5226: .include "../../graphics/jpeg/buildlink3.mk"
5227: .endif # TIFF_BUILDLINK3_MK
1.1 dsieger 5228:
1.184 rillig 5229: BUILDLINK_TREE+= -tiff
1.1 dsieger 5230:
1.184 rillig 5231: The header and footer manipulate BUILDLINK_TREE, which is common across all
5232: buildlink3.mk files and is used to track the dependency tree.
1.1 dsieger 5233:
1.184 rillig 5234: The main section is protected from multiple inclusion and controls how the
5235: dependency on pkg is added. Several important variables are set in the section:
1.1 dsieger 5236:
1.185 wiz 5237: * BUILDLINK_API_DEPENDS.pkg is the dependency version recorded in the
1.184 rillig 5238: installed package; this should always be set using += to ensure that we're
5239: appending to any pre-existing list of values. This variable should be set
1.185 wiz 5240: to the last version of the package that had an backwards-incompatible API
1.184 rillig 5241: change.
1.1 dsieger 5242:
1.184 rillig 5243: * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
1.1 dsieger 5244:
1.184 rillig 5245: * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
1.236 gutterid 5246: BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
1.266 martin 5247: is selected by setting BUILDLINK_DEPMETHOD.pkg to build . By default, the
1.236 gutterid 5248: full dependency is used.
1.1 dsieger 5249:
1.184 rillig 5250: * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
5251: of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
1.266 martin 5252: library search paths. These default to include and lib respectively.
1.1 dsieger 5253:
1.184 rillig 5254: * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
5255: to add to CPPFLAGS, which are passed on to the configure and build phases.
1.266 martin 5256: The -I option should be avoided and instead be handled using
1.184 rillig 5257: BUILDLINK_INCDIRS.pkg as above.
1.66 asau 5258:
1.184 rillig 5259: The following variables are all optionally defined within this second section
5260: (protected against multiple inclusion) and control which package files are
5261: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
5262: symlinking:
1.23 jakllsch 5263:
1.184 rillig 5264: * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
5265: {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
5266: *.h.
1.1 dsieger 5267:
1.184 rillig 5268: * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
5269: to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
5270: resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
5271: takes the +CONTENTS of a pkg and filters it through $
5272: {BUILDLINK_CONTENTS_FILTER.pkg}.
1.1 dsieger 5273:
1.184 rillig 5274: * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
5275: filters +CONTENTS input into a list of files relative to $
5276: {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
5277: outputs the contents of the include and lib directories in the package
5278: +CONTENTS.
1.1 dsieger 5279:
1.184 rillig 5280: * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
5281: used to transform the name of the source filename into a destination
5282: filename, e.g. -e "s|/curses.h|/ncurses.h|g".
1.1 dsieger 5283:
1.184 rillig 5284: This section can additionally include any buildlink3.mk needed for pkg's
5285: library dependencies. Including these buildlink3.mk files means that the
5286: headers and libraries for these dependencies are also symlinked into $
5287: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
5288: are only added for directly include buildlink3.mk files.
1.1 dsieger 5289:
1.184 rillig 5290: When providing a buildlink3.mk and including other buildlink3.mk files in it,
5291: please only add necessary ones, i.e., those whose libraries or header files are
5292: automatically exposed when the package is use.
1.1 dsieger 5293:
1.184 rillig 5294: In particular, if only an executable (bin/foo) is linked against a library,
5295: that library does not need to be propagated in the buildlink3.mk file.
1.1 dsieger 5296:
1.184 rillig 5297: The following steps should help you decide if a buildlink3.mk file needs to be
5298: included:
1.1 dsieger 5299:
1.184 rillig 5300: * Look at the installed header files: What headers do they include? The
5301: packages providing these files must be buildlinked.
1.1 dsieger 5302:
1.184 rillig 5303: * Run ldd on all installed libraries and look against what other libraries
5304: they link. Some of the packages providing these probably need to be
5305: buildlinked; however, it's not automatic, since e.g. GTK on some systems
5306: pulls in the X libraries, so they will show up in the ldd output, while on
5307: others (like OS X) it won't. ldd output can thus only be used as a hint.
1.1 dsieger 5308:
1.266 martin 5309: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.184 rillig 5310: buildlink3.mk files
1.16 jnemeth 5311:
1.185 wiz 5312: Both variables set lower bounds for a version of this package. The two
5313: variables differ in that one describes source compatibility (API) and the other
5314: binary compatibility (ABI). The difference is that a change in the API breaks
5315: compilation of programs while changes in the ABI stop compiled programs from
5316: running.
5317:
5318: The BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk should be changed
5319: very rarely. (One possible scenario: If all packages using this package need a
5320: higher version than defined in the buildlink3.mk, BUILDLINK_API_DEPENDS.pkg
5321: could be updated to that higher version.)
5322:
5323: On the other hand, changes to BUILDLINK_ABI_DEPENDS.pkg are more common. The
5324: variable will need to be updated every time the major version of one of its
5325: shared libraries is changed, or any other change where a binary built against
5326: the previous version of the package will not run against the new version any
5327: longer.
5328:
5329: In such a case, the package's BUILDLINK_ABI_DEPENDS.pkg must be increased to
5330: require the new package version. Then the PKGREVISION of all packages foo that
5331: depend on this package need to be increased, and if they have buildlink3.mk
5332: files, BUILDLINK_ABI_DEPENDS.foo in their buildlink3.mk files must be increased
5333: to the new version as well. This is required so that a package will pull in the
5334: versions of the packages that use the new ABI and that the packages'
5335: PKGREVISIONs uniquely identify the packages built against the new ABI. The
5336: pkgtools/revbump package can help with these updates.
1.1 dsieger 5337:
1.266 martin 5338: See Section 21.1.5, Handling dependencies for more information about
1.185 wiz 5339: dependencies on other packages, including the BUILDLINK_API_DEPENDS
5340: definitions.
1.1 dsieger 5341:
1.184 rillig 5342: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
1.185 wiz 5343: BUILDLINK_ABI_DEPENDS.pkg in a buildlink3.mk file as we don't want to cause
5344: unneeded package deletions and rebuilds. In many cases, new versions of
5345: packages work just fine with older dependencies.
1.1 dsieger 5346:
1.211 gutterid 5347: Also, it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
1.184 rillig 5348: BUILDLINK_API_DEPENDS.pkg.
1.1 dsieger 5349:
1.211 gutterid 5350: Note there is also the distinction that users are able to disable enforcement
5351: of ABI dependencies using the USE_ABI_DEPENDS variable, but there is no
5352: equivalent option for API dependencies.
5353:
1.266 martin 5354: 18.3. Writing builtin.mk files
1.1 dsieger 5355:
1.184 rillig 5356: Some packages in pkgsrc install headers and libraries that coincide with
5357: headers and libraries present in the base system. Aside from a buildlink3.mk
5358: file, these packages should also include a builtin.mk file that includes the
5359: necessary checks to decide whether using the built-in software or the pkgsrc
5360: software is appropriate.
1.1 dsieger 5361:
1.184 rillig 5362: The only requirements of a builtin.mk file for pkg are:
1.1 dsieger 5363:
1.266 martin 5364: 1. It should set USE_BUILTIN.pkg to either yes or no after it is included.
1.1 dsieger 5365:
1.184 rillig 5366: 2. It should not override any USE_BUILTIN.pkg which is already set before the
5367: builtin.mk file is included.
1.1 dsieger 5368:
1.184 rillig 5369: 3. It should be written to allow multiple inclusion. This is very important
5370: and takes careful attention to Makefile coding.
1.1 dsieger 5371:
1.266 martin 5372: 18.3.1. Anatomy of a builtin.mk file
1.1 dsieger 5373:
1.184 rillig 5374: The following is the recommended template for builtin.mk files:
1.1 dsieger 5375:
1.184 rillig 5376: .if !defined(IS_BUILTIN.foo)
5377: #
5378: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
5379: # genuinely exists in the system or not.
5380: #
5381: IS_BUILTIN.foo?= no
1.1 dsieger 5382:
1.184 rillig 5383: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
5384: # version can be determined.
5385: #
5386: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
5387: BUILTIN_PKG.foo?= foo-1.0
5388: . endif
5389: .endif # IS_BUILTIN.foo
1.1 dsieger 5390:
1.184 rillig 5391: .if !defined(USE_BUILTIN.foo)
5392: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
5393: . if defined(BUILTIN_PKG.foo)
5394: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
5395: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
5396: USE_BUILTIN.foo!= \
5397: ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo} \
5398: && ${ECHO} "yes" || ${ECHO} "no"
5399: . endif
5400: . endfor
5401: . endif
5402: .endif # USE_BUILTIN.foo
1.1 dsieger 5403:
1.184 rillig 5404: CHECK_BUILTIN.foo?= no
5405: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
5406: #
5407: # Here we place code that depends on whether USE_BUILTIN.foo is set to
5408: # "yes" or "no".
5409: #
5410: .endif # CHECK_BUILTIN.foo
1.1 dsieger 5411:
1.184 rillig 5412: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
5413: base system. This should not be a base system software with similar
1.266 martin 5414: functionality to pkg; it should only be yes if the actual package is included
1.184 rillig 5415: as part of the base system. This variable is only used internally within the
5416: builtin.mk file.
1.1 dsieger 5417:
1.184 rillig 5418: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
1.266 martin 5419: system if it exists (if IS_BUILTIN.pkg is yes ). This variable is only used
1.184 rillig 5420: internally within the builtin.mk file.
1.1 dsieger 5421:
1.184 rillig 5422: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
5423: The code in this section must make the determination whether the built-in
5424: software is adequate to satisfy the dependencies listed in
5425: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
5426: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg
5427: must be set to the correct value by the end of the builtin.mk file. Note that
1.266 martin 5428: USE_BUILTIN.pkg may be yes even if IS_BUILTIN.pkg is no because we may make
1.184 rillig 5429: the determination that the built-in version of the software is similar enough
5430: to be used as a replacement.
1.1 dsieger 5431:
1.184 rillig 5432: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
5433: the value of USE_BUILTIN.pkg set in the previous section. This typically
5434: includes, e.g., adding additional dependency restrictions and listing
5435: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
1.1 dsieger 5436:
1.266 martin 5437: Chapter 19. PLIST issues
1.1 dsieger 5438:
1.184 rillig 5439: Table of Contents
1.1 dsieger 5440:
1.184 rillig 5441: 19.1. RCS ID
5442: 19.2. Semi-automatic PLIST generation
5443: 19.3. Tweaking output of make print-PLIST
5444: 19.4. Variable substitution in PLIST
5445: 19.5. Man page compression
5446: 19.6. Changing PLIST source with PLIST_SRC
5447: 19.7. Platform-specific and differing PLISTs
5448: 19.8. Build-specific PLISTs
5449: 19.9. Sharing directories between packages
1.1 dsieger 5450:
1.266 martin 5451: The PLIST file contains a package's packing list , i.e. a list of files that
1.184 rillig 5452: belong to the package (relative to the ${PREFIX} directory it's been installed
5453: in) plus some additional statements - see the pkg_create(1) man page for a full
5454: list. This chapter addresses some issues that need attention when dealing with
5455: the PLIST file (or files, see below!).
1.1 dsieger 5456:
1.266 martin 5457: 19.1. RCS ID
1.1 dsieger 5458:
1.184 rillig 5459: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
1.1 dsieger 5460:
1.184 rillig 5461: @comment $NetBSD $
1.1 dsieger 5462:
1.184 rillig 5463: An artificial space has been added between NetBSD and $, this is a workaround
5464: here to prevent CVS expanding to the filename of the guide. When adding the RCS
5465: ID the space should be omitted.
1.38 wiz 5466:
1.266 martin 5467: 19.2. Semi-automatic PLIST generation
1.1 dsieger 5468:
1.184 rillig 5469: You can use the make print-PLIST command to output a PLIST that matches any new
1.266 martin 5470: files since the package was extracted. See Section 13.17, Other helpful
5471: targets for more information on this target.
1.11 rillig 5472:
1.266 martin 5473: 19.3. Tweaking output of make print-PLIST
1.1 dsieger 5474:
1.184 rillig 5475: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
5476: used to filter the output of print-PLIST. You can append any chunk of AWK
5477: scripting you like to it, but be careful with quoting.
1.1 dsieger 5478:
1.184 rillig 5479: For example, to get all files inside the libdata/foo directory removed from the
5480: resulting PLIST:
1.1 dsieger 5481:
1.184 rillig 5482: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
1.1 dsieger 5483:
1.185 wiz 5484: The PRINT_PLIST_AWK transformations are evaluated after the file list and
5485: directory list are sorted. EARLY_PRINT_PLIST_AWK is like PRINT_PLIST_AWK except
5486: it operates before the file list and directory list are sorted.
5487:
1.266 martin 5488: 19.4. Variable substitution in PLIST
1.1 dsieger 5489:
1.184 rillig 5490: A number of variables are substituted automatically in PLISTs when a package is
5491: installed on a system. This includes the following variables:
1.1 dsieger 5492:
1.184 rillig 5493: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
1.1 dsieger 5494:
1.184 rillig 5495: Some packages like emacs and perl embed information about which
5496: architecture they were built on into the pathnames where they install their
5497: files. To handle this case, PLIST will be preprocessed before actually
1.266 martin 5498: used, and the symbol ${MACHINE_ARCH} will be replaced by what uname -p
1.184 rillig 5499: gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
5500: PLIST somewhere - use this on packages that have GNU autoconf-created
5501: configure scripts.
1.1 dsieger 5502:
1.184 rillig 5503: Legacy note
1.1 dsieger 5504:
1.266 martin 5505: There used to be a symbol $ARCH that was replaced by the output of uname
1.184 rillig 5506: -m, but that's no longer supported and has been removed.
1.1 dsieger 5507:
1.184 rillig 5508: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
1.1 dsieger 5509:
1.184 rillig 5510: Some packages want to embed the OS name and version into some paths. To do
5511: this, use these variables in the PLIST:
1.1 dsieger 5512:
1.271 wiz 5513: o ${OPSYS} - output of uname -s
1.1 dsieger 5514:
1.271 wiz 5515: o ${LOWER_OPSYS} - lowercase common name (eg. solaris )
1.1 dsieger 5516:
1.271 wiz 5517: o ${OS_VERSION} - uname -r
1.1 dsieger 5518:
1.184 rillig 5519: For a list of values which are replaced by default, the output of make help
5520: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
5521: PLIST_SUBST should help.
1.1 dsieger 5522:
1.184 rillig 5523: If you want to change other variables not listed above, you can add variables
5524: and their expansions to this variable in the following way, similar to
1.266 martin 5525: MESSAGE_SUBST (see Section 12.5, Optional files ):
1.1 dsieger 5526:
1.184 rillig 5527: PLIST_SUBST+= SOMEVAR="somevalue"
1.1 dsieger 5528:
1.266 martin 5529: This replaces all occurrences of ${SOMEVAR} in the PLIST with somevalue .
1.1 dsieger 5530:
1.184 rillig 5531: The PLIST_VARS variable can be used to simplify the common case of
5532: conditionally including some PLIST entries. It can be done by adding
5533: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
1.266 martin 5534: entry should be included. This will substitute ${PLIST.foo} in the PLIST with
5535: either "" or "@comment " . For example, in Makefile:
1.1 dsieger 5536:
1.184 rillig 5537: PLIST_VARS+= foo
5538: .if condition
5539: PLIST.foo= yes
5540: .else
1.1 dsieger 5541:
1.184 rillig 5542: And then in PLIST:
1.1 dsieger 5543:
1.184 rillig 5544: @comment $NetBSD $
5545: bin/bar
5546: man/man1/bar.1
5547: ${PLIST.foo}bin/foo
5548: ${PLIST.foo}man/man1/foo.1
5549: ${PLIST.foo}share/bar/foo.data
1.1 dsieger 5550:
1.184 rillig 5551: An artificial space has been added between NetBSD and $, this is a workaround
5552: here to prevent CVS expanding to the filename of the guide. When adding the RCS
1.195 gutterid 5553: ID the space should be omitted.
1.1 dsieger 5554:
1.266 martin 5555: 19.5. Man page compression
1.1 dsieger 5556:
1.184 rillig 5557: Man pages should be installed in compressed form if MANZ is set (in
5558: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
1.266 martin 5559: suffix .gz is appended/removed automatically for man pages according to MANZ
1.184 rillig 5560: and MANCOMPRESSED being set or not, see above for details. This modification of
5561: the PLIST file is done on a copy of it, not PLIST itself.
1.100 leot 5562:
1.266 martin 5563: 19.6. Changing PLIST source with PLIST_SRC
1.100 leot 5564:
1.184 rillig 5565: To use one or more files as source for the PLIST used in generating the binary
5566: package, set the variable PLIST_SRC to the names of that file(s). The files are
5567: later concatenated using cat(1), and the order of things is important. The
5568: default for PLIST_SRC is ${PKGDIR}/PLIST.
1.1 dsieger 5569:
1.266 martin 5570: 19.7. Platform-specific and differing PLISTs
1.1 dsieger 5571:
1.184 rillig 5572: Some packages decide to install a different set of files based on the operating
5573: system being used. These differences can be automatically handled by using the
5574: following files:
1.1 dsieger 5575:
1.184 rillig 5576: * PLIST.common
1.1 dsieger 5577:
1.184 rillig 5578: * PLIST.${OPSYS}
1.1 dsieger 5579:
1.184 rillig 5580: * PLIST.${MACHINE_ARCH}
1.1 dsieger 5581:
1.184 rillig 5582: * PLIST.${OPSYS}-${MACHINE_ARCH}
1.1 dsieger 5583:
1.184 rillig 5584: * PLIST.common_end
1.1 dsieger 5585:
1.266 martin 5586: 19.8. Build-specific PLISTs
1.1 dsieger 5587:
1.184 rillig 5588: Some packages decide to generate hard-to-guess file names during installation
5589: that are hard to wire down.
1.1 dsieger 5590:
1.184 rillig 5591: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
5592: (with a semicolon) that will output PLIST entries which will be appended to the
5593: PLIST
1.1 dsieger 5594:
1.184 rillig 5595: You can find one example in editors/xemacs:
1.1 dsieger 5596:
1.184 rillig 5597: GENERATE_PLIST+= ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.1 dsieger 5598:
1.184 rillig 5599: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
1.1 dsieger 5600:
1.266 martin 5601: 19.9. Sharing directories between packages
1.1 dsieger 5602:
1.266 martin 5603: A shared directory is a directory where multiple (and unrelated) packages
1.184 rillig 5604: install files. These directories were problematic because you had to add
5605: special tricks in the PLIST to conditionally remove them, or have some
5606: centralized package handle them.
1.106 tnn 5607:
1.184 rillig 5608: In pkgsrc, it is now easy: Each package should create directories and install
5609: files as needed; pkg_delete will remove any directories left empty after
5610: uninstalling a package.
1.106 tnn 5611:
1.184 rillig 5612: If a package needs an empty directory to work, create the directory during
5613: installation as usual, and also add an entry to the PLIST:
1.1 dsieger 5614:
1.184 rillig 5615: @pkgdir path/to/empty/directory
1.1 dsieger 5616:
1.184 rillig 5617: or take a look at MAKE_DIRS and OWN_DIRS.
1.1 dsieger 5618:
1.266 martin 5619: Chapter 20. The pkginstall framework
1.1 dsieger 5620:
1.184 rillig 5621: Table of Contents
1.1 dsieger 5622:
1.184 rillig 5623: 20.1. Files and directories outside the installation prefix
5624: 20.1.1. Directory manipulation
5625: 20.1.2. File manipulation
5626: 20.2. Configuration files
5627: 20.2.1. How PKG_SYSCONFDIR is set
5628: 20.2.2. Telling the software where configuration files are
1.239 dholland 5629: 20.2.3. Patching installation
5630: 20.2.4. Declaring configuration files
5631: 20.2.5. Disabling handling of configuration files
1.184 rillig 5632: 20.3. System startup scripts
5633: 20.3.1. Disabling handling of system startup scripts
5634: 20.4. System users and groups
5635: 20.5. System shells
5636: 20.5.1. Disabling shell registration
5637: 20.6. Fonts
5638: 20.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 5639:
1.184 rillig 5640: This chapter describes the framework known as pkginstall, whose key features
5641: are:
1.1 dsieger 5642:
1.184 rillig 5643: * Generic installation and manipulation of directories and files outside the
5644: pkgsrc-handled tree, LOCALBASE.
1.1 dsieger 5645:
1.184 rillig 5646: * Automatic handling of configuration files during installation, provided
5647: that packages are correctly designed.
1.1 dsieger 5648:
1.184 rillig 5649: * Generation and installation of system startup scripts.
1.1 dsieger 5650:
1.184 rillig 5651: * Registration of system users and groups.
1.1 dsieger 5652:
1.184 rillig 5653: * Registration of system shells.
1.1 dsieger 5654:
1.184 rillig 5655: * Automatic updating of fonts databases.
1.1 dsieger 5656:
1.184 rillig 5657: The following sections inspect each of the above points in detail.
1.1 dsieger 5658:
1.184 rillig 5659: You may be thinking that many of the things described here could be easily done
5660: with simple code in the package's post-installation target (post-install). This
5661: is incorrect, as the code in them is only executed when building from source.
5662: Machines using binary packages could not benefit from it at all (as the code
5663: itself could be unavailable). Therefore, the only way to achieve any of the
5664: items described above is by means of the installation scripts, which are
5665: automatically generated by pkginstall.
1.1 dsieger 5666:
1.266 martin 5667: 20.1. Files and directories outside the installation prefix
1.95 wiz 5668:
1.184 rillig 5669: As you already know, the PLIST file holds a list of files and directories that
5670: belong to a package. The names used in it are relative to the installation
5671: prefix (${PREFIX}), which means that it cannot register files outside this
5672: directory (absolute path names are not allowed). Despite this restriction, some
5673: packages need to install files outside this location; e.g., under ${VARBASE} or
5674: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
5675: installation time by using installation scripts.
1.95 wiz 5676:
1.184 rillig 5677: The generic installation scripts are shell scripts that can contain arbitrary
5678: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
5679: which defaults to INSTALL. A similar variable exists for package removal
5680: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
5681: commands, so they have the potential to create and manage files anywhere in the
5682: file system.
1.95 wiz 5683:
1.184 rillig 5684: Using these general installation files is not recommended, but may be needed in
5685: some special cases. One reason for avoiding them is that the user has to trust
5686: the packager that there is no unwanted or simply erroneous code included in the
5687: installation script. Also, previously there were many similar scripts for the
5688: same functionality, and fixing a common error involved finding and changing all
5689: of them.
1.95 wiz 5690:
1.184 rillig 5691: The pkginstall framework offers another, standardized way. It provides generic
5692: scripts to abstract the manipulation of such files and directories based on
5693: variables set in the package's Makefile. The rest of this section describes
5694: these variables.
1.1 dsieger 5695:
1.266 martin 5696: 20.1.1. Directory manipulation
1.1 dsieger 5697:
1.184 rillig 5698: The following variables can be set to request the creation of directories
5699: anywhere in the file system:
1.1 dsieger 5700:
1.184 rillig 5701: * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
5702: and should attempt to be destroyed by the installation scripts. The
5703: difference between the two is that the latter prompts the administrator to
5704: remove any directories that may be left after deinstallation (because they
5705: were not empty), while the former does not. Example:
1.1 dsieger 5706:
1.184 rillig 5707: MAKE_DIRS+= ${VARBASE}/foo/private
1.1 dsieger 5708:
1.184 rillig 5709: * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
5710: which directories should be created and should attempt to be destroyed by
5711: the installation scripts. Each tuple holds the following values, separated
5712: by spaces: the directory name, its owner, its group and its numerical mode.
5713: For example:
1.1 dsieger 5714:
1.184 rillig 5715: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private \
5716: ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1 dsieger 5717:
1.184 rillig 5718: The difference between the two is exactly the same as their non-PERMS
5719: counterparts.
1.1 dsieger 5720:
1.266 martin 5721: 20.1.2. File manipulation
1.1 dsieger 5722:
1.184 rillig 5723: Creating non-empty files outside the installation prefix is tricky because the
5724: PLIST forces all files to be inside it. To overcome this problem, the only
1.239 dholland 5725: solution is to extract the file in a known place (i.e., inside the installation
5726: prefix) and copy it to the appropriate location during installation (done by
5727: the installation scripts generated by pkginstall). We will call the former the
5728: reference file in the following paragraphs, which describe the variables that
5729: can be used to automatically and consistently handle files outside the
5730: installation prefix:
5731:
5732: * REQD_FILES is a list of pairs of reference and target files. At
5733: installation time, the reference file is copied to the target if and only
5734: if the latter does not exist. Upon deinstallation, the reference file is
1.184 rillig 5735: removed provided that it was not modified by the installation.
1.1 dsieger 5736:
1.239 dholland 5737: * REQD_FILES_PERMS contains tuples describing reference files and targets,
5738: including owner, group, and numeric permissions that should be set. For
5739: example:
1.1 dsieger 5740:
1.184 rillig 5741: REQD_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile \
5742: ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1 dsieger 5743:
1.239 dholland 5744: * CONF_FILES and CONF_FILES_PERMS have the same syntax as REQD_FILES and
5745: REQD_FILES_PERMS respectively. The difference is that these variables are
5746: specifically intended for handling configuration files, for which
1.266 martin 5747: additional conventions and constraints apply. See Section 20.2,
5748: Configuration files for further discussion. Note in particular that while
1.239 dholland 5749: handling of configuration files can be disabled by the user (see
1.266 martin 5750: Section 20.2.5, Disabling handling of configuration files ), this setting
1.239 dholland 5751: does not affect REQD_FILES and REQD_FILES_PERMS.
5752:
5753: To install an empty file, one can use these macros and /dev/null as the
5754: reference file.
1.1 dsieger 5755:
1.266 martin 5756: 20.2. Configuration files
1.1 dsieger 5757:
1.239 dholland 5758: There are two principles that govern the handling of configuration files in
5759: pkgsrc: first, the user's configuration must not be lost or overwritten by
5760: upgrades or reinstallations; and second, the default configuration should
5761: always be available for reference. To that end, pkgsrc has a framework
5762: specifically for handling configuration files. In general, configuration files
5763: are installed into ${PREFIX}/share/examples, and copied from there to the
5764: pertinent etc directory as a separate step and only as needed.
5765:
5766: To make this work, there are three things that need to happen, any of which may
5767: require patching. First, the package must be told to read its configuration
5768: from the correct place at runtime; this place is ${PKG_SYSCONFDIR} (or possibly
5769: a subdirectory of it) which is often but not always ${PREFIX}/etc. Second, the
5770: package must be taught to install its default configuration files in ${PREFIX}/
5771: share/examples/${PKGBASE}; this is the point at which patching often becomes
5772: required because it is not the same place as the runtime location. Third, the
5773: configuration files need to be declared in the package makefile; this is the
5774: easy part.
5775:
5776: With those elements in place, the right things will happen: the package install
5777: phase and resulting binary package will not touch ${PKG_SYSCONFDIR}, and the
5778: default configuration will be copied into place by the pkgsrc framework only if
5779: not already present. Similarly, upon deinstall the configuration will not be
5780: removed if it has been modified. (This means that in the case of reinstallation
5781: and upgrades, unmodified configuration files are updated but modifications are
5782: never discarded.)
5783:
5784: The following sections describe how to make these things happen and document
5785: other relevant knobs available in the pkgsrc infrastructure.
1.1 dsieger 5786:
1.266 martin 5787: 20.2.1. How PKG_SYSCONFDIR is set
1.1 dsieger 5788:
1.184 rillig 5789: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
5790: shall be installed. Its contents are set based upon the following variables:
1.1 dsieger 5791:
1.184 rillig 5792: * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
1.239 dholland 5793: etc although it may be overridden by the user to point to their preferred
1.184 rillig 5794: location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
1.1 dsieger 5795:
1.184 rillig 5796: * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
5797: configuration files for the package being built shall be installed. The
5798: definition of this variable only makes sense in the package's Makefile
5799: (i.e., it is not user-customizable).
1.1 dsieger 5800:
1.184 rillig 5801: As an example, consider the Apache package, www/apache24, which places its
5802: configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
5803: should be set in the package Makefile.
1.1 dsieger 5804:
1.184 rillig 5805: * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
5806: package's configuration directory (if different from PKG_SYSCONFBASE). It
5807: defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
1.1 dsieger 5808:
1.184 rillig 5809: * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
5810: configuration files for the package identified by PKG_SYSCONFVAR's shall be
5811: placed.
1.1 dsieger 5812:
1.184 rillig 5813: Based on the above variables, pkginstall determines the value of
1.239 dholland 5814: PKG_SYSCONFDIR, which is the only variable that may be used within a package to
1.184 rillig 5815: refer to its configuration directory. The algorithm used to set its value is
5816: basically the following:
1.1 dsieger 5817:
1.184 rillig 5818: 1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
1.1 dsieger 5819:
1.184 rillig 5820: 2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
5821: package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
5822: {PKG_SYSCONFSUBDIR}.
1.1 dsieger 5823:
1.184 rillig 5824: 3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
1.1 dsieger 5825:
1.184 rillig 5826: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
1.239 dholland 5827: OWN_DIRS. This causes it to be automatically created if needed. See
1.266 martin 5828: Section 20.1.1, Directory manipulation for further details. This does not
1.239 dholland 5829: apply to subdirectories of ${PKG_SYSCONFDIR}; they must be manually created
5830: with OWN_DIRS or MAKE_DIRS.
1.1 dsieger 5831:
1.266 martin 5832: 20.2.2. Telling the software where configuration files are
1.1 dsieger 5833:
1.184 rillig 5834: Given that pkgsrc (and users!) expect configuration files to be in a known
1.239 dholland 5835: place, you need to teach each package where to install its files. In some cases
5836: you will have to patch the package Makefiles to achieve it. If you are lucky,
5837: though, it may be as easy as passing an extra flag to the configuration script.
5838: This is the case for packages using GNU autoconf:
1.1 dsieger 5839:
1.184 rillig 5840: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1 dsieger 5841:
1.184 rillig 5842: Note that this specifies where the package has to look for its configuration
1.239 dholland 5843: files, not where they will be installed. Fortunately, there is a different way
1.240 gutterid 5844: to specify the latter, as seen in the next section, although the combination is
5845: rather confusing at first glance.
1.1 dsieger 5846:
1.266 martin 5847: 20.2.3. Patching installation
1.1 dsieger 5848:
1.239 dholland 5849: As discussed above, packages themselves must not touch the contents of $
1.184 rillig 5850: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
5851: will, out of the box, mess with the contents of that directory. So what is the
5852: correct procedure to fix this issue?
1.1 dsieger 5853:
1.184 rillig 5854: You must teach the package (usually by manually patching it) to install any
5855: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
5856: This way, the PLIST registers them and the administrator always has the
5857: original copies available.
1.1 dsieger 5858:
1.239 dholland 5859: It turns out that for packages using GNU autoconf it is possible to create the
5860: desired effect by setting sysconfdir on the make command line at install time.
5861: Consider this example taken from mail/mutt:
5862:
5863: EGDIR= ${PREFIX}/share/examples/mutt
5864: INSTALL_MAKE_FLAGS= ${MAKE_FLAGS} sysconfdir=${EGDIR}
5865:
5866: Note that the EGDIR variable, though commonly used for this purpose, is local
5867: to that package and has no meaning outside it.
1.1 dsieger 5868:
1.266 martin 5869: 20.2.4. Declaring configuration files
1.1 dsieger 5870:
1.239 dholland 5871: Once the required configuration files are in place (i.e., under the examples
5872: hierarchy), the pkginstall framework can use them as reference copies during
5873: the package installation to update what is in ${PKG_SYSCONFDIR}. To achieve
5874: this, the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
1.266 martin 5875: Section 20.1.2, File manipulation for further information about their syntax
1.239 dholland 5876: and their purpose. Here is an example, taken from the mail/mutt package:
5877:
5878: EGDIR= ${PREFIX}/share/examples/mutt
5879: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
5880:
5881: Note that (as in the previous section's example) the EGDIR variable is specific
5882: to the package and has no meaning outside it.
5883:
5884: For reference, the complete example from Mutt is as follows:
5885:
5886: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
5887: EGDIR= ${PREFIX}/share/examples/mutt
5888: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
5889: INSTALLATION_DIRS+= ${EGDIR}
5890: INSTALL_MAKE_FLAGS= ${MAKE_FLAGS} sysconfdir=${EGDIR}
1.1 dsieger 5891:
1.266 martin 5892: 20.2.5. Disabling handling of configuration files
1.1 dsieger 5893:
1.184 rillig 5894: The automatic copying of config files can be toggled by setting the environment
5895: variable PKG_CONFIG prior to package installation.
1.1 dsieger 5896:
1.266 martin 5897: 20.3. System startup scripts
1.1 dsieger 5898:
1.184 rillig 5899: System startup scripts are special files because they must be installed in a
5900: place known by the underlying OS, usually outside the installation prefix.
1.266 martin 5901: Therefore, the same rules described in Section 20.1, Files and directories
5902: outside the installation prefix apply, and the same solutions can be used.
1.184 rillig 5903: However, pkginstall provides a special mechanism to handle these files.
1.1 dsieger 5904:
1.184 rillig 5905: In order to provide system startup scripts, the package has to:
1.1 dsieger 5906:
1.184 rillig 5907: 1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
1.223 nia 5908: Considering the print/cups-base package as an example, it has a cupsd.sh in
5909: its files directory.
1.95 wiz 5910:
1.184 rillig 5911: 2. Tell pkginstall to handle it, appending the name of the script, without its
5912: extension, to the RCD_SCRIPTS variable. Continuing the previous example:
1.95 wiz 5913:
1.184 rillig 5914: RCD_SCRIPTS+= cupsd
1.95 wiz 5915:
1.184 rillig 5916: Once this is done, pkginstall will do the following steps for each script in an
5917: automated fashion:
1.95 wiz 5918:
1.184 rillig 5919: 1. Process the file found in the files directory applying all the
5920: substitutions described in the FILES_SUBST variable.
1.1 dsieger 5921:
1.184 rillig 5922: 2. Copy the script from the files directory to the examples hierarchy, $
1.239 dholland 5923: {PREFIX}/share/examples/rc.d/. Note that this reference file must be
1.184 rillig 5924: explicitly registered in the PLIST.
1.1 dsieger 5925:
1.184 rillig 5926: 3. Add code to the installation scripts to copy the startup script from the
5927: examples hierarchy into the system-wide startup scripts directory.
1.1 dsieger 5928:
1.266 martin 5929: 20.3.1. Disabling handling of system startup scripts
1.1 dsieger 5930:
1.184 rillig 5931: The automatic copying of config files can be toggled by setting the environment
5932: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
5933: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
5934: rc.d/, no matter what the value of this variable is.
1.1 dsieger 5935:
1.266 martin 5936: 20.4. System users and groups
1.1 dsieger 5937:
1.184 rillig 5938: If a package needs to create special users and/or groups during installation,
5939: it can do so by using the pkginstall framework.
1.1 dsieger 5940:
1.184 rillig 5941: Users can be created by adding entries to the PKG_USERS variable. Each entry
5942: has the following syntax:
1.1 dsieger 5943:
1.184 rillig 5944: user:group
1.1 dsieger 5945:
1.184 rillig 5946: Further specification of user details may be done by setting per-user
5947: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
5948: user's description or comment. PKG_HOME.user is the user's home directory, and
5949: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
5950: and defaults to /sbin/nologin if not specified.
1.1 dsieger 5951:
1.184 rillig 5952: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
5953: whose syntax is:
1.1 dsieger 5954:
1.184 rillig 5955: group
1.1 dsieger 5956:
1.184 rillig 5957: The numeric GID of the group may be set by defining PKG_GID.group.
1.1 dsieger 5958:
1.184 rillig 5959: If a package needs to create the users and groups at an earlier stage, then it
5960: can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
5961: the phase before which the users and groups are created. In this case, the
5962: numeric UIDs and GIDs of the created users and groups are automatically
5963: hardcoded into the final installation scripts.
1.1 dsieger 5964:
1.266 martin 5965: 20.5. System shells
1.1 dsieger 5966:
1.184 rillig 5967: Packages that install system shells should register them in the shell database,
5968: /etc/shells, to make things easier to the administrator. This must be done from
5969: the installation scripts to keep binary packages working on any system.
5970: pkginstall provides an easy way to accomplish this task.
1.1 dsieger 5971:
1.184 rillig 5972: When a package provides a shell interpreter, it has to set the PKG_SHELL
5973: variable to its absolute file name. This will add some hooks to the
5974: installation scripts to handle it. Consider the following example, taken from
5975: shells/zsh:
1.1 dsieger 5976:
1.184 rillig 5977: PKG_SHELL= ${PREFIX}/bin/zsh
1.1 dsieger 5978:
1.266 martin 5979: 20.5.1. Disabling shell registration
1.1 dsieger 5980:
1.184 rillig 5981: The automatic registration of shell interpreters can be disabled by the
5982: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
1.1 dsieger 5983:
1.266 martin 5984: 20.6. Fonts
1.1 dsieger 5985:
1.184 rillig 5986: Packages that install X11 fonts should update the database files that index the
5987: fonts within each fonts directory. This can easily be accomplished within the
5988: pkginstall framework.
1.1 dsieger 5989:
1.184 rillig 5990: When a package installs X11 fonts, it must list the directories in which fonts
1.266 martin 5991: are installed in the FONTS_DIRS.type variables, where type can be one of ttf ,
5992: type1 or x11 . This will add hooks to the installation scripts to run the
1.184 rillig 5993: appropriate commands to update the fonts database files within each of those
5994: directories. For convenience, if the directory path is relative, it is taken to
5995: be relative to the package's installation prefix. Consider the following
5996: example, taken from fonts/dbz-ttf:
1.1 dsieger 5997:
1.184 rillig 5998: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1 dsieger 5999:
1.266 martin 6000: 20.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 6001:
1.184 rillig 6002: The automatic update of fonts databases can be disabled by the administrator by
6003: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
1.1 dsieger 6004:
1.266 martin 6005: Chapter 21. Making your package work
1.1 dsieger 6006:
6007: Table of Contents
6008:
1.154 rillig 6009: 21.1. General operation
6010: 21.1.1. How to pull in user-settable variables from mk.conf
6011: 21.1.2. User interaction
6012: 21.1.3. Handling licenses
6013: 21.1.4. Restricted packages
6014: 21.1.5. Handling dependencies
6015: 21.1.6. Handling conflicts with other packages
6016: 21.1.7. Packages that cannot or should not be built
6017: 21.1.8. Packages which should not be deleted, once installed
6018: 21.1.9. Handling packages with security problems
6019: 21.1.10. How to handle incrementing versions when fixing an existing
1.271 wiz 6020: package
1.154 rillig 6021: 21.1.11. Substituting variable text in the package files (the SUBST
1.271 wiz 6022: framework)
1.154 rillig 6023: 21.2. The fetch phase
6024: 21.2.1. Packages whose distfiles aren't available for plain downloading
6025: 21.2.2. How to handle modified distfiles with the 'old' name
6026: 21.2.3. Packages hosted on github.com
6027: 21.3. The configure phase
6028: 21.3.1. Shared libraries - libtool
6029: 21.3.2. Using libtool on GNU packages that already support libtool
6030: 21.3.3. GNU Autoconf/Automake
1.223 nia 6031: 21.3.4. Meson / ninja
1.260 wiz 6032: 21.3.5. Determining the endianness
1.154 rillig 6033: 21.4. Programming languages
6034: 21.4.1. C, C++, and Fortran
6035: 21.4.2. Java
1.205 wiz 6036: 21.4.3. Go
1.223 nia 6037: 21.4.4. Rust
6038: 21.4.5. Packages containing Perl scripts
6039: 21.4.6. Packages containing shell scripts
6040: 21.4.7. Other programming languages
1.154 rillig 6041: 21.5. The build phase
6042: 21.5.1. Compiling C and C++ code conditionally
6043: 21.5.2. How to handle compiler bugs
1.172 rillig 6044: 21.5.3. No such file or directory
1.266 martin 6045: 21.5.4. Undefined reference to ...
1.172 rillig 6046: 21.5.5. Running out of memory
1.154 rillig 6047: 21.6. The install phase
6048: 21.6.1. Creating needed directories
6049: 21.6.2. Where to install documentation
6050: 21.6.3. Installing highscore files
6051: 21.6.4. Adding DESTDIR support to packages
6052: 21.6.5. Packages with hardcoded paths to other interpreters
1.203 nia 6053: 21.6.6. Packages installing Perl modules
1.254 wiz 6054: 21.6.7. Packages installing pkg-config files
6055: 21.6.8. Packages installing info files
6056: 21.6.9. Packages installing man pages
6057: 21.6.10. Packages installing X11 fonts
6058: 21.6.11. Packages installing SGML or XML data
6059: 21.6.12. Packages installing extensions to the MIME database
6060: 21.6.13. Packages using intltool
6061: 21.6.14. Packages installing startup scripts
6062: 21.6.15. Packages installing TeX modules
6063: 21.6.16. Packages supporting running binaries in emulation
6064: 21.6.17. Packages installing hicolor icons
6065: 21.6.18. Packages installing desktop files
1.154 rillig 6066: 21.7. Marking packages as having problems
1.1 dsieger 6067:
1.266 martin 6068: 21.1. General operation
1.1 dsieger 6069:
6070: One appealing feature of pkgsrc is that it runs on many different platforms. As
6071: a result, it is important to ensure, where possible, that packages in pkgsrc
6072: are portable. This chapter mentions some particular details you should pay
6073: attention to while working on pkgsrc.
6074:
1.266 martin 6075: 21.1.1. How to pull in user-settable variables from mk.conf
1.1 dsieger 6076:
6077: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4 rillig 6078: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
6079: those variables in the preprocessor directives of make(1) (for example .if or
6080: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
6081: loads the user preferences.
1.1 dsieger 6082:
6083: But note that some variables may not be completely defined after ../../mk/
6084: bsd.prefs.mk has been included, as they may contain references to variables
1.108 rillig 6085: that are not yet defined. In shell commands (the lines in Makefile that are
6086: indented with a tab) this is no problem, since variables are only expanded when
6087: they are used. But in the preprocessor directives mentioned above and in
6088: dependency lines (of the form target: dependencies) the variables are expanded
6089: at load time.
1.1 dsieger 6090:
6091: Note
6092:
1.108 rillig 6093: To check whether a variable can be used at load time, run pkglint -Wall on your
6094: package.
1.1 dsieger 6095:
1.266 martin 6096: 21.1.2. User interaction
1.1 dsieger 6097:
6098: Occasionally, packages require interaction from the user, and this can be in a
6099: number of ways:
6100:
6101: * When fetching the distfiles, some packages require user interaction such as
6102: entering username/password or accepting a license on a web page.
6103:
6104: * When extracting the distfiles, some packages may ask for passwords.
6105:
6106: * help to configure the package before it is built
6107:
6108: * help during the build process
6109:
6110: * help during the installation of a package
6111:
1.108 rillig 6112: A package can set the INTERACTIVE_STAGE variable to define which stages need
6113: interaction. This should be done in the package's Makefile, e.g.:
1.1 dsieger 6114:
6115: INTERACTIVE_STAGE= configure install
6116:
6117: The user can then decide to skip this package by setting the BATCH variable.
1.108 rillig 6118: Packages that require interaction are also excluded from bulk builds.
1.1 dsieger 6119:
1.266 martin 6120: 21.1.3. Handling licenses
1.1 dsieger 6121:
6122: Authors of software can choose the licence under which software can be copied.
1.111 sevan 6123: The Free Software Foundation has declared some licenses "Free", and the Open
6124: Source Initiative has a definition of "Open Source".
6125:
6126: By default, pkgsrc allows packages with Free or Open Source licenses to be
6127: built. To allow packages with other licenses to be built as well, the pkgsrc
6128: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
6129: . Note that this variable only affects which packages may be built, while the
6130: license terms often also restrict the actual use of the package and its
6131: redistribution.
1.1 dsieger 6132:
6133: One might want to only install packages with a BSD license, or the GPL, and not
1.20 jnemeth 6134: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111 sevan 6135: variable. The pkgsrc user can override the default by setting the
6136: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
6137: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
6138: pkgsrc/mk/license.mk.
1.1 dsieger 6139:
6140: The license tag mechanism is intended to address copyright-related issues
6141: surrounding building, installing and using a package, and not to address
1.20 jnemeth 6142: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
6143: redistribution restrictions should set these tags.
1.1 dsieger 6144:
6145: Denoting that a package may be copied according to a particular license is done
6146: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
6147: string identifying the license, e.g. in graphics/xv:
6148:
6149: LICENSE= xv-license
6150:
6151: When trying to build, the user will get a notice that the package is covered by
6152: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
6153:
6154: % make
6155: ===> xv-3.10anb9 has an unacceptable license: xv-license.
6156: ===> To view the license, enter "/usr/bin/make show-license".
6157: ===> To indicate acceptance, add this line to your /etc/mk.conf:
6158: ===> ACCEPTABLE_LICENSES+=xv-license
6159: *** Error code 1
6160:
1.260 wiz 6161: In case a package requires multiple licenses, you can add all of them to the
6162: LICENSE variable, connected with the upper-case keyword AND. If the user has a
6163: choice between multiple licenses, you can add them connected with the
6164: upper-case keyword OR, for example:
6165:
6166: LICENSE= isc AND apache-2.0
6167: LICENSE= 2-clause-bsd OR ruby-license
6168:
1.1 dsieger 6169: The license can be viewed with make show-license, and if the user so chooses,
1.4 rillig 6170: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1 dsieger 6171: should not in the future fail because of that license:
6172:
6173: ACCEPTABLE_LICENSES+=xv-license
6174:
1.111 sevan 6175: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
6176: is deprecated because it does not crisply refer to a particular license text.
6177: Another problem with such usage is that it does not enable a user to tell
6178: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
6179: for all packages with that tag.
6180:
1.266 martin 6181: 21.1.3.1. Adding a package with a new license
1.1 dsieger 6182:
1.49 rodent 6183: When adding a package with a new license, the following steps are required:
6184:
1.111 sevan 6185: 1. Check whether the license qualifies as Free or Open Source by referencing
6186: Various Licenses and Comments about Them and Licenses by Name | Open Source
6187: Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
6188: need the -license suffix, and the license name should be added to:
1.49 rodent 6189:
6190: + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
6191:
6192: + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
6193: license.c
6194:
6195: 2. The license text should be added to pkgsrc/licenses for displaying. A list
6196: of known licenses can be seen in this directory.
1.1 dsieger 6197:
1.266 martin 6198: 21.1.3.2. Change to the license
1.1 dsieger 6199:
1.111 sevan 6200: When the license changes (in a way other than formatting), make sure that the
6201: new license has a different name (e.g., append the version number if it exists,
6202: or the date). Just because a user told pkgsrc to build programs under a
6203: previous version of a license does not mean that pkgsrc should build programs
6204: under the new licenses. The higher-level point is that pkgsrc does not evaluate
6205: licenses for reasonableness; the only test is a mechanistic test of whether a
6206: particular text has been approved by either of two bodies (FSF or OSI).
1.1 dsieger 6207:
1.266 martin 6208: 21.1.4. Restricted packages
1.1 dsieger 6209:
1.111 sevan 6210: Some licenses restrict how software may be re-distributed. By declaring the
6211: restrictions, package tools can automatically refrain from e.g. placing binary
6212: packages on FTP sites.
6213:
6214: There are four possible restrictions, which are the cross product of sources
6215: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
6216: this is rarely the exact language in any license, and because non-Free licenses
6217: tend to be different from each other, pkgsrc adopts a definition of FTP and
6218: CD-ROM. "FTP" means making the source or binary file available over the
6219: Internet at no charge. "CD-ROM" means making the source or binary available on
6220: some kind of media, together with other source and binary packages, which is
6221: sold for a distribution charge.
1.1 dsieger 6222:
6223: In order to encode these restrictions, the package system defines five make
6224: variables that can be set to note these restrictions:
6225:
6226: * RESTRICTED
6227:
6228: This variable should be set whenever a restriction exists (regardless of
6229: its kind). Set this variable to a string containing the reason for the
6230: restriction. It should be understood that those wanting to understand the
6231: restriction will have to read the license, and perhaps seek advice of
6232: counsel.
6233:
6234: * NO_BIN_ON_CDROM
6235:
6236: Binaries may not be placed on CD-ROM containing other binary packages, for
6237: which a distribution charge may be made. In this case, set this variable to
6238: ${RESTRICTED}.
6239:
6240: * NO_BIN_ON_FTP
6241:
6242: Binaries may not made available on the Internet without charge. In this
6243: case, set this variable to ${RESTRICTED}. If this variable is set, binary
6244: packages will not be included on ftp.NetBSD.org.
6245:
6246: * NO_SRC_ON_CDROM
6247:
6248: Distfiles may not be placed on CD-ROM, together with other distfiles, for
6249: which a fee may be charged. In this case, set this variable to $
6250: {RESTRICTED}.
6251:
6252: * NO_SRC_ON_FTP
6253:
6254: Distfiles may not made available via FTP at no charge. In this case, set
6255: this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
6256: will not be mirrored on ftp.NetBSD.org.
6257:
1.111 sevan 6258: Please note that packages will be removed from pkgsrc when the distfiles are
1.33 wiz 6259: not distributable and cannot be obtained for a period of one full quarter
1.111 sevan 6260: branch. Packages with manual/interactive fetch must have a maintainer and it is
6261: his/her responsibility to ensure this.
1.33 wiz 6262:
1.266 martin 6263: 21.1.5. Handling dependencies
1.1 dsieger 6264:
1.175 gutterid 6265: Your package may depend on some other package being present, and there are
6266: various ways of expressing this dependency. pkgsrc supports the DEPENDS,
6267: BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS definitions, the USE_TOOLS
6268: definition, as well as dependencies via buildlink3.mk, which is the preferred
6269: way to handle dependencies, and which uses the variables named above. See
1.266 martin 6270: Chapter 18, Buildlink methodology for more information.
1.175 gutterid 6271:
6272: The basic difference is that the DEPENDS definition registers that
6273: pre-requisite in the binary package so it will be pulled in when the binary
6274: package is later installed, whilst the BUILD_DEPENDS, TOOL_DEPENDS, and
6275: TEST_DEPENDS definitions do not, marking a dependency that is only needed for
1.266 martin 6276: building or testing the resulting package. See also Chapter 14, Creating a new
1.175 gutterid 6277: pkgsrc package from scratch for more information.
6278:
6279: This means that if you only need a package present whilst you are building or
6280: testing, it should be noted as a TOOL_DEPENDS, BUILD_DEPENDS, or TEST_DEPENDS.
6281: When cross-compiling, TOOL_DEPENDS are native packages, i.e. packages for the
6282: architecture where the package is built; BUILD_DEPENDS are target packages,
6283: i.e., packages for the architecture for which the package is built.
1.1 dsieger 6284:
1.175 gutterid 6285: The format for a DEPENDS, BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS
6286: definition is:
1.1 dsieger 6287:
6288: <pre-req-package-name>:../../<category>/<pre-req-package>
6289:
1.266 martin 6290: Please note that the pre-req-package-name may include any of the wildcard
1.1 dsieger 6291: version numbers recognized by pkg_info(1).
6292:
1.55 wiz 6293: 1. If your package needs another package's binaries or libraries to build and
1.1 dsieger 6294: run, and if that package has a buildlink3.mk file available, use it:
6295:
6296: .include "../../graphics/jpeg/buildlink3.mk"
6297:
1.55 wiz 6298: 2. If your package needs another package's binaries or libraries only for
6299: building, and if that package has a buildlink3.mk file available, use it:
6300:
6301: .include "../../graphics/jpeg/buildlink3.mk"
6302:
6303: but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
6304: This case is rather rare.
6305:
6306: 3. If your package needs binaries from another package to build, use the
1.156 leot 6307: TOOL_DEPENDS definition:
6308:
6309: TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool
1.1 dsieger 6310:
1.156 leot 6311: 4. If your package needs static libraries to link against, header files to
6312: include, etc. from another package to build, use the BUILD_DEPENDS
6313: definition.
1.1 dsieger 6314:
1.156 leot 6315: 5. If your package needs a library with which to link and there is no
1.26 spz 6316: buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
6317: because the include files and libraries will be hidden from the compiler.
1.1 dsieger 6318:
1.156 leot 6319: 6. If your package needs some executable to be able to run correctly and if
1.26 spz 6320: there's no buildlink3.mk file, this is specified using the DEPENDS
6321: variable. The print/lyx package needs to be able to execute the latex
1.129 wiz 6322: binary from the tex-latex-bin package when it runs, and that is specified:
1.1 dsieger 6323:
1.129 wiz 6324: DEPENDS+= tex-latex-bin-[0-9]*:../../print/tex-latex-bin
1.1 dsieger 6325:
1.175 gutterid 6326: 7. If your package includes a test suite that has extra dependencies only
1.266 martin 6327: required for this purpose (frequently this can be run as a make test
1.175 gutterid 6328: target), use the TEST_DEPENDS variable.
6329:
6330: 8. You can use wildcards in package dependencies. Note that such wildcard
1.26 spz 6331: dependencies are retained when creating binary packages. The dependency is
6332: checked when installing the binary package and any package which matches
6333: the pattern will be used. Wildcard dependencies should be used with care.
1.1 dsieger 6334:
1.266 martin 6335: The -[0-9]* should be used instead of -* to avoid potentially ambiguous
6336: matches such as tk-postgresql matching a tk-* DEPENDS.
1.1 dsieger 6337:
6338: Wildcards can also be used to specify that a package will only build
6339: against a certain minimum version of a pre-requisite:
6340:
1.26 spz 6341: DEPENDS+= ImageMagick>=6.0:../../graphics/ImageMagick
1.1 dsieger 6342:
1.26 spz 6343: This means that the package will build using version 6.0 of ImageMagick or
6344: newer. Such a dependency may be warranted if, for example, the command line
6345: options of an executable have changed.
6346:
1.183 wiz 6347: If you need to depend on minimum versions of libraries, set
6348: BUILDLINK_API_DEPENDS.pkg to the appropriate pattern before including its
6349: buildlink3.mk file, e.g.
6350:
6351: BUILDLINK_API_DEPENDS.jpeg+= jpeg>=9.0
6352: .include "../../graphics/jpeg/buildlink3.mk"
1.1 dsieger 6353:
6354: For security fixes, please update the package vulnerabilities file. See
1.266 martin 6355: Section 21.1.9, Handling packages with security problems for more
1.1 dsieger 6356: information.
6357:
6358: If your package needs files from another package to build, add the relevant
6359: distribution files to DISTFILES, so they will be extracted automatically. See
6360: the print/ghostscript package for an example. (It relies on the jpeg sources
6361: being present in source form during the build.)
6362:
1.266 martin 6363: 21.1.6. Handling conflicts with other packages
1.1 dsieger 6364:
1.226 gutterid 6365: Your package may conflict with other packages users might already have
6366: installed on their system, e.g., if your package installs the same set of files
1.227 wiz 6367: as another package in the pkgsrc tree.
1.1 dsieger 6368:
1.142 leot 6369: For example, x11/libXaw3d and x11/Xaw-Xpm install the same shared library, thus
6370: you set in pkgsrc/x11/libXaw3d/Makefile:
1.1 dsieger 6371:
1.142 leot 6372: CONFLICTS= Xaw-Xpm-[0-9]*
1.1 dsieger 6373:
1.142 leot 6374: and in pkgsrc/x11/Xaw-Xpm/Makefile:
1.1 dsieger 6375:
1.142 leot 6376: CONFLICTS= libXaw3d-[0-9]*
1.1 dsieger 6377:
1.142 leot 6378: pkg_add(1) is able to detect attempts to install packages that conflict with
6379: existing packages and abort. However, in many situations this is too late in
6380: the process. Binary package managers will not know about the conflict until
6381: they attempt to install the package after already downloading it and all its
6382: dependencies. Users may also waste time building a package and its dependencies
6383: only to find out at the end that it conflicts with another package they have
6384: installed.
6385:
6386: To avoid these issues CONFLICTS entries should be added in all cases where it
6387: is known that packages conflict with each other. These CONFLICTS entries are
6388: exported in pkg_summary(5) files and consumed by binary package managers to
6389: inform users that packages cannot be installed onto the target system.
1.1 dsieger 6390:
1.266 martin 6391: 21.1.7. Packages that cannot or should not be built
1.1 dsieger 6392:
6393: There are several reasons why a package might be instructed to not build under
6394: certain circumstances. If the package builds and runs on most platforms, the
1.83 dholland 6395: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
6396: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
6397: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
6398: (OS-version-platform) that can use glob-style wildcards.
6399:
1.114 maya 6400: If a package is not appropriate for some platforms (as opposed to merely
1.83 dholland 6401: broken), a different set of variables should be used as this affects failure
6402: reporting and statistics. If the package is appropriate for most platforms, the
6403: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
6404: for only a small handful of platforms (often exactly one), set
6405: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
6406: triples (OS-version-platform) that can use glob-style wildcards.
1.1 dsieger 6407:
6408: Some packages are tightly bound to a specific version of an operating system,
6409: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
6410: with other versions of the OS, and should be uploaded to a version specific
6411: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
1.266 martin 6412: to yes . This variable is not currently used by any of the package system
1.1 dsieger 6413: internals, but may be used in the future.
6414:
6415: If the package should be skipped (for example, because it provides
6416: functionality already provided by the system), set PKG_SKIP_REASON to a
6417: descriptive message. If the package should fail because some preconditions are
6418: not met, set PKG_FAIL_REASON to a descriptive message.
6419:
1.266 martin 6420: 21.1.8. Packages which should not be deleted, once installed
1.1 dsieger 6421:
6422: To ensure that a package may not be deleted, once it has been installed, the
6423: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.266 martin 6424: carried into any binary package that is made from this pkgsrc entry. A
6425: preserved package will not be deleted using pkg_delete(1) unless the -f
1.1 dsieger 6426: option is used.
6427:
1.266 martin 6428: 21.1.9. Handling packages with security problems
1.1 dsieger 6429:
1.247 wiz 6430: When a vulnerability is found, this should be noted in pkgsrc/doc/
6431: pkg-vulnerabilities. Entries in that file consist of three parts:
1.205 wiz 6432:
6433: * package version pattern
6434:
6435: * type of vulnerability (please cut'n'paste an existing one where possible)
6436:
6437: * URL providing additional information about the issue
6438:
6439: For the package version pattern please always use `<' to mark an upper bound
6440: (not `<='!). This will avoid possible problems due unrelated PKGREVISION bumps
6441: not related to security fixes. Lower bounds can be added too, using '>' or '>=
1.266 martin 6442: '. For example, foo>=1<1.2 would mark versions 1.0 (included) to 1.2
6443: (excluded) of foo as affected by the security issue.
1.205 wiz 6444:
6445: Entries should always be added at the bottom of the file.
6446:
6447: When fixing packages, please modify the upper bound of the corresponding entry.
6448: To continue the previous example, if a fix was backported to version 1.1nb2,
1.266 martin 6449: change the previous pattern to foo>=1<1.1nb2 .
1.205 wiz 6450:
6451: To locally test a package version pattern against a PKGNAME you can use the
6452: pkg_admin pmatch command.
6453:
6454: The URL should be as permanent as possible and provide as much information
6455: about the issue as possible. CVE entries are preferred.
6456:
6457: After committing that file, ask pkgsrc-security@NetBSD.org to update the file
6458: on ftp.NetBSD.org.
1.1 dsieger 6459:
6460: After fixing the vulnerability by a patch, its PKGREVISION should be increased
6461: (this is of course not necessary if the problem is fixed by using a newer
1.32 wiz 6462: release of the software), and the pattern in the pkg-vulnerabilities file must
6463: be updated.
1.1 dsieger 6464:
6465: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
6466: submit a pullup request!
6467:
6468: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
6469: a weekly cron job.
6470:
1.205 wiz 6471: In case a security issue is disputed, please contact
6472: pkgsrc-security@NetBSD.org.
6473:
1.266 martin 6474: 21.1.10. How to handle incrementing versions when fixing an existing package
1.1 dsieger 6475:
6476: When making fixes to an existing package it can be useful to change the version
6477: number in PKGNAME. To avoid conflicting with future versions by the original
1.266 martin 6478: author, a nb1 , nb2 , ... suffix can be used on package versions by setting
6479: PKGREVISION=1 (2, ...). The nb is treated like a . by the package tools.
1.1 dsieger 6480: e.g.
6481:
6482: DISTNAME= foo-17.42
6483: PKGREVISION= 9
6484:
1.266 martin 6485: will result in a PKGNAME of foo-17.42nb9 . If you want to use the original
6486: value of PKGNAME without the nbX suffix, e.g. for setting DIST_SUBDIR, use
1.1 dsieger 6487: PKGNAME_NOREV.
6488:
6489: When a new release of the package is released, the PKGREVISION should be
6490: removed, e.g. on a new minor release of the above package, things should be
6491: like:
6492:
6493: DISTNAME= foo-17.43
6494:
6495: PKGREVISION should be incremented for any non-trivial change in the resulting
6496: binary package. Without a PKGREVISION bump, someone with the previous version
6497: installed has no way of knowing that their package is out of date. Thus,
6498: changes without increasing PKGREVISION are essentially labeled "this is so
6499: trivial that no reasonable person would want to upgrade", and this is the rough
6500: test for when increasing PKGREVISION is appropriate. Examples of changes that
6501: do not merit increasing PKGREVISION are:
6502:
1.274 wiz 6503: * Changing HOMEPAGE, MAINTAINER, or comments in Makefile.
1.1 dsieger 6504:
6505: * Changing build variables if the resulting binary package is the same.
6506:
6507: * Changing DESCR.
6508:
6509: * Adding PKG_OPTIONS if the default options don't change.
6510:
6511: Examples of changes that do merit an increase to PKGREVISION include:
6512:
6513: * Security fixes
6514:
6515: * Changes or additions to a patch file
6516:
6517: * Changes to the PLIST
6518:
1.12 weinem 6519: * A dependency is changed or renamed.
6520:
1.1 dsieger 6521: PKGREVISION must also be incremented when dependencies have ABI changes.
6522:
1.266 martin 6523: 21.1.11. Substituting variable text in the package files (the SUBST framework)
1.1 dsieger 6524:
1.180 rillig 6525: When you want to replace the same text in multiple files, or multiple times in
6526: the same file, it is cumbersome to maintain a patch file for this. This is
6527: where the SUBST framework steps in. It provides an easy-to-use interface for
6528: replacing text in files. It just needs the following information:
1.172 rillig 6529:
1.180 rillig 6530: * In which phase of the package build cycle should the replacement happen?
1.172 rillig 6531:
1.180 rillig 6532: * In which files should the replacement happen?
1.172 rillig 6533:
6534: * Which text should be replaced with what?
6535:
1.180 rillig 6536: This information is encoded in a block of SUBST variables. A minimal example
6537: is:
6538:
6539: SUBST_CLASSES+= paths
6540: SUBST_STAGE.paths= pre-configure
6541: SUBST_FILES.paths= src/*.c
6542: SUBST_SED.paths= -e 's,/usr/local,${PREFIX},g'
6543:
6544: Translated into English, it means: In the pre-configure stage (that is, after
6545: applying the patches from the patches/ directory and before running the
6546: configure script and the portability check), replace the text /usr/local with
6547: the content of the variable PREFIX.
6548:
6549: Each SUBST block starts by appending an identifier to SUBST_CLASSES (note the +
6550: =). This identifier can be chosen freely by the package. If there should ever
6551: be duplicate identifiers, the pkgsrc infrastructure will catch this and fail
6552: early, so don't worry about name collisions.
6553:
6554: Except for SUBST_CLASSES, all variables in a SUBST block are parameterized
6555: using this identifier. In the remainder of this section, these parameterized
6556: variables are written as SUBST_STAGE.*.
6557:
6558: SUBST_CLASSES+= paths
6559: SUBST_STAGE.paths= pre-configure
6560: SUBST_MESSAGE.paths= Fixing absolute paths.
6561: SUBST_FILES.paths= src/*.c
6562: SUBST_FILES.paths+= scripts/*.sh
6563: SUBST_SED.paths= -e 's,"/usr/local,"${PREFIX},g'
6564: SUBST_SED.paths+= -e 's,"/var/log,"${VARBASE}/log,g'
6565: SUBST_VARS.paths= LOCALBASE PREFIX PKGVERSION
6566:
6567: To get a complete picture about the SUBST substitutions, run bmake
6568: show-all-subst. If something doesn't work as expected, run pkglint on the
6569: package, which detects several typical mistakes surrounding the SUBST blocks.
6570: For any questions that might remain after this, have a look at mk/subst.mk.
6571:
1.266 martin 6572: 21.1.11.1. Choosing the time where the substitutions happen
1.180 rillig 6573:
6574: The SUBST_STAGE.* is one of {pre,do,post}-
6575: {extract,patch,configure,build,test,install}. Of these, pre-configure is used
6576: most often, by far. The most popular stages are, in chronological order:
6577:
6578: post-extract
6579:
6580: The substitutions are applied immediately after the distfiles are
6581: extracted. Running bmake extract on the package will leave no traces of the
6582: original files.
6583:
6584: When the substitution applies to files for which there is also a patch in
6585: the patches/ directory, this means that the patches will be computed based
6586: on the result of the substitution. When these patches are sent to the
6587: upstream maintainer later, to be fixed in the upstream package, these
6588: patches may no longer match what the upstream author is used to. Because of
6589: this, pre-configure is often a better choice.
6590:
6591: pre-configure
6592:
6593: The substitutions are applied after the patches from the patches/
6594: directory. This makes it possible to run bmake patch on the package, after
6595: which the patches can be edited using the tools pkgvi and mkpatches from
6596: the pkgtools/pkgdiff package.
6597:
6598: When updating the patches, it is helpful to explicitly separate the bmake
6599: patch from the bmake configure, and to only edit the patches between these
6600: commands. Otherwise the substitutions from the SUBST block will end up in
6601: the patch file. When this happens in really obvious ways, pkglint will
6602: complain about patches that contain a hard-coded /usr/pkg instead of the
6603: correct and intended @PREFIX@, but it can only detect these really obvious
6604: cases.
6605:
6606: do-configure
6607:
6608: This stage should only be used if the package defines a pre-configure
6609: action itself, and the substitution must happen after that. Typical
6610: examples are packages that use the pre-configure stage to regenerate the
6611: GNU configure script from configure.ac.
6612:
6613: post-configure
6614:
6615: This stage is used to fix up any mistakes by the configure stage.
6616:
6617: pre-build
6618:
6619: This stage should only be used for substitutions that are clearly related
6620: to building the package, not for fixing the configuration. Substitutions
6621: for pathnames (such as replacing /usr/local with ${PREFIX}) or user names
6622: (such as replacing @MY_USER@ with the actual username) belong in
6623: pre-configure or post-configure instead.
6624:
6625: post-build
6626:
6627: Just as with pre-build, this stage should only be used for substitutions
6628: that are clearly related to building the package, not for fixing the
6629: configuration. Substitutions for pathnames (such as replacing /usr/local
6630: with ${PREFIX}) or user names (such as replacing @MY_USER@ with the actual
6631: username) belong in pre-configure or post-configure instead.
6632:
6633: A typical use is to update pkg-config files to include the rpath compiler
6634: options.
6635:
6636: pre-install
6637:
6638: In general, the install phase should be as simple as possible. As with the
6639: pre-build and post-build stages, it should not be used to fix pathnames or
6640: user names, these belong in pre-configure instead. There are only few
6641: legitimate use cases for applying substitutions in this stage.
6642:
1.266 martin 6643: 21.1.11.2. Choosing the files where the substitutions happen
1.180 rillig 6644:
6645: The SUBST_FILES.* variable contains a list of filename patterns. These patterns
6646: are relative to WRKSRC since that is where most substitutions happen. A typical
6647: example is:
6648:
6649: SUBST_FILES.path= Makefile */Makefile */*/Makefile *.[ch]
6650:
6651: The above patterns, especially the last, are quite broad. The SUBST
6652: implementation checks that each filename pattern that is mentioned here has an
6653: effect. For example, if none of the */*/Makefile files contains the patterns to
6654: be found and substituted, that filename pattern is redundant and should be left
1.181 rillig 6655: out. By default, the SUBST framework will complain with an error message. If
6656: the text to be substituted occurs in some of the files from a single pattern,
6657: but not in all of them, that is totally ok, and the SUBST framework will only
6658: print an INFO message for those files.
1.180 rillig 6659:
6660: If there is a good reason for having redundant filename patterns, set
1.181 rillig 6661: SUBST_NOOP_OK.* to yes.
1.180 rillig 6662:
6663: Another popular way of choosing the files for the substitutions is via a shell
6664: command, like this:
6665:
1.181 rillig 6666: C_FILES_CMD= cd ${WRKSRC} && ${FIND} . -name '*.c'
1.180 rillig 6667: SUBST_FILES.path= ${C_FILES_CMD:sh}
6668:
6669: The variable name C_FILES_CMD in this example is freely chosen and independent
6670: of the SUBST framework.
6671:
6672: In this variant, the SUBST_FILES.* variable lists each file individually.
6673: Thereby chances are higher that there are filename patterns in which no
6674: substitution happens. Since the SUBST framework cannot know whether the
6675: filename patterns in SUBST_FILES.* have been explicitly listed in the Makefile
6676: (where any redundant filename pattern would be suspicious) or been generated by
6677: a shell command (in which redundant filename patterns are more likely and to be
6678: expected), it will complain about these redundant filename patterns. Therefore,
6679: SUBST blocks that use a shell command to generate the list of filename patterns
6680: often need to set SUBST_NOOP_OK.* to yes.
6681:
1.266 martin 6682: 21.1.11.3. Choosing what to substitute
1.180 rillig 6683:
6684: In most cases, the substitutions are given using one or more sed(1) commands,
6685: like this:
6686:
6687: SUBST_SED.path= -e 's|/usr/local|${PREFIX}|g'
6688:
6689: Each of the sed commands needs to be preceded by the -e option and should be
6690: specified on a line of its own, to avoid hiding short sed commands at the end
6691: of a line.
6692:
6693: Since the sed commands often contain shell metacharacters as the separator (the
6694: | in the above example), it is common to enclose them in single quotes.
6695:
6696: A common substitution is to replace placeholders of the form @VARNAME@ with
6697: their pkgsrc counterpart variable ${VARNAME}. A typical example is:
6698:
6699: SUBST_VARS.path= PREFIX
6700:
1.181 rillig 6701: This type of substitutions is typically done by the GNU configure scripts
6702: during the do-configure stage, but in some cases these need to be overridden.
6703: The same pattern is also used when a package defines patches that replace
6704: previously hard-coded paths like /usr/local with a @PREFIX@ placeholder first,
6705: which then gets substituted by the actual ${PREFIX} in the pre-configure stage.
6706: In many of these cases, it works equally well to just use the SUBST framework
6707: to directly replace /usr/local with ${PREFIX}, thereby omitting the
6708: intermediate patch file.
1.180 rillig 6709:
6710: If the above is not flexible enough, it is possible to not use sed at all for
6711: the substitution but to specify an entirely different command, like this:
6712:
6713: SUBST_FILTER_CMD.path= LC_ALL=C ${TR} -d '\r'
1.1 dsieger 6714:
1.180 rillig 6715: This is used for the few remaining packages in which the distributed files use
6716: Windows-style line endings that need to be converted to UNIX-style line
6717: endings.
1.1 dsieger 6718:
1.266 martin 6719: 21.1.11.4. Other SUBST variables
1.172 rillig 6720:
1.180 rillig 6721: When a SUBST block is applied during a package build, a message is logged. The
6722: default message is fine for most purposes but can be overridden by setting
6723: SUBST_MESSAGE.* to an individual message.
1.1 dsieger 6724:
1.266 martin 6725: 21.2. The fetch phase
1.1 dsieger 6726:
1.266 martin 6727: 21.2.1. Packages whose distfiles aren't available for plain downloading
1.1 dsieger 6728:
6729: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
6730: a make fetch will call files/getsite.sh with the name of each file to download
6731: as an argument, expecting it to output the URL of the directory from which to
6732: download it. graphics/ns-cult3d is an example of this usage.
6733:
6734: If the download can't be automated, because the user must submit personal
6735: information to apply for a password, or must pay for the source, or whatever,
6736: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
6737: before aborting the build. Example:
6738:
6739: FETCH_MESSAGE= "Please download the files"
6740: FETCH_MESSAGE+= " "${DISTFILES:Q}
6741: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
6742:
1.266 martin 6743: 21.2.2. How to handle modified distfiles with the 'old' name
1.1 dsieger 6744:
6745: Sometimes authors of a software package make some modifications after the
6746: software was released, and they put up a new distfile without changing the
6747: package's version number. If a package is already in pkgsrc at that time, the
6748: checksum will no longer match. The contents of the new distfile should be
6749: compared against the old one before changing anything, to make sure the
6750: distfile was really updated on purpose, and that no trojan horse or so crept
6751: in. Please mention that the distfiles were compared and what was found in your
1.54 rodent 6752: commit message.
6753:
6754: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109 wiz 6755: directory name, usually based on PKGNAME_NOREV (but take care with python or
6756: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
6757: PATCHFILES for this package will be put in that subdirectory of the local
1.266 martin 6758: distfiles directory. (See Section 21.1.10, How to handle incrementing versions
6759: when fixing an existing package for more details.) In case this happens more
1.109 wiz 6760: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
6761: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54 rodent 6762:
6763: DIST_SUBDIR is also used when a distfile's name does not contain a version and
6764: the distfile is apt to change. In cases where the likelihood of this is very
6765: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
6766: removed unless the distfile name changes, even if a package is being moved or
6767: renamed.
6768:
6769: Do not forget regenerating the distinfo file after that, since it contains the
6770: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
6771: installed package is different. Furthermore, a mail to the package's authors
6772: seems appropriate telling them that changing distfiles after releases without
6773: changing the file names is not good practice.
1.1 dsieger 6774:
1.266 martin 6775: 21.2.3. Packages hosted on github.com
1.88 tnn 6776:
1.90 tnn 6777: Helper methods exist for packages hosted on github.com which will often have
6778: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
6779: of the three recipes from below:
1.88 tnn 6780:
1.266 martin 6781: 21.2.3.1. Fetch based on a tagged release
1.88 tnn 6782:
1.189 bacon 6783: If your distfile URL looks similar to https://github.com/username/example/
6784: archive/v1.0.zip, then you are packaging a tagged release.
1.88 tnn 6785:
1.189 bacon 6786: DISTNAME= example-1.0
1.90 tnn 6787: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1.189 bacon 6788: #GITHUB_PROJECT= example # can be omitted if same as DISTNAME
1.90 tnn 6789: GITHUB_TAG= v${PKGVERSION_NOREV}
1.88 tnn 6790: EXTRACT_SUFX= .zip
6791:
1.230 gutterid 6792: Here, DISTNAME combined with use of GITHUB_TAG leads the file fetching
6793: infrastructure to save the resulting file locally as example-1.0.zip.
6794:
1.266 martin 6795: 21.2.3.2. Fetch based on a specific commit before the first release
1.189 bacon 6796:
6797: If your distfile looks similar to https://github.com/username/example/archive/
6798: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit before the first
6799: release, then set the package version to 0.0.0.N, where N is the number of
6800: commits to the repository, and set GITHUB_TAG to the commit hash. This will
6801: (almost) ensure that the first tagged release will have a version greater than
6802: this one so that package upgrades will function properly.
6803:
6804: DISTNAME= example-0.0.0.347
6805: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
6806: #GITHUB_PROJECT= example # can be omitted if same as DISTNAME
6807: GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
6808:
1.266 martin 6809: 21.2.3.3. Fetch based on a specific commit after a release
1.88 tnn 6810:
1.189 bacon 6811: If your distfile looks similar to https://github.com/username/example/archive/
6812: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit after a release,
6813: then include the last release version and the commit count since that release
6814: in the package version and set GITHUB_TAG to the commit hash. The latest
6815: release and commit count are shown in the output of "git describe --tags":
6816:
6817: # git clone https://github.com/username/example
6818: # cd example
6819: # git describe --tags
6820: 1.2.3-5-g988881a
1.88 tnn 6821:
1.189 bacon 6822: DISTNAME= example-1.2.3.5
6823: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
6824: #GITHUB_PROJECT= example # can be omitted if same as DISTNAME
1.90 tnn 6825: GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88 tnn 6826:
1.266 martin 6827: 21.2.3.4. Fetch based on release
1.88 tnn 6828:
1.189 bacon 6829: If your distfile URL looks similar to https://github.com/username/example/
6830: releases/download/rel-1.6/offensive-1.6.zip, then you are packaging a release.
1.88 tnn 6831:
1.90 tnn 6832: DISTNAME= offensive-1.6
1.88 tnn 6833: PKGNAME= ${DISTNAME:S/offensive/proper/}
1.90 tnn 6834: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1.189 bacon 6835: GITHUB_PROJECT= example
1.90 tnn 6836: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
6837: EXTRACT_SUFX= .zip
1.88 tnn 6838:
1.266 martin 6839: 21.3. The configure phase
1.1 dsieger 6840:
1.266 martin 6841: 21.3.1. Shared libraries - libtool
1.1 dsieger 6842:
6843: pkgsrc supports many different machines, with different object formats like
6844: a.out and ELF, and varying abilities to do shared library and dynamic loading
6845: at all. To accompany this, varying commands and options have to be passed to
6846: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
6847: especially if you don't have all the machines at your hand to test things. The
1.266 martin 6848: devel/libtool pkg can help here, as it just knows how to build both static
1.1 dsieger 6849: and dynamic libraries from a set of source files, thus being
6850: platform-independent.
6851:
6852: Here's how to use libtool in a package in seven simple steps:
6853:
6854: 1. Add USE_LIBTOOL=yes to the package Makefile.
6855:
1.266 martin 6856: 2. For library objects, use ${LIBTOOL} --mode=compile ${CC} in place of $
6857: {CC} . You could even add it to the definition of CC, if only libraries are
1.1 dsieger 6858: being built in a given Makefile. This one command will build both PIC and
6859: non-PIC library objects, so you need not have separate shared and
6860: non-shared library rules.
6861:
1.266 martin 6862: 3. For the linking of the library, remove any ar , ranlib , and ld
6863: -Bshareable commands, and instead use:
1.1 dsieger 6864:
6865: ${LIBTOOL} --mode=link \
6866: ${CC} -o ${.TARGET:.a=.la} \
6867: ${OBJS:.o=.lo} \
6868: -rpath ${PREFIX}/lib \
6869: -version-info major:minor
6870:
6871: Note that the library is changed to have a .la extension, and the objects
6872: are changed to have a .lo extension. Change OBJS as necessary. This
6873: automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
1.266 martin 6874: necessary) in the build directory. Be sure to include -version-info ,
1.1 dsieger 6875: especially when major and minor are zero, as libtool will otherwise strip
6876: off the shared library version.
6877:
6878: From the libtool manual:
6879:
6880: So, libtool library versions are described by three integers:
6881:
6882: CURRENT
6883: The most recent interface number that this library implements.
6884:
6885: REVISION
6886: The implementation number of the CURRENT interface.
6887:
6888: AGE
6889: The difference between the newest and oldest interfaces that
6890: this library implements. In other words, the library implements
6891: all the interface numbers in the range from number `CURRENT -
6892: AGE' to `CURRENT'.
6893:
6894: If two libraries have identical CURRENT and AGE numbers, then the
6895: dynamic linker chooses the library with the greater REVISION number.
6896:
1.266 martin 6897: The -release option will produce different results for a.out and ELF
6898: (excluding symlinks) in only one case. An ELF library of the form
6899: libfoo-release.so.x.y will have a symlink of libfoo.so.x.y on an a.out
1.1 dsieger 6900: platform. This is handled automatically.
6901:
1.266 martin 6902: The -rpath argument is the install directory of the library being built.
1.1 dsieger 6903:
6904: In the PLIST, include only the .la file, the other files will be added
6905: automatically.
6906:
6907: 4. When linking shared object (.so) files, i.e. files that are loaded via
1.266 martin 6908: dlopen(3), NOT shared libraries, use -module -avoid-version to prevent
1.1 dsieger 6909: them getting version tacked on.
6910:
6911: The PLIST file gets the foo.so entry.
6912:
6913: 5. When linking programs that depend on these libraries before they are
1.266 martin 6914: installed, preface the cc(1) or ld(1) line with ${LIBTOOL} --mode=link ,
1.1 dsieger 6915: and it will find the correct libraries (static or shared), but please be
6916: aware that libtool will not allow you to specify a relative path in -L
1.266 martin 6917: (such as -L../somelib ), because it expects you to change that argument to
1.1 dsieger 6918: be the .la file. e.g.
6919:
6920: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
6921:
6922: should be changed to:
6923:
6924: ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
6925:
6926: and it will do the right thing with the libraries.
6927:
1.266 martin 6928: 6. When installing libraries, preface the install(1) or cp(1) command with $
6929: {LIBTOOL} --mode=install , and change the library name to .la. e.g.
1.1 dsieger 6930:
1.23 jakllsch 6931: ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1 dsieger 6932:
6933: This will install the static .a, shared library, any needed symlinks, and
6934: run ldconfig(8).
6935:
6936: 7. In your PLIST, include only the .la file (this is a change from previous
6937: behaviour).
6938:
1.266 martin 6939: 21.3.2. Using libtool on GNU packages that already support libtool
1.1 dsieger 6940:
6941: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
6942: own libtool in most cases. For older libtool using packages, libtool is made by
6943: ltconfig script during the do-configure step; you can check the libtool script
6944: location by doing make configure; find work*/ -name libtool.
6945:
6946: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
1.266 martin 6947: override. By default, it is set to libtool */libtool */*/libtool . If this
1.1 dsieger 6948: does not match the location of the package's libtool script(s), set it as
6949: appropriate.
6950:
6951: If you do not need *.a static libraries built and installed, then use
6952: SHLIBTOOL_OVERRIDE instead.
6953:
6954: If your package makes use of the platform-independent library for loading
6955: dynamic shared objects, that comes with libtool (libltdl), you should include
6956: devel/libltdl/buildlink3.mk.
6957:
6958: Some packages use libtool incorrectly so that the package may not work or build
6959: in some circumstances. Some of the more common errors are:
6960:
6961: * The inclusion of a shared object (-module) as a dependent library in an
6962: executable or library. This in itself isn't a problem if one of two things
6963: has been done:
6964:
6965: 1. The shared object is named correctly, i.e. libfoo.la, not foo.la
6966:
6967: 2. The -dlopen option is used when linking an executable.
6968:
6969: * The use of libltdl without the correct calls to initialisation routines.
6970: The function lt_dlinit() should be called and the macro
6971: LTDL_SET_PRELOADED_SYMBOLS included in executables.
6972:
1.266 martin 6973: 21.3.3. GNU Autoconf/Automake
1.1 dsieger 6974:
6975: If a package needs GNU autoconf or automake to be executed to regenerate the
1.223 nia 6976: configure script and Makefile.in makefile templates from configure.ac and
6977: Makefile.am, then they should be executed in a pre-configure target:
1.1 dsieger 6978:
1.223 nia 6979: USE_TOOLS+= autoconf automake autoreconf
6980: GNU_CONFIGURE= yes
1.1 dsieger 6981: ...
6982:
6983: pre-configure:
1.223 nia 6984: set -e; cd ${WRKSRC} && autoreconf -fi
1.1 dsieger 6985: ...
6986:
1.223 nia 6987: Packages which use GNU Automake will sometimes require GNU Make (gmake in
6988: USE_TOOLS), but not always. Note that autoreconf only needs to be executed if
6989: configure.ac or Makefiles are modified, or configure is not present.
1.1 dsieger 6990:
6991: There are times when the configure process makes additional changes to the
6992: generated files, which then causes the build process to try to re-execute the
6993: automake sequence. This is prevented by touching various files in the configure
6994: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
6995: NO in the package Makefile.
6996:
1.266 martin 6997: 21.3.4. Meson / ninja
1.223 nia 6998:
6999: Packages using Meson to configure need to include:
7000:
7001: .include "../../devel/meson/build.mk"
7002:
7003: In nearly all cases (any program with dependencies), pkg-config needs to be
7004: added to USE_TOOLS. If the package installs translation files for non-English
7005: languages, also add msgfmt and xgettext:
7006:
7007: USE_TOOLS+= pkg-config msgfmt xgettext
7008:
7009: If any options need to be passed to Meson, use MESON_ARGS instead of
7010: CONFIGURE_ARGS:
7011:
7012: MESON_ARGS+= -Dx11=false
7013:
1.266 martin 7014: 21.3.5. Determining the endianness
1.260 wiz 7015:
7016: To determine the endianness of the target platform, have a look at mk/
7017: endian.mk.
7018:
1.266 martin 7019: 21.4. Programming languages
1.1 dsieger 7020:
1.266 martin 7021: 21.4.1. C, C++, and Fortran
1.1 dsieger 7022:
1.244 gutterid 7023: Compilers for the C and C++ languages come with the NetBSD base system. By
1.223 nia 7024: default, pkgsrc assumes that a package is written in C and will hide all other
1.266 martin 7025: compilers (via the wrapper framework, see Chapter 18, Buildlink methodology).
1.1 dsieger 7026:
1.243 gutterid 7027: To declare which languages should be made available through pkgsrc's compiler
7028: wrappers, use the USE_LANGUAGES variable. Allowed values currently are:
1.212 wiz 7029:
1.244 gutterid 7030: c, c++, fortran, fortran77, java, objc, obj-c++, and ada.
1.212 wiz 7031:
1.266 martin 7032: (and any combination). The default is c . Packages using GNU configure
1.212 wiz 7033: scripts, even if written in C++, usually need a C compiler for the configure
1.244 gutterid 7034: phase.
1.243 gutterid 7035:
1.250 jnemeth 7036: To declare which features a package requires from the compiler, set either
1.243 gutterid 7037: USE_CC_FEATURES or USE_CXX_FEATURES. Allowed values for USE_CC_FEATURES are
7038: currently:
7039:
7040: c11, c99, has_include
7041:
7042: Allowed values for USE_CXX_FEATURES are currently:
7043:
7044: c++11, c++14, c++17, c++20, has_include, regex, filesystem,
7045: charconv, parallelism_ts, unique_ptr, put_time,
7046: is_trivially_copy_constructible
1.1 dsieger 7047:
1.251 gutterid 7048: Note at present these variables only affect use of GCC, not other compilers.
7049:
1.244 gutterid 7050: Language variants like gnu99 and c++11 can be specified in FORCE_C_STD and
7051: FORCE_CXX_STD if the package does not explicitly set -std=... when compiling
7052: (i.e. the package assumes the compiler defaults to C++11 or some other
7053: standard). This is a common bug in upstream build systems.
7054:
7055: Allowed values for FORCE_C_STD are currently:
7056:
7057: c90, c99, c11, gnu90, gnu99, gnu11
7058:
7059: Allowed values for FORCE_CXX_STD are currently:
7060:
7061: c++03, c++11, c++14, c++17, c++20,
7062: gnu++03, gnu++11, gnu++14, gnu++17, gnu++20
7063:
1.251 gutterid 7064: Note at present these variables only affect use of GCC and Clang.
7065:
1.266 martin 7066: 21.4.2. Java
1.1 dsieger 7067:
7068: If a program is written in Java, use the Java framework in pkgsrc. The package
7069: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
7070: variables:
7071:
7072: * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
1.266 martin 7073: set to run , then there is only a runtime dependency on the JDK. The
7074: default is yes , which also adds a build dependency on the JDK.
1.1 dsieger 7075:
7076: * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
1.266 martin 7077: supported values are yes , 1.4 , and 1.5 . yes accepts any Java2
7078: implementation, 1.4 insists on versions 1.4 or above, and 1.5 only
1.1 dsieger 7079: accepts versions 1.5 or above. This variable is not set by default.
7080:
1.25 wiz 7081: * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
7082: implementation dependency. It may be used to set JAVA_HOME to a good value
7083: if the program needs this variable to be defined.
7084:
1.266 martin 7085: 21.4.3. Go
1.205 wiz 7086:
7087: If a program is written in Go and has any dependencies on other Go modules,
7088: have the package include ../../lang/go/go-module.mk.
7089:
7090: 1. Generate a list of those dependencies with make clean && make patch && make
7091: show-go-modules > go-modules.mk.
7092:
1.223 nia 7093: 2. Prepend .include "go-modules.mk" to any other .includes.
7094:
7095: 3. Incorporate these modules in distinfo with make makesum.
1.205 wiz 7096:
1.266 martin 7097: 21.4.4. Rust
1.205 wiz 7098:
1.223 nia 7099: If a program is written in Rust and uses Cargo to build, have the package
7100: include ../../lang/rust/cargo.mk.
1.205 wiz 7101:
1.275 wiz 7102: 1. It will usually depend on a lot of other code (distributed in so-called
7103: crates). Generate a list of those dependencies with make extract && make
7104: print-cargo-depends > cargo-depends.mk.
1.205 wiz 7105:
1.223 nia 7106: 2. Prepend .include "cargo-depends.mk" to any other .includes.
1.205 wiz 7107:
7108: 3. Incorporate these modules in distinfo with make makesum.
7109:
1.266 martin 7110: 21.4.5. Packages containing Perl scripts
1.1 dsieger 7111:
1.266 martin 7112: If your package contains interpreted Perl scripts, add perl to the USE_TOOLS
1.1 dsieger 7113: variable and set REPLACE_PERL to ensure that the proper interpreter path is
7114: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74 wiz 7115: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
1.210 gutterid 7116: replaced with the full path to the Perl executable.
1.1 dsieger 7117:
1.210 gutterid 7118: If a particular version of Perl is needed, set the PERL5_REQD variable to the
1.266 martin 7119: version number. The default is 5.0 .
1.1 dsieger 7120:
1.266 martin 7121: See Section 21.6.6, Packages installing Perl modules for information about
1.210 gutterid 7122: handling Perl modules.
7123:
7124: There is also the REPLACE_PERL6 variable for the language now known as Raku.
1.1 dsieger 7125:
1.266 martin 7126: 21.4.6. Packages containing shell scripts
1.41 wiz 7127:
7128: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
1.225 gutterid 7129: shell she-bangs in files. Please use the appropriate one, preferring REPLACE_SH
7130: when this shell is sufficient. Each should contain a list of scripts, relative
7131: to WRKSRC, that you want adjusted. Every occurrence of the matching shell in a
7132: she-bang line will be replaced with the full path to the shell executable. When
7133: using REPLACE_BASH, don't forget to add bash to USE_TOOLS.
1.41 wiz 7134:
1.266 martin 7135: 21.4.7. Other programming languages
1.1 dsieger 7136:
1.210 gutterid 7137: There are further similar REPLACE variables available, e.g., REPLACE_AWK for
7138: packages containing awk scripts, and REPLACE_R for R. These two, like the
1.211 gutterid 7139: others noted above, have their actions defined centrally in mk/configure/
7140: replace-interpreter.mk. Other languages define the actions of these variables
7141: within their own dedicated part of the tree, e.g., REPLACE_PHP is actioned in
1.245 gutterid 7142: lang/php/replace.mk, and REPLACE_PYTHON is actioned in lang/python/
1.211 gutterid 7143: application.mk. For other languages, consult the mk files found within their
1.216 gutterid 7144: specific directories (the naming convention varies), or check the list found in
1.266 martin 7145: Appendix E, Help topics.
1.210 gutterid 7146:
7147: Currently, special handling for other languages varies in pkgsrc. If a compiler
7148: package provides a buildlink3.mk file, include that, otherwise just add a
7149: (build) dependency on the appropriate compiler package.
1.1 dsieger 7150:
1.266 martin 7151: 21.5. The build phase
1.1 dsieger 7152:
7153: The most common failures when building a package are that some platforms do not
7154: provide certain header files, functions or libraries, or they provide the
7155: functions in a library that the original package author didn't know. To work
7156: around this, you can rewrite the source code in most cases so that it does not
7157: use the missing functions or provides a replacement function.
7158:
1.266 martin 7159: 21.5.1. Compiling C and C++ code conditionally
1.1 dsieger 7160:
7161: If a package already comes with a GNU configure script, the preferred way to
7162: fix the build failure is to change the configure script, not the code. In the
7163: other cases, you can utilize the C preprocessor, which defines certain macros
7164: depending on the operating system and hardware architecture it compiles for.
7165: These macros can be queried using for example #if defined(__i386). Almost every
7166: operating system, hardware architecture and compiler has its own macro. For
7167: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
7168: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
7169: GCC.
7170:
7171: The list of the following macros for hardware and operating system depends on
7172: the compiler that is used. For example, if you want to conditionally compile
7173: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
7174: Use __sun instead.
7175:
1.266 martin 7176: 21.5.1.1. C preprocessor macros to identify the operating system
1.1 dsieger 7177:
1.223 nia 7178: To distinguish between specific NetBSD versions, you should use the following
7179: code.
7180:
7181: #ifdef __NetBSD__
7182: #include <sys/param.h>
7183: #if __NetBSD_Prereq__(9,99,17)
7184: /* use a newer feature */
7185: #else
7186: /* older code */
7187: #endif
7188: #endif
7189:
7190: #ifndef _WIN32
7191: /* Unix-like specific code */
7192: #endif
7193:
1.1 dsieger 7194: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
7195: should use the following code.
7196:
7197: #include <sys/param.h>
7198: #if (defined(BSD) && BSD >= 199306)
7199: /* BSD-specific code goes here */
7200: #else
7201: /* non-BSD-specific code goes here */
7202: #endif
7203:
1.223 nia 7204: You can also test for the following macros:
1.1 dsieger 7205:
1.46 obache 7206: Cygwin __CYGWIN__
7207: DragonFly __DragonFly__
1.1 dsieger 7208: FreeBSD __FreeBSD__
1.46 obache 7209: Haiku __HAIKU__
1.1 dsieger 7210: IRIX __sgi (TODO: get a definite source for this)
1.223 nia 7211: Linux __linux
1.83 dholland 7212: Mac OS X __APPLE__
1.46 obache 7213: Minix3 __minix
1.1 dsieger 7214: NetBSD __NetBSD__
7215: OpenBSD __OpenBSD__
7216: Solaris sun, __sun
7217:
1.266 martin 7218: 21.5.1.2. C preprocessor macros to identify the hardware architecture
1.1 dsieger 7219:
7220: i386 i386, __i386, __i386__
1.223 nia 7221: x86-64 __amd64__, __x86_64__
7222: ARM __arm__
1.1 dsieger 7223: MIPS __mips
7224: SPARC sparc, __sparc
1.223 nia 7225: PowerPC __powerpc
1.1 dsieger 7226:
1.266 martin 7227: 21.5.1.3. C preprocessor macros to identify the compiler
1.1 dsieger 7228:
7229: GCC __GNUC__ (major version), __GNUC_MINOR__
7230: MIPSpro _COMPILER_VERSION (0x741 for MIPSpro 7.41)
7231: SunPro __SUNPRO_C (0x570 for Sun C 5.7)
7232: SunPro C++ __SUNPRO_CC (0x580 for Sun C++ 5.8)
7233:
1.266 martin 7234: 21.5.2. How to handle compiler bugs
1.1 dsieger 7235:
7236: Some source files trigger bugs in the compiler, based on combinations of
7237: compiler version and architecture and almost always relation to optimisation
7238: being enabled. Common symptoms are gcc internal errors or never finishing
7239: compiling a file.
7240:
7241: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87 tnn 7242: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
7243:
7244: This used to be a big problem in the past, but is rarely needed now as compiler
7245: technology has matured. If you still need to add a compiler specific
7246: workaround, please do so in the file hacks.mk and describe the symptom and
7247: compiler version as detailed as possible.
1.1 dsieger 7248:
1.266 martin 7249: 21.5.3. No such file or directory
1.172 rillig 7250:
7251: Compilation sometimes fails with an error message like this:
7252:
7253: .../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
7254: fatal error: pango/pango.h: No such file or directory
7255:
7256: The proper way to fix this problem depends on the type of the header, which is
7257: described in the following sections.
7258:
1.266 martin 7259: 21.5.3.1. Headers from other packages
1.172 rillig 7260:
7261: If the header name looks like it comes from a different package, that other
7262: package should be included via the buildlink3 framework.
7263:
7264: First, look whether the header is somewhere in the buildlink3 directory below
7265: WRKDIR. In the above case of the missing Pango header:
7266:
7267: $ find work/.buildlink/ -print | grep -F pango/pango.h
7268:
7269: In the case of Pango, the output is:
7270:
7271: work/.buildlink/include/pango-1.0/pango/pango.h
7272:
7273: If the pango/pango.h file were placed directly in the .buildlink directory, it
7274: would have been found automatically. There is an extra pango-1.0 path component
7275: though, which means that the compiler command line must contain an option of
7276: the form -I${BUILDLINK3_PREFIX.pango}/include/pango-1.0. In most cases this
7277: option is generated by the configure script, which can be examined using:
7278:
7279: $ $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
7280: -I/usr/pkg/include/pango-1.0
7281: -I/usr/pkg/include/pango-1.0
7282: -I/usr/pkg/include/pango-1.0
7283: -I/usr/pkg/include/pango-1.0
7284: -I/usr/pkg/include/pango-1.0
7285:
7286: This looks good. These options are transformed by the buildlink wrapper to
7287: refer to the correct path inside work/.buildlink.
7288:
7289: Since the compilation fails though, examine the compiler command lines in work
7290: /.work.log to see whether the -I option is included in the particular command
7291: line.
7292:
7293: To further analyze the situation, run bmake build-env, which sets up an
7294: interactive, realistic environment including all the pkgsrc wrapper commands
7295: and environment variables. From there, try to compile some simple example
7296: programs that use the header.
7297:
1.266 martin 7298: 21.5.3.2. Headers generated during the build
1.172 rillig 7299:
7300: If the name of the header seems to come from the package itself, and if the
7301: build is run with parallel jobs, the package may have some undeclared
7302: dependencies between the .c and the .h files, and a C file is compiled before
7303: its required header is generated.
7304:
7305: To see whether the build runs with parallel jobs, run bmake show-all-build |
7306: grep JOBS. Its output looks like this:
7307:
7308: usr MAKE_JOBS= 7
7309: pkg MAKE_JOBS_SAFE # undefined
7310: def _MAKE_JOBS_N= 7
7311:
7312: In this case the pkgsrc user has asked pkgsrc to build packages with 7 jobs in
7313: parallel (MAKE_JOBS). The package could have disabled parallel builds by
7314: setting MAKE_JOBS_SAFE to no, but in this case it hasn't.
7315:
7316: To see whether the build failure is caused by parallel builds, first save the
7317: exact error message and a bit of context, maybe you need it later for reporting
7318: a bug. Next, run:
7319:
7320: MAKE_JOBS_SAFE=no bmake clean build
7321:
7322: If that succeeds, file a bug report against the pkgsrc package, including the
7323: exact error message and the contents of your mk.conf file.
7324:
1.266 martin 7325: 21.5.3.3. Symlinks
1.173 rillig 7326:
7327: Pkgsrc does not work reliably if any of LOCALBASE, VARBASE or WRKDIR contains a
7328: symlink. Since 2019Q2, the pkgsrc bootstrap program prevents installing pkgsrc
7329: in symlink-based directories. Existing pkgsrc installations are not checked for
7330: symlinks though.
7331:
7332: The "No such file or directory" error messages are a typical symptom of
7333: symlinks, and it's quite difficult to find out that this is the actual cause.
7334:
1.266 martin 7335: 21.5.3.4. Stale working directories
1.173 rillig 7336:
7337: When building a hierarchy of packages, it may happen that one package is built
7338: and then pkgsrc is updated. This situation can provoke various hard to diagnose
7339: build errors. To clean up the situation:
7340:
1.223 nia 7341: $ (cd ../../ && cat mk/bsd.pkg.mk >/dev/null && rm -rf */*/work)
1.173 rillig 7342:
1.223 nia 7343: (The only purpose of the bsd.pkg.mk is to prevent running this command in the
7344: wrong directory.)
1.173 rillig 7345:
7346: If you have set WRKOBJDIR in mk.conf, remove that directory as well.
7347:
1.266 martin 7348: 21.5.3.5. Other possible reasons
1.173 rillig 7349:
7350: On platforms other than BSD, third-party packages are installed in /usr/
7351: include, together with the base system. This means that pkgsrc cannot
7352: distinguish between headers provided by the base system (which it needs) and
7353: headers from third-party packages (which are often included in pkgsrc as well).
7354: This can lead to subtle version mismatches.
7355:
7356: In pkgsrc installations that have been active for several years, it may happen
7357: that some files are manually deleted. To exclude this unlikely reason, run
7358: pkg_admin check.
7359:
7360: It may help to run pkg_admin rebuild-tree to check/fix dependencies.
7361:
1.266 martin 7362: If all of the above doesn't help, see Chapter 2, Getting help for contact
1.173 rillig 7363: information. Be prepared to describe what you have tried so far and what any
7364: error messages were.
7365:
1.266 martin 7366: 21.5.4. Undefined reference to ...
1.1 dsieger 7367:
7368: This error message often means that a package did not link to a shared library
7369: it needs. The following functions are known to cause this error message over
7370: and over.
7371:
7372: +-----------------------------------------------------+
7373: | Function |Library |Affected platforms|
7374: |-------------------------+--------+------------------|
7375: |accept, bind, connect |-lsocket|Solaris |
7376: |-------------------------+--------+------------------|
7377: |crypt |-lcrypt |DragonFly, NetBSD |
7378: |-------------------------+--------+------------------|
7379: |dlopen, dlsym |-ldl |Linux |
7380: |-------------------------+--------+------------------|
7381: |gethost* |-lnsl |Solaris |
7382: |-------------------------+--------+------------------|
7383: |inet_aton |-lresolv|Solaris |
7384: |-------------------------+--------+------------------|
7385: |nanosleep, sem_*, timer_*|-lrt |Solaris |
7386: |-------------------------+--------+------------------|
7387: |openpty |-lutil |Linux |
7388: +-----------------------------------------------------+
7389:
1.223 nia 7390: To fix these linker errors, it is often sufficient to add LIBS.OperatingSystem+
7391: = -lfoo to the package Makefile and then run bmake clean; bmake.
1.1 dsieger 7392:
1.266 martin 7393: 21.5.4.1. The SunPro compiler and inline functions
1.1 dsieger 7394:
7395: When you are using the SunPro compiler, there is another possibility. That
7396: compiler cannot handle the following code:
7397:
7398: extern int extern_func(int);
7399:
7400: static inline int
7401: inline_func(int x)
7402: {
7403: return extern_func(x);
7404: }
7405:
7406: int main(void)
7407: {
7408: return 0;
7409: }
7410:
7411: It generates the code for inline_func even if that function is never used. This
7412: code then refers to extern_func, which can usually not be resolved. To solve
7413: this problem you can try to tell the package to disable inlining of functions.
7414:
1.266 martin 7415: 21.5.4.2. Missing atomic functions
1.228 gutterid 7416:
7417: When building for older machine architectures (e.g., i386, PowerPC), builds may
7418: fail because the package expects modern 64-bit atomic functions which the
7419: underlying hardware either doesn't support, or will only support with specific
7420: compiler flags. This is generally handled via inclusion of mk/atomic64.mk.
7421:
1.266 martin 7422: 21.5.5. Running out of memory
1.1 dsieger 7423:
7424: Sometimes packages fail to build because the compiler runs into an operating
7425: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.266 martin 7426: told to unlimit the resources. The allowed values are any combination of
7427: cputime , datasize , memorysize , stacksize and virtualsize . Setting this
1.223 nia 7428: variable is similar to running the shell builtin ulimit command to raise the
7429: maximum data segment size or maximum stack size of a process, respectively, to
7430: their hard limits.
1.1 dsieger 7431:
1.266 martin 7432: 21.6. The install phase
1.1 dsieger 7433:
1.266 martin 7434: 21.6.1. Creating needed directories
1.1 dsieger 7435:
7436: The BSD-compatible install supplied with some operating systems cannot create
7437: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
7438: like this:
7439:
7440: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
7441: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
7442:
1.266 martin 7443: Instead of running the install commands directly, you can also append dir1
7444: dir2 to the INSTALLATION_DIRS variable, which will automatically do the right
1.223 nia 7445: thing.
1.1 dsieger 7446:
1.266 martin 7447: 21.6.2. Where to install documentation
1.1 dsieger 7448:
7449: In general, documentation should be installed into ${PREFIX}/share/doc/$
1.223 nia 7450: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME_NOREV} (the latter includes the
7451: version number of the package).
1.1 dsieger 7452:
7453: Many modern packages using GNU autoconf allow to set the directory where HTML
1.266 martin 7454: documentation is installed with the --with-html-dir option. Sometimes using
1.1 dsieger 7455: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
1.223 nia 7456: share/doc/html or other places. In pkgsrc, the HTML documentation should go
7457: into the package-specific directory, just like any other documentation.
1.1 dsieger 7458:
7459: An exception to the above is that library API documentation generated with the
7460: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
7461: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
7462: can be recognized from files ending in .devhelp or .devhelp2. (It is also
7463: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
7464: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
7465: then, no additional subdirectory level is allowed in this case. This is usually
1.266 martin 7466: achieved by using --with-html-dir=${PREFIX}/share/doc . ${PREFIX}/share/
1.1 dsieger 7467: gtk-doc is preferred though.)
7468:
1.266 martin 7469: 21.6.3. Installing highscore files
1.1 dsieger 7470:
7471: Certain packages, most of them in the games category, install a score file that
7472: allows all users on the system to record their highscores. In order for this to
7473: work, the binaries need to be installed setgid and the score files owned by the
1.36 wiz 7474: appropriate group and/or owner (traditionally the "games" user/group). Set
7475: USE_GAMESGROUP to yes to support this. The following variables, documented in
7476: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100 leot 7477: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
7478: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
7479:
7480: An example that illustrates some of the variables described above is games/
7481: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
7482: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
7483: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
7484: to install setgid the game binary:
7485:
7486: USE_GAMESGROUP= yes
7487:
7488: BUILD_DEFS+= VARBASE
7489:
7490: OWN_DIRS_PERMS+= ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
7491: REQD_FILES_PERMS+= /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
7492: SPECIAL_PERMS+= ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
7493:
7494: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
7495: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
7496: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1 dsieger 7497:
1.14 jmcneill 7498: A package should therefore never hard code file ownership or access permissions
1.100 leot 7499: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
7500: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1 dsieger 7501:
1.266 martin 7502: 21.6.4. Adding DESTDIR support to packages
1.4 rillig 7503:
1.14 jmcneill 7504: DESTDIR support means that a package installs into a staging directory, not the
7505: final location of the files. Then a binary package is created which can be used
7506: for installation as usual. There are two ways: Either the package must install
1.266 martin 7507: as root ( destdir ) or the package can install as non-root user ( user-destdir
1.25 wiz 7508: ).
1.14 jmcneill 7509:
1.266 martin 7510: * PKG_DESTDIR_SUPPORT has to be set to destdir or user-destdir . By
7511: default PKG_DESTDIR_SUPPORT is set to user-destdir to help catching more
1.113 leot 7512: potential packaging problems. If bsd.prefs.mk is included in the Makefile,
7513: PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14 jmcneill 7514:
1.4 rillig 7515: * All installation operations have to be prefixed with ${DESTDIR}.
7516:
7517: * automake gets this DESTDIR mostly right automatically. Many manual rules
7518: and pre/post-install often are incorrect; fix them.
7519:
1.17 imil 7520: * If files are installed with special owner/group use SPECIAL_PERMS.
1.4 rillig 7521:
7522: * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
7523:
1.266 martin 7524: 21.6.5. Packages with hardcoded paths to other interpreters
1.1 dsieger 7525:
7526: Your package may also contain scripts with hardcoded paths to other
1.203 nia 7527: interpreters besides (or as well as) Perl. To correct the full pathname to the
1.1 dsieger 7528: script interpreter, you need to set the following definitions in your Makefile
7529: (we shall use tclsh in this example):
7530:
7531: REPLACE_INTERPRETER+= tcl
7532: REPLACE.tcl.old= .*/bin/tclsh
7533: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
7534: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
7535: # relative to ${WRKSRC}, just as in REPLACE_PERL
7536:
1.266 martin 7537: 21.6.6. Packages installing Perl modules
1.1 dsieger 7538:
7539: Makefiles of packages providing perl5 modules should include the Makefile
7540: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
7541: standard perl configuration for such modules as well as various hooks to tune
7542: this configuration. See comments in this file for details.
7543:
7544: Perl5 modules will install into different places depending on the version of
7545: perl used during the build process. To address this, pkgsrc will append lines
7546: to the PLIST corresponding to the files listed in the installed .packlist file
7547: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48 wiz 7548: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
7549: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1 dsieger 7550:
1.48 wiz 7551: PERL5_PACKLIST= auto/Pg/.packlist
1.1 dsieger 7552:
1.48 wiz 7553: The perl5 config variables installarchlib, installscript, installvendorbin,
7554: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
7555: and installvendorman3dir represent those locations in which components of perl5
7556: modules may be installed, provided as variable with uppercase and prefixed with
7557: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
7558: have a packlist. These variables are also substituted for in the PLIST as
7559: uppercase prefixed with PERL5_SUB_.
1.1 dsieger 7560:
1.266 martin 7561: 21.6.7. Packages installing pkg-config files
1.254 wiz 7562:
7563: Some packages, usually those providing libraries, install pkg-config files so
7564: that their headers and libraries can easily be found. The file names end with
7565: .pc.
7566:
7567: Most of the time, these files only provide the linker flags for the library,
7568: but do not include the flags for setting the rpath so the libraries can also be
7569: found at runtime. Since this is so common, pkgsrc provides PKGCONFIG_OVERRIDE
7570: for this. Many packages generate the .pc from .pc.in, in that case add those
7571: files to the PKGCONFIG_OVERRIDE variable:
7572:
7573: PKGCONFIG_OVERRIDE+= foo.pc.in
7574:
7575:
7576: For packages using meson, the files are generated during build and you also
7577: need to change the phase in which the replacement is done. For example:
7578:
7579: PKGCONFIG_OVERRIDE+= output/meson-private/foo.pc
7580: PKGCONFIG_OVERRIDE_STAGE= post-build
7581:
7582:
1.266 martin 7583: 21.6.8. Packages installing info files
1.1 dsieger 7584:
1.266 martin 7585: Some packages install info files or use the makeinfo or install-info
1.1 dsieger 7586: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
7587: and DEINSTALL scripts will be generated to handle registration of the info
1.266 martin 7588: files in the Info directory file. The install-info command used for the info
1.1 dsieger 7589: files registration is either provided by the system, or by a special purpose
7590: package automatically added as dependency if needed.
7591:
7592: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
1.266 martin 7593: located. PKGINFODIR defaults to info and can be overridden by the user.
1.1 dsieger 7594:
7595: The info files for the package should be listed in the package PLIST; however
7596: any split info files need not be listed.
7597:
1.266 martin 7598: A package which needs the makeinfo command at build time must add makeinfo
7599: to USE_TOOLS in its Makefile. If a minimum version of the makeinfo command is
1.1 dsieger 7600: needed it should be noted with the TEXINFO_REQD variable in the package
7601: Makefile. By default, a minimum version of 3.12 is required. If the system does
7602: not provide a makeinfo command or if it does not match the required minimum, a
7603: build dependency on the devel/gtexinfo package will be added automatically.
7604:
7605: The build and installation process of the software provided by the package
7606: should not use the install-info command as the registration of info files is
1.25 wiz 7607: the task of the package INSTALL script, and it must use the appropriate
1.1 dsieger 7608: makeinfo command.
7609:
7610: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
7611: the install-info and makeinfo commands in a directory listed early in PATH.
7612:
7613: The script overriding install-info has no effect except the logging of a
7614: message. The script overriding makeinfo logs a message and according to the
7615: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
7616: error.
7617:
1.266 martin 7618: 21.6.9. Packages installing man pages
1.1 dsieger 7619:
7620: All packages that install manual pages should install them into the same
7621: directory, so that there is one common place to look for them. In pkgsrc, this
7622: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.266 martin 7623: packages. The default for PKGMANDIR is man . Another often-used value is
7624: share/man .
1.1 dsieger 7625:
7626: Note
7627:
7628: The support for a custom PKGMANDIR is far from complete.
7629:
7630: The PLIST files can just use man/ as the top level directory for the man page
7631: file entries, and the pkgsrc framework will convert as needed. In all other
7632: places, the correct PKGMANDIR must be used.
7633:
1.266 martin 7634: Packages that are configured with GNU_CONFIGURE set as yes , by default will
1.1 dsieger 7635: use the ./configure --mandir switch to set where the man pages should be
7636: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
7637: {PKGMANDIR}.
7638:
7639: Packages that use GNU_CONFIGURE but do not use --mandir, can set
1.266 martin 7640: CONFIGURE_HAS_MANDIR to no . Or if the ./configure script uses a non-standard
1.1 dsieger 7641: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
7642:
1.266 martin 7643: See Section 19.5, Man page compression for information on installation of
1.1 dsieger 7644: compressed manual pages.
7645:
1.266 martin 7646: 21.6.10. Packages installing X11 fonts
1.1 dsieger 7647:
7648: If a package installs font files, you will need to rebuild the fonts database
7649: in the directory where they get installed at installation and deinstallation
7650: time. This can be automatically done by using the pkginstall framework.
7651:
7652: You can list the directories where fonts are installed in the FONTS_DIRS.type
1.266 martin 7653: variables, where type can be one of ttf , type1 or x11 . Also make sure
1.1 dsieger 7654: that the database file fonts.dir is not listed in the PLIST.
7655:
7656: Note that you should not create new directories for fonts; instead use the
7657: standard ones to avoid that the user needs to manually configure his X server
7658: to find them.
7659:
1.266 martin 7660: 21.6.11. Packages installing SGML or XML data
1.1 dsieger 7661:
7662: If a package installs SGML or XML data files that need to be registered in
7663: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
7664: extra steps:
7665:
7666: 1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
7667: care of registering those files in system-wide catalogs at installation and
7668: deinstallation time.
7669:
7670: 2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
7671: package.
7672:
7673: 3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
7674: package.
7675:
7676: 4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
7677: These come in groups of three strings; see xmlcatmgr(1) for more
7678: information (specifically, arguments recognized by the 'add' action). Note
7679: that you will normally not use this variable.
7680:
7681: 5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
7682: come in groups of three strings; see xmlcatmgr(1) for more information
7683: (specifically, arguments recognized by the 'add' action). Note that you
7684: will normally not use this variable.
7685:
1.266 martin 7686: 21.6.12. Packages installing extensions to the MIME database
1.1 dsieger 7687:
7688: If a package provides extensions to the MIME database by installing .xml files
7689: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
7690: ensure that the database is kept consistent with respect to these new files:
7691:
7692: 1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
7693: buildlink3.mk file from this same directory, which is reserved for
7694: inclusion from other buildlink3.mk files). It takes care of rebuilding the
7695: MIME database at installation and deinstallation time, and disallows any
7696: access to it directly from the package.
7697:
1.25 wiz 7698: 2. Check the PLIST and remove any entries under the share/mime directory,
1.1 dsieger 7699: except for files saved under share/mime/packages. The former are handled
7700: automatically by the update-mime-database program, but the latter are
7701: package-dependent and must be removed by the package that installed them in
7702: the first place.
7703:
7704: 3. Remove any share/mime/* directories from the PLIST. They will be handled by
7705: the shared-mime-info package.
7706:
1.266 martin 7707: 21.6.13. Packages using intltool
1.1 dsieger 7708:
7709: If a package uses intltool during its build, add intltool to the USE_TOOLS,
7710: which forces it to use the intltool package provided by pkgsrc, instead of the
7711: one bundled with the distribution file.
7712:
7713: This tracks intltool's build-time dependencies and uses the latest available
7714: version; this way, the package benefits of any bug fixes that may have appeared
7715: since it was released.
7716:
1.266 martin 7717: 21.6.14. Packages installing startup scripts
1.1 dsieger 7718:
1.256 wiz 7719: If a package contains an rc.d script, it won't be copied into the startup
7720: directory (/etc/rc.d) by default, but you can enable copying by setting the
7721: option PKG_RCD_SCRIPTS=YES in mk.conf. With PKG_RCD_SCRIPTS=YES, rc.d scripts
7722: will be copied into /etc/rc.d when a package is installed, but only if the
7723: target does not already exist. Copies in /etc/rc.d will be automatically
7724: removed only if they have not been modified.
7725:
7726: Note that this alone does not enable the service: It must still be added to /
7727: etc/rc.conf.
1.1 dsieger 7728:
1.266 martin 7729: 21.6.15. Packages installing TeX modules
1.1 dsieger 7730:
7731: If a package installs TeX packages into the texmf tree, the ls-R database of
7732: the tree needs to be updated.
7733:
7734: Note
7735:
1.23 jakllsch 7736: Except the main TeX packages such as kpathsea, packages should install files
7737: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1 dsieger 7738:
1.23 jakllsch 7739: 1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
7740: ls-R database at installation and deinstallation time.
1.1 dsieger 7741:
1.23 jakllsch 7742: 2. If your package installs files into a texmf tree other than the one at $
7743: {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
7744: trees that need database update.
1.1 dsieger 7745:
7746: If your package also installs font map files that need to be registered
1.30 dholland 7747: using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
7748: and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then
7749: updmap will be run automatically at installation/deinstallation to enable/
7750: disable font map files for TeX output drivers.
1.1 dsieger 7751:
7752: 3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30 dholland 7753: be removed only by the kpathsea package.
1.1 dsieger 7754:
1.266 martin 7755: 21.6.16. Packages supporting running binaries in emulation
1.1 dsieger 7756:
7757: There are some packages that provide libraries and executables for running
7758: binaries from a one operating system on a different one (if the latter supports
7759: it). One example is running Linux binaries on NetBSD.
7760:
7761: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
7762:
7763: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
7764: if all libraries for each installed executable can be found by the dynamic
7765: linker. Since the standard dynamic linker is run, this fails for emulation
7766: packages, because the libraries used by the emulation are not in the standard
7767: directories.
7768:
1.266 martin 7769: 21.6.17. Packages installing hicolor icons
1.1 dsieger 7770:
7771: If a package installs images under the share/icons/hicolor and/or updates the
7772: share/icons/hicolor/icon-theme.cache database, you need to take some extra
7773: steps to make sure that the shared theme directory is handled appropriately and
7774: that the cache database is rebuilt:
7775:
7776: 1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
7777:
7778: 2. Check the PLIST and remove the entry that refers to the theme cache.
7779:
7780: 3. Ensure that the PLIST does not remove the shared icon directories from the
7781: share/icons/hicolor hierarchy because they will be handled automatically.
7782:
7783: The best way to verify that the PLIST is correct with respect to the last two
7784: points is to regenerate it using make print-PLIST.
7785:
1.266 martin 7786: 21.6.18. Packages installing desktop files
1.1 dsieger 7787:
7788: If a package installs .desktop files under share/applications and these include
1.54 rodent 7789: MIME information (MimeType key), you need to take extra steps to ensure that
7790: they are registered into the MIME database:
1.1 dsieger 7791:
7792: 1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
7793:
7794: 2. Check the PLIST and remove the entry that refers to the share/applications/
7795: mimeinfo.cache file. It will be handled automatically.
7796:
7797: The best way to verify that the PLIST is correct with respect to the last point
7798: is to regenerate it using make print-PLIST.
7799:
1.266 martin 7800: 21.7. Marking packages as having problems
1.1 dsieger 7801:
1.23 jakllsch 7802: In some cases one does not have the time to solve a problem immediately. In
7803: this case, one can plainly mark a package as broken. For this, one just sets
7804: the variable BROKEN to the reason why the package is broken (similar to the
1.162 rillig 7805: PKG_FAIL_REASON variable). A user trying to build the package will immediately
7806: be shown this message, and the build will not be even tried.
1.1 dsieger 7807:
1.23 jakllsch 7808: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1 dsieger 7809:
1.266 martin 7810: Chapter 22. GNOME packaging and porting
1.184 rillig 7811:
7812: Table of Contents
7813:
7814: 22.1. Meta packages
7815: 22.2. Packaging a GNOME application
7816: 22.3. Updating GNOME to a newer version
7817: 22.4. Patching guidelines
7818:
7819: Quoting GNOME's web site:
7820:
7821: The GNOME project provides two things: The GNOME desktop environment, an
7822: intuitive and attractive desktop for users, and the GNOME development
7823: platform, an extensive framework for building applications that integrate
7824: into the rest of the desktop.
7825:
7826: pkgsrc provides a seamless way to automatically build and install a complete
7827: GNOME environment under many different platforms. We can say with confidence
7828: that pkgsrc is one of the most advanced build and packaging systems for GNOME
7829: due to its included technologies buildlink3, the wrappers and tools framework
7830: and automatic configuration file management. Lots of efforts are put into
7831: achieving a completely clean deinstallation of installed software components.
7832:
7833: Given that pkgsrc is NetBSD's official packaging system, the above also means
7834: that great efforts are put into making GNOME work under this operating system.
7835:
7836: This chapter is aimed at pkgsrc developers and other people interested in
7837: helping our GNOME porting and packaging efforts. It provides instructions on
7838: how to manage the existing packages and some important information regarding
7839: their internals.
7840:
1.266 martin 7841: 22.1. Meta packages
1.184 rillig 7842:
7843: pkgsrc includes three GNOME-related meta packages:
7844:
7845: * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
7846: includes the necessary bits to get it to boot correctly, although it may
7847: lack important functionality for daily operation. The idea behind this
7848: package is to let end users build their own configurations on top of this
7849: one, first installing this meta package to achieve a functional setup and
7850: then adding individual applications.
7851:
7852: * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
7853: desktop as defined by the GNOME project; this is based on the components
7854: distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
7855: directories of the official FTP server. Developer-only tools found in those
7856: directories are not installed unless required by some other component to
7857: work properly. Similarly, packages from the bindings set (bindings/x.y/
7858: x.y.z/sources) are not pulled in unless required as a dependency for an
7859: end-user component. This package "extends" meta-pkgs/gnome-base.
7860:
7861: * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
7862: component when fetched from the CVS repository. These are required to let
7863: the autogen.sh scripts work appropriately.
7864:
7865: In all these packages, the DEPENDS lines are sorted in a way that eases
7866: updates: a package may depend on other packages listed before it but not on any
7867: listed after it. It is very important to keep this order to ease updates so...
7868: do not change it to alphabetical sorting!
7869:
1.266 martin 7870: 22.2. Packaging a GNOME application
1.184 rillig 7871:
7872: Almost all GNOME applications are written in C and use a common set of tools as
7873: their build system. Things get different with the new bindings to other
7874: languages (such as Python), but the following will give you a general idea on
7875: the minimum required tools:
7876:
7877: * Almost all GNOME applications use the GNU Autotools as their build system.
7878: As a general rule you will need to tell this to your package:
7879:
1.223 nia 7880: GNU_CONFIGURE= yes
7881: USE_LIBTOOL= yes
7882: USE_TOOLS+= gmake
1.184 rillig 7883:
7884: * If the package uses pkg-config to detect dependencies, add this tool to the
7885: list of required utilities:
7886:
1.223 nia 7887: USE_TOOLS+= pkg-config
1.184 rillig 7888:
7889: Also use pkgtools/verifypc at the end of the build process to ensure that
7890: you did not miss to specify any dependency in your package and that the
7891: version requirements are all correct.
7892:
7893: * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
7894: handle dependencies and to force the package to use the latest available
7895: version.
7896:
7897: * If the package uses gtk-doc (a documentation generation utility), do not
7898: add a dependency on it. The tool is rather big and the distfile should come
7899: with pregenerated documentation anyway; if it does not, it is a bug that
7900: you ought to report. For such packages you should disable gtk-doc (unless
7901: it is the default):
7902:
1.223 nia 7903: CONFIGURE_ARGS+= --disable-gtk-doc
1.184 rillig 7904:
7905: The default location of installed HTML files (share/gtk-doc/<package-name>)
7906: is correct and should not be changed unless the package insists on
7907: installing them somewhere else. Otherwise programs as devhelp will not be
7908: able to open them. You can do that with an entry similar to:
1.1 dsieger 7909:
1.223 nia 7910: CONFIGURE_ARGS+= --with-html-dir=${PREFIX}/share/gtk-doc/...
1.1 dsieger 7911:
1.184 rillig 7912: GNOME uses multiple shared directories and files under the installation prefix
7913: to maintain databases. In this context, shared means that those exact same
7914: directories and files are used among several different packages, leading to
7915: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
7916: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
7917: your file lists and omitting shared files from them. If you find yourself doing
7918: those, your package is most likely incorrect.
1.1 dsieger 7919:
1.184 rillig 7920: The following table lists the common situations that result in using shared
7921: directories or files. For each of them, the appropriate solution is given.
7922: After applying the solution be sure to regenerate the package's file list with
7923: make print-PLIST and ensure it is correct.
1.1 dsieger 7924:
1.266 martin 7925: Table 22.1. PLIST handling for GNOME packages
1.1 dsieger 7926:
1.184 rillig 7927: +-----------------------------------------------------------------------------+
7928: | If the package... | Then... |
7929: |-------------------------------------------+---------------------------------|
1.266 martin 7930: |Installs icons under the share/icons/ |See Section 21.6.17, Packages |
7931: |hicolor hierarchy or updates share/icons/ |installing hicolor icons . |
1.184 rillig 7932: |hicolor/icon-theme.cache. | |
7933: |-------------------------------------------+---------------------------------|
1.266 martin 7934: | |See Section 21.6.12, Packages |
1.184 rillig 7935: |Installs files under share/mime/packages. |installing extensions to the MIME|
1.266 martin 7936: | |database . |
1.184 rillig 7937: |-------------------------------------------+---------------------------------|
1.266 martin 7938: |Installs .desktop files under share/ |See Section 21.6.18, Packages |
7939: |applications and these include MIME |installing desktop files . |
1.184 rillig 7940: |information. | |
7941: +-----------------------------------------------------------------------------+
1.1 dsieger 7942:
7943:
1.266 martin 7944: 22.3. Updating GNOME to a newer version
1.1 dsieger 7945:
1.184 rillig 7946: When seeing GNOME as a whole, there are two kinds of updates:
1.1 dsieger 7947:
1.184 rillig 7948: Major update
1.1 dsieger 7949:
1.184 rillig 7950: Given that there is still a very long way for GNOME 3 (if it ever appears),
7951: we consider a major update one that goes from a 2.X version to a 2.Y one,
7952: where Y is even and greater than X. These are hard to achieve because they
7953: introduce lots of changes in the components' code and almost all GNOME
7954: distfiles are updated to newer versions. Some of them can even break API
7955: and ABI compatibility with the previous major version series. As a result,
7956: the update needs to be done all at once to minimize breakage.
1.1 dsieger 7957:
1.184 rillig 7958: A major update typically consists of around 80 package updates and the
7959: addition of some new ones.
1.1 dsieger 7960:
1.184 rillig 7961: Minor update
1.1 dsieger 7962:
1.184 rillig 7963: We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
7964: one where Y is greater than X. These are easy to achieve because they do
7965: not update all GNOME components, can be done in an incremental way and do
7966: not break API nor ABI compatibility.
1.1 dsieger 7967:
1.184 rillig 7968: A minor update typically consists of around 50 package updates, although
7969: the numbers here may vary a lot.
1.1 dsieger 7970:
1.184 rillig 7971: In order to update the GNOME components in pkgsrc to a new stable release
7972: (either major or minor), the following steps should be followed:
1.1 dsieger 7973:
1.184 rillig 7974: 1. Get a list of all the tarballs that form the new release by using the
7975: following commands. These will leave the full list of the components'
7976: distfiles into the list.txt file:
1.1 dsieger 7977:
1.184 rillig 7978: % echo ls "*.tar.bz2" | \
7979: ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
7980: awk '{ print $9 }' >list.txt
7981: % echo ls "*.tar.bz2" | \
7982: ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
7983: awk '{ print $9 }' >>list.txt
1.1 dsieger 7984:
1.184 rillig 7985: 2. Open each meta package's Makefile and bump their version to the release you
7986: are updating them to. The three meta packages should be always consistent
7987: with versioning. Obviously remove any PKGREVISIONs that might be in them.
1.1 dsieger 7988:
1.184 rillig 7989: 3. For each meta package, update all its DEPENDS lines to match the latest
7990: versions as shown by the above commands. Do not list any newer version
7991: (even if found in the FTP) because the meta packages are supposed to list
7992: the exact versions that form a specific GNOME release. Exceptions are
7993: permitted here if a newer version solves a serious issue in the overall
7994: desktop experience; these typically come in the form of a revision bump in
7995: pkgsrc, not in newer versions from the developers.
1.1 dsieger 7996:
1.184 rillig 7997: Packages not listed in the list.txt file should be updated to the latest
7998: version available (if found in pkgsrc). This is the case, for example, of
7999: the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
8000: package.
1.1 dsieger 8001:
1.184 rillig 8002: 4. Generate a patch from the modified meta packages and extract the list of
8003: "new" lines. This will provide you an outline on what packages need to be
8004: updated in pkgsrc and in what order:
1.1 dsieger 8005:
1.184 rillig 8006: % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
1.1 dsieger 8007:
1.184 rillig 8008: 5. For major desktop updates it is recommended to zap all your installed
8009: packages and start over from scratch at this point.
1.1 dsieger 8010:
1.184 rillig 8011: 6. Now comes the longest step by far: iterate over the contents of todo.txt
8012: and update the packages listed in it in order. For major desktop updates
8013: none of these should be committed until the entire set is completed because
8014: there are chances of breaking not-yet-updated packages.
1.1 dsieger 8015:
1.184 rillig 8016: 7. Once the packages are up to date and working, commit them to the tree one
8017: by one with appropriate log messages. At the end, commit the three meta
8018: package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
8019: and pkgsrc/doc/TODO files.
1.1 dsieger 8020:
1.266 martin 8021: 22.4. Patching guidelines
1.1 dsieger 8022:
1.184 rillig 8023: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
8024: it is very important that you always, always, always feed back any portability
8025: fixes you do to a GNOME package to the mainstream developers (see
1.266 martin 8026: Section 12.3.5, Feedback to the author ). This is the only way to get their
1.184 rillig 8027: attention on portability issues and to ensure that future versions can be built
8028: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
8029: updates are. Those developers in charge of issuing major GNOME updates will be
8030: grateful if you do that.
1.1 dsieger 8031:
1.200 cirnatda 8032: The most common places to report bugs are the GNOME's GitLab and the
8033: freedesktop.org's GitLab. Not all components use these to track bugs, but most
8034: of them do. Do not be short on your reports: always provide detailed
1.184 rillig 8035: explanations of the current failure, how it can be improved to achieve maximum
1.200 cirnatda 8036: portability and, if at all possible, provide a patch against the main Git
8037: branch. The more verbose you are, the higher chances of your patch being
8038: accepted.
1.1 dsieger 8039:
1.184 rillig 8040: Also, please avoid using preprocessor magic to fix portability issues. While
8041: the FreeBSD GNOME people are doing a great job in porting GNOME to their
8042: operating system, the official GNOME sources are now plagued by conditionals
8043: that check for __FreeBSD__ and similar macros. This hurts portability. Please
1.266 martin 8044: see our patching guidelines (Section 12.3.4, Patching guidelines ) for more
1.184 rillig 8045: details.
1.1 dsieger 8046:
1.266 martin 8047: Chapter 23. Submitting and Committing
1.1 dsieger 8048:
8049: Table of Contents
8050:
1.154 rillig 8051: 23.1. Submitting binary packages
8052: 23.2. Submitting source packages (for non-NetBSD-developers)
8053: 23.3. General notes when adding, updating, or removing packages
8054: 23.4. Commit Messages
8055: 23.5. Committing: Adding a package to CVS
8056: 23.6. Updating a package to a newer version
8057: 23.7. Renaming a package in pkgsrc
8058: 23.8. Moving a package in pkgsrc
1.1 dsieger 8059:
1.266 martin 8060: 23.1. Submitting binary packages
1.1 dsieger 8061:
8062: Our policy is that we accept binaries only from pkgsrc developers to guarantee
8063: that the packages don't contain any trojan horses etc. This is not to annoy
8064: anyone but rather to protect our users! You're still free to put up your
8065: home-made binary packages and tell the world where to get them. NetBSD
1.266 martin 8066: developers doing bulk builds and wanting to upload them please see Chapter 8,
1.66 asau 8067: Creating binary packages for everything in pkgsrc (bulk builds).
1.1 dsieger 8068:
1.266 martin 8069: 23.2. Submitting source packages (for non-NetBSD-developers)
1.1 dsieger 8070:
1.266 martin 8071: Firstly, you can import new packages into pkgsrc-wip ( pkgsrc work-in-progress
1.218 nia 8072: ); see the homepage at https://pkgsrc.org/wip/ for details.
8073:
8074: Next, check that your package is complete, compiles and runs well; see
1.266 martin 8075: Chapter 14, Creating a new pkgsrc package from scratch and the rest of this
1.218 nia 8076: document. Run the pkgtools/pkglint tool and fix any errors that appear.
8077:
8078: Finally, send a report to the pkgsrc bug tracking system, either with the
8079: send-pr(1) command, or if you don't have that, go to the web page https://
8080: www.NetBSD.org/support/send-pr.html, which contains some instructions and a
8081: link to a form where you can submit packages. The sysutils/gtk-send-pr package
8082: is also available as a substitute for either of the above two tools.
1.1 dsieger 8083:
1.266 martin 8084: In the form of the problem report, the category should be pkg , the synopsis
1.1 dsieger 8085: should include the package name and version number, and the description field
8086: should contain a short description of your package (contents of the COMMENT
1.218 nia 8087: variable or DESCR file are OK).
1.1 dsieger 8088:
1.266 martin 8089: 23.3. General notes when adding, updating, or removing packages
1.1 dsieger 8090:
8091: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
8092: CHANGES-YYYY. It's very important to keep this file up to date and conforming
8093: to the existing format, because it will be used by scripts to automatically
8094: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
8095: doc/TODO file and remove the entry for the package you updated or removed, in
8096: case it was mentioned there.
8097:
8098: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
8099: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
8100: that result from a dependency being updated should not be mentioned. In all
8101: other cases it's the developer's decision.
8102:
8103: There is a make target that helps in creating proper CHANGES-YYYY entries: make
8104: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
8105: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
8106: (to avoid having to resolve conflicts later-on) and then to cd to the package
8107: directory. For package updates, make changes-entry is enough. For new packages,
8108: or package moves or removals, set the CTYPE variable on the command line to
1.4 rillig 8109: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23 jakllsch 8110: your local login name is not the same as your NetBSD login name. The target
8111: also automatically removes possibly existing entries for the package in the
8112: TODO file. Don't forget to commit the changes, e.g. by using make
1.66 asau 8113: commit-changes-entry! If you are not using a checkout directly from
1.23 jakllsch 8114: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
8115: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1 dsieger 8116:
1.266 martin 8117: 23.4. Commit Messages
1.130 wiz 8118:
8119: For several years, there have been mirrors of pkgsrc in fossil, git, and hg.
1.257 jkoshy 8120: Standard practice when using these tools is to make the first line of a commit
1.130 wiz 8121: message function as a summary that can be read without the rest, such as is
8122: commonly done with "git log --oneline". For this reason, we have the following
8123: guidelines for pkgsrc commit messages:
8124:
1.131 wiz 8125: * Start the commit message with a line that explains the big picture in 65
1.130 wiz 8126: characters or less. When a commit is for one package, include the name of
8127: the package. For updates, include the version to which it is updated.
8128:
8129: * Leave the next line empty.
8130:
8131: * Then come the details for the commit (changes in that package, reason for a
8132: change) and any relevant PRs. Wrap this section.
8133:
8134: Here is an example:
8135:
1.238 wiz 8136: libxslt: update to 1.0.30
1.130 wiz 8137:
1.238 wiz 8138: Changes since 1.0.29:
8139: ...
1.130 wiz 8140:
8141: Here is another example:
8142:
1.238 wiz 8143: mk/bsd.pkg.mk: enable SSP by default on NetBSD
1.130 wiz 8144:
1.238 wiz 8145: (rationale)
1.130 wiz 8146:
1.266 martin 8147: Commit messages are final: no cvs admin is allowed on the pkgsrc repository
1.130 wiz 8148: to change commit messages.
8149:
1.266 martin 8150: 23.5. Committing: Adding a package to CVS
1.1 dsieger 8151:
8152: This section is only of interest for pkgsrc developers with write access to the
1.34 wiz 8153: pkgsrc repository.
8154:
1.266 martin 8155: When the package is finished, cvs add the files. Start by adding the
1.34 wiz 8156: directory and then files in the directory. Don't forget to add the new package
8157: to the category's Makefile. Make sure you don't forget any files; you can check
1.266 martin 8158: by running cvs status . An example:
1.34 wiz 8159:
8160: $ cd .../pkgsrc/category
8161: $ cvs add pkgname
8162: $ cd pkgname
8163: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
8164: $ cvs add patches/p*
8165: $ cvs status | less
1.35 wiz 8166: $ cvs commit
1.34 wiz 8167: $ cd ..
1.236 gutterid 8168: $ vi Makefile # add SUBDIR+=pkgname line
1.35 wiz 8169: $ cvs commit Makefile
1.66 asau 8170: $ cd pkgname
1.73 jnemeth 8171: $ make CTYPE=Added commit-changes-entry
1.1 dsieger 8172:
8173: The commit message of the initial import should include part of the DESCR file,
8174: so people reading the mailing lists know what the package is/does.
8175:
1.34 wiz 8176: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
8177:
1.266 martin 8178: Previously, cvs import was suggested, but it was much easier to get wrong
8179: than cvs add .
1.1 dsieger 8180:
1.266 martin 8181: 23.6. Updating a package to a newer version
1.1 dsieger 8182:
8183: Please always put a concise, appropriate and relevant summary of the changes
8184: between old and new versions into the commit log when updating a package. There
8185: are various reasons for this:
8186:
8187: * A URL is volatile, and can change over time. It may go away completely or
8188: its information may be overwritten by newer information.
8189:
8190: * Having the change information between old and new versions in our CVS
8191: repository is very useful for people who use either cvs or anoncvs.
8192:
8193: * Having the change information between old and new versions in our CVS
8194: repository is very useful for people who read the pkgsrc-changes mailing
8195: list, so that they can make tactical decisions about when to upgrade the
8196: package.
8197:
8198: Please also recognize that, just because a new version of a package has been
8199: released, it should not automatically be upgraded in the CVS repository. We
8200: prefer to be conservative in the packages that are included in pkgsrc -
8201: development or beta packages are not really the best thing for most places in
8202: which pkgsrc is used. Please use your judgement about what should go into
8203: pkgsrc, and bear in mind that stability is to be preferred above new and
8204: possibly untested features.
8205:
1.266 martin 8206: 23.7. Renaming a package in pkgsrc
1.21 snj 8207:
8208: Renaming packages is not recommended.
8209:
1.175 gutterid 8210: When renaming packages, be sure to fix any references to the old name in other
1.21 snj 8211: Makefiles, options, buildlink files, etc.
8212:
1.175 gutterid 8213: Also, when renaming a package, please add the package name and version pattern
1.167 leot 8214: (s) of the previous package to SUPERSEDES. This may be repeated for multiple
8215: renames. The new package would be an exact replacement. Example:
8216:
8217: SUPERSEDES+= p5-IO-Compress-Zlib<2.017
8218: SUPERSEDES+= optcomp-[0-9]*
1.21 snj 8219:
1.266 martin 8220: Note that successor in the CHANGES-YYYY file doesn't necessarily mean that it
1.21 snj 8221: supersedes, as that successor may not be an exact replacement but is a
8222: suggestion for the replaced functionality.
8223:
1.266 martin 8224: 23.8. Moving a package in pkgsrc
1.21 snj 8225:
8226: It is preferred that packages are not renamed or moved, but if needed please
8227: follow these steps.
1.1 dsieger 8228:
8229: 1. Make a copy of the directory somewhere else.
8230:
8231: 2. Remove all CVS dirs.
8232:
8233: Alternatively to the first two steps you can also do:
8234:
8235: % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
8236:
8237: and use that for further work.
8238:
1.266 martin 8239: 3. Fix CATEGORIES and any DEPENDS paths that just did ../package instead of
8240: ../../category/package .
1.1 dsieger 8241:
1.21 snj 8242: 4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
8243: previous category/package pathname. The PREV_PKGPATH can be used by tools
8244: for doing an update using pkgsrc building; for example, it can search the
8245: pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
8246: the corresponding new PKGPATH for that moved package. Note that it may have
8247: multiple matches, so the tool should also check on the PKGBASE too. The
8248: PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
8249: PKGBASE stays the same.
8250:
1.237 gutterid 8251: 5. cvs add the modified package in the new place.
1.1 dsieger 8252:
1.21 snj 8253: 6. Check if any package depends on it:
1.1 dsieger 8254:
8255: % cd /usr/pkgsrc
8256: % grep /package */*/Makefile* */*/buildlink*
8257:
1.21 snj 8258: 7. Fix paths in packages from step 5 to point to new location.
1.1 dsieger 8259:
1.21 snj 8260: 8. cvs rm (-f) the package at the old location.
1.1 dsieger 8261:
1.21 snj 8262: 9. Remove from oldcategory/Makefile.
1.1 dsieger 8263:
1.21 snj 8264: 10. Add to newcategory/Makefile.
1.1 dsieger 8265:
1.21 snj 8266: 11. Commit the changed and removed files:
1.1 dsieger 8267:
8268: % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
8269:
8270: (and any packages from step 5, of course).
8271:
1.266 martin 8272: Chapter 24. pkgsrc Policies
1.263 wiz 8273:
8274: Table of Contents
8275:
8276: 24.1. Packages for which updating is restricted
8277: 24.1.1. Limited Updates - ABI
8278: 24.1.2. Limited Updates - Bootstrap
8279:
1.266 martin 8280: 24.1. Packages for which updating is restricted
1.263 wiz 8281:
8282: In the past, some packages have caused more package failures than others, and
8283: we'd like to reduce this in the future.
8284:
8285: For this reason, pkgsrc-pmc marks some packages with POLICY_UPDATE_LIMITED. The
8286: possible values currently are:
8287:
8288: * abi for packages where ABI/API changes often broke the packages depending
8289: on them
8290:
8291: * bootstrap for packages that are used during the pkgsrc bootstrap
8292:
8293: pkglint will warn when committing updates to these packages.
8294:
1.266 martin 8295: 24.1.1. Limited Updates - ABI
1.263 wiz 8296:
8297: Before committing non-micro version updates to packages marked with
8298: POLICY_UPDATE_LIMITED=abi, a limited bulk build of meta-pkgs/bulk-test-$
8299: {PACKAGE} needs to be run and the result posted to the tech-pkg mailing list,
8300: highlighting what packages would stop building (if any).
8301:
8302: Depending on the result, pkgsrc-pmc then decides:
8303:
8304: * go ahead with the update
8305:
8306: * wait for packages X, Y, Z to be fixed (upstream or locally) with the
8307: updated version, which is put in wip in the meantime
8308:
8309: * In the second case, all pkgsrc developers are encouraged to work on fixing
8310: this - it is not only the updater's task to fix them.
8311:
8312: The decision to wait for packages can be revisited.
8313:
1.266 martin 8314: 24.1.2. Limited Updates - Bootstrap
1.263 wiz 8315:
8316: When updating packages used in the bootstrap, i.e. marked with
8317: POLICY_UPDATE_LIMITED=bootstrap, test the bootstrap process and preferably some
8318: basic packages and send the patch to the tech-pkg mailing list so it can be
8319: tested on other platforms as well. Give at least two weeks for feedback and
8320: testing by others.
8321:
1.266 martin 8322: Chapter 25. Frequently Asked Questions
1.1 dsieger 8323:
8324: This section contains the answers to questions that may arise when you are
8325: writing a package. If you don't find your question answered here, first have a
8326: look in the other chapters, and if you still don't have the answer, ask on the
8327: pkgsrc-users mailing list.
8328:
1.263 wiz 8329: 25.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
8330: 25.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
8331: 25.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
8332: 25.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
8333: 25.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.271 wiz 8334: the := inside it.
1.263 wiz 8335: 25.6. Which mailing lists are there for package developers?
8336: 25.7. Where is the pkgsrc documentation?
8337: 25.8. I have a little time to kill. What shall I do?
1.1 dsieger 8338:
1.263 wiz 8339: 25.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1 dsieger 8340:
8341: MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
1.223 nia 8342: (1).
8343:
8344: MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM when
8345: building the package.
8346:
8347: .MAKEFLAGS is an internal variable of bmake and should not be used by
8348: packages.
1.1 dsieger 8349:
1.263 wiz 8350: 25.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1 dsieger 8351:
8352: MAKE is the path to the make(1) program that is used in the pkgsrc
1.223 nia 8353: infrastructure.
8354:
8355: GMAKE is the path to GNU Make, but you need to say USE_TOOLS+=gmake to
8356: use that.
8357:
8358: MAKE_PROGRAM is the path to the Make program that is used for building
8359: the package.
1.1 dsieger 8360:
1.263 wiz 8361: 25.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1 dsieger 8362:
8363: CC is the path to the real C compiler, which can be configured by the
1.223 nia 8364: pkgsrc user.
1.1 dsieger 8365:
1.223 nia 8366: PKG_CC is the path to the compiler wrapper.
1.1 dsieger 8367:
1.223 nia 8368: PKGSRC_COMPILER is not a path to a compiler, but the type of compiler
8369: that should be used. See mk/compiler.mk for more information about the
8370: latter variable.
1.1 dsieger 8371:
1.263 wiz 8372: 25.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1 dsieger 8373:
1.266 martin 8374: For optimization reasons, some variables are only available in the
8375: wrapper phase and later. To simulate the wrapper phase, append
1.1 dsieger 8376: PKG_PHASE=wrapper to the above command.
8377:
1.263 wiz 8378: 25.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1 dsieger 8379: the := inside it.
8380:
1.223 nia 8381: The := is not an assignment operator, even though it may look like one.
1.108 rillig 8382: Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
8383: is documented in the make(1) man page and which is commonly used in the
8384: form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
8385: string and new_string is package/. That's where the : and the = fall
8386: together.
1.1 dsieger 8387:
1.263 wiz 8388: 25.6. Which mailing lists are there for package developers?
1.1 dsieger 8389:
8390: tech-pkg
8391:
8392: This is a list for technical discussions related to pkgsrc
8393: development, e.g. soliciting feedback for changes to pkgsrc
8394: infrastructure, proposed new features, questions related to porting
8395: pkgsrc to a new platform, advice for maintaining a package, patches
8396: that affect many packages, help requests moved from pkgsrc-users when
8397: an infrastructure bug is found, etc.
8398:
8399: pkgsrc-bugs
8400:
8401: All bug reports in category "pkg" sent with send-pr(1) appear here.
8402: Please do not report your bugs here directly; use one of the other
8403: mailing lists.
1.271 wiz 8404:
1.263 wiz 8405: 25.7. Where is the pkgsrc documentation?
1.1 dsieger 8406:
8407: There are many places where you can find documentation about pkgsrc:
8408:
8409: * The pkgsrc guide (this document) is a collection of chapters that
8410: explain large parts of pkgsrc, but some chapters tend to be outdated.
8411: Which ones they are is hard to say.
8412:
1.174 leot 8413: * On the mailing list archives (see https://mail-index.NetBSD.org/),
8414: you can find discussions about certain features, announcements of new
1.1 dsieger 8415: parts of the pkgsrc infrastructure and sometimes even announcements
8416: that a certain feature has been marked as obsolete. The benefit here
8417: is that each message has a date appended to it.
8418:
8419: * Many of the files in the mk/ directory start with a comment that
8420: describes the purpose of the file and how it can be used by the
8421: pkgsrc user and package authors. An easy way to find this
8422: documentation is to run bmake help.
8423:
8424: * The CVS log messages are a rich source of information, but they tend
8425: to be highly abbreviated, especially for actions that occur often.
8426: Some contain a detailed description of what has changed, but they are
8427: geared towards the other pkgsrc developers, not towards an average
8428: pkgsrc user. They also only document changes, so if you don't know
8429: what has been before, these messages may not be worth too much to
8430: you.
8431:
1.266 martin 8432: * Some parts of pkgsrc are only implicitly documented , that is the
1.1 dsieger 8433: documentation exists only in the mind of the developer who wrote the
8434: code. To get this information, use the cvs annotate command to see
8435: who has written it and ask on the tech-pkg mailing list, so that
8436: others can find your questions later (see above). To be sure that the
8437: developer in charge reads the mail, you may CC him or her.
8438:
1.263 wiz 8439: 25.8. I have a little time to kill. What shall I do?
1.1 dsieger 8440:
8441: This is not really an FAQ yet, but here's the answer anyway.
8442:
8443: * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
8444: about newer versions of installed packages that are available, but
8445: not yet updated in pkgsrc.
8446:
1.266 martin 8447: * Browse pkgsrc/doc/TODO it contains a list of suggested new packages
8448: and a list of cleanups and enhancements for pkgsrc that would be nice
8449: to have.
1.1 dsieger 8450:
1.71 wiz 8451: * Review packages for which review was requested on the tech-pkg
8452: mailing list.
1.1 dsieger 8453:
1.266 martin 8454: Part III. The pkgsrc infrastructure internals
1.1 dsieger 8455:
8456: This part of the guide deals with everything from the infrastructure that is
8457: behind the interfaces described in the developer's guide. A casual package
8458: maintainer should not need anything from this part.
8459:
8460: Table of Contents
8461:
1.263 wiz 8462: 26. Design of the pkgsrc infrastructure
8463: 26.1. The meaning of variable definitions
8464: 26.2. Avoiding problems before they arise
8465: 26.3. Variable evaluation
8466: 26.3.1. At load time
8467: 26.3.2. At runtime
8468: 26.4. How can variables be specified?
8469: 26.5. Designing interfaces for Makefile fragments
8470: 26.5.1. Procedures with parameters
8471: 26.5.2. Actions taken on behalf of parameters
8472: 26.6. The order in which files are loaded
8473: 26.6.1. The order in bsd.prefs.mk
8474: 26.6.2. The order in bsd.pkg.mk
8475: 27. Regression tests
8476: 27.1. Running the regression tests
8477: 27.2. Adding a new regression test
8478: 27.2.1. Overridable functions
8479: 27.2.2. Helper functions
8480: 28. Porting pkgsrc
8481: 28.1. Porting pkgsrc to a new operating system
1.1 dsieger 8482:
1.266 martin 8483: Chapter 26. Design of the pkgsrc infrastructure
1.1 dsieger 8484:
8485: Table of Contents
8486:
1.263 wiz 8487: 26.1. The meaning of variable definitions
8488: 26.2. Avoiding problems before they arise
8489: 26.3. Variable evaluation
8490: 26.3.1. At load time
8491: 26.3.2. At runtime
8492: 26.4. How can variables be specified?
8493: 26.5. Designing interfaces for Makefile fragments
8494: 26.5.1. Procedures with parameters
8495: 26.5.2. Actions taken on behalf of parameters
8496: 26.6. The order in which files are loaded
8497: 26.6.1. The order in bsd.prefs.mk
8498: 26.6.2. The order in bsd.pkg.mk
1.1 dsieger 8499:
8500: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
8501: fragment needs a properly specified interface. This chapter explains how such
8502: an interface looks like.
8503:
1.266 martin 8504: 26.1. The meaning of variable definitions
1.1 dsieger 8505:
8506: Whenever a variable is defined in the pkgsrc infrastructure, the location and
8507: the way of definition provide much information about the intended use of that
8508: variable. Additionally, more documentation may be found in a header comment or
8509: in this pkgsrc guide.
8510:
8511: A special file is mk/defaults/mk.conf, which lists all variables that are
8512: intended to be user-defined. They are either defined using the ?= operator or
8513: they are left undefined because defining them to anything would effectively
1.266 martin 8514: mean yes . All these variables may be overridden by the pkgsrc user in the
1.1 dsieger 8515: MAKECONF file.
8516:
8517: Outside this file, the following conventions apply: Variables that are defined
8518: using the ?= operator may be overridden by a package.
8519:
8520: Variables that are defined using the = operator may be used read-only at
8521: run-time.
8522:
8523: Variables whose name starts with an underscore must not be accessed outside the
8524: pkgsrc infrastructure at all. They may change without further notice.
8525:
8526: Note
8527:
8528: These conventions are currently not applied consistently to the complete pkgsrc
8529: infrastructure.
8530:
1.266 martin 8531: 26.2. Avoiding problems before they arise
1.1 dsieger 8532:
8533: All variables that contain lists of things should default to being empty. Two
8534: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
8535: variables cannot simply be modified using the += operator in package Makefiles
8536: (or other files included by them), since there is no guarantee whether the
8537: variable is already set or not, and what its value is. In the case of
1.266 martin 8538: DISTFILES, the packages know the default value and just define it as in the
1.1 dsieger 8539: following example.
8540:
8541: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
8542:
8543: Because of the selection of this default value, the same value appears in many
8544: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
1.266 martin 8545: value ( c ) is so short that it doesn't stand out. Nevertheless it is mentioned
1.1 dsieger 8546: in many files.
8547:
1.266 martin 8548: 26.3. Variable evaluation
1.1 dsieger 8549:
1.266 martin 8550: 26.3.1. At load time
1.1 dsieger 8551:
8552: Variable evaluation takes place either at load time or at runtime, depending on
8553: the context in which they occur. The contexts where variables are evaluated at
8554: load time are:
8555:
8556: * The right hand side of the := and != operators,
8557:
8558: * Make directives like .if or .for,
8559:
8560: * Dependency lines.
8561:
8562: A special exception are references to the iteration variables of .for loops,
8563: which are expanded inline, no matter in which context they appear.
8564:
8565: As the values of variables may change during load time, care must be taken not
8566: to evaluate them by accident. Typical examples for variables that should not be
8567: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
8568: clear, here is an example:
8569:
8570: CONFIGURE_ARGS= # none
8571: CFLAGS= -O
8572: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
8573:
8574: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
8575:
8576: CFLAGS+= -Wall
8577:
8578: This code shows how the use of the := operator can quickly lead to unexpected
8579: results. The first paragraph is fairly common code. The second paragraph
8580: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
8581: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
8582: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
8583: typically occur in completely unrelated files.
8584:
1.266 martin 8585: 26.3.2. At runtime
1.1 dsieger 8586:
8587: After all the files have been loaded, the values of the variables cannot be
8588: changed anymore. Variables that are used in the shell commands are expanded at
8589: this point.
8590:
1.266 martin 8591: 26.4. How can variables be specified?
1.1 dsieger 8592:
8593: There are many ways in which the definition and use of a variable can be
8594: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108 rillig 8595: policies. A package can be checked with pkglint -Wall to see whether it meets
8596: these rules.
1.1 dsieger 8597:
1.266 martin 8598: 26.5. Designing interfaces for Makefile fragments
1.1 dsieger 8599:
8600: Most of the .mk files fall into one of the following classes. Cases where a
8601: file falls into more than one class should be avoided as it often leads to
8602: subtle bugs.
8603:
1.266 martin 8604: 26.5.1. Procedures with parameters
1.1 dsieger 8605:
8606: In a traditional imperative programming language some of the .mk files could be
1.266 martin 8607: described as procedures. They take some input parameters and after
8608: inclusion provide a result in output parameters. Since all variables in
1.23 jakllsch 8609: Makefiles have global scope care must be taken not to use parameter names that
8610: have already another meaning. For example, PKGNAME is a bad choice for a
8611: parameter name.
1.1 dsieger 8612:
8613: Procedures are completely evaluated at preprocessing time. That is, when
8614: calling a procedure all input parameters must be completely resolvable. For
8615: example, CONFIGURE_ARGS should never be an input parameter since it is very
8616: likely that further text will be added after calling the procedure, which would
8617: effectively apply the procedure to only a part of the variable. Also,
1.108 rillig 8618: references to other variables will be modified after calling the procedure.
1.1 dsieger 8619:
8620: A procedure can declare its output parameters either as suitable for use in
8621: preprocessing directives or as only available at runtime. The latter
8622: alternative is for variables that contain references to other runtime
8623: variables.
8624:
8625: Procedures shall be written such that it is possible to call the procedure more
8626: than once. That is, the file must not contain multiple-inclusion guards.
8627:
8628: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
8629: To express that the parameters are evaluated at load time, they should be
8630: assigned using the := operator, which should be used only for this purpose.
8631:
1.266 martin 8632: 26.5.2. Actions taken on behalf of parameters
1.1 dsieger 8633:
8634: Action files take some input parameters and may define runtime variables. They
8635: shall not define loadtime variables. There are action files that are included
8636: implicitly by the pkgsrc infrastructure, while other must be included
8637: explicitly.
8638:
8639: An example for action files is mk/subst.mk.
8640:
1.266 martin 8641: 26.6. The order in which files are loaded
1.1 dsieger 8642:
8643: Package Makefiles usually consist of a set of variable definitions, and include
8644: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
8645: include various other *.mk files if they need to query the availability of
8646: certain features like the type of compiler or the X11 implementation. Due to
8647: the heavy use of preprocessor directives like .if and .for, the order in which
8648: the files are loaded matters.
8649:
8650: This section describes at which point the various files are loaded and gives
8651: reasons for that order.
8652:
1.266 martin 8653: 26.6.1. The order in bsd.prefs.mk
1.1 dsieger 8654:
8655: The very first action in bsd.prefs.mk is to define some essential variables
8656: like OPSYS, OS_VERSION and MACHINE_ARCH.
8657:
1.4 rillig 8658: Then, the user settings are loaded from the file specified in MAKECONF, which
8659: is usually mk.conf. After that, those variables that have not been overridden
8660: by the user are loaded from mk/defaults/mk.conf.
1.1 dsieger 8661:
8662: After the user settings, the system settings and platform settings are loaded,
8663: which may override the user settings.
8664:
8665: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
8666: This only happens when building a package, so the proper variables must be used
8667: instead of the direct tool names.
8668:
8669: As the last steps, some essential variables from the wrapper and the package
8670: system flavor are loaded, as well as the variables that have been cached in
8671: earlier phases of a package build.
8672:
1.266 martin 8673: 26.6.2. The order in bsd.pkg.mk
1.1 dsieger 8674:
8675: First, bsd.prefs.mk is loaded.
8676:
8677: Then, the various *-vars.mk files are loaded, which fill default values for
8678: those variables that have not been defined by the package. These variables may
8679: later be used even in unrelated files.
8680:
8681: Then, the file bsd.pkg.error.mk provides the target error-check that is added
8682: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
8683: DELAYED_WARNING_MSG.
8684:
8685: Then, the package-specific hacks from hacks.mk are included.
8686:
8687: Then, various other files follow. Most of them don't have any dependencies on
8688: what they need to have included before or after them, though some do.
8689:
8690: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
8691: restricts the use of these variables to all the files that have been included
8692: before. Appearances in later files will be silently ignored.
8693:
8694: Then, the files for the main targets are included, in the order of later
8695: execution, though the actual order should not matter.
8696:
8697: At last, some more files are included that don't set any interesting variables
8698: but rather just define make targets to be executed.
8699:
1.266 martin 8700: Chapter 27. Regression tests
1.1 dsieger 8701:
8702: Table of Contents
8703:
1.263 wiz 8704: 27.1. Running the regression tests
8705: 27.2. Adding a new regression test
8706: 27.2.1. Overridable functions
8707: 27.2.2. Helper functions
1.1 dsieger 8708:
8709: The pkgsrc infrastructure consists of a large codebase, and there are many
8710: corners where every little bit of a file is well thought out, making pkgsrc
8711: likely to fail as soon as anything is changed near those parts. To prevent most
8712: changes from breaking anything, a suite of regression tests should go along
8713: with every important part of the pkgsrc infrastructure. This chapter describes
8714: how regression tests work in pkgsrc and how you can add new tests.
8715:
1.266 martin 8716: 27.1. Running the regression tests
1.1 dsieger 8717:
1.25 wiz 8718: You first need to install the pkgtools/pkg_regress package, which provides the
1.1 dsieger 8719: pkg_regress command. Then you can simply run that command, which will run all
1.168 rillig 8720: tests in the regress/ directory.
1.1 dsieger 8721:
1.266 martin 8722: 27.2. Adding a new regression test
1.1 dsieger 8723:
1.168 rillig 8724: Every directory in the regress/ directory that contains a file called spec is
1.1 dsieger 8725: considered a regression test. This file is a shell program that is included by
8726: the pkg_regress command. The following functions can be overridden to suit your
8727: needs.
8728:
1.266 martin 8729: 27.2.1. Overridable functions
1.1 dsieger 8730:
1.266 martin 8731: These functions do not take any parameters. Although they are called in set -e
8732: mode, they don't stop at the first failing command. See this Stack Overflow
1.108 rillig 8733: question for details.
1.1 dsieger 8734:
1.108 rillig 8735: do_setup
1.1 dsieger 8736:
8737: This function prepares the environment for the test. By default it does
8738: nothing.
8739:
1.108 rillig 8740: do_test
1.1 dsieger 8741:
8742: This function runs the actual test. By default, it calls TEST_MAKE with the
8743: arguments MAKEARGS_TEST and writes its output including error messages into
8744: the file TEST_OUTFILE.
8745:
1.108 rillig 8746: When defining this function, make sure that all output that needs to be
8747: checked is written to the correct output file. Example:
8748:
8749: do_test() {
8750: echo "Example output"
8751: } 1>$TEST_OUTFILE 2>&1
8752:
8753: check_result
1.1 dsieger 8754:
8755: This function is run after the test and is typically used to compare the
8756: actual output from the one that is expected. It can make use of the various
1.108 rillig 8757: helper functions from the next section. Example:
8758:
8759: check_result() {
8760: exit_status 0
8761: output_require "Example"
8762: output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
8763: output_prohibit "no such file or directory"
1.169 rillig 8764: regress_fail "expected $expected but got $actual for input $input"
1.108 rillig 8765: }
1.1 dsieger 8766:
1.108 rillig 8767: do_cleanup
1.1 dsieger 8768:
8769: This function cleans everything up after the test has been run. By default
8770: it does nothing.
8771:
1.266 martin 8772: 27.2.2. Helper functions
1.1 dsieger 8773:
1.168 rillig 8774: regress_fail message...
8775:
8776: This function makes the test fail with the given error message.
8777:
1.108 rillig 8778: exit_status expected
1.1 dsieger 8779:
1.108 rillig 8780: This function compares the exitcode of the do_test function with its first
8781: parameter. If they differ, the test will fail.
1.1 dsieger 8782:
1.108 rillig 8783: output_require regex...
1.1 dsieger 8784:
8785: This function checks for each of its parameters if the output from do_test
1.108 rillig 8786: matches the extended regular expression. If it does not, the test will
8787: fail. Example:
8788:
8789: output_require "looks fine"
8790: output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1 dsieger 8791:
1.177 leot 8792: output_prohibit regex...
1.1 dsieger 8793:
8794: This function checks for each of its parameters if the output from do_test
8795: () does not match the extended regular expression. If any of the regular
8796: expressions matches, the test will fail.
8797:
1.266 martin 8798: Chapter 28. Porting pkgsrc
1.1 dsieger 8799:
8800: Table of Contents
8801:
1.263 wiz 8802: 28.1. Porting pkgsrc to a new operating system
1.1 dsieger 8803:
8804: The pkgsrc system has already been ported to many operating systems, hardware
8805: architectures and compilers. This chapter explains the necessary steps to make
8806: pkgsrc even more portable.
8807:
1.266 martin 8808: 28.1. Porting pkgsrc to a new operating system
1.1 dsieger 8809:
8810: To port pkgsrc to a new operating system (called MyOS in this example), you
8811: need to touch the following files:
8812:
8813: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
8814:
8815: This file contains some basic definitions, for example the name of the C
8816: compiler.
8817:
8818: mk/bsd.prefs.mk
8819:
1.212 wiz 8820: Insert code that defines the variables OPSYS, OS_VERSION, OPSYS_VERSION,
1.1 dsieger 8821: LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
8822: that appear in this file.
8823:
8824: mk/platform/MyOS.mk
8825:
8826: This file contains the platform-specific definitions that are used by
8827: pkgsrc. Start by copying one of the other files and edit it to your needs.
8828:
8829: mk/tools/tools.MyOS.mk
8830:
8831: This file defines the paths to all the tools that are needed by one or the
8832: other package in pkgsrc, as well as by pkgsrc itself. Find out where these
8833: tools are on your platform and add them.
8834:
8835: Now, you should be able to build some basic packages, like lang/perl5, shells/
8836: bash.
8837:
1.266 martin 8838: Appendix A. A simple example package: bison
1.1 dsieger 8839:
8840: Table of Contents
8841:
8842: A.1. files
8843: A.1.1. Makefile
8844: A.1.2. DESCR
8845: A.1.3. PLIST
8846: A.1.4. Checking a package with pkglint
8847: A.2. Steps for building, installing, packaging
8848:
8849: We checked to find a piece of software that wasn't in the packages collection,
1.25 wiz 8850: and picked GNU bison. Quite why someone would want to have bison when Berkeley
1.1 dsieger 8851: yacc is already present in the tree is beyond us, but it's useful for the
8852: purposes of this exercise.
8853:
1.266 martin 8854: A.1. files
1.1 dsieger 8855:
1.266 martin 8856: A.1.1. Makefile
1.1 dsieger 8857:
1.2 rillig 8858: # $NetBSD$
1.1 dsieger 8859: #
8860:
8861: DISTNAME= bison-1.25
8862: CATEGORIES= devel
1.171 rillig 8863: MASTER_SITES= ${MASTER_SITE_GNU:=bison/}
1.1 dsieger 8864:
1.30 dholland 8865: MAINTAINER= pkgsrc-users@NetBSD.org
1.174 leot 8866: HOMEPAGE= https://www.gnu.org/software/bison/bison.html
1.1 dsieger 8867: COMMENT= GNU yacc clone
8868:
8869: GNU_CONFIGURE= yes
1.47 wiz 8870: INFO_FILES= yes
1.1 dsieger 8871:
8872: .include "../../mk/bsd.pkg.mk"
8873:
1.266 martin 8874: A.1.2. DESCR
1.1 dsieger 8875:
8876: GNU version of yacc. Can make re-entrant parsers, and numerous other
8877: improvements. Why you would want this when Berkeley yacc(1) is part
8878: of the NetBSD source tree is beyond me.
8879:
1.266 martin 8880: A.1.3. PLIST
1.1 dsieger 8881:
1.2 rillig 8882: @comment $NetBSD$
1.1 dsieger 8883: bin/bison
8884: man/man1/bison.1.gz
8885: share/bison.simple
8886: share/bison.hairy
8887:
1.266 martin 8888: A.1.4. Checking a package with pkglint
1.1 dsieger 8889:
8890: The NetBSD package system comes with pkgtools/pkglint which helps to check the
8891: contents of these files. After installation it is quite easy to use, just
1.171 rillig 8892: change to the directory of the package you wish to examine and run pkglint:
1.1 dsieger 8893:
8894: $ pkglint
1.171 rillig 8895: ERROR: Makefile: Each package must define its LICENSE.
8896: WARN: Makefile:9: HOMEPAGE should migrate from http to https.
8897: NOTE: PLIST:3: The .gz extension is unnecessary for manual pages.
8898: WARN: PLIST:5: "share/bison.hairy" should be sorted before "share/bison.simple".
8899: 1 error, 2 warnings and 1 note found.
8900: (Run "pkglint -e" to show explanations.)
8901: (Run "pkglint -fs" to show what can be fixed automatically.)
1.172 rillig 8902: (Run "pkglint -F" to automatically fix some issues.)
1.1 dsieger 8903:
8904: Depending on the supplied command line arguments (see pkglint(1)), more checks
1.170 rillig 8905: will be performed. Use e.g. pkglint -Wall for a very thorough check.
1.1 dsieger 8906:
1.266 martin 8907: A.2. Steps for building, installing, packaging
1.1 dsieger 8908:
8909: Create the directory where the package lives, plus any auxiliary directories:
8910:
8911: # cd /usr/pkgsrc/lang
8912: # mkdir bison
8913: # cd bison
8914: # mkdir patches
8915:
1.266 martin 8916: Create Makefile, DESCR and PLIST (see Chapter 12, Package components - files,
1.1 dsieger 8917: directories and contents) then continue with fetching the distfile:
8918:
8919: # make fetch
8920: >> bison-1.25.tar.gz doesn't seem to exist on this system.
8921: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
8922: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8923: ftp: Error retrieving file: 500 Internal error
8924:
8925: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
8926: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8927: ftp: Error retrieving file: 500 Internal error
8928:
8929: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
8930: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8931: Successfully retrieved file.
8932:
8933: Generate the checksum of the distfile into distinfo:
8934:
8935: # make makedistinfo
8936:
8937: Now compile:
8938:
8939: # make
8940: >> Checksum OK for bison-1.25.tar.gz.
8941: ===> Extracting for bison-1.25
8942: ===> Patching for bison-1.25
8943: ===> Ignoring empty patch directory
8944: ===> Configuring for bison-1.25
8945: creating cache ./config.cache
8946: checking for gcc... cc
8947: checking whether we are using GNU C... yes
8948: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
8949: checking how to run the C preprocessor... cc -E
8950: checking for minix/config.h... no
8951: checking for POSIXized ISC... no
8952: checking whether cross-compiling... no
8953: checking for ANSI C header files... yes
8954: checking for string.h... yes
8955: checking for stdlib.h... yes
8956: checking for memory.h... yes
8957: checking for working const... yes
8958: checking for working alloca.h... no
8959: checking for alloca... yes
8960: checking for strerror... yes
8961: updating cache ./config.cache
8962: creating ./config.status
8963: creating Makefile
8964: ===> Building for bison-1.25
8965: 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
8966: 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
8967: 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
8968: 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
8969: 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
8970: 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
8971: 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
8972: 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
8973: 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
8974: 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
8975: 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
8976: 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
8977: 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
8978: 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
8979: 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
8980: 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
8981: 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
8982: 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
8983: 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
8984: 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
8985: 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
8986: 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
8987: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
8988: rm -f bison.s1
8989: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
8990:
8991: Everything seems OK, so install the files:
8992:
8993: # make install
8994: >> Checksum OK for bison-1.25.tar.gz.
8995: ===> Installing for bison-1.25
8996: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
8997: rm -f /usr/pkg/bin/bison
8998: cd /usr/pkg/share; rm -f bison.simple bison.hairy
8999: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
9000: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
9001: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
9002: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
9003: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
9004: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
9005: ===> Registering installation for bison-1.25
9006:
9007: You can now use bison, and also - if you decide so - remove it with pkg_delete
9008: bison. Should you decide that you want a binary package, do this now:
9009:
9010: # make package
9011: >> Checksum OK for bison-1.25.tar.gz.
9012: ===> Building package for bison-1.25
9013: Creating package bison-1.25.tgz
9014: Registering depends:.
9015: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
9016:
9017: Now that you don't need the source and object files any more, clean up:
9018:
9019: # make clean
9020: ===> Cleaning for bison-1.25
9021:
1.266 martin 9022: Appendix B. Security hardening
1.207 leot 9023:
9024: Table of Contents
9025:
9026: B.1. Mechanisms
9027: B.1.1. Enabled by default
9028: B.1.2. Not enabled by default
9029: B.2. Caveats
9030: B.2.1. Problems with PKGSRC_MKPIE
9031: B.2.2. Problems with PKGSRC_USE_FORTIFY
9032: B.2.3. Problems with PKGSRC_USE_RELRO
9033: B.2.4. Problems with PKGSRC_USE_SSP
9034: B.3. Auditing the system
9035: B.3.1. Checking for PIE
9036: B.3.2. Checking for partial RELRO
9037: B.3.3. Checking for full RELRO
9038: B.3.4. Checking for SSP
9039:
9040: A number of mechanisms are available in pkgsrc to improve the security of the
9041: resulting system. This page describes the mechanisms, and gives hints about
9042: detecting and fixing problems.
9043:
9044: Mechanisms can be enabled individually in mk.conf, and are individually
9045: described below.
9046:
9047: Typically, a feature will cause some programs to fail to build or work when
9048: first enabled. This can be due to latent problems in the program, and can be
9049: due to other reasons. After enough testing to have confidence that user
9050: problems will be quite rare, individual mechanisms will be enabled by default.
9051:
9052: For each mechanism, see the Caveats section below for an explanation of what
9053: might go wrong at compile time and at run time, and how to notice and address
9054: these problems.
9055:
1.266 martin 9056: B.1. Mechanisms
1.207 leot 9057:
1.266 martin 9058: B.1.1. Enabled by default
1.207 leot 9059:
1.266 martin 9060: B.1.1.1. PKGSRC_USE_FORTIFY
1.207 leot 9061:
9062: This allows substitute wrappers to be used for some commonly used library
9063: functions that do not have built-in bounds checking - but could in some cases.
9064:
9065: Two mitigation levels are available:
9066:
9067: * "weak" only enables checks at compile-time.
9068:
9069: * "strong" enables checks at compile-time and runtime.
9070:
9071: "strong" has been enabled by default since pkgsrc-2017Q3.
9072:
1.266 martin 9073: B.1.1.2. PKGSRC_USE_SSP
1.207 leot 9074:
9075: This enables a stack-smashing protection mitigation. It is done by adding a
9076: guard variable to functions with vulnerable objects. The guards are initialized
9077: when a function is entered and then checked when the function exits. The guard
9078: check will fail and the program forcibly exited if the variable was modified in
9079: the meantime. This can happen in case of buffer overflows or memory corruption,
9080: and therefore exposing these bugs.
9081:
9082: Different mitigation levels are available:
9083:
9084: * "yes", which will only protect functions considered vulnerable by the
9085: compiler;
9086:
9087: * "all", which will protect every function;
9088:
9089: * "strong", the default, which will apply a better balance between the two
9090: settings above.
9091:
9092: This mitigation is supported by both GCC and clang. It may be supported in
9093: additional compilers, possibly under a different name. It is particularly
9094: useful for unsafe programming languages, such as C/C++.
9095:
9096: * "yes" is enabled by default where known supported since pkgsrc-2017Q3.
9097:
9098: * "strong" is enabled by default where known supported since pkgsrc-2021Q4.
9099:
9100: More details can be found here:
9101:
9102: * Buffer overflow protection on Wikipedia
9103:
1.266 martin 9104: B.1.1.3. PKGSRC_MKPIE
1.207 leot 9105:
9106: This requests the creation of PIE (Position Independent Executables) for all
9107: executables. The PIE mechanism is normally used for shared libraries, so that
9108: they can be loaded at differing addresses at runtime. PIE itself does not have
9109: useful security properties; however, it is necessary to fully leverage some,
9110: such as ASLR. Some operating systems support Address Space Layout Randomization
9111: (ASLR), which causes different addresses to be used each time a program is run.
9112: This makes it more difficult for an attacker to guess addresses and thus makes
9113: exploits harder to construct. With PIE, ASLR can really be applied to the
9114: entire program, instead of the stack and heap only.
9115:
9116: PIE executables will only be built for toolchains that are known to support
9117: PIE. Currently, this means NetBSD on x86, ARM, SPARC64, m68k, and MIPS.
9118:
9119: PKGSRC_MKPIE was enabled by default after the pkgsrc-2021Q3 branch.
9120:
1.266 martin 9121: B.1.1.4. PKGSRC_USE_RELRO
1.207 leot 9122:
9123: This also makes the exploitation of some security vulnerabilities more
9124: difficult in some cases.
9125:
9126: Two different mitigation levels are available:
9127:
1.219 nia 9128: * partial (the default): the ELF sections are reordered so that internal data
9129: sections precede the program's own data sections, and non-PLT GOT is
9130: read-only;
1.207 leot 9131:
9132: * full: in addition to partial RELRO, every relocation is performed
1.218 nia 9133: immediately when starting the program, allowing the entire GOT to be
9134: read-only. This can greatly slow down startup of large programs.
1.207 leot 9135:
9136: This is currently supported by GCC. Many software distributions now enable this
1.220 nia 9137: feature by default, at the "partial" level.
1.207 leot 9138:
9139: More details can be found here:
9140:
9141: * Hardening ELF binaries using Relocation Read-Only (RELRO)
9142:
1.266 martin 9143: B.1.2. Not enabled by default
1.219 nia 9144:
1.266 martin 9145: B.1.2.1. PKGSRC_MKREPRO
1.219 nia 9146:
9147: With this option, pkgsrc will try to build packages reproducibly. This allows
9148: packages built from the same tree and with the same options, to produce
9149: identical results bit by bit. This option should be combined with ASLR and
9150: PKGSRC_MKPIE to avoid predictable address offsets for attackers attempting to
9151: exploit security vulnerabilities.
9152:
9153: More details can be found here:
9154:
9155: * Reproducible Builds - a set of software development practices that create
9156: an independently-verifiable path from source to binary code
9157:
9158: More work likely needs to be done before pkgsrc is fully reproducible.
9159:
1.266 martin 9160: B.1.2.2. PKGSRC_USE_STACK_CHECK
1.207 leot 9161:
9162: This uses -fstack-check with GCC for another stack protection mitigation.
9163:
9164: It asks the compiler to generate code verifying that it does not corrupt the
9165: stack. According to GCC's manual page, this is really only useful for
9166: multi-threaded programs.
9167:
1.266 martin 9168: B.2. Caveats
1.207 leot 9169:
1.266 martin 9170: B.2.1. Problems with PKGSRC_MKPIE
1.207 leot 9171:
1.266 martin 9172: B.2.1.1. Packages failing to build
1.207 leot 9173:
9174: A number of packages may fail to build with this option enabled. The failures
9175: are often related to the absence of the -fPIC compilation flag when building
9176: libraries or executables (or ideally -fPIE in the latter case). This flag is
9177: added to the CFLAGS already, but requires the package to actually support it.
9178:
1.266 martin 9179: B.2.1.1.1. How to fix
1.207 leot 9180:
9181: These instructions are meant as a reference only; they likely need to be
9182: adapted for many packages individually.
9183:
9184: For packages using Makefiles:
9185:
9186: MAKE_FLAGS+= CFLAGS=${CFLAGS:Q}
9187: MAKE_FLAGS+= LDFLAGS=${LDFLAGS:Q}
9188:
9189: For packages using Imakefiles:
9190:
9191: MAKE_FLAGS+= CCOPTIONS=${CFLAGS:Q}
9192: MAKE_FLAGS+= LOCAL_LDFLAGS=${LDFLAGS:Q}
9193:
1.266 martin 9194: B.2.1.2. Run-time crashes
1.207 leot 9195:
9196: Some programs may fail to run, or crash at random times once built as PIE. Two
9197: scenarios are essentially possible. This is nearly always due to a bug in the
9198: program being exposed due to ASLR.
9199:
1.266 martin 9200: B.2.1.3. Disabling PKGSRC_MKPIE on a per-package basis
1.207 leot 9201:
9202: Ideally, packages should be fixed for compatibility with MKPIE. However, in
9203: some cases this is very difficult, due to complex build systems, packages using
9204: non-standard toolchains, or programming languages with odd bootstrapping
9205: mechanisms.
9206:
9207: To disable PKGSRC_MKPIE on a per-package basis, set MKPIE_SUPPORTED= no in the
9208: package's Makefile before bsd.prefs.mk is included.
9209:
1.266 martin 9210: B.2.2. Problems with PKGSRC_USE_FORTIFY
1.207 leot 9211:
1.266 martin 9212: B.2.2.1. Packages failing to build
1.207 leot 9213:
9214: This feature makes use of pre-processing directives to look for hardened,
9215: alternative implementations of essential library calls. Some programs may fail
9216: to build as a result; this usually happens for those trying too hard to be
9217: portable, or otherwise abusing definitions in the standard library.
9218:
1.266 martin 9219: B.2.2.2. Run-time crashes
1.207 leot 9220:
9221: This feature may cause some programs to crash, usually indicating an actual bug
9222: in the program. The fix will typically involve patching the original program's
9223: source code.
9224:
1.266 martin 9225: B.2.2.3. Optimization is required
1.207 leot 9226:
9227: At least in the case of GCC, FORTIFY will only be applied if optimization is
9228: applied while compiling. This means that the CFLAGS should also contain -O, -O2
9229: or another optimization level. This cannot easily be applied globally, as some
9230: packages may require specific optimization levels.
9231:
1.266 martin 9232: B.2.2.4. Disabling FORTIFY on a per-package basis
1.207 leot 9233:
9234: Note
9235:
9236: FORTIFY should not be disabled to work around runtime crashes in the program!
9237: This is a very bad idea and will expose you to security vulnerabilities.
9238:
9239: To disable FORTIFY on a per-package basis, set the following in the package's
9240: Makefile before bsd.prefs.mk is included:
9241:
9242: FORTIFY_SUPPORTED= no
9243:
1.266 martin 9244: B.2.3. Problems with PKGSRC_USE_RELRO
1.207 leot 9245:
1.266 martin 9246: B.2.3.1. Performance impact
1.207 leot 9247:
9248: For better protection, full RELRO requires every symbol to be resolved when the
9249: program starts, rather than simply when required at run-time. This will have
9250: more impact on programs using a lot of symbols, or linked to libraries exposing
9251: a lot of symbols. Therefore, daemons or programs otherwise running in
9252: background are affected only when started. Programs loading plug-ins at
9253: run-time are affected when loading the plug-ins.
9254:
9255: The impact is not expected to be noticeable on modern hardware, except in some
9256: cases for big programs.
9257:
1.266 martin 9258: B.2.3.2. Run-time crashes
1.207 leot 9259:
9260: Some programs handle plug-ins and dependencies in a way that conflicts with
9261: RELRO: for instance, with an initialization routine listing any other plug-in
9262: required. With full RELRO, the missing symbols are resolved before the
9263: initialization routine can run, and the dynamic loader will not be able to find
9264: them directly and abort as a result. Unfortunately, this is how Xorg loads its
9265: drivers. Partial RELRO can be applied instead in this case.
9266:
1.266 martin 9267: B.2.3.3. Disabling RELRO on a per-package basis
1.207 leot 9268:
9269: To disable RELRO on a per-package basis, set the following in the package's
9270: Makefile before bsd.prefs.mk is included:
9271:
9272: RELRO_SUPPORTED= no
9273:
1.209 nia 9274: It is also possible to at most enable partial RELRO, by setting RELRO_SUPPORTED
9275: to partial.
9276:
1.266 martin 9277: B.2.4. Problems with PKGSRC_USE_SSP
1.207 leot 9278:
1.266 martin 9279: B.2.4.1. Packages failing to build
1.207 leot 9280:
9281: The stack-smashing protection provided by this option does not work for some
9282: programs. The most common situation in which this happens is when the program
9283: allocates variables on the stack, with the size determined at run-time.
9284:
1.266 martin 9285: B.2.4.2. Run-time crashes
1.207 leot 9286:
9287: Again, this feature may cause some programs to crash via a SIGABRT, usually
9288: indicating an actual bug in the program.
9289:
9290: On NetBSD LOG_CRIT level syslog messages are sent and - by default - appended
9291: to /var/log/messages, e.g.:
9292:
9293: Jan 6 15:42:51 hostname -: hostname program - - - buffer overflow detected; terminated
9294:
9295: (where hostname is the hostname(1) and program is the basename(1) of the
9296: program crashed).
9297:
9298: Patching the original program is then required.
9299:
9300: Rebuilding the package via:
9301:
9302: % env CFLAGS=-g INSTALL_UNSTRIPPED=yes make replace
9303:
9304: and inspecting the backtrace of the coredump via the debugger should point out
9305: the problematic call by inspecting the frame calling the _chk() (SSP) function.
9306:
1.266 martin 9307: B.2.4.3. Performance impact
1.207 leot 9308:
9309: The compiler emits extra code when using this feature: a check for buffer
9310: overflows is performed when entering and exiting functions, requiring an extra
9311: variable on the stack. The level of protection can otherwise be adjusted to
9312: affect only those functions considered more sensitive by the compiler (with
9313: -fstack-protector instead of -fstack-protector-all).
9314:
9315: The impact is not expected to be noticeable on modern hardware. However,
9316: programs with a hard requirement to run at the fastest possible speed should
9317: avoid using this feature, or using libraries built with this feature.
9318:
1.266 martin 9319: B.2.4.4. Disabling SSP on a per-package basis
1.207 leot 9320:
9321: Note
9322:
9323: SSP should not be disabled to work around runtime crashes in the program! This
9324: is a very bad idea and will expose you to security vulnerabilities.
9325:
9326: To disable SSP on a per-package basis, set the following in the package's
9327: Makefile before bsd.prefs.mk is included:
9328:
9329: SSP_SUPPORTED= no
9330:
1.266 martin 9331: B.3. Auditing the system
1.207 leot 9332:
9333: The illusion of security is worse than having no security at all. This section
9334: lists a number of ways to ensure the security features requested are actually
9335: effective.
9336:
9337: These instructions were obtained and tested on a system derived from NetBSD 7
9338: (amd64). YMMV.
9339:
1.266 martin 9340: B.3.1. Checking for PIE
1.207 leot 9341:
9342: The ELF executable type in use changes for binaries built as PIE; without:
9343:
9344: $ file /path/to/bin/ary
9345: /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
9346:
9347: as opposed to the following binary, built as PIE:
9348:
9349: $ file /path/to/pie/bin/ary
9350: /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
9351:
9352: The latter result is then what is expected.
9353:
1.266 martin 9354: B.3.2. Checking for partial RELRO
1.207 leot 9355:
9356: The following command should list a section called RELRO:
9357:
9358: $ objdump -p /path/to/bin/ary
9359:
9360: /path/to/bin/ary: file format elf64-x86-64
9361:
9362: Program Header:
9363: [...]
9364: RELRO off 0x0000000000000d78 vaddr 0x0000000000600d78 paddr 0x0000000000600d78 align 2**0
9365:
9366: This check is now performed automatically if PKG_DEVELOPER is set and RELRO is
9367: enabled.
9368:
1.266 martin 9369: B.3.3. Checking for full RELRO
1.207 leot 9370:
9371: The dynamic loader will apply RELRO immediately when detecting the presence of
9372: the BIND_NOW flag:
9373:
9374: $ objdump -x /path/to/bin/ary
9375:
9376: /path/to/bin/ary: file format elf64-x86-64
9377:
9378: Dynamic Section:
9379: [...]
9380: BIND_NOW 0x0000000000000000
9381:
9382: This has to be combined with partial RELRO (see above) to be fully efficient.
9383:
9384: This check is now performed automatically (where supported) if PKG_DEVELOPER is
9385: set.
9386:
1.266 martin 9387: B.3.4. Checking for SSP
1.207 leot 9388:
1.208 nia 9389: Note
9390:
9391: Checking for SSP using this method only works where the operating system uses
9392: libssp. libssp is not used on recent NetBSD/FreeBSD/Linux versions.
9393:
1.207 leot 9394: Building objects, binaries and libraries with SSP will affect the presence of
9395: additional symbols in the resulting file:
9396:
9397: $ nm /path/to/bin/ary
9398: [...]
9399: U __stack_chk_fail
9400: 0000000000600ea0 B __stack_chk_guard
9401:
9402: This is an indicator that the program was indeed built with support for SSP.
9403:
9404: This check is now performed automatically (where supported) if PKG_DEVELOPER is
9405: set and SSP is enabled.
9406:
1.266 martin 9407: Appendix C. Build logs
1.1 dsieger 9408:
9409: Table of Contents
9410:
1.207 leot 9411: C.1. Building figlet
9412: C.2. Packaging figlet
1.1 dsieger 9413:
1.266 martin 9414: C.1. Building figlet
1.1 dsieger 9415:
9416: # make
9417: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9418: => figlet221.tar.gz doesn't seem to exist on this system.
9419: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
9420: => [172219 bytes]
9421: Connected to ftp.plig.net.
9422: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
9423: 331 Guest login ok, send your complete e-mail address as password.
9424: 230-You are user #5 of 500 simultaneous users allowed.
9425: 230-
9426: 230- ___ _ _ _
9427: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
9428: 230- | _| _| . |_| . | | | . |_| . | _| . |
9429: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
9430: 230- |_| |_| |___| |___|
9431: 230-
9432: 230-** Welcome to ftp.plig.org **
9433: 230-
9434: 230-Please note that all transfers from this FTP site are logged. If you
9435: 230-do not like this, please disconnect now.
9436: 230-
1.19 snj 9437: 230-This archive is available via
1.1 dsieger 9438: 230-
9439: 230-HTTP: http://ftp.plig.org/
9440: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
9441: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
9442: 230-
9443: 230-Please email comments, bug reports and requests for packages to be
9444: 230-mirrored to ftp-admin@plig.org.
9445: 230-
9446: 230-
9447: 230 Logged in anonymously.
9448: Remote system type is UNIX.
9449: Using binary mode to transfer files.
9450: 200 Type okay.
9451: 250 "/pub" is new cwd.
9452: 250-"/pub/figlet" is new cwd.
9453: 250-
9454: 250-Welcome to the figlet archive at ftp.figlet.org
9455: 250-
9456: 250- ftp://ftp.figlet.org/pub/figlet/
9457: 250-
9458: 250-The official FIGlet web page is:
9459: 250- http://www.figlet.org/
9460: 250-
9461: 250-If you have questions, please mailto:info@figlet.org. If you want to
9462: 250-contribute a font or something else, you can email us.
9463: 250
9464: 250 "/pub/figlet/program" is new cwd.
9465: 250 "/pub/figlet/program/unix" is new cwd.
9466: local: figlet221.tar.gz remote: figlet221.tar.gz
9467: 502 Unimplemented command.
9468: 227 Entering Passive Mode (195,40,6,41,246,104)
9469: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
9470: 38% |************** | 65800 64.16 KB/s 00:01 ETA
9471: 226 Transfer completed.
9472: 172219 bytes received in 00:02 (75.99 KB/s)
9473: 221 Goodbye.
9474: => Checksum OK for figlet221.tar.gz.
9475: ===> Extracting for figlet-2.2.1nb2
9476: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
9477: ===> Patching for figlet-2.2.1nb2
9478: ===> Applying pkgsrc patches for figlet-2.2.1nb2
9479: ===> Overriding tools for figlet-2.2.1nb2
9480: ===> Creating toolchain wrappers for figlet-2.2.1nb2
9481: ===> Configuring for figlet-2.2.1nb2
9482: ===> Building for figlet-2.2.1nb2
9483: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
9484: chmod a+x figlet
9485: gcc -O2 -o chkfont chkfont.c
9486: => Unwrapping files-to-be-installed.
9487: #
9488: # make install
9489: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9490: ===> Installing for figlet-2.2.1nb2
9491: install -d -o root -g wheel -m 755 /usr/pkg/bin
9492: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
9493: mkdir -p /usr/pkg/share/figlet
9494: cp figlet /usr/pkg/bin
9495: cp chkfont /usr/pkg/bin
9496: chmod 555 figlist showfigfonts
9497: cp figlist /usr/pkg/bin
9498: cp showfigfonts /usr/pkg/bin
9499: cp fonts/*.flf /usr/pkg/share/figlet
9500: cp fonts/*.flc /usr/pkg/share/figlet
9501: cp figlet.6 /usr/pkg/man/man6
9502: ===> Registering installation for figlet-2.2.1nb2
9503: #
9504:
1.266 martin 9505: C.2. Packaging figlet
1.1 dsieger 9506:
9507: # make package
9508: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9509: ===> Packaging figlet-2.2.1nb2
9510: ===> Building binary package for figlet-2.2.1nb2
9511: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
9512: Using SrcDir value of /usr/pkg
9513: Registering depends:.
9514: #
9515:
1.266 martin 9516: Appendix D. Directory layout of the pkgsrc FTP server
1.1 dsieger 9517:
9518: Table of Contents
9519:
1.207 leot 9520: D.1. distfiles: The distributed source files
9521: D.2. misc: Miscellaneous things
9522: D.3. packages: Binary packages
9523: D.4. reports: Bulk build reports
9524: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1 dsieger 9525:
9526: As in other big projects, the directory layout of pkgsrc is quite complex for
9527: newbies. This chapter explains where you find things on the FTP server. The
9528: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
9529: different, but inside this directory, everything should look the same, no
9530: matter on which server you are. This directory contains some subdirectories,
9531: which are explained below.
9532:
1.266 martin 9533: D.1. distfiles: The distributed source files
1.1 dsieger 9534:
9535: The directory distfiles contains lots of archive files from all pkgsrc
9536: packages, which are mirrored here. The subdirectories are called after their
9537: package names and are used when the distributed files have names that don't
9538: explicitly contain a version number or are otherwise too generic (for example
9539: release.tar.gz).
9540:
1.266 martin 9541: D.2. misc: Miscellaneous things
1.1 dsieger 9542:
9543: This directory contains things that individual pkgsrc developers find worth
9544: publishing.
9545:
1.266 martin 9546: D.3. packages: Binary packages
1.1 dsieger 9547:
1.3 rillig 9548: This directory contains binary packages for the various platforms that are
9549: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
9550: The meaning of these variables is:
9551:
9552: * OPSYS is the name of the operating system for which the packages have been
1.9 rillig 9553: built. The name is taken from the output of the uname command, so it may
9554: differ from the one you are used to hear.
1.3 rillig 9555:
1.8 rillig 9556: * ARCH is the hardware architecture of the platform for which the packages
1.10 hubertf 9557: have been built. It also includes the ABI (Application Binary Interface)
9558: for platforms that have several of them.
1.3 rillig 9559:
1.255 wiz 9560: * OSVERSION is the version of the operating system. Typically it is the
9561: version defining an ABI, e.g. 9.0.
9562:
9563: * TAG is either 20YYQN for a stable branch, or current for packages built
9564: from the HEAD branch. The latter should only be used when the packages are
9565: updated on a regular basis.
9566:
9567: The rationale for this scheme is that users can first search by OPSYS and ARCH,
9568: since these are more or less unchangeable. After that, there is a management
9569: set of directories with OSVERSION and TAG.
9570:
9571: See also README.md in packages for more details, including about symlinks.
1.3 rillig 9572:
9573: In each of these directories, there is a whole binary packages collection for a
9574: specific platform. It has a directory called All which contains all binary
1.255 wiz 9575: packages.
1.1 dsieger 9576:
1.266 martin 9577: D.4. reports: Bulk build reports
1.8 rillig 9578:
9579: Here are the reports from bulk builds, for those who want to fix packages that
9580: didn't build on some of the platforms. The structure of subdirectories should
1.266 martin 9581: look like the one in Section D.3, packages: Binary packages .
1.8 rillig 9582:
1.266 martin 9583: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1 dsieger 9584:
1.266 martin 9585: These directories contain the real pkgsrc, that is the files that define how
1.1 dsieger 9586: to create binary packages from source archives.
9587:
1.149 leot 9588: Each of the current, stable and pkgsrc-20xxQy directories share the same
9589: structure. They each contain a pkgsrc directory and pkgsrc.tar.{bz,gz,xz} file.
9590:
1.1 dsieger 9591: The directory pkgsrc contains a snapshot of the CVS repository, which is
1.149 leot 9592: updated regularly. The file pkgsrc.tar.{bz,gz,xz} contains the same as the
9593: directory, ready to be downloaded as a whole.
1.1 dsieger 9594:
1.149 leot 9595: The current directory contains files related to the HEAD branch of the CVS
9596: repository. In this directory there is an additional file called
9597: pkgsrc-readmes.tar.{bz,gz,xz} that contains all pkgsrc READMEs with information
9598: about categories and packages.
9599:
9600: The stable directory is a symlink to the latest pkgsrc-20xxQy.
9601:
9602: The pkgsrc-20xxQy. directories contain files related to the -20xxQy stable
9603: branch of the CVS repository. In these directories there is an additional file
9604: called pkgsrc-20xxQy.tar.{bz,gz,xz}, which contains the state of pkgsrc when it
9605: was branched.
1.148 leot 9606:
1.266 martin 9607: Appendix E. Help topics
1.154 rillig 9608:
9609: The following list contains all help topics that are available when running
9610: bmake help topic=:index.
9611:
1.273 wiz 9612: #! -lintl
9613: 32bit 64bit
9614: ABI ACCEPTABLE_LICENSES
9615: ACROREAD_FONTPATH AFAIK
9616: AIX ALLOW_NETWORK_ACCESS
9617: ALLOW_NEWER_COMPILER ALLOW_VULNERABLE_PACKAGES
9618: ALL_ENV ALSA_PC
9619: ALTERNATIVES_SRC AMANDA_TMP
9620: AMANDA_USER AMANDA_VAR
9621: APACHE_GROUP APACHE_MODULE_NAME
9622: APACHE_MODULE_SRC APACHE_MODULE_SRCDIR
9623: APACHE_PKG_PREFIX APACHE_SUEXEC_CONFIGURE_ARGS
9624: APACHE_SUEXEC_DOCROOT APACHE_USER
9625: ARGMAX_REQ ARG_MAX
9626: ARLA_CACHE AUDIT_PACKAGES_FLAGS
9627: AUTOCONF_REQD AUTOMAKE_OVERRIDE
9628: AUTOMAKE_REQD AUTO_MKDIRS
9629: AUX BDB185_DEFAULT
9630: BDBBASE BDB_ACCEPTED
9631: BDB_DEFAULT BDB_LIBS
9632: BDB_TYPE BINCIMAP_GROUP
9633: BINCIMAP_LOG_USER BINCIMAP_USER
9634: BIND_DIR BIND_GROUP
9635: BIND_USER BINOWN
9636: BINPKG_SITES BIN_INSTALL_FLAGS
9637: BISON_PKGDATADIR BLAS
9638: BLAS_ACCEPTED BLAS_C_INTERFACE
9639: BLAS_INCLUDES BLAS_INDEX64
9640: BLAS_LIBS BLAS_PC
9641: BLAS_TYPE BOOTSTRAP_DEPENDS
9642: BROKEN BROKEN_EXCEPT_ON_PLATFORM
9643: BROKEN_ON_PLATFORM BSDSRCDIR
9644: BSD_MAKE_ENV BUILDLINK_AUTO_DIRS
9645: BUILDLINK_AUTO_VARS BUILDLINK_CFLAGS
9646: BUILDLINK_CONTENTS_FILTER BUILDLINK_CPPFLAGS
9647: BUILDLINK_DEPMETHOD BUILDLINK_FILES
9648: BUILDLINK_FILES_CMD BUILDLINK_FNAME_TRANSFORM
9649: BUILDLINK_LDFLAGS BUILDLINK_LIBS
9650: BUILDLINK_OPSYS_SUPPORT_PTHREAD BUILDLINK_PKGNAME
9651: BUILDLINK_PREFIX BUILDLINK_RPATHDIRS
9652: BUILDLINK_TREE BUILD_DEFS
9653: BUILD_DEFS_EFFECTS BUILD_DEPENDS
9654: BUILD_DIRS BUILD_ENV_SHELL
9655: BUILD_MAKE_CMD BUILD_MAKE_FLAGS
9656: BUILD_TARGET BUILTIN_FIND_FILES
9657: BUILTIN_FIND_FILES_VAR BUILTIN_FIND_GREP
9658: BUILTIN_FIND_HEADERS BUILTIN_FIND_HEADERS_VAR
9659: BUILTIN_FIND_PKGCONFIG BUILTIN_FIND_PKGCONFIG_VAR
9660: BUILTIN_PKG BUILTIN_TEST_CURSES_DEFINES
9661: BUILTIN_TEST_CURSES_FUNCS BUILTIN_VERSION_SCRIPT
9662: BUILTIN_X11_TYPE BUILTIN_X11_VERSION
9663: CACTI_GROUP CACTI_USER
9664: CANNA_GROUP CANNA_USER
9665: CAT CBLAS_LIBS
9666: CBLAS_PC CCACHE_BASE
9667: CCACHE_DIR CCACHE_LOGFILE
9668: CCACHE_RECACHE CC_VERSION
9669: CDRECORD_CONF CDROM_PKG_URL_DIR
9670: CDROM_PKG_URL_HOST CHANGES
9671: CHECKOUT_DATE CHECK_COMPILER
9672: CHECK_FAKEHOME CHECK_FILES
9673: CHECK_FILES_ONLY_PREFIX CHECK_FILES_SKIP
9674: CHECK_FILES_STRICT CHECK_HEADERS
9675: CHECK_HEADERS_SKIP CHECK_INTERPRETER
9676: CHECK_INTERPRETER_SKIP CHECK_PERMS
9677: CHECK_PERMS_AUTOFIX CHECK_PERMS_SKIP
9678: CHECK_PIE CHECK_PIE_SKIP
9679: CHECK_PIE_SUPPORTED CHECK_PORTABILITY
9680: CHECK_PORTABILITY_EXPERIMENTAL CHECK_PORTABILITY_SKIP
9681: CHECK_RELRO CHECK_RELRO_SKIP
9682: CHECK_RELRO_SUPPORTED CHECK_SHLIBS
9683: CHECK_SHLIBS_SKIP CHECK_SHLIBS_SUPPORTED
9684: CHECK_SHLIBS_TOXIC CHECK_SSP
9685: CHECK_SSP_SKIP CHECK_SSP_SUPPORTED
9686: CHECK_STRIPPED CHECK_STRIPPED_SKIP
9687: CHECK_WRKREF CHECK_WRKREF_EXTRA_DIRS
9688: CHECK_WRKREF_SKIP CLAMAV_DBDIR
9689: CLAMAV_GROUP CLAMAV_USER
9690: CLANGBASE CLEANDEPENDS
9691: CLT CMAKE_DEPENDENCIES_REWRITE
9692: CMAKE_INSTALL_NAME_DIR CMAKE_INSTALL_PREFIX
9693: CMAKE_MODULE_PATH_OVERRIDE CMAKE_PKGSRC_BUILD_FLAGS
9694: CMAKE_PREFIX_PATH CMAKE_USE_GNU_INSTALL_DIRS
9695: COMMON_LISP_DOCFILES COMMON_LISP_EXAMPLES
9696: COMMON_LISP_EXTRAFILES COMMON_LISP_PACKAGES
9697: COMMON_LISP_SYSTEM COMPILER_RPATH_FLAG
9698: COMPILER_USE_SYMLINKS CONFIGURE_ARGS
9699: CONFIGURE_DIRS CONFIGURE_ENV
9700: CONFIGURE_ENV_SHELL CONFIGURE_HAS_INFODIR
9701: CONFIGURE_HAS_MANDIR CONFIGURE_SCRIPT
9702: CONFIG_SHELL CONFIG_SHELL_FLAGS
9703: CONF_FILES CONF_FILES_MODE
9704: CONF_FILES_PERMS CONSERVER_DEFAULTHOST
9705: CONSERVER_DEFAULTPORT CP
9706: CPE CPE_EDITION
9707: CPE_LANG CPE_OTHER
9708: CPE_PART CPE_PRODUCT
9709: CPE_SW_EDITION CPE_TARGET_HW
9710: CPE_TARGET_SW CPE_UPDATE
9711: CPE_URI CPE_VENDOR
9712: CPE_VERSION CPP
9713: CPP_PRECOMP_FLAGS CREATE_WRKDIR_SYMLINK
9714: CROSSBASE CTFCONVERT
9715: CTF_FILES_SKIP CTF_SUPPORTED
9716: CTYPE CUPS_GROUP
9717: CUPS_SYSTEM_GROUPS CUPS_USER
9718: CURSES_DEFAULT CURSES_TYPE
9719: CVS_EXTRACTDIR CVS_MODULE
9720: CVS_PROJECT CVS_REPOSITORIES
9721: CVS_ROOT CVS_ROOT_GNU
9722: CVS_ROOT_NONGNU CVS_ROOT_SOURCEFORGE
9723: CVS_TAG CYRUS_GROUP
9724: CYRUS_IDLE CYRUS_USER
9725: DAEMONTOOLS_GROUP DAEMONTOOLS_LOG_USER
9726: DARWIN_NO_SYSTEM_LIBS DARWIN_REQUIRES_FILTER
9727: DBUS_GROUP DBUS_USER
9728: DEFANG_GROUP DEFANG_USER
9729: DEFAULT_ACCEPTABLE_LICENSES DEFAULT_DISTFILES
9730: DEFAULT_IRC_SERVER DEFAULT_SERIAL_DEVICE
9731: DEF_UMASK DEINSTALLDEPENDS
9732: DEINSTALL_SRC DEINSTALL_TEMPLATES
9733: DELAYED_ERROR_MSG DELAYED_WARNING_MSG
9734: DEPENDS DEPENDS_TARGET
9735: DEPENDS_TYPE DESTDIR
9736: DESTDIR_VARNAME DIALER_GROUP
9737: DIGEST_REQD DISTDIR
9738: DISTFILES DISTINFO_FILE
9739: DISTNAME DIST_PATH
9740: DIST_SUBDIR DJBDNS_AXFR_USER
9741: DJBDNS_CACHE_USER DJBDNS_DJBDNS_GROUP
9742: DJBDNS_LOG_USER DJBDNS_RBL_USER
9743: DJBDNS_TINY_USER DLOPEN_REQUIRE_PTHREADS
9744: DL_AUTO_VARS DL_CFLAGS
9745: DL_LDFLAGS DL_LIBS
9746: DNS DOCOWN
9747: DOWNLOADED_DISTFILE DQCACHE_GROUP
9748: DQCACHE_USER DT_LAYOUT
9749: DYNAMIC_SITES_CMD DYNAMIC_SITES_SCRIPT
9750: ECHO ECHO_N
9751: ELK_GUI EMACS_TYPE
9752: EMULDIR EMULSUBDIR
9753: EMULSUBDIRSLASH EMUL_ARCH
9754: EMUL_DISTRO EMUL_EXEC_FMT
9755: EMUL_IS_NATIVE EMUL_MODULES
9756: EMUL_OPSYS EMUL_PKG_FMT
9757: EMUL_PLATFORM EMUL_PLATFORMS
9758: EMUL_PREFER EMUL_REQD
9759: EMUL_TYPE ERROR_MSG
9760: EXIM_GROUP EXIM_USER
9761: EXPORT_SYMBOLS_LDFLAGS EXTRACTOR
9762: EXTRACT_CMD EXTRACT_CMD_DEFAULT
9763: EXTRACT_DIR EXTRACT_ELEMENTS
9764: EXTRACT_ENV EXTRACT_ONLY
9765: EXTRACT_OPTS EXTRACT_SUFX
9766: EXTRACT_USING FAIL
9767: FAILOVER_FETCH FAIL_MSG
9768: FAKE_NCURSES FAM
9769: FAM_ACCEPTED FAM_DEFAULT
9770: FAM_SERVER FCPATH
9771: FETCH_AFTER_ARGS FETCH_BEFORE_ARGS
9772: FETCH_CMD FETCH_INSECURE
9773: FETCH_OUTPUT_ARGS FETCH_PROXY
9774: FETCH_RESUME_ARGS FETCH_TIMEOUT
9775: FETCH_USE_IPV4_ONLY FETCH_USING
9776: FILES_SUBST FILES_SUBST_SED
9777: FIX_SYSTEM_HEADERS FONTDIR
9778: FONTS_DIRS FONTS_VERBOSE
9779: FOO_HACKS_MK FORCE_CXX_STD
9780: FORCE_C_STD FOSSIL_EXTRACTDIR
9781: FOSSIL_REPO FOSSIL_REPOSITORIES
9782: FOSSIL_VERSION FOX_USE_XUNICODE
9783: FREEWNN_GROUP FREEWNN_USER
9784: FTP_PKG_URL_DIR FTP_PKG_URL_HOST
9785: GAMEDATAMODE GAMEDATA_PERMS
9786: GAMEDIRMODE GAMEDIR_PERMS
9787: GAMEGRP GAMEMODE
9788: GAMEOWN GAMES_GROUP
9789: GAMES_USER GCC
9790: GCCBASE GCC_REQD
9791: GCC_VERSION_SUFFIX GEM_BUILD
9792: GEM_CLEANBUILD GEM_CLEANBUILD_EXTENSIONS
9793: GEM_DOCDIR GEM_EXTSDIR
9794: GEM_HOME GEM_KEEPBUILD
9795: GEM_LIBDIR GEM_NAME
9796: GEM_PATH GEM_PLUGINSDIR
9797: GEM_SPECFILE GENERATE_PLIST
9798: GHC GHOSTSCRIPT_REQD
9799: GITHUB_PROJECT GITHUB_RELEASE
9800: GITHUB_SUBMODULES GITHUB_TAG
9801: GITHUB_TYPE GITLAB_PROJECT
9802: GITLAB_RELEASE GITLAB_SUBMODULES
9803: GITLAB_TAG GITLAB_TYPE
9804: GIT_BRANCH GIT_ENV
9805: GIT_EXTRACTDIR GIT_REPO
9806: GIT_REPOSITORIES GIT_REVISION
9807: GIT_TAG GNAT
9808: GNU GNU_CONFIGURE
9809: GNU_CONFIGURE_ICONV GNU_CONFIGURE_INFODIR
9810: GNU_CONFIGURE_MANDIR GNU_CONFIGURE_QUIET
9811: GNU_CONFIGURE_STRICT GOFLAGS
9812: GO_BUILD_PATTERN GO_DIST_BASE
9813: GO_EXTRA_MOD_DIRS GO_MODULE_EXTRACT
9814: GO_MODULE_FILES GO_SRCPATH
9815: GROUP_SPECIFIC_PKGS GRUB_NETWORK_CARDS
9816: GRUB_PRESET_COMMAND GRUB_SCAN_ARGS
9817: GZIP HASKELL_COMPILER
9818: HASKELL_DISABLE_EXECUTABLES HASKELL_DISABLE_LIBRARIES
9819: HASKELL_ENABLE_DYNAMIC_EXECUTABLE HASKELL_ENABLE_HADDOCK_DOCUMENTATION
9820: HASKELL_ENABLE_LIBRARY_PROFILING HASKELL_ENABLE_SHARED_LIBRARY
9821: HASKELL_ENABLE_TESTS HASKELL_OPTIMIZATION_LEVEL
9822: HASKELL_PKG_NAME HASKELL_UNRESTRICT_DEPENDENCIES
9823: HEADER_TEMPLATES HG_REPO
9824: HG_REPOSITORIES HG_TAG
9825: HOMEPAGE HOST_PKGTOOLS_ARGS
9826: HOST_SPECIFIC_PKGS HOWL_GROUP
9827: HOWL_USER ICCBASE
9828: ICECAST_CHROOTDIR ICON_THEMES
9829: IDOBASE IGNORE_CCACHE
9830: IGNORE_INFO_DIRS IGNORE_INTERACTIVE_FETCH
9831: IMAKE IMAKEOPTS
9832: IMAKE_MAKE IMAKE_MANINSTALL
9833: IMAP_UW_CCLIENT_MBOX_FMT IMDICTDIR
9834: INCOMPAT_CURSES INFO_DIR
9835: INFO_FILES INFO_MSG
9836: INIT_SYSTEM INN_DATA_DIR
9837: INN_GROUP INN_USER
9838: INSTALLATION_DIRS INSTALLATION_DIRS_FROM_PLIST
9839: INSTALL_ENV INSTALL_ENV_SHELL
9840: INSTALL_SH_OVERRIDE INSTALL_SRC
9841: INSTALL_TEMPLATES INSTALL_UNSTRIPPED
9842: IRCD_HYBRID_IRC_GROUP IRCD_HYBRID_IRC_USER
9843: IRCD_HYBRID_MAXCONN IRCD_HYBRID_NICLEN
9844: IRCD_HYBRID_SYSLOG_EVENTS IRCD_HYBRID_SYSLOG_FACILITY
9845: IRCD_HYBRID_TOPICLEN IRIX
9846: IRRD_USE_PGP JABBERD_GROUP
9847: JABBERD_LOGDIR JABBERD_PIDDIR
9848: JABBERD_SPOOLDIR JABBERD_USER
9849: JAVA_APP_PATH JAVA_APP_TARGETS
9850: JAVA_BINPREFIX JAVA_CLASSPATH
9851: JAVA_HOME JAVA_LD_LIBRARY_PATH
9852: JAVA_NAME JAVA_UNLIMIT
9853: JAVA_WRAPPERS JPEG_ACCEPTED
9854: JPEG_DEFAULT KERBEROS
9855: KERMIT_SUID_UUCP KJS_USE_PCRE
9856: KNEWS_DOMAIN_FILE KNEWS_DOMAIN_NAME
9857: KRB5_ACCEPTED KRB5_DEFAULT
9858: LANGUAGES LAPACKE_LIBS
9859: LAPACKE_PC LAPACK_LIBS
9860: LAPACK_PC LATEX2HTML_ICONPATH
9861: LDCONFIG_ADD_CMD LDCONFIG_REMOVE_CMD
9862: LDD LEAFNODE_DATA_DIR
9863: LEAFNODE_GROUP LEAFNODE_USER
9864: LIBDVDCSS_HOMEPAGE LIBDVDCSS_MASTER_SITES
9865: LIBIMAGEQUANT_TYPE LIBRSVG_TYPE
9866: LIBTOOL LIBTOOLIZE_PLIST
9867: LIBTOOL_M4_OVERRIDE LIBUSB_TYPE
9868: LICENSE LINKER_RPATH_FLAG
9869: LINK_RPATH_FLAG LINUX_BASE_NODEPS
9870: LINUX_BASE_PREFERRED LINUX_BASE_REQUIRED
9871: LINUX_LOCALES LOCALBASE
9872: LOCALBASE_LOCKTYPE LOCALPATCHES
9873: LOVE_DATA LOVE_GAME
9874: LOVE_VERSION LOWER_OPSYS
9875: LOWER_OPSYS_VERSUFFIX LOWER_VARIANT_VERSION
9876: LOWER_VENDOR LP32PLATFORMS
9877: LP64PLATFORMS LUA_BUSTED_ARGS
9878: LUA_CDIR LUA_COMPILER
9879: LUA_DOCDIR LUA_EXAMPLESDIR
9880: LUA_INCDIR LUA_INTERPRETER
9881: LUA_LDIR LUA_LINKER_MAGIC
9882: LUA_PKGPREFIX LUA_SELF_CONFLICT
9883: LUA_USE_BUSTED LUA_VERSIONS_ACCEPTED
9884: LUA_VERSIONS_INCOMPATIBLE LUA_VERSION_DEFAULT
9885: LUA_VERSION_REQD Lua
9886: MACHINE_PLATFORM MAILAGENT_DOMAIN
9887: MAILAGENT_EMAIL MAILAGENT_FQDN
9888: MAILAGENT_ORGANIZATION MAJORDOMO_HOMEDIR
9889: MAJOR_OS_VERSION MAKEINFO_ARGS
9890: MAKE_DIRS MAKE_DIRS_PERMS
9891: MAKE_ENV MAKE_FILE
9892: MAKE_FLAGS MAKE_JOBS
9893: MAKE_JOBS_SAFE MAKE_PROGRAM
9894: MANCOMPRESSED_IF_MANZ MANINSTALL
9895: MANZ MARIADB_VERSIONS_ALL
9896: MASTER_SITES MASTER_SITE_BACKUP
9897: MASTER_SITE_LOCAL MASTER_SITE_MOZILLA
9898: MASTER_SITE_OVERRIDE MASTER_SITE_PERL_CPAN
9899: MASTER_SORT MASTER_SORT_RANDOM
9900: MASTER_SORT_REGEX MECAB_CHARSET
9901: MEDIATOMB_GROUP MEDIATOMB_USER
9902: MIPSPROBASE MIREDO_GROUP
9903: MIREDO_USER MISSING_FEATURES
9904: MKDIR MKPIE_SUPPORTED
9905: MLDONKEY_GROUP MLDONKEY_HOME
9906: MLDONKEY_USER MONOTONE_GROUP
9907: MONOTONE_USER MOTIFBASE
9908: MOTIF_TYPE MOTIF_TYPE_DEFAULT
9909: MPI_TYPE MSGFMT_STRIP_MSGCTXT
9910: MSGFMT_STRIP_MSGID_PLURAL MTOOLS_ENABLE_FLOPPYD
9911: MUST MV
9912: MYSQL_CHARSET MYSQL_DATADIR
9913: MYSQL_EXTRA_CHARSET MYSQL_GROUP
9914: MYSQL_USER MYSQL_VERSION
9915: MYSQL_VERSIONS_ACCEPTED MYSQL_VERSION_DEFAULT
9916: NAGIOSCMD_GROUP NAGIOSDIR
9917: NAGIOS_GROUP NAGIOS_USER
9918: NATIVE_EXEC_FMT NATIVE_LOWER_OPSYS
9919: NATIVE_LOWER_VENDOR NATIVE_MACHINE_PLATFORM
9920: NATIVE_OBJECT_FMT NATIVE_OPSYS_VERSION
9921: NATIVE_OS_VARIANT NATIVE_OS_VERSION
9922: NBPAX_PROGRAM_PREFIX NETBSD_LOGIN_NAME
9923: NMH_EDITOR NMH_MTA
9924: NMH_PAGER NODE_VERSIONS_ACCEPTED
9925: NODE_VERSIONS_INCOMPATIBLE NODE_VERSION_DEFAULT
9926: NODE_VERSION_REQD NOLOGIN
9927: NOTE NOT_FOR_PLATFORM
9928: NOT_PAX_ASLR_SAFE NOT_PAX_MPROTECT_SAFE
9929: NO_BUILD NO_CHECKSUM
9930: NO_CONFIGURE NO_SKIP
9931: NSD_GROUP NSD_LOG_FACILITY
9932: NSD_USER NS_PREFERRED
9933: NULLMAILER_GROUP NULLMAILER_USER
9934: OBJECT_FMT OBJHOSTNAME
9935: OBJMACHINE OCAML_FINDLIB_DIRS
9936: OCAML_FINDLIB_REGISTER OCAML_FINDLIB_REGISTER_VERBOSE
9937: OCAML_SITELIBDIR OMF
9938: ONLY_FOR_COMPILER ONLY_FOR_PLATFORM
9939: OPENSSH_CHROOT OPENSSH_GROUP
9940: OPENSSH_USER OPSYS
9941: OPSYS_EMULDIR OPSYS_VERSION
9942: OS OSS_TYPE
9943: OSX OSX_PATH_TO_M4
9944: OSX_PATH_TO_YACC OS_HAVE_ALSA
9945: OS_HAVE_RCD OS_VARIANT
9946: OS_VERSION OTF_FONTS_DIR
9947: OVERRIDE_DIRDEPTH OVERRIDE_GEMSPEC
9948: OVERRIDE_GNU_CONFIG_SCRIPTS OVERRIDE_ROCKSPEC
9949: OWN_DIRS OWN_DIRS_PERMS
9950: P4GROUP P4PORT
9951: P4ROOT P4USER
9952: PACKAGES PALMOS_DEFAULT_SDK
9953: PAMBASE PAM_DEFAULT
9954: PAPERSIZE PASSIVE_FETCH
9955: PATCHDIR PATCHFILES
9956: PATCH_ARGS PATCH_DEBUG
9957: PATCH_DIST_ARGS PATCH_DIST_CAT
9958: PATCH_DIST_STRIP PATCH_FUZZ_FACTOR
9959: PATCH_STRIP PATH
9960: PCCBASE PEAR
9961: PEAR_CHANNEL PEAR_CHANNEL_ALIAS
9962: PEAR_CHANNEL_VERSION PEAR_CMD
9963: PEAR_LIB PEAR_PACKAGE_XML
9964: PEP-518 PERL5
9965: PERL5_CONFIGURE PERL5_CONFIGURE_DIRS
9966: PERL5_LDFLAGS PERL5_LICENSE
9967: PERL5_MODULE_TYPE PERL5_PACKLIST
9968: PERL5_PACKLIST_DIR PERL5_PERLBASE
9969: PERL5_SITEBASE PERL5_USE_PACKLIST
9970: PERL5_VENDORBASE PFCTL
9971: PFVAR_H PF_VERSION
9972: PGGROUP PGHOME
9973: PGPKGSRCDIR PGSQL_TYPE
9974: PGSQL_VERSION PGSQL_VERSIONS_ACCEPTED
9975: PGSQL_VERSION_DEFAULT PGUSER
9976: PG_LIB_EXT PHP
9977: PHPCOMMON_MK PHPPKGSRCDIR
9978: PHP_BASE_VERS PHP_EGDIR
9979: PHP_EXTENSION_DIR PHP_INCDIR
9980: PHP_LIBDIR PHP_MAJOR_VERS
9981: PHP_MINIMUM_TEENY PHP_MINOR_VERS
9982: PHP_PKG_PREFIX PHP_SHAREDIR
9983: PHP_VER PHP_VERSION
9984: PHP_VERSIONS_ACCEPTED PHP_VERSIONS_INCOMPATIBLE
9985: PHP_VERSION_DEFAULT PHP_VERSION_REQD
9986: PILRC_USE_GTK PKGCONFIG_BASE
9987: PKGCONFIG_FILE PKGCONFIG_OVERRIDE
9988: PKGCONFIG_OVERRIDE_STAGE PKGDIR
9989: PKGGNUDIR PKGINFODIR
9990: PKGLOCALEDIR PKGMANDIR
9991: PKGNAME PKGNAME_REQD
9992: PKGPATH PKGREVISION
9993: PKGSRC_BLAS_TYPES PKGSRC_CHANGES
9994: PKGSRC_COMPILER PKGSRC_KEEP_BIN_PKGS
9995: PKGSRC_LOCKTYPE PKGSRC_MAKE_ENV
9996: PKGSRC_MESSAGE_RECIPIENTS PKGSRC_MKPIE
9997: PKGSRC_MKREPRO PKGSRC_OVERRIDE_MKPIE
9998: PKGSRC_RUN_TEST PKGSRC_SETENV
9999: PKGSRC_SLEEPSECS PKGSRC_TODO
10000: PKGSRC_USE_CTF PKGSRC_USE_FORTIFY
10001: PKGSRC_USE_MKTOOLS PKGSRC_USE_RELRO
10002: PKGSRC_USE_SSP PKGSRC_USE_STACK_CHECK
10003: PKGTASKS_DATAFILE PKGTOOLS_ARGS
10004: PKGTOOLS_ENV PKG_ALTERNATIVES
10005: PKG_APACHE PKG_APACHE_ACCEPTED
10006: PKG_APACHE_DEFAULT PKG_BEST_EXISTS
10007: PKG_BUILD_OPTIONS PKG_COMPRESSION
10008: PKG_CONFIG PKG_CONFIG_PERMS
10009: PKG_CREATE_USERGROUP PKG_DBDIR
10010: PKG_DB_TMPDIR PKG_DEBUG_LEVEL
10011: PKG_DEFAULT_OPTIONS PKG_DESTDIR_SUPPORT
10012: PKG_DEVELOPER PKG_DISABLED_OPTIONS
10013: PKG_FATAL_ERRORS PKG_FC
10014: PKG_FILELIST_CMD PKG_GECOS
10015: PKG_GID PKG_GROUPS
10016: PKG_GROUPS_VARS PKG_HOME
10017: PKG_INIT_SCRIPTS PKG_JAVA_HOME
10018: PKG_JVM PKG_JVMS_ACCEPTED
10019: PKG_JVM_DEFAULT PKG_LEGACY_OPTIONS
10020: PKG_LIBTOOL PKG_MKSYMLINKS
10021: PKG_OPTIONS PKG_OPTIONS_DEPRECATED_WARNINGS
10022: PKG_OPTIONS_LEGACY_OPTS PKG_OPTIONS_LEGACY_VARS
10023: PKG_OPTIONS_NONEMPTY_SETS PKG_OPTIONS_OPTIONAL_GROUPS
10024: PKG_OPTIONS_REQUIRED_GROUPS PKG_OPTIONS_VAR
10025: PKG_RCD_SCRIPTS PKG_REFCOUNT_DBDIR
10026: PKG_REGISTER_SHELLS PKG_RESUME_TRANSFERS
10027: PKG_SHELL PKG_SUGGESTED_OPTIONS
10028: PKG_SUPPORTED_OPTIONS PKG_SYSCONFBASE
10029: PKG_SYSCONFBASEDIR PKG_SYSCONFDIR
10030: PKG_SYSCONFDIR_PERMS PKG_SYSCONFSUBDIR
10031: PKG_SYSCONFVAR PKG_TOOLS_BIN
10032: PKG_UID PKG_UPDATE_FONTS_DB
10033: PKG_USERS PKG_USERS_VARS
10034: PKG_VERBOSE PLEASE
10035: PLIST PLIST_AWK
10036: PLIST_AWK_ENV PLIST_SRC
10037: PLIST_SUBST PLIST_TYPE
10038: PLIST_VARS POPTOP_USE_MPPE
10039: POSSIBLE_GFORTRAN_VERSION POST_FETCH_HOOK
10040: PREFER PREFER_NATIVE
10041: PREFER_NATIVE_PTHREADS PREFER_PKGSRC
10042: PREFIX PREPEND_PATH
10043: PRE_ROOT_CMD PRIVILEGED_STAGES
10044: PS PTHREAD_AUTO_VARS
10045: PTHREAD_CFLAGS PTHREAD_LDFLAGS
10046: PTHREAD_LIBS PTHREAD_OPTS
10047: PTHREAD_TYPE PVM_SSH
10048: PYPKGPREFIX PYSOABISUFFIX
10049: PYTHON_27_ACCEPTED PYTHON_FOR_BUILD_ONLY
10050: PYTHON_SELF_CONFLICT PYTHON_VERSION
10051: PYTHON_VERSIONED_DEPENDENCIES PYTHON_VERSIONS_ACCEPTED
10052: PYTHON_VERSIONS_INCOMPATIBLE PYTHON_VERSION_DEFAULT
10053: PYTHON_VERSION_REQD PYVERSSUFFIX
10054: QMAILDIR QMAIL_ALIAS_USER
10055: QMAIL_DAEMON_USER QMAIL_LOG_USER
10056: QMAIL_NOFILES_GROUP QMAIL_PASSWD_USER
10057: QMAIL_QMAIL_GROUP QMAIL_QUEUE_DIR
10058: QMAIL_QUEUE_EXTRA QMAIL_QUEUE_USER
10059: QMAIL_REMOTE_USER QMAIL_ROOT_USER
10060: QMAIL_SEND_USER QORE_LATEST_MODULE_API
10061: QORE_MODULE_API QORE_MODULE_DIR
10062: QORE_USER_MODULE_DIR QORE_VERSION
10063: QPOPPER_FAC QPOPPER_SPOOL_DIR
10064: QPOPPER_USER RAKE_NAME
10065: RASMOL_DEPTH RCD_DIR
10066: RCD_ORDER RCD_SCRIPTS
10067: RCD_SCRIPTS_DIR RCD_SCRIPTS_EXAMPLEDIR
10068: RCD_SCRIPTS_MODE RCD_SCRIPTS_SHELL
10069: RCD_SCRIPT_SRC RCD_SUBR
10070: RDOC READLINE_DEFAULT
10071: READLINE_TYPE REAL_ROOT_GROUP
10072: REAL_ROOT_USER RECURSIVE_MAKE
10073: RELAY_CTRL_DIR RELRO_SUPPORTED
10074: REPLACE_AWK REPLACE_BASH
10075: REPLACE_CSH REPLACE_KSH
10076: REPLACE_LUA REPLACE_NODEJS
10077: REPLACE_OCTAVE REPLACE_PERL
10078: REPLACE_PERL6 REPLACE_PHP
10079: REPLACE_PYTHON REPLACE_QORE
10080: REPLACE_R REPLACE_RUBY
10081: REPLACE_RUBY_DIRS REPLACE_RUBY_PAT
10082: REPLACE_SH REPLACE_TEXLUA
10083: REPLACE_TOOL_PYTHON REPLACE_WISH
10084: REQD_DIRS REQD_DIRS_PERMS
10085: REQD_FILES REQD_FILES_MODE
10086: REQD_FILES_PERMS RESOLV_AUTO_VARS
10087: RESOLV_LDFLAGS RESOLV_LIBS
10088: RM ROCKSPEC_NAME
10089: ROCKSPEC_SPECFILE ROOT_CMD
10090: ROOT_GROUP ROOT_USER
10091: RPCGEN RPM
10092: RPM2PKG_PLIST RPM2PKG_PREFIX
10093: RPM2PKG_STAGE RPM2PKG_STRIP
10094: RPM2PKG_SUBPREFIX RPMFILES
10095: RPMIGNOREPATH RPM_DB_PREFIX
10096: RSSH_CVS_PATH RSSH_RDIST_PATH
10097: RSSH_RSYNC_PATH RSSH_SCP_PATH
10098: RSSH_SFTP_SERVER_PATH RUBY
10099: RUBYGEM RUBYGEM_MANPAGES
10100: RUBYGEM_NAME RUBYGEM_OPTIONS
10101: RUBYGEM_USE_MANPAGES RUBYGEM_VERBOSE
10102: RUBY_ABI_VERSION RUBY_ALLOW_HAS_RDOC
10103: RUBY_ARCH RUBY_ARCHINC
10104: RUBY_ARCHLIB RUBY_BASE
10105: RUBY_BASERIDIR RUBY_BUILD_DOCUMENT
10106: RUBY_DLEXT RUBY_DOC
10107: RUBY_DYNAMIC_DIRS RUBY_EG
10108: RUBY_EXTCONF RUBY_EXTCONF_CHECK
10109: RUBY_EXTCONF_DEBUG RUBY_EXTCONF_MAKEFILE
10110: RUBY_GEM_ARCH RUBY_GEM_BASE
10111: RUBY_INC RUBY_LIB
10112: RUBY_LIB_BASE RUBY_NAME
10113: RUBY_NOVERSION RUBY_PKGPREFIX
1.276 ! wiz 10114: RUBY_RAILS RUBY_RAILS72_VERSION
! 10115: RUBY_RAILS80_VERSION RUBY_RAILS_ACCEPTED
! 10116: RUBY_RAILS_DEFAULT RUBY_RAILS_REQD
! 10117: RUBY_RAILS_STRICT_DEP RUBY_RIDIR
! 10118: RUBY_SETUP RUBY_SHLIB
! 10119: RUBY_SHLIBALIAS RUBY_SHLIBVER
! 10120: RUBY_SIMPLE_INSTALL RUBY_SITEARCHLIB
! 10121: RUBY_SITELIB RUBY_SITELIB_BASE
! 10122: RUBY_SITERIDIR RUBY_SLEXT
! 10123: RUBY_SRCDIR RUBY_STATICLIB
! 10124: RUBY_SUFFIX RUBY_SYSRIDIR
! 10125: RUBY_USE_PTHREAD RUBY_VENDORARCHLIB
! 10126: RUBY_VENDORLIB RUBY_VENDORLIB_BASE
! 10127: RUBY_VER RUBY_VERSION
! 10128: RUBY_VERSIONS_ACCEPTED RUBY_VERSIONS_INCOMPATIBLE
! 10129: RUBY_VERSION_DEFAULT RUBY_VERSION_REQD
! 10130: RUBY_VER_DIR RUN
! 10131: RUN_LDCONFIG RUST_TYPE
! 10132: SCO SCREWS_GROUP
! 10133: SCREWS_USER SCRIPTS_ENV
! 10134: SCROLLKEEPER_DATADIR SCROLLKEEPER_REBUILDDB
! 10135: SCROLLKEEPER_UPDATEDB SDIST_PAWD
! 10136: SDL12_TYPE SERIAL_DEVICES
! 10137: SETGIDGAME SETGID_GAMES_PERMS
! 10138: SETUID_ROOT_PERMS SH
! 10139: SHAIRPORT_GROUP SHAIRPORT_USER
! 10140: SHLIB_EXT SHORTNAME
! 10141: SIGN_PACKAGES SILC_CLIENT_WITH_PERL
! 10142: SITE_SPECIFIC_PKGS SKIP_DEPENDS
! 10143: SMF_INSTANCES SMF_MANIFEST
! 10144: SMF_METHODS SMF_METHOD_SHELL
! 10145: SMF_METHOD_SRC SMF_NAME
! 10146: SMF_PREFIX SMF_SRCDIR
! 10147: SNIPROXY_GROUP SNIPROXY_USER
! 10148: SOURCE_BUFFSIZE SPECIAL_PERMS
! 10149: SPECIFIC_PKGS SSH_SUID
! 10150: SSLCERTBUNDLE SSLCERTS
! 10151: SSLDIR SSLKEYS
! 10152: SSP_SUPPORTED SSYNC_PAWD
! 10153: STEP_MSG STRIP
! 10154: STRIP_DBG STRIP_DEBUG
! 10155: STRIP_DEBUG_SUPPORTED STRIP_FILES_SKIP
! 10156: SU SUBDIR
! 10157: SUBST SUBST_CLASSES
! 10158: SUBST_FILES SUBST_FILTER_CMD
! 10159: SUBST_MESSAGE SUBST_NOOP_OK
! 10160: SUBST_SED SUBST_SHOW_DIFF
! 10161: SUBST_SKIP_TEXT_CHECK SUBST_STAGE
! 10162: SUBST_VARS SUNWSPROBASE
! 10163: SUSE_PREFER SU_CMD
! 10164: SVN_EXTRACTDIR SVN_REPO
! 10165: SVN_REPOSITORIES SVN_REVISION
! 10166: SYSCONFBASE TARGET_MACHINE_ARCH
! 10167: TBL TERMCAP_TYPE
! 10168: TERMINFO_DEFAULT TERMINFO_TYPE
! 10169: TEST TEST_DEPENDS
! 10170: TEST_DIRS TEST_ENV
! 10171: TEST_ENV_SHELL TEST_MAKE_CMD
! 10172: TEST_MAKE_FLAGS TEST_TARGET
! 10173: TEXLIVE_IGNORE_PATTERNS TEXLIVE_REV
! 10174: TEXLIVE_UNVERSIONED TEXMFSITE
! 10175: TEX_FORMATS TEX_HYPHEN_DAT
! 10176: TEX_HYPHEN_DEF TEX_TEXMF_DIRS
! 10177: THTTPD_LOG_FACILITY TINYDYN_USER
! 10178: TLS TLSWRAPPER_CHROOT
! 10179: TO TOOLDIR
! 10180: TOOLS_ALIASES TOOLS_ALWAYS_WRAP
! 10181: TOOLS_ARGS TOOLS_BROKEN
! 10182: TOOLS_CMD TOOLS_CMDLINE_SED
! 10183: TOOLS_CREATE TOOLS_CROSS_DESTDIR
! 10184: TOOLS_DIR TOOLS_FAIL
! 10185: TOOLS_GNU_MISSING TOOLS_LDCONFIG
! 10186: TOOLS_NOOP TOOLS_PATH
! 10187: TOOLS_SCRIPT TOOLS_USE_CROSS_COMPILE
! 10188: TOOL_DEPENDS TTF_FONTDIR
! 10189: TTF_FONTS_DIR TYPE
! 10190: UAC_REQD_EXECS UCSPI_SSL_GROUP
! 10191: UCSPI_SSL_USER UDEV_REQUIRED
! 10192: UDEV_TYPE UNBOUND_GROUP
! 10193: UNBOUND_LOG_FACILITY UNBOUND_USER
! 10194: UNLIMIT_RESOURCES UNPRIVILEGED
! 10195: UNPRIVILEGED_GROUP UNPRIVILEGED_GROUPS
! 10196: UNPRIVILEGED_USER UNWRAP_FILES
! 10197: UNWRAP_PATTERNS UPDATE_GEMSPEC
! 10198: UPDATE_TARGET URI
! 10199: USERGROUP_PHASE USERPPP_GROUP
! 10200: USER_SPECIFIC_PKGS USE_ABI_DEPENDS
! 10201: USE_ADA_FEATURES USE_APR
! 10202: USE_BSD_MAKEFILE USE_BUILTIN
! 10203: USE_CC_FEATURES USE_CROSS_COMPILE
! 10204: USE_CURSES USE_CWRAPPERS
! 10205: USE_CXX_FEATURES USE_DB185
! 10206: USE_FEATURES USE_GAMESGROUP
! 10207: USE_GCC_RUNTIME USE_IMAKE
! 10208: USE_INDIRECT_DEPENDS USE_JAVA
! 10209: USE_JAVA2 USE_LANGUAGES
! 10210: USE_LIBTOOL USE_NATIVE_GCC
! 10211: USE_NETBSD_REPO USE_PKGSRC_GCC
! 10212: USE_PKGSRC_GCC_RUNTIME USE_PKGTASKS
! 10213: USE_PKG_ADMIN_DIGEST USE_RUBY_EXTCONF
! 10214: USE_RUBY_INSTALL USE_RUBY_SETUP
! 10215: USE_RUBY_SETUP_PKG USE_TMPFILES
! 10216: USE_TOOLS UUCP_GROUP
! 10217: UUCP_USER VARBASE
! 10218: VARNAME VIM_EXTRA_OPTS
! 10219: WARNING_MSG WCALC_CGIDIR
! 10220: WCALC_CGIPATH WCALC_HTMLDIR
! 10221: WCALC_HTMLPATH WDM_MANAGERS
! 10222: WRAPPER_CC WRAPPER_REORDER_CMDS
! 10223: WRKDIR WRKDIR_BASENAME
! 10224: WRKDIR_LOCKTYPE WRKLOG
! 10225: WRKOBJDIR WRKSRC
! 10226: X10_PORT X11
! 10227: X11BASE X11_PKGSRCDIR
! 10228: X11_TYPE X509_CERTIFICATE
! 10229: X509_KEY XAW_TYPE
! 10230: XLOCK_DEFAULT_MODE XMKMF
! 10231: XMKMF_FLAGS XXX
! 10232: XXXX YES
! 10233: ZSH_STATIC __stdc__
! 10234: _vargroups accept
! 10235: acquire-localbase-lock acquire-lock
! 10236: add added
! 10237: administrator alloca
! 10238: alternatives aslr
! 10239: asprintf atlas
! 10240: autoconf automake
! 10241: autoreconf awk
! 10242: barrier bash
! 10243: big-endian bin-install
! 10244: bind binpkg-list
! 10245: blas bootstrap-depends
! 10246: broken broken_on_platform
! 10247: bsd bsd.prog.mk
! 10248: build build-env
! 10249: buildlink-directories buildlink-oss-soundcard-h
! 10250: built-in builtin
! 10251: c c++
! 10252: ccache cce
! 10253: cdefs ceil
! 10254: changes changes-entry
! 10255: changes-entry-noupdate check
! 10256: check-clean check-files
! 10257: check-files-clean check-hackage
! 10258: check-vulnerable checksum
! 10259: checksum-phase clean
! 10260: clean-depends cleandir
! 10261: commit commit-changes-entry
! 10262: compact compiler
! 10263: conf config.guess
! 10264: config.sub configuration
! 10265: configure configure-env
! 10266: configure-help configure_args
! 10267: connect cos
! 10268: cpe cputime
! 10269: create-usergroup csh
! 10270: ctf cvs
! 10271: debug debug-barrier
! 10272: declaration declare
! 10273: defined depend
! 10274: dependencies depends
! 10275: depends-checksum depends-fetch
! 10276: describe destdir
! 10277: disable distclean
! 10278: distfiles distinfo
! 10279: dl dlopen
! 10280: do-buildlink do-clean
! 10281: do-configure do-configure-post-hook
! 10282: do-extract do-fetch
! 10283: do-install download
! 10284: emul emul-distinfo
! 10285: emul-fetch emulation
! 10286: emulator enable
! 10287: endian endif
! 10288: enomem ensurepip
! 10289: err errx
! 10290: etc exp
! 10291: extract-rpm fabs
! 10292: feature features
! 10293: fetch fetch-list
! 10294: follows forbids
! 10295: form format
! 10296: fortify fortify_source
! 10297: fossil friend
! 10298: fts fts_close
! 10299: fts_open fts_read
! 10300: fts_set gcc
! 10301: gethostbyaddr gethostbyname
! 10302: gethostbyname2 getopt_long
! 10303: getprogname getservbyname
! 10304: getservbyport getservent
! 10305: gettext git
! 10306: github gitlab
! 10307: glob gnu
! 10308: gnu_configure_strict go
! 10309: golang guess-license
! 10310: hashbang heimdal
! 10311: help hg
! 10312: imake in-tree
! 10313: increment indirect
! 10314: inet_aton install
! 10315: install-env interp
! 10316: interpreter intl
! 10317: ip4 ip6
! 10318: ipv4 ipv6
! 10319: iso kerberos
! 10320: krb krb5
! 10321: ksh lapack
! 10322: latex libiconv
! 10323: libintl_bindtextdomain libintl_gettext
! 10324: libintl_textdomain libnbcompat
! 10325: libs libtool
! 10326: licence license
! 10327: lintl little-endian
! 10328: lock locking
! 10329: lua lvalue
! 10330: machine_endian make
! 10331: makedistinfo makepatchsum
! 10332: makesum mdi
! 10333: memory mercurial
! 10334: meta meta-package
! 10335: meta_package mit-krb5
! 10336: mk.conf mkl
! 10337: mount move
! 10338: moved mprotect
! 10339: mps mremap
! 10340: native nb
! 10341: nbcompat netlib
! 10342: network node
! 10343: node.js nodejs
! 10344: obstack obstack_ptr_grow
! 10345: occurs only
! 10346: openblas options
! 10347: options.mk order
! 10348: override override-intltool
! 10349: override-message-intltool package
! 10350: parallel path
! 10351: pax paxctl
! 10352: pbulk-index pc
! 10353: perl perl5
! 10354: perms php
! 10355: pkg-build-options pkg-config
! 10356: pkg_build_options pkgsrc
! 10357: platform plist
! 10358: post-extract post-fetch
! 10359: post-wrapper pre-build-checks-hook
! 10360: pre-configure-checks-hook pre-extract
! 10361: pre-fetch print-plist
! 10362: print-summary-data privileged-install-hook
! 10363: pypi python
! 10364: r readme-all
! 10365: recursive recv
! 10366: recvfrom regcomp
! 10367: release-localbase-lock release-lock
! 10368: relro remove
! 10369: removed rename
! 10370: renamed reorder
! 10371: replace replace_interpreter
! 10372: reproducible resolv
! 10373: root ruby
! 10374: send sendfile
! 10375: sendto setenv
! 10376: setgid setprogname
! 10377: setuid sh
! 10378: shebang show
! 10379: show-all show-build-defs
! 10380: show-depends show-depends-dirs
! 10381: show-depends-pkgpaths show-depends-recursive
! 10382: show-deps show-distfiles
! 10383: show-downlevel show-subdir-var
! 10384: show-tools show-var
! 10385: show-vars snprintf
! 10386: socket ssp
! 10387: st_mode stage-install
! 10388: strcasestr strict
! 10389: strip strndup
! 10390: strnlen strsep
! 10391: subst substitutions
! 10392: subversion sun
! 10393: sunpro sunwspro
! 10394: svn symlink
! 10395: test test-env
! 10396: tex texlive
! 10397: tmp todo
! 10398: tool tools
! 10399: tools-libtool-m4-override transitive
! 10400: type ulimit
! 10401: undefined undo-replace
! 10402: unlimit unprivileged
! 10403: unprivileged-install-hook unstripped
! 10404: update updated
! 10405: upload upload-distfiles
! 10406: use_tools user
! 10407: utimes vasprintf
! 10408: verbose vsnprintf
! 10409: warn warning
! 10410: warnings warnx
! 10411: wattr_off wattr_on
! 10412: work wrapper
! 10413: wrkdir
1.154 rillig 10414:
1.266 martin 10415: Appendix F. Editing guidelines for the pkgsrc guide
1.1 dsieger 10416:
10417: Table of Contents
10418:
1.207 leot 10419: F.1. Make targets
10420: F.2. Procedure
1.1 dsieger 10421:
10422: This section contains information on editing the pkgsrc guide itself.
10423:
1.266 martin 10424: F.1. Make targets
1.1 dsieger 10425:
10426: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
10427: files are created from it:
10428:
10429: * pkgsrc/doc/pkgsrc.txt
10430:
10431: * pkgsrc/doc/pkgsrc.html
10432:
1.174 leot 10433: * https://www.NetBSD.org/docs/pkgsrc/
1.1 dsieger 10434:
1.174 leot 10435: * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the
10436: pkgsrc guide.
1.1 dsieger 10437:
1.174 leot 10438: * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
1.2 rillig 10439: pkgsrc guide.
1.1 dsieger 10440:
1.266 martin 10441: F.2. Procedure
1.1 dsieger 10442:
10443: The procedure to edit the pkgsrc guide is:
10444:
1.190 bacon 10445: 1. Make sure you have checked out the htdocs repository into a sibling
10446: directory of your pkgsrc directory. You will need the ability to commit
10447: from both pkgsrc and htdocs.
10448:
10449: 2. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46 obache 10450: other XML-based NetBSD documentation) installed. These are automatically
10451: installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1 dsieger 10452:
1.190 bacon 10453: 3. Run cd doc/guide to get to the right directory. All further steps will take
1.1 dsieger 10454: place here.
10455:
1.190 bacon 10456: 4. Edit the XML file(s) in files/.
1.1 dsieger 10457:
1.190 bacon 10458: 5. Run bmake to check the pkgsrc guide for valid XML and to build the final
1.1 dsieger 10459: output files. If you get any errors at this stage, you can just edit the
10460: files, as there are only symbolic links in the working directory, pointing
10461: to the files in files/.
10462:
1.190 bacon 10463: 6. (cd files && cvs commit)
1.1 dsieger 10464:
1.190 bacon 10465: 7. Run bmake clean && bmake to regenerate the output files with the proper RCS
1.1 dsieger 10466: Ids.
10467:
1.190 bacon 10468: 8. Run bmake regen to install and commit the files in both pkgsrc/doc and
1.1 dsieger 10469: htdocs.
10470:
10471: Note
10472:
10473: If you have added, removed or renamed some chapters, you need to
10474: synchronize them using cvs add or cvs delete in the htdocs directory.
10475:
CVSweb <webmaster@jp.NetBSD.org>