Annotation of htdocs/docs/pkgsrc/pkgsrc.txt, revision 1.121
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.107 jnemeth 15: Copyright 1994-2016 The NetBSD Foundation, Inc
1.1 dsieger 16:
1.108 rillig 17: $NetBSD: pkgsrc.xml,v 1.30 2016/06/11 18:14:42 rillig 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:
46: 2. Where to get pkgsrc and how to keep it up-to-date
47:
48: 2.1. Getting pkgsrc for the first time
49:
1.52 asau 50: 2.1.1. As tar archive
1.24 wiz 51: 2.1.2. Via anonymous CVS
1.1 dsieger 52:
53: 2.2. Keeping pkgsrc up-to-date
54:
55: 2.2.1. Via tar files
56: 2.2.2. Via CVS
57:
58: 3. Using pkgsrc on systems other than NetBSD
59:
60: 3.1. Binary distribution
61: 3.2. Bootstrapping pkgsrc
62:
63: 4. Using pkgsrc
64:
65: 4.1. Using binary packages
66:
67: 4.1.1. Finding binary packages
68: 4.1.2. Installing binary packages
69: 4.1.3. Deinstalling packages
70: 4.1.4. Getting information about installed packages
71: 4.1.5. Checking for security vulnerabilities in installed packages
72: 4.1.6. Finding if newer versions of your installed packages are in
73: pkgsrc
74: 4.1.7. Other administrative functions
75:
76: 4.2. Building packages from source
77:
78: 4.2.1. Requirements
79: 4.2.2. Fetching distfiles
80: 4.2.3. How to build and install
81:
82: 5. Configuring pkgsrc
83:
84: 5.1. General configuration
85: 5.2. Variables affecting the build process
1.9 rillig 86: 5.3. Variables affecting the installation process
1.4 rillig 87: 5.4. Selecting and configuring the compiler
1.1 dsieger 88:
1.4 rillig 89: 5.4.1. Selecting the compiler
90: 5.4.2. Additional flags to the compiler (CFLAGS)
91: 5.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 92:
1.4 rillig 93: 5.5. Developer/advanced settings
94: 5.6. Selecting Build Options
1.1 dsieger 95:
96: 6. Creating binary packages
97:
98: 6.1. Building a single binary package
99: 6.2. Settings for creation of binary packages
100:
1.6 rillig 101: 7. Creating binary packages for everything in pkgsrc (bulk builds)
102:
1.71 wiz 103: 7.1. Preparations
104: 7.2. Running a pbulk-style bulk build
1.6 rillig 105:
1.71 wiz 106: 7.2.1. Configuration
1.6 rillig 107:
1.71 wiz 108: 7.3. Requirements of a full bulk build
1.66 asau 109: 7.4. Creating a multiple CD-ROM packages collection
1.6 rillig 110:
1.66 asau 111: 7.4.1. Example of cdpack
1.6 rillig 112:
113: 8. Directory layout of the installed files
114:
115: 8.1. File system layout in ${LOCALBASE}
116: 8.2. File system layout in ${VARBASE}
117:
118: 9. Frequently Asked Questions
119:
120: 9.1. Are there any mailing lists for pkg-related discussion?
1.84 wiz 121: 9.2. Utilities for package management (pkgtools)
122: 9.3. How to use pkgsrc as non-root
123: 9.4. How to resume transfers when fetching distfiles?
124: 9.5. How can I install/use modular X.org from pkgsrc?
125: 9.6. How to fetch files from behind a firewall
126: 9.7. How to fetch files from HTTPS sites
127: 9.8. How do I tell make fetch to do passive FTP?
128: 9.9. How to fetch all distfiles at once
129: 9.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc"
1.24 wiz 130: mean?
1.84 wiz 131: 9.11. What does "Could not find bsd.own.mk" mean?
132: 9.12. Using 'sudo' with pkgsrc
133: 9.13. How do I change the location of configuration files?
134: 9.14. Automated security checks
135: 9.15. Why do some packages ignore my CFLAGS?
136: 9.16. A package does not build. What shall I do?
137: 9.17. What does "Makefile appears to contain unresolved cvs/rcs/???
1.24 wiz 138: merge conflicts" mean?
1.1 dsieger 139:
140: II. The pkgsrc developer's guide
141:
1.6 rillig 142: 10. Creating a new pkgsrc package from scratch
1.1 dsieger 143:
1.6 rillig 144: 10.1. Common types of packages
1.1 dsieger 145:
1.6 rillig 146: 10.1.1. Perl modules
1.121 ! sevan 147: 10.1.2. KDE3 & KDE4 applications
1.17 imil 148: 10.1.3. Python modules and programs
1.1 dsieger 149:
1.6 rillig 150: 10.2. Examples
1.1 dsieger 151:
1.6 rillig 152: 10.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 153:
1.6 rillig 154: 11. Package components - files, directories and contents
1.1 dsieger 155:
1.6 rillig 156: 11.1. Makefile
157: 11.2. distinfo
158: 11.3. patches/*
1.1 dsieger 159:
1.6 rillig 160: 11.3.1. Structure of a single patch file
161: 11.3.2. Creating patch files
162: 11.3.3. Sources where the patch files come from
163: 11.3.4. Patching guidelines
164: 11.3.5. Feedback to the author
1.1 dsieger 165:
1.6 rillig 166: 11.4. Other mandatory files
167: 11.5. Optional files
1.1 dsieger 168:
1.6 rillig 169: 11.5.1. Files affecting the binary package
170: 11.5.2. Files affecting the build process
171: 11.5.3. Files affecting nothing at all
1.1 dsieger 172:
1.6 rillig 173: 11.6. work*
174: 11.7. files/*
1.1 dsieger 175:
1.6 rillig 176: 12. Programming in Makefiles
1.1 dsieger 177:
1.6 rillig 178: 12.1. Caveats
179: 12.2. Makefile variables
1.1 dsieger 180:
1.6 rillig 181: 12.2.1. Naming conventions
1.1 dsieger 182:
1.6 rillig 183: 12.3. Code snippets
1.1 dsieger 184:
1.6 rillig 185: 12.3.1. Adding things to a list
1.117 sevan 186: 12.3.2. Echoing a string exactly as-is
1.108 rillig 187: 12.3.3. Passing CFLAGS to GNU configure scripts
188: 12.3.4. Handling possibly empty variables
1.1 dsieger 189:
1.6 rillig 190: 13. PLIST issues
1.1 dsieger 191:
1.6 rillig 192: 13.1. RCS ID
193: 13.2. Semi-automatic PLIST generation
194: 13.3. Tweaking output of make print-PLIST
195: 13.4. Variable substitution in PLIST
196: 13.5. Man page compression
197: 13.6. Changing PLIST source with PLIST_SRC
198: 13.7. Platform-specific and differing PLISTs
1.86 wiz 199: 13.8. Build-specific PLISTs
200: 13.9. Sharing directories between packages
1.1 dsieger 201:
1.6 rillig 202: 14. Buildlink methodology
1.1 dsieger 203:
1.6 rillig 204: 14.1. Converting packages to use buildlink3
205: 14.2. Writing buildlink3.mk files
1.1 dsieger 206:
1.6 rillig 207: 14.2.1. Anatomy of a buildlink3.mk file
1.27 wiz 208: 14.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
209: BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.1 dsieger 210:
1.6 rillig 211: 14.3. Writing builtin.mk files
1.1 dsieger 212:
1.6 rillig 213: 14.3.1. Anatomy of a builtin.mk file
214: 14.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 215:
1.6 rillig 216: 15. The pkginstall framework
1.1 dsieger 217:
1.6 rillig 218: 15.1. Files and directories outside the installation prefix
1.1 dsieger 219:
1.6 rillig 220: 15.1.1. Directory manipulation
221: 15.1.2. File manipulation
1.1 dsieger 222:
1.6 rillig 223: 15.2. Configuration files
1.1 dsieger 224:
1.6 rillig 225: 15.2.1. How PKG_SYSCONFDIR is set
226: 15.2.2. Telling the software where configuration files are
227: 15.2.3. Patching installations
228: 15.2.4. Disabling handling of configuration files
1.1 dsieger 229:
1.6 rillig 230: 15.3. System startup scripts
1.1 dsieger 231:
1.6 rillig 232: 15.3.1. Disabling handling of system startup scripts
1.1 dsieger 233:
1.6 rillig 234: 15.4. System users and groups
235: 15.5. System shells
1.1 dsieger 236:
1.6 rillig 237: 15.5.1. Disabling shell registration
1.1 dsieger 238:
1.6 rillig 239: 15.6. Fonts
1.1 dsieger 240:
1.6 rillig 241: 15.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 242:
1.6 rillig 243: 16. Options handling
1.1 dsieger 244:
1.6 rillig 245: 16.1. Global default options
246: 16.2. Converting packages to use bsd.options.mk
247: 16.3. Option Names
1.7 rillig 248: 16.4. Determining the options of dependencies
1.1 dsieger 249:
1.6 rillig 250: 17. The build process
1.1 dsieger 251:
1.6 rillig 252: 17.1. Introduction
253: 17.2. Program location
254: 17.3. Directories used during the build process
255: 17.4. Running a phase
256: 17.5. The fetch phase
1.1 dsieger 257:
1.6 rillig 258: 17.5.1. What to fetch and where to get it from
259: 17.5.2. How are the files fetched?
1.1 dsieger 260:
1.6 rillig 261: 17.6. The checksum phase
262: 17.7. The extract phase
263: 17.8. The patch phase
264: 17.9. The tools phase
265: 17.10. The wrapper phase
266: 17.11. The configure phase
267: 17.12. The build phase
268: 17.13. The test phase
269: 17.14. The install phase
270: 17.15. The package phase
271: 17.16. Cleaning up
272: 17.17. Other helpful targets
1.1 dsieger 273:
1.6 rillig 274: 18. Tools needed for building or running
1.1 dsieger 275:
1.6 rillig 276: 18.1. Tools for pkgsrc builds
277: 18.2. Tools needed by packages
278: 18.3. Tools provided by platforms
1.1 dsieger 279:
1.6 rillig 280: 19. Making your package work
1.1 dsieger 281:
1.6 rillig 282: 19.1. General operation
1.1 dsieger 283:
1.108 rillig 284: 19.1.1. How to pull in user-settable variables from mk.conf
285: 19.1.2. User interaction
286: 19.1.3. Handling licenses
287: 19.1.4. Restricted packages
288: 19.1.5. Handling dependencies
289: 19.1.6. Handling conflicts with other packages
290: 19.1.7. Packages that cannot or should not be built
291: 19.1.8. Packages which should not be deleted, once installed
292: 19.1.9. Handling packages with security problems
293: 19.1.10. How to handle incrementing versions when fixing an
1.1 dsieger 294: existing package
1.108 rillig 295: 19.1.11. Substituting variable text in the package files (the SUBST
1.1 dsieger 296: framework)
297:
1.108 rillig 298: 19.2. The fetch phase
1.1 dsieger 299:
1.6 rillig 300: 19.2.1. Packages whose distfiles aren't available for plain
1.1 dsieger 301: downloading
1.6 rillig 302: 19.2.2. How to handle modified distfiles with the 'old' name
1.88 tnn 303: 19.2.3. Packages hosted on github.com
1.1 dsieger 304:
1.108 rillig 305: 19.3. The configure phase
1.1 dsieger 306:
1.6 rillig 307: 19.3.1. Shared libraries - libtool
308: 19.3.2. Using libtool on GNU packages that already support libtool
309: 19.3.3. GNU Autoconf/Automake
310:
311: 19.4. Programming languages
312:
313: 19.4.1. C, C++, and Fortran
314: 19.4.2. Java
315: 19.4.3. Packages containing perl scripts
1.41 wiz 316: 19.4.4. Packages containing shell scripts
317: 19.4.5. Other programming languages
1.6 rillig 318:
1.108 rillig 319: 19.5. The build phase
1.6 rillig 320:
321: 19.5.1. Compiling C and C++ code conditionally
322: 19.5.2. How to handle compiler bugs
1.24 wiz 323: 19.5.3. Undefined reference to "..."
1.6 rillig 324: 19.5.4. Running out of memory
325:
1.108 rillig 326: 19.6. The install phase
1.6 rillig 327:
328: 19.6.1. Creating needed directories
329: 19.6.2. Where to install documentation
330: 19.6.3. Installing highscore files
331: 19.6.4. Adding DESTDIR support to packages
332: 19.6.5. Packages with hardcoded paths to other interpreters
333: 19.6.6. Packages installing perl modules
334: 19.6.7. Packages installing info files
335: 19.6.8. Packages installing man pages
1.7 rillig 336: 19.6.9. Packages installing GConf data files
1.18 mishka 337: 19.6.10. Packages installing scrollkeeper/rarian data files
1.6 rillig 338: 19.6.11. Packages installing X11 fonts
339: 19.6.12. Packages installing GTK2 modules
340: 19.6.13. Packages installing SGML or XML data
341: 19.6.14. Packages installing extensions to the MIME database
342: 19.6.15. Packages using intltool
343: 19.6.16. Packages installing startup scripts
344: 19.6.17. Packages installing TeX modules
345: 19.6.18. Packages supporting running binaries in emulation
346: 19.6.19. Packages installing hicolor theme icons
347: 19.6.20. Packages installing desktop files
348:
349: 19.7. Marking packages as having problems
350:
351: 20. Debugging
352: 21. Submitting and Committing
353:
354: 21.1. Submitting binary packages
355: 21.2. Submitting source packages (for non-NetBSD-developers)
356: 21.3. General notes when adding, updating, or removing packages
1.34 wiz 357: 21.4. Committing: Adding a package to CVS
1.6 rillig 358: 21.5. Updating a package to a newer version
1.21 snj 359: 21.6. Renaming a package in pkgsrc
360: 21.7. Moving a package in pkgsrc
1.6 rillig 361:
362: 22. Frequently Asked Questions
363: 23. GNOME packaging and porting
364:
365: 23.1. Meta packages
366: 23.2. Packaging a GNOME application
367: 23.3. Updating GNOME to a newer version
368: 23.4. Patching guidelines
1.1 dsieger 369:
370: III. The pkgsrc infrastructure internals
371:
1.6 rillig 372: 24. Design of the pkgsrc infrastructure
1.1 dsieger 373:
1.6 rillig 374: 24.1. The meaning of variable definitions
375: 24.2. Avoiding problems before they arise
376: 24.3. Variable evaluation
1.1 dsieger 377:
1.6 rillig 378: 24.3.1. At load time
379: 24.3.2. At runtime
1.1 dsieger 380:
1.6 rillig 381: 24.4. How can variables be specified?
382: 24.5. Designing interfaces for Makefile fragments
1.1 dsieger 383:
1.6 rillig 384: 24.5.1. Procedures with parameters
385: 24.5.2. Actions taken on behalf of parameters
1.1 dsieger 386:
1.6 rillig 387: 24.6. The order in which files are loaded
1.1 dsieger 388:
1.6 rillig 389: 24.6.1. The order in bsd.prefs.mk
390: 24.6.2. The order in bsd.pkg.mk
1.1 dsieger 391:
1.6 rillig 392: 25. Regression tests
1.1 dsieger 393:
1.108 rillig 394: 25.1. Running the regression tests
395: 25.2. Adding a new regression test
1.1 dsieger 396:
1.108 rillig 397: 25.2.1. Overridable functions
398: 25.2.2. Helper functions
1.1 dsieger 399:
1.6 rillig 400: 26. Porting pkgsrc
1.1 dsieger 401:
1.6 rillig 402: 26.1. Porting pkgsrc to a new operating system
1.1 dsieger 403:
404: A. A simple example package: bison
405:
406: A.1. files
407:
408: A.1.1. Makefile
409: A.1.2. DESCR
410: A.1.3. PLIST
411: A.1.4. Checking a package with pkglint
412:
413: A.2. Steps for building, installing, packaging
414:
415: B. Build logs
416:
417: B.1. Building figlet
418: B.2. Packaging figlet
419:
420: C. Directory layout of the pkgsrc FTP server
421:
1.23 jakllsch 422: C.1. distfiles: The distributed source files
423: C.2. misc: Miscellaneous things
424: C.3. packages: Binary packages
425: C.4. reports: Bulk build reports
426: C.5. current, pkgsrc-20xxQy: source packages
1.1 dsieger 427:
428: D. Editing guidelines for the pkgsrc guide
429:
430: D.1. Make targets
431: D.2. Procedure
432:
433: List of Tables
434:
435: 1.1. Platforms supported by pkgsrc
1.6 rillig 436: 11.1. Patching examples
437: 23.1. PLIST handling for GNOME packages
1.1 dsieger 438:
439: Chapter 1. What is pkgsrc?
440:
441: Table of Contents
442:
443: 1.1. Introduction
444:
445: 1.1.1. Why pkgsrc?
446: 1.1.2. Supported platforms
447:
448: 1.2. Overview
449: 1.3. Terminology
450:
451: 1.3.1. Roles involved in pkgsrc
452:
453: 1.4. Typography
454:
455: 1.1. Introduction
456:
457: There is a lot of software freely available for Unix-based systems, which is
458: usually available in form of the source code. Before such software can be used,
459: it needs to be configured to the local system, compiled and installed, and this
460: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
461: some basic commands to handle binary packages, so that not every user has to
462: build the packages for himself, which is a time-costly task.
463:
464: pkgsrc currently contains several thousand packages, including:
465:
1.104 sevan 466: * www/apache24 - The Apache web server
1.1 dsieger 467:
468: * www/firefox - The Firefox web browser
469:
470: * meta-pkgs/gnome - The GNOME Desktop Environment
471:
1.102 ryoon 472: * meta-pkgs/kde4 - The K Desktop Environment
1.1 dsieger 473:
1.108 rillig 474: ? just to name a few.
1.1 dsieger 475:
476: pkgsrc has built-in support for handling varying dependencies, such as pthreads
477: and X11, and extended features such as IPv6 support on a range of platforms.
478:
479: 1.1.1. Why pkgsrc?
480:
481: pkgsrc provides the following key features:
482:
483: * Easy building of software from source as well as the creation and
484: installation of binary packages. The source and latest patches are
485: retrieved from a master or mirror download site, checksum verified, then
486: built on your system. Support for binary-only distributions is available
487: for both native platforms and NetBSD emulated platforms.
488:
489: * All packages are installed in a consistent directory tree, including
490: binaries, libraries, man pages and other documentation.
491:
1.104 sevan 492: * Tracking of package dependencies automatically, including when performing
493: updates, to ensure required packages are installed. The configuration files
494: of various packages are handled automatically during updates, so local
495: changes are preserved.
1.1 dsieger 496:
497: * Like NetBSD, pkgsrc is designed with portability in mind and consists of
498: highly portable code. This allows the greatest speed of development when
1.26 spz 499: porting to a new platform. This portability also ensures that pkgsrc is
1.1 dsieger 500: consistent across all platforms.
501:
502: * The installation prefix, acceptable software licenses, international
503: encryption requirements and build-time options for a large number of
504: packages are all set in a simple, central configuration file.
505:
506: * The entire source (not including the distribution files) is freely
507: available under a BSD license, so you may extend and adapt pkgsrc to your
508: needs. Support for local packages and patches is available right out of the
509: box, so you can configure it specifically for your environment.
510:
511: The following principles are basic to pkgsrc:
512:
513: * "It should only work if it's right." ? That means, if a package contains
514: bugs, it's better to find them and to complain about them rather than to
515: just install the package and hope that it works. There are numerous checks
516: in pkgsrc that try to find such bugs: Static analysis tools (pkgtools/
517: pkglint), build-time checks (portability of shell scripts), and
518: post-installation checks (installed files, references to shared libraries,
519: script interpreters).
520:
521: * "If it works, it should work everywhere" ? Like NetBSD has been ported to
522: many hardware architectures, pkgsrc has been ported to many operating
523: systems. Care is taken that packages behave the same on all platforms.
524:
525: 1.1.2. Supported platforms
526:
527: pkgsrc consists of both a source distribution and a binary distribution for
528: these operating systems. After retrieving the required source or binaries, you
529: can be up and running with pkgsrc in just minutes!
530:
531: pkgsrc was derived from FreeBSD's ports system, and initially developed for
532: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
533: platforms:
534:
535: Table 1.1. Platforms supported by pkgsrc
536:
1.92 sevan 537: +-----------------------------------------------------------------------------+
538: | Platform | Date Support | Notes |
539: | | Added | |
540: |--------------------------------------+---------------+----------------------|
541: |NetBSD | Aug 1997 | |
542: |--------------------------------------+---------------+----------------------|
543: |Solaris | Mar 1999 |README.Solaris |
544: |--------------------------------------+---------------+----------------------|
545: |Linux | Jun 1999 |README.Linux |
546: |--------------------------------------+---------------+----------------------|
1.118 sevan 547: |Darwin / Mac OS X / OS X / macOS | Oct 2001 |README.MacOSX |
1.92 sevan 548: |--------------------------------------+---------------+----------------------|
549: |FreeBSD | Nov 2002 |README.FreeBSD |
550: |--------------------------------------+---------------+----------------------|
551: |OpenBSD | Nov 2002 |README.OpenBSD |
552: |--------------------------------------+---------------+----------------------|
553: |IRIX | Dec 2002 |README.IRIX |
554: | | |README.IRIX5.3 |
555: |--------------------------------------+---------------+----------------------|
556: |BSD/OS | Dec 2003 | |
557: |--------------------------------------+---------------+----------------------|
558: |AIX | Dec 2003 |README.AIX |
559: |--------------------------------------+---------------+----------------------|
560: |Interix (Microsoft Windows Services | Mar 2004 |README.Interix |
561: |for Unix) | | |
562: |--------------------------------------+---------------+----------------------|
563: |DragonFlyBSD | Oct 2004 | |
564: |--------------------------------------+---------------+----------------------|
565: |OSF/1 | Nov 2004 |README.OSF1 |
566: |--------------------------------------+---------------+----------------------|
567: |HP-UX | Apr 2007 |README.HPUX |
568: |--------------------------------------+---------------+----------------------|
569: |Haiku | Sep 2010 |README.Haiku |
570: |--------------------------------------+---------------+----------------------|
571: |MirBSD | Jan 2011 | |
572: |--------------------------------------+---------------+----------------------|
573: |Minix3 | Nov 2011 |README.Minix3 |
574: |--------------------------------------+---------------+----------------------|
575: |Cygwin | Mar 2013 |README.Cygwin |
576: |--------------------------------------+---------------+----------------------|
577: |GNU/kFreeBSD | Jul 2013 |README.GNUkFreeBSD |
1.104 sevan 578: |--------------------------------------+---------------+----------------------|
579: |Bitrig | Jun 2014 |README.Bitrig |
1.92 sevan 580: +-----------------------------------------------------------------------------+
1.1 dsieger 581:
582:
583: 1.2. Overview
584:
585: This document is divided into three parts. The first, The pkgsrc user's guide,
586: describes how one can use one of the packages in the Package Collection, either
587: by installing a precompiled binary package, or by building one's own copy using
588: the NetBSD package system. The second part, The pkgsrc developer's guide,
589: explains how to prepare a package so it can be easily built by other NetBSD
590: users without knowing about the package's building details. The third part, The
591: pkgsrc infrastructure internals is intended for those who want to understand
592: how pkgsrc is implemented.
593:
594: This document is available in various formats: HTML, PDF, PS, TXT.
595:
596: 1.3. Terminology
597:
598: There has been a lot of talk about "ports", "packages", etc. so far. Here is a
599: description of all the terminology used within this document.
600:
601: Package
602:
603: A set of files and building instructions that describe what's necessary to
604: build a certain piece of software using pkgsrc. Packages are traditionally
605: stored under /usr/pkgsrc.
606:
607: The NetBSD package system
608:
609: This is the former name of "pkgsrc". It is part of the NetBSD operating
610: system and can be bootstrapped to run on non-NetBSD operating systems as
611: well. It handles building (compiling), installing, and removing of
612: packages.
613:
614: Distfile
615:
616: This term describes the file or files that are provided by the author of
617: the piece of software to distribute his work. All the changes necessary to
618: build on NetBSD are reflected in the corresponding package. Usually the
619: distfile is in the form of a compressed tar-archive, but other types are
620: possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
621:
622: Port
623:
624: This is the term used by FreeBSD and OpenBSD people for what we call a
625: package. In NetBSD terminology, "port" refers to a different architecture.
626:
627: Precompiled/binary package
628:
629: A set of binaries built with pkgsrc from a distfile and stuffed together in
630: a single .tgz file so it can be installed on machines of the same machine
631: architecture without the need to recompile. Packages are usually generated
632: in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
633:
634: Sometimes, this is referred to by the term "package" too, especially in the
635: context of precompiled packages.
636:
637: Program
638:
639: The piece of software to be installed which will be constructed from all
640: the files in the distfile by the actions defined in the corresponding
641: package.
642:
643: 1.3.1. Roles involved in pkgsrc
644:
645: pkgsrc users
646:
647: The pkgsrc users are people who use the packages provided by pkgsrc.
648: Typically they are system administrators. The people using the software
649: that is inside the packages (maybe called "end users") are not covered by
650: the pkgsrc guide.
651:
652: There are two kinds of pkgsrc users: Some only want to install pre-built
653: binary packages. Others build the pkgsrc packages from source, either for
654: installing them directly or for building binary packages themselves. For
655: pkgsrc users Part I, "The pkgsrc user's guide" should provide all necessary
656: documentation.
657:
658: package maintainers
659:
660: A package maintainer creates packages as described in Part II, "The pkgsrc
661: developer's guide".
662:
663: infrastructure developers
664:
665: These people are involved in all those files that live in the mk/ directory
666: and below. Only these people should need to read through Part III, "The
667: pkgsrc infrastructure internals", though others might be curious, too.
668:
669: 1.4. Typography
670:
671: When giving examples for commands, shell prompts are used to show if the
672: command should/can be issued as root, or if "normal" user privileges are
1.115 sevan 673: sufficient. We use a # for root's shell prompt, a % for users' shell prompt,
674: assuming they use the C-shell or tcsh and a $ for bourne shell and derivatives.
1.1 dsieger 675:
676: Part I. The pkgsrc user's guide
677:
678: Table of Contents
679:
680: 2. Where to get pkgsrc and how to keep it up-to-date
681:
682: 2.1. Getting pkgsrc for the first time
683:
1.52 asau 684: 2.1.1. As tar archive
1.24 wiz 685: 2.1.2. Via anonymous CVS
1.1 dsieger 686:
687: 2.2. Keeping pkgsrc up-to-date
688:
689: 2.2.1. Via tar files
690: 2.2.2. Via CVS
691:
692: 3. Using pkgsrc on systems other than NetBSD
693:
694: 3.1. Binary distribution
695: 3.2. Bootstrapping pkgsrc
696:
697: 4. Using pkgsrc
698:
699: 4.1. Using binary packages
700:
701: 4.1.1. Finding binary packages
702: 4.1.2. Installing binary packages
703: 4.1.3. Deinstalling packages
704: 4.1.4. Getting information about installed packages
705: 4.1.5. Checking for security vulnerabilities in installed packages
706: 4.1.6. Finding if newer versions of your installed packages are in
707: pkgsrc
708: 4.1.7. Other administrative functions
709:
710: 4.2. Building packages from source
711:
712: 4.2.1. Requirements
713: 4.2.2. Fetching distfiles
714: 4.2.3. How to build and install
715:
716: 5. Configuring pkgsrc
717:
718: 5.1. General configuration
719: 5.2. Variables affecting the build process
1.9 rillig 720: 5.3. Variables affecting the installation process
1.4 rillig 721: 5.4. Selecting and configuring the compiler
1.1 dsieger 722:
1.4 rillig 723: 5.4.1. Selecting the compiler
724: 5.4.2. Additional flags to the compiler (CFLAGS)
725: 5.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 726:
1.4 rillig 727: 5.5. Developer/advanced settings
728: 5.6. Selecting Build Options
1.1 dsieger 729:
730: 6. Creating binary packages
731:
732: 6.1. Building a single binary package
733: 6.2. Settings for creation of binary packages
734:
1.6 rillig 735: 7. Creating binary packages for everything in pkgsrc (bulk builds)
736:
1.71 wiz 737: 7.1. Preparations
738: 7.2. Running a pbulk-style bulk build
1.6 rillig 739:
1.71 wiz 740: 7.2.1. Configuration
1.6 rillig 741:
1.71 wiz 742: 7.3. Requirements of a full bulk build
1.66 asau 743: 7.4. Creating a multiple CD-ROM packages collection
1.6 rillig 744:
1.66 asau 745: 7.4.1. Example of cdpack
1.6 rillig 746:
747: 8. Directory layout of the installed files
748:
749: 8.1. File system layout in ${LOCALBASE}
750: 8.2. File system layout in ${VARBASE}
751:
752: 9. Frequently Asked Questions
753:
754: 9.1. Are there any mailing lists for pkg-related discussion?
1.84 wiz 755: 9.2. Utilities for package management (pkgtools)
756: 9.3. How to use pkgsrc as non-root
757: 9.4. How to resume transfers when fetching distfiles?
758: 9.5. How can I install/use modular X.org from pkgsrc?
759: 9.6. How to fetch files from behind a firewall
760: 9.7. How to fetch files from HTTPS sites
761: 9.8. How do I tell make fetch to do passive FTP?
762: 9.9. How to fetch all distfiles at once
763: 9.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
764: 9.11. What does "Could not find bsd.own.mk" mean?
765: 9.12. Using 'sudo' with pkgsrc
766: 9.13. How do I change the location of configuration files?
767: 9.14. Automated security checks
768: 9.15. Why do some packages ignore my CFLAGS?
769: 9.16. A package does not build. What shall I do?
770: 9.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24 wiz 771: conflicts" mean?
1.1 dsieger 772:
773: Chapter 2. Where to get pkgsrc and how to keep it up-to-date
774:
775: Table of Contents
776:
777: 2.1. Getting pkgsrc for the first time
778:
1.52 asau 779: 2.1.1. As tar archive
1.24 wiz 780: 2.1.2. Via anonymous CVS
1.1 dsieger 781:
782: 2.2. Keeping pkgsrc up-to-date
783:
784: 2.2.1. Via tar files
785: 2.2.2. Via CVS
786:
787: Before you download and extract the files, you need to decide where you want to
788: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
789: usr/pkgsrc. You are though free to install the sources and binary packages
790: wherever you want in your filesystem, provided that the pathname does not
791: contain white-space or other characters that are interpreted specially by the
792: shell and some other programs. A safe bet is to use only letters, digits,
793: underscores and dashes.
794:
795: 2.1. Getting pkgsrc for the first time
796:
1.25 wiz 797: Before you download any pkgsrc files, you should decide whether you want the
1.1 dsieger 798: current branch or the stable branch. The latter is forked on a quarterly basis
799: from the current branch and only gets modified for security updates. The names
800: of the stable branches are built from the year and the quarter, for example
1.118 sevan 801: 2016Q4.
1.1 dsieger 802:
803: The second step is to decide how you want to download pkgsrc. You can get it as
1.24 wiz 804: a tar file or via CVS. Both ways are described here.
1.1 dsieger 805:
1.52 asau 806: Note that tar archive contains CVS working copy. Thus you can switch to using
807: CVS at any later time.
1.1 dsieger 808:
1.52 asau 809: 2.1.1. As tar archive
810:
811: The primary download location for all pkgsrc files is http://ftp.NetBSD.org/pub
812: /pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same location).
813: There are a number of subdirectories for different purposes, which are
1.1 dsieger 814: described in detail in Appendix C, Directory layout of the pkgsrc FTP server.
815:
1.52 asau 816: The tar archive for the current branch is in the directory current and is
1.118 sevan 817: called pkgsrc.tar.gz. It is autogenerated weekly.
1.52 asau 818:
819: To save download time we provide bzip2- and xz-compressed archives which are
820: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
821:
822: You can fetch the same files using FTP.
1.1 dsieger 823:
1.118 sevan 824: The tar file for the stable branch 2016Q4 is in the directory pkgsrc-2016Q4 and
1.59 jnemeth 825: is also called pkgsrc.tar.gz.
1.1 dsieger 826:
1.12 weinem 827: To download a pkgsrc stable tarball, run:
828:
1.59 jnemeth 829: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-20xxQy/pkgsrc.tar.gz
1.12 weinem 830:
1.25 wiz 831: Where pkgsrc-20xxQy is the stable branch to be downloaded, for example, "
1.118 sevan 832: pkgsrc-2016Q4".
1.12 weinem 833:
1.78 snj 834: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52 asau 835:
1.12 weinem 836: Then, extract it with:
837:
1.78 snj 838: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12 weinem 839:
840: This will create the directory pkgsrc/ in /usr/ and all the package source will
841: be stored under /usr/pkgsrc/.
842:
843: To download pkgsrc-current, run:
844:
845: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1 dsieger 846:
1.24 wiz 847: 2.1.2. Via anonymous CVS
1.1 dsieger 848:
1.24 wiz 849: To fetch a specific pkgsrc stable branch, run:
1.1 dsieger 850:
1.40 wiz 851: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-20xxQy -P pkgsrc
1.1 dsieger 852:
1.25 wiz 853: Where pkgsrc-20xxQy is the stable branch to be checked out, for example, "
1.118 sevan 854: pkgsrc-2016Q4"
1.13 weinem 855:
1.24 wiz 856: This will create the directory pkgsrc/ in your /usr/ directory and all the
857: package source will be stored under /usr/pkgsrc/.
858:
859: To fetch the pkgsrc current branch, run:
1.1 dsieger 860:
1.40 wiz 861: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 862:
1.30 dholland 863: Refer to the list of available mirrors to choose a faster CVS mirror, if
864: needed.
1.1 dsieger 865:
1.24 wiz 866: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1 dsieger 867:
1.40 wiz 868: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 869:
1.24 wiz 870: Refer to documentation on your command shell how to set CVS_RSH=ssh
871: permanently. For Bourne shells, you can set it in your .profile or better
872: globally in /etc/profile:
873:
874: # set CVS remote shell command
875: CVS_RSH=ssh
876: export CVS_RSH
1.12 weinem 877:
1.13 weinem 878: By default, CVS doesn't do things like most people would expect it to do. But
879: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12 weinem 880: directory and saving the following lines to it. This file will save you lots of
881: headache and some bug reports, so we strongly recommend it. You can find an
882: explanation of this file in the CVS documentation.
1.2 rillig 883:
884: # recommended CVS configuration file from the pkgsrc guide
1.40 wiz 885: cvs -q -z2
1.2 rillig 886: checkout -P
1.4 rillig 887: update -dP
888: diff -upN
1.2 rillig 889: rdiff -u
1.24 wiz 890: release -d
1.1 dsieger 891:
892: 2.2. Keeping pkgsrc up-to-date
893:
894: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
895: have first installed it via a tar file). It saves bandwidth and hard disk
896: activity, compared to downloading the tar file again.
897:
898: 2.2.1. Via tar files
899:
900: Warning
901:
902: When updating from a tar file, you first need to completely remove the old
903: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
904: the mean time will not be removed on your local disk, resulting in
905: inconsistencies. When removing the old files, any changes that you have done to
906: the pkgsrc files will be lost after updating. Therefore updating via CVS is
907: strongly recommended.
908:
909: Note that by default the distfiles and the binary packages are saved in the
910: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78 snj 911: configure pkgsrc to store distfiles and packages in directories outside the
912: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter 5,
913: Configuring pkgsrc for the details.
1.1 dsieger 914:
915: To update pkgsrc from a tar file, download the tar file as explained above.
916: Then, make sure that you have not made any changes to the files in the pkgsrc
917: directory. Remove the pkgsrc directory and extract the new tar file. Done.
918:
919: 2.2.2. Via CVS
920:
1.26 spz 921: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12 weinem 922:
1.26 spz 923: $ cd /usr/pkgsrc && cvs update -dP
924:
925: If you get error messages from rsh, you need to set CVS_RSH variable as
926: described above. E.g.:
927:
928: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1 dsieger 929:
930: 2.2.2.1. Switching between different pkgsrc branches
931:
932: When updating pkgsrc, the CVS program keeps track of the branch you selected.
933: But if you, for whatever reason, want to switch from the stable branch to the
934: current one, you can do it by adding the option "-A" after the "update"
1.25 wiz 935: keyword. To switch from the current branch back to the stable branch, add the "
1.118 sevan 936: -rpkgsrc-2016Q4" option.
1.1 dsieger 937:
938: 2.2.2.2. What happens to my changes when updating?
939:
940: When you update pkgsrc, the CVS program will only touch those files that are
941: registered in the CVS repository. That means that any packages that you created
942: on your own will stay unmodified. If you change files that are managed by CVS,
943: later updates will try to merge your changes with those that have been done by
944: others. See the CVS manual, chapter "update" for details.
945:
946: Chapter 3. Using pkgsrc on systems other than NetBSD
947:
948: Table of Contents
949:
950: 3.1. Binary distribution
951: 3.2. Bootstrapping pkgsrc
952:
953: 3.1. Binary distribution
954:
1.9 rillig 955: See Section 4.1, "Using binary packages".
1.1 dsieger 956:
957: 3.2. Bootstrapping pkgsrc
958:
1.44 asau 959: pkgsrc can be bootstrapped for use in two different modes: privileged and
960: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45 asau 961: programs are installed under one particular user and cannot utilise privileged
1.44 asau 962: operations (packages don't create special users and all special file
963: permissions like setuid are ignored).
964:
1.1 dsieger 965: Installing the bootstrap kit from source should be as simple as:
966:
1.60 asau 967: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 968: # cd pkgsrc/bootstrap
969: # ./bootstrap
970:
971:
1.44 asau 972: To bootstrap in unprivileged mode pass "--unprivileged" flag to bootstrap
973:
974: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1.118 sevan 975: will be installed in, and /usr/pkg/pkgdb for the package database directory
976: where pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1.44 asau 977: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1.118 sevan 978: for prefix, ~/pkg/pkgdb for the package database, and ~/pkg/var for varbase.
1.44 asau 979:
980: You can change default layout using command-line arguments. Run "./bootstrap
981: --help" to get details.
1.1 dsieger 982:
983: Note
984:
985: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
986: For examples in this guide, use bmake instead of "make".
987:
1.44 asau 988: Note
989:
990: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
991: directories. Use bmake corresponding to the installation you're working with to
992: build and install packages.
993:
1.1 dsieger 994: Chapter 4. Using pkgsrc
995:
996: Table of Contents
997:
998: 4.1. Using binary packages
999:
1000: 4.1.1. Finding binary packages
1001: 4.1.2. Installing binary packages
1002: 4.1.3. Deinstalling packages
1003: 4.1.4. Getting information about installed packages
1004: 4.1.5. Checking for security vulnerabilities in installed packages
1005: 4.1.6. Finding if newer versions of your installed packages are in pkgsrc
1006: 4.1.7. Other administrative functions
1007:
1008: 4.2. Building packages from source
1009:
1010: 4.2.1. Requirements
1011: 4.2.2. Fetching distfiles
1012: 4.2.3. How to build and install
1013:
1014: Basically, there are two ways of using pkgsrc. The first is to only install the
1015: package tools and to use binary packages that someone else has prepared. This
1016: is the "pkg" in pkgsrc. The second way is to install the "src" of pkgsrc, too.
1017: Then you are able to build your own packages, and you can still use binary
1018: packages from someone else.
1019:
1020: 4.1. Using binary packages
1021:
1.9 rillig 1022: On the ftp.NetBSD.org server and its mirrors, there are collections of binary
1023: packages, ready to be installed. These binary packages have been built using
1024: the default settings for the directories, that is:
1025:
1026: * /usr/pkg for LOCALBASE, where most of the files are installed,
1027:
1028: * /usr/pkg/etc for configuration files,
1029:
1030: * /var for VARBASE, where those files are installed that may change after
1031: installation.
1032:
1033: If you cannot use these directories for whatever reasons (maybe because you're
1034: not root), you cannot use these binary packages, but have to build the packages
1035: yourself, which is explained in Section 3.2, "Bootstrapping pkgsrc".
1.1 dsieger 1036:
1037: 4.1.1. Finding binary packages
1038:
1.5 weinem 1039: To install binary packages, you first need to know from where to get them. The
1040: first place where you should look is on the main pkgsrc FTP server in the
1041: directory /pub/pkgsrc/packages.
1042:
1043: This directory contains binary packages for multiple platforms. First, select
1044: your operating system. (Ignore the directories with version numbers attached to
1045: it, they just exist for legacy reasons.) Then, select your hardware
1046: architecture, and in the third step, the OS version and the "version" of
1.9 rillig 1047: pkgsrc.
1048:
1049: In this directory, you often find a file called bootstrap.tar.gz which contains
1050: the package management tools. If the file is missing, it is likely that your
1051: operating system already provides those tools. Download the file and extract it
1052: in the / directory. It will create the directories /usr/pkg (containing the
1.118 sevan 1053: tools for managing binary packages and the database of installed packages).
1.1 dsieger 1054:
1055: 4.1.2. Installing binary packages
1056:
1.85 wiz 1057: In the directory from the last section, there is a subdirectory called All/,
1.9 rillig 1058: which contains all the binary packages that are available for the platform,
1059: excluding those that may not be distributed via FTP or CDROM (depending on
1.24 wiz 1060: which medium you are using).
1.9 rillig 1061:
1062: To install packages directly from an FTP or HTTP server, run the following
1063: commands in a Bourne-compatible shell (be sure to su to root first):
1064:
1065: # PATH="/usr/pkg/sbin:$PATH"
1.85 wiz 1066: # PKG_PATH="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/OPSYS/ARCH/VERSIONS/All/"
1.9 rillig 1067: # export PATH PKG_PATH
1068:
1069: Instead of URLs, you can also use local paths, for example if you are
1070: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
1071: to install packages from multiple sources, you can separate them by a semicolon
1072: in PKG_PATH.
1073:
1074: After these preparations, installing a package is very easy:
1075:
1.118 sevan 1076: # pkg_add libreoffice
1.9 rillig 1077: # pkg_add kde-3.5.7
1.118 sevan 1078: # pkg_add ap24-php71-*
1.1 dsieger 1079:
1080: Note that any prerequisite packages needed to run the package in question will
1081: be installed, too, assuming they are present where you install from.
1082:
1.25 wiz 1083: Adding packages might install vulnerable packages. Thus you should run
1.24 wiz 1084: pkg_admin audit regularly, especially after installing new packages, and verify
1085: that the vulnerabilities are acceptable for your configuration.
1.1 dsieger 1086:
1087: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
1088: in your PATH so you can actually start the just installed program.
1089:
1090: 4.1.3. Deinstalling packages
1091:
1092: To deinstall a package, it does not matter whether it was installed from source
1093: code or from a binary package. The pkg_delete command does not know it anyway.
1094: To delete a package, you can just run pkg_delete package-name. The package name
1095: can be given with or without version number. Wildcards can also be used to
1096: deinstall a set of packages, for example *emacs*. Be sure to include them in
1097: quotes, so that the shell does not expand them before pkg_delete sees them.
1098:
1099: The -r option is very powerful: it removes all the packages that require the
1100: package in question and then removes the package itself. For example:
1101:
1102: # pkg_delete -r jpeg
1103:
1104:
1105: will remove jpeg and all the packages that used it; this allows upgrading the
1106: jpeg package.
1107:
1108: 4.1.4. Getting information about installed packages
1109:
1110: The pkg_info shows information about installed packages or binary package
1111: files.
1112:
1113: 4.1.5. Checking for security vulnerabilities in installed packages
1114:
1115: The NetBSD Security-Officer and Packages Groups maintain a list of known
1116: security vulnerabilities to packages which are (or have been) included in
1117: pkgsrc. The list is available from the NetBSD FTP site at ftp://ftp.NetBSD.org/
1118: pub/pkgsrc/distfiles/vulnerabilities.
1119:
1.23 jakllsch 1120: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
1121: automatically, and a security audit of all packages installed on a system can
1122: take place.
1123:
1124: There are two components to auditing. The first step, pkg_admin
1125: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
1126: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
1127: your installed packages are vulnerable. If a package is vulnerable, you will
1128: see output similar to the following:
1.1 dsieger 1129:
1130: Package samba-2.0.9 has a local-root-shell vulnerability, see
1131: http://www.samba.org/samba/whatsnew/macroexploit.html
1132:
1.23 jakllsch 1133: You may wish to have the vulnerabilities file downloaded daily so that it
1134: remains current. This may be done by adding an appropriate entry to the root
1135: users crontab(5) entry. For example the entry
1136:
1.121 ! sevan 1137: # Download vulnerabilities file
1.118 sevan 1138: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.121 ! sevan 1139: # Audit the installed packages and email results to root
! 1140: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
! 1141: root >/dev/null 2>&1
1.118 sevan 1142:
1143:
1144: will update the vulnerability list every day at 3AM, followed by an audit at
1145: 3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
1146: accomplished instead by adding the following line to /etc/daily.conf:
1147:
1148: fetch_pkg_vulnerabilities=YES
1149:
1.23 jakllsch 1150:
1.118 sevan 1151: to fetch the vulnerability list from the daily security script. The system is
1152: set to audit the packages by default but can be set explicitly, if desired (not
1153: required), by adding the follwing line to /etc/security.conf:
1.23 jakllsch 1154:
1.118 sevan 1155: check_pkg_vulnerabilities=YES
1.23 jakllsch 1156:
1157:
1.118 sevan 1158: see daily.conf(5) and security.conf(5) for more details.
1.1 dsieger 1159:
1160: 4.1.6. Finding if newer versions of your installed packages are in pkgsrc
1161:
1.12 weinem 1162: Install pkgtools/lintpkgsrc and run lintpkgsrc with the "-i" argument to check
1163: if your packages are up-to-date, e.g.
1.1 dsieger 1164:
1165: % lintpkgsrc -i
1166: ...
1167: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
1168:
1169:
1170: You can then use make update to update the package on your system and rebuild
1171: any dependencies.
1172:
1173: 4.1.7. Other administrative functions
1174:
1175: The pkg_admin executes various administrative functions on the package system.
1176:
1177: 4.2. Building packages from source
1178:
1179: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25 wiz 1180: organized into categories. You can browse the online index of packages, or run
1.1 dsieger 1181: make readme from the pkgsrc directory to build local README.html files for all
1182: packages, viewable with any web browser such as www/lynx or www/firefox.
1183:
1184: The default prefix for installed packages is /usr/pkg. If you wish to change
1185: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
1186: use multiple different LOCALBASE definitions on the same system (inside a
1187: chroot is an exception).
1188:
1189: The rest of this chapter assumes that the package is already in pkgsrc. If it
1190: is not, see Part II, "The pkgsrc developer's guide" for instructions how to
1191: create your own packages.
1192:
1193: 4.2.1. Requirements
1194:
1195: To build packages from source, you need a working C compiler. On NetBSD, you
1196: need to install the "comp" and the "text" distribution sets. If you want to
1197: build X11-related packages, the "xbase" and "xcomp" distribution sets are
1198: required, too.
1199:
1200: 4.2.2. Fetching distfiles
1201:
1202: The first step for building a package is downloading the distfiles (i.e. the
1203: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
1204: them automatically.
1205:
1206: If you have all files that you need in the distfiles directory, you don't need
1207: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
1208: and add:
1209:
1210: DISTDIR=/cdrom/pkgsrc/distfiles
1211:
1212: to your mk.conf.
1213:
1214: By default a list of distribution sites will be randomly intermixed to prevent
1215: huge load on servers which holding popular packages (for example,
1216: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
1217: distfile all the mirrors will be tried in new (random) order. You can turn this
1218: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
1219: disabled).
1220:
1221: You can overwrite some of the major distribution sites to fit to sites that are
1222: close to your own. By setting one or two variables you can modify the order in
1223: which the master sites are accessed. MASTER_SORT contains a whitespace
1224: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
1225: contains a whitespace delimited list of regular expressions. It has higher
1226: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
1227: some examples. This may save some of your bandwidth and time.
1228:
1229: You can change these settings either in your shell's environment, or, if you
1.4 rillig 1230: want to keep the settings, by editing the mk.conf file, and adding the
1.1 dsieger 1231: definitions there.
1232:
1233: If a package depends on many other packages (such as meta-pkgs/kde3), the build
1234: process may alternate between periods of downloading source, and compiling. To
1235: ensure you have all the source downloaded initially you can run the command:
1236:
1237: % make fetch-list | sh
1238:
1239: which will output and run a set of shell commands to fetch the necessary files
1240: into the distfiles directory. You can also choose to download the files
1241: manually.
1242:
1243: 4.2.3. How to build and install
1244:
1245: Once the software has downloaded, any patches will be applied, then it will be
1246: compiled for you. This may take some time depending on your computer, and how
1247: many other packages the software depends on and their compile time.
1248:
1249: Note
1250:
1251: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
1252: command instead of "make" in the examples in this guide.
1253:
1254: For example, type
1255:
1256: % cd misc/figlet
1257: % make
1258:
1259:
1260: at the shell prompt to build the various components of the package.
1261:
1262: The next stage is to actually install the newly compiled program onto your
1263: system. Do this by entering:
1264:
1265: % make install
1266:
1267:
1268: while you are still in the directory for whatever package you are installing.
1269:
1270: Installing the package on your system may require you to be root. However,
1271: pkgsrc has a just-in-time-su feature, which allows you to only become root for
1272: the actual installation step.
1273:
1274: That's it, the software should now be installed and setup for use. You can now
1275: enter:
1276:
1277: % make clean
1278:
1279:
1280: to remove the compiled files in the work directory, as you shouldn't need them
1281: any more. If other packages were also added to your system (dependencies) to
1282: allow your program to compile, you can tidy these up also with the command:
1283:
1284: % make clean-depends
1285:
1286:
1287: Taking the figlet utility as an example, we can install it on our system by
1288: building as shown in Appendix B, Build logs.
1289:
1290: The program is installed under the default root of the packages tree - /usr/
1291: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
1292: environment, and it will use that value as the root of your packages tree. So,
1293: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
1294: that you should use a directory which is dedicated to packages and not shared
1295: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
1296: not try to add any of your own files or directories (such as src/, obj/, or
1297: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
1298: between programs and other files installed by the package system and whatever
1299: else may have been installed there.
1300:
1.4 rillig 1301: Some packages look in mk.conf to alter some configuration options at build
1.1 dsieger 1302: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
1303: be set there by default. Environment variables such as LOCALBASE can be set in
1.4 rillig 1304: mk.conf to save having to remember to set them each time you want to use
1.1 dsieger 1305: pkgsrc.
1306:
1307: Occasionally, people want to "look under the covers" to see what is going on
1308: when a package is building or being installed. This may be for debugging
1309: purposes, or out of simple curiosity. A number of utility values have been
1310: added to help with this.
1311:
1312: 1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
1313: amount of information will be displayed. For example,
1314:
1315: make patch PKG_DEBUG_LEVEL=2
1316:
1.25 wiz 1317: will show all the commands that are invoked, up to and including the "patch
1318: " stage.
1.1 dsieger 1319:
1320: 2. If you want to know the value of a certain make(1) definition, then the
1321: VARNAME definition should be used, in conjunction with the show-var target.
1322: e.g. to show the expansion of the make(1) variable LOCALBASE:
1323:
1324: % make show-var VARNAME=LOCALBASE
1325: /usr/pkg
1326: %
1327:
1328:
1329: If you want to install a binary package that you've either created yourself
1330: (see next section), that you put into pkgsrc/packages manually or that is
1331: located on a remote FTP server, you can use the "bin-install" target. This
1332: target will install a binary package - if available - via pkg_add(1), else do a
1333: make package. The list of remote FTP sites searched is kept in the variable
1334: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
1335: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
1336: for more details.
1337:
1338: A final word of warning: If you set up a system that has a non-standard setting
1339: for LOCALBASE, be sure to set that before any packages are installed, as you
1340: cannot use several directories for the same purpose. Doing so will result in
1341: pkgsrc not being able to properly detect your installed packages, and fail
1342: miserably. Note also that precompiled binary packages are usually built with
1343: the default LOCALBASE of /usr/pkg, and that you should not install any if you
1344: use a non-standard LOCALBASE.
1345:
1346: Chapter 5. Configuring pkgsrc
1347:
1348: Table of Contents
1349:
1350: 5.1. General configuration
1351: 5.2. Variables affecting the build process
1.9 rillig 1352: 5.3. Variables affecting the installation process
1.4 rillig 1353: 5.4. Selecting and configuring the compiler
1.1 dsieger 1354:
1.4 rillig 1355: 5.4.1. Selecting the compiler
1356: 5.4.2. Additional flags to the compiler (CFLAGS)
1357: 5.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 1358:
1.4 rillig 1359: 5.5. Developer/advanced settings
1360: 5.6. Selecting Build Options
1.1 dsieger 1361:
1362: The whole pkgsrc system is configured in a single file, usually called mk.conf.
1363: In which directory pkgsrc looks for that file depends on the installation. On
1364: NetBSD, when you use make(1) from the base system, it is in the directory /etc
1365: /. In all other cases the default location is ${PREFIX}/etc/, depending on
1366: where you told the bootstrap program to install the binary packages.
1367:
1368: The format of the configuration file is that of the usual BSD-style Makefiles.
1369: The whole pkgsrc configuration is done by setting variables in this file. Note
1370: that you can define all kinds of variables, and no special error checking (for
1.112 rillig 1371: example for spelling mistakes) takes place.
1.1 dsieger 1372:
1373: 5.1. General configuration
1374:
1.112 rillig 1375: The following variables apply to all pkgsrc packages. A complete list of the
1376: variables that can be configured by the user is available in mk/defaults/
1377: mk.conf, together with some comments that describe each variable's intent.
1.1 dsieger 1378:
1379: * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
1380: not mix binary packages with different LOCALBASEs!
1381:
1382: * CROSSBASE: Where "cross" category packages will be installed. The default
1383: is ${LOCALBASE}/cross.
1384:
1.84 wiz 1385: * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1 dsieger 1386:
1387: * DISTDIR: Where to store the downloaded copies of the original source
1388: distributions used for building pkgsrc packages. The default is $
1389: {PKGSRCDIR}/distfiles.
1390:
1391: * PKG_DBDIR: Where the database about installed packages is stored. The
1.118 sevan 1392: default is /usr/pkg/pkgdb.
1.1 dsieger 1393:
1394: * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
1395: value.
1396:
1397: * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
1398: files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.118 sevan 1399: respectively. The defaults is ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1.1 dsieger 1400: {DIST_SUBDIR}/.
1401:
1402: * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
1403: with OS release ("2.0", etc.) and architecture ("mipsel", etc.).
1404:
1.23 jakllsch 1405: * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
1406: case-sensitive. Whenever you try to build a package whose license is not in
1407: this list, you will get an error message. If the license condition is
1408: simple enough, the error message will include specific instructions on how
1409: to change this variable.
1.1 dsieger 1410:
1411: 5.2. Variables affecting the build process
1412:
1413: * PACKAGES: The top level directory for the binary packages. The default is $
1414: {PKGSRCDIR}/packages.
1415:
1416: * WRKOBJDIR: The top level directory where, if defined, the separate working
1417: directories will get created, and symbolically linked to from ${WRKDIR}
1418: (see below). This is useful for building packages on several architectures,
1419: then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
1420: architecture. (It should be noted that PKGSRCDIR should not be set by the
1421: user ? it is an internal definition which refers to the root of the pkgsrc
1422: tree. It is possible to have many pkgsrc tree instances.)
1423:
1424: * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.6 rillig 1425: Section 11.3, "patches/*" for more information.
1.1 dsieger 1426:
1427: * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
1428: Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
1429: up settings used by builds in /usr/src.
1430:
1431: * DEPENDS_TARGET: By default, dependencies are only installed, and no binary
1.66 asau 1432: package is created for them. You can set this variable to package-install
1433: to automatically create binary packages after installing dependencies.
1.84 wiz 1434: Please note that the PKGSRC_KEEP_BIN_PKGS can be set to yes to preserve
1.80 wiz 1435: binary packages when using the install as well.
1.1 dsieger 1436:
1.9 rillig 1437: 5.3. Variables affecting the installation process
1.1 dsieger 1438:
1.107 jnemeth 1439: Packages have to support installation into a subdirectory of WRKDIR. This
1440: allows a package to be built, before the actual filesystem is touched. DESTDIR
1441: support exists in two variations:
1.4 rillig 1442:
1443: * Basic DESTDIR support means that the package installation and packaging is
1444: still run as root.
1445:
1446: * Full DESTDIR support can run the complete build, installation and packaging
1447: as normal user. Root privileges are only needed to add packages.
1448:
1449: With basic DESTDIR support, make clean needs to be run as root.
1450:
1.17 imil 1451: Considering the foo/bar package, DESTDIR full support can be tested using the
1452: following commands
1453:
1454: $ id
1455: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
1456: $ mkdir $HOME/packages
1457: $ cd $PKGSRCDIR/foo/bar
1458:
1459: Verify DESTDIR full support, no root privileges should be needed
1460:
1.66 asau 1461: $ make stage-install
1.17 imil 1462:
1463: Create a package without root privileges
1464:
1.66 asau 1465: $ make PACKAGES=$HOME/packages package
1.17 imil 1466:
1467: For the following command, you must be able to gain root privileges using su(1)
1468:
1.66 asau 1469: $ make PACKAGES=$HOME/packages install
1.17 imil 1470:
1471: Then, as a simple user
1472:
1473: $ make clean
1474:
1.4 rillig 1475: 5.4. Selecting and configuring the compiler
1476:
1477: 5.4.1. Selecting the compiler
1.1 dsieger 1478:
1479: By default, pkgsrc will use GCC to build packages. This may be overridden by
1480: setting the following variables in /etc/mk.conf:
1481:
1482: PKGSRC_COMPILER:
1483:
1484: This is a list of values specifying the chain of compilers to invoke when
1485: building packages. Valid values are:
1486:
1.66 asau 1487: + ccc: Compaq C Compilers (Tru64)
1488:
1489: + ccache: compiler cache (chainable)
1490:
1491: + clang: Clang C and Objective-C compiler
1492:
1.42 asau 1493: + distcc: distributed C/C++ (chainable)
1.1 dsieger 1494:
1.66 asau 1495: + f2c: Fortran 77 to C compiler (chainable)
1496:
1497: + icc: Intel C++ Compiler (Linux)
1498:
1499: + ido: SGI IRIS Development Option cc (IRIX 5)
1.1 dsieger 1500:
1.42 asau 1501: + gcc: GNU C/C++ Compiler
1.1 dsieger 1502:
1.66 asau 1503: + hp: HP-UX C/aC++ compilers
1504:
1.42 asau 1505: + mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1 dsieger 1506:
1.66 asau 1507: + mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1 dsieger 1508:
1.42 asau 1509: + sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1 dsieger 1510:
1.118 sevan 1511: + xlc: IBM's XL C/C++ compiler suite
1.66 asau 1512:
1.1 dsieger 1513: The default is "gcc". You can use ccache and/or distcc with an appropriate
1514: PKGSRC_COMPILER setting, e.g. "ccache gcc". This variable should always be
1515: terminated with a value for a real compiler. Note that only one real
1516: compiler should be listed (e.g. "sunpro gcc" is not allowed).
1517:
1518: GCC_REQD:
1519:
1520: This specifies the minimum version of GCC to use when building packages. If
1521: the system GCC doesn't satisfy this requirement, then pkgsrc will build and
1522: install one of the GCC packages to use instead.
1523:
1.114 maya 1524: PYTHON_DEFAULT_VERSION:
1525:
1526: Specifies which version of python to use when several options are
1527: available.
1528:
1529: PKGSRC_FORTRAN:
1530:
1531: Specifies the fortran compiler to use. The default is g95, and gfortran is
1532: an alternative.
1533:
1534: GFORTRAN_VERSION:
1535:
1536: If PKGSRC_FORTRAN= gfortran is used, this option specifies which version to
1537: use.
1538:
1.4 rillig 1539: 5.4.2. Additional flags to the compiler (CFLAGS)
1.1 dsieger 1540:
1541: If you wish to set the CFLAGS variable, please make sure to use the += operator
1542: instead of the = operator:
1543:
1544: CFLAGS+= -your -flags
1545:
1546: Using CFLAGS= (i.e. without the "+") may lead to problems with packages that
1.16 jnemeth 1547: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24 wiz 1548: package if you're interested in optimization specifically for the current CPU.
1.1 dsieger 1549:
1.4 rillig 1550: 5.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 1551:
1552: If you want to pass flags to the linker, both in the configure step and the
1553: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
1554: difference between the two is that LIBS will be appended to the command line,
1555: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
1556: machines depending on the setting of USE_IMAKE or the inclusion of mk/
1557: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
1558: settings, use the += operator:
1559:
1560: LDFLAGS+= -your -linkerflags
1561:
1.4 rillig 1562: 5.5. Developer/advanced settings
1.1 dsieger 1563:
1564: * PKG_DEVELOPER: Run some sanity checks that package developers want:
1565:
1.42 asau 1566: + make sure patches apply with zero fuzz
1.1 dsieger 1567:
1.42 asau 1568: + run check-shlibs to see that all binaries will find their shared libs.
1.1 dsieger 1569:
1570: * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
1571: making and installing the package. The default value for this is 0, which
1572: will not display the commands as they are executed (normal, default, quiet
1573: operation); the value 1 will display all shell commands before their
1574: invocation, and the value 2 will display both the shell commands before
1.112 rillig 1575: their invocation, as well as their actual execution progress with set -x.
1.1 dsieger 1576:
1.4 rillig 1577: 5.6. Selecting Build Options
1.1 dsieger 1578:
1579: Some packages have build time options, usually to select between different
1580: dependencies, enable optional support for big dependencies or enable
1581: experimental features.
1582:
1583: To see which options, if any, a package supports, and which options are
1584: mutually exclusive, run make show-options, for example:
1585:
1586: The following options are supported by this package:
1587: ssl Enable SSL support.
1588: Exactly one of the following gecko options is required:
1589: firefox Use firefox as gecko rendering engine.
1590: mozilla Use mozilla as gecko rendering engine.
1591: At most one of the following database options may be selected:
1592: mysql Enable support for MySQL database.
1593: pgsql Enable support for PostgreSQL database.
1594:
1595: These options are enabled by default: firefox
1596: These options are currently enabled: mozilla ssl
1597:
1.4 rillig 1598: The following variables can be defined in mk.conf to select which options to
1599: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1 dsieger 1600: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
1601: which can be used to select or disable options specifically for package pkgbase
1602: . Options listed in these variables are selected, options preceded by "-" are
1603: disabled. A few examples:
1604:
1.4 rillig 1605: $ grep "PKG.*OPTION" mk.conf
1.1 dsieger 1606: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
1607: PKG_OPTIONS.kdebase= debug -sasl
1608: PKG_OPTIONS.apache= suexec
1609:
1.11 rillig 1610: It is important to note that options that were specifically suggested by the
1.19 snj 1611: package maintainer must be explicitly removed if you do not wish to include the
1612: option. If you are unsure you can view the current state with make show-options
1613: .
1.11 rillig 1614:
1.1 dsieger 1615: The following settings are consulted in the order given, and the last setting
1616: that selects or disables an option is used:
1617:
1618: 1. the default options as suggested by the package maintainer
1619:
1620: 2. the options implied by the settings of legacy variables (see below)
1621:
1622: 3. PKG_DEFAULT_OPTIONS
1623:
1624: 4. PKG_OPTIONS.pkgbase
1625:
1626: For groups of mutually exclusive options, the last option selected is used, all
1627: others are automatically disabled. If an option of the group is explicitly
1628: disabled, the previously selected option, if any, is used. It is an error if no
1629: option from a required group of options is selected, and building the package
1630: will fail.
1631:
1632: Before the options framework was introduced, build options were selected by
1.4 rillig 1633: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
1634: transition to the options framework for the user, these legacy variables are
1635: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
1636: automatically. A warning is issued to prompt the user to update mk.conf to use
1637: the options framework directly. Support for the legacy variables will be
1.1 dsieger 1638: removed eventually.
1639:
1640: Chapter 6. Creating binary packages
1641:
1642: Table of Contents
1643:
1644: 6.1. Building a single binary package
1645: 6.2. Settings for creation of binary packages
1646:
1647: 6.1. Building a single binary package
1648:
1649: Once you have built and installed a package, you can create a binary package
1650: which can be installed on another system with pkg_add(1). This saves having to
1651: build the same package on a group of hosts and wasting CPU time. It also
1652: provides a simple means for others to install your package, should you
1653: distribute it.
1654:
1655: To create a binary package, change into the appropriate directory in pkgsrc,
1656: and run make package:
1657:
1.112 rillig 1658: $ cd misc/figlet
1659: $ make package
1.1 dsieger 1660:
1661: This will build and install your package (if not already done), and then build
1662: a binary package from what was installed. You can then use the pkg_* tools to
1663: manipulate it. Binary packages are created by default in /usr/pkgsrc/packages,
1664: in the form of a gzipped tar file. See Section B.2, "Packaging figlet" for a
1665: continuation of the above misc/figlet example.
1666:
1.6 rillig 1667: See Chapter 21, Submitting and Committing for information on how to submit such
1.1 dsieger 1668: a binary package.
1669:
1670: 6.2. Settings for creation of binary packages
1671:
1.6 rillig 1672: See Section 17.17, "Other helpful targets".
1673:
1674: Chapter 7. Creating binary packages for everything in pkgsrc (bulk builds)
1675:
1676: Table of Contents
1677:
1.71 wiz 1678: 7.1. Preparations
1679: 7.2. Running a pbulk-style bulk build
1.6 rillig 1680:
1.71 wiz 1681: 7.2.1. Configuration
1.6 rillig 1682:
1.71 wiz 1683: 7.3. Requirements of a full bulk build
1.66 asau 1684: 7.4. Creating a multiple CD-ROM packages collection
1.6 rillig 1685:
1.66 asau 1686: 7.4.1. Example of cdpack
1.6 rillig 1687:
1.71 wiz 1688: For a number of reasons you may want to build binary packages for a large
1689: selected set of packages in pkgsrc or even for all pkgsrc packages. For
1690: instance, when you have multiple machines that should run the same software, it
1691: is wasted time if they all build their packages themselves from source. Or you
1692: may want to build a list of packages you want and check them before deploying
1693: onto production system. There is a way of getting a set of binary packages: The
1.112 rillig 1694: bulk build system, or pbulk ("p" stands for "parallel"). This chapter describes
1695: how to set it up.
1.71 wiz 1696:
1697: 7.1. Preparations
1698:
1699: First of all, you have to decide whether you build all packages or a limited
1700: set of them. Full bulk builds usually consume a lot more resources, both space
1701: and time, than builds for some practical sets of packages. There exists a
1702: number of particularly heavy packages that are not actually interesting to a
1703: wide audience. For a limited bulk builds you need to make a list of packages
1.112 rillig 1704: you want to build. Note that all their dependencies will be built, so you don't
1705: need to track them manually.
1.71 wiz 1706:
1707: During bulk builds various packages are installed and deinstalled in /usr/pkg
1708: (or whatever LOCALBASE is), so make sure that you don't need any package during
1.112 rillig 1709: the builds. Essentially, you should provide a fresh system, either a chroot
1.71 wiz 1710: environment or something even more restrictive, depending on what the operating
1711: system provides, or dedicate the whole physical machine. As a useful side
1712: effect this makes sure that bulk builds cannot break anything in your system.
1713: There have been numerous cases where certain packages tried to install files
1714: outside the LOCALBASE or wanted to edit some files in /etc.
1.6 rillig 1715:
1.71 wiz 1716: 7.2. Running a pbulk-style bulk build
1.6 rillig 1717:
1.15 rillig 1718: Running a pbulk-style bulk build works roughly as follows:
1719:
1720: * First, build the pbulk infrastructure in a fresh pkgsrc location.
1721:
1722: * Then, build each of the packages from a clean installation directory using
1723: the infrastructure.
1724:
1.71 wiz 1725: 7.2.1. Configuration
1.6 rillig 1726:
1.112 rillig 1727: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6 rillig 1728:
1.68 asau 1729: In order to use it, prepare a clear system (real one, chroot environment, jail,
1730: zone, virtual machine). Configure network access to fetch distribution files.
1.112 rillig 1731: Create a user with name "pbulk".
1.68 asau 1732:
1733: Fetch and extract pkgsrc. Use a command like one of these:
1734:
1.72 wiz 1735: # (cd /usr && ftp -o - http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1736: # (cd /usr && fetch -o - http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1737: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68 asau 1738:
1739: Or any other way that fits (e.g., curl, wget).
1740:
1741: Deploy and configure pbulk tools, e.g.:
1742:
1.118 sevan 1743: # sh pbulk.sh -n # use native make, no bootstrap kit needed (for use on NetBSD)
1.68 asau 1744: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
1745: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
1746:
1747: Note
1748:
1749: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
1750: to packages you build. For instance,
1751:
1.112 rillig 1752: PKG_DEVELOPER= yes # perform more checks
1753: X11_TYPE= modular # use pkgsrc X11
1754: SKIP_LICENSE_CHECK= yes # accept all licences (useful
1755: # when building all packages)
1.68 asau 1756:
1757: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112 rillig 1758: with your list of packages, one per line without empty lines or comments. E.g.:
1.68 asau 1759:
1760: www/firefox
1761: mail/thunderbird
1762: misc/libreoffice4
1763:
1.69 asau 1764: At this point you can also review configuration in /usr/pbulk/etc and make
1765: final amendments, if wanted.
1766:
1.68 asau 1767: Start it:
1768:
1769: # /usr/pbulk/bin/bulkbuild
1770:
1771: After it finishes, you'll have /mnt filled with distribution files, binary
1772: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
1773:
1774: Note
1775:
1776: The pbulk.sh script does not cover all possible use cases. While being ready to
1777: run, it serves as a good starting point to understand and build more complex
1778: setups. The script is kept small enough for better understanding.
1779:
1780: Note
1781:
1782: The pbulk.sh script supports running unprivileged bulk build and helps
1783: configuring distributed bulk builds.
1.15 rillig 1784:
1.71 wiz 1785: 7.3. Requirements of a full bulk build
1786:
1787: A complete bulk build requires lots of disk space. Some of the disk space can
1788: be read-only, some other must be writable. Some can be on remote filesystems
1789: (such as NFS) and some should be local. Some can be temporary filesystems,
1790: others must survive a sudden reboot.
1791:
1792: * 40 GB for the distfiles (read-write, remote, temporary)
1793:
1794: * 30 GB for the binary packages (read-write, remote, permanent)
1795:
1796: * 1 GB for the pkgsrc tree (read-only, remote, permanent)
1797:
1798: * 5 GB for LOCALBASE (read-write, local, temporary)
1799:
1800: * 10 GB for the log files (read-write, remote, permanent)
1801:
1802: * 5 GB for temporary files (read-write, local, temporary)
1803:
1.66 asau 1804: 7.4. Creating a multiple CD-ROM packages collection
1.1 dsieger 1805:
1806: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
1807: of the resulting binary packages to assist in installing packages on other
1808: machines. The pkgtools/cdpack package provides a simple tool for creating the
1809: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
1810: keeps all the dependencies for a given package on the same CD as that package.
1811:
1.66 asau 1812: 7.4.1. Example of cdpack
1.1 dsieger 1813:
1814: Complete documentation for cdpack is found in the cdpack(1) man page. The
1815: following short example assumes that the binary packages are left in /usr/
1816: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
1817: ISO 9660 images.
1818:
1819: # mkdir /u2/images
1820: # pkg_add /usr/pkgsrc/packages/All/cdpack
1821: # cdpack /usr/pkgsrc/packages/All /u2/images
1822:
1823:
1824: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
1825: CD in the collection, then you need to create a directory which contains these
1826: files. e.g.
1827:
1828: # mkdir /tmp/common
1829: # echo "This is a README" > /tmp/common/README
1830: # echo "Another file" > /tmp/common/COPYING
1831: # mkdir /tmp/common/bin
1832: # echo "#!/bin/sh" > /tmp/common/bin/myscript
1833: # echo "echo Hello world" >> /tmp/common/bin/myscript
1834: # chmod 755 /tmp/common/bin/myscript
1835:
1836:
1837: Now create the images:
1838:
1839: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
1840:
1841: Each image will contain README, COPYING, and bin/myscript in their root
1842: directories.
1843:
1.6 rillig 1844: Chapter 8. Directory layout of the installed files
1.1 dsieger 1845:
1846: Table of Contents
1847:
1.6 rillig 1848: 8.1. File system layout in ${LOCALBASE}
1849: 8.2. File system layout in ${VARBASE}
1.1 dsieger 1850:
1851: The files that are installed by pkgsrc are organized in a way that is similar
1852: to what you find in the /usr directory of the base system. But some details are
1853: different. This is because pkgsrc initially came from FreeBSD and had adopted
1854: its file system hierarchy. Later it was largely influenced by NetBSD. But no
1855: matter which operating system you are using pkgsrc with, you can expect the
1856: same layout for pkgsrc.
1857:
1858: There are mainly four root directories for pkgsrc, which are all configurable
1859: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
1860: default locations are:
1861:
1862: LOCALBASE= /usr/pkg
1863: PKG_SYSCONFBASE= /usr/pkg/etc
1864: VARBASE= /var
1.119 sevan 1865: PKG_DBDIR= /usr/pkg/pkgdb
1.1 dsieger 1866:
1867: In unprivileged mode (when pkgsrc has been installed as any other user), the
1868: default locations are:
1869:
1870: LOCALBASE= ${HOME}/pkg
1871: PKG_SYSCONFBASE= ${HOME}/pkg/etc
1872: VARBASE= ${HOME}/pkg/var
1.119 sevan 1873: PKG_DBDIR= ${HOME}/pkg/pkgdb
1.1 dsieger 1874:
1875: What these four directories are for, and what they look like is explained
1876: below.
1877:
1.25 wiz 1878: * LOCALBASE corresponds to the /usr directory in the base system. It is the "
1879: main" directory where the files are installed and contains the well-known
1.1 dsieger 1880: subdirectories like bin, include, lib, share and sbin.
1881:
1882: * VARBASE corresponds to /var in the base system. Some programs (especially
1883: games, network daemons) need write access to it during normal operation.
1884:
1885: * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
1886: configuration files of the packages, as well as pkgsrc's mk.conf itself.
1887:
1.6 rillig 1888: 8.1. File system layout in ${LOCALBASE}
1.1 dsieger 1889:
1890: The following directories exist in a typical pkgsrc installation in $
1891: {LOCALBASE}.
1892:
1893: bin
1894:
1895: Contains executable programs that are intended to be directly used by the
1896: end user.
1897:
1898: emul
1899:
1900: Contains files for the emulation layers of various other operating systems,
1901: especially for NetBSD.
1902:
1903: etc (the usual location of ${PKG_SYSCONFDIR})
1904:
1905: Contains the configuration files.
1906:
1907: include
1908:
1909: Contains headers for the C and C++ programming languages.
1910:
1911: info
1912:
1913: Contains GNU info files of various packages.
1914:
1915: lib
1916:
1917: Contains shared and static libraries.
1918:
1919: libdata
1920:
1921: Contains data files that don't change after installation. Other data files
1922: belong into ${VARBASE}.
1923:
1924: libexec
1925:
1926: Contains programs that are not intended to be used by end users, such as
1927: helper programs or network daemons.
1928:
1929: libexec/cgi-bin
1930:
1931: Contains programs that are intended to be executed as CGI scripts by a web
1932: server.
1933:
1934: man (the usual value of ${PKGMANDIR})
1935:
1936: Contains brief documentation in form of manual pages.
1937:
1938: sbin
1939:
1940: Contains programs that are intended to be used only by the super-user.
1941:
1942: share
1943:
1944: Contains platform-independent data files that don't change after
1945: installation.
1946:
1947: share/doc
1948:
1949: Contains documentation files provided by the packages.
1950:
1951: share/examples
1952:
1953: Contains example files provided by the packages. Among others, the original
1954: configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
1955: installation.
1956:
1957: share/examples/rc.d
1958:
1959: Contains the original files for rc.d scripts.
1960:
1961: var (the usual location of ${VARBASE})
1962:
1963: Contains files that may be modified after installation.
1964:
1.6 rillig 1965: 8.2. File system layout in ${VARBASE}
1.1 dsieger 1966:
1967: db/pkg (the usual location of ${PKG_DBDIR})
1968:
1969: Contains information about the currently installed packages.
1970:
1971: games
1972:
1973: Contains highscore files.
1974:
1975: log
1976:
1977: Contains log files.
1978:
1979: run
1980:
1981: Contains informational files about daemons that are currently running.
1982:
1.6 rillig 1983: Chapter 9. Frequently Asked Questions
1.1 dsieger 1984:
1985: Table of Contents
1986:
1.6 rillig 1987: 9.1. Are there any mailing lists for pkg-related discussion?
1.84 wiz 1988: 9.2. Utilities for package management (pkgtools)
1989: 9.3. How to use pkgsrc as non-root
1990: 9.4. How to resume transfers when fetching distfiles?
1991: 9.5. How can I install/use modular X.org from pkgsrc?
1992: 9.6. How to fetch files from behind a firewall
1993: 9.7. How to fetch files from HTTPS sites
1994: 9.8. How do I tell make fetch to do passive FTP?
1995: 9.9. How to fetch all distfiles at once
1996: 9.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1997: 9.11. What does "Could not find bsd.own.mk" mean?
1998: 9.12. Using 'sudo' with pkgsrc
1999: 9.13. How do I change the location of configuration files?
2000: 9.14. Automated security checks
2001: 9.15. Why do some packages ignore my CFLAGS?
2002: 9.16. A package does not build. What shall I do?
2003: 9.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24 wiz 2004: conflicts" mean?
1.1 dsieger 2005:
2006: This section contains hints, tips & tricks on special things in pkgsrc that we
2007: didn't find a better place for in the previous chapters, and it contains items
2008: for both pkgsrc users and developers.
2009:
1.6 rillig 2010: 9.1. Are there any mailing lists for pkg-related discussion?
1.1 dsieger 2011:
2012: The following mailing lists may be of interest to pkgsrc users:
2013:
2014: * pkgsrc-users: This is a general purpose list for most issues regarding
2015: pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
2016: configuration, unexpected build failures, using particular packages,
2017: upgrading pkgsrc installations, questions regarding the pkgsrc release
2018: branches, etc. General announcements or proposals for changes that impact
2019: the pkgsrc user community, e.g. major infrastructure changes, new features,
2020: package removals, etc., may also be posted.
2021:
2022: * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
2023: discussed.
2024:
2025: * pkgsrc-changes: This list is for those who are interested in getting a
2026: commit message for every change committed to pkgsrc. It is also available
2027: in digest form, meaning one daily message containing all commit messages
2028: for changes to the package source tree in that 24 hour period.
2029:
2030: To subscribe, do:
2031:
2032: % echo subscribe listname | mail majordomo@NetBSD.org
2033:
2034: Archives for all these mailing lists are available from http://
2035: mail-index.NetBSD.org/.
2036:
1.84 wiz 2037: 9.2. Utilities for package management (pkgtools)
1.1 dsieger 2038:
2039: The directory pkgsrc/pkgtools contains a number of useful utilities for both
2040: users and developers of pkgsrc. This section attempts only to make the reader
1.121 ! sevan 2041: aware of some of the utilities and when they might be useful, and not to
! 2042: duplicate the documentation that comes with each package.
1.1 dsieger 2043:
2044: Utilities used by pkgsrc (automatically installed when needed):
2045:
2046: * pkgtools/x11-links: Symlinks for use by buildlink.
2047:
2048: OS tool augmentation (automatically installed when needed):
2049:
1.121 ! sevan 2050: * pkgtools/digest: Calculates various kinds of checksums (including SHA3).
1.1 dsieger 2051:
2052: * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
2053:
2054: * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
2055:
2056: * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
2057: for use on operating systems where pkg_install is not present.
2058:
2059: Utilities used by pkgsrc (not automatically installed):
2060:
2061: * pkgtools/pkg_tarup: Create a binary package from an already-installed
2062: package. Used by make replace to save the old package.
2063:
2064: * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
2065: distfiles from multiple locations. It currently supports the following
2066: methods: multiple CD-ROMs and network FTP/HTTP connections.
2067:
2068: * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24 wiz 2069: current CPU and compiler.
1.1 dsieger 2070:
2071: Utilities for keeping track of installed packages, being up to date, etc:
2072:
1.65 wiz 2073: * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
2074: and upgrade binary packages easily.
2075:
1.1 dsieger 2076: * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
2077: the latest pkgsrc entries.
2078:
2079: * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
2080: strategy for updating.
2081:
2082: * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
2083: graphviz).
2084:
1.12 weinem 2085: * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
2086:
2087: * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
2088: complete pkgsrc system.
1.1 dsieger 2089:
2090: * pkgtools/pkgsurvey: Report what packages you have installed.
2091:
2092: Utilities for people maintaining or creating individual packages:
2093:
2094: * pkgtools/pkgdiff: Automate making and maintaining patches for a package
2095: (includes pkgdiff, pkgvi, mkpatches, etc.).
2096:
1.65 wiz 2097: * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1 dsieger 2098:
2099: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
2100:
2101: * pkgtools/pkg_comp: Build packages in a chrooted area.
2102:
2103: * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
2104:
1.84 wiz 2105: 9.3. How to use pkgsrc as non-root
1.1 dsieger 2106:
1.108 rillig 2107: To install packages from source as a non-root user, download pkgsrc as
2108: described in Chapter 2, Where to get pkgsrc and how to keep it up-to-date, cd
2109: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
2110:
2111: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
2112: configuration mk.conf into ~/pkg/etc.
2113:
2114: For more details, see mk/unprivileged.mk.
1.1 dsieger 2115:
1.84 wiz 2116: 9.4. How to resume transfers when fetching distfiles?
1.1 dsieger 2117:
2118: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4 rillig 2119: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
2120: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1 dsieger 2121:
1.61 wiz 2122: You can also use a different program than the platform default program by
2123: changing the FETCH_USING variable. You can specify the program by using of ftp,
2124: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
2125: manual. A value of custom disables the system defaults and dependency tracking
2126: for the fetch program. In that case you have to provide FETCH_CMD,
2127: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1 dsieger 2128:
1.16 jnemeth 2129: For example, if you want to use wget to download, you'll have to use something
2130: like:
1.1 dsieger 2131:
1.16 jnemeth 2132: FETCH_USING= wget
1.1 dsieger 2133:
1.84 wiz 2134: 9.5. How can I install/use modular X.org from pkgsrc?
1.1 dsieger 2135:
1.4 rillig 2136: If you want to use modular X.org from pkgsrc instead of your system's own X11
2137: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1 dsieger 2138: mk.conf:
2139:
1.4 rillig 2140: X11_TYPE=modular
1.1 dsieger 2141:
1.84 wiz 2142: 9.6. How to fetch files from behind a firewall
1.1 dsieger 2143:
2144: If you are sitting behind a firewall which does not allow direct connections to
2145: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
2146: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
2147: machine "orpheus.amdahl.com" is one of the firewalls, and it uses port 80 as
2148: the proxy port number. So the proxy environment variables are:
2149:
2150: ftp_proxy=ftp://orpheus.amdahl.com:80/
2151: http_proxy=http://orpheus.amdahl.com:80/
2152:
1.84 wiz 2153: 9.7. How to fetch files from HTTPS sites
1.65 wiz 2154:
2155: Some fetch tools are not prepared to support HTTPS by default (for example, the
2156: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
2157: openssl dependency that low in the dependency graph).
2158:
2159: Usually you won't notice, because distribution files are mirrored weekly to "
2160: ftp.NetBSD.org", but that might not be often enough if you are following
2161: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to "curl" or
2162: "wget", which are both compiled with HTTPS support by default. Of course, these
2163: tools need to be installed before you can use them this way.
2164:
1.84 wiz 2165: 9.8. How do I tell make fetch to do passive FTP?
1.1 dsieger 2166:
2167: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
2168: FETCH_CMD is assigned the first available command from the following list:
2169:
2170: * ${LOCALBASE}/bin/ftp
2171:
2172: * /usr/bin/ftp
2173:
2174: On a default NetBSD installation, this will be /usr/bin/ftp, which
2175: automatically tries passive connections first, and falls back to active
2176: connections if the server refuses to do passive. For the other tools, add the
1.4 rillig 2177: following to your mk.conf file: PASSIVE_FETCH=1.
1.1 dsieger 2178:
2179: Having that option present will prevent /usr/bin/ftp from falling back to
2180: active transfers.
2181:
1.84 wiz 2182: 9.9. How to fetch all distfiles at once
1.1 dsieger 2183:
2184: You would like to download all the distfiles in a single batch from work or
2185: university, where you can't run a make fetch. There is an archive of distfiles
2186: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
2187:
2188: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
2189: subdirectories, carry the resulting list to your machine at work/school and use
2190: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
2191: don't forget to set FETCH_CMD to something that fetches a URL:
2192:
2193: At home:
2194:
2195: % cd /usr/pkgsrc
2196: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
2197: % scp /tmp/fetch.sh work:/tmp
2198:
2199: At work:
2200:
2201: % sh /tmp/fetch.sh
2202:
2203: then tar up /tmp/distfiles and take it home.
2204:
2205: If you have a machine running NetBSD, and you want to get all distfiles (even
2206: ones that aren't for your machine architecture), you can do so by using the
2207: above-mentioned make fetch-list approach, or fetch the distfiles directly by
2208: running:
2209:
2210: % make mirror-distfiles
2211:
2212: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
2213: everything by running:
2214:
2215: % make fetch NO_SKIP=yes
2216:
1.84 wiz 2217: 9.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1.1 dsieger 2218:
2219: When compiling the pkgtools/pkg_install package, you get the error from make
2220: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
2221: that you don't have installed the "text" set (nroff, ...) from the NetBSD base
2222: distribution on your machine. It is recommended to do that to format man pages.
2223:
2224: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4 rillig 2225: NOMAN=YES either in the environment or in mk.conf.
1.1 dsieger 2226:
1.84 wiz 2227: 9.11. What does "Could not find bsd.own.mk" mean?
1.1 dsieger 2228:
2229: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
2230: machine. Please get and install it, by extracting it in /:
2231:
2232: # cd /
2233: # tar --unlink -zxvpf .../comp.tgz
2234:
2235: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
2236: release (determine via uname -r).
2237:
1.84 wiz 2238: 9.12. Using 'sudo' with pkgsrc
1.1 dsieger 2239:
2240: When installing packages as non-root user and using the just-in-time su(1)
2241: feature of pkgsrc, it can become annoying to type in the root password for each
2242: required package installed. To avoid this, the sudo package can be used, which
2243: does password caching over a limited time. To use it, install sudo (either as
1.4 rillig 2244: binary package or from security/sudo) and then put the following into your
2245: mk.conf, somewhere after the definition of the LOCALBASE variable:
1.1 dsieger 2246:
2247: .if exists(${LOCALBASE}/bin/sudo)
2248: SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
2249: .endif
2250:
1.84 wiz 2251: 9.13. How do I change the location of configuration files?
1.1 dsieger 2252:
2253: As the system administrator, you can choose where configuration files are
2254: installed. The default settings make all these files go into ${PREFIX}/etc or
2255: some of its subdirectories; this may be suboptimal depending on your
2256: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
2257: configuration of the provided packages).
2258:
2259: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4 rillig 2260: (in mk.conf) to point to your preferred configuration directory; some common
2261: examples include /etc or /etc/pkg.
1.1 dsieger 2262:
2263: Furthermore, you can change this value on a per-package basis by setting the
2264: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
2265: matches the name of the package you would like to modify, that is, the contents
2266: of PKGBASE.
2267:
2268: Note that after changing these settings, you must rebuild and reinstall any
2269: affected packages.
2270:
1.84 wiz 2271: 9.14. Automated security checks
1.1 dsieger 2272:
2273: Please be aware that there can often be bugs in third-party software, and some
2274: of these bugs can leave a machine vulnerable to exploitation by attackers. In
2275: an effort to lessen the exposure, the NetBSD packages team maintains a database
2276: of known-exploits to packages which have at one time been included in pkgsrc.
2277: The database can be downloaded automatically, and a security audit of all
1.14 jmcneill 2278: packages installed on a system can take place. To do this, refer to the
2279: following two tools (installed as part of the pkgtools/pkg_install package):
1.1 dsieger 2280:
1.21 snj 2281: 1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
2282: security vulnerabilities information. This list is kept up to date by the
1.26 spz 2283: pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1 dsieger 2284:
1.26 spz 2285: ftp://ftp.NetBSD.org/pkgsrc/distfiles/pkg-vulnerabilities
1.1 dsieger 2286:
1.21 snj 2287: 2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24 wiz 2288: known vulnerability. If a vulnerable package is installed, it will be shown
2289: by output to stdout, including a description of the type of vulnerability,
2290: and a URL containing more information.
1.1 dsieger 2291:
1.121 ! sevan 2292: Use of these tools is strongly recommended! See Section 4.1.5, "Checking for
! 2293: security vulnerabilities in installed packages" for instructions on how to
! 2294: automate checking and reporting.
! 2295:
! 2296: If this database is installed, pkgsrc builds will use it to perform a security
! 2297: check before building any package.
1.1 dsieger 2298:
1.84 wiz 2299: 9.15. Why do some packages ignore my CFLAGS?
1.1 dsieger 2300:
2301: When you add your own preferences to the CFLAGS variable in your mk.conf, these
2302: flags are passed in environment variables to the ./configure scripts and to
2303: make(1). Some package authors ignore the CFLAGS from the environment variable
2304: by overriding them in the Makefiles of their package.
2305:
2306: Currently there is no solution to this problem. If you really need the package
2307: to use your CFLAGS you should run make patch in the package directory and then
2308: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
2309: Usually you can remove these lines. But be aware that some "smart" programmers
2310: write so bad code that it only works for the specific combination of CFLAGS
2311: they have chosen.
2312:
1.84 wiz 2313: 9.16. A package does not build. What shall I do?
1.1 dsieger 2314:
2315: 1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
2316: is that people only update pkgsrc in parts, because of performance reasons.
2317: Since pkgsrc is one large system, not a collection of many small systems,
2318: there are sometimes changes that only work when the whole pkgsrc tree is
2319: updated.
2320:
1.25 wiz 2321: 2. Make sure that you don't have any CVS conflicts. Search for "<<<<<<" or "
2322: >>>>>>" in all your pkgsrc files.
1.1 dsieger 2323:
1.25 wiz 2324: 3. Make sure that you don't have old copies of the packages extracted. Run
1.1 dsieger 2325: make clean clean-depends to verify this.
2326:
1.108 rillig 2327: 4. If you are a package developer who wants to invest some work, have a look
2328: at Chapter 19, Making your package work.
2329:
2330: 5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1 dsieger 2331:
1.84 wiz 2332: 9.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.1 dsieger 2333: conflicts" mean?
2334:
2335: You have modified a file from pkgsrc, and someone else has modified that same
2336: file afterwards in the CVS repository. Both changes are in the same region of
2337: the file, so when you updated pkgsrc, the cvs command marked the conflicting
2338: changes in the file. Because of these markers, the file is no longer a valid
2339: Makefile.
2340:
2341: Have a look at that file, and if you don't need your local changes anymore, you
2342: can remove that file and run cvs -q update -dP in that directory to download
2343: the current version.
2344:
2345: Part II. The pkgsrc developer's guide
2346:
2347: This part of the book deals with creating and modifying packages. It starts
2348: with a "HOWTO"-like guide on creating a new package. The remaining chapters are
2349: more like a reference manual for pkgsrc.
2350:
2351: Table of Contents
2352:
1.6 rillig 2353: 10. Creating a new pkgsrc package from scratch
1.1 dsieger 2354:
1.6 rillig 2355: 10.1. Common types of packages
1.1 dsieger 2356:
1.6 rillig 2357: 10.1.1. Perl modules
1.121 ! sevan 2358: 10.1.2. KDE3 & KDE4 applications
1.17 imil 2359: 10.1.3. Python modules and programs
1.1 dsieger 2360:
1.6 rillig 2361: 10.2. Examples
1.1 dsieger 2362:
1.6 rillig 2363: 10.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 2364:
1.6 rillig 2365: 11. Package components - files, directories and contents
1.1 dsieger 2366:
1.6 rillig 2367: 11.1. Makefile
2368: 11.2. distinfo
2369: 11.3. patches/*
1.1 dsieger 2370:
1.6 rillig 2371: 11.3.1. Structure of a single patch file
2372: 11.3.2. Creating patch files
2373: 11.3.3. Sources where the patch files come from
2374: 11.3.4. Patching guidelines
2375: 11.3.5. Feedback to the author
1.1 dsieger 2376:
1.6 rillig 2377: 11.4. Other mandatory files
2378: 11.5. Optional files
1.1 dsieger 2379:
1.6 rillig 2380: 11.5.1. Files affecting the binary package
2381: 11.5.2. Files affecting the build process
2382: 11.5.3. Files affecting nothing at all
1.1 dsieger 2383:
1.6 rillig 2384: 11.6. work*
2385: 11.7. files/*
1.1 dsieger 2386:
1.6 rillig 2387: 12. Programming in Makefiles
1.1 dsieger 2388:
1.6 rillig 2389: 12.1. Caveats
2390: 12.2. Makefile variables
1.1 dsieger 2391:
1.6 rillig 2392: 12.2.1. Naming conventions
1.1 dsieger 2393:
1.6 rillig 2394: 12.3. Code snippets
1.1 dsieger 2395:
1.6 rillig 2396: 12.3.1. Adding things to a list
1.117 sevan 2397: 12.3.2. Echoing a string exactly as-is
1.108 rillig 2398: 12.3.3. Passing CFLAGS to GNU configure scripts
2399: 12.3.4. Handling possibly empty variables
1.1 dsieger 2400:
1.6 rillig 2401: 13. PLIST issues
1.1 dsieger 2402:
1.6 rillig 2403: 13.1. RCS ID
2404: 13.2. Semi-automatic PLIST generation
2405: 13.3. Tweaking output of make print-PLIST
2406: 13.4. Variable substitution in PLIST
2407: 13.5. Man page compression
2408: 13.6. Changing PLIST source with PLIST_SRC
2409: 13.7. Platform-specific and differing PLISTs
1.86 wiz 2410: 13.8. Build-specific PLISTs
2411: 13.9. Sharing directories between packages
1.1 dsieger 2412:
1.6 rillig 2413: 14. Buildlink methodology
1.1 dsieger 2414:
1.6 rillig 2415: 14.1. Converting packages to use buildlink3
2416: 14.2. Writing buildlink3.mk files
1.1 dsieger 2417:
1.6 rillig 2418: 14.2.1. Anatomy of a buildlink3.mk file
1.27 wiz 2419: 14.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
2420: pkg in buildlink3.mk files
1.1 dsieger 2421:
1.6 rillig 2422: 14.3. Writing builtin.mk files
1.1 dsieger 2423:
1.6 rillig 2424: 14.3.1. Anatomy of a builtin.mk file
2425: 14.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 2426:
1.6 rillig 2427: 15. The pkginstall framework
1.1 dsieger 2428:
1.6 rillig 2429: 15.1. Files and directories outside the installation prefix
1.1 dsieger 2430:
1.6 rillig 2431: 15.1.1. Directory manipulation
2432: 15.1.2. File manipulation
1.1 dsieger 2433:
1.6 rillig 2434: 15.2. Configuration files
1.1 dsieger 2435:
1.6 rillig 2436: 15.2.1. How PKG_SYSCONFDIR is set
2437: 15.2.2. Telling the software where configuration files are
2438: 15.2.3. Patching installations
2439: 15.2.4. Disabling handling of configuration files
1.1 dsieger 2440:
1.6 rillig 2441: 15.3. System startup scripts
1.1 dsieger 2442:
1.6 rillig 2443: 15.3.1. Disabling handling of system startup scripts
1.1 dsieger 2444:
1.6 rillig 2445: 15.4. System users and groups
2446: 15.5. System shells
1.1 dsieger 2447:
1.6 rillig 2448: 15.5.1. Disabling shell registration
1.1 dsieger 2449:
1.6 rillig 2450: 15.6. Fonts
1.1 dsieger 2451:
1.6 rillig 2452: 15.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 2453:
1.6 rillig 2454: 16. Options handling
1.1 dsieger 2455:
1.6 rillig 2456: 16.1. Global default options
2457: 16.2. Converting packages to use bsd.options.mk
2458: 16.3. Option Names
1.7 rillig 2459: 16.4. Determining the options of dependencies
1.1 dsieger 2460:
1.6 rillig 2461: 17. The build process
1.1 dsieger 2462:
1.6 rillig 2463: 17.1. Introduction
2464: 17.2. Program location
2465: 17.3. Directories used during the build process
2466: 17.4. Running a phase
2467: 17.5. The fetch phase
1.1 dsieger 2468:
1.6 rillig 2469: 17.5.1. What to fetch and where to get it from
2470: 17.5.2. How are the files fetched?
1.1 dsieger 2471:
1.6 rillig 2472: 17.6. The checksum phase
2473: 17.7. The extract phase
2474: 17.8. The patch phase
2475: 17.9. The tools phase
2476: 17.10. The wrapper phase
2477: 17.11. The configure phase
2478: 17.12. The build phase
2479: 17.13. The test phase
2480: 17.14. The install phase
2481: 17.15. The package phase
2482: 17.16. Cleaning up
2483: 17.17. Other helpful targets
1.1 dsieger 2484:
1.6 rillig 2485: 18. Tools needed for building or running
1.1 dsieger 2486:
1.6 rillig 2487: 18.1. Tools for pkgsrc builds
2488: 18.2. Tools needed by packages
2489: 18.3. Tools provided by platforms
1.1 dsieger 2490:
1.6 rillig 2491: 19. Making your package work
1.1 dsieger 2492:
1.6 rillig 2493: 19.1. General operation
1.1 dsieger 2494:
1.108 rillig 2495: 19.1.1. How to pull in user-settable variables from mk.conf
2496: 19.1.2. User interaction
2497: 19.1.3. Handling licenses
2498: 19.1.4. Restricted packages
2499: 19.1.5. Handling dependencies
2500: 19.1.6. Handling conflicts with other packages
2501: 19.1.7. Packages that cannot or should not be built
2502: 19.1.8. Packages which should not be deleted, once installed
2503: 19.1.9. Handling packages with security problems
2504: 19.1.10. How to handle incrementing versions when fixing an existing
1.1 dsieger 2505: package
1.108 rillig 2506: 19.1.11. Substituting variable text in the package files (the SUBST
1.1 dsieger 2507: framework)
2508:
1.108 rillig 2509: 19.2. The fetch phase
1.1 dsieger 2510:
1.6 rillig 2511: 19.2.1. Packages whose distfiles aren't available for plain downloading
2512: 19.2.2. How to handle modified distfiles with the 'old' name
1.88 tnn 2513: 19.2.3. Packages hosted on github.com
1.1 dsieger 2514:
1.108 rillig 2515: 19.3. The configure phase
1.1 dsieger 2516:
1.6 rillig 2517: 19.3.1. Shared libraries - libtool
2518: 19.3.2. Using libtool on GNU packages that already support libtool
2519: 19.3.3. GNU Autoconf/Automake
2520:
2521: 19.4. Programming languages
2522:
2523: 19.4.1. C, C++, and Fortran
2524: 19.4.2. Java
2525: 19.4.3. Packages containing perl scripts
1.41 wiz 2526: 19.4.4. Packages containing shell scripts
2527: 19.4.5. Other programming languages
1.6 rillig 2528:
1.108 rillig 2529: 19.5. The build phase
1.6 rillig 2530:
2531: 19.5.1. Compiling C and C++ code conditionally
2532: 19.5.2. How to handle compiler bugs
1.24 wiz 2533: 19.5.3. Undefined reference to "..."
1.6 rillig 2534: 19.5.4. Running out of memory
2535:
1.108 rillig 2536: 19.6. The install phase
1.6 rillig 2537:
2538: 19.6.1. Creating needed directories
2539: 19.6.2. Where to install documentation
2540: 19.6.3. Installing highscore files
2541: 19.6.4. Adding DESTDIR support to packages
2542: 19.6.5. Packages with hardcoded paths to other interpreters
2543: 19.6.6. Packages installing perl modules
2544: 19.6.7. Packages installing info files
2545: 19.6.8. Packages installing man pages
1.7 rillig 2546: 19.6.9. Packages installing GConf data files
1.18 mishka 2547: 19.6.10. Packages installing scrollkeeper/rarian data files
1.6 rillig 2548: 19.6.11. Packages installing X11 fonts
2549: 19.6.12. Packages installing GTK2 modules
2550: 19.6.13. Packages installing SGML or XML data
2551: 19.6.14. Packages installing extensions to the MIME database
2552: 19.6.15. Packages using intltool
2553: 19.6.16. Packages installing startup scripts
2554: 19.6.17. Packages installing TeX modules
2555: 19.6.18. Packages supporting running binaries in emulation
2556: 19.6.19. Packages installing hicolor theme icons
2557: 19.6.20. Packages installing desktop files
2558:
2559: 19.7. Marking packages as having problems
2560:
2561: 20. Debugging
2562: 21. Submitting and Committing
2563:
2564: 21.1. Submitting binary packages
2565: 21.2. Submitting source packages (for non-NetBSD-developers)
2566: 21.3. General notes when adding, updating, or removing packages
1.34 wiz 2567: 21.4. Committing: Adding a package to CVS
1.6 rillig 2568: 21.5. Updating a package to a newer version
1.21 snj 2569: 21.6. Renaming a package in pkgsrc
2570: 21.7. Moving a package in pkgsrc
1.6 rillig 2571:
2572: 22. Frequently Asked Questions
2573: 23. GNOME packaging and porting
2574:
2575: 23.1. Meta packages
2576: 23.2. Packaging a GNOME application
2577: 23.3. Updating GNOME to a newer version
2578: 23.4. Patching guidelines
1.1 dsieger 2579:
1.6 rillig 2580: Chapter 10. Creating a new pkgsrc package from scratch
1.1 dsieger 2581:
2582: Table of Contents
2583:
1.6 rillig 2584: 10.1. Common types of packages
1.1 dsieger 2585:
1.6 rillig 2586: 10.1.1. Perl modules
1.121 ! sevan 2587: 10.1.2. KDE3 & KDE4 applications
1.17 imil 2588: 10.1.3. Python modules and programs
1.1 dsieger 2589:
1.6 rillig 2590: 10.2. Examples
1.1 dsieger 2591:
1.6 rillig 2592: 10.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 2593:
2594: When you find a package that is not yet in pkgsrc, you most likely have a URL
2595: from where you can download the source code. Starting with this URL, creating a
2596: package involves only a few steps.
2597:
2598: 1. First, install the packages pkgtools/url2pkg and pkgtools/pkglint.
2599:
2600: 2. Then, choose one of the top-level directories as the category in which you
2601: want to place your package. You can also create a directory of your own
2602: (maybe called local). In that category directory, create another directory
2603: for your package and change into it.
2604:
2605: 3. Run the program url2pkg, which will ask you for a URL. Enter the URL of the
2606: distribution file (in most cases a .tar.gz file) and watch how the basic
2607: ingredients of your package are created automatically. The distribution
2608: file is extracted automatically to fill in some details in the Makefile
2609: that would otherwise have to be done manually.
2610:
2611: 4. Examine the extracted files to determine the dependencies of your package.
2612: Ideally, this is mentioned in some README file, but things may differ. For
2613: each of these dependencies, look where it exists in pkgsrc, and if there is
2614: a file called buildlink3.mk in that directory, add a line to your package
2615: Makefile which includes that file just before the last line. If the
1.26 spz 2616: buildlink3.mk file does not exist, it must be created first. The
2617: buildlink3.mk file makes sure that the package's include files and
2618: libraries are provided.
2619:
2620: If you just need binaries from a package, add a DEPENDS line to the
2621: Makefile, which specifies the version of the dependency and where it can be
2622: found in pkgsrc. This line should be placed in the third paragraph. If the
1.1 dsieger 2623: dependency is only needed for building the package, but not when using it,
2624: use BUILD_DEPENDS instead of DEPENDS. Your package may then look like this:
2625:
2626: [...]
2627:
1.66 asau 2628: BUILD_DEPENDS+= libxslt-[0-9]*:../../textproc/libxslt
1.1 dsieger 2629: DEPENDS+= screen-[0-9]*:../../misc/screen
2630: DEPENDS+= screen>=4.0:../../misc/screen
2631:
2632: [...]
2633:
2634: .include "../../category/package/buildlink3.mk"
2635: .include "../../devel/glib2/buildlink3.mk"
2636: .include "../../mk/bsd.pkg.mk"
2637:
2638: 5. Run pkglint to see what things still need to be done to make your package a
2639: "good" one. If you don't know what pkglint's warnings want to tell you, try
2640: pkglint --explain or pkglint -e, which outputs additional explanations.
2641:
2642: 6. In many cases the package is not yet ready to build. You can find
1.6 rillig 2643: instructions for the most common cases in the next section, Section 10.1,
1.1 dsieger 2644: "Common types of packages". After you have followed the instructions over
2645: there, you can hopefully continue here.
2646:
2647: 7. Run bmake clean to clean the working directory from the extracted files.
2648: Besides these files, a lot of cache files and other system information has
2649: been saved in the working directory, which may become wrong after you
2650: edited the Makefile.
2651:
2652: 8. Now, run bmake to build the package. For the various things that can go
1.6 rillig 2653: wrong in this phase, consult Chapter 19, Making your package work.
1.1 dsieger 2654:
1.25 wiz 2655: 9. When the package builds fine, the next step is to install the package. Run
1.1 dsieger 2656: bmake install and hope that everything works.
2657:
2658: 10. Up to now, the file PLIST, which contains a list of the files that are
2659: installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
2660: generate a probably correct list. Check the file using your preferred text
2661: editor to see if the list of files looks plausible.
2662:
2663: 11. Run pkglint again to see if the generated PLIST contains garbage or not.
2664:
2665: 12. When you ran bmake install, the package has been registered in the database
2666: of installed files, but with an empty list of files. To fix this, run bmake
2667: deinstall and bmake install again. Now the package is registered with the
2668: list of files from PLIST.
2669:
2670: 13. Run bmake package to create a binary package from the set of installed
2671: files.
2672:
1.6 rillig 2673: 10.1. Common types of packages
1.1 dsieger 2674:
1.6 rillig 2675: 10.1.1. Perl modules
1.1 dsieger 2676:
2677: Simple Perl modules are handled automatically by url2pkg, including
2678: dependencies.
2679:
1.121 ! sevan 2680: 10.1.2. KDE3 & KDE4 applications
1.1 dsieger 2681:
1.66 asau 2682: KDE3 applications should always include meta-pkgs/kde3/kde3.mk, which contains
1.121 ! sevan 2683: numerous settings that are typical of KDE3 packages and KDE4 applications
! 2684: should always include meta-pkgs/kde4/kde4.mk, respectively.
1.1 dsieger 2685:
1.17 imil 2686: 10.1.3. Python modules and programs
2687:
2688: Python modules and programs packages are easily created using a set of
2689: predefined variables.
2690:
1.63 wiz 2691: If some Python versions are not supported by the software, set the
2692: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
2693: supported, e.g.
1.17 imil 2694:
1.93 sevan 2695: PYTHON_VERSIONS_INCOMPATIBLE= 27
1.17 imil 2696:
1.103 wiz 2697: If the packaged software is a Python module, include one of ../../lang/python/
2698: egg.mk, ../../lang/python/distutils.mk, or ../../lang/python/extension.mk.
2699:
2700: Most Python packages use either "distutils" or easy-setup/setuptools ("eggs").
2701: if the packaged software is using setuptools, you only need to include "../../
2702: lang/python/egg.mk". Otherwise, if the software uses "distutils", include "..
2703: /../lang/python/distutils.mk". so pkgsrc will use this framework. "distutils"
2704: uses a script called setup.py, if the "distutils" driver is not called
2705: setup.py, set the PYSETUP variable to the name of the script.
2706:
2707: Either way, the package directory should be called "py-software" and PKGNAME
2708: should be set to "${PYPKGPREFIX}-${DISTNAME}", e.g.
1.17 imil 2709:
2710: DISTNAME= foopymodule-1.2.10
2711: PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
2712:
1.63 wiz 2713: If it is an application, include "../../lang/python/application.mk". In order
2714: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
2715: variable and set it to the list of files (paths relative to WRKSRC) that must
2716: be corrected. For example:
1.17 imil 2717:
1.63 wiz 2718: REPLACE_PYTHON= *.py
1.17 imil 2719:
1.63 wiz 2720: Some Python modules have separate distributions for Python-2.x and Python-3.x
2721: support. In pkgsrc this is handled by the versioned_dependencies.mk file. Set
2722: PYTHON_VERSIONED_DEPENDENCIES to the list of packages that should be depended
2723: upon and include "../../lang/python/versioned_dependencies.mk", then the pkgsrc
2724: infrastructure will depend on the appropriate package version. For example:
1.17 imil 2725:
1.110 wiz 2726: PYTHON_VERSIONED_DEPENDENCIES=dateutil
1.63 wiz 2727:
2728: Look inside versioned_dependencies.mk for a list of supported packages.
1.17 imil 2729:
1.6 rillig 2730: 10.2. Examples
1.1 dsieger 2731:
1.6 rillig 2732: 10.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 2733:
1.6 rillig 2734: 10.2.1.1. The initial package
1.1 dsieger 2735:
2736: Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
2737: been imported into pkgsrc. As the description says it has to do with the web,
2738: the obvious choice for the category is "www".
2739:
2740: $ mkdir www/nvu
2741: $ cd www/nvu
2742:
2743: The web site says that the sources are available as a tar file, so I fed that
2744: URL to the url2pkg program:
2745:
2746: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
2747:
2748: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
2749: package name should not have the word "sources" in it. I also filled in the
2750: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
2751: that:
2752:
1.121 ! sevan 2753: # $NetBSD $
1.1 dsieger 2754: #
2755:
2756: DISTNAME= nvu-1.0-sources
2757: PKGNAME= nvu-1.0
2758: CATEGORIES= www
2759: MASTER_SITES= http://cvs.nvu.com/download/
2760: EXTRACT_SUFX= .tar.bz2
2761:
2762: MAINTAINER= rillig@NetBSD.org
2763: HOMEPAGE= http://cvs.nvu.com/
2764: COMMENT= Web Authoring System
2765:
2766: # url2pkg-marker (please do not remove this line.)
2767: .include "../../mk/bsd.pkg.mk"
2768:
1.121 ! sevan 2769: On the first line of output above, an artificial space has been added betweeen
! 2770: NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
! 2771: the guide.
! 2772:
1.1 dsieger 2773: Then, I quit the editor and watched pkgsrc downloading a large source archive:
2774:
2775: url2pkg> Running "make makesum" ...
2776: => Required installed package digest>=20010302: digest-20060826 found
2777: => Fetching nvu-1.0-sources.tar.bz2
2778: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
2779: 100% |*************************************| 28992 KB 150.77 KB/s00:00 ETA
2780: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
2781: url2pkg> Running "make extract" ...
2782: => Required installed package digest>=20010302: digest-20060826 found
2783: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
2784: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
2785: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
2786: ===> Installing dependencies for nvu-1.0
2787: ===> Overriding tools for nvu-1.0
2788: ===> Extracting for nvu-1.0
2789: url2pkg> Adjusting the Makefile.
2790:
2791: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
2792:
2793: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
2794:
1.6 rillig 2795: 10.2.1.2. Fixing all kinds of problems to make the package work
1.1 dsieger 2796:
2797: Now that the package has been extracted, let's see what's inside it. The
2798: package has a README.txt, but that only says something about mozilla, so it's
2799: probably useless for seeing what dependencies this package has. But since there
2800: is a GNU configure script in the package, let's hope that it will complain
2801: about everything it needs.
2802:
2803: $ bmake
2804: => Required installed package digest>=20010302: digest-20060826 found
2805: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
2806: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
2807: ===> Patching for nvu-1.0
2808: ===> Creating toolchain wrappers for nvu-1.0
2809: ===> Configuring for nvu-1.0
2810: [...]
2811: configure: error: Perl 5.004 or higher is required.
2812: [...]
2813: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
2814: [...]
2815:
2816: That worked quite well. So I opened the package Makefile in my editor, and
2817: since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
2818: dependencies of the package have changed now, and since a perl wrapper is
2819: automatically installed in the "tools" phase, I need to build the package from
2820: scratch.
2821:
2822: $ bmake clean
2823: ===> Cleaning for nvu-1.0
2824: $ bmake
2825: [...]
2826: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
2827: GNU Make. You will not be able to build Mozilla without GNU Make.
2828: [...]
2829:
2830: So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
2831:
2832: [...]
2833: checking for GTK - version >= 1.2.0... no
2834: *** Could not run GTK test program, checking why...
2835: [...]
2836:
2837: Now to the other dependencies. The first question is: Where is the GTK package
2838: hidden in pkgsrc?
2839:
2840: $ echo ../../*/gtk*
2841: [many packages ...]
2842: $ echo ../../*/gtk
2843: ../../x11/gtk
2844: $ echo ../../*/gtk2
2845: ../../x11/gtk2
2846: $ echo ../../*/gtk2/bui*
2847: ../../x11/gtk2/buildlink3.mk
2848:
2849: The first try was definitely too broad. The second one had exactly one result,
2850: which is very good. But there is one pitfall with GNOME packages. Before GNOME
2851: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
2852: able to continue to use these packages, the GNOME 2 packages were imported as
2853: separate packages, and their names usually have a "2" appended. So I checked
2854: whether this was the case here, and indeed it was.
2855:
2856: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
2857: easy. I just inserted an .include line before the last line of the package
2858: Makefile, so that it now looks like this:
2859:
2860: [...]
2861: .include "../../x11/gtk2/buildlink3.mk"
2862: .include "../../mk/bsd.pkg.mk
2863:
2864: After another bmake clean && bmake, the answer was:
2865:
2866: [...]
2867: checking for gtk-config... /home/roland/pkg/bin/gtk-config
2868: checking for GTK - version >= 1.2.0... no
2869: *** Could not run GTK test program, checking why...
2870: *** The test program failed to compile or link. See the file config.log for the
2871: *** exact error that occured. This usually means GTK was incorrectly installed
2872: *** or that you have moved GTK since it was installed. In the latter case, you
2873: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
2874: configure: error: Test for GTK failed.
2875: [...]
2876:
2877: In this particular case, the assumption that "every package prefers GNOME 2"
2878: had been wrong. The first of the lines above told me that this package really
2879: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
2880: it would have looked for pkg-config instead of gtk-config. So I changed the x11
2881: /gtk2 to x11/gtk in the package Makefile, and tried again.
2882:
2883: [...]
1.59 jnemeth 2884: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\" [...]
1.1 dsieger 2885: In file included from xpidl.c:42:
2886: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
2887: In file included from xpidl.c:42:
2888: xpidl.h:132: error: parse error before "IDL_ns"
2889: [...]
2890:
2891: The package still does not find all of its dependencies. Now the question is:
2892: Which package provides the libIDL/IDL.h header file?
2893:
2894: $ echo ../../*/*idl*
2895: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
2896: $ echo ../../*/*IDL*
2897: ../../net/libIDL
2898:
2899: Let's take the one from the second try. So I included the ../../net/libIDL/
2900: buildlink3.mk file and tried again. But the error didn't change. After digging
2901: through some of the code, I concluded that the build process of the package was
2902: broken and couldn't have ever worked, but since the Mozilla source tree is
2903: quite large, I didn't want to fix it. So I added the following to the package
2904: Makefile and tried again:
2905:
2906: CPPFLAGS+= -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
2907: BUILDLINK_TRANSFORM+= -l:IDL:IDL-2
2908:
2909: The latter line is needed because the package expects the library libIDL.so,
2910: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
2911: that on the fly.
2912:
2913: The next problem was related to a recent change of the FreeType interface. I
2914: looked up in www/seamonkey which patch files were relevant for this issue and
2915: copied them to the patches directory. Then I retried, fixed the patches so that
2916: they applied cleanly and retried again. This time, everything worked.
2917:
1.6 rillig 2918: 10.2.1.3. Installing the package
1.1 dsieger 2919:
2920: $ bmake CHECK_FILES=no install
2921: [...]
2922: $ bmake print-PLIST >PLIST
2923: $ bmake deinstall
2924: $ bmake install
2925:
1.6 rillig 2926: Chapter 11. Package components - files, directories and contents
1.1 dsieger 2927:
2928: Table of Contents
2929:
1.6 rillig 2930: 11.1. Makefile
2931: 11.2. distinfo
2932: 11.3. patches/*
2933:
2934: 11.3.1. Structure of a single patch file
2935: 11.3.2. Creating patch files
2936: 11.3.3. Sources where the patch files come from
2937: 11.3.4. Patching guidelines
2938: 11.3.5. Feedback to the author
2939:
2940: 11.4. Other mandatory files
2941: 11.5. Optional files
2942:
2943: 11.5.1. Files affecting the binary package
2944: 11.5.2. Files affecting the build process
2945: 11.5.3. Files affecting nothing at all
1.1 dsieger 2946:
1.6 rillig 2947: 11.6. work*
2948: 11.7. files/*
1.1 dsieger 2949:
2950: Whenever you're preparing a package, there are a number of files involved which
2951: are described in the following sections.
2952:
1.6 rillig 2953: 11.1. Makefile
1.1 dsieger 2954:
2955: Building, installation and creation of a binary package are all controlled by
2956: the package's Makefile. The Makefile describes various things about a package,
2957: for example from where to get it, how to configure, build, and install it.
2958:
2959: A package Makefile contains several sections that describe the package.
2960:
2961: In the first section there are the following variables, which should appear
2962: exactly in the order given here. The order and grouping of the variables is
2963: mostly historical and has no further meaning.
2964:
2965: * DISTNAME is the basename of the distribution file to be downloaded from the
2966: package's website.
2967:
1.66 asau 2968: * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
2969: it if DISTNAME (which is the default) is not a good name for the package in
2970: pkgsrc or DISTNAME is not provided (no distribution file is required).
2971: Usually it is the pkgsrc directory name together with the version number.
2972: It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
2973: is, it starts with a letter or digit, and contains only letters, digits,
2974: dashes, underscores, dots and plus signs.
1.1 dsieger 2975:
2976: * CATEGORIES is a list of categories which the package fits in. You can
2977: choose any of the top-level directories of pkgsrc for it.
2978:
2979: Currently the following values are available for CATEGORIES. If more than
2980: one is used, they need to be separated by spaces:
2981:
2982: archivers cross geography meta-pkgs security
2983: audio databases graphics misc shells
2984: benchmarks devel ham multimedia sysutils
2985: biology editors inputmethod net textproc
2986: cad emulators lang news time
2987: chat finance mail parallel wm
2988: comms fonts math pkgtools www
2989: converters games mbone print x11
2990:
2991: * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
1.6 rillig 2992: are discussed in detail in Section 17.5, "The fetch phase".
1.1 dsieger 2993:
2994: The second section contains information about separately downloaded patches, if
2995: any.
2996:
2997: * PATCHFILES: Name(s) of additional files that contain distribution patches.
2998: There is no default. pkgsrc will look for them at PATCH_SITES. They will
2999: automatically be uncompressed before patching if the names end with .gz or
3000: .Z.
3001:
3002: * PATCH_SITES: Primary location(s) for distribution patch files (see
1.80 wiz 3003: PATCHFILES above) if not found locally.
3004:
3005: * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
3006: count to help find the correct files to patch. It defaults to -p0.
1.1 dsieger 3007:
3008: The third section contains the following variables.
3009:
3010: * MAINTAINER is the email address of the person who feels responsible for
3011: this package, and who is most likely to look at problems or questions
3012: regarding this package which have been reported with send-pr(1). Other
1.14 jmcneill 3013: developers may contact the MAINTAINER before making changes to the package,
3014: but are not required to do so. When packaging a new program, set MAINTAINER
3015: to yourself. If you really can't maintain the package for future updates,
3016: set it to <pkgsrc-users@NetBSD.org>.
3017:
3018: * OWNER should be used instead of MAINTAINER when you do not want other
3019: developers to update or change the package without contacting you first. A
3020: package Makefile should contain one of MAINTAINER or OWNER, but not both.
1.1 dsieger 3021:
3022: * HOMEPAGE is a URL where users can find more information about the package.
3023:
3024: * COMMENT is a one-line description of the package (should not include the
3025: package name).
3026:
3027: Other variables that affect the build:
3028:
3029: * WRKSRC: The directory where the interesting distribution files of the
3030: package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
3031: most packages.
3032:
3033: If a package doesn't create a subdirectory for itself (most GNU software
3034: does, for instance), but extracts itself in the current directory, you
3035: should set WRKSRC=${WRKDIR}.
3036:
3037: If a package doesn't create a subdirectory with the name of DISTNAME but
3038: some different name, set WRKSRC to point to the proper name in ${WRKDIR},
3039: for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
3040: other examples.
3041:
3042: The name of the working directory created by pkgsrc is taken from the
3043: WRKDIR_BASENAME variable. By default, its value is work. If you want to use
3044: the same pkgsrc tree for building different kinds of binary packages, you
3045: can change the variable according to your needs. Two other variables handle
3046: common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
1.4 rillig 3047: defined in mk.conf, the first component of the host's name is attached to
3048: the directory name. If OBJMACHINE is defined, the platform name is
1.1 dsieger 3049: attached, which might look like work.i386 or work.sparc.
3050:
3051: Please pay attention to the following gotchas:
3052:
3053: * Add MANCOMPRESSED if man pages are installed in compressed form by the
3054: package. For packages using BSD-style makefiles which honor MANZ, there is
3055: MANCOMPRESSED_IF_MANZ.
3056:
3057: * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
3058:
1.6 rillig 3059: * If the package installs any info files, see Section 19.6.7, "Packages
1.1 dsieger 3060: installing info files".
3061:
1.6 rillig 3062: 11.2. distinfo
1.1 dsieger 3063:
3064: The distinfo file contains the message digest, or checksum, of each distfile
3065: needed for the package. This ensures that the distfiles retrieved from the
3066: Internet have not been corrupted during transfer or altered by a malign force
1.108 rillig 3067: to introduce a security hole. To provide maximum security, all distfiles are
3068: protected using three different message digest algorithms (SHA1, RMD160,
3069: SHA512), as well as the file size.
1.1 dsieger 3070:
3071: The distinfo file also contains the checksums for all the patches found in the
1.6 rillig 3072: patches directory (see Section 11.3, "patches/*").
1.1 dsieger 3073:
1.108 rillig 3074: To regenerate the distinfo file, use the make distinfo command.
1.1 dsieger 3075:
3076: Some packages have different sets of distfiles depending on the platform, for
1.24 wiz 3077: example lang/openjdk7. These are kept in the same distinfo file and care should
3078: be taken when upgrading such a package to ensure distfile information is not
3079: lost.
1.1 dsieger 3080:
1.6 rillig 3081: 11.3. patches/*
1.1 dsieger 3082:
1.108 rillig 3083: Some packages don't work out-of-the box on the various platforms that are
3084: supported by pkgsrc. These packages need to be patched to make them work. The
3085: patch files can be found in the patches/ directory.
1.1 dsieger 3086:
3087: In the patch phase, these patches are applied to the files in WRKSRC directory
1.25 wiz 3088: after extracting them, in alphabetic order.
1.1 dsieger 3089:
1.6 rillig 3090: 11.3.1. Structure of a single patch file
1.1 dsieger 3091:
3092: The patch-* files should be in diff -bu format, and apply without a fuzz to
3093: avoid problems. (To force patches to apply with fuzz you can set
3094: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
3095: a single file, and no file should be patched by more than one patch file. This
3096: helps to keep future modifications simple.
3097:
3098: Each patch file is structured as follows: In the first line, there is the RCS
3099: Id of the patch itself. The second line should be empty for aesthetic reasons.
3100: After that, there should be a comment for each change that the patch does.
3101: There are a number of standard cases:
3102:
3103: * Patches for commonly known vulnerabilities should mention the vulnerability
3104: ID (CAN, CVE).
3105:
3106: * Patches that change source code should mention the platform and other
3107: environment (for example, the compiler) that the patch is needed for.
3108:
1.108 rillig 3109: The patch should be commented so that any developer who knows the code of the
3110: application can make some use of the patch. Special care should be taken for
3111: the upstream developers, since we generally want that they accept our patches,
3112: so we have less work in the future.
1.1 dsieger 3113:
1.6 rillig 3114: 11.3.2. Creating patch files
1.1 dsieger 3115:
3116: One important thing to mention is to pay attention that no RCS IDs get stored
3117: in the patch files, as these will cause problems when later checked into the
3118: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
3119: avoid these problems.
3120:
3121: For even more automation, we recommend using mkpatches from the same package to
3122: make a whole set of patches. You just have to backup files before you edit them
1.25 wiz 3123: to filename.orig, e.g. with cp -p filename filename.orig or, easier, by using
1.1 dsieger 3124: pkgvi again from the same package. If you upgrade a package this way, you can
1.25 wiz 3125: easily compare the new set of patches with the previously existing one with
3126: patchdiff. The files in patches are replaced by new files, so carefully check
3127: if you want to take all the changes.
1.1 dsieger 3128:
3129: When you have finished a package, remember to generate the checksums for the
1.6 rillig 3130: patch files by using the make makepatchsum command, see Section 11.2,
1.1 dsieger 3131: "distinfo".
3132:
3133: When adding a patch that corrects a problem in the distfile (rather than e.g.
3134: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
3135: report to the maintainer. This benefits non-pkgsrc users of the package, and
3136: usually makes it possible to remove the patch in future version.
3137:
1.25 wiz 3138: The file names of the patch files are usually of the form patch-
3139: path_to_file__with__underscores.c. Many packages still use the previous
3140: convention patch-[a-z][a-z], but new patches should be of the form containing
3141: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
3142: automatically.
1.2 rillig 3143:
1.6 rillig 3144: 11.3.3. Sources where the patch files come from
1.1 dsieger 3145:
3146: If you want to share patches between multiple packages in pkgsrc, e.g. because
3147: they use the same distfiles, set PATCHDIR to the path where the patch files can
3148: be found, e.g.:
3149:
3150: PATCHDIR= ${.CURDIR}/../xemacs/patches
3151:
3152: Patch files that are distributed by the author or other maintainers can be
3153: listed in PATCHFILES.
3154:
3155: If it is desired to store any patches that should not be committed into pkgsrc,
3156: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
3157: directory tree there is expected to have the same "category/package" structure
3158: as pkgsrc, and patches are expected to be stored inside these dirs (also known
3159: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
3160: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
3161: files in the named directory are expected to be patch files, and they are
3162: applied after pkgsrc patches are applied.
3163:
1.6 rillig 3164: 11.3.4. Patching guidelines
1.1 dsieger 3165:
3166: When fixing a portability issue in the code do not use preprocessor magic to
3167: check for the current operating system nor platform. Doing so hurts portability
3168: to other platforms because the OS-specific details are not abstracted
3169: appropriately.
3170:
3171: The general rule to follow is: instead of checking for the operating system the
3172: application is being built on, check for the specific features you need. For
3173: example, instead of assuming that kqueue is available under NetBSD and using
3174: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
3175: kqueue itself ? yes, this generally involves patching the configure script.
3176: There is absolutely nothing that prevents some OSes from adopting interfaces
3177: from other OSes (e.g. Linux implementing kqueue), something that the above
3178: checks cannot take into account.
3179:
3180: Of course, checking for features generally involves more work on the
3181: developer's side, but the resulting changes are cleaner and there are chances
3182: they will work on many other platforms. Not to mention that there are higher
3183: chances of being later integrated into the mainstream sources. Remember: It
3184: doesn't work unless it is right!
3185:
3186: Some typical examples:
3187:
1.6 rillig 3188: Table 11.1. Patching examples
1.1 dsieger 3189:
3190: +-------------------------------------------------------------------------------------------+
3191: | Where | Incorrect | Correct |
3192: |---------+--------------------------+------------------------------------------------------|
3193: | |case ${target_os} in | |
3194: |configure|netbsd*) have_kvm=yes ;; |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
3195: |script |*) have_kvm=no ;; | |
3196: | |esac | |
3197: |---------+--------------------------+------------------------------------------------------|
1.2 rillig 3198: |C source |#if defined(__NetBSD__) |#if defined(HAVE_SYS_EVENT_H) |
3199: |file |# include <sys/event.h> |# include <sys/event.h> |
3200: | |#endif |#endif |
1.1 dsieger 3201: |---------+--------------------------+------------------------------------------------------|
3202: | |int |int |
3203: | |monitor_file(...) |monitor_file(...) |
3204: | |{ |{ |
3205: | |#if defined(__NetBSD__) |#if defined(HAVE_KQUEUE) |
3206: |C source | int fd = kqueue();| int fd = kqueue(); |
3207: |file | ... | ... |
3208: | |#else |#else |
3209: | | ... | ... |
3210: | |#endif |#endif |
3211: | |} |} |
3212: +-------------------------------------------------------------------------------------------+
3213:
3214:
3215: For more information, please read the Making packager-friendly software article
3216: (part 1, part 2). It summarizes multiple details on how to make software easier
3217: to package; all the suggestions in it were collected from our experience in
3218: pkgsrc work, so they are possibly helpful when creating patches too.
3219:
1.6 rillig 3220: 11.3.5. Feedback to the author
1.1 dsieger 3221:
3222: Always, always, always feed back any portability fixes or improvements you do
3223: to a package to the mainstream developers. This is the only way to get their
3224: attention on portability issues and to ensure that future versions can be built
3225: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
3226: get the fixes straight from the packaged code.
3227:
3228: This generally involves cleaning up the patches (because sometimes the patches
1.41 wiz 3229: that are added to pkgsrc are quick hacks), filing bug reports in the
1.1 dsieger 3230: appropriate trackers for the projects and working with the mainstream authors
3231: to accept your changes. It is extremely important that you do it so that the
3232: packages in pkgsrc are kept simple and thus further changes can be done without
3233: much hassle.
3234:
1.25 wiz 3235: When you have done this, please add a URL to the upstream bug report to the
3236: patch comment.
3237:
1.1 dsieger 3238: Support the idea of free software!
3239:
1.6 rillig 3240: 11.4. Other mandatory files
1.1 dsieger 3241:
3242: DESCR
3243:
3244: A multi-line description of the piece of software. This should include any
3245: credits where they are due. Please bear in mind that others do not share
3246: your sense of humour (or spelling idiosyncrasies), and that others will
3247: read everything that you write here.
3248:
3249: PLIST
3250:
3251: This file governs the files that are installed on your system: all the
3252: binaries, manual pages, etc. There are other directives which may be
3253: entered in this file, to control the creation and deletion of directories,
1.6 rillig 3254: and the location of inserted files. See Chapter 13, PLIST issues for more
1.1 dsieger 3255: information.
3256:
1.6 rillig 3257: 11.5. Optional files
1.1 dsieger 3258:
1.6 rillig 3259: 11.5.1. Files affecting the binary package
1.1 dsieger 3260:
3261: INSTALL
3262:
3263: This shell script is invoked twice by pkg_add(1). First time after package
3264: extraction and before files are moved in place, the second time after the
3265: files to install are moved in place. This can be used to do any custom
3266: procedures not possible with @exec commands in PLIST. See pkg_add(1) and
1.6 rillig 3267: pkg_create(1) for more information. See also Section 15.1, "Files and
1.29 wiz 3268: directories outside the installation prefix". Please note that you can
3269: modify variables in it easily by using FILES_SUBST in the package's
3270: Makefile:
3271:
3272: FILES_SUBST+= SOMEVAR="somevalue"
3273:
3274: replaces "@SOMEVAR@" with "somevalue" in the INSTALL. By default,
3275: substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
3276: few others, type make help topic=FILES_SUBST for a complete list.
1.1 dsieger 3277:
3278: DEINSTALL
3279:
3280: This script is executed before and after any files are removed. It is this
3281: script's responsibility to clean up any additional messy details around the
3282: package's installation, since all pkg_delete knows is how to delete the
3283: files created in the original distribution. See pkg_delete(1) and
1.29 wiz 3284: pkg_create(1) for more information. The same methods to replace variables
3285: can be used as for the INSTALL file.
1.1 dsieger 3286:
3287: MESSAGE
3288:
3289: This file is displayed after installation of the package. Useful for things
3290: like legal notices on almost-free software and hints for updating config
3291: files after installing modules for apache, PHP etc. Please note that you
3292: can modify variables in it easily by using MESSAGE_SUBST in the package's
3293: Makefile:
3294:
3295: MESSAGE_SUBST+= SOMEVAR="somevalue"
3296:
3297: replaces "${SOMEVAR}" with "somevalue" in MESSAGE. By default, substitution
1.99 sevan 3298: is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
1.16 jnemeth 3299: PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1 dsieger 3300:
3301: You can display a different or additional files by setting the MESSAGE_SRC
3302: variable. Its default is MESSAGE, if the file exists.
3303:
3304: ALTERNATIVES
3305:
1.66 asau 3306: This file is used by the alternatives framework. It creates, configures,
3307: and destroys generic wrappers used to run programs with similar interfaces.
3308: See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
3309: information.
3310:
3311: Each line of the file contains two filenames, first the wrapper and then
3312: the alternative provided by the package. Both paths are relative to PREFIX.
1.1 dsieger 3313:
1.6 rillig 3314: 11.5.2. Files affecting the build process
1.1 dsieger 3315:
3316: Makefile.common
3317:
3318: This file contains arbitrary things that could also go into a Makefile, but
3319: its purpose is to be used by more than one package. This file should only
3320: be used when the packages that will use the file are known in advance. For
3321: other purposes it is often better to write a *.mk file and give it a good
3322: name that describes what it does.
3323:
3324: buildlink3.mk
3325:
3326: This file contains the dependency information for the buildlink3 framework
1.6 rillig 3327: (see Chapter 14, Buildlink methodology).
1.1 dsieger 3328:
3329: hacks.mk
3330:
3331: This file contains workarounds for compiler bugs and similar things. It is
3332: included automatically by the pkgsrc infrastructure, so you don't need an
3333: extra .include line for it.
3334:
3335: options.mk
3336:
3337: This file contains the code for the package-specific options (see
1.6 rillig 3338: Chapter 16, Options handling) that can be selected by the user. If a
1.1 dsieger 3339: package has only one or two options, it is equally acceptable to put the
3340: code directly into the Makefile.
3341:
1.6 rillig 3342: 11.5.3. Files affecting nothing at all
1.1 dsieger 3343:
3344: README*
3345:
3346: These files do not take place in the creation of a package and thus are
3347: purely informative to the package developer.
3348:
3349: TODO
3350:
3351: This file contains things that need to be done to make the package even
3352: better.
3353:
1.6 rillig 3354: 11.6. work*
1.1 dsieger 3355:
3356: When you type make, the distribution files are unpacked into the directory
3357: denoted by WRKDIR. It can be removed by running make clean. Besides the
3358: sources, this directory is also used to keep various timestamp files. The
3359: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
3360: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
3361:
1.6 rillig 3362: 11.7. files/*
1.1 dsieger 3363:
3364: If you have any files that you wish to be placed in the package prior to
3365: configuration or building, you could place these files here and use a ${CP}
3366: command in the "pre-configure" target to achieve this. Alternatively, you could
3367: simply diff the file against /dev/null and use the patch mechanism to manage
3368: the creation of this file.
3369:
3370: If you want to share files in this way with other packages, set the FILESDIR
3371: variable to point to the other package's files directory, e.g.:
3372:
3373: FILESDIR=${.CURDIR}/../xemacs/files
3374:
1.6 rillig 3375: Chapter 12. Programming in Makefiles
1.1 dsieger 3376:
3377: Table of Contents
3378:
1.6 rillig 3379: 12.1. Caveats
3380: 12.2. Makefile variables
1.1 dsieger 3381:
1.6 rillig 3382: 12.2.1. Naming conventions
1.1 dsieger 3383:
1.6 rillig 3384: 12.3. Code snippets
1.1 dsieger 3385:
1.6 rillig 3386: 12.3.1. Adding things to a list
1.117 sevan 3387: 12.3.2. Echoing a string exactly as-is
1.108 rillig 3388: 12.3.3. Passing CFLAGS to GNU configure scripts
3389: 12.3.4. Handling possibly empty variables
1.1 dsieger 3390:
3391: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
3392: part of the pkgsrc system. Using the make(1) system as a programming language
3393: for a big system like pkgsrc requires some discipline to keep the code correct
3394: and understandable.
3395:
3396: The basic ingredients for Makefile programming are variables (which are
3397: actually macros) and shell commands. Among these shell commands may even be
3398: more complex ones like awk(1) programs. To make sure that every shell command
3399: runs as intended it is necessary to quote all variables correctly when they are
3400: used.
3401:
3402: This chapter describes some patterns, that appear quite often in Makefiles,
3403: including the pitfalls that come along with them.
3404:
1.6 rillig 3405: 12.1. Caveats
1.1 dsieger 3406:
3407: * When you are creating a file as a target of a rule, always write the data
3408: to a temporary file first and finally rename that file. Otherwise there
3409: might occur an error in the middle of generating the file, and when the
3410: user runs make(1) for the second time, the file exists and will not be
3411: regenerated properly. Example:
3412:
3413: wrong:
3414: @echo "line 1" > ${.TARGET}
3415: @echo "line 2" >> ${.TARGET}
3416: @false
3417:
3418: correct:
3419: @echo "line 1" > ${.TARGET}.tmp
3420: @echo "line 2" >> ${.TARGET}.tmp
3421: @false
3422: @mv ${.TARGET}.tmp ${.TARGET}
3423:
3424: When you run make wrong twice, the file wrong will exist, although there
3425: was an error message in the first run. On the other hand, running make
3426: correct gives an error message twice, as expected.
3427:
3428: You might remember that make(1) sometimes removes ${.TARGET} in case of
3429: error, but this only happens when it is interrupted, for example by
3430: pressing ^C. This does not happen when one of the commands fails (like
3431: false(1) above).
3432:
1.6 rillig 3433: 12.2. Makefile variables
1.1 dsieger 3434:
3435: Makefile variables contain strings that can be processed using the five
3436: operators ``='', ``+='', ``?='', ``:='', and ``!='', which are described in the
3437: make(1) man page.
3438:
3439: When a variable's value is parsed from a Makefile, the hash character ``#'' and
3440: the backslash character ``\'' are handled specially. If a backslash is followed
3441: by a newline, any whitespace immediately in front of the backslash, the
3442: backslash, the newline, and any whitespace immediately behind the newline are
3443: replaced with a single space. A backslash character and an immediately
3444: following hash character are replaced with a single hash character. Otherwise,
3445: the backslash is passed as is. In a variable assignment, any hash character
3446: that is not preceded by a backslash starts a comment that continues upto the
3447: end of the logical line.
3448:
1.108 rillig 3449: The evaluation of variables either happens immediately or lazy. It happens
3450: immediately when the variable occurs on the right-hand side of the ``:='' or
3451: the ``!='' operator, in a .if condition or a .for loop. In the other cases, it
3452: is evaluated lazily.
1.1 dsieger 3453:
3454: Some of the modifiers split the string into words and then operate on the
3455: words, others operate on the string as a whole. When a string is split into
1.108 rillig 3456: words, it is split like in sh(1).
1.1 dsieger 3457:
3458: There are several types of variables that should be handled differently.
3459: Strings and two types of lists.
3460:
3461: * Strings can contain arbitrary characters. Nevertheless, you should restrict
3462: yourself to only using printable characters. Examples are PREFIX and
3463: COMMENT.
3464:
3465: * Internal lists are lists that are never exported to any shell command.
3466: Their elements are separated by whitespace. Therefore, the elements
3467: themselves cannot have embedded whitespace. Any other characters are
3468: allowed. Internal lists can be used in .for loops. Examples are DEPENDS and
3469: BUILD_DEPENDS.
3470:
3471: * External lists are lists that may be exported to a shell command. Their
3472: elements can contain any characters, including whitespace. That's why they
3473: cannot be used in .for loops. Examples are DISTFILES and MASTER_SITES.
3474:
1.6 rillig 3475: 12.2.1. Naming conventions
1.1 dsieger 3476:
3477: * All variable names starting with an underscore are reserved for use by the
3478: pkgsrc infrastructure. They shall not be used by package Makefiles.
3479:
3480: * In .for loops you should use lowercase variable names for the iteration
3481: variables.
3482:
3483: * All list variables should have a ``plural'' name, e.g. PKG_OPTIONS or
3484: DISTFILES.
3485:
1.6 rillig 3486: 12.3. Code snippets
1.1 dsieger 3487:
1.108 rillig 3488: 12.3.1. Adding things to a list
3489:
3490: When adding a string that possibly contains whitespace or quotes to a list
3491: (example 1), it must be quoted using the :Q modifier.
1.1 dsieger 3492:
1.108 rillig 3493: When adding another list to a list (example 2), it must not be quoted, since
3494: its elements are already quoted.
1.1 dsieger 3495:
1.108 rillig 3496: STRING= foo * bar `date`
3497: LIST= # empty
3498: ANOTHER_LIST= a=b c=d
1.1 dsieger 3499:
1.108 rillig 3500: LIST+= ${STRING:Q} # 1
3501: LIST+= ${ANOTHER_LIST} # 2
1.1 dsieger 3502:
1.117 sevan 3503: 12.3.2. Echoing a string exactly as-is
1.1 dsieger 3504:
1.108 rillig 3505: Echoing a string containing special characters needs special work.
1.1 dsieger 3506:
3507: STRING= foo bar < > * `date` $$HOME ' "
1.108 rillig 3508: EXAMPLE_ENV= string=${STRING:Q} x=multiple\ quoted\ words
1.1 dsieger 3509:
3510: all:
3511: echo ${STRING} # 1
1.108 rillig 3512: echo ${STRING:Q} # 2
3513: printf '%s\n' ${STRING:Q}'' # 3
3514: env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"' # 4
1.1 dsieger 3515:
3516: Example 1 leads to a syntax error in the shell, as the characters are just
3517: copied.
3518:
1.108 rillig 3519: Example 2 quotes the string so that the shell interprets it correctly. But the
3520: echo command may additionally interpret strings with a leading dash or those
3521: containing backslashes.
3522:
3523: Example 3 can handle arbitrary strings, since printf(1) only interprets the
3524: format string, but not the next argument.
3525:
3526: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
3527: has already been done when adding elements to the list.
3528:
3529: 12.3.3. Passing CFLAGS to GNU configure scripts
3530:
3531: When passing CFLAGS or similar variables to a GNU-style configure script
3532: (especially those that call other configure scripts), it must not have leading
3533: or trailing whitespace, since otherwise the configure script gets confused. To
3534: trim leading and trailing whitespace, use the :M modifier, as in the following
3535: example:
3536:
3537: CPPFLAGS= # empty
3538: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX}\"
3539: CPPFLAGS+= ${MY_CPPFLAGS}
3540:
3541: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
3542:
3543: all:
3544: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
3545: echo x${CONFIGURE_ARGS:Q}x # properly trimmed
3546:
3547: In this example, CPPFLAGS has both leading and trailing whitespace because the
3548: += operator always adds a space.
3549:
3550: 12.3.4. Handling possibly empty variables
3551:
3552: When a possibly empty variable is used in a shell program, it may lead to a
3553: syntax error.
3554:
3555: EGFILES= # empty
3556:
3557: install-examples: # produces a syntax error in the shell
3558: for egfile in ${EGFILES}; do \
3559: echo "Installing $$egfile"; \
3560: done
3561:
3562: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
3563: with an empty string by make(1). To fix this syntax error, use one of the
3564: snippets below.
3565:
3566: EMPTY= # empty
3567:
3568: install-examples:
3569: for egfile in ${EGFILES} ""; do \
3570: [ -n "$$egfile" ] || continue; \
3571: echo "Installing $$egfile"; \
3572: done
3573:
3574: In this case, an empty string is appended to the iteration list (to prevent the
3575: syntax error) and filtered out later.
1.1 dsieger 3576:
1.108 rillig 3577: EGFILES= # empty
1.1 dsieger 3578:
1.108 rillig 3579: install-examples:
3580: .for egfile in ${EGFILES}
3581: echo "Installing ${egfile}"
3582: .endfor
3583:
3584: This variant only works when EGFILES does not contain filenames with spaces,
3585: since the .for loop splits on simple whitespace.
3586:
3587: To have a shell command test whether a make variable is empty, use the
3588: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1 dsieger 3589:
1.6 rillig 3590: Chapter 13. PLIST issues
1.1 dsieger 3591:
3592: Table of Contents
3593:
1.6 rillig 3594: 13.1. RCS ID
3595: 13.2. Semi-automatic PLIST generation
3596: 13.3. Tweaking output of make print-PLIST
3597: 13.4. Variable substitution in PLIST
3598: 13.5. Man page compression
3599: 13.6. Changing PLIST source with PLIST_SRC
3600: 13.7. Platform-specific and differing PLISTs
1.86 wiz 3601: 13.8. Build-specific PLISTs
3602: 13.9. Sharing directories between packages
1.1 dsieger 3603:
3604: The PLIST file contains a package's "packing list", i.e. a list of files that
3605: belong to the package (relative to the ${PREFIX} directory it's been installed
3606: in) plus some additional statements - see the pkg_create(1) man page for a full
3607: list. This chapter addresses some issues that need attention when dealing with
3608: the PLIST file (or files, see below!).
3609:
1.6 rillig 3610: 13.1. RCS ID
1.1 dsieger 3611:
3612: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
3613:
1.121 ! sevan 3614: @comment $NetBSD $
! 3615:
! 3616: An artificial space has been added betweeen NetBSD and $, this is a workaround
! 3617: here to prevent CVS expanding to the filename of the guide. When adding the RCS
! 3618: ID the space should be ommited.
1.1 dsieger 3619:
1.6 rillig 3620: 13.2. Semi-automatic PLIST generation
1.1 dsieger 3621:
3622: You can use the make print-PLIST command to output a PLIST that matches any new
1.6 rillig 3623: files since the package was extracted. See Section 17.17, "Other helpful
1.1 dsieger 3624: targets" for more information on this target.
3625:
1.6 rillig 3626: 13.3. Tweaking output of make print-PLIST
1.1 dsieger 3627:
3628: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
3629: used to filter the output of print-PLIST. You can append any chunk of AWK
3630: scripting you like to it, but be careful with quoting.
3631:
3632: For example, to get all files inside the libdata/foo directory removed from the
3633: resulting PLIST:
3634:
3635: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
3636:
1.6 rillig 3637: 13.4. Variable substitution in PLIST
1.1 dsieger 3638:
3639: A number of variables are substituted automatically in PLISTs when a package is
3640: installed on a system. This includes the following variables:
3641:
3642: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
3643:
3644: Some packages like emacs and perl embed information about which
3645: architecture they were built on into the pathnames where they install their
3646: files. To handle this case, PLIST will be preprocessed before actually
3647: used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
3648: gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
3649: PLIST somewhere - use this on packages that have GNU autoconf-created
3650: configure scripts.
3651:
3652: Legacy note
3653:
3654: There used to be a symbol "$ARCH" that was replaced by the output of uname
3655: -m, but that's no longer supported and has been removed.
3656:
3657: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
3658:
3659: Some packages want to embed the OS name and version into some paths. To do
3660: this, use these variables in the PLIST:
3661:
1.42 asau 3662: + ${OPSYS} - output of "uname -s"
1.1 dsieger 3663:
1.42 asau 3664: + ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
1.1 dsieger 3665:
1.42 asau 3666: + ${OS_VERSION} - "uname -r"
1.1 dsieger 3667:
1.88 tnn 3668: For a list of values which are replaced by default, the output of make help
3669: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
3670: PLIST_SUBST should help.
1.1 dsieger 3671:
3672: If you want to change other variables not listed above, you can add variables
3673: and their expansions to this variable in the following way, similar to
1.6 rillig 3674: MESSAGE_SUBST (see Section 11.5, "Optional files"):
1.1 dsieger 3675:
3676: PLIST_SUBST+= SOMEVAR="somevalue"
3677:
3678: This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
3679:
1.19 snj 3680: The PLIST_VARS variable can be used to simplify the common case of
3681: conditionally including some PLIST entries. It can be done by adding
3682: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
3683: entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
3684: either """" or ""@comment "". For example, in Makefile:
1.18 mishka 3685:
3686: PLIST_VARS+= foo
3687: .if condition
3688: PLIST.foo= yes
3689: .else
3690:
3691: And then in PLIST:
3692:
1.121 ! sevan 3693: @comment $NetBSD $
1.18 mishka 3694: bin/bar
3695: man/man1/bar.1
3696: ${PLIST.foo}bin/foo
3697: ${PLIST.foo}man/man1/foo.1
3698: ${PLIST.foo}share/bar/foo.data
3699:
1.121 ! sevan 3700: An artificial space has been added betweeen NetBSD and $, this is a workaround
! 3701: here to prevent CVS expanding to the filename of the guide. When adding the RCS
! 3702: ID the space should be ommited.
! 3703:
1.6 rillig 3704: 13.5. Man page compression
1.1 dsieger 3705:
3706: Man pages should be installed in compressed form if MANZ is set (in
3707: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
3708: suffix ".gz" is appended/removed automatically for man pages according to MANZ
3709: and MANCOMPRESSED being set or not, see above for details. This modification of
3710: the PLIST file is done on a copy of it, not PLIST itself.
3711:
1.6 rillig 3712: 13.6. Changing PLIST source with PLIST_SRC
1.1 dsieger 3713:
3714: To use one or more files as source for the PLIST used in generating the binary
3715: package, set the variable PLIST_SRC to the names of that file(s). The files are
3716: later concatenated using cat(1), and the order of things is important. The
3717: default for PLIST_SRC is ${PKGDIR}/PLIST.
3718:
1.6 rillig 3719: 13.7. Platform-specific and differing PLISTs
1.1 dsieger 3720:
3721: Some packages decide to install a different set of files based on the operating
3722: system being used. These differences can be automatically handled by using the
3723: following files:
3724:
3725: * PLIST.common
3726:
3727: * PLIST.${OPSYS}
3728:
3729: * PLIST.${MACHINE_ARCH}
3730:
3731: * PLIST.${OPSYS}-${MACHINE_ARCH}
3732:
3733: * PLIST.common_end
3734:
1.86 wiz 3735: 13.8. Build-specific PLISTs
3736:
3737: Some packages decide to generate hard-to-guess file names during installation
3738: that are hard to wire down.
3739:
3740: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
3741: (with a semicolon) that will output PLIST entries which will be appended to the
3742: PLIST
3743:
3744: You can find one example in editors/xemacs:
3745:
1.111 sevan 3746: GENERATE_PLIST+= ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.86 wiz 3747:
3748: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
3749:
3750: 13.9. Sharing directories between packages
1.1 dsieger 3751:
3752: A "shared directory" is a directory where multiple (and unrelated) packages
1.23 jakllsch 3753: install files. These directories were problematic because you had to add
1.1 dsieger 3754: special tricks in the PLIST to conditionally remove them, or have some
3755: centralized package handle them.
3756:
1.23 jakllsch 3757: In pkgsrc, it is now easy: Each package should create directories and install
3758: files as needed; pkg_delete will remove any directories left empty after
3759: uninstalling a package.
1.1 dsieger 3760:
1.23 jakllsch 3761: If a package needs an empty directory to work, create the directory during
3762: installation as usual, and also add an entry to the PLIST:
1.1 dsieger 3763:
1.23 jakllsch 3764: @pkgdir path/to/empty/directory
1.1 dsieger 3765:
1.86 wiz 3766: or take a look at MAKE_DIRS and OWN_DIRS.
3767:
1.6 rillig 3768: Chapter 14. Buildlink methodology
1.1 dsieger 3769:
3770: Table of Contents
3771:
1.6 rillig 3772: 14.1. Converting packages to use buildlink3
3773: 14.2. Writing buildlink3.mk files
1.1 dsieger 3774:
1.6 rillig 3775: 14.2.1. Anatomy of a buildlink3.mk file
1.27 wiz 3776: 14.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
3777: buildlink3.mk files
1.1 dsieger 3778:
1.6 rillig 3779: 14.3. Writing builtin.mk files
1.1 dsieger 3780:
1.6 rillig 3781: 14.3.1. Anatomy of a builtin.mk file
3782: 14.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 3783:
3784: Buildlink is a framework in pkgsrc that controls what headers and libraries are
3785: seen by a package's configure and build processes. This is implemented in a two
3786: step process:
3787:
3788: 1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
3789: default is a subdirectory of WRKDIR.
3790:
3791: 2. Create wrapper scripts that are used in place of the normal compiler tools
3792: that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
3793: references to BUILDLINK_DIR. The wrapper scripts also make native compiler
3794: on some operating systems look like GCC, so that packages that expect GCC
3795: won't require modifications to build with those native compilers.
3796:
3797: This normalizes the environment in which a package is built so that the package
3798: may be built consistently despite what other software may be installed. Please
3799: note that the normal system header and library paths, e.g. /usr/include, /usr/
3800: lib, etc., are always searched -- buildlink3 is designed to insulate the
3801: package build from non-system-supplied software.
3802:
1.6 rillig 3803: 14.1. Converting packages to use buildlink3
1.1 dsieger 3804:
1.25 wiz 3805: The process of converting packages to use the buildlink3 framework ("bl3ifying"
3806: ) is fairly straightforward. The things to keep in mind are:
1.1 dsieger 3807:
3808: 1. Ensure that the build always calls the wrapper scripts instead of the
3809: actual toolchain. Some packages are tricky, and the only way to know for
3810: sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
3811: invoked.
3812:
3813: 2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
3814: standalone shells, etc., because the code to symlink files into $
3815: {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
3816:
3817: 3. Remember that only the buildlink3.mk files that you list in a package's
3818: Makefile are added as dependencies for that package.
3819:
3820: If a dependency on a particular package is required for its libraries and
3821: headers, then we replace:
3822:
3823: DEPENDS+= foo>=1.1.0:../../category/foo
3824:
3825: with
3826:
3827: .include "../../category/foo/buildlink3.mk"
3828:
3829: The buildlink3.mk files usually define the required dependencies. If you need a
3830: newer version of the dependency when using buildlink3.mk files, then you can
3831: define it in your Makefile; for example:
3832:
3833: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
3834: .include "../../category/foo/buildlink3.mk"
3835:
3836: There are several buildlink3.mk files in pkgsrc/mk that handle special package
3837: issues:
3838:
3839: * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
3840: implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
3841:
3842: * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
3843: this will take care to install the devel/ncurses package.
3844:
3845: * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
3846: a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
3847: implementation.
3848:
3849: * motif.buildlink3.mk checks for a system-provided Motif installation or adds
1.46 obache 3850: a dependency on x11/lesstif, x11/motif or x11/openmotif. The user can set
3851: MOTIF_TYPE to "dt", "lesstif", "motif" or "openmotif" to choose which Motif
3852: version will be used.
1.1 dsieger 3853:
1.57 wiz 3854: * readline.buildlink3.mk checks for a system-provided GNU readline or
3855: editline (libedit) installation, or adds a dependency on devel/readline,
3856: devel/editline. The user can set READLINE_DEFAULT to choose readline
1.56 ryoon 3857: implementation. If your package really needs GNU readline library, its
3858: Makefile should include devel/readline/buildlink3.mk instead of
3859: readline.buildlink3.mk.
3860:
1.1 dsieger 3861: * oss.buildlink3.mk defines several variables that may be used by packages
3862: that use the Open Sound System (OSS) API.
3863:
1.36 wiz 3864: * pgsql.buildlink3.mk will accept any of the Postgres versions in the
3865: variable PGSQL_VERSIONS_ACCEPTED and default to the version
3866: PGSQL_VERSION_DEFAULT. See the file for more information.
1.1 dsieger 3867:
3868: * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
3869: pthreads or adds a dependency on devel/pth as needed.
3870:
3871: * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
3872: widgets library.
3873:
3874: The comments in those buildlink3.mk files provide a more complete description
3875: of how to use them properly.
3876:
1.6 rillig 3877: 14.2. Writing buildlink3.mk files
1.1 dsieger 3878:
3879: A package's buildlink3.mk file is included by Makefiles to indicate the need to
3880: compile and link against header files and libraries provided by the package. A
3881: buildlink3.mk file should always provide enough information to add the correct
3882: type of dependency relationship and include any other buildlink3.mk files that
3883: it needs to find headers and libraries that it needs in turn.
3884:
3885: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
3886: pkgtools/createbuildlink package is highly recommended. For most packages, the
3887: following command will generate a good starting point for buildlink3.mk files:
3888:
3889: % cd pkgsrc/category/pkgdir
3890: % createbuildlink >buildlink3.mk
3891:
3892:
1.6 rillig 3893: 14.2.1. Anatomy of a buildlink3.mk file
1.1 dsieger 3894:
3895: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
3896: tiff:
3897:
1.19 snj 3898: # $NetBSD: buildlink3.mk,v 1.16 2009/03/20 19:24:45 joerg Exp $
1.1 dsieger 3899:
1.19 snj 3900: BUILDLINK_TREE+= tiff
1.1 dsieger 3901:
1.19 snj 3902: .if !defined(TIFF_BUILDLINK3_MK)
3903: TIFF_BUILDLINK3_MK:=
1.1 dsieger 3904:
1.19 snj 3905: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
3906: BUILDLINK_ABI_DEPENDS.tiff+= tiff>=3.7.2nb1
1.1 dsieger 3907: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
3908:
3909: .include "../../devel/zlib/buildlink3.mk"
3910: .include "../../graphics/jpeg/buildlink3.mk"
1.19 snj 3911: .endif # TIFF_BUILDLINK3_MK
1.1 dsieger 3912:
1.19 snj 3913: BUILDLINK_TREE+= -tiff
1.1 dsieger 3914:
1.19 snj 3915: The header and footer manipulate BUILDLINK_TREE, which is common across all
3916: buildlink3.mk files and is used to track the dependency tree.
1.1 dsieger 3917:
1.19 snj 3918: The main section is protected from multiple inclusion and controls how the
1.1 dsieger 3919: dependency on pkg is added. Several important variables are set in the section:
3920:
3921: * BUILDLINK_API_DEPENDS.pkg is the actual dependency recorded in the
3922: installed package; this should always be set using += to ensure that we're
3923: appending to any pre-existing list of values. This variable should be set
1.27 wiz 3924: to the first version of the package that had an backwards-incompatible API
3925: change.
1.1 dsieger 3926:
3927: * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
3928:
3929: * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
3930: BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
3931: is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
3932: full dependency is used.
3933:
3934: * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
3935: of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
3936: library search paths. These default to "include" and "lib" respectively.
3937:
3938: * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
3939: to add to CPPFLAGS, which are passed on to the configure and build phases.
3940: The "-I" option should be avoided and instead be handled using
3941: BUILDLINK_INCDIRS.pkg as above.
3942:
3943: The following variables are all optionally defined within this second section
3944: (protected against multiple inclusion) and control which package files are
3945: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
3946: symlinking:
3947:
3948: * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
3949: {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
3950: *.h.
3951:
3952: * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
3953: to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
3954: resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
3955: takes the +CONTENTS of a pkg and filters it through $
3956: {BUILDLINK_CONTENTS_FILTER.pkg}.
3957:
3958: * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
3959: filters +CONTENTS input into a list of files relative to $
1.84 wiz 3960: {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
3961: outputs the contents of the include and lib directories in the package
3962: +CONTENTS.
1.1 dsieger 3963:
3964: * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
3965: used to transform the name of the source filename into a destination
3966: filename, e.g. -e "s|/curses.h|/ncurses.h|g".
3967:
1.19 snj 3968: This section can additionally include any buildlink3.mk needed for pkg's
3969: library dependencies. Including these buildlink3.mk files means that the
3970: headers and libraries for these dependencies are also symlinked into $
3971: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
3972: are only added for directly include buildlink3.mk files.
1.1 dsieger 3973:
1.48 wiz 3974: When providing a buildlink3.mk and including other buildlink3.mk files in it,
1.51 wiz 3975: please only add necessary ones, i.e., those whose libraries or header files are
1.48 wiz 3976: automatically exposed when the package is use.
3977:
3978: In particular, if only an executable (bin/foo) is linked against a library,
3979: that library does not need to be propagated in the buildlink3.mk file.
3980:
3981: The following steps should help you decide if a buildlink3.mk file needs to be
3982: included:
3983:
3984: * Look at the installed header files: What headers do they include? The
3985: packages providing these files must be buildlinked.
3986:
1.50 wiz 3987: * Run ldd on all installed libraries and look against what other libraries
3988: they link. Some of the packages providing these probably need to be
3989: buildlinked; however, it's not automatic, since e.g. GTK on some systems
3990: pulls in the X libraries, so they will show up in the ldd output, while on
1.51 wiz 3991: others (like OS X) it won't. ldd output can thus only be used as a hint.
1.50 wiz 3992:
1.27 wiz 3993: 14.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
3994: buildlink3.mk files
1.1 dsieger 3995:
1.27 wiz 3996: These two variables differ in that one describes source compatibility (API) and
3997: the other binary compatibility (ABI). The difference is that a change in the
3998: API breaks compilation of programs while changes in the ABI stop compiled
3999: programs from running.
4000:
1.28 wiz 4001: Changes to the BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk file
4002: happen very rarely. One possible reason is that all packages depending on this
4003: already need a newer version. In case it is bumped see the description below.
1.27 wiz 4004:
4005: The most common example of an ABI change is that the major version of a shared
4006: library is increased. In this case, BUILDLINK_ABI_DEPENDS.pkg should be
4007: adjusted to require at least the new package version. Then the packages that
4008: depend on this package need their PKGREVISIONs increased and, if they have
4009: buildlink3.mk files, their BUILDLINK_ABI_DEPENDS.pkg adjusted, too. This is
4010: needed so pkgsrc will require the correct package dependency and not settle for
4011: an older one when building the source.
1.1 dsieger 4012:
1.108 rillig 4013: See Section 19.1.5, "Handling dependencies" for more information about
1.1 dsieger 4014: dependencies on other packages, including the BUILDLINK_ABI_DEPENDS and
4015: ABI_DEPENDS definitions.
4016:
4017: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
4018: BUILDLINK_ABI_DEPENDS.pkg as we don't want to cause unneeded package deletions
4019: and rebuilds. In many cases, new versions of packages work just fine with older
4020: dependencies.
4021:
4022: Also it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
4023: BUILDLINK_API_DEPENDS.pkg.
4024:
1.6 rillig 4025: 14.3. Writing builtin.mk files
1.1 dsieger 4026:
4027: Some packages in pkgsrc install headers and libraries that coincide with
4028: headers and libraries present in the base system. Aside from a buildlink3.mk
4029: file, these packages should also include a builtin.mk file that includes the
4030: necessary checks to decide whether using the built-in software or the pkgsrc
4031: software is appropriate.
4032:
4033: The only requirements of a builtin.mk file for pkg are:
4034:
4035: 1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
4036:
4037: 2. It should not override any USE_BUILTIN.pkg which is already set before the
4038: builtin.mk file is included.
4039:
4040: 3. It should be written to allow multiple inclusion. This is very important
4041: and takes careful attention to Makefile coding.
4042:
1.6 rillig 4043: 14.3.1. Anatomy of a builtin.mk file
1.1 dsieger 4044:
4045: The following is the recommended template for builtin.mk files:
4046:
4047: .if !defined(IS_BUILTIN.foo)
4048: #
4049: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
4050: # genuinely exists in the system or not.
4051: #
4052: IS_BUILTIN.foo?= no
4053:
4054: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
4055: # version can be determined.
4056: #
4057: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
4058: BUILTIN_PKG.foo?= foo-1.0
4059: . endif
4060: .endif # IS_BUILTIN.foo
4061:
4062: .if !defined(USE_BUILTIN.foo)
4063: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
4064: . if defined(BUILTIN_PKG.foo)
4065: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
4066: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
4067: USE_BUILTIN.foo!= \
4068: ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo} \
4069: && ${ECHO} "yes" || ${ECHO} "no"
4070: . endif
4071: . endfor
4072: . endif
4073: .endif # USE_BUILTIN.foo
4074:
4075: CHECK_BUILTIN.foo?= no
4076: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
4077: #
4078: # Here we place code that depends on whether USE_BUILTIN.foo is set to
4079: # "yes" or "no".
4080: #
4081: .endif # CHECK_BUILTIN.foo
4082:
4083: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
4084: base system. This should not be a base system software with similar
4085: functionality to pkg; it should only be "yes" if the actual package is included
4086: as part of the base system. This variable is only used internally within the
4087: builtin.mk file.
4088:
4089: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
4090: system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
4091: internally within the builtin.mk file.
4092:
4093: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
4094: The code in this section must make the determination whether the built-in
4095: software is adequate to satisfy the dependencies listed in
4096: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
1.25 wiz 4097: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg
1.1 dsieger 4098: must be set to the correct value by the end of the builtin.mk file. Note that
4099: USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
4100: the determination that the built-in version of the software is similar enough
4101: to be used as a replacement.
4102:
4103: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
4104: the value of USE_BUILTIN.pkg set in the previous section. This typically
4105: includes, e.g., adding additional dependency restrictions and listing
4106: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
4107:
1.6 rillig 4108: 14.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 4109:
4110: When building packages, it's possible to choose whether to set a global
4111: preference for using either the built-in (native) version or the pkgsrc version
4112: of software to satisfy a dependency. This is controlled by setting
1.25 wiz 4113: PREFER_PKGSRC and PREFER_NATIVE. These variables take values of either "yes", "
4114: no", or a list of packages. PREFER_PKGSRC tells pkgsrc to use the pkgsrc
1.1 dsieger 4115: versions of software, while PREFER_NATIVE tells pkgsrc to use the built-in
4116: versions. Preferences are determined by the most specific instance of the
4117: package in either PREFER_PKGSRC or PREFER_NATIVE. If a package is specified in
4118: neither or in both variables, then PREFER_PKGSRC has precedence over
4119: PREFER_NATIVE. For example, to require using pkgsrc versions of software for
4120: all but the most basic bits on a NetBSD system, you can set:
4121:
4122: PREFER_PKGSRC= yes
4123: PREFER_NATIVE= getopt skey tcp_wrappers
4124:
4125: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
4126: it is simply ignored in that list.
4127:
1.117 sevan 4128: Setting PREFER_NATIVE should be performed straight after bootstrap and
4129: PREFER_PKGSRC during bootstrap. Switching between settings globally at a later
4130: date can introduce complications with dependency resolution. This is caused by
4131: packages built with the opposite preference being installed alongside each
4132: other.
4133:
4134: # ./bootstrap --prefer-pkgsrc yes
4135:
1.6 rillig 4136: Chapter 15. The pkginstall framework
1.1 dsieger 4137:
4138: Table of Contents
4139:
1.6 rillig 4140: 15.1. Files and directories outside the installation prefix
1.1 dsieger 4141:
1.6 rillig 4142: 15.1.1. Directory manipulation
4143: 15.1.2. File manipulation
1.1 dsieger 4144:
1.6 rillig 4145: 15.2. Configuration files
1.1 dsieger 4146:
1.6 rillig 4147: 15.2.1. How PKG_SYSCONFDIR is set
4148: 15.2.2. Telling the software where configuration files are
4149: 15.2.3. Patching installations
4150: 15.2.4. Disabling handling of configuration files
1.1 dsieger 4151:
1.6 rillig 4152: 15.3. System startup scripts
1.1 dsieger 4153:
1.6 rillig 4154: 15.3.1. Disabling handling of system startup scripts
1.1 dsieger 4155:
1.6 rillig 4156: 15.4. System users and groups
4157: 15.5. System shells
1.1 dsieger 4158:
1.6 rillig 4159: 15.5.1. Disabling shell registration
1.1 dsieger 4160:
1.6 rillig 4161: 15.6. Fonts
1.1 dsieger 4162:
1.6 rillig 4163: 15.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 4164:
4165: This chapter describes the framework known as pkginstall, whose key features
4166: are:
4167:
4168: * Generic installation and manipulation of directories and files outside the
4169: pkgsrc-handled tree, LOCALBASE.
4170:
4171: * Automatic handling of configuration files during installation, provided
4172: that packages are correctly designed.
4173:
4174: * Generation and installation of system startup scripts.
4175:
4176: * Registration of system users and groups.
4177:
4178: * Registration of system shells.
4179:
4180: * Automatic updating of fonts databases.
4181:
4182: The following sections inspect each of the above points in detail.
4183:
4184: You may be thinking that many of the things described here could be easily done
4185: with simple code in the package's post-installation target (post-install). This
4186: is incorrect, as the code in them is only executed when building from source.
4187: Machines using binary packages could not benefit from it at all (as the code
4188: itself could be unavailable). Therefore, the only way to achieve any of the
4189: items described above is by means of the installation scripts, which are
4190: automatically generated by pkginstall.
4191:
1.6 rillig 4192: 15.1. Files and directories outside the installation prefix
1.1 dsieger 4193:
4194: As you already know, the PLIST file holds a list of files and directories that
4195: belong to a package. The names used in it are relative to the installation
4196: prefix (${PREFIX}), which means that it cannot register files outside this
4197: directory (absolute path names are not allowed). Despite this restriction, some
4198: packages need to install files outside this location; e.g., under ${VARBASE} or
4199: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
4200: installation time by using installation scripts.
4201:
4202: The generic installation scripts are shell scripts that can contain arbitrary
4203: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
4204: which defaults to INSTALL. A similar variable exists for package removal
4205: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
4206: commands, so they have the potential to create and manage files anywhere in the
4207: file system.
4208:
4209: Using these general installation files is not recommended, but may be needed in
4210: some special cases. One reason for avoiding them is that the user has to trust
4211: the packager that there is no unwanted or simply erroneous code included in the
4212: installation script. Also, previously there were many similar scripts for the
4213: same functionality, and fixing a common error involved finding and changing all
4214: of them.
4215:
4216: The pkginstall framework offers another, standardized way. It provides generic
4217: scripts to abstract the manipulation of such files and directories based on
4218: variables set in the package's Makefile. The rest of this section describes
4219: these variables.
4220:
1.6 rillig 4221: 15.1.1. Directory manipulation
1.1 dsieger 4222:
4223: The following variables can be set to request the creation of directories
4224: anywhere in the file system:
4225:
4226: * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
4227: and should attempt to be destroyed by the installation scripts. The
4228: difference between the two is that the latter prompts the administrator to
4229: remove any directories that may be left after deinstallation (because they
1.108 rillig 4230: were not empty), while the former does not. Example:
4231:
4232: MAKE_DIRS+= ${VARBASE}/foo/private
1.1 dsieger 4233:
4234: * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
4235: which directories should be created and should attempt to be destroyed by
4236: the installation scripts. Each tuple holds the following values, separated
4237: by spaces: the directory name, its owner, its group and its numerical mode.
4238: For example:
4239:
1.108 rillig 4240: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private \
4241: ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1 dsieger 4242:
4243: The difference between the two is exactly the same as their non-PERMS
4244: counterparts.
4245:
1.6 rillig 4246: 15.1.2. File manipulation
1.1 dsieger 4247:
4248: Creating non-empty files outside the installation prefix is tricky because the
4249: PLIST forces all files to be inside it. To overcome this problem, the only
4250: solution is to extract the file in the known place (i.e., inside the
4251: installation prefix) and copy it to the appropriate location during
4252: installation (done by the installation scripts generated by pkginstall). We
4253: will call the former the master file in the following paragraphs, which
4254: describe the variables that can be used to automatically and consistently
4255: handle files outside the installation prefix:
4256:
1.31 wiz 4257: * CONF_FILES and REQD_FILES are pairs of master and target files. During
1.1 dsieger 4258: installation time, the master file is copied to the target one if and only
4259: if the latter does not exist. Upon deinstallation, the target file is
4260: removed provided that it was not modified by the installation.
4261:
4262: The difference between the two is that the latter prompts the administrator
4263: to remove any files that may be left after deinstallation (because they
4264: were not empty), while the former does not.
4265:
1.31 wiz 4266: * CONF_FILES_PERMS and REQD_FILES_PERMS contain tuples describing master
1.1 dsieger 4267: files as well as their target locations. For each of them, it also
4268: specifies their owner, their group and their numeric permissions, in this
4269: order. For example:
4270:
1.108 rillig 4271: REQD_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile \
4272: ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1 dsieger 4273:
4274: The difference between the two is exactly the same as their non-PERMS
4275: counterparts.
4276:
1.6 rillig 4277: 15.2. Configuration files
1.1 dsieger 4278:
4279: Configuration files are special in the sense that they are installed in their
4280: own specific directory, PKG_SYSCONFDIR, and need special treatment during
4281: installation (most of which is automated by pkginstall). The main concept you
4282: must bear in mind is that files marked as configuration files are automatically
4283: copied to the right place (somewhere inside PKG_SYSCONFDIR) during installation
4284: if and only if they didn't exist before. Similarly, they will not be removed if
4285: they have local modifications. This ensures that administrators never lose any
4286: custom changes they may have made.
4287:
1.6 rillig 4288: 15.2.1. How PKG_SYSCONFDIR is set
1.1 dsieger 4289:
4290: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
4291: shall be installed. Its contents are set based upon the following variables:
4292:
4293: * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
4294: etc although it may be overridden by the user to point to his preferred
4295: location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
4296:
4297: * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
4298: configuration files for the package being built shall be installed. The
4299: definition of this variable only makes sense in the package's Makefile
4300: (i.e., it is not user-customizable).
4301:
1.68 asau 4302: As an example, consider the Apache package, www/apache24, which places its
1.1 dsieger 4303: configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
4304: should be set in the package Makefile.
4305:
4306: * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
4307: package's configuration directory (if different from PKG_SYSCONFBASE). It
4308: defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
4309:
4310: * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
4311: configuration files for the package identified by PKG_SYSCONFVAR's shall be
4312: placed.
4313:
4314: Based on the above variables, pkginstall determines the value of
4315: PKG_SYSCONFDIR, which is the only variable that can be used within a package to
4316: refer to its configuration directory. The algorithm used to set its value is
4317: basically the following:
4318:
4319: 1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
4320:
4321: 2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
4322: package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
4323: {PKG_SYSCONFSUBDIR}.
4324:
4325: 3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
4326:
4327: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
1.16 jnemeth 4328: OWN_DIRS. See Section 15.1.1, "Directory manipulation" what this means. This
4329: does not apply to subdirectories of ${PKG_SYSCONFDIR}, they still have to be
4330: created with OWN_DIRS or MAKE_DIRS.
1.1 dsieger 4331:
1.6 rillig 4332: 15.2.2. Telling the software where configuration files are
1.1 dsieger 4333:
4334: Given that pkgsrc (and users!) expect configuration files to be in a known
4335: place, you need to teach each package where it shall install its files. In some
4336: cases you will have to patch the package Makefiles to achieve it. If you are
4337: lucky, though, it may be as easy as passing an extra flag to the configuration
4338: script; this is the case of GNU Autoconf- generated files:
4339:
4340: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
4341:
4342: Note that this specifies where the package has to look for its configuration
4343: files, not where they will be originally installed (although the difference is
4344: never explicit, unfortunately).
4345:
1.6 rillig 4346: 15.2.3. Patching installations
1.1 dsieger 4347:
4348: As said before, pkginstall automatically handles configuration files. This
4349: means that the packages themselves must not touch the contents of $
4350: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
4351: will, out of the box, mess with the contents of that directory. So what is the
4352: correct procedure to fix this issue?
4353:
4354: You must teach the package (usually by manually patching it) to install any
4355: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
4356: This way, the PLIST registers them and the administrator always has the
4357: original copies available.
4358:
4359: Once the required configuration files are in place (i.e., under the examples
4360: hierarchy), the pkginstall framework can use them as master copies during the
4361: package installation to update what is in ${PKG_SYSCONFDIR}. To achieve this,
4362: the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
1.6 rillig 4363: Section 15.1.2, "File manipulation" for information about their syntax and
1.1 dsieger 4364: their purpose. Here is an example, taken from the mail/mutt package:
4365:
4366: EGDIR= ${PREFIX}/share/doc/mutt/samples
4367: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
4368:
4369: Note that the EGDIR variable is specific to that package and has no meaning
4370: outside it.
4371:
1.6 rillig 4372: 15.2.4. Disabling handling of configuration files
1.1 dsieger 4373:
4374: The automatic copying of config files can be toggled by setting the environment
4375: variable PKG_CONFIG prior to package installation.
4376:
1.6 rillig 4377: 15.3. System startup scripts
1.1 dsieger 4378:
4379: System startup scripts are special files because they must be installed in a
4380: place known by the underlying OS, usually outside the installation prefix.
1.6 rillig 4381: Therefore, the same rules described in Section 15.1, "Files and directories
1.1 dsieger 4382: outside the installation prefix" apply, and the same solutions can be used.
4383: However, pkginstall provides a special mechanism to handle these files.
4384:
4385: In order to provide system startup scripts, the package has to:
4386:
4387: 1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
4388: Considering the print/cups package as an example, it has a cupsd.sh in its
4389: files directory.
4390:
4391: 2. Tell pkginstall to handle it, appending the name of the script, without its
4392: extension, to the RCD_SCRIPTS variable. Continuing the previous example:
4393:
4394: RCD_SCRIPTS+= cupsd
4395:
4396: Once this is done, pkginstall will do the following steps for each script in an
4397: automated fashion:
4398:
4399: 1. Process the file found in the files directory applying all the
4400: substitutions described in the FILES_SUBST variable.
4401:
4402: 2. Copy the script from the files directory to the examples hierarchy, $
4403: {PREFIX}/share/examples/rc.d/. Note that this master file must be
4404: explicitly registered in the PLIST.
4405:
4406: 3. Add code to the installation scripts to copy the startup script from the
4407: examples hierarchy into the system-wide startup scripts directory.
4408:
1.6 rillig 4409: 15.3.1. Disabling handling of system startup scripts
1.1 dsieger 4410:
4411: The automatic copying of config files can be toggled by setting the environment
4412: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
4413: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
4414: rc.d/, no matter what the value of this variable is.
4415:
1.6 rillig 4416: 15.4. System users and groups
1.1 dsieger 4417:
4418: If a package needs to create special users and/or groups during installation,
4419: it can do so by using the pkginstall framework.
4420:
4421: Users can be created by adding entries to the PKG_USERS variable. Each entry
4422: has the following syntax:
4423:
4424: user:group
4425:
4426: Further specification of user details may be done by setting per-user
4427: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
4428: user's description or comment. PKG_HOME.user is the user's home directory, and
4429: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
4430: and defaults to /sbin/nologin if not specified.
4431:
4432: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
4433: whose syntax is:
4434:
4435: group
4436:
4437: The numeric GID of the group may be set by defining PKG_GID.group.
4438:
4439: If a package needs to create the users and groups at an earlier stage, then it
1.116 wiz 4440: can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
4441: the phase before which the users and groups are created. In this case, the
4442: numeric UIDs and GIDs of the created users and groups are automatically
4443: hardcoded into the final installation scripts.
1.1 dsieger 4444:
1.6 rillig 4445: 15.5. System shells
1.1 dsieger 4446:
4447: Packages that install system shells should register them in the shell database,
4448: /etc/shells, to make things easier to the administrator. This must be done from
4449: the installation scripts to keep binary packages working on any system.
4450: pkginstall provides an easy way to accomplish this task.
4451:
4452: When a package provides a shell interpreter, it has to set the PKG_SHELL
4453: variable to its absolute file name. This will add some hooks to the
4454: installation scripts to handle it. Consider the following example, taken from
4455: shells/zsh:
4456:
4457: PKG_SHELL= ${PREFIX}/bin/zsh
4458:
1.6 rillig 4459: 15.5.1. Disabling shell registration
1.1 dsieger 4460:
4461: The automatic registration of shell interpreters can be disabled by the
4462: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
4463:
1.6 rillig 4464: 15.6. Fonts
1.1 dsieger 4465:
4466: Packages that install X11 fonts should update the database files that index the
4467: fonts within each fonts directory. This can easily be accomplished within the
4468: pkginstall framework.
4469:
4470: When a package installs X11 fonts, it must list the directories in which fonts
4471: are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
4472: "type1" or "x11". This will add hooks to the installation scripts to run the
4473: appropriate commands to update the fonts database files within each of those
4474: directories. For convenience, if the directory path is relative, it is taken to
4475: be relative to the package's installation prefix. Consider the following
4476: example, taken from fonts/dbz-ttf:
4477:
1.67 wiz 4478: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1 dsieger 4479:
1.6 rillig 4480: 15.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 4481:
4482: The automatic update of fonts databases can be disabled by the administrator by
4483: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
4484:
1.6 rillig 4485: Chapter 16. Options handling
1.1 dsieger 4486:
4487: Table of Contents
4488:
1.6 rillig 4489: 16.1. Global default options
4490: 16.2. Converting packages to use bsd.options.mk
4491: 16.3. Option Names
1.7 rillig 4492: 16.4. Determining the options of dependencies
1.1 dsieger 4493:
4494: Many packages have the ability to be built to support different sets of
4495: features. bsd.options.mk is a framework in pkgsrc that provides generic
4496: handling of those options that determine different ways in which the packages
4497: can be built. It's possible for the user to specify exactly which sets of
4498: options will be built into a package or to allow a set of global default
4499: options apply.
4500:
1.7 rillig 4501: There are two broad classes of behaviors that one might want to control via
4502: options. One is whether some particular feature is enabled in a program that
4503: will be built anyway, often by including or not including a dependency on some
4504: other package. The other is whether or not an additional program will be built
4505: as part of the package. Generally, it is better to make a split package for
4506: such additional programs instead of using options, because it enables binary
4507: packages to be built which can then be added separately. For example, the foo
4508: package might have minimal dependencies (those packages without which foo
4509: doesn't make sense), and then the foo-gfoo package might include the GTK
4510: frontend program gfoo. This is better than including a gtk option to foo that
4511: adds gfoo, because either that option is default, in which case binary users
4512: can't get foo without gfoo, or not default, in which case they can't get gfoo.
4513: With split packages, they can install foo without having GTK, and later decide
4514: to install gfoo (pulling in GTK at that time). This is an advantage to source
4515: users too, avoiding the need for rebuilds.
4516:
4517: Plugins with widely varying dependencies should usually be split instead of
4518: options.
4519:
4520: It is often more work to maintain split packages, especially if the upstream
4521: package does not support this. The decision of split vs. option should be made
4522: based on the likelihood that users will want or object to the various pieces,
4523: the size of the dependencies that are included, and the amount of work.
4524:
4525: A further consideration is licensing. Non-free parts, or parts that depend on
4526: non-free dependencies (especially plugins) should almost always be split if
4527: feasible.
4528:
1.6 rillig 4529: 16.1. Global default options
1.1 dsieger 4530:
4531: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
4532: the options that should be built into every package if that option is
1.4 rillig 4533: supported. This variable should be set in mk.conf.
1.1 dsieger 4534:
1.6 rillig 4535: 16.2. Converting packages to use bsd.options.mk
1.1 dsieger 4536:
4537: The following example shows how bsd.options.mk should be used by the
4538: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
4539: e.g. options.mk, that is included by the main package Makefile.
4540:
4541: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
4542: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
4543: PKG_OPTIONS_OPTIONAL_GROUPS= database
4544: PKG_OPTIONS_GROUP.database= mysql pgsql
4545: PKG_SUGGESTED_OPTIONS= wibble-foo
4546: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
4547: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
4548:
4549: .include "../../mk/bsd.prefs.mk"
4550:
4551: # this package was previously named wibble2
4552: .if defined(PKG_OPTIONS.wibble2)
4553: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
4554: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
4555: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
4556: .endif
4557:
4558: .include "../../mk/bsd.options.mk"
4559:
4560: # Package-specific option-handling
4561:
4562: ###
4563: ### FOO support
4564: ###
4565: .if !empty(PKG_OPTIONS:Mwibble-foo)
4566: CONFIGURE_ARGS+= --enable-foo
4567: .endif
4568:
4569: ###
4570: ### LDAP support
4571: ###
4572: .if !empty(PKG_OPTIONS:Mldap)
4573: . include "../../databases/openldap-client/buildlink3.mk"
4574: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
4575: .endif
4576:
4577: ###
4578: ### database support
4579: ###
4580: .if !empty(PKG_OPTIONS:Mmysql)
4581: . include "../../mk/mysql.buildlink3.mk"
4582: .endif
4583: .if !empty(PKG_OPTIONS:Mpgsql)
4584: . include "../../mk/pgsql.buildlink3.mk"
4585: .endif
4586:
4587: The first section contains the information about which build options are
4588: supported by the package, and any default options settings if needed.
4589:
4590: 1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
4591: to override the default options. It should be set to PKG_OPTIONS.pkgbase.
4592: Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
4593: the point where the options are processed.
4594:
4595: 2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
4596:
4597: 3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
4598: exclusive options. The options in each group are listed in
4599: PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
4600: the group takes precedence over all other options in the group. Options
4601: from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
4602:
4603: 4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
4604: building the packages will fail if no option from the group is selected.
4605:
4606: 5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
4607: one option from each set must be selected. The options in each set are
4608: listed in PKG_OPTIONS_SET.setname. Options from the sets will be
4609: automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
4610: fail if no option from the set is selected.
4611:
4612: 6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
4613: default.
4614:
4615: 7. PKG_OPTIONS_LEGACY_VARS is a list of "USE_VARIABLE:option" pairs that map
1.4 rillig 4616: legacy mk.conf variables to their option counterparts. Pairs should be
1.1 dsieger 4617: added with "+=" to keep the listing of global legacy variables. A warning
4618: will be issued if the user uses a legacy variable.
4619:
4620: 8. PKG_OPTIONS_LEGACY_OPTS is a list of "old-option:new-option" pairs that map
4621: options that have been renamed to their new counterparts. Pairs should be
4622: added with "+=" to keep the listing of global legacy options. A warning
4623: will be issued if the user uses a legacy option.
4624:
4625: 9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
4626: used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
4627: PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
4628:
4629: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
4630: variables or options used, and what to use instead.
4631:
4632: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
4633: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
4634: options, use PKG_SUGGESTED_OPTIONS.
4635:
4636: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
4637: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
4638: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
4639: options if none of them is supported on the current platform), PKG_OPTIONS is
4640: set to the empty list and the package is otherwise treated as not using the
4641: options framework.
4642:
4643: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
4644: list of selected build options, properly filtered to remove unsupported and
4645: duplicate options.
4646:
4647: The remaining sections contain the logic that is specific to each option. The
4648: correct way to check for an option is to check whether it is listed in
4649: PKG_OPTIONS:
4650:
4651: .if !empty(PKG_OPTIONS:Moption)
4652:
1.6 rillig 4653: 16.3. Option Names
1.1 dsieger 4654:
4655: Options that enable similar features in different packages (like optional
4656: support for a library) should use a common name in all packages that support it
4657: (like the name of the library). If another package already has an option with
4658: the same meaning, use the same name.
4659:
4660: Options that enable features specific to one package, where it's unlikely that
4661: another (unrelated) package has the same (or a similar) optional feature,
4662: should use a name prefixed with pkgname-.
4663:
4664: If a group of related packages share an optional feature specific to that
4665: group, prefix it with the name of the "main" package (e. g.
4666: djbware-errno-hack).
4667:
4668: For new options, add a line to mk/defaults/options.description. Lines have two
4669: fields, separated by tab. The first field is the option name, the second its
4670: description. The description should be a whole sentence (starting with an
4671: uppercase letter and ending with a period) that describes what enabling the
4672: option does. E. g. "Enable ispell support." The file is sorted by option names.
4673:
1.7 rillig 4674: 16.4. Determining the options of dependencies
4675:
4676: When writing buildlink3.mk files, it is often necessary to list different
4677: dependencies based on the options with which the package was built. For
4678: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
4679: A typical example looks like this:
4680:
4681: pkgbase := libpurple
4682: .include "../../mk/pkg-build-options.mk"
4683:
4684: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
4685: ...
4686: .endif
4687:
4688: Including pkg-build-options.mk here will set the variable
4689: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
4690: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
4691: pkg-build-options.mk for more details.
4692:
1.6 rillig 4693: Chapter 17. The build process
1.1 dsieger 4694:
4695: Table of Contents
4696:
1.6 rillig 4697: 17.1. Introduction
4698: 17.2. Program location
4699: 17.3. Directories used during the build process
4700: 17.4. Running a phase
4701: 17.5. The fetch phase
4702:
4703: 17.5.1. What to fetch and where to get it from
4704: 17.5.2. How are the files fetched?
4705:
4706: 17.6. The checksum phase
4707: 17.7. The extract phase
4708: 17.8. The patch phase
4709: 17.9. The tools phase
4710: 17.10. The wrapper phase
4711: 17.11. The configure phase
4712: 17.12. The build phase
4713: 17.13. The test phase
4714: 17.14. The install phase
4715: 17.15. The package phase
4716: 17.16. Cleaning up
4717: 17.17. Other helpful targets
1.1 dsieger 4718:
1.6 rillig 4719: 17.1. Introduction
1.1 dsieger 4720:
4721: This chapter gives a detailed description on how a package is built. Building a
4722: package is separated into different phases (for example fetch, build, install),
1.19 snj 4723: all of which are described in the following sections. Each phase is split into
4724: so-called stages, which take the name of the containing phase, prefixed by one
4725: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
4726: actual work is done in the do-* stages.
1.1 dsieger 4727:
4728: Never override the regular targets (like fetch), if you have to, override the
4729: do-* ones instead.
4730:
4731: The basic steps for building a program are always the same. First the program's
4732: source (distfile) must be brought to the local system and then extracted. After
4733: any pkgsrc-specific patches to compile properly are applied, the software can
4734: be configured, then built (usually by compiling), and finally the generated
4735: binaries, etc. can be put into place on the system.
4736:
4737: To get more details about what is happening at each step, you can set the
4738: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
4739: more details about the patch step.
4740:
1.6 rillig 4741: 17.2. Program location
1.1 dsieger 4742:
4743: Before outlining the process performed by the NetBSD package system in the next
4744: section, here's a brief discussion on where programs are installed, and which
4745: variables influence this.
4746:
4747: The automatic variable PREFIX indicates where all files of the final program
4748: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
4749: pkgs in the cross category. The value of PREFIX needs to be put into the
4750: various places in the program's source where paths to these files are encoded.
1.6 rillig 4751: See Section 11.3, "patches/*" and Section 19.3.1, "Shared libraries - libtool"
1.1 dsieger 4752: for more details.
4753:
4754: When choosing which of these variables to use, follow the following rules:
4755:
4756: * PREFIX always points to the location where the current pkg will be
1.25 wiz 4757: installed. When referring to a pkg's own installation path, use "${PREFIX}"
4758: .
1.1 dsieger 4759:
4760: * LOCALBASE is where all non-X11 pkgs are installed. If you need to construct
4761: a -I or -L argument to the compiler to find includes and libraries
4762: installed by another non-X11 pkg, use "${LOCALBASE}". The name LOCALBASE
4763: stems from FreeBSD, which installed all packages in /usr/local. As pkgsrc
4764: leaves /usr/local for the system administrator, this variable is a
4765: misnomer.
4766:
4767: * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
4768: installed. When looking for standard X11 includes (not those installed by a
4769: package), use "${X11BASE}".
4770:
1.99 sevan 4771: * X11-based packages using imake must set USE_IMAKE to be installed correctly
4772: under LOCALBASE.
1.1 dsieger 4773:
1.99 sevan 4774: * To determine the prefix of an installed package, the EVAL_PREFIX definition
4775: can be used. It takes pairs in the format "DIRNAME=<package>", and the make
4776: (1) variable DIRNAME will be set to the prefix of the installed package
4777: <package>, or "${PREFIX}" if the package is not installed.
1.1 dsieger 4778:
4779: This is best illustrated by example.
4780:
4781: The following lines are taken from pkgsrc/wm/scwm/Makefile:
4782:
4783: EVAL_PREFIX+= GTKDIR=gtk+
4784: CONFIGURE_ARGS+= --with-guile-prefix=${LOCALBASE:Q}
4785: CONFIGURE_ARGS+= --with-gtk-prefix=${GTKDIR:Q}
4786: CONFIGURE_ARGS+= --enable-multibyte
4787:
4788: Specific defaults can be defined for the packages evaluated using
4789: EVAL_PREFIX, by using a definition of the form:
4790:
4791: GTKDIR_DEFAULT= ${LOCALBASE}
4792:
4793: where GTKDIR corresponds to the first definition in the EVAL_PREFIX pair.
4794:
4795: * Within ${PREFIX}, packages should install files according to hier(7), with
4796: the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
4797: man.
4798:
1.6 rillig 4799: 17.3. Directories used during the build process
1.1 dsieger 4800:
1.14 jmcneill 4801: When building a package, various directories are used to store source files,
1.1 dsieger 4802: temporary files, pkgsrc-internal files, and so on. These directories are
4803: explained here.
4804:
4805: Some of the directory variables contain relative pathnames. There are two
4806: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
4807: used for directories that are pkgsrc-specific. WRKSRC is used for directories
4808: inside the package itself.
4809:
4810: PKGSRCDIR
4811:
4812: This is an absolute pathname that points to the pkgsrc root directory.
4813: Generally, you don't need it.
4814:
4815: PKGDIR
4816:
4817: This is an absolute pathname that points to the current package.
4818:
4819: PKGPATH
4820:
4821: This is a pathname relative to PKGSRCDIR that points to the current
4822: package.
4823:
4824: WRKDIR
4825:
4826: This is an absolute pathname pointing to the directory where all work takes
4827: place. The distfiles are extracted to this directory. It also contains
4828: temporary directories and log files used by the various pkgsrc frameworks,
4829: like buildlink or the wrappers.
4830:
4831: WRKSRC
4832:
4833: This is an absolute pathname pointing to the directory where the distfiles
4834: are extracted. It is usually a direct subdirectory of WRKDIR, and often
4835: it's the only directory entry that isn't hidden. This variable may be
4836: changed by a package Makefile.
4837:
1.14 jmcneill 4838: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
1.15 rillig 4839: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
1.14 jmcneill 4840: created in the pkgsrc entry's directory. If users would like to have their
4841: pkgsrc trees behave in a read-only manner, then the value of
4842: CREATE_WRKDIR_SYMLINK should be set to no.
4843:
1.6 rillig 4844: 17.4. Running a phase
1.1 dsieger 4845:
4846: You can run a particular phase by typing make phase, where phase is the name of
4847: the phase. This will automatically run all phases that are required for this
4848: phase. The default phase is build, that is, when you run make without
4849: parameters in a package directory, the package will be built, but not
4850: installed.
4851:
1.6 rillig 4852: 17.5. The fetch phase
1.1 dsieger 4853:
4854: The first step in building a package is to fetch the distribution files
1.25 wiz 4855: (distfiles) from the sites that are providing them. This is the task of the
1.1 dsieger 4856: fetch phase.
4857:
1.6 rillig 4858: 17.5.1. What to fetch and where to get it from
1.1 dsieger 4859:
4860: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
4861: name is derived from the DISTNAME variable, is fetched. The more complicated
4862: cases are described below.
4863:
4864: The variable DISTFILES specifies the list of distfiles that have to be fetched.
1.66 asau 4865: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
4866: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
4867: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
4868: your package requires additional distfiles to the default one, you cannot just
4869: append the additional filenames using the += operator, but you have write for
4870: example:
1.1 dsieger 4871:
1.66 asau 4872: DISTFILES= ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1 dsieger 4873:
4874: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
4875: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
4876: can set SITES.distfile to the list of URLs where the file distfile (including
4877: the suffix) can be found.
4878:
4879: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
4880: DISTFILES+= foo-file.tar.gz
4881: SITES.foo-file.tar.gz= \
4882: http://www.somewhere.com/somehow/ \
4883: http://www.somewhereelse.com/mirror/somehow/
4884:
4885: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
4886: gets the name of each distfile appended to it, without an intermediate slash.
4887: Therefore, all site values have to end with a slash or other separator
4888: character. This allows for example to set MASTER_SITES to a URL of a CGI script
4889: that gets the name of the distfile as a parameter. In this case, the definition
4890: would look like:
4891:
4892: MASTER_SITES= http://www.example.com/download.cgi?file=
4893:
1.23 jakllsch 4894: The exception to this rule are URLs starting with a dash. In that case the URL
4895: is taken as is, fetched and the result stored under the name of the distfile.
1.66 asau 4896: You can use this style for the case when the download URL style does not match
4897: the above common case. For example, if permanent download URL is a redirector
4898: to the real download URL, or the download file name is offered by an HTTP
4899: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
4900: created instead of the default v1.0.0.tar.gz.
4901:
4902: DISTNAME= foo-1.0.0
4903: MASTER_SITES= -http://www.example.com/archive/v1.0.0.tar.gz
1.23 jakllsch 4904:
1.1 dsieger 4905: There are some predefined values for MASTER_SITES, which can be used in
4906: packages. The names of the variables should speak for themselves.
4907:
4908: ${MASTER_SITE_APACHE}
4909: ${MASTER_SITE_BACKUP}
4910: ${MASTER_SITE_CYGWIN}
4911: ${MASTER_SITE_DEBIAN}
4912: ${MASTER_SITE_FREEBSD}
4913: ${MASTER_SITE_FREEBSD_LOCAL}
4914: ${MASTER_SITE_GENTOO}
4915: ${MASTER_SITE_GNOME}
4916: ${MASTER_SITE_GNU}
4917: ${MASTER_SITE_GNUSTEP}
1.66 asau 4918: ${MASTER_SITE_HASKELL_HACKAGE}
1.1 dsieger 4919: ${MASTER_SITE_IFARCHIVE}
4920: ${MASTER_SITE_KDE}
4921: ${MASTER_SITE_MOZILLA}
1.66 asau 4922: ${MASTER_SITE_MOZILLA_ALL}
4923: ${MASTER_SITE_MOZILLA_ESR}
1.1 dsieger 4924: ${MASTER_SITE_MYSQL}
1.66 asau 4925: ${MASTER_SITE_NETLIB}
1.1 dsieger 4926: ${MASTER_SITE_OPENOFFICE}
1.98 ryoon 4927: ${MASTER_SITE_OSDN}
1.1 dsieger 4928: ${MASTER_SITE_PERL_CPAN}
4929: ${MASTER_SITE_PGSQL}
1.66 asau 4930: ${MASTER_SITE_RUBYGEMS}
1.1 dsieger 4931: ${MASTER_SITE_R_CRAN}
4932: ${MASTER_SITE_SOURCEFORGE}
4933: ${MASTER_SITE_SUNSITE}
4934: ${MASTER_SITE_SUSE}
4935: ${MASTER_SITE_TEX_CTAN}
4936: ${MASTER_SITE_XCONTRIB}
4937: ${MASTER_SITE_XEMACS}
1.66 asau 4938: ${MASTER_SITE_XORG}
1.1 dsieger 4939:
4940: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
4941: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
1.27 wiz 4942: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
1.26 spz 4943: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
4944: distfiles/LOCAL_PORTS/.
1.1 dsieger 4945:
4946: If you choose one of these predefined sites, you may want to specify a
4947: subdirectory of that site. Since these macros may expand to more than one
4948: actual site, you must use the following construct to specify a subdirectory:
4949:
4950: MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/}
4951: MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/}
4952:
4953: Note the trailing slash after the subdirectory name.
4954:
1.6 rillig 4955: 17.5.2. How are the files fetched?
1.1 dsieger 4956:
4957: The fetch phase makes sure that all the distfiles exist in a local directory
4958: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
4959: are fetched using commands of the form
4960:
4961: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
4962:
4963: where ${site} varies through several possibilities in turn: first,
4964: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
4965: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
4966: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
4967: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
4968: MASTER_SORT_AWK or MASTER_SORT_REGEX.
4969:
1.16 jnemeth 4970: The specific command and arguments used depend on the FETCH_USING parameter.
4971: The example above is for FETCH_USING=custom.
4972:
1.1 dsieger 4973: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
4974: target to mirror the distfiles, if they are freely distributable. Packages
4975: setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
4976: distfiles mirrored.
4977:
1.6 rillig 4978: 17.6. The checksum phase
1.1 dsieger 4979:
4980: After the distfile(s) are fetched, their checksum is generated and compared
4981: with the checksums stored in the distinfo file. If the checksums don't match,
4982: the build is aborted. This is to ensure the same distfile is used for building,
4983: and that the distfile wasn't changed, e.g. by some malign force, deliberately
4984: changed distfiles on the master distribution site or network lossage.
4985:
1.6 rillig 4986: 17.7. The extract phase
1.1 dsieger 4987:
4988: When the distfiles are present on the local system, they need to be extracted,
4989: as they usually come in the form of some compressed archive format.
4990:
4991: By default, all DISTFILES are extracted. If you only need some of them, you can
4992: set the EXTRACT_ONLY variable to the list of those files.
4993:
4994: Extracting the files is usually done by a little program, mk/extract/extract,
4995: which already knows how to extract various archive formats, so most likely you
4996: will not need to change anything here. But if you need, the following variables
4997: may help you:
4998:
4999: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
5000:
5001: Use these variables to override the default options for an extract command,
5002: which are defined in mk/extract/extract.
5003:
5004: EXTRACT_USING
5005:
1.14 jmcneill 5006: This variable can be set to bsdtar, gtar, nbtar (which is the default
5007: value), pax, or an absolute pathname pointing to the command with which tar
5008: archives should be extracted. It is preferred to choose bsdtar over gtar if
5009: NetBSD's pax-as-tar is not good enough.
1.1 dsieger 5010:
5011: If the extract program doesn't serve your needs, you can also override the
5012: EXTRACT_CMD variable, which holds the command used for extracting the files.
5013: This command is executed in the ${WRKSRC} directory. During execution of this
5014: command, the shell variable extract_file holds the absolute pathname of the
5015: file that is going to be extracted.
5016:
5017: And if that still does not suffice, you can override the do-extract target in
5018: the package Makefile.
5019:
1.6 rillig 5020: 17.8. The patch phase
1.1 dsieger 5021:
5022: After extraction, all the patches named by the PATCHFILES, those present in the
5023: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
5024: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
5025: are uncompressed before they are applied, files ending in .orig or .rej are
5026: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
1.6 rillig 5027: Section 11.3, "patches/*" for more details.
1.1 dsieger 5028:
5029: By default patch(1) is given special args to make it fail if the patches apply
5030: with some lines of fuzz. Please fix (regen) the patches so that they apply
5031: cleanly. The rationale behind this is that patches that don't apply cleanly may
5032: end up being applied in the wrong place, and cause severe harm there.
5033:
1.6 rillig 5034: 17.9. The tools phase
1.1 dsieger 5035:
1.6 rillig 5036: This is covered in Chapter 18, Tools needed for building or running.
1.1 dsieger 5037:
1.6 rillig 5038: 17.10. The wrapper phase
1.1 dsieger 5039:
5040: This phase creates wrapper programs for the compilers and linkers. The
5041: following variables can be used to tweak the wrappers.
5042:
5043: ECHO_WRAPPER_MSG
5044:
5045: The command used to print progress messages. Does nothing by default. Set
5046: to ${ECHO} to see the progress messages.
5047:
5048: WRAPPER_DEBUG
5049:
5050: This variable can be set to yes (default) or no, depending on whether you
5051: want additional information in the wrapper log file.
5052:
5053: WRAPPER_UPDATE_CACHE
5054:
5055: This variable can be set to yes or no, depending on whether the wrapper
5056: should use its cache, which will improve the speed. The default value is
5057: yes, but is forced to no if the platform does not support it.
5058:
5059: WRAPPER_REORDER_CMDS
5060:
5061: A list of reordering commands. A reordering command has the form reorder:l:
5062: lib1:lib2. It ensures that that -llib1 occurs before -llib2.
5063:
5064: WRAPPER_TRANSFORM_CMDS
5065:
5066: A list of transformation commands. [TODO: investigate further]
5067:
1.6 rillig 5068: 17.11. The configure phase
1.1 dsieger 5069:
5070: Most pieces of software need information on the header files, system calls, and
5071: library routines which are available on the platform they run on. The process
5072: of determining this information is known as configuration, and is usually
5073: automated. In most cases, a script is supplied with the distfiles, and its
5074: invocation results in generation of header files, Makefiles, etc.
5075:
5076: If the package contains a configure script, this can be invoked by setting
5077: HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
5078: should set GNU_CONFIGURE to "yes" instead. What happens in the configure phase
5079: is roughly:
5080:
5081: .for d in ${CONFIGURE_DIRS}
5082: cd ${WRKSRC} \
5083: && cd ${d} \
5084: && env ${CONFIGURE_ENV} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
5085: .endfor
5086:
5087: CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
5088: each of these directories, the configure script is run with the environment
5089: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
5090: CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
5091: by the package.
5092:
1.38 wiz 5093: If the program uses the Perl way of configuration (mainly Perl modules, but not
5094: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
5095: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
5096: (e.g., MAKE_PARAMS+=foo=bar
5097:
1.1 dsieger 5098: If the program uses an Imakefile for configuration, the appropriate steps can
1.99 sevan 5099: be invoked by setting USE_IMAKE to "yes". If you only need xmkmf, add it to
5100: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
5101: SCRIPTS_ENV variable.
1.1 dsieger 5102:
1.11 rillig 5103: If the program uses cmake for configuration, the appropriate steps can be
5104: invoked by setting USE_CMAKE to "yes". You can add variables to cmake's
5105: environment by adding them to the CONFIGURE_ENV variable and arguments to cmake
5106: by adding them to the CMAKE_ARGS variable. The top directory argument is given
5107: by the CMAKE_ARG_PATH variable, that defaults to "." (relative to
5108: CONFIGURE_DIRS)
5109:
1.1 dsieger 5110: If there is no configure step at all, set NO_CONFIGURE to "yes".
5111:
1.6 rillig 5112: 17.12. The build phase
1.1 dsieger 5113:
5114: For building a package, a rough equivalent of the following code is executed.
5115:
5116: .for d in ${BUILD_DIRS}
5117: cd ${WRKSRC} \
5118: && cd ${d} \
5119: && env ${MAKE_ENV} \
5120: ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
5121: -f ${MAKE_FILE} \
5122: ${BUILD_TARGET}
5123: .endfor
5124:
5125: BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
5126: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
5127: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
5128: and BUILD_TARGET may all be changed by the package.
5129:
1.25 wiz 5130: The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
5131: make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
5132: defaults to "all".
1.1 dsieger 5133:
5134: If there is no build step at all, set NO_BUILD to "yes".
5135:
1.6 rillig 5136: 17.13. The test phase
1.1 dsieger 5137:
5138: [TODO]
5139:
1.6 rillig 5140: 17.14. The install phase
1.1 dsieger 5141:
5142: Once the build stage has completed, the final step is to install the software
5143: in public directories, so users can access the programs and files.
5144:
5145: In the install phase, a rough equivalent of the following code is executed.
5146: Additionally, before and after this code, much magic is performed to do
5147: consistency checks, registering the package, and so on.
5148:
5149: .for d in ${INSTALL_DIRS}
5150: cd ${WRKSRC} \
5151: && cd ${d} \
5152: && env ${MAKE_ENV} \
5153: ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
5154: -f ${MAKE_FILE} \
5155: ${INSTALL_TARGET}
5156: .endfor
5157:
5158: The variable's meanings are analogous to the ones in the build phase.
5159: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
5160: plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
5161: defined.
5162:
5163: In the install phase, the following variables are useful. They are all
5164: variations of the install(1) command that have the owner, group and permissions
5165: preset. INSTALL is the plain install command. The specialized variants,
5166: together with their intended use, are:
5167:
5168: INSTALL_PROGRAM_DIR
5169:
5170: directories that contain binaries
5171:
5172: INSTALL_SCRIPT_DIR
5173:
5174: directories that contain scripts
5175:
5176: INSTALL_LIB_DIR
5177:
5178: directories that contain shared and static libraries
5179:
5180: INSTALL_DATA_DIR
5181:
5182: directories that contain data files
5183:
5184: INSTALL_MAN_DIR
5185:
5186: directories that contain man pages
5187:
1.100 leot 5188: INSTALL_GAME_DIR
5189:
5190: directories that contain data files for games
5191:
1.1 dsieger 5192: INSTALL_PROGRAM
5193:
5194: binaries that can be stripped from debugging symbols
5195:
5196: INSTALL_SCRIPT
5197:
5198: binaries that cannot be stripped
5199:
5200: INSTALL_GAME
5201:
5202: game binaries
5203:
5204: INSTALL_LIB
5205:
5206: shared and static libraries
5207:
5208: INSTALL_DATA
5209:
5210: data files
5211:
5212: INSTALL_GAME_DATA
5213:
5214: data files for games
5215:
5216: INSTALL_MAN
5217:
5218: man pages
5219:
5220: Some other variables are:
5221:
1.106 tnn 5222: INSTALL_UNSTRIPPED
5223:
5224: If set to yes, do not run strip(1) when installing binaries. Any debugging
5225: sections and symbols present in binaries will be preserved.
5226:
1.1 dsieger 5227: INSTALLATION_DIRS
5228:
5229: A list of directories relative to PREFIX that are created by pkgsrc at the
5230: beginning of the install phase. The package is supposed to create all
5231: needed directories itself before installing files to it and list all other
5232: directories here.
5233:
1.25 wiz 5234: In the rare cases that a package shouldn't install anything, set NO_INSTALL to
1.1 dsieger 5235: "yes". This is mostly relevant for packages in the regress category.
5236:
1.6 rillig 5237: 17.15. The package phase
1.1 dsieger 5238:
5239: Once the install stage has completed, a binary package of the installed files
5240: can be built. These binary packages can be used for quick installation without
5241: previous compilation, e.g. by the make bin-install or by using pkg_add.
5242:
5243: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
5244: created in ${PACKAGES}/category, one for each category in the CATEGORIES
5245: variable. PACKAGES defaults to pkgsrc/packages.
5246:
1.6 rillig 5247: 17.16. Cleaning up
1.1 dsieger 5248:
5249: Once you're finished with a package, you can clean the work directory by
5250: running make clean. If you want to clean the work directories of all
5251: dependencies too, use make clean-depends.
5252:
1.6 rillig 5253: 17.17. Other helpful targets
1.1 dsieger 5254:
5255: pre/post-*
5256:
5257: For any of the main targets described in the previous section, two
5258: auxiliary targets exist with "pre-" and "post-" used as a prefix for the
5259: main target's name. These targets are invoked before and after the main
5260: target is called, allowing extra configuration or installation steps be
5261: performed from a package's Makefile, for example, which a program's
5262: configure script or install target omitted.
5263:
5264: do-*
5265:
5266: Should one of the main targets do the wrong thing, and should there be no
5267: variable to fix this, you can redefine it with the do-* target. (Note that
5268: redefining the target itself instead of the do-* target is a bad idea, as
5269: the pre-* and post-* targets won't be called anymore, etc.) You will not
5270: usually need to do this.
5271:
5272: reinstall
5273:
5274: If you did a make install and you noticed some file was not installed
5275: properly, you can repeat the installation with this target, which will
5276: ignore the "already installed" flag.
5277:
5278: This is the default value of DEPENDS_TARGET except in the case of make
5279: update and make package, where the defaults are "package" and "update",
5280: respectively.
5281:
5282: deinstall
5283:
5284: This target does a pkg_delete(1) in the current directory, effectively
5285: de-installing the package. The following variables can be used to tune the
5286: behaviour:
5287:
5288: PKG_VERBOSE
5289:
5290: Add a "-v" to the pkg_delete(1) command.
5291:
5292: DEINSTALLDEPENDS
5293:
5294: Remove all packages that require (depend on) the given package. This
5295: can be used to remove any packages that may have been pulled in by a
5296: given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
1.25 wiz 5297: pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
5298: " to the pkg_delete(1) command line.
1.1 dsieger 5299:
5300: bin-install
5301:
5302: Install a binary package from local disk and via FTP from a list of sites
5303: (see the BINPKG_SITES variable), and do a make package if no binary package
5304: is available anywhere. The arguments given to pkg_add can be set via
5305: BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
5306:
1.95 wiz 5307: install-clean
5308:
5309: This target removes the state files for the "install" and later phases so
5310: that the "install" target may be re-invoked. This can be used after editing
5311: the PLIST to install the package without rebuilding it.
5312:
5313: build-clean
5314:
5315: This target removes the state files for the "build" and later phases so
5316: that the "build" target may be re-invoked.
5317:
1.1 dsieger 5318: update
5319:
5320: This target causes the current package to be updated to the latest version.
5321: The package and all depending packages first get de-installed, then current
5322: versions of the corresponding packages get compiled and installed. This is
5323: similar to manually noting which packages are currently installed, then
5324: performing a series of make deinstall and make install (or whatever
5325: UPDATE_TARGET is set to) for these packages.
5326:
5327: You can use the "update" target to resume package updating in case a
5328: previous make update was interrupted for some reason. However, in this
5329: case, make sure you don't call make clean or otherwise remove the list of
5330: dependent packages in WRKDIR. Otherwise, you lose the ability to
5331: automatically update the current package along with the dependent packages
5332: you have installed.
5333:
5334: Resuming an interrupted make update will only work as long as the package
5335: tree remains unchanged. If the source code for one of the packages to be
5336: updated has been changed, resuming make update will most certainly fail!
5337:
1.4 rillig 5338: The following variables can be used either on the command line or in
1.1 dsieger 5339: mk.conf to alter the behaviour of make update:
5340:
5341: UPDATE_TARGET
5342:
5343: Install target to recursively use for the updated package and the
5344: dependent packages. Defaults to DEPENDS_TARGET if set, "install"
1.25 wiz 5345: otherwise for make update. Other good targets are "package" or "
5346: bin-install". Do not set this to "update" or you will get stuck in an
1.1 dsieger 5347: endless loop!
5348:
5349: NOCLEAN
5350:
5351: Don't clean up after updating. Useful if you want to leave the work
5352: sources of the updated packages around for inspection or other
1.25 wiz 5353: purposes. Be sure you eventually clean up the source tree (see the "
5354: clean-update" target below) or you may run into troubles with old
1.1 dsieger 5355: source code still lying around on your next make or make update.
5356:
5357: REINSTALL
5358:
5359: Deinstall each package before installing (making DEPENDS_TARGET). This
5360: may be necessary if the "clean-update" target (see below) was called
5361: after interrupting a running make update.
5362:
5363: DEPENDS_TARGET
5364:
5365: Allows you to disable recursion and hardcode the target for packages.
5366: The default is "update" for the update target, facilitating a recursive
5367: update of prerequisite packages. Only set DEPENDS_TARGET if you want to
5368: disable recursive updates. Use UPDATE_TARGET instead to just set a
5369: specific target for each package to be installed during make update
5370: (see above).
5371:
5372: clean-update
5373:
5374: Clean the source tree for all packages that would get updated if make
5375: update was called from the current directory. This target should not be
5376: used if the current package (or any of its depending packages) have already
5377: been de-installed (e.g., after calling make update) or you may lose some
1.25 wiz 5378: packages you intended to update. As a rule of thumb: only use this target
1.1 dsieger 5379: before the first time you run make update and only if you have a dirty
5380: package tree (e.g., if you used NOCLEAN).
5381:
5382: If you are unsure about whether your tree is clean, you can either perform
5383: a make clean at the top of the tree, or use the following sequence of
5384: commands from the directory of the package you want to update (before
5385: running make update for the first time, otherwise you lose all the packages
5386: you wanted to update!):
5387:
5388: # make clean-update
5389: # make clean CLEANDEPENDS=YES
5390: # make update
5391:
5392:
1.4 rillig 5393: The following variables can be used either on the command line or in
1.1 dsieger 5394: mk.conf to alter the behaviour of make clean-update:
5395:
5396: CLEAR_DIRLIST
5397:
5398: After make clean, do not reconstruct the list of directories to update
5399: for this package. Only use this if make update successfully installed
5400: all packages you wanted to update. Normally, this is done automatically
5401: on make update, but may have been suppressed by the NOCLEAN variable
5402: (see above).
5403:
5404: replace
5405:
5406: Update the installation of the current package. This differs from update in
5407: that it does not replace dependent packages. You will need to install
5408: pkgtools/pkg_tarup for this target to work.
5409:
5410: Be careful when using this target! There are no guarantees that dependent
5411: packages will still work, in particular they will most certainly break if
5412: you make replace a library package whose shared library major version
5413: changed between your installed version and the new one. For this reason,
5414: this target is not officially supported and only recommended for advanced
5415: users.
5416:
5417: info
5418:
5419: This target invokes pkg_info(1) for the current package. You can use this
5420: to check which version of a package is installed.
5421:
5422: index
5423:
5424: This is a top-level command, i.e. it should be used in the pkgsrc
5425: directory. It creates a database of all packages in the local pkgsrc tree,
5426: including dependencies, comment, maintainer, and some other useful
5427: information. Individual entries are created by running make describe in the
5428: packages' directories. This index file is saved as pkgsrc/INDEX. It can be
5429: displayed in verbose format by running make print-index. You can search in
5430: it with make search key=something. You can extract a list of all packages
5431: that depend on a particular one by running make show-deps PKG=somepackage.
5432:
5433: Running this command takes a very long time, some hours even on fast
5434: machines!
5435:
5436: readme
5437:
5438: This target generates a README.html file, which can be viewed using a
5439: browser such as www/firefox or www/links. The generated files contain
5440: references to any packages which are in the PACKAGES directory on the local
5441: host. The generated files can be made to refer to URLs based on
5442: FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
5443: README.html files which pointed to binary packages on the local machine, in
5444: the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
5445: FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
5446: subdirectories will be searched for all the binary packages.
5447:
5448: The target can be run at the toplevel or in category directories, in which
5449: case it descends recursively.
5450:
5451: readme-all
5452:
5453: This is a top-level command, run it in pkgsrc. Use this target to create a
5454: file README-all.html which contains a list of all packages currently
5455: available in the NetBSD Packages Collection, together with the category
5456: they belong to and a short description. This file is compiled from the
5457: pkgsrc/*/README.html files, so be sure to run this after a make readme.
5458:
5459: cdrom-readme
5460:
5461: This is very much the same as the "readme" target (see above), but is to be
5462: used when generating a pkgsrc tree to be written to a CD-ROM. This target
5463: also produces README.html files, and can be made to refer to URLs based on
5464: CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
5465:
5466: show-distfiles
5467:
5468: This target shows which distfiles and patchfiles are needed to build the
5469: package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
5470: patches/*).
5471:
5472: show-downlevel
5473:
5474: This target shows nothing if the package is not installed. If a version of
5475: this package is installed, but is not the version provided in this version
5476: of pkgsrc, then a warning message is displayed. This target can be used to
5477: show which of your installed packages are downlevel, and so the old
5478: versions can be deleted, and the current ones added.
5479:
5480: show-pkgsrc-dir
5481:
5482: This target shows the directory in the pkgsrc hierarchy from which the
5483: package can be built and installed. This may not be the same directory as
5484: the one from which the package was installed. This target is intended to be
5485: used by people who may wish to upgrade many packages on a single host, and
1.25 wiz 5486: can be invoked from the top-level pkgsrc Makefile by using the "
5487: show-host-specific-pkgs" target.
1.1 dsieger 5488:
5489: show-installed-depends
5490:
5491: This target shows which installed packages match the current package's
5492: DEPENDS. Useful if out of date dependencies are causing build problems.
5493:
1.95 wiz 5494: print-build-depends-list
5495:
5496: This target shows the list of packages that the current package depends on
5497: for building.
5498:
5499: print-run-depends-list
5500:
5501: This target shows the list of packages that the current package depends on
5502: for running.
5503:
1.1 dsieger 5504: check-shlibs
5505:
5506: After a package is installed, check all its binaries and (on ELF platforms)
5507: shared libraries to see if they find the shared libs they need. Run by
1.4 rillig 5508: default if PKG_DEVELOPER is set in mk.conf.
1.1 dsieger 5509:
5510: print-PLIST
5511:
5512: After a "make install" from a new or upgraded pkg, this prints out an
5513: attempt to generate a new PLIST from a find -newer work/.extract_done. An
5514: attempt is made to care for shared libs etc., but it is strongly
5515: recommended to review the result before putting it into PLIST. On upgrades,
5516: it's useful to diff the output of this command against an already existing
5517: PLIST file.
5518:
5519: If the package installs files via tar(1) or other methods that don't update
5520: file access times, be sure to add these files manually to your PLIST, as
5521: the "find -newer" command used by this target won't catch them!
5522:
1.6 rillig 5523: See Section 13.3, "Tweaking output of make print-PLIST" for more
1.1 dsieger 5524: information on this target.
5525:
5526: bulk-package
5527:
5528: Used to do bulk builds. If an appropriate binary package already exists, no
5529: action is taken. If not, this target will compile, install and package it
1.66 asau 5530: (and its depends, if PKG_DEPENDS is set properly. See Chapter 7, Creating
5531: binary packages for everything in pkgsrc (bulk builds)). After creating the
5532: binary package, the sources, the just-installed package and its required
5533: packages are removed, preserving free disk space.
1.1 dsieger 5534:
5535: Beware that this target may deinstall all packages installed on a system!
5536:
5537: bulk-install
5538:
5539: Used during bulk-installs to install required packages. If an up-to-date
1.25 wiz 5540: binary package is available, it will be installed via pkg_add(1). If not,
1.1 dsieger 5541: make bulk-package will be executed, but the installed binary won't be
5542: removed.
5543:
5544: A binary package is considered "up-to-date" to be installed via pkg_add(1)
5545: if:
5546:
1.42 asau 5547: + None of the package's files (Makefile, ...) were modified since it was
1.1 dsieger 5548: built.
5549:
1.42 asau 5550: + None of the package's required (binary) packages were modified since it
1.1 dsieger 5551: was built.
5552:
5553: Beware that this target may deinstall all packages installed on a system!
5554:
1.6 rillig 5555: Chapter 18. Tools needed for building or running
1.1 dsieger 5556:
5557: Table of Contents
5558:
1.6 rillig 5559: 18.1. Tools for pkgsrc builds
5560: 18.2. Tools needed by packages
5561: 18.3. Tools provided by platforms
1.1 dsieger 5562:
5563: The USE_TOOLS definition is used both internally by pkgsrc and also for
5564: individual packages to define what commands are needed for building a package
5565: (like BUILD_DEPENDS) or for later run-time of an installed packaged (such as
5566: DEPENDS). If the native system provides an adequate tool, then in many cases, a
5567: pkgsrc package will not be used.
5568:
5569: When building a package, the replacement tools are made available in a
5570: directory (as symlinks or wrapper scripts) that is early in the executable
5571: search path. Just like the buildlink system, this helps with consistent builds.
5572:
5573: A tool may be needed to help build a specific package. For example, perl, GNU
5574: make (gmake) or yacc may be needed.
5575:
5576: Also a tool may be needed, for example, because the native system's supplied
5577: tool may be inefficient for building a package with pkgsrc. For example, a
5578: package may need GNU awk, bison (instead of yacc) or a better sed.
5579:
5580: The tools used by a package can be listed by running make show-tools.
5581:
1.6 rillig 5582: 18.1. Tools for pkgsrc builds
1.1 dsieger 5583:
5584: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
5585: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
5586: seen by running: make show-var VARNAME=USE_TOOLS.
5587:
5588: If a package needs a specific program to build then the USE_TOOLS variable can
5589: be used to define the tools needed.
5590:
1.6 rillig 5591: 18.2. Tools needed by packages
1.1 dsieger 5592:
1.29 wiz 5593: In the following examples, the :run means that it is needed at run-time (and
5594: becomes a DEPENDS). The default is a build dependency which can be set with
5595: :build. (So in this example, it is the same as gmake:build and
5596: pkg-config:build.)
1.1 dsieger 5597:
5598: USE_TOOLS+= gmake perl:run pkg-config
5599:
5600: When using the tools framework, a TOOLS_PATH.foo variable is defined which
5601: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
5602: could be "/bin/bash" on Linux systems.
5603:
5604: If you always need a pkgsrc version of the tool at run-time, then just use
5605: DEPENDS instead.
5606:
1.6 rillig 5607: 18.3. Tools provided by platforms
1.1 dsieger 5608:
5609: When improving or porting pkgsrc to a new platform, have a look at (or create)
5610: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
5611: tools.${OPSYS}.mk which defines the name of the common tools. For example:
5612:
5613: .if exists(/usr/bin/bzcat)
5614: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
5615: .elif exists(/usr/bin/bzip2)
5616: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
5617: .endif
5618:
5619: TOOLS_PLATFORM.true?= true # shell builtin
5620:
1.6 rillig 5621: Chapter 19. Making your package work
1.1 dsieger 5622:
5623: Table of Contents
5624:
1.6 rillig 5625: 19.1. General operation
1.1 dsieger 5626:
1.108 rillig 5627: 19.1.1. How to pull in user-settable variables from mk.conf
5628: 19.1.2. User interaction
5629: 19.1.3. Handling licenses
5630: 19.1.4. Restricted packages
5631: 19.1.5. Handling dependencies
5632: 19.1.6. Handling conflicts with other packages
5633: 19.1.7. Packages that cannot or should not be built
5634: 19.1.8. Packages which should not be deleted, once installed
5635: 19.1.9. Handling packages with security problems
5636: 19.1.10. How to handle incrementing versions when fixing an existing
1.1 dsieger 5637: package
1.108 rillig 5638: 19.1.11. Substituting variable text in the package files (the SUBST
1.1 dsieger 5639: framework)
5640:
1.108 rillig 5641: 19.2. The fetch phase
1.1 dsieger 5642:
1.6 rillig 5643: 19.2.1. Packages whose distfiles aren't available for plain downloading
5644: 19.2.2. How to handle modified distfiles with the 'old' name
1.88 tnn 5645: 19.2.3. Packages hosted on github.com
1.1 dsieger 5646:
1.108 rillig 5647: 19.3. The configure phase
1.1 dsieger 5648:
1.6 rillig 5649: 19.3.1. Shared libraries - libtool
5650: 19.3.2. Using libtool on GNU packages that already support libtool
5651: 19.3.3. GNU Autoconf/Automake
5652:
5653: 19.4. Programming languages
5654:
5655: 19.4.1. C, C++, and Fortran
5656: 19.4.2. Java
5657: 19.4.3. Packages containing perl scripts
1.41 wiz 5658: 19.4.4. Packages containing shell scripts
5659: 19.4.5. Other programming languages
1.6 rillig 5660:
1.108 rillig 5661: 19.5. The build phase
1.6 rillig 5662:
5663: 19.5.1. Compiling C and C++ code conditionally
5664: 19.5.2. How to handle compiler bugs
1.24 wiz 5665: 19.5.3. Undefined reference to "..."
1.6 rillig 5666: 19.5.4. Running out of memory
5667:
1.108 rillig 5668: 19.6. The install phase
1.6 rillig 5669:
5670: 19.6.1. Creating needed directories
5671: 19.6.2. Where to install documentation
5672: 19.6.3. Installing highscore files
5673: 19.6.4. Adding DESTDIR support to packages
5674: 19.6.5. Packages with hardcoded paths to other interpreters
5675: 19.6.6. Packages installing perl modules
5676: 19.6.7. Packages installing info files
5677: 19.6.8. Packages installing man pages
1.7 rillig 5678: 19.6.9. Packages installing GConf data files
1.18 mishka 5679: 19.6.10. Packages installing scrollkeeper/rarian data files
1.6 rillig 5680: 19.6.11. Packages installing X11 fonts
5681: 19.6.12. Packages installing GTK2 modules
5682: 19.6.13. Packages installing SGML or XML data
5683: 19.6.14. Packages installing extensions to the MIME database
5684: 19.6.15. Packages using intltool
5685: 19.6.16. Packages installing startup scripts
5686: 19.6.17. Packages installing TeX modules
5687: 19.6.18. Packages supporting running binaries in emulation
5688: 19.6.19. Packages installing hicolor theme icons
5689: 19.6.20. Packages installing desktop files
1.1 dsieger 5690:
1.6 rillig 5691: 19.7. Marking packages as having problems
1.1 dsieger 5692:
1.6 rillig 5693: 19.1. General operation
1.1 dsieger 5694:
5695: One appealing feature of pkgsrc is that it runs on many different platforms. As
5696: a result, it is important to ensure, where possible, that packages in pkgsrc
5697: are portable. This chapter mentions some particular details you should pay
5698: attention to while working on pkgsrc.
5699:
1.108 rillig 5700: 19.1.1. How to pull in user-settable variables from mk.conf
1.1 dsieger 5701:
5702: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4 rillig 5703: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
5704: those variables in the preprocessor directives of make(1) (for example .if or
5705: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
5706: loads the user preferences.
1.1 dsieger 5707:
5708: But note that some variables may not be completely defined after ../../mk/
5709: bsd.prefs.mk has been included, as they may contain references to variables
1.108 rillig 5710: that are not yet defined. In shell commands (the lines in Makefile that are
5711: indented with a tab) this is no problem, since variables are only expanded when
5712: they are used. But in the preprocessor directives mentioned above and in
5713: dependency lines (of the form target: dependencies) the variables are expanded
5714: at load time.
1.1 dsieger 5715:
5716: Note
5717:
1.108 rillig 5718: To check whether a variable can be used at load time, run pkglint -Wall on your
5719: package.
1.1 dsieger 5720:
1.108 rillig 5721: 19.1.2. User interaction
1.1 dsieger 5722:
5723: Occasionally, packages require interaction from the user, and this can be in a
5724: number of ways:
5725:
5726: * When fetching the distfiles, some packages require user interaction such as
5727: entering username/password or accepting a license on a web page.
5728:
5729: * When extracting the distfiles, some packages may ask for passwords.
5730:
5731: * help to configure the package before it is built
5732:
5733: * help during the build process
5734:
5735: * help during the installation of a package
5736:
1.108 rillig 5737: A package can set the INTERACTIVE_STAGE variable to define which stages need
5738: interaction. This should be done in the package's Makefile, e.g.:
1.1 dsieger 5739:
5740: INTERACTIVE_STAGE= configure install
5741:
5742: The user can then decide to skip this package by setting the BATCH variable.
1.108 rillig 5743: Packages that require interaction are also excluded from bulk builds.
1.1 dsieger 5744:
1.108 rillig 5745: 19.1.3. Handling licenses
1.1 dsieger 5746:
5747: Authors of software can choose the licence under which software can be copied.
1.111 sevan 5748: The Free Software Foundation has declared some licenses "Free", and the Open
5749: Source Initiative has a definition of "Open Source".
5750:
5751: By default, pkgsrc allows packages with Free or Open Source licenses to be
5752: built. To allow packages with other licenses to be built as well, the pkgsrc
5753: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
5754: . Note that this variable only affects which packages may be built, while the
5755: license terms often also restrict the actual use of the package and its
5756: redistribution.
1.1 dsieger 5757:
5758: One might want to only install packages with a BSD license, or the GPL, and not
1.20 jnemeth 5759: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111 sevan 5760: variable. The pkgsrc user can override the default by setting the
5761: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
5762: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
5763: pkgsrc/mk/license.mk.
1.1 dsieger 5764:
5765: The license tag mechanism is intended to address copyright-related issues
5766: surrounding building, installing and using a package, and not to address
1.20 jnemeth 5767: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
5768: redistribution restrictions should set these tags.
1.1 dsieger 5769:
5770: Denoting that a package may be copied according to a particular license is done
5771: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
5772: string identifying the license, e.g. in graphics/xv:
5773:
5774: LICENSE= xv-license
5775:
5776: When trying to build, the user will get a notice that the package is covered by
5777: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
5778:
5779: % make
5780: ===> xv-3.10anb9 has an unacceptable license: xv-license.
5781: ===> To view the license, enter "/usr/bin/make show-license".
5782: ===> To indicate acceptance, add this line to your /etc/mk.conf:
5783: ===> ACCEPTABLE_LICENSES+=xv-license
5784: *** Error code 1
5785:
5786: The license can be viewed with make show-license, and if the user so chooses,
1.4 rillig 5787: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1 dsieger 5788: should not in the future fail because of that license:
5789:
5790: ACCEPTABLE_LICENSES+=xv-license
5791:
1.111 sevan 5792: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
5793: is deprecated because it does not crisply refer to a particular license text.
5794: Another problem with such usage is that it does not enable a user to tell
5795: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
5796: for all packages with that tag.
5797:
5798: 19.1.3.1. Adding a package with a new license
1.1 dsieger 5799:
1.49 rodent 5800: When adding a package with a new license, the following steps are required:
5801:
1.111 sevan 5802: 1. Check whether the license qualifies as Free or Open Source by referencing
5803: Various Licenses and Comments about Them and Licenses by Name | Open Source
5804: Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
5805: need the -license suffix, and the license name should be added to:
1.49 rodent 5806:
5807: + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
5808:
5809: + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
5810: license.c
5811:
5812: 2. The license text should be added to pkgsrc/licenses for displaying. A list
5813: of known licenses can be seen in this directory.
1.1 dsieger 5814:
1.111 sevan 5815: 19.1.3.2. Change to the license
1.1 dsieger 5816:
1.111 sevan 5817: When the license changes (in a way other than formatting), make sure that the
5818: new license has a different name (e.g., append the version number if it exists,
5819: or the date). Just because a user told pkgsrc to build programs under a
5820: previous version of a license does not mean that pkgsrc should build programs
5821: under the new licenses. The higher-level point is that pkgsrc does not evaluate
5822: licenses for reasonableness; the only test is a mechanistic test of whether a
5823: particular text has been approved by either of two bodies (FSF or OSI).
1.1 dsieger 5824:
1.108 rillig 5825: 19.1.4. Restricted packages
1.1 dsieger 5826:
1.111 sevan 5827: Some licenses restrict how software may be re-distributed. By declaring the
5828: restrictions, package tools can automatically refrain from e.g. placing binary
5829: packages on FTP sites.
5830:
5831: There are four possible restrictions, which are the cross product of sources
5832: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
5833: this is rarely the exact language in any license, and because non-Free licenses
5834: tend to be different from each other, pkgsrc adopts a definition of FTP and
5835: CD-ROM. "FTP" means making the source or binary file available over the
5836: Internet at no charge. "CD-ROM" means making the source or binary available on
5837: some kind of media, together with other source and binary packages, which is
5838: sold for a distribution charge.
1.1 dsieger 5839:
5840: In order to encode these restrictions, the package system defines five make
5841: variables that can be set to note these restrictions:
5842:
5843: * RESTRICTED
5844:
5845: This variable should be set whenever a restriction exists (regardless of
5846: its kind). Set this variable to a string containing the reason for the
5847: restriction. It should be understood that those wanting to understand the
5848: restriction will have to read the license, and perhaps seek advice of
5849: counsel.
5850:
5851: * NO_BIN_ON_CDROM
5852:
5853: Binaries may not be placed on CD-ROM containing other binary packages, for
5854: which a distribution charge may be made. In this case, set this variable to
5855: ${RESTRICTED}.
5856:
5857: * NO_BIN_ON_FTP
5858:
5859: Binaries may not made available on the Internet without charge. In this
5860: case, set this variable to ${RESTRICTED}. If this variable is set, binary
5861: packages will not be included on ftp.NetBSD.org.
5862:
5863: * NO_SRC_ON_CDROM
5864:
5865: Distfiles may not be placed on CD-ROM, together with other distfiles, for
5866: which a fee may be charged. In this case, set this variable to $
5867: {RESTRICTED}.
5868:
5869: * NO_SRC_ON_FTP
5870:
5871: Distfiles may not made available via FTP at no charge. In this case, set
5872: this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
5873: will not be mirrored on ftp.NetBSD.org.
5874:
1.111 sevan 5875: Please note that packages will be removed from pkgsrc when the distfiles are
1.33 wiz 5876: not distributable and cannot be obtained for a period of one full quarter
1.111 sevan 5877: branch. Packages with manual/interactive fetch must have a maintainer and it is
5878: his/her responsibility to ensure this.
1.33 wiz 5879:
1.108 rillig 5880: 19.1.5. Handling dependencies
1.1 dsieger 5881:
5882: Your package may depend on some other package being present - and there are
5883: various ways of expressing this dependency. pkgsrc supports the BUILD_DEPENDS
5884: and DEPENDS definitions, the USE_TOOLS definition, as well as dependencies via
5885: buildlink3.mk, which is the preferred way to handle dependencies, and which
1.6 rillig 5886: uses the variables named above. See Chapter 14, Buildlink methodology for more
1.1 dsieger 5887: information.
5888:
5889: The basic difference between the two variables is as follows: The DEPENDS
5890: definition registers that pre-requisite in the binary package so it will be
5891: pulled in when the binary package is later installed, whilst the BUILD_DEPENDS
5892: definition does not, marking a dependency that is only needed for building the
5893: package.
5894:
5895: This means that if you only need a package present whilst you are building, it
5896: should be noted as a BUILD_DEPENDS.
5897:
5898: The format for a BUILD_DEPENDS and a DEPENDS definition is:
5899:
5900: <pre-req-package-name>:../../<category>/<pre-req-package>
5901:
5902: Please note that the "pre-req-package-name" may include any of the wildcard
5903: version numbers recognized by pkg_info(1).
5904:
1.55 wiz 5905: 1. If your package needs another package's binaries or libraries to build and
1.1 dsieger 5906: run, and if that package has a buildlink3.mk file available, use it:
5907:
5908: .include "../../graphics/jpeg/buildlink3.mk"
5909:
1.55 wiz 5910: 2. If your package needs another package's binaries or libraries only for
5911: building, and if that package has a buildlink3.mk file available, use it:
5912:
5913: .include "../../graphics/jpeg/buildlink3.mk"
5914:
5915: but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
5916: This case is rather rare.
5917:
5918: 3. If your package needs binaries from another package to build, use the
1.26 spz 5919: BUILD_DEPENDS definition:
1.1 dsieger 5920:
1.26 spz 5921: BUILD_DEPENDS+= scons-[0-9]*:../../devel/scons
1.1 dsieger 5922:
1.55 wiz 5923: 4. If your package needs a library with which to link and there is no
1.26 spz 5924: buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
5925: because the include files and libraries will be hidden from the compiler.
1.1 dsieger 5926:
1.55 wiz 5927: 5. If your package needs some executable to be able to run correctly and if
1.26 spz 5928: there's no buildlink3.mk file, this is specified using the DEPENDS
5929: variable. The print/lyx package needs to be able to execute the latex
5930: binary from the teTeX package when it runs, and that is specified:
1.1 dsieger 5931:
1.26 spz 5932: DEPENDS+= teTeX-[0-9]*:../../print/teTeX
1.1 dsieger 5933:
1.55 wiz 5934: 6. You can use wildcards in package dependencies. Note that such wildcard
1.26 spz 5935: dependencies are retained when creating binary packages. The dependency is
5936: checked when installing the binary package and any package which matches
5937: the pattern will be used. Wildcard dependencies should be used with care.
1.1 dsieger 5938:
5939: The "-[0-9]*" should be used instead of "-*" to avoid potentially ambiguous
5940: matches such as "tk-postgresql" matching a "tk-*" DEPENDS.
5941:
5942: Wildcards can also be used to specify that a package will only build
5943: against a certain minimum version of a pre-requisite:
5944:
1.26 spz 5945: DEPENDS+= ImageMagick>=6.0:../../graphics/ImageMagick
1.1 dsieger 5946:
1.26 spz 5947: This means that the package will build using version 6.0 of ImageMagick or
5948: newer. Such a dependency may be warranted if, for example, the command line
5949: options of an executable have changed.
5950:
5951: If you need to depend on minimum versions of libraries, see the buildlink
5952: section of the pkgsrc guide.
1.1 dsieger 5953:
5954: For security fixes, please update the package vulnerabilities file. See
1.108 rillig 5955: Section 19.1.9, "Handling packages with security problems" for more
1.1 dsieger 5956: information.
5957:
5958: If your package needs files from another package to build, add the relevant
5959: distribution files to DISTFILES, so they will be extracted automatically. See
5960: the print/ghostscript package for an example. (It relies on the jpeg sources
5961: being present in source form during the build.)
5962:
1.108 rillig 5963: 19.1.6. Handling conflicts with other packages
1.1 dsieger 5964:
5965: Your package may conflict with other packages a user might already have
5966: installed on his system, e.g. if your package installs the same set of files as
1.80 wiz 5967: another package in the pkgsrc tree or has the same PKGNAME.
1.1 dsieger 5968:
1.80 wiz 5969: These cases are handled automatically by the packaging tools at package
5970: installation time and do not need to be handled manually.
1.1 dsieger 5971:
1.80 wiz 5972: In case the conflicts can not be recognized automatically (e.g., packages using
5973: the same config file location but no other shared files), you can set CONFLICTS
5974: to a space-separated list of packages (including version string) your package
5975: conflicts with.
1.1 dsieger 5976:
1.80 wiz 5977: For example, if both foo/bar and foo/baz use the same config file, you would
5978: set in foo/bar/Makefile:
1.1 dsieger 5979:
1.80 wiz 5980: CONFLICTS= baz-[0-9]*
1.1 dsieger 5981:
1.80 wiz 5982: and in pkgsrc/foo/baz/Makefile:
1.1 dsieger 5983:
1.80 wiz 5984: CONFLICTS= bar-[0-9]*
1.1 dsieger 5985:
1.108 rillig 5986: 19.1.7. Packages that cannot or should not be built
1.1 dsieger 5987:
5988: There are several reasons why a package might be instructed to not build under
5989: certain circumstances. If the package builds and runs on most platforms, the
1.83 dholland 5990: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
5991: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
5992: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
5993: (OS-version-platform) that can use glob-style wildcards.
5994:
1.114 maya 5995: If a package is not appropriate for some platforms (as opposed to merely
1.83 dholland 5996: broken), a different set of variables should be used as this affects failure
5997: reporting and statistics. If the package is appropriate for most platforms, the
5998: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
5999: for only a small handful of platforms (often exactly one), set
6000: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
6001: triples (OS-version-platform) that can use glob-style wildcards.
1.1 dsieger 6002:
6003: Some packages are tightly bound to a specific version of an operating system,
6004: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
6005: with other versions of the OS, and should be uploaded to a version specific
6006: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
6007: to "yes". This variable is not currently used by any of the package system
6008: internals, but may be used in the future.
6009:
6010: If the package should be skipped (for example, because it provides
6011: functionality already provided by the system), set PKG_SKIP_REASON to a
6012: descriptive message. If the package should fail because some preconditions are
6013: not met, set PKG_FAIL_REASON to a descriptive message.
6014:
1.108 rillig 6015: 19.1.8. Packages which should not be deleted, once installed
1.1 dsieger 6016:
6017: To ensure that a package may not be deleted, once it has been installed, the
6018: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.25 wiz 6019: carried into any binary package that is made from this pkgsrc entry. A "
6020: preserved" package will not be deleted using pkg_delete(1) unless the "-f"
1.1 dsieger 6021: option is used.
6022:
1.108 rillig 6023: 19.1.9. Handling packages with security problems
1.1 dsieger 6024:
6025: When a vulnerability is found, this should be noted in localsrc/security/
1.32 wiz 6026: advisories/pkg-vulnerabilities, and after committing that file, ask
6027: pkgsrc-security@NetBSD.org to update the file on ftp.NetBSD.org.
1.1 dsieger 6028:
6029: After fixing the vulnerability by a patch, its PKGREVISION should be increased
6030: (this is of course not necessary if the problem is fixed by using a newer
1.32 wiz 6031: release of the software), and the pattern in the pkg-vulnerabilities file must
6032: be updated.
1.1 dsieger 6033:
6034: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
6035: submit a pullup request!
6036:
6037: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
6038: a weekly cron job.
6039:
1.108 rillig 6040: 19.1.10. How to handle incrementing versions when fixing an existing package
1.1 dsieger 6041:
6042: When making fixes to an existing package it can be useful to change the version
6043: number in PKGNAME. To avoid conflicting with future versions by the original
6044: author, a "nb1", "nb2", ... suffix can be used on package versions by setting
6045: PKGREVISION=1 (2, ...). The "nb" is treated like a "." by the package tools.
6046: e.g.
6047:
6048: DISTNAME= foo-17.42
6049: PKGREVISION= 9
6050:
6051: will result in a PKGNAME of "foo-17.42nb9". If you want to use the original
6052: value of PKGNAME without the "nbX" suffix, e.g. for setting DIST_SUBDIR, use
6053: PKGNAME_NOREV.
6054:
6055: When a new release of the package is released, the PKGREVISION should be
6056: removed, e.g. on a new minor release of the above package, things should be
6057: like:
6058:
6059: DISTNAME= foo-17.43
6060:
6061: PKGREVISION should be incremented for any non-trivial change in the resulting
6062: binary package. Without a PKGREVISION bump, someone with the previous version
6063: installed has no way of knowing that their package is out of date. Thus,
6064: changes without increasing PKGREVISION are essentially labeled "this is so
6065: trivial that no reasonable person would want to upgrade", and this is the rough
6066: test for when increasing PKGREVISION is appropriate. Examples of changes that
6067: do not merit increasing PKGREVISION are:
6068:
1.14 jmcneill 6069: * Changing HOMEPAGE, MAINTAINER, OWNER, or comments in Makefile.
1.1 dsieger 6070:
6071: * Changing build variables if the resulting binary package is the same.
6072:
6073: * Changing DESCR.
6074:
6075: * Adding PKG_OPTIONS if the default options don't change.
6076:
6077: Examples of changes that do merit an increase to PKGREVISION include:
6078:
6079: * Security fixes
6080:
6081: * Changes or additions to a patch file
6082:
6083: * Changes to the PLIST
6084:
1.12 weinem 6085: * A dependency is changed or renamed.
6086:
1.1 dsieger 6087: PKGREVISION must also be incremented when dependencies have ABI changes.
6088:
1.108 rillig 6089: 19.1.11. Substituting variable text in the package files (the SUBST framework)
1.1 dsieger 6090:
6091: When you want to replace the same text in multiple files or when the
6092: replacement text varies, patches alone cannot help. This is where the SUBST
6093: framework comes in. It provides an easy-to-use interface for replacing text in
6094: files. Example:
6095:
6096: SUBST_CLASSES+= fix-paths
6097: SUBST_STAGE.fix-paths= pre-configure
6098: SUBST_MESSAGE.fix-paths= Fixing absolute paths.
6099: SUBST_FILES.fix-paths= src/*.c
6100: SUBST_FILES.fix-paths+= scripts/*.sh
6101: SUBST_SED.fix-paths= -e 's,"/usr/local,"${PREFIX},g'
6102: SUBST_SED.fix-paths+= -e 's,"/var/log,"${VARBASE}/log,g'
6103:
6104: SUBST_CLASSES is a list of identifiers that are used to identify the different
6105: SUBST blocks that are defined. The SUBST framework is heavily used by pkgsrc,
6106: so it is important to always use the += operator with this variable. Otherwise
6107: some substitutions may be skipped.
6108:
6109: The remaining variables of each SUBST block are parameterized with the
6110: identifier from the first line (fix-paths in this case.) They can be seen as
6111: parameters to a function call.
6112:
6113: SUBST_STAGE.* specifies the stage at which the replacement will take place. All
6114: combinations of pre-, do- and post- together with a phase name are possible,
6115: though only few are actually used. Most commonly used are post-patch and
6116: pre-configure. Of these two, pre-configure should be preferred because then it
6117: is possible to run bmake patch and have the state after applying the patches
6118: but before making any other changes. This is especially useful when you are
6119: debugging a package in order to create new patches for it. Similarly,
6120: post-build is preferred over pre-install, because the install phase should
6121: generally be kept as simple as possible. When you use post-build, you have the
6122: same files in the working directory that will be installed later, so you can
6123: check if the substitution has succeeded.
6124:
6125: SUBST_MESSAGE.* is an optional text that is printed just before the
6126: substitution is done.
6127:
6128: SUBST_FILES.* is the list of shell globbing patterns that specifies the files
6129: in which the substitution will take place. The patterns are interpreted
6130: relatively to the WRKSRC directory.
6131:
6132: SUBST_SED.* is a list of arguments to sed(1) that specify the actual
6133: substitution. Every sed command should be prefixed with -e, so that all SUBST
6134: blocks look uniform.
6135:
6136: There are some more variables, but they are so seldomly used that they are only
6137: documented in the mk/subst.mk file.
6138:
1.108 rillig 6139: 19.2. The fetch phase
1.1 dsieger 6140:
1.6 rillig 6141: 19.2.1. Packages whose distfiles aren't available for plain downloading
1.1 dsieger 6142:
6143: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
6144: a make fetch will call files/getsite.sh with the name of each file to download
6145: as an argument, expecting it to output the URL of the directory from which to
6146: download it. graphics/ns-cult3d is an example of this usage.
6147:
6148: If the download can't be automated, because the user must submit personal
6149: information to apply for a password, or must pay for the source, or whatever,
6150: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
6151: before aborting the build. Example:
6152:
6153: FETCH_MESSAGE= "Please download the files"
6154: FETCH_MESSAGE+= " "${DISTFILES:Q}
6155: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
6156:
1.6 rillig 6157: 19.2.2. How to handle modified distfiles with the 'old' name
1.1 dsieger 6158:
6159: Sometimes authors of a software package make some modifications after the
6160: software was released, and they put up a new distfile without changing the
6161: package's version number. If a package is already in pkgsrc at that time, the
6162: checksum will no longer match. The contents of the new distfile should be
6163: compared against the old one before changing anything, to make sure the
6164: distfile was really updated on purpose, and that no trojan horse or so crept
6165: in. Please mention that the distfiles were compared and what was found in your
1.54 rodent 6166: commit message.
6167:
6168: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109 wiz 6169: directory name, usually based on PKGNAME_NOREV (but take care with python or
6170: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
6171: PATCHFILES for this package will be put in that subdirectory of the local
6172: distfiles directory. (See Section 19.1.10, "How to handle incrementing versions
6173: when fixing an existing package" for more details.) In case this happens more
6174: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
6175: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54 rodent 6176:
6177: DIST_SUBDIR is also used when a distfile's name does not contain a version and
6178: the distfile is apt to change. In cases where the likelihood of this is very
6179: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
6180: removed unless the distfile name changes, even if a package is being moved or
6181: renamed.
6182:
6183: Do not forget regenerating the distinfo file after that, since it contains the
6184: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
6185: installed package is different. Furthermore, a mail to the package's authors
6186: seems appropriate telling them that changing distfiles after releases without
6187: changing the file names is not good practice.
1.1 dsieger 6188:
1.88 tnn 6189: 19.2.3. Packages hosted on github.com
6190:
1.90 tnn 6191: Helper methods exist for packages hosted on github.com which will often have
6192: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
6193: of the three recipes from below:
1.88 tnn 6194:
6195: 19.2.3.1. Fetch based on a tagged release
6196:
6197: If your distfile URL looks similar to http://github.com/username/exampleproject
6198: /archive/v1.0.zip, then you are packaging a tagged release.
6199:
6200: DISTNAME= exampleproject-1.0
1.90 tnn 6201: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
6202: #GITHUB_PROJECT= # can be omitted if same as DISTNAME
6203: GITHUB_TAG= v${PKGVERSION_NOREV}
1.88 tnn 6204: EXTRACT_SUFX= .zip
6205:
6206: 19.2.3.2. Fetch based on a specific commit
6207:
6208: If your distfile URL looks similar to http://github.com/example/example/archive
6209: /988881adc9fc3655077dc2d4d757d480b5ea0e11.tar.gz, then you are packaging a
6210: specific commit not tied to a release.
6211:
6212: DISTNAME= example-1.0
1.107 jnemeth 6213: MASTER_SITES= ${MASTER_SITE_GITHUB:=example/}
1.90 tnn 6214: #GITHUB_PROJECT= # can be omitted if same as DISTNAME
6215: GITHUB_TAG= 988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88 tnn 6216:
6217: 19.2.3.3. Fetch based on release
6218:
6219: If your distfile URL looks similar to http://github.com/username/exampleproject
6220: /releases/download/rel-1.6/offensive-1.6.zip, then you are packaging a release.
6221:
1.90 tnn 6222: DISTNAME= offensive-1.6
1.88 tnn 6223: PKGNAME= ${DISTNAME:S/offensive/proper/}
1.90 tnn 6224: MASTER_SITES= ${MASTER_SITE_GITHUB:=username/}
6225: GITHUB_PROJECT= exampleproject
6226: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
6227: EXTRACT_SUFX= .zip
1.88 tnn 6228:
1.108 rillig 6229: 19.3. The configure phase
1.1 dsieger 6230:
1.6 rillig 6231: 19.3.1. Shared libraries - libtool
1.1 dsieger 6232:
6233: pkgsrc supports many different machines, with different object formats like
6234: a.out and ELF, and varying abilities to do shared library and dynamic loading
6235: at all. To accompany this, varying commands and options have to be passed to
6236: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
6237: especially if you don't have all the machines at your hand to test things. The
6238: devel/libtool pkg can help here, as it just "knows" how to build both static
6239: and dynamic libraries from a set of source files, thus being
6240: platform-independent.
6241:
6242: Here's how to use libtool in a package in seven simple steps:
6243:
6244: 1. Add USE_LIBTOOL=yes to the package Makefile.
6245:
6246: 2. For library objects, use "${LIBTOOL} --mode=compile ${CC}" in place of "$
6247: {CC}". You could even add it to the definition of CC, if only libraries are
6248: being built in a given Makefile. This one command will build both PIC and
6249: non-PIC library objects, so you need not have separate shared and
6250: non-shared library rules.
6251:
6252: 3. For the linking of the library, remove any "ar", "ranlib", and "ld
6253: -Bshareable" commands, and instead use:
6254:
6255: ${LIBTOOL} --mode=link \
6256: ${CC} -o ${.TARGET:.a=.la} \
6257: ${OBJS:.o=.lo} \
6258: -rpath ${PREFIX}/lib \
6259: -version-info major:minor
6260:
6261: Note that the library is changed to have a .la extension, and the objects
6262: are changed to have a .lo extension. Change OBJS as necessary. This
6263: automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
6264: necessary) in the build directory. Be sure to include "-version-info",
6265: especially when major and minor are zero, as libtool will otherwise strip
6266: off the shared library version.
6267:
6268: From the libtool manual:
6269:
6270: So, libtool library versions are described by three integers:
6271:
6272: CURRENT
6273: The most recent interface number that this library implements.
6274:
6275: REVISION
6276: The implementation number of the CURRENT interface.
6277:
6278: AGE
6279: The difference between the newest and oldest interfaces that
6280: this library implements. In other words, the library implements
6281: all the interface numbers in the range from number `CURRENT -
6282: AGE' to `CURRENT'.
6283:
6284: If two libraries have identical CURRENT and AGE numbers, then the
6285: dynamic linker chooses the library with the greater REVISION number.
6286:
6287: The "-release" option will produce different results for a.out and ELF
1.25 wiz 6288: (excluding symlinks) in only one case. An ELF library of the form "
6289: libfoo-release.so.x.y" will have a symlink of "libfoo.so.x.y" on an a.out
1.1 dsieger 6290: platform. This is handled automatically.
6291:
6292: The "-rpath argument" is the install directory of the library being built.
6293:
6294: In the PLIST, include only the .la file, the other files will be added
6295: automatically.
6296:
6297: 4. When linking shared object (.so) files, i.e. files that are loaded via
6298: dlopen(3), NOT shared libraries, use "-module -avoid-version" to prevent
6299: them getting version tacked on.
6300:
6301: The PLIST file gets the foo.so entry.
6302:
6303: 5. When linking programs that depend on these libraries before they are
6304: installed, preface the cc(1) or ld(1) line with "${LIBTOOL} --mode=link",
6305: and it will find the correct libraries (static or shared), but please be
6306: aware that libtool will not allow you to specify a relative path in -L
6307: (such as "-L../somelib"), because it expects you to change that argument to
6308: be the .la file. e.g.
6309:
6310: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
6311:
6312: should be changed to:
6313:
6314: ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
6315:
6316: and it will do the right thing with the libraries.
6317:
6318: 6. When installing libraries, preface the install(1) or cp(1) command with "$
6319: {LIBTOOL} --mode=install", and change the library name to .la. e.g.
6320:
1.23 jakllsch 6321: ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1 dsieger 6322:
6323: This will install the static .a, shared library, any needed symlinks, and
6324: run ldconfig(8).
6325:
6326: 7. In your PLIST, include only the .la file (this is a change from previous
6327: behaviour).
6328:
1.6 rillig 6329: 19.3.2. Using libtool on GNU packages that already support libtool
1.1 dsieger 6330:
6331: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
6332: own libtool in most cases. For older libtool using packages, libtool is made by
6333: ltconfig script during the do-configure step; you can check the libtool script
6334: location by doing make configure; find work*/ -name libtool.
6335:
6336: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
6337: override. By default, it is set to "libtool */libtool */*/libtool". If this
6338: does not match the location of the package's libtool script(s), set it as
6339: appropriate.
6340:
6341: If you do not need *.a static libraries built and installed, then use
6342: SHLIBTOOL_OVERRIDE instead.
6343:
6344: If your package makes use of the platform-independent library for loading
6345: dynamic shared objects, that comes with libtool (libltdl), you should include
6346: devel/libltdl/buildlink3.mk.
6347:
6348: Some packages use libtool incorrectly so that the package may not work or build
6349: in some circumstances. Some of the more common errors are:
6350:
6351: * The inclusion of a shared object (-module) as a dependent library in an
6352: executable or library. This in itself isn't a problem if one of two things
6353: has been done:
6354:
6355: 1. The shared object is named correctly, i.e. libfoo.la, not foo.la
6356:
6357: 2. The -dlopen option is used when linking an executable.
6358:
6359: * The use of libltdl without the correct calls to initialisation routines.
6360: The function lt_dlinit() should be called and the macro
6361: LTDL_SET_PRELOADED_SYMBOLS included in executables.
6362:
1.6 rillig 6363: 19.3.3. GNU Autoconf/Automake
1.1 dsieger 6364:
6365: If a package needs GNU autoconf or automake to be executed to regenerate the
6366: configure script and Makefile.in makefile templates, then they should be
6367: executed in a pre-configure target.
6368:
6369: For packages that need only autoconf:
6370:
6371: AUTOCONF_REQD= 2.50 # if default version is not good enough
6372: USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
6373: ...
6374:
6375: pre-configure:
6376: cd ${WRKSRC} && autoconf
6377:
6378: ...
6379:
6380: and for packages that need automake and autoconf:
6381:
6382: AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
6383: USE_TOOLS+= automake # use "automake14" for automake-1.4
6384: ...
6385:
6386: pre-configure:
6387: set -e; cd ${WRKSRC}; \
6388: aclocal; autoheader; automake -a --foreign -i; autoconf
6389:
6390: ...
6391:
6392: Packages which use GNU Automake will almost certainly require GNU Make.
6393:
6394: There are times when the configure process makes additional changes to the
6395: generated files, which then causes the build process to try to re-execute the
6396: automake sequence. This is prevented by touching various files in the configure
6397: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
6398: NO in the package Makefile.
6399:
1.6 rillig 6400: 19.4. Programming languages
1.1 dsieger 6401:
1.6 rillig 6402: 19.4.1. C, C++, and Fortran
1.1 dsieger 6403:
6404: Compilers for the C, C++, and Fortran languages comes with the NetBSD base
6405: system. By default, pkgsrc assumes that a package is written in C and will hide
1.6 rillig 6406: all other compilers (via the wrapper framework, see Chapter 14, Buildlink
1.1 dsieger 6407: methodology).
6408:
6409: To declare which language's compiler a package needs, set the USE_LANGUAGES
6410: variable. Allowed values currently are "c", "c++", and "fortran" (and any
6411: combination). The default is "c". Packages using GNU configure scripts, even if
6412: written in C++, usually need a C compiler for the configure phase.
6413:
1.6 rillig 6414: 19.4.2. Java
1.1 dsieger 6415:
6416: If a program is written in Java, use the Java framework in pkgsrc. The package
6417: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
6418: variables:
6419:
6420: * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
6421: set to "run", then there is only a runtime dependency on the JDK. The
6422: default is "yes", which also adds a build dependency on the JDK.
6423:
6424: * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
6425: supported values are "yes", "1.4", and "1.5". "yes" accepts any Java2
6426: implementation, "1.4" insists on versions 1.4 or above, and "1.5" only
6427: accepts versions 1.5 or above. This variable is not set by default.
6428:
1.25 wiz 6429: * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
6430: implementation dependency. It may be used to set JAVA_HOME to a good value
6431: if the program needs this variable to be defined.
6432:
1.6 rillig 6433: 19.4.3. Packages containing perl scripts
1.1 dsieger 6434:
6435: If your package contains interpreted perl scripts, add "perl" to the USE_TOOLS
6436: variable and set REPLACE_PERL to ensure that the proper interpreter path is
6437: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74 wiz 6438: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
6439: replaced with the full path to the perl executable.
1.1 dsieger 6440:
6441: If a particular version of perl is needed, set the PERL5_REQD variable to the
6442: version number. The default is "5.0".
6443:
1.6 rillig 6444: See Section 19.6.6, "Packages installing perl modules" for information about
1.1 dsieger 6445: handling perl modules.
6446:
1.41 wiz 6447: 19.4.4. Packages containing shell scripts
6448:
6449: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
6450: shell hash bangs in files. Please use the appropriate one, prefering REPLACE_SH
1.74 wiz 6451: in case this shell is sufficient. Each should contain a list of scripts,
6452: relative to WRKSRC, that you want adjusted. Every occurrence of the matching
6453: shell in a she-bang line will be replaced with the full path to the shell
6454: executable. When using REPLACE_BASH, don't forget to add bash to USE_TOOLS.
1.41 wiz 6455:
6456: 19.4.5. Other programming languages
1.1 dsieger 6457:
6458: Currently, there is no special handling for other languages in pkgsrc. If a
6459: compiler package provides a buildlink3.mk file, include that, otherwise just
6460: add a (build) dependency on the appropriate compiler package.
6461:
1.108 rillig 6462: 19.5. The build phase
1.1 dsieger 6463:
6464: The most common failures when building a package are that some platforms do not
6465: provide certain header files, functions or libraries, or they provide the
6466: functions in a library that the original package author didn't know. To work
6467: around this, you can rewrite the source code in most cases so that it does not
6468: use the missing functions or provides a replacement function.
6469:
1.6 rillig 6470: 19.5.1. Compiling C and C++ code conditionally
1.1 dsieger 6471:
6472: If a package already comes with a GNU configure script, the preferred way to
6473: fix the build failure is to change the configure script, not the code. In the
6474: other cases, you can utilize the C preprocessor, which defines certain macros
6475: depending on the operating system and hardware architecture it compiles for.
6476: These macros can be queried using for example #if defined(__i386). Almost every
6477: operating system, hardware architecture and compiler has its own macro. For
6478: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
6479: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
6480: GCC.
6481:
6482: The list of the following macros for hardware and operating system depends on
6483: the compiler that is used. For example, if you want to conditionally compile
6484: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
6485: Use __sun instead.
6486:
1.6 rillig 6487: 19.5.1.1. C preprocessor macros to identify the operating system
1.1 dsieger 6488:
6489: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
6490: should use the following code.
6491:
6492: #include <sys/param.h>
6493: #if (defined(BSD) && BSD >= 199306)
6494: /* BSD-specific code goes here */
6495: #else
6496: /* non-BSD-specific code goes here */
6497: #endif
6498:
6499: If this distinction is not fine enough, you can also test for the following
6500: macros.
6501:
1.46 obache 6502: Cygwin __CYGWIN__
6503: DragonFly __DragonFly__
1.1 dsieger 6504: FreeBSD __FreeBSD__
1.46 obache 6505: Haiku __HAIKU__
1.1 dsieger 6506: Interix __INTERIX
6507: IRIX __sgi (TODO: get a definite source for this)
6508: Linux linux, __linux, __linux__
1.83 dholland 6509: Mac OS X __APPLE__
1.46 obache 6510: MirBSD __MirBSD__ (__OpenBSD__ is also defined)
6511: Minix3 __minix
1.1 dsieger 6512: NetBSD __NetBSD__
6513: OpenBSD __OpenBSD__
6514: Solaris sun, __sun
6515:
1.6 rillig 6516: 19.5.1.2. C preprocessor macros to identify the hardware architecture
1.1 dsieger 6517:
6518: i386 i386, __i386, __i386__
6519: MIPS __mips
6520: SPARC sparc, __sparc
6521:
1.6 rillig 6522: 19.5.1.3. C preprocessor macros to identify the compiler
1.1 dsieger 6523:
6524: GCC __GNUC__ (major version), __GNUC_MINOR__
6525: MIPSpro _COMPILER_VERSION (0x741 for MIPSpro 7.41)
6526: SunPro __SUNPRO_C (0x570 for Sun C 5.7)
6527: SunPro C++ __SUNPRO_CC (0x580 for Sun C++ 5.8)
6528:
1.6 rillig 6529: 19.5.2. How to handle compiler bugs
1.1 dsieger 6530:
6531: Some source files trigger bugs in the compiler, based on combinations of
6532: compiler version and architecture and almost always relation to optimisation
6533: being enabled. Common symptoms are gcc internal errors or never finishing
6534: compiling a file.
6535:
6536: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87 tnn 6537: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
6538:
6539: This used to be a big problem in the past, but is rarely needed now as compiler
6540: technology has matured. If you still need to add a compiler specific
6541: workaround, please do so in the file hacks.mk and describe the symptom and
6542: compiler version as detailed as possible.
1.1 dsieger 6543:
1.6 rillig 6544: 19.5.3. Undefined reference to "..."
1.1 dsieger 6545:
6546: This error message often means that a package did not link to a shared library
6547: it needs. The following functions are known to cause this error message over
6548: and over.
6549:
6550: +-----------------------------------------------------+
6551: | Function |Library |Affected platforms|
6552: |-------------------------+--------+------------------|
6553: |accept, bind, connect |-lsocket|Solaris |
6554: |-------------------------+--------+------------------|
6555: |crypt |-lcrypt |DragonFly, NetBSD |
6556: |-------------------------+--------+------------------|
6557: |dlopen, dlsym |-ldl |Linux |
6558: |-------------------------+--------+------------------|
6559: |gethost* |-lnsl |Solaris |
6560: |-------------------------+--------+------------------|
6561: |inet_aton |-lresolv|Solaris |
6562: |-------------------------+--------+------------------|
6563: |nanosleep, sem_*, timer_*|-lrt |Solaris |
6564: |-------------------------+--------+------------------|
6565: |openpty |-lutil |Linux |
6566: +-----------------------------------------------------+
6567:
6568: To fix these linker errors, it is often sufficient to say LIBS.OperatingSystem+
6569: = -lfoo to the package Makefile and then say bmake clean; bmake.
6570:
1.6 rillig 6571: 19.5.3.1. Special issue: The SunPro compiler
1.1 dsieger 6572:
6573: When you are using the SunPro compiler, there is another possibility. That
6574: compiler cannot handle the following code:
6575:
6576: extern int extern_func(int);
6577:
6578: static inline int
6579: inline_func(int x)
6580: {
6581: return extern_func(x);
6582: }
6583:
6584: int main(void)
6585: {
6586: return 0;
6587: }
6588:
6589: It generates the code for inline_func even if that function is never used. This
6590: code then refers to extern_func, which can usually not be resolved. To solve
6591: this problem you can try to tell the package to disable inlining of functions.
6592:
1.6 rillig 6593: 19.5.4. Running out of memory
1.1 dsieger 6594:
6595: Sometimes packages fail to build because the compiler runs into an operating
6596: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.94 wiz 6597: told to unlimit the resources. Currently, the allowed values are any
6598: combination of "cputime", "datasize", "memorysize", and "stacksize". Setting
6599: this variable is similar to running the shell builtin ulimit command to raise
6600: the maximum data segment size or maximum stack size of a process, respectively,
6601: to their hard limits.
1.1 dsieger 6602:
1.108 rillig 6603: 19.6. The install phase
1.1 dsieger 6604:
1.6 rillig 6605: 19.6.1. Creating needed directories
1.1 dsieger 6606:
6607: The BSD-compatible install supplied with some operating systems cannot create
6608: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
6609: like this:
6610:
6611: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
6612: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
6613:
6614: You can also just append "dir1 dir2" to the INSTALLATION_DIRS variable, which
6615: will automatically do the right thing.
6616:
1.6 rillig 6617: 19.6.2. Where to install documentation
1.1 dsieger 6618:
6619: In general, documentation should be installed into ${PREFIX}/share/doc/$
6620: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME} (the latter includes the version
6621: number of the package).
6622:
6623: Many modern packages using GNU autoconf allow to set the directory where HTML
6624: documentation is installed with the "--with-html-dir" option. Sometimes using
6625: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
6626: share/doc/html or other places.
6627:
6628: An exception to the above is that library API documentation generated with the
6629: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
6630: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
6631: can be recognized from files ending in .devhelp or .devhelp2. (It is also
6632: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
6633: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
6634: then, no additional subdirectory level is allowed in this case. This is usually
6635: achieved by using "--with-html-dir=${PREFIX}/share/doc". ${PREFIX}/share/
6636: gtk-doc is preferred though.)
6637:
1.6 rillig 6638: 19.6.3. Installing highscore files
1.1 dsieger 6639:
6640: Certain packages, most of them in the games category, install a score file that
6641: allows all users on the system to record their highscores. In order for this to
6642: work, the binaries need to be installed setgid and the score files owned by the
1.36 wiz 6643: appropriate group and/or owner (traditionally the "games" user/group). Set
6644: USE_GAMESGROUP to yes to support this. The following variables, documented in
6645: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100 leot 6646: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
6647: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
6648:
6649: An example that illustrates some of the variables described above is games/
6650: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
6651: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
6652: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
6653: to install setgid the game binary:
6654:
6655: USE_GAMESGROUP= yes
6656:
6657: BUILD_DEFS+= VARBASE
6658:
6659: OWN_DIRS_PERMS+= ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
6660: REQD_FILES_PERMS+= /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
6661: SPECIAL_PERMS+= ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
6662:
6663: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
6664: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
6665: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1 dsieger 6666:
1.14 jmcneill 6667: A package should therefore never hard code file ownership or access permissions
1.100 leot 6668: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
6669: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1 dsieger 6670:
1.6 rillig 6671: 19.6.4. Adding DESTDIR support to packages
1.4 rillig 6672:
1.14 jmcneill 6673: DESTDIR support means that a package installs into a staging directory, not the
6674: final location of the files. Then a binary package is created which can be used
6675: for installation as usual. There are two ways: Either the package must install
1.25 wiz 6676: as root ("destdir") or the package can install as non-root user ("user-destdir"
6677: ).
1.14 jmcneill 6678:
1.113 leot 6679: * PKG_DESTDIR_SUPPORT has to be set to "destdir" or "user-destdir". By
6680: default PKG_DESTDIR_SUPPORT is set to "user-destdir" to help catching more
6681: potential packaging problems. If bsd.prefs.mk is included in the Makefile,
6682: PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14 jmcneill 6683:
1.4 rillig 6684: * All installation operations have to be prefixed with ${DESTDIR}.
6685:
6686: * automake gets this DESTDIR mostly right automatically. Many manual rules
6687: and pre/post-install often are incorrect; fix them.
6688:
1.17 imil 6689: * If files are installed with special owner/group use SPECIAL_PERMS.
1.4 rillig 6690:
6691: * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
6692:
1.6 rillig 6693: 19.6.5. Packages with hardcoded paths to other interpreters
1.1 dsieger 6694:
6695: Your package may also contain scripts with hardcoded paths to other
6696: interpreters besides (or as well as) perl. To correct the full pathname to the
6697: script interpreter, you need to set the following definitions in your Makefile
6698: (we shall use tclsh in this example):
6699:
6700: REPLACE_INTERPRETER+= tcl
6701: REPLACE.tcl.old= .*/bin/tclsh
6702: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
6703: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
6704: # relative to ${WRKSRC}, just as in REPLACE_PERL
6705:
6706: Note
6707:
6708: Before March 2006, these variables were called _REPLACE.* and _REPLACE_FILES.*.
6709:
1.6 rillig 6710: 19.6.6. Packages installing perl modules
1.1 dsieger 6711:
6712: Makefiles of packages providing perl5 modules should include the Makefile
6713: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
6714: standard perl configuration for such modules as well as various hooks to tune
6715: this configuration. See comments in this file for details.
6716:
6717: Perl5 modules will install into different places depending on the version of
6718: perl used during the build process. To address this, pkgsrc will append lines
6719: to the PLIST corresponding to the files listed in the installed .packlist file
6720: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48 wiz 6721: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
6722: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1 dsieger 6723:
1.48 wiz 6724: PERL5_PACKLIST= auto/Pg/.packlist
1.1 dsieger 6725:
1.48 wiz 6726: The perl5 config variables installarchlib, installscript, installvendorbin,
6727: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
6728: and installvendorman3dir represent those locations in which components of perl5
6729: modules may be installed, provided as variable with uppercase and prefixed with
6730: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
6731: have a packlist. These variables are also substituted for in the PLIST as
6732: uppercase prefixed with PERL5_SUB_.
1.1 dsieger 6733:
1.6 rillig 6734: 19.6.7. Packages installing info files
1.1 dsieger 6735:
6736: Some packages install info files or use the "makeinfo" or "install-info"
6737: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
6738: and DEINSTALL scripts will be generated to handle registration of the info
6739: files in the Info directory file. The "install-info" command used for the info
6740: files registration is either provided by the system, or by a special purpose
6741: package automatically added as dependency if needed.
6742:
6743: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
6744: located. PKGINFODIR defaults to "info" and can be overridden by the user.
6745:
6746: The info files for the package should be listed in the package PLIST; however
6747: any split info files need not be listed.
6748:
6749: A package which needs the "makeinfo" command at build time must add "makeinfo"
6750: to USE_TOOLS in its Makefile. If a minimum version of the "makeinfo" command is
6751: needed it should be noted with the TEXINFO_REQD variable in the package
6752: Makefile. By default, a minimum version of 3.12 is required. If the system does
6753: not provide a makeinfo command or if it does not match the required minimum, a
6754: build dependency on the devel/gtexinfo package will be added automatically.
6755:
6756: The build and installation process of the software provided by the package
6757: should not use the install-info command as the registration of info files is
1.25 wiz 6758: the task of the package INSTALL script, and it must use the appropriate
1.1 dsieger 6759: makeinfo command.
6760:
6761: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
6762: the install-info and makeinfo commands in a directory listed early in PATH.
6763:
6764: The script overriding install-info has no effect except the logging of a
6765: message. The script overriding makeinfo logs a message and according to the
6766: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
6767: error.
6768:
1.6 rillig 6769: 19.6.8. Packages installing man pages
1.1 dsieger 6770:
6771: All packages that install manual pages should install them into the same
6772: directory, so that there is one common place to look for them. In pkgsrc, this
6773: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.25 wiz 6774: packages. The default for PKGMANDIR is "man". Another often-used value is "
6775: share/man".
1.1 dsieger 6776:
6777: Note
6778:
6779: The support for a custom PKGMANDIR is far from complete.
6780:
6781: The PLIST files can just use man/ as the top level directory for the man page
6782: file entries, and the pkgsrc framework will convert as needed. In all other
6783: places, the correct PKGMANDIR must be used.
6784:
6785: Packages that are configured with GNU_CONFIGURE set as "yes", by default will
6786: use the ./configure --mandir switch to set where the man pages should be
6787: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
6788: {PKGMANDIR}.
6789:
6790: Packages that use GNU_CONFIGURE but do not use --mandir, can set
6791: CONFIGURE_HAS_MANDIR to "no". Or if the ./configure script uses a non-standard
6792: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
6793:
1.6 rillig 6794: See Section 13.5, "Man page compression" for information on installation of
1.1 dsieger 6795: compressed manual pages.
6796:
1.7 rillig 6797: 19.6.9. Packages installing GConf data files
1.1 dsieger 6798:
1.7 rillig 6799: If a package installs .schemas or .entries files, used by GConf, you need to
1.1 dsieger 6800: take some extra steps to make sure they get registered in the database:
6801:
1.7 rillig 6802: 1. Include ../../devel/GConf/schemas.mk instead of its buildlink3.mk file.
6803: This takes care of rebuilding the GConf database at installation and
6804: deinstallation time, and tells the package where to install GConf data
1.1 dsieger 6805: files using some standard configure arguments. It also disallows any access
6806: to the database directly from the package.
6807:
6808: 2. Ensure that the package installs its .schemas files under ${PREFIX}/share/
6809: gconf/schemas. If they get installed under ${PREFIX}/etc, you will need to
6810: manually patch the package.
6811:
6812: 3. Check the PLIST and remove any entries under the etc/gconf directory, as
1.84 wiz 6813: they will be handled automatically. See Section 9.13, "How do I change the
1.1 dsieger 6814: location of configuration files?" for more information.
6815:
1.7 rillig 6816: 4. Define the GCONF_SCHEMAS variable in your Makefile with a list of all
1.1 dsieger 6817: .schemas files installed by the package, if any. Names must not contain any
6818: directories in them.
6819:
1.7 rillig 6820: 5. Define the GCONF_ENTRIES variable in your Makefile with a list of all
1.1 dsieger 6821: .entries files installed by the package, if any. Names must not contain any
6822: directories in them.
6823:
1.18 mishka 6824: 19.6.10. Packages installing scrollkeeper/rarian data files
1.1 dsieger 6825:
1.18 mishka 6826: If a package installs .omf files, used by scrollkeeper/rarian, you need to take
6827: some extra steps to make sure they get registered in the database:
1.1 dsieger 6828:
1.18 mishka 6829: 1. Include ../../mk/omf-scrollkeeper.mk instead of rarian's buildlink3.mk
6830: file. This takes care of rebuilding the scrollkeeper database at
6831: installation and deinstallation time, and disallows any access to it
6832: directly from the package.
1.1 dsieger 6833:
6834: 2. Check the PLIST and remove any entries under the libdata/scrollkeeper
6835: directory, as they will be handled automatically.
6836:
6837: 3. Remove the share/omf directory from the PLIST. It will be handled by
1.18 mishka 6838: rarian. (make print-PLIST does this automatically.)
1.1 dsieger 6839:
1.6 rillig 6840: 19.6.11. Packages installing X11 fonts
1.1 dsieger 6841:
6842: If a package installs font files, you will need to rebuild the fonts database
6843: in the directory where they get installed at installation and deinstallation
6844: time. This can be automatically done by using the pkginstall framework.
6845:
6846: You can list the directories where fonts are installed in the FONTS_DIRS.type
6847: variables, where type can be one of "ttf", "type1" or "x11". Also make sure
6848: that the database file fonts.dir is not listed in the PLIST.
6849:
6850: Note that you should not create new directories for fonts; instead use the
6851: standard ones to avoid that the user needs to manually configure his X server
6852: to find them.
6853:
1.6 rillig 6854: 19.6.12. Packages installing GTK2 modules
1.1 dsieger 6855:
6856: If a package installs GTK2 immodules or loaders, you need to take some extra
6857: steps to get them registered in the GTK2 database properly:
6858:
6859: 1. Include ../../x11/gtk2/modules.mk instead of its buildlink3.mk file. This
6860: takes care of rebuilding the database at installation and deinstallation
6861: time.
6862:
6863: 2. Set GTK2_IMMODULES=YES if your package installs GTK2 immodules.
6864:
6865: 3. Set GTK2_LOADERS=YES if your package installs GTK2 loaders.
6866:
6867: 4. Patch the package to not touch any of the GTK2 databases directly. These
6868: are:
6869:
1.42 asau 6870: + libdata/gtk-2.0/gdk-pixbuf.loaders
1.1 dsieger 6871:
1.42 asau 6872: + libdata/gtk-2.0/gtk.immodules
1.1 dsieger 6873:
6874: 5. Check the PLIST and remove any entries under the libdata/gtk-2.0 directory,
6875: as they will be handled automatically.
6876:
1.6 rillig 6877: 19.6.13. Packages installing SGML or XML data
1.1 dsieger 6878:
6879: If a package installs SGML or XML data files that need to be registered in
6880: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
6881: extra steps:
6882:
6883: 1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
6884: care of registering those files in system-wide catalogs at installation and
6885: deinstallation time.
6886:
6887: 2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
6888: package.
6889:
6890: 3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
6891: package.
6892:
6893: 4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
6894: These come in groups of three strings; see xmlcatmgr(1) for more
6895: information (specifically, arguments recognized by the 'add' action). Note
6896: that you will normally not use this variable.
6897:
6898: 5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
6899: come in groups of three strings; see xmlcatmgr(1) for more information
6900: (specifically, arguments recognized by the 'add' action). Note that you
6901: will normally not use this variable.
6902:
1.6 rillig 6903: 19.6.14. Packages installing extensions to the MIME database
1.1 dsieger 6904:
6905: If a package provides extensions to the MIME database by installing .xml files
6906: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
6907: ensure that the database is kept consistent with respect to these new files:
6908:
6909: 1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
6910: buildlink3.mk file from this same directory, which is reserved for
6911: inclusion from other buildlink3.mk files). It takes care of rebuilding the
6912: MIME database at installation and deinstallation time, and disallows any
6913: access to it directly from the package.
6914:
1.25 wiz 6915: 2. Check the PLIST and remove any entries under the share/mime directory,
1.1 dsieger 6916: except for files saved under share/mime/packages. The former are handled
6917: automatically by the update-mime-database program, but the latter are
6918: package-dependent and must be removed by the package that installed them in
6919: the first place.
6920:
6921: 3. Remove any share/mime/* directories from the PLIST. They will be handled by
6922: the shared-mime-info package.
6923:
1.6 rillig 6924: 19.6.15. Packages using intltool
1.1 dsieger 6925:
6926: If a package uses intltool during its build, add intltool to the USE_TOOLS,
6927: which forces it to use the intltool package provided by pkgsrc, instead of the
6928: one bundled with the distribution file.
6929:
6930: This tracks intltool's build-time dependencies and uses the latest available
6931: version; this way, the package benefits of any bug fixes that may have appeared
6932: since it was released.
6933:
1.6 rillig 6934: 19.6.16. Packages installing startup scripts
1.1 dsieger 6935:
6936: If a package contains a rc.d script, it won't be copied into the startup
6937: directory by default, but you can enable it, by adding the option
1.4 rillig 6938: PKG_RCD_SCRIPTS=YES in mk.conf. This option will copy the scripts into /etc/
6939: rc.d when a package is installed, and it will automatically remove the scripts
6940: when the package is deinstalled.
1.1 dsieger 6941:
1.6 rillig 6942: 19.6.17. Packages installing TeX modules
1.1 dsieger 6943:
6944: If a package installs TeX packages into the texmf tree, the ls-R database of
6945: the tree needs to be updated.
6946:
6947: Note
6948:
1.23 jakllsch 6949: Except the main TeX packages such as kpathsea, packages should install files
6950: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1 dsieger 6951:
1.23 jakllsch 6952: 1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
6953: ls-R database at installation and deinstallation time.
1.1 dsieger 6954:
1.23 jakllsch 6955: 2. If your package installs files into a texmf tree other than the one at $
6956: {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
6957: trees that need database update.
1.1 dsieger 6958:
6959: If your package also installs font map files that need to be registered
1.30 dholland 6960: using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
6961: and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then
6962: updmap will be run automatically at installation/deinstallation to enable/
6963: disable font map files for TeX output drivers.
1.1 dsieger 6964:
6965: 3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30 dholland 6966: be removed only by the kpathsea package.
1.1 dsieger 6967:
1.6 rillig 6968: 19.6.18. Packages supporting running binaries in emulation
1.1 dsieger 6969:
6970: There are some packages that provide libraries and executables for running
6971: binaries from a one operating system on a different one (if the latter supports
6972: it). One example is running Linux binaries on NetBSD.
6973:
6974: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
6975:
6976: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
6977: if all libraries for each installed executable can be found by the dynamic
6978: linker. Since the standard dynamic linker is run, this fails for emulation
6979: packages, because the libraries used by the emulation are not in the standard
6980: directories.
6981:
1.6 rillig 6982: 19.6.19. Packages installing hicolor theme icons
1.1 dsieger 6983:
6984: If a package installs images under the share/icons/hicolor and/or updates the
6985: share/icons/hicolor/icon-theme.cache database, you need to take some extra
6986: steps to make sure that the shared theme directory is handled appropriately and
6987: that the cache database is rebuilt:
6988:
6989: 1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
6990:
6991: 2. Check the PLIST and remove the entry that refers to the theme cache.
6992:
6993: 3. Ensure that the PLIST does not remove the shared icon directories from the
6994: share/icons/hicolor hierarchy because they will be handled automatically.
6995:
6996: The best way to verify that the PLIST is correct with respect to the last two
6997: points is to regenerate it using make print-PLIST.
6998:
1.6 rillig 6999: 19.6.20. Packages installing desktop files
1.1 dsieger 7000:
7001: If a package installs .desktop files under share/applications and these include
1.54 rodent 7002: MIME information (MimeType key), you need to take extra steps to ensure that
7003: they are registered into the MIME database:
1.1 dsieger 7004:
7005: 1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
7006:
7007: 2. Check the PLIST and remove the entry that refers to the share/applications/
7008: mimeinfo.cache file. It will be handled automatically.
7009:
7010: The best way to verify that the PLIST is correct with respect to the last point
7011: is to regenerate it using make print-PLIST.
7012:
1.6 rillig 7013: 19.7. Marking packages as having problems
1.1 dsieger 7014:
1.23 jakllsch 7015: In some cases one does not have the time to solve a problem immediately. In
7016: this case, one can plainly mark a package as broken. For this, one just sets
7017: the variable BROKEN to the reason why the package is broken (similar to the
7018: RESTRICTED variable). A user trying to build the package will immediately be
7019: shown this message, and the build will not be even tried.
1.1 dsieger 7020:
1.23 jakllsch 7021: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1 dsieger 7022:
1.6 rillig 7023: Chapter 20. Debugging
1.1 dsieger 7024:
7025: To check out all the gotchas when building a package, here are the steps that I
7026: do in order to get a package working. Please note this is basically the same as
7027: what was explained in the previous sections, only with some debugging aids.
7028:
1.4 rillig 7029: * Be sure to set PKG_DEVELOPER=yes in mk.conf.
1.1 dsieger 7030:
7031: * Install pkgtools/url2pkg, create a directory for a new package, change into
7032: it, then run url2pkg:
7033:
7034: % mkdir /usr/pkgsrc/category/examplepkg
7035: % cd /usr/pkgsrc/category/examplepkg
7036: % url2pkg http://www.example.com/path/to/distfile.tar.gz
7037:
7038: * Edit the Makefile as requested.
7039:
7040: * Fill in the DESCR file
7041:
7042: * Run make configure
7043:
7044: * Add any dependencies glimpsed from documentation and the configure step to
7045: the package's Makefile.
7046:
7047: * Make the package compile, doing multiple rounds of
7048:
7049: % make
7050: % pkgvi ${WRKSRC}/some/file/that/does/not/compile
7051: % mkpatches
7052: % patchdiff
7053: % mv ${WRKDIR}/.newpatches/* patches
7054: % make mps
7055: % make clean
7056:
7057: Doing this step as non-root user will ensure that no files are modified
7058: that shouldn't be, especially during the build phase. mkpatches, patchdiff
7059: and pkgvi are from the pkgtools/pkgdiff package.
7060:
1.6 rillig 7061: * Look at the Makefile, fix if necessary; see Section 11.1, "Makefile".
1.1 dsieger 7062:
7063: * Generate a PLIST:
7064:
7065: # make install
7066: # make print-PLIST >PLIST
7067: # make deinstall
7068: # make install
7069: # make deinstall
7070:
7071: You usually need to be root to do this. Look if there are any files left:
7072:
7073: # make print-PLIST
7074:
7075: If this reveals any files that are missing in PLIST, add them.
7076:
7077: * Now that the PLIST is OK, install the package again and make a binary
7078: package:
7079:
7080: # make reinstall
7081: # make package
7082:
7083: * Delete the installed package:
7084:
7085: # pkg_delete examplepkg
7086:
7087: * Repeat the above make print-PLIST command, which shouldn't find anything
7088: now:
7089:
7090: # make print-PLIST
7091:
7092: * Reinstall the binary package:
7093:
7094: # pkg_add .../examplepkg.tgz
7095:
7096: * Play with it. Make sure everything works.
7097:
7098: * Run pkglint from pkgtools/pkglint, and fix the problems it reports:
7099:
7100: # pkglint
7101:
1.6 rillig 7102: * Submit (or commit, if you have cvs access); see Chapter 21, Submitting and
1.1 dsieger 7103: Committing.
7104:
1.6 rillig 7105: Chapter 21. Submitting and Committing
1.1 dsieger 7106:
7107: Table of Contents
7108:
1.6 rillig 7109: 21.1. Submitting binary packages
7110: 21.2. Submitting source packages (for non-NetBSD-developers)
7111: 21.3. General notes when adding, updating, or removing packages
1.34 wiz 7112: 21.4. Committing: Adding a package to CVS
1.6 rillig 7113: 21.5. Updating a package to a newer version
1.21 snj 7114: 21.6. Renaming a package in pkgsrc
7115: 21.7. Moving a package in pkgsrc
1.1 dsieger 7116:
1.6 rillig 7117: 21.1. Submitting binary packages
1.1 dsieger 7118:
7119: Our policy is that we accept binaries only from pkgsrc developers to guarantee
7120: that the packages don't contain any trojan horses etc. This is not to annoy
7121: anyone but rather to protect our users! You're still free to put up your
7122: home-made binary packages and tell the world where to get them. NetBSD
1.66 asau 7123: developers doing bulk builds and wanting to upload them please see Chapter 7,
7124: Creating binary packages for everything in pkgsrc (bulk builds).
1.1 dsieger 7125:
1.6 rillig 7126: 21.2. Submitting source packages (for non-NetBSD-developers)
1.1 dsieger 7127:
7128: First, check that your package is complete, compiles and runs well; see
1.6 rillig 7129: Chapter 20, Debugging and the rest of this document. Next, generate an
1.1 dsieger 7130: uuencoded gzipped tar(1) archive that contains all files that make up the
7131: package. Finally, send this package to the pkgsrc bug tracking system, either
7132: with the send-pr(1) command, or if you don't have that, go to the web page
1.4 rillig 7133: http://www.NetBSD.org/support/send-pr.html, which contains some instructions
1.22 snj 7134: and a link to a form where you can submit packages. The sysutils/gtk-send-pr
7135: package is also available as a substitute for either of the above two tools.
1.1 dsieger 7136:
7137: In the form of the problem report, the category should be "pkg", the synopsis
7138: should include the package name and version number, and the description field
7139: should contain a short description of your package (contents of the COMMENT
1.25 wiz 7140: variable or DESCR file are OK). The uuencoded package data should go into the "
7141: fix" field.
1.1 dsieger 7142:
7143: If you want to submit several packages, please send a separate PR for each one,
7144: it's easier for us to track things that way.
7145:
7146: Alternatively, you can also import new packages into pkgsrc-wip ("pkgsrc
1.105 wiz 7147: work-in-progress"); see the homepage at http://pkgsrc.org/wip/ for details.
1.1 dsieger 7148:
1.6 rillig 7149: 21.3. General notes when adding, updating, or removing packages
1.1 dsieger 7150:
7151: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
7152: CHANGES-YYYY. It's very important to keep this file up to date and conforming
7153: to the existing format, because it will be used by scripts to automatically
7154: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
7155: doc/TODO file and remove the entry for the package you updated or removed, in
7156: case it was mentioned there.
7157:
7158: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
7159: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
7160: that result from a dependency being updated should not be mentioned. In all
7161: other cases it's the developer's decision.
7162:
7163: There is a make target that helps in creating proper CHANGES-YYYY entries: make
7164: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
7165: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
7166: (to avoid having to resolve conflicts later-on) and then to cd to the package
7167: directory. For package updates, make changes-entry is enough. For new packages,
7168: or package moves or removals, set the CTYPE variable on the command line to
1.4 rillig 7169: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23 jakllsch 7170: your local login name is not the same as your NetBSD login name. The target
7171: also automatically removes possibly existing entries for the package in the
7172: TODO file. Don't forget to commit the changes, e.g. by using make
1.66 asau 7173: commit-changes-entry! If you are not using a checkout directly from
1.23 jakllsch 7174: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
7175: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1 dsieger 7176:
1.34 wiz 7177: 21.4. Committing: Adding a package to CVS
1.1 dsieger 7178:
7179: This section is only of interest for pkgsrc developers with write access to the
1.34 wiz 7180: pkgsrc repository.
7181:
7182: When the package is finished, "cvs add" the files. Start by adding the
7183: directory and then files in the directory. Don't forget to add the new package
7184: to the category's Makefile. Make sure you don't forget any files; you can check
7185: by running "cvs status". An example:
7186:
7187: $ cd .../pkgsrc/category
7188: $ cvs add pkgname
7189: $ cd pkgname
7190: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
7191: $ cvs add patches/p*
7192: $ cvs status | less
1.35 wiz 7193: $ cvs commit
1.34 wiz 7194: $ cd ..
7195: $ vi Makefile # add SUBDIRS+=pkgname line
1.35 wiz 7196: $ cvs commit Makefile
1.66 asau 7197: $ cd pkgname
1.73 jnemeth 7198: $ make CTYPE=Added commit-changes-entry
1.1 dsieger 7199:
7200: The commit message of the initial import should include part of the DESCR file,
7201: so people reading the mailing lists know what the package is/does.
7202:
1.34 wiz 7203: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
7204:
7205: Previously, "cvs import" was suggested, but it was much easier to get wrong
7206: than "cvs add".
1.1 dsieger 7207:
1.6 rillig 7208: 21.5. Updating a package to a newer version
1.1 dsieger 7209:
7210: Please always put a concise, appropriate and relevant summary of the changes
7211: between old and new versions into the commit log when updating a package. There
7212: are various reasons for this:
7213:
7214: * A URL is volatile, and can change over time. It may go away completely or
7215: its information may be overwritten by newer information.
7216:
7217: * Having the change information between old and new versions in our CVS
7218: repository is very useful for people who use either cvs or anoncvs.
7219:
7220: * Having the change information between old and new versions in our CVS
7221: repository is very useful for people who read the pkgsrc-changes mailing
7222: list, so that they can make tactical decisions about when to upgrade the
7223: package.
7224:
7225: Please also recognize that, just because a new version of a package has been
7226: released, it should not automatically be upgraded in the CVS repository. We
7227: prefer to be conservative in the packages that are included in pkgsrc -
7228: development or beta packages are not really the best thing for most places in
7229: which pkgsrc is used. Please use your judgement about what should go into
7230: pkgsrc, and bear in mind that stability is to be preferred above new and
7231: possibly untested features.
7232:
1.21 snj 7233: 21.6. Renaming a package in pkgsrc
7234:
7235: Renaming packages is not recommended.
7236:
7237: When renaming packages, be sure to fix any references to old name in other
7238: Makefiles, options, buildlink files, etc.
7239:
7240: Also When renaming a package, please define SUPERSEDES to the package name and
7241: dewey version pattern(s) of the previous package name. This may be repeated for
7242: multiple renames. The new package would be an exact replacement.
7243:
7244: Note that "successor" in the CHANGES-YYYY file doesn't necessarily mean that it
7245: supersedes, as that successor may not be an exact replacement but is a
7246: suggestion for the replaced functionality.
7247:
7248: 21.7. Moving a package in pkgsrc
7249:
7250: It is preferred that packages are not renamed or moved, but if needed please
7251: follow these steps.
1.1 dsieger 7252:
7253: 1. Make a copy of the directory somewhere else.
7254:
7255: 2. Remove all CVS dirs.
7256:
7257: Alternatively to the first two steps you can also do:
7258:
7259: % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
7260:
7261: and use that for further work.
7262:
1.25 wiz 7263: 3. Fix CATEGORIES and any DEPENDS paths that just did "../package" instead of
1.1 dsieger 7264: "../../category/package".
7265:
1.21 snj 7266: 4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
7267: previous category/package pathname. The PREV_PKGPATH can be used by tools
7268: for doing an update using pkgsrc building; for example, it can search the
7269: pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
7270: the corresponding new PKGPATH for that moved package. Note that it may have
7271: multiple matches, so the tool should also check on the PKGBASE too. The
7272: PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
7273: PKGBASE stays the same.
7274:
7275: 5. cvs import the modified package in the new place.
1.1 dsieger 7276:
1.21 snj 7277: 6. Check if any package depends on it:
1.1 dsieger 7278:
7279: % cd /usr/pkgsrc
7280: % grep /package */*/Makefile* */*/buildlink*
7281:
1.21 snj 7282: 7. Fix paths in packages from step 5 to point to new location.
1.1 dsieger 7283:
1.21 snj 7284: 8. cvs rm (-f) the package at the old location.
1.1 dsieger 7285:
1.21 snj 7286: 9. Remove from oldcategory/Makefile.
1.1 dsieger 7287:
1.21 snj 7288: 10. Add to newcategory/Makefile.
1.1 dsieger 7289:
1.21 snj 7290: 11. Commit the changed and removed files:
1.1 dsieger 7291:
7292: % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
7293:
7294: (and any packages from step 5, of course).
7295:
1.6 rillig 7296: Chapter 22. Frequently Asked Questions
1.1 dsieger 7297:
7298: This section contains the answers to questions that may arise when you are
7299: writing a package. If you don't find your question answered here, first have a
7300: look in the other chapters, and if you still don't have the answer, ask on the
7301: pkgsrc-users mailing list.
7302:
1.6 rillig 7303: 22.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
7304: 22.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
7305: 22.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
7306: 22.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1 dsieger 7307: BUILDLINK_LIBS?
1.6 rillig 7308: 22.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
7309: 22.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1 dsieger 7310: the := inside it.
1.6 rillig 7311: 22.7. Which mailing lists are there for package developers?
7312: 22.8. Where is the pkgsrc documentation?
7313: 22.9. I have a little time to kill. What shall I do?
1.1 dsieger 7314:
1.6 rillig 7315: 22.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1 dsieger 7316:
7317: MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
7318: (1), while MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM
7319: when building the package. [FIXME: What is .MAKEFLAGS for?]
7320:
1.6 rillig 7321: 22.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1 dsieger 7322:
7323: MAKE is the path to the make(1) program that is used in the pkgsrc
7324: infrastructure. GMAKE is the path to GNU Make, but you need to say
7325: USE_TOOLS+=gmake to use that. MAKE_PROGRAM is the path to the Make
7326: program that is used for building the package.
7327:
1.6 rillig 7328: 22.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1 dsieger 7329:
7330: CC is the path to the real C compiler, which can be configured by the
7331: pkgsrc user. PKG_CC is the path to the compiler wrapper. PKGSRC_COMPILER
7332: is not a path to a compiler, but the type of compiler that should be
7333: used. See mk/compiler.mk for more information about the latter variable.
7334:
1.6 rillig 7335: 22.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1 dsieger 7336: BUILDLINK_LIBS?
7337:
7338: [FIXME]
7339:
1.6 rillig 7340: 22.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1 dsieger 7341:
1.25 wiz 7342: For optimization reasons, some variables are only available in the "
7343: wrapper" phase and later. To "simulate" the wrapper phase, append
1.1 dsieger 7344: PKG_PHASE=wrapper to the above command.
7345:
1.6 rillig 7346: 22.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1 dsieger 7347: the := inside it.
7348:
1.108 rillig 7349: The := is not really an assignment operator, although it looks like it.
7350: Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
7351: is documented in the make(1) man page and which is commonly used in the
7352: form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
7353: string and new_string is package/. That's where the : and the = fall
7354: together.
1.1 dsieger 7355:
1.6 rillig 7356: 22.7. Which mailing lists are there for package developers?
1.1 dsieger 7357:
7358: tech-pkg
7359:
7360: This is a list for technical discussions related to pkgsrc
7361: development, e.g. soliciting feedback for changes to pkgsrc
7362: infrastructure, proposed new features, questions related to porting
7363: pkgsrc to a new platform, advice for maintaining a package, patches
7364: that affect many packages, help requests moved from pkgsrc-users when
7365: an infrastructure bug is found, etc.
7366:
7367: pkgsrc-bugs
7368:
7369: All bug reports in category "pkg" sent with send-pr(1) appear here.
7370: Please do not report your bugs here directly; use one of the other
7371: mailing lists.
7372:
1.6 rillig 7373: 22.8. Where is the pkgsrc documentation?
1.1 dsieger 7374:
7375: There are many places where you can find documentation about pkgsrc:
7376:
7377: * The pkgsrc guide (this document) is a collection of chapters that
7378: explain large parts of pkgsrc, but some chapters tend to be outdated.
7379: Which ones they are is hard to say.
7380:
7381: * On the mailing list archives (see http://mail-index.NetBSD.org/), you
7382: can find discussions about certain features, announcements of new
7383: parts of the pkgsrc infrastructure and sometimes even announcements
7384: that a certain feature has been marked as obsolete. The benefit here
7385: is that each message has a date appended to it.
7386:
7387: * Many of the files in the mk/ directory start with a comment that
7388: describes the purpose of the file and how it can be used by the
7389: pkgsrc user and package authors. An easy way to find this
7390: documentation is to run bmake help.
7391:
7392: * The CVS log messages are a rich source of information, but they tend
7393: to be highly abbreviated, especially for actions that occur often.
7394: Some contain a detailed description of what has changed, but they are
7395: geared towards the other pkgsrc developers, not towards an average
7396: pkgsrc user. They also only document changes, so if you don't know
7397: what has been before, these messages may not be worth too much to
7398: you.
7399:
7400: * Some parts of pkgsrc are only "implicitly documented", that is the
7401: documentation exists only in the mind of the developer who wrote the
7402: code. To get this information, use the cvs annotate command to see
7403: who has written it and ask on the tech-pkg mailing list, so that
7404: others can find your questions later (see above). To be sure that the
7405: developer in charge reads the mail, you may CC him or her.
7406:
1.6 rillig 7407: 22.9. I have a little time to kill. What shall I do?
1.1 dsieger 7408:
7409: This is not really an FAQ yet, but here's the answer anyway.
7410:
7411: * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
7412: about newer versions of installed packages that are available, but
7413: not yet updated in pkgsrc.
7414:
7415: * Browse pkgsrc/doc/TODO ? it contains a list of suggested new packages
7416: and a list of cleanups and enhancements for pkgsrc that would be nice
7417: to have.
7418:
1.71 wiz 7419: * Review packages for which review was requested on the tech-pkg
7420: mailing list.
1.1 dsieger 7421:
1.6 rillig 7422: Chapter 23. GNOME packaging and porting
1.1 dsieger 7423:
7424: Table of Contents
7425:
1.6 rillig 7426: 23.1. Meta packages
7427: 23.2. Packaging a GNOME application
7428: 23.3. Updating GNOME to a newer version
7429: 23.4. Patching guidelines
1.1 dsieger 7430:
7431: Quoting GNOME's web site:
7432:
7433: The GNOME project provides two things: The GNOME desktop environment, an
7434: intuitive and attractive desktop for users, and the GNOME development
7435: platform, an extensive framework for building applications that integrate
7436: into the rest of the desktop.
7437:
7438: pkgsrc provides a seamless way to automatically build and install a complete
7439: GNOME environment under many different platforms. We can say with confidence
7440: that pkgsrc is one of the most advanced build and packaging systems for GNOME
7441: due to its included technologies buildlink3, the wrappers and tools framework
7442: and automatic configuration file management. Lots of efforts are put into
7443: achieving a completely clean deinstallation of installed software components.
7444:
7445: Given that pkgsrc is NetBSD's official packaging system, the above also means
7446: that great efforts are put into making GNOME work under this operating system.
7447: Recently, DragonFly BSD also adopted pkgsrc as its preferred packaging system,
7448: contributing lots of portability fixes to make GNOME build and install under
7449: it.
7450:
7451: This chapter is aimed at pkgsrc developers and other people interested in
7452: helping our GNOME porting and packaging efforts. It provides instructions on
7453: how to manage the existing packages and some important information regarding
7454: their internals.
7455:
7456: We need your help!
7457:
7458: Should you have some spare cycles to devote to NetBSD, pkgsrc and GNOME and are
7459: willing to learn new exciting stuff, please jump straight to the pending work
7460: list! There is still a long way to go to get a fully-functional GNOME desktop
7461: under NetBSD and we need your help to achieve it!
7462:
1.6 rillig 7463: 23.1. Meta packages
1.1 dsieger 7464:
7465: pkgsrc includes three GNOME-related meta packages:
7466:
7467: * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
7468: includes the necessary bits to get it to boot correctly, although it may
7469: lack important functionality for daily operation. The idea behind this
7470: package is to let end users build their own configurations on top of this
7471: one, first installing this meta package to achieve a functional setup and
7472: then adding individual applications.
7473:
7474: * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
7475: desktop as defined by the GNOME project; this is based on the components
7476: distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
7477: directories of the official FTP server. Developer-only tools found in those
7478: directories are not installed unless required by some other component to
7479: work properly. Similarly, packages from the bindings set (bindings/x.y/
7480: x.y.z/sources) are not pulled in unless required as a dependency for an
7481: end-user component. This package "extends" meta-pkgs/gnome-base.
7482:
7483: * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
7484: component when fetched from the CVS repository. These are required to let
7485: the autogen.sh scripts work appropriately.
7486:
7487: In all these packages, the DEPENDS lines are sorted in a way that eases
7488: updates: a package may depend on other packages listed before it but not on any
1.25 wiz 7489: listed after it. It is very important to keep this order to ease updates so...
1.1 dsieger 7490: do not change it to alphabetical sorting!
7491:
1.6 rillig 7492: 23.2. Packaging a GNOME application
1.1 dsieger 7493:
7494: Almost all GNOME applications are written in C and use a common set of tools as
7495: their build system. Things get different with the new bindings to other
7496: languages (such as Python), but the following will give you a general idea on
7497: the minimum required tools:
7498:
7499: * Almost all GNOME applications use the GNU Autotools as their build system.
7500: As a general rule you will need to tell this to your package:
7501:
7502: GNU_CONFIGURE=yes
7503: USE_LIBTOOL=yes
7504: USE_TOOLS+=gmake
7505:
7506: * If the package uses pkg-config to detect dependencies, add this tool to the
7507: list of required utilities:
7508:
7509: USE_TOOLS+=pkg-config
7510:
7511: Also use pkgtools/verifypc at the end of the build process to ensure that
7512: you did not miss to specify any dependency in your package and that the
7513: version requirements are all correct.
7514:
7515: * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
7516: handle dependencies and to force the package to use the latest available
7517: version.
7518:
7519: * If the package uses gtk-doc (a documentation generation utility), do not
7520: add a dependency on it. The tool is rather big and the distfile should come
7521: with pregenerated documentation anyway; if it does not, it is a bug that
7522: you ought to report. For such packages you should disable gtk-doc (unless
7523: it is the default):
7524:
7525: CONFIGURE_ARGS+=--disable-gtk-doc
7526:
7527: The default location of installed HTML files (share/gtk-doc/<package-name>)
7528: is correct and should not be changed unless the package insists on
7529: installing them somewhere else. Otherwise programs as devhelp will not be
7530: able to open them. You can do that with an entry similar to:
7531:
7532: CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...
7533:
7534: GNOME uses multiple shared directories and files under the installation prefix
7535: to maintain databases. In this context, shared means that those exact same
7536: directories and files are used among several different packages, leading to
7537: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
7538: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
7539: your file lists and omitting shared files from them. If you find yourself doing
7540: those, your package is most likely incorrect.
7541:
7542: The following table lists the common situations that result in using shared
7543: directories or files. For each of them, the appropriate solution is given.
1.25 wiz 7544: After applying the solution be sure to regenerate the package's file list with
1.1 dsieger 7545: make print-PLIST and ensure it is correct.
7546:
1.6 rillig 7547: Table 23.1. PLIST handling for GNOME packages
1.1 dsieger 7548:
7549: +-----------------------------------------------------------------------------+
7550: | If the package... | Then... |
7551: |-------------------------------------------+---------------------------------|
1.6 rillig 7552: | |See Section 19.6.10, "Packages |
1.18 mishka 7553: |Installs OMF files under share/omf. |installing scrollkeeper/rarian |
7554: | |data files". |
1.1 dsieger 7555: |-------------------------------------------+---------------------------------|
1.6 rillig 7556: |Installs icons under the share/icons/ |See Section 19.6.19, "Packages |
1.1 dsieger 7557: |hicolor hierarchy or updates share/icons/ |installing hicolor theme icons". |
7558: |hicolor/icon-theme.cache. | |
7559: |-------------------------------------------+---------------------------------|
1.6 rillig 7560: | |See Section 19.6.14, "Packages |
1.1 dsieger 7561: |Installs files under share/mime/packages. |installing extensions to the MIME|
7562: | |database". |
7563: |-------------------------------------------+---------------------------------|
1.6 rillig 7564: |Installs .desktop files under share/ |See Section 19.6.20, "Packages |
1.1 dsieger 7565: |applications and these include MIME |installing desktop files". |
7566: |information. | |
7567: +-----------------------------------------------------------------------------+
7568:
7569:
1.6 rillig 7570: 23.3. Updating GNOME to a newer version
1.1 dsieger 7571:
7572: When seeing GNOME as a whole, there are two kinds of updates:
7573:
7574: Major update
7575:
7576: Given that there is still a very long way for GNOME 3 (if it ever appears),
7577: we consider a major update one that goes from a 2.X version to a 2.Y one,
7578: where Y is even and greater than X. These are hard to achieve because they
7579: introduce lots of changes in the components' code and almost all GNOME
7580: distfiles are updated to newer versions. Some of them can even break API
7581: and ABI compatibility with the previous major version series. As a result,
7582: the update needs to be done all at once to minimize breakage.
7583:
7584: A major update typically consists of around 80 package updates and the
7585: addition of some new ones.
7586:
7587: Minor update
7588:
7589: We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
7590: one where Y is greater than X. These are easy to achieve because they do
7591: not update all GNOME components, can be done in an incremental way and do
7592: not break API nor ABI compatibility.
7593:
7594: A minor update typically consists of around 50 package updates, although
7595: the numbers here may vary a lot.
7596:
7597: In order to update the GNOME components in pkgsrc to a new stable release
7598: (either major or minor), the following steps should be followed:
7599:
7600: 1. Get a list of all the tarballs that form the new release by using the
1.19 snj 7601: following commands. These will leave the full list of the components'
1.1 dsieger 7602: distfiles into the list.txt file:
7603:
7604: % echo ls "*.tar.bz2" | \
7605: ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
7606: awk '{ print $9 }' >list.txt
7607: % echo ls "*.tar.bz2" | \
7608: ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
7609: awk '{ print $9 }' >>list.txt
7610:
7611: 2. Open each meta package's Makefile and bump their version to the release you
7612: are updating them to. The three meta packages should be always consistent
7613: with versioning. Obviously remove any PKGREVISIONs that might be in them.
7614:
7615: 3. For each meta package, update all its DEPENDS lines to match the latest
7616: versions as shown by the above commands. Do not list any newer version
7617: (even if found in the FTP) because the meta packages are supposed to list
7618: the exact versions that form a specific GNOME release. Exceptions are
7619: permitted here if a newer version solves a serious issue in the overall
7620: desktop experience; these typically come in the form of a revision bump in
7621: pkgsrc, not in newer versions from the developers.
7622:
7623: Packages not listed in the list.txt file should be updated to the latest
7624: version available (if found in pkgsrc). This is the case, for example, of
7625: the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
7626: package.
7627:
7628: 4. Generate a patch from the modified meta packages and extract the list of
7629: "new" lines. This will provide you an outline on what packages need to be
7630: updated in pkgsrc and in what order:
7631:
7632: % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
7633:
7634: 5. For major desktop updates it is recommended to zap all your installed
7635: packages and start over from scratch at this point.
7636:
7637: 6. Now comes the longest step by far: iterate over the contents of todo.txt
7638: and update the packages listed in it in order. For major desktop updates
7639: none of these should be committed until the entire set is completed because
7640: there are chances of breaking not-yet-updated packages.
7641:
7642: 7. Once the packages are up to date and working, commit them to the tree one
7643: by one with appropriate log messages. At the end, commit the three meta
7644: package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
7645: and pkgsrc/doc/TODO files.
7646:
1.6 rillig 7647: 23.4. Patching guidelines
1.1 dsieger 7648:
7649: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
7650: it is very important that you always, always, always feed back any portability
7651: fixes you do to a GNOME package to the mainstream developers (see
1.6 rillig 7652: Section 11.3.5, "Feedback to the author"). This is the only way to get their
1.1 dsieger 7653: attention on portability issues and to ensure that future versions can be built
7654: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
7655: updates are. Those developers in charge of issuing major GNOME updates will be
7656: grateful if you do that.
7657:
7658: The most common places to report bugs are the GNOME's Bugzilla and the
7659: freedesktop.org's Bugzilla. Not all components use these to track bugs, but
7660: most of them do. Do not be short on your reports: always provide detailed
7661: explanations of the current failure, how it can be improved to achieve maximum
7662: portability and, if at all possible, provide a patch against CVS head. The more
7663: verbose you are, the higher chances of your patch being accepted.
7664:
7665: Also, please avoid using preprocessor magic to fix portability issues. While
7666: the FreeBSD GNOME people are doing a great job in porting GNOME to their
7667: operating system, the official GNOME sources are now plagued by conditionals
7668: that check for __FreeBSD__ and similar macros. This hurts portability. Please
1.6 rillig 7669: see our patching guidelines (Section 11.3.4, "Patching guidelines") for more
1.1 dsieger 7670: details.
7671:
7672: Part III. The pkgsrc infrastructure internals
7673:
7674: This part of the guide deals with everything from the infrastructure that is
7675: behind the interfaces described in the developer's guide. A casual package
7676: maintainer should not need anything from this part.
7677:
7678: Table of Contents
7679:
1.6 rillig 7680: 24. Design of the pkgsrc infrastructure
1.1 dsieger 7681:
1.6 rillig 7682: 24.1. The meaning of variable definitions
7683: 24.2. Avoiding problems before they arise
7684: 24.3. Variable evaluation
1.1 dsieger 7685:
1.6 rillig 7686: 24.3.1. At load time
7687: 24.3.2. At runtime
1.1 dsieger 7688:
1.6 rillig 7689: 24.4. How can variables be specified?
7690: 24.5. Designing interfaces for Makefile fragments
1.1 dsieger 7691:
1.6 rillig 7692: 24.5.1. Procedures with parameters
7693: 24.5.2. Actions taken on behalf of parameters
1.1 dsieger 7694:
1.6 rillig 7695: 24.6. The order in which files are loaded
1.1 dsieger 7696:
1.6 rillig 7697: 24.6.1. The order in bsd.prefs.mk
7698: 24.6.2. The order in bsd.pkg.mk
1.1 dsieger 7699:
1.6 rillig 7700: 25. Regression tests
1.1 dsieger 7701:
1.108 rillig 7702: 25.1. Running the regression tests
7703: 25.2. Adding a new regression test
1.1 dsieger 7704:
1.108 rillig 7705: 25.2.1. Overridable functions
7706: 25.2.2. Helper functions
1.1 dsieger 7707:
1.6 rillig 7708: 26. Porting pkgsrc
1.1 dsieger 7709:
1.6 rillig 7710: 26.1. Porting pkgsrc to a new operating system
1.1 dsieger 7711:
1.6 rillig 7712: Chapter 24. Design of the pkgsrc infrastructure
1.1 dsieger 7713:
7714: Table of Contents
7715:
1.6 rillig 7716: 24.1. The meaning of variable definitions
7717: 24.2. Avoiding problems before they arise
7718: 24.3. Variable evaluation
1.1 dsieger 7719:
1.6 rillig 7720: 24.3.1. At load time
7721: 24.3.2. At runtime
1.1 dsieger 7722:
1.6 rillig 7723: 24.4. How can variables be specified?
7724: 24.5. Designing interfaces for Makefile fragments
1.1 dsieger 7725:
1.6 rillig 7726: 24.5.1. Procedures with parameters
7727: 24.5.2. Actions taken on behalf of parameters
1.1 dsieger 7728:
1.6 rillig 7729: 24.6. The order in which files are loaded
1.1 dsieger 7730:
1.6 rillig 7731: 24.6.1. The order in bsd.prefs.mk
7732: 24.6.2. The order in bsd.pkg.mk
1.1 dsieger 7733:
7734: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
7735: fragment needs a properly specified interface. This chapter explains how such
7736: an interface looks like.
7737:
1.6 rillig 7738: 24.1. The meaning of variable definitions
1.1 dsieger 7739:
7740: Whenever a variable is defined in the pkgsrc infrastructure, the location and
7741: the way of definition provide much information about the intended use of that
7742: variable. Additionally, more documentation may be found in a header comment or
7743: in this pkgsrc guide.
7744:
7745: A special file is mk/defaults/mk.conf, which lists all variables that are
7746: intended to be user-defined. They are either defined using the ?= operator or
7747: they are left undefined because defining them to anything would effectively
7748: mean "yes". All these variables may be overridden by the pkgsrc user in the
7749: MAKECONF file.
7750:
7751: Outside this file, the following conventions apply: Variables that are defined
7752: using the ?= operator may be overridden by a package.
7753:
7754: Variables that are defined using the = operator may be used read-only at
7755: run-time.
7756:
7757: Variables whose name starts with an underscore must not be accessed outside the
7758: pkgsrc infrastructure at all. They may change without further notice.
7759:
7760: Note
7761:
7762: These conventions are currently not applied consistently to the complete pkgsrc
7763: infrastructure.
7764:
1.6 rillig 7765: 24.2. Avoiding problems before they arise
1.1 dsieger 7766:
7767: All variables that contain lists of things should default to being empty. Two
7768: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
7769: variables cannot simply be modified using the += operator in package Makefiles
7770: (or other files included by them), since there is no guarantee whether the
7771: variable is already set or not, and what its value is. In the case of
7772: DISTFILES, the packages "know" the default value and just define it as in the
7773: following example.
7774:
7775: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
7776:
7777: Because of the selection of this default value, the same value appears in many
7778: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
7779: value ("c") is so short that it doesn't stand out. Nevertheless it is mentioned
7780: in many files.
7781:
1.6 rillig 7782: 24.3. Variable evaluation
1.1 dsieger 7783:
1.6 rillig 7784: 24.3.1. At load time
1.1 dsieger 7785:
7786: Variable evaluation takes place either at load time or at runtime, depending on
7787: the context in which they occur. The contexts where variables are evaluated at
7788: load time are:
7789:
7790: * The right hand side of the := and != operators,
7791:
7792: * Make directives like .if or .for,
7793:
7794: * Dependency lines.
7795:
7796: A special exception are references to the iteration variables of .for loops,
7797: which are expanded inline, no matter in which context they appear.
7798:
7799: As the values of variables may change during load time, care must be taken not
7800: to evaluate them by accident. Typical examples for variables that should not be
7801: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
7802: clear, here is an example:
7803:
7804: CONFIGURE_ARGS= # none
7805: CFLAGS= -O
7806: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
7807:
7808: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
7809:
7810: CFLAGS+= -Wall
7811:
7812: This code shows how the use of the := operator can quickly lead to unexpected
7813: results. The first paragraph is fairly common code. The second paragraph
7814: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
7815: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
7816: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
7817: typically occur in completely unrelated files.
7818:
1.6 rillig 7819: 24.3.2. At runtime
1.1 dsieger 7820:
7821: After all the files have been loaded, the values of the variables cannot be
7822: changed anymore. Variables that are used in the shell commands are expanded at
7823: this point.
7824:
1.6 rillig 7825: 24.4. How can variables be specified?
1.1 dsieger 7826:
7827: There are many ways in which the definition and use of a variable can be
7828: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108 rillig 7829: policies. A package can be checked with pkglint -Wall to see whether it meets
7830: these rules.
1.1 dsieger 7831:
1.6 rillig 7832: 24.5. Designing interfaces for Makefile fragments
1.1 dsieger 7833:
7834: Most of the .mk files fall into one of the following classes. Cases where a
7835: file falls into more than one class should be avoided as it often leads to
7836: subtle bugs.
7837:
1.6 rillig 7838: 24.5.1. Procedures with parameters
1.1 dsieger 7839:
7840: In a traditional imperative programming language some of the .mk files could be
1.23 jakllsch 7841: described as procedures. They take some input parameters and?after
7842: inclusion?provide a result in output parameters. Since all variables in
7843: Makefiles have global scope care must be taken not to use parameter names that
7844: have already another meaning. For example, PKGNAME is a bad choice for a
7845: parameter name.
1.1 dsieger 7846:
7847: Procedures are completely evaluated at preprocessing time. That is, when
7848: calling a procedure all input parameters must be completely resolvable. For
7849: example, CONFIGURE_ARGS should never be an input parameter since it is very
7850: likely that further text will be added after calling the procedure, which would
7851: effectively apply the procedure to only a part of the variable. Also,
1.108 rillig 7852: references to other variables will be modified after calling the procedure.
1.1 dsieger 7853:
7854: A procedure can declare its output parameters either as suitable for use in
7855: preprocessing directives or as only available at runtime. The latter
7856: alternative is for variables that contain references to other runtime
7857: variables.
7858:
7859: Procedures shall be written such that it is possible to call the procedure more
7860: than once. That is, the file must not contain multiple-inclusion guards.
7861:
7862: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
7863: To express that the parameters are evaluated at load time, they should be
7864: assigned using the := operator, which should be used only for this purpose.
7865:
1.6 rillig 7866: 24.5.2. Actions taken on behalf of parameters
1.1 dsieger 7867:
7868: Action files take some input parameters and may define runtime variables. They
7869: shall not define loadtime variables. There are action files that are included
7870: implicitly by the pkgsrc infrastructure, while other must be included
7871: explicitly.
7872:
7873: An example for action files is mk/subst.mk.
7874:
1.6 rillig 7875: 24.6. The order in which files are loaded
1.1 dsieger 7876:
7877: Package Makefiles usually consist of a set of variable definitions, and include
7878: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
7879: include various other *.mk files if they need to query the availability of
7880: certain features like the type of compiler or the X11 implementation. Due to
7881: the heavy use of preprocessor directives like .if and .for, the order in which
7882: the files are loaded matters.
7883:
7884: This section describes at which point the various files are loaded and gives
7885: reasons for that order.
7886:
1.6 rillig 7887: 24.6.1. The order in bsd.prefs.mk
1.1 dsieger 7888:
7889: The very first action in bsd.prefs.mk is to define some essential variables
7890: like OPSYS, OS_VERSION and MACHINE_ARCH.
7891:
1.4 rillig 7892: Then, the user settings are loaded from the file specified in MAKECONF, which
7893: is usually mk.conf. After that, those variables that have not been overridden
7894: by the user are loaded from mk/defaults/mk.conf.
1.1 dsieger 7895:
7896: After the user settings, the system settings and platform settings are loaded,
7897: which may override the user settings.
7898:
7899: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
7900: This only happens when building a package, so the proper variables must be used
7901: instead of the direct tool names.
7902:
7903: As the last steps, some essential variables from the wrapper and the package
7904: system flavor are loaded, as well as the variables that have been cached in
7905: earlier phases of a package build.
7906:
1.6 rillig 7907: 24.6.2. The order in bsd.pkg.mk
1.1 dsieger 7908:
7909: First, bsd.prefs.mk is loaded.
7910:
7911: Then, the various *-vars.mk files are loaded, which fill default values for
7912: those variables that have not been defined by the package. These variables may
7913: later be used even in unrelated files.
7914:
7915: Then, the file bsd.pkg.error.mk provides the target error-check that is added
7916: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
7917: DELAYED_WARNING_MSG.
7918:
7919: Then, the package-specific hacks from hacks.mk are included.
7920:
7921: Then, various other files follow. Most of them don't have any dependencies on
7922: what they need to have included before or after them, though some do.
7923:
7924: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
7925: restricts the use of these variables to all the files that have been included
7926: before. Appearances in later files will be silently ignored.
7927:
7928: Then, the files for the main targets are included, in the order of later
7929: execution, though the actual order should not matter.
7930:
7931: At last, some more files are included that don't set any interesting variables
7932: but rather just define make targets to be executed.
7933:
1.6 rillig 7934: Chapter 25. Regression tests
1.1 dsieger 7935:
7936: Table of Contents
7937:
1.108 rillig 7938: 25.1. Running the regression tests
7939: 25.2. Adding a new regression test
1.1 dsieger 7940:
1.108 rillig 7941: 25.2.1. Overridable functions
7942: 25.2.2. Helper functions
1.1 dsieger 7943:
7944: The pkgsrc infrastructure consists of a large codebase, and there are many
7945: corners where every little bit of a file is well thought out, making pkgsrc
7946: likely to fail as soon as anything is changed near those parts. To prevent most
7947: changes from breaking anything, a suite of regression tests should go along
7948: with every important part of the pkgsrc infrastructure. This chapter describes
7949: how regression tests work in pkgsrc and how you can add new tests.
7950:
1.108 rillig 7951: 25.1. Running the regression tests
1.1 dsieger 7952:
1.25 wiz 7953: You first need to install the pkgtools/pkg_regress package, which provides the
1.1 dsieger 7954: pkg_regress command. Then you can simply run that command, which will run all
7955: tests in the regress category.
7956:
1.108 rillig 7957: 25.2. Adding a new regression test
1.1 dsieger 7958:
7959: Every directory in the regress category that contains a file called spec is
7960: considered a regression test. This file is a shell program that is included by
7961: the pkg_regress command. The following functions can be overridden to suit your
7962: needs.
7963:
1.108 rillig 7964: 25.2.1. Overridable functions
1.1 dsieger 7965:
1.108 rillig 7966: These functions do not take any parameters. Although they are called in "set -e
7967: " mode, they don't stop at the first failing command. See this StackOverflow
7968: question for details.
1.1 dsieger 7969:
1.108 rillig 7970: do_setup
1.1 dsieger 7971:
7972: This function prepares the environment for the test. By default it does
7973: nothing.
7974:
1.108 rillig 7975: do_test
1.1 dsieger 7976:
7977: This function runs the actual test. By default, it calls TEST_MAKE with the
7978: arguments MAKEARGS_TEST and writes its output including error messages into
7979: the file TEST_OUTFILE.
7980:
1.108 rillig 7981: When defining this function, make sure that all output that needs to be
7982: checked is written to the correct output file. Example:
7983:
7984: do_test() {
7985: echo "Example output"
7986: } 1>$TEST_OUTFILE 2>&1
7987:
7988: check_result
1.1 dsieger 7989:
7990: This function is run after the test and is typically used to compare the
7991: actual output from the one that is expected. It can make use of the various
1.108 rillig 7992: helper functions from the next section. Example:
7993:
7994: check_result() {
7995: exit_status 0
7996: output_require "Example"
7997: output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
7998: output_prohibit "no such file or directory"
7999: }
1.1 dsieger 8000:
1.108 rillig 8001: do_cleanup
1.1 dsieger 8002:
8003: This function cleans everything up after the test has been run. By default
8004: it does nothing.
8005:
1.108 rillig 8006: 25.2.2. Helper functions
1.1 dsieger 8007:
1.108 rillig 8008: exit_status expected
1.1 dsieger 8009:
1.108 rillig 8010: This function compares the exitcode of the do_test function with its first
8011: parameter. If they differ, the test will fail.
1.1 dsieger 8012:
1.108 rillig 8013: output_require regex...
1.1 dsieger 8014:
8015: This function checks for each of its parameters if the output from do_test
1.108 rillig 8016: matches the extended regular expression. If it does not, the test will
8017: fail. Example:
8018:
8019: output_require "looks fine"
8020: output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1 dsieger 8021:
8022: output_prohibit(regex...)
8023:
8024: This function checks for each of its parameters if the output from do_test
8025: () does not match the extended regular expression. If any of the regular
8026: expressions matches, the test will fail.
8027:
1.6 rillig 8028: Chapter 26. Porting pkgsrc
1.1 dsieger 8029:
8030: Table of Contents
8031:
1.6 rillig 8032: 26.1. Porting pkgsrc to a new operating system
1.1 dsieger 8033:
8034: The pkgsrc system has already been ported to many operating systems, hardware
8035: architectures and compilers. This chapter explains the necessary steps to make
8036: pkgsrc even more portable.
8037:
1.6 rillig 8038: 26.1. Porting pkgsrc to a new operating system
1.1 dsieger 8039:
8040: To port pkgsrc to a new operating system (called MyOS in this example), you
8041: need to touch the following files:
8042:
8043: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
8044:
8045: This file contains some basic definitions, for example the name of the C
8046: compiler.
8047:
8048: mk/bsd.prefs.mk
8049:
8050: Insert code that defines the variables OPSYS, OS_VERSION, LOWER_OS_VERSION,
8051: LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
8052: that appear in this file.
8053:
8054: mk/platform/MyOS.mk
8055:
8056: This file contains the platform-specific definitions that are used by
8057: pkgsrc. Start by copying one of the other files and edit it to your needs.
8058:
8059: mk/tools/tools.MyOS.mk
8060:
8061: This file defines the paths to all the tools that are needed by one or the
8062: other package in pkgsrc, as well as by pkgsrc itself. Find out where these
8063: tools are on your platform and add them.
8064:
8065: Now, you should be able to build some basic packages, like lang/perl5, shells/
8066: bash.
8067:
8068: Appendix A. A simple example package: bison
8069:
8070: Table of Contents
8071:
8072: A.1. files
8073:
8074: A.1.1. Makefile
8075: A.1.2. DESCR
8076: A.1.3. PLIST
8077: A.1.4. Checking a package with pkglint
8078:
8079: A.2. Steps for building, installing, packaging
8080:
8081: We checked to find a piece of software that wasn't in the packages collection,
1.25 wiz 8082: and picked GNU bison. Quite why someone would want to have bison when Berkeley
1.1 dsieger 8083: yacc is already present in the tree is beyond us, but it's useful for the
8084: purposes of this exercise.
8085:
8086: A.1. files
8087:
8088: A.1.1. Makefile
8089:
1.2 rillig 8090: # $NetBSD$
1.1 dsieger 8091: #
8092:
8093: DISTNAME= bison-1.25
8094: CATEGORIES= devel
8095: MASTER_SITES= ${MASTER_SITE_GNU}
8096:
1.30 dholland 8097: MAINTAINER= pkgsrc-users@NetBSD.org
1.1 dsieger 8098: HOMEPAGE= http://www.gnu.org/software/bison/bison.html
8099: COMMENT= GNU yacc clone
8100:
8101: GNU_CONFIGURE= yes
1.47 wiz 8102: INFO_FILES= yes
1.1 dsieger 8103:
8104: .include "../../mk/bsd.pkg.mk"
8105:
8106: A.1.2. DESCR
8107:
8108: GNU version of yacc. Can make re-entrant parsers, and numerous other
8109: improvements. Why you would want this when Berkeley yacc(1) is part
8110: of the NetBSD source tree is beyond me.
8111:
8112: A.1.3. PLIST
8113:
1.2 rillig 8114: @comment $NetBSD$
1.1 dsieger 8115: bin/bison
8116: man/man1/bison.1.gz
8117: share/bison.simple
8118: share/bison.hairy
8119:
8120: A.1.4. Checking a package with pkglint
8121:
8122: The NetBSD package system comes with pkgtools/pkglint which helps to check the
8123: contents of these files. After installation it is quite easy to use, just
8124: change to the directory of the package you wish to examine and execute pkglint:
8125:
8126: $ pkglint
8127: looks fine.
8128:
8129: Depending on the supplied command line arguments (see pkglint(1)), more checks
8130: will be performed. Use e.g. pkglint -Call -Wall for a very thorough check.
8131:
8132: A.2. Steps for building, installing, packaging
8133:
8134: Create the directory where the package lives, plus any auxiliary directories:
8135:
8136: # cd /usr/pkgsrc/lang
8137: # mkdir bison
8138: # cd bison
8139: # mkdir patches
8140:
1.6 rillig 8141: Create Makefile, DESCR and PLIST (see Chapter 11, Package components - files,
1.1 dsieger 8142: directories and contents) then continue with fetching the distfile:
8143:
8144: # make fetch
8145: >> bison-1.25.tar.gz doesn't seem to exist on this system.
8146: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
8147: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8148: ftp: Error retrieving file: 500 Internal error
8149:
8150: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
8151: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8152: ftp: Error retrieving file: 500 Internal error
8153:
8154: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
8155: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
8156: Successfully retrieved file.
8157:
8158: Generate the checksum of the distfile into distinfo:
8159:
8160: # make makedistinfo
8161:
8162: Now compile:
8163:
8164: # make
8165: >> Checksum OK for bison-1.25.tar.gz.
8166: ===> Extracting for bison-1.25
8167: ===> Patching for bison-1.25
8168: ===> Ignoring empty patch directory
8169: ===> Configuring for bison-1.25
8170: creating cache ./config.cache
8171: checking for gcc... cc
8172: checking whether we are using GNU C... yes
8173: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
8174: checking how to run the C preprocessor... cc -E
8175: checking for minix/config.h... no
8176: checking for POSIXized ISC... no
8177: checking whether cross-compiling... no
8178: checking for ANSI C header files... yes
8179: checking for string.h... yes
8180: checking for stdlib.h... yes
8181: checking for memory.h... yes
8182: checking for working const... yes
8183: checking for working alloca.h... no
8184: checking for alloca... yes
8185: checking for strerror... yes
8186: updating cache ./config.cache
8187: creating ./config.status
8188: creating Makefile
8189: ===> Building for bison-1.25
8190: 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
8191: 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
8192: 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
8193: 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
8194: 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
8195: 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
8196: 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
8197: 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
8198: 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
8199: 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
8200: 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
8201: 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
8202: 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
8203: 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
8204: 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
8205: 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
8206: 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
8207: 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
8208: 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
8209: 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
8210: 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
8211: 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
8212: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
8213: rm -f bison.s1
8214: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
8215:
8216: Everything seems OK, so install the files:
8217:
8218: # make install
8219: >> Checksum OK for bison-1.25.tar.gz.
8220: ===> Installing for bison-1.25
8221: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
8222: rm -f /usr/pkg/bin/bison
8223: cd /usr/pkg/share; rm -f bison.simple bison.hairy
8224: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
8225: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
8226: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
8227: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
8228: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
8229: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
8230: ===> Registering installation for bison-1.25
8231:
8232: You can now use bison, and also - if you decide so - remove it with pkg_delete
8233: bison. Should you decide that you want a binary package, do this now:
8234:
8235: # make package
8236: >> Checksum OK for bison-1.25.tar.gz.
8237: ===> Building package for bison-1.25
8238: Creating package bison-1.25.tgz
8239: Registering depends:.
8240: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
8241:
8242: Now that you don't need the source and object files any more, clean up:
8243:
8244: # make clean
8245: ===> Cleaning for bison-1.25
8246:
8247: Appendix B. Build logs
8248:
8249: Table of Contents
8250:
8251: B.1. Building figlet
8252: B.2. Packaging figlet
8253:
8254: B.1. Building figlet
8255:
8256: # make
8257: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8258: => figlet221.tar.gz doesn't seem to exist on this system.
8259: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
8260: => [172219 bytes]
8261: Connected to ftp.plig.net.
8262: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
8263: 331 Guest login ok, send your complete e-mail address as password.
8264: 230-You are user #5 of 500 simultaneous users allowed.
8265: 230-
8266: 230- ___ _ _ _
8267: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
8268: 230- | _| _| . |_| . | | | . |_| . | _| . |
8269: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
8270: 230- |_| |_| |___| |___|
8271: 230-
8272: 230-** Welcome to ftp.plig.org **
8273: 230-
8274: 230-Please note that all transfers from this FTP site are logged. If you
8275: 230-do not like this, please disconnect now.
8276: 230-
1.19 snj 8277: 230-This archive is available via
1.1 dsieger 8278: 230-
8279: 230-HTTP: http://ftp.plig.org/
8280: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
8281: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
8282: 230-
8283: 230-Please email comments, bug reports and requests for packages to be
8284: 230-mirrored to ftp-admin@plig.org.
8285: 230-
8286: 230-
8287: 230 Logged in anonymously.
8288: Remote system type is UNIX.
8289: Using binary mode to transfer files.
8290: 200 Type okay.
8291: 250 "/pub" is new cwd.
8292: 250-"/pub/figlet" is new cwd.
8293: 250-
8294: 250-Welcome to the figlet archive at ftp.figlet.org
8295: 250-
8296: 250- ftp://ftp.figlet.org/pub/figlet/
8297: 250-
8298: 250-The official FIGlet web page is:
8299: 250- http://www.figlet.org/
8300: 250-
8301: 250-If you have questions, please mailto:info@figlet.org. If you want to
8302: 250-contribute a font or something else, you can email us.
8303: 250
8304: 250 "/pub/figlet/program" is new cwd.
8305: 250 "/pub/figlet/program/unix" is new cwd.
8306: local: figlet221.tar.gz remote: figlet221.tar.gz
8307: 502 Unimplemented command.
8308: 227 Entering Passive Mode (195,40,6,41,246,104)
8309: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
8310: 38% |************** | 65800 64.16 KB/s 00:01 ETA
8311: 226 Transfer completed.
8312: 172219 bytes received in 00:02 (75.99 KB/s)
8313: 221 Goodbye.
8314: => Checksum OK for figlet221.tar.gz.
8315: ===> Extracting for figlet-2.2.1nb2
8316: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
8317: ===> Patching for figlet-2.2.1nb2
8318: ===> Applying pkgsrc patches for figlet-2.2.1nb2
8319: ===> Overriding tools for figlet-2.2.1nb2
8320: ===> Creating toolchain wrappers for figlet-2.2.1nb2
8321: ===> Configuring for figlet-2.2.1nb2
8322: ===> Building for figlet-2.2.1nb2
8323: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
8324: chmod a+x figlet
8325: gcc -O2 -o chkfont chkfont.c
8326: => Unwrapping files-to-be-installed.
8327: #
8328: # make install
8329: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8330: ===> Installing for figlet-2.2.1nb2
8331: install -d -o root -g wheel -m 755 /usr/pkg/bin
8332: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
8333: mkdir -p /usr/pkg/share/figlet
8334: cp figlet /usr/pkg/bin
8335: cp chkfont /usr/pkg/bin
8336: chmod 555 figlist showfigfonts
8337: cp figlist /usr/pkg/bin
8338: cp showfigfonts /usr/pkg/bin
8339: cp fonts/*.flf /usr/pkg/share/figlet
8340: cp fonts/*.flc /usr/pkg/share/figlet
8341: cp figlet.6 /usr/pkg/man/man6
8342: ===> Registering installation for figlet-2.2.1nb2
8343: #
8344:
8345: B.2. Packaging figlet
8346:
8347: # make package
8348: ===> Checking for vulnerabilities in figlet-2.2.1nb2
8349: ===> Packaging figlet-2.2.1nb2
8350: ===> Building binary package for figlet-2.2.1nb2
8351: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
8352: Using SrcDir value of /usr/pkg
8353: Registering depends:.
8354: #
8355:
8356: Appendix C. Directory layout of the pkgsrc FTP server
8357:
8358: Table of Contents
8359:
1.23 jakllsch 8360: C.1. distfiles: The distributed source files
8361: C.2. misc: Miscellaneous things
8362: C.3. packages: Binary packages
8363: C.4. reports: Bulk build reports
8364: C.5. current, pkgsrc-20xxQy: source packages
1.1 dsieger 8365:
8366: As in other big projects, the directory layout of pkgsrc is quite complex for
8367: newbies. This chapter explains where you find things on the FTP server. The
8368: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
8369: different, but inside this directory, everything should look the same, no
8370: matter on which server you are. This directory contains some subdirectories,
8371: which are explained below.
8372:
1.23 jakllsch 8373: C.1. distfiles: The distributed source files
1.1 dsieger 8374:
8375: The directory distfiles contains lots of archive files from all pkgsrc
8376: packages, which are mirrored here. The subdirectories are called after their
8377: package names and are used when the distributed files have names that don't
8378: explicitly contain a version number or are otherwise too generic (for example
8379: release.tar.gz).
8380:
1.23 jakllsch 8381: C.2. misc: Miscellaneous things
1.1 dsieger 8382:
8383: This directory contains things that individual pkgsrc developers find worth
8384: publishing.
8385:
1.23 jakllsch 8386: C.3. packages: Binary packages
1.1 dsieger 8387:
1.3 rillig 8388: This directory contains binary packages for the various platforms that are
8389: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
8390: The meaning of these variables is:
8391:
8392: * OPSYS is the name of the operating system for which the packages have been
1.9 rillig 8393: built. The name is taken from the output of the uname command, so it may
8394: differ from the one you are used to hear.
1.3 rillig 8395:
1.8 rillig 8396: * ARCH is the hardware architecture of the platform for which the packages
1.10 hubertf 8397: have been built. It also includes the ABI (Application Binary Interface)
8398: for platforms that have several of them.
1.3 rillig 8399:
1.8 rillig 8400: * OSVERSION is the version of the operating system. For version numbers that
8401: change often (for example NetBSD-current), the often-changing part should
8402: be replaced with an x, for example 4.99.x.
1.3 rillig 8403:
1.23 jakllsch 8404: * TAG is either 20xxQy for a stable branch, or head for packages built from
1.8 rillig 8405: the HEAD branch. The latter should only be used when the packages are
8406: updated on a regular basis. Otherwise the date from checking out pkgsrc
8407: should be appended, for example head_20071015.
1.3 rillig 8408:
8409: The rationale for exactly this scheme is that the pkgsrc users looking for
8410: binary packages can quickly click through the directories on the server and
8411: find the best binary packages for their machines. Since they usually know the
8412: operating system and the hardware architecture, OPSYS and ARCH are placed
8413: first. After these choices, they can select the best combination of OSVERSION
8414: and TAG together, since it is usually the case that packages stay compatible
8415: between different version of the operating system.
8416:
8417: In each of these directories, there is a whole binary packages collection for a
8418: specific platform. It has a directory called All which contains all binary
8419: packages. Besides that, there are various category directories that contain
8420: symbolic links to the real binary packages.
1.1 dsieger 8421:
1.23 jakllsch 8422: C.4. reports: Bulk build reports
1.8 rillig 8423:
8424: Here are the reports from bulk builds, for those who want to fix packages that
8425: didn't build on some of the platforms. The structure of subdirectories should
1.23 jakllsch 8426: look like the one in Section C.3, "packages: Binary packages".
1.8 rillig 8427:
1.23 jakllsch 8428: C.5. current, pkgsrc-20xxQy: source packages
1.1 dsieger 8429:
8430: These directories contain the "real" pkgsrc, that is the files that define how
8431: to create binary packages from source archives.
8432:
8433: The directory pkgsrc contains a snapshot of the CVS repository, which is
8434: updated regularly. The file pkgsrc.tar.gz contains the same as the directory,
8435: ready to be downloaded as a whole.
8436:
8437: In the directories for the quarterly branches, there is an additional file
1.23 jakllsch 8438: called pkgsrc-20xxQy.tar.gz, which contains the state of pkgsrc when it was
1.1 dsieger 8439: branched.
8440:
8441: Appendix D. Editing guidelines for the pkgsrc guide
8442:
8443: Table of Contents
8444:
8445: D.1. Make targets
8446: D.2. Procedure
8447:
8448: This section contains information on editing the pkgsrc guide itself.
8449:
8450: D.1. Make targets
8451:
8452: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
8453: files are created from it:
8454:
8455: * pkgsrc/doc/pkgsrc.txt
8456:
8457: * pkgsrc/doc/pkgsrc.html
8458:
1.2 rillig 8459: * http://www.NetBSD.org/docs/pkgsrc/
1.1 dsieger 8460:
1.2 rillig 8461: * http://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the pkgsrc
8462: guide.
1.1 dsieger 8463:
1.2 rillig 8464: * http://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
8465: pkgsrc guide.
1.1 dsieger 8466:
8467: D.2. Procedure
8468:
8469: The procedure to edit the pkgsrc guide is:
8470:
8471: 1. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46 obache 8472: other XML-based NetBSD documentation) installed. These are automatically
8473: installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1 dsieger 8474:
8475: 2. Run cd doc/guide to get to the right directory. All further steps will take
8476: place here.
8477:
8478: 3. Edit the XML file(s) in files/.
8479:
8480: 4. Run bmake to check the pkgsrc guide for valid XML and to build the final
8481: output files. If you get any errors at this stage, you can just edit the
8482: files, as there are only symbolic links in the working directory, pointing
8483: to the files in files/.
8484:
8485: 5. (cd files && cvs commit)
8486:
8487: 6. Run bmake clean && bmake to regenerate the output files with the proper RCS
8488: Ids.
8489:
8490: 7. Run bmake regen to install and commit the files in both pkgsrc/doc and
8491: htdocs.
8492:
8493: Note
8494:
8495: If you have added, removed or renamed some chapters, you need to
8496: synchronize them using cvs add or cvs delete in the htdocs directory.
8497:
CVSweb <webmaster@jp.NetBSD.org>