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