Annotation of htdocs/docs/pkgsrc/pkgsrc.txt, revision 1.217
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.213 jnemeth 15: Copyright 1994-2022 The NetBSD Foundation, Inc
1.1 dsieger 16:
1.213 jnemeth 17: $NetBSD: pkgsrc.xml,v 1.41 2022/01/01 06:45:38 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:
32: 1.1. Introduction
33:
34: 1.1.1. Why pkgsrc?
35: 1.1.2. Supported platforms
36:
37: 1.2. Overview
38: 1.3. Terminology
39:
40: 1.3.1. Roles involved in pkgsrc
41:
42: 1.4. Typography
43:
44: I. The pkgsrc user's guide
45:
1.154 rillig 46: 2. Getting help
47: 3. Where to get pkgsrc and how to keep it up-to-date
1.1 dsieger 48:
1.154 rillig 49: 3.1. Getting pkgsrc for the first time
1.1 dsieger 50:
1.154 rillig 51: 3.1.1. As tar archive
52: 3.1.2. Via anonymous CVS
1.1 dsieger 53:
1.154 rillig 54: 3.2. Keeping pkgsrc up-to-date
1.1 dsieger 55:
1.154 rillig 56: 3.2.1. Via tar files
57: 3.2.2. Via CVS
1.1 dsieger 58:
1.154 rillig 59: 4. Using pkgsrc on systems other than NetBSD
1.1 dsieger 60:
1.154 rillig 61: 4.1. Binary distribution
62: 4.2. Bootstrapping pkgsrc
1.1 dsieger 63:
1.154 rillig 64: 5. Using pkgsrc
1.1 dsieger 65:
1.154 rillig 66: 5.1. Using binary packages
1.1 dsieger 67:
1.154 rillig 68: 5.1.1. Finding binary packages
69: 5.1.2. Installing binary packages
1.202 nia 70: 5.1.3. Updating packages
71: 5.1.4. Deinstalling packages
72: 5.1.5. Getting information about installed packages
73: 5.1.6. Checking for security vulnerabilities in installed packages
74: 5.1.7. Finding if newer versions of your installed packages are in
1.1 dsieger 75: pkgsrc
1.202 nia 76: 5.1.8. Other administrative functions
1.1 dsieger 77:
1.154 rillig 78: 5.2. Building packages from source
1.1 dsieger 79:
1.154 rillig 80: 5.2.1. Requirements
81: 5.2.2. Fetching distfiles
82: 5.2.3. How to build and install
1.1 dsieger 83:
1.154 rillig 84: 6. Configuring pkgsrc
1.1 dsieger 85:
1.154 rillig 86: 6.1. General configuration
87: 6.2. Variables affecting the build process
88: 6.3. Variables affecting the installation process
89: 6.4. Selecting and configuring the compiler
1.1 dsieger 90:
1.154 rillig 91: 6.4.1. Selecting the compiler
92: 6.4.2. Additional flags to the compiler (CFLAGS)
93: 6.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 94:
1.154 rillig 95: 6.5. Developer/advanced settings
96: 6.6. Selecting Build Options
1.1 dsieger 97:
1.154 rillig 98: 7. Creating binary packages
1.1 dsieger 99:
1.154 rillig 100: 7.1. Building a single binary package
101: 7.2. Settings for creation of binary packages
1.1 dsieger 102:
1.154 rillig 103: 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6 rillig 104:
1.154 rillig 105: 8.1. Preparations
1.180 rillig 106: 8.2. Running a bulk build
1.6 rillig 107:
1.154 rillig 108: 8.2.1. Configuration
1.6 rillig 109:
1.154 rillig 110: 8.3. Requirements of a full bulk build
1.178 rillig 111: 8.4. Bulk build variants
1.6 rillig 112:
1.179 rillig 113: 8.4.1. Detect unknown configure options
114: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.181 rillig 115: 8.4.3. Force compiler options only in the build phase
116: 8.4.4. Use custom directories
117: 8.4.5. Turn warnings into errors
118: 8.4.6. Reject packages for which pkglint reports errors
119: 8.4.7. Reject packages that contain forbidden strings
120: 8.4.8. Reject packages whose self-test fails
121: 8.4.9. Reject packages that use undefined shell variables
122: 8.4.10. Turn off verbose logging
1.178 rillig 123:
124: 8.5. Creating a multiple CD-ROM packages collection
125:
126: 8.5.1. Example of cdpack
1.6 rillig 127:
1.154 rillig 128: 9. Directory layout of the installed files
1.6 rillig 129:
1.154 rillig 130: 9.1. File system layout in ${LOCALBASE}
131: 9.2. File system layout in ${VARBASE}
1.6 rillig 132:
1.154 rillig 133: 10. Frequently Asked Questions
1.6 rillig 134:
1.154 rillig 135: 10.1. Are there any mailing lists for pkg-related discussion?
136: 10.2. Utilities for package management (pkgtools)
137: 10.3. How to use pkgsrc as non-root
138: 10.4. How to resume transfers when fetching distfiles?
139: 10.5. How can I install/use modular X.org from pkgsrc?
140: 10.6. How to fetch files from behind a firewall
141: 10.7. How to fetch files from HTTPS sites
142: 10.8. How do I tell make fetch to do passive FTP?
143: 10.9. How to fetch all distfiles at once
144: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc"
1.24 wiz 145: mean?
1.154 rillig 146: 10.11. What does "Could not find bsd.own.mk" mean?
147: 10.12. Using 'sudo' with pkgsrc
148: 10.13. How do I change the location of configuration files?
149: 10.14. Automated security checks
150: 10.15. Why do some packages ignore my CFLAGS?
151: 10.16. A package does not build. What shall I do?
152: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/???
1.24 wiz 153: merge conflicts" mean?
1.1 dsieger 154:
155: II. The pkgsrc developer's guide
156:
1.154 rillig 157: 11. Getting help
1.184 rillig 158: 12. Package components - files, directories and contents
1.1 dsieger 159:
1.184 rillig 160: 12.1. Makefile
161: 12.2. distinfo
162: 12.3. patches/*
1.1 dsieger 163:
1.184 rillig 164: 12.3.1. Structure of a single patch file
165: 12.3.2. Creating patch files
166: 12.3.3. Sources where the patch files come from
167: 12.3.4. Patching guidelines
168: 12.3.5. Feedback to the author
1.1 dsieger 169:
1.184 rillig 170: 12.4. Other mandatory files
171: 12.5. Optional files
1.1 dsieger 172:
1.184 rillig 173: 12.5.1. Files affecting the binary package
174: 12.5.2. Files affecting the build process
175: 12.5.3. Files affecting nothing at all
1.1 dsieger 176:
1.184 rillig 177: 12.6. work*
178: 12.7. files/*
1.1 dsieger 179:
1.184 rillig 180: 13. The build process
1.1 dsieger 181:
1.184 rillig 182: 13.1. Introduction
183: 13.2. Program location
184: 13.3. Directories used during the build process
185: 13.4. Running a phase
186: 13.5. The fetch phase
1.1 dsieger 187:
1.184 rillig 188: 13.5.1. What to fetch and where to get it from
189: 13.5.2. How are the files fetched?
1.1 dsieger 190:
1.184 rillig 191: 13.6. The checksum phase
192: 13.7. The extract phase
193: 13.8. The patch phase
194: 13.9. The tools phase
195: 13.10. The wrapper phase
196: 13.11. The configure phase
197: 13.12. The build phase
198: 13.13. The test phase
199: 13.14. The install phase
200: 13.15. The package phase
201: 13.16. Cleaning up
202: 13.17. Other helpful targets
1.1 dsieger 203:
1.184 rillig 204: 14. Creating a new pkgsrc package from scratch
1.1 dsieger 205:
1.184 rillig 206: 14.1. Common types of packages
1.1 dsieger 207:
1.217 ! rillig 208: 14.1.1. Python modules and programs
! 209: 14.1.2. R packages
! 210: 14.1.3. TeXlive packages
1.1 dsieger 211:
1.184 rillig 212: 14.2. Examples
1.1 dsieger 213:
1.184 rillig 214: 14.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 215:
1.184 rillig 216: 15. Programming in Makefiles
1.1 dsieger 217:
1.184 rillig 218: 15.1. Caveats
219: 15.2. Makefile variables
1.1 dsieger 220:
1.184 rillig 221: 15.2.1. Naming conventions
1.1 dsieger 222:
1.184 rillig 223: 15.3. Code snippets
1.1 dsieger 224:
1.184 rillig 225: 15.3.1. Adding things to a list
226: 15.3.2. Echoing a string exactly as-is
227: 15.3.3. Passing CFLAGS to GNU configure scripts
228: 15.3.4. Handling possibly empty variables
1.1 dsieger 229:
1.184 rillig 230: 16. Options handling
1.1 dsieger 231:
1.184 rillig 232: 16.1. Global default options
233: 16.2. Converting packages to use bsd.options.mk
234: 16.3. Option Names
235: 16.4. Determining the options of dependencies
1.1 dsieger 236:
1.184 rillig 237: 17. Tools needed for building or running
1.1 dsieger 238:
1.184 rillig 239: 17.1. Tools for pkgsrc builds
240: 17.2. Tools needed by packages
241: 17.3. Tools provided by platforms
1.1 dsieger 242:
1.184 rillig 243: 18. Buildlink methodology
1.1 dsieger 244:
1.184 rillig 245: 18.1. Converting packages to use buildlink3
246: 18.2. Writing buildlink3.mk files
1.1 dsieger 247:
1.184 rillig 248: 18.2.1. Anatomy of a buildlink3.mk file
249: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
250: BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.1 dsieger 251:
1.184 rillig 252: 18.3. Writing builtin.mk files
1.1 dsieger 253:
1.184 rillig 254: 18.3.1. Anatomy of a builtin.mk file
255: 18.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 256:
1.184 rillig 257: 19. PLIST issues
1.1 dsieger 258:
1.184 rillig 259: 19.1. RCS ID
260: 19.2. Semi-automatic PLIST generation
261: 19.3. Tweaking output of make print-PLIST
262: 19.4. Variable substitution in PLIST
263: 19.5. Man page compression
264: 19.6. Changing PLIST source with PLIST_SRC
265: 19.7. Platform-specific and differing PLISTs
266: 19.8. Build-specific PLISTs
267: 19.9. Sharing directories between packages
1.1 dsieger 268:
1.184 rillig 269: 20. The pkginstall framework
1.1 dsieger 270:
1.184 rillig 271: 20.1. Files and directories outside the installation prefix
1.1 dsieger 272:
1.184 rillig 273: 20.1.1. Directory manipulation
274: 20.1.2. File manipulation
1.1 dsieger 275:
1.184 rillig 276: 20.2. Configuration files
1.1 dsieger 277:
1.184 rillig 278: 20.2.1. How PKG_SYSCONFDIR is set
279: 20.2.2. Telling the software where configuration files are
280: 20.2.3. Patching installations
281: 20.2.4. Disabling handling of configuration files
1.1 dsieger 282:
1.184 rillig 283: 20.3. System startup scripts
1.1 dsieger 284:
1.184 rillig 285: 20.3.1. Disabling handling of system startup scripts
1.1 dsieger 286:
1.184 rillig 287: 20.4. System users and groups
288: 20.5. System shells
1.1 dsieger 289:
1.184 rillig 290: 20.5.1. Disabling shell registration
1.1 dsieger 291:
1.184 rillig 292: 20.6. Fonts
1.1 dsieger 293:
1.184 rillig 294: 20.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 295:
1.154 rillig 296: 21. Making your package work
1.1 dsieger 297:
1.154 rillig 298: 21.1. General operation
1.1 dsieger 299:
1.154 rillig 300: 21.1.1. How to pull in user-settable variables from mk.conf
301: 21.1.2. User interaction
302: 21.1.3. Handling licenses
303: 21.1.4. Restricted packages
304: 21.1.5. Handling dependencies
305: 21.1.6. Handling conflicts with other packages
306: 21.1.7. Packages that cannot or should not be built
307: 21.1.8. Packages which should not be deleted, once installed
308: 21.1.9. Handling packages with security problems
309: 21.1.10. How to handle incrementing versions when fixing an
1.1 dsieger 310: existing package
1.154 rillig 311: 21.1.11. Substituting variable text in the package files (the SUBST
1.1 dsieger 312: framework)
313:
1.154 rillig 314: 21.2. The fetch phase
1.1 dsieger 315:
1.154 rillig 316: 21.2.1. Packages whose distfiles aren't available for plain
1.1 dsieger 317: downloading
1.154 rillig 318: 21.2.2. How to handle modified distfiles with the 'old' name
319: 21.2.3. Packages hosted on github.com
1.1 dsieger 320:
1.154 rillig 321: 21.3. The configure phase
1.1 dsieger 322:
1.154 rillig 323: 21.3.1. Shared libraries - libtool
324: 21.3.2. Using libtool on GNU packages that already support libtool
325: 21.3.3. GNU Autoconf/Automake
326:
327: 21.4. Programming languages
328:
329: 21.4.1. C, C++, and Fortran
330: 21.4.2. Java
1.205 wiz 331: 21.4.3. Go
332: 21.4.4. Packages containing Perl scripts
333: 21.4.5. Packages containing shell scripts
334: 21.4.6. Other programming languages
1.154 rillig 335:
336: 21.5. The build phase
337:
338: 21.5.1. Compiling C and C++ code conditionally
339: 21.5.2. How to handle compiler bugs
1.172 rillig 340: 21.5.3. No such file or directory
341: 21.5.4. Undefined reference to "..."
342: 21.5.5. Running out of memory
1.154 rillig 343:
344: 21.6. The install phase
345:
346: 21.6.1. Creating needed directories
347: 21.6.2. Where to install documentation
348: 21.6.3. Installing highscore files
349: 21.6.4. Adding DESTDIR support to packages
350: 21.6.5. Packages with hardcoded paths to other interpreters
1.203 nia 351: 21.6.6. Packages installing Perl modules
1.154 rillig 352: 21.6.7. Packages installing info files
353: 21.6.8. Packages installing man pages
1.203 nia 354: 21.6.9. Packages installing X11 fonts
355: 21.6.10. Packages installing SGML or XML data
356: 21.6.11. Packages installing extensions to the MIME database
357: 21.6.12. Packages using intltool
358: 21.6.13. Packages installing startup scripts
359: 21.6.14. Packages installing TeX modules
360: 21.6.15. Packages supporting running binaries in emulation
361: 21.6.16. Packages installing hicolor icons
362: 21.6.17. Packages installing desktop files
1.154 rillig 363:
364: 21.7. Marking packages as having problems
365:
1.184 rillig 366: 22. GNOME packaging and porting
367:
368: 22.1. Meta packages
369: 22.2. Packaging a GNOME application
370: 22.3. Updating GNOME to a newer version
371: 22.4. Patching guidelines
372:
1.154 rillig 373: 23. Submitting and Committing
374:
375: 23.1. Submitting binary packages
376: 23.2. Submitting source packages (for non-NetBSD-developers)
377: 23.3. General notes when adding, updating, or removing packages
378: 23.4. Commit Messages
379: 23.5. Committing: Adding a package to CVS
380: 23.6. Updating a package to a newer version
381: 23.7. Renaming a package in pkgsrc
382: 23.8. Moving a package in pkgsrc
383:
384: 24. Frequently Asked Questions
1.1 dsieger 385:
386: III. The pkgsrc infrastructure internals
387:
1.184 rillig 388: 25. Design of the pkgsrc infrastructure
1.1 dsieger 389:
1.184 rillig 390: 25.1. The meaning of variable definitions
391: 25.2. Avoiding problems before they arise
392: 25.3. Variable evaluation
1.1 dsieger 393:
1.184 rillig 394: 25.3.1. At load time
395: 25.3.2. At runtime
1.1 dsieger 396:
1.184 rillig 397: 25.4. How can variables be specified?
398: 25.5. Designing interfaces for Makefile fragments
1.1 dsieger 399:
1.184 rillig 400: 25.5.1. Procedures with parameters
401: 25.5.2. Actions taken on behalf of parameters
1.1 dsieger 402:
1.184 rillig 403: 25.6. The order in which files are loaded
1.1 dsieger 404:
1.184 rillig 405: 25.6.1. The order in bsd.prefs.mk
406: 25.6.2. The order in bsd.pkg.mk
1.1 dsieger 407:
1.184 rillig 408: 26. Regression tests
1.1 dsieger 409:
1.184 rillig 410: 26.1. Running the regression tests
411: 26.2. Adding a new regression test
1.1 dsieger 412:
1.184 rillig 413: 26.2.1. Overridable functions
414: 26.2.2. Helper functions
1.1 dsieger 415:
1.184 rillig 416: 27. Porting pkgsrc
1.1 dsieger 417:
1.184 rillig 418: 27.1. Porting pkgsrc to a new operating system
1.1 dsieger 419:
420: A. A simple example package: bison
421:
422: A.1. files
423:
424: A.1.1. Makefile
425: A.1.2. DESCR
426: A.1.3. PLIST
427: A.1.4. Checking a package with pkglint
428:
429: A.2. Steps for building, installing, packaging
430:
1.207 leot 431: B. Security hardening
1.1 dsieger 432:
1.207 leot 433: B.1. Mechanisms
1.1 dsieger 434:
1.207 leot 435: B.1.1. Enabled by default
436: B.1.2. Not enabled by default
1.1 dsieger 437:
1.207 leot 438: B.2. Caveats
1.1 dsieger 439:
1.207 leot 440: B.2.1. Problems with PKGSRC_MKPIE
441: B.2.2. Problems with PKGSRC_USE_FORTIFY
442: B.2.3. Problems with PKGSRC_USE_RELRO
443: B.2.4. Problems with PKGSRC_USE_SSP
1.1 dsieger 444:
1.207 leot 445: B.3. Auditing the system
446:
447: B.3.1. Checking for PIE
448: B.3.2. Checking for partial RELRO
449: B.3.3. Checking for full RELRO
450: B.3.4. Checking for SSP
451:
452: C. Build logs
453:
454: C.1. Building figlet
455: C.2. Packaging figlet
456:
457: D. Directory layout of the pkgsrc FTP server
458:
459: D.1. distfiles: The distributed source files
460: D.2. misc: Miscellaneous things
461: D.3. packages: Binary packages
462: D.4. reports: Bulk build reports
463: D.5. current, stable, pkgsrc-20xxQy: source packages
464:
465: E. Help topics
466: F. Editing guidelines for the pkgsrc guide
467:
468: F.1. Make targets
469: F.2. Procedure
1.1 dsieger 470:
471: List of Tables
472:
473: 1.1. Platforms supported by pkgsrc
1.184 rillig 474: 12.1. Patching examples
475: 22.1. PLIST handling for GNOME packages
1.1 dsieger 476:
477: Chapter 1. What is pkgsrc?
478:
479: Table of Contents
480:
481: 1.1. Introduction
482:
483: 1.1.1. Why pkgsrc?
484: 1.1.2. Supported platforms
485:
486: 1.2. Overview
487: 1.3. Terminology
488:
489: 1.3.1. Roles involved in pkgsrc
490:
491: 1.4. Typography
492:
493: 1.1. Introduction
494:
495: There is a lot of software freely available for Unix-based systems, which is
496: usually available in form of the source code. Before such software can be used,
497: it needs to be configured to the local system, compiled and installed, and this
498: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
499: some basic commands to handle binary packages, so that not every user has to
500: build the packages for himself, which is a time-costly task.
501:
502: pkgsrc currently contains several thousand packages, including:
503:
1.104 sevan 504: * www/apache24 - The Apache web server
1.1 dsieger 505:
506: * www/firefox - The Firefox web browser
507:
508: * meta-pkgs/gnome - The GNOME Desktop Environment
509:
1.102 ryoon 510: * meta-pkgs/kde4 - The K Desktop Environment
1.1 dsieger 511:
1.108 rillig 512: ? just to name a few.
1.1 dsieger 513:
514: pkgsrc has built-in support for handling varying dependencies, such as pthreads
515: and X11, and extended features such as IPv6 support on a range of platforms.
516:
517: 1.1.1. Why pkgsrc?
518:
519: pkgsrc provides the following key features:
520:
521: * Easy building of software from source as well as the creation and
522: installation of binary packages. The source and latest patches are
523: retrieved from a master or mirror download site, checksum verified, then
524: built on your system. Support for binary-only distributions is available
525: for both native platforms and NetBSD emulated platforms.
526:
527: * All packages are installed in a consistent directory tree, including
528: binaries, libraries, man pages and other documentation.
529:
1.104 sevan 530: * Tracking of package dependencies automatically, including when performing
531: updates, to ensure required packages are installed. The configuration files
532: of various packages are handled automatically during updates, so local
533: changes are preserved.
1.1 dsieger 534:
535: * Like NetBSD, pkgsrc is designed with portability in mind and consists of
536: highly portable code. This allows the greatest speed of development when
1.26 spz 537: porting to a new platform. This portability also ensures that pkgsrc is
1.1 dsieger 538: consistent across all platforms.
539:
540: * The installation prefix, acceptable software licenses, international
541: encryption requirements and build-time options for a large number of
542: packages are all set in a simple, central configuration file.
543:
544: * The entire source (not including the distribution files) is freely
545: available under a BSD license, so you may extend and adapt pkgsrc to your
546: needs. Support for local packages and patches is available right out of the
547: box, so you can configure it specifically for your environment.
548:
549: The following principles are basic to pkgsrc:
550:
1.198 leot 551: * "It should only work if it's right." -- That means, if a package contains
1.1 dsieger 552: bugs, it's better to find them and to complain about them rather than to
553: just install the package and hope that it works. There are numerous checks
1.175 gutterid 554: in pkgsrc that try to find such bugs: static analysis tools (pkgtools/
1.1 dsieger 555: pkglint), build-time checks (portability of shell scripts), and
556: post-installation checks (installed files, references to shared libraries,
557: script interpreters).
558:
1.198 leot 559: * "If it works, it should work everywhere" -- Like NetBSD has been ported to
1.1 dsieger 560: many hardware architectures, pkgsrc has been ported to many operating
561: systems. Care is taken that packages behave the same on all platforms.
562:
563: 1.1.2. Supported platforms
564:
565: pkgsrc consists of both a source distribution and a binary distribution for
566: these operating systems. After retrieving the required source or binaries, you
567: can be up and running with pkgsrc in just minutes!
568:
569: pkgsrc was derived from FreeBSD's ports system, and initially developed for
570: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
571: platforms:
572:
573: Table 1.1. Platforms supported by pkgsrc
574:
1.92 sevan 575: +-----------------------------------------------------------------------------+
576: | Platform | Date Support | Notes |
577: | | Added | |
578: |--------------------------------------+---------------+----------------------|
579: |NetBSD | Aug 1997 | |
580: |--------------------------------------+---------------+----------------------|
581: |Solaris | Mar 1999 |README.Solaris |
582: |--------------------------------------+---------------+----------------------|
583: |Linux | Jun 1999 |README.Linux |
584: |--------------------------------------+---------------+----------------------|
1.191 bacon 585: |Darwin / Mac OS X / OS X / macOS | Oct 2001 |README.macOS |
1.92 sevan 586: |--------------------------------------+---------------+----------------------|
587: |FreeBSD | Nov 2002 |README.FreeBSD |
588: |--------------------------------------+---------------+----------------------|
589: |OpenBSD | Nov 2002 |README.OpenBSD |
590: |--------------------------------------+---------------+----------------------|
591: |IRIX | Dec 2002 |README.IRIX |
592: | | |README.IRIX5.3 |
593: |--------------------------------------+---------------+----------------------|
594: |BSD/OS | Dec 2003 | |
595: |--------------------------------------+---------------+----------------------|
596: |AIX | Dec 2003 |README.AIX |
597: |--------------------------------------+---------------+----------------------|
598: |Interix (Microsoft Windows Services | Mar 2004 |README.Interix |
599: |for Unix) | | |
600: |--------------------------------------+---------------+----------------------|
601: |DragonFlyBSD | Oct 2004 | |
602: |--------------------------------------+---------------+----------------------|
603: |OSF/1 | Nov 2004 |README.OSF1 |
604: |--------------------------------------+---------------+----------------------|
605: |HP-UX | Apr 2007 |README.HPUX |
606: |--------------------------------------+---------------+----------------------|
607: |Haiku | Sep 2010 |README.Haiku |
608: |--------------------------------------+---------------+----------------------|
609: |MirBSD | Jan 2011 | |
610: |--------------------------------------+---------------+----------------------|
611: |Minix3 | Nov 2011 |README.Minix3 |
612: |--------------------------------------+---------------+----------------------|
613: |Cygwin | Mar 2013 |README.Cygwin |
614: |--------------------------------------+---------------+----------------------|
615: |GNU/kFreeBSD | Jul 2013 |README.GNUkFreeBSD |
1.104 sevan 616: |--------------------------------------+---------------+----------------------|
617: |Bitrig | Jun 2014 |README.Bitrig |
1.92 sevan 618: +-----------------------------------------------------------------------------+
1.1 dsieger 619:
620:
621: 1.2. Overview
622:
623: This document is divided into three parts. The first, The pkgsrc user's guide,
624: describes how one can use one of the packages in the Package Collection, either
625: by installing a precompiled binary package, or by building one's own copy using
626: the NetBSD package system. The second part, The pkgsrc developer's guide,
627: explains how to prepare a package so it can be easily built by other NetBSD
628: users without knowing about the package's building details. The third part, The
629: pkgsrc infrastructure internals is intended for those who want to understand
630: how pkgsrc is implemented.
631:
632: This document is available in various formats: HTML, PDF, PS, TXT.
633:
634: 1.3. Terminology
635:
636: There has been a lot of talk about "ports", "packages", etc. so far. Here is a
637: description of all the terminology used within this document.
638:
639: Package
640:
641: A set of files and building instructions that describe what's necessary to
642: build a certain piece of software using pkgsrc. Packages are traditionally
1.123 wiz 643: stored under /usr/pkgsrc, but may be stored in any location, referred to as
644: PKGSRCDIR.
1.1 dsieger 645:
646: The NetBSD package system
647:
648: This is the former name of "pkgsrc". It is part of the NetBSD operating
649: system and can be bootstrapped to run on non-NetBSD operating systems as
650: well. It handles building (compiling), installing, and removing of
651: packages.
652:
653: Distfile
654:
655: This term describes the file or files that are provided by the author of
656: the piece of software to distribute his work. All the changes necessary to
657: build on NetBSD are reflected in the corresponding package. Usually the
658: distfile is in the form of a compressed tar-archive, but other types are
659: possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
660:
661: Port
662:
663: This is the term used by FreeBSD and OpenBSD people for what we call a
664: package. In NetBSD terminology, "port" refers to a different architecture.
665:
666: Precompiled/binary package
667:
668: A set of binaries built with pkgsrc from a distfile and stuffed together in
669: a single .tgz file so it can be installed on machines of the same machine
670: architecture without the need to recompile. Packages are usually generated
671: in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
672:
673: Sometimes, this is referred to by the term "package" too, especially in the
674: context of precompiled packages.
675:
676: Program
677:
678: The piece of software to be installed which will be constructed from all
679: the files in the distfile by the actions defined in the corresponding
680: package.
681:
682: 1.3.1. Roles involved in pkgsrc
683:
684: pkgsrc users
685:
686: The pkgsrc users are people who use the packages provided by pkgsrc.
687: Typically they are system administrators. The people using the software
688: that is inside the packages (maybe called "end users") are not covered by
689: the pkgsrc guide.
690:
691: There are two kinds of pkgsrc users: Some only want to install pre-built
692: binary packages. Others build the pkgsrc packages from source, either for
693: installing them directly or for building binary packages themselves. For
694: pkgsrc users Part I, "The pkgsrc user's guide" should provide all necessary
695: documentation.
696:
697: package maintainers
698:
699: A package maintainer creates packages as described in Part II, "The pkgsrc
700: developer's guide".
701:
702: infrastructure developers
703:
704: These people are involved in all those files that live in the mk/ directory
705: and below. Only these people should need to read through Part III, "The
706: pkgsrc infrastructure internals", though others might be curious, too.
707:
708: 1.4. Typography
709:
710: When giving examples for commands, shell prompts are used to show if the
711: command should/can be issued as root, or if "normal" user privileges are
1.115 sevan 712: sufficient. We use a # for root's shell prompt, a % for users' shell prompt,
713: assuming they use the C-shell or tcsh and a $ for bourne shell and derivatives.
1.1 dsieger 714:
715: Part I. The pkgsrc user's guide
716:
717: Table of Contents
718:
1.154 rillig 719: 2. Getting help
720: 3. Where to get pkgsrc and how to keep it up-to-date
1.1 dsieger 721:
1.154 rillig 722: 3.1. Getting pkgsrc for the first time
1.1 dsieger 723:
1.154 rillig 724: 3.1.1. As tar archive
725: 3.1.2. Via anonymous CVS
1.1 dsieger 726:
1.154 rillig 727: 3.2. Keeping pkgsrc up-to-date
1.1 dsieger 728:
1.154 rillig 729: 3.2.1. Via tar files
730: 3.2.2. Via CVS
1.1 dsieger 731:
1.154 rillig 732: 4. Using pkgsrc on systems other than NetBSD
1.1 dsieger 733:
1.154 rillig 734: 4.1. Binary distribution
735: 4.2. Bootstrapping pkgsrc
1.1 dsieger 736:
1.154 rillig 737: 5. Using pkgsrc
1.1 dsieger 738:
1.154 rillig 739: 5.1. Using binary packages
1.1 dsieger 740:
1.154 rillig 741: 5.1.1. Finding binary packages
742: 5.1.2. Installing binary packages
1.202 nia 743: 5.1.3. Updating packages
744: 5.1.4. Deinstalling packages
745: 5.1.5. Getting information about installed packages
746: 5.1.6. Checking for security vulnerabilities in installed packages
747: 5.1.7. Finding if newer versions of your installed packages are in
1.1 dsieger 748: pkgsrc
1.202 nia 749: 5.1.8. Other administrative functions
1.1 dsieger 750:
1.154 rillig 751: 5.2. Building packages from source
1.1 dsieger 752:
1.154 rillig 753: 5.2.1. Requirements
754: 5.2.2. Fetching distfiles
755: 5.2.3. How to build and install
1.1 dsieger 756:
1.154 rillig 757: 6. Configuring pkgsrc
1.1 dsieger 758:
1.154 rillig 759: 6.1. General configuration
760: 6.2. Variables affecting the build process
761: 6.3. Variables affecting the installation process
762: 6.4. Selecting and configuring the compiler
1.1 dsieger 763:
1.154 rillig 764: 6.4.1. Selecting the compiler
765: 6.4.2. Additional flags to the compiler (CFLAGS)
766: 6.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 767:
1.154 rillig 768: 6.5. Developer/advanced settings
769: 6.6. Selecting Build Options
1.1 dsieger 770:
1.154 rillig 771: 7. Creating binary packages
1.1 dsieger 772:
1.154 rillig 773: 7.1. Building a single binary package
774: 7.2. Settings for creation of binary packages
1.1 dsieger 775:
1.154 rillig 776: 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6 rillig 777:
1.154 rillig 778: 8.1. Preparations
1.180 rillig 779: 8.2. Running a bulk build
1.6 rillig 780:
1.154 rillig 781: 8.2.1. Configuration
1.6 rillig 782:
1.154 rillig 783: 8.3. Requirements of a full bulk build
1.178 rillig 784: 8.4. Bulk build variants
785:
1.179 rillig 786: 8.4.1. Detect unknown configure options
787: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.181 rillig 788: 8.4.3. Force compiler options only in the build phase
789: 8.4.4. Use custom directories
790: 8.4.5. Turn warnings into errors
791: 8.4.6. Reject packages for which pkglint reports errors
792: 8.4.7. Reject packages that contain forbidden strings
793: 8.4.8. Reject packages whose self-test fails
794: 8.4.9. Reject packages that use undefined shell variables
795: 8.4.10. Turn off verbose logging
1.6 rillig 796:
1.178 rillig 797: 8.5. Creating a multiple CD-ROM packages collection
798:
799: 8.5.1. Example of cdpack
1.6 rillig 800:
1.154 rillig 801: 9. Directory layout of the installed files
1.6 rillig 802:
1.154 rillig 803: 9.1. File system layout in ${LOCALBASE}
804: 9.2. File system layout in ${VARBASE}
1.6 rillig 805:
1.154 rillig 806: 10. Frequently Asked Questions
1.6 rillig 807:
1.154 rillig 808: 10.1. Are there any mailing lists for pkg-related discussion?
809: 10.2. Utilities for package management (pkgtools)
810: 10.3. How to use pkgsrc as non-root
811: 10.4. How to resume transfers when fetching distfiles?
812: 10.5. How can I install/use modular X.org from pkgsrc?
813: 10.6. How to fetch files from behind a firewall
814: 10.7. How to fetch files from HTTPS sites
815: 10.8. How do I tell make fetch to do passive FTP?
816: 10.9. How to fetch all distfiles at once
817: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
818: 10.11. What does "Could not find bsd.own.mk" mean?
819: 10.12. Using 'sudo' with pkgsrc
820: 10.13. How do I change the location of configuration files?
821: 10.14. Automated security checks
822: 10.15. Why do some packages ignore my CFLAGS?
823: 10.16. A package does not build. What shall I do?
824: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24 wiz 825: conflicts" mean?
1.1 dsieger 826:
1.154 rillig 827: Chapter 2. Getting help
828:
829: To get help when using pkgsrc, the definitive source is this document, the
830: pkgsrc guide. If you don't find anything here, there are alternatives:
831:
832: * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
833: Run bmake help topic=? to get help for any topic, such as a variable name
834: like BUILD_DEFS, a make target like do-build, a missing C or C++ function
835: like strcasecmp or any other topic.
836:
1.207 leot 837: The available help topics are listed in Appendix E, Help topics.
1.154 rillig 838:
1.163 rillig 839: * To see the value of a single variable, run bmake show-var VARNAME=X.
840:
841: * To see the values of the most common variables, run bmake show-all. These
842: variables are grouped by topic. To see the variables for a single topic,
843: run bmake show-all-topic, for example bmake show-all-fetch.
844:
1.154 rillig 845: * The pkgsrc-users mailing list, to which you can subscribe and then ask your
846: questions.
847:
848: * The #pkgsrc IRC channel, which is accessible via a web browser or by using
849: a specialized chat program such as XChat. Pick any user name and join the
850: channel #pkgsrc.
851:
852: Chapter 3. Where to get pkgsrc and how to keep it up-to-date
1.1 dsieger 853:
854: Table of Contents
855:
1.154 rillig 856: 3.1. Getting pkgsrc for the first time
1.1 dsieger 857:
1.154 rillig 858: 3.1.1. As tar archive
859: 3.1.2. Via anonymous CVS
1.1 dsieger 860:
1.154 rillig 861: 3.2. Keeping pkgsrc up-to-date
1.1 dsieger 862:
1.154 rillig 863: 3.2.1. Via tar files
864: 3.2.2. Via CVS
1.1 dsieger 865:
866: Before you download and extract the files, you need to decide where you want to
867: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
868: usr/pkgsrc. You are though free to install the sources and binary packages
869: wherever you want in your filesystem, provided that the pathname does not
870: contain white-space or other characters that are interpreted specially by the
871: shell and some other programs. A safe bet is to use only letters, digits,
872: underscores and dashes.
873:
1.154 rillig 874: 3.1. Getting pkgsrc for the first time
1.1 dsieger 875:
1.25 wiz 876: Before you download any pkgsrc files, you should decide whether you want the
1.1 dsieger 877: current branch or the stable branch. The latter is forked on a quarterly basis
878: from the current branch and only gets modified for security updates. The names
879: of the stable branches are built from the year and the quarter, for example
1.214 leot 880: 2021Q4.
1.1 dsieger 881:
882: The second step is to decide how you want to download pkgsrc. You can get it as
1.24 wiz 883: a tar file or via CVS. Both ways are described here.
1.1 dsieger 884:
1.52 asau 885: Note that tar archive contains CVS working copy. Thus you can switch to using
886: CVS at any later time.
1.1 dsieger 887:
1.154 rillig 888: 3.1.1. As tar archive
1.52 asau 889:
1.151 sevan 890: The primary download location for all pkgsrc files is https://cdn.NetBSD.org/
891: pub/pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same
892: location). There are a number of subdirectories for different purposes, which
1.207 leot 893: are described in detail in Appendix D, Directory layout of the pkgsrc FTP
1.151 sevan 894: server.
1.1 dsieger 895:
1.52 asau 896: The tar archive for the current branch is in the directory current and is
1.118 sevan 897: called pkgsrc.tar.gz. It is autogenerated weekly.
1.52 asau 898:
899: To save download time we provide bzip2- and xz-compressed archives which are
900: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
901:
902: You can fetch the same files using FTP.
1.1 dsieger 903:
1.214 leot 904: The tar file for the stable branch 2021Q4 is in the directory pkgsrc-2021Q4 and
1.59 jnemeth 905: is also called pkgsrc.tar.gz.
1.1 dsieger 906:
1.136 leot 907: To download the latest pkgsrc stable tarball, run:
1.12 weinem 908:
1.214 leot 909: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2021Q4/pkgsrc.tar.gz
1.12 weinem 910:
1.78 snj 911: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52 asau 912:
1.12 weinem 913: Then, extract it with:
914:
1.78 snj 915: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12 weinem 916:
917: This will create the directory pkgsrc/ in /usr/ and all the package source will
918: be stored under /usr/pkgsrc/.
919:
920: To download pkgsrc-current, run:
921:
922: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1 dsieger 923:
1.154 rillig 924: 3.1.2. Via anonymous CVS
1.1 dsieger 925:
1.24 wiz 926: To fetch a specific pkgsrc stable branch, run:
1.1 dsieger 927:
1.214 leot 928: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2021Q4 -P pkgsrc
1.13 weinem 929:
1.24 wiz 930: This will create the directory pkgsrc/ in your /usr/ directory and all the
931: package source will be stored under /usr/pkgsrc/.
932:
933: To fetch the pkgsrc current branch, run:
1.1 dsieger 934:
1.40 wiz 935: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 936:
1.30 dholland 937: Refer to the list of available mirrors to choose a faster CVS mirror, if
938: needed.
1.1 dsieger 939:
1.24 wiz 940: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1 dsieger 941:
1.40 wiz 942: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 943:
1.24 wiz 944: Refer to documentation on your command shell how to set CVS_RSH=ssh
945: permanently. For Bourne shells, you can set it in your .profile or better
946: globally in /etc/profile:
947:
948: # set CVS remote shell command
949: CVS_RSH=ssh
950: export CVS_RSH
1.12 weinem 951:
1.13 weinem 952: By default, CVS doesn't do things like most people would expect it to do. But
953: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12 weinem 954: directory and saving the following lines to it. This file will save you lots of
955: headache and some bug reports, so we strongly recommend it. You can find an
956: explanation of this file in the CVS documentation.
1.2 rillig 957:
958: # recommended CVS configuration file from the pkgsrc guide
1.155 sevan 959: cvs -q
1.2 rillig 960: checkout -P
1.4 rillig 961: update -dP
962: diff -upN
1.2 rillig 963: rdiff -u
1.24 wiz 964: release -d
1.1 dsieger 965:
1.154 rillig 966: 3.2. Keeping pkgsrc up-to-date
1.1 dsieger 967:
968: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
969: have first installed it via a tar file). It saves bandwidth and hard disk
970: activity, compared to downloading the tar file again.
971:
1.154 rillig 972: 3.2.1. Via tar files
1.1 dsieger 973:
974: Warning
975:
976: When updating from a tar file, you first need to completely remove the old
977: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
978: the mean time will not be removed on your local disk, resulting in
979: inconsistencies. When removing the old files, any changes that you have done to
980: the pkgsrc files will be lost after updating. Therefore updating via CVS is
981: strongly recommended.
982:
983: Note that by default the distfiles and the binary packages are saved in the
984: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78 snj 985: configure pkgsrc to store distfiles and packages in directories outside the
1.154 rillig 986: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter 6,
1.78 snj 987: Configuring pkgsrc for the details.
1.1 dsieger 988:
989: To update pkgsrc from a tar file, download the tar file as explained above.
990: Then, make sure that you have not made any changes to the files in the pkgsrc
991: directory. Remove the pkgsrc directory and extract the new tar file. Done.
992:
1.154 rillig 993: 3.2.2. Via CVS
1.1 dsieger 994:
1.26 spz 995: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12 weinem 996:
1.26 spz 997: $ cd /usr/pkgsrc && cvs update -dP
998:
999: If you get error messages from rsh, you need to set CVS_RSH variable as
1000: described above. E.g.:
1001:
1002: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1 dsieger 1003:
1.154 rillig 1004: 3.2.2.1. Switching between different pkgsrc branches
1.1 dsieger 1005:
1006: When updating pkgsrc, the CVS program keeps track of the branch you selected.
1007: But if you, for whatever reason, want to switch from the stable branch to the
1008: current one, you can do it by adding the option "-A" after the "update"
1.25 wiz 1009: keyword. To switch from the current branch back to the stable branch, add the "
1.214 leot 1010: -rpkgsrc-2021Q4" option.
1.1 dsieger 1011:
1.154 rillig 1012: 3.2.2.2. What happens to my changes when updating?
1.1 dsieger 1013:
1014: When you update pkgsrc, the CVS program will only touch those files that are
1015: registered in the CVS repository. That means that any packages that you created
1016: on your own will stay unmodified. If you change files that are managed by CVS,
1017: later updates will try to merge your changes with those that have been done by
1018: others. See the CVS manual, chapter "update" for details.
1019:
1.154 rillig 1020: Chapter 4. Using pkgsrc on systems other than NetBSD
1.1 dsieger 1021:
1022: Table of Contents
1023:
1.154 rillig 1024: 4.1. Binary distribution
1025: 4.2. Bootstrapping pkgsrc
1.1 dsieger 1026:
1.154 rillig 1027: 4.1. Binary distribution
1.1 dsieger 1028:
1.154 rillig 1029: See Section 5.1, "Using binary packages".
1.1 dsieger 1030:
1.154 rillig 1031: 4.2. Bootstrapping pkgsrc
1.1 dsieger 1032:
1.44 asau 1033: pkgsrc can be bootstrapped for use in two different modes: privileged and
1034: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45 asau 1035: programs are installed under one particular user and cannot utilise privileged
1.44 asau 1036: operations (packages don't create special users and all special file
1037: permissions like setuid are ignored).
1038:
1.1 dsieger 1039: Installing the bootstrap kit from source should be as simple as:
1040:
1.60 asau 1041: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 1042: # cd pkgsrc/bootstrap
1043: # ./bootstrap
1044:
1045:
1.44 asau 1046: To bootstrap in unprivileged mode pass "--unprivileged" flag to bootstrap
1047:
1048: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1.118 sevan 1049: will be installed in, and /usr/pkg/pkgdb for the package database directory
1050: where pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1.44 asau 1051: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1.118 sevan 1052: for prefix, ~/pkg/pkgdb for the package database, and ~/pkg/var for varbase.
1.44 asau 1053:
1054: You can change default layout using command-line arguments. Run "./bootstrap
1055: --help" to get details.
1.1 dsieger 1056:
1057: Note
1058:
1059: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
1060: For examples in this guide, use bmake instead of "make".
1061:
1.44 asau 1062: Note
1063:
1064: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
1065: directories. Use bmake corresponding to the installation you're working with to
1066: build and install packages.
1067:
1.154 rillig 1068: Chapter 5. Using pkgsrc
1.1 dsieger 1069:
1070: Table of Contents
1071:
1.154 rillig 1072: 5.1. Using binary packages
1.1 dsieger 1073:
1.154 rillig 1074: 5.1.1. Finding binary packages
1075: 5.1.2. Installing binary packages
1.202 nia 1076: 5.1.3. Updating packages
1077: 5.1.4. Deinstalling packages
1078: 5.1.5. Getting information about installed packages
1079: 5.1.6. Checking for security vulnerabilities in installed packages
1080: 5.1.7. Finding if newer versions of your installed packages are in pkgsrc
1081: 5.1.8. Other administrative functions
1.154 rillig 1082:
1083: 5.2. Building packages from source
1084:
1085: 5.2.1. Requirements
1086: 5.2.2. Fetching distfiles
1087: 5.2.3. How to build and install
1.1 dsieger 1088:
1089: Basically, there are two ways of using pkgsrc. The first is to only install the
1090: package tools and to use binary packages that someone else has prepared. This
1091: is the "pkg" in pkgsrc. The second way is to install the "src" of pkgsrc, too.
1092: Then you are able to build your own packages, and you can still use binary
1093: packages from someone else.
1094:
1.154 rillig 1095: 5.1. Using binary packages
1.1 dsieger 1096:
1.151 sevan 1097: On the cdn.NetBSD.org site and mirrors, there are collections of binary
1.9 rillig 1098: packages, ready to be installed. These binary packages have been built using
1099: the default settings for the directories, that is:
1100:
1101: * /usr/pkg for LOCALBASE, where most of the files are installed,
1102:
1103: * /usr/pkg/etc for configuration files,
1104:
1105: * /var for VARBASE, where those files are installed that may change after
1106: installation.
1107:
1108: If you cannot use these directories for whatever reasons (maybe because you're
1109: not root), you cannot use these binary packages, but have to build the packages
1.154 rillig 1110: yourself, which is explained in Section 4.2, "Bootstrapping pkgsrc".
1.1 dsieger 1111:
1.154 rillig 1112: 5.1.1. Finding binary packages
1.1 dsieger 1113:
1.5 weinem 1114: To install binary packages, you first need to know from where to get them. The
1.202 nia 1115: first place where you should look is on the main pkgsrc CDN in the directory /
1116: pub/pkgsrc/packages.
1.5 weinem 1117:
1118: This directory contains binary packages for multiple platforms. First, select
1119: your operating system. (Ignore the directories with version numbers attached to
1120: it, they just exist for legacy reasons.) Then, select your hardware
1121: architecture, and in the third step, the OS version and the "version" of
1.9 rillig 1122: pkgsrc.
1123:
1124: In this directory, you often find a file called bootstrap.tar.gz which contains
1125: the package management tools. If the file is missing, it is likely that your
1126: operating system already provides those tools. Download the file and extract it
1127: in the / directory. It will create the directories /usr/pkg (containing the
1.118 sevan 1128: tools for managing binary packages and the database of installed packages).
1.1 dsieger 1129:
1.154 rillig 1130: 5.1.2. Installing binary packages
1.1 dsieger 1131:
1.85 wiz 1132: In the directory from the last section, there is a subdirectory called All/,
1.9 rillig 1133: which contains all the binary packages that are available for the platform,
1.202 nia 1134: excluding those that may not be distributed via HTTP or FTP.
1.9 rillig 1135:
1136: To install packages directly from an FTP or HTTP server, run the following
1137: commands in a Bourne-compatible shell (be sure to su to root first):
1138:
1.202 nia 1139: # PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
1140: # PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages"
1.169 rillig 1141: # PKG_PATH="$PKG_PATH/OPSYS/ARCH/VERSIONS/All/"
1.9 rillig 1142: # export PATH PKG_PATH
1.202 nia 1143: # pkg_add pkgin
1.9 rillig 1144:
1145: Instead of URLs, you can also use local paths, for example if you are
1146: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
1147: to install packages from multiple sources, you can separate them by a semicolon
1148: in PKG_PATH.
1149:
1150: After these preparations, installing a package is very easy:
1151:
1.202 nia 1152: # pkgin search nginx
1153: nginx-1.19.6 Lightweight HTTP server and mail proxy server
1154: nginx-1.18.0nb8 Lightweight HTTP server and mail proxy server
1155: # pkgin install zsh nginx-1.19.6 vim
1.1 dsieger 1156:
1.202 nia 1157: Note that pkgin is a user-friendly frontend to the pkg_* tools.
1.1 dsieger 1158:
1.202 nia 1159: Any prerequisite packages needed to run the package in question will be
1160: installed, too, assuming they are present in the repository.
1.1 dsieger 1161:
1162: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
1163: in your PATH so you can actually start the just installed program.
1164:
1.202 nia 1165: 5.1.3. Updating packages
1.1 dsieger 1166:
1.202 nia 1167: To update binary packages, it is recommended that you use pkgin upgrade. This
1168: will compare the remote package repository to your locally installed packages
1169: and safely replace any older packages.
1.1 dsieger 1170:
1.202 nia 1171: Note that pkgsrc is released as quarterly branches. If you are updating to a
1172: newer quarterly branch of pkgsrc, you may need to adjust the repository in /usr
1173: /pkg/etc/pkgin/repositories.conf.
1.1 dsieger 1174:
1.202 nia 1175: 5.1.4. Deinstalling packages
1.1 dsieger 1176:
1.202 nia 1177: To deinstall a package, it does not matter whether it was installed from source
1178: code or from a binary package. Neither the pkgin or the pkg_delete command need
1179: to know.
1.1 dsieger 1180:
1.202 nia 1181: To delete a package, you can just run pkgin remove package-name. The package
1182: name can be given with or without version number.
1.1 dsieger 1183:
1.202 nia 1184: 5.1.5. Getting information about installed packages
1.1 dsieger 1185:
1186: The pkg_info shows information about installed packages or binary package
1.202 nia 1187: files. As with other management tools, it works with packages installed from
1188: source or binaries.
1.1 dsieger 1189:
1.202 nia 1190: 5.1.6. Checking for security vulnerabilities in installed packages
1.1 dsieger 1191:
1.202 nia 1192: The pkgsrc Security Team and Packages Groups maintain a list of known
1.164 leot 1193: vulnerabilities to packages which are (or have been) included in pkgsrc. The
1.202 nia 1194: list is available from the NetBSD CDN at https://cdn.NetBSD.org/pub/NetBSD/
1.179 rillig 1195: packages/vulns/pkg-vulnerabilities.
1.1 dsieger 1196:
1.202 nia 1197: Please note that not every "vulnerability" with a CVE assignment is exploitable
1198: in every configuration. Some bugs are marked as active simply because an fix
1199: was not marked as such. Operating system specific hardening and mitigation
1200: features may also reduce the impact of bugs.
1201:
1.23 jakllsch 1202: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
1203: automatically, and a security audit of all packages installed on a system can
1204: take place.
1205:
1206: There are two components to auditing. The first step, pkg_admin
1207: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
1208: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
1209: your installed packages are vulnerable. If a package is vulnerable, you will
1210: see output similar to the following:
1.1 dsieger 1211:
1212: Package samba-2.0.9 has a local-root-shell vulnerability, see
1.174 leot 1213: https://www.samba.org/samba/whatsnew/macroexploit.html
1.1 dsieger 1214:
1.23 jakllsch 1215: You may wish to have the vulnerabilities file downloaded daily so that it
1216: remains current. This may be done by adding an appropriate entry to the root
1217: users crontab(5) entry. For example the entry
1218:
1.121 sevan 1219: # Download vulnerabilities file
1.118 sevan 1220: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.121 sevan 1221: # Audit the installed packages and email results to root
1222: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
1223: root >/dev/null 2>&1
1.118 sevan 1224:
1225:
1226: will update the vulnerability list every day at 3AM, followed by an audit at
1227: 3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
1228: accomplished instead by adding the following line to /etc/daily.conf:
1229:
1230: fetch_pkg_vulnerabilities=YES
1231:
1.23 jakllsch 1232:
1.118 sevan 1233: to fetch the vulnerability list from the daily security script. The system is
1234: set to audit the packages by default but can be set explicitly, if desired (not
1.123 wiz 1235: required), by adding the following line to /etc/security.conf:
1.23 jakllsch 1236:
1.118 sevan 1237: check_pkg_vulnerabilities=YES
1.23 jakllsch 1238:
1239:
1.118 sevan 1240: see daily.conf(5) and security.conf(5) for more details.
1.1 dsieger 1241:
1.202 nia 1242: 5.1.7. Finding if newer versions of your installed packages are in pkgsrc
1.1 dsieger 1243:
1.12 weinem 1244: Install pkgtools/lintpkgsrc and run lintpkgsrc with the "-i" argument to check
1.202 nia 1245: if any packages are stale, e.g.
1.1 dsieger 1246:
1247: % lintpkgsrc -i
1248: ...
1249: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
1250:
1251:
1.202 nia 1252: 5.1.8. Other administrative functions
1.1 dsieger 1253:
1254: The pkg_admin executes various administrative functions on the package system.
1255:
1.154 rillig 1256: 5.2. Building packages from source
1.1 dsieger 1257:
1258: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25 wiz 1259: organized into categories. You can browse the online index of packages, or run
1.1 dsieger 1260: make readme from the pkgsrc directory to build local README.html files for all
1261: packages, viewable with any web browser such as www/lynx or www/firefox.
1262:
1263: The default prefix for installed packages is /usr/pkg. If you wish to change
1264: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
1265: use multiple different LOCALBASE definitions on the same system (inside a
1266: chroot is an exception).
1267:
1268: The rest of this chapter assumes that the package is already in pkgsrc. If it
1269: is not, see Part II, "The pkgsrc developer's guide" for instructions how to
1270: create your own packages.
1271:
1.154 rillig 1272: 5.2.1. Requirements
1.1 dsieger 1273:
1274: To build packages from source, you need a working C compiler. On NetBSD, you
1275: need to install the "comp" and the "text" distribution sets. If you want to
1276: build X11-related packages, the "xbase" and "xcomp" distribution sets are
1277: required, too.
1278:
1.154 rillig 1279: 5.2.2. Fetching distfiles
1.1 dsieger 1280:
1281: The first step for building a package is downloading the distfiles (i.e. the
1282: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
1283: them automatically.
1284:
1285: If you have all files that you need in the distfiles directory, you don't need
1286: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
1287: and add:
1288:
1289: DISTDIR=/cdrom/pkgsrc/distfiles
1290:
1291: to your mk.conf.
1292:
1293: By default a list of distribution sites will be randomly intermixed to prevent
1294: huge load on servers which holding popular packages (for example,
1295: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
1296: distfile all the mirrors will be tried in new (random) order. You can turn this
1297: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
1298: disabled).
1299:
1300: You can overwrite some of the major distribution sites to fit to sites that are
1301: close to your own. By setting one or two variables you can modify the order in
1302: which the master sites are accessed. MASTER_SORT contains a whitespace
1303: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
1304: contains a whitespace delimited list of regular expressions. It has higher
1305: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
1306: some examples. This may save some of your bandwidth and time.
1307:
1308: You can change these settings either in your shell's environment, or, if you
1.4 rillig 1309: want to keep the settings, by editing the mk.conf file, and adding the
1.1 dsieger 1310: definitions there.
1311:
1.132 wiz 1312: If a package depends on many other packages (such as meta-pkgs/kde4), the build
1.1 dsieger 1313: process may alternate between periods of downloading source, and compiling. To
1314: ensure you have all the source downloaded initially you can run the command:
1315:
1316: % make fetch-list | sh
1317:
1318: which will output and run a set of shell commands to fetch the necessary files
1319: into the distfiles directory. You can also choose to download the files
1320: manually.
1321:
1.154 rillig 1322: 5.2.3. How to build and install
1.1 dsieger 1323:
1324: Once the software has downloaded, any patches will be applied, then it will be
1325: compiled for you. This may take some time depending on your computer, and how
1326: many other packages the software depends on and their compile time.
1327:
1328: Note
1329:
1330: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
1331: command instead of "make" in the examples in this guide.
1332:
1333: For example, type
1334:
1335: % cd misc/figlet
1336: % make
1337:
1338:
1339: at the shell prompt to build the various components of the package.
1340:
1341: The next stage is to actually install the newly compiled program onto your
1342: system. Do this by entering:
1343:
1344: % make install
1345:
1346:
1347: while you are still in the directory for whatever package you are installing.
1348:
1349: Installing the package on your system may require you to be root. However,
1350: pkgsrc has a just-in-time-su feature, which allows you to only become root for
1351: the actual installation step.
1352:
1353: That's it, the software should now be installed and setup for use. You can now
1354: enter:
1355:
1356: % make clean
1357:
1358:
1359: to remove the compiled files in the work directory, as you shouldn't need them
1360: any more. If other packages were also added to your system (dependencies) to
1361: allow your program to compile, you can tidy these up also with the command:
1362:
1363: % make clean-depends
1364:
1365:
1366: Taking the figlet utility as an example, we can install it on our system by
1.207 leot 1367: building as shown in Appendix C, Build logs.
1.1 dsieger 1368:
1369: The program is installed under the default root of the packages tree - /usr/
1370: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
1371: environment, and it will use that value as the root of your packages tree. So,
1372: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
1373: that you should use a directory which is dedicated to packages and not shared
1374: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
1375: not try to add any of your own files or directories (such as src/, obj/, or
1376: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
1377: between programs and other files installed by the package system and whatever
1378: else may have been installed there.
1379:
1.4 rillig 1380: Some packages look in mk.conf to alter some configuration options at build
1.1 dsieger 1381: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
1382: be set there by default. Environment variables such as LOCALBASE can be set in
1.4 rillig 1383: mk.conf to save having to remember to set them each time you want to use
1.1 dsieger 1384: pkgsrc.
1385:
1386: Occasionally, people want to "look under the covers" to see what is going on
1387: when a package is building or being installed. This may be for debugging
1388: purposes, or out of simple curiosity. A number of utility values have been
1389: added to help with this.
1390:
1391: 1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
1392: amount of information will be displayed. For example,
1393:
1394: make patch PKG_DEBUG_LEVEL=2
1395:
1.25 wiz 1396: will show all the commands that are invoked, up to and including the "patch
1397: " stage.
1.1 dsieger 1398:
1399: 2. If you want to know the value of a certain make(1) definition, then the
1400: VARNAME definition should be used, in conjunction with the show-var target.
1401: e.g. to show the expansion of the make(1) variable LOCALBASE:
1402:
1403: % make show-var VARNAME=LOCALBASE
1404: /usr/pkg
1405: %
1406:
1407:
1408: If you want to install a binary package that you've either created yourself
1409: (see next section), that you put into pkgsrc/packages manually or that is
1410: located on a remote FTP server, you can use the "bin-install" target. This
1411: target will install a binary package - if available - via pkg_add(1), else do a
1412: make package. The list of remote FTP sites searched is kept in the variable
1413: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
1414: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
1415: for more details.
1416:
1417: A final word of warning: If you set up a system that has a non-standard setting
1418: for LOCALBASE, be sure to set that before any packages are installed, as you
1419: cannot use several directories for the same purpose. Doing so will result in
1420: pkgsrc not being able to properly detect your installed packages, and fail
1421: miserably. Note also that precompiled binary packages are usually built with
1422: the default LOCALBASE of /usr/pkg, and that you should not install any if you
1423: use a non-standard LOCALBASE.
1424:
1.154 rillig 1425: Chapter 6. Configuring pkgsrc
1.1 dsieger 1426:
1427: Table of Contents
1428:
1.154 rillig 1429: 6.1. General configuration
1430: 6.2. Variables affecting the build process
1431: 6.3. Variables affecting the installation process
1432: 6.4. Selecting and configuring the compiler
1433:
1434: 6.4.1. Selecting the compiler
1435: 6.4.2. Additional flags to the compiler (CFLAGS)
1436: 6.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 1437:
1.154 rillig 1438: 6.5. Developer/advanced settings
1439: 6.6. Selecting Build Options
1.1 dsieger 1440:
1441: The whole pkgsrc system is configured in a single file, usually called mk.conf.
1442: In which directory pkgsrc looks for that file depends on the installation. On
1443: NetBSD, when you use make(1) from the base system, it is in the directory /etc
1444: /. In all other cases the default location is ${PREFIX}/etc/, depending on
1445: where you told the bootstrap program to install the binary packages.
1446:
1447: The format of the configuration file is that of the usual BSD-style Makefiles.
1448: The whole pkgsrc configuration is done by setting variables in this file. Note
1449: that you can define all kinds of variables, and no special error checking (for
1.112 rillig 1450: example for spelling mistakes) takes place.
1.1 dsieger 1451:
1.154 rillig 1452: 6.1. General configuration
1.1 dsieger 1453:
1.112 rillig 1454: The following variables apply to all pkgsrc packages. A complete list of the
1455: variables that can be configured by the user is available in mk/defaults/
1456: mk.conf, together with some comments that describe each variable's intent.
1.1 dsieger 1457:
1458: * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
1459: not mix binary packages with different LOCALBASEs!
1460:
1461: * CROSSBASE: Where "cross" category packages will be installed. The default
1462: is ${LOCALBASE}/cross.
1463:
1.84 wiz 1464: * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1 dsieger 1465:
1466: * DISTDIR: Where to store the downloaded copies of the original source
1467: distributions used for building pkgsrc packages. The default is $
1468: {PKGSRCDIR}/distfiles.
1469:
1470: * PKG_DBDIR: Where the database about installed packages is stored. The
1.118 sevan 1471: default is /usr/pkg/pkgdb.
1.1 dsieger 1472:
1473: * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
1474: value.
1475:
1476: * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
1477: files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.118 sevan 1478: respectively. The defaults is ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1.1 dsieger 1479: {DIST_SUBDIR}/.
1480:
1481: * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
1482: with OS release ("2.0", etc.) and architecture ("mipsel", etc.).
1483:
1.23 jakllsch 1484: * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
1485: case-sensitive. Whenever you try to build a package whose license is not in
1486: this list, you will get an error message. If the license condition is
1487: simple enough, the error message will include specific instructions on how
1488: to change this variable.
1.1 dsieger 1489:
1.154 rillig 1490: 6.2. Variables affecting the build process
1.1 dsieger 1491:
1492: * PACKAGES: The top level directory for the binary packages. The default is $
1493: {PKGSRCDIR}/packages.
1494:
1495: * WRKOBJDIR: The top level directory where, if defined, the separate working
1496: directories will get created, and symbolically linked to from ${WRKDIR}
1497: (see below). This is useful for building packages on several architectures,
1498: then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
1499: architecture. (It should be noted that PKGSRCDIR should not be set by the
1.198 leot 1500: user -- it is an internal definition which refers to the root of the pkgsrc
1.1 dsieger 1501: tree. It is possible to have many pkgsrc tree instances.)
1502:
1503: * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.184 rillig 1504: Section 12.3, "patches/*" for more information.
1.1 dsieger 1505:
1506: * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
1507: Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
1508: up settings used by builds in /usr/src.
1509:
1.154 rillig 1510: 6.3. Variables affecting the installation process
1.1 dsieger 1511:
1.198 leot 1512: * PKGSRC_KEEP_BIN_PKGS: By default, binary packages of built packages are
1.150 leot 1513: preserved in ${PACKAGES}/All. Setting this variable to "no" prevents this.
1.1 dsieger 1514:
1.107 jnemeth 1515: Packages have to support installation into a subdirectory of WRKDIR. This
1516: allows a package to be built, before the actual filesystem is touched. DESTDIR
1517: support exists in two variations:
1.4 rillig 1518:
1519: * Basic DESTDIR support means that the package installation and packaging is
1520: still run as root.
1521:
1522: * Full DESTDIR support can run the complete build, installation and packaging
1523: as normal user. Root privileges are only needed to add packages.
1524:
1525: With basic DESTDIR support, make clean needs to be run as root.
1526:
1.17 imil 1527: Considering the foo/bar package, DESTDIR full support can be tested using the
1528: following commands
1529:
1530: $ id
1531: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
1532: $ mkdir $HOME/packages
1533: $ cd $PKGSRCDIR/foo/bar
1534:
1535: Verify DESTDIR full support, no root privileges should be needed
1536:
1.66 asau 1537: $ make stage-install
1.17 imil 1538:
1539: Create a package without root privileges
1540:
1.66 asau 1541: $ make PACKAGES=$HOME/packages package
1.17 imil 1542:
1543: For the following command, you must be able to gain root privileges using su(1)
1544:
1.66 asau 1545: $ make PACKAGES=$HOME/packages install
1.17 imil 1546:
1547: Then, as a simple user
1548:
1549: $ make clean
1550:
1.154 rillig 1551: 6.4. Selecting and configuring the compiler
1.4 rillig 1552:
1.154 rillig 1553: 6.4.1. Selecting the compiler
1.1 dsieger 1554:
1555: By default, pkgsrc will use GCC to build packages. This may be overridden by
1556: setting the following variables in /etc/mk.conf:
1557:
1558: PKGSRC_COMPILER:
1559:
1560: This is a list of values specifying the chain of compilers to invoke when
1561: building packages. Valid values are:
1562:
1.66 asau 1563: + ccc: Compaq C Compilers (Tru64)
1564:
1565: + ccache: compiler cache (chainable)
1566:
1567: + clang: Clang C and Objective-C compiler
1568:
1.42 asau 1569: + distcc: distributed C/C++ (chainable)
1.1 dsieger 1570:
1.66 asau 1571: + f2c: Fortran 77 to C compiler (chainable)
1572:
1573: + icc: Intel C++ Compiler (Linux)
1574:
1575: + ido: SGI IRIS Development Option cc (IRIX 5)
1.1 dsieger 1576:
1.42 asau 1577: + gcc: GNU C/C++ Compiler
1.1 dsieger 1578:
1.66 asau 1579: + hp: HP-UX C/aC++ compilers
1580:
1.42 asau 1581: + mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1 dsieger 1582:
1.66 asau 1583: + mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1 dsieger 1584:
1.42 asau 1585: + sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1 dsieger 1586:
1.118 sevan 1587: + xlc: IBM's XL C/C++ compiler suite
1.66 asau 1588:
1.1 dsieger 1589: The default is "gcc". You can use ccache and/or distcc with an appropriate
1590: PKGSRC_COMPILER setting, e.g. "ccache gcc". This variable should always be
1591: terminated with a value for a real compiler. Note that only one real
1592: compiler should be listed (e.g. "sunpro gcc" is not allowed).
1593:
1594: GCC_REQD:
1595:
1596: This specifies the minimum version of GCC to use when building packages. If
1597: the system GCC doesn't satisfy this requirement, then pkgsrc will build and
1598: install one of the GCC packages to use instead.
1599:
1.153 leot 1600: PYTHON_VERSION_DEFAULT:
1.114 maya 1601:
1602: Specifies which version of python to use when several options are
1603: available.
1604:
1605: PKGSRC_FORTRAN:
1606:
1.176 gutterid 1607: Specifies the Fortran compiler to use. The default is gfortran.
1.114 maya 1608:
1609: GFORTRAN_VERSION:
1610:
1611: If PKGSRC_FORTRAN= gfortran is used, this option specifies which version to
1612: use.
1613:
1.154 rillig 1614: 6.4.2. Additional flags to the compiler (CFLAGS)
1.1 dsieger 1615:
1616: If you wish to set the CFLAGS variable, please make sure to use the += operator
1617: instead of the = operator:
1618:
1619: CFLAGS+= -your -flags
1620:
1621: Using CFLAGS= (i.e. without the "+") may lead to problems with packages that
1.16 jnemeth 1622: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24 wiz 1623: package if you're interested in optimization specifically for the current CPU.
1.1 dsieger 1624:
1.154 rillig 1625: 6.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 1626:
1627: If you want to pass flags to the linker, both in the configure step and the
1628: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
1629: difference between the two is that LIBS will be appended to the command line,
1630: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
1631: machines depending on the setting of USE_IMAKE or the inclusion of mk/
1632: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
1633: settings, use the += operator:
1634:
1635: LDFLAGS+= -your -linkerflags
1636:
1.154 rillig 1637: 6.5. Developer/advanced settings
1.1 dsieger 1638:
1639: * PKG_DEVELOPER: Run some sanity checks that package developers want:
1640:
1.42 asau 1641: + make sure patches apply with zero fuzz
1.1 dsieger 1642:
1.42 asau 1643: + run check-shlibs to see that all binaries will find their shared libs.
1.1 dsieger 1644:
1645: * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
1646: making and installing the package. The default value for this is 0, which
1647: will not display the commands as they are executed (normal, default, quiet
1648: operation); the value 1 will display all shell commands before their
1649: invocation, and the value 2 will display both the shell commands before
1.112 rillig 1650: their invocation, as well as their actual execution progress with set -x.
1.1 dsieger 1651:
1.154 rillig 1652: 6.6. Selecting Build Options
1.1 dsieger 1653:
1654: Some packages have build time options, usually to select between different
1655: dependencies, enable optional support for big dependencies or enable
1656: experimental features.
1657:
1658: To see which options, if any, a package supports, and which options are
1659: mutually exclusive, run make show-options, for example:
1660:
1661: The following options are supported by this package:
1662: ssl Enable SSL support.
1663: Exactly one of the following gecko options is required:
1664: firefox Use firefox as gecko rendering engine.
1665: mozilla Use mozilla as gecko rendering engine.
1666: At most one of the following database options may be selected:
1667: mysql Enable support for MySQL database.
1668: pgsql Enable support for PostgreSQL database.
1669:
1670: These options are enabled by default: firefox
1671: These options are currently enabled: mozilla ssl
1672:
1.4 rillig 1673: The following variables can be defined in mk.conf to select which options to
1674: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1 dsieger 1675: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
1676: which can be used to select or disable options specifically for package pkgbase
1677: . Options listed in these variables are selected, options preceded by "-" are
1678: disabled. A few examples:
1679:
1.4 rillig 1680: $ grep "PKG.*OPTION" mk.conf
1.1 dsieger 1681: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
1682: PKG_OPTIONS.kdebase= debug -sasl
1683: PKG_OPTIONS.apache= suexec
1684:
1.11 rillig 1685: It is important to note that options that were specifically suggested by the
1.19 snj 1686: package maintainer must be explicitly removed if you do not wish to include the
1687: option. If you are unsure you can view the current state with make show-options
1688: .
1.11 rillig 1689:
1.1 dsieger 1690: The following settings are consulted in the order given, and the last setting
1691: that selects or disables an option is used:
1692:
1693: 1. the default options as suggested by the package maintainer
1694:
1695: 2. the options implied by the settings of legacy variables (see below)
1696:
1697: 3. PKG_DEFAULT_OPTIONS
1698:
1699: 4. PKG_OPTIONS.pkgbase
1700:
1701: For groups of mutually exclusive options, the last option selected is used, all
1702: others are automatically disabled. If an option of the group is explicitly
1703: disabled, the previously selected option, if any, is used. It is an error if no
1704: option from a required group of options is selected, and building the package
1705: will fail.
1706:
1707: Before the options framework was introduced, build options were selected by
1.4 rillig 1708: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
1709: transition to the options framework for the user, these legacy variables are
1710: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
1711: automatically. A warning is issued to prompt the user to update mk.conf to use
1712: the options framework directly. Support for the legacy variables will be
1.1 dsieger 1713: removed eventually.
1714:
1.154 rillig 1715: Chapter 7. Creating binary packages
1.1 dsieger 1716:
1717: Table of Contents
1718:
1.154 rillig 1719: 7.1. Building a single binary package
1720: 7.2. Settings for creation of binary packages
1.1 dsieger 1721:
1.154 rillig 1722: 7.1. Building a single binary package
1.1 dsieger 1723:
1724: Once you have built and installed a package, you can create a binary package
1725: which can be installed on another system with pkg_add(1). This saves having to
1726: build the same package on a group of hosts and wasting CPU time. It also
1727: provides a simple means for others to install your package, should you
1728: distribute it.
1729:
1730: To create a binary package, change into the appropriate directory in pkgsrc,
1731: and run make package:
1732:
1.112 rillig 1733: $ cd misc/figlet
1734: $ make package
1.1 dsieger 1735:
1736: This will build and install your package (if not already done), and then build
1737: a binary package from what was installed. You can then use the pkg_* tools to
1738: manipulate it. Binary packages are created by default in /usr/pkgsrc/packages,
1.207 leot 1739: in the form of a gzipped tar file. See Section C.2, "Packaging figlet" for a
1.1 dsieger 1740: continuation of the above misc/figlet example.
1741:
1.154 rillig 1742: See Chapter 23, Submitting and Committing for information on how to submit such
1.1 dsieger 1743: a binary package.
1744:
1.154 rillig 1745: 7.2. Settings for creation of binary packages
1.1 dsieger 1746:
1.184 rillig 1747: See Section 13.17, "Other helpful targets".
1.6 rillig 1748:
1.154 rillig 1749: Chapter 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6 rillig 1750:
1751: Table of Contents
1752:
1.154 rillig 1753: 8.1. Preparations
1.180 rillig 1754: 8.2. Running a bulk build
1.6 rillig 1755:
1.154 rillig 1756: 8.2.1. Configuration
1.6 rillig 1757:
1.154 rillig 1758: 8.3. Requirements of a full bulk build
1.178 rillig 1759: 8.4. Bulk build variants
1760:
1.179 rillig 1761: 8.4.1. Detect unknown configure options
1762: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.181 rillig 1763: 8.4.3. Force compiler options only in the build phase
1764: 8.4.4. Use custom directories
1765: 8.4.5. Turn warnings into errors
1766: 8.4.6. Reject packages for which pkglint reports errors
1767: 8.4.7. Reject packages that contain forbidden strings
1768: 8.4.8. Reject packages whose self-test fails
1769: 8.4.9. Reject packages that use undefined shell variables
1770: 8.4.10. Turn off verbose logging
1.6 rillig 1771:
1.178 rillig 1772: 8.5. Creating a multiple CD-ROM packages collection
1773:
1774: 8.5.1. Example of cdpack
1.6 rillig 1775:
1.175 gutterid 1776: For a number of reasons, you may want to build binary packages for a large
1777: selected set of packages in pkgsrc, or even for all pkgsrc packages. For
1.71 wiz 1778: instance, when you have multiple machines that should run the same software, it
1779: is wasted time if they all build their packages themselves from source. Or you
1780: may want to build a list of packages you want and check them before deploying
1.175 gutterid 1781: onto production systems. There is a way of getting a set of binary packages:
1782: the bulk build system, or pbulk ("p" stands for "parallel"). This chapter
1783: describes how to set it up.
1.71 wiz 1784:
1.154 rillig 1785: 8.1. Preparations
1.71 wiz 1786:
1787: First of all, you have to decide whether you build all packages or a limited
1788: set of them. Full bulk builds usually consume a lot more resources, both space
1.175 gutterid 1789: and time, than builds for some practical sets of packages. A number of
1790: particularly heavy packages exist that are not actually interesting to a wide
1791: audience. (The approximate resource consumption for a full bulk build is given
1792: in section Section 8.3, "Requirements of a full bulk build".) For limited bulk
1793: builds you need to make a list of packages you want to build. Note that all
1794: their dependencies will be built, so you don't need to track them manually.
1.71 wiz 1795:
1796: During bulk builds various packages are installed and deinstalled in /usr/pkg
1797: (or whatever LOCALBASE is), so make sure that you don't need any package during
1.112 rillig 1798: the builds. Essentially, you should provide a fresh system, either a chroot
1.71 wiz 1799: environment or something even more restrictive, depending on what the operating
1800: system provides, or dedicate the whole physical machine. As a useful side
1801: effect this makes sure that bulk builds cannot break anything in your system.
1802: There have been numerous cases where certain packages tried to install files
1803: outside the LOCALBASE or wanted to edit some files in /etc.
1.6 rillig 1804:
1.180 rillig 1805: 8.2. Running a bulk build
1.6 rillig 1806:
1.180 rillig 1807: Running a bulk build works roughly as follows:
1.15 rillig 1808:
1809: * First, build the pbulk infrastructure in a fresh pkgsrc location.
1810:
1811: * Then, build each of the packages from a clean installation directory using
1812: the infrastructure.
1813:
1.154 rillig 1814: 8.2.1. Configuration
1.6 rillig 1815:
1.112 rillig 1816: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6 rillig 1817:
1.68 asau 1818: In order to use it, prepare a clear system (real one, chroot environment, jail,
1819: zone, virtual machine). Configure network access to fetch distribution files.
1.112 rillig 1820: Create a user with name "pbulk".
1.68 asau 1821:
1822: Fetch and extract pkgsrc. Use a command like one of these:
1823:
1.151 sevan 1824: # (cd /usr && ftp -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1825: # (cd /usr && fetch -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1.72 wiz 1826: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68 asau 1827:
1828: Or any other way that fits (e.g., curl, wget).
1829:
1830: Deploy and configure pbulk tools, e.g.:
1831:
1.118 sevan 1832: # sh pbulk.sh -n # use native make, no bootstrap kit needed (for use on NetBSD)
1.68 asau 1833: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
1834: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
1835:
1836: Note
1837:
1838: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
1839: to packages you build. For instance,
1840:
1.112 rillig 1841: PKG_DEVELOPER= yes # perform more checks
1842: X11_TYPE= modular # use pkgsrc X11
1843: SKIP_LICENSE_CHECK= yes # accept all licences (useful
1844: # when building all packages)
1.68 asau 1845:
1846: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112 rillig 1847: with your list of packages, one per line without empty lines or comments. E.g.:
1.68 asau 1848:
1849: www/firefox
1850: mail/thunderbird
1851: misc/libreoffice4
1852:
1.69 asau 1853: At this point you can also review configuration in /usr/pbulk/etc and make
1854: final amendments, if wanted.
1855:
1.68 asau 1856: Start it:
1857:
1858: # /usr/pbulk/bin/bulkbuild
1859:
1860: After it finishes, you'll have /mnt filled with distribution files, binary
1861: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
1862:
1863: Note
1864:
1865: The pbulk.sh script does not cover all possible use cases. While being ready to
1866: run, it serves as a good starting point to understand and build more complex
1867: setups. The script is kept small enough for better understanding.
1868:
1869: Note
1870:
1871: The pbulk.sh script supports running unprivileged bulk build and helps
1.205 wiz 1872: configuring distributed bulk builds. Distributed bulk builds support either
1873: building in worker chroots (each node is a path to a different chroot) that
1874: replicate the target system, including the pbulk prefix, or remote machines
1875: (each node is an IP address that must be accessible over SSH without a
1876: password).
1.15 rillig 1877:
1.154 rillig 1878: 8.3. Requirements of a full bulk build
1.71 wiz 1879:
1880: A complete bulk build requires lots of disk space. Some of the disk space can
1881: be read-only, some other must be writable. Some can be on remote filesystems
1882: (such as NFS) and some should be local. Some can be temporary filesystems,
1883: others must survive a sudden reboot.
1884:
1.205 wiz 1885: * 70 GB for the distfiles (read-write, remote, temporary)
1.71 wiz 1886:
1.205 wiz 1887: * 60 GB for the binary packages (read-write, remote, permanent)
1.71 wiz 1888:
1889: * 1 GB for the pkgsrc tree (read-only, remote, permanent)
1890:
1891: * 5 GB for LOCALBASE (read-write, local, temporary)
1892:
1893: * 10 GB for the log files (read-write, remote, permanent)
1894:
1895: * 5 GB for temporary files (read-write, local, temporary)
1896:
1.178 rillig 1897: 8.4. Bulk build variants
1898:
1899: To ensure that pkgsrc packages work in different configurations, it makes sense
1900: to run non-default bulk builds from time to time. This section lists some ideas
1901: for bulk builds that intentionally let packages fail if they don't follow the
1902: pkgsrc style.
1903:
1.179 rillig 1904: 8.4.1. Detect unknown configure options
1.178 rillig 1905:
1906: Add the following line to mk.conf.
1907:
1908: GNU_CONFIGURE_STRICT= yes
1909:
1910: When a package fails this additional check, the most common cause is that the
1911: configure option was valid for an older version of the package but does not
1912: apply anymore. In that case, just remove it.
1913:
1.179 rillig 1914: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.178 rillig 1915:
1916: The job of a compiler is not restricted to producing executable code, most
1.179 rillig 1917: compilers also detect typical programming mistakes. The pkgsrc compiler
1918: wrappers make it easy to force compiler options when the package is built. This
1919: can be used to find typical bugs across all packages that are in pkgsrc. By
1920: reporting these bugs upstream, the packages will be more reliable with the next
1921: updates.
1.178 rillig 1922:
1.179 rillig 1923: Add some of the following lines to mk.conf:
1.178 rillig 1924:
1925: CFLAGS+= -Werror=char-subscripts
1.179 rillig 1926: CFLAGS+= -Werror=implicit-function-declaration
1.178 rillig 1927:
1.179 rillig 1928: When a package fails to build using these stricter compiler options, document
1929: the circumstances in which the compiler produced the error message. This
1930: includes:
1.178 rillig 1931:
1932: * The platform (MACHINE_PLATFORM)
1933:
1934: * The source file
1935:
1936: * An excerpt of the code. GCC and Clang already do this as part of the
1937: diagnostic.
1938:
1.179 rillig 1939: * The exact error message from the compiler.
1.178 rillig 1940:
1.179 rillig 1941: If a package produces these error messages, but the package is fine, record
1942: this in your local mk.conf, like this, to skip this check in the next builds:
1.178 rillig 1943:
1.179 rillig 1944: .if ${PKGPATH} == category/package
1.178 rillig 1945: # Version ${VERSION} failed on ${MACHINE_PLATFORM}:
1946: # error message
1947: # code
1.179 rillig 1948: # Reason why the code does not need to be fixed.
1.178 rillig 1949: BUILDLINK_TRANSFORM+= rm:-Werror=char-subscripts
1.179 rillig 1950: .endif
1.178 rillig 1951:
1952: If the error messages from the compiler are valid and the code needs to be
1.179 rillig 1953: fixed, prepare a local patch (see LOCALPATCHES) and report the bug to the
1954: upstream authors of the package, providing them with the information you
1955: collected above.
1.178 rillig 1956:
1.179 rillig 1957: Patches that are not essential for the package to work should only be reported
1958: upstream but not committed to pkgsrc, to make future updates easier.
1959:
1.181 rillig 1960: 8.4.3. Force compiler options only in the build phase
1961:
1962: When adding custom compiler flags via CFLAGS, these apply to all phases of the
1963: package build process. Especially in the configure phase, adding -Werror leads
1964: to wrong decisions. The GNU configure scripts feed many small test programs to
1965: the C compiler to see whether certain headers are available, functions are
1966: defined in a library and programs can be run. In many cases these programs
1967: would not survive a strict compiler run with -Wall -Wextra -Werror.
1968:
1969: The pkgsrc infrastructure is flexible enough to support compiler options being
1970: added between the configure and build phases. It's a little more complicated
1971: than the other examples in this section but still easy enough.
1972:
1973: The basic idea is to use the pkgsrc compiler wrapper to inject the desired
1974: compiler options. The compiler wrapper's original task is to hide unwanted
1975: directories of include files and to normalize compiler options. It does this by
1976: wrapping the compiler command and rewriting the command line. To see this in
1977: action, run bmake patch in a package directory and examine the work/.cwrappers/
1978: config directory. It contains individual configurations for the C compiler and
1979: the related tools. The plan is to find a hook between the configure and build
1980: phases, and to modify these configuration files at that point.
1981:
1982: To find this hook, have a look at mk/build/build.mk, which contains among
1983: others the pre-build-checks-hook. The word checks doesn't quite fit, but the
1984: pre-build-hook sounds good enough.
1985:
1986: The code to be included in mk.conf is:
1987:
1988: # Just a few example options.
1989: BUILD_ONLY_CFLAGS= -Wall -Werror -O2 -DTEMPDIR='"/tmp"'
1990:
1991: .if ${BUILD_ONLY_CFLAGS:U:M*}
1992: pre-build-checks-hook: add-build-only-cflags
1993:
1994: add-build-only-cflags: .PHONY
1995: ${RUN} cd ${CWRAPPERS_CONFIG_DIR}; \
1996: ${TEST} ! -f ${.TARGET} || exit 0; \
1997: for flag in ${BUILD_ONLY_CFLAGS}; do \
1998: ${ECHO} "append=$$flag" >> cc; \
1999: done; \
2000: > ${.TARGET}
2001: .endif
2002:
2003: (When editing the mk.conf, make sure that the commands of the
2004: add-build-only-cflags target are indented with a tab, not with spaces.)
2005:
2006: The condition in the .if statement contains the :U modifier to prevent parse
2007: errors if the variable should be undefined, possibly because it is only defined
2008: for a subset of the packages. The :M* modifier ensures that there is at least
2009: one compiler option, to prevent a syntax error in the shell parser.
2010:
2011: The code around the ${.TARGET} variable ensures that the additional compiler
2012: options are only appended once, even if bmake build is run multiple times. To
2013: do this, it creates a marker file.
2014:
2015: To verify that this setup works, run bmake configure in a package directory. Up
2016: to now, everything works as usual. Examine the directory work/.cwrappers/config
2017: to see that the compiler options from BUILD_ONLY_CFLAGS are not yet added to
2018: the file cc. Examine the tail of the work/.work.log file to see that the normal
2019: compiler options are used.
2020:
2021: Now run bmake build. This will append the options to the file cc and will
2022: create the marker file in the same directory. After that, the build starts as
2023: usual, but with the added compiler options. Examine the tail of the file work
2024: /.work.log to see that the lines starting with [*] don't contain the compiler
2025: options, but the corresponding lines starting with <.> do end with these
2026: options.
2027:
2028: Building packages using this setup variant and fixing the resulting bugs is the
2029: same as in Section 8.4.2, "Detect classes of bugs by forcing compiler warnings"
2030: .
2031:
2032: 8.4.4. Use custom directories
1.178 rillig 2033:
2034: Some directories like PREFIX, VARBASE, PKG_SYSCONFDIR, PKGMANDIR, PKG_INFODIR
2035: can be configured in pkgsrc. Set these to arbitrary paths during bootstrap or
2036: afterwards in mk.conf.
2037:
2038: PREFIX= /a-random-uuid
2039: PKG_SYSCONFDIR= /a-random-uuid
2040: VARBASE= /a-random-uuid
2041: PKGMANDIR= a-random-uuid
2042: PKG_INFODIR= a-random-uuid
2043:
1.181 rillig 2044: 8.4.5. Turn warnings into errors
1.178 rillig 2045:
2046: When building a package, warnings are typically ignored since they just flow by
2047: and do not cause the build to fail immediately. To find these warnings,
2048: redefine them to errors in mk.conf.
2049:
2050: DELAYED_WARNING_MSG= ${DELAYED_ERROR_MSG} "(was warning)"
2051: WARNING_MSG= ${FAIL_MSG} "(was warning)"
2052:
2053: (There are many more classes of warnings in pkgsrc, and most of them can be
2054: redefined with a simple definition like above.
2055:
1.179 rillig 2056: If a package suggests to add USE_TOOLS+=perl to the package Makefile, research
1.178 rillig 2057: whether the package actually needs Perl. If it does, add USE_TOOLS+=perl to the
2058: package Makefile, and if it doesn't, add TOOLS_BROKEN+=perl.
2059:
1.181 rillig 2060: 8.4.6. Reject packages for which pkglint reports errors
1.178 rillig 2061:
2062: Using pkglint as part of the regular build process is mostly a waste of time.
2063: If you want to fix some of the warnings, just run pkglint recursively on the
2064: whole pkgsrc tree. This will take a few minutes (up to 10), which is much
2065: faster than a complete bulk build.
2066:
1.181 rillig 2067: 8.4.7. Reject packages that contain forbidden strings
1.178 rillig 2068:
2069: To ensure that the binary packages don't contain references to the build
2070: directory, there is already CHECK_WRKREF. If that variable includes the item
2071: extra, it is possible to define additional patterns that must not appear in any
2072: installed file. This is specified in mk.conf.
2073:
2074: CHECK_WRKREF= extra
2075: CHECK_WRKREF_EXTRA_DIRS+= /usr/local
2076: CHECK_WRKREF_EXTRA_DIRS+= /usr/pkg
2077: CHECK_WRKREF_EXTRA_DIRS+= @[A-Z][A-Z]*@
2078:
2079: The above patterns will probably generate many false positives, therefore the
2080: results need to be taken with a grain of salt.
2081:
1.181 rillig 2082: 8.4.8. Reject packages whose self-test fails
1.178 rillig 2083:
2084: To run the test suites that come with each package, add this line to mk.conf.
2085:
2086: PKGSRC_RUN_TEST= yes
2087:
2088: Be prepared that even the most basic packages fail this test. When doing a bulk
2089: build with this, it will often abort in the early phase where the packages are
2090: scanned for their dependencies since there are cyclic dependencies. There is
2091: still a lot to do in this area.
2092:
1.181 rillig 2093: 8.4.9. Reject packages that use undefined shell variables
1.178 rillig 2094:
2095: To catch typos in the shell snippets from the Makefile fragments, add the -u
2096: flag to most of the commands by adding this line to mk.conf.
2097:
2098: RUN= @set -eu;
2099:
1.181 rillig 2100: After that, ensure that none of the bulk build log files (even those for
2101: successfully built packages) contains the string parameter not set or whatever
2102: error message the command sh -ceu '$undefined' outputs.
2103:
1.178 rillig 2104: See mk/misc/common.mk for the existing definition.
2105:
1.181 rillig 2106: 8.4.10. Turn off verbose logging
1.178 rillig 2107:
2108: The build logs of a package are often quite long. This allows error messages or
2109: other interesting details to hide between the noise. To make the actual error
2110: message stand out more, add these lines to mk.conf.
2111:
2112: GNU_CONFIGURE_QUIET= yes
2113: MAKE_FLAGS+= -s
2114:
2115: The -s option works for both GNU Make and BSD Make. On exotic platforms with
2116: their own make, it may be a little different.
2117:
2118: 8.5. Creating a multiple CD-ROM packages collection
1.1 dsieger 2119:
2120: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
2121: of the resulting binary packages to assist in installing packages on other
2122: machines. The pkgtools/cdpack package provides a simple tool for creating the
2123: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
2124: keeps all the dependencies for a given package on the same CD as that package.
2125:
1.178 rillig 2126: 8.5.1. Example of cdpack
1.1 dsieger 2127:
2128: Complete documentation for cdpack is found in the cdpack(1) man page. The
2129: following short example assumes that the binary packages are left in /usr/
2130: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
2131: ISO 9660 images.
2132:
2133: # mkdir /u2/images
2134: # pkg_add /usr/pkgsrc/packages/All/cdpack
2135: # cdpack /usr/pkgsrc/packages/All /u2/images
2136:
2137:
2138: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
2139: CD in the collection, then you need to create a directory which contains these
1.175 gutterid 2140: files, e.g.:
1.1 dsieger 2141:
2142: # mkdir /tmp/common
2143: # echo "This is a README" > /tmp/common/README
2144: # echo "Another file" > /tmp/common/COPYING
2145: # mkdir /tmp/common/bin
2146: # echo "#!/bin/sh" > /tmp/common/bin/myscript
2147: # echo "echo Hello world" >> /tmp/common/bin/myscript
2148: # chmod 755 /tmp/common/bin/myscript
2149:
2150:
2151: Now create the images:
2152:
2153: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
2154:
2155: Each image will contain README, COPYING, and bin/myscript in their root
2156: directories.
2157:
1.154 rillig 2158: Chapter 9. Directory layout of the installed files
1.1 dsieger 2159:
2160: Table of Contents
2161:
1.154 rillig 2162: 9.1. File system layout in ${LOCALBASE}
2163: 9.2. File system layout in ${VARBASE}
1.1 dsieger 2164:
2165: The files that are installed by pkgsrc are organized in a way that is similar
2166: to what you find in the /usr directory of the base system. But some details are
2167: different. This is because pkgsrc initially came from FreeBSD and had adopted
2168: its file system hierarchy. Later it was largely influenced by NetBSD. But no
2169: matter which operating system you are using pkgsrc with, you can expect the
2170: same layout for pkgsrc.
2171:
2172: There are mainly four root directories for pkgsrc, which are all configurable
2173: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
2174: default locations are:
2175:
2176: LOCALBASE= /usr/pkg
2177: PKG_SYSCONFBASE= /usr/pkg/etc
2178: VARBASE= /var
1.119 sevan 2179: PKG_DBDIR= /usr/pkg/pkgdb
1.1 dsieger 2180:
2181: In unprivileged mode (when pkgsrc has been installed as any other user), the
2182: default locations are:
2183:
2184: LOCALBASE= ${HOME}/pkg
2185: PKG_SYSCONFBASE= ${HOME}/pkg/etc
2186: VARBASE= ${HOME}/pkg/var
1.119 sevan 2187: PKG_DBDIR= ${HOME}/pkg/pkgdb
1.1 dsieger 2188:
2189: What these four directories are for, and what they look like is explained
2190: below.
2191:
1.25 wiz 2192: * LOCALBASE corresponds to the /usr directory in the base system. It is the "
2193: main" directory where the files are installed and contains the well-known
1.1 dsieger 2194: subdirectories like bin, include, lib, share and sbin.
2195:
2196: * VARBASE corresponds to /var in the base system. Some programs (especially
2197: games, network daemons) need write access to it during normal operation.
2198:
2199: * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
2200: configuration files of the packages, as well as pkgsrc's mk.conf itself.
2201:
1.154 rillig 2202: 9.1. File system layout in ${LOCALBASE}
1.1 dsieger 2203:
2204: The following directories exist in a typical pkgsrc installation in $
2205: {LOCALBASE}.
2206:
2207: bin
2208:
2209: Contains executable programs that are intended to be directly used by the
2210: end user.
2211:
2212: emul
2213:
2214: Contains files for the emulation layers of various other operating systems,
2215: especially for NetBSD.
2216:
2217: etc (the usual location of ${PKG_SYSCONFDIR})
2218:
2219: Contains the configuration files.
2220:
2221: include
2222:
2223: Contains headers for the C and C++ programming languages.
2224:
2225: info
2226:
2227: Contains GNU info files of various packages.
2228:
2229: lib
2230:
2231: Contains shared and static libraries.
2232:
2233: libdata
2234:
2235: Contains data files that don't change after installation. Other data files
2236: belong into ${VARBASE}.
2237:
2238: libexec
2239:
2240: Contains programs that are not intended to be used by end users, such as
2241: helper programs or network daemons.
2242:
2243: libexec/cgi-bin
2244:
2245: Contains programs that are intended to be executed as CGI scripts by a web
2246: server.
2247:
2248: man (the usual value of ${PKGMANDIR})
2249:
2250: Contains brief documentation in form of manual pages.
2251:
2252: sbin
2253:
2254: Contains programs that are intended to be used only by the super-user.
2255:
2256: share
2257:
2258: Contains platform-independent data files that don't change after
2259: installation.
2260:
2261: share/doc
2262:
2263: Contains documentation files provided by the packages.
2264:
2265: share/examples
2266:
2267: Contains example files provided by the packages. Among others, the original
2268: configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
2269: installation.
2270:
2271: share/examples/rc.d
2272:
2273: Contains the original files for rc.d scripts.
2274:
2275: var (the usual location of ${VARBASE})
2276:
2277: Contains files that may be modified after installation.
2278:
1.154 rillig 2279: 9.2. File system layout in ${VARBASE}
1.1 dsieger 2280:
2281: db/pkg (the usual location of ${PKG_DBDIR})
2282:
2283: Contains information about the currently installed packages.
2284:
2285: games
2286:
2287: Contains highscore files.
2288:
2289: log
2290:
2291: Contains log files.
2292:
2293: run
2294:
2295: Contains informational files about daemons that are currently running.
2296:
1.154 rillig 2297: Chapter 10. Frequently Asked Questions
1.1 dsieger 2298:
2299: Table of Contents
2300:
1.154 rillig 2301: 10.1. Are there any mailing lists for pkg-related discussion?
2302: 10.2. Utilities for package management (pkgtools)
2303: 10.3. How to use pkgsrc as non-root
2304: 10.4. How to resume transfers when fetching distfiles?
2305: 10.5. How can I install/use modular X.org from pkgsrc?
2306: 10.6. How to fetch files from behind a firewall
2307: 10.7. How to fetch files from HTTPS sites
2308: 10.8. How do I tell make fetch to do passive FTP?
2309: 10.9. How to fetch all distfiles at once
2310: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
2311: 10.11. What does "Could not find bsd.own.mk" mean?
2312: 10.12. Using 'sudo' with pkgsrc
2313: 10.13. How do I change the location of configuration files?
2314: 10.14. Automated security checks
2315: 10.15. Why do some packages ignore my CFLAGS?
2316: 10.16. A package does not build. What shall I do?
2317: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24 wiz 2318: conflicts" mean?
1.1 dsieger 2319:
2320: This section contains hints, tips & tricks on special things in pkgsrc that we
2321: didn't find a better place for in the previous chapters, and it contains items
2322: for both pkgsrc users and developers.
2323:
1.154 rillig 2324: 10.1. Are there any mailing lists for pkg-related discussion?
1.1 dsieger 2325:
2326: The following mailing lists may be of interest to pkgsrc users:
2327:
2328: * pkgsrc-users: This is a general purpose list for most issues regarding
2329: pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
2330: configuration, unexpected build failures, using particular packages,
2331: upgrading pkgsrc installations, questions regarding the pkgsrc release
2332: branches, etc. General announcements or proposals for changes that impact
2333: the pkgsrc user community, e.g. major infrastructure changes, new features,
2334: package removals, etc., may also be posted.
2335:
2336: * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
2337: discussed.
2338:
2339: * pkgsrc-changes: This list is for those who are interested in getting a
2340: commit message for every change committed to pkgsrc. It is also available
2341: in digest form, meaning one daily message containing all commit messages
2342: for changes to the package source tree in that 24 hour period.
2343:
2344: To subscribe, do:
2345:
2346: % echo subscribe listname | mail majordomo@NetBSD.org
2347:
1.174 leot 2348: Archives for all these mailing lists are available from https://
1.1 dsieger 2349: mail-index.NetBSD.org/.
2350:
1.154 rillig 2351: 10.2. Utilities for package management (pkgtools)
1.1 dsieger 2352:
2353: The directory pkgsrc/pkgtools contains a number of useful utilities for both
2354: users and developers of pkgsrc. This section attempts only to make the reader
1.121 sevan 2355: aware of some of the utilities and when they might be useful, and not to
2356: duplicate the documentation that comes with each package.
1.1 dsieger 2357:
2358: Utilities used by pkgsrc (automatically installed when needed):
2359:
2360: * pkgtools/x11-links: Symlinks for use by buildlink.
2361:
2362: OS tool augmentation (automatically installed when needed):
2363:
1.121 sevan 2364: * pkgtools/digest: Calculates various kinds of checksums (including SHA3).
1.1 dsieger 2365:
2366: * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
2367:
2368: * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
2369:
2370: * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
2371: for use on operating systems where pkg_install is not present.
2372:
2373: Utilities used by pkgsrc (not automatically installed):
2374:
2375: * pkgtools/pkg_tarup: Create a binary package from an already-installed
2376: package. Used by make replace to save the old package.
2377:
2378: * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
2379: distfiles from multiple locations. It currently supports the following
2380: methods: multiple CD-ROMs and network FTP/HTTP connections.
2381:
2382: * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24 wiz 2383: current CPU and compiler.
1.1 dsieger 2384:
2385: Utilities for keeping track of installed packages, being up to date, etc:
2386:
1.65 wiz 2387: * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
2388: and upgrade binary packages easily.
2389:
1.1 dsieger 2390: * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
2391: the latest pkgsrc entries.
2392:
2393: * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
2394: strategy for updating.
2395:
2396: * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
2397: graphviz).
2398:
1.12 weinem 2399: * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
2400:
2401: * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
2402: complete pkgsrc system.
1.1 dsieger 2403:
2404: * pkgtools/pkgsurvey: Report what packages you have installed.
2405:
2406: Utilities for people maintaining or creating individual packages:
2407:
2408: * pkgtools/pkgdiff: Automate making and maintaining patches for a package
2409: (includes pkgdiff, pkgvi, mkpatches, etc.).
2410:
1.65 wiz 2411: * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1 dsieger 2412:
2413: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
2414:
2415: * pkgtools/pkg_comp: Build packages in a chrooted area.
2416:
2417: * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
2418:
1.154 rillig 2419: 10.3. How to use pkgsrc as non-root
1.1 dsieger 2420:
1.108 rillig 2421: To install packages from source as a non-root user, download pkgsrc as
1.154 rillig 2422: described in Chapter 3, Where to get pkgsrc and how to keep it up-to-date, cd
1.108 rillig 2423: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
2424:
2425: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
2426: configuration mk.conf into ~/pkg/etc.
2427:
2428: For more details, see mk/unprivileged.mk.
1.1 dsieger 2429:
1.154 rillig 2430: 10.4. How to resume transfers when fetching distfiles?
1.1 dsieger 2431:
2432: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4 rillig 2433: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
2434: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1 dsieger 2435:
1.61 wiz 2436: You can also use a different program than the platform default program by
2437: changing the FETCH_USING variable. You can specify the program by using of ftp,
2438: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
2439: manual. A value of custom disables the system defaults and dependency tracking
2440: for the fetch program. In that case you have to provide FETCH_CMD,
2441: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1 dsieger 2442:
1.16 jnemeth 2443: For example, if you want to use wget to download, you'll have to use something
2444: like:
1.1 dsieger 2445:
1.16 jnemeth 2446: FETCH_USING= wget
1.1 dsieger 2447:
1.154 rillig 2448: 10.5. How can I install/use modular X.org from pkgsrc?
1.1 dsieger 2449:
1.4 rillig 2450: If you want to use modular X.org from pkgsrc instead of your system's own X11
2451: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1 dsieger 2452: mk.conf:
2453:
1.4 rillig 2454: X11_TYPE=modular
1.1 dsieger 2455:
1.154 rillig 2456: 10.6. How to fetch files from behind a firewall
1.1 dsieger 2457:
2458: If you are sitting behind a firewall which does not allow direct connections to
2459: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
2460: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
2461: machine "orpheus.amdahl.com" is one of the firewalls, and it uses port 80 as
2462: the proxy port number. So the proxy environment variables are:
2463:
2464: ftp_proxy=ftp://orpheus.amdahl.com:80/
2465: http_proxy=http://orpheus.amdahl.com:80/
2466:
1.154 rillig 2467: 10.7. How to fetch files from HTTPS sites
1.65 wiz 2468:
2469: Some fetch tools are not prepared to support HTTPS by default (for example, the
2470: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
2471: openssl dependency that low in the dependency graph).
2472:
2473: Usually you won't notice, because distribution files are mirrored weekly to "
2474: ftp.NetBSD.org", but that might not be often enough if you are following
2475: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to "curl" or
2476: "wget", which are both compiled with HTTPS support by default. Of course, these
2477: tools need to be installed before you can use them this way.
2478:
1.154 rillig 2479: 10.8. How do I tell make fetch to do passive FTP?
1.1 dsieger 2480:
2481: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
2482: FETCH_CMD is assigned the first available command from the following list:
2483:
2484: * ${LOCALBASE}/bin/ftp
2485:
2486: * /usr/bin/ftp
2487:
2488: On a default NetBSD installation, this will be /usr/bin/ftp, which
2489: automatically tries passive connections first, and falls back to active
2490: connections if the server refuses to do passive. For the other tools, add the
1.4 rillig 2491: following to your mk.conf file: PASSIVE_FETCH=1.
1.1 dsieger 2492:
2493: Having that option present will prevent /usr/bin/ftp from falling back to
2494: active transfers.
2495:
1.154 rillig 2496: 10.9. How to fetch all distfiles at once
1.1 dsieger 2497:
2498: You would like to download all the distfiles in a single batch from work or
2499: university, where you can't run a make fetch. There is an archive of distfiles
2500: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
2501:
2502: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
2503: subdirectories, carry the resulting list to your machine at work/school and use
2504: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
2505: don't forget to set FETCH_CMD to something that fetches a URL:
2506:
2507: At home:
2508:
2509: % cd /usr/pkgsrc
2510: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
2511: % scp /tmp/fetch.sh work:/tmp
2512:
2513: At work:
2514:
2515: % sh /tmp/fetch.sh
2516:
2517: then tar up /tmp/distfiles and take it home.
2518:
2519: If you have a machine running NetBSD, and you want to get all distfiles (even
2520: ones that aren't for your machine architecture), you can do so by using the
2521: above-mentioned make fetch-list approach, or fetch the distfiles directly by
2522: running:
2523:
2524: % make mirror-distfiles
2525:
2526: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
2527: everything by running:
2528:
2529: % make fetch NO_SKIP=yes
2530:
1.154 rillig 2531: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1.1 dsieger 2532:
2533: When compiling the pkgtools/pkg_install package, you get the error from make
2534: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
2535: that you don't have installed the "text" set (nroff, ...) from the NetBSD base
2536: distribution on your machine. It is recommended to do that to format man pages.
2537:
2538: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4 rillig 2539: NOMAN=YES either in the environment or in mk.conf.
1.1 dsieger 2540:
1.154 rillig 2541: 10.11. What does "Could not find bsd.own.mk" mean?
1.1 dsieger 2542:
2543: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
2544: machine. Please get and install it, by extracting it in /:
2545:
2546: # cd /
2547: # tar --unlink -zxvpf .../comp.tgz
2548:
2549: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
2550: release (determine via uname -r).
2551:
1.154 rillig 2552: 10.12. Using 'sudo' with pkgsrc
1.1 dsieger 2553:
2554: When installing packages as non-root user and using the just-in-time su(1)
2555: feature of pkgsrc, it can become annoying to type in the root password for each
2556: required package installed. To avoid this, the sudo package can be used, which
2557: does password caching over a limited time. To use it, install sudo (either as
1.4 rillig 2558: binary package or from security/sudo) and then put the following into your
2559: mk.conf, somewhere after the definition of the LOCALBASE variable:
1.1 dsieger 2560:
2561: .if exists(${LOCALBASE}/bin/sudo)
2562: SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
2563: .endif
2564:
1.154 rillig 2565: 10.13. How do I change the location of configuration files?
1.1 dsieger 2566:
2567: As the system administrator, you can choose where configuration files are
2568: installed. The default settings make all these files go into ${PREFIX}/etc or
2569: some of its subdirectories; this may be suboptimal depending on your
2570: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
2571: configuration of the provided packages).
2572:
2573: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4 rillig 2574: (in mk.conf) to point to your preferred configuration directory; some common
2575: examples include /etc or /etc/pkg.
1.1 dsieger 2576:
2577: Furthermore, you can change this value on a per-package basis by setting the
2578: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
2579: matches the name of the package you would like to modify, that is, the contents
2580: of PKGBASE.
2581:
2582: Note that after changing these settings, you must rebuild and reinstall any
2583: affected packages.
2584:
1.154 rillig 2585: 10.14. Automated security checks
1.1 dsieger 2586:
2587: Please be aware that there can often be bugs in third-party software, and some
2588: of these bugs can leave a machine vulnerable to exploitation by attackers. In
2589: an effort to lessen the exposure, the NetBSD packages team maintains a database
2590: of known-exploits to packages which have at one time been included in pkgsrc.
2591: The database can be downloaded automatically, and a security audit of all
1.14 jmcneill 2592: packages installed on a system can take place. To do this, refer to the
2593: following two tools (installed as part of the pkgtools/pkg_install package):
1.1 dsieger 2594:
1.21 snj 2595: 1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
2596: security vulnerabilities information. This list is kept up to date by the
1.26 spz 2597: pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1 dsieger 2598:
1.177 leot 2599: https://ftp.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities
1.1 dsieger 2600:
1.21 snj 2601: 2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24 wiz 2602: known vulnerability. If a vulnerable package is installed, it will be shown
2603: by output to stdout, including a description of the type of vulnerability,
2604: and a URL containing more information.
1.1 dsieger 2605:
1.202 nia 2606: Use of these tools is strongly recommended! See Section 5.1.6, "Checking for
1.121 sevan 2607: security vulnerabilities in installed packages" for instructions on how to
2608: automate checking and reporting.
2609:
2610: If this database is installed, pkgsrc builds will use it to perform a security
2611: check before building any package.
1.1 dsieger 2612:
1.154 rillig 2613: 10.15. Why do some packages ignore my CFLAGS?
1.1 dsieger 2614:
2615: When you add your own preferences to the CFLAGS variable in your mk.conf, these
2616: flags are passed in environment variables to the ./configure scripts and to
2617: make(1). Some package authors ignore the CFLAGS from the environment variable
2618: by overriding them in the Makefiles of their package.
2619:
2620: Currently there is no solution to this problem. If you really need the package
2621: to use your CFLAGS you should run make patch in the package directory and then
2622: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
2623: Usually you can remove these lines. But be aware that some "smart" programmers
2624: write so bad code that it only works for the specific combination of CFLAGS
2625: they have chosen.
2626:
1.172 rillig 2627: To find out where the CFLAGS are ignored, add the following lines to mk.conf:
2628:
2629: CPPFLAGS+= -Dpkgsrc___CPPFLAGS
2630: CFLAGS+= -Dpkgsrc___CFLAGS
2631: CXXFLAGS+= -Dpkgsrc___CXXFLAGS
2632:
2633: Then run bmake show-all-configure show-all-build to see whether the above flags
2634: are passed to the actual build commands in general.
2635:
2636: To find out whether the flags are passed to individual compiler commands, have
2637: a look at the file work/.work.log. In most cases, the flags from the original
2638: command lines (the lines starting with [*]) are passed unmodified to the actual
2639: compiler (the lines starting with <.>). If the flag is missing from the actual
2640: compiler command, it must have been removed by the pkgsrc compiler wrappers.
2641:
1.154 rillig 2642: 10.16. A package does not build. What shall I do?
1.1 dsieger 2643:
2644: 1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
2645: is that people only update pkgsrc in parts, because of performance reasons.
2646: Since pkgsrc is one large system, not a collection of many small systems,
2647: there are sometimes changes that only work when the whole pkgsrc tree is
2648: updated.
2649:
1.25 wiz 2650: 2. Make sure that you don't have any CVS conflicts. Search for "<<<<<<" or "
2651: >>>>>>" in all your pkgsrc files.
1.1 dsieger 2652:
1.25 wiz 2653: 3. Make sure that you don't have old copies of the packages extracted. Run
1.1 dsieger 2654: make clean clean-depends to verify this.
2655:
1.108 rillig 2656: 4. If you are a package developer who wants to invest some work, have a look
1.154 rillig 2657: at Chapter 21, Making your package work.
1.108 rillig 2658:
2659: 5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1 dsieger 2660:
1.154 rillig 2661: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.1 dsieger 2662: conflicts" mean?
2663:
2664: You have modified a file from pkgsrc, and someone else has modified that same
2665: file afterwards in the CVS repository. Both changes are in the same region of
2666: the file, so when you updated pkgsrc, the cvs command marked the conflicting
2667: changes in the file. Because of these markers, the file is no longer a valid
2668: Makefile.
2669:
2670: Have a look at that file, and if you don't need your local changes anymore, you
2671: can remove that file and run cvs -q update -dP in that directory to download
2672: the current version.
2673:
2674: Part II. The pkgsrc developer's guide
2675:
2676: This part of the book deals with creating and modifying packages. It starts
2677: with a "HOWTO"-like guide on creating a new package. The remaining chapters are
2678: more like a reference manual for pkgsrc.
2679:
2680: Table of Contents
2681:
1.154 rillig 2682: 11. Getting help
1.184 rillig 2683: 12. Package components - files, directories and contents
1.1 dsieger 2684:
1.184 rillig 2685: 12.1. Makefile
2686: 12.2. distinfo
2687: 12.3. patches/*
1.1 dsieger 2688:
1.184 rillig 2689: 12.3.1. Structure of a single patch file
2690: 12.3.2. Creating patch files
2691: 12.3.3. Sources where the patch files come from
2692: 12.3.4. Patching guidelines
2693: 12.3.5. Feedback to the author
1.1 dsieger 2694:
1.184 rillig 2695: 12.4. Other mandatory files
2696: 12.5. Optional files
1.1 dsieger 2697:
1.184 rillig 2698: 12.5.1. Files affecting the binary package
2699: 12.5.2. Files affecting the build process
2700: 12.5.3. Files affecting nothing at all
1.1 dsieger 2701:
1.184 rillig 2702: 12.6. work*
2703: 12.7. files/*
1.1 dsieger 2704:
1.184 rillig 2705: 13. The build process
1.1 dsieger 2706:
1.184 rillig 2707: 13.1. Introduction
2708: 13.2. Program location
2709: 13.3. Directories used during the build process
2710: 13.4. Running a phase
2711: 13.5. The fetch phase
1.1 dsieger 2712:
1.184 rillig 2713: 13.5.1. What to fetch and where to get it from
2714: 13.5.2. How are the files fetched?
1.1 dsieger 2715:
1.184 rillig 2716: 13.6. The checksum phase
2717: 13.7. The extract phase
2718: 13.8. The patch phase
2719: 13.9. The tools phase
2720: 13.10. The wrapper phase
2721: 13.11. The configure phase
2722: 13.12. The build phase
2723: 13.13. The test phase
2724: 13.14. The install phase
2725: 13.15. The package phase
2726: 13.16. Cleaning up
2727: 13.17. Other helpful targets
1.1 dsieger 2728:
1.184 rillig 2729: 14. Creating a new pkgsrc package from scratch
1.1 dsieger 2730:
1.184 rillig 2731: 14.1. Common types of packages
1.1 dsieger 2732:
1.217 ! rillig 2733: 14.1.1. Python modules and programs
! 2734: 14.1.2. R packages
! 2735: 14.1.3. TeXlive packages
1.1 dsieger 2736:
1.184 rillig 2737: 14.2. Examples
1.1 dsieger 2738:
1.184 rillig 2739: 14.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 2740:
1.184 rillig 2741: 15. Programming in Makefiles
1.1 dsieger 2742:
1.184 rillig 2743: 15.1. Caveats
2744: 15.2. Makefile variables
1.1 dsieger 2745:
1.184 rillig 2746: 15.2.1. Naming conventions
1.1 dsieger 2747:
1.184 rillig 2748: 15.3. Code snippets
1.1 dsieger 2749:
1.184 rillig 2750: 15.3.1. Adding things to a list
2751: 15.3.2. Echoing a string exactly as-is
2752: 15.3.3. Passing CFLAGS to GNU configure scripts
2753: 15.3.4. Handling possibly empty variables
1.1 dsieger 2754:
1.184 rillig 2755: 16. Options handling
1.1 dsieger 2756:
1.184 rillig 2757: 16.1. Global default options
2758: 16.2. Converting packages to use bsd.options.mk
2759: 16.3. Option Names
2760: 16.4. Determining the options of dependencies
1.1 dsieger 2761:
1.184 rillig 2762: 17. Tools needed for building or running
1.1 dsieger 2763:
1.184 rillig 2764: 17.1. Tools for pkgsrc builds
2765: 17.2. Tools needed by packages
2766: 17.3. Tools provided by platforms
1.1 dsieger 2767:
1.184 rillig 2768: 18. Buildlink methodology
1.1 dsieger 2769:
1.184 rillig 2770: 18.1. Converting packages to use buildlink3
2771: 18.2. Writing buildlink3.mk files
1.1 dsieger 2772:
1.184 rillig 2773: 18.2.1. Anatomy of a buildlink3.mk file
2774: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
2775: pkg in buildlink3.mk files
1.1 dsieger 2776:
1.184 rillig 2777: 18.3. Writing builtin.mk files
1.1 dsieger 2778:
1.184 rillig 2779: 18.3.1. Anatomy of a builtin.mk file
2780: 18.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 2781:
1.184 rillig 2782: 19. PLIST issues
1.1 dsieger 2783:
1.184 rillig 2784: 19.1. RCS ID
2785: 19.2. Semi-automatic PLIST generation
2786: 19.3. Tweaking output of make print-PLIST
2787: 19.4. Variable substitution in PLIST
2788: 19.5. Man page compression
2789: 19.6. Changing PLIST source with PLIST_SRC
2790: 19.7. Platform-specific and differing PLISTs
2791: 19.8. Build-specific PLISTs
2792: 19.9. Sharing directories between packages
1.1 dsieger 2793:
1.184 rillig 2794: 20. The pkginstall framework
1.1 dsieger 2795:
1.184 rillig 2796: 20.1. Files and directories outside the installation prefix
1.1 dsieger 2797:
1.184 rillig 2798: 20.1.1. Directory manipulation
2799: 20.1.2. File manipulation
1.1 dsieger 2800:
1.184 rillig 2801: 20.2. Configuration files
1.1 dsieger 2802:
1.184 rillig 2803: 20.2.1. How PKG_SYSCONFDIR is set
2804: 20.2.2. Telling the software where configuration files are
2805: 20.2.3. Patching installations
2806: 20.2.4. Disabling handling of configuration files
1.1 dsieger 2807:
1.184 rillig 2808: 20.3. System startup scripts
1.1 dsieger 2809:
1.184 rillig 2810: 20.3.1. Disabling handling of system startup scripts
1.1 dsieger 2811:
1.184 rillig 2812: 20.4. System users and groups
2813: 20.5. System shells
1.1 dsieger 2814:
1.184 rillig 2815: 20.5.1. Disabling shell registration
1.1 dsieger 2816:
1.184 rillig 2817: 20.6. Fonts
1.1 dsieger 2818:
1.184 rillig 2819: 20.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 2820:
1.154 rillig 2821: 21. Making your package work
1.1 dsieger 2822:
1.154 rillig 2823: 21.1. General operation
1.1 dsieger 2824:
1.154 rillig 2825: 21.1.1. How to pull in user-settable variables from mk.conf
2826: 21.1.2. User interaction
2827: 21.1.3. Handling licenses
2828: 21.1.4. Restricted packages
2829: 21.1.5. Handling dependencies
2830: 21.1.6. Handling conflicts with other packages
2831: 21.1.7. Packages that cannot or should not be built
2832: 21.1.8. Packages which should not be deleted, once installed
2833: 21.1.9. Handling packages with security problems
2834: 21.1.10. How to handle incrementing versions when fixing an existing
1.1 dsieger 2835: package
1.154 rillig 2836: 21.1.11. Substituting variable text in the package files (the SUBST
1.1 dsieger 2837: framework)
2838:
1.154 rillig 2839: 21.2. The fetch phase
1.1 dsieger 2840:
1.154 rillig 2841: 21.2.1. Packages whose distfiles aren't available for plain downloading
2842: 21.2.2. How to handle modified distfiles with the 'old' name
2843: 21.2.3. Packages hosted on github.com
2844:
2845: 21.3. The configure phase
2846:
2847: 21.3.1. Shared libraries - libtool
2848: 21.3.2. Using libtool on GNU packages that already support libtool
2849: 21.3.3. GNU Autoconf/Automake
2850:
2851: 21.4. Programming languages
2852:
2853: 21.4.1. C, C++, and Fortran
2854: 21.4.2. Java
1.205 wiz 2855: 21.4.3. Go
2856: 21.4.4. Packages containing Perl scripts
2857: 21.4.5. Packages containing shell scripts
2858: 21.4.6. Other programming languages
1.154 rillig 2859:
2860: 21.5. The build phase
2861:
2862: 21.5.1. Compiling C and C++ code conditionally
2863: 21.5.2. How to handle compiler bugs
1.172 rillig 2864: 21.5.3. No such file or directory
2865: 21.5.4. Undefined reference to "..."
2866: 21.5.5. Running out of memory
1.154 rillig 2867:
2868: 21.6. The install phase
2869:
2870: 21.6.1. Creating needed directories
2871: 21.6.2. Where to install documentation
2872: 21.6.3. Installing highscore files
2873: 21.6.4. Adding DESTDIR support to packages
2874: 21.6.5. Packages with hardcoded paths to other interpreters
1.203 nia 2875: 21.6.6. Packages installing Perl modules
1.154 rillig 2876: 21.6.7. Packages installing info files
2877: 21.6.8. Packages installing man pages
1.203 nia 2878: 21.6.9. Packages installing X11 fonts
2879: 21.6.10. Packages installing SGML or XML data
2880: 21.6.11. Packages installing extensions to the MIME database
2881: 21.6.12. Packages using intltool
2882: 21.6.13. Packages installing startup scripts
2883: 21.6.14. Packages installing TeX modules
2884: 21.6.15. Packages supporting running binaries in emulation
2885: 21.6.16. Packages installing hicolor icons
2886: 21.6.17. Packages installing desktop files
1.154 rillig 2887:
2888: 21.7. Marking packages as having problems
2889:
1.184 rillig 2890: 22. GNOME packaging and porting
2891:
2892: 22.1. Meta packages
2893: 22.2. Packaging a GNOME application
2894: 22.3. Updating GNOME to a newer version
2895: 22.4. Patching guidelines
2896:
1.154 rillig 2897: 23. Submitting and Committing
2898:
2899: 23.1. Submitting binary packages
2900: 23.2. Submitting source packages (for non-NetBSD-developers)
2901: 23.3. General notes when adding, updating, or removing packages
2902: 23.4. Commit Messages
2903: 23.5. Committing: Adding a package to CVS
2904: 23.6. Updating a package to a newer version
2905: 23.7. Renaming a package in pkgsrc
2906: 23.8. Moving a package in pkgsrc
2907:
2908: 24. Frequently Asked Questions
2909:
2910: Chapter 11. Getting help
2911:
2912: To get help when developing pkgsrc, the definitive source is this document, the
2913: pkgsrc guide. If you don't find anything here, there are alternatives:
2914:
2915: * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
2916: Run bmake help topic=? to get help for any topic, such as a variable name
2917: like BUILD_DEFS, a make target like do-build, a missing C or C++ function
2918: like strcasecmp or any other topic.
2919:
1.207 leot 2920: The available help topics are listed in Appendix E, Help topics.
1.154 rillig 2921:
1.163 rillig 2922: * To see the value of a single variable, run bmake show-var VARNAME=X.
2923:
2924: * To see the values of the most common variables, run bmake show-all. These
2925: variables are grouped by topic. To see the variables for a single topic,
2926: run bmake show-all-topic, for example bmake show-all-fetch.
2927:
1.154 rillig 2928: * The tech-pkg mailing list, to which you can subscribe and then ask your
2929: questions.
2930:
2931: * The #pkgsrc IRC channel, which is accessible via a web browser or by using
2932: a specialized chat program such as XChat. Pick any user name and join the
2933: channel #pkgsrc.
1.1 dsieger 2934:
1.184 rillig 2935: Chapter 12. Package components - files, directories and contents
1.1 dsieger 2936:
2937: Table of Contents
2938:
1.184 rillig 2939: 12.1. Makefile
2940: 12.2. distinfo
2941: 12.3. patches/*
2942:
2943: 12.3.1. Structure of a single patch file
2944: 12.3.2. Creating patch files
2945: 12.3.3. Sources where the patch files come from
2946: 12.3.4. Patching guidelines
2947: 12.3.5. Feedback to the author
2948:
2949: 12.4. Other mandatory files
2950: 12.5. Optional files
2951:
2952: 12.5.1. Files affecting the binary package
2953: 12.5.2. Files affecting the build process
2954: 12.5.3. Files affecting nothing at all
1.1 dsieger 2955:
1.184 rillig 2956: 12.6. work*
2957: 12.7. files/*
1.1 dsieger 2958:
1.184 rillig 2959: Whenever you're preparing a package, there are a number of files involved which
2960: are described in the following sections.
1.1 dsieger 2961:
1.184 rillig 2962: 12.1. Makefile
1.1 dsieger 2963:
1.184 rillig 2964: Building, installation and creation of a binary package are all controlled by
2965: the package's Makefile. The Makefile describes various things about a package,
2966: for example from where to get it, how to configure, build, and install it.
1.1 dsieger 2967:
1.184 rillig 2968: A package Makefile contains several sections that describe the package.
1.1 dsieger 2969:
1.184 rillig 2970: In the first section there are the following variables, which should appear
2971: exactly in the order given here. The order and grouping of the variables is
2972: mostly historical and has no further meaning.
1.1 dsieger 2973:
1.184 rillig 2974: * DISTNAME is the basename of the distribution file to be downloaded from the
2975: package's website.
1.1 dsieger 2976:
1.184 rillig 2977: * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
2978: it if DISTNAME (which is the default) is not a good name for the package in
2979: pkgsrc or DISTNAME is not provided (no distribution file is required).
2980: Usually it is the pkgsrc directory name together with the version number.
2981: It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
2982: is, it starts with a letter or digit, and contains only letters, digits,
1.204 nia 2983: dashes, underscores, dots and plus signs. New packages should have entirely
2984: lower-case names, with the exception of some that must follow pre-existing
2985: conventions (e.g. R packages begin with R-). You can use the :tl variable
2986: modifier to lower-case the package name.
1.26 spz 2987:
1.184 rillig 2988: * CATEGORIES is a list of categories which the package fits in. You can
2989: choose any of the top-level directories of pkgsrc for it.
1.1 dsieger 2990:
1.184 rillig 2991: Currently the following values are available for CATEGORIES. If more than
2992: one is used, they need to be separated by spaces:
1.1 dsieger 2993:
1.184 rillig 2994: archivers cross geography meta-pkgs security
2995: audio databases graphics misc shells
2996: benchmarks devel ham multimedia sysutils
2997: biology editors inputmethod net textproc
2998: cad emulators lang news time
2999: chat finance mail parallel wm
3000: comms fonts math pkgtools www
3001: converters games mbone print x11
1.1 dsieger 3002:
1.184 rillig 3003: * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
3004: are discussed in detail in Section 13.5, "The fetch phase".
1.1 dsieger 3005:
1.184 rillig 3006: The second section contains information about separately downloaded patches, if
3007: any.
1.1 dsieger 3008:
1.184 rillig 3009: * PATCHFILES: Name(s) of additional files that contain distribution patches.
3010: There is no default. pkgsrc will look for them at PATCH_SITES. They will
3011: automatically be uncompressed before patching if the names end with .gz or
3012: .Z.
1.1 dsieger 3013:
1.184 rillig 3014: * PATCH_SITES: Primary location(s) for distribution patch files (see
3015: PATCHFILES above) if not found locally.
1.1 dsieger 3016:
1.184 rillig 3017: * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
3018: count to help find the correct files to patch. It defaults to -p0.
1.1 dsieger 3019:
1.184 rillig 3020: The third section contains the following variables.
1.1 dsieger 3021:
1.184 rillig 3022: * MAINTAINER is the email address of the person who feels responsible for
3023: this package, and who is most likely to look at problems or questions
3024: regarding this package which have been reported with send-pr(1). Other
3025: developers may contact the MAINTAINER before making changes to the package,
3026: but are not required to do so. When packaging a new program, set MAINTAINER
3027: to yourself. If you really can't maintain the package for future updates,
3028: set it to <pkgsrc-users@NetBSD.org>.
1.1 dsieger 3029:
1.184 rillig 3030: * OWNER should be used instead of MAINTAINER when you do not want other
3031: developers to update or change the package without contacting you first. A
3032: package Makefile should contain one of MAINTAINER or OWNER, but not both.
1.1 dsieger 3033:
1.184 rillig 3034: * HOMEPAGE is a URL where users can find more information about the package.
1.1 dsieger 3035:
1.184 rillig 3036: * COMMENT is a one-line description of the package (should not include the
3037: package name).
1.1 dsieger 3038:
1.184 rillig 3039: * LICENSE indicates the license(s) applicable for the package. See
3040: Section 21.1.3, "Handling licenses" for further details.
1.1 dsieger 3041:
1.184 rillig 3042: Other variables that affect the build:
1.1 dsieger 3043:
1.184 rillig 3044: * WRKSRC: The directory where the interesting distribution files of the
3045: package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
3046: most packages.
1.1 dsieger 3047:
1.184 rillig 3048: If a package doesn't create a subdirectory for itself (most GNU software
3049: does, for instance), but extracts itself in the current directory, you
3050: should set WRKSRC=${WRKDIR}.
1.1 dsieger 3051:
1.184 rillig 3052: If a package doesn't create a subdirectory with the name of DISTNAME but
3053: some different name, set WRKSRC to point to the proper name in ${WRKDIR},
3054: for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
3055: other examples.
1.17 imil 3056:
1.184 rillig 3057: The name of the working directory created by pkgsrc is taken from the
3058: WRKDIR_BASENAME variable. By default, its value is work. If you want to use
3059: the same pkgsrc tree for building different kinds of binary packages, you
3060: can change the variable according to your needs. Two other variables handle
3061: common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
3062: defined in mk.conf, the first component of the host's name is attached to
3063: the directory name. If OBJMACHINE is defined, the platform name is
3064: attached, which might look like work.i386 or work.sparc.
1.17 imil 3065:
1.184 rillig 3066: Please pay attention to the following gotchas:
1.17 imil 3067:
1.184 rillig 3068: * Add MANCOMPRESSED if man pages are installed in compressed form by the
3069: package. For packages using BSD-style makefiles which honor MANZ, there is
3070: MANCOMPRESSED_IF_MANZ.
1.17 imil 3071:
1.184 rillig 3072: * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
1.103 wiz 3073:
1.184 rillig 3074: * If the package installs any info files, see Section 21.6.7, "Packages
3075: installing info files".
1.103 wiz 3076:
1.184 rillig 3077: 12.2. distinfo
1.17 imil 3078:
1.184 rillig 3079: The distinfo file contains the message digest, or checksum, of each distfile
3080: needed for the package. This ensures that the distfiles retrieved from the
3081: Internet have not been corrupted during transfer or altered by a malign force
3082: to introduce a security hole. To provide maximum security, all distfiles are
3083: protected using three different message digest algorithms (SHA1, RMD160,
3084: SHA512), as well as the file size.
1.17 imil 3085:
1.184 rillig 3086: The distinfo file also contains the checksums for all the patches found in the
3087: patches directory (see Section 12.3, "patches/*"). These checksums ensure that
3088: patches are only applied intentionally and that they don't accidentally change,
3089: e.g. when merging different changes together. They also make sure that new
3090: patches are actually added to CVS and old ones are removed. Too see whether the
3091: patches and the distinfo file match, run pkglint after changing the patches.
1.17 imil 3092:
1.184 rillig 3093: To regenerate the distinfo file, use the make distinfo command.
1.17 imil 3094:
1.184 rillig 3095: Some packages have different sets of distfiles depending on the platform, for
3096: example lang/openjdk8. These are kept in the same distinfo file and care should
3097: be taken when upgrading such a package to ensure distfile information is not
3098: lost.
1.17 imil 3099:
1.184 rillig 3100: 12.3. patches/*
1.63 wiz 3101:
1.184 rillig 3102: Some packages don't work out-of-the box on the various platforms that are
3103: supported by pkgsrc. These packages need to be patched to make them work. The
3104: patch files can be found in the patches/ directory.
1.17 imil 3105:
1.184 rillig 3106: In the patch phase, these patches are applied to the files in WRKSRC directory
3107: after extracting them, in alphabetic order.
1.160 brook 3108:
1.184 rillig 3109: 12.3.1. Structure of a single patch file
1.160 brook 3110:
1.184 rillig 3111: The patch-* files should be in diff -bu format, and apply without a fuzz to
3112: avoid problems. (To force patches to apply with fuzz you can set
3113: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
3114: a single file, and no file should be patched by more than one patch file. This
3115: helps to keep future modifications simple.
1.160 brook 3116:
1.184 rillig 3117: Each patch file is structured as follows: In the first line, there is the RCS
3118: Id of the patch itself. The second line should be empty for aesthetic reasons.
3119: After that, there should be a comment for each change that the patch does.
3120: There are a number of standard cases:
1.160 brook 3121:
1.184 rillig 3122: * Patches for commonly known vulnerabilities should mention the vulnerability
3123: ID (CAN, CVE).
1.160 brook 3124:
1.184 rillig 3125: * Patches that change source code should mention the platform and other
3126: environment (for example, the compiler) that the patch is needed for.
1.160 brook 3127:
1.184 rillig 3128: The patch should be commented so that any developer who knows the code of the
3129: application can make some use of the patch. Special care should be taken for
3130: the upstream developers, since we generally want that they accept our patches,
3131: so we have less work in the future.
1.160 brook 3132:
1.184 rillig 3133: 12.3.2. Creating patch files
1.160 brook 3134:
1.184 rillig 3135: One important thing to mention is to pay attention that no RCS IDs get stored
3136: in the patch files, as these will cause problems when later checked into the
3137: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
3138: avoid these problems.
1.160 brook 3139:
1.184 rillig 3140: For even more automation, we recommend using mkpatches from the same package to
3141: make a whole set of patches. You just have to backup files before you edit them
3142: to filename.orig, e.g. with cp -p filename filename.orig or, easier, by using
3143: pkgvi again from the same package. If you upgrade a package this way, you can
3144: easily compare the new set of patches with the previously existing one with
3145: patchdiff. The files in patches are replaced by new files, so carefully check
3146: if you want to take all the changes.
1.160 brook 3147:
1.184 rillig 3148: When you have finished a package, remember to generate the checksums for the
3149: patch files by using the make makepatchsum command, see Section 12.2,
3150: "distinfo".
1.1 dsieger 3151:
1.184 rillig 3152: When adding a patch that corrects a problem in the distfile (rather than e.g.
3153: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
3154: report to the maintainer. This benefits non-pkgsrc users of the package, and
3155: usually makes it possible to remove the patch in future version.
1.1 dsieger 3156:
1.184 rillig 3157: The file names of the patch files are usually of the form patch-
3158: path_to_file__with__underscores.c. Many packages still use the previous
3159: convention patch-[a-z][a-z], but new patches should be of the form containing
3160: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
3161: automatically.
1.1 dsieger 3162:
1.184 rillig 3163: 12.3.3. Sources where the patch files come from
1.1 dsieger 3164:
1.184 rillig 3165: If you want to share patches between multiple packages in pkgsrc, e.g. because
3166: they use the same distfiles, set PATCHDIR to the path where the patch files can
3167: be found, e.g.:
1.1 dsieger 3168:
1.184 rillig 3169: PATCHDIR= ../../editors/xemacs/patches
1.1 dsieger 3170:
1.184 rillig 3171: Patch files that are distributed by the author or other maintainers can be
3172: listed in PATCHFILES.
1.1 dsieger 3173:
1.184 rillig 3174: If it is desired to store any patches that should not be committed into pkgsrc,
3175: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
3176: directory tree there is expected to have the same "category/package" structure
3177: as pkgsrc, and patches are expected to be stored inside these dirs (also known
3178: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
3179: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
3180: files in the named directory are expected to be patch files, and they are
3181: applied after pkgsrc patches are applied.
1.1 dsieger 3182:
1.184 rillig 3183: 12.3.4. Patching guidelines
1.1 dsieger 3184:
1.184 rillig 3185: When fixing a portability issue in the code do not use preprocessor magic to
3186: check for the current operating system nor platform. Doing so hurts portability
3187: to other platforms because the OS-specific details are not abstracted
3188: appropriately.
1.1 dsieger 3189:
1.184 rillig 3190: The general rule to follow is: instead of checking for the operating system the
3191: application is being built on, check for the specific features you need. For
3192: example, instead of assuming that kqueue is available under NetBSD and using
3193: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
1.198 leot 3194: kqueue itself -- yes, this generally involves patching the configure script.
1.184 rillig 3195: There is absolutely nothing that prevents some OSes from adopting interfaces
3196: from other OSes (e.g. Linux implementing kqueue), something that the above
3197: checks cannot take into account.
1.1 dsieger 3198:
1.184 rillig 3199: Of course, checking for features generally involves more work on the
3200: developer's side, but the resulting changes are cleaner and there are chances
3201: they will work on many other platforms. Not to mention that there are higher
3202: chances of being later integrated into the mainstream sources. Remember: It
3203: doesn't work unless it is right!
1.1 dsieger 3204:
1.184 rillig 3205: Some typical examples:
1.121 sevan 3206:
1.184 rillig 3207: Table 12.1. Patching examples
1.1 dsieger 3208:
1.184 rillig 3209: +-------------------------------------------------------------------------------------------+
3210: | Where | Incorrect | Correct |
3211: |---------+--------------------------+------------------------------------------------------|
3212: | |case ${target_os} in | |
3213: |configure|netbsd*) have_kvm=yes ;; |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
3214: |script |*) have_kvm=no ;; | |
3215: | |esac | |
3216: |---------+--------------------------+------------------------------------------------------|
3217: |C source |#if defined(__NetBSD__) |#if defined(HAVE_SYS_EVENT_H) |
3218: |file |# include <sys/event.h> |# include <sys/event.h> |
3219: | |#endif |#endif |
3220: |---------+--------------------------+------------------------------------------------------|
3221: | |int |int |
3222: | |monitor_file(...) |monitor_file(...) |
3223: | |{ |{ |
3224: | |#if defined(__NetBSD__) |#if defined(HAVE_KQUEUE) |
3225: |C source | int fd = kqueue();| int fd = kqueue(); |
3226: |file | ... | ... |
3227: | |#else |#else |
3228: | | ... | ... |
3229: | |#endif |#endif |
3230: | |} |} |
3231: +-------------------------------------------------------------------------------------------+
1.1 dsieger 3232:
3233:
1.184 rillig 3234: 12.3.5. Feedback to the author
1.1 dsieger 3235:
1.184 rillig 3236: Always, always, always feed back any portability fixes or improvements you do
3237: to a package to the mainstream developers. This is the only way to get their
3238: attention on portability issues and to ensure that future versions can be built
3239: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
3240: get the fixes straight from the packaged code.
1.1 dsieger 3241:
1.184 rillig 3242: This generally involves cleaning up the patches (because sometimes the patches
3243: that are added to pkgsrc are quick hacks), filing bug reports in the
3244: appropriate trackers for the projects and working with the mainstream authors
3245: to accept your changes. It is extremely important that you do it so that the
3246: packages in pkgsrc are kept simple and thus further changes can be done without
3247: much hassle.
1.1 dsieger 3248:
1.184 rillig 3249: When you have done this, please add a URL to the upstream bug report to the
3250: patch comment.
1.1 dsieger 3251:
1.184 rillig 3252: Support the idea of free software!
1.1 dsieger 3253:
1.184 rillig 3254: 12.4. Other mandatory files
1.1 dsieger 3255:
1.184 rillig 3256: DESCR
1.1 dsieger 3257:
1.184 rillig 3258: A multi-line description of the piece of software. This should include any
3259: credits where they are due. Please bear in mind that others do not share
3260: your sense of humour (or spelling idiosyncrasies), and that others will
3261: read everything that you write here.
1.1 dsieger 3262:
1.184 rillig 3263: PLIST
1.1 dsieger 3264:
1.184 rillig 3265: This file governs the files that are installed on your system: all the
3266: binaries, manual pages, etc. There are other directives which may be
3267: entered in this file, to control the creation and deletion of directories,
3268: and the location of inserted files. See Chapter 19, PLIST issues for more
3269: information.
1.1 dsieger 3270:
1.184 rillig 3271: 12.5. Optional files
1.1 dsieger 3272:
1.184 rillig 3273: 12.5.1. Files affecting the binary package
1.1 dsieger 3274:
1.184 rillig 3275: INSTALL
1.1 dsieger 3276:
1.184 rillig 3277: This shell script is invoked twice by pkg_add(1). First time after package
3278: extraction and before files are moved in place, the second time after the
3279: files to install are moved in place. This can be used to do any custom
3280: procedures not possible with @exec commands in PLIST. See pkg_add(1) and
3281: pkg_create(1) for more information. See also Section 20.1, "Files and
3282: directories outside the installation prefix". Please note that you can
3283: modify variables in it easily by using FILES_SUBST in the package's
3284: Makefile:
1.1 dsieger 3285:
1.184 rillig 3286: FILES_SUBST+= SOMEVAR="somevalue"
1.1 dsieger 3287:
1.184 rillig 3288: replaces "@SOMEVAR@" with "somevalue" in the INSTALL. By default,
3289: substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
3290: few others, type make help topic=FILES_SUBST for a complete list.
1.1 dsieger 3291:
1.184 rillig 3292: DEINSTALL
1.1 dsieger 3293:
1.184 rillig 3294: This script is executed before and after any files are removed. It is this
3295: script's responsibility to clean up any additional messy details around the
3296: package's installation, since all pkg_delete knows is how to delete the
3297: files created in the original distribution. See pkg_delete(1) and
3298: pkg_create(1) for more information. The same methods to replace variables
3299: can be used as for the INSTALL file.
1.1 dsieger 3300:
1.184 rillig 3301: MESSAGE
1.1 dsieger 3302:
1.198 leot 3303: This file is displayed after installation of the package. While this was
3304: used often in the past, it has two problems: the display will be missed if
3305: many packages are intalled at once, and the person installing the package
3306: and the one using or configuring it may be different. It should therefore
3307: be used only in exceptional circumstances where lasting negative
3308: consequences would result from someone not reading it.
3309:
3310: MESSAGE should not be used for:
3311:
3312: + exhortations to read the documentation
3313:
3314: + reminders to install rc.d files and set variables
3315:
3316: + anything that should be explained in the installation/configuration
3317: documentation that should come with the package
3318:
3319: If the documentation provided by upstream needs enhancing, create e.g.
3320: files/README.pkgsrc and install it in the package's documentation
3321: directory.
3322:
3323: Note that MESSAGE is shown for all operating systems and all init systems.
3324: If a MESSAGE is necessary, it should be narrowed to only those operating
3325: systems and init systems to which it applies.
3326:
3327: Note that you can modify variables in it easily by using MESSAGE_SUBST in
3328: the package's Makefile:
1.1 dsieger 3329:
1.184 rillig 3330: MESSAGE_SUBST+= SOMEVAR="somevalue"
1.1 dsieger 3331:
1.184 rillig 3332: replaces "${SOMEVAR}" with "somevalue" in MESSAGE. By default, substitution
3333: is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
3334: PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1 dsieger 3335:
1.184 rillig 3336: You can display a different or additional files by setting the MESSAGE_SRC
3337: variable. Its default is MESSAGE, if the file exists.
1.1 dsieger 3338:
1.184 rillig 3339: ALTERNATIVES
1.1 dsieger 3340:
1.184 rillig 3341: This file is used by the alternatives framework. It creates, configures,
3342: and destroys generic wrappers used to run programs with similar interfaces.
3343: See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
3344: information.
1.1 dsieger 3345:
1.184 rillig 3346: Each line of the file contains two filenames, first the wrapper and then
3347: the alternative provided by the package. Both paths are relative to PREFIX.
1.1 dsieger 3348:
1.184 rillig 3349: 12.5.2. Files affecting the build process
1.1 dsieger 3350:
1.184 rillig 3351: Makefile.common
1.1 dsieger 3352:
1.184 rillig 3353: This file contains arbitrary things that could also go into a Makefile, but
3354: its purpose is to be used by more than one package. This file should only
3355: be used when the packages that will use the file are known in advance. For
3356: other purposes it is often better to write a *.mk file and give it a good
3357: name that describes what it does.
1.1 dsieger 3358:
1.184 rillig 3359: buildlink3.mk
1.1 dsieger 3360:
1.184 rillig 3361: This file contains the dependency information for the buildlink3 framework
3362: (see Chapter 18, Buildlink methodology).
1.1 dsieger 3363:
1.184 rillig 3364: hacks.mk
1.1 dsieger 3365:
1.184 rillig 3366: This file contains workarounds for compiler bugs and similar things. It is
3367: included automatically by the pkgsrc infrastructure, so you don't need an
3368: extra .include line for it.
1.1 dsieger 3369:
1.184 rillig 3370: options.mk
1.1 dsieger 3371:
1.184 rillig 3372: This file contains the code for the package-specific options (see
3373: Chapter 16, Options handling) that can be selected by the user. If a
3374: package has only one or two options, it is equally acceptable to put the
3375: code directly into the Makefile.
1.1 dsieger 3376:
1.184 rillig 3377: 12.5.3. Files affecting nothing at all
1.1 dsieger 3378:
1.184 rillig 3379: README*
1.1 dsieger 3380:
1.184 rillig 3381: These files do not take place in the creation of a package and thus are
3382: purely informative to the package developer.
1.1 dsieger 3383:
1.184 rillig 3384: TODO
1.1 dsieger 3385:
1.184 rillig 3386: This file contains things that need to be done to make the package even
3387: better.
1.1 dsieger 3388:
1.184 rillig 3389: 12.6. work*
1.1 dsieger 3390:
1.184 rillig 3391: When you type make, the distribution files are unpacked into the directory
3392: denoted by WRKDIR. It can be removed by running make clean. Besides the
3393: sources, this directory is also used to keep various timestamp files. The
3394: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
3395: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
1.1 dsieger 3396:
1.184 rillig 3397: 12.7. files/*
1.80 wiz 3398:
1.184 rillig 3399: If you have any files that you wish to be placed in the package prior to
3400: configuration or building, you can place these files here and use a ${CP}
3401: command in the "post-extract" target to achieve this.
1.1 dsieger 3402:
1.184 rillig 3403: If you want to share files in this way with other packages, set the FILESDIR
3404: variable to point to the other package's files directory, e.g.:
1.1 dsieger 3405:
1.184 rillig 3406: FILESDIR= ../../editors/xemacs/files
1.14 jmcneill 3407:
1.184 rillig 3408: Chapter 13. The build process
1.1 dsieger 3409:
1.184 rillig 3410: Table of Contents
1.1 dsieger 3411:
1.184 rillig 3412: 13.1. Introduction
3413: 13.2. Program location
3414: 13.3. Directories used during the build process
3415: 13.4. Running a phase
3416: 13.5. The fetch phase
3417:
3418: 13.5.1. What to fetch and where to get it from
3419: 13.5.2. How are the files fetched?
3420:
3421: 13.6. The checksum phase
3422: 13.7. The extract phase
3423: 13.8. The patch phase
3424: 13.9. The tools phase
3425: 13.10. The wrapper phase
3426: 13.11. The configure phase
3427: 13.12. The build phase
3428: 13.13. The test phase
3429: 13.14. The install phase
3430: 13.15. The package phase
3431: 13.16. Cleaning up
3432: 13.17. Other helpful targets
1.1 dsieger 3433:
1.184 rillig 3434: 13.1. Introduction
1.122 leot 3435:
1.184 rillig 3436: This chapter gives a detailed description on how a package is built. Building a
3437: package is separated into different phases (for example fetch, build, install),
3438: all of which are described in the following sections. Each phase is split into
3439: so-called stages, which take the name of the containing phase, prefixed by one
3440: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
3441: actual work is done in the do-* stages.
1.1 dsieger 3442:
1.184 rillig 3443: Never override the regular targets (like fetch), if you have to, override the
3444: do-* ones instead.
1.1 dsieger 3445:
1.184 rillig 3446: The basic steps for building a program are always the same. First the program's
3447: source (distfile) must be brought to the local system and then extracted. After
3448: any pkgsrc-specific patches to compile properly are applied, the software can
3449: be configured, then built (usually by compiling), and finally the generated
3450: binaries, etc. can be put into place on the system.
1.1 dsieger 3451:
1.184 rillig 3452: To get more details about what is happening at each step, you can set the
3453: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
3454: more details about the patch step.
1.1 dsieger 3455:
1.184 rillig 3456: 13.2. Program location
1.1 dsieger 3457:
1.184 rillig 3458: Before outlining the process performed by the NetBSD package system in the next
3459: section, here's a brief discussion on where programs are installed, and which
3460: variables influence this.
1.1 dsieger 3461:
1.184 rillig 3462: The automatic variable PREFIX indicates where all files of the final program
3463: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
3464: pkgs in the cross category. The value of PREFIX needs to be put into the
3465: various places in the program's source where paths to these files are encoded.
3466: See Section 12.3, "patches/*" and Section 21.3.1, "Shared libraries - libtool"
3467: for more details.
1.1 dsieger 3468:
1.184 rillig 3469: When choosing which of these variables to use, follow the following rules:
1.1 dsieger 3470:
1.184 rillig 3471: * PREFIX always points to the location where the current pkg will be
3472: installed. When referring to a pkg's own installation path, use "${PREFIX}"
3473: .
1.1 dsieger 3474:
1.184 rillig 3475: * LOCALBASE is where all non-X11 pkgs are installed. If you need to construct
3476: a -I or -L argument to the compiler to find includes and libraries
3477: installed by another non-X11 pkg, use "${LOCALBASE}". The name LOCALBASE
3478: stems from FreeBSD, which installed all packages in /usr/local. As pkgsrc
3479: leaves /usr/local for the system administrator, this variable is a
3480: misnomer.
1.1 dsieger 3481:
1.184 rillig 3482: * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
3483: installed. When looking for standard X11 includes (not those installed by a
3484: package), use "${X11BASE}".
1.1 dsieger 3485:
1.184 rillig 3486: * X11-based packages using imake must set USE_IMAKE to be installed correctly
3487: under LOCALBASE.
1.1 dsieger 3488:
1.184 rillig 3489: * Within ${PREFIX}, packages should install files according to hier(7), with
3490: the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
3491: man.
1.1 dsieger 3492:
1.184 rillig 3493: 13.3. Directories used during the build process
1.2 rillig 3494:
1.184 rillig 3495: When building a package, various directories are used to store source files,
3496: temporary files, pkgsrc-internal files, and so on. These directories are
3497: explained here.
1.1 dsieger 3498:
1.184 rillig 3499: Some of the directory variables contain relative pathnames. There are two
3500: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
3501: used for directories that are pkgsrc-specific. WRKSRC is used for directories
3502: inside the package itself.
1.1 dsieger 3503:
1.184 rillig 3504: PKGSRCDIR
1.1 dsieger 3505:
1.184 rillig 3506: This is an absolute pathname that points to the pkgsrc root directory.
3507: Generally, you don't need it.
1.1 dsieger 3508:
1.184 rillig 3509: PKGDIR
1.1 dsieger 3510:
1.184 rillig 3511: This is an absolute pathname that points to the current package.
1.1 dsieger 3512:
1.184 rillig 3513: PKGPATH
1.1 dsieger 3514:
1.184 rillig 3515: This is a pathname relative to PKGSRCDIR that points to the current
3516: package.
1.1 dsieger 3517:
1.184 rillig 3518: WRKDIR
1.1 dsieger 3519:
1.184 rillig 3520: This is an absolute pathname pointing to the directory where all work takes
3521: place. The distfiles are extracted to this directory. It also contains
3522: temporary directories and log files used by the various pkgsrc frameworks,
3523: like buildlink or the wrappers.
1.1 dsieger 3524:
1.184 rillig 3525: WRKSRC
1.1 dsieger 3526:
1.184 rillig 3527: This is an absolute pathname pointing to the directory where the distfiles
3528: are extracted. It is usually a direct subdirectory of WRKDIR, and often
3529: it's the only directory entry that isn't hidden. This variable may be
3530: changed by a package Makefile.
1.1 dsieger 3531:
1.184 rillig 3532: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
3533: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
3534: created in the pkgsrc entry's directory. If users would like to have their
3535: pkgsrc trees behave in a read-only manner, then the value of
3536: CREATE_WRKDIR_SYMLINK should be set to no.
1.1 dsieger 3537:
1.184 rillig 3538: 13.4. Running a phase
1.1 dsieger 3539:
1.184 rillig 3540: You can run a particular phase by typing make phase, where phase is the name of
3541: the phase. This will automatically run all phases that are required for this
3542: phase. The default phase is build, that is, when you run make without
3543: parameters in a package directory, the package will be built, but not
3544: installed.
1.1 dsieger 3545:
1.184 rillig 3546: 13.5. The fetch phase
1.1 dsieger 3547:
1.184 rillig 3548: The first step in building a package is to fetch the distribution files
3549: (distfiles) from the sites that are providing them. This is the task of the
3550: fetch phase.
1.25 wiz 3551:
1.184 rillig 3552: 13.5.1. What to fetch and where to get it from
1.1 dsieger 3553:
1.184 rillig 3554: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
3555: name is derived from the DISTNAME variable, is fetched. The more complicated
3556: cases are described below.
1.1 dsieger 3557:
1.184 rillig 3558: The variable DISTFILES specifies the list of distfiles that have to be fetched.
3559: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
3560: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
3561: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
3562: your package requires additional distfiles to the default one, you cannot just
3563: append the additional filenames using the += operator, but you have write for
3564: example:
1.1 dsieger 3565:
1.184 rillig 3566: DISTFILES= ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1 dsieger 3567:
1.184 rillig 3568: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
3569: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
3570: can set SITES.distfile to the list of URLs where the file distfile (including
3571: the suffix) can be found.
1.1 dsieger 3572:
1.184 rillig 3573: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
3574: DISTFILES+= foo-file.tar.gz
3575: SITES.foo-file.tar.gz= \
3576: https://www.somewhere.com/somehow/ \
3577: https://www.somewhereelse.com/mirror/somehow/
1.1 dsieger 3578:
1.184 rillig 3579: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
3580: gets the name of each distfile appended to it, without an intermediate slash.
3581: Therefore, all site values have to end with a slash or other separator
3582: character. This allows for example to set MASTER_SITES to a URL of a CGI script
3583: that gets the name of the distfile as a parameter. In this case, the definition
3584: would look like:
1.1 dsieger 3585:
1.184 rillig 3586: MASTER_SITES= https://www.example.com/download.cgi?file=
1.1 dsieger 3587:
1.184 rillig 3588: The exception to this rule are URLs starting with a dash. In that case the URL
3589: is taken as is, fetched and the result stored under the name of the distfile.
3590: You can use this style for the case when the download URL style does not match
3591: the above common case. For example, if permanent download URL is a redirector
3592: to the real download URL, or the download file name is offered by an HTTP
3593: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
3594: created instead of the default v1.0.0.tar.gz.
1.1 dsieger 3595:
1.184 rillig 3596: DISTNAME= foo-1.0.0
3597: MASTER_SITES= -https://www.example.com/archive/v1.0.0.tar.gz
1.29 wiz 3598:
1.184 rillig 3599: There are some predefined values for MASTER_SITES, which can be used in
3600: packages. The names of the variables should speak for themselves.
1.29 wiz 3601:
1.184 rillig 3602: MASTER_SITE_APACHE MASTER_SITE_BACKUP
3603: MASTER_SITE_CRATESIO MASTER_SITE_CYGWIN
3604: MASTER_SITE_DEBIAN MASTER_SITE_FREEBSD
3605: MASTER_SITE_FREEBSD_LOCAL MASTER_SITE_GENTOO
3606: MASTER_SITE_GITHUB MASTER_SITE_GNOME
3607: MASTER_SITE_GNU MASTER_SITE_GNUSTEP
3608: MASTER_SITE_HASKELL_HACKAGE MASTER_SITE_IFARCHIVE
3609: MASTER_SITE_KDE MASTER_SITE_MOZILLA
3610: MASTER_SITE_MOZILLA_ALL MASTER_SITE_MYSQL
3611: MASTER_SITE_NETLIB MASTER_SITE_OPENBSD
3612: MASTER_SITE_OPENOFFICE MASTER_SITE_OSDN
3613: MASTER_SITE_PERL_CPAN MASTER_SITE_PGSQL
3614: MASTER_SITE_PYPI MASTER_SITE_RUBYGEMS
3615: MASTER_SITE_R_CRAN MASTER_SITE_SOURCEFORGE
3616: MASTER_SITE_SUNSITE MASTER_SITE_SUSE
3617: MASTER_SITE_TEX_CTAN MASTER_SITE_XCONTRIB
3618: MASTER_SITE_XEMACS MASTER_SITE_XORG
1.1 dsieger 3619:
1.184 rillig 3620: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
3621: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
3622: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
3623: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
3624: distfiles/LOCAL_PORTS/.
1.1 dsieger 3625:
1.184 rillig 3626: If you choose one of these predefined sites, you may want to specify a
3627: subdirectory of that site. Since these macros may expand to more than one
3628: actual site, you must use the following construct to specify a subdirectory:
1.1 dsieger 3629:
1.184 rillig 3630: MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/}
3631: MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1 dsieger 3632:
1.184 rillig 3633: Note the trailing slash after the subdirectory name.
1.1 dsieger 3634:
1.184 rillig 3635: 13.5.2. How are the files fetched?
1.1 dsieger 3636:
1.184 rillig 3637: The fetch phase makes sure that all the distfiles exist in a local directory
3638: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
3639: are fetched using commands of the form
1.1 dsieger 3640:
1.184 rillig 3641: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
1.1 dsieger 3642:
1.184 rillig 3643: where ${site} varies through several possibilities in turn: first,
3644: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
3645: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
3646: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
3647: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
3648: MASTER_SORT_AWK or MASTER_SORT_REGEX.
1.1 dsieger 3649:
1.184 rillig 3650: The specific command and arguments used depend on the FETCH_USING parameter.
3651: The example above is for FETCH_USING=custom.
1.66 asau 3652:
1.184 rillig 3653: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
3654: target to mirror the distfiles, if they are freely distributable. Packages
3655: setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
3656: distfiles mirrored.
1.1 dsieger 3657:
1.184 rillig 3658: 13.6. The checksum phase
1.1 dsieger 3659:
1.184 rillig 3660: After the distfile(s) are fetched, their checksum is generated and compared
3661: with the checksums stored in the distinfo file. If the checksums don't match,
3662: the build is aborted. This is to ensure the same distfile is used for building,
3663: and that the distfile wasn't changed, e.g. by some malign force, deliberately
3664: changed distfiles on the master distribution site or network lossage.
1.1 dsieger 3665:
1.184 rillig 3666: 13.7. The extract phase
1.1 dsieger 3667:
1.184 rillig 3668: When the distfiles are present on the local system, they need to be extracted,
3669: as they usually come in the form of some compressed archive format.
1.1 dsieger 3670:
1.184 rillig 3671: By default, all DISTFILES are extracted. If you only need some of them, you can
3672: set the EXTRACT_ONLY variable to the list of those files.
1.1 dsieger 3673:
1.184 rillig 3674: Extracting the files is usually done by a little program, mk/extract/extract,
3675: which already knows how to extract various archive formats, so most likely you
3676: will not need to change anything here. But if you need, the following variables
3677: may help you:
1.1 dsieger 3678:
1.184 rillig 3679: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
1.1 dsieger 3680:
1.184 rillig 3681: Use these variables to override the default options for an extract command,
3682: which are defined in mk/extract/extract.
1.1 dsieger 3683:
1.184 rillig 3684: EXTRACT_USING
1.1 dsieger 3685:
1.184 rillig 3686: This variable can be set to bsdtar, gtar, nbtar (which is the default
3687: value), pax, or an absolute pathname pointing to the command with which tar
3688: archives should be extracted. It is preferred to choose bsdtar over gtar if
3689: NetBSD's pax-as-tar is not good enough.
1.1 dsieger 3690:
1.184 rillig 3691: If the extract program doesn't serve your needs, you can also override the
3692: EXTRACT_CMD variable, which holds the command used for extracting the files.
3693: This command is executed in the ${WRKSRC} directory. During execution of this
3694: command, the shell variable extract_file holds the absolute pathname of the
3695: file that is going to be extracted.
1.1 dsieger 3696:
1.184 rillig 3697: And if that still does not suffice, you can override the do-extract target in
3698: the package Makefile.
1.1 dsieger 3699:
1.184 rillig 3700: 13.8. The patch phase
1.1 dsieger 3701:
1.184 rillig 3702: After extraction, all the patches named by the PATCHFILES, those present in the
3703: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
3704: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
3705: are uncompressed before they are applied, files ending in .orig or .rej are
3706: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
3707: Section 12.3, "patches/*" for more details.
1.1 dsieger 3708:
1.184 rillig 3709: By default patch(1) is given special arguments to make it fail if the expected
3710: text from the patch context is not found in the patched file. If that happens,
3711: fix the patch file by comparing it with the actual text in the file to be
3712: patched.
1.1 dsieger 3713:
1.184 rillig 3714: 13.9. The tools phase
1.1 dsieger 3715:
1.184 rillig 3716: This is covered in Chapter 17, Tools needed for building or running.
1.1 dsieger 3717:
1.184 rillig 3718: 13.10. The wrapper phase
1.1 dsieger 3719:
1.184 rillig 3720: This phase creates wrapper programs for the compilers and linkers. The
3721: following variables can be used to tweak the wrappers.
1.1 dsieger 3722:
1.184 rillig 3723: ECHO_WRAPPER_MSG
1.1 dsieger 3724:
1.184 rillig 3725: The command used to print progress messages. Does nothing by default. Set
3726: to ${ECHO} to see the progress messages.
1.1 dsieger 3727:
1.184 rillig 3728: WRAPPER_DEBUG
1.1 dsieger 3729:
1.184 rillig 3730: This variable can be set to yes (default) or no, depending on whether you
3731: want additional information in the wrapper log file.
1.1 dsieger 3732:
1.184 rillig 3733: WRAPPER_UPDATE_CACHE
1.1 dsieger 3734:
1.184 rillig 3735: This variable can be set to yes or no, depending on whether the wrapper
3736: should use its cache, which will improve the speed. The default value is
3737: yes, but is forced to no if the platform does not support it.
1.1 dsieger 3738:
1.184 rillig 3739: WRAPPER_REORDER_CMDS
1.1 dsieger 3740:
1.184 rillig 3741: A list of reordering commands. A reordering command has the form reorder:l:
3742: lib1:lib2. It ensures that that -llib1 occurs before -llib2.
1.1 dsieger 3743:
1.184 rillig 3744: 13.11. The configure phase
1.1 dsieger 3745:
1.184 rillig 3746: Most pieces of software need information on the header files, system calls, and
3747: library routines which are available on the platform they run on. The process
3748: of determining this information is known as configuration, and is usually
3749: automated. In most cases, a script is supplied with the distfiles, and its
3750: invocation results in generation of header files, Makefiles, etc.
1.1 dsieger 3751:
1.184 rillig 3752: If the package contains a configure script, this can be invoked by setting
3753: HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
1.187 rillig 3754: should set GNU_CONFIGURE to "yes" instead.
1.1 dsieger 3755:
1.187 rillig 3756: In the do-configure stage, a rough equivalent of the following command is run.
3757: See mk/configure/configure.mk, target do-configure-script for the exact
3758: definition.
3759:
3760: .for dir in ${CONFIGURE_DIRS}
3761: cd ${WRKSRC} && cd ${dir} \
3762: && env ${CONFIGURE_ENV} \
3763: ${CONFIG_SHELL} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
1.184 rillig 3764: .endfor
1.1 dsieger 3765:
1.184 rillig 3766: CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
3767: each of these directories, the configure script is run with the environment
3768: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
3769: CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
3770: by the package.
1.1 dsieger 3771:
1.184 rillig 3772: If the program uses the Perl way of configuration (mainly Perl modules, but not
3773: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
3774: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
3775: (e.g., MAKE_PARAMS+=foo=bar
1.1 dsieger 3776:
1.184 rillig 3777: If the program uses an Imakefile for configuration, the appropriate steps can
3778: be invoked by setting USE_IMAKE to "yes". If you only need xmkmf, add it to
3779: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
3780: SCRIPTS_ENV variable.
1.1 dsieger 3781:
1.184 rillig 3782: If the program uses cmake for configuration, the appropriate steps can be
3783: invoked by setting USE_CMAKE to "yes". You can add variables to cmake's
3784: environment by adding them to the CONFIGURE_ENV variable and arguments to cmake
3785: by adding them to the CMAKE_ARGS variable. The top directory argument is given
3786: by the CMAKE_ARG_PATH variable, that defaults to "." (relative to
3787: CONFIGURE_DIRS)
1.1 dsieger 3788:
1.184 rillig 3789: If there is no configure step at all, set NO_CONFIGURE to "yes".
1.1 dsieger 3790:
1.184 rillig 3791: 13.12. The build phase
1.1 dsieger 3792:
1.187 rillig 3793: For building a package, a rough equivalent of the following code is executed;
3794: see mk/build/build.mk, target do-build for the exact definition.
1.154 rillig 3795:
1.187 rillig 3796: .for dir in ${BUILD_DIRS}
3797: cd ${WRKSRC} && cd ${dir} \
1.184 rillig 3798: && env ${MAKE_ENV} \
1.187 rillig 3799: ${MAKE_PROGRAM} ${MAKE_FLAGS} ${BUILD_MAKE_FLAGS} \
1.184 rillig 3800: -f ${MAKE_FILE} \
3801: ${BUILD_TARGET}
3802: .endfor
1.1 dsieger 3803:
1.184 rillig 3804: BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
3805: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
3806: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
3807: and BUILD_TARGET may all be changed by the package.
1.1 dsieger 3808:
1.184 rillig 3809: The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
3810: make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
3811: defaults to "all".
1.1 dsieger 3812:
1.184 rillig 3813: If there is no build step at all, set NO_BUILD to "yes".
1.1 dsieger 3814:
1.184 rillig 3815: 13.13. The test phase
1.1 dsieger 3816:
1.184 rillig 3817: [TODO]
1.1 dsieger 3818:
1.184 rillig 3819: 13.14. The install phase
1.1 dsieger 3820:
1.184 rillig 3821: Once the build stage has completed, the final step is to install the software
3822: in public directories, so users can access the programs and files.
1.1 dsieger 3823:
1.187 rillig 3824: In the install phase, a rough equivalent of the following code is executed; see
3825: mk/install/install.mk, target do-install for the exact definition.
3826: Additionally, before and after this code, several consistency checks are run
3827: against the files-to-be-installed, see mk/check/*.mk for details.
3828:
3829: .for dir in ${INSTALL_DIRS}
3830: cd ${WRKSRC} && cd ${dir} \
3831: && env ${INSTALL_ENV} ${MAKE_ENV} \
3832: ${MAKE_PROGRAM} ${MAKE_FLAGS} ${INSTALL_MAKE_FLAGS} \
3833: -f ${MAKE_FILE} ${INSTALL_TARGET}
1.184 rillig 3834: .endfor
1.1 dsieger 3835:
1.184 rillig 3836: The variable's meanings are analogous to the ones in the build phase.
3837: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
3838: plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
3839: defined.
1.1 dsieger 3840:
1.184 rillig 3841: In the install phase, the following variables are useful. They are all
3842: variations of the install(1) command that have the owner, group and permissions
3843: preset. INSTALL is the plain install command. The specialized variants,
3844: together with their intended use, are:
1.1 dsieger 3845:
1.184 rillig 3846: INSTALL_PROGRAM_DIR
1.1 dsieger 3847:
1.184 rillig 3848: directories that contain binaries
1.1 dsieger 3849:
1.184 rillig 3850: INSTALL_SCRIPT_DIR
1.1 dsieger 3851:
1.184 rillig 3852: directories that contain scripts
1.1 dsieger 3853:
1.184 rillig 3854: INSTALL_LIB_DIR
1.1 dsieger 3855:
1.184 rillig 3856: directories that contain shared and static libraries
1.1 dsieger 3857:
1.184 rillig 3858: INSTALL_DATA_DIR
1.108 rillig 3859:
1.184 rillig 3860: directories that contain data files
1.108 rillig 3861:
1.184 rillig 3862: INSTALL_MAN_DIR
1.108 rillig 3863:
1.184 rillig 3864: directories that contain man pages
1.108 rillig 3865:
1.184 rillig 3866: INSTALL_GAME_DIR
1.108 rillig 3867:
1.184 rillig 3868: directories that contain data files for games
1.108 rillig 3869:
1.184 rillig 3870: INSTALL_PROGRAM
1.108 rillig 3871:
1.184 rillig 3872: binaries that can be stripped from debugging symbols
1.108 rillig 3873:
1.184 rillig 3874: INSTALL_SCRIPT
1.108 rillig 3875:
1.184 rillig 3876: binaries that cannot be stripped
1.108 rillig 3877:
1.184 rillig 3878: INSTALL_GAME
1.108 rillig 3879:
1.184 rillig 3880: game binaries
1.108 rillig 3881:
1.184 rillig 3882: INSTALL_LIB
1.108 rillig 3883:
1.184 rillig 3884: shared and static libraries
1.108 rillig 3885:
1.184 rillig 3886: INSTALL_DATA
1.108 rillig 3887:
1.184 rillig 3888: data files
1.1 dsieger 3889:
1.184 rillig 3890: INSTALL_GAME_DATA
1.1 dsieger 3891:
1.184 rillig 3892: data files for games
1.108 rillig 3893:
1.184 rillig 3894: INSTALL_MAN
1.108 rillig 3895:
1.184 rillig 3896: man pages
1.1 dsieger 3897:
1.184 rillig 3898: Some other variables are:
1.1 dsieger 3899:
1.184 rillig 3900: INSTALL_UNSTRIPPED
1.1 dsieger 3901:
1.184 rillig 3902: If set to yes, do not run strip(1) when installing binaries. Any debugging
3903: sections and symbols present in binaries will be preserved.
1.1 dsieger 3904:
1.184 rillig 3905: INSTALLATION_DIRS
1.1 dsieger 3906:
1.184 rillig 3907: A list of directories relative to PREFIX that are created by pkgsrc at the
3908: beginning of the install phase. The package is supposed to create all
3909: needed directories itself before installing files to it and list all other
3910: directories here.
1.1 dsieger 3911:
1.184 rillig 3912: In the rare cases that a package shouldn't install anything, set NO_INSTALL to
3913: "yes". This is mostly relevant for packages in the regress category.
1.1 dsieger 3914:
1.184 rillig 3915: 13.15. The package phase
1.121 sevan 3916:
1.184 rillig 3917: Once the install stage has completed, a binary package of the installed files
3918: can be built. These binary packages can be used for quick installation without
3919: previous compilation, e.g. by the make bin-install or by using pkg_add.
1.1 dsieger 3920:
1.184 rillig 3921: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
3922: created in ${PACKAGES}/category, one for each category in the CATEGORIES
3923: variable. PACKAGES defaults to pkgsrc/packages.
1.1 dsieger 3924:
1.184 rillig 3925: 13.16. Cleaning up
1.1 dsieger 3926:
1.184 rillig 3927: Once you're finished with a package, you can clean the work directory by
3928: running make clean. If you want to clean the work directories of all
3929: dependencies too, use make clean-depends.
1.1 dsieger 3930:
1.184 rillig 3931: 13.17. Other helpful targets
1.1 dsieger 3932:
1.184 rillig 3933: pre/post-*
1.1 dsieger 3934:
1.184 rillig 3935: For any of the main targets described in the previous section (configure,
3936: build, install, etc.), two auxiliary targets exist with "pre-" and "post-"
3937: used as a prefix for the main target's name. These targets are invoked
3938: before and after the main target is called, allowing extra configuration or
3939: installation steps be performed from a package's Makefile, for example,
3940: which a program's configure script or install target omitted.
3941:
3942: About 5% of the pkgsrc packages define their custom post-extract target,
3943: another 5% define pre-configure, and 10% define post-install. The other pre
3944: /post-* targets are defined even less often.
1.1 dsieger 3945:
1.184 rillig 3946: do-*
1.182 leot 3947:
1.184 rillig 3948: Should one of the main targets do the wrong thing, and should there be no
3949: variable to fix this, you can redefine it with the do-* target. (Note that
3950: redefining the target itself instead of the do-* target is a bad idea, as
3951: the pre-* and post-* targets won't be called anymore, etc.)
1.1 dsieger 3952:
1.184 rillig 3953: About 15% of the pkgsrc packages override the default do-install, the other
3954: do-* targets are overridden even less often.
1.1 dsieger 3955:
1.184 rillig 3956: reinstall
1.1 dsieger 3957:
1.184 rillig 3958: If you did a make install and you noticed some file was not installed
3959: properly, you can repeat the installation with this target, which will
3960: ignore the "already installed" flag.
1.1 dsieger 3961:
1.184 rillig 3962: This is the default value of DEPENDS_TARGET except in the case of make
3963: update and make package, where the defaults are "package" and "update",
3964: respectively.
1.1 dsieger 3965:
1.184 rillig 3966: deinstall
1.1 dsieger 3967:
1.184 rillig 3968: This target does a pkg_delete(1) in the current directory, effectively
3969: de-installing the package. The following variables can be used to tune the
3970: behaviour:
1.1 dsieger 3971:
1.184 rillig 3972: PKG_VERBOSE
1.1 dsieger 3973:
1.184 rillig 3974: Add a "-v" to the pkg_delete(1) command.
1.1 dsieger 3975:
1.184 rillig 3976: DEINSTALLDEPENDS
1.1 dsieger 3977:
1.184 rillig 3978: Remove all packages that require (depend on) the given package. This
3979: can be used to remove any packages that may have been pulled in by a
3980: given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
3981: pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
3982: " to the pkg_delete(1) command line.
1.1 dsieger 3983:
1.184 rillig 3984: bin-install
1.1 dsieger 3985:
1.184 rillig 3986: Install a binary package from local disk and via FTP from a list of sites
3987: (see the BINPKG_SITES variable), and do a make package if no binary package
3988: is available anywhere. The arguments given to pkg_add can be set via
3989: BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
1.1 dsieger 3990:
1.184 rillig 3991: install-clean
1.1 dsieger 3992:
1.184 rillig 3993: This target removes the state files for the "install" and later phases so
3994: that the "install" target may be re-invoked. This can be used after editing
3995: the PLIST to install the package without rebuilding it.
1.1 dsieger 3996:
1.184 rillig 3997: build-clean
1.18 mishka 3998:
1.184 rillig 3999: This target removes the state files for the "build" and later phases so
4000: that the "build" target may be re-invoked.
1.18 mishka 4001:
1.184 rillig 4002: update
1.18 mishka 4003:
1.184 rillig 4004: This target causes the current package to be updated to the latest version.
4005: The package and all depending packages first get de-installed, then current
4006: versions of the corresponding packages get compiled and installed. This is
4007: similar to manually noting which packages are currently installed, then
4008: performing a series of make deinstall and make install (or whatever
4009: UPDATE_TARGET is set to) for these packages.
1.18 mishka 4010:
1.184 rillig 4011: You can use the "update" target to resume package updating in case a
4012: previous make update was interrupted for some reason. However, in this
4013: case, make sure you don't call make clean or otherwise remove the list of
4014: dependent packages in WRKDIR. Otherwise, you lose the ability to
4015: automatically update the current package along with the dependent packages
4016: you have installed.
1.121 sevan 4017:
1.184 rillig 4018: Resuming an interrupted make update will only work as long as the package
4019: tree remains unchanged. If the source code for one of the packages to be
4020: updated has been changed, resuming make update will most certainly fail!
1.1 dsieger 4021:
1.184 rillig 4022: The following variables can be used either on the command line or in
4023: mk.conf to alter the behaviour of make update:
1.1 dsieger 4024:
1.184 rillig 4025: UPDATE_TARGET
1.1 dsieger 4026:
1.184 rillig 4027: Install target to recursively use for the updated package and the
4028: dependent packages. Defaults to DEPENDS_TARGET if set, "install"
4029: otherwise for make update. Other good targets are "package" or "
4030: bin-install". Do not set this to "update" or you will get stuck in an
4031: endless loop!
1.1 dsieger 4032:
1.184 rillig 4033: NOCLEAN
1.1 dsieger 4034:
1.184 rillig 4035: Don't clean up after updating. Useful if you want to leave the work
4036: sources of the updated packages around for inspection or other
4037: purposes. Be sure you eventually clean up the source tree (see the "
4038: clean-update" target below) or you may run into troubles with old
4039: source code still lying around on your next make or make update.
1.1 dsieger 4040:
1.184 rillig 4041: REINSTALL
1.1 dsieger 4042:
1.184 rillig 4043: Deinstall each package before installing (making DEPENDS_TARGET). This
4044: may be necessary if the "clean-update" target (see below) was called
4045: after interrupting a running make update.
1.1 dsieger 4046:
1.184 rillig 4047: DEPENDS_TARGET
1.1 dsieger 4048:
1.184 rillig 4049: Allows you to disable recursion and hardcode the target for packages.
4050: The default is "update" for the update target, facilitating a recursive
4051: update of prerequisite packages. Only set DEPENDS_TARGET if you want to
4052: disable recursive updates. Use UPDATE_TARGET instead to just set a
4053: specific target for each package to be installed during make update
4054: (see above).
1.1 dsieger 4055:
1.184 rillig 4056: clean-update
1.1 dsieger 4057:
1.184 rillig 4058: Clean the source tree for all packages that would get updated if make
4059: update was called from the current directory. This target should not be
4060: used if the current package (or any of its depending packages) have already
4061: been de-installed (e.g., after calling make update) or you may lose some
4062: packages you intended to update. As a rule of thumb: only use this target
4063: before the first time you run make update and only if you have a dirty
4064: package tree (e.g., if you used NOCLEAN).
1.86 wiz 4065:
1.184 rillig 4066: If you are unsure about whether your tree is clean, you can either perform
4067: a make clean at the top of the tree, or use the following sequence of
4068: commands from the directory of the package you want to update (before
4069: running make update for the first time, otherwise you lose all the packages
4070: you wanted to update!):
1.86 wiz 4071:
1.184 rillig 4072: # make clean-update
4073: # make clean CLEANDEPENDS=YES
4074: # make update
1.86 wiz 4075:
4076:
1.184 rillig 4077: The following variables can be used either on the command line or in
4078: mk.conf to alter the behaviour of make clean-update:
1.86 wiz 4079:
1.184 rillig 4080: CLEAR_DIRLIST
1.86 wiz 4081:
1.184 rillig 4082: After make clean, do not reconstruct the list of directories to update
4083: for this package. Only use this if make update successfully installed
4084: all packages you wanted to update. Normally, this is done automatically
4085: on make update, but may have been suppressed by the NOCLEAN variable
4086: (see above).
1.1 dsieger 4087:
1.184 rillig 4088: replace
1.1 dsieger 4089:
1.184 rillig 4090: Update the installation of the current package. This differs from update in
4091: that it does not replace dependent packages. You will need to install
4092: pkgtools/pkg_tarup for this target to work.
1.1 dsieger 4093:
1.184 rillig 4094: Be careful when using this target! There are no guarantees that dependent
4095: packages will still work, in particular they will most certainly break if
4096: you make replace a library package whose shared library major version
4097: changed between your installed version and the new one. For this reason,
4098: this target is not officially supported and only recommended for advanced
4099: users.
1.1 dsieger 4100:
1.184 rillig 4101: info
1.1 dsieger 4102:
1.184 rillig 4103: This target invokes pkg_info(1) for the current package. You can use this
4104: to check which version of a package is installed.
1.86 wiz 4105:
1.184 rillig 4106: index
1.1 dsieger 4107:
1.184 rillig 4108: This is a top-level command, i.e. it should be used in the pkgsrc
4109: directory. It creates a database of all packages in the local pkgsrc tree,
4110: including dependencies, comment, maintainer, and some other useful
4111: information. Individual entries are created by running make describe in the
4112: packages' directories. This index file is saved as pkgsrc/INDEX. It can be
4113: displayed in verbose format by running make print-index. You can search in
4114: it with make search key=something. You can extract a list of all packages
4115: that depend on a particular one by running make show-deps PKG=somepackage.
1.1 dsieger 4116:
1.184 rillig 4117: Running this command takes a very long time, some hours even on fast
4118: machines!
1.1 dsieger 4119:
1.184 rillig 4120: readme
1.1 dsieger 4121:
1.199 nia 4122: This target generates a index.html file, which can be viewed using a
1.184 rillig 4123: browser such as www/firefox or www/links. The generated files contain
4124: references to any packages which are in the PACKAGES directory on the local
4125: host. The generated files can be made to refer to URLs based on
4126: FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
1.199 nia 4127: index.html files which pointed to binary packages on the local machine, in
1.184 rillig 4128: the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
4129: FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
4130: subdirectories will be searched for all the binary packages.
1.1 dsieger 4131:
1.184 rillig 4132: The target can be run at the toplevel or in category directories, in which
4133: case it descends recursively.
1.1 dsieger 4134:
1.184 rillig 4135: readme-all
1.1 dsieger 4136:
1.184 rillig 4137: This is a top-level command, run it in pkgsrc. Use this target to create a
4138: file README-all.html which contains a list of all packages currently
4139: available in the NetBSD Packages Collection, together with the category
4140: they belong to and a short description. This file is compiled from the
1.199 nia 4141: pkgsrc/*/index.html files, so be sure to run this after a make readme.
1.1 dsieger 4142:
1.184 rillig 4143: cdrom-readme
1.1 dsieger 4144:
1.184 rillig 4145: This is very much the same as the "readme" target (see above), but is to be
4146: used when generating a pkgsrc tree to be written to a CD-ROM. This target
1.199 nia 4147: also produces index.html files, and can be made to refer to URLs based on
1.184 rillig 4148: CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
1.1 dsieger 4149:
1.184 rillig 4150: show-distfiles
1.1 dsieger 4151:
1.184 rillig 4152: This target shows which distfiles and patchfiles are needed to build the
4153: package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
4154: patches/*).
1.1 dsieger 4155:
1.184 rillig 4156: show-downlevel
1.1 dsieger 4157:
1.184 rillig 4158: This target shows nothing if the package is not installed. If a version of
4159: this package is installed, but is not the version provided in this version
4160: of pkgsrc, then a warning message is displayed. This target can be used to
4161: show which of your installed packages are downlevel, and so the old
4162: versions can be deleted, and the current ones added.
1.1 dsieger 4163:
1.184 rillig 4164: show-pkgsrc-dir
1.1 dsieger 4165:
1.184 rillig 4166: This target shows the directory in the pkgsrc hierarchy from which the
4167: package can be built and installed. This may not be the same directory as
4168: the one from which the package was installed. This target is intended to be
4169: used by people who may wish to upgrade many packages on a single host, and
4170: can be invoked from the top-level pkgsrc Makefile by using the "
4171: show-host-specific-pkgs" target.
1.1 dsieger 4172:
1.184 rillig 4173: show-installed-depends
1.1 dsieger 4174:
1.184 rillig 4175: This target shows which installed packages match the current package's
4176: DEPENDS. Useful if out of date dependencies are causing build problems.
1.1 dsieger 4177:
1.184 rillig 4178: print-build-depends-list
1.1 dsieger 4179:
1.184 rillig 4180: This target shows the list of packages that the current package depends on
4181: for building.
1.1 dsieger 4182:
1.184 rillig 4183: print-run-depends-list
1.1 dsieger 4184:
1.184 rillig 4185: This target shows the list of packages that the current package depends on
4186: for running.
1.1 dsieger 4187:
1.184 rillig 4188: check-shlibs
1.1 dsieger 4189:
1.184 rillig 4190: After a package is installed, check all its binaries and (on ELF platforms)
4191: shared libraries to see if they find the shared libs they need. Run by
4192: default if PKG_DEVELOPER is set in mk.conf.
1.1 dsieger 4193:
1.184 rillig 4194: print-PLIST
1.1 dsieger 4195:
1.184 rillig 4196: After a "make install" from a new or upgraded pkg, this prints out an
4197: attempt to generate a new PLIST from a find -newer work/.extract_done. An
4198: attempt is made to care for shared libs etc., but it is strongly
4199: recommended to review the result before putting it into PLIST. On upgrades,
4200: it's useful to diff the output of this command against an already existing
4201: PLIST file.
1.1 dsieger 4202:
1.184 rillig 4203: If the package installs files via tar(1) or other methods that don't update
4204: file access times, be sure to add these files manually to your PLIST, as
4205: the "find -newer" command used by this target won't catch them!
1.56 ryoon 4206:
1.184 rillig 4207: See Section 19.3, "Tweaking output of make print-PLIST" for more
4208: information on this target.
1.1 dsieger 4209:
1.184 rillig 4210: Chapter 14. Creating a new pkgsrc package from scratch
1.1 dsieger 4211:
1.184 rillig 4212: Table of Contents
1.1 dsieger 4213:
1.184 rillig 4214: 14.1. Common types of packages
1.1 dsieger 4215:
1.217 ! rillig 4216: 14.1.1. Python modules and programs
! 4217: 14.1.2. R packages
! 4218: 14.1.3. TeXlive packages
1.1 dsieger 4219:
1.184 rillig 4220: 14.2. Examples
1.1 dsieger 4221:
1.184 rillig 4222: 14.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 4223:
1.184 rillig 4224: When you find a package that is not yet in pkgsrc, you most likely have a URL
4225: from where you can download the source code. Starting with this URL, creating a
4226: package involves only a few steps.
1.1 dsieger 4227:
1.184 rillig 4228: 1. In your mk.conf, set PKG_DEVELOPER=yes to enable the basic quality checks.
1.1 dsieger 4229:
1.184 rillig 4230: 2. Install the package meta-pkgs/pkg_developer, which among others will
4231: install the utilities url2pkg, pkglint, pkgvi and mkpatches:
1.1 dsieger 4232:
1.184 rillig 4233: $ cd /usr/pkgsrc
4234: $ (cd meta-pkgs/pkg_developer && bmake update)
1.1 dsieger 4235:
1.184 rillig 4236: 3. Choose one of the top-level directories as the category in which you want
4237: to place your package. You can also create a directory of your own (maybe
1.217 ! rillig 4238: called local). Change into that category directory:
1.1 dsieger 4239:
1.217 ! rillig 4240: $ cd category
1.1 dsieger 4241:
1.217 ! rillig 4242: 4. Run the program url2pkg, passing as argument the URL of the distribution
! 4243: file (in most cases a .tar.gz file). This will download the distribution
! 4244: file and create the necessary files of the package, based on what's in the
! 4245: distribution file:
1.1 dsieger 4246:
1.184 rillig 4247: $ url2pkg https://www.example.org/packages/package-1.0.tar.gz
1.1 dsieger 4248:
1.184 rillig 4249: 5. Examine the extracted files to determine the dependencies of your package.
4250: Ideally, this is mentioned in some README file, but things may differ. For
4251: each of these dependencies, look where it exists in pkgsrc, and if there is
4252: a file called buildlink3.mk in that directory, add a line to your package
4253: Makefile which includes that file just before the last line. If the
4254: buildlink3.mk file does not exist, it must be created first. The
4255: buildlink3.mk file makes sure that the package's include files and
4256: libraries are provided.
1.1 dsieger 4257:
1.217 ! rillig 4258: If you just need binaries from a dependent package, add a DEPENDS line to
! 4259: the Makefile, which specifies the version of the dependency and where it
! 4260: can be found in pkgsrc. This line should be placed in the third paragraph.
! 4261: If the dependency is only needed for building the package, but not when
! 4262: using it, use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The
! 4263: difference between TOOL_DEPENDS and BUILD_DEPENDS occurs when
! 4264: cross-compiling: TOOL_DEPENDS are native packages, i.e. packages for the
! 4265: platform where the package is built; BUILD_DEPENDS are target packages,
! 4266: i.e. packages for the platform for which the package is built. There is
! 4267: also TEST_DEPENDS, which specifies a dependency used only for testing the
! 4268: resulting package built, using the upstream project's included test suite,
! 4269: on the native platform. Your package may then look like this:
1.1 dsieger 4270:
1.184 rillig 4271: [...]
1.1 dsieger 4272:
1.184 rillig 4273: TOOL_DEPENDS+= libxslt-[0-9]*:../../textproc/libxslt
4274: DEPENDS+= screen-[0-9]*:../../misc/screen
4275: DEPENDS+= screen>=4.0:../../misc/screen
1.1 dsieger 4276:
1.184 rillig 4277: [...]
1.1 dsieger 4278:
1.184 rillig 4279: .include "../../category/package/buildlink3.mk"
4280: .include "../../devel/glib2/buildlink3.mk"
4281: .include "../../mk/bsd.pkg.mk"
1.1 dsieger 4282:
1.184 rillig 4283: 6. Run pkglint to see what things still need to be done to make your package a
4284: "good" one. If you don't know what pkglint's warnings want to tell you, try
4285: pkglint --explain or pkglint -e, which outputs additional explanations.
1.1 dsieger 4286:
1.184 rillig 4287: 7. In many cases the package is not yet ready to build. You can find
4288: instructions for the most common cases in the next section, Section 14.1,
4289: "Common types of packages". After you have followed the instructions over
4290: there, you can hopefully continue here.
1.1 dsieger 4291:
1.184 rillig 4292: 8. Run bmake clean to clean the working directory from the extracted files.
1.217 ! rillig 4293: Besides these files, a lot of cache files and other system information have
! 4294: been saved in the working directory, which may have become outdated after
! 4295: you edited the Makefile.
1.1 dsieger 4296:
1.184 rillig 4297: 9. Now, run bmake to build the package. For the various things that can go
4298: wrong in this phase, consult Chapter 21, Making your package work.
1.1 dsieger 4299:
1.184 rillig 4300: If the extracted files from the package need to be fixed, run multiple
4301: rounds of these commands:
1.1 dsieger 4302:
1.217 ! rillig 4303: $ bmake
1.184 rillig 4304: $ pkgvi ${WRKSRC}/some/file/that/does/not/compile
4305: $ mkpatches
1.217 ! rillig 4306: $ bmake mps
! 4307: $ bmake clean
1.1 dsieger 4308:
1.184 rillig 4309: 10. When the package builds fine, the next step is to install the package. Run
4310: bmake install and hope that everything works.
1.1 dsieger 4311:
1.184 rillig 4312: 11. Up to now, the file PLIST, which contains a list of the files that are
4313: installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
4314: generate a probably correct list. Check the file using your preferred text
4315: editor to see if the list of files looks plausible.
1.1 dsieger 4316:
1.184 rillig 4317: 12. Run pkglint again to see if the generated PLIST contains garbage or not.
1.1 dsieger 4318:
1.184 rillig 4319: 13. When you ran bmake install, the package had been registered in the database
4320: of installed files, but with an empty list of files. To fix this, run bmake
4321: deinstall and bmake install again. Now the package is registered with the
4322: list of files from PLIST.
1.48 wiz 4323:
1.217 ! rillig 4324: 14. Run bmake clean update to run everything from above again in a single step,
1.184 rillig 4325: making sure that the PLIST is correct and the whole package is created as
4326: intended.
1.48 wiz 4327:
1.217 ! rillig 4328: 15. Run pkglint to see if there's anything left to do.
1.48 wiz 4329:
1.217 ! rillig 4330: 16. Commit the package to pkgsrc-wip or main pkgsrc; see Chapter 23, Submitting
1.184 rillig 4331: and Committing.
1.50 wiz 4332:
1.184 rillig 4333: 14.1. Common types of packages
1.1 dsieger 4334:
1.217 ! rillig 4335: 14.1.1. Python modules and programs
1.1 dsieger 4336:
1.184 rillig 4337: Python modules and programs packages are easily created using a set of
4338: predefined variables.
1.1 dsieger 4339:
1.184 rillig 4340: If some Python versions are not supported by the software, set the
4341: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
4342: supported, e.g.
1.1 dsieger 4343:
1.184 rillig 4344: PYTHON_VERSIONS_INCOMPATIBLE= 27
1.1 dsieger 4345:
1.184 rillig 4346: If the packaged software is a Python module, include one of ../../lang/python/
1.215 wiz 4347: egg.mk or ../../lang/python/extension.mk.
1.1 dsieger 4348:
1.215 wiz 4349: Most Python packages use setuptools ("eggs"). If the packaged software is using
4350: setuptools, you only need to include "../../lang/python/egg.mk".
1.1 dsieger 4351:
1.184 rillig 4352: Either way, the package directory should be called "py-software" and PKGNAME
4353: should be set to "${PYPKGPREFIX}-${DISTNAME}", e.g.
1.1 dsieger 4354:
1.184 rillig 4355: DISTNAME= foopymodule-1.2.10
4356: PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
1.1 dsieger 4357:
1.184 rillig 4358: If it is an application, include "../../lang/python/application.mk". In order
4359: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
4360: variable and set it to the list of files (paths relative to WRKSRC) that must
4361: be corrected. For example:
1.1 dsieger 4362:
1.184 rillig 4363: REPLACE_PYTHON= *.py
1.1 dsieger 4364:
1.184 rillig 4365: Some Python modules have separate distributions for Python-2.x and Python-3.x
4366: support. In pkgsrc this is handled by the versioned_dependencies.mk file. Set
4367: PYTHON_VERSIONED_DEPENDENCIES to the list of packages that should be depended
4368: upon and include "../../lang/python/versioned_dependencies.mk", then the pkgsrc
4369: infrastructure will depend on the appropriate package version. For example:
1.1 dsieger 4370:
1.184 rillig 4371: PYTHON_VERSIONED_DEPENDENCIES=dialog
1.1 dsieger 4372:
1.184 rillig 4373: Look inside versioned_dependencies.mk for a list of supported packages.
1.1 dsieger 4374:
1.217 ! rillig 4375: 14.1.2. R packages
1.1 dsieger 4376:
1.184 rillig 4377: Simple R packages from CRAN are handled automatically by R2pkg, which is
4378: available in pkgtools/R2pkg. Individual packages (and optionally their
4379: dependencies) may be created and updated. R packages generally follow the same
4380: form, and most of the relevant information needed is contained in a DESCRIPTION
4381: file as part of each R package on CRAN. Consequently, R2pkg downloads that
4382: information and creates or updates a package in the canonical form. The
4383: resulting package should be reviewed for correctness.
1.1 dsieger 4384:
1.217 ! rillig 4385: 14.1.3. TeXlive packages
1.1 dsieger 4386:
1.184 rillig 4387: TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
4388: available in pkgtools/texlive2pkg.
1.1 dsieger 4389:
1.184 rillig 4390: If the TeXlive package name is not known, it may be useful to search CTAN. A "
4391: Contained in" field on the package page typically identifies the basename of
4392: the package file in the TeXlive archive.
1.1 dsieger 4393:
1.184 rillig 4394: If the TeXlive package name is known, download the files from the TeXlive
4395: archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
4396: packages also have associated documentation packages, so download
4397: foo.doc.tar.xz at the same time. These files should be placed in the
4398: appropriate category directory, which is often but not always print. Then run
4399: the following command in the category directory.
1.1 dsieger 4400:
1.184 rillig 4401: texlive2pkg foo.tar.xz foo.doc.tar.xz
1.1 dsieger 4402:
1.184 rillig 4403: This will create two packages, tex-foo and tex-foo-doc. Be sure to check that
4404: both packages are correct.
1.1 dsieger 4405:
1.184 rillig 4406: Finally, CTAN currently does not include version information in package
4407: filenames and changes their contents periodically when updates occur.
4408: Consequently, pkgsrc avoids downloading distfiles directly from CTAN and
4409: instead relies on the pkgsrc archives. For each new or updated TeXlive package,
4410: e.g., the main one and the corresponding documentation, upload the distfiles
4411: with the following command in each package directory.
1.1 dsieger 4412:
1.184 rillig 4413: make upload-distfiles
1.117 sevan 4414:
1.184 rillig 4415: 14.2. Examples
1.117 sevan 4416:
1.184 rillig 4417: 14.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 4418:
1.184 rillig 4419: 14.2.1.1. The initial package
1.1 dsieger 4420:
1.184 rillig 4421: Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
4422: been imported into pkgsrc. As the description says it has to do with the web,
4423: the obvious choice for the category is "www".
1.1 dsieger 4424:
1.184 rillig 4425: $ mkdir www/nvu
4426: $ cd www/nvu
1.1 dsieger 4427:
1.184 rillig 4428: The web site says that the sources are available as a tar file, so I fed that
4429: URL to the url2pkg program:
1.1 dsieger 4430:
1.184 rillig 4431: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
1.1 dsieger 4432:
1.184 rillig 4433: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
4434: package name should not have the word "sources" in it. I also filled in the
4435: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
4436: that:
1.1 dsieger 4437:
1.184 rillig 4438: # $NetBSD $
4439: #
1.1 dsieger 4440:
1.184 rillig 4441: DISTNAME= nvu-1.0-sources
4442: PKGNAME= nvu-1.0
4443: CATEGORIES= www
4444: MASTER_SITES= http://cvs.nvu.com/download/
4445: EXTRACT_SUFX= .tar.bz2
1.1 dsieger 4446:
1.184 rillig 4447: MAINTAINER= rillig@NetBSD.org
4448: HOMEPAGE= http://cvs.nvu.com/
4449: COMMENT= Web Authoring System
1.1 dsieger 4450:
1.184 rillig 4451: # url2pkg-marker (please do not remove this line.)
4452: .include "../../mk/bsd.pkg.mk"
1.1 dsieger 4453:
1.184 rillig 4454: On the first line of output above, an artificial space has been added between
4455: NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
4456: the guide.
1.1 dsieger 4457:
1.184 rillig 4458: Then, I quit the editor and watched pkgsrc downloading a large source archive:
1.1 dsieger 4459:
1.184 rillig 4460: url2pkg> Running "make makesum" ...
4461: => Required installed package digest>=20010302: digest-20060826 found
4462: => Fetching nvu-1.0-sources.tar.bz2
4463: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
4464: 100% |*************************************| 28992 KB 150.77 KB/s00:00 ETA
4465: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
4466: url2pkg> Running "make extract" ...
4467: => Required installed package digest>=20010302: digest-20060826 found
4468: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
4469: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
4470: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
4471: ===> Installing dependencies for nvu-1.0
4472: ===> Overriding tools for nvu-1.0
4473: ===> Extracting for nvu-1.0
4474: url2pkg> Adjusting the Makefile.
1.1 dsieger 4475:
1.184 rillig 4476: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
1.1 dsieger 4477:
1.184 rillig 4478: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
1.1 dsieger 4479:
1.184 rillig 4480: 14.2.1.2. Fixing all kinds of problems to make the package work
1.1 dsieger 4481:
1.184 rillig 4482: Now that the package has been extracted, let's see what's inside it. The
4483: package has a README.txt, but that only says something about mozilla, so it's
4484: probably useless for seeing what dependencies this package has. But since there
4485: is a GNU configure script in the package, let's hope that it will complain
4486: about everything it needs.
1.1 dsieger 4487:
1.184 rillig 4488: $ bmake
4489: => Required installed package digest>=20010302: digest-20060826 found
4490: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
4491: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
4492: ===> Patching for nvu-1.0
4493: ===> Creating toolchain wrappers for nvu-1.0
4494: ===> Configuring for nvu-1.0
4495: [...]
4496: configure: error: Perl 5.004 or higher is required.
4497: [...]
4498: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
4499: [...]
1.1 dsieger 4500:
1.184 rillig 4501: That worked quite well. So I opened the package Makefile in my editor, and
4502: since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
4503: dependencies of the package have changed now, and since a perl wrapper is
4504: automatically installed in the "tools" phase, I need to build the package from
4505: scratch.
1.1 dsieger 4506:
1.184 rillig 4507: $ bmake clean
4508: ===> Cleaning for nvu-1.0
4509: $ bmake
4510: [...]
4511: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
4512: GNU Make. You will not be able to build Mozilla without GNU Make.
4513: [...]
1.1 dsieger 4514:
1.184 rillig 4515: So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
1.1 dsieger 4516:
1.184 rillig 4517: [...]
4518: checking for GTK - version >= 1.2.0... no
4519: *** Could not run GTK test program, checking why...
4520: [...]
1.1 dsieger 4521:
1.184 rillig 4522: Now to the other dependencies. The first question is: Where is the GTK package
4523: hidden in pkgsrc?
1.1 dsieger 4524:
1.184 rillig 4525: $ echo ../../*/gtk*
4526: [many packages ...]
4527: $ echo ../../*/gtk
4528: ../../x11/gtk
4529: $ echo ../../*/gtk2
4530: ../../x11/gtk2
4531: $ echo ../../*/gtk2/bui*
4532: ../../x11/gtk2/buildlink3.mk
1.1 dsieger 4533:
1.184 rillig 4534: The first try was definitely too broad. The second one had exactly one result,
4535: which is very good. But there is one pitfall with GNOME packages. Before GNOME
4536: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
4537: able to continue to use these packages, the GNOME 2 packages were imported as
4538: separate packages, and their names usually have a "2" appended. So I checked
4539: whether this was the case here, and indeed it was.
1.1 dsieger 4540:
1.184 rillig 4541: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
4542: easy. I just inserted an .include line before the last line of the package
4543: Makefile, so that it now looks like this:
1.1 dsieger 4544:
1.184 rillig 4545: [...]
4546: .include "../../x11/gtk2/buildlink3.mk"
4547: .include "../../mk/bsd.pkg.mk
1.1 dsieger 4548:
1.184 rillig 4549: After another bmake clean && bmake, the answer was:
1.108 rillig 4550:
1.184 rillig 4551: [...]
4552: checking for gtk-config... /home/roland/pkg/bin/gtk-config
4553: checking for GTK - version >= 1.2.0... no
4554: *** Could not run GTK test program, checking why...
4555: *** The test program failed to compile or link. See the file config.log for the
4556: *** exact error that occured. This usually means GTK was incorrectly installed
4557: *** or that you have moved GTK since it was installed. In the latter case, you
4558: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
4559: configure: error: Test for GTK failed.
4560: [...]
1.1 dsieger 4561:
1.184 rillig 4562: In this particular case, the assumption that "every package prefers GNOME 2"
4563: had been wrong. The first of the lines above told me that this package really
4564: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
4565: it would have looked for pkg-config instead of gtk-config. So I changed the x11
4566: /gtk2 to x11/gtk in the package Makefile, and tried again.
1.1 dsieger 4567:
1.184 rillig 4568: [...]
4569: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\" [...]
4570: In file included from xpidl.c:42:
4571: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
4572: In file included from xpidl.c:42:
4573: xpidl.h:132: error: parse error before "IDL_ns"
4574: [...]
1.1 dsieger 4575:
1.184 rillig 4576: The package still does not find all of its dependencies. Now the question is:
4577: Which package provides the libIDL/IDL.h header file?
1.1 dsieger 4578:
1.184 rillig 4579: $ echo ../../*/*idl*
4580: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
4581: $ echo ../../*/*IDL*
4582: ../../net/libIDL
1.1 dsieger 4583:
1.184 rillig 4584: Let's take the one from the second try. So I included the ../../net/libIDL/
4585: buildlink3.mk file and tried again. But the error didn't change. After digging
4586: through some of the code, I concluded that the build process of the package was
4587: broken and couldn't have ever worked, but since the Mozilla source tree is
4588: quite large, I didn't want to fix it. So I added the following to the package
4589: Makefile and tried again:
1.1 dsieger 4590:
1.184 rillig 4591: CPPFLAGS+= -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
4592: BUILDLINK_TRANSFORM+= l:IDL:IDL-2
1.1 dsieger 4593:
1.184 rillig 4594: The latter line is needed because the package expects the library libIDL.so,
4595: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
4596: that on the fly.
1.1 dsieger 4597:
1.184 rillig 4598: The next problem was related to a recent change of the FreeType interface. I
4599: looked up in www/seamonkey which patch files were relevant for this issue and
4600: copied them to the patches directory. Then I retried, fixed the patches so that
4601: they applied cleanly and retried again. This time, everything worked.
1.1 dsieger 4602:
1.184 rillig 4603: 14.2.1.3. Installing the package
1.1 dsieger 4604:
1.184 rillig 4605: $ bmake CHECK_FILES=no install
4606: [...]
4607: $ bmake print-PLIST >PLIST
4608: $ bmake deinstall
4609: $ bmake install
1.1 dsieger 4610:
1.184 rillig 4611: Chapter 15. Programming in Makefiles
1.1 dsieger 4612:
1.184 rillig 4613: Table of Contents
1.1 dsieger 4614:
1.184 rillig 4615: 15.1. Caveats
4616: 15.2. Makefile variables
1.1 dsieger 4617:
1.184 rillig 4618: 15.2.1. Naming conventions
1.1 dsieger 4619:
1.184 rillig 4620: 15.3. Code snippets
1.1 dsieger 4621:
1.184 rillig 4622: 15.3.1. Adding things to a list
4623: 15.3.2. Echoing a string exactly as-is
4624: 15.3.3. Passing CFLAGS to GNU configure scripts
4625: 15.3.4. Handling possibly empty variables
1.1 dsieger 4626:
1.184 rillig 4627: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
4628: part of the pkgsrc system. Using the make(1) system as a programming language
4629: for a big system like pkgsrc requires some discipline to keep the code correct
4630: and understandable.
1.1 dsieger 4631:
1.184 rillig 4632: The basic ingredients for Makefile programming are variables and shell
4633: commands. Among these shell commands may even be more complex ones like awk(1)
4634: programs. To make sure that every shell command runs as intended it is
4635: necessary to quote all variables correctly when they are used.
1.1 dsieger 4636:
1.184 rillig 4637: This chapter describes some patterns that appear quite often in Makefiles,
4638: including the pitfalls that come along with them.
1.1 dsieger 4639:
1.184 rillig 4640: 15.1. Caveats
1.1 dsieger 4641:
1.184 rillig 4642: * When you are creating a file as a target of a rule, always write the data
4643: to a temporary file first and finally rename that file. Otherwise there
4644: might occur an error in the middle of generating the file, and when the
4645: user runs make(1) for the second time, the file exists and will not be
4646: regenerated properly. Example:
1.1 dsieger 4647:
1.184 rillig 4648: wrong:
4649: @echo "line 1" > ${.TARGET}
4650: @echo "line 2" >> ${.TARGET}
4651: @false
1.1 dsieger 4652:
1.184 rillig 4653: correct:
4654: @echo "line 1" > ${.TARGET}.tmp
4655: @echo "line 2" >> ${.TARGET}.tmp
4656: @false
4657: @mv ${.TARGET}.tmp ${.TARGET}
1.1 dsieger 4658:
1.184 rillig 4659: When you run make wrong twice, the file wrong will exist, although there
4660: was an error message in the first run. On the other hand, running make
4661: correct gives an error message twice, as expected.
1.1 dsieger 4662:
1.184 rillig 4663: You might remember that make(1) sometimes removes ${.TARGET} in case of
4664: error, but this only happens when it is interrupted, for example by
4665: pressing Ctrl+C. This does not happen when one of the commands fails (like
4666: false(1) above).
1.1 dsieger 4667:
1.184 rillig 4668: 15.2. Makefile variables
1.1 dsieger 4669:
1.184 rillig 4670: Makefile variables contain strings that can be processed using the five
4671: operators =, +=, ?=, := and !=, which are described in the make(1) man page.
1.1 dsieger 4672:
1.184 rillig 4673: When a variable's value is parsed from a Makefile, the hash character # and the
4674: backslash character \ are handled specially. If a backslash is the last
4675: character in a line, that backslash is removed from the line and the line
4676: continues with the next line of the file.
1.1 dsieger 4677:
1.184 rillig 4678: The # character starts a comment that reaches until the end of the line. To get
4679: an actual # character, such as in a URL, write \# instead.
1.1 dsieger 4680:
1.184 rillig 4681: The evaluation of variables either happens immediately or lazy. It happens
4682: immediately when the variable occurs on the right-hand side of the := or the !=
4683: operator, in a .if condition or a .for loop. In the other cases, it is
4684: evaluated lazily.
1.1 dsieger 4685:
1.184 rillig 4686: Some of the modifiers split the string into words and then operate on the
4687: words, others operate on the string as a whole. When a string is split into
4688: words, double quotes and single quotes are interpreted as delimiters, just like
4689: in sh(1).
1.1 dsieger 4690:
1.184 rillig 4691: 15.2.1. Naming conventions
1.1 dsieger 4692:
1.184 rillig 4693: * All variable names starting with an underscore are reserved for use by the
4694: pkgsrc infrastructure. They shall not be used by packages.
1.1 dsieger 4695:
1.184 rillig 4696: * In .for loops you should use lowercase variable names for the iteration
4697: variables.
1.1 dsieger 4698:
1.184 rillig 4699: * All list variables should have a plural name, such as PKG_OPTIONS or
4700: DISTFILES.
1.1 dsieger 4701:
1.184 rillig 4702: 15.3. Code snippets
1.1 dsieger 4703:
1.184 rillig 4704: 15.3.1. Adding things to a list
1.1 dsieger 4705:
1.184 rillig 4706: When adding a string that possibly contains whitespace or quotes to a list
4707: (example 1), it must be quoted using the :Q modifier.
1.1 dsieger 4708:
1.184 rillig 4709: When adding another list to a list (example 2), it must not be quoted, since
4710: its elements are already quoted.
1.1 dsieger 4711:
1.184 rillig 4712: STRING= foo * bar `date`
4713: LIST= # empty
4714: ANOTHER_LIST= a=b c=d
1.1 dsieger 4715:
1.184 rillig 4716: LIST+= ${STRING:Q} # 1
4717: LIST+= ${ANOTHER_LIST} # 2
1.1 dsieger 4718:
1.184 rillig 4719: 15.3.2. Echoing a string exactly as-is
1.1 dsieger 4720:
1.184 rillig 4721: Echoing a string containing special characters needs special work.
1.1 dsieger 4722:
1.184 rillig 4723: STRING= foo bar < > * `date` $$HOME ' "
4724: EXAMPLE_ENV= string=${STRING:Q} x=multiple\ quoted\ words
1.1 dsieger 4725:
1.184 rillig 4726: all:
4727: echo ${STRING} # 1
4728: echo ${STRING:Q} # 2
4729: printf '%s\n' ${STRING:Q}'' # 3
4730: env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"' # 4
1.1 dsieger 4731:
1.184 rillig 4732: Example 1 leads to a syntax error in the shell, as the characters are just
4733: copied.
1.1 dsieger 4734:
1.184 rillig 4735: Example 2 quotes the string so that the shell interprets it correctly. But the
4736: echo command may additionally interpret strings with a leading dash or those
4737: containing backslashes.
1.1 dsieger 4738:
1.184 rillig 4739: Example 3 can handle arbitrary strings, since printf(1) only interprets the
4740: format string, but not the next argument. The trailing single quotes handle the
4741: case when the string is empty. In that case, the :Q modifier would result in an
4742: empty string too, which would then be skipped by the shell. For printf(1) this
4743: doesn't make a difference, but other programs may care.
1.1 dsieger 4744:
1.184 rillig 4745: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
4746: has already been done when adding elements to the list.
1.1 dsieger 4747:
1.184 rillig 4748: 15.3.3. Passing CFLAGS to GNU configure scripts
1.1 dsieger 4749:
1.184 rillig 4750: When passing CFLAGS or similar variables to a GNU-style configure script
4751: (especially those that call other configure scripts), it must not have leading
4752: or trailing whitespace, since otherwise the configure script gets confused. To
4753: trim leading and trailing whitespace, use the :M modifier, as in the following
4754: example:
1.1 dsieger 4755:
1.184 rillig 4756: CPPFLAGS= # empty
4757: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX}\"
4758: CPPFLAGS+= ${MY_CPPFLAGS}
1.1 dsieger 4759:
1.184 rillig 4760: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
1.1 dsieger 4761:
1.184 rillig 4762: all:
4763: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
4764: echo x${CONFIGURE_ARGS:Q}x # properly trimmed
1.1 dsieger 4765:
1.184 rillig 4766: In this example, CPPFLAGS has both leading and trailing whitespace because the
4767: += operator always adds a space.
1.1 dsieger 4768:
1.184 rillig 4769: 15.3.4. Handling possibly empty variables
1.1 dsieger 4770:
1.184 rillig 4771: When a possibly empty variable is used in a shell program, it may lead to a
4772: syntax error.
1.1 dsieger 4773:
1.184 rillig 4774: EGFILES= # empty
1.1 dsieger 4775:
1.184 rillig 4776: install-examples: # produces a syntax error in the shell
4777: for egfile in ${EGFILES}; do \
4778: echo "Installing $$egfile"; \
4779: done
1.1 dsieger 4780:
1.184 rillig 4781: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
4782: with an empty string by make(1). To fix this syntax error, use one of the
4783: snippets below.
1.1 dsieger 4784:
1.184 rillig 4785: EMPTY= # empty
1.1 dsieger 4786:
1.184 rillig 4787: install-examples:
4788: for egfile in ${EGFILES} ""; do \
4789: [ -n "$$egfile" ] || continue; \
4790: echo "Installing $$egfile"; \
4791: done
1.1 dsieger 4792:
1.184 rillig 4793: In this case, an empty string is appended to the iteration list (to prevent the
4794: syntax error) and filtered out later.
1.1 dsieger 4795:
1.184 rillig 4796: EGFILES= # empty
1.1 dsieger 4797:
1.184 rillig 4798: install-examples:
4799: .for egfile in ${EGFILES}
4800: echo "Installing ${egfile}"
4801: .endfor
1.1 dsieger 4802:
1.184 rillig 4803: If one of the filenames contains special characters, it should be enclosed in
4804: single or double quotes.
1.1 dsieger 4805:
1.184 rillig 4806: To have a shell command test whether a make variable is empty, use the
4807: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1 dsieger 4808:
1.184 rillig 4809: Chapter 16. Options handling
1.1 dsieger 4810:
4811: Table of Contents
4812:
1.184 rillig 4813: 16.1. Global default options
4814: 16.2. Converting packages to use bsd.options.mk
4815: 16.3. Option Names
4816: 16.4. Determining the options of dependencies
1.1 dsieger 4817:
4818: Many packages have the ability to be built to support different sets of
4819: features. bsd.options.mk is a framework in pkgsrc that provides generic
4820: handling of those options that determine different ways in which the packages
4821: can be built. It's possible for the user to specify exactly which sets of
4822: options will be built into a package or to allow a set of global default
4823: options apply.
4824:
1.7 rillig 4825: There are two broad classes of behaviors that one might want to control via
4826: options. One is whether some particular feature is enabled in a program that
4827: will be built anyway, often by including or not including a dependency on some
4828: other package. The other is whether or not an additional program will be built
4829: as part of the package. Generally, it is better to make a split package for
4830: such additional programs instead of using options, because it enables binary
4831: packages to be built which can then be added separately. For example, the foo
4832: package might have minimal dependencies (those packages without which foo
4833: doesn't make sense), and then the foo-gfoo package might include the GTK
4834: frontend program gfoo. This is better than including a gtk option to foo that
4835: adds gfoo, because either that option is default, in which case binary users
4836: can't get foo without gfoo, or not default, in which case they can't get gfoo.
4837: With split packages, they can install foo without having GTK, and later decide
4838: to install gfoo (pulling in GTK at that time). This is an advantage to source
4839: users too, avoiding the need for rebuilds.
4840:
4841: Plugins with widely varying dependencies should usually be split instead of
4842: options.
4843:
4844: It is often more work to maintain split packages, especially if the upstream
4845: package does not support this. The decision of split vs. option should be made
4846: based on the likelihood that users will want or object to the various pieces,
4847: the size of the dependencies that are included, and the amount of work.
4848:
4849: A further consideration is licensing. Non-free parts, or parts that depend on
4850: non-free dependencies (especially plugins) should almost always be split if
4851: feasible.
4852:
1.184 rillig 4853: 16.1. Global default options
1.1 dsieger 4854:
4855: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
4856: the options that should be built into every package if that option is
1.4 rillig 4857: supported. This variable should be set in mk.conf.
1.1 dsieger 4858:
1.184 rillig 4859: 16.2. Converting packages to use bsd.options.mk
1.1 dsieger 4860:
4861: The following example shows how bsd.options.mk should be used by the
4862: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
4863: e.g. options.mk, that is included by the main package Makefile.
4864:
4865: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
4866: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
4867: PKG_OPTIONS_OPTIONAL_GROUPS= database
4868: PKG_OPTIONS_GROUP.database= mysql pgsql
4869: PKG_SUGGESTED_OPTIONS= wibble-foo
4870: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
4871: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
4872:
4873: .include "../../mk/bsd.prefs.mk"
4874:
4875: # this package was previously named wibble2
4876: .if defined(PKG_OPTIONS.wibble2)
4877: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
4878: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
4879: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
4880: .endif
4881:
4882: .include "../../mk/bsd.options.mk"
4883:
4884: # Package-specific option-handling
4885:
4886: ###
4887: ### FOO support
4888: ###
4889: .if !empty(PKG_OPTIONS:Mwibble-foo)
4890: CONFIGURE_ARGS+= --enable-foo
4891: .endif
4892:
4893: ###
4894: ### LDAP support
4895: ###
4896: .if !empty(PKG_OPTIONS:Mldap)
4897: . include "../../databases/openldap-client/buildlink3.mk"
4898: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
4899: .endif
4900:
4901: ###
4902: ### database support
4903: ###
4904: .if !empty(PKG_OPTIONS:Mmysql)
4905: . include "../../mk/mysql.buildlink3.mk"
4906: .endif
4907: .if !empty(PKG_OPTIONS:Mpgsql)
4908: . include "../../mk/pgsql.buildlink3.mk"
4909: .endif
4910:
4911: The first section contains the information about which build options are
4912: supported by the package, and any default options settings if needed.
4913:
4914: 1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
4915: to override the default options. It should be set to PKG_OPTIONS.pkgbase.
4916: Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
4917: the point where the options are processed.
4918:
4919: 2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
4920:
4921: 3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
4922: exclusive options. The options in each group are listed in
4923: PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
4924: the group takes precedence over all other options in the group. Options
4925: from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
4926:
4927: 4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
4928: building the packages will fail if no option from the group is selected.
4929:
4930: 5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
4931: one option from each set must be selected. The options in each set are
4932: listed in PKG_OPTIONS_SET.setname. Options from the sets will be
4933: automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
4934: fail if no option from the set is selected.
4935:
4936: 6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
4937: default.
4938:
4939: 7. PKG_OPTIONS_LEGACY_VARS is a list of "USE_VARIABLE:option" pairs that map
1.4 rillig 4940: legacy mk.conf variables to their option counterparts. Pairs should be
1.1 dsieger 4941: added with "+=" to keep the listing of global legacy variables. A warning
4942: will be issued if the user uses a legacy variable.
4943:
4944: 8. PKG_OPTIONS_LEGACY_OPTS is a list of "old-option:new-option" pairs that map
4945: options that have been renamed to their new counterparts. Pairs should be
4946: added with "+=" to keep the listing of global legacy options. A warning
4947: will be issued if the user uses a legacy option.
4948:
4949: 9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
4950: used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
4951: PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
4952:
4953: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
4954: variables or options used, and what to use instead.
4955:
4956: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
4957: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
4958: options, use PKG_SUGGESTED_OPTIONS.
4959:
4960: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
4961: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
4962: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
4963: options if none of them is supported on the current platform), PKG_OPTIONS is
4964: set to the empty list and the package is otherwise treated as not using the
4965: options framework.
4966:
4967: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
4968: list of selected build options, properly filtered to remove unsupported and
4969: duplicate options.
4970:
4971: The remaining sections contain the logic that is specific to each option. The
4972: correct way to check for an option is to check whether it is listed in
4973: PKG_OPTIONS:
4974:
4975: .if !empty(PKG_OPTIONS:Moption)
4976:
1.184 rillig 4977: 16.3. Option Names
1.1 dsieger 4978:
4979: Options that enable similar features in different packages (like optional
4980: support for a library) should use a common name in all packages that support it
4981: (like the name of the library). If another package already has an option with
4982: the same meaning, use the same name.
4983:
4984: Options that enable features specific to one package, where it's unlikely that
4985: another (unrelated) package has the same (or a similar) optional feature,
4986: should use a name prefixed with pkgname-.
4987:
4988: If a group of related packages share an optional feature specific to that
4989: group, prefix it with the name of the "main" package (e. g.
4990: djbware-errno-hack).
4991:
4992: For new options, add a line to mk/defaults/options.description. Lines have two
4993: fields, separated by tab. The first field is the option name, the second its
4994: description. The description should be a whole sentence (starting with an
4995: uppercase letter and ending with a period) that describes what enabling the
4996: option does. E. g. "Enable ispell support." The file is sorted by option names.
4997:
1.184 rillig 4998: 16.4. Determining the options of dependencies
1.7 rillig 4999:
5000: When writing buildlink3.mk files, it is often necessary to list different
5001: dependencies based on the options with which the package was built. For
5002: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
5003: A typical example looks like this:
5004:
5005: pkgbase := libpurple
5006: .include "../../mk/pkg-build-options.mk"
5007:
5008: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
5009: ...
5010: .endif
5011:
5012: Including pkg-build-options.mk here will set the variable
5013: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
5014: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
5015: pkg-build-options.mk for more details.
5016:
1.184 rillig 5017: Chapter 17. Tools needed for building or running
5018:
5019: Table of Contents
5020:
5021: 17.1. Tools for pkgsrc builds
5022: 17.2. Tools needed by packages
5023: 17.3. Tools provided by platforms
5024:
5025: The USE_TOOLS definition is used both internally by pkgsrc and also for
5026: individual packages to define what commands are needed for building a package
5027: (like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
5028: DEPENDS). If the native system provides an adequate tool, then in many cases, a
5029: pkgsrc package will not be used.
5030:
5031: When building a package, the replacement tools are made available in a
5032: directory (as symlinks or wrapper scripts) that is early in the executable
5033: search path. Just like the buildlink system, this helps with consistent builds.
5034:
5035: A tool may be needed to help build a specific package. For example, perl, GNU
5036: make (gmake) or yacc may be needed.
5037:
5038: Also a tool may be needed, for example, because the native system's supplied
5039: tool may be inefficient for building a package with pkgsrc. For example, a
5040: package may need GNU awk, bison (instead of yacc) or a better sed.
5041:
5042: The tools used by a package can be listed by running make show-tools.
5043:
5044: 17.1. Tools for pkgsrc builds
5045:
5046: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
5047: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
5048: seen by running: make show-var VARNAME=USE_TOOLS.
5049:
5050: If a package needs a specific program to build then the USE_TOOLS variable can
5051: be used to define the tools needed.
5052:
5053: 17.2. Tools needed by packages
5054:
5055: In the following examples, the :run means that it is needed at run-time (and
5056: becomes a DEPENDS). The default is a build dependency which can be set with
5057: :build. (So in this example, it is the same as gmake:build and
5058: pkg-config:build.)
5059:
5060: USE_TOOLS+= gmake perl:run pkg-config
5061:
5062: When using the tools framework, a TOOLS_PATH.foo variable is defined which
5063: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
5064: could be "/bin/bash" on Linux systems.
5065:
5066: If you always need a pkgsrc version of the tool at run-time, then just use
5067: DEPENDS instead.
5068:
5069: 17.3. Tools provided by platforms
5070:
5071: When improving or porting pkgsrc to a new platform, have a look at (or create)
5072: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
5073: tools.${OPSYS}.mk which defines the name of the common tools. For example:
5074:
5075: .if exists(/usr/bin/bzcat)
5076: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
5077: .elif exists(/usr/bin/bzip2)
5078: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
5079: .endif
5080:
5081: TOOLS_PLATFORM.true?= true # shell builtin
5082:
5083: Chapter 18. Buildlink methodology
1.1 dsieger 5084:
5085: Table of Contents
5086:
1.184 rillig 5087: 18.1. Converting packages to use buildlink3
5088: 18.2. Writing buildlink3.mk files
5089:
5090: 18.2.1. Anatomy of a buildlink3.mk file
5091: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
5092: buildlink3.mk files
5093:
5094: 18.3. Writing builtin.mk files
5095:
5096: 18.3.1. Anatomy of a builtin.mk file
5097: 18.3.2. Global preferences for native or pkgsrc software
5098:
5099: Buildlink is a framework in pkgsrc that controls what headers and libraries are
5100: seen by a package's configure and build processes. This is implemented in a two
5101: step process:
5102:
5103: 1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
5104: default is a subdirectory of WRKDIR.
5105:
5106: 2. Create wrapper scripts that are used in place of the normal compiler tools
5107: that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
5108: references to BUILDLINK_DIR. The wrapper scripts also make native compiler
5109: on some operating systems look like GCC, so that packages that expect GCC
5110: won't require modifications to build with those native compilers.
5111:
5112: This normalizes the environment in which a package is built so that the package
5113: may be built consistently despite what other software may be installed. Please
5114: note that the normal system header and library paths, e.g. /usr/include, /usr/
5115: lib, etc., are always searched -- buildlink3 is designed to insulate the
5116: package build from non-system-supplied software.
5117:
5118: 18.1. Converting packages to use buildlink3
1.1 dsieger 5119:
1.184 rillig 5120: The process of converting packages to use the buildlink3 framework ("bl3ifying"
5121: ) is fairly straightforward. The things to keep in mind are:
1.1 dsieger 5122:
1.184 rillig 5123: 1. Ensure that the build always calls the wrapper scripts instead of the
5124: actual toolchain. Some packages are tricky, and the only way to know for
5125: sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
5126: invoked.
1.1 dsieger 5127:
1.184 rillig 5128: 2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
5129: standalone shells, etc., because the code to symlink files into $
5130: {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
1.1 dsieger 5131:
1.184 rillig 5132: 3. Remember that only the buildlink3.mk files that you list in a package's
5133: Makefile are added as dependencies for that package.
1.1 dsieger 5134:
1.184 rillig 5135: If a dependency on a particular package is required for its libraries and
5136: headers, then we replace:
1.1 dsieger 5137:
1.184 rillig 5138: DEPENDS+= foo>=1.1.0:../../category/foo
1.1 dsieger 5139:
1.184 rillig 5140: with
1.1 dsieger 5141:
1.184 rillig 5142: .include "../../category/foo/buildlink3.mk"
1.1 dsieger 5143:
1.184 rillig 5144: The buildlink3.mk files usually define the required dependencies. If you need a
5145: newer version of the dependency when using buildlink3.mk files, then you can
5146: define it in your Makefile; for example:
1.1 dsieger 5147:
1.184 rillig 5148: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
5149: .include "../../category/foo/buildlink3.mk"
1.1 dsieger 5150:
1.184 rillig 5151: There are several buildlink3.mk files in pkgsrc/mk that handle special package
5152: issues:
1.1 dsieger 5153:
1.184 rillig 5154: * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
5155: implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
1.1 dsieger 5156:
1.184 rillig 5157: * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
5158: this will take care to install the devel/ncurses package.
1.1 dsieger 5159:
1.184 rillig 5160: * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
5161: a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
5162: implementation.
1.1 dsieger 5163:
1.184 rillig 5164: * motif.buildlink3.mk checks for a system-provided Motif installation or adds
5165: a dependency on x11/lesstif or x11/motif. The user can set MOTIF_TYPE to "
5166: dt", "lesstif" or "motif" to choose which Motif version will be used.
1.1 dsieger 5167:
1.184 rillig 5168: * readline.buildlink3.mk checks for a system-provided GNU readline or
5169: editline (libedit) installation, or adds a dependency on devel/readline,
5170: devel/editline. The user can set READLINE_DEFAULT to choose readline
5171: implementation. If your package really needs GNU readline library, its
5172: Makefile should include devel/readline/buildlink3.mk instead of
5173: readline.buildlink3.mk.
1.1 dsieger 5174:
1.184 rillig 5175: * oss.buildlink3.mk defines several variables that may be used by packages
5176: that use the Open Sound System (OSS) API.
1.1 dsieger 5177:
1.184 rillig 5178: * pgsql.buildlink3.mk will accept any of the Postgres versions in the
5179: variable PGSQL_VERSIONS_ACCEPTED and default to the version
5180: PGSQL_VERSION_DEFAULT. See the file for more information.
1.1 dsieger 5181:
1.184 rillig 5182: * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
5183: pthreads or adds a dependency on devel/pth as needed.
1.1 dsieger 5184:
1.184 rillig 5185: * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
5186: widgets library.
1.1 dsieger 5187:
1.184 rillig 5188: The comments in those buildlink3.mk files provide a more complete description
5189: of how to use them properly.
1.1 dsieger 5190:
1.184 rillig 5191: 18.2. Writing buildlink3.mk files
1.1 dsieger 5192:
1.184 rillig 5193: A package's buildlink3.mk file is included by Makefiles to indicate the need to
5194: compile and link against header files and libraries provided by the package. A
5195: buildlink3.mk file should always provide enough information to add the correct
5196: type of dependency relationship and include any other buildlink3.mk files that
5197: it needs to find headers and libraries that it needs in turn.
1.1 dsieger 5198:
1.184 rillig 5199: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
5200: pkgtools/createbuildlink package is highly recommended. For most packages, the
5201: following command will generate a good starting point for buildlink3.mk files:
1.1 dsieger 5202:
1.184 rillig 5203: % cd pkgsrc/category/pkgdir
5204: % createbuildlink >buildlink3.mk
1.1 dsieger 5205:
5206:
1.184 rillig 5207: 18.2.1. Anatomy of a buildlink3.mk file
1.1 dsieger 5208:
1.184 rillig 5209: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
5210: tiff:
1.14 jmcneill 5211:
1.184 rillig 5212: # $NetBSD: buildlink3.mk,v 1.16 2009/03/20 19:24:45 joerg Exp $
1.1 dsieger 5213:
1.184 rillig 5214: BUILDLINK_TREE+= tiff
1.1 dsieger 5215:
1.184 rillig 5216: .if !defined(TIFF_BUILDLINK3_MK)
5217: TIFF_BUILDLINK3_MK:=
1.1 dsieger 5218:
1.184 rillig 5219: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
5220: BUILDLINK_ABI_DEPENDS.tiff+= tiff>=3.7.2nb1
5221: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
1.1 dsieger 5222:
1.184 rillig 5223: .include "../../devel/zlib/buildlink3.mk"
5224: .include "../../graphics/jpeg/buildlink3.mk"
5225: .endif # TIFF_BUILDLINK3_MK
1.1 dsieger 5226:
1.184 rillig 5227: BUILDLINK_TREE+= -tiff
1.1 dsieger 5228:
1.184 rillig 5229: The header and footer manipulate BUILDLINK_TREE, which is common across all
5230: buildlink3.mk files and is used to track the dependency tree.
1.1 dsieger 5231:
1.184 rillig 5232: The main section is protected from multiple inclusion and controls how the
5233: dependency on pkg is added. Several important variables are set in the section:
1.1 dsieger 5234:
1.185 wiz 5235: * BUILDLINK_API_DEPENDS.pkg is the dependency version recorded in the
1.184 rillig 5236: installed package; this should always be set using += to ensure that we're
5237: appending to any pre-existing list of values. This variable should be set
1.185 wiz 5238: to the last version of the package that had an backwards-incompatible API
1.184 rillig 5239: change.
1.1 dsieger 5240:
1.184 rillig 5241: * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
1.1 dsieger 5242:
1.184 rillig 5243: * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
5244: BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
5245: is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
5246: full dependency is used.
1.1 dsieger 5247:
1.184 rillig 5248: * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
5249: of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
5250: library search paths. These default to "include" and "lib" respectively.
1.1 dsieger 5251:
1.184 rillig 5252: * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
5253: to add to CPPFLAGS, which are passed on to the configure and build phases.
5254: The "-I" option should be avoided and instead be handled using
5255: BUILDLINK_INCDIRS.pkg as above.
1.66 asau 5256:
1.184 rillig 5257: The following variables are all optionally defined within this second section
5258: (protected against multiple inclusion) and control which package files are
5259: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
5260: symlinking:
1.23 jakllsch 5261:
1.184 rillig 5262: * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
5263: {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
5264: *.h.
1.1 dsieger 5265:
1.184 rillig 5266: * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
5267: to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
5268: resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
5269: takes the +CONTENTS of a pkg and filters it through $
5270: {BUILDLINK_CONTENTS_FILTER.pkg}.
1.1 dsieger 5271:
1.184 rillig 5272: * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
5273: filters +CONTENTS input into a list of files relative to $
5274: {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
5275: outputs the contents of the include and lib directories in the package
5276: +CONTENTS.
1.1 dsieger 5277:
1.184 rillig 5278: * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
5279: used to transform the name of the source filename into a destination
5280: filename, e.g. -e "s|/curses.h|/ncurses.h|g".
1.1 dsieger 5281:
1.184 rillig 5282: This section can additionally include any buildlink3.mk needed for pkg's
5283: library dependencies. Including these buildlink3.mk files means that the
5284: headers and libraries for these dependencies are also symlinked into $
5285: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
5286: are only added for directly include buildlink3.mk files.
1.1 dsieger 5287:
1.184 rillig 5288: When providing a buildlink3.mk and including other buildlink3.mk files in it,
5289: please only add necessary ones, i.e., those whose libraries or header files are
5290: automatically exposed when the package is use.
1.1 dsieger 5291:
1.184 rillig 5292: In particular, if only an executable (bin/foo) is linked against a library,
5293: that library does not need to be propagated in the buildlink3.mk file.
1.1 dsieger 5294:
1.184 rillig 5295: The following steps should help you decide if a buildlink3.mk file needs to be
5296: included:
1.1 dsieger 5297:
1.184 rillig 5298: * Look at the installed header files: What headers do they include? The
5299: packages providing these files must be buildlinked.
1.1 dsieger 5300:
1.184 rillig 5301: * Run ldd on all installed libraries and look against what other libraries
5302: they link. Some of the packages providing these probably need to be
5303: buildlinked; however, it's not automatic, since e.g. GTK on some systems
5304: pulls in the X libraries, so they will show up in the ldd output, while on
5305: others (like OS X) it won't. ldd output can thus only be used as a hint.
1.1 dsieger 5306:
1.184 rillig 5307: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
5308: buildlink3.mk files
1.16 jnemeth 5309:
1.185 wiz 5310: Both variables set lower bounds for a version of this package. The two
5311: variables differ in that one describes source compatibility (API) and the other
5312: binary compatibility (ABI). The difference is that a change in the API breaks
5313: compilation of programs while changes in the ABI stop compiled programs from
5314: running.
5315:
5316: The BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk should be changed
5317: very rarely. (One possible scenario: If all packages using this package need a
5318: higher version than defined in the buildlink3.mk, BUILDLINK_API_DEPENDS.pkg
5319: could be updated to that higher version.)
5320:
5321: On the other hand, changes to BUILDLINK_ABI_DEPENDS.pkg are more common. The
5322: variable will need to be updated every time the major version of one of its
5323: shared libraries is changed, or any other change where a binary built against
5324: the previous version of the package will not run against the new version any
5325: longer.
5326:
5327: In such a case, the package's BUILDLINK_ABI_DEPENDS.pkg must be increased to
5328: require the new package version. Then the PKGREVISION of all packages foo that
5329: depend on this package need to be increased, and if they have buildlink3.mk
5330: files, BUILDLINK_ABI_DEPENDS.foo in their buildlink3.mk files must be increased
5331: to the new version as well. This is required so that a package will pull in the
5332: versions of the packages that use the new ABI and that the packages'
5333: PKGREVISIONs uniquely identify the packages built against the new ABI. The
5334: pkgtools/revbump package can help with these updates.
1.1 dsieger 5335:
1.184 rillig 5336: See Section 21.1.5, "Handling dependencies" for more information about
1.185 wiz 5337: dependencies on other packages, including the BUILDLINK_API_DEPENDS
5338: definitions.
1.1 dsieger 5339:
1.184 rillig 5340: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
1.185 wiz 5341: BUILDLINK_ABI_DEPENDS.pkg in a buildlink3.mk file as we don't want to cause
5342: unneeded package deletions and rebuilds. In many cases, new versions of
5343: packages work just fine with older dependencies.
1.1 dsieger 5344:
1.211 gutterid 5345: Also, it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
1.184 rillig 5346: BUILDLINK_API_DEPENDS.pkg.
1.1 dsieger 5347:
1.211 gutterid 5348: Note there is also the distinction that users are able to disable enforcement
5349: of ABI dependencies using the USE_ABI_DEPENDS variable, but there is no
5350: equivalent option for API dependencies.
5351:
1.184 rillig 5352: 18.3. Writing builtin.mk files
1.1 dsieger 5353:
1.184 rillig 5354: Some packages in pkgsrc install headers and libraries that coincide with
5355: headers and libraries present in the base system. Aside from a buildlink3.mk
5356: file, these packages should also include a builtin.mk file that includes the
5357: necessary checks to decide whether using the built-in software or the pkgsrc
5358: software is appropriate.
1.1 dsieger 5359:
1.184 rillig 5360: The only requirements of a builtin.mk file for pkg are:
1.1 dsieger 5361:
1.184 rillig 5362: 1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
1.1 dsieger 5363:
1.184 rillig 5364: 2. It should not override any USE_BUILTIN.pkg which is already set before the
5365: builtin.mk file is included.
1.1 dsieger 5366:
1.184 rillig 5367: 3. It should be written to allow multiple inclusion. This is very important
5368: and takes careful attention to Makefile coding.
1.1 dsieger 5369:
1.184 rillig 5370: 18.3.1. Anatomy of a builtin.mk file
1.1 dsieger 5371:
1.184 rillig 5372: The following is the recommended template for builtin.mk files:
1.1 dsieger 5373:
1.184 rillig 5374: .if !defined(IS_BUILTIN.foo)
5375: #
5376: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
5377: # genuinely exists in the system or not.
5378: #
5379: IS_BUILTIN.foo?= no
1.1 dsieger 5380:
1.184 rillig 5381: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
5382: # version can be determined.
5383: #
5384: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
5385: BUILTIN_PKG.foo?= foo-1.0
5386: . endif
5387: .endif # IS_BUILTIN.foo
1.1 dsieger 5388:
1.184 rillig 5389: .if !defined(USE_BUILTIN.foo)
5390: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
5391: . if defined(BUILTIN_PKG.foo)
5392: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
5393: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
5394: USE_BUILTIN.foo!= \
5395: ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo} \
5396: && ${ECHO} "yes" || ${ECHO} "no"
5397: . endif
5398: . endfor
5399: . endif
5400: .endif # USE_BUILTIN.foo
1.1 dsieger 5401:
1.184 rillig 5402: CHECK_BUILTIN.foo?= no
5403: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
5404: #
5405: # Here we place code that depends on whether USE_BUILTIN.foo is set to
5406: # "yes" or "no".
5407: #
5408: .endif # CHECK_BUILTIN.foo
1.1 dsieger 5409:
1.184 rillig 5410: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
5411: base system. This should not be a base system software with similar
5412: functionality to pkg; it should only be "yes" if the actual package is included
5413: as part of the base system. This variable is only used internally within the
5414: builtin.mk file.
1.1 dsieger 5415:
1.184 rillig 5416: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
5417: system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
5418: internally within the builtin.mk file.
1.1 dsieger 5419:
1.184 rillig 5420: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
5421: The code in this section must make the determination whether the built-in
5422: software is adequate to satisfy the dependencies listed in
5423: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
5424: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg
5425: must be set to the correct value by the end of the builtin.mk file. Note that
5426: USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
5427: the determination that the built-in version of the software is similar enough
5428: to be used as a replacement.
1.1 dsieger 5429:
1.184 rillig 5430: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
5431: the value of USE_BUILTIN.pkg set in the previous section. This typically
5432: includes, e.g., adding additional dependency restrictions and listing
5433: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
1.1 dsieger 5434:
1.184 rillig 5435: 18.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 5436:
1.184 rillig 5437: When building packages, it's possible to choose whether to set a global
5438: preference for using either the built-in (native) version or the pkgsrc version
5439: of software to satisfy a dependency. This is controlled by setting
5440: PREFER_PKGSRC and PREFER_NATIVE. These variables take values of either "yes", "
5441: no", or a list of packages. PREFER_PKGSRC tells pkgsrc to use the pkgsrc
5442: versions of software, while PREFER_NATIVE tells pkgsrc to use the built-in
5443: versions. Preferences are determined by the most specific instance of the
5444: package in either PREFER_PKGSRC or PREFER_NATIVE. If a package is specified in
5445: neither or in both variables, then PREFER_PKGSRC has precedence over
5446: PREFER_NATIVE. For example, to require using pkgsrc versions of software for
5447: all but the most basic bits on a NetBSD system, you can set:
1.1 dsieger 5448:
1.184 rillig 5449: PREFER_PKGSRC= yes
5450: PREFER_NATIVE= getopt skey tcp_wrappers
1.1 dsieger 5451:
1.184 rillig 5452: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
5453: it is simply ignored in that list.
1.1 dsieger 5454:
1.191 bacon 5455: PREFER_PKGSRC and PREFER_NATIVE should be set during bootstrap to ensure that
5456: the bootstrap process does not use inapropriate native tools as dependencies
5457: for core packages.
5458:
5459: # ./bootstrap --prefer-pkgsrc yes --prefer-native openssl
5460:
5461: Switching between settings globally at a later date can introduce complications
5462: with dependency resolution. This is caused by packages built with the opposite
5463: preference being installed alongside each other. Hence, any changes to these
5464: variables after bootstrap will necessitate rebuilding all packages depending on
5465: one whose preference has been changed. This is not trivial and should be
5466: avoided.
5467:
5468: When using pkgsrc on Linux systems, there is high risk of "leakage", where
5469: programs installed by pkgsrc may inadvertently use a command or library not
5470: installed by pkgsrc, e.g. those installed by yum or apt. Such foreign
5471: dependencies may be installed, removed, or upgraded to a version incompatible
5472: with the pkgsrc package at any time, causing pkgsrc packages to subsequently
5473: malfunction. Pkgsrc cannot prevent this, as it has no control over other
5474: package managers. Another potential problem is that under Redhat Enterprise and
5475: related Linux systems, yum packages are only patched and never upgraded, so
5476: eventually they may become too outdated for use by pkgsrc. Even intentionally
5477: using foreign dependencies, not considered leakage, can lead to these problems,
5478: so it is generally discouraged. In order to minimize such problems,
5479: PREFER_PKGSRC defaults to "yes" on Linux systems. This ensures that pkgsrc is
5480: aware of any changes to dependency packages and can rebuild or upgrade the
5481: entire dependency tree as needed. This default can be overridden by setting
5482: --prefer-pkgsrc to "no" or a list of packages, or by setting --prefer-native to
5483: "yes".
1.1 dsieger 5484:
1.184 rillig 5485: Chapter 19. PLIST issues
1.1 dsieger 5486:
1.184 rillig 5487: Table of Contents
1.1 dsieger 5488:
1.184 rillig 5489: 19.1. RCS ID
5490: 19.2. Semi-automatic PLIST generation
5491: 19.3. Tweaking output of make print-PLIST
5492: 19.4. Variable substitution in PLIST
5493: 19.5. Man page compression
5494: 19.6. Changing PLIST source with PLIST_SRC
5495: 19.7. Platform-specific and differing PLISTs
5496: 19.8. Build-specific PLISTs
5497: 19.9. Sharing directories between packages
1.1 dsieger 5498:
1.184 rillig 5499: The PLIST file contains a package's "packing list", i.e. a list of files that
5500: belong to the package (relative to the ${PREFIX} directory it's been installed
5501: in) plus some additional statements - see the pkg_create(1) man page for a full
5502: list. This chapter addresses some issues that need attention when dealing with
5503: the PLIST file (or files, see below!).
1.1 dsieger 5504:
1.184 rillig 5505: 19.1. RCS ID
1.1 dsieger 5506:
1.184 rillig 5507: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
1.1 dsieger 5508:
1.184 rillig 5509: @comment $NetBSD $
1.1 dsieger 5510:
1.184 rillig 5511: An artificial space has been added between NetBSD and $, this is a workaround
5512: here to prevent CVS expanding to the filename of the guide. When adding the RCS
5513: ID the space should be omitted.
1.38 wiz 5514:
1.184 rillig 5515: 19.2. Semi-automatic PLIST generation
1.1 dsieger 5516:
1.184 rillig 5517: You can use the make print-PLIST command to output a PLIST that matches any new
5518: files since the package was extracted. See Section 13.17, "Other helpful
5519: targets" for more information on this target.
1.11 rillig 5520:
1.184 rillig 5521: 19.3. Tweaking output of make print-PLIST
1.1 dsieger 5522:
1.184 rillig 5523: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
5524: used to filter the output of print-PLIST. You can append any chunk of AWK
5525: scripting you like to it, but be careful with quoting.
1.1 dsieger 5526:
1.184 rillig 5527: For example, to get all files inside the libdata/foo directory removed from the
5528: resulting PLIST:
1.1 dsieger 5529:
1.184 rillig 5530: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
1.1 dsieger 5531:
1.185 wiz 5532: The PRINT_PLIST_AWK transformations are evaluated after the file list and
5533: directory list are sorted. EARLY_PRINT_PLIST_AWK is like PRINT_PLIST_AWK except
5534: it operates before the file list and directory list are sorted.
5535:
1.184 rillig 5536: 19.4. Variable substitution in PLIST
1.1 dsieger 5537:
1.184 rillig 5538: A number of variables are substituted automatically in PLISTs when a package is
5539: installed on a system. This includes the following variables:
1.1 dsieger 5540:
1.184 rillig 5541: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
1.1 dsieger 5542:
1.184 rillig 5543: Some packages like emacs and perl embed information about which
5544: architecture they were built on into the pathnames where they install their
5545: files. To handle this case, PLIST will be preprocessed before actually
5546: used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
5547: gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
5548: PLIST somewhere - use this on packages that have GNU autoconf-created
5549: configure scripts.
1.1 dsieger 5550:
1.184 rillig 5551: Legacy note
1.1 dsieger 5552:
1.184 rillig 5553: There used to be a symbol "$ARCH" that was replaced by the output of uname
5554: -m, but that's no longer supported and has been removed.
1.1 dsieger 5555:
1.184 rillig 5556: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
1.1 dsieger 5557:
1.184 rillig 5558: Some packages want to embed the OS name and version into some paths. To do
5559: this, use these variables in the PLIST:
1.1 dsieger 5560:
1.184 rillig 5561: + ${OPSYS} - output of "uname -s"
1.1 dsieger 5562:
1.184 rillig 5563: + ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
1.1 dsieger 5564:
1.184 rillig 5565: + ${OS_VERSION} - "uname -r"
1.1 dsieger 5566:
1.184 rillig 5567: For a list of values which are replaced by default, the output of make help
5568: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
5569: PLIST_SUBST should help.
1.1 dsieger 5570:
1.184 rillig 5571: If you want to change other variables not listed above, you can add variables
5572: and their expansions to this variable in the following way, similar to
5573: MESSAGE_SUBST (see Section 12.5, "Optional files"):
1.1 dsieger 5574:
1.184 rillig 5575: PLIST_SUBST+= SOMEVAR="somevalue"
1.1 dsieger 5576:
1.184 rillig 5577: This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
1.1 dsieger 5578:
1.184 rillig 5579: The PLIST_VARS variable can be used to simplify the common case of
5580: conditionally including some PLIST entries. It can be done by adding
5581: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
5582: entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
5583: either """" or ""@comment "". For example, in Makefile:
1.1 dsieger 5584:
1.184 rillig 5585: PLIST_VARS+= foo
5586: .if condition
5587: PLIST.foo= yes
5588: .else
1.1 dsieger 5589:
1.184 rillig 5590: And then in PLIST:
1.1 dsieger 5591:
1.184 rillig 5592: @comment $NetBSD $
5593: bin/bar
5594: man/man1/bar.1
5595: ${PLIST.foo}bin/foo
5596: ${PLIST.foo}man/man1/foo.1
5597: ${PLIST.foo}share/bar/foo.data
1.1 dsieger 5598:
1.184 rillig 5599: An artificial space has been added between NetBSD and $, this is a workaround
5600: here to prevent CVS expanding to the filename of the guide. When adding the RCS
1.195 gutterid 5601: ID the space should be omitted.
1.1 dsieger 5602:
1.184 rillig 5603: 19.5. Man page compression
1.1 dsieger 5604:
1.184 rillig 5605: Man pages should be installed in compressed form if MANZ is set (in
5606: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
5607: suffix ".gz" is appended/removed automatically for man pages according to MANZ
5608: and MANCOMPRESSED being set or not, see above for details. This modification of
5609: the PLIST file is done on a copy of it, not PLIST itself.
1.100 leot 5610:
1.184 rillig 5611: 19.6. Changing PLIST source with PLIST_SRC
1.100 leot 5612:
1.184 rillig 5613: To use one or more files as source for the PLIST used in generating the binary
5614: package, set the variable PLIST_SRC to the names of that file(s). The files are
5615: later concatenated using cat(1), and the order of things is important. The
5616: default for PLIST_SRC is ${PKGDIR}/PLIST.
1.1 dsieger 5617:
1.184 rillig 5618: 19.7. Platform-specific and differing PLISTs
1.1 dsieger 5619:
1.184 rillig 5620: Some packages decide to install a different set of files based on the operating
5621: system being used. These differences can be automatically handled by using the
5622: following files:
1.1 dsieger 5623:
1.184 rillig 5624: * PLIST.common
1.1 dsieger 5625:
1.184 rillig 5626: * PLIST.${OPSYS}
1.1 dsieger 5627:
1.184 rillig 5628: * PLIST.${MACHINE_ARCH}
1.1 dsieger 5629:
1.184 rillig 5630: * PLIST.${OPSYS}-${MACHINE_ARCH}
1.1 dsieger 5631:
1.184 rillig 5632: * PLIST.common_end
1.1 dsieger 5633:
1.184 rillig 5634: 19.8. Build-specific PLISTs
1.1 dsieger 5635:
1.184 rillig 5636: Some packages decide to generate hard-to-guess file names during installation
5637: that are hard to wire down.
1.1 dsieger 5638:
1.184 rillig 5639: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
5640: (with a semicolon) that will output PLIST entries which will be appended to the
5641: PLIST
1.1 dsieger 5642:
1.184 rillig 5643: You can find one example in editors/xemacs:
1.1 dsieger 5644:
1.184 rillig 5645: GENERATE_PLIST+= ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.1 dsieger 5646:
1.184 rillig 5647: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
1.1 dsieger 5648:
1.184 rillig 5649: 19.9. Sharing directories between packages
1.1 dsieger 5650:
1.184 rillig 5651: A "shared directory" is a directory where multiple (and unrelated) packages
5652: install files. These directories were problematic because you had to add
5653: special tricks in the PLIST to conditionally remove them, or have some
5654: centralized package handle them.
1.106 tnn 5655:
1.184 rillig 5656: In pkgsrc, it is now easy: Each package should create directories and install
5657: files as needed; pkg_delete will remove any directories left empty after
5658: uninstalling a package.
1.106 tnn 5659:
1.184 rillig 5660: If a package needs an empty directory to work, create the directory during
5661: installation as usual, and also add an entry to the PLIST:
1.1 dsieger 5662:
1.184 rillig 5663: @pkgdir path/to/empty/directory
1.1 dsieger 5664:
1.184 rillig 5665: or take a look at MAKE_DIRS and OWN_DIRS.
1.1 dsieger 5666:
1.184 rillig 5667: Chapter 20. The pkginstall framework
1.1 dsieger 5668:
1.184 rillig 5669: Table of Contents
1.1 dsieger 5670:
1.184 rillig 5671: 20.1. Files and directories outside the installation prefix
1.1 dsieger 5672:
1.184 rillig 5673: 20.1.1. Directory manipulation
5674: 20.1.2. File manipulation
1.1 dsieger 5675:
1.184 rillig 5676: 20.2. Configuration files
1.1 dsieger 5677:
1.184 rillig 5678: 20.2.1. How PKG_SYSCONFDIR is set
5679: 20.2.2. Telling the software where configuration files are
5680: 20.2.3. Patching installations
5681: 20.2.4. Disabling handling of configuration files
1.1 dsieger 5682:
1.184 rillig 5683: 20.3. System startup scripts
1.1 dsieger 5684:
1.184 rillig 5685: 20.3.1. Disabling handling of system startup scripts
1.1 dsieger 5686:
1.184 rillig 5687: 20.4. System users and groups
5688: 20.5. System shells
1.1 dsieger 5689:
1.184 rillig 5690: 20.5.1. Disabling shell registration
1.1 dsieger 5691:
1.184 rillig 5692: 20.6. Fonts
1.1 dsieger 5693:
1.184 rillig 5694: 20.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 5695:
1.184 rillig 5696: This chapter describes the framework known as pkginstall, whose key features
5697: are:
1.1 dsieger 5698:
1.184 rillig 5699: * Generic installation and manipulation of directories and files outside the
5700: pkgsrc-handled tree, LOCALBASE.
1.1 dsieger 5701:
1.184 rillig 5702: * Automatic handling of configuration files during installation, provided
5703: that packages are correctly designed.
1.1 dsieger 5704:
1.184 rillig 5705: * Generation and installation of system startup scripts.
1.1 dsieger 5706:
1.184 rillig 5707: * Registration of system users and groups.
1.1 dsieger 5708:
1.184 rillig 5709: * Registration of system shells.
1.1 dsieger 5710:
1.184 rillig 5711: * Automatic updating of fonts databases.
1.1 dsieger 5712:
1.184 rillig 5713: The following sections inspect each of the above points in detail.
1.1 dsieger 5714:
1.184 rillig 5715: You may be thinking that many of the things described here could be easily done
5716: with simple code in the package's post-installation target (post-install). This
5717: is incorrect, as the code in them is only executed when building from source.
5718: Machines using binary packages could not benefit from it at all (as the code
5719: itself could be unavailable). Therefore, the only way to achieve any of the
5720: items described above is by means of the installation scripts, which are
5721: automatically generated by pkginstall.
1.1 dsieger 5722:
1.184 rillig 5723: 20.1. Files and directories outside the installation prefix
1.95 wiz 5724:
1.184 rillig 5725: As you already know, the PLIST file holds a list of files and directories that
5726: belong to a package. The names used in it are relative to the installation
5727: prefix (${PREFIX}), which means that it cannot register files outside this
5728: directory (absolute path names are not allowed). Despite this restriction, some
5729: packages need to install files outside this location; e.g., under ${VARBASE} or
5730: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
5731: installation time by using installation scripts.
1.95 wiz 5732:
1.184 rillig 5733: The generic installation scripts are shell scripts that can contain arbitrary
5734: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
5735: which defaults to INSTALL. A similar variable exists for package removal
5736: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
5737: commands, so they have the potential to create and manage files anywhere in the
5738: file system.
1.95 wiz 5739:
1.184 rillig 5740: Using these general installation files is not recommended, but may be needed in
5741: some special cases. One reason for avoiding them is that the user has to trust
5742: the packager that there is no unwanted or simply erroneous code included in the
5743: installation script. Also, previously there were many similar scripts for the
5744: same functionality, and fixing a common error involved finding and changing all
5745: of them.
1.95 wiz 5746:
1.184 rillig 5747: The pkginstall framework offers another, standardized way. It provides generic
5748: scripts to abstract the manipulation of such files and directories based on
5749: variables set in the package's Makefile. The rest of this section describes
5750: these variables.
1.1 dsieger 5751:
1.184 rillig 5752: 20.1.1. Directory manipulation
1.1 dsieger 5753:
1.184 rillig 5754: The following variables can be set to request the creation of directories
5755: anywhere in the file system:
1.1 dsieger 5756:
1.184 rillig 5757: * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
5758: and should attempt to be destroyed by the installation scripts. The
5759: difference between the two is that the latter prompts the administrator to
5760: remove any directories that may be left after deinstallation (because they
5761: were not empty), while the former does not. Example:
1.1 dsieger 5762:
1.184 rillig 5763: MAKE_DIRS+= ${VARBASE}/foo/private
1.1 dsieger 5764:
1.184 rillig 5765: * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
5766: which directories should be created and should attempt to be destroyed by
5767: the installation scripts. Each tuple holds the following values, separated
5768: by spaces: the directory name, its owner, its group and its numerical mode.
5769: For example:
1.1 dsieger 5770:
1.184 rillig 5771: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private \
5772: ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1 dsieger 5773:
1.184 rillig 5774: The difference between the two is exactly the same as their non-PERMS
5775: counterparts.
1.1 dsieger 5776:
1.184 rillig 5777: 20.1.2. File manipulation
1.1 dsieger 5778:
1.184 rillig 5779: Creating non-empty files outside the installation prefix is tricky because the
5780: PLIST forces all files to be inside it. To overcome this problem, the only
5781: solution is to extract the file in the known place (i.e., inside the
5782: installation prefix) and copy it to the appropriate location during
5783: installation (done by the installation scripts generated by pkginstall). We
5784: will call the former the master file in the following paragraphs, which
5785: describe the variables that can be used to automatically and consistently
5786: handle files outside the installation prefix:
1.1 dsieger 5787:
1.184 rillig 5788: * CONF_FILES and REQD_FILES are pairs of master and target files. During
5789: installation time, the master file is copied to the target one if and only
5790: if the latter does not exist. Upon deinstallation, the target file is
5791: removed provided that it was not modified by the installation.
1.1 dsieger 5792:
1.184 rillig 5793: The difference between the two is that the latter prompts the administrator
5794: to remove any files that may be left after deinstallation (because they
5795: were not empty), while the former does not.
1.1 dsieger 5796:
1.184 rillig 5797: * CONF_FILES_PERMS and REQD_FILES_PERMS contain tuples describing master
5798: files as well as their target locations. For each of them, it also
5799: specifies their owner, their group and their numeric permissions, in this
5800: order. For example:
1.1 dsieger 5801:
1.184 rillig 5802: REQD_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile \
5803: ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1 dsieger 5804:
1.184 rillig 5805: The difference between the two is exactly the same as their non-PERMS
5806: counterparts.
1.1 dsieger 5807:
1.184 rillig 5808: 20.2. Configuration files
1.1 dsieger 5809:
1.184 rillig 5810: Configuration files are special in the sense that they are installed in their
5811: own specific directory, PKG_SYSCONFDIR, and need special treatment during
5812: installation (most of which is automated by pkginstall). The main concept you
5813: must bear in mind is that files marked as configuration files are automatically
5814: copied to the right place (somewhere inside PKG_SYSCONFDIR) during installation
5815: if and only if they didn't exist before. Similarly, they will not be removed if
5816: they have local modifications. This ensures that administrators never lose any
5817: custom changes they may have made.
1.1 dsieger 5818:
1.184 rillig 5819: 20.2.1. How PKG_SYSCONFDIR is set
1.1 dsieger 5820:
1.184 rillig 5821: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
5822: shall be installed. Its contents are set based upon the following variables:
1.1 dsieger 5823:
1.184 rillig 5824: * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
5825: etc although it may be overridden by the user to point to his preferred
5826: location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
1.1 dsieger 5827:
1.184 rillig 5828: * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
5829: configuration files for the package being built shall be installed. The
5830: definition of this variable only makes sense in the package's Makefile
5831: (i.e., it is not user-customizable).
1.1 dsieger 5832:
1.184 rillig 5833: As an example, consider the Apache package, www/apache24, which places its
5834: configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
5835: should be set in the package Makefile.
1.1 dsieger 5836:
1.184 rillig 5837: * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
5838: package's configuration directory (if different from PKG_SYSCONFBASE). It
5839: defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
1.1 dsieger 5840:
1.184 rillig 5841: * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
5842: configuration files for the package identified by PKG_SYSCONFVAR's shall be
5843: placed.
1.1 dsieger 5844:
1.184 rillig 5845: Based on the above variables, pkginstall determines the value of
5846: PKG_SYSCONFDIR, which is the only variable that can be used within a package to
5847: refer to its configuration directory. The algorithm used to set its value is
5848: basically the following:
1.1 dsieger 5849:
1.184 rillig 5850: 1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
1.1 dsieger 5851:
1.184 rillig 5852: 2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
5853: package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
5854: {PKG_SYSCONFSUBDIR}.
1.1 dsieger 5855:
1.184 rillig 5856: 3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
1.1 dsieger 5857:
1.184 rillig 5858: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
5859: OWN_DIRS. See Section 20.1.1, "Directory manipulation" what this means. This
5860: does not apply to subdirectories of ${PKG_SYSCONFDIR}, they still have to be
5861: created with OWN_DIRS or MAKE_DIRS.
1.1 dsieger 5862:
1.184 rillig 5863: 20.2.2. Telling the software where configuration files are
1.1 dsieger 5864:
1.184 rillig 5865: Given that pkgsrc (and users!) expect configuration files to be in a known
5866: place, you need to teach each package where it shall install its files. In some
5867: cases you will have to patch the package Makefiles to achieve it. If you are
5868: lucky, though, it may be as easy as passing an extra flag to the configuration
5869: script; this is the case of GNU Autoconf- generated files:
1.1 dsieger 5870:
1.184 rillig 5871: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1 dsieger 5872:
1.184 rillig 5873: Note that this specifies where the package has to look for its configuration
5874: files, not where they will be originally installed (although the difference is
5875: never explicit, unfortunately).
1.1 dsieger 5876:
1.184 rillig 5877: 20.2.3. Patching installations
1.1 dsieger 5878:
1.184 rillig 5879: As said before, pkginstall automatically handles configuration files. This
5880: means that the packages themselves must not touch the contents of $
5881: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
5882: will, out of the box, mess with the contents of that directory. So what is the
5883: correct procedure to fix this issue?
1.1 dsieger 5884:
1.184 rillig 5885: You must teach the package (usually by manually patching it) to install any
5886: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
5887: This way, the PLIST registers them and the administrator always has the
5888: original copies available.
1.1 dsieger 5889:
1.184 rillig 5890: Once the required configuration files are in place (i.e., under the examples
5891: hierarchy), the pkginstall framework can use them as master copies during the
5892: package installation to update what is in ${PKG_SYSCONFDIR}. To achieve this,
5893: the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
5894: Section 20.1.2, "File manipulation" for information about their syntax and
5895: their purpose. Here is an example, taken from the mail/mutt package:
1.1 dsieger 5896:
1.184 rillig 5897: EGDIR= ${PREFIX}/share/doc/mutt/samples
5898: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1 dsieger 5899:
1.184 rillig 5900: Note that the EGDIR variable is specific to that package and has no meaning
5901: outside it.
1.1 dsieger 5902:
1.184 rillig 5903: 20.2.4. Disabling handling of configuration files
1.1 dsieger 5904:
1.184 rillig 5905: The automatic copying of config files can be toggled by setting the environment
5906: variable PKG_CONFIG prior to package installation.
1.1 dsieger 5907:
1.184 rillig 5908: 20.3. System startup scripts
1.1 dsieger 5909:
1.184 rillig 5910: System startup scripts are special files because they must be installed in a
5911: place known by the underlying OS, usually outside the installation prefix.
5912: Therefore, the same rules described in Section 20.1, "Files and directories
5913: outside the installation prefix" apply, and the same solutions can be used.
5914: However, pkginstall provides a special mechanism to handle these files.
1.1 dsieger 5915:
1.184 rillig 5916: In order to provide system startup scripts, the package has to:
1.1 dsieger 5917:
1.184 rillig 5918: 1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
5919: Considering the print/cups package as an example, it has a cupsd.sh in its
5920: files directory.
1.95 wiz 5921:
1.184 rillig 5922: 2. Tell pkginstall to handle it, appending the name of the script, without its
5923: extension, to the RCD_SCRIPTS variable. Continuing the previous example:
1.95 wiz 5924:
1.184 rillig 5925: RCD_SCRIPTS+= cupsd
1.95 wiz 5926:
1.184 rillig 5927: Once this is done, pkginstall will do the following steps for each script in an
5928: automated fashion:
1.95 wiz 5929:
1.184 rillig 5930: 1. Process the file found in the files directory applying all the
5931: substitutions described in the FILES_SUBST variable.
1.1 dsieger 5932:
1.184 rillig 5933: 2. Copy the script from the files directory to the examples hierarchy, $
5934: {PREFIX}/share/examples/rc.d/. Note that this master file must be
5935: explicitly registered in the PLIST.
1.1 dsieger 5936:
1.184 rillig 5937: 3. Add code to the installation scripts to copy the startup script from the
5938: examples hierarchy into the system-wide startup scripts directory.
1.1 dsieger 5939:
1.184 rillig 5940: 20.3.1. Disabling handling of system startup scripts
1.1 dsieger 5941:
1.184 rillig 5942: The automatic copying of config files can be toggled by setting the environment
5943: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
5944: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
5945: rc.d/, no matter what the value of this variable is.
1.1 dsieger 5946:
1.184 rillig 5947: 20.4. System users and groups
1.1 dsieger 5948:
1.184 rillig 5949: If a package needs to create special users and/or groups during installation,
5950: it can do so by using the pkginstall framework.
1.1 dsieger 5951:
1.184 rillig 5952: Users can be created by adding entries to the PKG_USERS variable. Each entry
5953: has the following syntax:
1.1 dsieger 5954:
1.184 rillig 5955: user:group
1.1 dsieger 5956:
1.184 rillig 5957: Further specification of user details may be done by setting per-user
5958: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
5959: user's description or comment. PKG_HOME.user is the user's home directory, and
5960: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
5961: and defaults to /sbin/nologin if not specified.
1.1 dsieger 5962:
1.184 rillig 5963: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
5964: whose syntax is:
1.1 dsieger 5965:
1.184 rillig 5966: group
1.1 dsieger 5967:
1.184 rillig 5968: The numeric GID of the group may be set by defining PKG_GID.group.
1.1 dsieger 5969:
1.184 rillig 5970: If a package needs to create the users and groups at an earlier stage, then it
5971: can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
5972: the phase before which the users and groups are created. In this case, the
5973: numeric UIDs and GIDs of the created users and groups are automatically
5974: hardcoded into the final installation scripts.
1.1 dsieger 5975:
1.184 rillig 5976: 20.5. System shells
1.1 dsieger 5977:
1.184 rillig 5978: Packages that install system shells should register them in the shell database,
5979: /etc/shells, to make things easier to the administrator. This must be done from
5980: the installation scripts to keep binary packages working on any system.
5981: pkginstall provides an easy way to accomplish this task.
1.1 dsieger 5982:
1.184 rillig 5983: When a package provides a shell interpreter, it has to set the PKG_SHELL
5984: variable to its absolute file name. This will add some hooks to the
5985: installation scripts to handle it. Consider the following example, taken from
5986: shells/zsh:
1.1 dsieger 5987:
1.184 rillig 5988: PKG_SHELL= ${PREFIX}/bin/zsh
1.1 dsieger 5989:
1.184 rillig 5990: 20.5.1. Disabling shell registration
1.1 dsieger 5991:
1.184 rillig 5992: The automatic registration of shell interpreters can be disabled by the
5993: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
1.1 dsieger 5994:
1.184 rillig 5995: 20.6. Fonts
1.1 dsieger 5996:
1.184 rillig 5997: Packages that install X11 fonts should update the database files that index the
5998: fonts within each fonts directory. This can easily be accomplished within the
5999: pkginstall framework.
1.1 dsieger 6000:
1.184 rillig 6001: When a package installs X11 fonts, it must list the directories in which fonts
6002: are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
6003: "type1" or "x11". This will add hooks to the installation scripts to run the
6004: appropriate commands to update the fonts database files within each of those
6005: directories. For convenience, if the directory path is relative, it is taken to
6006: be relative to the package's installation prefix. Consider the following
6007: example, taken from fonts/dbz-ttf:
1.1 dsieger 6008:
1.184 rillig 6009: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1 dsieger 6010:
1.184 rillig 6011: 20.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 6012:
1.184 rillig 6013: The automatic update of fonts databases can be disabled by the administrator by
6014: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
1.1 dsieger 6015:
1.154 rillig 6016: Chapter 21. Making your package work
1.1 dsieger 6017:
6018: Table of Contents
6019:
1.154 rillig 6020: 21.1. General operation
1.1 dsieger 6021:
1.154 rillig 6022: 21.1.1. How to pull in user-settable variables from mk.conf
6023: 21.1.2. User interaction
6024: 21.1.3. Handling licenses
6025: 21.1.4. Restricted packages
6026: 21.1.5. Handling dependencies
6027: 21.1.6. Handling conflicts with other packages
6028: 21.1.7. Packages that cannot or should not be built
6029: 21.1.8. Packages which should not be deleted, once installed
6030: 21.1.9. Handling packages with security problems
6031: 21.1.10. How to handle incrementing versions when fixing an existing
1.1 dsieger 6032: package
1.154 rillig 6033: 21.1.11. Substituting variable text in the package files (the SUBST
1.1 dsieger 6034: framework)
6035:
1.154 rillig 6036: 21.2. The fetch phase
1.1 dsieger 6037:
1.154 rillig 6038: 21.2.1. Packages whose distfiles aren't available for plain downloading
6039: 21.2.2. How to handle modified distfiles with the 'old' name
6040: 21.2.3. Packages hosted on github.com
6041:
6042: 21.3. The configure phase
6043:
6044: 21.3.1. Shared libraries - libtool
6045: 21.3.2. Using libtool on GNU packages that already support libtool
6046: 21.3.3. GNU Autoconf/Automake
6047:
6048: 21.4. Programming languages
6049:
6050: 21.4.1. C, C++, and Fortran
6051: 21.4.2. Java
1.205 wiz 6052: 21.4.3. Go
6053: 21.4.4. Packages containing Perl scripts
6054: 21.4.5. Packages containing shell scripts
6055: 21.4.6. Other programming languages
1.154 rillig 6056:
6057: 21.5. The build phase
6058:
6059: 21.5.1. Compiling C and C++ code conditionally
6060: 21.5.2. How to handle compiler bugs
1.172 rillig 6061: 21.5.3. No such file or directory
6062: 21.5.4. Undefined reference to "..."
6063: 21.5.5. Running out of memory
1.154 rillig 6064:
6065: 21.6. The install phase
6066:
6067: 21.6.1. Creating needed directories
6068: 21.6.2. Where to install documentation
6069: 21.6.3. Installing highscore files
6070: 21.6.4. Adding DESTDIR support to packages
6071: 21.6.5. Packages with hardcoded paths to other interpreters
1.203 nia 6072: 21.6.6. Packages installing Perl modules
1.154 rillig 6073: 21.6.7. Packages installing info files
6074: 21.6.8. Packages installing man pages
1.203 nia 6075: 21.6.9. Packages installing X11 fonts
6076: 21.6.10. Packages installing SGML or XML data
6077: 21.6.11. Packages installing extensions to the MIME database
6078: 21.6.12. Packages using intltool
6079: 21.6.13. Packages installing startup scripts
6080: 21.6.14. Packages installing TeX modules
6081: 21.6.15. Packages supporting running binaries in emulation
6082: 21.6.16. Packages installing hicolor icons
6083: 21.6.17. Packages installing desktop files
1.1 dsieger 6084:
1.154 rillig 6085: 21.7. Marking packages as having problems
1.1 dsieger 6086:
1.154 rillig 6087: 21.1. General operation
1.1 dsieger 6088:
6089: One appealing feature of pkgsrc is that it runs on many different platforms. As
6090: a result, it is important to ensure, where possible, that packages in pkgsrc
6091: are portable. This chapter mentions some particular details you should pay
6092: attention to while working on pkgsrc.
6093:
1.154 rillig 6094: 21.1.1. How to pull in user-settable variables from mk.conf
1.1 dsieger 6095:
6096: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4 rillig 6097: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
6098: those variables in the preprocessor directives of make(1) (for example .if or
6099: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
6100: loads the user preferences.
1.1 dsieger 6101:
6102: But note that some variables may not be completely defined after ../../mk/
6103: bsd.prefs.mk has been included, as they may contain references to variables
1.108 rillig 6104: that are not yet defined. In shell commands (the lines in Makefile that are
6105: indented with a tab) this is no problem, since variables are only expanded when
6106: they are used. But in the preprocessor directives mentioned above and in
6107: dependency lines (of the form target: dependencies) the variables are expanded
6108: at load time.
1.1 dsieger 6109:
6110: Note
6111:
1.108 rillig 6112: To check whether a variable can be used at load time, run pkglint -Wall on your
6113: package.
1.1 dsieger 6114:
1.154 rillig 6115: 21.1.2. User interaction
1.1 dsieger 6116:
6117: Occasionally, packages require interaction from the user, and this can be in a
6118: number of ways:
6119:
6120: * When fetching the distfiles, some packages require user interaction such as
6121: entering username/password or accepting a license on a web page.
6122:
6123: * When extracting the distfiles, some packages may ask for passwords.
6124:
6125: * help to configure the package before it is built
6126:
6127: * help during the build process
6128:
6129: * help during the installation of a package
6130:
1.108 rillig 6131: A package can set the INTERACTIVE_STAGE variable to define which stages need
6132: interaction. This should be done in the package's Makefile, e.g.:
1.1 dsieger 6133:
6134: INTERACTIVE_STAGE= configure install
6135:
6136: The user can then decide to skip this package by setting the BATCH variable.
1.108 rillig 6137: Packages that require interaction are also excluded from bulk builds.
1.1 dsieger 6138:
1.154 rillig 6139: 21.1.3. Handling licenses
1.1 dsieger 6140:
6141: Authors of software can choose the licence under which software can be copied.
1.111 sevan 6142: The Free Software Foundation has declared some licenses "Free", and the Open
6143: Source Initiative has a definition of "Open Source".
6144:
6145: By default, pkgsrc allows packages with Free or Open Source licenses to be
6146: built. To allow packages with other licenses to be built as well, the pkgsrc
6147: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
6148: . Note that this variable only affects which packages may be built, while the
6149: license terms often also restrict the actual use of the package and its
6150: redistribution.
1.1 dsieger 6151:
6152: One might want to only install packages with a BSD license, or the GPL, and not
1.20 jnemeth 6153: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111 sevan 6154: variable. The pkgsrc user can override the default by setting the
6155: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
6156: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
6157: pkgsrc/mk/license.mk.
1.1 dsieger 6158:
6159: The license tag mechanism is intended to address copyright-related issues
6160: surrounding building, installing and using a package, and not to address
1.20 jnemeth 6161: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
6162: redistribution restrictions should set these tags.
1.1 dsieger 6163:
6164: Denoting that a package may be copied according to a particular license is done
6165: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
6166: string identifying the license, e.g. in graphics/xv:
6167:
6168: LICENSE= xv-license
6169:
6170: When trying to build, the user will get a notice that the package is covered by
6171: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
6172:
6173: % make
6174: ===> xv-3.10anb9 has an unacceptable license: xv-license.
6175: ===> To view the license, enter "/usr/bin/make show-license".
6176: ===> To indicate acceptance, add this line to your /etc/mk.conf:
6177: ===> ACCEPTABLE_LICENSES+=xv-license
6178: *** Error code 1
6179:
6180: The license can be viewed with make show-license, and if the user so chooses,
1.4 rillig 6181: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1 dsieger 6182: should not in the future fail because of that license:
6183:
6184: ACCEPTABLE_LICENSES+=xv-license
6185:
1.111 sevan 6186: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
6187: is deprecated because it does not crisply refer to a particular license text.
6188: Another problem with such usage is that it does not enable a user to tell
6189: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
6190: for all packages with that tag.
6191:
1.154 rillig 6192: 21.1.3.1. Adding a package with a new license
1.1 dsieger 6193:
1.49 rodent 6194: When adding a package with a new license, the following steps are required:
6195:
1.111 sevan 6196: 1. Check whether the license qualifies as Free or Open Source by referencing
6197: Various Licenses and Comments about Them and Licenses by Name | Open Source
6198: Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
6199: need the -license suffix, and the license name should be added to:
1.49 rodent 6200:
6201: + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
6202:
6203: + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
6204: license.c
6205:
6206: 2. The license text should be added to pkgsrc/licenses for displaying. A list
6207: of known licenses can be seen in this directory.
1.1 dsieger 6208:
1.154 rillig 6209: 21.1.3.2. Change to the license
1.1 dsieger 6210:
1.111 sevan 6211: When the license changes (in a way other than formatting), make sure that the
6212: new license has a different name (e.g., append the version number if it exists,
6213: or the date). Just because a user told pkgsrc to build programs under a
6214: previous version of a license does not mean that pkgsrc should build programs
6215: under the new licenses. The higher-level point is that pkgsrc does not evaluate
6216: licenses for reasonableness; the only test is a mechanistic test of whether a
6217: particular text has been approved by either of two bodies (FSF or OSI).
1.1 dsieger 6218:
1.154 rillig 6219: 21.1.4. Restricted packages
1.1 dsieger 6220:
1.111 sevan 6221: Some licenses restrict how software may be re-distributed. By declaring the
6222: restrictions, package tools can automatically refrain from e.g. placing binary
6223: packages on FTP sites.
6224:
6225: There are four possible restrictions, which are the cross product of sources
6226: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
6227: this is rarely the exact language in any license, and because non-Free licenses
6228: tend to be different from each other, pkgsrc adopts a definition of FTP and
6229: CD-ROM. "FTP" means making the source or binary file available over the
6230: Internet at no charge. "CD-ROM" means making the source or binary available on
6231: some kind of media, together with other source and binary packages, which is
6232: sold for a distribution charge.
1.1 dsieger 6233:
6234: In order to encode these restrictions, the package system defines five make
6235: variables that can be set to note these restrictions:
6236:
6237: * RESTRICTED
6238:
6239: This variable should be set whenever a restriction exists (regardless of
6240: its kind). Set this variable to a string containing the reason for the
6241: restriction. It should be understood that those wanting to understand the
6242: restriction will have to read the license, and perhaps seek advice of
6243: counsel.
6244:
6245: * NO_BIN_ON_CDROM
6246:
6247: Binaries may not be placed on CD-ROM containing other binary packages, for
6248: which a distribution charge may be made. In this case, set this variable to
6249: ${RESTRICTED}.
6250:
6251: * NO_BIN_ON_FTP
6252:
6253: Binaries may not made available on the Internet without charge. In this
6254: case, set this variable to ${RESTRICTED}. If this variable is set, binary
6255: packages will not be included on ftp.NetBSD.org.
6256:
6257: * NO_SRC_ON_CDROM
6258:
6259: Distfiles may not be placed on CD-ROM, together with other distfiles, for
6260: which a fee may be charged. In this case, set this variable to $
6261: {RESTRICTED}.
6262:
6263: * NO_SRC_ON_FTP
6264:
6265: Distfiles may not made available via FTP at no charge. In this case, set
6266: this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
6267: will not be mirrored on ftp.NetBSD.org.
6268:
1.111 sevan 6269: Please note that packages will be removed from pkgsrc when the distfiles are
1.33 wiz 6270: not distributable and cannot be obtained for a period of one full quarter
1.111 sevan 6271: branch. Packages with manual/interactive fetch must have a maintainer and it is
6272: his/her responsibility to ensure this.
1.33 wiz 6273:
1.154 rillig 6274: 21.1.5. Handling dependencies
1.1 dsieger 6275:
1.175 gutterid 6276: Your package may depend on some other package being present, and there are
6277: various ways of expressing this dependency. pkgsrc supports the DEPENDS,
6278: BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS definitions, the USE_TOOLS
6279: definition, as well as dependencies via buildlink3.mk, which is the preferred
6280: way to handle dependencies, and which uses the variables named above. See
1.184 rillig 6281: Chapter 18, Buildlink methodology for more information.
1.175 gutterid 6282:
6283: The basic difference is that the DEPENDS definition registers that
6284: pre-requisite in the binary package so it will be pulled in when the binary
6285: package is later installed, whilst the BUILD_DEPENDS, TOOL_DEPENDS, and
6286: TEST_DEPENDS definitions do not, marking a dependency that is only needed for
1.184 rillig 6287: building or testing the resulting package. See also Chapter 14, Creating a new
1.175 gutterid 6288: pkgsrc package from scratch for more information.
6289:
6290: This means that if you only need a package present whilst you are building or
6291: testing, it should be noted as a TOOL_DEPENDS, BUILD_DEPENDS, or TEST_DEPENDS.
6292: When cross-compiling, TOOL_DEPENDS are native packages, i.e. packages for the
6293: architecture where the package is built; BUILD_DEPENDS are target packages,
6294: i.e., packages for the architecture for which the package is built.
1.1 dsieger 6295:
1.175 gutterid 6296: The format for a DEPENDS, BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS
6297: definition is:
1.1 dsieger 6298:
6299: <pre-req-package-name>:../../<category>/<pre-req-package>
6300:
6301: Please note that the "pre-req-package-name" may include any of the wildcard
6302: version numbers recognized by pkg_info(1).
6303:
1.55 wiz 6304: 1. If your package needs another package's binaries or libraries to build and
1.1 dsieger 6305: run, and if that package has a buildlink3.mk file available, use it:
6306:
6307: .include "../../graphics/jpeg/buildlink3.mk"
6308:
1.55 wiz 6309: 2. If your package needs another package's binaries or libraries only for
6310: building, and if that package has a buildlink3.mk file available, use it:
6311:
6312: .include "../../graphics/jpeg/buildlink3.mk"
6313:
6314: but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
6315: This case is rather rare.
6316:
6317: 3. If your package needs binaries from another package to build, use the
1.156 leot 6318: TOOL_DEPENDS definition:
6319:
6320: TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool
1.1 dsieger 6321:
1.156 leot 6322: 4. If your package needs static libraries to link against, header files to
6323: include, etc. from another package to build, use the BUILD_DEPENDS
6324: definition.
1.1 dsieger 6325:
1.156 leot 6326: 5. If your package needs a library with which to link and there is no
1.26 spz 6327: buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
6328: because the include files and libraries will be hidden from the compiler.
1.1 dsieger 6329:
1.156 leot 6330: 6. If your package needs some executable to be able to run correctly and if
1.26 spz 6331: there's no buildlink3.mk file, this is specified using the DEPENDS
6332: variable. The print/lyx package needs to be able to execute the latex
1.129 wiz 6333: binary from the tex-latex-bin package when it runs, and that is specified:
1.1 dsieger 6334:
1.129 wiz 6335: DEPENDS+= tex-latex-bin-[0-9]*:../../print/tex-latex-bin
1.1 dsieger 6336:
1.175 gutterid 6337: 7. If your package includes a test suite that has extra dependencies only
6338: required for this purpose (frequently this can be run as a "make test"
6339: target), use the TEST_DEPENDS variable.
6340:
6341: 8. You can use wildcards in package dependencies. Note that such wildcard
1.26 spz 6342: dependencies are retained when creating binary packages. The dependency is
6343: checked when installing the binary package and any package which matches
6344: the pattern will be used. Wildcard dependencies should be used with care.
1.1 dsieger 6345:
6346: The "-[0-9]*" should be used instead of "-*" to avoid potentially ambiguous
6347: matches such as "tk-postgresql" matching a "tk-*" DEPENDS.
6348:
6349: Wildcards can also be used to specify that a package will only build
6350: against a certain minimum version of a pre-requisite:
6351:
1.26 spz 6352: DEPENDS+= ImageMagick>=6.0:../../graphics/ImageMagick
1.1 dsieger 6353:
1.26 spz 6354: This means that the package will build using version 6.0 of ImageMagick or
6355: newer. Such a dependency may be warranted if, for example, the command line
6356: options of an executable have changed.
6357:
1.183 wiz 6358: If you need to depend on minimum versions of libraries, set
6359: BUILDLINK_API_DEPENDS.pkg to the appropriate pattern before including its
6360: buildlink3.mk file, e.g.
6361:
6362: BUILDLINK_API_DEPENDS.jpeg+= jpeg>=9.0
6363: .include "../../graphics/jpeg/buildlink3.mk"
1.1 dsieger 6364:
6365: For security fixes, please update the package vulnerabilities file. See
1.154 rillig 6366: Section 21.1.9, "Handling packages with security problems" for more
1.1 dsieger 6367: information.
6368:
6369: If your package needs files from another package to build, add the relevant
6370: distribution files to DISTFILES, so they will be extracted automatically. See
6371: the print/ghostscript package for an example. (It relies on the jpeg sources
6372: being present in source form during the build.)
6373:
1.154 rillig 6374: 21.1.6. Handling conflicts with other packages
1.1 dsieger 6375:
6376: Your package may conflict with other packages a user might already have
6377: installed on his system, e.g. if your package installs the same set of files as
1.80 wiz 6378: another package in the pkgsrc tree or has the same PKGNAME.
1.1 dsieger 6379:
1.142 leot 6380: For example, x11/libXaw3d and x11/Xaw-Xpm install the same shared library, thus
6381: you set in pkgsrc/x11/libXaw3d/Makefile:
1.1 dsieger 6382:
1.142 leot 6383: CONFLICTS= Xaw-Xpm-[0-9]*
1.1 dsieger 6384:
6385:
1.142 leot 6386: and in pkgsrc/x11/Xaw-Xpm/Makefile:
1.1 dsieger 6387:
1.142 leot 6388: CONFLICTS= libXaw3d-[0-9]*
1.1 dsieger 6389:
1.142 leot 6390:
6391: pkg_add(1) is able to detect attempts to install packages that conflict with
6392: existing packages and abort. However, in many situations this is too late in
6393: the process. Binary package managers will not know about the conflict until
6394: they attempt to install the package after already downloading it and all its
6395: dependencies. Users may also waste time building a package and its dependencies
6396: only to find out at the end that it conflicts with another package they have
6397: installed.
6398:
6399: To avoid these issues CONFLICTS entries should be added in all cases where it
6400: is known that packages conflict with each other. These CONFLICTS entries are
6401: exported in pkg_summary(5) files and consumed by binary package managers to
6402: inform users that packages cannot be installed onto the target system.
1.1 dsieger 6403:
1.154 rillig 6404: 21.1.7. Packages that cannot or should not be built
1.1 dsieger 6405:
6406: There are several reasons why a package might be instructed to not build under
6407: certain circumstances. If the package builds and runs on most platforms, the
1.83 dholland 6408: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
6409: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
6410: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
6411: (OS-version-platform) that can use glob-style wildcards.
6412:
1.114 maya 6413: If a package is not appropriate for some platforms (as opposed to merely
1.83 dholland 6414: broken), a different set of variables should be used as this affects failure
6415: reporting and statistics. If the package is appropriate for most platforms, the
6416: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
6417: for only a small handful of platforms (often exactly one), set
6418: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
6419: triples (OS-version-platform) that can use glob-style wildcards.
1.1 dsieger 6420:
6421: Some packages are tightly bound to a specific version of an operating system,
6422: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
6423: with other versions of the OS, and should be uploaded to a version specific
6424: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
6425: to "yes". This variable is not currently used by any of the package system
6426: internals, but may be used in the future.
6427:
6428: If the package should be skipped (for example, because it provides
6429: functionality already provided by the system), set PKG_SKIP_REASON to a
6430: descriptive message. If the package should fail because some preconditions are
6431: not met, set PKG_FAIL_REASON to a descriptive message.
6432:
1.154 rillig 6433: 21.1.8. Packages which should not be deleted, once installed
1.1 dsieger 6434:
6435: To ensure that a package may not be deleted, once it has been installed, the
6436: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.25 wiz 6437: carried into any binary package that is made from this pkgsrc entry. A "
6438: preserved" package will not be deleted using pkg_delete(1) unless the "-f"
1.1 dsieger 6439: option is used.
6440:
1.154 rillig 6441: 21.1.9. Handling packages with security problems
1.1 dsieger 6442:
6443: When a vulnerability is found, this should be noted in localsrc/security/
1.205 wiz 6444: advisories/pkg-vulnerabilities. Entries in that file consist of three parts:
6445:
6446: * package version pattern
6447:
6448: * type of vulnerability (please cut'n'paste an existing one where possible)
6449:
6450: * URL providing additional information about the issue
6451:
6452: For the package version pattern please always use `<' to mark an upper bound
6453: (not `<='!). This will avoid possible problems due unrelated PKGREVISION bumps
6454: not related to security fixes. Lower bounds can be added too, using '>' or '>=
1.206 wiz 6455: '. For example, "foo>=1<1.2" would mark versions 1.0 (included) to 1.2
1.205 wiz 6456: (excluded) of "foo" as affected by the security issue.
6457:
6458: Entries should always be added at the bottom of the file.
6459:
6460: When fixing packages, please modify the upper bound of the corresponding entry.
6461: To continue the previous example, if a fix was backported to version 1.1nb2,
1.206 wiz 6462: change the previous pattern to "foo>=1<1.1nb2".
1.205 wiz 6463:
6464: To locally test a package version pattern against a PKGNAME you can use the
6465: pkg_admin pmatch command.
6466:
6467: The URL should be as permanent as possible and provide as much information
6468: about the issue as possible. CVE entries are preferred.
6469:
6470: After committing that file, ask pkgsrc-security@NetBSD.org to update the file
6471: on ftp.NetBSD.org.
1.1 dsieger 6472:
6473: After fixing the vulnerability by a patch, its PKGREVISION should be increased
6474: (this is of course not necessary if the problem is fixed by using a newer
1.32 wiz 6475: release of the software), and the pattern in the pkg-vulnerabilities file must
6476: be updated.
1.1 dsieger 6477:
6478: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
6479: submit a pullup request!
6480:
6481: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
6482: a weekly cron job.
6483:
1.205 wiz 6484: In case a security issue is disputed, please contact
6485: pkgsrc-security@NetBSD.org.
6486:
1.154 rillig 6487: 21.1.10. How to handle incrementing versions when fixing an existing package
1.1 dsieger 6488:
6489: When making fixes to an existing package it can be useful to change the version
6490: number in PKGNAME. To avoid conflicting with future versions by the original
6491: author, a "nb1", "nb2", ... suffix can be used on package versions by setting
6492: PKGREVISION=1 (2, ...). The "nb" is treated like a "." by the package tools.
6493: e.g.
6494:
6495: DISTNAME= foo-17.42
6496: PKGREVISION= 9
6497:
6498: will result in a PKGNAME of "foo-17.42nb9". If you want to use the original
6499: value of PKGNAME without the "nbX" suffix, e.g. for setting DIST_SUBDIR, use
6500: PKGNAME_NOREV.
6501:
6502: When a new release of the package is released, the PKGREVISION should be
6503: removed, e.g. on a new minor release of the above package, things should be
6504: like:
6505:
6506: DISTNAME= foo-17.43
6507:
6508: PKGREVISION should be incremented for any non-trivial change in the resulting
6509: binary package. Without a PKGREVISION bump, someone with the previous version
6510: installed has no way of knowing that their package is out of date. Thus,
6511: changes without increasing PKGREVISION are essentially labeled "this is so
6512: trivial that no reasonable person would want to upgrade", and this is the rough
6513: test for when increasing PKGREVISION is appropriate. Examples of changes that
6514: do not merit increasing PKGREVISION are:
6515:
1.14 jmcneill 6516: * Changing HOMEPAGE, MAINTAINER, OWNER, or comments in Makefile.
1.1 dsieger 6517:
6518: * Changing build variables if the resulting binary package is the same.
6519:
6520: * Changing DESCR.
6521:
6522: * Adding PKG_OPTIONS if the default options don't change.
6523:
6524: Examples of changes that do merit an increase to PKGREVISION include:
6525:
6526: * Security fixes
6527:
6528: * Changes or additions to a patch file
6529:
6530: * Changes to the PLIST
6531:
1.12 weinem 6532: * A dependency is changed or renamed.
6533:
1.1 dsieger 6534: PKGREVISION must also be incremented when dependencies have ABI changes.
6535:
1.154 rillig 6536: 21.1.11. Substituting variable text in the package files (the SUBST framework)
1.1 dsieger 6537:
1.180 rillig 6538: When you want to replace the same text in multiple files, or multiple times in
6539: the same file, it is cumbersome to maintain a patch file for this. This is
6540: where the SUBST framework steps in. It provides an easy-to-use interface for
6541: replacing text in files. It just needs the following information:
1.172 rillig 6542:
1.180 rillig 6543: * In which phase of the package build cycle should the replacement happen?
1.172 rillig 6544:
1.180 rillig 6545: * In which files should the replacement happen?
1.172 rillig 6546:
6547: * Which text should be replaced with what?
6548:
1.180 rillig 6549: This information is encoded in a block of SUBST variables. A minimal example
6550: is:
6551:
6552: SUBST_CLASSES+= paths
6553: SUBST_STAGE.paths= pre-configure
6554: SUBST_FILES.paths= src/*.c
6555: SUBST_SED.paths= -e 's,/usr/local,${PREFIX},g'
6556:
6557: Translated into English, it means: In the pre-configure stage (that is, after
6558: applying the patches from the patches/ directory and before running the
6559: configure script and the portability check), replace the text /usr/local with
6560: the content of the variable PREFIX.
6561:
6562: Each SUBST block starts by appending an identifier to SUBST_CLASSES (note the +
6563: =). This identifier can be chosen freely by the package. If there should ever
6564: be duplicate identifiers, the pkgsrc infrastructure will catch this and fail
6565: early, so don't worry about name collisions.
6566:
6567: Except for SUBST_CLASSES, all variables in a SUBST block are parameterized
6568: using this identifier. In the remainder of this section, these parameterized
6569: variables are written as SUBST_STAGE.*.
6570:
6571: SUBST_CLASSES+= paths
6572: SUBST_STAGE.paths= pre-configure
6573: SUBST_MESSAGE.paths= Fixing absolute paths.
6574: SUBST_FILES.paths= src/*.c
6575: SUBST_FILES.paths+= scripts/*.sh
6576: SUBST_SED.paths= -e 's,"/usr/local,"${PREFIX},g'
6577: SUBST_SED.paths+= -e 's,"/var/log,"${VARBASE}/log,g'
6578: SUBST_VARS.paths= LOCALBASE PREFIX PKGVERSION
6579:
6580: To get a complete picture about the SUBST substitutions, run bmake
6581: show-all-subst. If something doesn't work as expected, run pkglint on the
6582: package, which detects several typical mistakes surrounding the SUBST blocks.
6583: For any questions that might remain after this, have a look at mk/subst.mk.
6584:
6585: 21.1.11.1. Choosing the time where the substitutions happen
6586:
6587: The SUBST_STAGE.* is one of {pre,do,post}-
6588: {extract,patch,configure,build,test,install}. Of these, pre-configure is used
6589: most often, by far. The most popular stages are, in chronological order:
6590:
6591: post-extract
6592:
6593: The substitutions are applied immediately after the distfiles are
6594: extracted. Running bmake extract on the package will leave no traces of the
6595: original files.
6596:
6597: When the substitution applies to files for which there is also a patch in
6598: the patches/ directory, this means that the patches will be computed based
6599: on the result of the substitution. When these patches are sent to the
6600: upstream maintainer later, to be fixed in the upstream package, these
6601: patches may no longer match what the upstream author is used to. Because of
6602: this, pre-configure is often a better choice.
6603:
6604: pre-configure
6605:
6606: The substitutions are applied after the patches from the patches/
6607: directory. This makes it possible to run bmake patch on the package, after
6608: which the patches can be edited using the tools pkgvi and mkpatches from
6609: the pkgtools/pkgdiff package.
6610:
6611: When updating the patches, it is helpful to explicitly separate the bmake
6612: patch from the bmake configure, and to only edit the patches between these
6613: commands. Otherwise the substitutions from the SUBST block will end up in
6614: the patch file. When this happens in really obvious ways, pkglint will
6615: complain about patches that contain a hard-coded /usr/pkg instead of the
6616: correct and intended @PREFIX@, but it can only detect these really obvious
6617: cases.
6618:
6619: do-configure
6620:
6621: This stage should only be used if the package defines a pre-configure
6622: action itself, and the substitution must happen after that. Typical
6623: examples are packages that use the pre-configure stage to regenerate the
6624: GNU configure script from configure.ac.
6625:
6626: post-configure
6627:
6628: This stage is used to fix up any mistakes by the configure stage.
6629:
6630: pre-build
6631:
6632: This stage should only be used for substitutions that are clearly related
6633: to building the package, not for fixing the configuration. Substitutions
6634: for pathnames (such as replacing /usr/local with ${PREFIX}) or user names
6635: (such as replacing @MY_USER@ with the actual username) belong in
6636: pre-configure or post-configure instead.
6637:
6638: post-build
6639:
6640: Just as with pre-build, this stage should only be used for substitutions
6641: that are clearly related to building the package, not for fixing the
6642: configuration. Substitutions for pathnames (such as replacing /usr/local
6643: with ${PREFIX}) or user names (such as replacing @MY_USER@ with the actual
6644: username) belong in pre-configure or post-configure instead.
6645:
6646: A typical use is to update pkg-config files to include the rpath compiler
6647: options.
6648:
6649: pre-install
6650:
6651: In general, the install phase should be as simple as possible. As with the
6652: pre-build and post-build stages, it should not be used to fix pathnames or
6653: user names, these belong in pre-configure instead. There are only few
6654: legitimate use cases for applying substitutions in this stage.
6655:
1.181 rillig 6656: 21.1.11.2. Choosing the files where the substitutions happen
1.180 rillig 6657:
6658: The SUBST_FILES.* variable contains a list of filename patterns. These patterns
6659: are relative to WRKSRC since that is where most substitutions happen. A typical
6660: example is:
6661:
6662: SUBST_FILES.path= Makefile */Makefile */*/Makefile *.[ch]
6663:
6664: The above patterns, especially the last, are quite broad. The SUBST
6665: implementation checks that each filename pattern that is mentioned here has an
6666: effect. For example, if none of the */*/Makefile files contains the patterns to
6667: be found and substituted, that filename pattern is redundant and should be left
1.181 rillig 6668: out. By default, the SUBST framework will complain with an error message. If
6669: the text to be substituted occurs in some of the files from a single pattern,
6670: but not in all of them, that is totally ok, and the SUBST framework will only
6671: print an INFO message for those files.
1.180 rillig 6672:
6673: If there is a good reason for having redundant filename patterns, set
1.181 rillig 6674: SUBST_NOOP_OK.* to yes.
1.180 rillig 6675:
6676: Another popular way of choosing the files for the substitutions is via a shell
6677: command, like this:
6678:
1.181 rillig 6679: C_FILES_CMD= cd ${WRKSRC} && ${FIND} . -name '*.c'
1.180 rillig 6680: SUBST_FILES.path= ${C_FILES_CMD:sh}
6681:
6682: The variable name C_FILES_CMD in this example is freely chosen and independent
6683: of the SUBST framework.
6684:
6685: In this variant, the SUBST_FILES.* variable lists each file individually.
6686: Thereby chances are higher that there are filename patterns in which no
6687: substitution happens. Since the SUBST framework cannot know whether the
6688: filename patterns in SUBST_FILES.* have been explicitly listed in the Makefile
6689: (where any redundant filename pattern would be suspicious) or been generated by
6690: a shell command (in which redundant filename patterns are more likely and to be
6691: expected), it will complain about these redundant filename patterns. Therefore,
6692: SUBST blocks that use a shell command to generate the list of filename patterns
6693: often need to set SUBST_NOOP_OK.* to yes.
6694:
6695: 21.1.11.3. Choosing what to substitute
6696:
6697: In most cases, the substitutions are given using one or more sed(1) commands,
6698: like this:
6699:
6700: SUBST_SED.path= -e 's|/usr/local|${PREFIX}|g'
6701:
6702: Each of the sed commands needs to be preceded by the -e option and should be
6703: specified on a line of its own, to avoid hiding short sed commands at the end
6704: of a line.
6705:
6706: Since the sed commands often contain shell metacharacters as the separator (the
6707: | in the above example), it is common to enclose them in single quotes.
6708:
6709: A common substitution is to replace placeholders of the form @VARNAME@ with
6710: their pkgsrc counterpart variable ${VARNAME}. A typical example is:
6711:
6712: SUBST_VARS.path= PREFIX
6713:
1.181 rillig 6714: This type of substitutions is typically done by the GNU configure scripts
6715: during the do-configure stage, but in some cases these need to be overridden.
6716: The same pattern is also used when a package defines patches that replace
6717: previously hard-coded paths like /usr/local with a @PREFIX@ placeholder first,
6718: which then gets substituted by the actual ${PREFIX} in the pre-configure stage.
6719: In many of these cases, it works equally well to just use the SUBST framework
6720: to directly replace /usr/local with ${PREFIX}, thereby omitting the
6721: intermediate patch file.
1.180 rillig 6722:
6723: If the above is not flexible enough, it is possible to not use sed at all for
6724: the substitution but to specify an entirely different command, like this:
6725:
6726: SUBST_FILTER_CMD.path= LC_ALL=C ${TR} -d '\r'
1.1 dsieger 6727:
1.180 rillig 6728: This is used for the few remaining packages in which the distributed files use
6729: Windows-style line endings that need to be converted to UNIX-style line
6730: endings.
1.1 dsieger 6731:
1.180 rillig 6732: 21.1.11.4. Other SUBST variables
1.172 rillig 6733:
1.180 rillig 6734: When a SUBST block is applied during a package build, a message is logged. The
6735: default message is fine for most purposes but can be overridden by setting
6736: SUBST_MESSAGE.* to an individual message.
1.1 dsieger 6737:
1.154 rillig 6738: 21.2. The fetch phase
1.1 dsieger 6739:
1.154 rillig 6740: 21.2.1. Packages whose distfiles aren't available for plain downloading
1.1 dsieger 6741:
6742: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
6743: a make fetch will call files/getsite.sh with the name of each file to download
6744: as an argument, expecting it to output the URL of the directory from which to
6745: download it. graphics/ns-cult3d is an example of this usage.
6746:
6747: If the download can't be automated, because the user must submit personal
6748: information to apply for a password, or must pay for the source, or whatever,
6749: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
6750: before aborting the build. Example:
6751:
6752: FETCH_MESSAGE= "Please download the files"
6753: FETCH_MESSAGE+= " "${DISTFILES:Q}
6754: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
6755:
1.154 rillig 6756: 21.2.2. How to handle modified distfiles with the 'old' name
1.1 dsieger 6757:
6758: Sometimes authors of a software package make some modifications after the
6759: software was released, and they put up a new distfile without changing the
6760: package's version number. If a package is already in pkgsrc at that time, the
6761: checksum will no longer match. The contents of the new distfile should be
6762: compared against the old one before changing anything, to make sure the
6763: distfile was really updated on purpose, and that no trojan horse or so crept
6764: in. Please mention that the distfiles were compared and what was found in your
1.54 rodent 6765: commit message.
6766:
6767: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109 wiz 6768: directory name, usually based on PKGNAME_NOREV (but take care with python or
6769: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
6770: PATCHFILES for this package will be put in that subdirectory of the local
1.154 rillig 6771: distfiles directory. (See Section 21.1.10, "How to handle incrementing versions
1.109 wiz 6772: when fixing an existing package" for more details.) In case this happens more
6773: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
6774: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54 rodent 6775:
6776: DIST_SUBDIR is also used when a distfile's name does not contain a version and
6777: the distfile is apt to change. In cases where the likelihood of this is very
6778: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
6779: removed unless the distfile name changes, even if a package is being moved or
6780: renamed.
6781:
6782: Do not forget regenerating the distinfo file after that, since it contains the
6783: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
6784: installed package is different. Furthermore, a mail to the package's authors
6785: seems appropriate telling them that changing distfiles after releases without
6786: changing the file names is not good practice.
1.1 dsieger 6787:
1.154 rillig 6788: 21.2.3. Packages hosted on github.com
1.88 tnn 6789:
1.90 tnn 6790: Helper methods exist for packages hosted on github.com which will often have
6791: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
6792: of the three recipes from below:
1.88 tnn 6793:
1.154 rillig 6794: 21.2.3.1. Fetch based on a tagged release
1.88 tnn 6795:
1.189 bacon 6796: If your distfile URL looks similar to https://github.com/username/example/
6797: archive/v1.0.zip, then you are packaging a tagged release.
1.88 tnn 6798:
1.189 bacon 6799: DISTNAME= example-1.0
1.90 tnn 6800: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1.189 bacon 6801: #GITHUB_PROJECT= example # can be omitted if same as DISTNAME
1.90 tnn 6802: GITHUB_TAG= v${PKGVERSION_NOREV}
1.88 tnn 6803: EXTRACT_SUFX= .zip
6804:
1.189 bacon 6805: 21.2.3.2. Fetch based on a specific commit before the first release
6806:
6807: If your distfile looks similar to https://github.com/username/example/archive/
6808: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit before the first
6809: release, then set the package version to 0.0.0.N, where N is the number of
6810: commits to the repository, and set GITHUB_TAG to the commit hash. This will
6811: (almost) ensure that the first tagged release will have a version greater than
6812: this one so that package upgrades will function properly.
6813:
6814: DISTNAME= example-0.0.0.347
6815: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
6816: #GITHUB_PROJECT= example # can be omitted if same as DISTNAME
6817: GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
6818:
6819: 21.2.3.3. Fetch based on a specific commit after a release
1.88 tnn 6820:
1.189 bacon 6821: If your distfile looks similar to https://github.com/username/example/archive/
6822: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit after a release,
6823: then include the last release version and the commit count since that release
6824: in the package version and set GITHUB_TAG to the commit hash. The latest
6825: release and commit count are shown in the output of "git describe --tags":
6826:
6827: # git clone https://github.com/username/example
6828: # cd example
6829: # git describe --tags
6830: 1.2.3-5-g988881a
1.88 tnn 6831:
1.189 bacon 6832: DISTNAME= example-1.2.3.5
6833: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
6834: #GITHUB_PROJECT= example # can be omitted if same as DISTNAME
1.90 tnn 6835: GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88 tnn 6836:
1.189 bacon 6837: 21.2.3.4. Fetch based on release
1.88 tnn 6838:
1.189 bacon 6839: If your distfile URL looks similar to https://github.com/username/example/
6840: releases/download/rel-1.6/offensive-1.6.zip, then you are packaging a release.
1.88 tnn 6841:
1.90 tnn 6842: DISTNAME= offensive-1.6
1.88 tnn 6843: PKGNAME= ${DISTNAME:S/offensive/proper/}
1.90 tnn 6844: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
1.189 bacon 6845: GITHUB_PROJECT= example
1.90 tnn 6846: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
6847: EXTRACT_SUFX= .zip
1.88 tnn 6848:
1.154 rillig 6849: 21.3. The configure phase
1.1 dsieger 6850:
1.154 rillig 6851: 21.3.1. Shared libraries - libtool
1.1 dsieger 6852:
6853: pkgsrc supports many different machines, with different object formats like
6854: a.out and ELF, and varying abilities to do shared library and dynamic loading
6855: at all. To accompany this, varying commands and options have to be passed to
6856: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
6857: especially if you don't have all the machines at your hand to test things. The
6858: devel/libtool pkg can help here, as it just "knows" how to build both static
6859: and dynamic libraries from a set of source files, thus being
6860: platform-independent.
6861:
6862: Here's how to use libtool in a package in seven simple steps:
6863:
6864: 1. Add USE_LIBTOOL=yes to the package Makefile.
6865:
6866: 2. For library objects, use "${LIBTOOL} --mode=compile ${CC}" in place of "$
6867: {CC}". You could even add it to the definition of CC, if only libraries are
6868: being built in a given Makefile. This one command will build both PIC and
6869: non-PIC library objects, so you need not have separate shared and
6870: non-shared library rules.
6871:
6872: 3. For the linking of the library, remove any "ar", "ranlib", and "ld
6873: -Bshareable" commands, and instead use:
6874:
6875: ${LIBTOOL} --mode=link \
6876: ${CC} -o ${.TARGET:.a=.la} \
6877: ${OBJS:.o=.lo} \
6878: -rpath ${PREFIX}/lib \
6879: -version-info major:minor
6880:
6881: Note that the library is changed to have a .la extension, and the objects
6882: are changed to have a .lo extension. Change OBJS as necessary. This
6883: automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
6884: necessary) in the build directory. Be sure to include "-version-info",
6885: especially when major and minor are zero, as libtool will otherwise strip
6886: off the shared library version.
6887:
6888: From the libtool manual:
6889:
6890: So, libtool library versions are described by three integers:
6891:
6892: CURRENT
6893: The most recent interface number that this library implements.
6894:
6895: REVISION
6896: The implementation number of the CURRENT interface.
6897:
6898: AGE
6899: The difference between the newest and oldest interfaces that
6900: this library implements. In other words, the library implements
6901: all the interface numbers in the range from number `CURRENT -
6902: AGE' to `CURRENT'.
6903:
6904: If two libraries have identical CURRENT and AGE numbers, then the
6905: dynamic linker chooses the library with the greater REVISION number.
6906:
6907: The "-release" option will produce different results for a.out and ELF
1.25 wiz 6908: (excluding symlinks) in only one case. An ELF library of the form "
6909: libfoo-release.so.x.y" will have a symlink of "libfoo.so.x.y" on an a.out
1.1 dsieger 6910: platform. This is handled automatically.
6911:
6912: The "-rpath argument" is the install directory of the library being built.
6913:
6914: In the PLIST, include only the .la file, the other files will be added
6915: automatically.
6916:
6917: 4. When linking shared object (.so) files, i.e. files that are loaded via
6918: dlopen(3), NOT shared libraries, use "-module -avoid-version" to prevent
6919: them getting version tacked on.
6920:
6921: The PLIST file gets the foo.so entry.
6922:
6923: 5. When linking programs that depend on these libraries before they are
6924: installed, preface the cc(1) or ld(1) line with "${LIBTOOL} --mode=link",
6925: and it will find the correct libraries (static or shared), but please be
6926: aware that libtool will not allow you to specify a relative path in -L
6927: (such as "-L../somelib"), because it expects you to change that argument to
6928: be the .la file. e.g.
6929:
6930: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
6931:
6932: should be changed to:
6933:
6934: ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
6935:
6936: and it will do the right thing with the libraries.
6937:
6938: 6. When installing libraries, preface the install(1) or cp(1) command with "$
6939: {LIBTOOL} --mode=install", and change the library name to .la. e.g.
6940:
1.23 jakllsch 6941: ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1 dsieger 6942:
6943: This will install the static .a, shared library, any needed symlinks, and
6944: run ldconfig(8).
6945:
6946: 7. In your PLIST, include only the .la file (this is a change from previous
6947: behaviour).
6948:
1.154 rillig 6949: 21.3.2. Using libtool on GNU packages that already support libtool
1.1 dsieger 6950:
6951: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
6952: own libtool in most cases. For older libtool using packages, libtool is made by
6953: ltconfig script during the do-configure step; you can check the libtool script
6954: location by doing make configure; find work*/ -name libtool.
6955:
6956: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
6957: override. By default, it is set to "libtool */libtool */*/libtool". If this
6958: does not match the location of the package's libtool script(s), set it as
6959: appropriate.
6960:
6961: If you do not need *.a static libraries built and installed, then use
6962: SHLIBTOOL_OVERRIDE instead.
6963:
6964: If your package makes use of the platform-independent library for loading
6965: dynamic shared objects, that comes with libtool (libltdl), you should include
6966: devel/libltdl/buildlink3.mk.
6967:
6968: Some packages use libtool incorrectly so that the package may not work or build
6969: in some circumstances. Some of the more common errors are:
6970:
6971: * The inclusion of a shared object (-module) as a dependent library in an
6972: executable or library. This in itself isn't a problem if one of two things
6973: has been done:
6974:
6975: 1. The shared object is named correctly, i.e. libfoo.la, not foo.la
6976:
6977: 2. The -dlopen option is used when linking an executable.
6978:
6979: * The use of libltdl without the correct calls to initialisation routines.
6980: The function lt_dlinit() should be called and the macro
6981: LTDL_SET_PRELOADED_SYMBOLS included in executables.
6982:
1.154 rillig 6983: 21.3.3. GNU Autoconf/Automake
1.1 dsieger 6984:
6985: If a package needs GNU autoconf or automake to be executed to regenerate the
6986: configure script and Makefile.in makefile templates, then they should be
6987: executed in a pre-configure target.
6988:
6989: For packages that need only autoconf:
6990:
6991: AUTOCONF_REQD= 2.50 # if default version is not good enough
6992: USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
6993: ...
6994:
6995: pre-configure:
6996: cd ${WRKSRC} && autoconf
6997:
6998: ...
6999:
7000: and for packages that need automake and autoconf:
7001:
7002: AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
7003: USE_TOOLS+= automake # use "automake14" for automake-1.4
7004: ...
7005:
7006: pre-configure:
7007: set -e; cd ${WRKSRC}; \
7008: aclocal; autoheader; automake -a --foreign -i; autoconf
7009:
7010: ...
7011:
7012: Packages which use GNU Automake will almost certainly require GNU Make.
7013:
7014: There are times when the configure process makes additional changes to the
7015: generated files, which then causes the build process to try to re-execute the
7016: automake sequence. This is prevented by touching various files in the configure
7017: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
7018: NO in the package Makefile.
7019:
1.154 rillig 7020: 21.4. Programming languages
1.1 dsieger 7021:
1.154 rillig 7022: 21.4.1. C, C++, and Fortran
1.1 dsieger 7023:
7024: Compilers for the C, C++, and Fortran languages comes with the NetBSD base
7025: system. By default, pkgsrc assumes that a package is written in C and will hide
1.184 rillig 7026: all other compilers (via the wrapper framework, see Chapter 18, Buildlink
1.1 dsieger 7027: methodology).
7028:
7029: To declare which language's compiler a package needs, set the USE_LANGUAGES
1.212 wiz 7030: variable. Allowed values currently are:
7031:
7032: c99, c++, c++03, gnu++03, c++0x, gnu++0x, c++11, gnu++11,
7033: c++14, gnu++14, c++17, gnu++17, c++20, gnu++20, fortran,
7034: fortran77, java, objc, obj-c++, and ada.
7035:
7036:
7037: (and any combination). The default is "c". Packages using GNU configure
7038: scripts, even if written in C++, usually need a C compiler for the configure
7039: phase.
1.1 dsieger 7040:
1.154 rillig 7041: 21.4.2. Java
1.1 dsieger 7042:
7043: If a program is written in Java, use the Java framework in pkgsrc. The package
7044: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
7045: variables:
7046:
7047: * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
7048: set to "run", then there is only a runtime dependency on the JDK. The
7049: default is "yes", which also adds a build dependency on the JDK.
7050:
7051: * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
7052: supported values are "yes", "1.4", and "1.5". "yes" accepts any Java2
7053: implementation, "1.4" insists on versions 1.4 or above, and "1.5" only
7054: accepts versions 1.5 or above. This variable is not set by default.
7055:
1.25 wiz 7056: * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
7057: implementation dependency. It may be used to set JAVA_HOME to a good value
7058: if the program needs this variable to be defined.
7059:
1.205 wiz 7060: 21.4.3. Go
7061:
7062: If a program is written in Go and has any dependencies on other Go modules,
7063: have the package include ../../lang/go/go-module.mk.
7064:
7065: 1. Generate a list of those dependencies with make clean && make patch && make
7066: show-go-modules > go-modules.mk.
7067:
7068: 2. Prepend
7069:
7070: .include
7071: "go-modules.mk"
7072:
7073: to any other
7074:
7075: .include
7076:
7077: s.
7078:
7079: 3. Incorporate these modules in distinfo with make makesum.
7080:
7081: 21.4.4. Packages containing Perl scripts
1.1 dsieger 7082:
1.203 nia 7083: If your package contains interpreted Perl scripts, add "perl" to the USE_TOOLS
1.1 dsieger 7084: variable and set REPLACE_PERL to ensure that the proper interpreter path is
7085: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74 wiz 7086: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
1.210 gutterid 7087: replaced with the full path to the Perl executable.
1.1 dsieger 7088:
1.210 gutterid 7089: If a particular version of Perl is needed, set the PERL5_REQD variable to the
1.1 dsieger 7090: version number. The default is "5.0".
7091:
1.203 nia 7092: See Section 21.6.6, "Packages installing Perl modules" for information about
1.210 gutterid 7093: handling Perl modules.
7094:
7095: There is also the REPLACE_PERL6 variable for the language now known as Raku.
1.1 dsieger 7096:
1.205 wiz 7097: 21.4.5. Packages containing shell scripts
1.41 wiz 7098:
7099: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
1.195 gutterid 7100: shell hash bangs in files. Please use the appropriate one, preferring
7101: REPLACE_SH in case this shell is sufficient. Each should contain a list of
7102: scripts, relative to WRKSRC, that you want adjusted. Every occurrence of the
7103: matching shell in a she-bang line will be replaced with the full path to the
7104: shell executable. When using REPLACE_BASH, don't forget to add bash to
7105: USE_TOOLS.
1.41 wiz 7106:
1.205 wiz 7107: 21.4.6. Other programming languages
1.1 dsieger 7108:
1.210 gutterid 7109: There are further similar REPLACE variables available, e.g., REPLACE_AWK for
7110: packages containing awk scripts, and REPLACE_R for R. These two, like the
1.211 gutterid 7111: others noted above, have their actions defined centrally in mk/configure/
7112: replace-interpreter.mk. Other languages define the actions of these variables
7113: within their own dedicated part of the tree, e.g., REPLACE_PHP is actioned in
7114: lang/php/phpversion.mk, and REPLACE_PYTHON is actioned in lang/python/
7115: application.mk. For other languages, consult the mk files found within their
1.216 gutterid 7116: specific directories (the naming convention varies), or check the list found in
7117: Appendix E, Help topics.
1.210 gutterid 7118:
7119: Currently, special handling for other languages varies in pkgsrc. If a compiler
7120: package provides a buildlink3.mk file, include that, otherwise just add a
7121: (build) dependency on the appropriate compiler package.
1.1 dsieger 7122:
1.154 rillig 7123: 21.5. The build phase
1.1 dsieger 7124:
7125: The most common failures when building a package are that some platforms do not
7126: provide certain header files, functions or libraries, or they provide the
7127: functions in a library that the original package author didn't know. To work
7128: around this, you can rewrite the source code in most cases so that it does not
7129: use the missing functions or provides a replacement function.
7130:
1.154 rillig 7131: 21.5.1. Compiling C and C++ code conditionally
1.1 dsieger 7132:
7133: If a package already comes with a GNU configure script, the preferred way to
7134: fix the build failure is to change the configure script, not the code. In the
7135: other cases, you can utilize the C preprocessor, which defines certain macros
7136: depending on the operating system and hardware architecture it compiles for.
7137: These macros can be queried using for example #if defined(__i386). Almost every
7138: operating system, hardware architecture and compiler has its own macro. For
7139: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
7140: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
7141: GCC.
7142:
7143: The list of the following macros for hardware and operating system depends on
7144: the compiler that is used. For example, if you want to conditionally compile
7145: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
7146: Use __sun instead.
7147:
1.154 rillig 7148: 21.5.1.1. C preprocessor macros to identify the operating system
1.1 dsieger 7149:
7150: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
7151: should use the following code.
7152:
7153: #include <sys/param.h>
7154: #if (defined(BSD) && BSD >= 199306)
7155: /* BSD-specific code goes here */
7156: #else
7157: /* non-BSD-specific code goes here */
7158: #endif
7159:
7160: If this distinction is not fine enough, you can also test for the following
7161: macros.
7162:
1.46 obache 7163: Cygwin __CYGWIN__
7164: DragonFly __DragonFly__
1.1 dsieger 7165: FreeBSD __FreeBSD__
1.46 obache 7166: Haiku __HAIKU__
1.1 dsieger 7167: Interix __INTERIX
7168: IRIX __sgi (TODO: get a definite source for this)
7169: Linux linux, __linux, __linux__
1.83 dholland 7170: Mac OS X __APPLE__
1.46 obache 7171: MirBSD __MirBSD__ (__OpenBSD__ is also defined)
7172: Minix3 __minix
1.1 dsieger 7173: NetBSD __NetBSD__
7174: OpenBSD __OpenBSD__
7175: Solaris sun, __sun
7176:
1.154 rillig 7177: 21.5.1.2. C preprocessor macros to identify the hardware architecture
1.1 dsieger 7178:
7179: i386 i386, __i386, __i386__
7180: MIPS __mips
7181: SPARC sparc, __sparc
7182:
1.154 rillig 7183: 21.5.1.3. C preprocessor macros to identify the compiler
1.1 dsieger 7184:
7185: GCC __GNUC__ (major version), __GNUC_MINOR__
7186: MIPSpro _COMPILER_VERSION (0x741 for MIPSpro 7.41)
7187: SunPro __SUNPRO_C (0x570 for Sun C 5.7)
7188: SunPro C++ __SUNPRO_CC (0x580 for Sun C++ 5.8)
7189:
1.154 rillig 7190: 21.5.2. How to handle compiler bugs
1.1 dsieger 7191:
7192: Some source files trigger bugs in the compiler, based on combinations of
7193: compiler version and architecture and almost always relation to optimisation
7194: being enabled. Common symptoms are gcc internal errors or never finishing
7195: compiling a file.
7196:
7197: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87 tnn 7198: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
7199:
7200: This used to be a big problem in the past, but is rarely needed now as compiler
7201: technology has matured. If you still need to add a compiler specific
7202: workaround, please do so in the file hacks.mk and describe the symptom and
7203: compiler version as detailed as possible.
1.1 dsieger 7204:
1.172 rillig 7205: 21.5.3. No such file or directory
7206:
7207: Compilation sometimes fails with an error message like this:
7208:
7209: .../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
7210: fatal error: pango/pango.h: No such file or directory
7211:
7212: The proper way to fix this problem depends on the type of the header, which is
7213: described in the following sections.
7214:
7215: 21.5.3.1. Headers from other packages
7216:
7217: If the header name looks like it comes from a different package, that other
7218: package should be included via the buildlink3 framework.
7219:
7220: First, look whether the header is somewhere in the buildlink3 directory below
7221: WRKDIR. In the above case of the missing Pango header:
7222:
7223: $ find work/.buildlink/ -print | grep -F pango/pango.h
7224:
7225: In the case of Pango, the output is:
7226:
7227: work/.buildlink/include/pango-1.0/pango/pango.h
7228:
7229: If the pango/pango.h file were placed directly in the .buildlink directory, it
7230: would have been found automatically. There is an extra pango-1.0 path component
7231: though, which means that the compiler command line must contain an option of
7232: the form -I${BUILDLINK3_PREFIX.pango}/include/pango-1.0. In most cases this
7233: option is generated by the configure script, which can be examined using:
7234:
7235: $ $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
7236: -I/usr/pkg/include/pango-1.0
7237: -I/usr/pkg/include/pango-1.0
7238: -I/usr/pkg/include/pango-1.0
7239: -I/usr/pkg/include/pango-1.0
7240: -I/usr/pkg/include/pango-1.0
7241:
7242: This looks good. These options are transformed by the buildlink wrapper to
7243: refer to the correct path inside work/.buildlink.
7244:
7245: Since the compilation fails though, examine the compiler command lines in work
7246: /.work.log to see whether the -I option is included in the particular command
7247: line.
7248:
7249: To further analyze the situation, run bmake build-env, which sets up an
7250: interactive, realistic environment including all the pkgsrc wrapper commands
7251: and environment variables. From there, try to compile some simple example
7252: programs that use the header.
7253:
7254: 21.5.3.2. Headers generated during the build
7255:
7256: If the name of the header seems to come from the package itself, and if the
7257: build is run with parallel jobs, the package may have some undeclared
7258: dependencies between the .c and the .h files, and a C file is compiled before
7259: its required header is generated.
7260:
7261: To see whether the build runs with parallel jobs, run bmake show-all-build |
7262: grep JOBS. Its output looks like this:
7263:
7264: usr MAKE_JOBS= 7
7265: pkg MAKE_JOBS_SAFE # undefined
7266: def _MAKE_JOBS_N= 7
7267:
7268: In this case the pkgsrc user has asked pkgsrc to build packages with 7 jobs in
7269: parallel (MAKE_JOBS). The package could have disabled parallel builds by
7270: setting MAKE_JOBS_SAFE to no, but in this case it hasn't.
7271:
7272: To see whether the build failure is caused by parallel builds, first save the
7273: exact error message and a bit of context, maybe you need it later for reporting
7274: a bug. Next, run:
7275:
7276: MAKE_JOBS_SAFE=no bmake clean build
7277:
7278: If that succeeds, file a bug report against the pkgsrc package, including the
7279: exact error message and the contents of your mk.conf file.
7280:
1.173 rillig 7281: 21.5.3.3. Symlinks
7282:
7283: Pkgsrc does not work reliably if any of LOCALBASE, VARBASE or WRKDIR contains a
7284: symlink. Since 2019Q2, the pkgsrc bootstrap program prevents installing pkgsrc
7285: in symlink-based directories. Existing pkgsrc installations are not checked for
7286: symlinks though.
7287:
7288: The "No such file or directory" error messages are a typical symptom of
7289: symlinks, and it's quite difficult to find out that this is the actual cause.
7290:
7291: 21.5.3.4. Stale working directories
7292:
7293: When building a hierarchy of packages, it may happen that one package is built
7294: and then pkgsrc is updated. This situation can provoke various hard to diagnose
7295: build errors. To clean up the situation:
7296:
7297: $ (cd ../../ && test -f mk/bsd.pkg.mk && rm -rf */*/work)
7298:
7299: (The test for bsd.pkg.mk just prevents running this command in the wrong
7300: directory.)
7301:
7302: If you have set WRKOBJDIR in mk.conf, remove that directory as well.
7303:
7304: 21.5.3.5. Other possible reasons
7305:
7306: On platforms other than BSD, third-party packages are installed in /usr/
7307: include, together with the base system. This means that pkgsrc cannot
7308: distinguish between headers provided by the base system (which it needs) and
7309: headers from third-party packages (which are often included in pkgsrc as well).
7310: This can lead to subtle version mismatches.
7311:
7312: In pkgsrc installations that have been active for several years, it may happen
7313: that some files are manually deleted. To exclude this unlikely reason, run
7314: pkg_admin check.
7315:
7316: It may help to run pkg_admin rebuild-tree to check/fix dependencies.
7317:
7318: If all of the above doesn't help, see Chapter 2, Getting help for contact
7319: information. Be prepared to describe what you have tried so far and what any
7320: error messages were.
7321:
1.172 rillig 7322: 21.5.4. Undefined reference to "..."
1.1 dsieger 7323:
7324: This error message often means that a package did not link to a shared library
7325: it needs. The following functions are known to cause this error message over
7326: and over.
7327:
7328: +-----------------------------------------------------+
7329: | Function |Library |Affected platforms|
7330: |-------------------------+--------+------------------|
7331: |accept, bind, connect |-lsocket|Solaris |
7332: |-------------------------+--------+------------------|
7333: |crypt |-lcrypt |DragonFly, NetBSD |
7334: |-------------------------+--------+------------------|
7335: |dlopen, dlsym |-ldl |Linux |
7336: |-------------------------+--------+------------------|
7337: |gethost* |-lnsl |Solaris |
7338: |-------------------------+--------+------------------|
7339: |inet_aton |-lresolv|Solaris |
7340: |-------------------------+--------+------------------|
7341: |nanosleep, sem_*, timer_*|-lrt |Solaris |
7342: |-------------------------+--------+------------------|
7343: |openpty |-lutil |Linux |
7344: +-----------------------------------------------------+
7345:
7346: To fix these linker errors, it is often sufficient to say LIBS.OperatingSystem+
7347: = -lfoo to the package Makefile and then say bmake clean; bmake.
7348:
1.172 rillig 7349: 21.5.4.1. Special issue: The SunPro compiler
1.1 dsieger 7350:
7351: When you are using the SunPro compiler, there is another possibility. That
7352: compiler cannot handle the following code:
7353:
7354: extern int extern_func(int);
7355:
7356: static inline int
7357: inline_func(int x)
7358: {
7359: return extern_func(x);
7360: }
7361:
7362: int main(void)
7363: {
7364: return 0;
7365: }
7366:
7367: It generates the code for inline_func even if that function is never used. This
7368: code then refers to extern_func, which can usually not be resolved. To solve
7369: this problem you can try to tell the package to disable inlining of functions.
7370:
1.172 rillig 7371: 21.5.5. Running out of memory
1.1 dsieger 7372:
7373: Sometimes packages fail to build because the compiler runs into an operating
7374: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.94 wiz 7375: told to unlimit the resources. Currently, the allowed values are any
7376: combination of "cputime", "datasize", "memorysize", and "stacksize". Setting
7377: this variable is similar to running the shell builtin ulimit command to raise
7378: the maximum data segment size or maximum stack size of a process, respectively,
7379: to their hard limits.
1.1 dsieger 7380:
1.154 rillig 7381: 21.6. The install phase
1.1 dsieger 7382:
1.154 rillig 7383: 21.6.1. Creating needed directories
1.1 dsieger 7384:
7385: The BSD-compatible install supplied with some operating systems cannot create
7386: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
7387: like this:
7388:
7389: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
7390: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
7391:
7392: You can also just append "dir1 dir2" to the INSTALLATION_DIRS variable, which
7393: will automatically do the right thing.
7394:
1.154 rillig 7395: 21.6.2. Where to install documentation
1.1 dsieger 7396:
7397: In general, documentation should be installed into ${PREFIX}/share/doc/$
7398: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME} (the latter includes the version
7399: number of the package).
7400:
7401: Many modern packages using GNU autoconf allow to set the directory where HTML
7402: documentation is installed with the "--with-html-dir" option. Sometimes using
7403: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
7404: share/doc/html or other places.
7405:
7406: An exception to the above is that library API documentation generated with the
7407: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
7408: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
7409: can be recognized from files ending in .devhelp or .devhelp2. (It is also
7410: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
7411: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
7412: then, no additional subdirectory level is allowed in this case. This is usually
7413: achieved by using "--with-html-dir=${PREFIX}/share/doc". ${PREFIX}/share/
7414: gtk-doc is preferred though.)
7415:
1.154 rillig 7416: 21.6.3. Installing highscore files
1.1 dsieger 7417:
7418: Certain packages, most of them in the games category, install a score file that
7419: allows all users on the system to record their highscores. In order for this to
7420: work, the binaries need to be installed setgid and the score files owned by the
1.36 wiz 7421: appropriate group and/or owner (traditionally the "games" user/group). Set
7422: USE_GAMESGROUP to yes to support this. The following variables, documented in
7423: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100 leot 7424: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
7425: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
7426:
7427: An example that illustrates some of the variables described above is games/
7428: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
7429: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
7430: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
7431: to install setgid the game binary:
7432:
7433: USE_GAMESGROUP= yes
7434:
7435: BUILD_DEFS+= VARBASE
7436:
7437: OWN_DIRS_PERMS+= ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
7438: REQD_FILES_PERMS+= /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
7439: SPECIAL_PERMS+= ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
7440:
7441: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
7442: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
7443: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1 dsieger 7444:
1.14 jmcneill 7445: A package should therefore never hard code file ownership or access permissions
1.100 leot 7446: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
7447: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1 dsieger 7448:
1.154 rillig 7449: 21.6.4. Adding DESTDIR support to packages
1.4 rillig 7450:
1.14 jmcneill 7451: DESTDIR support means that a package installs into a staging directory, not the
7452: final location of the files. Then a binary package is created which can be used
7453: for installation as usual. There are two ways: Either the package must install
1.25 wiz 7454: as root ("destdir") or the package can install as non-root user ("user-destdir"
7455: ).
1.14 jmcneill 7456:
1.113 leot 7457: * PKG_DESTDIR_SUPPORT has to be set to "destdir" or "user-destdir". By
7458: default PKG_DESTDIR_SUPPORT is set to "user-destdir" to help catching more
7459: potential packaging problems. If bsd.prefs.mk is included in the Makefile,
7460: PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14 jmcneill 7461:
1.4 rillig 7462: * All installation operations have to be prefixed with ${DESTDIR}.
7463:
7464: * automake gets this DESTDIR mostly right automatically. Many manual rules
7465: and pre/post-install often are incorrect; fix them.
7466:
1.17 imil 7467: * If files are installed with special owner/group use SPECIAL_PERMS.
1.4 rillig 7468:
7469: * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
7470:
1.154 rillig 7471: 21.6.5. Packages with hardcoded paths to other interpreters
1.1 dsieger 7472:
7473: Your package may also contain scripts with hardcoded paths to other
1.203 nia 7474: interpreters besides (or as well as) Perl. To correct the full pathname to the
1.1 dsieger 7475: script interpreter, you need to set the following definitions in your Makefile
7476: (we shall use tclsh in this example):
7477:
7478: REPLACE_INTERPRETER+= tcl
7479: REPLACE.tcl.old= .*/bin/tclsh
7480: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
7481: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
7482: # relative to ${WRKSRC}, just as in REPLACE_PERL
7483:
7484: Note
7485:
7486: Before March 2006, these variables were called _REPLACE.* and _REPLACE_FILES.*.
7487:
1.203 nia 7488: 21.6.6. Packages installing Perl modules
1.1 dsieger 7489:
7490: Makefiles of packages providing perl5 modules should include the Makefile
7491: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
7492: standard perl configuration for such modules as well as various hooks to tune
7493: this configuration. See comments in this file for details.
7494:
7495: Perl5 modules will install into different places depending on the version of
7496: perl used during the build process. To address this, pkgsrc will append lines
7497: to the PLIST corresponding to the files listed in the installed .packlist file
7498: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48 wiz 7499: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
7500: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1 dsieger 7501:
1.48 wiz 7502: PERL5_PACKLIST= auto/Pg/.packlist
1.1 dsieger 7503:
1.48 wiz 7504: The perl5 config variables installarchlib, installscript, installvendorbin,
7505: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
7506: and installvendorman3dir represent those locations in which components of perl5
7507: modules may be installed, provided as variable with uppercase and prefixed with
7508: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
7509: have a packlist. These variables are also substituted for in the PLIST as
7510: uppercase prefixed with PERL5_SUB_.
1.1 dsieger 7511:
1.154 rillig 7512: 21.6.7. Packages installing info files
1.1 dsieger 7513:
7514: Some packages install info files or use the "makeinfo" or "install-info"
7515: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
7516: and DEINSTALL scripts will be generated to handle registration of the info
7517: files in the Info directory file. The "install-info" command used for the info
7518: files registration is either provided by the system, or by a special purpose
7519: package automatically added as dependency if needed.
7520:
7521: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
7522: located. PKGINFODIR defaults to "info" and can be overridden by the user.
7523:
7524: The info files for the package should be listed in the package PLIST; however
7525: any split info files need not be listed.
7526:
7527: A package which needs the "makeinfo" command at build time must add "makeinfo"
7528: to USE_TOOLS in its Makefile. If a minimum version of the "makeinfo" command is
7529: needed it should be noted with the TEXINFO_REQD variable in the package
7530: Makefile. By default, a minimum version of 3.12 is required. If the system does
7531: not provide a makeinfo command or if it does not match the required minimum, a
7532: build dependency on the devel/gtexinfo package will be added automatically.
7533:
7534: The build and installation process of the software provided by the package
7535: should not use the install-info command as the registration of info files is
1.25 wiz 7536: the task of the package INSTALL script, and it must use the appropriate
1.1 dsieger 7537: makeinfo command.
7538:
7539: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
7540: the install-info and makeinfo commands in a directory listed early in PATH.
7541:
7542: The script overriding install-info has no effect except the logging of a
7543: message. The script overriding makeinfo logs a message and according to the
7544: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
7545: error.
7546:
1.154 rillig 7547: 21.6.8. Packages installing man pages
1.1 dsieger 7548:
7549: All packages that install manual pages should install them into the same
7550: directory, so that there is one common place to look for them. In pkgsrc, this
7551: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.25 wiz 7552: packages. The default for PKGMANDIR is "man". Another often-used value is "
7553: share/man".
1.1 dsieger 7554:
7555: Note
7556:
7557: The support for a custom PKGMANDIR is far from complete.
7558:
7559: The PLIST files can just use man/ as the top level directory for the man page
7560: file entries, and the pkgsrc framework will convert as needed. In all other
7561: places, the correct PKGMANDIR must be used.
7562:
7563: Packages that are configured with GNU_CONFIGURE set as "yes", by default will
7564: use the ./configure --mandir switch to set where the man pages should be
7565: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
7566: {PKGMANDIR}.
7567:
7568: Packages that use GNU_CONFIGURE but do not use --mandir, can set
7569: CONFIGURE_HAS_MANDIR to "no". Or if the ./configure script uses a non-standard
7570: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
7571:
1.184 rillig 7572: See Section 19.5, "Man page compression" for information on installation of
1.1 dsieger 7573: compressed manual pages.
7574:
1.203 nia 7575: 21.6.9. Packages installing X11 fonts
1.1 dsieger 7576:
7577: If a package installs font files, you will need to rebuild the fonts database
7578: in the directory where they get installed at installation and deinstallation
7579: time. This can be automatically done by using the pkginstall framework.
7580:
7581: You can list the directories where fonts are installed in the FONTS_DIRS.type
7582: variables, where type can be one of "ttf", "type1" or "x11". Also make sure
7583: that the database file fonts.dir is not listed in the PLIST.
7584:
7585: Note that you should not create new directories for fonts; instead use the
7586: standard ones to avoid that the user needs to manually configure his X server
7587: to find them.
7588:
1.203 nia 7589: 21.6.10. Packages installing SGML or XML data
1.1 dsieger 7590:
7591: If a package installs SGML or XML data files that need to be registered in
7592: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
7593: extra steps:
7594:
7595: 1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
7596: care of registering those files in system-wide catalogs at installation and
7597: deinstallation time.
7598:
7599: 2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
7600: package.
7601:
7602: 3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
7603: package.
7604:
7605: 4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
7606: These come in groups of three strings; see xmlcatmgr(1) for more
7607: information (specifically, arguments recognized by the 'add' action). Note
7608: that you will normally not use this variable.
7609:
7610: 5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
7611: come in groups of three strings; see xmlcatmgr(1) for more information
7612: (specifically, arguments recognized by the 'add' action). Note that you
7613: will normally not use this variable.
7614:
1.203 nia 7615: 21.6.11. Packages installing extensions to the MIME database
1.1 dsieger 7616:
7617: If a package provides extensions to the MIME database by installing .xml files
7618: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
7619: ensure that the database is kept consistent with respect to these new files:
7620:
7621: 1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
7622: buildlink3.mk file from this same directory, which is reserved for
7623: inclusion from other buildlink3.mk files). It takes care of rebuilding the
7624: MIME database at installation and deinstallation time, and disallows any
7625: access to it directly from the package.
7626:
1.25 wiz 7627: 2. Check the PLIST and remove any entries under the share/mime directory,
1.1 dsieger 7628: except for files saved under share/mime/packages. The former are handled
7629: automatically by the update-mime-database program, but the latter are
7630: package-dependent and must be removed by the package that installed them in
7631: the first place.
7632:
7633: 3. Remove any share/mime/* directories from the PLIST. They will be handled by
7634: the shared-mime-info package.
7635:
1.203 nia 7636: 21.6.12. Packages using intltool
1.1 dsieger 7637:
7638: If a package uses intltool during its build, add intltool to the USE_TOOLS,
7639: which forces it to use the intltool package provided by pkgsrc, instead of the
7640: one bundled with the distribution file.
7641:
7642: This tracks intltool's build-time dependencies and uses the latest available
7643: version; this way, the package benefits of any bug fixes that may have appeared
7644: since it was released.
7645:
1.203 nia 7646: 21.6.13. Packages installing startup scripts
1.1 dsieger 7647:
7648: If a package contains a rc.d script, it won't be copied into the startup
7649: directory by default, but you can enable it, by adding the option
1.4 rillig 7650: PKG_RCD_SCRIPTS=YES in mk.conf. This option will copy the scripts into /etc/
7651: rc.d when a package is installed, and it will automatically remove the scripts
7652: when the package is deinstalled.
1.1 dsieger 7653:
1.203 nia 7654: 21.6.14. Packages installing TeX modules
1.1 dsieger 7655:
7656: If a package installs TeX packages into the texmf tree, the ls-R database of
7657: the tree needs to be updated.
7658:
7659: Note
7660:
1.23 jakllsch 7661: Except the main TeX packages such as kpathsea, packages should install files
7662: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1 dsieger 7663:
1.23 jakllsch 7664: 1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
7665: ls-R database at installation and deinstallation time.
1.1 dsieger 7666:
1.23 jakllsch 7667: 2. If your package installs files into a texmf tree other than the one at $
7668: {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
7669: trees that need database update.
1.1 dsieger 7670:
7671: If your package also installs font map files that need to be registered
1.30 dholland 7672: using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
7673: and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then
7674: updmap will be run automatically at installation/deinstallation to enable/
7675: disable font map files for TeX output drivers.
1.1 dsieger 7676:
7677: 3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30 dholland 7678: be removed only by the kpathsea package.
1.1 dsieger 7679:
1.203 nia 7680: 21.6.15. Packages supporting running binaries in emulation
1.1 dsieger 7681:
7682: There are some packages that provide libraries and executables for running
7683: binaries from a one operating system on a different one (if the latter supports
7684: it). One example is running Linux binaries on NetBSD.
7685:
7686: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
7687:
7688: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
7689: if all libraries for each installed executable can be found by the dynamic
7690: linker. Since the standard dynamic linker is run, this fails for emulation
7691: packages, because the libraries used by the emulation are not in the standard
7692: directories.
7693:
1.203 nia 7694: 21.6.16. Packages installing hicolor icons
1.1 dsieger 7695:
7696: If a package installs images under the share/icons/hicolor and/or updates the
7697: share/icons/hicolor/icon-theme.cache database, you need to take some extra
7698: steps to make sure that the shared theme directory is handled appropriately and
7699: that the cache database is rebuilt:
7700:
7701: 1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
7702:
7703: 2. Check the PLIST and remove the entry that refers to the theme cache.
7704:
7705: 3. Ensure that the PLIST does not remove the shared icon directories from the
7706: share/icons/hicolor hierarchy because they will be handled automatically.
7707:
7708: The best way to verify that the PLIST is correct with respect to the last two
7709: points is to regenerate it using make print-PLIST.
7710:
1.203 nia 7711: 21.6.17. Packages installing desktop files
1.1 dsieger 7712:
7713: If a package installs .desktop files under share/applications and these include
1.54 rodent 7714: MIME information (MimeType key), you need to take extra steps to ensure that
7715: they are registered into the MIME database:
1.1 dsieger 7716:
7717: 1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
7718:
7719: 2. Check the PLIST and remove the entry that refers to the share/applications/
7720: mimeinfo.cache file. It will be handled automatically.
7721:
7722: The best way to verify that the PLIST is correct with respect to the last point
7723: is to regenerate it using make print-PLIST.
7724:
1.154 rillig 7725: 21.7. Marking packages as having problems
1.1 dsieger 7726:
1.23 jakllsch 7727: In some cases one does not have the time to solve a problem immediately. In
7728: this case, one can plainly mark a package as broken. For this, one just sets
7729: the variable BROKEN to the reason why the package is broken (similar to the
1.162 rillig 7730: PKG_FAIL_REASON variable). A user trying to build the package will immediately
7731: be shown this message, and the build will not be even tried.
1.1 dsieger 7732:
1.23 jakllsch 7733: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1 dsieger 7734:
1.184 rillig 7735: Chapter 22. GNOME packaging and porting
7736:
7737: Table of Contents
7738:
7739: 22.1. Meta packages
7740: 22.2. Packaging a GNOME application
7741: 22.3. Updating GNOME to a newer version
7742: 22.4. Patching guidelines
7743:
7744: Quoting GNOME's web site:
7745:
7746: The GNOME project provides two things: The GNOME desktop environment, an
7747: intuitive and attractive desktop for users, and the GNOME development
7748: platform, an extensive framework for building applications that integrate
7749: into the rest of the desktop.
7750:
7751: pkgsrc provides a seamless way to automatically build and install a complete
7752: GNOME environment under many different platforms. We can say with confidence
7753: that pkgsrc is one of the most advanced build and packaging systems for GNOME
7754: due to its included technologies buildlink3, the wrappers and tools framework
7755: and automatic configuration file management. Lots of efforts are put into
7756: achieving a completely clean deinstallation of installed software components.
7757:
7758: Given that pkgsrc is NetBSD's official packaging system, the above also means
7759: that great efforts are put into making GNOME work under this operating system.
7760:
7761: This chapter is aimed at pkgsrc developers and other people interested in
7762: helping our GNOME porting and packaging efforts. It provides instructions on
7763: how to manage the existing packages and some important information regarding
7764: their internals.
7765:
7766: We need your help!
7767:
7768: Should you have some spare cycles to devote to NetBSD, pkgsrc and GNOME and are
7769: willing to learn new exciting stuff, please jump straight to the pending work
7770: list! There is still a long way to go to get a fully-functional GNOME desktop
7771: under NetBSD and we need your help to achieve it!
7772:
7773: 22.1. Meta packages
7774:
7775: pkgsrc includes three GNOME-related meta packages:
7776:
7777: * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
7778: includes the necessary bits to get it to boot correctly, although it may
7779: lack important functionality for daily operation. The idea behind this
7780: package is to let end users build their own configurations on top of this
7781: one, first installing this meta package to achieve a functional setup and
7782: then adding individual applications.
7783:
7784: * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
7785: desktop as defined by the GNOME project; this is based on the components
7786: distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
7787: directories of the official FTP server. Developer-only tools found in those
7788: directories are not installed unless required by some other component to
7789: work properly. Similarly, packages from the bindings set (bindings/x.y/
7790: x.y.z/sources) are not pulled in unless required as a dependency for an
7791: end-user component. This package "extends" meta-pkgs/gnome-base.
7792:
7793: * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
7794: component when fetched from the CVS repository. These are required to let
7795: the autogen.sh scripts work appropriately.
7796:
7797: In all these packages, the DEPENDS lines are sorted in a way that eases
7798: updates: a package may depend on other packages listed before it but not on any
7799: listed after it. It is very important to keep this order to ease updates so...
7800: do not change it to alphabetical sorting!
7801:
7802: 22.2. Packaging a GNOME application
7803:
7804: Almost all GNOME applications are written in C and use a common set of tools as
7805: their build system. Things get different with the new bindings to other
7806: languages (such as Python), but the following will give you a general idea on
7807: the minimum required tools:
7808:
7809: * Almost all GNOME applications use the GNU Autotools as their build system.
7810: As a general rule you will need to tell this to your package:
7811:
7812: GNU_CONFIGURE=yes
7813: USE_LIBTOOL=yes
7814: USE_TOOLS+=gmake
7815:
7816: * If the package uses pkg-config to detect dependencies, add this tool to the
7817: list of required utilities:
7818:
7819: USE_TOOLS+=pkg-config
7820:
7821: Also use pkgtools/verifypc at the end of the build process to ensure that
7822: you did not miss to specify any dependency in your package and that the
7823: version requirements are all correct.
7824:
7825: * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
7826: handle dependencies and to force the package to use the latest available
7827: version.
7828:
7829: * If the package uses gtk-doc (a documentation generation utility), do not
7830: add a dependency on it. The tool is rather big and the distfile should come
7831: with pregenerated documentation anyway; if it does not, it is a bug that
7832: you ought to report. For such packages you should disable gtk-doc (unless
7833: it is the default):
7834:
7835: CONFIGURE_ARGS+=--disable-gtk-doc
7836:
7837: The default location of installed HTML files (share/gtk-doc/<package-name>)
7838: is correct and should not be changed unless the package insists on
7839: installing them somewhere else. Otherwise programs as devhelp will not be
7840: able to open them. You can do that with an entry similar to:
1.1 dsieger 7841:
1.184 rillig 7842: CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...
1.1 dsieger 7843:
1.184 rillig 7844: GNOME uses multiple shared directories and files under the installation prefix
7845: to maintain databases. In this context, shared means that those exact same
7846: directories and files are used among several different packages, leading to
7847: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
7848: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
7849: your file lists and omitting shared files from them. If you find yourself doing
7850: those, your package is most likely incorrect.
1.1 dsieger 7851:
1.184 rillig 7852: The following table lists the common situations that result in using shared
7853: directories or files. For each of them, the appropriate solution is given.
7854: After applying the solution be sure to regenerate the package's file list with
7855: make print-PLIST and ensure it is correct.
1.1 dsieger 7856:
1.184 rillig 7857: Table 22.1. PLIST handling for GNOME packages
1.1 dsieger 7858:
1.184 rillig 7859: +-----------------------------------------------------------------------------+
7860: | If the package... | Then... |
7861: |-------------------------------------------+---------------------------------|
1.203 nia 7862: |Installs icons under the share/icons/ |See Section 21.6.16, "Packages |
7863: |hicolor hierarchy or updates share/icons/ |installing hicolor icons". |
1.184 rillig 7864: |hicolor/icon-theme.cache. | |
7865: |-------------------------------------------+---------------------------------|
1.203 nia 7866: | |See Section 21.6.11, "Packages |
1.184 rillig 7867: |Installs files under share/mime/packages. |installing extensions to the MIME|
7868: | |database". |
7869: |-------------------------------------------+---------------------------------|
1.203 nia 7870: |Installs .desktop files under share/ |See Section 21.6.17, "Packages |
1.184 rillig 7871: |applications and these include MIME |installing desktop files". |
7872: |information. | |
7873: +-----------------------------------------------------------------------------+
1.1 dsieger 7874:
7875:
1.184 rillig 7876: 22.3. Updating GNOME to a newer version
1.1 dsieger 7877:
1.184 rillig 7878: When seeing GNOME as a whole, there are two kinds of updates:
1.1 dsieger 7879:
1.184 rillig 7880: Major update
1.1 dsieger 7881:
1.184 rillig 7882: Given that there is still a very long way for GNOME 3 (if it ever appears),
7883: we consider a major update one that goes from a 2.X version to a 2.Y one,
7884: where Y is even and greater than X. These are hard to achieve because they
7885: introduce lots of changes in the components' code and almost all GNOME
7886: distfiles are updated to newer versions. Some of them can even break API
7887: and ABI compatibility with the previous major version series. As a result,
7888: the update needs to be done all at once to minimize breakage.
1.1 dsieger 7889:
1.184 rillig 7890: A major update typically consists of around 80 package updates and the
7891: addition of some new ones.
1.1 dsieger 7892:
1.184 rillig 7893: Minor update
1.1 dsieger 7894:
1.184 rillig 7895: We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
7896: one where Y is greater than X. These are easy to achieve because they do
7897: not update all GNOME components, can be done in an incremental way and do
7898: not break API nor ABI compatibility.
1.1 dsieger 7899:
1.184 rillig 7900: A minor update typically consists of around 50 package updates, although
7901: the numbers here may vary a lot.
1.1 dsieger 7902:
1.184 rillig 7903: In order to update the GNOME components in pkgsrc to a new stable release
7904: (either major or minor), the following steps should be followed:
1.1 dsieger 7905:
1.184 rillig 7906: 1. Get a list of all the tarballs that form the new release by using the
7907: following commands. These will leave the full list of the components'
7908: distfiles into the list.txt file:
1.1 dsieger 7909:
1.184 rillig 7910: % echo ls "*.tar.bz2" | \
7911: ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
7912: awk '{ print $9 }' >list.txt
7913: % echo ls "*.tar.bz2" | \
7914: ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
7915: awk '{ print $9 }' >>list.txt
1.1 dsieger 7916:
1.184 rillig 7917: 2. Open each meta package's Makefile and bump their version to the release you
7918: are updating them to. The three meta packages should be always consistent
7919: with versioning. Obviously remove any PKGREVISIONs that might be in them.
1.1 dsieger 7920:
1.184 rillig 7921: 3. For each meta package, update all its DEPENDS lines to match the latest
7922: versions as shown by the above commands. Do not list any newer version
7923: (even if found in the FTP) because the meta packages are supposed to list
7924: the exact versions that form a specific GNOME release. Exceptions are
7925: permitted here if a newer version solves a serious issue in the overall
7926: desktop experience; these typically come in the form of a revision bump in
7927: pkgsrc, not in newer versions from the developers.
1.1 dsieger 7928:
1.184 rillig 7929: Packages not listed in the list.txt file should be updated to the latest
7930: version available (if found in pkgsrc). This is the case, for example, of
7931: the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
7932: package.
1.1 dsieger 7933:
1.184 rillig 7934: 4. Generate a patch from the modified meta packages and extract the list of
7935: "new" lines. This will provide you an outline on what packages need to be
7936: updated in pkgsrc and in what order:
1.1 dsieger 7937:
1.184 rillig 7938: % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
1.1 dsieger 7939:
1.184 rillig 7940: 5. For major desktop updates it is recommended to zap all your installed
7941: packages and start over from scratch at this point.
1.1 dsieger 7942:
1.184 rillig 7943: 6. Now comes the longest step by far: iterate over the contents of todo.txt
7944: and update the packages listed in it in order. For major desktop updates
7945: none of these should be committed until the entire set is completed because
7946: there are chances of breaking not-yet-updated packages.
1.1 dsieger 7947:
1.184 rillig 7948: 7. Once the packages are up to date and working, commit them to the tree one
7949: by one with appropriate log messages. At the end, commit the three meta
7950: package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
7951: and pkgsrc/doc/TODO files.
1.1 dsieger 7952:
1.184 rillig 7953: 22.4. Patching guidelines
1.1 dsieger 7954:
1.184 rillig 7955: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
7956: it is very important that you always, always, always feed back any portability
7957: fixes you do to a GNOME package to the mainstream developers (see
7958: Section 12.3.5, "Feedback to the author"). This is the only way to get their
7959: attention on portability issues and to ensure that future versions can be built
7960: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
7961: updates are. Those developers in charge of issuing major GNOME updates will be
7962: grateful if you do that.
1.1 dsieger 7963:
1.200 cirnatda 7964: The most common places to report bugs are the GNOME's GitLab and the
7965: freedesktop.org's GitLab. Not all components use these to track bugs, but most
7966: of them do. Do not be short on your reports: always provide detailed
1.184 rillig 7967: explanations of the current failure, how it can be improved to achieve maximum
1.200 cirnatda 7968: portability and, if at all possible, provide a patch against the main Git
7969: branch. The more verbose you are, the higher chances of your patch being
7970: accepted.
1.1 dsieger 7971:
1.184 rillig 7972: Also, please avoid using preprocessor magic to fix portability issues. While
7973: the FreeBSD GNOME people are doing a great job in porting GNOME to their
7974: operating system, the official GNOME sources are now plagued by conditionals
7975: that check for __FreeBSD__ and similar macros. This hurts portability. Please
7976: see our patching guidelines (Section 12.3.4, "Patching guidelines") for more
7977: details.
1.1 dsieger 7978:
1.154 rillig 7979: Chapter 23. Submitting and Committing
1.1 dsieger 7980:
7981: Table of Contents
7982:
1.154 rillig 7983: 23.1. Submitting binary packages
7984: 23.2. Submitting source packages (for non-NetBSD-developers)
7985: 23.3. General notes when adding, updating, or removing packages
7986: 23.4. Commit Messages
7987: 23.5. Committing: Adding a package to CVS
7988: 23.6. Updating a package to a newer version
7989: 23.7. Renaming a package in pkgsrc
7990: 23.8. Moving a package in pkgsrc
1.1 dsieger 7991:
1.154 rillig 7992: 23.1. Submitting binary packages
1.1 dsieger 7993:
7994: Our policy is that we accept binaries only from pkgsrc developers to guarantee
7995: that the packages don't contain any trojan horses etc. This is not to annoy
7996: anyone but rather to protect our users! You're still free to put up your
7997: home-made binary packages and tell the world where to get them. NetBSD
1.154 rillig 7998: developers doing bulk builds and wanting to upload them please see Chapter 8,
1.66 asau 7999: Creating binary packages for everything in pkgsrc (bulk builds).
1.1 dsieger 8000:
1.154 rillig 8001: 23.2. Submitting source packages (for non-NetBSD-developers)
1.1 dsieger 8002:
8003: First, check that your package is complete, compiles and runs well; see
1.184 rillig 8004: Chapter 14, Creating a new pkgsrc package from scratch and the rest of this
8005: document. Next, generate an uuencoded gzipped tar(1) archive that contains all
8006: files that make up the package. Finally, send this package to the pkgsrc bug
8007: tracking system, either with the send-pr(1) command, or if you don't have that,
8008: go to the web page https://www.NetBSD.org/support/send-pr.html, which contains
8009: some instructions and a link to a form where you can submit packages. The
8010: sysutils/gtk-send-pr package is also available as a substitute for either of
8011: the above two tools.
1.1 dsieger 8012:
8013: In the form of the problem report, the category should be "pkg", the synopsis
8014: should include the package name and version number, and the description field
8015: should contain a short description of your package (contents of the COMMENT
1.25 wiz 8016: variable or DESCR file are OK). The uuencoded package data should go into the "
8017: fix" field.
1.1 dsieger 8018:
8019: If you want to submit several packages, please send a separate PR for each one,
8020: it's easier for us to track things that way.
8021:
8022: Alternatively, you can also import new packages into pkgsrc-wip ("pkgsrc
1.174 leot 8023: work-in-progress"); see the homepage at https://pkgsrc.org/wip/ for details.
1.1 dsieger 8024:
1.154 rillig 8025: 23.3. General notes when adding, updating, or removing packages
1.1 dsieger 8026:
8027: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
8028: CHANGES-YYYY. It's very important to keep this file up to date and conforming
8029: to the existing format, because it will be used by scripts to automatically
8030: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
8031: doc/TODO file and remove the entry for the package you updated or removed, in
8032: case it was mentioned there.
8033:
8034: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
8035: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
8036: that result from a dependency being updated should not be mentioned. In all
8037: other cases it's the developer's decision.
8038:
8039: There is a make target that helps in creating proper CHANGES-YYYY entries: make
8040: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
8041: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
8042: (to avoid having to resolve conflicts later-on) and then to cd to the package
8043: directory. For package updates, make changes-entry is enough. For new packages,
8044: or package moves or removals, set the CTYPE variable on the command line to
1.4 rillig 8045: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23 jakllsch 8046: your local login name is not the same as your NetBSD login name. The target
8047: also automatically removes possibly existing entries for the package in the
8048: TODO file. Don't forget to commit the changes, e.g. by using make
1.66 asau 8049: commit-changes-entry! If you are not using a checkout directly from
1.23 jakllsch 8050: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
8051: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1 dsieger 8052:
1.154 rillig 8053: 23.4. Commit Messages
1.130 wiz 8054:
8055: For several years, there have been mirrors of pkgsrc in fossil, git, and hg.
8056: Standard practise when using these tools is to make the first line of a commit
8057: message function as a summary that can be read without the rest, such as is
8058: commonly done with "git log --oneline". For this reason, we have the following
8059: guidelines for pkgsrc commit messages:
8060:
1.131 wiz 8061: * Start the commit message with a line that explains the big picture in 65
1.130 wiz 8062: characters or less. When a commit is for one package, include the name of
8063: the package. For updates, include the version to which it is updated.
8064:
8065: * Leave the next line empty.
8066:
8067: * Then come the details for the commit (changes in that package, reason for a
8068: change) and any relevant PRs. Wrap this section.
8069:
8070: Here is an example:
8071:
8072: libxslt: update to 1.0.30
8073:
8074: Changes since 1.0.29:
8075: ...
8076:
8077:
8078: Here is another example:
8079:
8080: mk/bsd.pkg.mk: enable SSP by default on NetBSD
8081:
8082: (rationale)
8083:
8084:
8085: Commit messages are final: no "cvs admin" is allowed on the pkgsrc repository
8086: to change commit messages.
8087:
1.154 rillig 8088: 23.5. Committing: Adding a package to CVS
1.1 dsieger 8089:
8090: This section is only of interest for pkgsrc developers with write access to the
1.34 wiz 8091: pkgsrc repository.
8092:
8093: When the package is finished, "cvs add" the files. Start by adding the
8094: directory and then files in the directory. Don't forget to add the new package
8095: to the category's Makefile. Make sure you don't forget any files; you can check
8096: by running "cvs status". An example:
8097:
8098: $ cd .../pkgsrc/category
8099: $ cvs add pkgname
8100: $ cd pkgname
8101: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
8102: $ cvs add patches/p*
8103: $ cvs status | less
1.35 wiz 8104: $ cvs commit
1.34 wiz 8105: $ cd ..
8106: $ vi Makefile # add SUBDIRS+=pkgname line
1.35 wiz 8107: $ cvs commit Makefile
1.66 asau 8108: $ cd pkgname
1.73 jnemeth 8109: $ make CTYPE=Added commit-changes-entry
1.1 dsieger 8110:
8111: The commit message of the initial import should include part of the DESCR file,
8112: so people reading the mailing lists know what the package is/does.
8113:
1.34 wiz 8114: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
8115:
8116: Previously, "cvs import" was suggested, but it was much easier to get wrong
8117: than "cvs add".
1.1 dsieger 8118:
1.154 rillig 8119: 23.6. Updating a package to a newer version
1.1 dsieger 8120:
8121: Please always put a concise, appropriate and relevant summary of the changes
8122: between old and new versions into the commit log when updating a package. There
8123: are various reasons for this:
8124:
8125: * A URL is volatile, and can change over time. It may go away completely or
8126: its information may be overwritten by newer information.
8127:
8128: * Having the change information between old and new versions in our CVS
8129: repository is very useful for people who use either cvs or anoncvs.
8130:
8131: * Having the change information between old and new versions in our CVS
8132: repository is very useful for people who read the pkgsrc-changes mailing
8133: list, so that they can make tactical decisions about when to upgrade the
8134: package.
8135:
8136: Please also recognize that, just because a new version of a package has been
8137: released, it should not automatically be upgraded in the CVS repository. We
8138: prefer to be conservative in the packages that are included in pkgsrc -
8139: development or beta packages are not really the best thing for most places in
8140: which pkgsrc is used. Please use your judgement about what should go into
8141: pkgsrc, and bear in mind that stability is to be preferred above new and
8142: possibly untested features.
8143:
1.154 rillig 8144: 23.7. Renaming a package in pkgsrc
1.21 snj 8145:
8146: Renaming packages is not recommended.
8147:
1.175 gutterid 8148: When renaming packages, be sure to fix any references to the old name in other
1.21 snj 8149: Makefiles, options, buildlink files, etc.
8150:
1.175 gutterid 8151: Also, when renaming a package, please add the package name and version pattern
1.167 leot 8152: (s) of the previous package to SUPERSEDES. This may be repeated for multiple
8153: renames. The new package would be an exact replacement. Example:
8154:
8155: SUPERSEDES+= p5-IO-Compress-Zlib<2.017
8156: SUPERSEDES+= optcomp-[0-9]*
1.21 snj 8157:
8158: Note that "successor" in the CHANGES-YYYY file doesn't necessarily mean that it
8159: supersedes, as that successor may not be an exact replacement but is a
8160: suggestion for the replaced functionality.
8161:
1.154 rillig 8162: 23.8. Moving a package in pkgsrc
1.21 snj 8163:
8164: It is preferred that packages are not renamed or moved, but if needed please
8165: follow these steps.
1.1 dsieger 8166:
8167: 1. Make a copy of the directory somewhere else.
8168:
8169: 2. Remove all CVS dirs.
8170:
8171: Alternatively to the first two steps you can also do:
8172:
8173: % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
8174:
8175: and use that for further work.
8176:
1.25 wiz 8177: 3. Fix CATEGORIES and any DEPENDS paths that just did "../package" instead of
1.1 dsieger 8178: "../../category/package".
8179:
1.21 snj 8180: 4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
8181: previous category/package pathname. The PREV_PKGPATH can be used by tools
8182: for doing an update using pkgsrc building; for example, it can search the
8183: pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
8184: the corresponding new PKGPATH for that moved package. Note that it may have
8185: multiple matches, so the tool should also check on the PKGBASE too. The
8186: PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
8187: PKGBASE stays the same.
8188:
8189: 5. cvs import the modified package in the new place.
1.1 dsieger 8190:
1.21 snj 8191: 6. Check if any package depends on it:
1.1 dsieger 8192:
8193: % cd /usr/pkgsrc
8194: % grep /package */*/Makefile* */*/buildlink*
8195:
1.21 snj 8196: 7. Fix paths in packages from step 5 to point to new location.
1.1 dsieger 8197:
1.21 snj 8198: 8. cvs rm (-f) the package at the old location.
1.1 dsieger 8199:
1.21 snj 8200: 9. Remove from oldcategory/Makefile.
1.1 dsieger 8201:
1.21 snj 8202: 10. Add to newcategory/Makefile.
1.1 dsieger 8203:
1.21 snj 8204: 11. Commit the changed and removed files:
1.1 dsieger 8205:
8206: % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
8207:
8208: (and any packages from step 5, of course).
8209:
1.154 rillig 8210: Chapter 24. Frequently Asked Questions
1.1 dsieger 8211:
8212: This section contains the answers to questions that may arise when you are
8213: writing a package. If you don't find your question answered here, first have a
8214: look in the other chapters, and if you still don't have the answer, ask on the
8215: pkgsrc-users mailing list.
8216:
1.154 rillig 8217: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
8218: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
8219: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
8220: 24.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1 dsieger 8221: BUILDLINK_LIBS?
1.154 rillig 8222: 24.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
8223: 24.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1 dsieger 8224: the := inside it.
1.154 rillig 8225: 24.7. Which mailing lists are there for package developers?
8226: 24.8. Where is the pkgsrc documentation?
8227: 24.9. I have a little time to kill. What shall I do?
1.1 dsieger 8228:
1.154 rillig 8229: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1 dsieger 8230:
8231: MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
8232: (1), while MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM
8233: when building the package. [FIXME: What is .MAKEFLAGS for?]
8234:
1.154 rillig 8235: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1 dsieger 8236:
8237: MAKE is the path to the make(1) program that is used in the pkgsrc
8238: infrastructure. GMAKE is the path to GNU Make, but you need to say
8239: USE_TOOLS+=gmake to use that. MAKE_PROGRAM is the path to the Make
8240: program that is used for building the package.
8241:
1.154 rillig 8242: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1 dsieger 8243:
8244: CC is the path to the real C compiler, which can be configured by the
8245: pkgsrc user. PKG_CC is the path to the compiler wrapper. PKGSRC_COMPILER
8246: is not a path to a compiler, but the type of compiler that should be
8247: used. See mk/compiler.mk for more information about the latter variable.
8248:
1.154 rillig 8249: 24.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1 dsieger 8250: BUILDLINK_LIBS?
8251:
8252: [FIXME]
8253:
1.154 rillig 8254: 24.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1 dsieger 8255:
1.25 wiz 8256: For optimization reasons, some variables are only available in the "
8257: wrapper" phase and later. To "simulate" the wrapper phase, append
1.1 dsieger 8258: PKG_PHASE=wrapper to the above command.
8259:
1.154 rillig 8260: 24.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1 dsieger 8261: the := inside it.
8262:
1.108 rillig 8263: The := is not really an assignment operator, although it looks like it.
8264: Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
8265: is documented in the make(1) man page and which is commonly used in the
8266: form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
8267: string and new_string is package/. That's where the : and the = fall
8268: together.
1.1 dsieger 8269:
1.154 rillig 8270: 24.7. Which mailing lists are there for package developers?
1.1 dsieger 8271:
8272: tech-pkg
8273:
8274: This is a list for technical discussions related to pkgsrc
8275: development, e.g. soliciting feedback for changes to pkgsrc
8276: infrastructure, proposed new features, questions related to porting
8277: pkgsrc to a new platform, advice for maintaining a package, patches
8278: that affect many packages, help requests moved from pkgsrc-users when
8279: an infrastructure bug is found, etc.
8280:
8281: pkgsrc-bugs
8282:
8283: All bug reports in category "pkg" sent with send-pr(1) appear here.
8284: Please do not report your bugs here directly; use one of the other
8285: mailing lists.
8286:
1.154 rillig 8287: 24.8. Where is the pkgsrc documentation?
1.1 dsieger 8288:
8289: There are many places where you can find documentation about pkgsrc:
8290:
8291: * The pkgsrc guide (this document) is a collection of chapters that
8292: explain large parts of pkgsrc, but some chapters tend to be outdated.
8293: Which ones they are is hard to say.
8294:
1.174 leot 8295: * On the mailing list archives (see https://mail-index.NetBSD.org/),
8296: you can find discussions about certain features, announcements of new
1.1 dsieger 8297: parts of the pkgsrc infrastructure and sometimes even announcements
8298: that a certain feature has been marked as obsolete. The benefit here
8299: is that each message has a date appended to it.
8300:
8301: * Many of the files in the mk/ directory start with a comment that
8302: describes the purpose of the file and how it can be used by the
8303: pkgsrc user and package authors. An easy way to find this
8304: documentation is to run bmake help.
8305:
8306: * The CVS log messages are a rich source of information, but they tend
8307: to be highly abbreviated, especially for actions that occur often.
8308: Some contain a detailed description of what has changed, but they are
8309: geared towards the other pkgsrc developers, not towards an average
8310: pkgsrc user. They also only document changes, so if you don't know
8311: what has been before, these messages may not be worth too much to
8312: you.
8313:
8314: * Some parts of pkgsrc are only "implicitly documented", that is the
8315: documentation exists only in the mind of the developer who wrote the
8316: code. To get this information, use the cvs annotate command to see
8317: who has written it and ask on the tech-pkg mailing list, so that
8318: others can find your questions later (see above). To be sure that the
8319: developer in charge reads the mail, you may CC him or her.
8320:
1.154 rillig 8321: 24.9. I have a little time to kill. What shall I do?
1.1 dsieger 8322:
8323: This is not really an FAQ yet, but here's the answer anyway.
8324:
8325: * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
8326: about newer versions of installed packages that are available, but
8327: not yet updated in pkgsrc.
8328:
1.198 leot 8329: * Browse pkgsrc/doc/TODO -- it contains a list of suggested new
8330: packages and a list of cleanups and enhancements for pkgsrc that
8331: would be nice to have.
1.1 dsieger 8332:
1.71 wiz 8333: * Review packages for which review was requested on the tech-pkg
8334: mailing list.
1.1 dsieger 8335:
8336: Part III. The pkgsrc infrastructure internals
8337:
8338: This part of the guide deals with everything from the infrastructure that is
8339: behind the interfaces described in the developer's guide. A casual package
8340: maintainer should not need anything from this part.
8341:
8342: Table of Contents
8343:
1.184 rillig 8344: 25. Design of the pkgsrc infrastructure
1.1 dsieger 8345:
1.184 rillig 8346: 25.1. The meaning of variable definitions
8347: 25.2. Avoiding problems before they arise
8348: 25.3. Variable evaluation
1.1 dsieger 8349:
1.184 rillig 8350: 25.3.1. At load time
8351: 25.3.2. At runtime
1.1 dsieger 8352:
1.184 rillig 8353: 25.4. How can variables be specified?
8354: 25.5. Designing interfaces for Makefile fragments
1.1 dsieger 8355:
1.184 rillig 8356: 25.5.1. Procedures with parameters
8357: 25.5.2. Actions taken on behalf of parameters
1.1 dsieger 8358:
1.184 rillig 8359: 25.6. The order in which files are loaded
1.1 dsieger 8360:
1.184 rillig 8361: 25.6.1. The order in bsd.prefs.mk
8362: 25.6.2. The order in bsd.pkg.mk
1.1 dsieger 8363:
1.184 rillig 8364: 26. Regression tests
1.1 dsieger 8365:
1.184 rillig 8366: 26.1. Running the regression tests
8367: 26.2. Adding a new regression test
1.1 dsieger 8368:
1.184 rillig 8369: 26.2.1. Overridable functions
8370: 26.2.2. Helper functions
1.1 dsieger 8371:
1.184 rillig 8372: 27. Porting pkgsrc
1.1 dsieger 8373:
1.184 rillig 8374: 27.1. Porting pkgsrc to a new operating system
1.1 dsieger 8375:
1.184 rillig 8376: Chapter 25. Design of the pkgsrc infrastructure
1.1 dsieger 8377:
8378: Table of Contents
8379:
1.184 rillig 8380: 25.1. The meaning of variable definitions
8381: 25.2. Avoiding problems before they arise
8382: 25.3. Variable evaluation
1.1 dsieger 8383:
1.184 rillig 8384: 25.3.1. At load time
8385: 25.3.2. At runtime
1.1 dsieger 8386:
1.184 rillig 8387: 25.4. How can variables be specified?
8388: 25.5. Designing interfaces for Makefile fragments
1.1 dsieger 8389:
1.184 rillig 8390: 25.5.1. Procedures with parameters
8391: 25.5.2. Actions taken on behalf of parameters
1.1 dsieger 8392:
1.184 rillig 8393: 25.6. The order in which files are loaded
1.1 dsieger 8394:
1.184 rillig 8395: 25.6.1. The order in bsd.prefs.mk
8396: 25.6.2. The order in bsd.pkg.mk
1.1 dsieger 8397:
8398: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
8399: fragment needs a properly specified interface. This chapter explains how such
8400: an interface looks like.
8401:
1.184 rillig 8402: 25.1. The meaning of variable definitions
1.1 dsieger 8403:
8404: Whenever a variable is defined in the pkgsrc infrastructure, the location and
8405: the way of definition provide much information about the intended use of that
8406: variable. Additionally, more documentation may be found in a header comment or
8407: in this pkgsrc guide.
8408:
8409: A special file is mk/defaults/mk.conf, which lists all variables that are
8410: intended to be user-defined. They are either defined using the ?= operator or
8411: they are left undefined because defining them to anything would effectively
8412: mean "yes". All these variables may be overridden by the pkgsrc user in the
8413: MAKECONF file.
8414:
8415: Outside this file, the following conventions apply: Variables that are defined
8416: using the ?= operator may be overridden by a package.
8417:
8418: Variables that are defined using the = operator may be used read-only at
8419: run-time.
8420:
8421: Variables whose name starts with an underscore must not be accessed outside the
8422: pkgsrc infrastructure at all. They may change without further notice.
8423:
8424: Note
8425:
8426: These conventions are currently not applied consistently to the complete pkgsrc
8427: infrastructure.
8428:
1.184 rillig 8429: 25.2. Avoiding problems before they arise
1.1 dsieger 8430:
8431: All variables that contain lists of things should default to being empty. Two
8432: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
8433: variables cannot simply be modified using the += operator in package Makefiles
8434: (or other files included by them), since there is no guarantee whether the
8435: variable is already set or not, and what its value is. In the case of
8436: DISTFILES, the packages "know" the default value and just define it as in the
8437: following example.
8438:
8439: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
8440:
8441: Because of the selection of this default value, the same value appears in many
8442: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
8443: value ("c") is so short that it doesn't stand out. Nevertheless it is mentioned
8444: in many files.
8445:
1.184 rillig 8446: 25.3. Variable evaluation
1.1 dsieger 8447:
1.184 rillig 8448: 25.3.1. At load time
1.1 dsieger 8449:
8450: Variable evaluation takes place either at load time or at runtime, depending on
8451: the context in which they occur. The contexts where variables are evaluated at
8452: load time are:
8453:
8454: * The right hand side of the := and != operators,
8455:
8456: * Make directives like .if or .for,
8457:
8458: * Dependency lines.
8459:
8460: A special exception are references to the iteration variables of .for loops,
8461: which are expanded inline, no matter in which context they appear.
8462:
8463: As the values of variables may change during load time, care must be taken not
8464: to evaluate them by accident. Typical examples for variables that should not be
8465: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
8466: clear, here is an example:
8467:
8468: CONFIGURE_ARGS= # none
8469: CFLAGS= -O
8470: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
8471:
8472: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
8473:
8474: CFLAGS+= -Wall
8475:
8476: This code shows how the use of the := operator can quickly lead to unexpected
8477: results. The first paragraph is fairly common code. The second paragraph
8478: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
8479: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
8480: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
8481: typically occur in completely unrelated files.
8482:
1.184 rillig 8483: 25.3.2. At runtime
1.1 dsieger 8484:
8485: After all the files have been loaded, the values of the variables cannot be
8486: changed anymore. Variables that are used in the shell commands are expanded at
8487: this point.
8488:
1.184 rillig 8489: 25.4. How can variables be specified?
1.1 dsieger 8490:
8491: There are many ways in which the definition and use of a variable can be
8492: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108 rillig 8493: policies. A package can be checked with pkglint -Wall to see whether it meets
8494: these rules.
1.1 dsieger 8495:
1.184 rillig 8496: 25.5. Designing interfaces for Makefile fragments
1.1 dsieger 8497:
8498: Most of the .mk files fall into one of the following classes. Cases where a
8499: file falls into more than one class should be avoided as it often leads to
8500: subtle bugs.
8501:
1.184 rillig 8502: 25.5.1. Procedures with parameters
1.1 dsieger 8503:
8504: In a traditional imperative programming language some of the .mk files could be
1.198 leot 8505: described as procedures. They take some input parameters and--after
8506: inclusion--provide a result in output parameters. Since all variables in
1.23 jakllsch 8507: Makefiles have global scope care must be taken not to use parameter names that
8508: have already another meaning. For example, PKGNAME is a bad choice for a
8509: parameter name.
1.1 dsieger 8510:
8511: Procedures are completely evaluated at preprocessing time. That is, when
8512: calling a procedure all input parameters must be completely resolvable. For
8513: example, CONFIGURE_ARGS should never be an input parameter since it is very
8514: likely that further text will be added after calling the procedure, which would
8515: effectively apply the procedure to only a part of the variable. Also,
1.108 rillig 8516: references to other variables will be modified after calling the procedure.
1.1 dsieger 8517:
8518: A procedure can declare its output parameters either as suitable for use in
8519: preprocessing directives or as only available at runtime. The latter
8520: alternative is for variables that contain references to other runtime
8521: variables.
8522:
8523: Procedures shall be written such that it is possible to call the procedure more
8524: than once. That is, the file must not contain multiple-inclusion guards.
8525:
8526: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
8527: To express that the parameters are evaluated at load time, they should be
8528: assigned using the := operator, which should be used only for this purpose.
8529:
1.184 rillig 8530: 25.5.2. Actions taken on behalf of parameters
1.1 dsieger 8531:
8532: Action files take some input parameters and may define runtime variables. They
8533: shall not define loadtime variables. There are action files that are included
8534: implicitly by the pkgsrc infrastructure, while other must be included
8535: explicitly.
8536:
8537: An example for action files is mk/subst.mk.
8538:
1.184 rillig 8539: 25.6. The order in which files are loaded
1.1 dsieger 8540:
8541: Package Makefiles usually consist of a set of variable definitions, and include
8542: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
8543: include various other *.mk files if they need to query the availability of
8544: certain features like the type of compiler or the X11 implementation. Due to
8545: the heavy use of preprocessor directives like .if and .for, the order in which
8546: the files are loaded matters.
8547:
8548: This section describes at which point the various files are loaded and gives
8549: reasons for that order.
8550:
1.184 rillig 8551: 25.6.1. The order in bsd.prefs.mk
1.1 dsieger 8552:
8553: The very first action in bsd.prefs.mk is to define some essential variables
8554: like OPSYS, OS_VERSION and MACHINE_ARCH.
8555:
1.4 rillig 8556: Then, the user settings are loaded from the file specified in MAKECONF, which
8557: is usually mk.conf. After that, those variables that have not been overridden
8558: by the user are loaded from mk/defaults/mk.conf.
1.1 dsieger 8559:
8560: After the user settings, the system settings and platform settings are loaded,
8561: which may override the user settings.
8562:
8563: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
8564: This only happens when building a package, so the proper variables must be used
8565: instead of the direct tool names.
8566:
8567: As the last steps, some essential variables from the wrapper and the package
8568: system flavor are loaded, as well as the variables that have been cached in
8569: earlier phases of a package build.
8570:
1.184 rillig 8571: 25.6.2. The order in bsd.pkg.mk
1.1 dsieger 8572:
8573: First, bsd.prefs.mk is loaded.
8574:
8575: Then, the various *-vars.mk files are loaded, which fill default values for
8576: those variables that have not been defined by the package. These variables may
8577: later be used even in unrelated files.
8578:
8579: Then, the file bsd.pkg.error.mk provides the target error-check that is added
8580: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
8581: DELAYED_WARNING_MSG.
8582:
8583: Then, the package-specific hacks from hacks.mk are included.
8584:
8585: Then, various other files follow. Most of them don't have any dependencies on
8586: what they need to have included before or after them, though some do.
8587:
8588: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
8589: restricts the use of these variables to all the files that have been included
8590: before. Appearances in later files will be silently ignored.
8591:
8592: Then, the files for the main targets are included, in the order of later
8593: execution, though the actual order should not matter.
8594:
8595: At last, some more files are included that don't set any interesting variables
8596: but rather just define make targets to be executed.
8597:
1.184 rillig 8598: Chapter 26. Regression tests
1.1 dsieger 8599:
8600: Table of Contents
8601:
1.184 rillig 8602: 26.1. Running the regression tests
8603: 26.2. Adding a new regression test
1.1 dsieger 8604:
1.184 rillig 8605: 26.2.1. Overridable functions
8606: 26.2.2. Helper functions
1.1 dsieger 8607:
8608: The pkgsrc infrastructure consists of a large codebase, and there are many
8609: corners where every little bit of a file is well thought out, making pkgsrc
8610: likely to fail as soon as anything is changed near those parts. To prevent most
8611: changes from breaking anything, a suite of regression tests should go along
8612: with every important part of the pkgsrc infrastructure. This chapter describes
8613: how regression tests work in pkgsrc and how you can add new tests.
8614:
1.184 rillig 8615: 26.1. Running the regression tests
1.1 dsieger 8616:
1.25 wiz 8617: You first need to install the pkgtools/pkg_regress package, which provides the
1.1 dsieger 8618: pkg_regress command. Then you can simply run that command, which will run all
1.168 rillig 8619: tests in the regress/ directory.
1.1 dsieger 8620:
1.184 rillig 8621: 26.2. Adding a new regression test
1.1 dsieger 8622:
1.168 rillig 8623: Every directory in the regress/ directory that contains a file called spec is
1.1 dsieger 8624: considered a regression test. This file is a shell program that is included by
8625: the pkg_regress command. The following functions can be overridden to suit your
8626: needs.
8627:
1.184 rillig 8628: 26.2.1. Overridable functions
1.1 dsieger 8629:
1.108 rillig 8630: These functions do not take any parameters. Although they are called in "set -e
1.168 rillig 8631: " mode, they don't stop at the first failing command. See this Stack Overflow
1.108 rillig 8632: question for details.
1.1 dsieger 8633:
1.108 rillig 8634: do_setup
1.1 dsieger 8635:
8636: This function prepares the environment for the test. By default it does
8637: nothing.
8638:
1.108 rillig 8639: do_test
1.1 dsieger 8640:
8641: This function runs the actual test. By default, it calls TEST_MAKE with the
8642: arguments MAKEARGS_TEST and writes its output including error messages into
8643: the file TEST_OUTFILE.
8644:
1.108 rillig 8645: When defining this function, make sure that all output that needs to be
8646: checked is written to the correct output file. Example:
8647:
8648: do_test() {
8649: echo "Example output"
8650: } 1>$TEST_OUTFILE 2>&1
8651:
8652: check_result
1.1 dsieger 8653:
8654: This function is run after the test and is typically used to compare the
8655: actual output from the one that is expected. It can make use of the various
1.108 rillig 8656: helper functions from the next section. Example:
8657:
8658: check_result() {
8659: exit_status 0
8660: output_require "Example"
8661: output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
8662: output_prohibit "no such file or directory"
1.169 rillig 8663: regress_fail "expected $expected but got $actual for input $input"
1.108 rillig 8664: }
1.1 dsieger 8665:
1.108 rillig 8666: do_cleanup
1.1 dsieger 8667:
8668: This function cleans everything up after the test has been run. By default
8669: it does nothing.
8670:
1.184 rillig 8671: 26.2.2. Helper functions
1.1 dsieger 8672:
1.168 rillig 8673: regress_fail message...
8674:
8675: This function makes the test fail with the given error message.
8676:
1.108 rillig 8677: exit_status expected
1.1 dsieger 8678:
1.108 rillig 8679: This function compares the exitcode of the do_test function with its first
8680: parameter. If they differ, the test will fail.
1.1 dsieger 8681:
1.108 rillig 8682: output_require regex...
1.1 dsieger 8683:
8684: This function checks for each of its parameters if the output from do_test
1.108 rillig 8685: matches the extended regular expression. If it does not, the test will
8686: fail. Example:
8687:
8688: output_require "looks fine"
8689: output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1 dsieger 8690:
1.177 leot 8691: output_prohibit regex...
1.1 dsieger 8692:
8693: This function checks for each of its parameters if the output from do_test
8694: () does not match the extended regular expression. If any of the regular
8695: expressions matches, the test will fail.
8696:
1.184 rillig 8697: Chapter 27. Porting pkgsrc
1.1 dsieger 8698:
8699: Table of Contents
8700:
1.184 rillig 8701: 27.1. Porting pkgsrc to a new operating system
1.1 dsieger 8702:
8703: The pkgsrc system has already been ported to many operating systems, hardware
8704: architectures and compilers. This chapter explains the necessary steps to make
8705: pkgsrc even more portable.
8706:
1.184 rillig 8707: 27.1. Porting pkgsrc to a new operating system
1.1 dsieger 8708:
8709: To port pkgsrc to a new operating system (called MyOS in this example), you
8710: need to touch the following files:
8711:
8712: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
8713:
8714: This file contains some basic definitions, for example the name of the C
8715: compiler.
8716:
8717: mk/bsd.prefs.mk
8718:
1.212 wiz 8719: Insert code that defines the variables OPSYS, OS_VERSION, OPSYS_VERSION,
1.1 dsieger 8720: LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
8721: that appear in this file.
8722:
8723: mk/platform/MyOS.mk
8724:
8725: This file contains the platform-specific definitions that are used by
8726: pkgsrc. Start by copying one of the other files and edit it to your needs.
8727:
8728: mk/tools/tools.MyOS.mk
8729:
8730: This file defines the paths to all the tools that are needed by one or the
8731: other package in pkgsrc, as well as by pkgsrc itself. Find out where these
8732: tools are on your platform and add them.
8733:
8734: Now, you should be able to build some basic packages, like lang/perl5, shells/
8735: bash.
8736:
8737: Appendix A. A simple example package: bison
8738:
8739: Table of Contents
8740:
8741: A.1. files
8742:
8743: A.1.1. Makefile
8744: A.1.2. DESCR
8745: A.1.3. PLIST
8746: A.1.4. Checking a package with pkglint
8747:
8748: A.2. Steps for building, installing, packaging
8749:
8750: We checked to find a piece of software that wasn't in the packages collection,
1.25 wiz 8751: and picked GNU bison. Quite why someone would want to have bison when Berkeley
1.1 dsieger 8752: yacc is already present in the tree is beyond us, but it's useful for the
8753: purposes of this exercise.
8754:
8755: A.1. files
8756:
8757: A.1.1. Makefile
8758:
1.2 rillig 8759: # $NetBSD$
1.1 dsieger 8760: #
8761:
8762: DISTNAME= bison-1.25
8763: CATEGORIES= devel
1.171 rillig 8764: MASTER_SITES= ${MASTER_SITE_GNU:=bison/}
1.1 dsieger 8765:
1.30 dholland 8766: MAINTAINER= pkgsrc-users@NetBSD.org
1.174 leot 8767: HOMEPAGE= https://www.gnu.org/software/bison/bison.html
1.1 dsieger 8768: COMMENT= GNU yacc clone
8769:
8770: GNU_CONFIGURE= yes
1.47 wiz 8771: INFO_FILES= yes
1.1 dsieger 8772:
8773: .include "../../mk/bsd.pkg.mk"
8774:
8775: A.1.2. DESCR
8776:
8777: GNU version of yacc. Can make re-entrant parsers, and numerous other
8778: improvements. Why you would want this when Berkeley yacc(1) is part
8779: of the NetBSD source tree is beyond me.
8780:
8781: A.1.3. PLIST
8782:
1.2 rillig 8783: @comment $NetBSD$
1.1 dsieger 8784: bin/bison
8785: man/man1/bison.1.gz
8786: share/bison.simple
8787: share/bison.hairy
8788:
8789: A.1.4. Checking a package with pkglint
8790:
8791: The NetBSD package system comes with pkgtools/pkglint which helps to check the
8792: contents of these files. After installation it is quite easy to use, just
1.171 rillig 8793: change to the directory of the package you wish to examine and run pkglint:
1.1 dsieger 8794:
8795: $ pkglint
1.171 rillig 8796: ERROR: Makefile: Each package must define its LICENSE.
8797: WARN: Makefile:9: HOMEPAGE should migrate from http to https.
8798: NOTE: PLIST:3: The .gz extension is unnecessary for manual pages.
8799: WARN: PLIST:5: "share/bison.hairy" should be sorted before "share/bison.simple".
8800: 1 error, 2 warnings and 1 note found.
8801: (Run "pkglint -e" to show explanations.)
8802: (Run "pkglint -fs" to show what can be fixed automatically.)
1.172 rillig 8803: (Run "pkglint -F" to automatically fix some issues.)
1.1 dsieger 8804:
8805: Depending on the supplied command line arguments (see pkglint(1)), more checks
1.170 rillig 8806: will be performed. Use e.g. pkglint -Wall for a very thorough check.
1.1 dsieger 8807:
8808: A.2. Steps for building, installing, packaging
8809:
8810: Create the directory where the package lives, plus any auxiliary directories:
8811:
8812: # cd /usr/pkgsrc/lang
8813: # mkdir bison
8814: # cd bison
8815: # mkdir patches
8816:
1.184 rillig 8817: Create Makefile, DESCR and PLIST (see Chapter 12, Package components - files,
1.1 dsieger 8818: directories and contents) then continue with fetching the distfile:
8819:
8820: # make fetch
8821: >> bison-1.25.tar.gz doesn't seem to exist on this system.
8822: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
8823: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8824: ftp: Error retrieving file: 500 Internal error
8825:
8826: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
8827: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8828: ftp: Error retrieving file: 500 Internal error
8829:
8830: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
8831: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8832: Successfully retrieved file.
8833:
8834: Generate the checksum of the distfile into distinfo:
8835:
8836: # make makedistinfo
8837:
8838: Now compile:
8839:
8840: # make
8841: >> Checksum OK for bison-1.25.tar.gz.
8842: ===> Extracting for bison-1.25
8843: ===> Patching for bison-1.25
8844: ===> Ignoring empty patch directory
8845: ===> Configuring for bison-1.25
8846: creating cache ./config.cache
8847: checking for gcc... cc
8848: checking whether we are using GNU C... yes
8849: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
8850: checking how to run the C preprocessor... cc -E
8851: checking for minix/config.h... no
8852: checking for POSIXized ISC... no
8853: checking whether cross-compiling... no
8854: checking for ANSI C header files... yes
8855: checking for string.h... yes
8856: checking for stdlib.h... yes
8857: checking for memory.h... yes
8858: checking for working const... yes
8859: checking for working alloca.h... no
8860: checking for alloca... yes
8861: checking for strerror... yes
8862: updating cache ./config.cache
8863: creating ./config.status
8864: creating Makefile
8865: ===> Building for bison-1.25
8866: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g LR0.c
8867: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g allocate.c
8868: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g closure.c
8869: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g conflicts.c
8870: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g derives.c
8871: cc -c -DXPFILE=\"/usr/pkg/share/bison.simple\" -DXPFILE1=\"/usr/pkg/share/bison.hairy\" -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -g ./files.c
8872: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g getargs.c
8873: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g gram.c
8874: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g lalr.c
8875: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g lex.c
8876: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g main.c
8877: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g nullable.c
8878: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g output.c
8879: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g print.c
8880: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g reader.c
8881: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g reduce.c
8882: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g symtab.c
8883: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g warshall.c
8884: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g version.c
8885: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g getopt.c
8886: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g getopt1.c
8887: cc -g -o bison LR0.o allocate.o closure.o conflicts.o derives.o files.o getargs.o gram.o lalr.o lex.o main.o nullable.o output.o print.o reader.o reduce.o symtab.o warshall.o version.o getopt.o getopt1.o
8888: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
8889: rm -f bison.s1
8890: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
8891:
8892: Everything seems OK, so install the files:
8893:
8894: # make install
8895: >> Checksum OK for bison-1.25.tar.gz.
8896: ===> Installing for bison-1.25
8897: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
8898: rm -f /usr/pkg/bin/bison
8899: cd /usr/pkg/share; rm -f bison.simple bison.hairy
8900: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
8901: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
8902: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
8903: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
8904: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
8905: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
8906: ===> Registering installation for bison-1.25
8907:
8908: You can now use bison, and also - if you decide so - remove it with pkg_delete
8909: bison. Should you decide that you want a binary package, do this now:
8910:
8911: # make package
8912: >> Checksum OK for bison-1.25.tar.gz.
8913: ===> Building package for bison-1.25
8914: Creating package bison-1.25.tgz
8915: Registering depends:.
8916: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
8917:
8918: Now that you don't need the source and object files any more, clean up:
8919:
8920: # make clean
8921: ===> Cleaning for bison-1.25
8922:
1.207 leot 8923: Appendix B. Security hardening
8924:
8925: Table of Contents
8926:
8927: B.1. Mechanisms
8928:
8929: B.1.1. Enabled by default
8930: B.1.2. Not enabled by default
8931:
8932: B.2. Caveats
8933:
8934: B.2.1. Problems with PKGSRC_MKPIE
8935: B.2.2. Problems with PKGSRC_USE_FORTIFY
8936: B.2.3. Problems with PKGSRC_USE_RELRO
8937: B.2.4. Problems with PKGSRC_USE_SSP
8938:
8939: B.3. Auditing the system
8940:
8941: B.3.1. Checking for PIE
8942: B.3.2. Checking for partial RELRO
8943: B.3.3. Checking for full RELRO
8944: B.3.4. Checking for SSP
8945:
8946: A number of mechanisms are available in pkgsrc to improve the security of the
8947: resulting system. This page describes the mechanisms, and gives hints about
8948: detecting and fixing problems.
8949:
8950: Mechanisms can be enabled individually in mk.conf, and are individually
8951: described below.
8952:
8953: Typically, a feature will cause some programs to fail to build or work when
8954: first enabled. This can be due to latent problems in the program, and can be
8955: due to other reasons. After enough testing to have confidence that user
8956: problems will be quite rare, individual mechanisms will be enabled by default.
8957:
8958: For each mechanism, see the Caveats section below for an explanation of what
8959: might go wrong at compile time and at run time, and how to notice and address
8960: these problems.
8961:
8962: B.1. Mechanisms
8963:
8964: B.1.1. Enabled by default
8965:
8966: B.1.1.1. PKGSRC_USE_FORTIFY
8967:
8968: This allows substitute wrappers to be used for some commonly used library
8969: functions that do not have built-in bounds checking - but could in some cases.
8970:
8971: Two mitigation levels are available:
8972:
8973: * "weak" only enables checks at compile-time.
8974:
8975: * "strong" enables checks at compile-time and runtime.
8976:
8977: "strong" has been enabled by default since pkgsrc-2017Q3.
8978:
8979: B.1.1.2. PKGSRC_USE_SSP
8980:
8981: This enables a stack-smashing protection mitigation. It is done by adding a
8982: guard variable to functions with vulnerable objects. The guards are initialized
8983: when a function is entered and then checked when the function exits. The guard
8984: check will fail and the program forcibly exited if the variable was modified in
8985: the meantime. This can happen in case of buffer overflows or memory corruption,
8986: and therefore exposing these bugs.
8987:
8988: Different mitigation levels are available:
8989:
8990: * "yes", which will only protect functions considered vulnerable by the
8991: compiler;
8992:
8993: * "all", which will protect every function;
8994:
8995: * "strong", the default, which will apply a better balance between the two
8996: settings above.
8997:
8998: This mitigation is supported by both GCC and clang. It may be supported in
8999: additional compilers, possibly under a different name. It is particularly
9000: useful for unsafe programming languages, such as C/C++.
9001:
9002: * "yes" is enabled by default where known supported since pkgsrc-2017Q3.
9003:
9004: * "strong" is enabled by default where known supported since pkgsrc-2021Q4.
9005:
9006: More details can be found here:
9007:
9008: * Buffer overflow protection on Wikipedia
9009:
9010: B.1.1.3. PKGSRC_MKPIE
9011:
9012: This requests the creation of PIE (Position Independent Executables) for all
9013: executables. The PIE mechanism is normally used for shared libraries, so that
9014: they can be loaded at differing addresses at runtime. PIE itself does not have
9015: useful security properties; however, it is necessary to fully leverage some,
9016: such as ASLR. Some operating systems support Address Space Layout Randomization
9017: (ASLR), which causes different addresses to be used each time a program is run.
9018: This makes it more difficult for an attacker to guess addresses and thus makes
9019: exploits harder to construct. With PIE, ASLR can really be applied to the
9020: entire program, instead of the stack and heap only.
9021:
9022: PIE executables will only be built for toolchains that are known to support
9023: PIE. Currently, this means NetBSD on x86, ARM, SPARC64, m68k, and MIPS.
9024:
9025: PKGSRC_MKPIE was enabled by default after the pkgsrc-2021Q3 branch.
9026:
1.210 gutterid 9027: B.1.2. Not enabled by default
9028:
9029: B.1.2.1. PKGSRC_MKREPRO
9030:
9031: With this option, pkgsrc will try to build packages reproducibly. This allows
9032: packages built from the same tree and with the same options, to produce
9033: identical results bit by bit. This option should be combined with ASLR and
9034: PKGSRC_MKPIE to avoid predictable address offsets for attackers attempting to
9035: exploit security vulnerabilities.
9036:
9037: More details can be found here:
9038:
9039: * Reproducible Builds - a set of software development practices that create
9040: an independently-verifiable path from source to binary code
9041:
9042: More work likely needs to be done before pkgsrc is fully reproducible.
9043:
9044: B.1.2.2. PKGSRC_USE_RELRO
1.207 leot 9045:
9046: This also makes the exploitation of some security vulnerabilities more
9047: difficult in some cases.
9048:
9049: Two different mitigation levels are available:
9050:
9051: * partial: the ELF sections are reordered so that internal data sections
9052: precede the program's own data sections, and non-PLT GOT is read-only;
9053:
9054: * full: in addition to partial RELRO, every relocation is performed
9055: immediately when starting the program (with a slight performance impact),
9056: allowing the entire GOT to be read-only.
9057:
9058: This is currently supported by GCC. Many software distributions now enable this
1.210 gutterid 9059: feature by default, at the "partial" level. However, it cannot yet be enforced
9060: globally in pkgsrc through cwrappers.
1.207 leot 9061:
9062: More details can be found here:
9063:
9064: * Hardening ELF binaries using Relocation Read-Only (RELRO)
9065:
1.210 gutterid 9066: B.1.2.3. PKGSRC_USE_STACK_CHECK
1.207 leot 9067:
9068: This uses -fstack-check with GCC for another stack protection mitigation.
9069:
9070: It asks the compiler to generate code verifying that it does not corrupt the
9071: stack. According to GCC's manual page, this is really only useful for
9072: multi-threaded programs.
9073:
9074: B.2. Caveats
9075:
9076: B.2.1. Problems with PKGSRC_MKPIE
9077:
9078: B.2.1.1. Packages failing to build
9079:
9080: A number of packages may fail to build with this option enabled. The failures
9081: are often related to the absence of the -fPIC compilation flag when building
9082: libraries or executables (or ideally -fPIE in the latter case). This flag is
9083: added to the CFLAGS already, but requires the package to actually support it.
9084:
9085: B.2.1.1.1. How to fix
9086:
9087: These instructions are meant as a reference only; they likely need to be
9088: adapted for many packages individually.
9089:
9090: For packages using Makefiles:
9091:
9092: MAKE_FLAGS+= CFLAGS=${CFLAGS:Q}
9093: MAKE_FLAGS+= LDFLAGS=${LDFLAGS:Q}
9094:
9095: For packages using Imakefiles:
9096:
9097: MAKE_FLAGS+= CCOPTIONS=${CFLAGS:Q}
9098: MAKE_FLAGS+= LOCAL_LDFLAGS=${LDFLAGS:Q}
9099:
9100: B.2.1.2. Run-time crashes
9101:
9102: Some programs may fail to run, or crash at random times once built as PIE. Two
9103: scenarios are essentially possible. This is nearly always due to a bug in the
9104: program being exposed due to ASLR.
9105:
9106: B.2.1.3. Disabling PKGSRC_MKPIE on a per-package basis
9107:
9108: Ideally, packages should be fixed for compatibility with MKPIE. However, in
9109: some cases this is very difficult, due to complex build systems, packages using
9110: non-standard toolchains, or programming languages with odd bootstrapping
9111: mechanisms.
9112:
9113: To disable PKGSRC_MKPIE on a per-package basis, set MKPIE_SUPPORTED= no in the
9114: package's Makefile before bsd.prefs.mk is included.
9115:
9116: B.2.2. Problems with PKGSRC_USE_FORTIFY
9117:
9118: B.2.2.1. Packages failing to build
9119:
9120: This feature makes use of pre-processing directives to look for hardened,
9121: alternative implementations of essential library calls. Some programs may fail
9122: to build as a result; this usually happens for those trying too hard to be
9123: portable, or otherwise abusing definitions in the standard library.
9124:
9125: B.2.2.2. Run-time crashes
9126:
9127: This feature may cause some programs to crash, usually indicating an actual bug
9128: in the program. The fix will typically involve patching the original program's
9129: source code.
9130:
9131: B.2.2.3. Optimization is required
9132:
9133: At least in the case of GCC, FORTIFY will only be applied if optimization is
9134: applied while compiling. This means that the CFLAGS should also contain -O, -O2
9135: or another optimization level. This cannot easily be applied globally, as some
9136: packages may require specific optimization levels.
9137:
9138: B.2.2.4. Disabling FORTIFY on a per-package basis
9139:
9140: Note
9141:
9142: FORTIFY should not be disabled to work around runtime crashes in the program!
9143: This is a very bad idea and will expose you to security vulnerabilities.
9144:
9145: To disable FORTIFY on a per-package basis, set the following in the package's
9146: Makefile before bsd.prefs.mk is included:
9147:
9148: FORTIFY_SUPPORTED= no
9149:
9150: B.2.3. Problems with PKGSRC_USE_RELRO
9151:
9152: B.2.3.1. Performance impact
9153:
9154: For better protection, full RELRO requires every symbol to be resolved when the
9155: program starts, rather than simply when required at run-time. This will have
9156: more impact on programs using a lot of symbols, or linked to libraries exposing
9157: a lot of symbols. Therefore, daemons or programs otherwise running in
9158: background are affected only when started. Programs loading plug-ins at
9159: run-time are affected when loading the plug-ins.
9160:
9161: The impact is not expected to be noticeable on modern hardware, except in some
9162: cases for big programs.
9163:
9164: B.2.3.2. Run-time crashes
9165:
9166: Some programs handle plug-ins and dependencies in a way that conflicts with
9167: RELRO: for instance, with an initialization routine listing any other plug-in
9168: required. With full RELRO, the missing symbols are resolved before the
9169: initialization routine can run, and the dynamic loader will not be able to find
9170: them directly and abort as a result. Unfortunately, this is how Xorg loads its
9171: drivers. Partial RELRO can be applied instead in this case.
9172:
9173: B.2.3.3. Disabling RELRO on a per-package basis
9174:
9175: To disable RELRO on a per-package basis, set the following in the package's
9176: Makefile before bsd.prefs.mk is included:
9177:
9178: RELRO_SUPPORTED= no
9179:
1.209 nia 9180: It is also possible to at most enable partial RELRO, by setting RELRO_SUPPORTED
9181: to partial.
9182:
1.207 leot 9183: B.2.4. Problems with PKGSRC_USE_SSP
9184:
9185: B.2.4.1. Packages failing to build
9186:
9187: The stack-smashing protection provided by this option does not work for some
9188: programs. The most common situation in which this happens is when the program
9189: allocates variables on the stack, with the size determined at run-time.
9190:
9191: B.2.4.2. Run-time crashes
9192:
9193: Again, this feature may cause some programs to crash via a SIGABRT, usually
9194: indicating an actual bug in the program.
9195:
9196: On NetBSD LOG_CRIT level syslog messages are sent and - by default - appended
9197: to /var/log/messages, e.g.:
9198:
9199: Jan 6 15:42:51 hostname -: hostname program - - - buffer overflow detected; terminated
9200:
9201: (where hostname is the hostname(1) and program is the basename(1) of the
9202: program crashed).
9203:
9204: Patching the original program is then required.
9205:
9206: Rebuilding the package via:
9207:
9208: % env CFLAGS=-g INSTALL_UNSTRIPPED=yes make replace
9209:
9210: and inspecting the backtrace of the coredump via the debugger should point out
9211: the problematic call by inspecting the frame calling the _chk() (SSP) function.
9212:
9213: B.2.4.3. Performance impact
9214:
9215: The compiler emits extra code when using this feature: a check for buffer
9216: overflows is performed when entering and exiting functions, requiring an extra
9217: variable on the stack. The level of protection can otherwise be adjusted to
9218: affect only those functions considered more sensitive by the compiler (with
9219: -fstack-protector instead of -fstack-protector-all).
9220:
9221: The impact is not expected to be noticeable on modern hardware. However,
9222: programs with a hard requirement to run at the fastest possible speed should
9223: avoid using this feature, or using libraries built with this feature.
9224:
9225: B.2.4.4. Disabling SSP on a per-package basis
9226:
9227: Note
9228:
9229: SSP should not be disabled to work around runtime crashes in the program! This
9230: is a very bad idea and will expose you to security vulnerabilities.
9231:
9232: To disable SSP on a per-package basis, set the following in the package's
9233: Makefile before bsd.prefs.mk is included:
9234:
9235: SSP_SUPPORTED= no
9236:
9237: B.3. Auditing the system
9238:
9239: The illusion of security is worse than having no security at all. This section
9240: lists a number of ways to ensure the security features requested are actually
9241: effective.
9242:
9243: These instructions were obtained and tested on a system derived from NetBSD 7
9244: (amd64). YMMV.
9245:
9246: B.3.1. Checking for PIE
9247:
9248: The ELF executable type in use changes for binaries built as PIE; without:
9249:
9250: $ file /path/to/bin/ary
9251: /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
9252:
9253: as opposed to the following binary, built as PIE:
9254:
9255: $ file /path/to/pie/bin/ary
9256: /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
9257:
9258: The latter result is then what is expected.
9259:
9260: B.3.2. Checking for partial RELRO
9261:
9262: The following command should list a section called RELRO:
9263:
9264: $ objdump -p /path/to/bin/ary
9265:
9266: /path/to/bin/ary: file format elf64-x86-64
9267:
9268: Program Header:
9269: [...]
9270: RELRO off 0x0000000000000d78 vaddr 0x0000000000600d78 paddr 0x0000000000600d78 align 2**0
9271:
9272: This check is now performed automatically if PKG_DEVELOPER is set and RELRO is
9273: enabled.
9274:
9275: B.3.3. Checking for full RELRO
9276:
9277: The dynamic loader will apply RELRO immediately when detecting the presence of
9278: the BIND_NOW flag:
9279:
9280: $ objdump -x /path/to/bin/ary
9281:
9282: /path/to/bin/ary: file format elf64-x86-64
9283:
9284: Dynamic Section:
9285: [...]
9286: BIND_NOW 0x0000000000000000
9287:
9288: This has to be combined with partial RELRO (see above) to be fully efficient.
9289:
9290: This check is now performed automatically (where supported) if PKG_DEVELOPER is
9291: set.
9292:
9293: B.3.4. Checking for SSP
9294:
1.208 nia 9295: Note
9296:
9297: Checking for SSP using this method only works where the operating system uses
9298: libssp. libssp is not used on recent NetBSD/FreeBSD/Linux versions.
9299:
1.207 leot 9300: Building objects, binaries and libraries with SSP will affect the presence of
9301: additional symbols in the resulting file:
9302:
9303: $ nm /path/to/bin/ary
9304: [...]
9305: U __stack_chk_fail
9306: 0000000000600ea0 B __stack_chk_guard
9307:
9308: This is an indicator that the program was indeed built with support for SSP.
9309:
9310: This check is now performed automatically (where supported) if PKG_DEVELOPER is
9311: set and SSP is enabled.
9312:
9313: Appendix C. Build logs
1.1 dsieger 9314:
9315: Table of Contents
9316:
1.207 leot 9317: C.1. Building figlet
9318: C.2. Packaging figlet
1.1 dsieger 9319:
1.207 leot 9320: C.1. Building figlet
1.1 dsieger 9321:
9322: # make
9323: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9324: => figlet221.tar.gz doesn't seem to exist on this system.
9325: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
9326: => [172219 bytes]
9327: Connected to ftp.plig.net.
9328: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
9329: 331 Guest login ok, send your complete e-mail address as password.
9330: 230-You are user #5 of 500 simultaneous users allowed.
9331: 230-
9332: 230- ___ _ _ _
9333: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
9334: 230- | _| _| . |_| . | | | . |_| . | _| . |
9335: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
9336: 230- |_| |_| |___| |___|
9337: 230-
9338: 230-** Welcome to ftp.plig.org **
9339: 230-
9340: 230-Please note that all transfers from this FTP site are logged. If you
9341: 230-do not like this, please disconnect now.
9342: 230-
1.19 snj 9343: 230-This archive is available via
1.1 dsieger 9344: 230-
9345: 230-HTTP: http://ftp.plig.org/
9346: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
9347: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
9348: 230-
9349: 230-Please email comments, bug reports and requests for packages to be
9350: 230-mirrored to ftp-admin@plig.org.
9351: 230-
9352: 230-
9353: 230 Logged in anonymously.
9354: Remote system type is UNIX.
9355: Using binary mode to transfer files.
9356: 200 Type okay.
9357: 250 "/pub" is new cwd.
9358: 250-"/pub/figlet" is new cwd.
9359: 250-
9360: 250-Welcome to the figlet archive at ftp.figlet.org
9361: 250-
9362: 250- ftp://ftp.figlet.org/pub/figlet/
9363: 250-
9364: 250-The official FIGlet web page is:
9365: 250- http://www.figlet.org/
9366: 250-
9367: 250-If you have questions, please mailto:info@figlet.org. If you want to
9368: 250-contribute a font or something else, you can email us.
9369: 250
9370: 250 "/pub/figlet/program" is new cwd.
9371: 250 "/pub/figlet/program/unix" is new cwd.
9372: local: figlet221.tar.gz remote: figlet221.tar.gz
9373: 502 Unimplemented command.
9374: 227 Entering Passive Mode (195,40,6,41,246,104)
9375: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
9376: 38% |************** | 65800 64.16 KB/s 00:01 ETA
9377: 226 Transfer completed.
9378: 172219 bytes received in 00:02 (75.99 KB/s)
9379: 221 Goodbye.
9380: => Checksum OK for figlet221.tar.gz.
9381: ===> Extracting for figlet-2.2.1nb2
9382: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
9383: ===> Patching for figlet-2.2.1nb2
9384: ===> Applying pkgsrc patches for figlet-2.2.1nb2
9385: ===> Overriding tools for figlet-2.2.1nb2
9386: ===> Creating toolchain wrappers for figlet-2.2.1nb2
9387: ===> Configuring for figlet-2.2.1nb2
9388: ===> Building for figlet-2.2.1nb2
9389: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
9390: chmod a+x figlet
9391: gcc -O2 -o chkfont chkfont.c
9392: => Unwrapping files-to-be-installed.
9393: #
9394: # make install
9395: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9396: ===> Installing for figlet-2.2.1nb2
9397: install -d -o root -g wheel -m 755 /usr/pkg/bin
9398: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
9399: mkdir -p /usr/pkg/share/figlet
9400: cp figlet /usr/pkg/bin
9401: cp chkfont /usr/pkg/bin
9402: chmod 555 figlist showfigfonts
9403: cp figlist /usr/pkg/bin
9404: cp showfigfonts /usr/pkg/bin
9405: cp fonts/*.flf /usr/pkg/share/figlet
9406: cp fonts/*.flc /usr/pkg/share/figlet
9407: cp figlet.6 /usr/pkg/man/man6
9408: ===> Registering installation for figlet-2.2.1nb2
9409: #
9410:
1.207 leot 9411: C.2. Packaging figlet
1.1 dsieger 9412:
9413: # make package
9414: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9415: ===> Packaging figlet-2.2.1nb2
9416: ===> Building binary package for figlet-2.2.1nb2
9417: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
9418: Using SrcDir value of /usr/pkg
9419: Registering depends:.
9420: #
9421:
1.207 leot 9422: Appendix D. Directory layout of the pkgsrc FTP server
1.1 dsieger 9423:
9424: Table of Contents
9425:
1.207 leot 9426: D.1. distfiles: The distributed source files
9427: D.2. misc: Miscellaneous things
9428: D.3. packages: Binary packages
9429: D.4. reports: Bulk build reports
9430: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1 dsieger 9431:
9432: As in other big projects, the directory layout of pkgsrc is quite complex for
9433: newbies. This chapter explains where you find things on the FTP server. The
9434: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
9435: different, but inside this directory, everything should look the same, no
9436: matter on which server you are. This directory contains some subdirectories,
9437: which are explained below.
9438:
1.207 leot 9439: D.1. distfiles: The distributed source files
1.1 dsieger 9440:
9441: The directory distfiles contains lots of archive files from all pkgsrc
9442: packages, which are mirrored here. The subdirectories are called after their
9443: package names and are used when the distributed files have names that don't
9444: explicitly contain a version number or are otherwise too generic (for example
9445: release.tar.gz).
9446:
1.207 leot 9447: D.2. misc: Miscellaneous things
1.1 dsieger 9448:
9449: This directory contains things that individual pkgsrc developers find worth
9450: publishing.
9451:
1.207 leot 9452: D.3. packages: Binary packages
1.1 dsieger 9453:
1.3 rillig 9454: This directory contains binary packages for the various platforms that are
9455: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
9456: The meaning of these variables is:
9457:
9458: * OPSYS is the name of the operating system for which the packages have been
1.9 rillig 9459: built. The name is taken from the output of the uname command, so it may
9460: differ from the one you are used to hear.
1.3 rillig 9461:
1.8 rillig 9462: * ARCH is the hardware architecture of the platform for which the packages
1.10 hubertf 9463: have been built. It also includes the ABI (Application Binary Interface)
9464: for platforms that have several of them.
1.3 rillig 9465:
1.8 rillig 9466: * OSVERSION is the version of the operating system. For version numbers that
9467: change often (for example NetBSD-current), the often-changing part should
9468: be replaced with an x, for example 4.99.x.
1.3 rillig 9469:
1.23 jakllsch 9470: * TAG is either 20xxQy for a stable branch, or head for packages built from
1.8 rillig 9471: the HEAD branch. The latter should only be used when the packages are
9472: updated on a regular basis. Otherwise the date from checking out pkgsrc
9473: should be appended, for example head_20071015.
1.3 rillig 9474:
9475: The rationale for exactly this scheme is that the pkgsrc users looking for
9476: binary packages can quickly click through the directories on the server and
9477: find the best binary packages for their machines. Since they usually know the
9478: operating system and the hardware architecture, OPSYS and ARCH are placed
9479: first. After these choices, they can select the best combination of OSVERSION
9480: and TAG together, since it is usually the case that packages stay compatible
9481: between different version of the operating system.
9482:
9483: In each of these directories, there is a whole binary packages collection for a
9484: specific platform. It has a directory called All which contains all binary
9485: packages. Besides that, there are various category directories that contain
9486: symbolic links to the real binary packages.
1.1 dsieger 9487:
1.207 leot 9488: D.4. reports: Bulk build reports
1.8 rillig 9489:
9490: Here are the reports from bulk builds, for those who want to fix packages that
9491: didn't build on some of the platforms. The structure of subdirectories should
1.207 leot 9492: look like the one in Section D.3, "packages: Binary packages".
1.8 rillig 9493:
1.207 leot 9494: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1 dsieger 9495:
9496: These directories contain the "real" pkgsrc, that is the files that define how
9497: to create binary packages from source archives.
9498:
1.149 leot 9499: Each of the current, stable and pkgsrc-20xxQy directories share the same
9500: structure. They each contain a pkgsrc directory and pkgsrc.tar.{bz,gz,xz} file.
9501:
1.1 dsieger 9502: The directory pkgsrc contains a snapshot of the CVS repository, which is
1.149 leot 9503: updated regularly. The file pkgsrc.tar.{bz,gz,xz} contains the same as the
9504: directory, ready to be downloaded as a whole.
1.1 dsieger 9505:
1.149 leot 9506: The current directory contains files related to the HEAD branch of the CVS
9507: repository. In this directory there is an additional file called
9508: pkgsrc-readmes.tar.{bz,gz,xz} that contains all pkgsrc READMEs with information
9509: about categories and packages.
9510:
9511: The stable directory is a symlink to the latest pkgsrc-20xxQy.
9512:
9513: The pkgsrc-20xxQy. directories contain files related to the -20xxQy stable
9514: branch of the CVS repository. In these directories there is an additional file
9515: called pkgsrc-20xxQy.tar.{bz,gz,xz}, which contains the state of pkgsrc when it
9516: was branched.
1.148 leot 9517:
1.207 leot 9518: Appendix E. Help topics
1.154 rillig 9519:
9520: The following list contains all help topics that are available when running
9521: bmake help topic=:index.
9522:
1.217 ! rillig 9523: #! -lintl
! 9524: 32bit 64bit
! 9525: ABI ACCEPTABLE_LICENSES
! 9526: ACROREAD_FONTPATH ADDITIONAL
! 9527: AFAIK AIX
! 9528: ALLOW_VULNERABLE_PACKAGES ALL_ENV
! 9529: ALSA_PC ALTERNATIVES_SRC
! 9530: AMANDA_TMP AMANDA_USER
! 9531: AMANDA_VAR APACHE_GROUP
! 9532: APACHE_MODULE_NAME APACHE_MODULE_SRC
! 9533: APACHE_MODULE_SRCDIR APACHE_PKG_PREFIX
! 9534: APACHE_SUEXEC_CONFIGURE_ARGS APACHE_SUEXEC_DOCROOT
! 9535: APACHE_USER APPEND_ABI
! 9536: APPEND_ELF ARLA_CACHE
! 9537: AUDIT_PACKAGES_FLAGS AUTOCONF_REQD
! 9538: AUTOMAKE_OVERRIDE AUTOMAKE_REQD
! 9539: AUTO_MKDIRS BDB185_DEFAULT
! 9540: BDBBASE BDB_ACCEPTED
! 9541: BDB_DEFAULT BDB_LIBS
! 9542: BDB_TYPE BINCIMAP_GROUP
! 9543: BINCIMAP_USER BIND_DIR
! 9544: BIND_GROUP BIND_USER
! 9545: BINOWN BINPKG_SITES
! 9546: BIN_INSTALL_FLAGS BISON_PKGDATADIR
! 9547: BLAS BLAS_ACCEPTED
! 9548: BLAS_C_INTERFACE BLAS_INCLUDES
! 9549: BLAS_INDEX64 BLAS_LIBS
! 9550: BLAS_TYPE BOOTSTRAP_DEPENDS
! 9551: BROKEN BROKEN_EXCEPT_ON_PLATFORM
! 9552: BROKEN_ON_PLATFORM BSDSRCDIR
! 9553: BSDXSRCDIR BSD_MAKE_ENV
! 9554: BUILDLINK_AUTO_DIRS BUILDLINK_AUTO_VARS
! 9555: BUILDLINK_CFLAGS BUILDLINK_CONTENTS_FILTER
! 9556: BUILDLINK_CPPFLAGS BUILDLINK_DEPMETHOD
! 9557: BUILDLINK_FILES BUILDLINK_FILES_CMD
! 9558: BUILDLINK_FNAME_TRANSFORM BUILDLINK_LDFLAGS
! 9559: BUILDLINK_LIBS BUILDLINK_OPSYS_SUPPORT_PTHREAD
! 9560: BUILDLINK_PKGNAME BUILDLINK_PREFIX
! 9561: BUILDLINK_RPATHDIRS BUILDLINK_TREE
! 9562: BUILD_DEFS BUILD_DEFS_EFFECTS
! 9563: BUILD_DEPENDS BUILD_DIRS
! 9564: BUILD_ENV_SHELL BUILD_MAKE_CMD
! 9565: BUILD_MAKE_FLAGS BUILD_TARGET
! 9566: BUILTIN_FIND_FILES BUILTIN_FIND_FILES_VAR
! 9567: BUILTIN_FIND_GREP BUILTIN_FIND_HEADERS
! 9568: BUILTIN_FIND_HEADERS_VAR BUILTIN_FIND_PKGCONFIG
! 9569: BUILTIN_FIND_PKGCONFIG_VAR BUILTIN_PKG
! 9570: BUILTIN_TEST_CURSES_DEFINES BUILTIN_TEST_CURSES_FUNCS
! 9571: BUILTIN_VERSION_SCRIPT BUILTIN_X11_TYPE
! 9572: BUILTIN_X11_VERSION CACTI_GROUP
! 9573: CACTI_USER CANNA_GROUP
! 9574: CANNA_USER CAT
! 9575: CBLAS_LIBS CCACHE_BASE
! 9576: CCACHE_DIR CCACHE_LOGFILE
! 9577: CC_VERSION CC_VERSION_STRING
! 9578: CDRECORD_CONF CDROM_PKG_URL_DIR
! 9579: CDROM_PKG_URL_HOST CHECKOUT_DATE
! 9580: CHECK_COMPILER CHECK_FAKEHOME
! 9581: CHECK_FILES CHECK_FILES_SKIP
! 9582: CHECK_FILES_STRICT CHECK_HEADERS
! 9583: CHECK_HEADERS_SKIP CHECK_INTERPRETER
! 9584: CHECK_INTERPRETER_SKIP CHECK_PERMS
! 9585: CHECK_PERMS_AUTOFIX CHECK_PERMS_SKIP
! 9586: CHECK_PIE CHECK_PIE_SKIP
! 9587: CHECK_PIE_SUPPORTED CHECK_PORTABILITY
! 9588: CHECK_PORTABILITY_EXPERIMENTAL CHECK_PORTABILITY_SKIP
! 9589: CHECK_RELRO CHECK_RELRO_SKIP
! 9590: CHECK_RELRO_SUPPORTED CHECK_SHLIBS
! 9591: CHECK_SHLIBS_SKIP CHECK_SHLIBS_SUPPORTED
! 9592: CHECK_SHLIBS_TOXIC CHECK_SSP
! 9593: CHECK_SSP_SKIP CHECK_SSP_SUPPORTED
! 9594: CHECK_STRIPPED CHECK_STRIPPED_SKIP
! 9595: CHECK_WRKREF CHECK_WRKREF_EXTRA_DIRS
! 9596: CHECK_WRKREF_SKIP CLAMAV_DBDIR
! 9597: CLAMAV_GROUP CLAMAV_USER
! 9598: CLANGBASE CLEANDEPENDS
! 9599: CMAKE_DEPENDENCIES_REWRITE CMAKE_INSTALL_NAME_DIR
! 9600: CMAKE_INSTALL_PREFIX CMAKE_MODULE_PATH_OVERRIDE
! 9601: CMAKE_PKGSRC_BUILD_FLAGS CMAKE_PREFIX_PATH
! 9602: CMAKE_USE_GNU_INSTALL_DIRS COMMON_LISP_DOCFILES
! 9603: COMMON_LISP_EXAMPLES COMMON_LISP_EXTRAFILES
! 9604: COMMON_LISP_PACKAGES COMMON_LISP_SYSTEM
! 9605: COMPILER_RPATH_FLAG COMPILER_USE_SYMLINKS
! 9606: CONFIGURE_ARGS CONFIGURE_DIRS
! 9607: CONFIGURE_ENV CONFIGURE_ENV_SHELL
! 9608: CONFIGURE_HAS_INFODIR CONFIGURE_HAS_MANDIR
! 9609: CONFIGURE_SCRIPT CONFIG_SHELL
! 9610: CONFIG_SHELL_FLAGS CONF_FILES
! 9611: CONF_FILES_MODE CONF_FILES_PERMS
! 9612: CONSERVER_DEFAULTHOST CONSERVER_DEFAULTPORT
! 9613: CP CPP
! 9614: CPP_PRECOMP_FLAGS CREATE_WRKDIR_SYMLINK
! 9615: CROSSBASE CTFCONVERT
! 9616: CTF_FILES_SKIP CTF_SUPPORTED
! 9617: CTYPE CUPS_GROUP
! 9618: CUPS_SYSTEM_GROUPS CUPS_USER
! 9619: CURSES_DEFAULT CURSES_TYPE
! 9620: CVS_EXTRACTDIR CVS_MODULE
! 9621: CVS_PROJECT CVS_REPOSITORIES
! 9622: CVS_ROOT CVS_ROOT_GNU
! 9623: CVS_ROOT_NONGNU CVS_ROOT_SOURCEFORGE
! 9624: CVS_TAG CXX
! 9625: CYRUS_GROUP CYRUS_IDLE
! 9626: CYRUS_USER DAEMONTOOLS_GROUP
! 9627: DAEMONTOOLS_LOG_USER DARWIN_NO_SYSTEM_LIBS
! 9628: DARWIN_REQUIRES_FILTER DBUS_GROUP
! 9629: DBUS_USER DEFANG_GROUP
! 9630: DEFANG_USER DEFAULT_ACCEPTABLE_LICENSES
! 9631: DEFAULT_DISTFILES DEFAULT_IRC_SERVER
! 9632: DEFAULT_SERIAL_DEVICE DEF_UMASK
! 9633: DEINSTALLDEPENDS DEINSTALL_SRC
! 9634: DEINSTALL_TEMPLATES DELAYED_ERROR_MSG
! 9635: DELAYED_WARNING_MSG DEPENDS
! 9636: DEPENDS_TARGET DEPENDS_TYPE
! 9637: DESTDIR DESTDIR_VARNAME
! 9638: DIALER_GROUP DIGEST_REQD
! 9639: DISTDIR DISTFILES
! 9640: DISTINFO_FILE DISTNAME
! 9641: DIST_PATH DIST_SUBDIR
! 9642: DJBDNS_AXFR_USER DJBDNS_CACHE_USER
! 9643: DJBDNS_DJBDNS_GROUP DJBDNS_LOG_USER
! 9644: DJBDNS_RBL_USER DJBDNS_TINY_USER
! 9645: DLOPEN_REQUIRE_PTHREADS DL_AUTO_VARS
! 9646: DL_CFLAGS DL_LDFLAGS
! 9647: DL_LIBS DNS
! 9648: DOCOWN DOWNLOADED_DISTFILE
! 9649: DT_LAYOUT DYNAMIC_SITES_CMD
! 9650: DYNAMIC_SITES_SCRIPT ECHO
! 9651: ECHO_N ELK_GUI
! 9652: EMACS_TYPE EMULDIR
! 9653: EMULSUBDIR EMULSUBDIRSLASH
! 9654: EMUL_ARCH EMUL_DISTRO
! 9655: EMUL_EXEC_FMT EMUL_IS_NATIVE
! 9656: EMUL_MODULES EMUL_OPSYS
! 9657: EMUL_PKG_FMT EMUL_PLATFORM
! 9658: EMUL_PLATFORMS EMUL_PREFER
! 9659: EMUL_REQD EMUL_TYPE
! 9660: ERROR_MSG EXIM_GROUP
! 9661: EXIM_USER EXPORT_SYMBOLS_LDFLAGS
! 9662: EXTRACTOR EXTRACT_CMD
! 9663: EXTRACT_CMD_DEFAULT EXTRACT_DIR
! 9664: EXTRACT_ELEMENTS EXTRACT_ENV
! 9665: EXTRACT_ONLY EXTRACT_OPTS
! 9666: EXTRACT_SUFX EXTRACT_USING
! 9667: FAIL FAILOVER_FETCH
! 9668: FAIL_MSG FAKE_NCURSES
! 9669: FAM FAM_ACCEPTED
! 9670: FAM_DEFAULT FAM_SERVER
! 9671: FCPATH FEATURE_CPPFLAGS
! 9672: FEATURE_LDFLAGS FEATURE_LIBS
! 9673: FETCH_AFTER_ARGS FETCH_BEFORE_ARGS
! 9674: FETCH_CMD FETCH_OUTPUT_ARGS
! 9675: FETCH_PROXY FETCH_RESUME_ARGS
! 9676: FETCH_TIMEOUT FETCH_USE_IPV4_ONLY
! 9677: FETCH_USING FILES_SUBST
! 9678: FILES_SUBST_SED FIX_SYSTEM_HEADERS
! 9679: FLUXBOX_USE_GNOME FLUXBOX_USE_KDE
! 9680: FLUXBOX_USE_XFT FLUXBOX_USE_XINERAMA
! 9681: FONTDIR FONTS_DIRS
! 9682: FONTS_VERBOSE FOO_HACKS_MK
! 9683: FOSSIL_EXTRACTDIR FOSSIL_REPO
! 9684: FOSSIL_REPOSITORIES FOSSIL_VERSION
! 9685: FOX_USE_XUNICODE FREEWNN_GROUP
! 9686: FREEWNN_USER FTP_PKG_URL_DIR
! 9687: FTP_PKG_URL_HOST GAMEDATAMODE
! 9688: GAMEDATA_PERMS GAMEDIRMODE
! 9689: GAMEDIR_PERMS GAMEGRP
! 9690: GAMEMODE GAMEOWN
! 9691: GAMES_GROUP GAMES_USER
! 9692: GCC GCCBASE
! 9693: GCC_REQD GCC_VERSION_SUFFIX
! 9694: GEM_BUILD GEM_CLEANBUILD
! 9695: GEM_CLEANBUILD_EXTENSIONS GEM_DOCDIR
! 9696: GEM_EXTSDIR GEM_HOME
! 9697: GEM_KEEPBUILD GEM_LIBDIR
! 9698: GEM_NAME GEM_PATH
! 9699: GEM_PLUGINSDIR GEM_SPECFILE
! 9700: GENERATE_PLIST GHC
! 9701: GHOSTSCRIPT_REQD GITHUB_PROJECT
! 9702: GITHUB_RELEASE GITHUB_SUBMODULES
! 9703: GITHUB_TAG GITHUB_TYPE
! 9704: GITLAB_PROJECT GITLAB_TAG
! 9705: GITLAB_TYPE GIT_BRANCH
! 9706: GIT_ENV GIT_EXTRACTDIR
! 9707: GIT_REPO GIT_REPOSITORIES
! 9708: GIT_REVISION GIT_TAG
! 9709: GNU GNU_CONFIGURE
! 9710: GNU_CONFIGURE_INFODIR GNU_CONFIGURE_MANDIR
! 9711: GNU_CONFIGURE_QUIET GNU_CONFIGURE_STRICT
! 9712: GODEP_REDIRECTS GO_BUILD_PATTERN
! 9713: GO_DEPS GO_DIST_BASE
! 9714: GO_EXTRA_MOD_DIRS GO_MODULE_FILES
! 9715: GO_SRCPATH GO_VERSION_DEFAULT
! 9716: GROUP_SPECIFIC_PKGS GRUB_NETWORK_CARDS
! 9717: GRUB_PRESET_COMMAND GRUB_SCAN_ARGS
! 9718: GZIP HASKELL_COMPILER
! 9719: HASKELL_ENABLE_HADDOCK_DOCUMENTATION HASKELL_ENABLE_LIBRARY_PROFILING
! 9720: HASKELL_ENABLE_SHARED_LIBRARY HASKELL_OPTIMIZATION_LEVEL
! 9721: HAS_CONFIGURE HEADER_TEMPLATES
! 9722: HG_REPO HG_REPOSITORIES
! 9723: HG_TAG HOMEPAGE
! 9724: HOST_PKGTOOLS_ARGS HOST_SPECIFIC_PKGS
! 9725: HOWL_GROUP HOWL_USER
! 9726: ICCBASE ICECAST_CHROOTDIR
! 9727: ICON_THEMES IDOBASE
! 9728: IGNORE_CCACHE IGNORE_INFO_DIRS
! 9729: IGNORE_INTERACTIVE_FETCH IMAKE
! 9730: IMAKEOPTS IMAKE_MAKE
! 9731: IMAKE_MANINSTALL IMAP_UW_CCLIENT_MBOX_FMT
! 9732: IMDICTDIR INCOMPAT_CURSES
! 9733: INFO_DIR INFO_FILES
! 9734: INFO_FILES_VERBOSE INFO_MSG
! 9735: INIT_SYSTEM INN_DATA_DIR
! 9736: INN_GROUP INN_USER
! 9737: INSTALLATION_DIRS INSTALLATION_DIRS_FROM_PLIST
! 9738: INSTALL_ENV INSTALL_SH_OVERRIDE
! 9739: INSTALL_SRC INSTALL_TEMPLATES
! 9740: INSTALL_UNSTRIPPED IRCD_HYBRID_IRC_GROUP
! 9741: IRCD_HYBRID_IRC_USER IRCD_HYBRID_MAXCONN
! 9742: IRCD_HYBRID_NICLEN IRCD_HYBRID_SYSLOG_EVENTS
! 9743: IRCD_HYBRID_SYSLOG_FACILITY IRCD_HYBRID_TOPICLEN
! 9744: IRIX IRRD_USE_PGP
! 9745: JABBERD_GROUP JABBERD_LOGDIR
! 9746: JABBERD_PIDDIR JABBERD_SPOOLDIR
! 9747: JABBERD_USER JAKARTA_HOME
! 9748: JAVA_APP_PATH JAVA_APP_TARGETS
! 9749: JAVA_BINPREFIX JAVA_CLASSPATH
! 9750: JAVA_HOME JAVA_LD_LIBRARY_PATH
! 9751: JAVA_NAME JAVA_UNLIMIT
! 9752: JAVA_WRAPPERS JPEG_ACCEPTED
! 9753: JPEG_DEFAULT KERBEROS
! 9754: KERMIT_SUID_UUCP KJS_USE_PCRE
! 9755: KNEWS_DOMAIN_FILE KNEWS_DOMAIN_NAME
! 9756: KRB5_ACCEPTED KRB5_DEFAULT
! 9757: LANGUAGES LAPACKE_LIBS
! 9758: LAPACK_LIBS LATEX2HTML_ICONPATH
! 9759: LDCONFIG_ADD_CMD LDCONFIG_REMOVE_CMD
! 9760: LDD LEAFNODE_DATA_DIR
! 9761: LEAFNODE_GROUP LEAFNODE_USER
! 9762: LIBDVDCSS_HOMEPAGE LIBDVDCSS_MASTER_SITES
! 9763: LIBRSVG_TYPE LIBTOOL
! 9764: LIBTOOLIZE_PLIST LIBTOOL_M4_OVERRIDE
! 9765: LIBUSB_TYPE LICENSE
! 9766: LINKER_RPATH_FLAG LINK_RPATH_FLAG
! 9767: LINUX_BASE_NODEPS LINUX_BASE_PREFERRED
! 9768: LINUX_BASE_REQUIRED LINUX_LOCALES
! 9769: LOCALBASE LOCALBASE_LOCKTYPE
! 9770: LOCALPATCHES LOVE_DATA
! 9771: LOVE_GAME LOVE_VERSION
! 9772: LP32PLATFORMS LP64PLATFORMS
! 9773: MACHINE_PLATFORM MAILAGENT_DOMAIN
! 9774: MAILAGENT_EMAIL MAILAGENT_FQDN
! 9775: MAILAGENT_ORGANIZATION MAJORDOMO_HOMEDIR
! 9776: MAJOR_OS_VERSION MAKEINFO_ARGS
! 9777: MAKE_DIRS MAKE_DIRS_PERMS
! 9778: MAKE_ENV MAKE_FILE
! 9779: MAKE_FLAGS MAKE_JOBS
! 9780: MAKE_JOBS_SAFE MAKE_PROGRAM
! 9781: MANCOMPRESSED_IF_MANZ MANINSTALL
! 9782: MANZ MASTER_SITES
! 9783: MASTER_SITE_BACKUP MASTER_SITE_LOCAL
! 9784: MASTER_SITE_MOZILLA MASTER_SITE_OVERRIDE
! 9785: MASTER_SITE_PERL_CPAN MASTER_SORT
! 9786: MASTER_SORT_RANDOM MASTER_SORT_REGEX
! 9787: MECAB_CHARSET MEDIATOMB_GROUP
! 9788: MEDIATOMB_USER MIPSPROBASE
! 9789: MIREDO_GROUP MIREDO_USER
! 9790: MISSING_FEATURES MKDIR
! 9791: MKPIE_SUPPORTED MLDONKEY_GROUP
! 9792: MLDONKEY_HOME MLDONKEY_USER
! 9793: MONOTONE_GROUP MONOTONE_USER
! 9794: MOTIFBASE MOTIF_TYPE
! 9795: MOTIF_TYPE_DEFAULT MPI_TYPE
! 9796: MSGFMT_STRIP_MSGCTXT MSGFMT_STRIP_MSGID_PLURAL
! 9797: MTOOLS_ENABLE_FLOPPYD MUST
! 9798: MV MYSQL_CHARSET
! 9799: MYSQL_DATADIR MYSQL_EXTRA_CHARSET
! 9800: MYSQL_GROUP MYSQL_USER
! 9801: MYSQL_VERSION MYSQL_VERSIONS_ACCEPTED
! 9802: MYSQL_VERSIONS_ALL MYSQL_VERSION_DEFAULT
! 9803: NAGIOSCMD_GROUP NAGIOSDIR
! 9804: NAGIOS_GROUP NAGIOS_USER
! 9805: NATIVE_APPEND_ABI NATIVE_APPEND_ELF
! 9806: NATIVE_EXEC_FMT NATIVE_MACHINE_PLATFORM
! 9807: NATIVE_OBJECT_FMT NBPAX_PROGRAM_PREFIX
! 9808: NETBSD_LOGIN_NAME NMH_EDITOR
! 9809: NMH_MTA NMH_PAGER
! 9810: NOLOGIN NOTE
! 9811: NOT_FOR_PLATFORM NOT_PAX_ASLR_SAFE
! 9812: NOT_PAX_MPROTECT_SAFE NO_BUILD
! 9813: NO_CHECKSUM NO_CONFIGURE
! 9814: NO_SKIP NS_PREFERRED
! 9815: NULLMAILER_GROUP NULLMAILER_USER
! 9816: OASIS OASIS_BUILD_ARGS
! 9817: OBJHOSTNAME OBJMACHINE
! 9818: OCAML_FINDLIB_DIRS OCAML_FINDLIB_REGISTER
! 9819: OCAML_FINDLIB_REGISTER_VERBOSE OCAML_SITELIBDIR
! 9820: OCAML_TOPKG_DOCDIR OCAML_USE_DUNE
! 9821: OCAML_USE_FINDLIB OCAML_USE_JBUILDER
! 9822: OCAML_USE_OASIS OCAML_USE_OASIS_DYNRUN
! 9823: OCAML_USE_OPAM OCAML_USE_OPT_COMPILER
! 9824: OCAML_USE_TOPKG OMF
! 9825: ONLY_FOR_COMPILER ONLY_FOR_PLATFORM
! 9826: OPENSSH_CHROOT OPENSSH_GROUP
! 9827: OPENSSH_USER OPSYS
! 9828: OPSYS_EMULDIR OPSYS_VERSION
! 9829: OS OSS_TYPE
! 9830: OSX OSX_TOLERATE_SDK_SKEW
! 9831: OS_HAVE_ALSA OS_HAVE_RCD
! 9832: OS_VARIANT OS_VERSION
! 9833: OTF_FONTS_DIR OVERRIDE_DIRDEPTH
! 9834: OVERRIDE_GEMSPEC OVERRIDE_GNU_CONFIG_SCRIPTS
! 9835: OVERRIDE_ROCKSPEC OWN_DIRS
! 9836: OWN_DIRS_PERMS P4GROUP
! 9837: P4PORT P4ROOT
! 9838: P4USER PACKAGES
! 9839: PALMOS_DEFAULT_SDK PAMBASE
! 9840: PAM_DEFAULT PAPERSIZE
! 9841: PASSIVE_FETCH PATCHDIR
! 9842: PATCHFILES PATCH_ARGS
! 9843: PATCH_DEBUG PATCH_DIST_ARGS
! 9844: PATCH_DIST_CAT PATCH_DIST_STRIP
! 9845: PATCH_FUZZ_FACTOR PATCH_STRIP
! 9846: PATH PCCBASE
! 9847: PEAR PEAR_CHANNEL
! 9848: PEAR_CHANNEL_ALIAS PEAR_CHANNEL_VERSION
! 9849: PEAR_CMD PEAR_LIB
! 9850: PEAR_PACKAGE_XML PERL5
! 9851: PERL5_CONFIGURE PERL5_CONFIGURE_DIRS
! 9852: PERL5_LDFLAGS PERL5_LICENSE
! 9853: PERL5_MODULE_TYPE PERL5_PACKLIST
! 9854: PERL5_PACKLIST_DIR PERL5_PERLBASE
! 9855: PERL5_SITEBASE PERL5_USE_PACKLIST
! 9856: PERL5_VENDORBASE PFCTL
! 9857: PFVAR_H PF_VERSION
! 9858: PGGROUP PGHOME
! 9859: PGPKGSRCDIR PGSQL_TYPE
! 9860: PGSQL_VERSION PGSQL_VERSIONS_ACCEPTED
! 9861: PGSQL_VERSION_DEFAULT PGUSER
! 9862: PG_LIB_EXT PHP
! 9863: PHPCOMMON_MK PHPPKGSRCDIR
! 9864: PHP_BASE_VERS PHP_CHECK_INSTALLED
! 9865: PHP_EXTENSION_DIR PHP_INITIAL_TEENY
! 9866: PHP_PKG_PREFIX PHP_VERSION
! 9867: PHP_VERSIONS_ACCEPTED PHP_VERSIONS_INCOMPATIBLE
! 9868: PHP_VERSION_DEFAULT PHP_VERSION_REQD
! 9869: PILRC_USE_GTK PKGCONFIG_BASE
! 9870: PKGCONFIG_FILE PKGCONFIG_OVERRIDE
! 9871: PKGCONFIG_OVERRIDE_STAGE PKGDIR
! 9872: PKGGNUDIR PKGINFODIR
! 9873: PKGLOCALEDIR PKGMANDIR
! 9874: PKGNAME PKGNAME_REQD
! 9875: PKGPATH PKGREVISION
! 9876: PKGSRC_BLAS_TYPES PKGSRC_CHANGES
! 9877: PKGSRC_COMPILER PKGSRC_KEEP_BIN_PKGS
! 9878: PKGSRC_LOCKTYPE PKGSRC_MAKE_ENV
! 9879: PKGSRC_MESSAGE_RECIPIENTS PKGSRC_MKPIE
! 9880: PKGSRC_MKREPRO PKGSRC_OVERRIDE_MKPIE
! 9881: PKGSRC_RUN_TEST PKGSRC_SETENV
! 9882: PKGSRC_SLEEPSECS PKGSRC_TODO
! 9883: PKGSRC_USE_CTF PKGSRC_USE_FORTIFY
! 9884: PKGSRC_USE_RELRO PKGSRC_USE_SSP
! 9885: PKGSRC_USE_STACK_CHECK PKGTASKS_DATAFILE
! 9886: PKGTOOLS_ARGS PKGTOOLS_ENV
! 9887: PKG_ALTERNATIVES PKG_APACHE
! 9888: PKG_APACHE_ACCEPTED PKG_APACHE_DEFAULT
! 9889: PKG_BEST_EXISTS PKG_BUILD_OPTIONS
! 9890: PKG_COMPRESSION PKG_CONFIG
! 9891: PKG_CONFIG_PERMS PKG_CREATE_USERGROUP
! 9892: PKG_DB_TMPDIR PKG_DEBUG_LEVEL
! 9893: PKG_DEFAULT_OPTIONS PKG_DESTDIR_SUPPORT
! 9894: PKG_DEVELOPER PKG_DISABLED_OPTIONS
! 9895: PKG_FATAL_ERRORS PKG_FC
! 9896: PKG_FILELIST_CMD PKG_GECOS
! 9897: PKG_GID PKG_GROUPS
! 9898: PKG_GROUPS_VARS PKG_HOME
! 9899: PKG_INIT_SCRIPTS PKG_JAVA_HOME
! 9900: PKG_JVM PKG_JVMS_ACCEPTED
! 9901: PKG_JVM_DEFAULT PKG_LEGACY_OPTIONS
! 9902: PKG_LIBTOOL PKG_OPTIONS
! 9903: PKG_OPTIONS_DEPRECATED_WARNINGS PKG_OPTIONS_LEGACY_OPTS
! 9904: PKG_OPTIONS_LEGACY_VARS PKG_OPTIONS_NONEMPTY_SETS
! 9905: PKG_OPTIONS_OPTIONAL_GROUPS PKG_OPTIONS_REQUIRED_GROUPS
! 9906: PKG_OPTIONS_VAR PKG_PHP
! 9907: PKG_PHP_MAJOR_VERS PKG_PHP_VERSION
! 9908: PKG_RCD_SCRIPTS PKG_REFCOUNT_DBDIR
! 9909: PKG_REGISTER_SHELLS PKG_RESUME_TRANSFERS
! 9910: PKG_SHELL PKG_SUGGESTED_OPTIONS
! 9911: PKG_SUPPORTED_OPTIONS PKG_SYSCONFBASE
! 9912: PKG_SYSCONFBASEDIR PKG_SYSCONFDIR
! 9913: PKG_SYSCONFDIR_PERMS PKG_SYSCONFSUBDIR
! 9914: PKG_SYSCONFVAR PKG_TOOLS_BIN
! 9915: PKG_UID PKG_UPDATE_FONTS_DB
! 9916: PKG_USERS PKG_USERS_VARS
! 9917: PKG_VERBOSE PLEASE
! 9918: PLIST PLIST_AWK
! 9919: PLIST_AWK_ENV PLIST_SRC
! 9920: PLIST_SUBST PLIST_TYPE
! 9921: PLIST_VARS POPTOP_USE_MPPE
! 9922: POSSIBLE_GFORTRAN_VERSION POST_FETCH_HOOK
! 9923: PREFER PREFER_NATIVE
! 9924: PREFER_NATIVE_PTHREADS PREFER_PKGSRC
! 9925: PREFIX PREPEND_PATH
! 9926: PRE_ROOT_CMD PRIVILEGED_STAGES
! 9927: PS PTHREAD_AUTO_VARS
! 9928: PTHREAD_CFLAGS PTHREAD_LDFLAGS
! 9929: PTHREAD_LIBS PTHREAD_OPTS
! 9930: PTHREAD_TYPE PVM_SSH
! 9931: PYPKGPREFIX PYTHON_FOR_BUILD_ONLY
! 9932: PYTHON_SELF_CONFLICT PYTHON_VERSIONED_DEPENDENCIES
! 9933: PYTHON_VERSIONS_ACCEPTED PYTHON_VERSIONS_INCOMPATIBLE
! 9934: PYTHON_VERSION_DEFAULT PYTHON_VERSION_REQD
! 9935: PYVERSSUFFIX QMAILDIR
! 9936: QMAIL_ALIAS_USER QMAIL_DAEMON_USER
! 9937: QMAIL_LOG_USER QMAIL_NOFILES_GROUP
! 9938: QMAIL_PASSWD_USER QMAIL_QMAIL_GROUP
! 9939: QMAIL_QUEUE_DIR QMAIL_QUEUE_EXTRA
! 9940: QMAIL_QUEUE_USER QMAIL_REMOTE_USER
! 9941: QMAIL_ROOT_USER QMAIL_SEND_USER
! 9942: QPOPPER_FAC QPOPPER_SPOOL_DIR
! 9943: QPOPPER_USER RAKE_NAME
! 9944: RASMOL_DEPTH RCD_DIR
! 9945: RCD_ORDER RCD_SCRIPTS
! 9946: RCD_SCRIPTS_DIR RCD_SCRIPTS_EXAMPLEDIR
! 9947: RCD_SCRIPTS_MODE RCD_SCRIPTS_SHELL
! 9948: RCD_SCRIPT_SRC RCD_SUBR
! 9949: RDOC READLINE_DEFAULT
! 9950: READLINE_TYPE REAL_ROOT_GROUP
! 9951: REAL_ROOT_USER RECURSIVE_MAKE
! 9952: RELAY_CTRL_DIR RELRO_SUPPORTED
! 9953: REPLACE_AWK REPLACE_BASH
! 9954: REPLACE_CSH REPLACE_KSH
! 9955: REPLACE_PERL REPLACE_PERL6
! 9956: REPLACE_PHP REPLACE_PYTHON
! 9957: REPLACE_R REPLACE_RUBY
! 9958: REPLACE_RUBY_DIRS REPLACE_RUBY_PAT
! 9959: REPLACE_SH REPLACE_TEXLUA
! 9960: REQD_DIRS REQD_DIRS_PERMS
! 9961: REQD_FILES REQD_FILES_MODE
! 9962: REQD_FILES_PERMS RESOLV_AUTO_VARS
! 9963: RESOLV_LDFLAGS RESOLV_LIBS
! 9964: RM ROCKSPEC_NAME
! 9965: ROCKSPEC_SPECFILE ROOT_CMD
! 9966: ROOT_GROUP ROOT_USER
! 9967: RPCGEN RPM
! 9968: RPM2PKG_PLIST RPM2PKG_PREFIX
! 9969: RPM2PKG_STAGE RPM2PKG_STRIP
! 9970: RPM2PKG_SUBPREFIX RPMFILES
! 9971: RPMIGNOREPATH RPM_DB_PREFIX
! 9972: RSSH_CVS_PATH RSSH_RDIST_PATH
! 9973: RSSH_RSYNC_PATH RSSH_SCP_PATH
! 9974: RSSH_SFTP_SERVER_PATH RUBY
! 9975: RUBYGEM RUBYGEM_NAME
! 9976: RUBYGEM_OPTIONS RUBYGEM_VERBOSE
! 9977: RUBY_ABI_VERSION RUBY_ARCH
! 9978: RUBY_ARCHINC RUBY_ARCHLIB
! 9979: RUBY_BASE RUBY_BASERIDIR
! 9980: RUBY_BUILD_DOCUMENT RUBY_DLEXT
! 9981: RUBY_DOC RUBY_DYNAMIC_DIRS
! 9982: RUBY_EG RUBY_ENCODING_ARG
! 9983: RUBY_EXTCONF RUBY_EXTCONF_CHECK
! 9984: RUBY_EXTCONF_DEBUG RUBY_EXTCONF_MAKEFILE
! 9985: RUBY_GEM_ARCH RUBY_GEM_BASE
! 9986: RUBY_INC RUBY_LIB
! 9987: RUBY_LIB_BASE RUBY_NAME
! 9988: RUBY_NOVERSION RUBY_PKGPREFIX
! 9989: RUBY_RAILS RUBY_RAILS52_VERSION
! 9990: RUBY_RAILS60_VERSION RUBY_RAILS61_VERSION
! 9991: RUBY_RAILS70_VERSION RUBY_RAILS_ACCEPTED
! 9992: RUBY_RAILS_DEFAULT RUBY_RAILS_REQD
! 9993: RUBY_RAILS_STRICT_DEP RUBY_RIDIR
! 9994: RUBY_SETUP RUBY_SHLIB
! 9995: RUBY_SHLIBALIAS RUBY_SHLIBVER
! 9996: RUBY_SIMPLE_INSTALL RUBY_SITEARCHLIB
! 9997: RUBY_SITELIB RUBY_SITELIB_BASE
! 9998: RUBY_SITERIDIR RUBY_SLEXT
! 9999: RUBY_SRCDIR RUBY_STATICLIB
! 10000: RUBY_SUFFIX RUBY_SYSRIDIR
! 10001: RUBY_USE_PTHREAD RUBY_VENDORARCHLIB
! 10002: RUBY_VENDORLIB RUBY_VENDORLIB_BASE
! 10003: RUBY_VER RUBY_VERSION
! 10004: RUBY_VERSIONS_ACCEPTED RUBY_VERSIONS_INCOMPATIBLE
! 10005: RUBY_VERSION_DEFAULT RUBY_VERSION_REQD
! 10006: RUBY_VER_DIR RUN
! 10007: RUN_LDCONFIG SAWFISH_THEMES
! 10008: SCO SCREWS_GROUP
! 10009: SCREWS_USER SCRIPTS_ENV
! 10010: SCROLLKEEPER_DATADIR SCROLLKEEPER_REBUILDDB
! 10011: SCROLLKEEPER_UPDATEDB SDIST_PAWD
! 10012: SERIAL_DEVICES SETGIDGAME
! 10013: SETGID_GAMES_PERMS SETUID_ROOT_PERMS
! 10014: SH SHLIB
! 10015: SHORTNAME SIGN_PACKAGES
! 10016: SILC_CLIENT_WITH_PERL SITE_SPECIFIC_PKGS
! 10017: SKIP_DEPENDS SMF_INSTANCES
! 10018: SMF_MANIFEST SMF_METHODS
! 10019: SMF_METHOD_SHELL SMF_METHOD_SRC
! 10020: SMF_NAME SMF_PREFIX
! 10021: SMF_SRCDIR SNIPROXY_GROUP
! 10022: SNIPROXY_USER SOURCE_BUFFSIZE
! 10023: SPECIAL_PERMS SPECIFIC_PKGS
! 10024: SSH_SUID SSP_SUPPORTED
! 10025: SSYNC_PAWD STEP_MSG
! 10026: STRIP STRIP_DBG
! 10027: STRIP_DEBUG STRIP_DEBUG_SUPPORTED
! 10028: STRIP_FILES_SKIP SU
! 10029: SUBDIR SUBST
! 10030: SUBST_CLASSES SUBST_FILES
! 10031: SUBST_FILTER_CMD SUBST_MESSAGE
! 10032: SUBST_NOOP_OK SUBST_SED
! 10033: SUBST_SHOW_DIFF SUBST_SKIP_TEXT_CHECK
! 10034: SUBST_STAGE SUBST_VARS
! 10035: SUNWSPROBASE SUSE_PREFER
! 10036: SU_CMD SVN_EXTRACTDIR
! 10037: SVN_REPO SVN_REPOSITORIES
! 10038: SVN_REVISION SYSCONFBASE
! 10039: TBL TERMCAP_TYPE
! 10040: TERMINFO_DEFAULT TERMINFO_TYPE
! 10041: TEST TEST_DEPENDS
! 10042: TEST_DIRS TEST_ENV
! 10043: TEST_ENV_SHELL TEST_MAKE_CMD
! 10044: TEST_MAKE_FLAGS TEST_TARGET
! 10045: TEXLIVE_IGNORE_PATTERNS TEXLIVE_REV
! 10046: TEXLIVE_UNVERSIONED TEXMFSITE
! 10047: TEX_FORMATS TEX_HYPHEN_DAT
! 10048: TEX_HYPHEN_DEF TEX_TEXMF_DIRS
! 10049: THTTPD_LOG_FACILITY TINYDYN_USER
! 10050: TLSWRAPPER_CHROOT TO
! 10051: TOOLS_ALIASES TOOLS_ALWAYS_WRAP
! 10052: TOOLS_ARGS TOOLS_BROKEN
! 10053: TOOLS_CMD TOOLS_CMDLINE_SED
! 10054: TOOLS_CREATE TOOLS_DIR
! 10055: TOOLS_FAIL TOOLS_GNU_MISSING
! 10056: TOOLS_LDCONFIG TOOLS_NOOP
! 10057: TOOLS_PATH TOOLS_SCRIPT
! 10058: TOOL_DEPENDS TTF_FONTDIR
! 10059: TTF_FONTS_DIR TYPE
! 10060: UAC_REQD_EXECS UCSPI_SSL_GROUP
! 10061: UCSPI_SSL_USER UNLIMIT_RESOURCES
! 10062: UNPRIVILEGED UNPRIVILEGED_GROUP
! 10063: UNPRIVILEGED_GROUPS UNPRIVILEGED_USER
! 10064: UNWRAP_FILES UNWRAP_PATTERNS
! 10065: UPDATE_GEMSPEC UPDATE_TARGET
! 10066: URI USERGROUP_PHASE
! 10067: USERPPP_GROUP USER_SPECIFIC_PKGS
! 10068: USE_ABI_DEPENDS USE_APR
! 10069: USE_BSD_MAKEFILE USE_BUILTIN
! 10070: USE_CROSS_COMPILE USE_CURSES
! 10071: USE_CWRAPPERS USE_DB185
! 10072: USE_FEATURES USE_GAMESGROUP
! 10073: USE_GCC_RUNTIME USE_IMAKE
! 10074: USE_JAVA USE_JAVA2
! 10075: USE_LANGUAGES USE_LIBTOOL
! 10076: USE_NATIVE_GCC USE_NETBSD_REPO
! 10077: USE_PKGSRC_GCC USE_PKGSRC_GCC_RUNTIME
! 10078: USE_PKGTASKS USE_PKG_ADMIN_DIGEST
! 10079: USE_RUBY_EXTCONF USE_RUBY_INSTALL
! 10080: USE_RUBY_SETUP USE_RUBY_SETUP_PKG
! 10081: USE_TOOLS UUCP_GROUP
! 10082: UUCP_USER VARBASE
! 10083: VARNAME VIM_EXTRA_OPTS
! 10084: WARNING_MSG WCALC_CGIDIR
! 10085: WCALC_CGIPATH WCALC_HTMLDIR
! 10086: WCALC_HTMLPATH WDM_MANAGERS
! 10087: WRAPPER_CC WRAPPER_REORDER_CMDS
! 10088: WRKDIR WRKDIR_BASENAME
! 10089: WRKDIR_LOCKTYPE WRKLOG
! 10090: WRKOBJDIR WRKSRC
! 10091: X10_PORT X11
! 10092: X11BASE X11_PKGSRCDIR
! 10093: X11_TYPE X509_CERTIFICATE
! 10094: X509_KEY XAW_TYPE
! 10095: XLOCK_DEFAULT_MODE XMKMF
! 10096: XMKMF_FLAGS XXX
! 10097: XXXX YES
! 10098: ZSH_STATIC __stdc__
! 10099: _vargroups accept
! 10100: acquire-localbase-lock acquire-lock
! 10101: add administrator
! 10102: alloca alternatives
! 10103: aslr asprintf
! 10104: atlas autoconf
! 10105: automake autoreconf
! 10106: awk bash
! 10107: big-endian bin-install
! 10108: bind binpkg-list
! 10109: blas bootstrap-depends
! 10110: broken broken_on_platform
! 10111: bsd bsd.prog.mk
! 10112: build build-env
! 10113: buildlink-directories buildlink-oss-soundcard-h
! 10114: c c++
! 10115: ccache cce
! 10116: cdefs ceil
! 10117: changes changes-entry
! 10118: changes-entry-noupdate check
! 10119: check-clean check-files
! 10120: check-files-clean check-vulnerable
! 10121: checksum checksum-phase
! 10122: clean clean-depends
! 10123: cleandir commit
! 10124: commit-changes-entry compact
! 10125: compiler conf
! 10126: config.guess config.sub
! 10127: configuration configure
! 10128: configure-env configure-help
! 10129: configure_args connect
! 10130: cos cputime
! 10131: create-usergroup csh
! 10132: ctf cvs
! 10133: debug declaration
! 10134: declare defined
! 10135: depend dependencies
! 10136: depends depends-checksum
! 10137: depends-fetch deps
! 10138: describe destdir
! 10139: disable distclean
! 10140: distinfo dl
! 10141: dlopen do-buildlink
! 10142: do-clean do-configure
! 10143: do-configure-post-hook do-extract
! 10144: do-fetch do-install
! 10145: emul emul-distinfo
! 10146: emul-fetch emulation
! 10147: emulator enable
! 10148: endian endif
! 10149: enomem err
! 10150: errx etc
! 10151: exp extract-rpm
! 10152: fabs feature
! 10153: features fetch
! 10154: fetch-list follows
! 10155: forbids form
! 10156: format fortify
! 10157: fortify_source fossil
! 10158: friend fts
! 10159: fts_close fts_open
! 10160: fts_read fts_set
! 10161: gcc gethostbyaddr
! 10162: gethostbyname gethostbyname2
! 10163: getopt_long getprogname
! 10164: getservbyname getservbyport
! 10165: getservent gettext
! 10166: git github
! 10167: gitlab glob
! 10168: gnu gnu_configure_strict
! 10169: go go-deps
! 10170: golang guess-license
! 10171: hashbang heimdal
! 10172: help hg
! 10173: imake increment
! 10174: inet_aton interp
! 10175: interpreter intl
! 10176: ip4 ip6
! 10177: ipv4 ipv6
! 10178: iso kerberos
! 10179: krb krb5
! 10180: ksh lapack
! 10181: latex libintl_bindtextdomain
! 10182: libintl_gettext libintl_textdomain
! 10183: libnbcompat libs
! 10184: libtool licence
! 10185: license lintl
! 10186: little-endian lock
! 10187: locking lvalue
! 10188: make makesum
! 10189: memory mercurial
! 10190: meta meta-package
! 10191: meta_package mit-krb5
! 10192: mk.conf mkl
! 10193: mount mprotect
! 10194: mremap nb
! 10195: nbcompat netlib
! 10196: obstack obstack_ptr_grow
! 10197: occurs only
! 10198: openblas options
! 10199: options.mk order
! 10200: override override-intltool
! 10201: override-message-intltool package
! 10202: parallel path
! 10203: pax paxctl
! 10204: pbulk-index pc
! 10205: perl perl5
! 10206: perms php
! 10207: pkg-build-options pkg-config
! 10208: pkg_build_options platform
! 10209: plist post-extract
! 10210: post-fetch post-wrapper
! 10211: pre-build-checks-hook pre-configure
! 10212: pre-configure-checks-hook pre-extract
! 10213: pre-fetch print-go-deps
! 10214: print-plist print-summary-data
! 10215: privileged-install-hook pypi
! 10216: python r
! 10217: readme-all recv
! 10218: recvfrom regcomp
! 10219: release-localbase-lock release-lock
! 10220: relro rename
! 10221: reorder replace
! 10222: replace_interpreter reproducible
! 10223: resolv root
! 10224: ruby send
! 10225: sendfile sendto
! 10226: setenv setgid
! 10227: setprogname setuid
! 10228: sh shebang
! 10229: show show-all
! 10230: show-build-defs show-depends
! 10231: show-deps show-distfiles
! 10232: show-downlevel show-subdir-var
! 10233: show-tools show-var
! 10234: show-vars snprintf
! 10235: socket ssp
! 10236: st_mode stage-install
! 10237: strcasestr strict
! 10238: strip strndup
! 10239: strnlen strsep
! 10240: subst substitutions
! 10241: subversion sun
! 10242: sunpro sunwspro
! 10243: svn symlink
! 10244: test test-env
! 10245: tex texlive
! 10246: tmp tool
! 10247: tools tools-libtool-m4-override
! 10248: type ulimit
! 10249: undefined undo-replace
! 10250: unlimit unprivileged
! 10251: unprivileged-install-hook unstripped
! 10252: update upload
! 10253: upload-distfiles use_tools
! 10254: user utimes
! 10255: vasprintf verbose
! 10256: vsnprintf warn
! 10257: warning warnings
! 10258: warnx wattr_off
! 10259: wattr_on work
! 10260: wrapper wrkdir
1.154 rillig 10261:
1.207 leot 10262: Appendix F. Editing guidelines for the pkgsrc guide
1.1 dsieger 10263:
10264: Table of Contents
10265:
1.207 leot 10266: F.1. Make targets
10267: F.2. Procedure
1.1 dsieger 10268:
10269: This section contains information on editing the pkgsrc guide itself.
10270:
1.207 leot 10271: F.1. Make targets
1.1 dsieger 10272:
10273: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
10274: files are created from it:
10275:
10276: * pkgsrc/doc/pkgsrc.txt
10277:
10278: * pkgsrc/doc/pkgsrc.html
10279:
1.174 leot 10280: * https://www.NetBSD.org/docs/pkgsrc/
1.1 dsieger 10281:
1.174 leot 10282: * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the
10283: pkgsrc guide.
1.1 dsieger 10284:
1.174 leot 10285: * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
1.2 rillig 10286: pkgsrc guide.
1.1 dsieger 10287:
1.207 leot 10288: F.2. Procedure
1.1 dsieger 10289:
10290: The procedure to edit the pkgsrc guide is:
10291:
1.190 bacon 10292: 1. Make sure you have checked out the htdocs repository into a sibling
10293: directory of your pkgsrc directory. You will need the ability to commit
10294: from both pkgsrc and htdocs.
10295:
10296: 2. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46 obache 10297: other XML-based NetBSD documentation) installed. These are automatically
10298: installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1 dsieger 10299:
1.190 bacon 10300: 3. Run cd doc/guide to get to the right directory. All further steps will take
1.1 dsieger 10301: place here.
10302:
1.190 bacon 10303: 4. Edit the XML file(s) in files/.
1.1 dsieger 10304:
1.190 bacon 10305: 5. Run bmake to check the pkgsrc guide for valid XML and to build the final
1.1 dsieger 10306: output files. If you get any errors at this stage, you can just edit the
10307: files, as there are only symbolic links in the working directory, pointing
10308: to the files in files/.
10309:
1.190 bacon 10310: 6. (cd files && cvs commit)
1.1 dsieger 10311:
1.190 bacon 10312: 7. Run bmake clean && bmake to regenerate the output files with the proper RCS
1.1 dsieger 10313: Ids.
10314:
1.190 bacon 10315: 8. Run bmake regen to install and commit the files in both pkgsrc/doc and
1.1 dsieger 10316: htdocs.
10317:
10318: Note
10319:
10320: If you have added, removed or renamed some chapters, you need to
10321: synchronize them using cvs add or cvs delete in the htdocs directory.
10322:
CVSweb <webmaster@jp.NetBSD.org>