Annotation of htdocs/docs/pkgsrc/pkgsrc.txt, revision 1.236
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.231 jnemeth 15: Copyright 1994-2023 The NetBSD Foundation, Inc
1.1 dsieger 16:
1.231 jnemeth 17: $NetBSD: pkgsrc.xml,v 1.42 2023/01/02 05:45:23 jnemeth 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.232 gutterid 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
68: 6.3. Variables affecting the installation process
69: 6.4. Selecting and configuring the compiler
70: 6.4.1. Selecting the compiler
71: 6.4.2. Additional flags to the compiler (CFLAGS)
72: 6.4.3. Additional flags to the linker (LDFLAGS)
73: 6.5. Developer/advanced settings
74: 6.6. Selecting Build Options
75: 7. Creating binary packages
76: 7.1. Building a single binary package
77: 7.2. Settings for creation of binary packages
78: 8. Creating binary packages for everything in pkgsrc (bulk builds)
79: 8.1. Preparations
1.180 rillig 80: 8.2. Running a bulk build
1.154 rillig 81: 8.2.1. Configuration
82: 8.3. Requirements of a full bulk build
1.178 rillig 83: 8.4. Bulk build variants
1.179 rillig 84: 8.4.1. Detect unknown configure options
85: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.181 rillig 86: 8.4.3. Force compiler options only in the build phase
87: 8.4.4. Use custom directories
88: 8.4.5. Turn warnings into errors
89: 8.4.6. Reject packages for which pkglint reports errors
90: 8.4.7. Reject packages that contain forbidden strings
91: 8.4.8. Reject packages whose self-test fails
92: 8.4.9. Reject packages that use undefined shell variables
93: 8.4.10. Turn off verbose logging
1.178 rillig 94: 8.5. Creating a multiple CD-ROM packages collection
95: 8.5.1. Example of cdpack
1.154 rillig 96: 9. Directory layout of the installed files
97: 9.1. File system layout in ${LOCALBASE}
98: 9.2. File system layout in ${VARBASE}
99: 10. Frequently Asked Questions
100: 10.1. Are there any mailing lists for pkg-related discussion?
101: 10.2. Utilities for package management (pkgtools)
102: 10.3. How to use pkgsrc as non-root
103: 10.4. How to resume transfers when fetching distfiles?
104: 10.5. How can I install/use modular X.org from pkgsrc?
105: 10.6. How to fetch files from behind a firewall
106: 10.7. How to fetch files from HTTPS sites
107: 10.8. How do I tell make fetch to do passive FTP?
108: 10.9. How to fetch all distfiles at once
109: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc"
1.232 gutterid 110: mean?
1.154 rillig 111: 10.11. What does "Could not find bsd.own.mk" mean?
1.221 nia 112: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154 rillig 113: 10.13. How do I change the location of configuration files?
114: 10.14. Automated security checks
115: 10.15. Why do some packages ignore my CFLAGS?
116: 10.16. A package does not build. What shall I do?
117: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/???
1.232 gutterid 118: merge conflicts" mean?
1.1 dsieger 119: II. The pkgsrc developer's guide
1.154 rillig 120: 11. Getting help
1.184 rillig 121: 12. Package components - files, directories and contents
122: 12.1. Makefile
123: 12.2. distinfo
124: 12.3. patches/*
125: 12.3.1. Structure of a single patch file
126: 12.3.2. Creating patch files
127: 12.3.3. Sources where the patch files come from
128: 12.3.4. Patching guidelines
129: 12.3.5. Feedback to the author
130: 12.4. Other mandatory files
131: 12.5. Optional files
132: 12.5.1. Files affecting the binary package
133: 12.5.2. Files affecting the build process
134: 12.5.3. Files affecting nothing at all
135: 12.6. work*
136: 12.7. files/*
137: 13. The build process
138: 13.1. Introduction
139: 13.2. Program location
140: 13.3. Directories used during the build process
141: 13.4. Running a phase
142: 13.5. The fetch phase
143: 13.5.1. What to fetch and where to get it from
144: 13.5.2. How are the files fetched?
145: 13.6. The checksum phase
146: 13.7. The extract phase
147: 13.8. The patch phase
148: 13.9. The tools phase
149: 13.10. The wrapper phase
150: 13.11. The configure phase
151: 13.12. The build phase
152: 13.13. The test phase
153: 13.14. The install phase
154: 13.15. The package phase
155: 13.16. Cleaning up
156: 13.17. Other helpful targets
157: 14. Creating a new pkgsrc package from scratch
158: 14.1. Common types of packages
1.219 nia 159: 14.1.1. Python modules and programs
160: 14.1.2. R packages
161: 14.1.3. TeXlive packages
1.184 rillig 162: 14.2. Examples
163: 14.2.1. How the www/nvu package came into pkgsrc
164: 15. Programming in Makefiles
165: 15.1. Caveats
166: 15.2. Makefile variables
167: 15.2.1. Naming conventions
168: 15.3. Code snippets
169: 15.3.1. Adding things to a list
170: 15.3.2. Echoing a string exactly as-is
171: 15.3.3. Passing CFLAGS to GNU configure scripts
172: 15.3.4. Handling possibly empty variables
1.229 gutterid 173: 15.3.5. Testing yes/no variables in conditions
1.184 rillig 174: 16. Options handling
175: 16.1. Global default options
176: 16.2. Converting packages to use bsd.options.mk
177: 16.3. Option Names
178: 16.4. Determining the options of dependencies
179: 17. Tools needed for building or running
180: 17.1. Tools for pkgsrc builds
181: 17.2. Tools needed by packages
182: 17.3. Tools provided by platforms
183: 18. Buildlink methodology
184: 18.1. Converting packages to use buildlink3
185: 18.2. Writing buildlink3.mk files
186: 18.2.1. Anatomy of a buildlink3.mk file
187: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
1.232 gutterid 188: BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.184 rillig 189: 18.3. Writing builtin.mk files
190: 18.3.1. Anatomy of a builtin.mk file
191: 18.3.2. Global preferences for native or pkgsrc software
192: 19. PLIST issues
193: 19.1. RCS ID
194: 19.2. Semi-automatic PLIST generation
195: 19.3. Tweaking output of make print-PLIST
196: 19.4. Variable substitution in PLIST
197: 19.5. Man page compression
198: 19.6. Changing PLIST source with PLIST_SRC
199: 19.7. Platform-specific and differing PLISTs
200: 19.8. Build-specific PLISTs
201: 19.9. Sharing directories between packages
202: 20. The pkginstall framework
203: 20.1. Files and directories outside the installation prefix
204: 20.1.1. Directory manipulation
205: 20.1.2. File manipulation
206: 20.2. Configuration files
207: 20.2.1. How PKG_SYSCONFDIR is set
208: 20.2.2. Telling the software where configuration files are
209: 20.2.3. Patching installations
210: 20.2.4. Disabling handling of configuration files
211: 20.3. System startup scripts
212: 20.3.1. Disabling handling of system startup scripts
213: 20.4. System users and groups
214: 20.5. System shells
215: 20.5.1. Disabling shell registration
216: 20.6. Fonts
217: 20.6.1. Disabling automatic update of the fonts databases
1.154 rillig 218: 21. Making your package work
219: 21.1. General operation
220: 21.1.1. How to pull in user-settable variables from mk.conf
221: 21.1.2. User interaction
222: 21.1.3. Handling licenses
223: 21.1.4. Restricted packages
224: 21.1.5. Handling dependencies
225: 21.1.6. Handling conflicts with other packages
226: 21.1.7. Packages that cannot or should not be built
227: 21.1.8. Packages which should not be deleted, once installed
228: 21.1.9. Handling packages with security problems
229: 21.1.10. How to handle incrementing versions when fixing an
1.232 gutterid 230: existing package
1.154 rillig 231: 21.1.11. Substituting variable text in the package files (the SUBST
1.232 gutterid 232: framework)
1.154 rillig 233: 21.2. The fetch phase
234: 21.2.1. Packages whose distfiles aren't available for plain
1.232 gutterid 235: downloading
1.154 rillig 236: 21.2.2. How to handle modified distfiles with the 'old' name
237: 21.2.3. Packages hosted on github.com
238: 21.3. The configure phase
239: 21.3.1. Shared libraries - libtool
240: 21.3.2. Using libtool on GNU packages that already support libtool
241: 21.3.3. GNU Autoconf/Automake
1.223 nia 242: 21.3.4. Meson / ninja
1.154 rillig 243: 21.4. Programming languages
244: 21.4.1. C, C++, and Fortran
245: 21.4.2. Java
1.205 wiz 246: 21.4.3. Go
1.223 nia 247: 21.4.4. Rust
248: 21.4.5. Packages containing Perl scripts
249: 21.4.6. Packages containing shell scripts
250: 21.4.7. Other programming languages
1.154 rillig 251: 21.5. The build phase
252: 21.5.1. Compiling C and C++ code conditionally
253: 21.5.2. How to handle compiler bugs
1.172 rillig 254: 21.5.3. No such file or directory
255: 21.5.4. Undefined reference to "..."
256: 21.5.5. Running out of memory
1.154 rillig 257: 21.6. The install phase
258: 21.6.1. Creating needed directories
259: 21.6.2. Where to install documentation
260: 21.6.3. Installing highscore files
261: 21.6.4. Adding DESTDIR support to packages
262: 21.6.5. Packages with hardcoded paths to other interpreters
1.203 nia 263: 21.6.6. Packages installing Perl modules
1.154 rillig 264: 21.6.7. Packages installing info files
265: 21.6.8. Packages installing man pages
1.203 nia 266: 21.6.9. Packages installing X11 fonts
267: 21.6.10. Packages installing SGML or XML data
268: 21.6.11. Packages installing extensions to the MIME database
269: 21.6.12. Packages using intltool
270: 21.6.13. Packages installing startup scripts
271: 21.6.14. Packages installing TeX modules
272: 21.6.15. Packages supporting running binaries in emulation
273: 21.6.16. Packages installing hicolor icons
274: 21.6.17. Packages installing desktop files
1.154 rillig 275: 21.7. Marking packages as having problems
1.184 rillig 276: 22. GNOME packaging and porting
277: 22.1. Meta packages
278: 22.2. Packaging a GNOME application
279: 22.3. Updating GNOME to a newer version
280: 22.4. Patching guidelines
1.154 rillig 281: 23. Submitting and Committing
282: 23.1. Submitting binary packages
283: 23.2. Submitting source packages (for non-NetBSD-developers)
284: 23.3. General notes when adding, updating, or removing packages
285: 23.4. Commit Messages
286: 23.5. Committing: Adding a package to CVS
287: 23.6. Updating a package to a newer version
288: 23.7. Renaming a package in pkgsrc
289: 23.8. Moving a package in pkgsrc
290: 24. Frequently Asked Questions
1.1 dsieger 291: III. The pkgsrc infrastructure internals
1.184 rillig 292: 25. Design of the pkgsrc infrastructure
293: 25.1. The meaning of variable definitions
294: 25.2. Avoiding problems before they arise
295: 25.3. Variable evaluation
296: 25.3.1. At load time
297: 25.3.2. At runtime
298: 25.4. How can variables be specified?
299: 25.5. Designing interfaces for Makefile fragments
300: 25.5.1. Procedures with parameters
301: 25.5.2. Actions taken on behalf of parameters
302: 25.6. The order in which files are loaded
303: 25.6.1. The order in bsd.prefs.mk
304: 25.6.2. The order in bsd.pkg.mk
305: 26. Regression tests
306: 26.1. Running the regression tests
307: 26.2. Adding a new regression test
308: 26.2.1. Overridable functions
309: 26.2.2. Helper functions
310: 27. Porting pkgsrc
311: 27.1. Porting pkgsrc to a new operating system
1.1 dsieger 312: A. A simple example package: bison
313: A.1. files
314: A.1.1. Makefile
315: A.1.2. DESCR
316: A.1.3. PLIST
317: A.1.4. Checking a package with pkglint
318: A.2. Steps for building, installing, packaging
1.207 leot 319: B. Security hardening
320: B.1. Mechanisms
321: B.1.1. Enabled by default
322: B.1.2. Not enabled by default
323: B.2. Caveats
324: B.2.1. Problems with PKGSRC_MKPIE
325: B.2.2. Problems with PKGSRC_USE_FORTIFY
326: B.2.3. Problems with PKGSRC_USE_RELRO
327: B.2.4. Problems with PKGSRC_USE_SSP
328: B.3. Auditing the system
329: B.3.1. Checking for PIE
330: B.3.2. Checking for partial RELRO
331: B.3.3. Checking for full RELRO
332: B.3.4. Checking for SSP
333: C. Build logs
334: C.1. Building figlet
335: C.2. Packaging figlet
336: D. Directory layout of the pkgsrc FTP server
337: D.1. distfiles: The distributed source files
338: D.2. misc: Miscellaneous things
339: D.3. packages: Binary packages
340: D.4. reports: Bulk build reports
341: D.5. current, stable, pkgsrc-20xxQy: source packages
342: E. Help topics
343: F. Editing guidelines for the pkgsrc guide
344: F.1. Make targets
345: F.2. Procedure
1.1 dsieger 346:
347: List of Tables
348:
349: 1.1. Platforms supported by pkgsrc
1.184 rillig 350: 12.1. Patching examples
351: 22.1. PLIST handling for GNOME packages
1.1 dsieger 352:
353: Chapter 1. What is pkgsrc?
354:
355: Table of Contents
356:
357: 1.1. Introduction
358: 1.1.1. Why pkgsrc?
359: 1.1.2. Supported platforms
360: 1.2. Overview
361: 1.3. Terminology
362: 1.3.1. Roles involved in pkgsrc
363: 1.4. Typography
364:
365: 1.1. Introduction
366:
367: There is a lot of software freely available for Unix-based systems, which is
368: usually available in form of the source code. Before such software can be used,
369: it needs to be configured to the local system, compiled and installed, and this
370: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
371: some basic commands to handle binary packages, so that not every user has to
372: build the packages for himself, which is a time-costly task.
373:
374: pkgsrc currently contains several thousand packages, including:
375:
1.104 sevan 376: * www/apache24 - The Apache web server
1.1 dsieger 377:
378: * www/firefox - The Firefox web browser
379:
380: * meta-pkgs/gnome - The GNOME Desktop Environment
381:
1.102 ryoon 382: * meta-pkgs/kde4 - The K Desktop Environment
1.1 dsieger 383:
1.108 rillig 384: ? just to name a few.
1.1 dsieger 385:
386: pkgsrc has built-in support for handling varying dependencies, such as pthreads
387: and X11, and extended features such as IPv6 support on a range of platforms.
388:
389: 1.1.1. Why pkgsrc?
390:
391: pkgsrc provides the following key features:
392:
393: * Easy building of software from source as well as the creation and
394: installation of binary packages. The source and latest patches are
395: retrieved from a master or mirror download site, checksum verified, then
396: built on your system. Support for binary-only distributions is available
397: for both native platforms and NetBSD emulated platforms.
398:
399: * All packages are installed in a consistent directory tree, including
400: binaries, libraries, man pages and other documentation.
401:
1.104 sevan 402: * Tracking of package dependencies automatically, including when performing
403: updates, to ensure required packages are installed. The configuration files
404: of various packages are handled automatically during updates, so local
405: changes are preserved.
1.1 dsieger 406:
407: * Like NetBSD, pkgsrc is designed with portability in mind and consists of
408: highly portable code. This allows the greatest speed of development when
1.26 spz 409: porting to a new platform. This portability also ensures that pkgsrc is
1.1 dsieger 410: consistent across all platforms.
411:
412: * The installation prefix, acceptable software licenses, international
413: encryption requirements and build-time options for a large number of
414: packages are all set in a simple, central configuration file.
415:
416: * The entire source (not including the distribution files) is freely
417: available under a BSD license, so you may extend and adapt pkgsrc to your
418: needs. Support for local packages and patches is available right out of the
419: box, so you can configure it specifically for your environment.
420:
421: The following principles are basic to pkgsrc:
422:
1.198 leot 423: * "It should only work if it's right." -- That means, if a package contains
1.1 dsieger 424: bugs, it's better to find them and to complain about them rather than to
425: just install the package and hope that it works. There are numerous checks
1.175 gutterid 426: in pkgsrc that try to find such bugs: static analysis tools (pkgtools/
1.1 dsieger 427: pkglint), build-time checks (portability of shell scripts), and
428: post-installation checks (installed files, references to shared libraries,
429: script interpreters).
430:
1.198 leot 431: * "If it works, it should work everywhere" -- Like NetBSD has been ported to
1.1 dsieger 432: many hardware architectures, pkgsrc has been ported to many operating
433: systems. Care is taken that packages behave the same on all platforms.
434:
435: 1.1.2. Supported platforms
436:
437: pkgsrc consists of both a source distribution and a binary distribution for
438: these operating systems. After retrieving the required source or binaries, you
439: can be up and running with pkgsrc in just minutes!
440:
441: pkgsrc was derived from FreeBSD's ports system, and initially developed for
442: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
443: platforms:
444:
445: Table 1.1. Platforms supported by pkgsrc
446:
1.92 sevan 447: +-----------------------------------------------------------------------------+
1.229 gutterid 448: | Platform | Date Support | Notes |
449: | | Added | |
450: |-------------------------------------+---------------+-----------------------|
451: |NetBSD | Aug 1997 | |
452: |-------------------------------------+---------------+-----------------------|
453: |Solaris | Mar 1999 |README.Solaris |
454: |-------------------------------------+---------------+-----------------------|
455: |Linux | Jun 1999 |README.Linux |
456: |-------------------------------------+---------------+-----------------------|
457: |Darwin / Mac OS X / OS X / macOS | Oct 2001 |README.macOS |
458: |-------------------------------------+---------------+-----------------------|
459: |FreeBSD | Nov 2002 |README.FreeBSD |
460: |-------------------------------------+---------------+-----------------------|
461: |OpenBSD | Nov 2002 |README.OpenBSD |
462: |-------------------------------------+---------------+-----------------------|
463: |IRIX | Dec 2002 |README.IRIX |
464: |-------------------------------------+---------------+-----------------------|
465: |BSD/OS | Dec 2003 | |
466: |-------------------------------------+---------------+-----------------------|
467: |AIX | Dec 2003 |README.AIX |
468: |-------------------------------------+---------------+-----------------------|
469: |Interix (Microsoft Windows Services | Mar 2004 |README.Interix |
470: |for Unix) | | |
471: |-------------------------------------+---------------+-----------------------|
472: |DragonFlyBSD | Oct 2004 | |
473: |-------------------------------------+---------------+-----------------------|
474: |OSF/1 | Nov 2004 |README.OSF1 |
475: |-------------------------------------+---------------+-----------------------|
476: |HP-UX | Apr 2007 |README.HPUX |
477: |-------------------------------------+---------------+-----------------------|
478: |Haiku | Sep 2010 |README.Haiku |
479: |-------------------------------------+---------------+-----------------------|
480: |MirBSD | Jan 2011 | |
481: |-------------------------------------+---------------+-----------------------|
482: |Minix3 | Nov 2011 |README.Minix3 |
483: |-------------------------------------+---------------+-----------------------|
484: |Cygwin | Mar 2013 |README.Cygwin |
485: |-------------------------------------+---------------+-----------------------|
486: |GNU/kFreeBSD | Jul 2013 |README.GNUkFreeBSD |
487: |-------------------------------------+---------------+-----------------------|
488: |Bitrig | Jun 2014 |Removed from pkgsrc Sep|
489: | | |2022 |
1.92 sevan 490: +-----------------------------------------------------------------------------+
1.1 dsieger 491:
492:
493: 1.2. Overview
494:
495: This document is divided into three parts. The first, The pkgsrc user's guide,
496: describes how one can use one of the packages in the Package Collection, either
497: by installing a precompiled binary package, or by building one's own copy using
498: the NetBSD package system. The second part, The pkgsrc developer's guide,
499: explains how to prepare a package so it can be easily built by other NetBSD
500: users without knowing about the package's building details. The third part, The
501: pkgsrc infrastructure internals is intended for those who want to understand
502: how pkgsrc is implemented.
503:
504: This document is available in various formats: HTML, PDF, PS, TXT.
505:
506: 1.3. Terminology
507:
508: There has been a lot of talk about "ports", "packages", etc. so far. Here is a
509: description of all the terminology used within this document.
510:
511: Package
512:
513: A set of files and building instructions that describe what's necessary to
514: build a certain piece of software using pkgsrc. Packages are traditionally
1.123 wiz 515: stored under /usr/pkgsrc, but may be stored in any location, referred to as
516: PKGSRCDIR.
1.1 dsieger 517:
518: The NetBSD package system
519:
520: This is the former name of "pkgsrc". It is part of the NetBSD operating
521: system and can be bootstrapped to run on non-NetBSD operating systems as
522: well. It handles building (compiling), installing, and removing of
523: packages.
524:
525: Distfile
526:
527: This term describes the file or files that are provided by the author of
528: the piece of software to distribute his work. All the changes necessary to
529: build on NetBSD are reflected in the corresponding package. Usually the
530: distfile is in the form of a compressed tar-archive, but other types are
531: possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
532:
533: Port
534:
535: This is the term used by FreeBSD and OpenBSD people for what we call a
536: package. In NetBSD terminology, "port" refers to a different architecture.
537:
538: Precompiled/binary package
539:
540: A set of binaries built with pkgsrc from a distfile and stuffed together in
541: a single .tgz file so it can be installed on machines of the same machine
542: architecture without the need to recompile. Packages are usually generated
543: in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
544:
545: Sometimes, this is referred to by the term "package" too, especially in the
546: context of precompiled packages.
547:
548: Program
549:
550: The piece of software to be installed which will be constructed from all
551: the files in the distfile by the actions defined in the corresponding
552: package.
553:
554: 1.3.1. Roles involved in pkgsrc
555:
556: pkgsrc users
557:
558: The pkgsrc users are people who use the packages provided by pkgsrc.
559: Typically they are system administrators. The people using the software
560: that is inside the packages (maybe called "end users") are not covered by
561: the pkgsrc guide.
562:
563: There are two kinds of pkgsrc users: Some only want to install pre-built
564: binary packages. Others build the pkgsrc packages from source, either for
565: installing them directly or for building binary packages themselves. For
566: pkgsrc users Part I, "The pkgsrc user's guide" should provide all necessary
567: documentation.
568:
569: package maintainers
570:
571: A package maintainer creates packages as described in Part II, "The pkgsrc
572: developer's guide".
573:
574: infrastructure developers
575:
576: These people are involved in all those files that live in the mk/ directory
577: and below. Only these people should need to read through Part III, "The
578: pkgsrc infrastructure internals", though others might be curious, too.
579:
580: 1.4. Typography
581:
582: When giving examples for commands, shell prompts are used to show if the
583: command should/can be issued as root, or if "normal" user privileges are
1.115 sevan 584: sufficient. We use a # for root's shell prompt, a % for users' shell prompt,
1.229 gutterid 585: assuming they use the C-shell or tcsh and a $ for Bourne shell and derivatives.
1.1 dsieger 586:
587: Part I. The pkgsrc user's guide
588:
589: Table of Contents
590:
1.154 rillig 591: 2. Getting help
592: 3. Where to get pkgsrc and how to keep it up-to-date
593: 3.1. Getting pkgsrc for the first time
594: 3.1.1. As tar archive
595: 3.1.2. Via anonymous CVS
596: 3.2. Keeping pkgsrc up-to-date
597: 3.2.1. Via tar files
598: 3.2.2. Via CVS
599: 4. Using pkgsrc on systems other than NetBSD
600: 4.1. Binary distribution
601: 4.2. Bootstrapping pkgsrc
602: 5. Using pkgsrc
603: 5.1. Using binary packages
604: 5.1.1. Finding binary packages
605: 5.1.2. Installing binary packages
1.202 nia 606: 5.1.3. Updating packages
607: 5.1.4. Deinstalling packages
608: 5.1.5. Getting information about installed packages
609: 5.1.6. Checking for security vulnerabilities in installed packages
610: 5.1.7. Finding if newer versions of your installed packages are in
1.232 gutterid 611: pkgsrc
1.202 nia 612: 5.1.8. Other administrative functions
1.154 rillig 613: 5.2. Building packages from source
614: 5.2.1. Requirements
615: 5.2.2. Fetching distfiles
616: 5.2.3. How to build and install
617: 6. Configuring pkgsrc
618: 6.1. General configuration
619: 6.2. Variables affecting the build process
620: 6.3. Variables affecting the installation process
621: 6.4. Selecting and configuring the compiler
622: 6.4.1. Selecting the compiler
623: 6.4.2. Additional flags to the compiler (CFLAGS)
624: 6.4.3. Additional flags to the linker (LDFLAGS)
625: 6.5. Developer/advanced settings
626: 6.6. Selecting Build Options
627: 7. Creating binary packages
628: 7.1. Building a single binary package
629: 7.2. Settings for creation of binary packages
630: 8. Creating binary packages for everything in pkgsrc (bulk builds)
631: 8.1. Preparations
1.180 rillig 632: 8.2. Running a bulk build
1.154 rillig 633: 8.2.1. Configuration
634: 8.3. Requirements of a full bulk build
1.178 rillig 635: 8.4. Bulk build variants
1.179 rillig 636: 8.4.1. Detect unknown configure options
637: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.181 rillig 638: 8.4.3. Force compiler options only in the build phase
639: 8.4.4. Use custom directories
640: 8.4.5. Turn warnings into errors
641: 8.4.6. Reject packages for which pkglint reports errors
642: 8.4.7. Reject packages that contain forbidden strings
643: 8.4.8. Reject packages whose self-test fails
644: 8.4.9. Reject packages that use undefined shell variables
645: 8.4.10. Turn off verbose logging
1.178 rillig 646: 8.5. Creating a multiple CD-ROM packages collection
647: 8.5.1. Example of cdpack
1.154 rillig 648: 9. Directory layout of the installed files
649: 9.1. File system layout in ${LOCALBASE}
650: 9.2. File system layout in ${VARBASE}
651: 10. Frequently Asked Questions
652: 10.1. Are there any mailing lists for pkg-related discussion?
653: 10.2. Utilities for package management (pkgtools)
654: 10.3. How to use pkgsrc as non-root
655: 10.4. How to resume transfers when fetching distfiles?
656: 10.5. How can I install/use modular X.org from pkgsrc?
657: 10.6. How to fetch files from behind a firewall
658: 10.7. How to fetch files from HTTPS sites
659: 10.8. How do I tell make fetch to do passive FTP?
660: 10.9. How to fetch all distfiles at once
661: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
662: 10.11. What does "Could not find bsd.own.mk" mean?
1.221 nia 663: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154 rillig 664: 10.13. How do I change the location of configuration files?
665: 10.14. Automated security checks
666: 10.15. Why do some packages ignore my CFLAGS?
667: 10.16. A package does not build. What shall I do?
668: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.232 gutterid 669: conflicts" mean?
1.1 dsieger 670:
1.154 rillig 671: Chapter 2. Getting help
672:
673: To get help when using pkgsrc, the definitive source is this document, the
674: pkgsrc guide. If you don't find anything here, there are alternatives:
675:
676: * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
677: Run bmake help topic=? to get help for any topic, such as a variable name
678: like BUILD_DEFS, a make target like do-build, a missing C or C++ function
679: like strcasecmp or any other topic.
680:
1.207 leot 681: The available help topics are listed in Appendix E, Help topics.
1.154 rillig 682:
1.163 rillig 683: * To see the value of a single variable, run bmake show-var VARNAME=X.
684:
685: * To see the values of the most common variables, run bmake show-all. These
686: variables are grouped by topic. To see the variables for a single topic,
687: run bmake show-all-topic, for example bmake show-all-fetch.
688:
1.154 rillig 689: * The pkgsrc-users mailing list, to which you can subscribe and then ask your
690: questions.
691:
692: * The #pkgsrc IRC channel, which is accessible via a web browser or by using
693: a specialized chat program such as XChat. Pick any user name and join the
694: channel #pkgsrc.
695:
696: Chapter 3. Where to get pkgsrc and how to keep it up-to-date
1.1 dsieger 697:
698: Table of Contents
699:
1.154 rillig 700: 3.1. Getting pkgsrc for the first time
701: 3.1.1. As tar archive
702: 3.1.2. Via anonymous CVS
703: 3.2. Keeping pkgsrc up-to-date
704: 3.2.1. Via tar files
705: 3.2.2. Via CVS
1.1 dsieger 706:
707: Before you download and extract the files, you need to decide where you want to
708: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
709: usr/pkgsrc. You are though free to install the sources and binary packages
710: wherever you want in your filesystem, provided that the pathname does not
711: contain white-space or other characters that are interpreted specially by the
712: shell and some other programs. A safe bet is to use only letters, digits,
713: underscores and dashes.
714:
1.154 rillig 715: 3.1. Getting pkgsrc for the first time
1.1 dsieger 716:
1.25 wiz 717: Before you download any pkgsrc files, you should decide whether you want the
1.1 dsieger 718: current branch or the stable branch. The latter is forked on a quarterly basis
719: from the current branch and only gets modified for security updates. The names
720: of the stable branches are built from the year and the quarter, for example
1.214 leot 721: 2021Q4.
1.1 dsieger 722:
723: The second step is to decide how you want to download pkgsrc. You can get it as
1.24 wiz 724: a tar file or via CVS. Both ways are described here.
1.1 dsieger 725:
1.52 asau 726: Note that tar archive contains CVS working copy. Thus you can switch to using
727: CVS at any later time.
1.1 dsieger 728:
1.154 rillig 729: 3.1.1. As tar archive
1.52 asau 730:
1.151 sevan 731: The primary download location for all pkgsrc files is https://cdn.NetBSD.org/
732: pub/pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same
733: location). There are a number of subdirectories for different purposes, which
1.207 leot 734: are described in detail in Appendix D, Directory layout of the pkgsrc FTP
1.151 sevan 735: server.
1.1 dsieger 736:
1.52 asau 737: The tar archive for the current branch is in the directory current and is
1.118 sevan 738: called pkgsrc.tar.gz. It is autogenerated weekly.
1.52 asau 739:
740: To save download time we provide bzip2- and xz-compressed archives which are
741: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
742:
743: You can fetch the same files using FTP.
1.1 dsieger 744:
1.214 leot 745: The tar file for the stable branch 2021Q4 is in the directory pkgsrc-2021Q4 and
1.59 jnemeth 746: is also called pkgsrc.tar.gz.
1.1 dsieger 747:
1.136 leot 748: To download the latest pkgsrc stable tarball, run:
1.12 weinem 749:
1.214 leot 750: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2021Q4/pkgsrc.tar.gz
1.12 weinem 751:
1.78 snj 752: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52 asau 753:
1.12 weinem 754: Then, extract it with:
755:
1.78 snj 756: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12 weinem 757:
758: This will create the directory pkgsrc/ in /usr/ and all the package source will
759: be stored under /usr/pkgsrc/.
760:
761: To download pkgsrc-current, run:
762:
763: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1 dsieger 764:
1.154 rillig 765: 3.1.2. Via anonymous CVS
1.1 dsieger 766:
1.24 wiz 767: To fetch a specific pkgsrc stable branch, run:
1.1 dsieger 768:
1.214 leot 769: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2021Q4 -P pkgsrc
1.13 weinem 770:
1.24 wiz 771: This will create the directory pkgsrc/ in your /usr/ directory and all the
772: package source will be stored under /usr/pkgsrc/.
773:
774: To fetch the pkgsrc current branch, run:
1.1 dsieger 775:
1.40 wiz 776: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 777:
1.30 dholland 778: Refer to the list of available mirrors to choose a faster CVS mirror, if
779: needed.
1.1 dsieger 780:
1.24 wiz 781: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1 dsieger 782:
1.40 wiz 783: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 784:
1.24 wiz 785: Refer to documentation on your command shell how to set CVS_RSH=ssh
786: permanently. For Bourne shells, you can set it in your .profile or better
787: globally in /etc/profile:
788:
789: # set CVS remote shell command
790: CVS_RSH=ssh
791: export CVS_RSH
1.12 weinem 792:
1.13 weinem 793: By default, CVS doesn't do things like most people would expect it to do. But
794: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12 weinem 795: directory and saving the following lines to it. This file will save you lots of
796: headache and some bug reports, so we strongly recommend it. You can find an
797: explanation of this file in the CVS documentation.
1.2 rillig 798:
799: # recommended CVS configuration file from the pkgsrc guide
1.155 sevan 800: cvs -q
1.2 rillig 801: checkout -P
1.4 rillig 802: update -dP
803: diff -upN
1.2 rillig 804: rdiff -u
1.24 wiz 805: release -d
1.1 dsieger 806:
1.154 rillig 807: 3.2. Keeping pkgsrc up-to-date
1.1 dsieger 808:
809: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
810: have first installed it via a tar file). It saves bandwidth and hard disk
811: activity, compared to downloading the tar file again.
812:
1.154 rillig 813: 3.2.1. Via tar files
1.1 dsieger 814:
815: Warning
816:
817: When updating from a tar file, you first need to completely remove the old
818: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
819: the mean time will not be removed on your local disk, resulting in
820: inconsistencies. When removing the old files, any changes that you have done to
821: the pkgsrc files will be lost after updating. Therefore updating via CVS is
822: strongly recommended.
823:
824: Note that by default the distfiles and the binary packages are saved in the
825: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78 snj 826: configure pkgsrc to store distfiles and packages in directories outside the
1.154 rillig 827: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter 6,
1.78 snj 828: Configuring pkgsrc for the details.
1.1 dsieger 829:
830: To update pkgsrc from a tar file, download the tar file as explained above.
831: Then, make sure that you have not made any changes to the files in the pkgsrc
832: directory. Remove the pkgsrc directory and extract the new tar file. Done.
833:
1.154 rillig 834: 3.2.2. Via CVS
1.1 dsieger 835:
1.26 spz 836: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12 weinem 837:
1.26 spz 838: $ cd /usr/pkgsrc && cvs update -dP
839:
840: If you get error messages from rsh, you need to set CVS_RSH variable as
841: described above. E.g.:
842:
843: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1 dsieger 844:
1.154 rillig 845: 3.2.2.1. Switching between different pkgsrc branches
1.1 dsieger 846:
847: When updating pkgsrc, the CVS program keeps track of the branch you selected.
848: But if you, for whatever reason, want to switch from the stable branch to the
849: current one, you can do it by adding the option "-A" after the "update"
1.25 wiz 850: keyword. To switch from the current branch back to the stable branch, add the "
1.214 leot 851: -rpkgsrc-2021Q4" option.
1.1 dsieger 852:
1.154 rillig 853: 3.2.2.2. What happens to my changes when updating?
1.1 dsieger 854:
855: When you update pkgsrc, the CVS program will only touch those files that are
856: registered in the CVS repository. That means that any packages that you created
857: on your own will stay unmodified. If you change files that are managed by CVS,
858: later updates will try to merge your changes with those that have been done by
859: others. See the CVS manual, chapter "update" for details.
860:
1.154 rillig 861: Chapter 4. Using pkgsrc on systems other than NetBSD
1.1 dsieger 862:
863: Table of Contents
864:
1.154 rillig 865: 4.1. Binary distribution
866: 4.2. Bootstrapping pkgsrc
1.1 dsieger 867:
1.154 rillig 868: 4.1. Binary distribution
1.1 dsieger 869:
1.154 rillig 870: See Section 5.1, "Using binary packages".
1.1 dsieger 871:
1.154 rillig 872: 4.2. Bootstrapping pkgsrc
1.1 dsieger 873:
1.44 asau 874: pkgsrc can be bootstrapped for use in two different modes: privileged and
875: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45 asau 876: programs are installed under one particular user and cannot utilise privileged
1.44 asau 877: operations (packages don't create special users and all special file
878: permissions like setuid are ignored).
879:
1.1 dsieger 880: Installing the bootstrap kit from source should be as simple as:
881:
1.60 asau 882: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 883: # cd pkgsrc/bootstrap
884: # ./bootstrap
885:
886:
1.44 asau 887: To bootstrap in unprivileged mode pass "--unprivileged" flag to bootstrap
888:
889: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1.118 sevan 890: will be installed in, and /usr/pkg/pkgdb for the package database directory
891: where pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1.44 asau 892: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1.118 sevan 893: for prefix, ~/pkg/pkgdb for the package database, and ~/pkg/var for varbase.
1.44 asau 894:
895: You can change default layout using command-line arguments. Run "./bootstrap
896: --help" to get details.
1.1 dsieger 897:
898: Note
899:
900: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
901: For examples in this guide, use bmake instead of "make".
902:
1.44 asau 903: Note
904:
905: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
906: directories. Use bmake corresponding to the installation you're working with to
907: build and install packages.
908:
1.154 rillig 909: Chapter 5. Using pkgsrc
1.1 dsieger 910:
911: Table of Contents
912:
1.154 rillig 913: 5.1. Using binary packages
914: 5.1.1. Finding binary packages
915: 5.1.2. Installing binary packages
1.202 nia 916: 5.1.3. Updating packages
917: 5.1.4. Deinstalling packages
918: 5.1.5. Getting information about installed packages
919: 5.1.6. Checking for security vulnerabilities in installed packages
920: 5.1.7. Finding if newer versions of your installed packages are in pkgsrc
921: 5.1.8. Other administrative functions
1.154 rillig 922: 5.2. Building packages from source
923: 5.2.1. Requirements
924: 5.2.2. Fetching distfiles
925: 5.2.3. How to build and install
1.1 dsieger 926:
927: Basically, there are two ways of using pkgsrc. The first is to only install the
928: package tools and to use binary packages that someone else has prepared. This
929: is the "pkg" in pkgsrc. The second way is to install the "src" of pkgsrc, too.
930: Then you are able to build your own packages, and you can still use binary
931: packages from someone else.
932:
1.154 rillig 933: 5.1. Using binary packages
1.1 dsieger 934:
1.151 sevan 935: On the cdn.NetBSD.org site and mirrors, there are collections of binary
1.9 rillig 936: packages, ready to be installed. These binary packages have been built using
937: the default settings for the directories, that is:
938:
939: * /usr/pkg for LOCALBASE, where most of the files are installed,
940:
941: * /usr/pkg/etc for configuration files,
942:
943: * /var for VARBASE, where those files are installed that may change after
944: installation.
945:
946: If you cannot use these directories for whatever reasons (maybe because you're
947: not root), you cannot use these binary packages, but have to build the packages
1.154 rillig 948: yourself, which is explained in Section 4.2, "Bootstrapping pkgsrc".
1.1 dsieger 949:
1.154 rillig 950: 5.1.1. Finding binary packages
1.1 dsieger 951:
1.5 weinem 952: To install binary packages, you first need to know from where to get them. The
1.202 nia 953: first place where you should look is on the main pkgsrc CDN in the directory /
954: pub/pkgsrc/packages.
1.5 weinem 955:
956: This directory contains binary packages for multiple platforms. First, select
1.226 gutterid 957: your operating system. Then, select your hardware architecture, and in the
958: third step, the OS version and the "version" of pkgsrc.
1.9 rillig 959:
1.226 gutterid 960: In this directory, you may find a file called bootstrap.tar.gz which contains
1.9 rillig 961: the package management tools. If the file is missing, it is likely that your
962: operating system already provides those tools. Download the file and extract it
963: in the / directory. It will create the directories /usr/pkg (containing the
1.118 sevan 964: tools for managing binary packages and the database of installed packages).
1.1 dsieger 965:
1.154 rillig 966: 5.1.2. Installing binary packages
1.1 dsieger 967:
1.85 wiz 968: In the directory from the last section, there is a subdirectory called All/,
1.9 rillig 969: which contains all the binary packages that are available for the platform,
1.202 nia 970: excluding those that may not be distributed via HTTP or FTP.
1.9 rillig 971:
972: To install packages directly from an FTP or HTTP server, run the following
973: commands in a Bourne-compatible shell (be sure to su to root first):
974:
1.202 nia 975: # PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
976: # PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages"
1.169 rillig 977: # PKG_PATH="$PKG_PATH/OPSYS/ARCH/VERSIONS/All/"
1.9 rillig 978: # export PATH PKG_PATH
1.202 nia 979: # pkg_add pkgin
1.9 rillig 980:
981: Instead of URLs, you can also use local paths, for example if you are
982: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
983: to install packages from multiple sources, you can separate them by a semicolon
984: in PKG_PATH.
985:
986: After these preparations, installing a package is very easy:
987:
1.202 nia 988: # pkgin search nginx
989: nginx-1.19.6 Lightweight HTTP server and mail proxy server
990: nginx-1.18.0nb8 Lightweight HTTP server and mail proxy server
991: # pkgin install zsh nginx-1.19.6 vim
1.1 dsieger 992:
1.202 nia 993: Note that pkgin is a user-friendly frontend to the pkg_* tools.
1.1 dsieger 994:
1.202 nia 995: Any prerequisite packages needed to run the package in question will be
996: installed, too, assuming they are present in the repository.
1.1 dsieger 997:
998: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
999: in your PATH so you can actually start the just installed program.
1000:
1.202 nia 1001: 5.1.3. Updating packages
1.1 dsieger 1002:
1.202 nia 1003: To update binary packages, it is recommended that you use pkgin upgrade. This
1004: will compare the remote package repository to your locally installed packages
1005: and safely replace any older packages.
1.1 dsieger 1006:
1.202 nia 1007: Note that pkgsrc is released as quarterly branches. If you are updating to a
1008: newer quarterly branch of pkgsrc, you may need to adjust the repository in /usr
1009: /pkg/etc/pkgin/repositories.conf.
1.1 dsieger 1010:
1.202 nia 1011: 5.1.4. Deinstalling packages
1.1 dsieger 1012:
1.202 nia 1013: To deinstall a package, it does not matter whether it was installed from source
1014: code or from a binary package. Neither the pkgin or the pkg_delete command need
1015: to know.
1.1 dsieger 1016:
1.202 nia 1017: To delete a package, you can just run pkgin remove package-name. The package
1018: name can be given with or without version number.
1.1 dsieger 1019:
1.202 nia 1020: 5.1.5. Getting information about installed packages
1.1 dsieger 1021:
1022: The pkg_info shows information about installed packages or binary package
1.202 nia 1023: files. As with other management tools, it works with packages installed from
1024: source or binaries.
1.1 dsieger 1025:
1.202 nia 1026: 5.1.6. Checking for security vulnerabilities in installed packages
1.1 dsieger 1027:
1.202 nia 1028: The pkgsrc Security Team and Packages Groups maintain a list of known
1.164 leot 1029: vulnerabilities to packages which are (or have been) included in pkgsrc. The
1.202 nia 1030: list is available from the NetBSD CDN at https://cdn.NetBSD.org/pub/NetBSD/
1.179 rillig 1031: packages/vulns/pkg-vulnerabilities.
1.1 dsieger 1032:
1.202 nia 1033: Please note that not every "vulnerability" with a CVE assignment is exploitable
1034: in every configuration. Some bugs are marked as active simply because an fix
1035: was not marked as such. Operating system specific hardening and mitigation
1036: features may also reduce the impact of bugs.
1037:
1.23 jakllsch 1038: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
1039: automatically, and a security audit of all packages installed on a system can
1040: take place.
1041:
1042: There are two components to auditing. The first step, pkg_admin
1043: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
1044: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
1045: your installed packages are vulnerable. If a package is vulnerable, you will
1046: see output similar to the following:
1.1 dsieger 1047:
1048: Package samba-2.0.9 has a local-root-shell vulnerability, see
1.174 leot 1049: https://www.samba.org/samba/whatsnew/macroexploit.html
1.1 dsieger 1050:
1.23 jakllsch 1051: You may wish to have the vulnerabilities file downloaded daily so that it
1052: remains current. This may be done by adding an appropriate entry to the root
1053: users crontab(5) entry. For example the entry
1054:
1.121 sevan 1055: # Download vulnerabilities file
1.118 sevan 1056: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.121 sevan 1057: # Audit the installed packages and email results to root
1058: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
1059: root >/dev/null 2>&1
1.118 sevan 1060:
1061:
1062: will update the vulnerability list every day at 3AM, followed by an audit at
1063: 3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
1064: accomplished instead by adding the following line to /etc/daily.conf:
1065:
1066: fetch_pkg_vulnerabilities=YES
1067:
1.23 jakllsch 1068:
1.118 sevan 1069: to fetch the vulnerability list from the daily security script. The system is
1070: set to audit the packages by default but can be set explicitly, if desired (not
1.123 wiz 1071: required), by adding the following line to /etc/security.conf:
1.23 jakllsch 1072:
1.118 sevan 1073: check_pkg_vulnerabilities=YES
1.23 jakllsch 1074:
1075:
1.118 sevan 1076: see daily.conf(5) and security.conf(5) for more details.
1.1 dsieger 1077:
1.202 nia 1078: 5.1.7. Finding if newer versions of your installed packages are in pkgsrc
1.1 dsieger 1079:
1.12 weinem 1080: Install pkgtools/lintpkgsrc and run lintpkgsrc with the "-i" argument to check
1.202 nia 1081: if any packages are stale, e.g.
1.1 dsieger 1082:
1083: % lintpkgsrc -i
1084: ...
1085: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
1086:
1087:
1.202 nia 1088: 5.1.8. Other administrative functions
1.1 dsieger 1089:
1090: The pkg_admin executes various administrative functions on the package system.
1091:
1.154 rillig 1092: 5.2. Building packages from source
1.1 dsieger 1093:
1094: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25 wiz 1095: organized into categories. You can browse the online index of packages, or run
1.1 dsieger 1096: make readme from the pkgsrc directory to build local README.html files for all
1097: packages, viewable with any web browser such as www/lynx or www/firefox.
1098:
1099: The default prefix for installed packages is /usr/pkg. If you wish to change
1100: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
1101: use multiple different LOCALBASE definitions on the same system (inside a
1102: chroot is an exception).
1103:
1104: The rest of this chapter assumes that the package is already in pkgsrc. If it
1105: is not, see Part II, "The pkgsrc developer's guide" for instructions how to
1106: create your own packages.
1107:
1.154 rillig 1108: 5.2.1. Requirements
1.1 dsieger 1109:
1110: To build packages from source, you need a working C compiler. On NetBSD, you
1111: need to install the "comp" and the "text" distribution sets. If you want to
1112: build X11-related packages, the "xbase" and "xcomp" distribution sets are
1113: required, too.
1114:
1.154 rillig 1115: 5.2.2. Fetching distfiles
1.1 dsieger 1116:
1117: The first step for building a package is downloading the distfiles (i.e. the
1118: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
1119: them automatically.
1120:
1121: If you have all files that you need in the distfiles directory, you don't need
1122: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
1123: and add:
1124:
1125: DISTDIR=/cdrom/pkgsrc/distfiles
1126:
1127: to your mk.conf.
1128:
1129: By default a list of distribution sites will be randomly intermixed to prevent
1130: huge load on servers which holding popular packages (for example,
1131: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
1132: distfile all the mirrors will be tried in new (random) order. You can turn this
1133: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
1134: disabled).
1135:
1136: You can overwrite some of the major distribution sites to fit to sites that are
1137: close to your own. By setting one or two variables you can modify the order in
1138: which the master sites are accessed. MASTER_SORT contains a whitespace
1139: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
1140: contains a whitespace delimited list of regular expressions. It has higher
1141: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
1142: some examples. This may save some of your bandwidth and time.
1143:
1144: You can change these settings either in your shell's environment, or, if you
1.4 rillig 1145: want to keep the settings, by editing the mk.conf file, and adding the
1.1 dsieger 1146: definitions there.
1147:
1.132 wiz 1148: If a package depends on many other packages (such as meta-pkgs/kde4), the build
1.1 dsieger 1149: process may alternate between periods of downloading source, and compiling. To
1150: ensure you have all the source downloaded initially you can run the command:
1151:
1152: % make fetch-list | sh
1153:
1154: which will output and run a set of shell commands to fetch the necessary files
1155: into the distfiles directory. You can also choose to download the files
1156: manually.
1157:
1.154 rillig 1158: 5.2.3. How to build and install
1.1 dsieger 1159:
1160: Once the software has downloaded, any patches will be applied, then it will be
1161: compiled for you. This may take some time depending on your computer, and how
1162: many other packages the software depends on and their compile time.
1163:
1164: Note
1165:
1166: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
1167: command instead of "make" in the examples in this guide.
1168:
1169: For example, type
1170:
1171: % cd misc/figlet
1172: % make
1173:
1174:
1175: at the shell prompt to build the various components of the package.
1176:
1177: The next stage is to actually install the newly compiled program onto your
1178: system. Do this by entering:
1179:
1180: % make install
1181:
1182:
1183: while you are still in the directory for whatever package you are installing.
1184:
1185: Installing the package on your system may require you to be root. However,
1186: pkgsrc has a just-in-time-su feature, which allows you to only become root for
1187: the actual installation step.
1188:
1189: That's it, the software should now be installed and setup for use. You can now
1190: enter:
1191:
1192: % make clean
1193:
1194:
1195: to remove the compiled files in the work directory, as you shouldn't need them
1196: any more. If other packages were also added to your system (dependencies) to
1197: allow your program to compile, you can tidy these up also with the command:
1198:
1199: % make clean-depends
1200:
1201:
1202: Taking the figlet utility as an example, we can install it on our system by
1.207 leot 1203: building as shown in Appendix C, Build logs.
1.1 dsieger 1204:
1205: The program is installed under the default root of the packages tree - /usr/
1206: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
1207: environment, and it will use that value as the root of your packages tree. So,
1208: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
1209: that you should use a directory which is dedicated to packages and not shared
1210: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
1211: not try to add any of your own files or directories (such as src/, obj/, or
1212: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
1213: between programs and other files installed by the package system and whatever
1214: else may have been installed there.
1215:
1.4 rillig 1216: Some packages look in mk.conf to alter some configuration options at build
1.1 dsieger 1217: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
1218: be set there by default. Environment variables such as LOCALBASE can be set in
1.4 rillig 1219: mk.conf to save having to remember to set them each time you want to use
1.1 dsieger 1220: pkgsrc.
1221:
1222: Occasionally, people want to "look under the covers" to see what is going on
1223: when a package is building or being installed. This may be for debugging
1224: purposes, or out of simple curiosity. A number of utility values have been
1225: added to help with this.
1226:
1227: 1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
1228: amount of information will be displayed. For example,
1229:
1230: make patch PKG_DEBUG_LEVEL=2
1231:
1.25 wiz 1232: will show all the commands that are invoked, up to and including the "patch
1233: " stage.
1.1 dsieger 1234:
1235: 2. If you want to know the value of a certain make(1) definition, then the
1236: VARNAME definition should be used, in conjunction with the show-var target.
1237: e.g. to show the expansion of the make(1) variable LOCALBASE:
1238:
1239: % make show-var VARNAME=LOCALBASE
1240: /usr/pkg
1241: %
1242:
1243:
1244: If you want to install a binary package that you've either created yourself
1245: (see next section), that you put into pkgsrc/packages manually or that is
1246: located on a remote FTP server, you can use the "bin-install" target. This
1247: target will install a binary package - if available - via pkg_add(1), else do a
1248: make package. The list of remote FTP sites searched is kept in the variable
1249: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
1250: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
1251: for more details.
1252:
1253: A final word of warning: If you set up a system that has a non-standard setting
1254: for LOCALBASE, be sure to set that before any packages are installed, as you
1255: cannot use several directories for the same purpose. Doing so will result in
1256: pkgsrc not being able to properly detect your installed packages, and fail
1257: miserably. Note also that precompiled binary packages are usually built with
1258: the default LOCALBASE of /usr/pkg, and that you should not install any if you
1259: use a non-standard LOCALBASE.
1260:
1.154 rillig 1261: Chapter 6. Configuring pkgsrc
1.1 dsieger 1262:
1263: Table of Contents
1264:
1.154 rillig 1265: 6.1. General configuration
1266: 6.2. Variables affecting the build process
1267: 6.3. Variables affecting the installation process
1268: 6.4. Selecting and configuring the compiler
1269: 6.4.1. Selecting the compiler
1270: 6.4.2. Additional flags to the compiler (CFLAGS)
1271: 6.4.3. Additional flags to the linker (LDFLAGS)
1272: 6.5. Developer/advanced settings
1273: 6.6. Selecting Build Options
1.1 dsieger 1274:
1275: The whole pkgsrc system is configured in a single file, usually called mk.conf.
1276: In which directory pkgsrc looks for that file depends on the installation. On
1277: NetBSD, when you use make(1) from the base system, it is in the directory /etc
1278: /. In all other cases the default location is ${PREFIX}/etc/, depending on
1279: where you told the bootstrap program to install the binary packages.
1280:
1281: The format of the configuration file is that of the usual BSD-style Makefiles.
1282: The whole pkgsrc configuration is done by setting variables in this file. Note
1283: that you can define all kinds of variables, and no special error checking (for
1.112 rillig 1284: example for spelling mistakes) takes place.
1.1 dsieger 1285:
1.154 rillig 1286: 6.1. General configuration
1.1 dsieger 1287:
1.112 rillig 1288: The following variables apply to all pkgsrc packages. A complete list of the
1289: variables that can be configured by the user is available in mk/defaults/
1290: mk.conf, together with some comments that describe each variable's intent.
1.1 dsieger 1291:
1292: * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
1293: not mix binary packages with different LOCALBASEs!
1294:
1295: * CROSSBASE: Where "cross" category packages will be installed. The default
1296: is ${LOCALBASE}/cross.
1297:
1.84 wiz 1298: * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1 dsieger 1299:
1300: * DISTDIR: Where to store the downloaded copies of the original source
1301: distributions used for building pkgsrc packages. The default is $
1302: {PKGSRCDIR}/distfiles.
1303:
1304: * PKG_DBDIR: Where the database about installed packages is stored. The
1.118 sevan 1305: default is /usr/pkg/pkgdb.
1.1 dsieger 1306:
1307: * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
1308: value.
1309:
1310: * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
1311: files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.118 sevan 1312: respectively. The defaults is ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1.1 dsieger 1313: {DIST_SUBDIR}/.
1314:
1315: * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
1316: with OS release ("2.0", etc.) and architecture ("mipsel", etc.).
1317:
1.23 jakllsch 1318: * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
1319: case-sensitive. Whenever you try to build a package whose license is not in
1320: this list, you will get an error message. If the license condition is
1321: simple enough, the error message will include specific instructions on how
1322: to change this variable.
1.1 dsieger 1323:
1.154 rillig 1324: 6.2. Variables affecting the build process
1.1 dsieger 1325:
1326: * PACKAGES: The top level directory for the binary packages. The default is $
1327: {PKGSRCDIR}/packages.
1328:
1329: * WRKOBJDIR: The top level directory where, if defined, the separate working
1330: directories will get created, and symbolically linked to from ${WRKDIR}
1331: (see below). This is useful for building packages on several architectures,
1332: then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
1333: architecture. (It should be noted that PKGSRCDIR should not be set by the
1.198 leot 1334: user -- it is an internal definition which refers to the root of the pkgsrc
1.1 dsieger 1335: tree. It is possible to have many pkgsrc tree instances.)
1336:
1337: * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.184 rillig 1338: Section 12.3, "patches/*" for more information.
1.1 dsieger 1339:
1340: * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
1341: Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
1342: up settings used by builds in /usr/src.
1343:
1.154 rillig 1344: 6.3. Variables affecting the installation process
1.1 dsieger 1345:
1.198 leot 1346: * PKGSRC_KEEP_BIN_PKGS: By default, binary packages of built packages are
1.150 leot 1347: preserved in ${PACKAGES}/All. Setting this variable to "no" prevents this.
1.1 dsieger 1348:
1.107 jnemeth 1349: Packages have to support installation into a subdirectory of WRKDIR. This
1350: allows a package to be built, before the actual filesystem is touched. DESTDIR
1351: support exists in two variations:
1.4 rillig 1352:
1353: * Basic DESTDIR support means that the package installation and packaging is
1354: still run as root.
1355:
1356: * Full DESTDIR support can run the complete build, installation and packaging
1357: as normal user. Root privileges are only needed to add packages.
1358:
1359: With basic DESTDIR support, make clean needs to be run as root.
1360:
1.17 imil 1361: Considering the foo/bar package, DESTDIR full support can be tested using the
1362: following commands
1363:
1364: $ id
1365: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
1366: $ mkdir $HOME/packages
1367: $ cd $PKGSRCDIR/foo/bar
1368:
1369: Verify DESTDIR full support, no root privileges should be needed
1370:
1.66 asau 1371: $ make stage-install
1.17 imil 1372:
1373: Create a package without root privileges
1374:
1.66 asau 1375: $ make PACKAGES=$HOME/packages package
1.17 imil 1376:
1377: For the following command, you must be able to gain root privileges using su(1)
1378:
1.66 asau 1379: $ make PACKAGES=$HOME/packages install
1.17 imil 1380:
1381: Then, as a simple user
1382:
1383: $ make clean
1384:
1.154 rillig 1385: 6.4. Selecting and configuring the compiler
1.4 rillig 1386:
1.154 rillig 1387: 6.4.1. Selecting the compiler
1.1 dsieger 1388:
1389: By default, pkgsrc will use GCC to build packages. This may be overridden by
1390: setting the following variables in /etc/mk.conf:
1391:
1392: PKGSRC_COMPILER:
1393:
1394: This is a list of values specifying the chain of compilers to invoke when
1395: building packages. Valid values are:
1396:
1.232 gutterid 1397: o ccc: Compaq C Compilers (Tru64)
1.66 asau 1398:
1.232 gutterid 1399: o ccache: compiler cache (chainable)
1.66 asau 1400:
1.232 gutterid 1401: o clang: Clang C and Objective-C compiler
1.66 asau 1402:
1.232 gutterid 1403: o distcc: distributed C/C++ (chainable)
1.1 dsieger 1404:
1.232 gutterid 1405: o f2c: Fortran 77 to C compiler (chainable)
1.66 asau 1406:
1.232 gutterid 1407: o icc: Intel C++ Compiler (Linux)
1.66 asau 1408:
1.232 gutterid 1409: o ido: SGI IRIS Development Option cc (IRIX 5)
1.1 dsieger 1410:
1.232 gutterid 1411: o gcc: GNU C/C++ Compiler
1.1 dsieger 1412:
1.232 gutterid 1413: o hp: HP-UX C/aC++ compilers
1.66 asau 1414:
1.232 gutterid 1415: o mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1 dsieger 1416:
1.232 gutterid 1417: o mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1 dsieger 1418:
1.232 gutterid 1419: o sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1 dsieger 1420:
1.232 gutterid 1421: o xlc: IBM's XL C/C++ compiler suite
1.66 asau 1422:
1.1 dsieger 1423: The default is "gcc". You can use ccache and/or distcc with an appropriate
1424: PKGSRC_COMPILER setting, e.g. "ccache gcc". This variable should always be
1425: terminated with a value for a real compiler. Note that only one real
1426: compiler should be listed (e.g. "sunpro gcc" is not allowed).
1427:
1428: GCC_REQD:
1429:
1430: This specifies the minimum version of GCC to use when building packages. If
1431: the system GCC doesn't satisfy this requirement, then pkgsrc will build and
1432: install one of the GCC packages to use instead.
1433:
1.153 leot 1434: PYTHON_VERSION_DEFAULT:
1.114 maya 1435:
1436: Specifies which version of python to use when several options are
1437: available.
1438:
1439: PKGSRC_FORTRAN:
1440:
1.176 gutterid 1441: Specifies the Fortran compiler to use. The default is gfortran.
1.114 maya 1442:
1443: GFORTRAN_VERSION:
1444:
1445: If PKGSRC_FORTRAN= gfortran is used, this option specifies which version to
1446: use.
1447:
1.154 rillig 1448: 6.4.2. Additional flags to the compiler (CFLAGS)
1.1 dsieger 1449:
1450: If you wish to set the CFLAGS variable, please make sure to use the += operator
1451: instead of the = operator:
1452:
1453: CFLAGS+= -your -flags
1454:
1455: Using CFLAGS= (i.e. without the "+") may lead to problems with packages that
1.16 jnemeth 1456: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24 wiz 1457: package if you're interested in optimization specifically for the current CPU.
1.1 dsieger 1458:
1.154 rillig 1459: 6.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 1460:
1461: If you want to pass flags to the linker, both in the configure step and the
1462: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
1463: difference between the two is that LIBS will be appended to the command line,
1464: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
1465: machines depending on the setting of USE_IMAKE or the inclusion of mk/
1466: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
1467: settings, use the += operator:
1468:
1469: LDFLAGS+= -your -linkerflags
1470:
1.154 rillig 1471: 6.5. Developer/advanced settings
1.1 dsieger 1472:
1473: * PKG_DEVELOPER: Run some sanity checks that package developers want:
1474:
1.42 asau 1475: + make sure patches apply with zero fuzz
1.1 dsieger 1476:
1.42 asau 1477: + run check-shlibs to see that all binaries will find their shared libs.
1.1 dsieger 1478:
1.232 gutterid 1479: * CHECK_FILES_STRICT: Also check VARBASE and PKG_SYSCONFDIR values in PLIST
1480: entries.
1481:
1.1 dsieger 1482: * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
1483: making and installing the package. The default value for this is 0, which
1484: will not display the commands as they are executed (normal, default, quiet
1485: operation); the value 1 will display all shell commands before their
1486: invocation, and the value 2 will display both the shell commands before
1.112 rillig 1487: their invocation, as well as their actual execution progress with set -x.
1.1 dsieger 1488:
1.154 rillig 1489: 6.6. Selecting Build Options
1.1 dsieger 1490:
1491: Some packages have build time options, usually to select between different
1492: dependencies, enable optional support for big dependencies or enable
1493: experimental features.
1494:
1495: To see which options, if any, a package supports, and which options are
1496: mutually exclusive, run make show-options, for example:
1497:
1498: The following options are supported by this package:
1499: ssl Enable SSL support.
1500: Exactly one of the following gecko options is required:
1501: firefox Use firefox as gecko rendering engine.
1502: mozilla Use mozilla as gecko rendering engine.
1503: At most one of the following database options may be selected:
1504: mysql Enable support for MySQL database.
1505: pgsql Enable support for PostgreSQL database.
1506:
1507: These options are enabled by default: firefox
1508: These options are currently enabled: mozilla ssl
1509:
1.4 rillig 1510: The following variables can be defined in mk.conf to select which options to
1511: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1 dsieger 1512: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
1513: which can be used to select or disable options specifically for package pkgbase
1514: . Options listed in these variables are selected, options preceded by "-" are
1515: disabled. A few examples:
1516:
1.4 rillig 1517: $ grep "PKG.*OPTION" mk.conf
1.1 dsieger 1518: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
1519: PKG_OPTIONS.kdebase= debug -sasl
1520: PKG_OPTIONS.apache= suexec
1521:
1.11 rillig 1522: It is important to note that options that were specifically suggested by the
1.19 snj 1523: package maintainer must be explicitly removed if you do not wish to include the
1524: option. If you are unsure you can view the current state with make show-options
1525: .
1.11 rillig 1526:
1.1 dsieger 1527: The following settings are consulted in the order given, and the last setting
1528: that selects or disables an option is used:
1529:
1530: 1. the default options as suggested by the package maintainer
1531:
1532: 2. the options implied by the settings of legacy variables (see below)
1533:
1534: 3. PKG_DEFAULT_OPTIONS
1535:
1536: 4. PKG_OPTIONS.pkgbase
1537:
1538: For groups of mutually exclusive options, the last option selected is used, all
1539: others are automatically disabled. If an option of the group is explicitly
1540: disabled, the previously selected option, if any, is used. It is an error if no
1541: option from a required group of options is selected, and building the package
1542: will fail.
1543:
1544: Before the options framework was introduced, build options were selected by
1.4 rillig 1545: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
1546: transition to the options framework for the user, these legacy variables are
1547: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
1548: automatically. A warning is issued to prompt the user to update mk.conf to use
1549: the options framework directly. Support for the legacy variables will be
1.1 dsieger 1550: removed eventually.
1551:
1.154 rillig 1552: Chapter 7. Creating binary packages
1.1 dsieger 1553:
1554: Table of Contents
1555:
1.154 rillig 1556: 7.1. Building a single binary package
1557: 7.2. Settings for creation of binary packages
1.1 dsieger 1558:
1.154 rillig 1559: 7.1. Building a single binary package
1.1 dsieger 1560:
1561: Once you have built and installed a package, you can create a binary package
1562: which can be installed on another system with pkg_add(1). This saves having to
1563: build the same package on a group of hosts and wasting CPU time. It also
1564: provides a simple means for others to install your package, should you
1565: distribute it.
1566:
1567: To create a binary package, change into the appropriate directory in pkgsrc,
1568: and run make package:
1569:
1.112 rillig 1570: $ cd misc/figlet
1571: $ make package
1.1 dsieger 1572:
1573: This will build and install your package (if not already done), and then build
1574: a binary package from what was installed. You can then use the pkg_* tools to
1575: manipulate it. Binary packages are created by default in /usr/pkgsrc/packages,
1.207 leot 1576: in the form of a gzipped tar file. See Section C.2, "Packaging figlet" for a
1.1 dsieger 1577: continuation of the above misc/figlet example.
1578:
1.154 rillig 1579: See Chapter 23, Submitting and Committing for information on how to submit such
1.1 dsieger 1580: a binary package.
1581:
1.154 rillig 1582: 7.2. Settings for creation of binary packages
1.1 dsieger 1583:
1.184 rillig 1584: See Section 13.17, "Other helpful targets".
1.6 rillig 1585:
1.154 rillig 1586: Chapter 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6 rillig 1587:
1588: Table of Contents
1589:
1.154 rillig 1590: 8.1. Preparations
1.180 rillig 1591: 8.2. Running a bulk build
1.154 rillig 1592: 8.2.1. Configuration
1593: 8.3. Requirements of a full bulk build
1.178 rillig 1594: 8.4. Bulk build variants
1.179 rillig 1595: 8.4.1. Detect unknown configure options
1596: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.181 rillig 1597: 8.4.3. Force compiler options only in the build phase
1598: 8.4.4. Use custom directories
1599: 8.4.5. Turn warnings into errors
1600: 8.4.6. Reject packages for which pkglint reports errors
1601: 8.4.7. Reject packages that contain forbidden strings
1602: 8.4.8. Reject packages whose self-test fails
1603: 8.4.9. Reject packages that use undefined shell variables
1604: 8.4.10. Turn off verbose logging
1.178 rillig 1605: 8.5. Creating a multiple CD-ROM packages collection
1606: 8.5.1. Example of cdpack
1.6 rillig 1607:
1.175 gutterid 1608: For a number of reasons, you may want to build binary packages for a large
1609: selected set of packages in pkgsrc, or even for all pkgsrc packages. For
1.71 wiz 1610: instance, when you have multiple machines that should run the same software, it
1611: is wasted time if they all build their packages themselves from source. Or you
1612: may want to build a list of packages you want and check them before deploying
1.175 gutterid 1613: onto production systems. There is a way of getting a set of binary packages:
1614: the bulk build system, or pbulk ("p" stands for "parallel"). This chapter
1615: describes how to set it up.
1.71 wiz 1616:
1.154 rillig 1617: 8.1. Preparations
1.71 wiz 1618:
1619: First of all, you have to decide whether you build all packages or a limited
1620: set of them. Full bulk builds usually consume a lot more resources, both space
1.175 gutterid 1621: and time, than builds for some practical sets of packages. A number of
1622: particularly heavy packages exist that are not actually interesting to a wide
1623: audience. (The approximate resource consumption for a full bulk build is given
1624: in section Section 8.3, "Requirements of a full bulk build".) For limited bulk
1625: builds you need to make a list of packages you want to build. Note that all
1626: their dependencies will be built, so you don't need to track them manually.
1.71 wiz 1627:
1628: During bulk builds various packages are installed and deinstalled in /usr/pkg
1629: (or whatever LOCALBASE is), so make sure that you don't need any package during
1.112 rillig 1630: the builds. Essentially, you should provide a fresh system, either a chroot
1.71 wiz 1631: environment or something even more restrictive, depending on what the operating
1632: system provides, or dedicate the whole physical machine. As a useful side
1633: effect this makes sure that bulk builds cannot break anything in your system.
1634: There have been numerous cases where certain packages tried to install files
1635: outside the LOCALBASE or wanted to edit some files in /etc.
1.6 rillig 1636:
1.180 rillig 1637: 8.2. Running a bulk build
1.6 rillig 1638:
1.180 rillig 1639: Running a bulk build works roughly as follows:
1.15 rillig 1640:
1641: * First, build the pbulk infrastructure in a fresh pkgsrc location.
1642:
1643: * Then, build each of the packages from a clean installation directory using
1644: the infrastructure.
1645:
1.154 rillig 1646: 8.2.1. Configuration
1.6 rillig 1647:
1.112 rillig 1648: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6 rillig 1649:
1.68 asau 1650: In order to use it, prepare a clear system (real one, chroot environment, jail,
1651: zone, virtual machine). Configure network access to fetch distribution files.
1.112 rillig 1652: Create a user with name "pbulk".
1.68 asau 1653:
1654: Fetch and extract pkgsrc. Use a command like one of these:
1655:
1.151 sevan 1656: # (cd /usr && ftp -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1657: # (cd /usr && fetch -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1.72 wiz 1658: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68 asau 1659:
1660: Or any other way that fits (e.g., curl, wget).
1661:
1662: Deploy and configure pbulk tools, e.g.:
1663:
1.118 sevan 1664: # sh pbulk.sh -n # use native make, no bootstrap kit needed (for use on NetBSD)
1.68 asau 1665: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
1666: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
1667:
1668: Note
1669:
1670: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
1671: to packages you build. For instance,
1672:
1.112 rillig 1673: PKG_DEVELOPER= yes # perform more checks
1674: X11_TYPE= modular # use pkgsrc X11
1675: SKIP_LICENSE_CHECK= yes # accept all licences (useful
1676: # when building all packages)
1.68 asau 1677:
1678: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112 rillig 1679: with your list of packages, one per line without empty lines or comments. E.g.:
1.68 asau 1680:
1681: www/firefox
1682: mail/thunderbird
1683: misc/libreoffice4
1684:
1.69 asau 1685: At this point you can also review configuration in /usr/pbulk/etc and make
1686: final amendments, if wanted.
1687:
1.68 asau 1688: Start it:
1689:
1690: # /usr/pbulk/bin/bulkbuild
1691:
1692: After it finishes, you'll have /mnt filled with distribution files, binary
1693: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
1694:
1695: Note
1696:
1697: The pbulk.sh script does not cover all possible use cases. While being ready to
1698: run, it serves as a good starting point to understand and build more complex
1699: setups. The script is kept small enough for better understanding.
1700:
1701: Note
1702:
1703: The pbulk.sh script supports running unprivileged bulk build and helps
1.205 wiz 1704: configuring distributed bulk builds. Distributed bulk builds support either
1705: building in worker chroots (each node is a path to a different chroot) that
1706: replicate the target system, including the pbulk prefix, or remote machines
1707: (each node is an IP address that must be accessible over SSH without a
1708: password).
1.15 rillig 1709:
1.154 rillig 1710: 8.3. Requirements of a full bulk build
1.71 wiz 1711:
1712: A complete bulk build requires lots of disk space. Some of the disk space can
1713: be read-only, some other must be writable. Some can be on remote filesystems
1714: (such as NFS) and some should be local. Some can be temporary filesystems,
1715: others must survive a sudden reboot.
1716:
1.205 wiz 1717: * 70 GB for the distfiles (read-write, remote, temporary)
1.71 wiz 1718:
1.205 wiz 1719: * 60 GB for the binary packages (read-write, remote, permanent)
1.71 wiz 1720:
1721: * 1 GB for the pkgsrc tree (read-only, remote, permanent)
1722:
1723: * 5 GB for LOCALBASE (read-write, local, temporary)
1724:
1725: * 10 GB for the log files (read-write, remote, permanent)
1726:
1727: * 5 GB for temporary files (read-write, local, temporary)
1728:
1.178 rillig 1729: 8.4. Bulk build variants
1730:
1731: To ensure that pkgsrc packages work in different configurations, it makes sense
1732: to run non-default bulk builds from time to time. This section lists some ideas
1733: for bulk builds that intentionally let packages fail if they don't follow the
1734: pkgsrc style.
1735:
1.179 rillig 1736: 8.4.1. Detect unknown configure options
1.178 rillig 1737:
1738: Add the following line to mk.conf.
1739:
1740: GNU_CONFIGURE_STRICT= yes
1741:
1742: When a package fails this additional check, the most common cause is that the
1743: configure option was valid for an older version of the package but does not
1744: apply anymore. In that case, just remove it.
1745:
1.179 rillig 1746: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.178 rillig 1747:
1748: The job of a compiler is not restricted to producing executable code, most
1.179 rillig 1749: compilers also detect typical programming mistakes. The pkgsrc compiler
1750: wrappers make it easy to force compiler options when the package is built. This
1751: can be used to find typical bugs across all packages that are in pkgsrc. By
1752: reporting these bugs upstream, the packages will be more reliable with the next
1753: updates.
1.178 rillig 1754:
1.179 rillig 1755: Add some of the following lines to mk.conf:
1.178 rillig 1756:
1757: CFLAGS+= -Werror=char-subscripts
1.179 rillig 1758: CFLAGS+= -Werror=implicit-function-declaration
1.178 rillig 1759:
1.179 rillig 1760: When a package fails to build using these stricter compiler options, document
1761: the circumstances in which the compiler produced the error message. This
1762: includes:
1.178 rillig 1763:
1764: * The platform (MACHINE_PLATFORM)
1765:
1766: * The source file
1767:
1768: * An excerpt of the code. GCC and Clang already do this as part of the
1769: diagnostic.
1770:
1.179 rillig 1771: * The exact error message from the compiler.
1.178 rillig 1772:
1.179 rillig 1773: If a package produces these error messages, but the package is fine, record
1774: this in your local mk.conf, like this, to skip this check in the next builds:
1.178 rillig 1775:
1.179 rillig 1776: .if ${PKGPATH} == category/package
1.178 rillig 1777: # Version ${VERSION} failed on ${MACHINE_PLATFORM}:
1778: # error message
1779: # code
1.179 rillig 1780: # Reason why the code does not need to be fixed.
1.178 rillig 1781: BUILDLINK_TRANSFORM+= rm:-Werror=char-subscripts
1.179 rillig 1782: .endif
1.178 rillig 1783:
1784: If the error messages from the compiler are valid and the code needs to be
1.179 rillig 1785: fixed, prepare a local patch (see LOCALPATCHES) and report the bug to the
1786: upstream authors of the package, providing them with the information you
1787: collected above.
1.178 rillig 1788:
1.179 rillig 1789: Patches that are not essential for the package to work should only be reported
1790: upstream but not committed to pkgsrc, to make future updates easier.
1791:
1.181 rillig 1792: 8.4.3. Force compiler options only in the build phase
1793:
1794: When adding custom compiler flags via CFLAGS, these apply to all phases of the
1795: package build process. Especially in the configure phase, adding -Werror leads
1796: to wrong decisions. The GNU configure scripts feed many small test programs to
1797: the C compiler to see whether certain headers are available, functions are
1798: defined in a library and programs can be run. In many cases these programs
1799: would not survive a strict compiler run with -Wall -Wextra -Werror.
1800:
1801: The pkgsrc infrastructure is flexible enough to support compiler options being
1802: added between the configure and build phases. It's a little more complicated
1803: than the other examples in this section but still easy enough.
1804:
1805: The basic idea is to use the pkgsrc compiler wrapper to inject the desired
1806: compiler options. The compiler wrapper's original task is to hide unwanted
1807: directories of include files and to normalize compiler options. It does this by
1808: wrapping the compiler command and rewriting the command line. To see this in
1809: action, run bmake patch in a package directory and examine the work/.cwrappers/
1810: config directory. It contains individual configurations for the C compiler and
1811: the related tools. The plan is to find a hook between the configure and build
1812: phases, and to modify these configuration files at that point.
1813:
1814: To find this hook, have a look at mk/build/build.mk, which contains among
1815: others the pre-build-checks-hook. The word checks doesn't quite fit, but the
1816: pre-build-hook sounds good enough.
1817:
1818: The code to be included in mk.conf is:
1819:
1820: # Just a few example options.
1821: BUILD_ONLY_CFLAGS= -Wall -Werror -O2 -DTEMPDIR='"/tmp"'
1822:
1823: .if ${BUILD_ONLY_CFLAGS:U:M*}
1824: pre-build-checks-hook: add-build-only-cflags
1825:
1826: add-build-only-cflags: .PHONY
1827: ${RUN} cd ${CWRAPPERS_CONFIG_DIR}; \
1828: ${TEST} ! -f ${.TARGET} || exit 0; \
1829: for flag in ${BUILD_ONLY_CFLAGS}; do \
1830: ${ECHO} "append=$$flag" >> cc; \
1831: done; \
1832: > ${.TARGET}
1833: .endif
1834:
1835: (When editing the mk.conf, make sure that the commands of the
1836: add-build-only-cflags target are indented with a tab, not with spaces.)
1837:
1838: The condition in the .if statement contains the :U modifier to prevent parse
1839: errors if the variable should be undefined, possibly because it is only defined
1840: for a subset of the packages. The :M* modifier ensures that there is at least
1841: one compiler option, to prevent a syntax error in the shell parser.
1842:
1843: The code around the ${.TARGET} variable ensures that the additional compiler
1844: options are only appended once, even if bmake build is run multiple times. To
1845: do this, it creates a marker file.
1846:
1847: To verify that this setup works, run bmake configure in a package directory. Up
1848: to now, everything works as usual. Examine the directory work/.cwrappers/config
1849: to see that the compiler options from BUILD_ONLY_CFLAGS are not yet added to
1850: the file cc. Examine the tail of the work/.work.log file to see that the normal
1851: compiler options are used.
1852:
1853: Now run bmake build. This will append the options to the file cc and will
1854: create the marker file in the same directory. After that, the build starts as
1855: usual, but with the added compiler options. Examine the tail of the file work
1856: /.work.log to see that the lines starting with [*] don't contain the compiler
1857: options, but the corresponding lines starting with <.> do end with these
1858: options.
1859:
1860: Building packages using this setup variant and fixing the resulting bugs is the
1861: same as in Section 8.4.2, "Detect classes of bugs by forcing compiler warnings"
1862: .
1863:
1864: 8.4.4. Use custom directories
1.178 rillig 1865:
1866: Some directories like PREFIX, VARBASE, PKG_SYSCONFDIR, PKGMANDIR, PKG_INFODIR
1867: can be configured in pkgsrc. Set these to arbitrary paths during bootstrap or
1868: afterwards in mk.conf.
1869:
1870: PREFIX= /a-random-uuid
1871: PKG_SYSCONFDIR= /a-random-uuid
1872: VARBASE= /a-random-uuid
1873: PKGMANDIR= a-random-uuid
1874: PKG_INFODIR= a-random-uuid
1875:
1.181 rillig 1876: 8.4.5. Turn warnings into errors
1.178 rillig 1877:
1878: When building a package, warnings are typically ignored since they just flow by
1879: and do not cause the build to fail immediately. To find these warnings,
1880: redefine them to errors in mk.conf.
1881:
1882: DELAYED_WARNING_MSG= ${DELAYED_ERROR_MSG} "(was warning)"
1883: WARNING_MSG= ${FAIL_MSG} "(was warning)"
1884:
1885: (There are many more classes of warnings in pkgsrc, and most of them can be
1886: redefined with a simple definition like above.
1887:
1.179 rillig 1888: If a package suggests to add USE_TOOLS+=perl to the package Makefile, research
1.178 rillig 1889: whether the package actually needs Perl. If it does, add USE_TOOLS+=perl to the
1890: package Makefile, and if it doesn't, add TOOLS_BROKEN+=perl.
1891:
1.181 rillig 1892: 8.4.6. Reject packages for which pkglint reports errors
1.178 rillig 1893:
1894: Using pkglint as part of the regular build process is mostly a waste of time.
1895: If you want to fix some of the warnings, just run pkglint recursively on the
1896: whole pkgsrc tree. This will take a few minutes (up to 10), which is much
1897: faster than a complete bulk build.
1898:
1.181 rillig 1899: 8.4.7. Reject packages that contain forbidden strings
1.178 rillig 1900:
1901: To ensure that the binary packages don't contain references to the build
1902: directory, there is already CHECK_WRKREF. If that variable includes the item
1903: extra, it is possible to define additional patterns that must not appear in any
1904: installed file. This is specified in mk.conf.
1905:
1906: CHECK_WRKREF= extra
1907: CHECK_WRKREF_EXTRA_DIRS+= /usr/local
1908: CHECK_WRKREF_EXTRA_DIRS+= /usr/pkg
1909: CHECK_WRKREF_EXTRA_DIRS+= @[A-Z][A-Z]*@
1910:
1911: The above patterns will probably generate many false positives, therefore the
1912: results need to be taken with a grain of salt.
1913:
1.181 rillig 1914: 8.4.8. Reject packages whose self-test fails
1.178 rillig 1915:
1916: To run the test suites that come with each package, add this line to mk.conf.
1917:
1918: PKGSRC_RUN_TEST= yes
1919:
1920: Be prepared that even the most basic packages fail this test. When doing a bulk
1921: build with this, it will often abort in the early phase where the packages are
1922: scanned for their dependencies since there are cyclic dependencies. There is
1923: still a lot to do in this area.
1924:
1.181 rillig 1925: 8.4.9. Reject packages that use undefined shell variables
1.178 rillig 1926:
1927: To catch typos in the shell snippets from the Makefile fragments, add the -u
1928: flag to most of the commands by adding this line to mk.conf.
1929:
1930: RUN= @set -eu;
1931:
1.181 rillig 1932: After that, ensure that none of the bulk build log files (even those for
1933: successfully built packages) contains the string parameter not set or whatever
1934: error message the command sh -ceu '$undefined' outputs.
1935:
1.178 rillig 1936: See mk/misc/common.mk for the existing definition.
1937:
1.181 rillig 1938: 8.4.10. Turn off verbose logging
1.178 rillig 1939:
1940: The build logs of a package are often quite long. This allows error messages or
1941: other interesting details to hide between the noise. To make the actual error
1942: message stand out more, add these lines to mk.conf.
1943:
1944: GNU_CONFIGURE_QUIET= yes
1945: MAKE_FLAGS+= -s
1946:
1947: The -s option works for both GNU Make and BSD Make. On exotic platforms with
1948: their own make, it may be a little different.
1949:
1950: 8.5. Creating a multiple CD-ROM packages collection
1.1 dsieger 1951:
1952: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
1953: of the resulting binary packages to assist in installing packages on other
1954: machines. The pkgtools/cdpack package provides a simple tool for creating the
1955: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
1956: keeps all the dependencies for a given package on the same CD as that package.
1957:
1.178 rillig 1958: 8.5.1. Example of cdpack
1.1 dsieger 1959:
1960: Complete documentation for cdpack is found in the cdpack(1) man page. The
1961: following short example assumes that the binary packages are left in /usr/
1962: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
1963: ISO 9660 images.
1964:
1965: # mkdir /u2/images
1966: # pkg_add /usr/pkgsrc/packages/All/cdpack
1967: # cdpack /usr/pkgsrc/packages/All /u2/images
1968:
1969:
1970: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
1971: CD in the collection, then you need to create a directory which contains these
1.175 gutterid 1972: files, e.g.:
1.1 dsieger 1973:
1974: # mkdir /tmp/common
1975: # echo "This is a README" > /tmp/common/README
1976: # echo "Another file" > /tmp/common/COPYING
1977: # mkdir /tmp/common/bin
1978: # echo "#!/bin/sh" > /tmp/common/bin/myscript
1979: # echo "echo Hello world" >> /tmp/common/bin/myscript
1980: # chmod 755 /tmp/common/bin/myscript
1981:
1982:
1983: Now create the images:
1984:
1985: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
1986:
1987: Each image will contain README, COPYING, and bin/myscript in their root
1988: directories.
1989:
1.154 rillig 1990: Chapter 9. Directory layout of the installed files
1.1 dsieger 1991:
1992: Table of Contents
1993:
1.154 rillig 1994: 9.1. File system layout in ${LOCALBASE}
1995: 9.2. File system layout in ${VARBASE}
1.1 dsieger 1996:
1997: The files that are installed by pkgsrc are organized in a way that is similar
1998: to what you find in the /usr directory of the base system. But some details are
1999: different. This is because pkgsrc initially came from FreeBSD and had adopted
2000: its file system hierarchy. Later it was largely influenced by NetBSD. But no
2001: matter which operating system you are using pkgsrc with, you can expect the
2002: same layout for pkgsrc.
2003:
2004: There are mainly four root directories for pkgsrc, which are all configurable
2005: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
2006: default locations are:
2007:
2008: LOCALBASE= /usr/pkg
2009: PKG_SYSCONFBASE= /usr/pkg/etc
2010: VARBASE= /var
1.119 sevan 2011: PKG_DBDIR= /usr/pkg/pkgdb
1.1 dsieger 2012:
2013: In unprivileged mode (when pkgsrc has been installed as any other user), the
2014: default locations are:
2015:
2016: LOCALBASE= ${HOME}/pkg
2017: PKG_SYSCONFBASE= ${HOME}/pkg/etc
2018: VARBASE= ${HOME}/pkg/var
1.119 sevan 2019: PKG_DBDIR= ${HOME}/pkg/pkgdb
1.1 dsieger 2020:
2021: What these four directories are for, and what they look like is explained
2022: below.
2023:
1.25 wiz 2024: * LOCALBASE corresponds to the /usr directory in the base system. It is the "
2025: main" directory where the files are installed and contains the well-known
1.1 dsieger 2026: subdirectories like bin, include, lib, share and sbin.
2027:
2028: * VARBASE corresponds to /var in the base system. Some programs (especially
2029: games, network daemons) need write access to it during normal operation.
2030:
2031: * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
2032: configuration files of the packages, as well as pkgsrc's mk.conf itself.
2033:
1.154 rillig 2034: 9.1. File system layout in ${LOCALBASE}
1.1 dsieger 2035:
2036: The following directories exist in a typical pkgsrc installation in $
2037: {LOCALBASE}.
2038:
2039: bin
2040:
2041: Contains executable programs that are intended to be directly used by the
2042: end user.
2043:
2044: emul
2045:
2046: Contains files for the emulation layers of various other operating systems,
2047: especially for NetBSD.
2048:
2049: etc (the usual location of ${PKG_SYSCONFDIR})
2050:
2051: Contains the configuration files.
2052:
2053: include
2054:
2055: Contains headers for the C and C++ programming languages.
2056:
2057: info
2058:
2059: Contains GNU info files of various packages.
2060:
2061: lib
2062:
2063: Contains shared and static libraries.
2064:
2065: libdata
2066:
2067: Contains data files that don't change after installation. Other data files
2068: belong into ${VARBASE}.
2069:
2070: libexec
2071:
2072: Contains programs that are not intended to be used by end users, such as
2073: helper programs or network daemons.
2074:
2075: libexec/cgi-bin
2076:
2077: Contains programs that are intended to be executed as CGI scripts by a web
2078: server.
2079:
2080: man (the usual value of ${PKGMANDIR})
2081:
2082: Contains brief documentation in form of manual pages.
2083:
2084: sbin
2085:
2086: Contains programs that are intended to be used only by the super-user.
2087:
2088: share
2089:
2090: Contains platform-independent data files that don't change after
2091: installation.
2092:
2093: share/doc
2094:
2095: Contains documentation files provided by the packages.
2096:
2097: share/examples
2098:
2099: Contains example files provided by the packages. Among others, the original
2100: configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
2101: installation.
2102:
2103: share/examples/rc.d
2104:
2105: Contains the original files for rc.d scripts.
2106:
2107: var (the usual location of ${VARBASE})
2108:
2109: Contains files that may be modified after installation.
2110:
1.154 rillig 2111: 9.2. File system layout in ${VARBASE}
1.1 dsieger 2112:
2113: db/pkg (the usual location of ${PKG_DBDIR})
2114:
2115: Contains information about the currently installed packages.
2116:
2117: games
2118:
2119: Contains highscore files.
2120:
2121: log
2122:
2123: Contains log files.
2124:
2125: run
2126:
2127: Contains informational files about daemons that are currently running.
2128:
1.154 rillig 2129: Chapter 10. Frequently Asked Questions
1.1 dsieger 2130:
2131: Table of Contents
2132:
1.154 rillig 2133: 10.1. Are there any mailing lists for pkg-related discussion?
2134: 10.2. Utilities for package management (pkgtools)
2135: 10.3. How to use pkgsrc as non-root
2136: 10.4. How to resume transfers when fetching distfiles?
2137: 10.5. How can I install/use modular X.org from pkgsrc?
2138: 10.6. How to fetch files from behind a firewall
2139: 10.7. How to fetch files from HTTPS sites
2140: 10.8. How do I tell make fetch to do passive FTP?
2141: 10.9. How to fetch all distfiles at once
2142: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
2143: 10.11. What does "Could not find bsd.own.mk" mean?
1.221 nia 2144: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154 rillig 2145: 10.13. How do I change the location of configuration files?
2146: 10.14. Automated security checks
2147: 10.15. Why do some packages ignore my CFLAGS?
2148: 10.16. A package does not build. What shall I do?
2149: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.232 gutterid 2150: conflicts" mean?
1.1 dsieger 2151:
2152: This section contains hints, tips & tricks on special things in pkgsrc that we
2153: didn't find a better place for in the previous chapters, and it contains items
2154: for both pkgsrc users and developers.
2155:
1.154 rillig 2156: 10.1. Are there any mailing lists for pkg-related discussion?
1.1 dsieger 2157:
2158: The following mailing lists may be of interest to pkgsrc users:
2159:
2160: * pkgsrc-users: This is a general purpose list for most issues regarding
2161: pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
2162: configuration, unexpected build failures, using particular packages,
2163: upgrading pkgsrc installations, questions regarding the pkgsrc release
2164: branches, etc. General announcements or proposals for changes that impact
2165: the pkgsrc user community, e.g. major infrastructure changes, new features,
2166: package removals, etc., may also be posted.
2167:
2168: * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
2169: discussed.
2170:
2171: * pkgsrc-changes: This list is for those who are interested in getting a
2172: commit message for every change committed to pkgsrc. It is also available
2173: in digest form, meaning one daily message containing all commit messages
2174: for changes to the package source tree in that 24 hour period.
2175:
2176: To subscribe, do:
2177:
2178: % echo subscribe listname | mail majordomo@NetBSD.org
2179:
1.174 leot 2180: Archives for all these mailing lists are available from https://
1.1 dsieger 2181: mail-index.NetBSD.org/.
2182:
1.154 rillig 2183: 10.2. Utilities for package management (pkgtools)
1.1 dsieger 2184:
2185: The directory pkgsrc/pkgtools contains a number of useful utilities for both
2186: users and developers of pkgsrc. This section attempts only to make the reader
1.121 sevan 2187: aware of some of the utilities and when they might be useful, and not to
2188: duplicate the documentation that comes with each package.
1.1 dsieger 2189:
2190: Utilities used by pkgsrc (automatically installed when needed):
2191:
2192: * pkgtools/x11-links: Symlinks for use by buildlink.
2193:
2194: OS tool augmentation (automatically installed when needed):
2195:
1.121 sevan 2196: * pkgtools/digest: Calculates various kinds of checksums (including SHA3).
1.1 dsieger 2197:
2198: * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
2199:
2200: * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
2201:
2202: * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
2203: for use on operating systems where pkg_install is not present.
2204:
2205: Utilities used by pkgsrc (not automatically installed):
2206:
2207: * pkgtools/pkg_tarup: Create a binary package from an already-installed
2208: package. Used by make replace to save the old package.
2209:
2210: * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
2211: distfiles from multiple locations. It currently supports the following
2212: methods: multiple CD-ROMs and network FTP/HTTP connections.
2213:
2214: * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24 wiz 2215: current CPU and compiler.
1.1 dsieger 2216:
2217: Utilities for keeping track of installed packages, being up to date, etc:
2218:
1.65 wiz 2219: * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
2220: and upgrade binary packages easily.
2221:
1.1 dsieger 2222: * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
2223: the latest pkgsrc entries.
2224:
2225: * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
2226: strategy for updating.
2227:
2228: * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
2229: graphviz).
2230:
1.12 weinem 2231: * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
2232:
2233: * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
2234: complete pkgsrc system.
1.1 dsieger 2235:
2236: * pkgtools/pkgsurvey: Report what packages you have installed.
2237:
2238: Utilities for people maintaining or creating individual packages:
2239:
2240: * pkgtools/pkgdiff: Automate making and maintaining patches for a package
2241: (includes pkgdiff, pkgvi, mkpatches, etc.).
2242:
1.65 wiz 2243: * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1 dsieger 2244:
2245: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
2246:
2247: * pkgtools/pkg_comp: Build packages in a chrooted area.
2248:
2249: * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
2250:
1.154 rillig 2251: 10.3. How to use pkgsrc as non-root
1.1 dsieger 2252:
1.108 rillig 2253: To install packages from source as a non-root user, download pkgsrc as
1.154 rillig 2254: described in Chapter 3, Where to get pkgsrc and how to keep it up-to-date, cd
1.108 rillig 2255: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
2256:
2257: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
2258: configuration mk.conf into ~/pkg/etc.
2259:
2260: For more details, see mk/unprivileged.mk.
1.1 dsieger 2261:
1.154 rillig 2262: 10.4. How to resume transfers when fetching distfiles?
1.1 dsieger 2263:
2264: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4 rillig 2265: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
2266: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1 dsieger 2267:
1.61 wiz 2268: You can also use a different program than the platform default program by
2269: changing the FETCH_USING variable. You can specify the program by using of ftp,
2270: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
2271: manual. A value of custom disables the system defaults and dependency tracking
2272: for the fetch program. In that case you have to provide FETCH_CMD,
2273: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1 dsieger 2274:
1.16 jnemeth 2275: For example, if you want to use wget to download, you'll have to use something
2276: like:
1.1 dsieger 2277:
1.16 jnemeth 2278: FETCH_USING= wget
1.1 dsieger 2279:
1.154 rillig 2280: 10.5. How can I install/use modular X.org from pkgsrc?
1.1 dsieger 2281:
1.4 rillig 2282: If you want to use modular X.org from pkgsrc instead of your system's own X11
2283: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1 dsieger 2284: mk.conf:
2285:
1.4 rillig 2286: X11_TYPE=modular
1.1 dsieger 2287:
1.154 rillig 2288: 10.6. How to fetch files from behind a firewall
1.1 dsieger 2289:
2290: If you are sitting behind a firewall which does not allow direct connections to
2291: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
2292: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
2293: machine "orpheus.amdahl.com" is one of the firewalls, and it uses port 80 as
2294: the proxy port number. So the proxy environment variables are:
2295:
2296: ftp_proxy=ftp://orpheus.amdahl.com:80/
2297: http_proxy=http://orpheus.amdahl.com:80/
2298:
1.154 rillig 2299: 10.7. How to fetch files from HTTPS sites
1.65 wiz 2300:
2301: Some fetch tools are not prepared to support HTTPS by default (for example, the
2302: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
2303: openssl dependency that low in the dependency graph).
2304:
2305: Usually you won't notice, because distribution files are mirrored weekly to "
2306: ftp.NetBSD.org", but that might not be often enough if you are following
2307: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to "curl" or
2308: "wget", which are both compiled with HTTPS support by default. Of course, these
2309: tools need to be installed before you can use them this way.
2310:
1.154 rillig 2311: 10.8. How do I tell make fetch to do passive FTP?
1.1 dsieger 2312:
2313: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
2314: FETCH_CMD is assigned the first available command from the following list:
2315:
2316: * ${LOCALBASE}/bin/ftp
2317:
2318: * /usr/bin/ftp
2319:
2320: On a default NetBSD installation, this will be /usr/bin/ftp, which
2321: automatically tries passive connections first, and falls back to active
2322: connections if the server refuses to do passive. For the other tools, add the
1.4 rillig 2323: following to your mk.conf file: PASSIVE_FETCH=1.
1.1 dsieger 2324:
2325: Having that option present will prevent /usr/bin/ftp from falling back to
2326: active transfers.
2327:
1.154 rillig 2328: 10.9. How to fetch all distfiles at once
1.1 dsieger 2329:
2330: You would like to download all the distfiles in a single batch from work or
2331: university, where you can't run a make fetch. There is an archive of distfiles
2332: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
2333:
2334: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
2335: subdirectories, carry the resulting list to your machine at work/school and use
2336: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
2337: don't forget to set FETCH_CMD to something that fetches a URL:
2338:
2339: At home:
2340:
2341: % cd /usr/pkgsrc
2342: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
2343: % scp /tmp/fetch.sh work:/tmp
2344:
2345: At work:
2346:
2347: % sh /tmp/fetch.sh
2348:
2349: then tar up /tmp/distfiles and take it home.
2350:
2351: If you have a machine running NetBSD, and you want to get all distfiles (even
2352: ones that aren't for your machine architecture), you can do so by using the
2353: above-mentioned make fetch-list approach, or fetch the distfiles directly by
2354: running:
2355:
2356: % make mirror-distfiles
2357:
2358: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
2359: everything by running:
2360:
2361: % make fetch NO_SKIP=yes
2362:
1.154 rillig 2363: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1.1 dsieger 2364:
2365: When compiling the pkgtools/pkg_install package, you get the error from make
2366: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
2367: that you don't have installed the "text" set (nroff, ...) from the NetBSD base
2368: distribution on your machine. It is recommended to do that to format man pages.
2369:
2370: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4 rillig 2371: NOMAN=YES either in the environment or in mk.conf.
1.1 dsieger 2372:
1.154 rillig 2373: 10.11. What does "Could not find bsd.own.mk" mean?
1.1 dsieger 2374:
2375: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
2376: machine. Please get and install it, by extracting it in /:
2377:
2378: # cd /
2379: # tar --unlink -zxvpf .../comp.tgz
2380:
2381: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
2382: release (determine via uname -r).
2383:
1.221 nia 2384: 10.12. Using 'sudo' or `priv` with pkgsrc
1.1 dsieger 2385:
2386: When installing packages as non-root user and using the just-in-time su(1)
2387: feature of pkgsrc, it can become annoying to type in the root password for each
2388: required package installed. To avoid this, the sudo package can be used, which
1.221 nia 2389: does password caching over a limited time. To use it, install sudo or priv
2390: (either as binary package, from security/priv, or security/sudo) and then put
2391: the following into your mk.conf, somewhere after the definition of the
2392: LOCALBASE variable:
1.1 dsieger 2393:
2394: .if exists(${LOCALBASE}/bin/sudo)
2395: SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
2396: .endif
2397:
1.154 rillig 2398: 10.13. How do I change the location of configuration files?
1.1 dsieger 2399:
2400: As the system administrator, you can choose where configuration files are
2401: installed. The default settings make all these files go into ${PREFIX}/etc or
2402: some of its subdirectories; this may be suboptimal depending on your
2403: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
2404: configuration of the provided packages).
2405:
2406: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4 rillig 2407: (in mk.conf) to point to your preferred configuration directory; some common
2408: examples include /etc or /etc/pkg.
1.1 dsieger 2409:
2410: Furthermore, you can change this value on a per-package basis by setting the
2411: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
2412: matches the name of the package you would like to modify, that is, the contents
2413: of PKGBASE.
2414:
2415: Note that after changing these settings, you must rebuild and reinstall any
2416: affected packages.
2417:
1.154 rillig 2418: 10.14. Automated security checks
1.1 dsieger 2419:
2420: Please be aware that there can often be bugs in third-party software, and some
2421: of these bugs can leave a machine vulnerable to exploitation by attackers. In
2422: an effort to lessen the exposure, the NetBSD packages team maintains a database
2423: of known-exploits to packages which have at one time been included in pkgsrc.
2424: The database can be downloaded automatically, and a security audit of all
1.14 jmcneill 2425: packages installed on a system can take place. To do this, refer to the
2426: following two tools (installed as part of the pkgtools/pkg_install package):
1.1 dsieger 2427:
1.21 snj 2428: 1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
2429: security vulnerabilities information. This list is kept up to date by the
1.26 spz 2430: pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1 dsieger 2431:
1.177 leot 2432: https://ftp.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities
1.1 dsieger 2433:
1.21 snj 2434: 2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24 wiz 2435: known vulnerability. If a vulnerable package is installed, it will be shown
2436: by output to stdout, including a description of the type of vulnerability,
2437: and a URL containing more information.
1.1 dsieger 2438:
1.202 nia 2439: Use of these tools is strongly recommended! See Section 5.1.6, "Checking for
1.121 sevan 2440: security vulnerabilities in installed packages" for instructions on how to
2441: automate checking and reporting.
2442:
2443: If this database is installed, pkgsrc builds will use it to perform a security
2444: check before building any package.
1.1 dsieger 2445:
1.154 rillig 2446: 10.15. Why do some packages ignore my CFLAGS?
1.1 dsieger 2447:
2448: When you add your own preferences to the CFLAGS variable in your mk.conf, these
2449: flags are passed in environment variables to the ./configure scripts and to
2450: make(1). Some package authors ignore the CFLAGS from the environment variable
2451: by overriding them in the Makefiles of their package.
2452:
2453: Currently there is no solution to this problem. If you really need the package
2454: to use your CFLAGS you should run make patch in the package directory and then
2455: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
2456: Usually you can remove these lines. But be aware that some "smart" programmers
2457: write so bad code that it only works for the specific combination of CFLAGS
2458: they have chosen.
2459:
1.172 rillig 2460: To find out where the CFLAGS are ignored, add the following lines to mk.conf:
2461:
2462: CPPFLAGS+= -Dpkgsrc___CPPFLAGS
2463: CFLAGS+= -Dpkgsrc___CFLAGS
2464: CXXFLAGS+= -Dpkgsrc___CXXFLAGS
2465:
2466: Then run bmake show-all-configure show-all-build to see whether the above flags
2467: are passed to the actual build commands in general.
2468:
2469: To find out whether the flags are passed to individual compiler commands, have
2470: a look at the file work/.work.log. In most cases, the flags from the original
2471: command lines (the lines starting with [*]) are passed unmodified to the actual
2472: compiler (the lines starting with <.>). If the flag is missing from the actual
2473: compiler command, it must have been removed by the pkgsrc compiler wrappers.
2474:
1.154 rillig 2475: 10.16. A package does not build. What shall I do?
1.1 dsieger 2476:
2477: 1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
2478: is that people only update pkgsrc in parts, because of performance reasons.
2479: Since pkgsrc is one large system, not a collection of many small systems,
2480: there are sometimes changes that only work when the whole pkgsrc tree is
2481: updated.
2482:
1.25 wiz 2483: 2. Make sure that you don't have any CVS conflicts. Search for "<<<<<<" or "
2484: >>>>>>" in all your pkgsrc files.
1.1 dsieger 2485:
1.25 wiz 2486: 3. Make sure that you don't have old copies of the packages extracted. Run
1.1 dsieger 2487: make clean clean-depends to verify this.
2488:
1.108 rillig 2489: 4. If you are a package developer who wants to invest some work, have a look
1.154 rillig 2490: at Chapter 21, Making your package work.
1.108 rillig 2491:
2492: 5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1 dsieger 2493:
1.154 rillig 2494: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.1 dsieger 2495: conflicts" mean?
2496:
2497: You have modified a file from pkgsrc, and someone else has modified that same
2498: file afterwards in the CVS repository. Both changes are in the same region of
2499: the file, so when you updated pkgsrc, the cvs command marked the conflicting
2500: changes in the file. Because of these markers, the file is no longer a valid
2501: Makefile.
2502:
2503: Have a look at that file, and if you don't need your local changes anymore, you
2504: can remove that file and run cvs -q update -dP in that directory to download
2505: the current version.
2506:
2507: Part II. The pkgsrc developer's guide
2508:
2509: This part of the book deals with creating and modifying packages. It starts
2510: with a "HOWTO"-like guide on creating a new package. The remaining chapters are
2511: more like a reference manual for pkgsrc.
2512:
2513: Table of Contents
2514:
1.154 rillig 2515: 11. Getting help
1.184 rillig 2516: 12. Package components - files, directories and contents
2517: 12.1. Makefile
2518: 12.2. distinfo
2519: 12.3. patches/*
2520: 12.3.1. Structure of a single patch file
2521: 12.3.2. Creating patch files
2522: 12.3.3. Sources where the patch files come from
2523: 12.3.4. Patching guidelines
2524: 12.3.5. Feedback to the author
2525: 12.4. Other mandatory files
2526: 12.5. Optional files
2527: 12.5.1. Files affecting the binary package
2528: 12.5.2. Files affecting the build process
2529: 12.5.3. Files affecting nothing at all
2530: 12.6. work*
2531: 12.7. files/*
2532: 13. The build process
2533: 13.1. Introduction
2534: 13.2. Program location
2535: 13.3. Directories used during the build process
2536: 13.4. Running a phase
2537: 13.5. The fetch phase
2538: 13.5.1. What to fetch and where to get it from
2539: 13.5.2. How are the files fetched?
2540: 13.6. The checksum phase
2541: 13.7. The extract phase
2542: 13.8. The patch phase
2543: 13.9. The tools phase
2544: 13.10. The wrapper phase
2545: 13.11. The configure phase
2546: 13.12. The build phase
2547: 13.13. The test phase
2548: 13.14. The install phase
2549: 13.15. The package phase
2550: 13.16. Cleaning up
2551: 13.17. Other helpful targets
2552: 14. Creating a new pkgsrc package from scratch
2553: 14.1. Common types of packages
1.219 nia 2554: 14.1.1. Python modules and programs
2555: 14.1.2. R packages
2556: 14.1.3. TeXlive packages
1.184 rillig 2557: 14.2. Examples
2558: 14.2.1. How the www/nvu package came into pkgsrc
2559: 15. Programming in Makefiles
2560: 15.1. Caveats
2561: 15.2. Makefile variables
2562: 15.2.1. Naming conventions
2563: 15.3. Code snippets
2564: 15.3.1. Adding things to a list
2565: 15.3.2. Echoing a string exactly as-is
2566: 15.3.3. Passing CFLAGS to GNU configure scripts
2567: 15.3.4. Handling possibly empty variables
1.229 gutterid 2568: 15.3.5. Testing yes/no variables in conditions
1.184 rillig 2569: 16. Options handling
2570: 16.1. Global default options
2571: 16.2. Converting packages to use bsd.options.mk
2572: 16.3. Option Names
2573: 16.4. Determining the options of dependencies
2574: 17. Tools needed for building or running
2575: 17.1. Tools for pkgsrc builds
2576: 17.2. Tools needed by packages
2577: 17.3. Tools provided by platforms
2578: 18. Buildlink methodology
2579: 18.1. Converting packages to use buildlink3
2580: 18.2. Writing buildlink3.mk files
2581: 18.2.1. Anatomy of a buildlink3.mk file
2582: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
1.232 gutterid 2583: pkg in buildlink3.mk files
1.184 rillig 2584: 18.3. Writing builtin.mk files
2585: 18.3.1. Anatomy of a builtin.mk file
2586: 18.3.2. Global preferences for native or pkgsrc software
2587: 19. PLIST issues
2588: 19.1. RCS ID
2589: 19.2. Semi-automatic PLIST generation
2590: 19.3. Tweaking output of make print-PLIST
2591: 19.4. Variable substitution in PLIST
2592: 19.5. Man page compression
2593: 19.6. Changing PLIST source with PLIST_SRC
2594: 19.7. Platform-specific and differing PLISTs
2595: 19.8. Build-specific PLISTs
2596: 19.9. Sharing directories between packages
2597: 20. The pkginstall framework
2598: 20.1. Files and directories outside the installation prefix
2599: 20.1.1. Directory manipulation
2600: 20.1.2. File manipulation
2601: 20.2. Configuration files
2602: 20.2.1. How PKG_SYSCONFDIR is set
2603: 20.2.2. Telling the software where configuration files are
2604: 20.2.3. Patching installations
2605: 20.2.4. Disabling handling of configuration files
2606: 20.3. System startup scripts
2607: 20.3.1. Disabling handling of system startup scripts
2608: 20.4. System users and groups
2609: 20.5. System shells
2610: 20.5.1. Disabling shell registration
2611: 20.6. Fonts
2612: 20.6.1. Disabling automatic update of the fonts databases
1.154 rillig 2613: 21. Making your package work
2614: 21.1. General operation
2615: 21.1.1. How to pull in user-settable variables from mk.conf
2616: 21.1.2. User interaction
2617: 21.1.3. Handling licenses
2618: 21.1.4. Restricted packages
2619: 21.1.5. Handling dependencies
2620: 21.1.6. Handling conflicts with other packages
2621: 21.1.7. Packages that cannot or should not be built
2622: 21.1.8. Packages which should not be deleted, once installed
2623: 21.1.9. Handling packages with security problems
2624: 21.1.10. How to handle incrementing versions when fixing an existing
1.232 gutterid 2625: package
1.154 rillig 2626: 21.1.11. Substituting variable text in the package files (the SUBST
1.232 gutterid 2627: framework)
1.154 rillig 2628: 21.2. The fetch phase
2629: 21.2.1. Packages whose distfiles aren't available for plain downloading
2630: 21.2.2. How to handle modified distfiles with the 'old' name
2631: 21.2.3. Packages hosted on github.com
2632: 21.3. The configure phase
2633: 21.3.1. Shared libraries - libtool
2634: 21.3.2. Using libtool on GNU packages that already support libtool
2635: 21.3.3. GNU Autoconf/Automake
1.223 nia 2636: 21.3.4. Meson / ninja
1.154 rillig 2637: 21.4. Programming languages
2638: 21.4.1. C, C++, and Fortran
2639: 21.4.2. Java
1.205 wiz 2640: 21.4.3. Go
1.223 nia 2641: 21.4.4. Rust
2642: 21.4.5. Packages containing Perl scripts
2643: 21.4.6. Packages containing shell scripts
2644: 21.4.7. Other programming languages
1.154 rillig 2645: 21.5. The build phase
2646: 21.5.1. Compiling C and C++ code conditionally
2647: 21.5.2. How to handle compiler bugs
1.172 rillig 2648: 21.5.3. No such file or directory
2649: 21.5.4. Undefined reference to "..."
2650: 21.5.5. Running out of memory
1.154 rillig 2651: 21.6. The install phase
2652: 21.6.1. Creating needed directories
2653: 21.6.2. Where to install documentation
2654: 21.6.3. Installing highscore files
2655: 21.6.4. Adding DESTDIR support to packages
2656: 21.6.5. Packages with hardcoded paths to other interpreters
1.203 nia 2657: 21.6.6. Packages installing Perl modules
1.154 rillig 2658: 21.6.7. Packages installing info files
2659: 21.6.8. Packages installing man pages
1.203 nia 2660: 21.6.9. Packages installing X11 fonts
2661: 21.6.10. Packages installing SGML or XML data
2662: 21.6.11. Packages installing extensions to the MIME database
2663: 21.6.12. Packages using intltool
2664: 21.6.13. Packages installing startup scripts
2665: 21.6.14. Packages installing TeX modules
2666: 21.6.15. Packages supporting running binaries in emulation
2667: 21.6.16. Packages installing hicolor icons
2668: 21.6.17. Packages installing desktop files
1.154 rillig 2669: 21.7. Marking packages as having problems
1.184 rillig 2670: 22. GNOME packaging and porting
2671: 22.1. Meta packages
2672: 22.2. Packaging a GNOME application
2673: 22.3. Updating GNOME to a newer version
2674: 22.4. Patching guidelines
1.154 rillig 2675: 23. Submitting and Committing
2676: 23.1. Submitting binary packages
2677: 23.2. Submitting source packages (for non-NetBSD-developers)
2678: 23.3. General notes when adding, updating, or removing packages
2679: 23.4. Commit Messages
2680: 23.5. Committing: Adding a package to CVS
2681: 23.6. Updating a package to a newer version
2682: 23.7. Renaming a package in pkgsrc
2683: 23.8. Moving a package in pkgsrc
2684: 24. Frequently Asked Questions
2685:
2686: Chapter 11. Getting help
2687:
2688: To get help when developing pkgsrc, the definitive source is this document, the
2689: pkgsrc guide. If you don't find anything here, there are alternatives:
2690:
2691: * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
2692: Run bmake help topic=? to get help for any topic, such as a variable name
2693: like BUILD_DEFS, a make target like do-build, a missing C or C++ function
2694: like strcasecmp or any other topic.
2695:
1.207 leot 2696: The available help topics are listed in Appendix E, Help topics.
1.154 rillig 2697:
1.163 rillig 2698: * To see the value of a single variable, run bmake show-var VARNAME=X.
2699:
2700: * To see the values of the most common variables, run bmake show-all. These
2701: variables are grouped by topic. To see the variables for a single topic,
2702: run bmake show-all-topic, for example bmake show-all-fetch.
2703:
1.154 rillig 2704: * The tech-pkg mailing list, to which you can subscribe and then ask your
2705: questions.
2706:
2707: * The #pkgsrc IRC channel, which is accessible via a web browser or by using
2708: a specialized chat program such as XChat. Pick any user name and join the
2709: channel #pkgsrc.
1.1 dsieger 2710:
1.184 rillig 2711: Chapter 12. Package components - files, directories and contents
1.1 dsieger 2712:
2713: Table of Contents
2714:
1.184 rillig 2715: 12.1. Makefile
2716: 12.2. distinfo
2717: 12.3. patches/*
2718: 12.3.1. Structure of a single patch file
2719: 12.3.2. Creating patch files
2720: 12.3.3. Sources where the patch files come from
2721: 12.3.4. Patching guidelines
2722: 12.3.5. Feedback to the author
2723: 12.4. Other mandatory files
2724: 12.5. Optional files
2725: 12.5.1. Files affecting the binary package
2726: 12.5.2. Files affecting the build process
2727: 12.5.3. Files affecting nothing at all
2728: 12.6. work*
2729: 12.7. files/*
1.1 dsieger 2730:
1.184 rillig 2731: Whenever you're preparing a package, there are a number of files involved which
2732: are described in the following sections.
1.1 dsieger 2733:
1.184 rillig 2734: 12.1. Makefile
1.1 dsieger 2735:
1.184 rillig 2736: Building, installation and creation of a binary package are all controlled by
2737: the package's Makefile. The Makefile describes various things about a package,
2738: for example from where to get it, how to configure, build, and install it.
1.1 dsieger 2739:
1.184 rillig 2740: A package Makefile contains several sections that describe the package.
1.1 dsieger 2741:
1.184 rillig 2742: In the first section there are the following variables, which should appear
2743: exactly in the order given here. The order and grouping of the variables is
2744: mostly historical and has no further meaning.
1.1 dsieger 2745:
1.184 rillig 2746: * DISTNAME is the basename of the distribution file to be downloaded from the
2747: package's website.
1.1 dsieger 2748:
1.184 rillig 2749: * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
2750: it if DISTNAME (which is the default) is not a good name for the package in
2751: pkgsrc or DISTNAME is not provided (no distribution file is required).
2752: Usually it is the pkgsrc directory name together with the version number.
2753: It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
2754: is, it starts with a letter or digit, and contains only letters, digits,
1.204 nia 2755: dashes, underscores, dots and plus signs. New packages should have entirely
2756: lower-case names, with the exception of some that must follow pre-existing
2757: conventions (e.g. R packages begin with R-). You can use the :tl variable
2758: modifier to lower-case the package name.
1.26 spz 2759:
1.184 rillig 2760: * CATEGORIES is a list of categories which the package fits in. You can
2761: choose any of the top-level directories of pkgsrc for it.
1.1 dsieger 2762:
1.184 rillig 2763: Currently the following values are available for CATEGORIES. If more than
2764: one is used, they need to be separated by spaces:
1.1 dsieger 2765:
1.184 rillig 2766: archivers cross geography meta-pkgs security
2767: audio databases graphics misc shells
2768: benchmarks devel ham multimedia sysutils
2769: biology editors inputmethod net textproc
2770: cad emulators lang news time
2771: chat finance mail parallel wm
2772: comms fonts math pkgtools www
2773: converters games mbone print x11
1.1 dsieger 2774:
1.184 rillig 2775: * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
2776: are discussed in detail in Section 13.5, "The fetch phase".
1.1 dsieger 2777:
1.184 rillig 2778: The second section contains information about separately downloaded patches, if
2779: any.
1.1 dsieger 2780:
1.184 rillig 2781: * PATCHFILES: Name(s) of additional files that contain distribution patches.
2782: There is no default. pkgsrc will look for them at PATCH_SITES. They will
2783: automatically be uncompressed before patching if the names end with .gz or
2784: .Z.
1.1 dsieger 2785:
1.184 rillig 2786: * PATCH_SITES: Primary location(s) for distribution patch files (see
2787: PATCHFILES above) if not found locally.
1.1 dsieger 2788:
1.184 rillig 2789: * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
2790: count to help find the correct files to patch. It defaults to -p0.
1.1 dsieger 2791:
1.184 rillig 2792: The third section contains the following variables.
1.1 dsieger 2793:
1.184 rillig 2794: * MAINTAINER is the email address of the person who feels responsible for
2795: this package, and who is most likely to look at problems or questions
2796: regarding this package which have been reported with send-pr(1). Other
2797: developers may contact the MAINTAINER before making changes to the package,
2798: but are not required to do so. When packaging a new program, set MAINTAINER
2799: to yourself. If you really can't maintain the package for future updates,
2800: set it to <pkgsrc-users@NetBSD.org>.
1.1 dsieger 2801:
1.184 rillig 2802: * OWNER should be used instead of MAINTAINER when you do not want other
2803: developers to update or change the package without contacting you first. A
2804: package Makefile should contain one of MAINTAINER or OWNER, but not both.
1.1 dsieger 2805:
1.184 rillig 2806: * HOMEPAGE is a URL where users can find more information about the package.
1.1 dsieger 2807:
1.184 rillig 2808: * COMMENT is a one-line description of the package (should not include the
2809: package name).
1.1 dsieger 2810:
1.184 rillig 2811: * LICENSE indicates the license(s) applicable for the package. See
2812: Section 21.1.3, "Handling licenses" for further details.
1.1 dsieger 2813:
1.184 rillig 2814: Other variables that affect the build:
1.1 dsieger 2815:
1.184 rillig 2816: * WRKSRC: The directory where the interesting distribution files of the
2817: package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
2818: most packages.
1.1 dsieger 2819:
1.184 rillig 2820: If a package doesn't create a subdirectory for itself (most GNU software
2821: does, for instance), but extracts itself in the current directory, you
2822: should set WRKSRC=${WRKDIR}.
1.1 dsieger 2823:
1.184 rillig 2824: If a package doesn't create a subdirectory with the name of DISTNAME but
2825: some different name, set WRKSRC to point to the proper name in ${WRKDIR},
2826: for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
2827: other examples.
1.17 imil 2828:
1.184 rillig 2829: The name of the working directory created by pkgsrc is taken from the
2830: WRKDIR_BASENAME variable. By default, its value is work. If you want to use
2831: the same pkgsrc tree for building different kinds of binary packages, you
2832: can change the variable according to your needs. Two other variables handle
2833: common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
2834: defined in mk.conf, the first component of the host's name is attached to
2835: the directory name. If OBJMACHINE is defined, the platform name is
2836: attached, which might look like work.i386 or work.sparc.
1.17 imil 2837:
1.184 rillig 2838: Please pay attention to the following gotchas:
1.17 imil 2839:
1.184 rillig 2840: * Add MANCOMPRESSED if man pages are installed in compressed form by the
2841: package. For packages using BSD-style makefiles which honor MANZ, there is
2842: MANCOMPRESSED_IF_MANZ.
1.17 imil 2843:
1.184 rillig 2844: * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
1.103 wiz 2845:
1.184 rillig 2846: * If the package installs any info files, see Section 21.6.7, "Packages
2847: installing info files".
1.103 wiz 2848:
1.184 rillig 2849: 12.2. distinfo
1.17 imil 2850:
1.184 rillig 2851: The distinfo file contains the message digest, or checksum, of each distfile
2852: needed for the package. This ensures that the distfiles retrieved from the
2853: Internet have not been corrupted during transfer or altered by a malign force
2854: to introduce a security hole. To provide maximum security, all distfiles are
2855: protected using three different message digest algorithms (SHA1, RMD160,
2856: SHA512), as well as the file size.
1.17 imil 2857:
1.184 rillig 2858: The distinfo file also contains the checksums for all the patches found in the
2859: patches directory (see Section 12.3, "patches/*"). These checksums ensure that
2860: patches are only applied intentionally and that they don't accidentally change,
2861: e.g. when merging different changes together. They also make sure that new
2862: patches are actually added to CVS and old ones are removed. Too see whether the
2863: patches and the distinfo file match, run pkglint after changing the patches.
1.17 imil 2864:
1.184 rillig 2865: To regenerate the distinfo file, use the make distinfo command.
1.17 imil 2866:
1.184 rillig 2867: Some packages have different sets of distfiles depending on the platform, for
2868: example lang/openjdk8. These are kept in the same distinfo file and care should
2869: be taken when upgrading such a package to ensure distfile information is not
2870: lost.
1.17 imil 2871:
1.184 rillig 2872: 12.3. patches/*
1.63 wiz 2873:
1.184 rillig 2874: Some packages don't work out-of-the box on the various platforms that are
2875: supported by pkgsrc. These packages need to be patched to make them work. The
2876: patch files can be found in the patches/ directory.
1.17 imil 2877:
1.184 rillig 2878: In the patch phase, these patches are applied to the files in WRKSRC directory
2879: after extracting them, in alphabetic order.
1.160 brook 2880:
1.184 rillig 2881: 12.3.1. Structure of a single patch file
1.160 brook 2882:
1.184 rillig 2883: The patch-* files should be in diff -bu format, and apply without a fuzz to
2884: avoid problems. (To force patches to apply with fuzz you can set
2885: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
2886: a single file, and no file should be patched by more than one patch file. This
2887: helps to keep future modifications simple.
1.160 brook 2888:
1.184 rillig 2889: Each patch file is structured as follows: In the first line, there is the RCS
2890: Id of the patch itself. The second line should be empty for aesthetic reasons.
2891: After that, there should be a comment for each change that the patch does.
2892: There are a number of standard cases:
1.160 brook 2893:
1.184 rillig 2894: * Patches for commonly known vulnerabilities should mention the vulnerability
2895: ID (CAN, CVE).
1.160 brook 2896:
1.184 rillig 2897: * Patches that change source code should mention the platform and other
2898: environment (for example, the compiler) that the patch is needed for.
1.160 brook 2899:
1.184 rillig 2900: The patch should be commented so that any developer who knows the code of the
2901: application can make some use of the patch. Special care should be taken for
2902: the upstream developers, since we generally want that they accept our patches,
2903: so we have less work in the future.
1.160 brook 2904:
1.184 rillig 2905: 12.3.2. Creating patch files
1.160 brook 2906:
1.184 rillig 2907: One important thing to mention is to pay attention that no RCS IDs get stored
2908: in the patch files, as these will cause problems when later checked into the
2909: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
2910: avoid these problems.
1.160 brook 2911:
1.184 rillig 2912: For even more automation, we recommend using mkpatches from the same package to
1.222 gutterid 2913: make a whole set of patches. You just have to back up files before you edit
2914: them to filename.orig, e.g., with cp -p filename filename.orig or, easier, by
2915: using pkgvi again from the same package. If you upgrade a package this way, you
2916: can easily compare the new set of patches with the previously existing one with
1.184 rillig 2917: patchdiff. The files in patches are replaced by new files, so carefully check
2918: if you want to take all the changes.
1.160 brook 2919:
1.184 rillig 2920: When you have finished a package, remember to generate the checksums for the
2921: patch files by using the make makepatchsum command, see Section 12.2,
2922: "distinfo".
1.1 dsieger 2923:
1.184 rillig 2924: When adding a patch that corrects a problem in the distfile (rather than e.g.
2925: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
2926: report to the maintainer. This benefits non-pkgsrc users of the package, and
2927: usually makes it possible to remove the patch in future version.
1.1 dsieger 2928:
1.184 rillig 2929: The file names of the patch files are usually of the form patch-
2930: path_to_file__with__underscores.c. Many packages still use the previous
2931: convention patch-[a-z][a-z], but new patches should be of the form containing
2932: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
2933: automatically.
1.1 dsieger 2934:
1.222 gutterid 2935: When updating pre-existing patch files, if a file uses the old patch-[a-z][a-z]
2936: convention, it's best not to change it to the new form, as that will just cause
2937: churn that makes it harder to track changes to patching over time. Similarly,
2938: if a patch now applies at different line offsets, but still applies cleanly
2939: as-is, there's no need to update it, as that also unnecessarily complicates the
2940: patch history.
2941:
1.184 rillig 2942: 12.3.3. Sources where the patch files come from
1.1 dsieger 2943:
1.184 rillig 2944: If you want to share patches between multiple packages in pkgsrc, e.g. because
2945: they use the same distfiles, set PATCHDIR to the path where the patch files can
2946: be found, e.g.:
1.1 dsieger 2947:
1.184 rillig 2948: PATCHDIR= ../../editors/xemacs/patches
1.1 dsieger 2949:
1.184 rillig 2950: Patch files that are distributed by the author or other maintainers can be
2951: listed in PATCHFILES.
1.1 dsieger 2952:
1.184 rillig 2953: If it is desired to store any patches that should not be committed into pkgsrc,
2954: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
2955: directory tree there is expected to have the same "category/package" structure
2956: as pkgsrc, and patches are expected to be stored inside these dirs (also known
2957: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
2958: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
2959: files in the named directory are expected to be patch files, and they are
2960: applied after pkgsrc patches are applied.
1.1 dsieger 2961:
1.184 rillig 2962: 12.3.4. Patching guidelines
1.1 dsieger 2963:
1.184 rillig 2964: When fixing a portability issue in the code do not use preprocessor magic to
2965: check for the current operating system nor platform. Doing so hurts portability
2966: to other platforms because the OS-specific details are not abstracted
2967: appropriately.
1.1 dsieger 2968:
1.184 rillig 2969: The general rule to follow is: instead of checking for the operating system the
2970: application is being built on, check for the specific features you need. For
2971: example, instead of assuming that kqueue is available under NetBSD and using
2972: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
1.198 leot 2973: kqueue itself -- yes, this generally involves patching the configure script.
1.184 rillig 2974: There is absolutely nothing that prevents some OSes from adopting interfaces
2975: from other OSes (e.g. Linux implementing kqueue), something that the above
2976: checks cannot take into account.
1.1 dsieger 2977:
1.184 rillig 2978: Of course, checking for features generally involves more work on the
2979: developer's side, but the resulting changes are cleaner and there are chances
2980: they will work on many other platforms. Not to mention that there are higher
2981: chances of being later integrated into the mainstream sources. Remember: It
2982: doesn't work unless it is right!
1.1 dsieger 2983:
1.184 rillig 2984: Some typical examples:
1.121 sevan 2985:
1.184 rillig 2986: Table 12.1. Patching examples
1.1 dsieger 2987:
1.184 rillig 2988: +-------------------------------------------------------------------------------------------+
2989: | Where | Incorrect | Correct |
2990: |---------+--------------------------+------------------------------------------------------|
2991: | |case ${target_os} in | |
2992: |configure|netbsd*) have_kvm=yes ;; |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
2993: |script |*) have_kvm=no ;; | |
2994: | |esac | |
2995: |---------+--------------------------+------------------------------------------------------|
2996: |C source |#if defined(__NetBSD__) |#if defined(HAVE_SYS_EVENT_H) |
2997: |file |# include <sys/event.h> |# include <sys/event.h> |
2998: | |#endif |#endif |
2999: |---------+--------------------------+------------------------------------------------------|
3000: | |int |int |
3001: | |monitor_file(...) |monitor_file(...) |
3002: | |{ |{ |
3003: | |#if defined(__NetBSD__) |#if defined(HAVE_KQUEUE) |
3004: |C source | int fd = kqueue();| int fd = kqueue(); |
3005: |file | ... | ... |
3006: | |#else |#else |
3007: | | ... | ... |
3008: | |#endif |#endif |
3009: | |} |} |
3010: +-------------------------------------------------------------------------------------------+
1.1 dsieger 3011:
3012:
1.184 rillig 3013: 12.3.5. Feedback to the author
1.1 dsieger 3014:
1.184 rillig 3015: Always, always, always feed back any portability fixes or improvements you do
3016: to a package to the mainstream developers. This is the only way to get their
3017: attention on portability issues and to ensure that future versions can be built
3018: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
3019: get the fixes straight from the packaged code.
1.1 dsieger 3020:
1.184 rillig 3021: This generally involves cleaning up the patches (because sometimes the patches
3022: that are added to pkgsrc are quick hacks), filing bug reports in the
3023: appropriate trackers for the projects and working with the mainstream authors
3024: to accept your changes. It is extremely important that you do it so that the
3025: packages in pkgsrc are kept simple and thus further changes can be done without
3026: much hassle.
1.1 dsieger 3027:
1.184 rillig 3028: When you have done this, please add a URL to the upstream bug report to the
3029: patch comment.
1.1 dsieger 3030:
1.184 rillig 3031: Support the idea of free software!
1.1 dsieger 3032:
1.184 rillig 3033: 12.4. Other mandatory files
1.1 dsieger 3034:
1.184 rillig 3035: DESCR
1.1 dsieger 3036:
1.184 rillig 3037: A multi-line description of the piece of software. This should include any
3038: credits where they are due. Please bear in mind that others do not share
3039: your sense of humour (or spelling idiosyncrasies), and that others will
3040: read everything that you write here.
1.1 dsieger 3041:
1.184 rillig 3042: PLIST
1.1 dsieger 3043:
1.184 rillig 3044: This file governs the files that are installed on your system: all the
3045: binaries, manual pages, etc. There are other directives which may be
3046: entered in this file, to control the creation and deletion of directories,
3047: and the location of inserted files. See Chapter 19, PLIST issues for more
3048: information.
1.1 dsieger 3049:
1.184 rillig 3050: 12.5. Optional files
1.1 dsieger 3051:
1.184 rillig 3052: 12.5.1. Files affecting the binary package
1.1 dsieger 3053:
1.184 rillig 3054: INSTALL
1.1 dsieger 3055:
1.184 rillig 3056: This shell script is invoked twice by pkg_add(1). First time after package
3057: extraction and before files are moved in place, the second time after the
3058: files to install are moved in place. This can be used to do any custom
3059: procedures not possible with @exec commands in PLIST. See pkg_add(1) and
3060: pkg_create(1) for more information. See also Section 20.1, "Files and
3061: directories outside the installation prefix". Please note that you can
3062: modify variables in it easily by using FILES_SUBST in the package's
3063: Makefile:
1.1 dsieger 3064:
1.184 rillig 3065: FILES_SUBST+= SOMEVAR="somevalue"
1.1 dsieger 3066:
1.184 rillig 3067: replaces "@SOMEVAR@" with "somevalue" in the INSTALL. By default,
3068: substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
3069: few others, type make help topic=FILES_SUBST for a complete list.
1.1 dsieger 3070:
1.184 rillig 3071: DEINSTALL
1.1 dsieger 3072:
1.184 rillig 3073: This script is executed before and after any files are removed. It is this
3074: script's responsibility to clean up any additional messy details around the
3075: package's installation, since all pkg_delete knows is how to delete the
3076: files created in the original distribution. See pkg_delete(1) and
3077: pkg_create(1) for more information. The same methods to replace variables
3078: can be used as for the INSTALL file.
1.1 dsieger 3079:
1.184 rillig 3080: MESSAGE
1.1 dsieger 3081:
1.198 leot 3082: This file is displayed after installation of the package. While this was
3083: used often in the past, it has two problems: the display will be missed if
3084: many packages are intalled at once, and the person installing the package
3085: and the one using or configuring it may be different. It should therefore
3086: be used only in exceptional circumstances where lasting negative
3087: consequences would result from someone not reading it.
3088:
3089: MESSAGE should not be used for:
3090:
1.232 gutterid 3091: o exhortations to read the documentation
1.198 leot 3092:
1.232 gutterid 3093: o reminders to install rc.d files and set variables
1.198 leot 3094:
1.232 gutterid 3095: o anything that should be explained in the installation/configuration
1.198 leot 3096: documentation that should come with the package
3097:
3098: If the documentation provided by upstream needs enhancing, create e.g.
3099: files/README.pkgsrc and install it in the package's documentation
3100: directory.
3101:
3102: Note that MESSAGE is shown for all operating systems and all init systems.
3103: If a MESSAGE is necessary, it should be narrowed to only those operating
3104: systems and init systems to which it applies.
3105:
3106: Note that you can modify variables in it easily by using MESSAGE_SUBST in
3107: the package's Makefile:
1.1 dsieger 3108:
1.184 rillig 3109: MESSAGE_SUBST+= SOMEVAR="somevalue"
1.1 dsieger 3110:
1.184 rillig 3111: replaces "${SOMEVAR}" with "somevalue" in MESSAGE. By default, substitution
3112: is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
3113: PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1 dsieger 3114:
1.184 rillig 3115: You can display a different or additional files by setting the MESSAGE_SRC
3116: variable. Its default is MESSAGE, if the file exists.
1.1 dsieger 3117:
1.184 rillig 3118: ALTERNATIVES
1.1 dsieger 3119:
1.184 rillig 3120: This file is used by the alternatives framework. It creates, configures,
3121: and destroys generic wrappers used to run programs with similar interfaces.
3122: See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
3123: information.
1.1 dsieger 3124:
1.184 rillig 3125: Each line of the file contains two filenames, first the wrapper and then
3126: the alternative provided by the package. Both paths are relative to PREFIX.
1.1 dsieger 3127:
1.184 rillig 3128: 12.5.2. Files affecting the build process
1.1 dsieger 3129:
1.184 rillig 3130: Makefile.common
1.1 dsieger 3131:
1.184 rillig 3132: This file contains arbitrary things that could also go into a Makefile, but
3133: its purpose is to be used by more than one package. This file should only
3134: be used when the packages that will use the file are known in advance. For
3135: other purposes it is often better to write a *.mk file and give it a good
3136: name that describes what it does.
1.1 dsieger 3137:
1.184 rillig 3138: buildlink3.mk
1.1 dsieger 3139:
1.184 rillig 3140: This file contains the dependency information for the buildlink3 framework
3141: (see Chapter 18, Buildlink methodology).
1.1 dsieger 3142:
1.184 rillig 3143: hacks.mk
1.1 dsieger 3144:
1.184 rillig 3145: This file contains workarounds for compiler bugs and similar things. It is
3146: included automatically by the pkgsrc infrastructure, so you don't need an
3147: extra .include line for it.
1.1 dsieger 3148:
1.184 rillig 3149: options.mk
1.1 dsieger 3150:
1.184 rillig 3151: This file contains the code for the package-specific options (see
3152: Chapter 16, Options handling) that can be selected by the user. If a
3153: package has only one or two options, it is equally acceptable to put the
3154: code directly into the Makefile.
1.1 dsieger 3155:
1.184 rillig 3156: 12.5.3. Files affecting nothing at all
1.1 dsieger 3157:
1.184 rillig 3158: README*
1.1 dsieger 3159:
1.184 rillig 3160: These files do not take place in the creation of a package and thus are
3161: purely informative to the package developer.
1.1 dsieger 3162:
1.184 rillig 3163: TODO
1.1 dsieger 3164:
1.184 rillig 3165: This file contains things that need to be done to make the package even
3166: better.
1.1 dsieger 3167:
1.184 rillig 3168: 12.6. work*
1.1 dsieger 3169:
1.184 rillig 3170: When you type make, the distribution files are unpacked into the directory
3171: denoted by WRKDIR. It can be removed by running make clean. Besides the
3172: sources, this directory is also used to keep various timestamp files. The
3173: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
3174: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
1.1 dsieger 3175:
1.184 rillig 3176: 12.7. files/*
1.80 wiz 3177:
1.184 rillig 3178: If you have any files that you wish to be placed in the package prior to
3179: configuration or building, you can place these files here and use a ${CP}
3180: command in the "post-extract" target to achieve this.
1.1 dsieger 3181:
1.184 rillig 3182: If you want to share files in this way with other packages, set the FILESDIR
3183: variable to point to the other package's files directory, e.g.:
1.1 dsieger 3184:
1.184 rillig 3185: FILESDIR= ../../editors/xemacs/files
1.14 jmcneill 3186:
1.184 rillig 3187: Chapter 13. The build process
1.1 dsieger 3188:
1.184 rillig 3189: Table of Contents
1.1 dsieger 3190:
1.184 rillig 3191: 13.1. Introduction
3192: 13.2. Program location
3193: 13.3. Directories used during the build process
3194: 13.4. Running a phase
3195: 13.5. The fetch phase
3196: 13.5.1. What to fetch and where to get it from
3197: 13.5.2. How are the files fetched?
3198: 13.6. The checksum phase
3199: 13.7. The extract phase
3200: 13.8. The patch phase
3201: 13.9. The tools phase
3202: 13.10. The wrapper phase
3203: 13.11. The configure phase
3204: 13.12. The build phase
3205: 13.13. The test phase
3206: 13.14. The install phase
3207: 13.15. The package phase
3208: 13.16. Cleaning up
3209: 13.17. Other helpful targets
1.1 dsieger 3210:
1.184 rillig 3211: 13.1. Introduction
1.122 leot 3212:
1.184 rillig 3213: This chapter gives a detailed description on how a package is built. Building a
3214: package is separated into different phases (for example fetch, build, install),
3215: all of which are described in the following sections. Each phase is split into
3216: so-called stages, which take the name of the containing phase, prefixed by one
3217: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
3218: actual work is done in the do-* stages.
1.1 dsieger 3219:
1.184 rillig 3220: Never override the regular targets (like fetch), if you have to, override the
3221: do-* ones instead.
1.1 dsieger 3222:
1.184 rillig 3223: The basic steps for building a program are always the same. First the program's
3224: source (distfile) must be brought to the local system and then extracted. After
3225: any pkgsrc-specific patches to compile properly are applied, the software can
3226: be configured, then built (usually by compiling), and finally the generated
3227: binaries, etc. can be put into place on the system.
1.1 dsieger 3228:
1.184 rillig 3229: To get more details about what is happening at each step, you can set the
3230: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
3231: more details about the patch step.
1.1 dsieger 3232:
1.184 rillig 3233: 13.2. Program location
1.1 dsieger 3234:
1.184 rillig 3235: Before outlining the process performed by the NetBSD package system in the next
3236: section, here's a brief discussion on where programs are installed, and which
3237: variables influence this.
1.1 dsieger 3238:
1.184 rillig 3239: The automatic variable PREFIX indicates where all files of the final program
3240: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
3241: pkgs in the cross category. The value of PREFIX needs to be put into the
3242: various places in the program's source where paths to these files are encoded.
3243: See Section 12.3, "patches/*" and Section 21.3.1, "Shared libraries - libtool"
3244: for more details.
1.1 dsieger 3245:
1.184 rillig 3246: When choosing which of these variables to use, follow the following rules:
1.1 dsieger 3247:
1.184 rillig 3248: * PREFIX always points to the location where the current pkg will be
3249: installed. When referring to a pkg's own installation path, use "${PREFIX}"
3250: .
1.1 dsieger 3251:
1.223 nia 3252: * LOCALBASE is where all pkgs are installed. If you need to construct a -I or
3253: -L argument to the compiler to find includes and libraries installed by
3254: another pkg, use "${LOCALBASE}". The name LOCALBASE stems from FreeBSD,
3255: which installed all packages in /usr/local. As pkgsrc leaves /usr/local for
3256: the system administrator, this variable is a misnomer.
1.1 dsieger 3257:
1.184 rillig 3258: * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
3259: installed. When looking for standard X11 includes (not those installed by a
3260: package), use "${X11BASE}".
1.1 dsieger 3261:
1.184 rillig 3262: * X11-based packages using imake must set USE_IMAKE to be installed correctly
3263: under LOCALBASE.
1.1 dsieger 3264:
1.184 rillig 3265: * Within ${PREFIX}, packages should install files according to hier(7), with
3266: the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
3267: man.
1.1 dsieger 3268:
1.184 rillig 3269: 13.3. Directories used during the build process
1.2 rillig 3270:
1.184 rillig 3271: When building a package, various directories are used to store source files,
3272: temporary files, pkgsrc-internal files, and so on. These directories are
3273: explained here.
1.1 dsieger 3274:
1.184 rillig 3275: Some of the directory variables contain relative pathnames. There are two
3276: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
3277: used for directories that are pkgsrc-specific. WRKSRC is used for directories
3278: inside the package itself.
1.1 dsieger 3279:
1.184 rillig 3280: PKGSRCDIR
1.1 dsieger 3281:
1.184 rillig 3282: This is an absolute pathname that points to the pkgsrc root directory.
3283: Generally, you don't need it.
1.1 dsieger 3284:
1.184 rillig 3285: PKGDIR
1.1 dsieger 3286:
1.184 rillig 3287: This is an absolute pathname that points to the current package.
1.1 dsieger 3288:
1.184 rillig 3289: PKGPATH
1.1 dsieger 3290:
1.184 rillig 3291: This is a pathname relative to PKGSRCDIR that points to the current
1.228 gutterid 3292: package. It is defined after including bsd.prefs.mk and can be used in
3293: makefile fragments that are used by several packages to distinguish between
3294: these packages. Other variables that would serve the same purpose are
3295: PKGBASE and PKGNAME, but these are only defined after including bsd.pkg.mk,
3296: which is too late.
3297:
3298: In mk.conf, the pkgsrc user can use PKGPATH to tweak variables like
3299: MAKE_JOBS and CFLAGS.
1.1 dsieger 3300:
1.184 rillig 3301: WRKDIR
1.1 dsieger 3302:
1.184 rillig 3303: This is an absolute pathname pointing to the directory where all work takes
3304: place. The distfiles are extracted to this directory. It also contains
3305: temporary directories and log files used by the various pkgsrc frameworks,
3306: like buildlink or the wrappers.
1.1 dsieger 3307:
1.184 rillig 3308: WRKSRC
1.1 dsieger 3309:
1.184 rillig 3310: This is an absolute pathname pointing to the directory where the distfiles
3311: are extracted. It is usually a direct subdirectory of WRKDIR, and often
3312: it's the only directory entry that isn't hidden. This variable may be
3313: changed by a package Makefile.
1.1 dsieger 3314:
1.184 rillig 3315: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
3316: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
3317: created in the pkgsrc entry's directory. If users would like to have their
3318: pkgsrc trees behave in a read-only manner, then the value of
3319: CREATE_WRKDIR_SYMLINK should be set to no.
1.1 dsieger 3320:
1.184 rillig 3321: 13.4. Running a phase
1.1 dsieger 3322:
1.184 rillig 3323: You can run a particular phase by typing make phase, where phase is the name of
3324: the phase. This will automatically run all phases that are required for this
3325: phase. The default phase is build, that is, when you run make without
3326: parameters in a package directory, the package will be built, but not
3327: installed.
1.1 dsieger 3328:
1.184 rillig 3329: 13.5. The fetch phase
1.1 dsieger 3330:
1.184 rillig 3331: The first step in building a package is to fetch the distribution files
3332: (distfiles) from the sites that are providing them. This is the task of the
3333: fetch phase.
1.25 wiz 3334:
1.184 rillig 3335: 13.5.1. What to fetch and where to get it from
1.1 dsieger 3336:
1.184 rillig 3337: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
3338: name is derived from the DISTNAME variable, is fetched. The more complicated
3339: cases are described below.
1.1 dsieger 3340:
1.184 rillig 3341: The variable DISTFILES specifies the list of distfiles that have to be fetched.
3342: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
3343: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
3344: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
3345: your package requires additional distfiles to the default one, you cannot just
3346: append the additional filenames using the += operator, but you have write for
3347: example:
1.1 dsieger 3348:
1.184 rillig 3349: DISTFILES= ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1 dsieger 3350:
1.184 rillig 3351: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
3352: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
3353: can set SITES.distfile to the list of URLs where the file distfile (including
3354: the suffix) can be found.
1.1 dsieger 3355:
1.184 rillig 3356: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
3357: DISTFILES+= foo-file.tar.gz
3358: SITES.foo-file.tar.gz= \
3359: https://www.somewhere.com/somehow/ \
3360: https://www.somewhereelse.com/mirror/somehow/
1.1 dsieger 3361:
1.184 rillig 3362: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
3363: gets the name of each distfile appended to it, without an intermediate slash.
3364: Therefore, all site values have to end with a slash or other separator
3365: character. This allows for example to set MASTER_SITES to a URL of a CGI script
3366: that gets the name of the distfile as a parameter. In this case, the definition
3367: would look like:
1.1 dsieger 3368:
1.184 rillig 3369: MASTER_SITES= https://www.example.com/download.cgi?file=
1.1 dsieger 3370:
1.184 rillig 3371: The exception to this rule are URLs starting with a dash. In that case the URL
3372: is taken as is, fetched and the result stored under the name of the distfile.
3373: You can use this style for the case when the download URL style does not match
3374: the above common case. For example, if permanent download URL is a redirector
3375: to the real download URL, or the download file name is offered by an HTTP
3376: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
3377: created instead of the default v1.0.0.tar.gz.
1.1 dsieger 3378:
1.184 rillig 3379: DISTNAME= foo-1.0.0
3380: MASTER_SITES= -https://www.example.com/archive/v1.0.0.tar.gz
1.29 wiz 3381:
1.184 rillig 3382: There are some predefined values for MASTER_SITES, which can be used in
3383: packages. The names of the variables should speak for themselves.
1.29 wiz 3384:
1.225 gutterid 3385: MASTER_SITE_APACHE MASTER_SITE_BACKUP
3386: MASTER_SITE_CRATESIO MASTER_SITE_CYGWIN
3387: MASTER_SITE_DEBIAN MASTER_SITE_FREEBSD
3388: MASTER_SITE_FREEBSD_LOCAL MASTER_SITE_GENTOO
3389: MASTER_SITE_GITHUB MASTER_SITE_GITLAB
3390: MASTER_SITE_GNOME MASTER_SITE_GNU
3391: MASTER_SITE_GNUSTEP MASTER_SITE_HASKELL_HACKAGE
3392: MASTER_SITE_IFARCHIVE MASTER_SITE_KDE
3393: MASTER_SITE_MOZILLA MASTER_SITE_MOZILLA_ALL
3394: MASTER_SITE_MYSQL MASTER_SITE_NETLIB
3395: MASTER_SITE_OPENBSD MASTER_SITE_OPENOFFICE
3396: MASTER_SITE_OSDN MASTER_SITE_PERL_CPAN
3397: MASTER_SITE_PGSQL MASTER_SITE_PYPI
3398: MASTER_SITE_RUBYGEMS MASTER_SITE_R_CRAN
3399: MASTER_SITE_SOURCEFORGE MASTER_SITE_SUNSITE
3400: MASTER_SITE_SUSE MASTER_SITE_TEX_CTAN
3401: MASTER_SITE_XCONTRIB MASTER_SITE_XEMACS
3402: MASTER_SITE_XORG
1.1 dsieger 3403:
1.184 rillig 3404: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
3405: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
3406: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
3407: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
3408: distfiles/LOCAL_PORTS/.
1.1 dsieger 3409:
1.184 rillig 3410: If you choose one of these predefined sites, you may want to specify a
3411: subdirectory of that site. Since these macros may expand to more than one
3412: actual site, you must use the following construct to specify a subdirectory:
1.1 dsieger 3413:
1.184 rillig 3414: MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/}
3415: MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1 dsieger 3416:
1.184 rillig 3417: Note the trailing slash after the subdirectory name.
1.1 dsieger 3418:
1.184 rillig 3419: 13.5.2. How are the files fetched?
1.1 dsieger 3420:
1.184 rillig 3421: The fetch phase makes sure that all the distfiles exist in a local directory
3422: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
3423: are fetched using commands of the form
1.1 dsieger 3424:
1.184 rillig 3425: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
1.1 dsieger 3426:
1.184 rillig 3427: where ${site} varies through several possibilities in turn: first,
3428: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
3429: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
3430: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
3431: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
3432: MASTER_SORT_AWK or MASTER_SORT_REGEX.
1.1 dsieger 3433:
1.184 rillig 3434: The specific command and arguments used depend on the FETCH_USING parameter.
3435: The example above is for FETCH_USING=custom.
1.66 asau 3436:
1.184 rillig 3437: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
3438: target to mirror the distfiles, if they are freely distributable. Packages
3439: setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
3440: distfiles mirrored.
1.1 dsieger 3441:
1.184 rillig 3442: 13.6. The checksum phase
1.1 dsieger 3443:
1.184 rillig 3444: After the distfile(s) are fetched, their checksum is generated and compared
3445: with the checksums stored in the distinfo file. If the checksums don't match,
3446: the build is aborted. This is to ensure the same distfile is used for building,
3447: and that the distfile wasn't changed, e.g. by some malign force, deliberately
3448: changed distfiles on the master distribution site or network lossage.
1.1 dsieger 3449:
1.184 rillig 3450: 13.7. The extract phase
1.1 dsieger 3451:
1.184 rillig 3452: When the distfiles are present on the local system, they need to be extracted,
3453: as they usually come in the form of some compressed archive format.
1.1 dsieger 3454:
1.184 rillig 3455: By default, all DISTFILES are extracted. If you only need some of them, you can
3456: set the EXTRACT_ONLY variable to the list of those files.
1.1 dsieger 3457:
1.184 rillig 3458: Extracting the files is usually done by a little program, mk/extract/extract,
3459: which already knows how to extract various archive formats, so most likely you
3460: will not need to change anything here. But if you need, the following variables
3461: may help you:
1.1 dsieger 3462:
1.184 rillig 3463: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
1.1 dsieger 3464:
1.184 rillig 3465: Use these variables to override the default options for an extract command,
3466: which are defined in mk/extract/extract.
1.1 dsieger 3467:
1.184 rillig 3468: EXTRACT_USING
1.1 dsieger 3469:
1.184 rillig 3470: This variable can be set to bsdtar, gtar, nbtar (which is the default
3471: value), pax, or an absolute pathname pointing to the command with which tar
3472: archives should be extracted. It is preferred to choose bsdtar over gtar if
3473: NetBSD's pax-as-tar is not good enough.
1.1 dsieger 3474:
1.184 rillig 3475: If the extract program doesn't serve your needs, you can also override the
3476: EXTRACT_CMD variable, which holds the command used for extracting the files.
3477: This command is executed in the ${WRKSRC} directory. During execution of this
3478: command, the shell variable extract_file holds the absolute pathname of the
3479: file that is going to be extracted.
1.1 dsieger 3480:
1.184 rillig 3481: And if that still does not suffice, you can override the do-extract target in
3482: the package Makefile.
1.1 dsieger 3483:
1.184 rillig 3484: 13.8. The patch phase
1.1 dsieger 3485:
1.184 rillig 3486: After extraction, all the patches named by the PATCHFILES, those present in the
3487: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
3488: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
3489: are uncompressed before they are applied, files ending in .orig or .rej are
3490: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
3491: Section 12.3, "patches/*" for more details.
1.1 dsieger 3492:
1.184 rillig 3493: By default patch(1) is given special arguments to make it fail if the expected
3494: text from the patch context is not found in the patched file. If that happens,
3495: fix the patch file by comparing it with the actual text in the file to be
3496: patched.
1.1 dsieger 3497:
1.184 rillig 3498: 13.9. The tools phase
1.1 dsieger 3499:
1.184 rillig 3500: This is covered in Chapter 17, Tools needed for building or running.
1.1 dsieger 3501:
1.184 rillig 3502: 13.10. The wrapper phase
1.1 dsieger 3503:
1.184 rillig 3504: This phase creates wrapper programs for the compilers and linkers. The
3505: following variables can be used to tweak the wrappers.
1.1 dsieger 3506:
1.184 rillig 3507: ECHO_WRAPPER_MSG
1.1 dsieger 3508:
1.184 rillig 3509: The command used to print progress messages. Does nothing by default. Set
3510: to ${ECHO} to see the progress messages.
1.1 dsieger 3511:
1.184 rillig 3512: WRAPPER_DEBUG
1.1 dsieger 3513:
1.184 rillig 3514: This variable can be set to yes (default) or no, depending on whether you
3515: want additional information in the wrapper log file.
1.1 dsieger 3516:
1.184 rillig 3517: WRAPPER_UPDATE_CACHE
1.1 dsieger 3518:
1.184 rillig 3519: This variable can be set to yes or no, depending on whether the wrapper
3520: should use its cache, which will improve the speed. The default value is
3521: yes, but is forced to no if the platform does not support it.
1.1 dsieger 3522:
1.184 rillig 3523: WRAPPER_REORDER_CMDS
1.1 dsieger 3524:
1.184 rillig 3525: A list of reordering commands. A reordering command has the form reorder:l:
3526: lib1:lib2. It ensures that that -llib1 occurs before -llib2.
1.1 dsieger 3527:
1.184 rillig 3528: 13.11. The configure phase
1.1 dsieger 3529:
1.184 rillig 3530: Most pieces of software need information on the header files, system calls, and
3531: library routines which are available on the platform they run on. The process
3532: of determining this information is known as configuration, and is usually
3533: automated. In most cases, a script is supplied with the distfiles, and its
3534: invocation results in generation of header files, Makefiles, etc.
1.1 dsieger 3535:
1.184 rillig 3536: If the package contains a configure script, this can be invoked by setting
3537: HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
1.187 rillig 3538: should set GNU_CONFIGURE to "yes" instead.
1.1 dsieger 3539:
1.187 rillig 3540: In the do-configure stage, a rough equivalent of the following command is run.
3541: See mk/configure/configure.mk, target do-configure-script for the exact
3542: definition.
3543:
3544: .for dir in ${CONFIGURE_DIRS}
3545: cd ${WRKSRC} && cd ${dir} \
3546: && env ${CONFIGURE_ENV} \
3547: ${CONFIG_SHELL} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
1.184 rillig 3548: .endfor
1.1 dsieger 3549:
1.184 rillig 3550: CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
3551: each of these directories, the configure script is run with the environment
3552: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
3553: CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
3554: by the package.
1.1 dsieger 3555:
1.184 rillig 3556: If the program uses the Perl way of configuration (mainly Perl modules, but not
3557: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
3558: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
3559: (e.g., MAKE_PARAMS+=foo=bar
1.1 dsieger 3560:
1.184 rillig 3561: If the program uses an Imakefile for configuration, the appropriate steps can
3562: be invoked by setting USE_IMAKE to "yes". If you only need xmkmf, add it to
3563: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
3564: SCRIPTS_ENV variable.
1.1 dsieger 3565:
1.184 rillig 3566: If the program uses cmake for configuration, the appropriate steps can be
1.233 wiz 3567: invoked by including ../../devel/cmake/build.mk. You can add variables to
3568: cmake's environment by adding them to the CONFIGURE_ENV variable and arguments
3569: to cmake by adding them to the CMAKE_ARGS variable. If you want to add
3570: arguments only for particular stages, you can use the CMAKE_CONFIGURE_ARGS,
3571: CMAKE_BUILD_ARGS, and CMAKE_INSTALL_ARGS variables. You can set the
3572: CONFIGURE_DIRS variable to the directories in which CMake should be run,
3573: relative to WRKSRC. This defaults to to ".".
1.1 dsieger 3574:
1.184 rillig 3575: If there is no configure step at all, set NO_CONFIGURE to "yes".
1.1 dsieger 3576:
1.184 rillig 3577: 13.12. The build phase
1.1 dsieger 3578:
1.187 rillig 3579: For building a package, a rough equivalent of the following code is executed;
3580: see mk/build/build.mk, target do-build for the exact definition.
1.154 rillig 3581:
1.187 rillig 3582: .for dir in ${BUILD_DIRS}
3583: cd ${WRKSRC} && cd ${dir} \
1.184 rillig 3584: && env ${MAKE_ENV} \
1.187 rillig 3585: ${MAKE_PROGRAM} ${MAKE_FLAGS} ${BUILD_MAKE_FLAGS} \
1.184 rillig 3586: -f ${MAKE_FILE} \
3587: ${BUILD_TARGET}
3588: .endfor
1.1 dsieger 3589:
1.184 rillig 3590: BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
3591: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
3592: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
3593: and BUILD_TARGET may all be changed by the package.
1.1 dsieger 3594:
1.184 rillig 3595: The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
3596: make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
3597: defaults to "all".
1.1 dsieger 3598:
1.184 rillig 3599: If there is no build step at all, set NO_BUILD to "yes".
1.1 dsieger 3600:
1.184 rillig 3601: 13.13. The test phase
1.1 dsieger 3602:
1.184 rillig 3603: [TODO]
1.1 dsieger 3604:
1.184 rillig 3605: 13.14. The install phase
1.1 dsieger 3606:
1.184 rillig 3607: Once the build stage has completed, the final step is to install the software
3608: in public directories, so users can access the programs and files.
1.1 dsieger 3609:
1.187 rillig 3610: In the install phase, a rough equivalent of the following code is executed; see
3611: mk/install/install.mk, target do-install for the exact definition.
3612: Additionally, before and after this code, several consistency checks are run
3613: against the files-to-be-installed, see mk/check/*.mk for details.
3614:
3615: .for dir in ${INSTALL_DIRS}
3616: cd ${WRKSRC} && cd ${dir} \
3617: && env ${INSTALL_ENV} ${MAKE_ENV} \
3618: ${MAKE_PROGRAM} ${MAKE_FLAGS} ${INSTALL_MAKE_FLAGS} \
3619: -f ${MAKE_FILE} ${INSTALL_TARGET}
1.184 rillig 3620: .endfor
1.1 dsieger 3621:
1.184 rillig 3622: The variable's meanings are analogous to the ones in the build phase.
3623: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
3624: plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
3625: defined.
1.1 dsieger 3626:
1.184 rillig 3627: In the install phase, the following variables are useful. They are all
3628: variations of the install(1) command that have the owner, group and permissions
3629: preset. INSTALL is the plain install command. The specialized variants,
3630: together with their intended use, are:
1.1 dsieger 3631:
1.184 rillig 3632: INSTALL_PROGRAM_DIR
1.1 dsieger 3633:
1.184 rillig 3634: directories that contain binaries
1.1 dsieger 3635:
1.184 rillig 3636: INSTALL_SCRIPT_DIR
1.1 dsieger 3637:
1.184 rillig 3638: directories that contain scripts
1.1 dsieger 3639:
1.184 rillig 3640: INSTALL_LIB_DIR
1.1 dsieger 3641:
1.184 rillig 3642: directories that contain shared and static libraries
1.1 dsieger 3643:
1.184 rillig 3644: INSTALL_DATA_DIR
1.108 rillig 3645:
1.184 rillig 3646: directories that contain data files
1.108 rillig 3647:
1.184 rillig 3648: INSTALL_MAN_DIR
1.108 rillig 3649:
1.184 rillig 3650: directories that contain man pages
1.108 rillig 3651:
1.184 rillig 3652: INSTALL_GAME_DIR
1.108 rillig 3653:
1.184 rillig 3654: directories that contain data files for games
1.108 rillig 3655:
1.184 rillig 3656: INSTALL_PROGRAM
1.108 rillig 3657:
1.184 rillig 3658: binaries that can be stripped from debugging symbols
1.108 rillig 3659:
1.184 rillig 3660: INSTALL_SCRIPT
1.108 rillig 3661:
1.184 rillig 3662: binaries that cannot be stripped
1.108 rillig 3663:
1.184 rillig 3664: INSTALL_GAME
1.108 rillig 3665:
1.184 rillig 3666: game binaries
1.108 rillig 3667:
1.184 rillig 3668: INSTALL_LIB
1.108 rillig 3669:
1.184 rillig 3670: shared and static libraries
1.108 rillig 3671:
1.184 rillig 3672: INSTALL_DATA
1.108 rillig 3673:
1.184 rillig 3674: data files
1.1 dsieger 3675:
1.184 rillig 3676: INSTALL_GAME_DATA
1.1 dsieger 3677:
1.184 rillig 3678: data files for games
1.108 rillig 3679:
1.184 rillig 3680: INSTALL_MAN
1.108 rillig 3681:
1.184 rillig 3682: man pages
1.1 dsieger 3683:
1.184 rillig 3684: Some other variables are:
1.1 dsieger 3685:
1.184 rillig 3686: INSTALL_UNSTRIPPED
1.1 dsieger 3687:
1.184 rillig 3688: If set to yes, do not run strip(1) when installing binaries. Any debugging
3689: sections and symbols present in binaries will be preserved.
1.1 dsieger 3690:
1.184 rillig 3691: INSTALLATION_DIRS
1.1 dsieger 3692:
1.184 rillig 3693: A list of directories relative to PREFIX that are created by pkgsrc at the
3694: beginning of the install phase. The package is supposed to create all
3695: needed directories itself before installing files to it and list all other
3696: directories here.
1.1 dsieger 3697:
1.184 rillig 3698: In the rare cases that a package shouldn't install anything, set NO_INSTALL to
3699: "yes". This is mostly relevant for packages in the regress category.
1.1 dsieger 3700:
1.184 rillig 3701: 13.15. The package phase
1.121 sevan 3702:
1.184 rillig 3703: Once the install stage has completed, a binary package of the installed files
3704: can be built. These binary packages can be used for quick installation without
3705: previous compilation, e.g. by the make bin-install or by using pkg_add.
1.1 dsieger 3706:
1.184 rillig 3707: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
3708: created in ${PACKAGES}/category, one for each category in the CATEGORIES
3709: variable. PACKAGES defaults to pkgsrc/packages.
1.1 dsieger 3710:
1.184 rillig 3711: 13.16. Cleaning up
1.1 dsieger 3712:
1.184 rillig 3713: Once you're finished with a package, you can clean the work directory by
3714: running make clean. If you want to clean the work directories of all
3715: dependencies too, use make clean-depends.
1.1 dsieger 3716:
1.184 rillig 3717: 13.17. Other helpful targets
1.1 dsieger 3718:
1.184 rillig 3719: pre/post-*
1.1 dsieger 3720:
1.184 rillig 3721: For any of the main targets described in the previous section (configure,
3722: build, install, etc.), two auxiliary targets exist with "pre-" and "post-"
3723: used as a prefix for the main target's name. These targets are invoked
3724: before and after the main target is called, allowing extra configuration or
3725: installation steps be performed from a package's Makefile, for example,
3726: which a program's configure script or install target omitted.
3727:
3728: About 5% of the pkgsrc packages define their custom post-extract target,
3729: another 5% define pre-configure, and 10% define post-install. The other pre
3730: /post-* targets are defined even less often.
1.1 dsieger 3731:
1.184 rillig 3732: do-*
1.182 leot 3733:
1.184 rillig 3734: Should one of the main targets do the wrong thing, and should there be no
3735: variable to fix this, you can redefine it with the do-* target. (Note that
3736: redefining the target itself instead of the do-* target is a bad idea, as
3737: the pre-* and post-* targets won't be called anymore, etc.)
1.1 dsieger 3738:
1.184 rillig 3739: About 15% of the pkgsrc packages override the default do-install, the other
3740: do-* targets are overridden even less often.
1.1 dsieger 3741:
1.184 rillig 3742: reinstall
1.1 dsieger 3743:
1.184 rillig 3744: If you did a make install and you noticed some file was not installed
3745: properly, you can repeat the installation with this target, which will
3746: ignore the "already installed" flag.
1.1 dsieger 3747:
1.184 rillig 3748: This is the default value of DEPENDS_TARGET except in the case of make
3749: update and make package, where the defaults are "package" and "update",
3750: respectively.
1.1 dsieger 3751:
1.184 rillig 3752: deinstall
1.1 dsieger 3753:
1.184 rillig 3754: This target does a pkg_delete(1) in the current directory, effectively
3755: de-installing the package. The following variables can be used to tune the
3756: behaviour:
1.1 dsieger 3757:
1.184 rillig 3758: PKG_VERBOSE
1.1 dsieger 3759:
1.184 rillig 3760: Add a "-v" to the pkg_delete(1) command.
1.1 dsieger 3761:
1.184 rillig 3762: DEINSTALLDEPENDS
1.1 dsieger 3763:
1.184 rillig 3764: Remove all packages that require (depend on) the given package. This
3765: can be used to remove any packages that may have been pulled in by a
3766: given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
3767: pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
3768: " to the pkg_delete(1) command line.
1.1 dsieger 3769:
1.184 rillig 3770: bin-install
1.1 dsieger 3771:
1.184 rillig 3772: Install a binary package from local disk and via FTP from a list of sites
3773: (see the BINPKG_SITES variable), and do a make package if no binary package
3774: is available anywhere. The arguments given to pkg_add can be set via
3775: BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
1.1 dsieger 3776:
1.184 rillig 3777: install-clean
1.1 dsieger 3778:
1.184 rillig 3779: This target removes the state files for the "install" and later phases so
3780: that the "install" target may be re-invoked. This can be used after editing
3781: the PLIST to install the package without rebuilding it.
1.1 dsieger 3782:
1.184 rillig 3783: build-clean
1.18 mishka 3784:
1.184 rillig 3785: This target removes the state files for the "build" and later phases so
3786: that the "build" target may be re-invoked.
1.18 mishka 3787:
1.184 rillig 3788: update
1.18 mishka 3789:
1.184 rillig 3790: This target causes the current package to be updated to the latest version.
3791: The package and all depending packages first get de-installed, then current
3792: versions of the corresponding packages get compiled and installed. This is
3793: similar to manually noting which packages are currently installed, then
3794: performing a series of make deinstall and make install (or whatever
3795: UPDATE_TARGET is set to) for these packages.
1.18 mishka 3796:
1.184 rillig 3797: You can use the "update" target to resume package updating in case a
3798: previous make update was interrupted for some reason. However, in this
3799: case, make sure you don't call make clean or otherwise remove the list of
3800: dependent packages in WRKDIR. Otherwise, you lose the ability to
3801: automatically update the current package along with the dependent packages
3802: you have installed.
1.121 sevan 3803:
1.184 rillig 3804: Resuming an interrupted make update will only work as long as the package
3805: tree remains unchanged. If the source code for one of the packages to be
3806: updated has been changed, resuming make update will most certainly fail!
1.1 dsieger 3807:
1.184 rillig 3808: The following variables can be used either on the command line or in
3809: mk.conf to alter the behaviour of make update:
1.1 dsieger 3810:
1.184 rillig 3811: UPDATE_TARGET
1.1 dsieger 3812:
1.184 rillig 3813: Install target to recursively use for the updated package and the
3814: dependent packages. Defaults to DEPENDS_TARGET if set, "install"
3815: otherwise for make update. Other good targets are "package" or "
3816: bin-install". Do not set this to "update" or you will get stuck in an
3817: endless loop!
1.1 dsieger 3818:
1.184 rillig 3819: NOCLEAN
1.1 dsieger 3820:
1.184 rillig 3821: Don't clean up after updating. Useful if you want to leave the work
3822: sources of the updated packages around for inspection or other
3823: purposes. Be sure you eventually clean up the source tree (see the "
3824: clean-update" target below) or you may run into troubles with old
3825: source code still lying around on your next make or make update.
1.1 dsieger 3826:
1.184 rillig 3827: REINSTALL
1.1 dsieger 3828:
1.184 rillig 3829: Deinstall each package before installing (making DEPENDS_TARGET). This
3830: may be necessary if the "clean-update" target (see below) was called
3831: after interrupting a running make update.
1.1 dsieger 3832:
1.184 rillig 3833: DEPENDS_TARGET
1.1 dsieger 3834:
1.184 rillig 3835: Allows you to disable recursion and hardcode the target for packages.
3836: The default is "update" for the update target, facilitating a recursive
3837: update of prerequisite packages. Only set DEPENDS_TARGET if you want to
3838: disable recursive updates. Use UPDATE_TARGET instead to just set a
3839: specific target for each package to be installed during make update
3840: (see above).
1.1 dsieger 3841:
1.184 rillig 3842: clean-update
1.1 dsieger 3843:
1.184 rillig 3844: Clean the source tree for all packages that would get updated if make
3845: update was called from the current directory. This target should not be
3846: used if the current package (or any of its depending packages) have already
3847: been de-installed (e.g., after calling make update) or you may lose some
3848: packages you intended to update. As a rule of thumb: only use this target
3849: before the first time you run make update and only if you have a dirty
3850: package tree (e.g., if you used NOCLEAN).
1.86 wiz 3851:
1.184 rillig 3852: If you are unsure about whether your tree is clean, you can either perform
3853: a make clean at the top of the tree, or use the following sequence of
3854: commands from the directory of the package you want to update (before
3855: running make update for the first time, otherwise you lose all the packages
3856: you wanted to update!):
1.86 wiz 3857:
1.184 rillig 3858: # make clean-update
3859: # make clean CLEANDEPENDS=YES
3860: # make update
1.86 wiz 3861:
3862:
1.184 rillig 3863: The following variables can be used either on the command line or in
3864: mk.conf to alter the behaviour of make clean-update:
1.86 wiz 3865:
1.184 rillig 3866: CLEAR_DIRLIST
1.86 wiz 3867:
1.184 rillig 3868: After make clean, do not reconstruct the list of directories to update
3869: for this package. Only use this if make update successfully installed
3870: all packages you wanted to update. Normally, this is done automatically
3871: on make update, but may have been suppressed by the NOCLEAN variable
3872: (see above).
1.1 dsieger 3873:
1.184 rillig 3874: replace
1.1 dsieger 3875:
1.184 rillig 3876: Update the installation of the current package. This differs from update in
3877: that it does not replace dependent packages. You will need to install
3878: pkgtools/pkg_tarup for this target to work.
1.1 dsieger 3879:
1.184 rillig 3880: Be careful when using this target! There are no guarantees that dependent
3881: packages will still work, in particular they will most certainly break if
3882: you make replace a library package whose shared library major version
3883: changed between your installed version and the new one. For this reason,
3884: this target is not officially supported and only recommended for advanced
3885: users.
1.1 dsieger 3886:
1.184 rillig 3887: info
1.1 dsieger 3888:
1.184 rillig 3889: This target invokes pkg_info(1) for the current package. You can use this
3890: to check which version of a package is installed.
1.86 wiz 3891:
1.184 rillig 3892: index
1.1 dsieger 3893:
1.184 rillig 3894: This is a top-level command, i.e. it should be used in the pkgsrc
3895: directory. It creates a database of all packages in the local pkgsrc tree,
3896: including dependencies, comment, maintainer, and some other useful
3897: information. Individual entries are created by running make describe in the
3898: packages' directories. This index file is saved as pkgsrc/INDEX. It can be
3899: displayed in verbose format by running make print-index. You can search in
3900: it with make search key=something. You can extract a list of all packages
3901: that depend on a particular one by running make show-deps PKG=somepackage.
1.1 dsieger 3902:
1.184 rillig 3903: Running this command takes a very long time, some hours even on fast
3904: machines!
1.1 dsieger 3905:
1.184 rillig 3906: readme
1.1 dsieger 3907:
1.199 nia 3908: This target generates a index.html file, which can be viewed using a
1.184 rillig 3909: browser such as www/firefox or www/links. The generated files contain
3910: references to any packages which are in the PACKAGES directory on the local
3911: host. The generated files can be made to refer to URLs based on
3912: FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
1.199 nia 3913: index.html files which pointed to binary packages on the local machine, in
1.184 rillig 3914: the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
3915: FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
3916: subdirectories will be searched for all the binary packages.
1.1 dsieger 3917:
1.184 rillig 3918: The target can be run at the toplevel or in category directories, in which
3919: case it descends recursively.
1.1 dsieger 3920:
1.184 rillig 3921: readme-all
1.1 dsieger 3922:
1.184 rillig 3923: This is a top-level command, run it in pkgsrc. Use this target to create a
3924: file README-all.html which contains a list of all packages currently
3925: available in the NetBSD Packages Collection, together with the category
3926: they belong to and a short description. This file is compiled from the
1.199 nia 3927: pkgsrc/*/index.html files, so be sure to run this after a make readme.
1.1 dsieger 3928:
1.184 rillig 3929: cdrom-readme
1.1 dsieger 3930:
1.184 rillig 3931: This is very much the same as the "readme" target (see above), but is to be
3932: used when generating a pkgsrc tree to be written to a CD-ROM. This target
1.199 nia 3933: also produces index.html files, and can be made to refer to URLs based on
1.184 rillig 3934: CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
1.1 dsieger 3935:
1.184 rillig 3936: show-distfiles
1.1 dsieger 3937:
1.184 rillig 3938: This target shows which distfiles and patchfiles are needed to build the
3939: package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
3940: patches/*).
1.1 dsieger 3941:
1.184 rillig 3942: show-downlevel
1.1 dsieger 3943:
1.184 rillig 3944: This target shows nothing if the package is not installed. If a version of
3945: this package is installed, but is not the version provided in this version
3946: of pkgsrc, then a warning message is displayed. This target can be used to
3947: show which of your installed packages are downlevel, and so the old
3948: versions can be deleted, and the current ones added.
1.1 dsieger 3949:
1.184 rillig 3950: show-pkgsrc-dir
1.1 dsieger 3951:
1.184 rillig 3952: This target shows the directory in the pkgsrc hierarchy from which the
3953: package can be built and installed. This may not be the same directory as
3954: the one from which the package was installed. This target is intended to be
3955: used by people who may wish to upgrade many packages on a single host, and
3956: can be invoked from the top-level pkgsrc Makefile by using the "
3957: show-host-specific-pkgs" target.
1.1 dsieger 3958:
1.184 rillig 3959: show-installed-depends
1.1 dsieger 3960:
1.184 rillig 3961: This target shows which installed packages match the current package's
3962: DEPENDS. Useful if out of date dependencies are causing build problems.
1.1 dsieger 3963:
1.184 rillig 3964: print-build-depends-list
1.1 dsieger 3965:
1.184 rillig 3966: This target shows the list of packages that the current package depends on
3967: for building.
1.1 dsieger 3968:
1.184 rillig 3969: print-run-depends-list
1.1 dsieger 3970:
1.184 rillig 3971: This target shows the list of packages that the current package depends on
3972: for running.
1.1 dsieger 3973:
1.184 rillig 3974: check-shlibs
1.1 dsieger 3975:
1.184 rillig 3976: After a package is installed, check all its binaries and (on ELF platforms)
3977: shared libraries to see if they find the shared libs they need. Run by
3978: default if PKG_DEVELOPER is set in mk.conf.
1.1 dsieger 3979:
1.184 rillig 3980: print-PLIST
1.1 dsieger 3981:
1.184 rillig 3982: After a "make install" from a new or upgraded pkg, this prints out an
3983: attempt to generate a new PLIST from a find -newer work/.extract_done. An
3984: attempt is made to care for shared libs etc., but it is strongly
3985: recommended to review the result before putting it into PLIST. On upgrades,
3986: it's useful to diff the output of this command against an already existing
3987: PLIST file.
1.1 dsieger 3988:
1.184 rillig 3989: If the package installs files via tar(1) or other methods that don't update
3990: file access times, be sure to add these files manually to your PLIST, as
3991: the "find -newer" command used by this target won't catch them!
1.56 ryoon 3992:
1.184 rillig 3993: See Section 19.3, "Tweaking output of make print-PLIST" for more
3994: information on this target.
1.1 dsieger 3995:
1.184 rillig 3996: Chapter 14. Creating a new pkgsrc package from scratch
1.1 dsieger 3997:
1.184 rillig 3998: Table of Contents
1.1 dsieger 3999:
1.184 rillig 4000: 14.1. Common types of packages
1.219 nia 4001: 14.1.1. Python modules and programs
4002: 14.1.2. R packages
4003: 14.1.3. TeXlive packages
1.184 rillig 4004: 14.2. Examples
4005: 14.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 4006:
1.184 rillig 4007: When you find a package that is not yet in pkgsrc, you most likely have a URL
4008: from where you can download the source code. Starting with this URL, creating a
4009: package involves only a few steps.
1.1 dsieger 4010:
1.184 rillig 4011: 1. In your mk.conf, set PKG_DEVELOPER=yes to enable the basic quality checks.
1.1 dsieger 4012:
1.184 rillig 4013: 2. Install the package meta-pkgs/pkg_developer, which among others will
4014: install the utilities url2pkg, pkglint, pkgvi and mkpatches:
1.1 dsieger 4015:
1.184 rillig 4016: $ cd /usr/pkgsrc
4017: $ (cd meta-pkgs/pkg_developer && bmake update)
1.1 dsieger 4018:
1.184 rillig 4019: 3. Choose one of the top-level directories as the category in which you want
4020: to place your package. You can also create a directory of your own (maybe
1.219 nia 4021: called local). Change into that category directory:
1.1 dsieger 4022:
1.219 nia 4023: $ cd category
1.1 dsieger 4024:
1.219 nia 4025: 4. Run the program url2pkg, passing as argument the URL of the distribution
4026: file (in most cases a .tar.gz file). This will download the distribution
4027: file and create the necessary files of the package, based on what's in the
4028: distribution file:
1.1 dsieger 4029:
1.184 rillig 4030: $ url2pkg https://www.example.org/packages/package-1.0.tar.gz
1.1 dsieger 4031:
1.184 rillig 4032: 5. Examine the extracted files to determine the dependencies of your package.
4033: Ideally, this is mentioned in some README file, but things may differ. For
4034: each of these dependencies, look where it exists in pkgsrc, and if there is
4035: a file called buildlink3.mk in that directory, add a line to your package
4036: Makefile which includes that file just before the last line. If the
4037: buildlink3.mk file does not exist, it must be created first. The
4038: buildlink3.mk file makes sure that the package's include files and
4039: libraries are provided.
1.1 dsieger 4040:
1.219 nia 4041: If you just need binaries from a dependent package, add a DEPENDS line to
4042: the Makefile, which specifies the version of the dependency and where it
4043: can be found in pkgsrc. This line should be placed in the third paragraph.
4044: If the dependency is only needed for building the package, but not when
4045: using it, use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The
4046: difference between TOOL_DEPENDS and BUILD_DEPENDS occurs when
4047: cross-compiling: TOOL_DEPENDS are native packages, i.e. packages for the
4048: platform where the package is built; BUILD_DEPENDS are target packages,
4049: i.e. packages for the platform for which the package is built. There is
4050: also TEST_DEPENDS, which specifies a dependency used only for testing the
4051: resulting package built, using the upstream project's included test suite,
4052: on the native platform. Your package may then look like this:
1.1 dsieger 4053:
1.184 rillig 4054: [...]
1.1 dsieger 4055:
1.184 rillig 4056: TOOL_DEPENDS+= libxslt-[0-9]*:../../textproc/libxslt
4057: DEPENDS+= screen-[0-9]*:../../misc/screen
4058: DEPENDS+= screen>=4.0:../../misc/screen
1.1 dsieger 4059:
1.184 rillig 4060: [...]
1.1 dsieger 4061:
1.184 rillig 4062: .include "../../category/package/buildlink3.mk"
4063: .include "../../devel/glib2/buildlink3.mk"
4064: .include "../../mk/bsd.pkg.mk"
1.1 dsieger 4065:
1.184 rillig 4066: 6. Run pkglint to see what things still need to be done to make your package a
4067: "good" one. If you don't know what pkglint's warnings want to tell you, try
4068: pkglint --explain or pkglint -e, which outputs additional explanations.
1.1 dsieger 4069:
1.184 rillig 4070: 7. In many cases the package is not yet ready to build. You can find
4071: instructions for the most common cases in the next section, Section 14.1,
4072: "Common types of packages". After you have followed the instructions over
4073: there, you can hopefully continue here.
1.1 dsieger 4074:
1.184 rillig 4075: 8. Run bmake clean to clean the working directory from the extracted files.
1.219 nia 4076: Besides these files, a lot of cache files and other system information have
4077: been saved in the working directory, which may have become outdated after
4078: you edited the Makefile.
1.1 dsieger 4079:
1.184 rillig 4080: 9. Now, run bmake to build the package. For the various things that can go
4081: wrong in this phase, consult Chapter 21, Making your package work.
1.1 dsieger 4082:
1.184 rillig 4083: If the extracted files from the package need to be fixed, run multiple
4084: rounds of these commands:
1.1 dsieger 4085:
1.219 nia 4086: $ bmake
1.184 rillig 4087: $ pkgvi ${WRKSRC}/some/file/that/does/not/compile
4088: $ mkpatches
1.219 nia 4089: $ bmake mps
4090: $ bmake clean
1.1 dsieger 4091:
1.184 rillig 4092: 10. When the package builds fine, the next step is to install the package. Run
4093: bmake install and hope that everything works.
1.1 dsieger 4094:
1.184 rillig 4095: 11. Up to now, the file PLIST, which contains a list of the files that are
4096: installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
4097: generate a probably correct list. Check the file using your preferred text
4098: editor to see if the list of files looks plausible.
1.1 dsieger 4099:
1.184 rillig 4100: 12. Run pkglint again to see if the generated PLIST contains garbage or not.
1.1 dsieger 4101:
1.184 rillig 4102: 13. When you ran bmake install, the package had been registered in the database
4103: of installed files, but with an empty list of files. To fix this, run bmake
4104: deinstall and bmake install again. Now the package is registered with the
4105: list of files from PLIST.
1.48 wiz 4106:
1.219 nia 4107: 14. Run bmake clean update to run everything from above again in a single step,
1.184 rillig 4108: making sure that the PLIST is correct and the whole package is created as
4109: intended.
1.48 wiz 4110:
1.219 nia 4111: 15. Run pkglint to see if there's anything left to do.
1.48 wiz 4112:
1.219 nia 4113: 16. Commit the package to pkgsrc-wip or main pkgsrc; see Chapter 23, Submitting
1.184 rillig 4114: and Committing.
1.50 wiz 4115:
1.184 rillig 4116: 14.1. Common types of packages
1.1 dsieger 4117:
1.219 nia 4118: 14.1.1. Python modules and programs
1.1 dsieger 4119:
1.184 rillig 4120: Python modules and programs packages are easily created using a set of
4121: predefined variables.
1.1 dsieger 4122:
1.184 rillig 4123: If some Python versions are not supported by the software, set the
4124: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
4125: supported, e.g.
1.1 dsieger 4126:
1.184 rillig 4127: PYTHON_VERSIONS_INCOMPATIBLE= 27
1.1 dsieger 4128:
1.184 rillig 4129: If the packaged software is a Python module, include one of ../../lang/python/
1.215 wiz 4130: egg.mk or ../../lang/python/extension.mk.
1.1 dsieger 4131:
1.215 wiz 4132: Most Python packages use setuptools ("eggs"). If the packaged software is using
4133: setuptools, you only need to include "../../lang/python/egg.mk".
1.1 dsieger 4134:
1.184 rillig 4135: Either way, the package directory should be called "py-software" and PKGNAME
4136: should be set to "${PYPKGPREFIX}-${DISTNAME}", e.g.
1.1 dsieger 4137:
1.184 rillig 4138: DISTNAME= foopymodule-1.2.10
4139: PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
1.1 dsieger 4140:
1.226 gutterid 4141: For software in PyPi, the name should match what PyPi specifies for "pip
4142: install software".
4143:
1.184 rillig 4144: If it is an application, include "../../lang/python/application.mk". In order
4145: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
4146: variable and set it to the list of files (paths relative to WRKSRC) that must
4147: be corrected. For example:
1.1 dsieger 4148:
1.184 rillig 4149: REPLACE_PYTHON= *.py
1.1 dsieger 4150:
1.184 rillig 4151: Some Python modules have separate distributions for Python-2.x and Python-3.x
4152: support. In pkgsrc this is handled by the versioned_dependencies.mk file. Set
4153: PYTHON_VERSIONED_DEPENDENCIES to the list of packages that should be depended
4154: upon and include "../../lang/python/versioned_dependencies.mk", then the pkgsrc
4155: infrastructure will depend on the appropriate package version. For example:
1.1 dsieger 4156:
1.184 rillig 4157: PYTHON_VERSIONED_DEPENDENCIES=dialog
1.1 dsieger 4158:
1.184 rillig 4159: Look inside versioned_dependencies.mk for a list of supported packages.
1.1 dsieger 4160:
1.219 nia 4161: 14.1.2. R packages
1.1 dsieger 4162:
1.184 rillig 4163: Simple R packages from CRAN are handled automatically by R2pkg, which is
4164: available in pkgtools/R2pkg. Individual packages (and optionally their
4165: dependencies) may be created and updated. R packages generally follow the same
4166: form, and most of the relevant information needed is contained in a DESCRIPTION
4167: file as part of each R package on CRAN. Consequently, R2pkg downloads that
4168: information and creates or updates a package in the canonical form. The
4169: resulting package should be reviewed for correctness.
1.1 dsieger 4170:
1.219 nia 4171: 14.1.3. TeXlive packages
1.1 dsieger 4172:
1.184 rillig 4173: TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
4174: available in pkgtools/texlive2pkg.
1.1 dsieger 4175:
1.184 rillig 4176: If the TeXlive package name is not known, it may be useful to search CTAN. A "
4177: Contained in" field on the package page typically identifies the basename of
4178: the package file in the TeXlive archive.
1.1 dsieger 4179:
1.184 rillig 4180: If the TeXlive package name is known, download the files from the TeXlive
4181: archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
4182: packages also have associated documentation packages, so download
4183: foo.doc.tar.xz at the same time. These files should be placed in the
4184: appropriate category directory, which is often but not always print. Then run
4185: the following command in the category directory.
1.1 dsieger 4186:
1.184 rillig 4187: texlive2pkg foo.tar.xz foo.doc.tar.xz
1.1 dsieger 4188:
1.184 rillig 4189: This will create two packages, tex-foo and tex-foo-doc. Be sure to check that
4190: both packages are correct.
1.1 dsieger 4191:
1.184 rillig 4192: Finally, CTAN currently does not include version information in package
4193: filenames and changes their contents periodically when updates occur.
4194: Consequently, pkgsrc avoids downloading distfiles directly from CTAN and
4195: instead relies on the pkgsrc archives. For each new or updated TeXlive package,
4196: e.g., the main one and the corresponding documentation, upload the distfiles
4197: with the following command in each package directory.
1.1 dsieger 4198:
1.184 rillig 4199: make upload-distfiles
1.117 sevan 4200:
1.184 rillig 4201: 14.2. Examples
1.117 sevan 4202:
1.184 rillig 4203: 14.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 4204:
1.184 rillig 4205: 14.2.1.1. The initial package
1.1 dsieger 4206:
1.184 rillig 4207: Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
4208: been imported into pkgsrc. As the description says it has to do with the web,
4209: the obvious choice for the category is "www".
1.1 dsieger 4210:
1.184 rillig 4211: $ mkdir www/nvu
4212: $ cd www/nvu
1.1 dsieger 4213:
1.184 rillig 4214: The web site says that the sources are available as a tar file, so I fed that
4215: URL to the url2pkg program:
1.1 dsieger 4216:
1.184 rillig 4217: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
1.1 dsieger 4218:
1.184 rillig 4219: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
4220: package name should not have the word "sources" in it. I also filled in the
4221: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
4222: that:
1.1 dsieger 4223:
1.184 rillig 4224: # $NetBSD $
4225: #
1.1 dsieger 4226:
1.184 rillig 4227: DISTNAME= nvu-1.0-sources
4228: PKGNAME= nvu-1.0
4229: CATEGORIES= www
4230: MASTER_SITES= http://cvs.nvu.com/download/
4231: EXTRACT_SUFX= .tar.bz2
1.1 dsieger 4232:
1.184 rillig 4233: MAINTAINER= rillig@NetBSD.org
4234: HOMEPAGE= http://cvs.nvu.com/
4235: COMMENT= Web Authoring System
1.1 dsieger 4236:
1.184 rillig 4237: # url2pkg-marker (please do not remove this line.)
4238: .include "../../mk/bsd.pkg.mk"
1.1 dsieger 4239:
1.184 rillig 4240: On the first line of output above, an artificial space has been added between
4241: NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
4242: the guide.
1.1 dsieger 4243:
1.184 rillig 4244: Then, I quit the editor and watched pkgsrc downloading a large source archive:
1.1 dsieger 4245:
1.184 rillig 4246: url2pkg> Running "make makesum" ...
4247: => Required installed package digest>=20010302: digest-20060826 found
4248: => Fetching nvu-1.0-sources.tar.bz2
4249: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
4250: 100% |*************************************| 28992 KB 150.77 KB/s00:00 ETA
4251: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
4252: url2pkg> Running "make extract" ...
4253: => Required installed package digest>=20010302: digest-20060826 found
4254: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
4255: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
4256: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
4257: ===> Installing dependencies for nvu-1.0
4258: ===> Overriding tools for nvu-1.0
4259: ===> Extracting for nvu-1.0
4260: url2pkg> Adjusting the Makefile.
1.1 dsieger 4261:
1.184 rillig 4262: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
1.1 dsieger 4263:
1.184 rillig 4264: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
1.1 dsieger 4265:
1.184 rillig 4266: 14.2.1.2. Fixing all kinds of problems to make the package work
1.1 dsieger 4267:
1.184 rillig 4268: Now that the package has been extracted, let's see what's inside it. The
4269: package has a README.txt, but that only says something about mozilla, so it's
4270: probably useless for seeing what dependencies this package has. But since there
4271: is a GNU configure script in the package, let's hope that it will complain
4272: about everything it needs.
1.1 dsieger 4273:
1.184 rillig 4274: $ bmake
4275: => Required installed package digest>=20010302: digest-20060826 found
4276: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
4277: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
4278: ===> Patching for nvu-1.0
4279: ===> Creating toolchain wrappers for nvu-1.0
4280: ===> Configuring for nvu-1.0
4281: [...]
4282: configure: error: Perl 5.004 or higher is required.
4283: [...]
4284: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
4285: [...]
1.1 dsieger 4286:
1.184 rillig 4287: That worked quite well. So I opened the package Makefile in my editor, and
4288: since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
4289: dependencies of the package have changed now, and since a perl wrapper is
4290: automatically installed in the "tools" phase, I need to build the package from
4291: scratch.
1.1 dsieger 4292:
1.184 rillig 4293: $ bmake clean
4294: ===> Cleaning for nvu-1.0
4295: $ bmake
4296: [...]
4297: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
4298: GNU Make. You will not be able to build Mozilla without GNU Make.
4299: [...]
1.1 dsieger 4300:
1.184 rillig 4301: So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
1.1 dsieger 4302:
1.184 rillig 4303: [...]
4304: checking for GTK - version >= 1.2.0... no
4305: *** Could not run GTK test program, checking why...
4306: [...]
1.1 dsieger 4307:
1.184 rillig 4308: Now to the other dependencies. The first question is: Where is the GTK package
4309: hidden in pkgsrc?
1.1 dsieger 4310:
1.184 rillig 4311: $ echo ../../*/gtk*
4312: [many packages ...]
4313: $ echo ../../*/gtk
4314: ../../x11/gtk
4315: $ echo ../../*/gtk2
4316: ../../x11/gtk2
4317: $ echo ../../*/gtk2/bui*
4318: ../../x11/gtk2/buildlink3.mk
1.1 dsieger 4319:
1.184 rillig 4320: The first try was definitely too broad. The second one had exactly one result,
4321: which is very good. But there is one pitfall with GNOME packages. Before GNOME
4322: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
4323: able to continue to use these packages, the GNOME 2 packages were imported as
4324: separate packages, and their names usually have a "2" appended. So I checked
4325: whether this was the case here, and indeed it was.
1.1 dsieger 4326:
1.184 rillig 4327: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
4328: easy. I just inserted an .include line before the last line of the package
4329: Makefile, so that it now looks like this:
1.1 dsieger 4330:
1.184 rillig 4331: [...]
4332: .include "../../x11/gtk2/buildlink3.mk"
4333: .include "../../mk/bsd.pkg.mk
1.1 dsieger 4334:
1.184 rillig 4335: After another bmake clean && bmake, the answer was:
1.108 rillig 4336:
1.184 rillig 4337: [...]
4338: checking for gtk-config... /home/roland/pkg/bin/gtk-config
4339: checking for GTK - version >= 1.2.0... no
4340: *** Could not run GTK test program, checking why...
4341: *** The test program failed to compile or link. See the file config.log for the
4342: *** exact error that occured. This usually means GTK was incorrectly installed
4343: *** or that you have moved GTK since it was installed. In the latter case, you
4344: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
4345: configure: error: Test for GTK failed.
4346: [...]
1.1 dsieger 4347:
1.184 rillig 4348: In this particular case, the assumption that "every package prefers GNOME 2"
4349: had been wrong. The first of the lines above told me that this package really
4350: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
4351: it would have looked for pkg-config instead of gtk-config. So I changed the x11
4352: /gtk2 to x11/gtk in the package Makefile, and tried again.
1.1 dsieger 4353:
1.184 rillig 4354: [...]
4355: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\" [...]
4356: In file included from xpidl.c:42:
4357: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
4358: In file included from xpidl.c:42:
4359: xpidl.h:132: error: parse error before "IDL_ns"
4360: [...]
1.1 dsieger 4361:
1.184 rillig 4362: The package still does not find all of its dependencies. Now the question is:
4363: Which package provides the libIDL/IDL.h header file?
1.1 dsieger 4364:
1.184 rillig 4365: $ echo ../../*/*idl*
4366: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
4367: $ echo ../../*/*IDL*
4368: ../../net/libIDL
1.1 dsieger 4369:
1.184 rillig 4370: Let's take the one from the second try. So I included the ../../net/libIDL/
4371: buildlink3.mk file and tried again. But the error didn't change. After digging
4372: through some of the code, I concluded that the build process of the package was
4373: broken and couldn't have ever worked, but since the Mozilla source tree is
4374: quite large, I didn't want to fix it. So I added the following to the package
4375: Makefile and tried again:
1.1 dsieger 4376:
1.184 rillig 4377: CPPFLAGS+= -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
4378: BUILDLINK_TRANSFORM+= l:IDL:IDL-2
1.1 dsieger 4379:
1.184 rillig 4380: The latter line is needed because the package expects the library libIDL.so,
4381: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
4382: that on the fly.
1.1 dsieger 4383:
1.184 rillig 4384: The next problem was related to a recent change of the FreeType interface. I
4385: looked up in www/seamonkey which patch files were relevant for this issue and
4386: copied them to the patches directory. Then I retried, fixed the patches so that
4387: they applied cleanly and retried again. This time, everything worked.
1.1 dsieger 4388:
1.184 rillig 4389: 14.2.1.3. Installing the package
1.1 dsieger 4390:
1.184 rillig 4391: $ bmake CHECK_FILES=no install
4392: [...]
4393: $ bmake print-PLIST >PLIST
4394: $ bmake deinstall
4395: $ bmake install
1.1 dsieger 4396:
1.184 rillig 4397: Chapter 15. Programming in Makefiles
1.1 dsieger 4398:
1.184 rillig 4399: Table of Contents
1.1 dsieger 4400:
1.184 rillig 4401: 15.1. Caveats
4402: 15.2. Makefile variables
4403: 15.2.1. Naming conventions
4404: 15.3. Code snippets
4405: 15.3.1. Adding things to a list
4406: 15.3.2. Echoing a string exactly as-is
4407: 15.3.3. Passing CFLAGS to GNU configure scripts
4408: 15.3.4. Handling possibly empty variables
1.229 gutterid 4409: 15.3.5. Testing yes/no variables in conditions
1.1 dsieger 4410:
1.184 rillig 4411: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
4412: part of the pkgsrc system. Using the make(1) system as a programming language
4413: for a big system like pkgsrc requires some discipline to keep the code correct
4414: and understandable.
1.1 dsieger 4415:
1.184 rillig 4416: The basic ingredients for Makefile programming are variables and shell
4417: commands. Among these shell commands may even be more complex ones like awk(1)
4418: programs. To make sure that every shell command runs as intended it is
4419: necessary to quote all variables correctly when they are used.
1.1 dsieger 4420:
1.184 rillig 4421: This chapter describes some patterns that appear quite often in Makefiles,
4422: including the pitfalls that come along with them.
1.1 dsieger 4423:
1.184 rillig 4424: 15.1. Caveats
1.1 dsieger 4425:
1.184 rillig 4426: * When you are creating a file as a target of a rule, always write the data
4427: to a temporary file first and finally rename that file. Otherwise there
4428: might occur an error in the middle of generating the file, and when the
4429: user runs make(1) for the second time, the file exists and will not be
4430: regenerated properly. Example:
1.1 dsieger 4431:
1.184 rillig 4432: wrong:
4433: @echo "line 1" > ${.TARGET}
4434: @echo "line 2" >> ${.TARGET}
4435: @false
1.1 dsieger 4436:
1.184 rillig 4437: correct:
4438: @echo "line 1" > ${.TARGET}.tmp
4439: @echo "line 2" >> ${.TARGET}.tmp
4440: @false
4441: @mv ${.TARGET}.tmp ${.TARGET}
1.1 dsieger 4442:
1.184 rillig 4443: When you run make wrong twice, the file wrong will exist, although there
4444: was an error message in the first run. On the other hand, running make
4445: correct gives an error message twice, as expected.
1.1 dsieger 4446:
1.184 rillig 4447: You might remember that make(1) sometimes removes ${.TARGET} in case of
4448: error, but this only happens when it is interrupted, for example by
4449: pressing Ctrl+C. This does not happen when one of the commands fails (like
4450: false(1) above).
1.1 dsieger 4451:
1.184 rillig 4452: 15.2. Makefile variables
1.1 dsieger 4453:
1.184 rillig 4454: Makefile variables contain strings that can be processed using the five
4455: operators =, +=, ?=, := and !=, which are described in the make(1) man page.
1.1 dsieger 4456:
1.184 rillig 4457: When a variable's value is parsed from a Makefile, the hash character # and the
4458: backslash character \ are handled specially. If a backslash is the last
4459: character in a line, that backslash is removed from the line and the line
4460: continues with the next line of the file.
1.1 dsieger 4461:
1.184 rillig 4462: The # character starts a comment that reaches until the end of the line. To get
4463: an actual # character, such as in a URL, write \# instead.
1.1 dsieger 4464:
1.184 rillig 4465: The evaluation of variables either happens immediately or lazy. It happens
4466: immediately when the variable occurs on the right-hand side of the := or the !=
4467: operator, in a .if condition or a .for loop. In the other cases, it is
4468: evaluated lazily.
1.1 dsieger 4469:
1.184 rillig 4470: Some of the modifiers split the string into words and then operate on the
4471: words, others operate on the string as a whole. When a string is split into
4472: words, double quotes and single quotes are interpreted as delimiters, just like
4473: in sh(1).
1.1 dsieger 4474:
1.184 rillig 4475: 15.2.1. Naming conventions
1.1 dsieger 4476:
1.184 rillig 4477: * All variable names starting with an underscore are reserved for use by the
4478: pkgsrc infrastructure. They shall not be used by packages.
1.1 dsieger 4479:
1.184 rillig 4480: * In .for loops you should use lowercase variable names for the iteration
4481: variables.
1.1 dsieger 4482:
1.184 rillig 4483: * All list variables should have a plural name, such as PKG_OPTIONS or
4484: DISTFILES.
1.1 dsieger 4485:
1.184 rillig 4486: 15.3. Code snippets
1.1 dsieger 4487:
1.184 rillig 4488: 15.3.1. Adding things to a list
1.1 dsieger 4489:
1.184 rillig 4490: When adding a string that possibly contains whitespace or quotes to a list
4491: (example 1), it must be quoted using the :Q modifier.
1.1 dsieger 4492:
1.184 rillig 4493: When adding another list to a list (example 2), it must not be quoted, since
4494: its elements are already quoted.
1.1 dsieger 4495:
1.184 rillig 4496: STRING= foo * bar `date`
4497: LIST= # empty
4498: ANOTHER_LIST= a=b c=d
1.1 dsieger 4499:
1.184 rillig 4500: LIST+= ${STRING:Q} # 1
4501: LIST+= ${ANOTHER_LIST} # 2
1.1 dsieger 4502:
1.184 rillig 4503: 15.3.2. Echoing a string exactly as-is
1.1 dsieger 4504:
1.184 rillig 4505: Echoing a string containing special characters needs special work.
1.1 dsieger 4506:
1.184 rillig 4507: STRING= foo bar < > * `date` $$HOME ' "
4508: EXAMPLE_ENV= string=${STRING:Q} x=multiple\ quoted\ words
1.1 dsieger 4509:
1.184 rillig 4510: all:
4511: echo ${STRING} # 1
4512: echo ${STRING:Q} # 2
4513: printf '%s\n' ${STRING:Q}'' # 3
4514: env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"' # 4
1.1 dsieger 4515:
1.184 rillig 4516: Example 1 leads to a syntax error in the shell, as the characters are just
4517: copied.
1.1 dsieger 4518:
1.184 rillig 4519: Example 2 quotes the string so that the shell interprets it correctly. But the
4520: echo command may additionally interpret strings with a leading dash or those
4521: containing backslashes.
1.1 dsieger 4522:
1.184 rillig 4523: Example 3 can handle arbitrary strings, since printf(1) only interprets the
4524: format string, but not the next argument. The trailing single quotes handle the
4525: case when the string is empty. In that case, the :Q modifier would result in an
4526: empty string too, which would then be skipped by the shell. For printf(1) this
4527: doesn't make a difference, but other programs may care.
1.1 dsieger 4528:
1.184 rillig 4529: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
4530: has already been done when adding elements to the list.
1.1 dsieger 4531:
1.184 rillig 4532: 15.3.3. Passing CFLAGS to GNU configure scripts
1.1 dsieger 4533:
1.184 rillig 4534: When passing CFLAGS or similar variables to a GNU-style configure script
4535: (especially those that call other configure scripts), it must not have leading
4536: or trailing whitespace, since otherwise the configure script gets confused. To
4537: trim leading and trailing whitespace, use the :M modifier, as in the following
4538: example:
1.1 dsieger 4539:
1.184 rillig 4540: CPPFLAGS= # empty
4541: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX}\"
4542: CPPFLAGS+= ${MY_CPPFLAGS}
1.1 dsieger 4543:
1.184 rillig 4544: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
1.1 dsieger 4545:
1.184 rillig 4546: all:
4547: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
4548: echo x${CONFIGURE_ARGS:Q}x # properly trimmed
1.1 dsieger 4549:
1.184 rillig 4550: In this example, CPPFLAGS has both leading and trailing whitespace because the
4551: += operator always adds a space.
1.1 dsieger 4552:
1.184 rillig 4553: 15.3.4. Handling possibly empty variables
1.1 dsieger 4554:
1.184 rillig 4555: When a possibly empty variable is used in a shell program, it may lead to a
4556: syntax error.
1.1 dsieger 4557:
1.184 rillig 4558: EGFILES= # empty
1.1 dsieger 4559:
1.184 rillig 4560: install-examples: # produces a syntax error in the shell
4561: for egfile in ${EGFILES}; do \
4562: echo "Installing $$egfile"; \
4563: done
1.1 dsieger 4564:
1.184 rillig 4565: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
4566: with an empty string by make(1). To fix this syntax error, use one of the
4567: snippets below.
1.1 dsieger 4568:
1.229 gutterid 4569: EGFILES= # empty
1.1 dsieger 4570:
1.184 rillig 4571: install-examples:
4572: for egfile in ${EGFILES} ""; do \
4573: [ -n "$$egfile" ] || continue; \
4574: echo "Installing $$egfile"; \
4575: done
1.1 dsieger 4576:
1.184 rillig 4577: In this case, an empty string is appended to the iteration list (to prevent the
4578: syntax error) and filtered out later.
1.1 dsieger 4579:
1.184 rillig 4580: EGFILES= # empty
1.1 dsieger 4581:
1.184 rillig 4582: install-examples:
4583: .for egfile in ${EGFILES}
4584: echo "Installing ${egfile}"
4585: .endfor
1.1 dsieger 4586:
1.184 rillig 4587: If one of the filenames contains special characters, it should be enclosed in
4588: single or double quotes.
1.1 dsieger 4589:
1.184 rillig 4590: To have a shell command test whether a make variable is empty, use the
4591: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1 dsieger 4592:
1.229 gutterid 4593: 15.3.5. Testing yes/no variables in conditions
4594:
4595: When a variable can have the values yes or no, use the following pattern to
4596: test the variable:
4597:
4598: .if ${VAR:U:tl} == "yes"
4599: # do something
4600: .endif
4601:
4602: The :U modifier is only necessary if the variable can be undefined. If the
4603: variable is guaranteed to be defined, the :U can be omitted.
4604:
4605: The :tl modifier converts the variable value to lowercase, allowing for the
4606: values yes, Yes, YES.
4607:
1.184 rillig 4608: Chapter 16. Options handling
1.1 dsieger 4609:
4610: Table of Contents
4611:
1.184 rillig 4612: 16.1. Global default options
4613: 16.2. Converting packages to use bsd.options.mk
4614: 16.3. Option Names
4615: 16.4. Determining the options of dependencies
1.1 dsieger 4616:
4617: Many packages have the ability to be built to support different sets of
4618: features. bsd.options.mk is a framework in pkgsrc that provides generic
4619: handling of those options that determine different ways in which the packages
4620: can be built. It's possible for the user to specify exactly which sets of
4621: options will be built into a package or to allow a set of global default
4622: options apply.
4623:
1.7 rillig 4624: There are two broad classes of behaviors that one might want to control via
4625: options. One is whether some particular feature is enabled in a program that
4626: will be built anyway, often by including or not including a dependency on some
4627: other package. The other is whether or not an additional program will be built
4628: as part of the package. Generally, it is better to make a split package for
4629: such additional programs instead of using options, because it enables binary
4630: packages to be built which can then be added separately. For example, the foo
4631: package might have minimal dependencies (those packages without which foo
4632: doesn't make sense), and then the foo-gfoo package might include the GTK
4633: frontend program gfoo. This is better than including a gtk option to foo that
4634: adds gfoo, because either that option is default, in which case binary users
4635: can't get foo without gfoo, or not default, in which case they can't get gfoo.
4636: With split packages, they can install foo without having GTK, and later decide
4637: to install gfoo (pulling in GTK at that time). This is an advantage to source
4638: users too, avoiding the need for rebuilds.
4639:
4640: Plugins with widely varying dependencies should usually be split instead of
4641: options.
4642:
4643: It is often more work to maintain split packages, especially if the upstream
4644: package does not support this. The decision of split vs. option should be made
4645: based on the likelihood that users will want or object to the various pieces,
4646: the size of the dependencies that are included, and the amount of work.
4647:
4648: A further consideration is licensing. Non-free parts, or parts that depend on
4649: non-free dependencies (especially plugins) should almost always be split if
4650: feasible.
4651:
1.184 rillig 4652: 16.1. Global default options
1.1 dsieger 4653:
4654: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
4655: the options that should be built into every package if that option is
1.4 rillig 4656: supported. This variable should be set in mk.conf.
1.1 dsieger 4657:
1.184 rillig 4658: 16.2. Converting packages to use bsd.options.mk
1.1 dsieger 4659:
4660: The following example shows how bsd.options.mk should be used by the
4661: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
4662: e.g. options.mk, that is included by the main package Makefile.
4663:
4664: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
4665: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
4666: PKG_OPTIONS_OPTIONAL_GROUPS= database
4667: PKG_OPTIONS_GROUP.database= mysql pgsql
4668: PKG_SUGGESTED_OPTIONS= wibble-foo
4669: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
4670: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
4671:
4672: .include "../../mk/bsd.prefs.mk"
4673:
4674: # this package was previously named wibble2
4675: .if defined(PKG_OPTIONS.wibble2)
4676: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
4677: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
4678: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
4679: .endif
4680:
4681: .include "../../mk/bsd.options.mk"
4682:
4683: # Package-specific option-handling
4684:
4685: ###
4686: ### FOO support
4687: ###
4688: .if !empty(PKG_OPTIONS:Mwibble-foo)
4689: CONFIGURE_ARGS+= --enable-foo
4690: .endif
4691:
4692: ###
4693: ### LDAP support
4694: ###
4695: .if !empty(PKG_OPTIONS:Mldap)
4696: . include "../../databases/openldap-client/buildlink3.mk"
4697: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
4698: .endif
4699:
4700: ###
4701: ### database support
4702: ###
4703: .if !empty(PKG_OPTIONS:Mmysql)
4704: . include "../../mk/mysql.buildlink3.mk"
4705: .endif
4706: .if !empty(PKG_OPTIONS:Mpgsql)
4707: . include "../../mk/pgsql.buildlink3.mk"
4708: .endif
4709:
4710: The first section contains the information about which build options are
4711: supported by the package, and any default options settings if needed.
4712:
4713: 1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
4714: to override the default options. It should be set to PKG_OPTIONS.pkgbase.
4715: Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
4716: the point where the options are processed.
4717:
4718: 2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
4719:
4720: 3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
4721: exclusive options. The options in each group are listed in
4722: PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
4723: the group takes precedence over all other options in the group. Options
4724: from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
4725:
4726: 4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
4727: building the packages will fail if no option from the group is selected.
4728:
4729: 5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
4730: one option from each set must be selected. The options in each set are
4731: listed in PKG_OPTIONS_SET.setname. Options from the sets will be
4732: automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
4733: fail if no option from the set is selected.
4734:
4735: 6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
4736: default.
4737:
4738: 7. PKG_OPTIONS_LEGACY_VARS is a list of "USE_VARIABLE:option" pairs that map
1.4 rillig 4739: legacy mk.conf variables to their option counterparts. Pairs should be
1.1 dsieger 4740: added with "+=" to keep the listing of global legacy variables. A warning
4741: will be issued if the user uses a legacy variable.
4742:
4743: 8. PKG_OPTIONS_LEGACY_OPTS is a list of "old-option:new-option" pairs that map
4744: options that have been renamed to their new counterparts. Pairs should be
4745: added with "+=" to keep the listing of global legacy options. A warning
4746: will be issued if the user uses a legacy option.
4747:
4748: 9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
4749: used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
4750: PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
4751:
4752: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
4753: variables or options used, and what to use instead.
4754:
4755: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
4756: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
4757: options, use PKG_SUGGESTED_OPTIONS.
4758:
4759: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
4760: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
4761: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
4762: options if none of them is supported on the current platform), PKG_OPTIONS is
4763: set to the empty list and the package is otherwise treated as not using the
4764: options framework.
4765:
4766: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
4767: list of selected build options, properly filtered to remove unsupported and
4768: duplicate options.
4769:
4770: The remaining sections contain the logic that is specific to each option. The
4771: correct way to check for an option is to check whether it is listed in
4772: PKG_OPTIONS:
4773:
4774: .if !empty(PKG_OPTIONS:Moption)
4775:
1.184 rillig 4776: 16.3. Option Names
1.1 dsieger 4777:
4778: Options that enable similar features in different packages (like optional
4779: support for a library) should use a common name in all packages that support it
4780: (like the name of the library). If another package already has an option with
4781: the same meaning, use the same name.
4782:
4783: Options that enable features specific to one package, where it's unlikely that
4784: another (unrelated) package has the same (or a similar) optional feature,
4785: should use a name prefixed with pkgname-.
4786:
4787: If a group of related packages share an optional feature specific to that
4788: group, prefix it with the name of the "main" package (e. g.
4789: djbware-errno-hack).
4790:
4791: For new options, add a line to mk/defaults/options.description. Lines have two
4792: fields, separated by tab. The first field is the option name, the second its
4793: description. The description should be a whole sentence (starting with an
4794: uppercase letter and ending with a period) that describes what enabling the
4795: option does. E. g. "Enable ispell support." The file is sorted by option names.
4796:
1.184 rillig 4797: 16.4. Determining the options of dependencies
1.7 rillig 4798:
4799: When writing buildlink3.mk files, it is often necessary to list different
4800: dependencies based on the options with which the package was built. For
4801: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
4802: A typical example looks like this:
4803:
4804: pkgbase := libpurple
4805: .include "../../mk/pkg-build-options.mk"
4806:
4807: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
4808: ...
4809: .endif
4810:
4811: Including pkg-build-options.mk here will set the variable
4812: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
4813: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
4814: pkg-build-options.mk for more details.
4815:
1.184 rillig 4816: Chapter 17. Tools needed for building or running
4817:
4818: Table of Contents
4819:
4820: 17.1. Tools for pkgsrc builds
4821: 17.2. Tools needed by packages
4822: 17.3. Tools provided by platforms
4823:
4824: The USE_TOOLS definition is used both internally by pkgsrc and also for
4825: individual packages to define what commands are needed for building a package
4826: (like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
4827: DEPENDS). If the native system provides an adequate tool, then in many cases, a
4828: pkgsrc package will not be used.
4829:
4830: When building a package, the replacement tools are made available in a
4831: directory (as symlinks or wrapper scripts) that is early in the executable
4832: search path. Just like the buildlink system, this helps with consistent builds.
4833:
4834: A tool may be needed to help build a specific package. For example, perl, GNU
4835: make (gmake) or yacc may be needed.
4836:
4837: Also a tool may be needed, for example, because the native system's supplied
4838: tool may be inefficient for building a package with pkgsrc. For example, a
4839: package may need GNU awk, bison (instead of yacc) or a better sed.
4840:
4841: The tools used by a package can be listed by running make show-tools.
4842:
4843: 17.1. Tools for pkgsrc builds
4844:
4845: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
4846: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
4847: seen by running: make show-var VARNAME=USE_TOOLS.
4848:
4849: If a package needs a specific program to build then the USE_TOOLS variable can
4850: be used to define the tools needed.
4851:
4852: 17.2. Tools needed by packages
4853:
4854: In the following examples, the :run means that it is needed at run-time (and
4855: becomes a DEPENDS). The default is a build dependency which can be set with
4856: :build. (So in this example, it is the same as gmake:build and
4857: pkg-config:build.)
4858:
4859: USE_TOOLS+= gmake perl:run pkg-config
4860:
4861: When using the tools framework, a TOOLS_PATH.foo variable is defined which
4862: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
4863: could be "/bin/bash" on Linux systems.
4864:
4865: If you always need a pkgsrc version of the tool at run-time, then just use
4866: DEPENDS instead.
4867:
4868: 17.3. Tools provided by platforms
4869:
4870: When improving or porting pkgsrc to a new platform, have a look at (or create)
4871: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
4872: tools.${OPSYS}.mk which defines the name of the common tools. For example:
4873:
4874: .if exists(/usr/bin/bzcat)
4875: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
4876: .elif exists(/usr/bin/bzip2)
4877: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
4878: .endif
4879:
4880: TOOLS_PLATFORM.true?= true # shell builtin
4881:
4882: Chapter 18. Buildlink methodology
1.1 dsieger 4883:
4884: Table of Contents
4885:
1.184 rillig 4886: 18.1. Converting packages to use buildlink3
4887: 18.2. Writing buildlink3.mk files
4888: 18.2.1. Anatomy of a buildlink3.mk file
4889: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.232 gutterid 4890: buildlink3.mk files
1.184 rillig 4891: 18.3. Writing builtin.mk files
4892: 18.3.1. Anatomy of a builtin.mk file
4893: 18.3.2. Global preferences for native or pkgsrc software
4894:
4895: Buildlink is a framework in pkgsrc that controls what headers and libraries are
4896: seen by a package's configure and build processes. This is implemented in a two
4897: step process:
4898:
4899: 1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
4900: default is a subdirectory of WRKDIR.
4901:
4902: 2. Create wrapper scripts that are used in place of the normal compiler tools
4903: that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
4904: references to BUILDLINK_DIR. The wrapper scripts also make native compiler
4905: on some operating systems look like GCC, so that packages that expect GCC
4906: won't require modifications to build with those native compilers.
4907:
4908: This normalizes the environment in which a package is built so that the package
4909: may be built consistently despite what other software may be installed. Please
4910: note that the normal system header and library paths, e.g. /usr/include, /usr/
4911: lib, etc., are always searched -- buildlink3 is designed to insulate the
4912: package build from non-system-supplied software.
4913:
4914: 18.1. Converting packages to use buildlink3
1.1 dsieger 4915:
1.184 rillig 4916: The process of converting packages to use the buildlink3 framework ("bl3ifying"
4917: ) is fairly straightforward. The things to keep in mind are:
1.1 dsieger 4918:
1.184 rillig 4919: 1. Ensure that the build always calls the wrapper scripts instead of the
4920: actual toolchain. Some packages are tricky, and the only way to know for
4921: sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
4922: invoked.
1.1 dsieger 4923:
1.184 rillig 4924: 2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
4925: standalone shells, etc., because the code to symlink files into $
4926: {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
1.1 dsieger 4927:
1.184 rillig 4928: 3. Remember that only the buildlink3.mk files that you list in a package's
4929: Makefile are added as dependencies for that package.
1.1 dsieger 4930:
1.184 rillig 4931: If a dependency on a particular package is required for its libraries and
4932: headers, then we replace:
1.1 dsieger 4933:
1.184 rillig 4934: DEPENDS+= foo>=1.1.0:../../category/foo
1.1 dsieger 4935:
1.184 rillig 4936: with
1.1 dsieger 4937:
1.184 rillig 4938: .include "../../category/foo/buildlink3.mk"
1.1 dsieger 4939:
1.184 rillig 4940: The buildlink3.mk files usually define the required dependencies. If you need a
4941: newer version of the dependency when using buildlink3.mk files, then you can
4942: define it in your Makefile; for example:
1.1 dsieger 4943:
1.184 rillig 4944: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
4945: .include "../../category/foo/buildlink3.mk"
1.1 dsieger 4946:
1.184 rillig 4947: There are several buildlink3.mk files in pkgsrc/mk that handle special package
4948: issues:
1.1 dsieger 4949:
1.184 rillig 4950: * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
4951: implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
1.1 dsieger 4952:
1.184 rillig 4953: * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
4954: this will take care to install the devel/ncurses package.
1.1 dsieger 4955:
1.184 rillig 4956: * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
4957: a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
4958: implementation.
1.1 dsieger 4959:
1.184 rillig 4960: * motif.buildlink3.mk checks for a system-provided Motif installation or adds
4961: a dependency on x11/lesstif or x11/motif. The user can set MOTIF_TYPE to "
4962: dt", "lesstif" or "motif" to choose which Motif version will be used.
1.1 dsieger 4963:
1.184 rillig 4964: * readline.buildlink3.mk checks for a system-provided GNU readline or
4965: editline (libedit) installation, or adds a dependency on devel/readline,
4966: devel/editline. The user can set READLINE_DEFAULT to choose readline
4967: implementation. If your package really needs GNU readline library, its
4968: Makefile should include devel/readline/buildlink3.mk instead of
4969: readline.buildlink3.mk.
1.1 dsieger 4970:
1.184 rillig 4971: * oss.buildlink3.mk defines several variables that may be used by packages
4972: that use the Open Sound System (OSS) API.
1.1 dsieger 4973:
1.184 rillig 4974: * pgsql.buildlink3.mk will accept any of the Postgres versions in the
4975: variable PGSQL_VERSIONS_ACCEPTED and default to the version
4976: PGSQL_VERSION_DEFAULT. See the file for more information.
1.1 dsieger 4977:
1.184 rillig 4978: * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
4979: pthreads or adds a dependency on devel/pth as needed.
1.1 dsieger 4980:
1.184 rillig 4981: * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
4982: widgets library.
1.1 dsieger 4983:
1.184 rillig 4984: The comments in those buildlink3.mk files provide a more complete description
4985: of how to use them properly.
1.1 dsieger 4986:
1.184 rillig 4987: 18.2. Writing buildlink3.mk files
1.1 dsieger 4988:
1.184 rillig 4989: A package's buildlink3.mk file is included by Makefiles to indicate the need to
4990: compile and link against header files and libraries provided by the package. A
4991: buildlink3.mk file should always provide enough information to add the correct
4992: type of dependency relationship and include any other buildlink3.mk files that
4993: it needs to find headers and libraries that it needs in turn.
1.1 dsieger 4994:
1.184 rillig 4995: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
4996: pkgtools/createbuildlink package is highly recommended. For most packages, the
4997: following command will generate a good starting point for buildlink3.mk files:
1.1 dsieger 4998:
1.184 rillig 4999: % cd pkgsrc/category/pkgdir
5000: % createbuildlink >buildlink3.mk
1.1 dsieger 5001:
5002:
1.184 rillig 5003: 18.2.1. Anatomy of a buildlink3.mk file
1.1 dsieger 5004:
1.184 rillig 5005: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
5006: tiff:
1.14 jmcneill 5007:
1.184 rillig 5008: BUILDLINK_TREE+= tiff
1.1 dsieger 5009:
1.184 rillig 5010: .if !defined(TIFF_BUILDLINK3_MK)
5011: TIFF_BUILDLINK3_MK:=
1.1 dsieger 5012:
1.184 rillig 5013: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
5014: BUILDLINK_ABI_DEPENDS.tiff+= tiff>=3.7.2nb1
5015: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
1.1 dsieger 5016:
1.184 rillig 5017: .include "../../devel/zlib/buildlink3.mk"
5018: .include "../../graphics/jpeg/buildlink3.mk"
5019: .endif # TIFF_BUILDLINK3_MK
1.1 dsieger 5020:
1.184 rillig 5021: BUILDLINK_TREE+= -tiff
1.1 dsieger 5022:
1.184 rillig 5023: The header and footer manipulate BUILDLINK_TREE, which is common across all
5024: buildlink3.mk files and is used to track the dependency tree.
1.1 dsieger 5025:
1.184 rillig 5026: The main section is protected from multiple inclusion and controls how the
5027: dependency on pkg is added. Several important variables are set in the section:
1.1 dsieger 5028:
1.185 wiz 5029: * BUILDLINK_API_DEPENDS.pkg is the dependency version recorded in the
1.184 rillig 5030: installed package; this should always be set using += to ensure that we're
5031: appending to any pre-existing list of values. This variable should be set
1.185 wiz 5032: to the last version of the package that had an backwards-incompatible API
1.184 rillig 5033: change.
1.1 dsieger 5034:
1.184 rillig 5035: * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
1.1 dsieger 5036:
1.184 rillig 5037: * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
1.236 ! gutterid 5038: BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
! 5039: is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
! 5040: full dependency is used.
1.1 dsieger 5041:
1.184 rillig 5042: * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
5043: of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
5044: library search paths. These default to "include" and "lib" respectively.
1.1 dsieger 5045:
1.184 rillig 5046: * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
5047: to add to CPPFLAGS, which are passed on to the configure and build phases.
5048: The "-I" option should be avoided and instead be handled using
5049: BUILDLINK_INCDIRS.pkg as above.
1.66 asau 5050:
1.184 rillig 5051: The following variables are all optionally defined within this second section
5052: (protected against multiple inclusion) and control which package files are
5053: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
5054: symlinking:
1.23 jakllsch 5055:
1.184 rillig 5056: * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
5057: {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
5058: *.h.
1.1 dsieger 5059:
1.184 rillig 5060: * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
5061: to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
5062: resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
5063: takes the +CONTENTS of a pkg and filters it through $
5064: {BUILDLINK_CONTENTS_FILTER.pkg}.
1.1 dsieger 5065:
1.184 rillig 5066: * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
5067: filters +CONTENTS input into a list of files relative to $
5068: {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
5069: outputs the contents of the include and lib directories in the package
5070: +CONTENTS.
1.1 dsieger 5071:
1.184 rillig 5072: * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
5073: used to transform the name of the source filename into a destination
5074: filename, e.g. -e "s|/curses.h|/ncurses.h|g".
1.1 dsieger 5075:
1.184 rillig 5076: This section can additionally include any buildlink3.mk needed for pkg's
5077: library dependencies. Including these buildlink3.mk files means that the
5078: headers and libraries for these dependencies are also symlinked into $
5079: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
5080: are only added for directly include buildlink3.mk files.
1.1 dsieger 5081:
1.184 rillig 5082: When providing a buildlink3.mk and including other buildlink3.mk files in it,
5083: please only add necessary ones, i.e., those whose libraries or header files are
5084: automatically exposed when the package is use.
1.1 dsieger 5085:
1.184 rillig 5086: In particular, if only an executable (bin/foo) is linked against a library,
5087: that library does not need to be propagated in the buildlink3.mk file.
1.1 dsieger 5088:
1.184 rillig 5089: The following steps should help you decide if a buildlink3.mk file needs to be
5090: included:
1.1 dsieger 5091:
1.184 rillig 5092: * Look at the installed header files: What headers do they include? The
5093: packages providing these files must be buildlinked.
1.1 dsieger 5094:
1.184 rillig 5095: * Run ldd on all installed libraries and look against what other libraries
5096: they link. Some of the packages providing these probably need to be
5097: buildlinked; however, it's not automatic, since e.g. GTK on some systems
5098: pulls in the X libraries, so they will show up in the ldd output, while on
5099: others (like OS X) it won't. ldd output can thus only be used as a hint.
1.1 dsieger 5100:
1.184 rillig 5101: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
5102: buildlink3.mk files
1.16 jnemeth 5103:
1.185 wiz 5104: Both variables set lower bounds for a version of this package. The two
5105: variables differ in that one describes source compatibility (API) and the other
5106: binary compatibility (ABI). The difference is that a change in the API breaks
5107: compilation of programs while changes in the ABI stop compiled programs from
5108: running.
5109:
5110: The BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk should be changed
5111: very rarely. (One possible scenario: If all packages using this package need a
5112: higher version than defined in the buildlink3.mk, BUILDLINK_API_DEPENDS.pkg
5113: could be updated to that higher version.)
5114:
5115: On the other hand, changes to BUILDLINK_ABI_DEPENDS.pkg are more common. The
5116: variable will need to be updated every time the major version of one of its
5117: shared libraries is changed, or any other change where a binary built against
5118: the previous version of the package will not run against the new version any
5119: longer.
5120:
5121: In such a case, the package's BUILDLINK_ABI_DEPENDS.pkg must be increased to
5122: require the new package version. Then the PKGREVISION of all packages foo that
5123: depend on this package need to be increased, and if they have buildlink3.mk
5124: files, BUILDLINK_ABI_DEPENDS.foo in their buildlink3.mk files must be increased
5125: to the new version as well. This is required so that a package will pull in the
5126: versions of the packages that use the new ABI and that the packages'
5127: PKGREVISIONs uniquely identify the packages built against the new ABI. The
5128: pkgtools/revbump package can help with these updates.
1.1 dsieger 5129:
1.184 rillig 5130: See Section 21.1.5, "Handling dependencies" for more information about
1.185 wiz 5131: dependencies on other packages, including the BUILDLINK_API_DEPENDS
5132: definitions.
1.1 dsieger 5133:
1.184 rillig 5134: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
1.185 wiz 5135: BUILDLINK_ABI_DEPENDS.pkg in a buildlink3.mk file as we don't want to cause
5136: unneeded package deletions and rebuilds. In many cases, new versions of
5137: packages work just fine with older dependencies.
1.1 dsieger 5138:
1.211 gutterid 5139: Also, it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
1.184 rillig 5140: BUILDLINK_API_DEPENDS.pkg.
1.1 dsieger 5141:
1.211 gutterid 5142: Note there is also the distinction that users are able to disable enforcement
5143: of ABI dependencies using the USE_ABI_DEPENDS variable, but there is no
5144: equivalent option for API dependencies.
5145:
1.184 rillig 5146: 18.3. Writing builtin.mk files
1.1 dsieger 5147:
1.184 rillig 5148: Some packages in pkgsrc install headers and libraries that coincide with
5149: headers and libraries present in the base system. Aside from a buildlink3.mk
5150: file, these packages should also include a builtin.mk file that includes the
5151: necessary checks to decide whether using the built-in software or the pkgsrc
5152: software is appropriate.
1.1 dsieger 5153:
1.184 rillig 5154: The only requirements of a builtin.mk file for pkg are:
1.1 dsieger 5155:
1.184 rillig 5156: 1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
1.1 dsieger 5157:
1.184 rillig 5158: 2. It should not override any USE_BUILTIN.pkg which is already set before the
5159: builtin.mk file is included.
1.1 dsieger 5160:
1.184 rillig 5161: 3. It should be written to allow multiple inclusion. This is very important
5162: and takes careful attention to Makefile coding.
1.1 dsieger 5163:
1.184 rillig 5164: 18.3.1. Anatomy of a builtin.mk file
1.1 dsieger 5165:
1.184 rillig 5166: The following is the recommended template for builtin.mk files:
1.1 dsieger 5167:
1.184 rillig 5168: .if !defined(IS_BUILTIN.foo)
5169: #
5170: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
5171: # genuinely exists in the system or not.
5172: #
5173: IS_BUILTIN.foo?= no
1.1 dsieger 5174:
1.184 rillig 5175: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
5176: # version can be determined.
5177: #
5178: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
5179: BUILTIN_PKG.foo?= foo-1.0
5180: . endif
5181: .endif # IS_BUILTIN.foo
1.1 dsieger 5182:
1.184 rillig 5183: .if !defined(USE_BUILTIN.foo)
5184: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
5185: . if defined(BUILTIN_PKG.foo)
5186: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
5187: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
5188: USE_BUILTIN.foo!= \
5189: ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo} \
5190: && ${ECHO} "yes" || ${ECHO} "no"
5191: . endif
5192: . endfor
5193: . endif
5194: .endif # USE_BUILTIN.foo
1.1 dsieger 5195:
1.184 rillig 5196: CHECK_BUILTIN.foo?= no
5197: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
5198: #
5199: # Here we place code that depends on whether USE_BUILTIN.foo is set to
5200: # "yes" or "no".
5201: #
5202: .endif # CHECK_BUILTIN.foo
1.1 dsieger 5203:
1.184 rillig 5204: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
5205: base system. This should not be a base system software with similar
5206: functionality to pkg; it should only be "yes" if the actual package is included
5207: as part of the base system. This variable is only used internally within the
5208: builtin.mk file.
1.1 dsieger 5209:
1.184 rillig 5210: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
5211: system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
5212: internally within the builtin.mk file.
1.1 dsieger 5213:
1.184 rillig 5214: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
5215: The code in this section must make the determination whether the built-in
5216: software is adequate to satisfy the dependencies listed in
5217: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
5218: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg
5219: must be set to the correct value by the end of the builtin.mk file. Note that
5220: USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
5221: the determination that the built-in version of the software is similar enough
5222: to be used as a replacement.
1.1 dsieger 5223:
1.184 rillig 5224: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
5225: the value of USE_BUILTIN.pkg set in the previous section. This typically
5226: includes, e.g., adding additional dependency restrictions and listing
5227: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
1.1 dsieger 5228:
1.184 rillig 5229: 18.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 5230:
1.184 rillig 5231: When building packages, it's possible to choose whether to set a global
5232: preference for using either the built-in (native) version or the pkgsrc version
5233: of software to satisfy a dependency. This is controlled by setting
5234: PREFER_PKGSRC and PREFER_NATIVE. These variables take values of either "yes", "
5235: no", or a list of packages. PREFER_PKGSRC tells pkgsrc to use the pkgsrc
5236: versions of software, while PREFER_NATIVE tells pkgsrc to use the built-in
5237: versions. Preferences are determined by the most specific instance of the
5238: package in either PREFER_PKGSRC or PREFER_NATIVE. If a package is specified in
5239: neither or in both variables, then PREFER_PKGSRC has precedence over
5240: PREFER_NATIVE. For example, to require using pkgsrc versions of software for
5241: all but the most basic bits on a NetBSD system, you can set:
1.1 dsieger 5242:
1.184 rillig 5243: PREFER_PKGSRC= yes
5244: PREFER_NATIVE= getopt skey tcp_wrappers
1.1 dsieger 5245:
1.184 rillig 5246: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
5247: it is simply ignored in that list.
1.1 dsieger 5248:
1.191 bacon 5249: PREFER_PKGSRC and PREFER_NATIVE should be set during bootstrap to ensure that
5250: the bootstrap process does not use inapropriate native tools as dependencies
5251: for core packages.
5252:
5253: # ./bootstrap --prefer-pkgsrc yes --prefer-native openssl
5254:
5255: Switching between settings globally at a later date can introduce complications
5256: with dependency resolution. This is caused by packages built with the opposite
5257: preference being installed alongside each other. Hence, any changes to these
5258: variables after bootstrap will necessitate rebuilding all packages depending on
5259: one whose preference has been changed. This is not trivial and should be
5260: avoided.
5261:
5262: When using pkgsrc on Linux systems, there is high risk of "leakage", where
5263: programs installed by pkgsrc may inadvertently use a command or library not
5264: installed by pkgsrc, e.g. those installed by yum or apt. Such foreign
5265: dependencies may be installed, removed, or upgraded to a version incompatible
5266: with the pkgsrc package at any time, causing pkgsrc packages to subsequently
5267: malfunction. Pkgsrc cannot prevent this, as it has no control over other
5268: package managers. Another potential problem is that under Redhat Enterprise and
5269: related Linux systems, yum packages are only patched and never upgraded, so
5270: eventually they may become too outdated for use by pkgsrc. Even intentionally
5271: using foreign dependencies, not considered leakage, can lead to these problems,
5272: so it is generally discouraged. In order to minimize such problems,
5273: PREFER_PKGSRC defaults to "yes" on Linux systems. This ensures that pkgsrc is
5274: aware of any changes to dependency packages and can rebuild or upgrade the
5275: entire dependency tree as needed. This default can be overridden by setting
5276: --prefer-pkgsrc to "no" or a list of packages, or by setting --prefer-native to
5277: "yes".
1.1 dsieger 5278:
1.184 rillig 5279: Chapter 19. PLIST issues
1.1 dsieger 5280:
1.184 rillig 5281: Table of Contents
1.1 dsieger 5282:
1.184 rillig 5283: 19.1. RCS ID
5284: 19.2. Semi-automatic PLIST generation
5285: 19.3. Tweaking output of make print-PLIST
5286: 19.4. Variable substitution in PLIST
5287: 19.5. Man page compression
5288: 19.6. Changing PLIST source with PLIST_SRC
5289: 19.7. Platform-specific and differing PLISTs
5290: 19.8. Build-specific PLISTs
5291: 19.9. Sharing directories between packages
1.1 dsieger 5292:
1.184 rillig 5293: The PLIST file contains a package's "packing list", i.e. a list of files that
5294: belong to the package (relative to the ${PREFIX} directory it's been installed
5295: in) plus some additional statements - see the pkg_create(1) man page for a full
5296: list. This chapter addresses some issues that need attention when dealing with
5297: the PLIST file (or files, see below!).
1.1 dsieger 5298:
1.184 rillig 5299: 19.1. RCS ID
1.1 dsieger 5300:
1.184 rillig 5301: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
1.1 dsieger 5302:
1.184 rillig 5303: @comment $NetBSD $
1.1 dsieger 5304:
1.184 rillig 5305: An artificial space has been added between NetBSD and $, this is a workaround
5306: here to prevent CVS expanding to the filename of the guide. When adding the RCS
5307: ID the space should be omitted.
1.38 wiz 5308:
1.184 rillig 5309: 19.2. Semi-automatic PLIST generation
1.1 dsieger 5310:
1.184 rillig 5311: You can use the make print-PLIST command to output a PLIST that matches any new
5312: files since the package was extracted. See Section 13.17, "Other helpful
5313: targets" for more information on this target.
1.11 rillig 5314:
1.184 rillig 5315: 19.3. Tweaking output of make print-PLIST
1.1 dsieger 5316:
1.184 rillig 5317: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
5318: used to filter the output of print-PLIST. You can append any chunk of AWK
5319: scripting you like to it, but be careful with quoting.
1.1 dsieger 5320:
1.184 rillig 5321: For example, to get all files inside the libdata/foo directory removed from the
5322: resulting PLIST:
1.1 dsieger 5323:
1.184 rillig 5324: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
1.1 dsieger 5325:
1.185 wiz 5326: The PRINT_PLIST_AWK transformations are evaluated after the file list and
5327: directory list are sorted. EARLY_PRINT_PLIST_AWK is like PRINT_PLIST_AWK except
5328: it operates before the file list and directory list are sorted.
5329:
1.184 rillig 5330: 19.4. Variable substitution in PLIST
1.1 dsieger 5331:
1.184 rillig 5332: A number of variables are substituted automatically in PLISTs when a package is
5333: installed on a system. This includes the following variables:
1.1 dsieger 5334:
1.184 rillig 5335: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
1.1 dsieger 5336:
1.184 rillig 5337: Some packages like emacs and perl embed information about which
5338: architecture they were built on into the pathnames where they install their
5339: files. To handle this case, PLIST will be preprocessed before actually
5340: used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
5341: gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
5342: PLIST somewhere - use this on packages that have GNU autoconf-created
5343: configure scripts.
1.1 dsieger 5344:
1.184 rillig 5345: Legacy note
1.1 dsieger 5346:
1.184 rillig 5347: There used to be a symbol "$ARCH" that was replaced by the output of uname
5348: -m, but that's no longer supported and has been removed.
1.1 dsieger 5349:
1.184 rillig 5350: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
1.1 dsieger 5351:
1.184 rillig 5352: Some packages want to embed the OS name and version into some paths. To do
5353: this, use these variables in the PLIST:
1.1 dsieger 5354:
1.232 gutterid 5355: o ${OPSYS} - output of "uname -s"
1.1 dsieger 5356:
1.232 gutterid 5357: o ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
1.1 dsieger 5358:
1.232 gutterid 5359: o ${OS_VERSION} - "uname -r"
1.1 dsieger 5360:
1.184 rillig 5361: For a list of values which are replaced by default, the output of make help
5362: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
5363: PLIST_SUBST should help.
1.1 dsieger 5364:
1.184 rillig 5365: If you want to change other variables not listed above, you can add variables
5366: and their expansions to this variable in the following way, similar to
5367: MESSAGE_SUBST (see Section 12.5, "Optional files"):
1.1 dsieger 5368:
1.184 rillig 5369: PLIST_SUBST+= SOMEVAR="somevalue"
1.1 dsieger 5370:
1.184 rillig 5371: This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
1.1 dsieger 5372:
1.184 rillig 5373: The PLIST_VARS variable can be used to simplify the common case of
5374: conditionally including some PLIST entries. It can be done by adding
5375: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
5376: entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
5377: either """" or ""@comment "". For example, in Makefile:
1.1 dsieger 5378:
1.184 rillig 5379: PLIST_VARS+= foo
5380: .if condition
5381: PLIST.foo= yes
5382: .else
1.1 dsieger 5383:
1.184 rillig 5384: And then in PLIST:
1.1 dsieger 5385:
1.184 rillig 5386: @comment $NetBSD $
5387: bin/bar
5388: man/man1/bar.1
5389: ${PLIST.foo}bin/foo
5390: ${PLIST.foo}man/man1/foo.1
5391: ${PLIST.foo}share/bar/foo.data
1.1 dsieger 5392:
1.184 rillig 5393: An artificial space has been added between NetBSD and $, this is a workaround
5394: here to prevent CVS expanding to the filename of the guide. When adding the RCS
1.195 gutterid 5395: ID the space should be omitted.
1.1 dsieger 5396:
1.184 rillig 5397: 19.5. Man page compression
1.1 dsieger 5398:
1.184 rillig 5399: Man pages should be installed in compressed form if MANZ is set (in
5400: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
5401: suffix ".gz" is appended/removed automatically for man pages according to MANZ
5402: and MANCOMPRESSED being set or not, see above for details. This modification of
5403: the PLIST file is done on a copy of it, not PLIST itself.
1.100 leot 5404:
1.184 rillig 5405: 19.6. Changing PLIST source with PLIST_SRC
1.100 leot 5406:
1.184 rillig 5407: To use one or more files as source for the PLIST used in generating the binary
5408: package, set the variable PLIST_SRC to the names of that file(s). The files are
5409: later concatenated using cat(1), and the order of things is important. The
5410: default for PLIST_SRC is ${PKGDIR}/PLIST.
1.1 dsieger 5411:
1.184 rillig 5412: 19.7. Platform-specific and differing PLISTs
1.1 dsieger 5413:
1.184 rillig 5414: Some packages decide to install a different set of files based on the operating
5415: system being used. These differences can be automatically handled by using the
5416: following files:
1.1 dsieger 5417:
1.184 rillig 5418: * PLIST.common
1.1 dsieger 5419:
1.184 rillig 5420: * PLIST.${OPSYS}
1.1 dsieger 5421:
1.184 rillig 5422: * PLIST.${MACHINE_ARCH}
1.1 dsieger 5423:
1.184 rillig 5424: * PLIST.${OPSYS}-${MACHINE_ARCH}
1.1 dsieger 5425:
1.184 rillig 5426: * PLIST.common_end
1.1 dsieger 5427:
1.184 rillig 5428: 19.8. Build-specific PLISTs
1.1 dsieger 5429:
1.184 rillig 5430: Some packages decide to generate hard-to-guess file names during installation
5431: that are hard to wire down.
1.1 dsieger 5432:
1.184 rillig 5433: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
5434: (with a semicolon) that will output PLIST entries which will be appended to the
5435: PLIST
1.1 dsieger 5436:
1.184 rillig 5437: You can find one example in editors/xemacs:
1.1 dsieger 5438:
1.184 rillig 5439: GENERATE_PLIST+= ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.1 dsieger 5440:
1.184 rillig 5441: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
1.1 dsieger 5442:
1.184 rillig 5443: 19.9. Sharing directories between packages
1.1 dsieger 5444:
1.184 rillig 5445: A "shared directory" is a directory where multiple (and unrelated) packages
5446: install files. These directories were problematic because you had to add
5447: special tricks in the PLIST to conditionally remove them, or have some
5448: centralized package handle them.
1.106 tnn 5449:
1.184 rillig 5450: In pkgsrc, it is now easy: Each package should create directories and install
5451: files as needed; pkg_delete will remove any directories left empty after
5452: uninstalling a package.
1.106 tnn 5453:
1.184 rillig 5454: If a package needs an empty directory to work, create the directory during
5455: installation as usual, and also add an entry to the PLIST:
1.1 dsieger 5456:
1.184 rillig 5457: @pkgdir path/to/empty/directory
1.1 dsieger 5458:
1.184 rillig 5459: or take a look at MAKE_DIRS and OWN_DIRS.
1.1 dsieger 5460:
1.184 rillig 5461: Chapter 20. The pkginstall framework
1.1 dsieger 5462:
1.184 rillig 5463: Table of Contents
1.1 dsieger 5464:
1.184 rillig 5465: 20.1. Files and directories outside the installation prefix
5466: 20.1.1. Directory manipulation
5467: 20.1.2. File manipulation
5468: 20.2. Configuration files
5469: 20.2.1. How PKG_SYSCONFDIR is set
5470: 20.2.2. Telling the software where configuration files are
5471: 20.2.3. Patching installations
5472: 20.2.4. Disabling handling of configuration files
5473: 20.3. System startup scripts
5474: 20.3.1. Disabling handling of system startup scripts
5475: 20.4. System users and groups
5476: 20.5. System shells
5477: 20.5.1. Disabling shell registration
5478: 20.6. Fonts
5479: 20.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 5480:
1.184 rillig 5481: This chapter describes the framework known as pkginstall, whose key features
5482: are:
1.1 dsieger 5483:
1.184 rillig 5484: * Generic installation and manipulation of directories and files outside the
5485: pkgsrc-handled tree, LOCALBASE.
1.1 dsieger 5486:
1.184 rillig 5487: * Automatic handling of configuration files during installation, provided
5488: that packages are correctly designed.
1.1 dsieger 5489:
1.184 rillig 5490: * Generation and installation of system startup scripts.
1.1 dsieger 5491:
1.184 rillig 5492: * Registration of system users and groups.
1.1 dsieger 5493:
1.184 rillig 5494: * Registration of system shells.
1.1 dsieger 5495:
1.184 rillig 5496: * Automatic updating of fonts databases.
1.1 dsieger 5497:
1.184 rillig 5498: The following sections inspect each of the above points in detail.
1.1 dsieger 5499:
1.184 rillig 5500: You may be thinking that many of the things described here could be easily done
5501: with simple code in the package's post-installation target (post-install). This
5502: is incorrect, as the code in them is only executed when building from source.
5503: Machines using binary packages could not benefit from it at all (as the code
5504: itself could be unavailable). Therefore, the only way to achieve any of the
5505: items described above is by means of the installation scripts, which are
5506: automatically generated by pkginstall.
1.1 dsieger 5507:
1.184 rillig 5508: 20.1. Files and directories outside the installation prefix
1.95 wiz 5509:
1.184 rillig 5510: As you already know, the PLIST file holds a list of files and directories that
5511: belong to a package. The names used in it are relative to the installation
5512: prefix (${PREFIX}), which means that it cannot register files outside this
5513: directory (absolute path names are not allowed). Despite this restriction, some
5514: packages need to install files outside this location; e.g., under ${VARBASE} or
5515: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
5516: installation time by using installation scripts.
1.95 wiz 5517:
1.184 rillig 5518: The generic installation scripts are shell scripts that can contain arbitrary
5519: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
5520: which defaults to INSTALL. A similar variable exists for package removal
5521: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
5522: commands, so they have the potential to create and manage files anywhere in the
5523: file system.
1.95 wiz 5524:
1.184 rillig 5525: Using these general installation files is not recommended, but may be needed in
5526: some special cases. One reason for avoiding them is that the user has to trust
5527: the packager that there is no unwanted or simply erroneous code included in the
5528: installation script. Also, previously there were many similar scripts for the
5529: same functionality, and fixing a common error involved finding and changing all
5530: of them.
1.95 wiz 5531:
1.184 rillig 5532: The pkginstall framework offers another, standardized way. It provides generic
5533: scripts to abstract the manipulation of such files and directories based on
5534: variables set in the package's Makefile. The rest of this section describes
5535: these variables.
1.1 dsieger 5536:
1.184 rillig 5537: 20.1.1. Directory manipulation
1.1 dsieger 5538:
1.184 rillig 5539: The following variables can be set to request the creation of directories
5540: anywhere in the file system:
1.1 dsieger 5541:
1.184 rillig 5542: * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
5543: and should attempt to be destroyed by the installation scripts. The
5544: difference between the two is that the latter prompts the administrator to
5545: remove any directories that may be left after deinstallation (because they
5546: were not empty), while the former does not. Example:
1.1 dsieger 5547:
1.184 rillig 5548: MAKE_DIRS+= ${VARBASE}/foo/private
1.1 dsieger 5549:
1.184 rillig 5550: * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
5551: which directories should be created and should attempt to be destroyed by
5552: the installation scripts. Each tuple holds the following values, separated
5553: by spaces: the directory name, its owner, its group and its numerical mode.
5554: For example:
1.1 dsieger 5555:
1.184 rillig 5556: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private \
5557: ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1 dsieger 5558:
1.184 rillig 5559: The difference between the two is exactly the same as their non-PERMS
5560: counterparts.
1.1 dsieger 5561:
1.184 rillig 5562: 20.1.2. File manipulation
1.1 dsieger 5563:
1.184 rillig 5564: Creating non-empty files outside the installation prefix is tricky because the
5565: PLIST forces all files to be inside it. To overcome this problem, the only
5566: solution is to extract the file in the known place (i.e., inside the
5567: installation prefix) and copy it to the appropriate location during
5568: installation (done by the installation scripts generated by pkginstall). We
5569: will call the former the master file in the following paragraphs, which
5570: describe the variables that can be used to automatically and consistently
5571: handle files outside the installation prefix:
1.1 dsieger 5572:
1.184 rillig 5573: * CONF_FILES and REQD_FILES are pairs of master and target files. During
5574: installation time, the master file is copied to the target one if and only
5575: if the latter does not exist. Upon deinstallation, the target file is
5576: removed provided that it was not modified by the installation.
1.1 dsieger 5577:
1.184 rillig 5578: The difference between the two is that the latter prompts the administrator
5579: to remove any files that may be left after deinstallation (because they
5580: were not empty), while the former does not.
1.1 dsieger 5581:
1.184 rillig 5582: * CONF_FILES_PERMS and REQD_FILES_PERMS contain tuples describing master
5583: files as well as their target locations. For each of them, it also
5584: specifies their owner, their group and their numeric permissions, in this
5585: order. For example:
1.1 dsieger 5586:
1.184 rillig 5587: REQD_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile \
5588: ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1 dsieger 5589:
1.184 rillig 5590: The difference between the two is exactly the same as their non-PERMS
5591: counterparts.
1.1 dsieger 5592:
1.184 rillig 5593: 20.2. Configuration files
1.1 dsieger 5594:
1.184 rillig 5595: Configuration files are special in the sense that they are installed in their
5596: own specific directory, PKG_SYSCONFDIR, and need special treatment during
5597: installation (most of which is automated by pkginstall). The main concept you
5598: must bear in mind is that files marked as configuration files are automatically
5599: copied to the right place (somewhere inside PKG_SYSCONFDIR) during installation
5600: if and only if they didn't exist before. Similarly, they will not be removed if
5601: they have local modifications. This ensures that administrators never lose any
5602: custom changes they may have made.
1.1 dsieger 5603:
1.184 rillig 5604: 20.2.1. How PKG_SYSCONFDIR is set
1.1 dsieger 5605:
1.184 rillig 5606: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
5607: shall be installed. Its contents are set based upon the following variables:
1.1 dsieger 5608:
1.184 rillig 5609: * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
5610: etc although it may be overridden by the user to point to his preferred
5611: location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
1.1 dsieger 5612:
1.184 rillig 5613: * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
5614: configuration files for the package being built shall be installed. The
5615: definition of this variable only makes sense in the package's Makefile
5616: (i.e., it is not user-customizable).
1.1 dsieger 5617:
1.184 rillig 5618: As an example, consider the Apache package, www/apache24, which places its
5619: configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
5620: should be set in the package Makefile.
1.1 dsieger 5621:
1.184 rillig 5622: * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
5623: package's configuration directory (if different from PKG_SYSCONFBASE). It
5624: defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
1.1 dsieger 5625:
1.184 rillig 5626: * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
5627: configuration files for the package identified by PKG_SYSCONFVAR's shall be
5628: placed.
1.1 dsieger 5629:
1.184 rillig 5630: Based on the above variables, pkginstall determines the value of
5631: PKG_SYSCONFDIR, which is the only variable that can be used within a package to
5632: refer to its configuration directory. The algorithm used to set its value is
5633: basically the following:
1.1 dsieger 5634:
1.184 rillig 5635: 1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
1.1 dsieger 5636:
1.184 rillig 5637: 2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
5638: package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
5639: {PKG_SYSCONFSUBDIR}.
1.1 dsieger 5640:
1.184 rillig 5641: 3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
1.1 dsieger 5642:
1.184 rillig 5643: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
5644: OWN_DIRS. See Section 20.1.1, "Directory manipulation" what this means. This
5645: does not apply to subdirectories of ${PKG_SYSCONFDIR}, they still have to be
5646: created with OWN_DIRS or MAKE_DIRS.
1.1 dsieger 5647:
1.184 rillig 5648: 20.2.2. Telling the software where configuration files are
1.1 dsieger 5649:
1.184 rillig 5650: Given that pkgsrc (and users!) expect configuration files to be in a known
5651: place, you need to teach each package where it shall install its files. In some
5652: cases you will have to patch the package Makefiles to achieve it. If you are
5653: lucky, though, it may be as easy as passing an extra flag to the configuration
5654: script; this is the case of GNU Autoconf- generated files:
1.1 dsieger 5655:
1.184 rillig 5656: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1 dsieger 5657:
1.184 rillig 5658: Note that this specifies where the package has to look for its configuration
5659: files, not where they will be originally installed (although the difference is
5660: never explicit, unfortunately).
1.1 dsieger 5661:
1.184 rillig 5662: 20.2.3. Patching installations
1.1 dsieger 5663:
1.184 rillig 5664: As said before, pkginstall automatically handles configuration files. This
5665: means that the packages themselves must not touch the contents of $
5666: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
5667: will, out of the box, mess with the contents of that directory. So what is the
5668: correct procedure to fix this issue?
1.1 dsieger 5669:
1.184 rillig 5670: You must teach the package (usually by manually patching it) to install any
5671: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
5672: This way, the PLIST registers them and the administrator always has the
5673: original copies available.
1.1 dsieger 5674:
1.184 rillig 5675: Once the required configuration files are in place (i.e., under the examples
5676: hierarchy), the pkginstall framework can use them as master copies during the
5677: package installation to update what is in ${PKG_SYSCONFDIR}. To achieve this,
5678: the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
5679: Section 20.1.2, "File manipulation" for information about their syntax and
5680: their purpose. Here is an example, taken from the mail/mutt package:
1.1 dsieger 5681:
1.184 rillig 5682: EGDIR= ${PREFIX}/share/doc/mutt/samples
5683: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1 dsieger 5684:
1.184 rillig 5685: Note that the EGDIR variable is specific to that package and has no meaning
5686: outside it.
1.1 dsieger 5687:
1.184 rillig 5688: 20.2.4. Disabling handling of configuration files
1.1 dsieger 5689:
1.184 rillig 5690: The automatic copying of config files can be toggled by setting the environment
5691: variable PKG_CONFIG prior to package installation.
1.1 dsieger 5692:
1.184 rillig 5693: 20.3. System startup scripts
1.1 dsieger 5694:
1.184 rillig 5695: System startup scripts are special files because they must be installed in a
5696: place known by the underlying OS, usually outside the installation prefix.
5697: Therefore, the same rules described in Section 20.1, "Files and directories
5698: outside the installation prefix" apply, and the same solutions can be used.
5699: However, pkginstall provides a special mechanism to handle these files.
1.1 dsieger 5700:
1.184 rillig 5701: In order to provide system startup scripts, the package has to:
1.1 dsieger 5702:
1.184 rillig 5703: 1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
1.223 nia 5704: Considering the print/cups-base package as an example, it has a cupsd.sh in
5705: its files directory.
1.95 wiz 5706:
1.184 rillig 5707: 2. Tell pkginstall to handle it, appending the name of the script, without its
5708: extension, to the RCD_SCRIPTS variable. Continuing the previous example:
1.95 wiz 5709:
1.184 rillig 5710: RCD_SCRIPTS+= cupsd
1.95 wiz 5711:
1.184 rillig 5712: Once this is done, pkginstall will do the following steps for each script in an
5713: automated fashion:
1.95 wiz 5714:
1.184 rillig 5715: 1. Process the file found in the files directory applying all the
5716: substitutions described in the FILES_SUBST variable.
1.1 dsieger 5717:
1.184 rillig 5718: 2. Copy the script from the files directory to the examples hierarchy, $
5719: {PREFIX}/share/examples/rc.d/. Note that this master file must be
5720: explicitly registered in the PLIST.
1.1 dsieger 5721:
1.184 rillig 5722: 3. Add code to the installation scripts to copy the startup script from the
5723: examples hierarchy into the system-wide startup scripts directory.
1.1 dsieger 5724:
1.184 rillig 5725: 20.3.1. Disabling handling of system startup scripts
1.1 dsieger 5726:
1.184 rillig 5727: The automatic copying of config files can be toggled by setting the environment
5728: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
5729: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
5730: rc.d/, no matter what the value of this variable is.
1.1 dsieger 5731:
1.184 rillig 5732: 20.4. System users and groups
1.1 dsieger 5733:
1.184 rillig 5734: If a package needs to create special users and/or groups during installation,
5735: it can do so by using the pkginstall framework.
1.1 dsieger 5736:
1.184 rillig 5737: Users can be created by adding entries to the PKG_USERS variable. Each entry
5738: has the following syntax:
1.1 dsieger 5739:
1.184 rillig 5740: user:group
1.1 dsieger 5741:
1.184 rillig 5742: Further specification of user details may be done by setting per-user
5743: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
5744: user's description or comment. PKG_HOME.user is the user's home directory, and
5745: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
5746: and defaults to /sbin/nologin if not specified.
1.1 dsieger 5747:
1.184 rillig 5748: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
5749: whose syntax is:
1.1 dsieger 5750:
1.184 rillig 5751: group
1.1 dsieger 5752:
1.184 rillig 5753: The numeric GID of the group may be set by defining PKG_GID.group.
1.1 dsieger 5754:
1.184 rillig 5755: If a package needs to create the users and groups at an earlier stage, then it
5756: can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
5757: the phase before which the users and groups are created. In this case, the
5758: numeric UIDs and GIDs of the created users and groups are automatically
5759: hardcoded into the final installation scripts.
1.1 dsieger 5760:
1.184 rillig 5761: 20.5. System shells
1.1 dsieger 5762:
1.184 rillig 5763: Packages that install system shells should register them in the shell database,
5764: /etc/shells, to make things easier to the administrator. This must be done from
5765: the installation scripts to keep binary packages working on any system.
5766: pkginstall provides an easy way to accomplish this task.
1.1 dsieger 5767:
1.184 rillig 5768: When a package provides a shell interpreter, it has to set the PKG_SHELL
5769: variable to its absolute file name. This will add some hooks to the
5770: installation scripts to handle it. Consider the following example, taken from
5771: shells/zsh:
1.1 dsieger 5772:
1.184 rillig 5773: PKG_SHELL= ${PREFIX}/bin/zsh
1.1 dsieger 5774:
1.184 rillig 5775: 20.5.1. Disabling shell registration
1.1 dsieger 5776:
1.184 rillig 5777: The automatic registration of shell interpreters can be disabled by the
5778: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
1.1 dsieger 5779:
1.184 rillig 5780: 20.6. Fonts
1.1 dsieger 5781:
1.184 rillig 5782: Packages that install X11 fonts should update the database files that index the
5783: fonts within each fonts directory. This can easily be accomplished within the
5784: pkginstall framework.
1.1 dsieger 5785:
1.184 rillig 5786: When a package installs X11 fonts, it must list the directories in which fonts
5787: are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
5788: "type1" or "x11". This will add hooks to the installation scripts to run the
5789: appropriate commands to update the fonts database files within each of those
5790: directories. For convenience, if the directory path is relative, it is taken to
5791: be relative to the package's installation prefix. Consider the following
5792: example, taken from fonts/dbz-ttf:
1.1 dsieger 5793:
1.184 rillig 5794: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1 dsieger 5795:
1.184 rillig 5796: 20.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 5797:
1.184 rillig 5798: The automatic update of fonts databases can be disabled by the administrator by
5799: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
1.1 dsieger 5800:
1.154 rillig 5801: Chapter 21. Making your package work
1.1 dsieger 5802:
5803: Table of Contents
5804:
1.154 rillig 5805: 21.1. General operation
5806: 21.1.1. How to pull in user-settable variables from mk.conf
5807: 21.1.2. User interaction
5808: 21.1.3. Handling licenses
5809: 21.1.4. Restricted packages
5810: 21.1.5. Handling dependencies
5811: 21.1.6. Handling conflicts with other packages
5812: 21.1.7. Packages that cannot or should not be built
5813: 21.1.8. Packages which should not be deleted, once installed
5814: 21.1.9. Handling packages with security problems
5815: 21.1.10. How to handle incrementing versions when fixing an existing
1.232 gutterid 5816: package
1.154 rillig 5817: 21.1.11. Substituting variable text in the package files (the SUBST
1.232 gutterid 5818: framework)
1.154 rillig 5819: 21.2. The fetch phase
5820: 21.2.1. Packages whose distfiles aren't available for plain downloading
5821: 21.2.2. How to handle modified distfiles with the 'old' name
5822: 21.2.3. Packages hosted on github.com
5823: 21.3. The configure phase
5824: 21.3.1. Shared libraries - libtool
5825: 21.3.2. Using libtool on GNU packages that already support libtool
5826: 21.3.3. GNU Autoconf/Automake
1.223 nia 5827: 21.3.4. Meson / ninja
1.154 rillig 5828: 21.4. Programming languages
5829: 21.4.1. C, C++, and Fortran
5830: 21.4.2. Java
1.205 wiz 5831: 21.4.3. Go
1.223 nia 5832: 21.4.4. Rust
5833: 21.4.5. Packages containing Perl scripts
5834: 21.4.6. Packages containing shell scripts
5835: 21.4.7. Other programming languages
1.154 rillig 5836: 21.5. The build phase
5837: 21.5.1. Compiling C and C++ code conditionally
5838: 21.5.2. How to handle compiler bugs
1.172 rillig 5839: 21.5.3. No such file or directory
5840: 21.5.4. Undefined reference to "..."
5841: 21.5.5. Running out of memory
1.154 rillig 5842: 21.6. The install phase
5843: 21.6.1. Creating needed directories
5844: 21.6.2. Where to install documentation
5845: 21.6.3. Installing highscore files
5846: 21.6.4. Adding DESTDIR support to packages
5847: 21.6.5. Packages with hardcoded paths to other interpreters
1.203 nia 5848: 21.6.6. Packages installing Perl modules
1.154 rillig 5849: 21.6.7. Packages installing info files
5850: 21.6.8. Packages installing man pages
1.203 nia 5851: 21.6.9. Packages installing X11 fonts
5852: 21.6.10. Packages installing SGML or XML data
5853: 21.6.11. Packages installing extensions to the MIME database
5854: 21.6.12. Packages using intltool
5855: 21.6.13. Packages installing startup scripts
5856: 21.6.14. Packages installing TeX modules
5857: 21.6.15. Packages supporting running binaries in emulation
5858: 21.6.16. Packages installing hicolor icons
5859: 21.6.17. Packages installing desktop files
1.154 rillig 5860: 21.7. Marking packages as having problems
1.1 dsieger 5861:
1.154 rillig 5862: 21.1. General operation
1.1 dsieger 5863:
5864: One appealing feature of pkgsrc is that it runs on many different platforms. As
5865: a result, it is important to ensure, where possible, that packages in pkgsrc
5866: are portable. This chapter mentions some particular details you should pay
5867: attention to while working on pkgsrc.
5868:
1.154 rillig 5869: 21.1.1. How to pull in user-settable variables from mk.conf
1.1 dsieger 5870:
5871: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4 rillig 5872: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
5873: those variables in the preprocessor directives of make(1) (for example .if or
5874: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
5875: loads the user preferences.
1.1 dsieger 5876:
5877: But note that some variables may not be completely defined after ../../mk/
5878: bsd.prefs.mk has been included, as they may contain references to variables
1.108 rillig 5879: that are not yet defined. In shell commands (the lines in Makefile that are
5880: indented with a tab) this is no problem, since variables are only expanded when
5881: they are used. But in the preprocessor directives mentioned above and in
5882: dependency lines (of the form target: dependencies) the variables are expanded
5883: at load time.
1.1 dsieger 5884:
5885: Note
5886:
1.108 rillig 5887: To check whether a variable can be used at load time, run pkglint -Wall on your
5888: package.
1.1 dsieger 5889:
1.154 rillig 5890: 21.1.2. User interaction
1.1 dsieger 5891:
5892: Occasionally, packages require interaction from the user, and this can be in a
5893: number of ways:
5894:
5895: * When fetching the distfiles, some packages require user interaction such as
5896: entering username/password or accepting a license on a web page.
5897:
5898: * When extracting the distfiles, some packages may ask for passwords.
5899:
5900: * help to configure the package before it is built
5901:
5902: * help during the build process
5903:
5904: * help during the installation of a package
5905:
1.108 rillig 5906: A package can set the INTERACTIVE_STAGE variable to define which stages need
5907: interaction. This should be done in the package's Makefile, e.g.:
1.1 dsieger 5908:
5909: INTERACTIVE_STAGE= configure install
5910:
5911: The user can then decide to skip this package by setting the BATCH variable.
1.108 rillig 5912: Packages that require interaction are also excluded from bulk builds.
1.1 dsieger 5913:
1.154 rillig 5914: 21.1.3. Handling licenses
1.1 dsieger 5915:
5916: Authors of software can choose the licence under which software can be copied.
1.111 sevan 5917: The Free Software Foundation has declared some licenses "Free", and the Open
5918: Source Initiative has a definition of "Open Source".
5919:
5920: By default, pkgsrc allows packages with Free or Open Source licenses to be
5921: built. To allow packages with other licenses to be built as well, the pkgsrc
5922: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
5923: . Note that this variable only affects which packages may be built, while the
5924: license terms often also restrict the actual use of the package and its
5925: redistribution.
1.1 dsieger 5926:
5927: One might want to only install packages with a BSD license, or the GPL, and not
1.20 jnemeth 5928: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111 sevan 5929: variable. The pkgsrc user can override the default by setting the
5930: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
5931: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
5932: pkgsrc/mk/license.mk.
1.1 dsieger 5933:
5934: The license tag mechanism is intended to address copyright-related issues
5935: surrounding building, installing and using a package, and not to address
1.20 jnemeth 5936: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
5937: redistribution restrictions should set these tags.
1.1 dsieger 5938:
5939: Denoting that a package may be copied according to a particular license is done
5940: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
5941: string identifying the license, e.g. in graphics/xv:
5942:
5943: LICENSE= xv-license
5944:
5945: When trying to build, the user will get a notice that the package is covered by
5946: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
5947:
5948: % make
5949: ===> xv-3.10anb9 has an unacceptable license: xv-license.
5950: ===> To view the license, enter "/usr/bin/make show-license".
5951: ===> To indicate acceptance, add this line to your /etc/mk.conf:
5952: ===> ACCEPTABLE_LICENSES+=xv-license
5953: *** Error code 1
5954:
5955: The license can be viewed with make show-license, and if the user so chooses,
1.4 rillig 5956: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1 dsieger 5957: should not in the future fail because of that license:
5958:
5959: ACCEPTABLE_LICENSES+=xv-license
5960:
1.111 sevan 5961: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
5962: is deprecated because it does not crisply refer to a particular license text.
5963: Another problem with such usage is that it does not enable a user to tell
5964: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
5965: for all packages with that tag.
5966:
1.154 rillig 5967: 21.1.3.1. Adding a package with a new license
1.1 dsieger 5968:
1.49 rodent 5969: When adding a package with a new license, the following steps are required:
5970:
1.111 sevan 5971: 1. Check whether the license qualifies as Free or Open Source by referencing
5972: Various Licenses and Comments about Them and Licenses by Name | Open Source
5973: Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
5974: need the -license suffix, and the license name should be added to:
1.49 rodent 5975:
5976: + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
5977:
5978: + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
5979: license.c
5980:
5981: 2. The license text should be added to pkgsrc/licenses for displaying. A list
5982: of known licenses can be seen in this directory.
1.1 dsieger 5983:
1.154 rillig 5984: 21.1.3.2. Change to the license
1.1 dsieger 5985:
1.111 sevan 5986: When the license changes (in a way other than formatting), make sure that the
5987: new license has a different name (e.g., append the version number if it exists,
5988: or the date). Just because a user told pkgsrc to build programs under a
5989: previous version of a license does not mean that pkgsrc should build programs
5990: under the new licenses. The higher-level point is that pkgsrc does not evaluate
5991: licenses for reasonableness; the only test is a mechanistic test of whether a
5992: particular text has been approved by either of two bodies (FSF or OSI).
1.1 dsieger 5993:
1.154 rillig 5994: 21.1.4. Restricted packages
1.1 dsieger 5995:
1.111 sevan 5996: Some licenses restrict how software may be re-distributed. By declaring the
5997: restrictions, package tools can automatically refrain from e.g. placing binary
5998: packages on FTP sites.
5999:
6000: There are four possible restrictions, which are the cross product of sources
6001: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
6002: this is rarely the exact language in any license, and because non-Free licenses
6003: tend to be different from each other, pkgsrc adopts a definition of FTP and
6004: CD-ROM. "FTP" means making the source or binary file available over the
6005: Internet at no charge. "CD-ROM" means making the source or binary available on
6006: some kind of media, together with other source and binary packages, which is
6007: sold for a distribution charge.
1.1 dsieger 6008:
6009: In order to encode these restrictions, the package system defines five make
6010: variables that can be set to note these restrictions:
6011:
6012: * RESTRICTED
6013:
6014: This variable should be set whenever a restriction exists (regardless of
6015: its kind). Set this variable to a string containing the reason for the
6016: restriction. It should be understood that those wanting to understand the
6017: restriction will have to read the license, and perhaps seek advice of
6018: counsel.
6019:
6020: * NO_BIN_ON_CDROM
6021:
6022: Binaries may not be placed on CD-ROM containing other binary packages, for
6023: which a distribution charge may be made. In this case, set this variable to
6024: ${RESTRICTED}.
6025:
6026: * NO_BIN_ON_FTP
6027:
6028: Binaries may not made available on the Internet without charge. In this
6029: case, set this variable to ${RESTRICTED}. If this variable is set, binary
6030: packages will not be included on ftp.NetBSD.org.
6031:
6032: * NO_SRC_ON_CDROM
6033:
6034: Distfiles may not be placed on CD-ROM, together with other distfiles, for
6035: which a fee may be charged. In this case, set this variable to $
6036: {RESTRICTED}.
6037:
6038: * NO_SRC_ON_FTP
6039:
6040: Distfiles may not made available via FTP at no charge. In this case, set
6041: this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
6042: will not be mirrored on ftp.NetBSD.org.
6043:
1.111 sevan 6044: Please note that packages will be removed from pkgsrc when the distfiles are
1.33 wiz 6045: not distributable and cannot be obtained for a period of one full quarter
1.111 sevan 6046: branch. Packages with manual/interactive fetch must have a maintainer and it is
6047: his/her responsibility to ensure this.
1.33 wiz 6048:
1.154 rillig 6049: 21.1.5. Handling dependencies
1.1 dsieger 6050:
1.175 gutterid 6051: Your package may depend on some other package being present, and there are
6052: various ways of expressing this dependency. pkgsrc supports the DEPENDS,
6053: BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS definitions, the USE_TOOLS
6054: definition, as well as dependencies via buildlink3.mk, which is the preferred
6055: way to handle dependencies, and which uses the variables named above. See
1.184 rillig 6056: Chapter 18, Buildlink methodology for more information.
1.175 gutterid 6057:
6058: The basic difference is that the DEPENDS definition registers that
6059: pre-requisite in the binary package so it will be pulled in when the binary
6060: package is later installed, whilst the BUILD_DEPENDS, TOOL_DEPENDS, and
6061: TEST_DEPENDS definitions do not, marking a dependency that is only needed for
1.184 rillig 6062: building or testing the resulting package. See also Chapter 14, Creating a new
1.175 gutterid 6063: pkgsrc package from scratch for more information.
6064:
6065: This means that if you only need a package present whilst you are building or
6066: testing, it should be noted as a TOOL_DEPENDS, BUILD_DEPENDS, or TEST_DEPENDS.
6067: When cross-compiling, TOOL_DEPENDS are native packages, i.e. packages for the
6068: architecture where the package is built; BUILD_DEPENDS are target packages,
6069: i.e., packages for the architecture for which the package is built.
1.1 dsieger 6070:
1.175 gutterid 6071: The format for a DEPENDS, BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS
6072: definition is:
1.1 dsieger 6073:
6074: <pre-req-package-name>:../../<category>/<pre-req-package>
6075:
6076: Please note that the "pre-req-package-name" may include any of the wildcard
6077: version numbers recognized by pkg_info(1).
6078:
1.55 wiz 6079: 1. If your package needs another package's binaries or libraries to build and
1.1 dsieger 6080: run, and if that package has a buildlink3.mk file available, use it:
6081:
6082: .include "../../graphics/jpeg/buildlink3.mk"
6083:
1.55 wiz 6084: 2. If your package needs another package's binaries or libraries only for
6085: building, and if that package has a buildlink3.mk file available, use it:
6086:
6087: .include "../../graphics/jpeg/buildlink3.mk"
6088:
6089: but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
6090: This case is rather rare.
6091:
6092: 3. If your package needs binaries from another package to build, use the
1.156 leot 6093: TOOL_DEPENDS definition:
6094:
6095: TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool
1.1 dsieger 6096:
1.156 leot 6097: 4. If your package needs static libraries to link against, header files to
6098: include, etc. from another package to build, use the BUILD_DEPENDS
6099: definition.
1.1 dsieger 6100:
1.156 leot 6101: 5. If your package needs a library with which to link and there is no
1.26 spz 6102: buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
6103: because the include files and libraries will be hidden from the compiler.
1.1 dsieger 6104:
1.156 leot 6105: 6. If your package needs some executable to be able to run correctly and if
1.26 spz 6106: there's no buildlink3.mk file, this is specified using the DEPENDS
6107: variable. The print/lyx package needs to be able to execute the latex
1.129 wiz 6108: binary from the tex-latex-bin package when it runs, and that is specified:
1.1 dsieger 6109:
1.129 wiz 6110: DEPENDS+= tex-latex-bin-[0-9]*:../../print/tex-latex-bin
1.1 dsieger 6111:
1.175 gutterid 6112: 7. If your package includes a test suite that has extra dependencies only
6113: required for this purpose (frequently this can be run as a "make test"
6114: target), use the TEST_DEPENDS variable.
6115:
6116: 8. You can use wildcards in package dependencies. Note that such wildcard
1.26 spz 6117: dependencies are retained when creating binary packages. The dependency is
6118: checked when installing the binary package and any package which matches
6119: the pattern will be used. Wildcard dependencies should be used with care.
1.1 dsieger 6120:
6121: The "-[0-9]*" should be used instead of "-*" to avoid potentially ambiguous
6122: matches such as "tk-postgresql" matching a "tk-*" DEPENDS.
6123:
6124: Wildcards can also be used to specify that a package will only build
6125: against a certain minimum version of a pre-requisite:
6126:
1.26 spz 6127: DEPENDS+= ImageMagick>=6.0:../../graphics/ImageMagick
1.1 dsieger 6128:
1.26 spz 6129: This means that the package will build using version 6.0 of ImageMagick or
6130: newer. Such a dependency may be warranted if, for example, the command line
6131: options of an executable have changed.
6132:
1.183 wiz 6133: If you need to depend on minimum versions of libraries, set
6134: BUILDLINK_API_DEPENDS.pkg to the appropriate pattern before including its
6135: buildlink3.mk file, e.g.
6136:
6137: BUILDLINK_API_DEPENDS.jpeg+= jpeg>=9.0
6138: .include "../../graphics/jpeg/buildlink3.mk"
1.1 dsieger 6139:
6140: For security fixes, please update the package vulnerabilities file. See
1.154 rillig 6141: Section 21.1.9, "Handling packages with security problems" for more
1.1 dsieger 6142: information.
6143:
6144: If your package needs files from another package to build, add the relevant
6145: distribution files to DISTFILES, so they will be extracted automatically. See
6146: the print/ghostscript package for an example. (It relies on the jpeg sources
6147: being present in source form during the build.)
6148:
1.154 rillig 6149: 21.1.6. Handling conflicts with other packages
1.1 dsieger 6150:
1.226 gutterid 6151: Your package may conflict with other packages users might already have
6152: installed on their system, e.g., if your package installs the same set of files
1.227 wiz 6153: as another package in the pkgsrc tree.
1.1 dsieger 6154:
1.142 leot 6155: For example, x11/libXaw3d and x11/Xaw-Xpm install the same shared library, thus
6156: you set in pkgsrc/x11/libXaw3d/Makefile:
1.1 dsieger 6157:
1.142 leot 6158: CONFLICTS= Xaw-Xpm-[0-9]*
1.1 dsieger 6159:
6160:
1.142 leot 6161: and in pkgsrc/x11/Xaw-Xpm/Makefile:
1.1 dsieger 6162:
1.142 leot 6163: CONFLICTS= libXaw3d-[0-9]*
1.1 dsieger 6164:
1.142 leot 6165:
6166: pkg_add(1) is able to detect attempts to install packages that conflict with
6167: existing packages and abort. However, in many situations this is too late in
6168: the process. Binary package managers will not know about the conflict until
6169: they attempt to install the package after already downloading it and all its
6170: dependencies. Users may also waste time building a package and its dependencies
6171: only to find out at the end that it conflicts with another package they have
6172: installed.
6173:
6174: To avoid these issues CONFLICTS entries should be added in all cases where it
6175: is known that packages conflict with each other. These CONFLICTS entries are
6176: exported in pkg_summary(5) files and consumed by binary package managers to
6177: inform users that packages cannot be installed onto the target system.
1.1 dsieger 6178:
1.154 rillig 6179: 21.1.7. Packages that cannot or should not be built
1.1 dsieger 6180:
6181: There are several reasons why a package might be instructed to not build under
6182: certain circumstances. If the package builds and runs on most platforms, the
1.83 dholland 6183: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
6184: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
6185: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
6186: (OS-version-platform) that can use glob-style wildcards.
6187:
1.114 maya 6188: If a package is not appropriate for some platforms (as opposed to merely
1.83 dholland 6189: broken), a different set of variables should be used as this affects failure
6190: reporting and statistics. If the package is appropriate for most platforms, the
6191: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
6192: for only a small handful of platforms (often exactly one), set
6193: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
6194: triples (OS-version-platform) that can use glob-style wildcards.
1.1 dsieger 6195:
6196: Some packages are tightly bound to a specific version of an operating system,
6197: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
6198: with other versions of the OS, and should be uploaded to a version specific
6199: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
6200: to "yes". This variable is not currently used by any of the package system
6201: internals, but may be used in the future.
6202:
6203: If the package should be skipped (for example, because it provides
6204: functionality already provided by the system), set PKG_SKIP_REASON to a
6205: descriptive message. If the package should fail because some preconditions are
6206: not met, set PKG_FAIL_REASON to a descriptive message.
6207:
1.154 rillig 6208: 21.1.8. Packages which should not be deleted, once installed
1.1 dsieger 6209:
6210: To ensure that a package may not be deleted, once it has been installed, the
6211: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.25 wiz 6212: carried into any binary package that is made from this pkgsrc entry. A "
6213: preserved" package will not be deleted using pkg_delete(1) unless the "-f"
1.1 dsieger 6214: option is used.
6215:
1.154 rillig 6216: 21.1.9. Handling packages with security problems
1.1 dsieger 6217:
6218: When a vulnerability is found, this should be noted in localsrc/security/
1.205 wiz 6219: advisories/pkg-vulnerabilities. Entries in that file consist of three parts:
6220:
6221: * package version pattern
6222:
6223: * type of vulnerability (please cut'n'paste an existing one where possible)
6224:
6225: * URL providing additional information about the issue
6226:
6227: For the package version pattern please always use `<' to mark an upper bound
6228: (not `<='!). This will avoid possible problems due unrelated PKGREVISION bumps
6229: not related to security fixes. Lower bounds can be added too, using '>' or '>=
1.206 wiz 6230: '. For example, "foo>=1<1.2" would mark versions 1.0 (included) to 1.2
1.205 wiz 6231: (excluded) of "foo" as affected by the security issue.
6232:
6233: Entries should always be added at the bottom of the file.
6234:
6235: When fixing packages, please modify the upper bound of the corresponding entry.
6236: To continue the previous example, if a fix was backported to version 1.1nb2,
1.206 wiz 6237: change the previous pattern to "foo>=1<1.1nb2".
1.205 wiz 6238:
6239: To locally test a package version pattern against a PKGNAME you can use the
6240: pkg_admin pmatch command.
6241:
6242: The URL should be as permanent as possible and provide as much information
6243: about the issue as possible. CVE entries are preferred.
6244:
6245: After committing that file, ask pkgsrc-security@NetBSD.org to update the file
6246: on ftp.NetBSD.org.
1.1 dsieger 6247:
6248: After fixing the vulnerability by a patch, its PKGREVISION should be increased
6249: (this is of course not necessary if the problem is fixed by using a newer
1.32 wiz 6250: release of the software), and the pattern in the pkg-vulnerabilities file must
6251: be updated.
1.1 dsieger 6252:
6253: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
6254: submit a pullup request!
6255:
6256: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
6257: a weekly cron job.
6258:
1.205 wiz 6259: In case a security issue is disputed, please contact
6260: pkgsrc-security@NetBSD.org.
6261:
1.154 rillig 6262: 21.1.10. How to handle incrementing versions when fixing an existing package
1.1 dsieger 6263:
6264: When making fixes to an existing package it can be useful to change the version
6265: number in PKGNAME. To avoid conflicting with future versions by the original
6266: author, a "nb1", "nb2", ... suffix can be used on package versions by setting
6267: PKGREVISION=1 (2, ...). The "nb" is treated like a "." by the package tools.
6268: e.g.
6269:
6270: DISTNAME= foo-17.42
6271: PKGREVISION= 9
6272:
6273: will result in a PKGNAME of "foo-17.42nb9". If you want to use the original
6274: value of PKGNAME without the "nbX" suffix, e.g. for setting DIST_SUBDIR, use
6275: PKGNAME_NOREV.
6276:
6277: When a new release of the package is released, the PKGREVISION should be
6278: removed, e.g. on a new minor release of the above package, things should be
6279: like:
6280:
6281: DISTNAME= foo-17.43
6282:
6283: PKGREVISION should be incremented for any non-trivial change in the resulting
6284: binary package. Without a PKGREVISION bump, someone with the previous version
6285: installed has no way of knowing that their package is out of date. Thus,
6286: changes without increasing PKGREVISION are essentially labeled "this is so
6287: trivial that no reasonable person would want to upgrade", and this is the rough
6288: test for when increasing PKGREVISION is appropriate. Examples of changes that
6289: do not merit increasing PKGREVISION are:
6290:
1.14 jmcneill 6291: * Changing HOMEPAGE, MAINTAINER, OWNER, or comments in Makefile.
1.1 dsieger 6292:
6293: * Changing build variables if the resulting binary package is the same.
6294:
6295: * Changing DESCR.
6296:
6297: * Adding PKG_OPTIONS if the default options don't change.
6298:
6299: Examples of changes that do merit an increase to PKGREVISION include:
6300:
6301: * Security fixes
6302:
6303: * Changes or additions to a patch file
6304:
6305: * Changes to the PLIST
6306:
1.12 weinem 6307: * A dependency is changed or renamed.
6308:
1.1 dsieger 6309: PKGREVISION must also be incremented when dependencies have ABI changes.
6310:
1.154 rillig 6311: 21.1.11. Substituting variable text in the package files (the SUBST framework)
1.1 dsieger 6312:
1.180 rillig 6313: When you want to replace the same text in multiple files, or multiple times in
6314: the same file, it is cumbersome to maintain a patch file for this. This is
6315: where the SUBST framework steps in. It provides an easy-to-use interface for
6316: replacing text in files. It just needs the following information:
1.172 rillig 6317:
1.180 rillig 6318: * In which phase of the package build cycle should the replacement happen?
1.172 rillig 6319:
1.180 rillig 6320: * In which files should the replacement happen?
1.172 rillig 6321:
6322: * Which text should be replaced with what?
6323:
1.180 rillig 6324: This information is encoded in a block of SUBST variables. A minimal example
6325: is:
6326:
6327: SUBST_CLASSES+= paths
6328: SUBST_STAGE.paths= pre-configure
6329: SUBST_FILES.paths= src/*.c
6330: SUBST_SED.paths= -e 's,/usr/local,${PREFIX},g'
6331:
6332: Translated into English, it means: In the pre-configure stage (that is, after
6333: applying the patches from the patches/ directory and before running the
6334: configure script and the portability check), replace the text /usr/local with
6335: the content of the variable PREFIX.
6336:
6337: Each SUBST block starts by appending an identifier to SUBST_CLASSES (note the +
6338: =). This identifier can be chosen freely by the package. If there should ever
6339: be duplicate identifiers, the pkgsrc infrastructure will catch this and fail
6340: early, so don't worry about name collisions.
6341:
6342: Except for SUBST_CLASSES, all variables in a SUBST block are parameterized
6343: using this identifier. In the remainder of this section, these parameterized
6344: variables are written as SUBST_STAGE.*.
6345:
6346: SUBST_CLASSES+= paths
6347: SUBST_STAGE.paths= pre-configure
6348: SUBST_MESSAGE.paths= Fixing absolute paths.
6349: SUBST_FILES.paths= src/*.c
6350: SUBST_FILES.paths+= scripts/*.sh
6351: SUBST_SED.paths= -e 's,"/usr/local,"${PREFIX},g'
6352: SUBST_SED.paths+= -e 's,"/var/log,"${VARBASE}/log,g'
6353: SUBST_VARS.paths= LOCALBASE PREFIX PKGVERSION
6354:
6355: To get a complete picture about the SUBST substitutions, run bmake
6356: show-all-subst. If something doesn't work as expected, run pkglint on the
6357: package, which detects several typical mistakes surrounding the SUBST blocks.
6358: For any questions that might remain after this, have a look at mk/subst.mk.
6359:
6360: 21.1.11.1. Choosing the time where the substitutions happen
6361:
6362: The SUBST_STAGE.* is one of {pre,do,post}-
6363: {extract,patch,configure,build,test,install}. Of these, pre-configure is used
6364: most often, by far. The most popular stages are, in chronological order:
6365:
6366: post-extract
6367:
6368: The substitutions are applied immediately after the distfiles are
6369: extracted. Running bmake extract on the package will leave no traces of the
6370: original files.
6371:
6372: When the substitution applies to files for which there is also a patch in
6373: the patches/ directory, this means that the patches will be computed based
6374: on the result of the substitution. When these patches are sent to the
6375: upstream maintainer later, to be fixed in the upstream package, these
6376: patches may no longer match what the upstream author is used to. Because of
6377: this, pre-configure is often a better choice.
6378:
6379: pre-configure
6380:
6381: The substitutions are applied after the patches from the patches/
6382: directory. This makes it possible to run bmake patch on the package, after
6383: which the patches can be edited using the tools pkgvi and mkpatches from
6384: the pkgtools/pkgdiff package.
6385:
6386: When updating the patches, it is helpful to explicitly separate the bmake
6387: patch from the bmake configure, and to only edit the patches between these
6388: commands. Otherwise the substitutions from the SUBST block will end up in
6389: the patch file. When this happens in really obvious ways, pkglint will
6390: complain about patches that contain a hard-coded /usr/pkg instead of the
6391: correct and intended @PREFIX@, but it can only detect these really obvious
6392: cases.
6393:
6394: do-configure
6395:
6396: This stage should only be used if the package defines a pre-configure
6397: action itself, and the substitution must happen after that. Typical
6398: examples are packages that use the pre-configure stage to regenerate the
6399: GNU configure script from configure.ac.
6400:
6401: post-configure
6402:
6403: This stage is used to fix up any mistakes by the configure stage.
6404:
6405: pre-build
6406:
6407: This stage should only be used for substitutions that are clearly related
6408: to building the package, not for fixing the configuration. Substitutions
6409: for pathnames (such as replacing /usr/local with ${PREFIX}) or user names
6410: (such as replacing @MY_USER@ with the actual username) belong in
6411: pre-configure or post-configure instead.
6412:
6413: post-build
6414:
6415: Just as with pre-build, this stage should only be used for substitutions
6416: that are clearly related to building the package, not for fixing the
6417: configuration. Substitutions for pathnames (such as replacing /usr/local
6418: with ${PREFIX}) or user names (such as replacing @MY_USER@ with the actual
6419: username) belong in pre-configure or post-configure instead.
6420:
6421: A typical use is to update pkg-config files to include the rpath compiler
6422: options.
6423:
6424: pre-install
6425:
6426: In general, the install phase should be as simple as possible. As with the
6427: pre-build and post-build stages, it should not be used to fix pathnames or
6428: user names, these belong in pre-configure instead. There are only few
6429: legitimate use cases for applying substitutions in this stage.
6430:
1.181 rillig 6431: 21.1.11.2. Choosing the files where the substitutions happen
1.180 rillig 6432:
6433: The SUBST_FILES.* variable contains a list of filename patterns. These patterns
6434: are relative to WRKSRC since that is where most substitutions happen. A typical
6435: example is:
6436:
6437: SUBST_FILES.path= Makefile */Makefile */*/Makefile *.[ch]
6438:
6439: The above patterns, especially the last, are quite broad. The SUBST
6440: implementation checks that each filename pattern that is mentioned here has an
6441: effect. For example, if none of the */*/Makefile files contains the patterns to
6442: be found and substituted, that filename pattern is redundant and should be left
1.181 rillig 6443: out. By default, the SUBST framework will complain with an error message. If
6444: the text to be substituted occurs in some of the files from a single pattern,
6445: but not in all of them, that is totally ok, and the SUBST framework will only
6446: print an INFO message for those files.
1.180 rillig 6447:
6448: If there is a good reason for having redundant filename patterns, set
1.181 rillig 6449: SUBST_NOOP_OK.* to yes.
1.180 rillig 6450:
6451: Another popular way of choosing the files for the substitutions is via a shell
6452: command, like this:
6453:
1.181 rillig 6454: C_FILES_CMD= cd ${WRKSRC} && ${FIND} . -name '*.c'
1.180 rillig 6455: SUBST_FILES.path= ${C_FILES_CMD:sh}
6456:
6457: The variable name C_FILES_CMD in this example is freely chosen and independent
6458: of the SUBST framework.
6459:
6460: In this variant, the SUBST_FILES.* variable lists each file individually.
6461: Thereby chances are higher that there are filename patterns in which no
6462: substitution happens. Since the SUBST framework cannot know whether the
6463: filename patterns in SUBST_FILES.* have been explicitly listed in the Makefile
6464: (where any redundant filename pattern would be suspicious) or been generated by
6465: a shell command (in which redundant filename patterns are more likely and to be
6466: expected), it will complain about these redundant filename patterns. Therefore,
6467: SUBST blocks that use a shell command to generate the list of filename patterns
6468: often need to set SUBST_NOOP_OK.* to yes.
6469:
6470: 21.1.11.3. Choosing what to substitute
6471:
6472: In most cases, the substitutions are given using one or more sed(1) commands,
6473: like this:
6474:
6475: SUBST_SED.path= -e 's|/usr/local|${PREFIX}|g'
6476:
6477: Each of the sed commands needs to be preceded by the -e option and should be
6478: specified on a line of its own, to avoid hiding short sed commands at the end
6479: of a line.
6480:
6481: Since the sed commands often contain shell metacharacters as the separator (the
6482: | in the above example), it is common to enclose them in single quotes.
6483:
6484: A common substitution is to replace placeholders of the form @VARNAME@ with
6485: their pkgsrc counterpart variable ${VARNAME}. A typical example is:
6486:
6487: SUBST_VARS.path= PREFIX
6488:
1.181 rillig 6489: This type of substitutions is typically done by the GNU configure scripts
6490: during the do-configure stage, but in some cases these need to be overridden.
6491: The same pattern is also used when a package defines patches that replace
6492: previously hard-coded paths like /usr/local with a @PREFIX@ placeholder first,
6493: which then gets substituted by the actual ${PREFIX} in the pre-configure stage.
6494: In many of these cases, it works equally well to just use the SUBST framework
6495: to directly replace /usr/local with ${PREFIX}, thereby omitting the
6496: intermediate patch file.
1.180 rillig 6497:
6498: If the above is not flexible enough, it is possible to not use sed at all for
6499: the substitution but to specify an entirely different command, like this:
6500:
6501: SUBST_FILTER_CMD.path= LC_ALL=C ${TR} -d '\r'
1.1 dsieger 6502:
1.180 rillig 6503: This is used for the few remaining packages in which the distributed files use
6504: Windows-style line endings that need to be converted to UNIX-style line
6505: endings.
1.1 dsieger 6506:
1.180 rillig 6507: 21.1.11.4. Other SUBST variables
1.172 rillig 6508:
1.180 rillig 6509: When a SUBST block is applied during a package build, a message is logged. The
6510: default message is fine for most purposes but can be overridden by setting
6511: SUBST_MESSAGE.* to an individual message.
1.1 dsieger 6512:
1.154 rillig 6513: 21.2. The fetch phase
1.1 dsieger 6514:
1.154 rillig 6515: 21.2.1. Packages whose distfiles aren't available for plain downloading
1.1 dsieger 6516:
6517: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
6518: a make fetch will call files/getsite.sh with the name of each file to download
6519: as an argument, expecting it to output the URL of the directory from which to
6520: download it. graphics/ns-cult3d is an example of this usage.
6521:
6522: If the download can't be automated, because the user must submit personal
6523: information to apply for a password, or must pay for the source, or whatever,
6524: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
6525: before aborting the build. Example:
6526:
6527: FETCH_MESSAGE= "Please download the files"
6528: FETCH_MESSAGE+= " "${DISTFILES:Q}
6529: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
6530:
1.154 rillig 6531: 21.2.2. How to handle modified distfiles with the 'old' name
1.1 dsieger 6532:
6533: Sometimes authors of a software package make some modifications after the
6534: software was released, and they put up a new distfile without changing the
6535: package's version number. If a package is already in pkgsrc at that time, the
6536: checksum will no longer match. The contents of the new distfile should be
6537: compared against the old one before changing anything, to make sure the
6538: distfile was really updated on purpose, and that no trojan horse or so crept
6539: in. Please mention that the distfiles were compared and what was found in your
1.54 rodent 6540: commit message.
6541:
6542: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109 wiz 6543: directory name, usually based on PKGNAME_NOREV (but take care with python or
6544: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
6545: PATCHFILES for this package will be put in that subdirectory of the local
1.154 rillig 6546: distfiles directory. (See Section 21.1.10, "How to handle incrementing versions
1.109 wiz 6547: when fixing an existing package" for more details.) In case this happens more
6548: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
6549: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54 rodent 6550:
6551: DIST_SUBDIR is also used when a distfile's name does not contain a version and
6552: the distfile is apt to change. In cases where the likelihood of this is very
6553: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
6554: removed unless the distfile name changes, even if a package is being moved or
6555: renamed.
6556:
6557: Do not forget regenerating the distinfo file after that, since it contains the
6558: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
6559: installed package is different. Furthermore, a mail to the package's authors
6560: seems appropriate telling them that changing distfiles after releases without
6561: changing the file names is not good practice.
1.1 dsieger 6562:
1.154 rillig 6563: 21.2.3. Packages hosted on github.com
1.88 tnn 6564:
1.90 tnn 6565: Helper methods exist for packages hosted on github.com which will often have
6566: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
6567: of the three recipes from below:
1.88 tnn 6568:
1.154 rillig 6569: 21.2.3.1. Fetch based on a tagged release
1.88 tnn 6570:
1.189 bacon 6571: If your distfile URL looks similar to https://github.com/username/example/
6572: archive/v1.0.zip, then you are packaging a tagged release.
1.88 tnn 6573:
1.189 bacon 6574: DISTNAME= example-1.0
1.90 tnn 6575: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1.189 bacon 6576: #GITHUB_PROJECT= example # can be omitted if same as DISTNAME
1.90 tnn 6577: GITHUB_TAG= v${PKGVERSION_NOREV}
1.88 tnn 6578: EXTRACT_SUFX= .zip
6579:
1.230 gutterid 6580: Here, DISTNAME combined with use of GITHUB_TAG leads the file fetching
6581: infrastructure to save the resulting file locally as example-1.0.zip.
6582:
1.189 bacon 6583: 21.2.3.2. Fetch based on a specific commit before the first release
6584:
6585: If your distfile looks similar to https://github.com/username/example/archive/
6586: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit before the first
6587: release, then set the package version to 0.0.0.N, where N is the number of
6588: commits to the repository, and set GITHUB_TAG to the commit hash. This will
6589: (almost) ensure that the first tagged release will have a version greater than
6590: this one so that package upgrades will function properly.
6591:
6592: DISTNAME= example-0.0.0.347
6593: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
6594: #GITHUB_PROJECT= example # can be omitted if same as DISTNAME
6595: GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
6596:
6597: 21.2.3.3. Fetch based on a specific commit after a release
1.88 tnn 6598:
1.189 bacon 6599: If your distfile looks similar to https://github.com/username/example/archive/
6600: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit after a release,
6601: then include the last release version and the commit count since that release
6602: in the package version and set GITHUB_TAG to the commit hash. The latest
6603: release and commit count are shown in the output of "git describe --tags":
6604:
6605: # git clone https://github.com/username/example
6606: # cd example
6607: # git describe --tags
6608: 1.2.3-5-g988881a
1.88 tnn 6609:
1.189 bacon 6610: DISTNAME= example-1.2.3.5
6611: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
6612: #GITHUB_PROJECT= example # can be omitted if same as DISTNAME
1.90 tnn 6613: GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88 tnn 6614:
1.189 bacon 6615: 21.2.3.4. Fetch based on release
1.88 tnn 6616:
1.189 bacon 6617: If your distfile URL looks similar to https://github.com/username/example/
6618: releases/download/rel-1.6/offensive-1.6.zip, then you are packaging a release.
1.88 tnn 6619:
1.90 tnn 6620: DISTNAME= offensive-1.6
1.88 tnn 6621: PKGNAME= ${DISTNAME:S/offensive/proper/}
1.90 tnn 6622: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1.189 bacon 6623: GITHUB_PROJECT= example
1.90 tnn 6624: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
6625: EXTRACT_SUFX= .zip
1.88 tnn 6626:
1.154 rillig 6627: 21.3. The configure phase
1.1 dsieger 6628:
1.154 rillig 6629: 21.3.1. Shared libraries - libtool
1.1 dsieger 6630:
6631: pkgsrc supports many different machines, with different object formats like
6632: a.out and ELF, and varying abilities to do shared library and dynamic loading
6633: at all. To accompany this, varying commands and options have to be passed to
6634: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
6635: especially if you don't have all the machines at your hand to test things. The
6636: devel/libtool pkg can help here, as it just "knows" how to build both static
6637: and dynamic libraries from a set of source files, thus being
6638: platform-independent.
6639:
6640: Here's how to use libtool in a package in seven simple steps:
6641:
6642: 1. Add USE_LIBTOOL=yes to the package Makefile.
6643:
6644: 2. For library objects, use "${LIBTOOL} --mode=compile ${CC}" in place of "$
6645: {CC}". You could even add it to the definition of CC, if only libraries are
6646: being built in a given Makefile. This one command will build both PIC and
6647: non-PIC library objects, so you need not have separate shared and
6648: non-shared library rules.
6649:
6650: 3. For the linking of the library, remove any "ar", "ranlib", and "ld
6651: -Bshareable" commands, and instead use:
6652:
6653: ${LIBTOOL} --mode=link \
6654: ${CC} -o ${.TARGET:.a=.la} \
6655: ${OBJS:.o=.lo} \
6656: -rpath ${PREFIX}/lib \
6657: -version-info major:minor
6658:
6659: Note that the library is changed to have a .la extension, and the objects
6660: are changed to have a .lo extension. Change OBJS as necessary. This
6661: automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
6662: necessary) in the build directory. Be sure to include "-version-info",
6663: especially when major and minor are zero, as libtool will otherwise strip
6664: off the shared library version.
6665:
6666: From the libtool manual:
6667:
6668: So, libtool library versions are described by three integers:
6669:
6670: CURRENT
6671: The most recent interface number that this library implements.
6672:
6673: REVISION
6674: The implementation number of the CURRENT interface.
6675:
6676: AGE
6677: The difference between the newest and oldest interfaces that
6678: this library implements. In other words, the library implements
6679: all the interface numbers in the range from number `CURRENT -
6680: AGE' to `CURRENT'.
6681:
6682: If two libraries have identical CURRENT and AGE numbers, then the
6683: dynamic linker chooses the library with the greater REVISION number.
6684:
6685: The "-release" option will produce different results for a.out and ELF
1.25 wiz 6686: (excluding symlinks) in only one case. An ELF library of the form "
6687: libfoo-release.so.x.y" will have a symlink of "libfoo.so.x.y" on an a.out
1.1 dsieger 6688: platform. This is handled automatically.
6689:
6690: The "-rpath argument" is the install directory of the library being built.
6691:
6692: In the PLIST, include only the .la file, the other files will be added
6693: automatically.
6694:
6695: 4. When linking shared object (.so) files, i.e. files that are loaded via
6696: dlopen(3), NOT shared libraries, use "-module -avoid-version" to prevent
6697: them getting version tacked on.
6698:
6699: The PLIST file gets the foo.so entry.
6700:
6701: 5. When linking programs that depend on these libraries before they are
6702: installed, preface the cc(1) or ld(1) line with "${LIBTOOL} --mode=link",
6703: and it will find the correct libraries (static or shared), but please be
6704: aware that libtool will not allow you to specify a relative path in -L
6705: (such as "-L../somelib"), because it expects you to change that argument to
6706: be the .la file. e.g.
6707:
6708: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
6709:
6710: should be changed to:
6711:
6712: ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
6713:
6714: and it will do the right thing with the libraries.
6715:
6716: 6. When installing libraries, preface the install(1) or cp(1) command with "$
6717: {LIBTOOL} --mode=install", and change the library name to .la. e.g.
6718:
1.23 jakllsch 6719: ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1 dsieger 6720:
6721: This will install the static .a, shared library, any needed symlinks, and
6722: run ldconfig(8).
6723:
6724: 7. In your PLIST, include only the .la file (this is a change from previous
6725: behaviour).
6726:
1.154 rillig 6727: 21.3.2. Using libtool on GNU packages that already support libtool
1.1 dsieger 6728:
6729: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
6730: own libtool in most cases. For older libtool using packages, libtool is made by
6731: ltconfig script during the do-configure step; you can check the libtool script
6732: location by doing make configure; find work*/ -name libtool.
6733:
6734: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
6735: override. By default, it is set to "libtool */libtool */*/libtool". If this
6736: does not match the location of the package's libtool script(s), set it as
6737: appropriate.
6738:
6739: If you do not need *.a static libraries built and installed, then use
6740: SHLIBTOOL_OVERRIDE instead.
6741:
6742: If your package makes use of the platform-independent library for loading
6743: dynamic shared objects, that comes with libtool (libltdl), you should include
6744: devel/libltdl/buildlink3.mk.
6745:
6746: Some packages use libtool incorrectly so that the package may not work or build
6747: in some circumstances. Some of the more common errors are:
6748:
6749: * The inclusion of a shared object (-module) as a dependent library in an
6750: executable or library. This in itself isn't a problem if one of two things
6751: has been done:
6752:
6753: 1. The shared object is named correctly, i.e. libfoo.la, not foo.la
6754:
6755: 2. The -dlopen option is used when linking an executable.
6756:
6757: * The use of libltdl without the correct calls to initialisation routines.
6758: The function lt_dlinit() should be called and the macro
6759: LTDL_SET_PRELOADED_SYMBOLS included in executables.
6760:
1.154 rillig 6761: 21.3.3. GNU Autoconf/Automake
1.1 dsieger 6762:
6763: If a package needs GNU autoconf or automake to be executed to regenerate the
1.223 nia 6764: configure script and Makefile.in makefile templates from configure.ac and
6765: Makefile.am, then they should be executed in a pre-configure target:
1.1 dsieger 6766:
1.223 nia 6767: USE_TOOLS+= autoconf automake autoreconf
6768: GNU_CONFIGURE= yes
1.1 dsieger 6769: ...
6770:
6771: pre-configure:
1.223 nia 6772: set -e; cd ${WRKSRC} && autoreconf -fi
1.1 dsieger 6773: ...
6774:
1.223 nia 6775: Packages which use GNU Automake will sometimes require GNU Make (gmake in
6776: USE_TOOLS), but not always. Note that autoreconf only needs to be executed if
6777: configure.ac or Makefiles are modified, or configure is not present.
1.1 dsieger 6778:
6779: There are times when the configure process makes additional changes to the
6780: generated files, which then causes the build process to try to re-execute the
6781: automake sequence. This is prevented by touching various files in the configure
6782: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
6783: NO in the package Makefile.
6784:
1.223 nia 6785: 21.3.4. Meson / ninja
6786:
6787: Packages using Meson to configure need to include:
6788:
6789: .include "../../devel/meson/build.mk"
6790:
6791: In nearly all cases (any program with dependencies), pkg-config needs to be
6792: added to USE_TOOLS. If the package installs translation files for non-English
6793: languages, also add msgfmt and xgettext:
6794:
6795: USE_TOOLS+= pkg-config msgfmt xgettext
6796:
6797: If any options need to be passed to Meson, use MESON_ARGS instead of
6798: CONFIGURE_ARGS:
6799:
6800: MESON_ARGS+= -Dx11=false
6801:
1.154 rillig 6802: 21.4. Programming languages
1.1 dsieger 6803:
1.154 rillig 6804: 21.4.1. C, C++, and Fortran
1.1 dsieger 6805:
1.223 nia 6806: Compilers for the C and C++ languages comes with the NetBSD base system. By
6807: default, pkgsrc assumes that a package is written in C and will hide all other
6808: compilers (via the wrapper framework, see Chapter 18, Buildlink methodology).
1.1 dsieger 6809:
6810: To declare which language's compiler a package needs, set the USE_LANGUAGES
1.212 wiz 6811: variable. Allowed values currently are:
6812:
6813: c99, c++, c++03, gnu++03, c++0x, gnu++0x, c++11, gnu++11,
6814: c++14, gnu++14, c++17, gnu++17, c++20, gnu++20, fortran,
6815: fortran77, java, objc, obj-c++, and ada.
6816:
6817:
6818: (and any combination). The default is "c". Packages using GNU configure
6819: scripts, even if written in C++, usually need a C compiler for the configure
6820: phase.
1.1 dsieger 6821:
1.223 nia 6822: To express a general requirement on a specific C or C++ version, normally only
6823: GCC_REQD needs to be set. For example, GCC 7 includes support for C++17, so if
6824: the package uses C++17 it should specify:
6825:
6826: GCC_REQD+= 7
6827:
6828:
6829: Language variants like c++11 for USE_LANGUAGES should only be specified if the
6830: package does not explicitly set -std=... when compiling (i.e. the package
6831: assumes the compiler defaults to C++11 or some other standard). This is usually
6832: a bug in the upstream build system.
6833:
6834: GCC version 5 includes support for C++14, while GCC 4.7 includes more-or-less
6835: complete support for C++11. For more information, consult GCC's own
6836: documentation on programming language support.
6837:
1.154 rillig 6838: 21.4.2. Java
1.1 dsieger 6839:
6840: If a program is written in Java, use the Java framework in pkgsrc. The package
6841: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
6842: variables:
6843:
6844: * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
6845: set to "run", then there is only a runtime dependency on the JDK. The
6846: default is "yes", which also adds a build dependency on the JDK.
6847:
6848: * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
6849: supported values are "yes", "1.4", and "1.5". "yes" accepts any Java2
6850: implementation, "1.4" insists on versions 1.4 or above, and "1.5" only
6851: accepts versions 1.5 or above. This variable is not set by default.
6852:
1.25 wiz 6853: * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
6854: implementation dependency. It may be used to set JAVA_HOME to a good value
6855: if the program needs this variable to be defined.
6856:
1.205 wiz 6857: 21.4.3. Go
6858:
6859: If a program is written in Go and has any dependencies on other Go modules,
6860: have the package include ../../lang/go/go-module.mk.
6861:
6862: 1. Generate a list of those dependencies with make clean && make patch && make
6863: show-go-modules > go-modules.mk.
6864:
1.223 nia 6865: 2. Prepend .include "go-modules.mk" to any other .includes.
6866:
6867: 3. Incorporate these modules in distinfo with make makesum.
1.205 wiz 6868:
1.223 nia 6869: 21.4.4. Rust
1.205 wiz 6870:
1.223 nia 6871: If a program is written in Rust and uses Cargo to build, have the package
6872: include ../../lang/rust/cargo.mk.
1.205 wiz 6873:
1.223 nia 6874: 1. Generate a list of those dependencies with make CARGO_ARGS="build
6875: --release" build && make print-cargo-depends > cargo-depends.mk.
1.205 wiz 6876:
1.223 nia 6877: 2. Prepend .include "cargo-depends.mk" to any other .includes.
1.205 wiz 6878:
6879: 3. Incorporate these modules in distinfo with make makesum.
6880:
1.223 nia 6881: 21.4.5. Packages containing Perl scripts
1.1 dsieger 6882:
1.203 nia 6883: If your package contains interpreted Perl scripts, add "perl" to the USE_TOOLS
1.1 dsieger 6884: variable and set REPLACE_PERL to ensure that the proper interpreter path is
6885: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74 wiz 6886: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
1.210 gutterid 6887: replaced with the full path to the Perl executable.
1.1 dsieger 6888:
1.210 gutterid 6889: If a particular version of Perl is needed, set the PERL5_REQD variable to the
1.1 dsieger 6890: version number. The default is "5.0".
6891:
1.203 nia 6892: See Section 21.6.6, "Packages installing Perl modules" for information about
1.210 gutterid 6893: handling Perl modules.
6894:
6895: There is also the REPLACE_PERL6 variable for the language now known as Raku.
1.1 dsieger 6896:
1.223 nia 6897: 21.4.6. Packages containing shell scripts
1.41 wiz 6898:
6899: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
1.225 gutterid 6900: shell she-bangs in files. Please use the appropriate one, preferring REPLACE_SH
6901: when this shell is sufficient. Each should contain a list of scripts, relative
6902: to WRKSRC, that you want adjusted. Every occurrence of the matching shell in a
6903: she-bang line will be replaced with the full path to the shell executable. When
6904: using REPLACE_BASH, don't forget to add bash to USE_TOOLS.
1.41 wiz 6905:
1.223 nia 6906: 21.4.7. Other programming languages
1.1 dsieger 6907:
1.210 gutterid 6908: There are further similar REPLACE variables available, e.g., REPLACE_AWK for
6909: packages containing awk scripts, and REPLACE_R for R. These two, like the
1.211 gutterid 6910: others noted above, have their actions defined centrally in mk/configure/
6911: replace-interpreter.mk. Other languages define the actions of these variables
6912: within their own dedicated part of the tree, e.g., REPLACE_PHP is actioned in
6913: lang/php/phpversion.mk, and REPLACE_PYTHON is actioned in lang/python/
6914: application.mk. For other languages, consult the mk files found within their
1.216 gutterid 6915: specific directories (the naming convention varies), or check the list found in
6916: Appendix E, Help topics.
1.210 gutterid 6917:
6918: Currently, special handling for other languages varies in pkgsrc. If a compiler
6919: package provides a buildlink3.mk file, include that, otherwise just add a
6920: (build) dependency on the appropriate compiler package.
1.1 dsieger 6921:
1.154 rillig 6922: 21.5. The build phase
1.1 dsieger 6923:
6924: The most common failures when building a package are that some platforms do not
6925: provide certain header files, functions or libraries, or they provide the
6926: functions in a library that the original package author didn't know. To work
6927: around this, you can rewrite the source code in most cases so that it does not
6928: use the missing functions or provides a replacement function.
6929:
1.154 rillig 6930: 21.5.1. Compiling C and C++ code conditionally
1.1 dsieger 6931:
6932: If a package already comes with a GNU configure script, the preferred way to
6933: fix the build failure is to change the configure script, not the code. In the
6934: other cases, you can utilize the C preprocessor, which defines certain macros
6935: depending on the operating system and hardware architecture it compiles for.
6936: These macros can be queried using for example #if defined(__i386). Almost every
6937: operating system, hardware architecture and compiler has its own macro. For
6938: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
6939: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
6940: GCC.
6941:
6942: The list of the following macros for hardware and operating system depends on
6943: the compiler that is used. For example, if you want to conditionally compile
6944: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
6945: Use __sun instead.
6946:
1.154 rillig 6947: 21.5.1.1. C preprocessor macros to identify the operating system
1.1 dsieger 6948:
1.223 nia 6949: To distinguish between specific NetBSD versions, you should use the following
6950: code.
6951:
6952: #ifdef __NetBSD__
6953: #include <sys/param.h>
6954: #if __NetBSD_Prereq__(9,99,17)
6955: /* use a newer feature */
6956: #else
6957: /* older code */
6958: #endif
6959: #endif
6960:
6961: #ifndef _WIN32
6962: /* Unix-like specific code */
6963: #endif
6964:
1.1 dsieger 6965: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
6966: should use the following code.
6967:
6968: #include <sys/param.h>
6969: #if (defined(BSD) && BSD >= 199306)
6970: /* BSD-specific code goes here */
6971: #else
6972: /* non-BSD-specific code goes here */
6973: #endif
6974:
1.223 nia 6975: You can also test for the following macros:
1.1 dsieger 6976:
1.46 obache 6977: Cygwin __CYGWIN__
6978: DragonFly __DragonFly__
1.1 dsieger 6979: FreeBSD __FreeBSD__
1.46 obache 6980: Haiku __HAIKU__
1.1 dsieger 6981: Interix __INTERIX
6982: IRIX __sgi (TODO: get a definite source for this)
1.223 nia 6983: Linux __linux
1.83 dholland 6984: Mac OS X __APPLE__
1.46 obache 6985: MirBSD __MirBSD__ (__OpenBSD__ is also defined)
6986: Minix3 __minix
1.1 dsieger 6987: NetBSD __NetBSD__
6988: OpenBSD __OpenBSD__
6989: Solaris sun, __sun
6990:
1.154 rillig 6991: 21.5.1.2. C preprocessor macros to identify the hardware architecture
1.1 dsieger 6992:
6993: i386 i386, __i386, __i386__
1.223 nia 6994: x86-64 __amd64__, __x86_64__
6995: ARM __arm__
1.1 dsieger 6996: MIPS __mips
6997: SPARC sparc, __sparc
1.223 nia 6998: PowerPC __powerpc
1.1 dsieger 6999:
1.154 rillig 7000: 21.5.1.3. C preprocessor macros to identify the compiler
1.1 dsieger 7001:
7002: GCC __GNUC__ (major version), __GNUC_MINOR__
7003: MIPSpro _COMPILER_VERSION (0x741 for MIPSpro 7.41)
7004: SunPro __SUNPRO_C (0x570 for Sun C 5.7)
7005: SunPro C++ __SUNPRO_CC (0x580 for Sun C++ 5.8)
7006:
1.154 rillig 7007: 21.5.2. How to handle compiler bugs
1.1 dsieger 7008:
7009: Some source files trigger bugs in the compiler, based on combinations of
7010: compiler version and architecture and almost always relation to optimisation
7011: being enabled. Common symptoms are gcc internal errors or never finishing
7012: compiling a file.
7013:
7014: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87 tnn 7015: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
7016:
7017: This used to be a big problem in the past, but is rarely needed now as compiler
7018: technology has matured. If you still need to add a compiler specific
7019: workaround, please do so in the file hacks.mk and describe the symptom and
7020: compiler version as detailed as possible.
1.1 dsieger 7021:
1.172 rillig 7022: 21.5.3. No such file or directory
7023:
7024: Compilation sometimes fails with an error message like this:
7025:
7026: .../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
7027: fatal error: pango/pango.h: No such file or directory
7028:
7029: The proper way to fix this problem depends on the type of the header, which is
7030: described in the following sections.
7031:
7032: 21.5.3.1. Headers from other packages
7033:
7034: If the header name looks like it comes from a different package, that other
7035: package should be included via the buildlink3 framework.
7036:
7037: First, look whether the header is somewhere in the buildlink3 directory below
7038: WRKDIR. In the above case of the missing Pango header:
7039:
7040: $ find work/.buildlink/ -print | grep -F pango/pango.h
7041:
7042: In the case of Pango, the output is:
7043:
7044: work/.buildlink/include/pango-1.0/pango/pango.h
7045:
7046: If the pango/pango.h file were placed directly in the .buildlink directory, it
7047: would have been found automatically. There is an extra pango-1.0 path component
7048: though, which means that the compiler command line must contain an option of
7049: the form -I${BUILDLINK3_PREFIX.pango}/include/pango-1.0. In most cases this
7050: option is generated by the configure script, which can be examined using:
7051:
7052: $ $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
7053: -I/usr/pkg/include/pango-1.0
7054: -I/usr/pkg/include/pango-1.0
7055: -I/usr/pkg/include/pango-1.0
7056: -I/usr/pkg/include/pango-1.0
7057: -I/usr/pkg/include/pango-1.0
7058:
7059: This looks good. These options are transformed by the buildlink wrapper to
7060: refer to the correct path inside work/.buildlink.
7061:
7062: Since the compilation fails though, examine the compiler command lines in work
7063: /.work.log to see whether the -I option is included in the particular command
7064: line.
7065:
7066: To further analyze the situation, run bmake build-env, which sets up an
7067: interactive, realistic environment including all the pkgsrc wrapper commands
7068: and environment variables. From there, try to compile some simple example
7069: programs that use the header.
7070:
7071: 21.5.3.2. Headers generated during the build
7072:
7073: If the name of the header seems to come from the package itself, and if the
7074: build is run with parallel jobs, the package may have some undeclared
7075: dependencies between the .c and the .h files, and a C file is compiled before
7076: its required header is generated.
7077:
7078: To see whether the build runs with parallel jobs, run bmake show-all-build |
7079: grep JOBS. Its output looks like this:
7080:
7081: usr MAKE_JOBS= 7
7082: pkg MAKE_JOBS_SAFE # undefined
7083: def _MAKE_JOBS_N= 7
7084:
7085: In this case the pkgsrc user has asked pkgsrc to build packages with 7 jobs in
7086: parallel (MAKE_JOBS). The package could have disabled parallel builds by
7087: setting MAKE_JOBS_SAFE to no, but in this case it hasn't.
7088:
7089: To see whether the build failure is caused by parallel builds, first save the
7090: exact error message and a bit of context, maybe you need it later for reporting
7091: a bug. Next, run:
7092:
7093: MAKE_JOBS_SAFE=no bmake clean build
7094:
7095: If that succeeds, file a bug report against the pkgsrc package, including the
7096: exact error message and the contents of your mk.conf file.
7097:
1.173 rillig 7098: 21.5.3.3. Symlinks
7099:
7100: Pkgsrc does not work reliably if any of LOCALBASE, VARBASE or WRKDIR contains a
7101: symlink. Since 2019Q2, the pkgsrc bootstrap program prevents installing pkgsrc
7102: in symlink-based directories. Existing pkgsrc installations are not checked for
7103: symlinks though.
7104:
7105: The "No such file or directory" error messages are a typical symptom of
7106: symlinks, and it's quite difficult to find out that this is the actual cause.
7107:
7108: 21.5.3.4. Stale working directories
7109:
7110: When building a hierarchy of packages, it may happen that one package is built
7111: and then pkgsrc is updated. This situation can provoke various hard to diagnose
7112: build errors. To clean up the situation:
7113:
1.223 nia 7114: $ (cd ../../ && cat mk/bsd.pkg.mk >/dev/null && rm -rf */*/work)
1.173 rillig 7115:
1.223 nia 7116: (The only purpose of the bsd.pkg.mk is to prevent running this command in the
7117: wrong directory.)
1.173 rillig 7118:
7119: If you have set WRKOBJDIR in mk.conf, remove that directory as well.
7120:
7121: 21.5.3.5. Other possible reasons
7122:
7123: On platforms other than BSD, third-party packages are installed in /usr/
7124: include, together with the base system. This means that pkgsrc cannot
7125: distinguish between headers provided by the base system (which it needs) and
7126: headers from third-party packages (which are often included in pkgsrc as well).
7127: This can lead to subtle version mismatches.
7128:
7129: In pkgsrc installations that have been active for several years, it may happen
7130: that some files are manually deleted. To exclude this unlikely reason, run
7131: pkg_admin check.
7132:
7133: It may help to run pkg_admin rebuild-tree to check/fix dependencies.
7134:
7135: If all of the above doesn't help, see Chapter 2, Getting help for contact
7136: information. Be prepared to describe what you have tried so far and what any
7137: error messages were.
7138:
1.172 rillig 7139: 21.5.4. Undefined reference to "..."
1.1 dsieger 7140:
7141: This error message often means that a package did not link to a shared library
7142: it needs. The following functions are known to cause this error message over
7143: and over.
7144:
7145: +-----------------------------------------------------+
7146: | Function |Library |Affected platforms|
7147: |-------------------------+--------+------------------|
7148: |accept, bind, connect |-lsocket|Solaris |
7149: |-------------------------+--------+------------------|
7150: |crypt |-lcrypt |DragonFly, NetBSD |
7151: |-------------------------+--------+------------------|
7152: |dlopen, dlsym |-ldl |Linux |
7153: |-------------------------+--------+------------------|
7154: |gethost* |-lnsl |Solaris |
7155: |-------------------------+--------+------------------|
7156: |inet_aton |-lresolv|Solaris |
7157: |-------------------------+--------+------------------|
7158: |nanosleep, sem_*, timer_*|-lrt |Solaris |
7159: |-------------------------+--------+------------------|
7160: |openpty |-lutil |Linux |
7161: +-----------------------------------------------------+
7162:
1.223 nia 7163: To fix these linker errors, it is often sufficient to add LIBS.OperatingSystem+
7164: = -lfoo to the package Makefile and then run bmake clean; bmake.
1.1 dsieger 7165:
1.223 nia 7166: 21.5.4.1. The SunPro compiler and inline functions
1.1 dsieger 7167:
7168: When you are using the SunPro compiler, there is another possibility. That
7169: compiler cannot handle the following code:
7170:
7171: extern int extern_func(int);
7172:
7173: static inline int
7174: inline_func(int x)
7175: {
7176: return extern_func(x);
7177: }
7178:
7179: int main(void)
7180: {
7181: return 0;
7182: }
7183:
7184: It generates the code for inline_func even if that function is never used. This
7185: code then refers to extern_func, which can usually not be resolved. To solve
7186: this problem you can try to tell the package to disable inlining of functions.
7187:
1.228 gutterid 7188: 21.5.4.2. Missing atomic functions
7189:
7190: When building for older machine architectures (e.g., i386, PowerPC), builds may
7191: fail because the package expects modern 64-bit atomic functions which the
7192: underlying hardware either doesn't support, or will only support with specific
7193: compiler flags. This is generally handled via inclusion of mk/atomic64.mk.
7194:
1.172 rillig 7195: 21.5.5. Running out of memory
1.1 dsieger 7196:
7197: Sometimes packages fail to build because the compiler runs into an operating
7198: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.223 nia 7199: told to unlimit the resources. The allowed values are any combination of "
7200: cputime", "datasize", "memorysize", "stacksize" and "virtualsize". Setting this
7201: variable is similar to running the shell builtin ulimit command to raise the
7202: maximum data segment size or maximum stack size of a process, respectively, to
7203: their hard limits.
1.1 dsieger 7204:
1.154 rillig 7205: 21.6. The install phase
1.1 dsieger 7206:
1.154 rillig 7207: 21.6.1. Creating needed directories
1.1 dsieger 7208:
7209: The BSD-compatible install supplied with some operating systems cannot create
7210: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
7211: like this:
7212:
7213: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
7214: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
7215:
1.223 nia 7216: Instead of running the install commands directly, you can also append "dir1
7217: dir2" to the INSTALLATION_DIRS variable, which will automatically do the right
7218: thing.
1.1 dsieger 7219:
1.154 rillig 7220: 21.6.2. Where to install documentation
1.1 dsieger 7221:
7222: In general, documentation should be installed into ${PREFIX}/share/doc/$
1.223 nia 7223: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME_NOREV} (the latter includes the
7224: version number of the package).
1.1 dsieger 7225:
7226: Many modern packages using GNU autoconf allow to set the directory where HTML
7227: documentation is installed with the "--with-html-dir" option. Sometimes using
7228: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
1.223 nia 7229: share/doc/html or other places. In pkgsrc, the HTML documentation should go
7230: into the package-specific directory, just like any other documentation.
1.1 dsieger 7231:
7232: An exception to the above is that library API documentation generated with the
7233: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
7234: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
7235: can be recognized from files ending in .devhelp or .devhelp2. (It is also
7236: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
7237: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
7238: then, no additional subdirectory level is allowed in this case. This is usually
7239: achieved by using "--with-html-dir=${PREFIX}/share/doc". ${PREFIX}/share/
7240: gtk-doc is preferred though.)
7241:
1.154 rillig 7242: 21.6.3. Installing highscore files
1.1 dsieger 7243:
7244: Certain packages, most of them in the games category, install a score file that
7245: allows all users on the system to record their highscores. In order for this to
7246: work, the binaries need to be installed setgid and the score files owned by the
1.36 wiz 7247: appropriate group and/or owner (traditionally the "games" user/group). Set
7248: USE_GAMESGROUP to yes to support this. The following variables, documented in
7249: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100 leot 7250: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
7251: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
7252:
7253: An example that illustrates some of the variables described above is games/
7254: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
7255: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
7256: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
7257: to install setgid the game binary:
7258:
7259: USE_GAMESGROUP= yes
7260:
7261: BUILD_DEFS+= VARBASE
7262:
7263: OWN_DIRS_PERMS+= ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
7264: REQD_FILES_PERMS+= /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
7265: SPECIAL_PERMS+= ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
7266:
7267: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
7268: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
7269: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1 dsieger 7270:
1.14 jmcneill 7271: A package should therefore never hard code file ownership or access permissions
1.100 leot 7272: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
7273: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1 dsieger 7274:
1.154 rillig 7275: 21.6.4. Adding DESTDIR support to packages
1.4 rillig 7276:
1.14 jmcneill 7277: DESTDIR support means that a package installs into a staging directory, not the
7278: final location of the files. Then a binary package is created which can be used
7279: for installation as usual. There are two ways: Either the package must install
1.25 wiz 7280: as root ("destdir") or the package can install as non-root user ("user-destdir"
7281: ).
1.14 jmcneill 7282:
1.113 leot 7283: * PKG_DESTDIR_SUPPORT has to be set to "destdir" or "user-destdir". By
7284: default PKG_DESTDIR_SUPPORT is set to "user-destdir" to help catching more
7285: potential packaging problems. If bsd.prefs.mk is included in the Makefile,
7286: PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14 jmcneill 7287:
1.4 rillig 7288: * All installation operations have to be prefixed with ${DESTDIR}.
7289:
7290: * automake gets this DESTDIR mostly right automatically. Many manual rules
7291: and pre/post-install often are incorrect; fix them.
7292:
1.17 imil 7293: * If files are installed with special owner/group use SPECIAL_PERMS.
1.4 rillig 7294:
7295: * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
7296:
1.154 rillig 7297: 21.6.5. Packages with hardcoded paths to other interpreters
1.1 dsieger 7298:
7299: Your package may also contain scripts with hardcoded paths to other
1.203 nia 7300: interpreters besides (or as well as) Perl. To correct the full pathname to the
1.1 dsieger 7301: script interpreter, you need to set the following definitions in your Makefile
7302: (we shall use tclsh in this example):
7303:
7304: REPLACE_INTERPRETER+= tcl
7305: REPLACE.tcl.old= .*/bin/tclsh
7306: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
7307: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
7308: # relative to ${WRKSRC}, just as in REPLACE_PERL
7309:
1.203 nia 7310: 21.6.6. Packages installing Perl modules
1.1 dsieger 7311:
7312: Makefiles of packages providing perl5 modules should include the Makefile
7313: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
7314: standard perl configuration for such modules as well as various hooks to tune
7315: this configuration. See comments in this file for details.
7316:
7317: Perl5 modules will install into different places depending on the version of
7318: perl used during the build process. To address this, pkgsrc will append lines
7319: to the PLIST corresponding to the files listed in the installed .packlist file
7320: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48 wiz 7321: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
7322: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1 dsieger 7323:
1.48 wiz 7324: PERL5_PACKLIST= auto/Pg/.packlist
1.1 dsieger 7325:
1.48 wiz 7326: The perl5 config variables installarchlib, installscript, installvendorbin,
7327: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
7328: and installvendorman3dir represent those locations in which components of perl5
7329: modules may be installed, provided as variable with uppercase and prefixed with
7330: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
7331: have a packlist. These variables are also substituted for in the PLIST as
7332: uppercase prefixed with PERL5_SUB_.
1.1 dsieger 7333:
1.154 rillig 7334: 21.6.7. Packages installing info files
1.1 dsieger 7335:
7336: Some packages install info files or use the "makeinfo" or "install-info"
7337: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
7338: and DEINSTALL scripts will be generated to handle registration of the info
7339: files in the Info directory file. The "install-info" command used for the info
7340: files registration is either provided by the system, or by a special purpose
7341: package automatically added as dependency if needed.
7342:
7343: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
7344: located. PKGINFODIR defaults to "info" and can be overridden by the user.
7345:
7346: The info files for the package should be listed in the package PLIST; however
7347: any split info files need not be listed.
7348:
7349: A package which needs the "makeinfo" command at build time must add "makeinfo"
7350: to USE_TOOLS in its Makefile. If a minimum version of the "makeinfo" command is
7351: needed it should be noted with the TEXINFO_REQD variable in the package
7352: Makefile. By default, a minimum version of 3.12 is required. If the system does
7353: not provide a makeinfo command or if it does not match the required minimum, a
7354: build dependency on the devel/gtexinfo package will be added automatically.
7355:
7356: The build and installation process of the software provided by the package
7357: should not use the install-info command as the registration of info files is
1.25 wiz 7358: the task of the package INSTALL script, and it must use the appropriate
1.1 dsieger 7359: makeinfo command.
7360:
7361: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
7362: the install-info and makeinfo commands in a directory listed early in PATH.
7363:
7364: The script overriding install-info has no effect except the logging of a
7365: message. The script overriding makeinfo logs a message and according to the
7366: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
7367: error.
7368:
1.154 rillig 7369: 21.6.8. Packages installing man pages
1.1 dsieger 7370:
7371: All packages that install manual pages should install them into the same
7372: directory, so that there is one common place to look for them. In pkgsrc, this
7373: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.25 wiz 7374: packages. The default for PKGMANDIR is "man". Another often-used value is "
7375: share/man".
1.1 dsieger 7376:
7377: Note
7378:
7379: The support for a custom PKGMANDIR is far from complete.
7380:
7381: The PLIST files can just use man/ as the top level directory for the man page
7382: file entries, and the pkgsrc framework will convert as needed. In all other
7383: places, the correct PKGMANDIR must be used.
7384:
7385: Packages that are configured with GNU_CONFIGURE set as "yes", by default will
7386: use the ./configure --mandir switch to set where the man pages should be
7387: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
7388: {PKGMANDIR}.
7389:
7390: Packages that use GNU_CONFIGURE but do not use --mandir, can set
7391: CONFIGURE_HAS_MANDIR to "no". Or if the ./configure script uses a non-standard
7392: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
7393:
1.184 rillig 7394: See Section 19.5, "Man page compression" for information on installation of
1.1 dsieger 7395: compressed manual pages.
7396:
1.203 nia 7397: 21.6.9. Packages installing X11 fonts
1.1 dsieger 7398:
7399: If a package installs font files, you will need to rebuild the fonts database
7400: in the directory where they get installed at installation and deinstallation
7401: time. This can be automatically done by using the pkginstall framework.
7402:
7403: You can list the directories where fonts are installed in the FONTS_DIRS.type
7404: variables, where type can be one of "ttf", "type1" or "x11". Also make sure
7405: that the database file fonts.dir is not listed in the PLIST.
7406:
7407: Note that you should not create new directories for fonts; instead use the
7408: standard ones to avoid that the user needs to manually configure his X server
7409: to find them.
7410:
1.203 nia 7411: 21.6.10. Packages installing SGML or XML data
1.1 dsieger 7412:
7413: If a package installs SGML or XML data files that need to be registered in
7414: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
7415: extra steps:
7416:
7417: 1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
7418: care of registering those files in system-wide catalogs at installation and
7419: deinstallation time.
7420:
7421: 2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
7422: package.
7423:
7424: 3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
7425: package.
7426:
7427: 4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
7428: These come in groups of three strings; see xmlcatmgr(1) for more
7429: information (specifically, arguments recognized by the 'add' action). Note
7430: that you will normally not use this variable.
7431:
7432: 5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
7433: come in groups of three strings; see xmlcatmgr(1) for more information
7434: (specifically, arguments recognized by the 'add' action). Note that you
7435: will normally not use this variable.
7436:
1.203 nia 7437: 21.6.11. Packages installing extensions to the MIME database
1.1 dsieger 7438:
7439: If a package provides extensions to the MIME database by installing .xml files
7440: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
7441: ensure that the database is kept consistent with respect to these new files:
7442:
7443: 1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
7444: buildlink3.mk file from this same directory, which is reserved for
7445: inclusion from other buildlink3.mk files). It takes care of rebuilding the
7446: MIME database at installation and deinstallation time, and disallows any
7447: access to it directly from the package.
7448:
1.25 wiz 7449: 2. Check the PLIST and remove any entries under the share/mime directory,
1.1 dsieger 7450: except for files saved under share/mime/packages. The former are handled
7451: automatically by the update-mime-database program, but the latter are
7452: package-dependent and must be removed by the package that installed them in
7453: the first place.
7454:
7455: 3. Remove any share/mime/* directories from the PLIST. They will be handled by
7456: the shared-mime-info package.
7457:
1.203 nia 7458: 21.6.12. Packages using intltool
1.1 dsieger 7459:
7460: If a package uses intltool during its build, add intltool to the USE_TOOLS,
7461: which forces it to use the intltool package provided by pkgsrc, instead of the
7462: one bundled with the distribution file.
7463:
7464: This tracks intltool's build-time dependencies and uses the latest available
7465: version; this way, the package benefits of any bug fixes that may have appeared
7466: since it was released.
7467:
1.203 nia 7468: 21.6.13. Packages installing startup scripts
1.1 dsieger 7469:
7470: If a package contains a rc.d script, it won't be copied into the startup
7471: directory by default, but you can enable it, by adding the option
1.4 rillig 7472: PKG_RCD_SCRIPTS=YES in mk.conf. This option will copy the scripts into /etc/
7473: rc.d when a package is installed, and it will automatically remove the scripts
7474: when the package is deinstalled.
1.1 dsieger 7475:
1.203 nia 7476: 21.6.14. Packages installing TeX modules
1.1 dsieger 7477:
7478: If a package installs TeX packages into the texmf tree, the ls-R database of
7479: the tree needs to be updated.
7480:
7481: Note
7482:
1.23 jakllsch 7483: Except the main TeX packages such as kpathsea, packages should install files
7484: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1 dsieger 7485:
1.23 jakllsch 7486: 1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
7487: ls-R database at installation and deinstallation time.
1.1 dsieger 7488:
1.23 jakllsch 7489: 2. If your package installs files into a texmf tree other than the one at $
7490: {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
7491: trees that need database update.
1.1 dsieger 7492:
7493: If your package also installs font map files that need to be registered
1.30 dholland 7494: using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
7495: and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then
7496: updmap will be run automatically at installation/deinstallation to enable/
7497: disable font map files for TeX output drivers.
1.1 dsieger 7498:
7499: 3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30 dholland 7500: be removed only by the kpathsea package.
1.1 dsieger 7501:
1.203 nia 7502: 21.6.15. Packages supporting running binaries in emulation
1.1 dsieger 7503:
7504: There are some packages that provide libraries and executables for running
7505: binaries from a one operating system on a different one (if the latter supports
7506: it). One example is running Linux binaries on NetBSD.
7507:
7508: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
7509:
7510: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
7511: if all libraries for each installed executable can be found by the dynamic
7512: linker. Since the standard dynamic linker is run, this fails for emulation
7513: packages, because the libraries used by the emulation are not in the standard
7514: directories.
7515:
1.203 nia 7516: 21.6.16. Packages installing hicolor icons
1.1 dsieger 7517:
7518: If a package installs images under the share/icons/hicolor and/or updates the
7519: share/icons/hicolor/icon-theme.cache database, you need to take some extra
7520: steps to make sure that the shared theme directory is handled appropriately and
7521: that the cache database is rebuilt:
7522:
7523: 1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
7524:
7525: 2. Check the PLIST and remove the entry that refers to the theme cache.
7526:
7527: 3. Ensure that the PLIST does not remove the shared icon directories from the
7528: share/icons/hicolor hierarchy because they will be handled automatically.
7529:
7530: The best way to verify that the PLIST is correct with respect to the last two
7531: points is to regenerate it using make print-PLIST.
7532:
1.203 nia 7533: 21.6.17. Packages installing desktop files
1.1 dsieger 7534:
7535: If a package installs .desktop files under share/applications and these include
1.54 rodent 7536: MIME information (MimeType key), you need to take extra steps to ensure that
7537: they are registered into the MIME database:
1.1 dsieger 7538:
7539: 1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
7540:
7541: 2. Check the PLIST and remove the entry that refers to the share/applications/
7542: mimeinfo.cache file. It will be handled automatically.
7543:
7544: The best way to verify that the PLIST is correct with respect to the last point
7545: is to regenerate it using make print-PLIST.
7546:
1.154 rillig 7547: 21.7. Marking packages as having problems
1.1 dsieger 7548:
1.23 jakllsch 7549: In some cases one does not have the time to solve a problem immediately. In
7550: this case, one can plainly mark a package as broken. For this, one just sets
7551: the variable BROKEN to the reason why the package is broken (similar to the
1.162 rillig 7552: PKG_FAIL_REASON variable). A user trying to build the package will immediately
7553: be shown this message, and the build will not be even tried.
1.1 dsieger 7554:
1.23 jakllsch 7555: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1 dsieger 7556:
1.184 rillig 7557: Chapter 22. GNOME packaging and porting
7558:
7559: Table of Contents
7560:
7561: 22.1. Meta packages
7562: 22.2. Packaging a GNOME application
7563: 22.3. Updating GNOME to a newer version
7564: 22.4. Patching guidelines
7565:
7566: Quoting GNOME's web site:
7567:
7568: The GNOME project provides two things: The GNOME desktop environment, an
7569: intuitive and attractive desktop for users, and the GNOME development
7570: platform, an extensive framework for building applications that integrate
7571: into the rest of the desktop.
7572:
7573: pkgsrc provides a seamless way to automatically build and install a complete
7574: GNOME environment under many different platforms. We can say with confidence
7575: that pkgsrc is one of the most advanced build and packaging systems for GNOME
7576: due to its included technologies buildlink3, the wrappers and tools framework
7577: and automatic configuration file management. Lots of efforts are put into
7578: achieving a completely clean deinstallation of installed software components.
7579:
7580: Given that pkgsrc is NetBSD's official packaging system, the above also means
7581: that great efforts are put into making GNOME work under this operating system.
7582:
7583: This chapter is aimed at pkgsrc developers and other people interested in
7584: helping our GNOME porting and packaging efforts. It provides instructions on
7585: how to manage the existing packages and some important information regarding
7586: their internals.
7587:
7588: 22.1. Meta packages
7589:
7590: pkgsrc includes three GNOME-related meta packages:
7591:
7592: * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
7593: includes the necessary bits to get it to boot correctly, although it may
7594: lack important functionality for daily operation. The idea behind this
7595: package is to let end users build their own configurations on top of this
7596: one, first installing this meta package to achieve a functional setup and
7597: then adding individual applications.
7598:
7599: * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
7600: desktop as defined by the GNOME project; this is based on the components
7601: distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
7602: directories of the official FTP server. Developer-only tools found in those
7603: directories are not installed unless required by some other component to
7604: work properly. Similarly, packages from the bindings set (bindings/x.y/
7605: x.y.z/sources) are not pulled in unless required as a dependency for an
7606: end-user component. This package "extends" meta-pkgs/gnome-base.
7607:
7608: * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
7609: component when fetched from the CVS repository. These are required to let
7610: the autogen.sh scripts work appropriately.
7611:
7612: In all these packages, the DEPENDS lines are sorted in a way that eases
7613: updates: a package may depend on other packages listed before it but not on any
7614: listed after it. It is very important to keep this order to ease updates so...
7615: do not change it to alphabetical sorting!
7616:
7617: 22.2. Packaging a GNOME application
7618:
7619: Almost all GNOME applications are written in C and use a common set of tools as
7620: their build system. Things get different with the new bindings to other
7621: languages (such as Python), but the following will give you a general idea on
7622: the minimum required tools:
7623:
7624: * Almost all GNOME applications use the GNU Autotools as their build system.
7625: As a general rule you will need to tell this to your package:
7626:
1.223 nia 7627: GNU_CONFIGURE= yes
7628: USE_LIBTOOL= yes
7629: USE_TOOLS+= gmake
1.184 rillig 7630:
7631: * If the package uses pkg-config to detect dependencies, add this tool to the
7632: list of required utilities:
7633:
1.223 nia 7634: USE_TOOLS+= pkg-config
1.184 rillig 7635:
7636: Also use pkgtools/verifypc at the end of the build process to ensure that
7637: you did not miss to specify any dependency in your package and that the
7638: version requirements are all correct.
7639:
7640: * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
7641: handle dependencies and to force the package to use the latest available
7642: version.
7643:
7644: * If the package uses gtk-doc (a documentation generation utility), do not
7645: add a dependency on it. The tool is rather big and the distfile should come
7646: with pregenerated documentation anyway; if it does not, it is a bug that
7647: you ought to report. For such packages you should disable gtk-doc (unless
7648: it is the default):
7649:
1.223 nia 7650: CONFIGURE_ARGS+= --disable-gtk-doc
1.184 rillig 7651:
7652: The default location of installed HTML files (share/gtk-doc/<package-name>)
7653: is correct and should not be changed unless the package insists on
7654: installing them somewhere else. Otherwise programs as devhelp will not be
7655: able to open them. You can do that with an entry similar to:
1.1 dsieger 7656:
1.223 nia 7657: CONFIGURE_ARGS+= --with-html-dir=${PREFIX}/share/gtk-doc/...
1.1 dsieger 7658:
1.184 rillig 7659: GNOME uses multiple shared directories and files under the installation prefix
7660: to maintain databases. In this context, shared means that those exact same
7661: directories and files are used among several different packages, leading to
7662: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
7663: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
7664: your file lists and omitting shared files from them. If you find yourself doing
7665: those, your package is most likely incorrect.
1.1 dsieger 7666:
1.184 rillig 7667: The following table lists the common situations that result in using shared
7668: directories or files. For each of them, the appropriate solution is given.
7669: After applying the solution be sure to regenerate the package's file list with
7670: make print-PLIST and ensure it is correct.
1.1 dsieger 7671:
1.184 rillig 7672: Table 22.1. PLIST handling for GNOME packages
1.1 dsieger 7673:
1.184 rillig 7674: +-----------------------------------------------------------------------------+
7675: | If the package... | Then... |
7676: |-------------------------------------------+---------------------------------|
1.203 nia 7677: |Installs icons under the share/icons/ |See Section 21.6.16, "Packages |
7678: |hicolor hierarchy or updates share/icons/ |installing hicolor icons". |
1.184 rillig 7679: |hicolor/icon-theme.cache. | |
7680: |-------------------------------------------+---------------------------------|
1.203 nia 7681: | |See Section 21.6.11, "Packages |
1.184 rillig 7682: |Installs files under share/mime/packages. |installing extensions to the MIME|
7683: | |database". |
7684: |-------------------------------------------+---------------------------------|
1.203 nia 7685: |Installs .desktop files under share/ |See Section 21.6.17, "Packages |
1.184 rillig 7686: |applications and these include MIME |installing desktop files". |
7687: |information. | |
7688: +-----------------------------------------------------------------------------+
1.1 dsieger 7689:
7690:
1.184 rillig 7691: 22.3. Updating GNOME to a newer version
1.1 dsieger 7692:
1.184 rillig 7693: When seeing GNOME as a whole, there are two kinds of updates:
1.1 dsieger 7694:
1.184 rillig 7695: Major update
1.1 dsieger 7696:
1.184 rillig 7697: Given that there is still a very long way for GNOME 3 (if it ever appears),
7698: we consider a major update one that goes from a 2.X version to a 2.Y one,
7699: where Y is even and greater than X. These are hard to achieve because they
7700: introduce lots of changes in the components' code and almost all GNOME
7701: distfiles are updated to newer versions. Some of them can even break API
7702: and ABI compatibility with the previous major version series. As a result,
7703: the update needs to be done all at once to minimize breakage.
1.1 dsieger 7704:
1.184 rillig 7705: A major update typically consists of around 80 package updates and the
7706: addition of some new ones.
1.1 dsieger 7707:
1.184 rillig 7708: Minor update
1.1 dsieger 7709:
1.184 rillig 7710: We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
7711: one where Y is greater than X. These are easy to achieve because they do
7712: not update all GNOME components, can be done in an incremental way and do
7713: not break API nor ABI compatibility.
1.1 dsieger 7714:
1.184 rillig 7715: A minor update typically consists of around 50 package updates, although
7716: the numbers here may vary a lot.
1.1 dsieger 7717:
1.184 rillig 7718: In order to update the GNOME components in pkgsrc to a new stable release
7719: (either major or minor), the following steps should be followed:
1.1 dsieger 7720:
1.184 rillig 7721: 1. Get a list of all the tarballs that form the new release by using the
7722: following commands. These will leave the full list of the components'
7723: distfiles into the list.txt file:
1.1 dsieger 7724:
1.184 rillig 7725: % echo ls "*.tar.bz2" | \
7726: ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
7727: awk '{ print $9 }' >list.txt
7728: % echo ls "*.tar.bz2" | \
7729: ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
7730: awk '{ print $9 }' >>list.txt
1.1 dsieger 7731:
1.184 rillig 7732: 2. Open each meta package's Makefile and bump their version to the release you
7733: are updating them to. The three meta packages should be always consistent
7734: with versioning. Obviously remove any PKGREVISIONs that might be in them.
1.1 dsieger 7735:
1.184 rillig 7736: 3. For each meta package, update all its DEPENDS lines to match the latest
7737: versions as shown by the above commands. Do not list any newer version
7738: (even if found in the FTP) because the meta packages are supposed to list
7739: the exact versions that form a specific GNOME release. Exceptions are
7740: permitted here if a newer version solves a serious issue in the overall
7741: desktop experience; these typically come in the form of a revision bump in
7742: pkgsrc, not in newer versions from the developers.
1.1 dsieger 7743:
1.184 rillig 7744: Packages not listed in the list.txt file should be updated to the latest
7745: version available (if found in pkgsrc). This is the case, for example, of
7746: the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
7747: package.
1.1 dsieger 7748:
1.184 rillig 7749: 4. Generate a patch from the modified meta packages and extract the list of
7750: "new" lines. This will provide you an outline on what packages need to be
7751: updated in pkgsrc and in what order:
1.1 dsieger 7752:
1.184 rillig 7753: % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
1.1 dsieger 7754:
1.184 rillig 7755: 5. For major desktop updates it is recommended to zap all your installed
7756: packages and start over from scratch at this point.
1.1 dsieger 7757:
1.184 rillig 7758: 6. Now comes the longest step by far: iterate over the contents of todo.txt
7759: and update the packages listed in it in order. For major desktop updates
7760: none of these should be committed until the entire set is completed because
7761: there are chances of breaking not-yet-updated packages.
1.1 dsieger 7762:
1.184 rillig 7763: 7. Once the packages are up to date and working, commit them to the tree one
7764: by one with appropriate log messages. At the end, commit the three meta
7765: package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
7766: and pkgsrc/doc/TODO files.
1.1 dsieger 7767:
1.184 rillig 7768: 22.4. Patching guidelines
1.1 dsieger 7769:
1.184 rillig 7770: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
7771: it is very important that you always, always, always feed back any portability
7772: fixes you do to a GNOME package to the mainstream developers (see
7773: Section 12.3.5, "Feedback to the author"). This is the only way to get their
7774: attention on portability issues and to ensure that future versions can be built
7775: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
7776: updates are. Those developers in charge of issuing major GNOME updates will be
7777: grateful if you do that.
1.1 dsieger 7778:
1.200 cirnatda 7779: The most common places to report bugs are the GNOME's GitLab and the
7780: freedesktop.org's GitLab. Not all components use these to track bugs, but most
7781: of them do. Do not be short on your reports: always provide detailed
1.184 rillig 7782: explanations of the current failure, how it can be improved to achieve maximum
1.200 cirnatda 7783: portability and, if at all possible, provide a patch against the main Git
7784: branch. The more verbose you are, the higher chances of your patch being
7785: accepted.
1.1 dsieger 7786:
1.184 rillig 7787: Also, please avoid using preprocessor magic to fix portability issues. While
7788: the FreeBSD GNOME people are doing a great job in porting GNOME to their
7789: operating system, the official GNOME sources are now plagued by conditionals
7790: that check for __FreeBSD__ and similar macros. This hurts portability. Please
7791: see our patching guidelines (Section 12.3.4, "Patching guidelines") for more
7792: details.
1.1 dsieger 7793:
1.154 rillig 7794: Chapter 23. Submitting and Committing
1.1 dsieger 7795:
7796: Table of Contents
7797:
1.154 rillig 7798: 23.1. Submitting binary packages
7799: 23.2. Submitting source packages (for non-NetBSD-developers)
7800: 23.3. General notes when adding, updating, or removing packages
7801: 23.4. Commit Messages
7802: 23.5. Committing: Adding a package to CVS
7803: 23.6. Updating a package to a newer version
7804: 23.7. Renaming a package in pkgsrc
7805: 23.8. Moving a package in pkgsrc
1.1 dsieger 7806:
1.154 rillig 7807: 23.1. Submitting binary packages
1.1 dsieger 7808:
7809: Our policy is that we accept binaries only from pkgsrc developers to guarantee
7810: that the packages don't contain any trojan horses etc. This is not to annoy
7811: anyone but rather to protect our users! You're still free to put up your
7812: home-made binary packages and tell the world where to get them. NetBSD
1.154 rillig 7813: developers doing bulk builds and wanting to upload them please see Chapter 8,
1.66 asau 7814: Creating binary packages for everything in pkgsrc (bulk builds).
1.1 dsieger 7815:
1.154 rillig 7816: 23.2. Submitting source packages (for non-NetBSD-developers)
1.1 dsieger 7817:
1.218 nia 7818: Firstly, you can import new packages into pkgsrc-wip ("pkgsrc work-in-progress"
7819: ); see the homepage at https://pkgsrc.org/wip/ for details.
7820:
7821: Next, check that your package is complete, compiles and runs well; see
1.184 rillig 7822: Chapter 14, Creating a new pkgsrc package from scratch and the rest of this
1.218 nia 7823: document. Run the pkgtools/pkglint tool and fix any errors that appear.
7824:
7825: Finally, send a report to the pkgsrc bug tracking system, either with the
7826: send-pr(1) command, or if you don't have that, go to the web page https://
7827: www.NetBSD.org/support/send-pr.html, which contains some instructions and a
7828: link to a form where you can submit packages. The sysutils/gtk-send-pr package
7829: is also available as a substitute for either of the above two tools.
1.1 dsieger 7830:
7831: In the form of the problem report, the category should be "pkg", the synopsis
7832: should include the package name and version number, and the description field
7833: should contain a short description of your package (contents of the COMMENT
1.218 nia 7834: variable or DESCR file are OK).
1.1 dsieger 7835:
1.154 rillig 7836: 23.3. General notes when adding, updating, or removing packages
1.1 dsieger 7837:
7838: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
7839: CHANGES-YYYY. It's very important to keep this file up to date and conforming
7840: to the existing format, because it will be used by scripts to automatically
7841: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
7842: doc/TODO file and remove the entry for the package you updated or removed, in
7843: case it was mentioned there.
7844:
7845: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
7846: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
7847: that result from a dependency being updated should not be mentioned. In all
7848: other cases it's the developer's decision.
7849:
7850: There is a make target that helps in creating proper CHANGES-YYYY entries: make
7851: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
7852: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
7853: (to avoid having to resolve conflicts later-on) and then to cd to the package
7854: directory. For package updates, make changes-entry is enough. For new packages,
7855: or package moves or removals, set the CTYPE variable on the command line to
1.4 rillig 7856: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23 jakllsch 7857: your local login name is not the same as your NetBSD login name. The target
7858: also automatically removes possibly existing entries for the package in the
7859: TODO file. Don't forget to commit the changes, e.g. by using make
1.66 asau 7860: commit-changes-entry! If you are not using a checkout directly from
1.23 jakllsch 7861: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
7862: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1 dsieger 7863:
1.154 rillig 7864: 23.4. Commit Messages
1.130 wiz 7865:
7866: For several years, there have been mirrors of pkgsrc in fossil, git, and hg.
7867: Standard practise when using these tools is to make the first line of a commit
7868: message function as a summary that can be read without the rest, such as is
7869: commonly done with "git log --oneline". For this reason, we have the following
7870: guidelines for pkgsrc commit messages:
7871:
1.131 wiz 7872: * Start the commit message with a line that explains the big picture in 65
1.130 wiz 7873: characters or less. When a commit is for one package, include the name of
7874: the package. For updates, include the version to which it is updated.
7875:
7876: * Leave the next line empty.
7877:
7878: * Then come the details for the commit (changes in that package, reason for a
7879: change) and any relevant PRs. Wrap this section.
7880:
7881: Here is an example:
7882:
7883: libxslt: update to 1.0.30
7884:
7885: Changes since 1.0.29:
7886: ...
7887:
7888:
7889: Here is another example:
7890:
7891: mk/bsd.pkg.mk: enable SSP by default on NetBSD
7892:
7893: (rationale)
7894:
7895:
7896: Commit messages are final: no "cvs admin" is allowed on the pkgsrc repository
7897: to change commit messages.
7898:
1.154 rillig 7899: 23.5. Committing: Adding a package to CVS
1.1 dsieger 7900:
7901: This section is only of interest for pkgsrc developers with write access to the
1.34 wiz 7902: pkgsrc repository.
7903:
7904: When the package is finished, "cvs add" the files. Start by adding the
7905: directory and then files in the directory. Don't forget to add the new package
7906: to the category's Makefile. Make sure you don't forget any files; you can check
7907: by running "cvs status". An example:
7908:
7909: $ cd .../pkgsrc/category
7910: $ cvs add pkgname
7911: $ cd pkgname
7912: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
7913: $ cvs add patches/p*
7914: $ cvs status | less
1.35 wiz 7915: $ cvs commit
1.34 wiz 7916: $ cd ..
1.236 ! gutterid 7917: $ vi Makefile # add SUBDIR+=pkgname line
1.35 wiz 7918: $ cvs commit Makefile
1.66 asau 7919: $ cd pkgname
1.73 jnemeth 7920: $ make CTYPE=Added commit-changes-entry
1.1 dsieger 7921:
7922: The commit message of the initial import should include part of the DESCR file,
7923: so people reading the mailing lists know what the package is/does.
7924:
1.34 wiz 7925: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
7926:
7927: Previously, "cvs import" was suggested, but it was much easier to get wrong
7928: than "cvs add".
1.1 dsieger 7929:
1.154 rillig 7930: 23.6. Updating a package to a newer version
1.1 dsieger 7931:
7932: Please always put a concise, appropriate and relevant summary of the changes
7933: between old and new versions into the commit log when updating a package. There
7934: are various reasons for this:
7935:
7936: * A URL is volatile, and can change over time. It may go away completely or
7937: its information may be overwritten by newer information.
7938:
7939: * Having the change information between old and new versions in our CVS
7940: repository is very useful for people who use either cvs or anoncvs.
7941:
7942: * Having the change information between old and new versions in our CVS
7943: repository is very useful for people who read the pkgsrc-changes mailing
7944: list, so that they can make tactical decisions about when to upgrade the
7945: package.
7946:
7947: Please also recognize that, just because a new version of a package has been
7948: released, it should not automatically be upgraded in the CVS repository. We
7949: prefer to be conservative in the packages that are included in pkgsrc -
7950: development or beta packages are not really the best thing for most places in
7951: which pkgsrc is used. Please use your judgement about what should go into
7952: pkgsrc, and bear in mind that stability is to be preferred above new and
7953: possibly untested features.
7954:
1.154 rillig 7955: 23.7. Renaming a package in pkgsrc
1.21 snj 7956:
7957: Renaming packages is not recommended.
7958:
1.175 gutterid 7959: When renaming packages, be sure to fix any references to the old name in other
1.21 snj 7960: Makefiles, options, buildlink files, etc.
7961:
1.175 gutterid 7962: Also, when renaming a package, please add the package name and version pattern
1.167 leot 7963: (s) of the previous package to SUPERSEDES. This may be repeated for multiple
7964: renames. The new package would be an exact replacement. Example:
7965:
7966: SUPERSEDES+= p5-IO-Compress-Zlib<2.017
7967: SUPERSEDES+= optcomp-[0-9]*
1.21 snj 7968:
7969: Note that "successor" in the CHANGES-YYYY file doesn't necessarily mean that it
7970: supersedes, as that successor may not be an exact replacement but is a
7971: suggestion for the replaced functionality.
7972:
1.154 rillig 7973: 23.8. Moving a package in pkgsrc
1.21 snj 7974:
7975: It is preferred that packages are not renamed or moved, but if needed please
7976: follow these steps.
1.1 dsieger 7977:
7978: 1. Make a copy of the directory somewhere else.
7979:
7980: 2. Remove all CVS dirs.
7981:
7982: Alternatively to the first two steps you can also do:
7983:
7984: % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
7985:
7986: and use that for further work.
7987:
1.25 wiz 7988: 3. Fix CATEGORIES and any DEPENDS paths that just did "../package" instead of
1.1 dsieger 7989: "../../category/package".
7990:
1.21 snj 7991: 4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
7992: previous category/package pathname. The PREV_PKGPATH can be used by tools
7993: for doing an update using pkgsrc building; for example, it can search the
7994: pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
7995: the corresponding new PKGPATH for that moved package. Note that it may have
7996: multiple matches, so the tool should also check on the PKGBASE too. The
7997: PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
7998: PKGBASE stays the same.
7999:
8000: 5. cvs import the modified package in the new place.
1.1 dsieger 8001:
1.21 snj 8002: 6. Check if any package depends on it:
1.1 dsieger 8003:
8004: % cd /usr/pkgsrc
8005: % grep /package */*/Makefile* */*/buildlink*
8006:
1.21 snj 8007: 7. Fix paths in packages from step 5 to point to new location.
1.1 dsieger 8008:
1.21 snj 8009: 8. cvs rm (-f) the package at the old location.
1.1 dsieger 8010:
1.21 snj 8011: 9. Remove from oldcategory/Makefile.
1.1 dsieger 8012:
1.21 snj 8013: 10. Add to newcategory/Makefile.
1.1 dsieger 8014:
1.21 snj 8015: 11. Commit the changed and removed files:
1.1 dsieger 8016:
8017: % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
8018:
8019: (and any packages from step 5, of course).
8020:
1.154 rillig 8021: Chapter 24. Frequently Asked Questions
1.1 dsieger 8022:
8023: This section contains the answers to questions that may arise when you are
8024: writing a package. If you don't find your question answered here, first have a
8025: look in the other chapters, and if you still don't have the answer, ask on the
8026: pkgsrc-users mailing list.
8027:
1.154 rillig 8028: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
8029: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
8030: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.223 nia 8031: 24.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
8032: 24.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.232 gutterid 8033: the := inside it.
1.223 nia 8034: 24.6. Which mailing lists are there for package developers?
8035: 24.7. Where is the pkgsrc documentation?
8036: 24.8. I have a little time to kill. What shall I do?
1.1 dsieger 8037:
1.154 rillig 8038: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1 dsieger 8039:
8040: MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
1.223 nia 8041: (1).
8042:
8043: MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM when
8044: building the package.
8045:
8046: .MAKEFLAGS is an internal variable of bmake and should not be used by
8047: packages.
1.1 dsieger 8048:
1.154 rillig 8049: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1 dsieger 8050:
8051: MAKE is the path to the make(1) program that is used in the pkgsrc
1.223 nia 8052: infrastructure.
8053:
8054: GMAKE is the path to GNU Make, but you need to say USE_TOOLS+=gmake to
8055: use that.
8056:
8057: MAKE_PROGRAM is the path to the Make program that is used for building
8058: the package.
1.1 dsieger 8059:
1.154 rillig 8060: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1 dsieger 8061:
8062: CC is the path to the real C compiler, which can be configured by the
1.223 nia 8063: pkgsrc user.
1.1 dsieger 8064:
1.223 nia 8065: PKG_CC is the path to the compiler wrapper.
1.1 dsieger 8066:
1.223 nia 8067: PKGSRC_COMPILER is not a path to a compiler, but the type of compiler
8068: that should be used. See mk/compiler.mk for more information about the
8069: latter variable.
1.1 dsieger 8070:
1.223 nia 8071: 24.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1 dsieger 8072:
1.25 wiz 8073: For optimization reasons, some variables are only available in the "
8074: wrapper" phase and later. To "simulate" the wrapper phase, append
1.1 dsieger 8075: PKG_PHASE=wrapper to the above command.
8076:
1.223 nia 8077: 24.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1 dsieger 8078: the := inside it.
8079:
1.223 nia 8080: The := is not an assignment operator, even though it may look like one.
1.108 rillig 8081: Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
8082: is documented in the make(1) man page and which is commonly used in the
8083: form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
8084: string and new_string is package/. That's where the : and the = fall
8085: together.
1.1 dsieger 8086:
1.223 nia 8087: 24.6. Which mailing lists are there for package developers?
1.1 dsieger 8088:
8089: tech-pkg
8090:
8091: This is a list for technical discussions related to pkgsrc
8092: development, e.g. soliciting feedback for changes to pkgsrc
8093: infrastructure, proposed new features, questions related to porting
8094: pkgsrc to a new platform, advice for maintaining a package, patches
8095: that affect many packages, help requests moved from pkgsrc-users when
8096: an infrastructure bug is found, etc.
8097:
8098: pkgsrc-bugs
8099:
8100: All bug reports in category "pkg" sent with send-pr(1) appear here.
8101: Please do not report your bugs here directly; use one of the other
8102: mailing lists.
8103:
1.223 nia 8104: 24.7. Where is the pkgsrc documentation?
1.1 dsieger 8105:
8106: There are many places where you can find documentation about pkgsrc:
8107:
8108: * The pkgsrc guide (this document) is a collection of chapters that
8109: explain large parts of pkgsrc, but some chapters tend to be outdated.
8110: Which ones they are is hard to say.
8111:
1.174 leot 8112: * On the mailing list archives (see https://mail-index.NetBSD.org/),
8113: you can find discussions about certain features, announcements of new
1.1 dsieger 8114: parts of the pkgsrc infrastructure and sometimes even announcements
8115: that a certain feature has been marked as obsolete. The benefit here
8116: is that each message has a date appended to it.
8117:
8118: * Many of the files in the mk/ directory start with a comment that
8119: describes the purpose of the file and how it can be used by the
8120: pkgsrc user and package authors. An easy way to find this
8121: documentation is to run bmake help.
8122:
8123: * The CVS log messages are a rich source of information, but they tend
8124: to be highly abbreviated, especially for actions that occur often.
8125: Some contain a detailed description of what has changed, but they are
8126: geared towards the other pkgsrc developers, not towards an average
8127: pkgsrc user. They also only document changes, so if you don't know
8128: what has been before, these messages may not be worth too much to
8129: you.
8130:
8131: * Some parts of pkgsrc are only "implicitly documented", that is the
8132: documentation exists only in the mind of the developer who wrote the
8133: code. To get this information, use the cvs annotate command to see
8134: who has written it and ask on the tech-pkg mailing list, so that
8135: others can find your questions later (see above). To be sure that the
8136: developer in charge reads the mail, you may CC him or her.
8137:
1.223 nia 8138: 24.8. I have a little time to kill. What shall I do?
1.1 dsieger 8139:
8140: This is not really an FAQ yet, but here's the answer anyway.
8141:
8142: * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
8143: about newer versions of installed packages that are available, but
8144: not yet updated in pkgsrc.
8145:
1.198 leot 8146: * Browse pkgsrc/doc/TODO -- it contains a list of suggested new
8147: packages and a list of cleanups and enhancements for pkgsrc that
8148: would be nice to have.
1.1 dsieger 8149:
1.71 wiz 8150: * Review packages for which review was requested on the tech-pkg
8151: mailing list.
1.1 dsieger 8152:
8153: Part III. The pkgsrc infrastructure internals
8154:
8155: This part of the guide deals with everything from the infrastructure that is
8156: behind the interfaces described in the developer's guide. A casual package
8157: maintainer should not need anything from this part.
8158:
8159: Table of Contents
8160:
1.184 rillig 8161: 25. Design of the pkgsrc infrastructure
8162: 25.1. The meaning of variable definitions
8163: 25.2. Avoiding problems before they arise
8164: 25.3. Variable evaluation
8165: 25.3.1. At load time
8166: 25.3.2. At runtime
8167: 25.4. How can variables be specified?
8168: 25.5. Designing interfaces for Makefile fragments
8169: 25.5.1. Procedures with parameters
8170: 25.5.2. Actions taken on behalf of parameters
8171: 25.6. The order in which files are loaded
8172: 25.6.1. The order in bsd.prefs.mk
8173: 25.6.2. The order in bsd.pkg.mk
8174: 26. Regression tests
8175: 26.1. Running the regression tests
8176: 26.2. Adding a new regression test
8177: 26.2.1. Overridable functions
8178: 26.2.2. Helper functions
8179: 27. Porting pkgsrc
8180: 27.1. Porting pkgsrc to a new operating system
1.1 dsieger 8181:
1.184 rillig 8182: Chapter 25. Design of the pkgsrc infrastructure
1.1 dsieger 8183:
8184: Table of Contents
8185:
1.184 rillig 8186: 25.1. The meaning of variable definitions
8187: 25.2. Avoiding problems before they arise
8188: 25.3. Variable evaluation
8189: 25.3.1. At load time
8190: 25.3.2. At runtime
8191: 25.4. How can variables be specified?
8192: 25.5. Designing interfaces for Makefile fragments
8193: 25.5.1. Procedures with parameters
8194: 25.5.2. Actions taken on behalf of parameters
8195: 25.6. The order in which files are loaded
8196: 25.6.1. The order in bsd.prefs.mk
8197: 25.6.2. The order in bsd.pkg.mk
1.1 dsieger 8198:
8199: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
8200: fragment needs a properly specified interface. This chapter explains how such
8201: an interface looks like.
8202:
1.184 rillig 8203: 25.1. The meaning of variable definitions
1.1 dsieger 8204:
8205: Whenever a variable is defined in the pkgsrc infrastructure, the location and
8206: the way of definition provide much information about the intended use of that
8207: variable. Additionally, more documentation may be found in a header comment or
8208: in this pkgsrc guide.
8209:
8210: A special file is mk/defaults/mk.conf, which lists all variables that are
8211: intended to be user-defined. They are either defined using the ?= operator or
8212: they are left undefined because defining them to anything would effectively
8213: mean "yes". All these variables may be overridden by the pkgsrc user in the
8214: MAKECONF file.
8215:
8216: Outside this file, the following conventions apply: Variables that are defined
8217: using the ?= operator may be overridden by a package.
8218:
8219: Variables that are defined using the = operator may be used read-only at
8220: run-time.
8221:
8222: Variables whose name starts with an underscore must not be accessed outside the
8223: pkgsrc infrastructure at all. They may change without further notice.
8224:
8225: Note
8226:
8227: These conventions are currently not applied consistently to the complete pkgsrc
8228: infrastructure.
8229:
1.184 rillig 8230: 25.2. Avoiding problems before they arise
1.1 dsieger 8231:
8232: All variables that contain lists of things should default to being empty. Two
8233: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
8234: variables cannot simply be modified using the += operator in package Makefiles
8235: (or other files included by them), since there is no guarantee whether the
8236: variable is already set or not, and what its value is. In the case of
8237: DISTFILES, the packages "know" the default value and just define it as in the
8238: following example.
8239:
8240: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
8241:
8242: Because of the selection of this default value, the same value appears in many
8243: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
8244: value ("c") is so short that it doesn't stand out. Nevertheless it is mentioned
8245: in many files.
8246:
1.184 rillig 8247: 25.3. Variable evaluation
1.1 dsieger 8248:
1.184 rillig 8249: 25.3.1. At load time
1.1 dsieger 8250:
8251: Variable evaluation takes place either at load time or at runtime, depending on
8252: the context in which they occur. The contexts where variables are evaluated at
8253: load time are:
8254:
8255: * The right hand side of the := and != operators,
8256:
8257: * Make directives like .if or .for,
8258:
8259: * Dependency lines.
8260:
8261: A special exception are references to the iteration variables of .for loops,
8262: which are expanded inline, no matter in which context they appear.
8263:
8264: As the values of variables may change during load time, care must be taken not
8265: to evaluate them by accident. Typical examples for variables that should not be
8266: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
8267: clear, here is an example:
8268:
8269: CONFIGURE_ARGS= # none
8270: CFLAGS= -O
8271: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
8272:
8273: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
8274:
8275: CFLAGS+= -Wall
8276:
8277: This code shows how the use of the := operator can quickly lead to unexpected
8278: results. The first paragraph is fairly common code. The second paragraph
8279: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
8280: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
8281: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
8282: typically occur in completely unrelated files.
8283:
1.184 rillig 8284: 25.3.2. At runtime
1.1 dsieger 8285:
8286: After all the files have been loaded, the values of the variables cannot be
8287: changed anymore. Variables that are used in the shell commands are expanded at
8288: this point.
8289:
1.184 rillig 8290: 25.4. How can variables be specified?
1.1 dsieger 8291:
8292: There are many ways in which the definition and use of a variable can be
8293: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108 rillig 8294: policies. A package can be checked with pkglint -Wall to see whether it meets
8295: these rules.
1.1 dsieger 8296:
1.184 rillig 8297: 25.5. Designing interfaces for Makefile fragments
1.1 dsieger 8298:
8299: Most of the .mk files fall into one of the following classes. Cases where a
8300: file falls into more than one class should be avoided as it often leads to
8301: subtle bugs.
8302:
1.184 rillig 8303: 25.5.1. Procedures with parameters
1.1 dsieger 8304:
8305: In a traditional imperative programming language some of the .mk files could be
1.198 leot 8306: described as procedures. They take some input parameters and--after
8307: inclusion--provide a result in output parameters. Since all variables in
1.23 jakllsch 8308: Makefiles have global scope care must be taken not to use parameter names that
8309: have already another meaning. For example, PKGNAME is a bad choice for a
8310: parameter name.
1.1 dsieger 8311:
8312: Procedures are completely evaluated at preprocessing time. That is, when
8313: calling a procedure all input parameters must be completely resolvable. For
8314: example, CONFIGURE_ARGS should never be an input parameter since it is very
8315: likely that further text will be added after calling the procedure, which would
8316: effectively apply the procedure to only a part of the variable. Also,
1.108 rillig 8317: references to other variables will be modified after calling the procedure.
1.1 dsieger 8318:
8319: A procedure can declare its output parameters either as suitable for use in
8320: preprocessing directives or as only available at runtime. The latter
8321: alternative is for variables that contain references to other runtime
8322: variables.
8323:
8324: Procedures shall be written such that it is possible to call the procedure more
8325: than once. That is, the file must not contain multiple-inclusion guards.
8326:
8327: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
8328: To express that the parameters are evaluated at load time, they should be
8329: assigned using the := operator, which should be used only for this purpose.
8330:
1.184 rillig 8331: 25.5.2. Actions taken on behalf of parameters
1.1 dsieger 8332:
8333: Action files take some input parameters and may define runtime variables. They
8334: shall not define loadtime variables. There are action files that are included
8335: implicitly by the pkgsrc infrastructure, while other must be included
8336: explicitly.
8337:
8338: An example for action files is mk/subst.mk.
8339:
1.184 rillig 8340: 25.6. The order in which files are loaded
1.1 dsieger 8341:
8342: Package Makefiles usually consist of a set of variable definitions, and include
8343: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
8344: include various other *.mk files if they need to query the availability of
8345: certain features like the type of compiler or the X11 implementation. Due to
8346: the heavy use of preprocessor directives like .if and .for, the order in which
8347: the files are loaded matters.
8348:
8349: This section describes at which point the various files are loaded and gives
8350: reasons for that order.
8351:
1.184 rillig 8352: 25.6.1. The order in bsd.prefs.mk
1.1 dsieger 8353:
8354: The very first action in bsd.prefs.mk is to define some essential variables
8355: like OPSYS, OS_VERSION and MACHINE_ARCH.
8356:
1.4 rillig 8357: Then, the user settings are loaded from the file specified in MAKECONF, which
8358: is usually mk.conf. After that, those variables that have not been overridden
8359: by the user are loaded from mk/defaults/mk.conf.
1.1 dsieger 8360:
8361: After the user settings, the system settings and platform settings are loaded,
8362: which may override the user settings.
8363:
8364: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
8365: This only happens when building a package, so the proper variables must be used
8366: instead of the direct tool names.
8367:
8368: As the last steps, some essential variables from the wrapper and the package
8369: system flavor are loaded, as well as the variables that have been cached in
8370: earlier phases of a package build.
8371:
1.184 rillig 8372: 25.6.2. The order in bsd.pkg.mk
1.1 dsieger 8373:
8374: First, bsd.prefs.mk is loaded.
8375:
8376: Then, the various *-vars.mk files are loaded, which fill default values for
8377: those variables that have not been defined by the package. These variables may
8378: later be used even in unrelated files.
8379:
8380: Then, the file bsd.pkg.error.mk provides the target error-check that is added
8381: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
8382: DELAYED_WARNING_MSG.
8383:
8384: Then, the package-specific hacks from hacks.mk are included.
8385:
8386: Then, various other files follow. Most of them don't have any dependencies on
8387: what they need to have included before or after them, though some do.
8388:
8389: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
8390: restricts the use of these variables to all the files that have been included
8391: before. Appearances in later files will be silently ignored.
8392:
8393: Then, the files for the main targets are included, in the order of later
8394: execution, though the actual order should not matter.
8395:
8396: At last, some more files are included that don't set any interesting variables
8397: but rather just define make targets to be executed.
8398:
1.184 rillig 8399: Chapter 26. Regression tests
1.1 dsieger 8400:
8401: Table of Contents
8402:
1.184 rillig 8403: 26.1. Running the regression tests
8404: 26.2. Adding a new regression test
8405: 26.2.1. Overridable functions
8406: 26.2.2. Helper functions
1.1 dsieger 8407:
8408: The pkgsrc infrastructure consists of a large codebase, and there are many
8409: corners where every little bit of a file is well thought out, making pkgsrc
8410: likely to fail as soon as anything is changed near those parts. To prevent most
8411: changes from breaking anything, a suite of regression tests should go along
8412: with every important part of the pkgsrc infrastructure. This chapter describes
8413: how regression tests work in pkgsrc and how you can add new tests.
8414:
1.184 rillig 8415: 26.1. Running the regression tests
1.1 dsieger 8416:
1.25 wiz 8417: You first need to install the pkgtools/pkg_regress package, which provides the
1.1 dsieger 8418: pkg_regress command. Then you can simply run that command, which will run all
1.168 rillig 8419: tests in the regress/ directory.
1.1 dsieger 8420:
1.184 rillig 8421: 26.2. Adding a new regression test
1.1 dsieger 8422:
1.168 rillig 8423: Every directory in the regress/ directory that contains a file called spec is
1.1 dsieger 8424: considered a regression test. This file is a shell program that is included by
8425: the pkg_regress command. The following functions can be overridden to suit your
8426: needs.
8427:
1.184 rillig 8428: 26.2.1. Overridable functions
1.1 dsieger 8429:
1.108 rillig 8430: These functions do not take any parameters. Although they are called in "set -e
1.168 rillig 8431: " mode, they don't stop at the first failing command. See this Stack Overflow
1.108 rillig 8432: question for details.
1.1 dsieger 8433:
1.108 rillig 8434: do_setup
1.1 dsieger 8435:
8436: This function prepares the environment for the test. By default it does
8437: nothing.
8438:
1.108 rillig 8439: do_test
1.1 dsieger 8440:
8441: This function runs the actual test. By default, it calls TEST_MAKE with the
8442: arguments MAKEARGS_TEST and writes its output including error messages into
8443: the file TEST_OUTFILE.
8444:
1.108 rillig 8445: When defining this function, make sure that all output that needs to be
8446: checked is written to the correct output file. Example:
8447:
8448: do_test() {
8449: echo "Example output"
8450: } 1>$TEST_OUTFILE 2>&1
8451:
8452: check_result
1.1 dsieger 8453:
8454: This function is run after the test and is typically used to compare the
8455: actual output from the one that is expected. It can make use of the various
1.108 rillig 8456: helper functions from the next section. Example:
8457:
8458: check_result() {
8459: exit_status 0
8460: output_require "Example"
8461: output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
8462: output_prohibit "no such file or directory"
1.169 rillig 8463: regress_fail "expected $expected but got $actual for input $input"
1.108 rillig 8464: }
1.1 dsieger 8465:
1.108 rillig 8466: do_cleanup
1.1 dsieger 8467:
8468: This function cleans everything up after the test has been run. By default
8469: it does nothing.
8470:
1.184 rillig 8471: 26.2.2. Helper functions
1.1 dsieger 8472:
1.168 rillig 8473: regress_fail message...
8474:
8475: This function makes the test fail with the given error message.
8476:
1.108 rillig 8477: exit_status expected
1.1 dsieger 8478:
1.108 rillig 8479: This function compares the exitcode of the do_test function with its first
8480: parameter. If they differ, the test will fail.
1.1 dsieger 8481:
1.108 rillig 8482: output_require regex...
1.1 dsieger 8483:
8484: This function checks for each of its parameters if the output from do_test
1.108 rillig 8485: matches the extended regular expression. If it does not, the test will
8486: fail. Example:
8487:
8488: output_require "looks fine"
8489: output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1 dsieger 8490:
1.177 leot 8491: output_prohibit regex...
1.1 dsieger 8492:
8493: This function checks for each of its parameters if the output from do_test
8494: () does not match the extended regular expression. If any of the regular
8495: expressions matches, the test will fail.
8496:
1.184 rillig 8497: Chapter 27. Porting pkgsrc
1.1 dsieger 8498:
8499: Table of Contents
8500:
1.184 rillig 8501: 27.1. Porting pkgsrc to a new operating system
1.1 dsieger 8502:
8503: The pkgsrc system has already been ported to many operating systems, hardware
8504: architectures and compilers. This chapter explains the necessary steps to make
8505: pkgsrc even more portable.
8506:
1.184 rillig 8507: 27.1. Porting pkgsrc to a new operating system
1.1 dsieger 8508:
8509: To port pkgsrc to a new operating system (called MyOS in this example), you
8510: need to touch the following files:
8511:
8512: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
8513:
8514: This file contains some basic definitions, for example the name of the C
8515: compiler.
8516:
8517: mk/bsd.prefs.mk
8518:
1.212 wiz 8519: Insert code that defines the variables OPSYS, OS_VERSION, OPSYS_VERSION,
1.1 dsieger 8520: LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
8521: that appear in this file.
8522:
8523: mk/platform/MyOS.mk
8524:
8525: This file contains the platform-specific definitions that are used by
8526: pkgsrc. Start by copying one of the other files and edit it to your needs.
8527:
8528: mk/tools/tools.MyOS.mk
8529:
8530: This file defines the paths to all the tools that are needed by one or the
8531: other package in pkgsrc, as well as by pkgsrc itself. Find out where these
8532: tools are on your platform and add them.
8533:
8534: Now, you should be able to build some basic packages, like lang/perl5, shells/
8535: bash.
8536:
8537: Appendix A. A simple example package: bison
8538:
8539: Table of Contents
8540:
8541: A.1. files
8542: A.1.1. Makefile
8543: A.1.2. DESCR
8544: A.1.3. PLIST
8545: A.1.4. Checking a package with pkglint
8546: A.2. Steps for building, installing, packaging
8547:
8548: We checked to find a piece of software that wasn't in the packages collection,
1.25 wiz 8549: and picked GNU bison. Quite why someone would want to have bison when Berkeley
1.1 dsieger 8550: yacc is already present in the tree is beyond us, but it's useful for the
8551: purposes of this exercise.
8552:
8553: A.1. files
8554:
8555: A.1.1. Makefile
8556:
1.2 rillig 8557: # $NetBSD$
1.1 dsieger 8558: #
8559:
8560: DISTNAME= bison-1.25
8561: CATEGORIES= devel
1.171 rillig 8562: MASTER_SITES= ${MASTER_SITE_GNU:=bison/}
1.1 dsieger 8563:
1.30 dholland 8564: MAINTAINER= pkgsrc-users@NetBSD.org
1.174 leot 8565: HOMEPAGE= https://www.gnu.org/software/bison/bison.html
1.1 dsieger 8566: COMMENT= GNU yacc clone
8567:
8568: GNU_CONFIGURE= yes
1.47 wiz 8569: INFO_FILES= yes
1.1 dsieger 8570:
8571: .include "../../mk/bsd.pkg.mk"
8572:
8573: A.1.2. DESCR
8574:
8575: GNU version of yacc. Can make re-entrant parsers, and numerous other
8576: improvements. Why you would want this when Berkeley yacc(1) is part
8577: of the NetBSD source tree is beyond me.
8578:
8579: A.1.3. PLIST
8580:
1.2 rillig 8581: @comment $NetBSD$
1.1 dsieger 8582: bin/bison
8583: man/man1/bison.1.gz
8584: share/bison.simple
8585: share/bison.hairy
8586:
8587: A.1.4. Checking a package with pkglint
8588:
8589: The NetBSD package system comes with pkgtools/pkglint which helps to check the
8590: contents of these files. After installation it is quite easy to use, just
1.171 rillig 8591: change to the directory of the package you wish to examine and run pkglint:
1.1 dsieger 8592:
8593: $ pkglint
1.171 rillig 8594: ERROR: Makefile: Each package must define its LICENSE.
8595: WARN: Makefile:9: HOMEPAGE should migrate from http to https.
8596: NOTE: PLIST:3: The .gz extension is unnecessary for manual pages.
8597: WARN: PLIST:5: "share/bison.hairy" should be sorted before "share/bison.simple".
8598: 1 error, 2 warnings and 1 note found.
8599: (Run "pkglint -e" to show explanations.)
8600: (Run "pkglint -fs" to show what can be fixed automatically.)
1.172 rillig 8601: (Run "pkglint -F" to automatically fix some issues.)
1.1 dsieger 8602:
8603: Depending on the supplied command line arguments (see pkglint(1)), more checks
1.170 rillig 8604: will be performed. Use e.g. pkglint -Wall for a very thorough check.
1.1 dsieger 8605:
8606: A.2. Steps for building, installing, packaging
8607:
8608: Create the directory where the package lives, plus any auxiliary directories:
8609:
8610: # cd /usr/pkgsrc/lang
8611: # mkdir bison
8612: # cd bison
8613: # mkdir patches
8614:
1.184 rillig 8615: Create Makefile, DESCR and PLIST (see Chapter 12, Package components - files,
1.1 dsieger 8616: directories and contents) then continue with fetching the distfile:
8617:
8618: # make fetch
8619: >> bison-1.25.tar.gz doesn't seem to exist on this system.
8620: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
8621: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8622: ftp: Error retrieving file: 500 Internal error
8623:
8624: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
8625: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8626: ftp: Error retrieving file: 500 Internal error
8627:
8628: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
8629: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8630: Successfully retrieved file.
8631:
8632: Generate the checksum of the distfile into distinfo:
8633:
8634: # make makedistinfo
8635:
8636: Now compile:
8637:
8638: # make
8639: >> Checksum OK for bison-1.25.tar.gz.
8640: ===> Extracting for bison-1.25
8641: ===> Patching for bison-1.25
8642: ===> Ignoring empty patch directory
8643: ===> Configuring for bison-1.25
8644: creating cache ./config.cache
8645: checking for gcc... cc
8646: checking whether we are using GNU C... yes
8647: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
8648: checking how to run the C preprocessor... cc -E
8649: checking for minix/config.h... no
8650: checking for POSIXized ISC... no
8651: checking whether cross-compiling... no
8652: checking for ANSI C header files... yes
8653: checking for string.h... yes
8654: checking for stdlib.h... yes
8655: checking for memory.h... yes
8656: checking for working const... yes
8657: checking for working alloca.h... no
8658: checking for alloca... yes
8659: checking for strerror... yes
8660: updating cache ./config.cache
8661: creating ./config.status
8662: creating Makefile
8663: ===> Building for bison-1.25
8664: 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
8665: 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
8666: 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
8667: 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
8668: 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
8669: 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
8670: 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
8671: 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
8672: 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
8673: 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
8674: 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
8675: 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
8676: 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
8677: 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
8678: 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
8679: 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
8680: 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
8681: 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
8682: 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
8683: 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
8684: 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
8685: 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
8686: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
8687: rm -f bison.s1
8688: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
8689:
8690: Everything seems OK, so install the files:
8691:
8692: # make install
8693: >> Checksum OK for bison-1.25.tar.gz.
8694: ===> Installing for bison-1.25
8695: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
8696: rm -f /usr/pkg/bin/bison
8697: cd /usr/pkg/share; rm -f bison.simple bison.hairy
8698: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
8699: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
8700: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
8701: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
8702: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
8703: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
8704: ===> Registering installation for bison-1.25
8705:
8706: You can now use bison, and also - if you decide so - remove it with pkg_delete
8707: bison. Should you decide that you want a binary package, do this now:
8708:
8709: # make package
8710: >> Checksum OK for bison-1.25.tar.gz.
8711: ===> Building package for bison-1.25
8712: Creating package bison-1.25.tgz
8713: Registering depends:.
8714: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
8715:
8716: Now that you don't need the source and object files any more, clean up:
8717:
8718: # make clean
8719: ===> Cleaning for bison-1.25
8720:
1.207 leot 8721: Appendix B. Security hardening
8722:
8723: Table of Contents
8724:
8725: B.1. Mechanisms
8726: B.1.1. Enabled by default
8727: B.1.2. Not enabled by default
8728: B.2. Caveats
8729: B.2.1. Problems with PKGSRC_MKPIE
8730: B.2.2. Problems with PKGSRC_USE_FORTIFY
8731: B.2.3. Problems with PKGSRC_USE_RELRO
8732: B.2.4. Problems with PKGSRC_USE_SSP
8733: B.3. Auditing the system
8734: B.3.1. Checking for PIE
8735: B.3.2. Checking for partial RELRO
8736: B.3.3. Checking for full RELRO
8737: B.3.4. Checking for SSP
8738:
8739: A number of mechanisms are available in pkgsrc to improve the security of the
8740: resulting system. This page describes the mechanisms, and gives hints about
8741: detecting and fixing problems.
8742:
8743: Mechanisms can be enabled individually in mk.conf, and are individually
8744: described below.
8745:
8746: Typically, a feature will cause some programs to fail to build or work when
8747: first enabled. This can be due to latent problems in the program, and can be
8748: due to other reasons. After enough testing to have confidence that user
8749: problems will be quite rare, individual mechanisms will be enabled by default.
8750:
8751: For each mechanism, see the Caveats section below for an explanation of what
8752: might go wrong at compile time and at run time, and how to notice and address
8753: these problems.
8754:
8755: B.1. Mechanisms
8756:
8757: B.1.1. Enabled by default
8758:
8759: B.1.1.1. PKGSRC_USE_FORTIFY
8760:
8761: This allows substitute wrappers to be used for some commonly used library
8762: functions that do not have built-in bounds checking - but could in some cases.
8763:
8764: Two mitigation levels are available:
8765:
8766: * "weak" only enables checks at compile-time.
8767:
8768: * "strong" enables checks at compile-time and runtime.
8769:
8770: "strong" has been enabled by default since pkgsrc-2017Q3.
8771:
8772: B.1.1.2. PKGSRC_USE_SSP
8773:
8774: This enables a stack-smashing protection mitigation. It is done by adding a
8775: guard variable to functions with vulnerable objects. The guards are initialized
8776: when a function is entered and then checked when the function exits. The guard
8777: check will fail and the program forcibly exited if the variable was modified in
8778: the meantime. This can happen in case of buffer overflows or memory corruption,
8779: and therefore exposing these bugs.
8780:
8781: Different mitigation levels are available:
8782:
8783: * "yes", which will only protect functions considered vulnerable by the
8784: compiler;
8785:
8786: * "all", which will protect every function;
8787:
8788: * "strong", the default, which will apply a better balance between the two
8789: settings above.
8790:
8791: This mitigation is supported by both GCC and clang. It may be supported in
8792: additional compilers, possibly under a different name. It is particularly
8793: useful for unsafe programming languages, such as C/C++.
8794:
8795: * "yes" is enabled by default where known supported since pkgsrc-2017Q3.
8796:
8797: * "strong" is enabled by default where known supported since pkgsrc-2021Q4.
8798:
8799: More details can be found here:
8800:
8801: * Buffer overflow protection on Wikipedia
8802:
8803: B.1.1.3. PKGSRC_MKPIE
8804:
8805: This requests the creation of PIE (Position Independent Executables) for all
8806: executables. The PIE mechanism is normally used for shared libraries, so that
8807: they can be loaded at differing addresses at runtime. PIE itself does not have
8808: useful security properties; however, it is necessary to fully leverage some,
8809: such as ASLR. Some operating systems support Address Space Layout Randomization
8810: (ASLR), which causes different addresses to be used each time a program is run.
8811: This makes it more difficult for an attacker to guess addresses and thus makes
8812: exploits harder to construct. With PIE, ASLR can really be applied to the
8813: entire program, instead of the stack and heap only.
8814:
8815: PIE executables will only be built for toolchains that are known to support
8816: PIE. Currently, this means NetBSD on x86, ARM, SPARC64, m68k, and MIPS.
8817:
8818: PKGSRC_MKPIE was enabled by default after the pkgsrc-2021Q3 branch.
8819:
1.219 nia 8820: B.1.1.4. PKGSRC_USE_RELRO
1.207 leot 8821:
8822: This also makes the exploitation of some security vulnerabilities more
8823: difficult in some cases.
8824:
8825: Two different mitigation levels are available:
8826:
1.219 nia 8827: * partial (the default): the ELF sections are reordered so that internal data
8828: sections precede the program's own data sections, and non-PLT GOT is
8829: read-only;
1.207 leot 8830:
8831: * full: in addition to partial RELRO, every relocation is performed
1.218 nia 8832: immediately when starting the program, allowing the entire GOT to be
8833: read-only. This can greatly slow down startup of large programs.
1.207 leot 8834:
8835: This is currently supported by GCC. Many software distributions now enable this
1.220 nia 8836: feature by default, at the "partial" level.
1.207 leot 8837:
8838: More details can be found here:
8839:
8840: * Hardening ELF binaries using Relocation Read-Only (RELRO)
8841:
1.219 nia 8842: B.1.2. Not enabled by default
8843:
8844: B.1.2.1. PKGSRC_MKREPRO
8845:
8846: With this option, pkgsrc will try to build packages reproducibly. This allows
8847: packages built from the same tree and with the same options, to produce
8848: identical results bit by bit. This option should be combined with ASLR and
8849: PKGSRC_MKPIE to avoid predictable address offsets for attackers attempting to
8850: exploit security vulnerabilities.
8851:
8852: More details can be found here:
8853:
8854: * Reproducible Builds - a set of software development practices that create
8855: an independently-verifiable path from source to binary code
8856:
8857: More work likely needs to be done before pkgsrc is fully reproducible.
8858:
8859: B.1.2.2. PKGSRC_USE_STACK_CHECK
1.207 leot 8860:
8861: This uses -fstack-check with GCC for another stack protection mitigation.
8862:
8863: It asks the compiler to generate code verifying that it does not corrupt the
8864: stack. According to GCC's manual page, this is really only useful for
8865: multi-threaded programs.
8866:
8867: B.2. Caveats
8868:
8869: B.2.1. Problems with PKGSRC_MKPIE
8870:
8871: B.2.1.1. Packages failing to build
8872:
8873: A number of packages may fail to build with this option enabled. The failures
8874: are often related to the absence of the -fPIC compilation flag when building
8875: libraries or executables (or ideally -fPIE in the latter case). This flag is
8876: added to the CFLAGS already, but requires the package to actually support it.
8877:
8878: B.2.1.1.1. How to fix
8879:
8880: These instructions are meant as a reference only; they likely need to be
8881: adapted for many packages individually.
8882:
8883: For packages using Makefiles:
8884:
8885: MAKE_FLAGS+= CFLAGS=${CFLAGS:Q}
8886: MAKE_FLAGS+= LDFLAGS=${LDFLAGS:Q}
8887:
8888: For packages using Imakefiles:
8889:
8890: MAKE_FLAGS+= CCOPTIONS=${CFLAGS:Q}
8891: MAKE_FLAGS+= LOCAL_LDFLAGS=${LDFLAGS:Q}
8892:
8893: B.2.1.2. Run-time crashes
8894:
8895: Some programs may fail to run, or crash at random times once built as PIE. Two
8896: scenarios are essentially possible. This is nearly always due to a bug in the
8897: program being exposed due to ASLR.
8898:
8899: B.2.1.3. Disabling PKGSRC_MKPIE on a per-package basis
8900:
8901: Ideally, packages should be fixed for compatibility with MKPIE. However, in
8902: some cases this is very difficult, due to complex build systems, packages using
8903: non-standard toolchains, or programming languages with odd bootstrapping
8904: mechanisms.
8905:
8906: To disable PKGSRC_MKPIE on a per-package basis, set MKPIE_SUPPORTED= no in the
8907: package's Makefile before bsd.prefs.mk is included.
8908:
8909: B.2.2. Problems with PKGSRC_USE_FORTIFY
8910:
8911: B.2.2.1. Packages failing to build
8912:
8913: This feature makes use of pre-processing directives to look for hardened,
8914: alternative implementations of essential library calls. Some programs may fail
8915: to build as a result; this usually happens for those trying too hard to be
8916: portable, or otherwise abusing definitions in the standard library.
8917:
8918: B.2.2.2. Run-time crashes
8919:
8920: This feature may cause some programs to crash, usually indicating an actual bug
8921: in the program. The fix will typically involve patching the original program's
8922: source code.
8923:
8924: B.2.2.3. Optimization is required
8925:
8926: At least in the case of GCC, FORTIFY will only be applied if optimization is
8927: applied while compiling. This means that the CFLAGS should also contain -O, -O2
8928: or another optimization level. This cannot easily be applied globally, as some
8929: packages may require specific optimization levels.
8930:
8931: B.2.2.4. Disabling FORTIFY on a per-package basis
8932:
8933: Note
8934:
8935: FORTIFY should not be disabled to work around runtime crashes in the program!
8936: This is a very bad idea and will expose you to security vulnerabilities.
8937:
8938: To disable FORTIFY on a per-package basis, set the following in the package's
8939: Makefile before bsd.prefs.mk is included:
8940:
8941: FORTIFY_SUPPORTED= no
8942:
8943: B.2.3. Problems with PKGSRC_USE_RELRO
8944:
8945: B.2.3.1. Performance impact
8946:
8947: For better protection, full RELRO requires every symbol to be resolved when the
8948: program starts, rather than simply when required at run-time. This will have
8949: more impact on programs using a lot of symbols, or linked to libraries exposing
8950: a lot of symbols. Therefore, daemons or programs otherwise running in
8951: background are affected only when started. Programs loading plug-ins at
8952: run-time are affected when loading the plug-ins.
8953:
8954: The impact is not expected to be noticeable on modern hardware, except in some
8955: cases for big programs.
8956:
8957: B.2.3.2. Run-time crashes
8958:
8959: Some programs handle plug-ins and dependencies in a way that conflicts with
8960: RELRO: for instance, with an initialization routine listing any other plug-in
8961: required. With full RELRO, the missing symbols are resolved before the
8962: initialization routine can run, and the dynamic loader will not be able to find
8963: them directly and abort as a result. Unfortunately, this is how Xorg loads its
8964: drivers. Partial RELRO can be applied instead in this case.
8965:
8966: B.2.3.3. Disabling RELRO on a per-package basis
8967:
8968: To disable RELRO on a per-package basis, set the following in the package's
8969: Makefile before bsd.prefs.mk is included:
8970:
8971: RELRO_SUPPORTED= no
8972:
1.209 nia 8973: It is also possible to at most enable partial RELRO, by setting RELRO_SUPPORTED
8974: to partial.
8975:
1.207 leot 8976: B.2.4. Problems with PKGSRC_USE_SSP
8977:
8978: B.2.4.1. Packages failing to build
8979:
8980: The stack-smashing protection provided by this option does not work for some
8981: programs. The most common situation in which this happens is when the program
8982: allocates variables on the stack, with the size determined at run-time.
8983:
8984: B.2.4.2. Run-time crashes
8985:
8986: Again, this feature may cause some programs to crash via a SIGABRT, usually
8987: indicating an actual bug in the program.
8988:
8989: On NetBSD LOG_CRIT level syslog messages are sent and - by default - appended
8990: to /var/log/messages, e.g.:
8991:
8992: Jan 6 15:42:51 hostname -: hostname program - - - buffer overflow detected; terminated
8993:
8994: (where hostname is the hostname(1) and program is the basename(1) of the
8995: program crashed).
8996:
8997: Patching the original program is then required.
8998:
8999: Rebuilding the package via:
9000:
9001: % env CFLAGS=-g INSTALL_UNSTRIPPED=yes make replace
9002:
9003: and inspecting the backtrace of the coredump via the debugger should point out
9004: the problematic call by inspecting the frame calling the _chk() (SSP) function.
9005:
9006: B.2.4.3. Performance impact
9007:
9008: The compiler emits extra code when using this feature: a check for buffer
9009: overflows is performed when entering and exiting functions, requiring an extra
9010: variable on the stack. The level of protection can otherwise be adjusted to
9011: affect only those functions considered more sensitive by the compiler (with
9012: -fstack-protector instead of -fstack-protector-all).
9013:
9014: The impact is not expected to be noticeable on modern hardware. However,
9015: programs with a hard requirement to run at the fastest possible speed should
9016: avoid using this feature, or using libraries built with this feature.
9017:
9018: B.2.4.4. Disabling SSP on a per-package basis
9019:
9020: Note
9021:
9022: SSP should not be disabled to work around runtime crashes in the program! This
9023: is a very bad idea and will expose you to security vulnerabilities.
9024:
9025: To disable SSP on a per-package basis, set the following in the package's
9026: Makefile before bsd.prefs.mk is included:
9027:
9028: SSP_SUPPORTED= no
9029:
9030: B.3. Auditing the system
9031:
9032: The illusion of security is worse than having no security at all. This section
9033: lists a number of ways to ensure the security features requested are actually
9034: effective.
9035:
9036: These instructions were obtained and tested on a system derived from NetBSD 7
9037: (amd64). YMMV.
9038:
9039: B.3.1. Checking for PIE
9040:
9041: The ELF executable type in use changes for binaries built as PIE; without:
9042:
9043: $ file /path/to/bin/ary
9044: /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
9045:
9046: as opposed to the following binary, built as PIE:
9047:
9048: $ file /path/to/pie/bin/ary
9049: /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
9050:
9051: The latter result is then what is expected.
9052:
9053: B.3.2. Checking for partial RELRO
9054:
9055: The following command should list a section called RELRO:
9056:
9057: $ objdump -p /path/to/bin/ary
9058:
9059: /path/to/bin/ary: file format elf64-x86-64
9060:
9061: Program Header:
9062: [...]
9063: RELRO off 0x0000000000000d78 vaddr 0x0000000000600d78 paddr 0x0000000000600d78 align 2**0
9064:
9065: This check is now performed automatically if PKG_DEVELOPER is set and RELRO is
9066: enabled.
9067:
9068: B.3.3. Checking for full RELRO
9069:
9070: The dynamic loader will apply RELRO immediately when detecting the presence of
9071: the BIND_NOW flag:
9072:
9073: $ objdump -x /path/to/bin/ary
9074:
9075: /path/to/bin/ary: file format elf64-x86-64
9076:
9077: Dynamic Section:
9078: [...]
9079: BIND_NOW 0x0000000000000000
9080:
9081: This has to be combined with partial RELRO (see above) to be fully efficient.
9082:
9083: This check is now performed automatically (where supported) if PKG_DEVELOPER is
9084: set.
9085:
9086: B.3.4. Checking for SSP
9087:
1.208 nia 9088: Note
9089:
9090: Checking for SSP using this method only works where the operating system uses
9091: libssp. libssp is not used on recent NetBSD/FreeBSD/Linux versions.
9092:
1.207 leot 9093: Building objects, binaries and libraries with SSP will affect the presence of
9094: additional symbols in the resulting file:
9095:
9096: $ nm /path/to/bin/ary
9097: [...]
9098: U __stack_chk_fail
9099: 0000000000600ea0 B __stack_chk_guard
9100:
9101: This is an indicator that the program was indeed built with support for SSP.
9102:
9103: This check is now performed automatically (where supported) if PKG_DEVELOPER is
9104: set and SSP is enabled.
9105:
9106: Appendix C. Build logs
1.1 dsieger 9107:
9108: Table of Contents
9109:
1.207 leot 9110: C.1. Building figlet
9111: C.2. Packaging figlet
1.1 dsieger 9112:
1.207 leot 9113: C.1. Building figlet
1.1 dsieger 9114:
9115: # make
9116: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9117: => figlet221.tar.gz doesn't seem to exist on this system.
9118: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
9119: => [172219 bytes]
9120: Connected to ftp.plig.net.
9121: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
9122: 331 Guest login ok, send your complete e-mail address as password.
9123: 230-You are user #5 of 500 simultaneous users allowed.
9124: 230-
9125: 230- ___ _ _ _
9126: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
9127: 230- | _| _| . |_| . | | | . |_| . | _| . |
9128: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
9129: 230- |_| |_| |___| |___|
9130: 230-
9131: 230-** Welcome to ftp.plig.org **
9132: 230-
9133: 230-Please note that all transfers from this FTP site are logged. If you
9134: 230-do not like this, please disconnect now.
9135: 230-
1.19 snj 9136: 230-This archive is available via
1.1 dsieger 9137: 230-
9138: 230-HTTP: http://ftp.plig.org/
9139: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
9140: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
9141: 230-
9142: 230-Please email comments, bug reports and requests for packages to be
9143: 230-mirrored to ftp-admin@plig.org.
9144: 230-
9145: 230-
9146: 230 Logged in anonymously.
9147: Remote system type is UNIX.
9148: Using binary mode to transfer files.
9149: 200 Type okay.
9150: 250 "/pub" is new cwd.
9151: 250-"/pub/figlet" is new cwd.
9152: 250-
9153: 250-Welcome to the figlet archive at ftp.figlet.org
9154: 250-
9155: 250- ftp://ftp.figlet.org/pub/figlet/
9156: 250-
9157: 250-The official FIGlet web page is:
9158: 250- http://www.figlet.org/
9159: 250-
9160: 250-If you have questions, please mailto:info@figlet.org. If you want to
9161: 250-contribute a font or something else, you can email us.
9162: 250
9163: 250 "/pub/figlet/program" is new cwd.
9164: 250 "/pub/figlet/program/unix" is new cwd.
9165: local: figlet221.tar.gz remote: figlet221.tar.gz
9166: 502 Unimplemented command.
9167: 227 Entering Passive Mode (195,40,6,41,246,104)
9168: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
9169: 38% |************** | 65800 64.16 KB/s 00:01 ETA
9170: 226 Transfer completed.
9171: 172219 bytes received in 00:02 (75.99 KB/s)
9172: 221 Goodbye.
9173: => Checksum OK for figlet221.tar.gz.
9174: ===> Extracting for figlet-2.2.1nb2
9175: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
9176: ===> Patching for figlet-2.2.1nb2
9177: ===> Applying pkgsrc patches for figlet-2.2.1nb2
9178: ===> Overriding tools for figlet-2.2.1nb2
9179: ===> Creating toolchain wrappers for figlet-2.2.1nb2
9180: ===> Configuring for figlet-2.2.1nb2
9181: ===> Building for figlet-2.2.1nb2
9182: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
9183: chmod a+x figlet
9184: gcc -O2 -o chkfont chkfont.c
9185: => Unwrapping files-to-be-installed.
9186: #
9187: # make install
9188: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9189: ===> Installing for figlet-2.2.1nb2
9190: install -d -o root -g wheel -m 755 /usr/pkg/bin
9191: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
9192: mkdir -p /usr/pkg/share/figlet
9193: cp figlet /usr/pkg/bin
9194: cp chkfont /usr/pkg/bin
9195: chmod 555 figlist showfigfonts
9196: cp figlist /usr/pkg/bin
9197: cp showfigfonts /usr/pkg/bin
9198: cp fonts/*.flf /usr/pkg/share/figlet
9199: cp fonts/*.flc /usr/pkg/share/figlet
9200: cp figlet.6 /usr/pkg/man/man6
9201: ===> Registering installation for figlet-2.2.1nb2
9202: #
9203:
1.207 leot 9204: C.2. Packaging figlet
1.1 dsieger 9205:
9206: # make package
9207: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9208: ===> Packaging figlet-2.2.1nb2
9209: ===> Building binary package for figlet-2.2.1nb2
9210: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
9211: Using SrcDir value of /usr/pkg
9212: Registering depends:.
9213: #
9214:
1.207 leot 9215: Appendix D. Directory layout of the pkgsrc FTP server
1.1 dsieger 9216:
9217: Table of Contents
9218:
1.207 leot 9219: D.1. distfiles: The distributed source files
9220: D.2. misc: Miscellaneous things
9221: D.3. packages: Binary packages
9222: D.4. reports: Bulk build reports
9223: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1 dsieger 9224:
9225: As in other big projects, the directory layout of pkgsrc is quite complex for
9226: newbies. This chapter explains where you find things on the FTP server. The
9227: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
9228: different, but inside this directory, everything should look the same, no
9229: matter on which server you are. This directory contains some subdirectories,
9230: which are explained below.
9231:
1.207 leot 9232: D.1. distfiles: The distributed source files
1.1 dsieger 9233:
9234: The directory distfiles contains lots of archive files from all pkgsrc
9235: packages, which are mirrored here. The subdirectories are called after their
9236: package names and are used when the distributed files have names that don't
9237: explicitly contain a version number or are otherwise too generic (for example
9238: release.tar.gz).
9239:
1.207 leot 9240: D.2. misc: Miscellaneous things
1.1 dsieger 9241:
9242: This directory contains things that individual pkgsrc developers find worth
9243: publishing.
9244:
1.207 leot 9245: D.3. packages: Binary packages
1.1 dsieger 9246:
1.3 rillig 9247: This directory contains binary packages for the various platforms that are
9248: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
9249: The meaning of these variables is:
9250:
9251: * OPSYS is the name of the operating system for which the packages have been
1.9 rillig 9252: built. The name is taken from the output of the uname command, so it may
9253: differ from the one you are used to hear.
1.3 rillig 9254:
1.8 rillig 9255: * ARCH is the hardware architecture of the platform for which the packages
1.10 hubertf 9256: have been built. It also includes the ABI (Application Binary Interface)
9257: for platforms that have several of them.
1.3 rillig 9258:
1.8 rillig 9259: * OSVERSION is the version of the operating system. For version numbers that
9260: change often (for example NetBSD-current), the often-changing part should
9261: be replaced with an x, for example 4.99.x.
1.3 rillig 9262:
1.23 jakllsch 9263: * TAG is either 20xxQy for a stable branch, or head for packages built from
1.8 rillig 9264: the HEAD branch. The latter should only be used when the packages are
9265: updated on a regular basis. Otherwise the date from checking out pkgsrc
9266: should be appended, for example head_20071015.
1.3 rillig 9267:
9268: The rationale for exactly this scheme is that the pkgsrc users looking for
9269: binary packages can quickly click through the directories on the server and
9270: find the best binary packages for their machines. Since they usually know the
9271: operating system and the hardware architecture, OPSYS and ARCH are placed
9272: first. After these choices, they can select the best combination of OSVERSION
9273: and TAG together, since it is usually the case that packages stay compatible
9274: between different version of the operating system.
9275:
9276: In each of these directories, there is a whole binary packages collection for a
9277: specific platform. It has a directory called All which contains all binary
9278: packages. Besides that, there are various category directories that contain
9279: symbolic links to the real binary packages.
1.1 dsieger 9280:
1.207 leot 9281: D.4. reports: Bulk build reports
1.8 rillig 9282:
9283: Here are the reports from bulk builds, for those who want to fix packages that
9284: didn't build on some of the platforms. The structure of subdirectories should
1.207 leot 9285: look like the one in Section D.3, "packages: Binary packages".
1.8 rillig 9286:
1.207 leot 9287: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1 dsieger 9288:
9289: These directories contain the "real" pkgsrc, that is the files that define how
9290: to create binary packages from source archives.
9291:
1.149 leot 9292: Each of the current, stable and pkgsrc-20xxQy directories share the same
9293: structure. They each contain a pkgsrc directory and pkgsrc.tar.{bz,gz,xz} file.
9294:
1.1 dsieger 9295: The directory pkgsrc contains a snapshot of the CVS repository, which is
1.149 leot 9296: updated regularly. The file pkgsrc.tar.{bz,gz,xz} contains the same as the
9297: directory, ready to be downloaded as a whole.
1.1 dsieger 9298:
1.149 leot 9299: The current directory contains files related to the HEAD branch of the CVS
9300: repository. In this directory there is an additional file called
9301: pkgsrc-readmes.tar.{bz,gz,xz} that contains all pkgsrc READMEs with information
9302: about categories and packages.
9303:
9304: The stable directory is a symlink to the latest pkgsrc-20xxQy.
9305:
9306: The pkgsrc-20xxQy. directories contain files related to the -20xxQy stable
9307: branch of the CVS repository. In these directories there is an additional file
9308: called pkgsrc-20xxQy.tar.{bz,gz,xz}, which contains the state of pkgsrc when it
9309: was branched.
1.148 leot 9310:
1.207 leot 9311: Appendix E. Help topics
1.154 rillig 9312:
9313: The following list contains all help topics that are available when running
9314: bmake help topic=:index.
9315:
1.232 gutterid 9316: #! -lintl
9317: 32bit 64bit
9318: ABI ACCEPTABLE_LICENSES
9319: ACROREAD_FONTPATH ADDITIONAL
9320: AFAIK AIX
9321: ALLOW_VULNERABLE_PACKAGES ALL_ENV
1.236 ! gutterid 9322: ALTERNATIVES_SRC AMANDA_TMP
! 9323: AMANDA_USER AMANDA_VAR
! 9324: APACHE_GROUP APACHE_MODULE_NAME
! 9325: APACHE_MODULE_SRC APACHE_MODULE_SRCDIR
! 9326: APACHE_PKG_PREFIX APACHE_SUEXEC_CONFIGURE_ARGS
! 9327: APACHE_SUEXEC_DOCROOT APACHE_USER
! 9328: APPEND_ABI APPEND_ELF
! 9329: ARLA_CACHE AUDIT_PACKAGES_FLAGS
! 9330: AUTOCONF_REQD AUTOMAKE_OVERRIDE
! 9331: AUTOMAKE_REQD AUTO_MKDIRS
! 9332: BDB185_DEFAULT BDBBASE
! 9333: BDB_ACCEPTED BDB_DEFAULT
! 9334: BDB_LIBS BDB_TYPE
! 9335: BINCIMAP_GROUP BINCIMAP_USER
! 9336: BIND_DIR BIND_GROUP
! 9337: BIND_USER BINOWN
! 9338: BINPKG_SITES BIN_INSTALL_FLAGS
! 9339: BISON_PKGDATADIR BLAS
! 9340: BLAS_ACCEPTED BLAS_C_INTERFACE
! 9341: BLAS_INCLUDES BLAS_INDEX64
! 9342: BLAS_LIBS BLAS_PC
! 9343: BLAS_TYPE BOOTSTRAP_DEPENDS
! 9344: BROKEN BROKEN_EXCEPT_ON_PLATFORM
! 9345: BROKEN_ON_PLATFORM BSDSRCDIR
! 9346: BSDXSRCDIR BSD_MAKE_ENV
! 9347: BUILDLINK_AUTO_DIRS BUILDLINK_AUTO_VARS
! 9348: BUILDLINK_CFLAGS BUILDLINK_CONTENTS_FILTER
! 9349: BUILDLINK_CPPFLAGS BUILDLINK_FILES
1.232 gutterid 9350: BUILDLINK_FILES_CMD BUILDLINK_FNAME_TRANSFORM
9351: BUILDLINK_LDFLAGS BUILDLINK_LIBS
9352: BUILDLINK_OPSYS_SUPPORT_PTHREAD BUILDLINK_PKGNAME
9353: BUILDLINK_PREFIX BUILDLINK_RPATHDIRS
9354: BUILDLINK_TREE BUILD_DEFS
9355: BUILD_DEFS_EFFECTS BUILD_DEPENDS
9356: BUILD_DIRS BUILD_ENV_SHELL
9357: BUILD_MAKE_CMD BUILD_MAKE_FLAGS
9358: BUILD_TARGET BUILTIN_FIND_FILES
9359: BUILTIN_FIND_FILES_VAR BUILTIN_FIND_GREP
9360: BUILTIN_FIND_HEADERS BUILTIN_FIND_HEADERS_VAR
9361: BUILTIN_FIND_PKGCONFIG BUILTIN_FIND_PKGCONFIG_VAR
9362: BUILTIN_PKG BUILTIN_TEST_CURSES_DEFINES
9363: BUILTIN_TEST_CURSES_FUNCS BUILTIN_VERSION_SCRIPT
9364: BUILTIN_X11_TYPE BUILTIN_X11_VERSION
9365: CACTI_GROUP CACTI_USER
9366: CANNA_GROUP CANNA_USER
9367: CAT CBLAS_LIBS
9368: CBLAS_PC CCACHE_BASE
9369: CCACHE_DIR CCACHE_LOGFILE
9370: CC_VERSION CC_VERSION_STRING
9371: CDRECORD_CONF CDROM_PKG_URL_DIR
9372: CDROM_PKG_URL_HOST CHANGES
1.236 ! gutterid 9373: CHECK_COMPILER CHECK_FAKEHOME
! 9374: CHECK_FILES CHECK_FILES_SKIP
! 9375: CHECK_FILES_STRICT CHECK_HEADERS
! 9376: CHECK_HEADERS_SKIP CHECK_INTERPRETER
! 9377: CHECK_INTERPRETER_SKIP CHECK_PERMS
! 9378: CHECK_PERMS_AUTOFIX CHECK_PERMS_SKIP
! 9379: CHECK_PIE CHECK_PIE_SKIP
! 9380: CHECK_PIE_SUPPORTED CHECK_PORTABILITY
! 9381: CHECK_PORTABILITY_EXPERIMENTAL CHECK_PORTABILITY_SKIP
! 9382: CHECK_RELRO CHECK_RELRO_SKIP
! 9383: CHECK_RELRO_SUPPORTED CHECK_SHLIBS
! 9384: CHECK_SHLIBS_SKIP CHECK_SHLIBS_SUPPORTED
! 9385: CHECK_SHLIBS_TOXIC CHECK_SSP
! 9386: CHECK_SSP_SKIP CHECK_SSP_SUPPORTED
! 9387: CHECK_STRIPPED CHECK_STRIPPED_SKIP
! 9388: CHECK_WRKREF CHECK_WRKREF_EXTRA_DIRS
! 9389: CHECK_WRKREF_SKIP CLAMAV_DBDIR
! 9390: CLAMAV_GROUP CLAMAV_USER
! 9391: CLANGBASE CLEANDEPENDS
! 9392: CMAKE_DEPENDENCIES_REWRITE CMAKE_INSTALL_NAME_DIR
! 9393: CMAKE_INSTALL_PREFIX CMAKE_MODULE_PATH_OVERRIDE
! 9394: CMAKE_PKGSRC_BUILD_FLAGS CMAKE_PREFIX_PATH
! 9395: CMAKE_USE_GNU_INSTALL_DIRS COMPILER_RPATH_FLAG
1.232 gutterid 9396: COMPILER_USE_SYMLINKS CONFIGURE_ARGS
9397: CONFIGURE_DIRS CONFIGURE_ENV
9398: CONFIGURE_ENV_SHELL CONFIGURE_HAS_INFODIR
9399: CONFIGURE_HAS_MANDIR CONFIGURE_SCRIPT
9400: CONFIG_SHELL CONFIG_SHELL_FLAGS
9401: CONF_FILES CONF_FILES_MODE
9402: CONF_FILES_PERMS CONSERVER_DEFAULTHOST
9403: CONSERVER_DEFAULTPORT CP
9404: CPE CPE_EDITION
9405: CPE_LANG CPE_OTHER
9406: CPE_PART CPE_PRODUCT
9407: CPE_SW_EDITION CPE_TARGET_HW
9408: CPE_TARGET_SW CPE_UPDATE
9409: CPE_URI CPE_VENDOR
9410: CPE_VERSION CPP
9411: CPP_PRECOMP_FLAGS CREATE_WRKDIR_SYMLINK
9412: CROSSBASE CTFCONVERT
9413: CTF_FILES_SKIP CTF_SUPPORTED
9414: CTYPE CUPS_GROUP
9415: CUPS_SYSTEM_GROUPS CUPS_USER
9416: CURSES_DEFAULT CURSES_TYPE
1.236 ! gutterid 9417: CXX CYRUS_GROUP
! 9418: CYRUS_IDLE CYRUS_USER
! 9419: DAEMONTOOLS_GROUP DAEMONTOOLS_LOG_USER
! 9420: DARWIN_NO_SYSTEM_LIBS DARWIN_REQUIRES_FILTER
! 9421: DBUS_GROUP DBUS_USER
! 9422: DEFANG_GROUP DEFANG_USER
! 9423: DEFAULT_ACCEPTABLE_LICENSES DEFAULT_DISTFILES
! 9424: DEFAULT_IRC_SERVER DEFAULT_SERIAL_DEVICE
! 9425: DEF_UMASK DEINSTALLDEPENDS
! 9426: DEINSTALL_SRC DEINSTALL_TEMPLATES
! 9427: DELAYED_ERROR_MSG DELAYED_WARNING_MSG
! 9428: DEPENDS DEPENDS_TARGET
! 9429: DEPENDS_TYPE DESTDIR
! 9430: DESTDIR_VARNAME DIALER_GROUP
! 9431: DIGEST_REQD DISTDIR
! 9432: DISTFILES DISTINFO_FILE
! 9433: DISTNAME DIST_PATH
! 9434: DIST_SUBDIR DJBDNS_AXFR_USER
! 9435: DJBDNS_CACHE_USER DJBDNS_DJBDNS_GROUP
! 9436: DJBDNS_LOG_USER DJBDNS_RBL_USER
! 9437: DJBDNS_TINY_USER DLOPEN_REQUIRE_PTHREADS
! 9438: DL_AUTO_VARS DL_CFLAGS
! 9439: DL_LDFLAGS DL_LIBS
! 9440: DNS DOCOWN
! 9441: DOWNLOADED_DISTFILE DQCACHE_GROUP
! 9442: DQCACHE_USER DT_LAYOUT
! 9443: DYNAMIC_SITES_CMD DYNAMIC_SITES_SCRIPT
! 9444: ECHO ECHO_N
! 9445: ELK_GUI EMACS_TYPE
! 9446: EMULDIR EMULSUBDIR
! 9447: EMULSUBDIRSLASH EMUL_ARCH
! 9448: EMUL_DISTRO EMUL_EXEC_FMT
! 9449: EMUL_IS_NATIVE EMUL_MODULES
! 9450: EMUL_OPSYS EMUL_PKG_FMT
! 9451: EMUL_PLATFORM EMUL_PLATFORMS
! 9452: EMUL_PREFER EMUL_REQD
! 9453: EMUL_TYPE ERROR_MSG
! 9454: EXIM_GROUP EXIM_USER
! 9455: EXPORT_SYMBOLS_LDFLAGS EXTRACTOR
! 9456: EXTRACT_CMD EXTRACT_CMD_DEFAULT
! 9457: EXTRACT_DIR EXTRACT_ELEMENTS
! 9458: EXTRACT_ENV EXTRACT_ONLY
! 9459: EXTRACT_OPTS EXTRACT_SUFX
! 9460: EXTRACT_USING FAIL
! 9461: FAILOVER_FETCH FAIL_MSG
! 9462: FAKE_NCURSES FAM
! 9463: FAM_ACCEPTED FAM_DEFAULT
! 9464: FAM_SERVER FCPATH
! 9465: FEATURE_CPPFLAGS FEATURE_LDFLAGS
! 9466: FEATURE_LIBS FETCH_AFTER_ARGS
! 9467: FETCH_BEFORE_ARGS FETCH_CMD
! 9468: FETCH_OUTPUT_ARGS FETCH_PROXY
! 9469: FETCH_RESUME_ARGS FETCH_TIMEOUT
! 9470: FETCH_USE_IPV4_ONLY FETCH_USING
! 9471: FILES_SUBST FILES_SUBST_SED
! 9472: FIX_SYSTEM_HEADERS FONTS_DIRS
1.232 gutterid 9473: FONTS_VERBOSE FOO_HACKS_MK
9474: FOX_USE_XUNICODE FREEWNN_GROUP
9475: FREEWNN_USER FTP_PKG_URL_DIR
9476: FTP_PKG_URL_HOST GAMEDATAMODE
9477: GAMEDATA_PERMS GAMEDIRMODE
9478: GAMEDIR_PERMS GAMEGRP
9479: GAMEMODE GAMEOWN
9480: GAMES_GROUP GAMES_USER
9481: GCC GCCBASE
9482: GCC_REQD GCC_VERSION_SUFFIX
9483: GEM_BUILD GEM_CLEANBUILD
9484: GEM_CLEANBUILD_EXTENSIONS GEM_DOCDIR
9485: GEM_EXTSDIR GEM_HOME
9486: GEM_KEEPBUILD GEM_LIBDIR
9487: GEM_NAME GEM_PATH
9488: GEM_PLUGINSDIR GEM_SPECFILE
9489: GENERATE_PLIST GHC
9490: GHOSTSCRIPT_REQD GITHUB_PROJECT
9491: GITHUB_RELEASE GITHUB_SUBMODULES
9492: GITHUB_TAG GITHUB_TYPE
9493: GITLAB_PROJECT GITLAB_RELEASE
9494: GITLAB_SUBMODULES GITLAB_TAG
1.236 ! gutterid 9495: GITLAB_TYPE GNU
! 9496: GNU_CONFIGURE GNU_CONFIGURE_INFODIR
! 9497: GNU_CONFIGURE_MANDIR GNU_CONFIGURE_QUIET
! 9498: GNU_CONFIGURE_STRICT GODEP_REDIRECTS
! 9499: GO_BUILD_PATTERN GO_DEPS
! 9500: GO_DIST_BASE GO_EXTRA_MOD_DIRS
! 9501: GO_MODULE_FILES GO_SRCPATH
! 9502: GROUP_SPECIFIC_PKGS GRUB_NETWORK_CARDS
! 9503: GRUB_PRESET_COMMAND GRUB_SCAN_ARGS
! 9504: GZIP HASKELL_ENABLE_DYNAMIC_EXECUTABLE
1.232 gutterid 9505: HASKELL_ENABLE_HADDOCK_DOCUMENTATION HASKELL_ENABLE_LIBRARY_PROFILING
1.236 ! gutterid 9506: HASKELL_ENABLE_SHARED_LIBRARY HASKELL_ENABLE_TESTS
! 9507: HASKELL_OPTIMIZATION_LEVEL HASKELL_PKG_NAME
! 9508: HASKELL_UNRESTRICT_DEPENDENCIES HEADER_TEMPLATES
! 9509: HOMEPAGE HOST_PKGTOOLS_ARGS
! 9510: HOST_SPECIFIC_PKGS HOWL_GROUP
! 9511: HOWL_USER ICCBASE
! 9512: ICECAST_CHROOTDIR ICON_THEMES
! 9513: IDOBASE IGNORE_CCACHE
! 9514: IGNORE_INFO_DIRS IGNORE_INTERACTIVE_FETCH
! 9515: IMAKE IMAKEOPTS
! 9516: IMAKE_MAKE IMAKE_MANINSTALL
! 9517: IMAP_UW_CCLIENT_MBOX_FMT IMDICTDIR
! 9518: INCOMPAT_CURSES INFO_DIR
! 9519: INFO_FILES INFO_FILES_VERBOSE
! 9520: INFO_MSG INIT_SYSTEM
! 9521: INN_DATA_DIR INN_GROUP
! 9522: INN_USER INSTALLATION_DIRS
! 9523: INSTALLATION_DIRS_FROM_PLIST INSTALL_ENV
! 9524: INSTALL_SH_OVERRIDE INSTALL_SRC
! 9525: INSTALL_TEMPLATES INSTALL_UNSTRIPPED
! 9526: IRCD_HYBRID_IRC_GROUP IRCD_HYBRID_IRC_USER
! 9527: IRCD_HYBRID_MAXCONN IRCD_HYBRID_NICLEN
! 9528: IRCD_HYBRID_SYSLOG_EVENTS IRCD_HYBRID_SYSLOG_FACILITY
! 9529: IRCD_HYBRID_TOPICLEN IRIX
! 9530: IRRD_USE_PGP JABBERD_GROUP
! 9531: JABBERD_LOGDIR JABBERD_PIDDIR
! 9532: JABBERD_SPOOLDIR JABBERD_USER
! 9533: JAVA_BINPREFIX JAVA_CLASSPATH
! 9534: JAVA_HOME JAVA_LD_LIBRARY_PATH
! 9535: JAVA_NAME JAVA_UNLIMIT
! 9536: JAVA_WRAPPERS JPEG_ACCEPTED
! 9537: JPEG_DEFAULT KERBEROS
! 9538: KERMIT_SUID_UUCP KJS_USE_PCRE
! 9539: KNEWS_DOMAIN_FILE KNEWS_DOMAIN_NAME
! 9540: KRB5_ACCEPTED KRB5_DEFAULT
! 9541: LANGUAGES LAPACKE_LIBS
! 9542: LAPACKE_PC LAPACK_LIBS
! 9543: LAPACK_PC LATEX2HTML_ICONPATH
! 9544: LDCONFIG_ADD_CMD LDCONFIG_REMOVE_CMD
! 9545: LDD LEAFNODE_DATA_DIR
! 9546: LEAFNODE_GROUP LEAFNODE_USER
! 9547: LIBDVDCSS_HOMEPAGE LIBDVDCSS_MASTER_SITES
! 9548: LIBRSVG_TYPE LIBTOOL
! 9549: LIBTOOLIZE_PLIST LIBTOOL_M4_OVERRIDE
! 9550: LIBUSB_TYPE LICENSE
! 9551: LINKER_RPATH_FLAG LINK_RPATH_FLAG
1.232 gutterid 9552: LINUX_LOCALES LOCALBASE
9553: LOCALBASE_LOCKTYPE LOCALPATCHES
9554: LOVE_DATA LOVE_GAME
9555: LOVE_VERSION LP32PLATFORMS
9556: LP64PLATFORMS LUA_BUSTED_ARGS
9557: LUA_CDIR LUA_COMPILER
9558: LUA_DOCDIR LUA_EXAMPLESDIR
9559: LUA_INCDIR LUA_INTERPRETER
9560: LUA_LDIR LUA_LINKER_MAGIC
9561: LUA_PKGPREFIX LUA_SELF_CONFLICT
9562: LUA_USE_BUSTED LUA_VERSIONS_ACCEPTED
9563: LUA_VERSIONS_INCOMPATIBLE LUA_VERSION_DEFAULT
9564: LUA_VERSION_REQD Lua
9565: MACHINE_PLATFORM MAILAGENT_DOMAIN
9566: MAILAGENT_EMAIL MAILAGENT_FQDN
9567: MAILAGENT_ORGANIZATION MAJORDOMO_HOMEDIR
1.236 ! gutterid 9568: MAKEINFO_ARGS MAKE_DIRS
! 9569: MAKE_DIRS_PERMS MAKE_ENV
! 9570: MAKE_FILE MAKE_FLAGS
! 9571: MAKE_JOBS MAKE_JOBS_SAFE
! 9572: MAKE_PROGRAM MANCOMPRESSED_IF_MANZ
! 9573: MANINSTALL MANZ
! 9574: MASTER_SITES MASTER_SITE_BACKUP
! 9575: MASTER_SITE_LOCAL MASTER_SITE_MOZILLA
! 9576: MASTER_SITE_OVERRIDE MASTER_SITE_PERL_CPAN
! 9577: MASTER_SORT MASTER_SORT_RANDOM
! 9578: MASTER_SORT_REGEX MECAB_CHARSET
! 9579: MEDIATOMB_GROUP MEDIATOMB_USER
! 9580: MIPSPROBASE MIREDO_GROUP
! 9581: MIREDO_USER MISSING_FEATURES
! 9582: MKDIR MKPIE_SUPPORTED
! 9583: MLDONKEY_GROUP MLDONKEY_HOME
! 9584: MLDONKEY_USER MONOTONE_GROUP
! 9585: MONOTONE_USER MOTIFBASE
! 9586: MOTIF_TYPE MOTIF_TYPE_DEFAULT
! 9587: MPI_TYPE MSGFMT_STRIP_MSGCTXT
! 9588: MSGFMT_STRIP_MSGID_PLURAL MTOOLS_ENABLE_FLOPPYD
1.232 gutterid 9589: MV MYSQL_CHARSET
9590: MYSQL_DATADIR MYSQL_EXTRA_CHARSET
9591: MYSQL_GROUP MYSQL_USER
9592: MYSQL_VERSION MYSQL_VERSIONS_ACCEPTED
9593: MYSQL_VERSIONS_ALL MYSQL_VERSION_DEFAULT
9594: NAGIOSCMD_GROUP NAGIOSDIR
9595: NAGIOS_GROUP NAGIOS_USER
9596: NATIVE_APPEND_ABI NATIVE_APPEND_ELF
9597: NATIVE_EXEC_FMT NATIVE_MACHINE_PLATFORM
9598: NATIVE_OBJECT_FMT NBPAX_PROGRAM_PREFIX
9599: NETBSD_LOGIN_NAME NMH_EDITOR
9600: NMH_MTA NMH_PAGER
9601: NODE_VERSIONS_ACCEPTED NODE_VERSIONS_INCOMPATIBLE
9602: NODE_VERSION_DEFAULT NODE_VERSION_REQD
9603: NOLOGIN NOTE
9604: NOT_FOR_PLATFORM NOT_PAX_ASLR_SAFE
9605: NOT_PAX_MPROTECT_SAFE NO_BUILD
9606: NO_CHECKSUM NO_CONFIGURE
9607: NO_SKIP NS_PREFERRED
9608: NULLMAILER_GROUP NULLMAILER_USER
9609: OBJHOSTNAME OBJMACHINE
9610: OCAML_FINDLIB_DIRS OCAML_FINDLIB_REGISTER
9611: OCAML_FINDLIB_REGISTER_VERBOSE OCAML_SITELIBDIR
1.236 ! gutterid 9612: OMF ONLY_FOR_COMPILER
! 9613: ONLY_FOR_PLATFORM OPENSSH_CHROOT
! 9614: OPENSSH_GROUP OPENSSH_USER
! 9615: OPSYS OPSYS_EMULDIR
! 9616: OPSYS_VERSION OS
! 9617: OSS_TYPE OSX
! 9618: OSX_TOLERATE_SDK_SKEW OS_VARIANT
! 9619: OS_VERSION OTF_FONTS_DIR
! 9620: OVERRIDE_DIRDEPTH OVERRIDE_GEMSPEC
! 9621: OVERRIDE_GNU_CONFIG_SCRIPTS OWN_DIRS
1.233 wiz 9622: OWN_DIRS_PERMS P4GROUP
9623: P4PORT P4ROOT
9624: P4USER PACKAGES
9625: PALMOS_DEFAULT_SDK PAMBASE
9626: PAM_DEFAULT PAPERSIZE
9627: PASSIVE_FETCH PATCHDIR
9628: PATCHFILES PATCH_ARGS
9629: PATCH_DEBUG PATCH_DIST_ARGS
9630: PATCH_DIST_CAT PATCH_DIST_STRIP
9631: PATCH_FUZZ_FACTOR PATCH_STRIP
9632: PATH PCCBASE
9633: PEAR_CMD PEAR_LIB
9634: PEAR_PACKAGE_XML PERL5
9635: PERL5_CONFIGURE PERL5_CONFIGURE_DIRS
9636: PERL5_LDFLAGS PERL5_LICENSE
9637: PERL5_MODULE_TYPE PERL5_PACKLIST
9638: PERL5_PACKLIST_DIR PERL5_PERLBASE
9639: PERL5_SITEBASE PERL5_USE_PACKLIST
9640: PERL5_VENDORBASE PFCTL
9641: PFVAR_H PF_VERSION
9642: PGGROUP PGHOME
9643: PGPKGSRCDIR PGSQL_TYPE
9644: PGSQL_VERSION PGSQL_VERSIONS_ACCEPTED
9645: PGSQL_VERSION_DEFAULT PGUSER
9646: PG_LIB_EXT PHP
9647: PHPCOMMON_MK PHPPKGSRCDIR
9648: PHP_BASE_VERS PHP_CHECK_INSTALLED
9649: PHP_EXTENSION_DIR PHP_INITIAL_TEENY
9650: PHP_PKG_PREFIX PHP_VERSION
9651: PHP_VERSIONS_ACCEPTED PHP_VERSIONS_INCOMPATIBLE
9652: PHP_VERSION_DEFAULT PHP_VERSION_REQD
9653: PILRC_USE_GTK PKGCONFIG_BASE
9654: PKGCONFIG_FILE PKGCONFIG_OVERRIDE
9655: PKGCONFIG_OVERRIDE_STAGE PKGDIR
9656: PKGGNUDIR PKGINFODIR
9657: PKGLOCALEDIR PKGMANDIR
9658: PKGNAME PKGNAME_REQD
9659: PKGPATH PKGREVISION
9660: PKGSRC_BLAS_TYPES PKGSRC_CHANGES
9661: PKGSRC_COMPILER PKGSRC_KEEP_BIN_PKGS
9662: PKGSRC_LOCKTYPE PKGSRC_MAKE_ENV
9663: PKGSRC_MESSAGE_RECIPIENTS PKGSRC_MKPIE
9664: PKGSRC_MKREPRO PKGSRC_OVERRIDE_MKPIE
9665: PKGSRC_RUN_TEST PKGSRC_SETENV
9666: PKGSRC_SLEEPSECS PKGSRC_TODO
9667: PKGSRC_USE_CTF PKGSRC_USE_FORTIFY
9668: PKGSRC_USE_MKTOOLS PKGSRC_USE_RELRO
9669: PKGSRC_USE_SSP PKGSRC_USE_STACK_CHECK
9670: PKGTASKS_DATAFILE PKGTOOLS_ARGS
9671: PKGTOOLS_ENV PKG_ALTERNATIVES
9672: PKG_APACHE PKG_APACHE_ACCEPTED
9673: PKG_APACHE_DEFAULT PKG_BEST_EXISTS
9674: PKG_BUILD_OPTIONS PKG_COMPRESSION
9675: PKG_CONFIG PKG_CONFIG_PERMS
9676: PKG_CREATE_USERGROUP PKG_DB_TMPDIR
9677: PKG_DEBUG_LEVEL PKG_DEFAULT_OPTIONS
9678: PKG_DESTDIR_SUPPORT PKG_DEVELOPER
9679: PKG_DISABLED_OPTIONS PKG_FATAL_ERRORS
9680: PKG_FC PKG_FILELIST_CMD
9681: PKG_GECOS PKG_GID
9682: PKG_GROUPS PKG_GROUPS_VARS
9683: PKG_HOME PKG_INIT_SCRIPTS
9684: PKG_JAVA_HOME PKG_JVM
9685: PKG_JVMS_ACCEPTED PKG_JVM_DEFAULT
9686: PKG_LEGACY_OPTIONS PKG_LIBTOOL
9687: PKG_MKSYMLINKS PKG_OPTIONS
9688: PKG_OPTIONS_DEPRECATED_WARNINGS PKG_OPTIONS_LEGACY_OPTS
9689: PKG_OPTIONS_LEGACY_VARS PKG_OPTIONS_NONEMPTY_SETS
9690: PKG_OPTIONS_OPTIONAL_GROUPS PKG_OPTIONS_REQUIRED_GROUPS
9691: PKG_OPTIONS_VAR PKG_PHP
9692: PKG_PHP_MAJOR_VERS PKG_PHP_VERSION
9693: PKG_RCD_SCRIPTS PKG_REFCOUNT_DBDIR
9694: PKG_REGISTER_SHELLS PKG_RESUME_TRANSFERS
9695: PKG_SHELL PKG_SUGGESTED_OPTIONS
9696: PKG_SUPPORTED_OPTIONS PKG_SYSCONFBASE
9697: PKG_SYSCONFBASEDIR PKG_SYSCONFDIR
9698: PKG_SYSCONFDIR_PERMS PKG_SYSCONFSUBDIR
9699: PKG_SYSCONFVAR PKG_TOOLS_BIN
9700: PKG_UID PKG_UPDATE_FONTS_DB
9701: PKG_USERS PKG_USERS_VARS
9702: PKG_VERBOSE PLEASE
9703: PLIST PLIST_AWK
9704: PLIST_AWK_ENV PLIST_SRC
9705: PLIST_SUBST PLIST_TYPE
9706: PLIST_VARS POPTOP_USE_MPPE
9707: POSSIBLE_GFORTRAN_VERSION POST_FETCH_HOOK
9708: PREFER PREFER_NATIVE
9709: PREFER_NATIVE_PTHREADS PREFER_PKGSRC
9710: PREFIX PREPEND_PATH
9711: PRE_ROOT_CMD PRIVILEGED_STAGES
9712: PS PTHREAD_AUTO_VARS
9713: PTHREAD_CFLAGS PTHREAD_LDFLAGS
9714: PTHREAD_LIBS PTHREAD_OPTS
9715: PTHREAD_TYPE PVM_SSH
9716: PYPKGPREFIX PYTHON_FOR_BUILD_ONLY
9717: PYTHON_SELF_CONFLICT PYTHON_VERSIONED_DEPENDENCIES
9718: PYTHON_VERSIONS_ACCEPTED PYTHON_VERSIONS_INCOMPATIBLE
9719: PYTHON_VERSION_DEFAULT PYTHON_VERSION_REQD
9720: PYVERSSUFFIX QMAILDIR
9721: QMAIL_ALIAS_USER QMAIL_DAEMON_USER
9722: QMAIL_LOG_USER QMAIL_NOFILES_GROUP
9723: QMAIL_PASSWD_USER QMAIL_QMAIL_GROUP
9724: QMAIL_QUEUE_DIR QMAIL_QUEUE_EXTRA
9725: QMAIL_QUEUE_USER QMAIL_REMOTE_USER
9726: QMAIL_ROOT_USER QMAIL_SEND_USER
9727: QORE_LATEST_MODULE_API QORE_MODULE_API
9728: QORE_MODULE_DIR QORE_USER_MODULE_DIR
9729: QORE_VERSION QPOPPER_FAC
9730: QPOPPER_SPOOL_DIR QPOPPER_USER
9731: RAKE_NAME RASMOL_DEPTH
9732: RCD_SCRIPTS RCD_SCRIPTS_DIR
9733: RCD_SCRIPTS_EXAMPLEDIR RCD_SCRIPTS_MODE
9734: RCD_SCRIPTS_SHELL RCD_SCRIPT_SRC
1.236 ! gutterid 9735: RDOC READLINE_DEFAULT
! 9736: READLINE_TYPE REAL_ROOT_GROUP
! 9737: REAL_ROOT_USER RECURSIVE_MAKE
! 9738: RELAY_CTRL_DIR RELRO_SUPPORTED
! 9739: REPLACE_AWK REPLACE_BASH
! 9740: REPLACE_CSH REPLACE_KSH
! 9741: REPLACE_LUA REPLACE_NODEJS
! 9742: REPLACE_OCTAVE REPLACE_PERL
! 9743: REPLACE_PERL6 REPLACE_PHP
! 9744: REPLACE_PYTHON REPLACE_QORE
! 9745: REPLACE_R REPLACE_RUBY
! 9746: REPLACE_RUBY_DIRS REPLACE_RUBY_PAT
! 9747: REPLACE_SH REPLACE_TEXLUA
! 9748: REPLACE_WISH REQD_DIRS
! 9749: REQD_DIRS_PERMS REQD_FILES
! 9750: REQD_FILES_MODE REQD_FILES_PERMS
! 9751: RESOLV_AUTO_VARS RESOLV_LDFLAGS
! 9752: RESOLV_LIBS RM
! 9753: ROOT_CMD ROOT_GROUP
! 9754: ROOT_USER RPCGEN
! 9755: RPM RPM2PKG_PLIST
! 9756: RPM2PKG_PREFIX RPM2PKG_STAGE
! 9757: RPM2PKG_STRIP RPM2PKG_SUBPREFIX
! 9758: RPMFILES RPMIGNOREPATH
! 9759: RPM_DB_PREFIX RSSH_CVS_PATH
! 9760: RSSH_RDIST_PATH RSSH_RSYNC_PATH
! 9761: RSSH_SCP_PATH RSSH_SFTP_SERVER_PATH
! 9762: RUBY RUBYGEM
! 9763: RUBYGEM_MANPAGES RUBYGEM_NAME
! 9764: RUBYGEM_OPTIONS RUBYGEM_USE_MANPAGES
! 9765: RUBYGEM_VERBOSE RUBY_ABI_VERSION
! 9766: RUBY_ARCH RUBY_ARCHINC
! 9767: RUBY_ARCHLIB RUBY_BASE
! 9768: RUBY_BASERIDIR RUBY_BUILD_DOCUMENT
! 9769: RUBY_DLEXT RUBY_DOC
! 9770: RUBY_DYNAMIC_DIRS RUBY_EG
! 9771: RUBY_ENCODING_ARG RUBY_EXTCONF
! 9772: RUBY_EXTCONF_CHECK RUBY_EXTCONF_DEBUG
! 9773: RUBY_EXTCONF_MAKEFILE RUBY_GEM_ARCH
! 9774: RUBY_GEM_BASE RUBY_INC
! 9775: RUBY_LIB RUBY_LIB_BASE
! 9776: RUBY_NAME RUBY_NOVERSION
! 9777: RUBY_PKGPREFIX RUBY_RAILS
! 9778: RUBY_RAILS52_VERSION RUBY_RAILS60_VERSION
! 9779: RUBY_RAILS61_VERSION RUBY_RAILS70_VERSION
! 9780: RUBY_RAILS_ACCEPTED RUBY_RAILS_DEFAULT
! 9781: RUBY_RAILS_REQD RUBY_RAILS_STRICT_DEP
! 9782: RUBY_RIDIR RUBY_SETUP
! 9783: RUBY_SHLIB RUBY_SHLIBALIAS
! 9784: RUBY_SHLIBVER RUBY_SIMPLE_INSTALL
! 9785: RUBY_SITEARCHLIB RUBY_SITELIB
! 9786: RUBY_SITELIB_BASE RUBY_SITERIDIR
! 9787: RUBY_SLEXT RUBY_SRCDIR
! 9788: RUBY_STATICLIB RUBY_SUFFIX
! 9789: RUBY_SYSRIDIR RUBY_USE_PTHREAD
! 9790: RUBY_VENDORARCHLIB RUBY_VENDORLIB
! 9791: RUBY_VENDORLIB_BASE RUBY_VER
! 9792: RUBY_VERSION RUBY_VERSIONS_ACCEPTED
! 9793: RUBY_VERSIONS_INCOMPATIBLE RUBY_VERSION_DEFAULT
! 9794: RUBY_VERSION_REQD RUBY_VER_DIR
! 9795: RUN RUN_LDCONFIG
! 9796: RUST_TYPE SCO
! 9797: SCREWS_GROUP SCREWS_USER
! 9798: SCRIPTS_ENV SCROLLKEEPER_DATADIR
! 9799: SCROLLKEEPER_REBUILDDB SCROLLKEEPER_UPDATEDB
! 9800: SDIST_PAWD SDL12_TYPE
! 9801: SERIAL_DEVICES SETGIDGAME
! 9802: SETGID_GAMES_PERMS SETUID_ROOT_PERMS
! 9803: SH SHLIB
1.233 wiz 9804: SIGN_PACKAGES SILC_CLIENT_WITH_PERL
9805: SITE_SPECIFIC_PKGS SKIP_DEPENDS
9806: SMF_INSTANCES SMF_MANIFEST
9807: SMF_METHODS SMF_METHOD_SHELL
9808: SMF_METHOD_SRC SMF_NAME
9809: SMF_PREFIX SMF_SRCDIR
9810: SNIPROXY_GROUP SNIPROXY_USER
9811: SOURCE_BUFFSIZE SPECIAL_PERMS
9812: SPECIFIC_PKGS SSH_SUID
9813: SSP_SUPPORTED SSYNC_PAWD
9814: STEP_MSG STRIP
9815: STRIP_DBG STRIP_DEBUG
9816: STRIP_DEBUG_SUPPORTED STRIP_FILES_SKIP
9817: SU SUBDIR
9818: SUBST SUBST_CLASSES
9819: SUBST_FILES SUBST_FILTER_CMD
9820: SUBST_MESSAGE SUBST_NOOP_OK
9821: SUBST_SED SUBST_SHOW_DIFF
9822: SUBST_SKIP_TEXT_CHECK SUBST_STAGE
9823: SUBST_VARS SUNWSPROBASE
9824: SUSE_PREFER SU_CMD
9825: SYSCONFBASE TARGET_ARCH
9826: TBL TERMCAP_TYPE
9827: TERMINFO_DEFAULT TERMINFO_TYPE
9828: TEST TEST_DEPENDS
9829: TEST_DIRS TEST_ENV
9830: TEST_ENV_SHELL TEST_MAKE_CMD
9831: TEST_MAKE_FLAGS TEST_TARGET
9832: TEXLIVE_IGNORE_PATTERNS TEXLIVE_REV
9833: TEXLIVE_UNVERSIONED TEXMFSITE
9834: TEX_FORMATS TEX_HYPHEN_DAT
9835: TEX_HYPHEN_DEF TEX_TEXMF_DIRS
9836: THTTPD_LOG_FACILITY TINYDYN_USER
9837: TLSWRAPPER_CHROOT TO
9838: TOOLS_ALIASES TOOLS_ALWAYS_WRAP
9839: TOOLS_ARGS TOOLS_BROKEN
9840: TOOLS_CMD TOOLS_CMDLINE_SED
9841: TOOLS_CREATE TOOLS_CROSS_DESTDIR
9842: TOOLS_DIR TOOLS_FAIL
9843: TOOLS_GNU_MISSING TOOLS_LDCONFIG
9844: TOOLS_NOOP TOOLS_PATH
9845: TOOLS_SCRIPT TOOLS_USE_CROSS_COMPILE
1.236 ! gutterid 9846: TOOL_DEPENDS TTF_FONTS_DIR
! 9847: TYPE UAC_REQD_EXECS
! 9848: UCSPI_SSL_GROUP UCSPI_SSL_USER
! 9849: UNLIMIT_RESOURCES UNPRIVILEGED
! 9850: UNPRIVILEGED_GROUP UNPRIVILEGED_GROUPS
! 9851: UNPRIVILEGED_USER UNWRAP_FILES
! 9852: UNWRAP_PATTERNS UPDATE_GEMSPEC
! 9853: UPDATE_TARGET URI
! 9854: USERGROUP_PHASE USERPPP_GROUP
! 9855: USER_SPECIFIC_PKGS USE_ABI_DEPENDS
! 9856: USE_APR USE_BSD_MAKEFILE
! 9857: USE_BUILTIN USE_CROSS_COMPILE
! 9858: USE_CURSES USE_CWRAPPERS
! 9859: USE_DB185 USE_FEATURES
! 9860: USE_GAMESGROUP USE_GCC_RUNTIME
! 9861: USE_IMAKE USE_JAVA
! 9862: USE_JAVA2 USE_LANGUAGES
! 9863: USE_LIBTOOL USE_NATIVE_GCC
! 9864: USE_NETBSD_REPO USE_PKGSRC_GCC
! 9865: USE_PKGSRC_GCC_RUNTIME USE_PKGTASKS
! 9866: USE_PKG_ADMIN_DIGEST USE_RUBY_EXTCONF
! 9867: USE_RUBY_INSTALL USE_RUBY_SETUP
! 9868: USE_RUBY_SETUP_PKG USE_TOOLS
! 9869: UUCP_GROUP UUCP_USER
! 9870: VARBASE VARNAME
! 9871: VIM_EXTRA_OPTS WARNING_MSG
! 9872: WCALC_CGIDIR WCALC_CGIPATH
! 9873: WCALC_HTMLDIR WCALC_HTMLPATH
! 9874: WDM_MANAGERS WRAPPER_CC
! 9875: WRAPPER_REORDER_CMDS WRKDIR
! 9876: WRKDIR_BASENAME WRKDIR_LOCKTYPE
! 9877: WRKLOG WRKOBJDIR
! 9878: WRKSRC X10_PORT
! 9879: X11 X11BASE
! 9880: X11_PKGSRCDIR X11_TYPE
! 9881: X509_CERTIFICATE X509_KEY
! 9882: XAW_TYPE XLOCK_DEFAULT_MODE
! 9883: XMKMF XMKMF_FLAGS
! 9884: XXX YES
1.233 wiz 9885: ZSH_STATIC __stdc__
9886: _vargroups accept
9887: acquire-localbase-lock acquire-lock
9888: add added
9889: administrator alloca
9890: alternatives aslr
9891: asprintf atlas
9892: autoconf automake
9893: autoreconf awk
9894: bash big-endian
9895: bin-install bind
9896: binpkg-list blas
9897: bootstrap-depends broken
9898: broken_on_platform bsd
9899: bsd.prog.mk build
9900: build-env buildlink-directories
9901: buildlink-oss-soundcard-h c
9902: c++ ccache
9903: cce cdefs
9904: ceil changes
9905: changes-entry changes-entry-noupdate
9906: check check-clean
9907: check-files check-files-clean
9908: check-vulnerable checksum
9909: checksum-phase clean
9910: clean-depends cleandir
9911: commit commit-changes-entry
9912: compact compiler
9913: conf config.guess
9914: config.sub configuration
9915: configure configure-env
9916: configure-help configure_args
9917: connect cos
9918: cpe cputime
9919: create-usergroup csh
1.236 ! gutterid 9920: ctf debug
! 9921: declaration declare
! 9922: defined depend
! 9923: dependencies depends
! 9924: depends-checksum depends-fetch
! 9925: deps describe
! 9926: destdir disable
! 9927: distclean distinfo
! 9928: dl dlopen
! 9929: do-buildlink do-clean
! 9930: do-configure do-configure-post-hook
! 9931: do-extract do-fetch
! 9932: do-install emul
! 9933: emul-distinfo emul-fetch
! 9934: emulation emulator
! 9935: enable endian
1.233 wiz 9936: enomem ensurepip
9937: err errx
9938: etc exp
9939: extract-rpm fabs
9940: feature features
9941: fetch fetch-list
9942: follows forbids
9943: form format
9944: fortify fortify_source
1.236 ! gutterid 9945: friend fts
! 9946: fts_close fts_open
! 9947: fts_read fts_set
! 9948: gcc gethostbyaddr
! 9949: gethostbyname gethostbyname2
! 9950: getopt_long getprogname
! 9951: getservbyname getservbyport
! 9952: getservent gettext
1.233 wiz 9953: github gitlab
9954: glob gnu
9955: gnu_configure_strict go
9956: go-deps golang
9957: guess-license hashbang
9958: heimdal help
1.236 ! gutterid 9959: imake increment
! 9960: indirect inet_aton
! 9961: interp interpreter
! 9962: intl ip4
! 9963: ip6 ipv4
! 9964: ipv6 iso
! 9965: kerberos krb
! 9966: krb5 ksh
! 9967: lapack latex
! 9968: libintl_bindtextdomain libintl_gettext
! 9969: libintl_textdomain libnbcompat
! 9970: libs libtool
! 9971: licence license
! 9972: lintl little-endian
! 9973: lock locking
! 9974: lua lvalue
! 9975: make makesum
! 9976: memory meta
1.233 wiz 9977: meta-package meta_package
9978: mit-krb5 mk.conf
9979: mkl mount
9980: move moved
9981: mprotect mremap
9982: nb nbcompat
9983: netlib node
9984: node.js nodejs
9985: obstack obstack_ptr_grow
9986: occurs only
9987: openblas options
9988: options.mk order
9989: override override-intltool
9990: override-message-intltool package
9991: parallel path
9992: pax paxctl
9993: pbulk-index pc
9994: perl perl5
9995: perms php
9996: pkg-build-options pkg-config
9997: pkg_build_options platform
9998: plist post-extract
9999: post-fetch post-wrapper
1.236 ! gutterid 10000: pre-build-checks-hook pre-configure-checks-hook
! 10001: pre-extract pre-fetch
! 10002: print-go-deps print-plist
! 10003: print-summary-data privileged-install-hook
! 10004: pypi python
! 10005: r readme-all
! 10006: recursive recv
! 10007: recvfrom regcomp
! 10008: release-localbase-lock release-lock
! 10009: relro remove
! 10010: removed rename
! 10011: renamed reorder
! 10012: replace replace_interpreter
! 10013: reproducible resolv
! 10014: root ruby
! 10015: send sendfile
! 10016: sendto setenv
! 10017: setgid setprogname
! 10018: setuid sh
! 10019: shebang show
! 10020: show-all show-build-defs
! 10021: show-depends show-depends-dirs
! 10022: show-depends-pkgpaths show-depends-recursive
! 10023: show-deps show-distfiles
! 10024: show-downlevel show-subdir-var
! 10025: show-tools show-var
! 10026: show-vars snprintf
! 10027: socket ssp
! 10028: st_mode stage-install
! 10029: strcasestr strict
! 10030: strip strndup
! 10031: strnlen strsep
! 10032: subst substitutions
1.232 gutterid 10033: sun sunpro
1.236 ! gutterid 10034: sunwspro symlink
! 10035: test test-env
! 10036: tex texlive
! 10037: tmp todo
! 10038: tool tools
! 10039: tools-libtool-m4-override transitive
! 10040: type ulimit
! 10041: undefined undo-replace
! 10042: unlimit unprivileged
! 10043: unprivileged-install-hook unstripped
! 10044: update updated
! 10045: upload upload-distfiles
! 10046: use_tools user
! 10047: utimes vasprintf
! 10048: verbose vsnprintf
! 10049: warn warning
! 10050: warnings warnx
! 10051: wattr_off wattr_on
! 10052: work wrapper
! 10053: wrkdir
1.154 rillig 10054:
1.207 leot 10055: Appendix F. Editing guidelines for the pkgsrc guide
1.1 dsieger 10056:
10057: Table of Contents
10058:
1.207 leot 10059: F.1. Make targets
10060: F.2. Procedure
1.1 dsieger 10061:
10062: This section contains information on editing the pkgsrc guide itself.
10063:
1.207 leot 10064: F.1. Make targets
1.1 dsieger 10065:
10066: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
10067: files are created from it:
10068:
10069: * pkgsrc/doc/pkgsrc.txt
10070:
10071: * pkgsrc/doc/pkgsrc.html
10072:
1.174 leot 10073: * https://www.NetBSD.org/docs/pkgsrc/
1.1 dsieger 10074:
1.174 leot 10075: * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the
10076: pkgsrc guide.
1.1 dsieger 10077:
1.174 leot 10078: * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
1.2 rillig 10079: pkgsrc guide.
1.1 dsieger 10080:
1.207 leot 10081: F.2. Procedure
1.1 dsieger 10082:
10083: The procedure to edit the pkgsrc guide is:
10084:
1.190 bacon 10085: 1. Make sure you have checked out the htdocs repository into a sibling
10086: directory of your pkgsrc directory. You will need the ability to commit
10087: from both pkgsrc and htdocs.
10088:
10089: 2. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46 obache 10090: other XML-based NetBSD documentation) installed. These are automatically
10091: installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1 dsieger 10092:
1.190 bacon 10093: 3. Run cd doc/guide to get to the right directory. All further steps will take
1.1 dsieger 10094: place here.
10095:
1.190 bacon 10096: 4. Edit the XML file(s) in files/.
1.1 dsieger 10097:
1.190 bacon 10098: 5. Run bmake to check the pkgsrc guide for valid XML and to build the final
1.1 dsieger 10099: output files. If you get any errors at this stage, you can just edit the
10100: files, as there are only symbolic links in the working directory, pointing
10101: to the files in files/.
10102:
1.190 bacon 10103: 6. (cd files && cvs commit)
1.1 dsieger 10104:
1.190 bacon 10105: 7. Run bmake clean && bmake to regenerate the output files with the proper RCS
1.1 dsieger 10106: Ids.
10107:
1.190 bacon 10108: 8. Run bmake regen to install and commit the files in both pkgsrc/doc and
1.1 dsieger 10109: htdocs.
10110:
10111: Note
10112:
10113: If you have added, removed or renamed some chapters, you need to
10114: synchronize them using cvs add or cvs delete in the htdocs directory.
10115:
CVSweb <webmaster@jp.NetBSD.org>