Annotation of htdocs/docs/pkgsrc/pkgsrc.txt, revision 1.65
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.4 rillig 15: Copyright 1994-2007 The NetBSD Foundation, Inc
1.1 dsieger 16:
1.6 rillig 17: $NetBSD: pkgsrc.xml,v 1.26 2007/09/18 08:17:21 rillig Exp $
1.1 dsieger 18:
19: Abstract
20:
21: pkgsrc is a centralized package management system for Unix-like operating
22: systems. This guide provides information for users and developers of pkgsrc. It
23: covers installation of binary and source packages, creation of binary and
24: source packages and a high-level overview about the infrastructure.
25:
26: -------------------------------------------------------------------------------
27:
28: Table of Contents
29:
30: 1. What is pkgsrc?
31:
32: 1.1. Introduction
33:
34: 1.1.1. Why pkgsrc?
35: 1.1.2. Supported platforms
36:
37: 1.2. Overview
38: 1.3. Terminology
39:
40: 1.3.1. Roles involved in pkgsrc
41:
42: 1.4. Typography
43:
44: I. The pkgsrc user's guide
45:
46: 2. Where to get pkgsrc and how to keep it up-to-date
47:
48: 2.1. Getting pkgsrc for the first time
49:
1.52 asau 50: 2.1.1. As tar archive
1.24 wiz 51: 2.1.2. Via anonymous CVS
1.1 dsieger 52:
53: 2.2. Keeping pkgsrc up-to-date
54:
55: 2.2.1. Via tar files
56: 2.2.2. Via CVS
57:
58: 3. Using pkgsrc on systems other than NetBSD
59:
60: 3.1. Binary distribution
61: 3.2. Bootstrapping pkgsrc
62: 3.3. Platform-specific notes
63:
1.46 obache 64: 3.3.1. Cygwin
65: 3.3.2. Darwin (Mac OS X)
66: 3.3.3. FreeBSD
1.58 ryoon 67: 3.3.4. GNU/kFreeBSD
68: 3.3.5. Interix
69: 3.3.6. IRIX
70: 3.3.7. Linux
71: 3.3.8. MirBSD
72: 3.3.9. OpenBSD
73: 3.3.10. Solaris
1.1 dsieger 74:
75: 4. Using pkgsrc
76:
77: 4.1. Using binary packages
78:
79: 4.1.1. Finding binary packages
80: 4.1.2. Installing binary packages
81: 4.1.3. Deinstalling packages
82: 4.1.4. Getting information about installed packages
83: 4.1.5. Checking for security vulnerabilities in installed packages
84: 4.1.6. Finding if newer versions of your installed packages are in
85: pkgsrc
86: 4.1.7. Other administrative functions
87: 4.1.8. A word of warning
88:
89: 4.2. Building packages from source
90:
91: 4.2.1. Requirements
92: 4.2.2. Fetching distfiles
93: 4.2.3. How to build and install
94:
95: 5. Configuring pkgsrc
96:
97: 5.1. General configuration
98: 5.2. Variables affecting the build process
1.9 rillig 99: 5.3. Variables affecting the installation process
1.4 rillig 100: 5.4. Selecting and configuring the compiler
1.1 dsieger 101:
1.4 rillig 102: 5.4.1. Selecting the compiler
103: 5.4.2. Additional flags to the compiler (CFLAGS)
104: 5.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 105:
1.4 rillig 106: 5.5. Developer/advanced settings
107: 5.6. Selecting Build Options
1.1 dsieger 108:
109: 6. Creating binary packages
110:
111: 6.1. Building a single binary package
112: 6.2. Settings for creation of binary packages
113:
1.6 rillig 114: 7. Creating binary packages for everything in pkgsrc (bulk builds)
115:
116: 7.1. Think first, build later
117: 7.2. Requirements of a bulk build
118: 7.3. Running an old-style bulk build
119:
120: 7.3.1. Configuration
121: 7.3.2. Other environmental considerations
122: 7.3.3. Operation
123: 7.3.4. What it does
124: 7.3.5. Disk space requirements
125: 7.3.6. Setting up a sandbox for chrooted builds
126: 7.3.7. Building a partial set of packages
127: 7.3.8. Uploading results of a bulk build
128:
129: 7.4. Running a pbulk-style bulk build
130:
1.15 rillig 131: 7.4.1. Preparation
132: 7.4.2. Configuration
1.6 rillig 133:
134: 7.5. Creating a multiple CD-ROM packages collection
135:
136: 7.5.1. Example of cdpack
137:
138: 8. Directory layout of the installed files
139:
140: 8.1. File system layout in ${LOCALBASE}
141: 8.2. File system layout in ${VARBASE}
142:
143: 9. Frequently Asked Questions
144:
145: 9.1. Are there any mailing lists for pkg-related discussion?
146: 9.2. Where's the pkgviews documentation?
147: 9.3. Utilities for package management (pkgtools)
148: 9.4. How to use pkgsrc as non-root
149: 9.5. How to resume transfers when fetching distfiles?
150: 9.6. How can I install/use modular X.org from pkgsrc?
151: 9.7. How to fetch files from behind a firewall
1.65 ! wiz 152: 9.8. How to fetch files from HTTPS sites
! 153: 9.9. How do I tell make fetch to do passive FTP?
! 154: 9.10. How to fetch all distfiles at once
! 155: 9.11. What does "Don't know how to make /usr/share/tmac/tmac.andoc"
1.24 wiz 156: mean?
1.65 ! wiz 157: 9.12. What does "Could not find bsd.own.mk" mean?
! 158: 9.13. Using 'sudo' with pkgsrc
! 159: 9.14. How do I change the location of configuration files?
! 160: 9.15. Automated security checks
! 161: 9.16. Why do some packages ignore my CFLAGS?
! 162: 9.17. A package does not build. What shall I do?
! 163: 9.18. What does "Makefile appears to contain unresolved cvs/rcs/???
1.24 wiz 164: merge conflicts" mean?
1.1 dsieger 165:
166: II. The pkgsrc developer's guide
167:
1.6 rillig 168: 10. Creating a new pkgsrc package from scratch
1.1 dsieger 169:
1.6 rillig 170: 10.1. Common types of packages
1.1 dsieger 171:
1.6 rillig 172: 10.1.1. Perl modules
173: 10.1.2. KDE applications
1.17 imil 174: 10.1.3. Python modules and programs
1.1 dsieger 175:
1.6 rillig 176: 10.2. Examples
1.1 dsieger 177:
1.6 rillig 178: 10.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 179:
1.6 rillig 180: 11. Package components - files, directories and contents
1.1 dsieger 181:
1.6 rillig 182: 11.1. Makefile
183: 11.2. distinfo
184: 11.3. patches/*
1.1 dsieger 185:
1.6 rillig 186: 11.3.1. Structure of a single patch file
187: 11.3.2. Creating patch files
188: 11.3.3. Sources where the patch files come from
189: 11.3.4. Patching guidelines
190: 11.3.5. Feedback to the author
1.1 dsieger 191:
1.6 rillig 192: 11.4. Other mandatory files
193: 11.5. Optional files
1.1 dsieger 194:
1.6 rillig 195: 11.5.1. Files affecting the binary package
196: 11.5.2. Files affecting the build process
197: 11.5.3. Files affecting nothing at all
1.1 dsieger 198:
1.6 rillig 199: 11.6. work*
200: 11.7. files/*
1.1 dsieger 201:
1.6 rillig 202: 12. Programming in Makefiles
1.1 dsieger 203:
1.6 rillig 204: 12.1. Caveats
205: 12.2. Makefile variables
1.1 dsieger 206:
1.6 rillig 207: 12.2.1. Naming conventions
1.1 dsieger 208:
1.6 rillig 209: 12.3. Code snippets
1.1 dsieger 210:
1.6 rillig 211: 12.3.1. Adding things to a list
212: 12.3.2. Converting an internal list into an external list
213: 12.3.3. Passing variables to a shell command
214: 12.3.4. Quoting guideline
215: 12.3.5. Workaround for a bug in BSD Make
1.1 dsieger 216:
1.6 rillig 217: 13. PLIST issues
1.1 dsieger 218:
1.6 rillig 219: 13.1. RCS ID
220: 13.2. Semi-automatic PLIST generation
221: 13.3. Tweaking output of make print-PLIST
222: 13.4. Variable substitution in PLIST
223: 13.5. Man page compression
224: 13.6. Changing PLIST source with PLIST_SRC
225: 13.7. Platform-specific and differing PLISTs
226: 13.8. Sharing directories between packages
1.1 dsieger 227:
1.6 rillig 228: 14. Buildlink methodology
1.1 dsieger 229:
1.6 rillig 230: 14.1. Converting packages to use buildlink3
231: 14.2. Writing buildlink3.mk files
1.1 dsieger 232:
1.6 rillig 233: 14.2.1. Anatomy of a buildlink3.mk file
1.27 wiz 234: 14.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
235: BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.1 dsieger 236:
1.6 rillig 237: 14.3. Writing builtin.mk files
1.1 dsieger 238:
1.6 rillig 239: 14.3.1. Anatomy of a builtin.mk file
240: 14.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 241:
1.6 rillig 242: 15. The pkginstall framework
1.1 dsieger 243:
1.6 rillig 244: 15.1. Files and directories outside the installation prefix
1.1 dsieger 245:
1.6 rillig 246: 15.1.1. Directory manipulation
247: 15.1.2. File manipulation
1.1 dsieger 248:
1.6 rillig 249: 15.2. Configuration files
1.1 dsieger 250:
1.6 rillig 251: 15.2.1. How PKG_SYSCONFDIR is set
252: 15.2.2. Telling the software where configuration files are
253: 15.2.3. Patching installations
254: 15.2.4. Disabling handling of configuration files
1.1 dsieger 255:
1.6 rillig 256: 15.3. System startup scripts
1.1 dsieger 257:
1.6 rillig 258: 15.3.1. Disabling handling of system startup scripts
1.1 dsieger 259:
1.6 rillig 260: 15.4. System users and groups
261: 15.5. System shells
1.1 dsieger 262:
1.6 rillig 263: 15.5.1. Disabling shell registration
1.1 dsieger 264:
1.6 rillig 265: 15.6. Fonts
1.1 dsieger 266:
1.6 rillig 267: 15.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 268:
1.6 rillig 269: 16. Options handling
1.1 dsieger 270:
1.6 rillig 271: 16.1. Global default options
272: 16.2. Converting packages to use bsd.options.mk
273: 16.3. Option Names
1.7 rillig 274: 16.4. Determining the options of dependencies
1.1 dsieger 275:
1.6 rillig 276: 17. The build process
1.1 dsieger 277:
1.6 rillig 278: 17.1. Introduction
279: 17.2. Program location
280: 17.3. Directories used during the build process
281: 17.4. Running a phase
282: 17.5. The fetch phase
1.1 dsieger 283:
1.6 rillig 284: 17.5.1. What to fetch and where to get it from
285: 17.5.2. How are the files fetched?
1.1 dsieger 286:
1.6 rillig 287: 17.6. The checksum phase
288: 17.7. The extract phase
289: 17.8. The patch phase
290: 17.9. The tools phase
291: 17.10. The wrapper phase
292: 17.11. The configure phase
293: 17.12. The build phase
294: 17.13. The test phase
295: 17.14. The install phase
296: 17.15. The package phase
297: 17.16. Cleaning up
298: 17.17. Other helpful targets
1.1 dsieger 299:
1.6 rillig 300: 18. Tools needed for building or running
1.1 dsieger 301:
1.6 rillig 302: 18.1. Tools for pkgsrc builds
303: 18.2. Tools needed by packages
304: 18.3. Tools provided by platforms
305: 18.4. Questions regarding the tools
1.1 dsieger 306:
1.6 rillig 307: 19. Making your package work
1.1 dsieger 308:
1.6 rillig 309: 19.1. General operation
1.1 dsieger 310:
1.6 rillig 311: 19.1.1. Portability of packages
1.24 wiz 312: 19.1.2. How to pull in user-settable variables from mk.conf
1.6 rillig 313: 19.1.3. User interaction
314: 19.1.4. Handling licenses
315: 19.1.5. Restricted packages
316: 19.1.6. Handling dependencies
317: 19.1.7. Handling conflicts with other packages
318: 19.1.8. Packages that cannot or should not be built
319: 19.1.9. Packages which should not be deleted, once installed
320: 19.1.10. Handling packages with security problems
321: 19.1.11. How to handle incrementing versions when fixing an
1.1 dsieger 322: existing package
1.6 rillig 323: 19.1.12. Substituting variable text in the package files (the SUBST
1.1 dsieger 324: framework)
325:
1.6 rillig 326: 19.2. Fixing problems in the fetch phase
1.1 dsieger 327:
1.6 rillig 328: 19.2.1. Packages whose distfiles aren't available for plain
1.1 dsieger 329: downloading
1.6 rillig 330: 19.2.2. How to handle modified distfiles with the 'old' name
1.1 dsieger 331:
1.6 rillig 332: 19.3. Fixing problems in the configure phase
1.1 dsieger 333:
1.6 rillig 334: 19.3.1. Shared libraries - libtool
335: 19.3.2. Using libtool on GNU packages that already support libtool
336: 19.3.3. GNU Autoconf/Automake
337:
338: 19.4. Programming languages
339:
340: 19.4.1. C, C++, and Fortran
341: 19.4.2. Java
342: 19.4.3. Packages containing perl scripts
1.41 wiz 343: 19.4.4. Packages containing shell scripts
344: 19.4.5. Other programming languages
1.6 rillig 345:
346: 19.5. Fixing problems in the build phase
347:
348: 19.5.1. Compiling C and C++ code conditionally
349: 19.5.2. How to handle compiler bugs
1.24 wiz 350: 19.5.3. Undefined reference to "..."
1.6 rillig 351: 19.5.4. Running out of memory
352:
353: 19.6. Fixing problems in the install phase
354:
355: 19.6.1. Creating needed directories
356: 19.6.2. Where to install documentation
357: 19.6.3. Installing highscore files
358: 19.6.4. Adding DESTDIR support to packages
359: 19.6.5. Packages with hardcoded paths to other interpreters
360: 19.6.6. Packages installing perl modules
361: 19.6.7. Packages installing info files
362: 19.6.8. Packages installing man pages
1.7 rillig 363: 19.6.9. Packages installing GConf data files
1.18 mishka 364: 19.6.10. Packages installing scrollkeeper/rarian data files
1.6 rillig 365: 19.6.11. Packages installing X11 fonts
366: 19.6.12. Packages installing GTK2 modules
367: 19.6.13. Packages installing SGML or XML data
368: 19.6.14. Packages installing extensions to the MIME database
369: 19.6.15. Packages using intltool
370: 19.6.16. Packages installing startup scripts
371: 19.6.17. Packages installing TeX modules
372: 19.6.18. Packages supporting running binaries in emulation
373: 19.6.19. Packages installing hicolor theme icons
374: 19.6.20. Packages installing desktop files
375:
376: 19.7. Marking packages as having problems
377:
378: 20. Debugging
379: 21. Submitting and Committing
380:
381: 21.1. Submitting binary packages
382: 21.2. Submitting source packages (for non-NetBSD-developers)
383: 21.3. General notes when adding, updating, or removing packages
1.34 wiz 384: 21.4. Committing: Adding a package to CVS
1.6 rillig 385: 21.5. Updating a package to a newer version
1.21 snj 386: 21.6. Renaming a package in pkgsrc
387: 21.7. Moving a package in pkgsrc
1.6 rillig 388:
389: 22. Frequently Asked Questions
390: 23. GNOME packaging and porting
391:
392: 23.1. Meta packages
393: 23.2. Packaging a GNOME application
394: 23.3. Updating GNOME to a newer version
395: 23.4. Patching guidelines
1.1 dsieger 396:
397: III. The pkgsrc infrastructure internals
398:
1.6 rillig 399: 24. Design of the pkgsrc infrastructure
1.1 dsieger 400:
1.6 rillig 401: 24.1. The meaning of variable definitions
402: 24.2. Avoiding problems before they arise
403: 24.3. Variable evaluation
1.1 dsieger 404:
1.6 rillig 405: 24.3.1. At load time
406: 24.3.2. At runtime
1.1 dsieger 407:
1.6 rillig 408: 24.4. How can variables be specified?
409: 24.5. Designing interfaces for Makefile fragments
1.1 dsieger 410:
1.6 rillig 411: 24.5.1. Procedures with parameters
412: 24.5.2. Actions taken on behalf of parameters
1.1 dsieger 413:
1.6 rillig 414: 24.6. The order in which files are loaded
1.1 dsieger 415:
1.6 rillig 416: 24.6.1. The order in bsd.prefs.mk
417: 24.6.2. The order in bsd.pkg.mk
1.1 dsieger 418:
1.6 rillig 419: 25. Regression tests
1.1 dsieger 420:
1.6 rillig 421: 25.1. The regression tests framework
422: 25.2. Running the regression tests
423: 25.3. Adding a new regression test
1.1 dsieger 424:
1.6 rillig 425: 25.3.1. Overridable functions
426: 25.3.2. Helper functions
1.1 dsieger 427:
1.6 rillig 428: 26. Porting pkgsrc
1.1 dsieger 429:
1.6 rillig 430: 26.1. Porting pkgsrc to a new operating system
431: 26.2. Adding support for a new compiler
1.1 dsieger 432:
433: A. A simple example package: bison
434:
435: A.1. files
436:
437: A.1.1. Makefile
438: A.1.2. DESCR
439: A.1.3. PLIST
440: A.1.4. Checking a package with pkglint
441:
442: A.2. Steps for building, installing, packaging
443:
444: B. Build logs
445:
446: B.1. Building figlet
447: B.2. Packaging figlet
448:
449: C. Directory layout of the pkgsrc FTP server
450:
1.23 jakllsch 451: C.1. distfiles: The distributed source files
452: C.2. misc: Miscellaneous things
453: C.3. packages: Binary packages
454: C.4. reports: Bulk build reports
455: C.5. current, pkgsrc-20xxQy: source packages
1.1 dsieger 456:
457: D. Editing guidelines for the pkgsrc guide
458:
459: D.1. Make targets
460: D.2. Procedure
461:
462: List of Tables
463:
464: 1.1. Platforms supported by pkgsrc
1.6 rillig 465: 11.1. Patching examples
466: 23.1. PLIST handling for GNOME packages
1.1 dsieger 467:
468: Chapter 1. What is pkgsrc?
469:
470: Table of Contents
471:
472: 1.1. Introduction
473:
474: 1.1.1. Why pkgsrc?
475: 1.1.2. Supported platforms
476:
477: 1.2. Overview
478: 1.3. Terminology
479:
480: 1.3.1. Roles involved in pkgsrc
481:
482: 1.4. Typography
483:
484: 1.1. Introduction
485:
486: There is a lot of software freely available for Unix-based systems, which is
487: usually available in form of the source code. Before such software can be used,
488: it needs to be configured to the local system, compiled and installed, and this
489: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
490: some basic commands to handle binary packages, so that not every user has to
491: build the packages for himself, which is a time-costly task.
492:
493: pkgsrc currently contains several thousand packages, including:
494:
495: * www/apache - The Apache web server
496:
497: * www/firefox - The Firefox web browser
498:
499: * meta-pkgs/gnome - The GNOME Desktop Environment
500:
501: * meta-pkgs/kde3 - The K Desktop Environment
502:
503: ...just to name a few.
504:
505: pkgsrc has built-in support for handling varying dependencies, such as pthreads
506: and X11, and extended features such as IPv6 support on a range of platforms.
507:
508: 1.1.1. Why pkgsrc?
509:
510: pkgsrc provides the following key features:
511:
512: * Easy building of software from source as well as the creation and
513: installation of binary packages. The source and latest patches are
514: retrieved from a master or mirror download site, checksum verified, then
515: built on your system. Support for binary-only distributions is available
516: for both native platforms and NetBSD emulated platforms.
517:
518: * All packages are installed in a consistent directory tree, including
519: binaries, libraries, man pages and other documentation.
520:
521: * Package dependencies, including when performing package updates, are
522: handled automatically. The configuration files of various packages are
523: handled automatically during updates, so local changes are preserved.
524:
525: * Like NetBSD, pkgsrc is designed with portability in mind and consists of
526: highly portable code. This allows the greatest speed of development when
1.26 spz 527: porting to a new platform. This portability also ensures that pkgsrc is
1.1 dsieger 528: consistent across all platforms.
529:
530: * The installation prefix, acceptable software licenses, international
531: encryption requirements and build-time options for a large number of
532: packages are all set in a simple, central configuration file.
533:
534: * The entire source (not including the distribution files) is freely
535: available under a BSD license, so you may extend and adapt pkgsrc to your
536: needs. Support for local packages and patches is available right out of the
537: box, so you can configure it specifically for your environment.
538:
539: The following principles are basic to pkgsrc:
540:
541: * "It should only work if it's right." ? That means, if a package contains
542: bugs, it's better to find them and to complain about them rather than to
543: just install the package and hope that it works. There are numerous checks
544: in pkgsrc that try to find such bugs: Static analysis tools (pkgtools/
545: pkglint), build-time checks (portability of shell scripts), and
546: post-installation checks (installed files, references to shared libraries,
547: script interpreters).
548:
549: * "If it works, it should work everywhere" ? Like NetBSD has been ported to
550: many hardware architectures, pkgsrc has been ported to many operating
551: systems. Care is taken that packages behave the same on all platforms.
552:
553: 1.1.2. Supported platforms
554:
555: pkgsrc consists of both a source distribution and a binary distribution for
556: these operating systems. After retrieving the required source or binaries, you
557: can be up and running with pkgsrc in just minutes!
558:
559: pkgsrc was derived from FreeBSD's ports system, and initially developed for
560: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
561: platforms:
562:
563: Table 1.1. Platforms supported by pkgsrc
564:
565: +----------------------------------------------------------------+
566: | Platform |Date Support Added|
567: |---------------------------------------------+------------------|
568: |NetBSD | Aug 1997 |
569: |---------------------------------------------+------------------|
570: |Solaris | Mar 1999 |
571: |---------------------------------------------+------------------|
572: |Linux | Jun 1999 |
573: |---------------------------------------------+------------------|
574: |Darwin (Mac OS X) | Oct 2001 |
575: |---------------------------------------------+------------------|
576: |FreeBSD | Nov 2002 |
577: |---------------------------------------------+------------------|
578: |OpenBSD | Nov 2002 |
579: |---------------------------------------------+------------------|
580: |IRIX | Dec 2002 |
581: |---------------------------------------------+------------------|
582: |BSD/OS | Dec 2003 |
583: |---------------------------------------------+------------------|
584: |AIX | Dec 2003 |
585: |---------------------------------------------+------------------|
586: |Interix (Microsoft Windows Services for Unix)| Mar 2004 |
587: |---------------------------------------------+------------------|
588: |DragonFlyBSD | Oct 2004 |
589: |---------------------------------------------+------------------|
590: |OSF/1 | Nov 2004 |
591: |---------------------------------------------+------------------|
592: |HP-UX | Apr 2007 |
1.24 wiz 593: |---------------------------------------------+------------------|
594: |Haiku | Sep 2010 |
1.46 obache 595: |---------------------------------------------+------------------|
1.58 ryoon 596: |MirBSD | Jan 2011 |
1.46 obache 597: |---------------------------------------------+------------------|
598: |Minix3 | Nov 2011 |
599: |---------------------------------------------+------------------|
600: |Cygwin | Mar 2013 |
1.58 ryoon 601: |---------------------------------------------+------------------|
602: |GNU/kFreeBSD | Jul 2013 |
1.1 dsieger 603: +----------------------------------------------------------------+
604:
605:
606: 1.2. Overview
607:
608: This document is divided into three parts. The first, The pkgsrc user's guide,
609: describes how one can use one of the packages in the Package Collection, either
610: by installing a precompiled binary package, or by building one's own copy using
611: the NetBSD package system. The second part, The pkgsrc developer's guide,
612: explains how to prepare a package so it can be easily built by other NetBSD
613: users without knowing about the package's building details. The third part, The
614: pkgsrc infrastructure internals is intended for those who want to understand
615: how pkgsrc is implemented.
616:
617: This document is available in various formats: HTML, PDF, PS, TXT.
618:
619: 1.3. Terminology
620:
621: There has been a lot of talk about "ports", "packages", etc. so far. Here is a
622: description of all the terminology used within this document.
623:
624: Package
625:
626: A set of files and building instructions that describe what's necessary to
627: build a certain piece of software using pkgsrc. Packages are traditionally
628: stored under /usr/pkgsrc.
629:
630: The NetBSD package system
631:
632: This is the former name of "pkgsrc". It is part of the NetBSD operating
633: system and can be bootstrapped to run on non-NetBSD operating systems as
634: well. It handles building (compiling), installing, and removing of
635: packages.
636:
637: Distfile
638:
639: This term describes the file or files that are provided by the author of
640: the piece of software to distribute his work. All the changes necessary to
641: build on NetBSD are reflected in the corresponding package. Usually the
642: distfile is in the form of a compressed tar-archive, but other types are
643: possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
644:
645: Port
646:
647: This is the term used by FreeBSD and OpenBSD people for what we call a
648: package. In NetBSD terminology, "port" refers to a different architecture.
649:
650: Precompiled/binary package
651:
652: A set of binaries built with pkgsrc from a distfile and stuffed together in
653: a single .tgz file so it can be installed on machines of the same machine
654: architecture without the need to recompile. Packages are usually generated
655: in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
656:
657: Sometimes, this is referred to by the term "package" too, especially in the
658: context of precompiled packages.
659:
660: Program
661:
662: The piece of software to be installed which will be constructed from all
663: the files in the distfile by the actions defined in the corresponding
664: package.
665:
666: 1.3.1. Roles involved in pkgsrc
667:
668: pkgsrc users
669:
670: The pkgsrc users are people who use the packages provided by pkgsrc.
671: Typically they are system administrators. The people using the software
672: that is inside the packages (maybe called "end users") are not covered by
673: the pkgsrc guide.
674:
675: There are two kinds of pkgsrc users: Some only want to install pre-built
676: binary packages. Others build the pkgsrc packages from source, either for
677: installing them directly or for building binary packages themselves. For
678: pkgsrc users Part I, "The pkgsrc user's guide" should provide all necessary
679: documentation.
680:
681: package maintainers
682:
683: A package maintainer creates packages as described in Part II, "The pkgsrc
684: developer's guide".
685:
686: infrastructure developers
687:
688: These people are involved in all those files that live in the mk/ directory
689: and below. Only these people should need to read through Part III, "The
690: pkgsrc infrastructure internals", though others might be curious, too.
691:
692: 1.4. Typography
693:
694: When giving examples for commands, shell prompts are used to show if the
695: command should/can be issued as root, or if "normal" user privileges are
696: sufficient. We use a # for root's shell prompt, and a % for users' shell
697: prompt, assuming they use the C-shell or tcsh.
698:
699: Part I. The pkgsrc user's guide
700:
701: Table of Contents
702:
703: 2. Where to get pkgsrc and how to keep it up-to-date
704:
705: 2.1. Getting pkgsrc for the first time
706:
1.52 asau 707: 2.1.1. As tar archive
1.24 wiz 708: 2.1.2. Via anonymous CVS
1.1 dsieger 709:
710: 2.2. Keeping pkgsrc up-to-date
711:
712: 2.2.1. Via tar files
713: 2.2.2. Via CVS
714:
715: 3. Using pkgsrc on systems other than NetBSD
716:
717: 3.1. Binary distribution
718: 3.2. Bootstrapping pkgsrc
719: 3.3. Platform-specific notes
720:
1.46 obache 721: 3.3.1. Cygwin
722: 3.3.2. Darwin (Mac OS X)
723: 3.3.3. FreeBSD
1.58 ryoon 724: 3.3.4. GNU/kFreeBSD
725: 3.3.5. Interix
726: 3.3.6. IRIX
727: 3.3.7. Linux
728: 3.3.8. MirBSD
729: 3.3.9. OpenBSD
730: 3.3.10. Solaris
1.1 dsieger 731:
732: 4. Using pkgsrc
733:
734: 4.1. Using binary packages
735:
736: 4.1.1. Finding binary packages
737: 4.1.2. Installing binary packages
738: 4.1.3. Deinstalling packages
739: 4.1.4. Getting information about installed packages
740: 4.1.5. Checking for security vulnerabilities in installed packages
741: 4.1.6. Finding if newer versions of your installed packages are in
742: pkgsrc
743: 4.1.7. Other administrative functions
744: 4.1.8. A word of warning
745:
746: 4.2. Building packages from source
747:
748: 4.2.1. Requirements
749: 4.2.2. Fetching distfiles
750: 4.2.3. How to build and install
751:
752: 5. Configuring pkgsrc
753:
754: 5.1. General configuration
755: 5.2. Variables affecting the build process
1.9 rillig 756: 5.3. Variables affecting the installation process
1.4 rillig 757: 5.4. Selecting and configuring the compiler
1.1 dsieger 758:
1.4 rillig 759: 5.4.1. Selecting the compiler
760: 5.4.2. Additional flags to the compiler (CFLAGS)
761: 5.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 762:
1.4 rillig 763: 5.5. Developer/advanced settings
764: 5.6. Selecting Build Options
1.1 dsieger 765:
766: 6. Creating binary packages
767:
768: 6.1. Building a single binary package
769: 6.2. Settings for creation of binary packages
770:
1.6 rillig 771: 7. Creating binary packages for everything in pkgsrc (bulk builds)
772:
773: 7.1. Think first, build later
774: 7.2. Requirements of a bulk build
775: 7.3. Running an old-style bulk build
776:
777: 7.3.1. Configuration
778: 7.3.2. Other environmental considerations
779: 7.3.3. Operation
780: 7.3.4. What it does
781: 7.3.5. Disk space requirements
782: 7.3.6. Setting up a sandbox for chrooted builds
783: 7.3.7. Building a partial set of packages
784: 7.3.8. Uploading results of a bulk build
785:
786: 7.4. Running a pbulk-style bulk build
787:
1.15 rillig 788: 7.4.1. Preparation
789: 7.4.2. Configuration
1.6 rillig 790:
791: 7.5. Creating a multiple CD-ROM packages collection
792:
793: 7.5.1. Example of cdpack
794:
795: 8. Directory layout of the installed files
796:
797: 8.1. File system layout in ${LOCALBASE}
798: 8.2. File system layout in ${VARBASE}
799:
800: 9. Frequently Asked Questions
801:
802: 9.1. Are there any mailing lists for pkg-related discussion?
803: 9.2. Where's the pkgviews documentation?
804: 9.3. Utilities for package management (pkgtools)
805: 9.4. How to use pkgsrc as non-root
806: 9.5. How to resume transfers when fetching distfiles?
807: 9.6. How can I install/use modular X.org from pkgsrc?
808: 9.7. How to fetch files from behind a firewall
1.65 ! wiz 809: 9.8. How to fetch files from HTTPS sites
! 810: 9.9. How do I tell make fetch to do passive FTP?
! 811: 9.10. How to fetch all distfiles at once
! 812: 9.11. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
! 813: 9.12. What does "Could not find bsd.own.mk" mean?
! 814: 9.13. Using 'sudo' with pkgsrc
! 815: 9.14. How do I change the location of configuration files?
! 816: 9.15. Automated security checks
! 817: 9.16. Why do some packages ignore my CFLAGS?
! 818: 9.17. A package does not build. What shall I do?
! 819: 9.18. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24 wiz 820: conflicts" mean?
1.1 dsieger 821:
822: Chapter 2. Where to get pkgsrc and how to keep it up-to-date
823:
824: Table of Contents
825:
826: 2.1. Getting pkgsrc for the first time
827:
1.52 asau 828: 2.1.1. As tar archive
1.24 wiz 829: 2.1.2. Via anonymous CVS
1.1 dsieger 830:
831: 2.2. Keeping pkgsrc up-to-date
832:
833: 2.2.1. Via tar files
834: 2.2.2. Via CVS
835:
836: Before you download and extract the files, you need to decide where you want to
837: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
838: usr/pkgsrc. You are though free to install the sources and binary packages
839: wherever you want in your filesystem, provided that the pathname does not
840: contain white-space or other characters that are interpreted specially by the
841: shell and some other programs. A safe bet is to use only letters, digits,
842: underscores and dashes.
843:
844: 2.1. Getting pkgsrc for the first time
845:
1.25 wiz 846: Before you download any pkgsrc files, you should decide whether you want the
1.1 dsieger 847: current branch or the stable branch. The latter is forked on a quarterly basis
848: from the current branch and only gets modified for security updates. The names
849: of the stable branches are built from the year and the quarter, for example
1.22 snj 850: 2009Q1.
1.1 dsieger 851:
852: The second step is to decide how you want to download pkgsrc. You can get it as
1.24 wiz 853: a tar file or via CVS. Both ways are described here.
1.1 dsieger 854:
1.52 asau 855: Note that tar archive contains CVS working copy. Thus you can switch to using
856: CVS at any later time.
1.1 dsieger 857:
1.52 asau 858: Note also that quarterly branch is not frozen in stone. It receives critical
859: updates.
860:
861: 2.1.1. As tar archive
862:
863: The primary download location for all pkgsrc files is http://ftp.NetBSD.org/pub
864: /pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same location).
865: There are a number of subdirectories for different purposes, which are
1.1 dsieger 866: described in detail in Appendix C, Directory layout of the pkgsrc FTP server.
867:
1.52 asau 868: The tar archive for the current branch is in the directory current and is
869: called pkgsrc.tar.gz. It is autogenerated daily.
870:
871: To save download time we provide bzip2- and xz-compressed archives which are
872: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
873:
874: You can fetch the same files using FTP.
1.1 dsieger 875:
1.59 jnemeth 876: The tar file for the stable branch 2013Q1 is in the directory pkgsrc-2013Q1 and
877: is also called pkgsrc.tar.gz.
1.1 dsieger 878:
1.12 weinem 879: To download a pkgsrc stable tarball, run:
880:
1.59 jnemeth 881: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-20xxQy/pkgsrc.tar.gz
1.12 weinem 882:
1.25 wiz 883: Where pkgsrc-20xxQy is the stable branch to be downloaded, for example, "
1.59 jnemeth 884: pkgsrc-2013Q1".
1.12 weinem 885:
1.52 asau 886: You can use fetch it also using "wget", "curl", or your web browser.
887:
1.12 weinem 888: Then, extract it with:
889:
1.23 jakllsch 890: $ tar -xzf pkgsrc-20xxQy.tar.gz -C /usr
1.12 weinem 891:
892: This will create the directory pkgsrc/ in /usr/ and all the package source will
893: be stored under /usr/pkgsrc/.
894:
895: To download pkgsrc-current, run:
896:
897: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1 dsieger 898:
1.24 wiz 899: 2.1.2. Via anonymous CVS
1.1 dsieger 900:
1.24 wiz 901: To fetch a specific pkgsrc stable branch, run:
1.1 dsieger 902:
1.40 wiz 903: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-20xxQy -P pkgsrc
1.1 dsieger 904:
1.25 wiz 905: Where pkgsrc-20xxQy is the stable branch to be checked out, for example, "
906: pkgsrc-2009Q1"
1.13 weinem 907:
1.24 wiz 908: This will create the directory pkgsrc/ in your /usr/ directory and all the
909: package source will be stored under /usr/pkgsrc/.
910:
911: To fetch the pkgsrc current branch, run:
1.1 dsieger 912:
1.40 wiz 913: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 914:
1.30 dholland 915: Refer to the list of available mirrors to choose a faster CVS mirror, if
916: needed.
1.1 dsieger 917:
1.24 wiz 918: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1 dsieger 919:
1.40 wiz 920: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 921:
1.24 wiz 922: Refer to documentation on your command shell how to set CVS_RSH=ssh
923: permanently. For Bourne shells, you can set it in your .profile or better
924: globally in /etc/profile:
925:
926: # set CVS remote shell command
927: CVS_RSH=ssh
928: export CVS_RSH
1.12 weinem 929:
1.13 weinem 930: By default, CVS doesn't do things like most people would expect it to do. But
931: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12 weinem 932: directory and saving the following lines to it. This file will save you lots of
933: headache and some bug reports, so we strongly recommend it. You can find an
934: explanation of this file in the CVS documentation.
1.2 rillig 935:
936: # recommended CVS configuration file from the pkgsrc guide
1.40 wiz 937: cvs -q -z2
1.2 rillig 938: checkout -P
1.4 rillig 939: update -dP
940: diff -upN
1.2 rillig 941: rdiff -u
1.24 wiz 942: release -d
1.1 dsieger 943:
944: 2.2. Keeping pkgsrc up-to-date
945:
946: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
947: have first installed it via a tar file). It saves bandwidth and hard disk
948: activity, compared to downloading the tar file again.
949:
950: 2.2.1. Via tar files
951:
952: Warning
953:
954: When updating from a tar file, you first need to completely remove the old
955: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
956: the mean time will not be removed on your local disk, resulting in
957: inconsistencies. When removing the old files, any changes that you have done to
958: the pkgsrc files will be lost after updating. Therefore updating via CVS is
959: strongly recommended.
960:
961: Note that by default the distfiles and the binary packages are saved in the
962: pkgsrc tree, so don't forget to rescue them before updating. You can also
963: configure pkgsrc to use other than the default directories by setting the
964: DISTDIR and PACKAGES variables. See Chapter 5, Configuring pkgsrc for the
965: details.
966:
967: To update pkgsrc from a tar file, download the tar file as explained above.
968: Then, make sure that you have not made any changes to the files in the pkgsrc
969: directory. Remove the pkgsrc directory and extract the new tar file. Done.
970:
971: 2.2.2. Via CVS
972:
1.26 spz 973: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12 weinem 974:
1.26 spz 975: $ cd /usr/pkgsrc && cvs update -dP
976:
977: If you get error messages from rsh, you need to set CVS_RSH variable as
978: described above. E.g.:
979:
980: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1 dsieger 981:
982: 2.2.2.1. Switching between different pkgsrc branches
983:
984: When updating pkgsrc, the CVS program keeps track of the branch you selected.
985: But if you, for whatever reason, want to switch from the stable branch to the
986: current one, you can do it by adding the option "-A" after the "update"
1.25 wiz 987: keyword. To switch from the current branch back to the stable branch, add the "
988: -rpkgsrc-2009Q3" option.
1.1 dsieger 989:
990: 2.2.2.2. What happens to my changes when updating?
991:
992: When you update pkgsrc, the CVS program will only touch those files that are
993: registered in the CVS repository. That means that any packages that you created
994: on your own will stay unmodified. If you change files that are managed by CVS,
995: later updates will try to merge your changes with those that have been done by
996: others. See the CVS manual, chapter "update" for details.
997:
998: Chapter 3. Using pkgsrc on systems other than NetBSD
999:
1000: Table of Contents
1001:
1002: 3.1. Binary distribution
1003: 3.2. Bootstrapping pkgsrc
1004: 3.3. Platform-specific notes
1005:
1.46 obache 1006: 3.3.1. Cygwin
1007: 3.3.2. Darwin (Mac OS X)
1008: 3.3.3. FreeBSD
1.58 ryoon 1009: 3.3.4. GNU/kFreeBSD
1010: 3.3.5. Interix
1011: 3.3.6. IRIX
1012: 3.3.7. Linux
1013: 3.3.8. MirBSD
1014: 3.3.9. OpenBSD
1015: 3.3.10. Solaris
1.1 dsieger 1016:
1017: 3.1. Binary distribution
1018:
1.9 rillig 1019: See Section 4.1, "Using binary packages".
1.1 dsieger 1020:
1021: 3.2. Bootstrapping pkgsrc
1022:
1.44 asau 1023: pkgsrc can be bootstrapped for use in two different modes: privileged and
1024: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45 asau 1025: programs are installed under one particular user and cannot utilise privileged
1.44 asau 1026: operations (packages don't create special users and all special file
1027: permissions like setuid are ignored).
1028:
1.1 dsieger 1029: Installing the bootstrap kit from source should be as simple as:
1030:
1.60 asau 1031: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1 dsieger 1032: # cd pkgsrc/bootstrap
1033: # ./bootstrap
1034:
1035:
1.44 asau 1036: To bootstrap in unprivileged mode pass "--unprivileged" flag to bootstrap
1037:
1038: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1039: will be installed in, and /var/db/pkg for the package database directory where
1040: pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1041: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1042: for prefix, ~/pkg/var/db/pkg for the package database, and ~/pkg/var for
1043: varbase.
1044:
1045: You can change default layout using command-line arguments. Run "./bootstrap
1046: --help" to get details.
1.1 dsieger 1047:
1048: Note
1049:
1050: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
1051: For examples in this guide, use bmake instead of "make".
1052:
1.44 asau 1053: Note
1054:
1055: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
1056: directories. Use bmake corresponding to the installation you're working with to
1057: build and install packages.
1058:
1.1 dsieger 1059: 3.3. Platform-specific notes
1060:
1061: Here are some platform-specific notes you should be aware of.
1062:
1.46 obache 1063: 3.3.1. Cygwin
1064:
1065: Cygwin 1.7.x and later are supported.
1066:
1067: You need to install minimal base packages in `Base' category plus any of
1068: compiler, gcc, gcc4, and/or clang. For gcc and gcc4, C and C++ compiler will be
1069: installed by default, but you can install Fortran compiler additionally because
1070: it will be required to use libtool. If it is not installed (or too old),
1071: Fortran compiler will be installed with pkgsrc automatically.
1072:
1073: As noted in Cygwin FAQ: `Why doesn't su work?', su(1) command has been in
1074: Cygwin distribution, but it has never worked. Unless you bootstrap pkgsrc with
1075: the --unprivileged option, workaround is:
1076:
1077: * Right click "Cygwin Terminal" in your Start Menu, then pick "Run as
1078: administrator".
1079:
1080: 3.3.2. Darwin (Mac OS X)
1.1 dsieger 1081:
1.42 asau 1082: Darwin 5.x and up are supported.
1083:
1084: Before you start, you need to download and install the Mac OS X Developer Tools
1085: from Apple's Developer Connection. This requires (free) membership. See http://
1086: developer.apple.com/macosx/ for details. Also, make sure you install X11 (an
1087: optional package included with the Developer Tools) if you intend to build
1088: packages that use the X11 Window System. (If you don't want or need the full
1089: Xcode GUI, download and install Command Line Tools for Xcode.)
1.1 dsieger 1090:
1.46 obache 1091: 3.3.3. FreeBSD
1.1 dsieger 1092:
1.30 dholland 1093: FreeBSD 8.3 and 9.0 have been tested and are supported, other versions may
1.1 dsieger 1094: work.
1095:
1096: Care should be taken so that the tools that this kit installs do not conflict
1097: with the FreeBSD userland tools. There are several steps:
1098:
1099: 1. FreeBSD stores its ports pkg database in /var/db/pkg. It is therefore
1100: recommended that you choose a different location (e.g. /usr/pkgdb) by using
1101: the --pkgdbdir option to the bootstrap script.
1102:
1103: 2. If you do not intend to use the FreeBSD ports tools, it's probably a good
1104: idea to move them out of the way to avoid confusion, e.g.
1105:
1106: # cd /usr/sbin
1107: # mv pkg_add pkg_add.orig
1108: # mv pkg_create pkg_create.orig
1109: # mv pkg_delete pkg_delete.orig
1110: # mv pkg_info pkg_info.orig
1111:
1112:
1.4 rillig 1113: 3. An example mk.conf file will be placed in /etc/mk.conf.example file when
1114: you use the bootstrap script.
1.1 dsieger 1115:
1.58 ryoon 1116: 3.3.4. GNU/kFreeBSD
1117:
1118: Debian GNU/kFreeBSD is the only GNU/kFreeBSD distribution now. Debian GNU/
1119: kFreeBSD 7.0 or later is tested and supported.
1120:
1121: You should install ncurses (libncurses and libncurses-dev) packages.
1122:
1123: 3.3.5. Interix
1.1 dsieger 1124:
1125: Interix is a POSIX-compatible subsystem for the Windows NT kernel, providing a
1126: Unix-like environment with a tighter kernel integration than available with
1127: Cygwin. It is part of the Windows Services for Unix package, available for free
1128: for any licensed copy of Windows 2000, XP (not including XP Home), or 2003. SFU
1129: can be downloaded from http://www.microsoft.com/windows/sfu/.
1130:
1131: Services for Unix 3.5 has been tested. 3.0 or 3.1 may work, but are not
1132: officially supported. (The main difference in 3.0/3.1 is lack of pthreads, but
1133: other parts of libc may also be lacking.)
1134:
1135: Services for Unix Applications (aka SUA) is an integrated component of Windows
1.24 wiz 1136: Server 2003 R2 (5.2), Windows Vista and Windows Server 2008 (6.0), Windows 7
1.25 wiz 1137: and Windows Server 2008 R2 (6.1). As of this writing, the SUA's Interix 6.0
1138: (32bit) and 6.1 (64bit) subsystems have been tested. Other versions may work as
1139: well. The Interix 5.x subsystem has not yet been tested with pkgsrc.
1.1 dsieger 1140:
1.58 ryoon 1141: 3.3.5.1. When installing Interix/SFU
1.1 dsieger 1142:
1143: At an absolute minimum, the following packages must be installed from the
1144: Windows Services for Unix 3.5 distribution in order to use pkgsrc:
1145:
1146: * Utilities -> Base Utilities
1147:
1148: * Interix GNU Components -> (all)
1149:
1150: * Remote Connectivity
1151:
1152: * Interix SDK
1153:
1154: When using pkgsrc on Interix, DO NOT install the Utilities subcomponent "UNIX
1155: Perl". That is Perl 5.6 without shared module support, installed to /usr/local,
1156: and will only cause confusion. Instead, install Perl 5.8 from pkgsrc (or from a
1157: binary package).
1158:
1159: The Remote Connectivity subcomponent "Windows Remote Shell Service" does not
1160: need to be installed, but Remote Connectivity itself should be installed in
1161: order to have a working inetd.
1162:
1163: During installation you may be asked whether to enable setuid behavior for
1164: Interix programs, and whether to make pathnames default to case-sensitive.
1165: Setuid should be enabled, and case-sensitivity MUST be enabled. (Without
1166: case-sensitivity, a large number of packages including perl will not build.)
1167:
1168: NOTE: Newer Windows service packs change the way binary execution works (via
1169: the Data Execution Prevention feature). In order to use pkgsrc and other
1170: gcc-compiled binaries reliably, a hotfix containing POSIX.EXE, PSXDLL.DLL,
1171: PSXRUN.EXE, and PSXSS.EXE (899522 or newer) must be installed. Hotfixes are
1.14 jmcneill 1172: available from Microsoft through a support contract; however, Debian Interix
1173: Port has made most Interix hotfixes available for personal use from http://
1174: www.debian-interix.net/hotfixes/.
1.1 dsieger 1175:
1176: In addition to the hotfix noted above, it may be necessary to disable Data
1177: Execution Prevention entirely to make Interix functional. This may happen only
1178: with certain types of CPUs; the cause is not fully understood at this time. If
1179: gcc or other applications still segfault repeatedly after installing one of the
1180: hotfixes note above, the following option can be added to the appropriate
1181: "boot.ini" line on the Windows boot drive: /NoExecute=AlwaysOff (WARNING, this
1182: will disable DEP completely, which may be a security risk if applications are
1183: often run as a user in the Administrators group!)
1184:
1.58 ryoon 1185: 3.3.5.2. What to do if Interix/SFU is already installed
1.1 dsieger 1186:
1187: If SFU is already installed and you wish to alter these settings to work with
1188: pkgsrc, note the following things.
1189:
1190: * To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft Windows
1191: Services for UNIX, then click Change. In the installer, choose Add or
1192: Remove, then uncheck Utilities->UNIX Perl.
1193:
1194: * To enable case-sensitivity for the file system, run REGEDIT.EXE, and change
1195: the following registry key:
1196:
1197: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel
1198:
1199: Set the DWORD value "obcaseinsensitive" to 0; then reboot.
1200:
1201: * To enable setuid binaries (optional), run REGEDIT.EXE, and change the
1202: following registry key:
1203:
1204: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX
1205:
1206: Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.
1207:
1.58 ryoon 1208: 3.3.5.3. Important notes for using pkgsrc
1.1 dsieger 1209:
1210: The package manager (either the pkgsrc "su" user, or the user running
1211: "pkg_add") must be a member of the local Administrators group. Such a user must
1212: also be used to run the bootstrap. This is slightly relaxed from the normal
1213: pkgsrc requirement of "root".
1214:
1215: The package manager should use a umask of 002. "make install" will
1216: automatically complain if this is not the case. This ensures that directories
1217: written in /var/db/pkg are Administrators-group writeable.
1218:
1219: The popular Interix binary packages from http://www.interopsystems.com/ use an
1220: older version of pkgsrc's pkg_* tools. Ideally, these should NOT be used in
1221: conjunction with pkgsrc. If you choose to use them at the same time as the
1222: pkgsrc packages, ensure that you use the proper pkg_* tools for each type of
1223: binary package.
1224:
1225: The TERM setting used for DOS-type console windows (including those invoked by
1226: the csh and ksh startup shortcuts) is "interix". Most systems don't have a
1227: termcap/terminfo entry for it, but the following .termcap entry provides
1228: adequate emulation in most cases:
1229:
1230: interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
1231:
1232:
1.58 ryoon 1233: 3.3.5.4. Limitations of the Interix platform
1.1 dsieger 1234:
1235: Though Interix suffices as a familiar and flexible substitute for a full
1236: Unix-like platform, it has some drawbacks that should be noted for those
1237: desiring to make the most of Interix.
1238:
1239: * X11:
1240:
1241: Interix comes with the standard set of X11R6 client libraries, and can run
1242: X11 based applications, but it does not come with an X server. Some options
1243: are StarNet X-Win32, Hummingbird Exceed (available in a trimmed version for
1244: Interix from Interop Systems as the Interop X Server), and the free X11
1245: server included with Cygwin.
1246:
1247: * X11 acceleration:
1248:
1249: Because Interix runs in a completely different NT subsystem from Win32
1250: applications, it does not currently support various X11 protocol extensions
1251: for acceleration (such as MIT-SHM or DGA). Most interactive applications to
1252: a local X server will run reasonably fast, but full motion video and other
1253: graphics intensive applications may require a faster-than-expected CPU.
1254:
1255: * Audio:
1256:
1257: Interix has no native support for audio output. For audio support, pkgsrc
1258: uses the esound client/server audio system on Interix. Unlike on most
1259: platforms, the audio/esound package does not contain the esd server
1260: component. To output audio via an Interix host, the emulators/cygwin_esound
1261: package must also be installed.
1262:
1263: * CD/DVDs, USB, and SCSI:
1264:
1265: Direct device access is not currently supported in Interix, so it is not
1266: currently possible to access CD/DVD drives, USB devices, or SCSI devices
1267: through non-filesystem means. Among other things, this makes it impossible
1268: to use Interix directly for CD/DVD burning.
1269:
1270: * Tape drives:
1271:
1272: Due to the same limitations as for CD-ROMs and SCSI devices, tape drives
1273: are also not directly accessible in Interix. However, support is in work to
1274: make tape drive access possible by using Cygwin as a bridge (similarly to
1275: audio bridged via Cygwin's esound server).
1276:
1.58 ryoon 1277: 3.3.5.5. Known issues for pkgsrc on Interix
1.1 dsieger 1278:
1279: It is not necessary, in general, to have a "root" user on the Windows system;
1280: any member of the local Administrators group will suffice. However, some
1281: packages currently assume that the user named "root" is the privileged user. To
1282: accommodate these, you may create such a user; make sure it is in the local
1283: group Administrators (or your language equivalent).
1284:
1285: pkg_add creates directories of mode 0755, not 0775, in $PKG_DBDIR. For the time
1286: being, install packages as the local Administrator (or your language
1287: equivalent), or run the following command after installing a package to work
1288: around the issue:
1289:
1290: # chmod -R g+w $PKG_DBDIR
1291:
1292:
1.58 ryoon 1293: 3.3.6. IRIX
1.1 dsieger 1294:
1295: You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
1296: compiler (cc/c89). Please set the CC environment variable according to your
1297: preference. If you do not have a license for the MIPSpro compiler suite, you
1298: can download a gcc tardist file from http://freeware.sgi.com/.
1299:
1300: Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
1301: version of IRIX providing support for if_indextoname(3), if_nametoindex(3),
1302: etc.
1303:
1304: At this point in time, pkgsrc only supports one ABI at a time. That is, you
1305: cannot switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit
1306: ABI. If you start out using "abi=n32", that's what all your packages will be
1307: built with.
1308:
1309: Therefore, please make sure that you have no conflicting CFLAGS in your
1.4 rillig 1310: environment or the mk.conf. Particularly, make sure that you do not try to link
1311: n32 object files with lib64 or vice versa. Check your /etc/compiler.defaults!
1.1 dsieger 1312:
1313: If you have the actual pkgsrc tree mounted via NFS from a different host,
1314: please make sure to set WRKOBJDIR to a local directory, as it appears that IRIX
1315: linker occasionally runs into issues when trying to link over a network-mounted
1316: file system.
1317:
1318: The bootstrapping process should set all the right options for programs such as
1319: imake(1), but you may want to set some options depending on your local setup.
1320: Please see pkgsrc/mk/defaults/mk.conf and, of course, your compiler's man pages
1321: for details.
1322:
1323: If you are using SGI's MIPSPro compiler, please set
1324:
1325: PKGSRC_COMPILER= mipspro
1326:
1327:
1.4 rillig 1328: in mk.conf. Otherwise, pkgsrc will assume you are using gcc and may end up
1.1 dsieger 1329: passing invalid flags to the compiler. Note that bootstrap should create an
1330: appropriate mk.conf.example by default.
1331:
1332: If you have both the MIPSPro compiler chain installed as well as gcc, but want
1333: to make sure that MIPSPro is used, please set your PATH to not include the
1334: location of gcc (often /usr/freeware/bin), and (important) pass the
1335: '--preserve-path' flag.
1336:
1.58 ryoon 1337: 3.3.7. Linux
1.1 dsieger 1338:
1339: Some versions of Linux (for example Debian GNU/Linux) need either libtermcap or
1340: libcurses (libncurses). Installing the distributions libncurses-dev package (or
1341: equivalent) should fix the problem.
1342:
1343: pkgsrc supports both gcc (GNU Compiler Collection) and icc (Intel C++
1344: Compiler). gcc is the default. icc 8.0 and 8.1 on i386 have been tested.
1345:
1346: To bootstrap using icc, assuming the default icc installation directory:
1347:
1.32 wiz 1348: env ICCBASE=/opt/intel/cc/10.1.008 ./bootstrap --compiler=icc
1.1 dsieger 1349:
1350:
1351: Note
1352:
1.32 wiz 1353: For icc 8.0 you must add `LDFLAGS=-static-libcxa' to this.
1.1 dsieger 1354:
1.32 wiz 1355: For icc 8.1 you must add `LDFLAGS=-i-static' instead.
1.1 dsieger 1356:
1.32 wiz 1357: For icc 10.1 neither of these appears to be necessary.
1.1 dsieger 1358:
1.32 wiz 1359: Use a value for ICCBASE that corresponds to the directory where icc is
1360: installed. After bootstrapping, set ICCBASE in mk.conf:
1.1 dsieger 1361:
1.32 wiz 1362: ICCBASE= /opt/intel/cc/10.1.008
1.1 dsieger 1363:
1364:
1.32 wiz 1365: The pkgsrc default for ICCBASE is /opt/intel_cc_80. This is the default install
1366: directory for icc 8.0. If you are using a more recent version, be sure to set
1367: the correct path explicitly.
1.1 dsieger 1368:
1369: pkgsrc uses the static linking method of the runtime libraries provided by icc,
1370: so binaries can be run on other systems which do not have the shared libraries
1371: installed.
1372:
1373: Libtool, however, extracts a list of libraries from the ld(1) command run when
1374: linking a C++ shared library and records it, throwing away the -Bstatic and
1375: -Bdynamic options interspersed between the libraries. This means that
1376: libtool-linked C++ shared libraries will have a runtime dependency on the icc
1377: libraries until this is fixed in libtool.
1378:
1.58 ryoon 1379: 3.3.8. MirBSD
1380:
1381: pkgsrc has been tested on MirBSD #10-current (2011 and newer). Older versions
1382: might also work. Releases before #10 are not supported.
1383:
1384: The package tools of the (older) native ports tree, MirPorts, have the same
1385: names as the ones used by pkgsrc. Care should be taken that the right tools are
1386: used. When installing packages from source, use the bmake command for pkgsrc
1387: and mmake for MirPorts.
1388:
1389: pkgsrc and MirPorts use the same location for the package database, /var/db/
1390: pkg. It is strongly recommended to use /usr/pkg/db instead, so that the pkgsrc
1391: tree is self-contained. This is also the default setting used in the binary
1392: package builds.
1393:
1394: Binary packages for MirBSD/i386 can be found on the pkgsrc ftp server. The
1395: bootstrap kit there already contains the pkgin package manager. See the pkgsrc
1396: on MirOS page for more details.
1397:
1398: 3.3.9. OpenBSD
1.1 dsieger 1399:
1.30 dholland 1400: OpenBSD 5.1 has been tested and supported, other versions may work.
1.1 dsieger 1401:
1402: Care should be taken so that the tools that this kit installs do not conflict
1403: with the OpenBSD userland tools. There are several steps:
1404:
1405: 1. OpenBSD stores its ports pkg database in /var/db/pkg. It is therefore
1406: recommended that you choose a different location (e.g. /usr/pkgdb) by using
1407: the --pkgdbdir option to the bootstrap script.
1408:
1409: 2. If you do not intend to use the OpenBSD ports tools, it's probably a good
1410: idea to move them out of the way to avoid confusion, e.g.
1411:
1412: # cd /usr/sbin
1413: # mv pkg_add pkg_add.orig
1414: # mv pkg_create pkg_create.orig
1415: # mv pkg_delete pkg_delete.orig
1416: # mv pkg_info pkg_info.orig
1417:
1418:
1.4 rillig 1419: 3. An example mk.conf file will be placed in /etc/mk.conf.example file when
1420: you use the bootstrap script. OpenBSD's make program uses mk.conf as well.
1421: You can work around this by enclosing all the pkgsrc-specific parts of the
1422: file with:
1.1 dsieger 1423:
1424: .ifdef BSD_PKG_MK
1425: # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
1426: .else
1427: # OpenBSD stuff
1428: .endif
1429:
1430:
1.58 ryoon 1431: 3.3.10. Solaris
1.1 dsieger 1432:
1.36 wiz 1433: Solaris 2.6 through 10 are supported on both x86 and sparc. You will need a
1434: working C compiler. Both gcc 4.5.3 and Sun WorkShop 5 have been tested.
1.1 dsieger 1435:
1436: The following packages are required on Solaris 8 for the bootstrap process and
1437: to build packages.
1438:
1439: * SUNWsprot
1440:
1441: * SUNWarc
1442:
1443: * SUNWbtool
1444:
1445: * SUNWtoo
1446:
1447: * SUNWlibm
1448:
1449: Please note that the use of GNU binutils on Solaris is not supported, as of
1450: June 2006.
1451:
1452: Whichever compiler you use, please ensure the compiler tools and your $prefix
1453: are in your PATH. This includes /usr/ccs/{bin,lib} and e.g. /usr/pkg/
1454: {bin,sbin}.
1455:
1.58 ryoon 1456: 3.3.10.1. If you are using gcc
1.1 dsieger 1457:
1458: It makes life much simpler if you only use the same gcc consistently for
1459: building all packages.
1460:
1461: It is recommended that an external gcc be used only for bootstrapping, then
1.36 wiz 1462: either build gcc from lang/gcc46 or install a binary gcc package, then remove
1463: gcc used during bootstrapping.
1.1 dsieger 1464:
1465: Binary packages of gcc can be found through http://www.sunfreeware.com/.
1466:
1.58 ryoon 1467: 3.3.10.2. If you are using Sun WorkShop
1.1 dsieger 1468:
1469: You will need at least the following packages installed (from WorkShop 5.0)
1470:
1471: * SPROcc - Sun WorkShop Compiler C 5.0
1472:
1473: * SPROcpl - Sun WorkShop Compiler C++ 5.0
1474:
1475: * SPROild - Sun WorkShop Incremental Linker
1476:
1477: * SPROlang - Sun WorkShop Compilers common components
1478:
1479: You should set the following variables in your mk.conf file:
1480:
1481: CC= cc
1482: CXX= CC
1483: CPP= cc -E
1484: CXXCPP= CC -E
1485:
1486: Note
1487:
1488: The CPP setting might break some packages that use the C preprocessor for
1489: processing things other than C source code.
1490:
1.58 ryoon 1491: 3.3.10.3. Building 64-bit binaries with SunPro
1.1 dsieger 1492:
1493: To build 64-bit packages, you just need to have the following lines in your
1494: mk.conf file:
1495:
1496: PKGSRC_COMPILER= sunpro
1497: ABI= 64
1498:
1499: Note
1500:
1501: This setting has been tested for the SPARC architecture. Intel and AMD machines
1502: need some more work.
1503:
1.58 ryoon 1504: 3.3.10.4. Common problems
1.1 dsieger 1505:
1506: Sometimes, when using libtool, /bin/ksh crashes with a segmentation fault. The
1507: workaround is to use another shell for the configure scripts, for example by
1508: installing shells/bash and adding the following lines to your mk.conf:
1509:
1510: CONFIG_SHELL= ${LOCALBASE}/bin/bash
1511: WRAPPER_SHELL= ${LOCALBASE}/bin/bash
1512:
1513:
1514: Then, rebuild the devel/libtool-base package.
1515:
1516: Chapter 4. Using pkgsrc
1517:
1518: Table of Contents
1519:
1520: 4.1. Using binary packages
1521:
1522: 4.1.1. Finding binary packages
1523: 4.1.2. Installing binary packages
1524: 4.1.3. Deinstalling packages
1525: 4.1.4. Getting information about installed packages
1526: 4.1.5. Checking for security vulnerabilities in installed packages
1527: 4.1.6. Finding if newer versions of your installed packages are in pkgsrc
1528: 4.1.7. Other administrative functions
1529: 4.1.8. A word of warning
1530:
1531: 4.2. Building packages from source
1532:
1533: 4.2.1. Requirements
1534: 4.2.2. Fetching distfiles
1535: 4.2.3. How to build and install
1536:
1537: Basically, there are two ways of using pkgsrc. The first is to only install the
1538: package tools and to use binary packages that someone else has prepared. This
1539: is the "pkg" in pkgsrc. The second way is to install the "src" of pkgsrc, too.
1540: Then you are able to build your own packages, and you can still use binary
1541: packages from someone else.
1542:
1543: 4.1. Using binary packages
1544:
1.9 rillig 1545: On the ftp.NetBSD.org server and its mirrors, there are collections of binary
1546: packages, ready to be installed. These binary packages have been built using
1547: the default settings for the directories, that is:
1548:
1549: * /usr/pkg for LOCALBASE, where most of the files are installed,
1550:
1551: * /usr/pkg/etc for configuration files,
1552:
1553: * /var for VARBASE, where those files are installed that may change after
1554: installation.
1555:
1556: If you cannot use these directories for whatever reasons (maybe because you're
1557: not root), you cannot use these binary packages, but have to build the packages
1558: yourself, which is explained in Section 3.2, "Bootstrapping pkgsrc".
1.1 dsieger 1559:
1560: 4.1.1. Finding binary packages
1561:
1.5 weinem 1562: To install binary packages, you first need to know from where to get them. The
1563: first place where you should look is on the main pkgsrc FTP server in the
1564: directory /pub/pkgsrc/packages.
1565:
1566: This directory contains binary packages for multiple platforms. First, select
1567: your operating system. (Ignore the directories with version numbers attached to
1568: it, they just exist for legacy reasons.) Then, select your hardware
1569: architecture, and in the third step, the OS version and the "version" of
1.9 rillig 1570: pkgsrc.
1571:
1572: In this directory, you often find a file called bootstrap.tar.gz which contains
1573: the package management tools. If the file is missing, it is likely that your
1574: operating system already provides those tools. Download the file and extract it
1575: in the / directory. It will create the directories /usr/pkg (containing the
1576: tools for managing binary packages) and /var/db/pkg (the database of installed
1577: packages).
1.1 dsieger 1578:
1579: 4.1.2. Installing binary packages
1580:
1.9 rillig 1581: In the directory from the last section, there is a subdirectory called All,
1582: which contains all the binary packages that are available for the platform,
1583: excluding those that may not be distributed via FTP or CDROM (depending on
1.24 wiz 1584: which medium you are using).
1.9 rillig 1585:
1586: To install packages directly from an FTP or HTTP server, run the following
1587: commands in a Bourne-compatible shell (be sure to su to root first):
1588:
1589: # PATH="/usr/pkg/sbin:$PATH"
1590: # PKG_PATH="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/OPSYS/ARCH/VERSIONS/All"
1591: # export PATH PKG_PATH
1592:
1593: Instead of URLs, you can also use local paths, for example if you are
1594: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
1595: to install packages from multiple sources, you can separate them by a semicolon
1596: in PKG_PATH.
1597:
1598: After these preparations, installing a package is very easy:
1599:
1600: # pkg_add openoffice2
1601: # pkg_add kde-3.5.7
1602: # pkg_add ap2-php5-*
1.1 dsieger 1603:
1604: Note that any prerequisite packages needed to run the package in question will
1605: be installed, too, assuming they are present where you install from.
1606:
1.25 wiz 1607: Adding packages might install vulnerable packages. Thus you should run
1.24 wiz 1608: pkg_admin audit regularly, especially after installing new packages, and verify
1609: that the vulnerabilities are acceptable for your configuration.
1.1 dsieger 1610:
1611: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
1612: in your PATH so you can actually start the just installed program.
1613:
1614: 4.1.3. Deinstalling packages
1615:
1616: To deinstall a package, it does not matter whether it was installed from source
1617: code or from a binary package. The pkg_delete command does not know it anyway.
1618: To delete a package, you can just run pkg_delete package-name. The package name
1619: can be given with or without version number. Wildcards can also be used to
1620: deinstall a set of packages, for example *emacs*. Be sure to include them in
1621: quotes, so that the shell does not expand them before pkg_delete sees them.
1622:
1623: The -r option is very powerful: it removes all the packages that require the
1624: package in question and then removes the package itself. For example:
1625:
1626: # pkg_delete -r jpeg
1627:
1628:
1629: will remove jpeg and all the packages that used it; this allows upgrading the
1630: jpeg package.
1631:
1632: 4.1.4. Getting information about installed packages
1633:
1634: The pkg_info shows information about installed packages or binary package
1635: files.
1636:
1637: 4.1.5. Checking for security vulnerabilities in installed packages
1638:
1639: The NetBSD Security-Officer and Packages Groups maintain a list of known
1640: security vulnerabilities to packages which are (or have been) included in
1641: pkgsrc. The list is available from the NetBSD FTP site at ftp://ftp.NetBSD.org/
1642: pub/pkgsrc/distfiles/vulnerabilities.
1643:
1.23 jakllsch 1644: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
1645: automatically, and a security audit of all packages installed on a system can
1646: take place.
1647:
1648: There are two components to auditing. The first step, pkg_admin
1649: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
1650: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
1651: your installed packages are vulnerable. If a package is vulnerable, you will
1652: see output similar to the following:
1.1 dsieger 1653:
1654: Package samba-2.0.9 has a local-root-shell vulnerability, see
1655: http://www.samba.org/samba/whatsnew/macroexploit.html
1656:
1.23 jakllsch 1657: You may wish to have the vulnerabilities file downloaded daily so that it
1658: remains current. This may be done by adding an appropriate entry to the root
1659: users crontab(5) entry. For example the entry
1660:
1661: # download vulnerabilities file
1662: 0 3 * * * /usr/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1663:
1664:
1665: will update the vulnerability list every day at 3AM. You may wish to do this
1666: more often than once a day. In addition, you may wish to run the package audit
1667: from the daily security script. This may be accomplished by adding the
1668: following line to /etc/security.local:
1669:
1670: /usr/sbin/pkg_admin audit
1671:
1.1 dsieger 1672:
1673: 4.1.6. Finding if newer versions of your installed packages are in pkgsrc
1674:
1.12 weinem 1675: Install pkgtools/lintpkgsrc and run lintpkgsrc with the "-i" argument to check
1676: if your packages are up-to-date, e.g.
1.1 dsieger 1677:
1678: % lintpkgsrc -i
1679: ...
1680: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
1681:
1682:
1683: You can then use make update to update the package on your system and rebuild
1684: any dependencies.
1685:
1686: 4.1.7. Other administrative functions
1687:
1688: The pkg_admin executes various administrative functions on the package system.
1689:
1690: 4.1.8. A word of warning
1691:
1692: Please pay very careful attention to the warnings expressed in the pkg_add(1)
1693: manual page about the inherent dangers of installing binary packages which you
1694: did not create yourself, and the security holes that can be introduced onto
1695: your system by indiscriminate adding of such files.
1696:
1697: The same warning of course applies to every package you install from source
1698: when you haven't completely read and understood the source code of the package,
1699: the compiler that is used to build the package and all the other tools that are
1700: involved.
1701:
1702: 4.2. Building packages from source
1703:
1704: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25 wiz 1705: organized into categories. You can browse the online index of packages, or run
1.1 dsieger 1706: make readme from the pkgsrc directory to build local README.html files for all
1707: packages, viewable with any web browser such as www/lynx or www/firefox.
1708:
1709: The default prefix for installed packages is /usr/pkg. If you wish to change
1710: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
1711: use multiple different LOCALBASE definitions on the same system (inside a
1712: chroot is an exception).
1713:
1714: The rest of this chapter assumes that the package is already in pkgsrc. If it
1715: is not, see Part II, "The pkgsrc developer's guide" for instructions how to
1716: create your own packages.
1717:
1718: 4.2.1. Requirements
1719:
1720: To build packages from source, you need a working C compiler. On NetBSD, you
1721: need to install the "comp" and the "text" distribution sets. If you want to
1722: build X11-related packages, the "xbase" and "xcomp" distribution sets are
1723: required, too.
1724:
1725: 4.2.2. Fetching distfiles
1726:
1727: The first step for building a package is downloading the distfiles (i.e. the
1728: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
1729: them automatically.
1730:
1731: If you have all files that you need in the distfiles directory, you don't need
1732: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
1733: and add:
1734:
1735: DISTDIR=/cdrom/pkgsrc/distfiles
1736:
1737: to your mk.conf.
1738:
1739: By default a list of distribution sites will be randomly intermixed to prevent
1740: huge load on servers which holding popular packages (for example,
1741: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
1742: distfile all the mirrors will be tried in new (random) order. You can turn this
1743: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
1744: disabled).
1745:
1746: You can overwrite some of the major distribution sites to fit to sites that are
1747: close to your own. By setting one or two variables you can modify the order in
1748: which the master sites are accessed. MASTER_SORT contains a whitespace
1749: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
1750: contains a whitespace delimited list of regular expressions. It has higher
1751: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
1752: some examples. This may save some of your bandwidth and time.
1753:
1754: You can change these settings either in your shell's environment, or, if you
1.4 rillig 1755: want to keep the settings, by editing the mk.conf file, and adding the
1.1 dsieger 1756: definitions there.
1757:
1758: If a package depends on many other packages (such as meta-pkgs/kde3), the build
1759: process may alternate between periods of downloading source, and compiling. To
1760: ensure you have all the source downloaded initially you can run the command:
1761:
1762: % make fetch-list | sh
1763:
1764: which will output and run a set of shell commands to fetch the necessary files
1765: into the distfiles directory. You can also choose to download the files
1766: manually.
1767:
1768: 4.2.3. How to build and install
1769:
1770: Once the software has downloaded, any patches will be applied, then it will be
1771: compiled for you. This may take some time depending on your computer, and how
1772: many other packages the software depends on and their compile time.
1773:
1774: Note
1775:
1776: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
1777: command instead of "make" in the examples in this guide.
1778:
1779: For example, type
1780:
1781: % cd misc/figlet
1782: % make
1783:
1784:
1785: at the shell prompt to build the various components of the package.
1786:
1787: The next stage is to actually install the newly compiled program onto your
1788: system. Do this by entering:
1789:
1790: % make install
1791:
1792:
1793: while you are still in the directory for whatever package you are installing.
1794:
1795: Installing the package on your system may require you to be root. However,
1796: pkgsrc has a just-in-time-su feature, which allows you to only become root for
1797: the actual installation step.
1798:
1799: That's it, the software should now be installed and setup for use. You can now
1800: enter:
1801:
1802: % make clean
1803:
1804:
1805: to remove the compiled files in the work directory, as you shouldn't need them
1806: any more. If other packages were also added to your system (dependencies) to
1807: allow your program to compile, you can tidy these up also with the command:
1808:
1809: % make clean-depends
1810:
1811:
1812: Taking the figlet utility as an example, we can install it on our system by
1813: building as shown in Appendix B, Build logs.
1814:
1815: The program is installed under the default root of the packages tree - /usr/
1816: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
1817: environment, and it will use that value as the root of your packages tree. So,
1818: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
1819: that you should use a directory which is dedicated to packages and not shared
1820: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
1821: not try to add any of your own files or directories (such as src/, obj/, or
1822: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
1823: between programs and other files installed by the package system and whatever
1824: else may have been installed there.
1825:
1.4 rillig 1826: Some packages look in mk.conf to alter some configuration options at build
1.1 dsieger 1827: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
1828: be set there by default. Environment variables such as LOCALBASE can be set in
1.4 rillig 1829: mk.conf to save having to remember to set them each time you want to use
1.1 dsieger 1830: pkgsrc.
1831:
1832: Occasionally, people want to "look under the covers" to see what is going on
1833: when a package is building or being installed. This may be for debugging
1834: purposes, or out of simple curiosity. A number of utility values have been
1835: added to help with this.
1836:
1837: 1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
1838: amount of information will be displayed. For example,
1839:
1840: make patch PKG_DEBUG_LEVEL=2
1841:
1.25 wiz 1842: will show all the commands that are invoked, up to and including the "patch
1843: " stage.
1.1 dsieger 1844:
1845: 2. If you want to know the value of a certain make(1) definition, then the
1846: VARNAME definition should be used, in conjunction with the show-var target.
1847: e.g. to show the expansion of the make(1) variable LOCALBASE:
1848:
1849: % make show-var VARNAME=LOCALBASE
1850: /usr/pkg
1851: %
1852:
1853:
1854: If you want to install a binary package that you've either created yourself
1855: (see next section), that you put into pkgsrc/packages manually or that is
1856: located on a remote FTP server, you can use the "bin-install" target. This
1857: target will install a binary package - if available - via pkg_add(1), else do a
1858: make package. The list of remote FTP sites searched is kept in the variable
1859: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
1860: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
1861: for more details.
1862:
1863: A final word of warning: If you set up a system that has a non-standard setting
1864: for LOCALBASE, be sure to set that before any packages are installed, as you
1865: cannot use several directories for the same purpose. Doing so will result in
1866: pkgsrc not being able to properly detect your installed packages, and fail
1867: miserably. Note also that precompiled binary packages are usually built with
1868: the default LOCALBASE of /usr/pkg, and that you should not install any if you
1869: use a non-standard LOCALBASE.
1870:
1871: Chapter 5. Configuring pkgsrc
1872:
1873: Table of Contents
1874:
1875: 5.1. General configuration
1876: 5.2. Variables affecting the build process
1.9 rillig 1877: 5.3. Variables affecting the installation process
1.4 rillig 1878: 5.4. Selecting and configuring the compiler
1.1 dsieger 1879:
1.4 rillig 1880: 5.4.1. Selecting the compiler
1881: 5.4.2. Additional flags to the compiler (CFLAGS)
1882: 5.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 1883:
1.4 rillig 1884: 5.5. Developer/advanced settings
1885: 5.6. Selecting Build Options
1.1 dsieger 1886:
1887: The whole pkgsrc system is configured in a single file, usually called mk.conf.
1888: In which directory pkgsrc looks for that file depends on the installation. On
1889: NetBSD, when you use make(1) from the base system, it is in the directory /etc
1890: /. In all other cases the default location is ${PREFIX}/etc/, depending on
1891: where you told the bootstrap program to install the binary packages.
1892:
1893: During the bootstrap, an example configuration file is created. To use that,
1894: you have to create the directory ${PREFIX}/etc and copy the example file there.
1895:
1896: The format of the configuration file is that of the usual BSD-style Makefiles.
1897: The whole pkgsrc configuration is done by setting variables in this file. Note
1898: that you can define all kinds of variables, and no special error checking (for
1899: example for spelling mistakes) takes place, so you have to try it out to see if
1900: it works.
1901:
1902: 5.1. General configuration
1903:
1904: In this section, you can find some variables that apply to all pkgsrc packages.
1905: A complete list of the variables that can be configured by the user is
1906: available in mk/defaults/mk.conf, together with some comments that describe
1907: each variable's intent.
1908:
1909: * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
1910: not mix binary packages with different LOCALBASEs!
1911:
1912: * CROSSBASE: Where "cross" category packages will be installed. The default
1913: is ${LOCALBASE}/cross.
1914:
1915: * X11BASE: Where X11 is installed on the system. The default is /usr/X11R6.
1916:
1917: * DISTDIR: Where to store the downloaded copies of the original source
1918: distributions used for building pkgsrc packages. The default is $
1919: {PKGSRCDIR}/distfiles.
1920:
1921: * PKG_DBDIR: Where the database about installed packages is stored. The
1922: default is /var/db/pkg.
1923:
1924: * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
1925: value.
1926:
1927: * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
1928: files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.26 spz 1929: respectively. The defaults are ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1930: {DIST_SUBDIR}/ and ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/$
1.1 dsieger 1931: {DIST_SUBDIR}/.
1932:
1933: * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
1934: with OS release ("2.0", etc.) and architecture ("mipsel", etc.).
1935:
1.23 jakllsch 1936: * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
1937: case-sensitive. Whenever you try to build a package whose license is not in
1938: this list, you will get an error message. If the license condition is
1939: simple enough, the error message will include specific instructions on how
1940: to change this variable.
1.1 dsieger 1941:
1942: 5.2. Variables affecting the build process
1943:
1944: XXX
1945:
1946: * PACKAGES: The top level directory for the binary packages. The default is $
1947: {PKGSRCDIR}/packages.
1948:
1949: * WRKOBJDIR: The top level directory where, if defined, the separate working
1950: directories will get created, and symbolically linked to from ${WRKDIR}
1951: (see below). This is useful for building packages on several architectures,
1952: then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
1953: architecture. (It should be noted that PKGSRCDIR should not be set by the
1954: user ? it is an internal definition which refers to the root of the pkgsrc
1955: tree. It is possible to have many pkgsrc tree instances.)
1956:
1957: * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.6 rillig 1958: Section 11.3, "patches/*" for more information.
1.1 dsieger 1959:
1960: * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
1961: Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
1962: up settings used by builds in /usr/src.
1963:
1964: * DEPENDS_TARGET: By default, dependencies are only installed, and no binary
1965: package is created for them. You can set this variable to package to
1966: automatically create binary packages after installing dependencies.
1967:
1.9 rillig 1968: 5.3. Variables affecting the installation process
1.1 dsieger 1969:
1.25 wiz 1970: Most packages support installation into a subdirectory of WRKDIR. This allows a
1971: package to be built, before the actual filesystem is touched. DESTDIR support
1972: exists in two variations:
1.4 rillig 1973:
1974: * Basic DESTDIR support means that the package installation and packaging is
1975: still run as root.
1976:
1977: * Full DESTDIR support can run the complete build, installation and packaging
1978: as normal user. Root privileges are only needed to add packages.
1979:
1.25 wiz 1980: DESTDIR support is now the default. To switch back to non-DESTDIR, you can set
1981: USE_DESTDIR=no; this setting will be deprecated though, so it's preferable to
1982: convert a package to DESTDIR instead.
1.4 rillig 1983:
1984: DESTDIR support changes the behaviour of various targets slightly. To install a
1985: package after building it, use package-install. package and install don't do
1986: that any longer. package-install can be used as DEPENDS_TARGET. bin-install
1987: will ask for the root password to install the package and fail, package-install
1988: will ask again.
1989:
1990: With basic DESTDIR support, make clean needs to be run as root.
1991:
1.17 imil 1992: Considering the foo/bar package, DESTDIR full support can be tested using the
1993: following commands
1994:
1995: $ id
1996: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
1997: $ mkdir $HOME/packages
1998: $ cd $PKGSRCDIR/foo/bar
1999:
2000: Verify DESTDIR full support, no root privileges should be needed
2001:
1.21 snj 2002: $ make USE_DESTDIR=yes install
1.17 imil 2003:
2004: Create a package without root privileges
2005:
1.21 snj 2006: $ make USE_DESTDIR=yes PACKAGES=$HOME/packages package
1.17 imil 2007:
2008: For the following command, you must be able to gain root privileges using su(1)
2009:
1.21 snj 2010: $ make USE_DESTDIR=yes PACKAGES=$HOME/packages package-install
1.17 imil 2011:
2012: Then, as a simple user
2013:
2014: $ make clean
2015:
1.4 rillig 2016: 5.4. Selecting and configuring the compiler
2017:
2018: 5.4.1. Selecting the compiler
1.1 dsieger 2019:
2020: By default, pkgsrc will use GCC to build packages. This may be overridden by
2021: setting the following variables in /etc/mk.conf:
2022:
2023: PKGSRC_COMPILER:
2024:
2025: This is a list of values specifying the chain of compilers to invoke when
2026: building packages. Valid values are:
2027:
1.42 asau 2028: + distcc: distributed C/C++ (chainable)
1.1 dsieger 2029:
1.42 asau 2030: + ccache: compiler cache (chainable)
1.1 dsieger 2031:
1.42 asau 2032: + gcc: GNU C/C++ Compiler
1.1 dsieger 2033:
1.42 asau 2034: + mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1 dsieger 2035:
1.42 asau 2036: + mipspro: Silicon Graphics, Inc. MIPSpro (o32)
1.1 dsieger 2037:
1.42 asau 2038: + sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1 dsieger 2039:
2040: The default is "gcc". You can use ccache and/or distcc with an appropriate
2041: PKGSRC_COMPILER setting, e.g. "ccache gcc". This variable should always be
2042: terminated with a value for a real compiler. Note that only one real
2043: compiler should be listed (e.g. "sunpro gcc" is not allowed).
2044:
2045: GCC_REQD:
2046:
2047: This specifies the minimum version of GCC to use when building packages. If
2048: the system GCC doesn't satisfy this requirement, then pkgsrc will build and
2049: install one of the GCC packages to use instead.
2050:
1.4 rillig 2051: 5.4.2. Additional flags to the compiler (CFLAGS)
1.1 dsieger 2052:
2053: If you wish to set the CFLAGS variable, please make sure to use the += operator
2054: instead of the = operator:
2055:
2056: CFLAGS+= -your -flags
2057:
2058: Using CFLAGS= (i.e. without the "+") may lead to problems with packages that
1.16 jnemeth 2059: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24 wiz 2060: package if you're interested in optimization specifically for the current CPU.
1.1 dsieger 2061:
1.4 rillig 2062: 5.4.3. Additional flags to the linker (LDFLAGS)
1.1 dsieger 2063:
2064: If you want to pass flags to the linker, both in the configure step and the
2065: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
2066: difference between the two is that LIBS will be appended to the command line,
2067: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
2068: machines depending on the setting of USE_IMAKE or the inclusion of mk/
2069: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
2070: settings, use the += operator:
2071:
2072: LDFLAGS+= -your -linkerflags
2073:
1.4 rillig 2074: 5.5. Developer/advanced settings
1.1 dsieger 2075:
2076: XXX
2077:
2078: * PKG_DEVELOPER: Run some sanity checks that package developers want:
2079:
1.42 asau 2080: + make sure patches apply with zero fuzz
1.1 dsieger 2081:
1.42 asau 2082: + run check-shlibs to see that all binaries will find their shared libs.
1.1 dsieger 2083:
2084: * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
2085: making and installing the package. The default value for this is 0, which
2086: will not display the commands as they are executed (normal, default, quiet
2087: operation); the value 1 will display all shell commands before their
2088: invocation, and the value 2 will display both the shell commands before
2089: their invocation, and their actual execution progress with set -x will be
2090: displayed.
2091:
1.4 rillig 2092: 5.6. Selecting Build Options
1.1 dsieger 2093:
2094: Some packages have build time options, usually to select between different
2095: dependencies, enable optional support for big dependencies or enable
2096: experimental features.
2097:
2098: To see which options, if any, a package supports, and which options are
2099: mutually exclusive, run make show-options, for example:
2100:
2101: The following options are supported by this package:
2102: ssl Enable SSL support.
2103: Exactly one of the following gecko options is required:
2104: firefox Use firefox as gecko rendering engine.
2105: mozilla Use mozilla as gecko rendering engine.
2106: At most one of the following database options may be selected:
2107: mysql Enable support for MySQL database.
2108: pgsql Enable support for PostgreSQL database.
2109:
2110: These options are enabled by default: firefox
2111: These options are currently enabled: mozilla ssl
2112:
1.4 rillig 2113: The following variables can be defined in mk.conf to select which options to
2114: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1 dsieger 2115: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
2116: which can be used to select or disable options specifically for package pkgbase
2117: . Options listed in these variables are selected, options preceded by "-" are
2118: disabled. A few examples:
2119:
1.4 rillig 2120: $ grep "PKG.*OPTION" mk.conf
1.1 dsieger 2121: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
2122: PKG_OPTIONS.kdebase= debug -sasl
2123: PKG_OPTIONS.apache= suexec
2124:
1.11 rillig 2125: It is important to note that options that were specifically suggested by the
1.19 snj 2126: package maintainer must be explicitly removed if you do not wish to include the
2127: option. If you are unsure you can view the current state with make show-options
2128: .
1.11 rillig 2129:
1.1 dsieger 2130: The following settings are consulted in the order given, and the last setting
2131: that selects or disables an option is used:
2132:
2133: 1. the default options as suggested by the package maintainer
2134:
2135: 2. the options implied by the settings of legacy variables (see below)
2136:
2137: 3. PKG_DEFAULT_OPTIONS
2138:
2139: 4. PKG_OPTIONS.pkgbase
2140:
2141: For groups of mutually exclusive options, the last option selected is used, all
2142: others are automatically disabled. If an option of the group is explicitly
2143: disabled, the previously selected option, if any, is used. It is an error if no
2144: option from a required group of options is selected, and building the package
2145: will fail.
2146:
2147: Before the options framework was introduced, build options were selected by
1.4 rillig 2148: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
2149: transition to the options framework for the user, these legacy variables are
2150: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
2151: automatically. A warning is issued to prompt the user to update mk.conf to use
2152: the options framework directly. Support for the legacy variables will be
1.1 dsieger 2153: removed eventually.
2154:
2155: Chapter 6. Creating binary packages
2156:
2157: Table of Contents
2158:
2159: 6.1. Building a single binary package
2160: 6.2. Settings for creation of binary packages
2161:
2162: 6.1. Building a single binary package
2163:
2164: Once you have built and installed a package, you can create a binary package
2165: which can be installed on another system with pkg_add(1). This saves having to
2166: build the same package on a group of hosts and wasting CPU time. It also
2167: provides a simple means for others to install your package, should you
2168: distribute it.
2169:
2170: To create a binary package, change into the appropriate directory in pkgsrc,
2171: and run make package:
2172:
2173: # cd misc/figlet
2174: # make package
2175:
2176:
2177: This will build and install your package (if not already done), and then build
2178: a binary package from what was installed. You can then use the pkg_* tools to
2179: manipulate it. Binary packages are created by default in /usr/pkgsrc/packages,
2180: in the form of a gzipped tar file. See Section B.2, "Packaging figlet" for a
2181: continuation of the above misc/figlet example.
2182:
1.6 rillig 2183: See Chapter 21, Submitting and Committing for information on how to submit such
1.1 dsieger 2184: a binary package.
2185:
2186: 6.2. Settings for creation of binary packages
2187:
1.6 rillig 2188: See Section 17.17, "Other helpful targets".
2189:
2190: Chapter 7. Creating binary packages for everything in pkgsrc (bulk builds)
2191:
2192: Table of Contents
2193:
2194: 7.1. Think first, build later
2195: 7.2. Requirements of a bulk build
2196: 7.3. Running an old-style bulk build
2197:
2198: 7.3.1. Configuration
2199: 7.3.2. Other environmental considerations
2200: 7.3.3. Operation
2201: 7.3.4. What it does
2202: 7.3.5. Disk space requirements
2203: 7.3.6. Setting up a sandbox for chrooted builds
2204: 7.3.7. Building a partial set of packages
2205: 7.3.8. Uploading results of a bulk build
2206:
2207: 7.4. Running a pbulk-style bulk build
2208:
1.15 rillig 2209: 7.4.1. Preparation
2210: 7.4.2. Configuration
1.6 rillig 2211:
2212: 7.5. Creating a multiple CD-ROM packages collection
2213:
2214: 7.5.1. Example of cdpack
2215:
2216: When you have multiple machines that should run the same packages, it is wasted
2217: time if they all build their packages themselves from source. There are two
2218: ways of getting a set of binary packages: The old bulk build system, or the new
2219: (as of 2007) parallel bulk build (pbulk) system. This chapter describes how to
2220: set them up so that the packages are most likely to be usable later.
2221:
2222: 7.1. Think first, build later
2223:
2224: Since a bulk build takes several days or even weeks to finish, you should think
2225: about the setup before you start everything. Pay attention to at least the
2226: following points:
1.1 dsieger 2227:
1.6 rillig 2228: * If you want to upload the binary packages to ftp.NetBSD.org, make sure the
2229: setup complies to the requirements for binary packages:
1.1 dsieger 2230:
1.42 asau 2231: + To end up on ftp.NetBSD.org, the packages must be built by a NetBSD
1.6 rillig 2232: developer on a trusted machine (that is, where you and only you have
2233: root access).
1.1 dsieger 2234:
1.42 asau 2235: + Packages on ftp.NetBSD.org should only be created from the stable
1.22 snj 2236: branches (like 2009Q1), so that users browsing the available
1.6 rillig 2237: collections can see at a glance how old the packages are.
1.1 dsieger 2238:
1.42 asau 2239: + The packages must be built as root, since some packages require set-uid
1.6 rillig 2240: binaries at runtime, and creating those packages as unprivileged user
2241: doesn't work well at the moment.
1.1 dsieger 2242:
1.6 rillig 2243: * Make sure that the bulk build cannot break anything in your system. Most
2244: bulk builds run as root, so they should be run at least in a chroot
2245: environment or something even more restrictive, depending on what the
2246: operating system provides. There have been numerous cases where certain
2247: packages tried to install files outside the LOCALBASE or wanted to edit
2248: some files in /etc. Furthermore, the bulk builds install and deinstall
2249: packages in /usr/pkg (or whatever LOCALBASE is) during their operation, so
2250: be sure that you don't need any package during the build.
2251:
2252: 7.2. Requirements of a bulk build
2253:
2254: A complete bulk build requires lots of disk space. Some of the disk space can
2255: be read-only, some other must be writable. Some can be on remote filesystems
2256: (such as NFS) and some should be local. Some can be temporary filesystems,
2257: others must survive a sudden reboot.
2258:
1.62 jnemeth 2259: * 40 GB for the distfiles (read-write, remote, temporary)
1.6 rillig 2260:
1.62 jnemeth 2261: * 30 GB for the binary packages (read-write, remote, permanent)
1.6 rillig 2262:
1.62 jnemeth 2263: * 1 GB for the pkgsrc tree (read-only, remote, permanent)
1.6 rillig 2264:
2265: * 5 GB for LOCALBASE (read-write, local, temporary for pbulk, permanent for
2266: old-bulk)
2267:
1.62 jnemeth 2268: * 10 GB for the log files (read-write, remote, permanent)
1.6 rillig 2269:
2270: * 5 GB for temporary files (read-write, local, temporary)
2271:
2272: 7.3. Running an old-style bulk build
2273:
1.15 rillig 2274: Note
1.6 rillig 2275:
1.25 wiz 2276: There are two ways of doing a bulk build. The old-style one and the new-style "
2277: pbulk". The latter is the recommended way.
1.6 rillig 2278:
2279: 7.3.1. Configuration
2280:
2281: 7.3.1.1. build.conf
1.1 dsieger 2282:
2283: The build.conf file is the main configuration file for bulk builds. You can
2284: configure how your copy of pkgsrc is kept up to date, how the distfiles are
2285: downloaded, how the packages are built and how the report is generated. You can
2286: find an annotated example file in pkgsrc/mk/bulk/build.conf-example. To use it,
2287: copy build.conf-example to build.conf and edit it, following the comments in
2288: that file.
2289:
1.6 rillig 2290: 7.3.1.2. mk.conf
1.1 dsieger 2291:
1.4 rillig 2292: You may want to set variables in mk.conf. Look at pkgsrc/mk/defaults/mk.conf
2293: for details of the default settings. You will want to ensure that
1.1 dsieger 2294: ACCEPTABLE_LICENSES meet your local policy. As used in this example,
1.23 jakllsch 2295: SKIP_LICENSE_CHECK=yes completely bypasses the license check.
1.1 dsieger 2296:
2297: PACKAGES?= ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
2298: WRKOBJDIR?= /usr/tmp/pkgsrc # build here instead of in pkgsrc
2299: BSDSRCDIR= /usr/src
2300: BSDXSRCDIR= /usr/xsrc # for x11/xservers
2301: OBJHOSTNAME?= yes # use work.`hostname`
2302: FAILOVER_FETCH= yes # insist on the correct checksum
2303: PKG_DEVELOPER?= yes
1.23 jakllsch 2304: SKIP_LICENSE_CHECK= yes
1.1 dsieger 2305:
2306: Some options that are especially useful for bulk builds can be found at the top
2307: lines of the file mk/bulk/bsd.bulk-pkg.mk. The most useful options of these are
2308: briefly described here.
2309:
1.25 wiz 2310: * If you are on a slow machine, you may want to set USE_BULK_BROKEN_CHECK to
1.1 dsieger 2311: "no".
2312:
2313: * If you are doing bulk builds from a read-only copy of pkgsrc, you have to
2314: set BULKFILESDIR to the directory where all log files are created.
2315: Otherwise the log files are created in the pkgsrc directory.
2316:
2317: * Another important variable is BULK_PREREQ, which is a list of packages that
2318: should be always available while building other packages.
2319:
2320: Some other options are scattered in the pkgsrc infrastructure:
2321:
2322: * ALLOW_VULNERABLE_PACKAGES should be set to yes. The purpose of the bulk
2323: builds is creating binary packages, no matter if they are vulnerable or
1.24 wiz 2324: not. Leaving this variable unset would prevent the bulk build system from
2325: even trying to build them, so possible building errors would not show up.
1.1 dsieger 2326:
2327: * CHECK_FILES (pkgsrc/mk/check/check-files.mk) can be set to "yes" to check
2328: that the installed set of files matches the PLIST.
2329:
1.25 wiz 2330: * CHECK_INTERPRETER (pkgsrc/mk/check/check-interpreter.mk) can be set to "yes
2331: " to check that the installed "#!"-scripts will find their interpreter.
1.1 dsieger 2332:
2333: * PKGSRC_RUN_TEST can be set to "yes" to run each package's self-test before
2334: installing it. Note that some packages make heavy use of "good" random
2335: numbers, so you need to assure that the machine on which you are doing the
2336: bulk builds is not completely idle. Otherwise some test programs will seem
2337: to hang, while they are just waiting for new random data to be available.
2338:
1.6 rillig 2339: 7.3.1.3. pre-build.local
1.1 dsieger 2340:
2341: It is possible to configure the bulk build to perform certain site-specific
2342: tasks at the end of the pre-build stage. If the file pre-build.local exists in
2343: /usr/pkgsrc/mk/bulk, it will be executed (as a sh(1) script) at the end of the
2344: usual pre-build stage. An example use of pre-build.local is to have the line:
2345:
2346: echo "I do not have enough disk space to build this pig." \
2347: > misc/openoffice/$BROKENF
2348:
2349: to prevent the system from trying to build a particular package which requires
2350: nearly 3 GB of disk space.
2351:
1.6 rillig 2352: 7.3.2. Other environmental considerations
1.1 dsieger 2353:
2354: As /usr/pkg will be completely deleted at the start of bulk builds, make sure
2355: your login shell is placed somewhere else. Either drop it into /usr/local/bin
2356: (and adjust your login shell in the passwd file), or (re-)install it via
2357: pkg_add(1) from /etc/rc.local, so you can login after a reboot (remember that
2358: your current process won't die if the package is removed, you just can't start
2359: any new instances of the shell any more). Also, if you use NetBSD earlier than
2360: 1.5, or you still want to use the pkgsrc version of ssh for some reason, be
2361: sure to install ssh before starting it from rc.local:
2362:
2363: (cd /usr/pkgsrc/security/ssh && make bulk-install)
2364: if [ -f /usr/pkg/etc/rc.d/sshd ]; then
2365: /usr/pkg/etc/rc.d/sshd
2366: fi
2367:
2368: Not doing so will result in you being not able to log in via ssh after the bulk
2369: build is finished or if the machine gets rebooted or crashes. You have been
2370: warned! :)
2371:
1.6 rillig 2372: 7.3.3. Operation
1.1 dsieger 2373:
2374: Make sure you don't need any of the packages still installed.
2375:
2376: Warning
2377:
2378: During the bulk build, all packages, their configuration files and some more
2379: files from /var, /home and possibly other locations will be removed! So don't
2380: run a bulk build with privileges that might harm your system.
2381:
2382: Be sure to remove all other things that might interfere with builds, like some
2383: libs installed in /usr/local, etc. then become root and type:
2384:
2385: # cd /usr/pkgsrc
2386: # sh mk/bulk/build
2387:
2388:
2389: If for some reason your last build didn't complete (power failure, system
2390: panic, ...), you can continue it by running:
2391:
2392: # sh mk/bulk/build restart
2393:
2394: At the end of the bulk build, you will get a summary via mail, and find build
2395: logs in the directory specified by FTP in the build.conf file.
2396:
1.6 rillig 2397: 7.3.4. What it does
1.1 dsieger 2398:
2399: The bulk builds consist of three steps:
2400:
2401: 1. pre-build
2402:
2403: The script updates your pkgsrc tree via (anon)cvs, then cleans out any
2404: broken distfiles, and removes all packages installed.
2405:
2406: 2. the bulk build
2407:
2408: This is basically "make bulk-package" with an optimised order in which
2409: packages will be built. Packages that don't require other packages will be
2410: built first, and packages with many dependencies will be built later.
2411:
2412: 3. post-build
2413:
2414: Generates a report that's placed in the directory specified in the
2415: build.conf file named broken.html, a short version of that report will also
2416: be mailed to the build's admin.
2417:
2418: During the build, a list of broken packages will be compiled in /usr/pkgsrc
2419: /.broken (or .../.broken.${MACHINE} if OBJMACHINE is set), individual build
2420: logs of broken builds can be found in the package's directory. These files are
2421: used by the bulk-targets to mark broken builds to not waste time trying to
2422: rebuild them, and they can be used to debug these broken package builds later.
2423:
1.6 rillig 2424: 7.3.5. Disk space requirements
1.1 dsieger 2425:
1.62 jnemeth 2426: Currently, roughly the following requirements are valid for NetBSD 6.99/amd64:
1.1 dsieger 2427:
1.62 jnemeth 2428: * 40 GB - distfiles (NFS ok)
1.1 dsieger 2429:
1.62 jnemeth 2430: * 30 GB - full set of all binaries (NFS ok)
1.1 dsieger 2431:
2432: * 5 GB - temp space for compiling (local disk recommended)
2433:
2434: Note that all pkgs will be de-installed as soon as they are turned into a
2435: binary package, and that sources are removed, so there is no excessively huge
2436: demand to disk space. Afterwards, if the package is needed again, it will be
2437: installed via pkg_add(1) instead of building again, so there are no cycles
2438: wasted by recompiling.
2439:
1.6 rillig 2440: 7.3.6. Setting up a sandbox for chrooted builds
1.1 dsieger 2441:
2442: If you don't want all the packages nuked from a machine (rendering it useless
2443: for anything but pkg compiling), there is the possibility of doing the package
2444: bulk build inside a chroot environment.
2445:
2446: The first step is to set up a chroot sandbox, e.g. /usr/sandbox. This can be
2447: done by using null mounts, or manually.
2448:
1.37 wiz 2449: There is a shell script called mksandbox installed by the pkgtools/mksandbox
2450: package, which will set up the sandbox environment using null mounts. It will
2451: also create a script called sandbox in the root of the sandbox environment,
2452: which will allow the null mounts to be activated using the sandbox mount
2453: command and deactivated using the sandbox umount command.
1.1 dsieger 2454:
2455: To set up a sandbox environment by hand, after extracting all the sets from a
2456: NetBSD installation or doing a make distribution DESTDIR=/usr/sandbox in /usr/
2457: src/etc, be sure the following items are present and properly configured:
2458:
2459: 1. Kernel
2460:
2461: # cp /netbsd /usr/sandbox
2462:
2463: 2. /dev/*
2464:
2465: # cd /usr/sandbox/dev ; sh MAKEDEV all
2466:
2467: 3. /etc/resolv.conf (for security/smtpd and mail):
2468:
2469: # cp /etc/resolv.conf /usr/sandbox/etc
2470:
2471: 4. Working(!) mail config (hostname, sendmail.cf):
2472:
2473: # cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail
2474:
2475: 5. /etc/localtime (for security/smtpd):
2476:
2477: # ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime
2478:
1.61 wiz 2479: 6. /usr/src (system sources, rarely used by packages if at all:
1.1 dsieger 2480:
2481: # ln -s ../disk1/cvs .
2482: # ln -s cvs/src-2.0 src
2483:
2484: 7. Create /var/db/pkg (not part of default install):
2485:
2486: # mkdir /usr/sandbox/var/db/pkg
2487:
2488: 8. Create /usr/pkg (not part of default install):
2489:
2490: # mkdir /usr/sandbox/usr/pkg
2491:
2492: 9. Checkout pkgsrc via cvs into /usr/sandbox/usr/pkgsrc:
2493:
2494: # cd /usr/sandbox/usr
2495: # cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc
2496:
2497:
2498: Do not mount/link this to the copy of your pkgsrc tree you do development
2499: in, as this will likely cause problems!
2500:
2501: 10. Make /usr/sandbox/usr/pkgsrc/packages and .../distfiles point somewhere
2502: appropriate. NFS- and/or nullfs-mounts may come in handy!
2503:
1.24 wiz 2504: 11. Edit mk.conf, see Section 7.3.1.2, "mk.conf".
1.1 dsieger 2505:
2506: 12. Adjust mk/bulk/build.conf to suit your needs.
2507:
2508: When the chroot sandbox is set up, you can start the build with the following
2509: steps:
2510:
2511: # cd /usr/sandbox/usr/pkgsrc
2512: # sh mk/bulk/do-sandbox-build
2513:
2514:
2515: This will just jump inside the sandbox and start building. At the end of the
2516: build, mail will be sent with the results of the build. Created binary pkgs
2517: will be in /usr/sandbox/usr/pkgsrc/packages (wherever that points/mounts to/
2518: from).
2519:
1.6 rillig 2520: 7.3.7. Building a partial set of packages
1.1 dsieger 2521:
2522: In addition to building a complete set of all packages in pkgsrc, the pkgsrc/mk
2523: /bulk/build script may be used to build a subset of the packages contained in
1.4 rillig 2524: pkgsrc. By setting SPECIFIC_PKGS in mk.conf, the variables
1.1 dsieger 2525:
2526: * SITE_SPECIFIC_PKGS
2527:
2528: * HOST_SPECIFIC_PKGS
2529:
2530: * GROUP_SPECIFIC_PKGS
2531:
2532: * USER_SPECIFIC_PKGS
2533:
2534: will define the set of packages which should be built. The bulk build code will
2535: also include any packages which are needed as dependencies for the explicitly
2536: listed packages.
2537:
2538: One use of this is to do a bulk build with SPECIFIC_PKGS in a chroot sandbox
2539: periodically to have a complete set of the binary packages needed for your site
2540: available without the overhead of building extra packages that are not needed.
2541:
1.6 rillig 2542: 7.3.8. Uploading results of a bulk build
1.1 dsieger 2543:
2544: This section describes how pkgsrc developers can upload binary pkgs built by
2545: bulk builds to ftp.NetBSD.org.
2546:
2547: If you would like to automatically create checksum files for the binary
2548: packages you intend to upload, remember to set MKSUMS=yes in your mk/bulk/
2549: build.conf.
2550:
2551: If you would like to PGP sign the checksum files (highly recommended!),
2552: remember to set SIGN_AS=username@NetBSD.org in your mk/bulk/build.conf. This
2553: will prompt you for your GPG password to sign the files before uploading
2554: everything.
2555:
2556: Then, make sure that you have RSYNC_DST set properly in your mk/bulk/build.conf
2557: file, i.e. adjust it to something like one of the following:
2558:
1.26 spz 2559: RSYNC_DST=ftp.NetBSD.org:/pub/pkgsrc/packages/NetBSD/arch/a.b.c-20xxQy/upload
1.1 dsieger 2560:
1.26 spz 2561: Please use appropriate values for "20xxQy" (the branch), "a.b.c" (the OS
2562: version) and "arch" here. If your login on ftp.NetBSD.org is different from
2563: your local login, write your login directly into the variable, e.g. my local
2564: account is "feyrer", but for my login "hubertf", I use:
1.1 dsieger 2565:
1.26 spz 2566: RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/pkgsrc/packages/NetBSD/arch/a.b.c-20xxQy/upload
1.1 dsieger 2567:
2568: A separate upload directory is used here to allow "closing" the directory
2569: during upload. To do so, run the following command on ftp.NetBSD.org next:
2570:
1.26 spz 2571: nbftp% mkdir -p -m 750 /pub/pkgsrc/packages/NetBSD/arch/a.b.c-20xxQy/upload
1.1 dsieger 2572:
2573: Before uploading the binary pkgs, ssh authentication needs to be set up. This
2574: example shows how to set up temporary keys for the root account inside the
2575: sandbox (assuming that no keys should be present there usually):
2576:
2577: # chroot /usr/sandbox
2578: chroot-# rm $HOME/.ssh/id-dsa*
1.26 spz 2579: chroot-# ssh-keygen -t rsa
2580: chroot-# cat $HOME/.ssh/id-rsa.pub
1.1 dsieger 2581:
2582:
1.26 spz 2583: Now take the output of id-rsa.pub and append it to your ~/.ssh/authorized_keys
2584: file on ftp.NetBSD.org. You should remove the key after the upload is done!
1.1 dsieger 2585:
2586: Next, test if your ssh connection really works:
2587:
2588: chroot-# ssh ftp.NetBSD.org date
2589:
2590: Use "-l yourNetBSDlogin" here as appropriate!
2591:
2592: Now after all this works, you can exit the sandbox and start the upload:
2593:
2594: chroot-# exit
2595: # cd /usr/sandbox/usr/pkgsrc
2596: # sh mk/bulk/do-sandbox-upload
2597:
2598:
2599: The upload process may take quite some time. Use ls(1) or du(1) on the FTP
2600: server to monitor progress of the upload. The upload script will take care of
1.24 wiz 2601: not uploading restricted packages.
1.1 dsieger 2602:
2603: After the upload has ended, first thing is to revoke ssh access:
2604:
2605: nbftp% vi ~/.ssh/authorized_keys
2606: Gdd:x!
2607:
2608: Use whatever is needed to remove the key you've entered before! Last, move the
2609: uploaded packages out of the upload directory to have them accessible to
2610: everyone:
2611:
1.26 spz 2612: nbftp% cd /pub/pkgsrc/packages/NetBSD/arch/a.b.c-20xxQy
1.1 dsieger 2613: nbftp% mv upload/* .
2614: nbftp% rmdir upload
1.26 spz 2615: nbftp% chgrp -R netbsd .
2616: nbftp% find . -type d | xargs chmod 775
1.1 dsieger 2617:
2618:
1.6 rillig 2619: 7.4. Running a pbulk-style bulk build
2620:
1.15 rillig 2621: Running a pbulk-style bulk build works roughly as follows:
2622:
2623: * First, build the pbulk infrastructure in a fresh pkgsrc location.
2624:
2625: * Then, build each of the packages from a clean installation directory using
2626: the infrastructure.
2627:
2628: 7.4.1. Preparation
2629:
2630: First, you need to create a pkgsrc installation for the pbulk infrastructure.
2631: No matter on which platform you are (even on NetBSD), you should bootstrap into
2632: its own directory. Let's take the directory /usr/pbulk or $HOME/pbulk for it.
2633: This installation will be bootstrapped and all the tools that are required for
2634: the bulk build will be installed there.
2635:
2636: $ cd /usr/pkgsrc
2637: $ ./bootstrap/bootstrap --prefix=/usr/pbulk --varbase=/usr/pbulk/var --workdir=/tmp/pbulk-bootstrap
2638: $ rm -rf /tmp/pbulk-bootstrap
2639:
2640: Now the basic environment for the pbulk infrastructure is installed. The
2641: specific tools are still missing. This is a good time to edit the pkgsrc
2642: configuration file /usr/pbulk/etc/mk.conf to fit your needs. Typical things you
2643: might set now are:
2644:
2645: * PKG_DEVELOPER=yes, to enable many consistency checks,
2646:
2647: * WRKOBJDIR=/tmp/pbulk-outer, to keep /usr/pkgsrc free from any
2648: modifications,
2649:
2650: * DISTDIR=/distfiles, to have only one directory in which all distfiles (for
2651: the infrastructure and for the actual packages) are downloaded,
2652:
2653: * ACCEPTABLE_LICENSES+=..., to select some licenses additional to the usual
2654: Free/Open Source licenses that are acceptable to you,
2655:
1.23 jakllsch 2656: * SKIP_LICENSE_CHECK=yes, to bypass the license checks.
1.15 rillig 2657:
2658: Now you are ready to build the rest of the pbulk infrastructure.
2659:
2660: $ cd pkgtools/pbulk
2661: $ /usr/pbulk/bin/bmake install
2662: $ rm -rf /tmp/pbulk-outer
2663:
2664: Now the pbulk infrastructure is built and installed. It still needs to be
2665: configured, and after some more preparation, we will be able to start the real
2666: bulk build.
2667:
2668: 7.4.2. Configuration
1.6 rillig 2669:
1.14 jmcneill 2670: TODO; see pkgsrc/doc/HOWTO-pbulk for more information.
1.6 rillig 2671:
1.15 rillig 2672: TODO: continue writing
2673:
1.6 rillig 2674: 7.5. Creating a multiple CD-ROM packages collection
1.1 dsieger 2675:
2676: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
2677: of the resulting binary packages to assist in installing packages on other
2678: machines. The pkgtools/cdpack package provides a simple tool for creating the
2679: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
2680: keeps all the dependencies for a given package on the same CD as that package.
2681:
1.6 rillig 2682: 7.5.1. Example of cdpack
1.1 dsieger 2683:
2684: Complete documentation for cdpack is found in the cdpack(1) man page. The
2685: following short example assumes that the binary packages are left in /usr/
2686: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
2687: ISO 9660 images.
2688:
2689: # mkdir /u2/images
2690: # pkg_add /usr/pkgsrc/packages/All/cdpack
2691: # cdpack /usr/pkgsrc/packages/All /u2/images
2692:
2693:
2694: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
2695: CD in the collection, then you need to create a directory which contains these
2696: files. e.g.
2697:
2698: # mkdir /tmp/common
2699: # echo "This is a README" > /tmp/common/README
2700: # echo "Another file" > /tmp/common/COPYING
2701: # mkdir /tmp/common/bin
2702: # echo "#!/bin/sh" > /tmp/common/bin/myscript
2703: # echo "echo Hello world" >> /tmp/common/bin/myscript
2704: # chmod 755 /tmp/common/bin/myscript
2705:
2706:
2707: Now create the images:
2708:
2709: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
2710:
2711: Each image will contain README, COPYING, and bin/myscript in their root
2712: directories.
2713:
1.6 rillig 2714: Chapter 8. Directory layout of the installed files
1.1 dsieger 2715:
2716: Table of Contents
2717:
1.6 rillig 2718: 8.1. File system layout in ${LOCALBASE}
2719: 8.2. File system layout in ${VARBASE}
1.1 dsieger 2720:
2721: The files that are installed by pkgsrc are organized in a way that is similar
2722: to what you find in the /usr directory of the base system. But some details are
2723: different. This is because pkgsrc initially came from FreeBSD and had adopted
2724: its file system hierarchy. Later it was largely influenced by NetBSD. But no
2725: matter which operating system you are using pkgsrc with, you can expect the
2726: same layout for pkgsrc.
2727:
2728: There are mainly four root directories for pkgsrc, which are all configurable
2729: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
2730: default locations are:
2731:
2732: LOCALBASE= /usr/pkg
2733: PKG_SYSCONFBASE= /usr/pkg/etc
2734: VARBASE= /var
2735: PKG_DBDIR= /var/db/pkg
2736:
2737: In unprivileged mode (when pkgsrc has been installed as any other user), the
2738: default locations are:
2739:
2740: LOCALBASE= ${HOME}/pkg
2741: PKG_SYSCONFBASE= ${HOME}/pkg/etc
2742: VARBASE= ${HOME}/pkg/var
2743: PKG_DBDIR= ${HOME}/pkg/var/db/pkg
2744:
2745: What these four directories are for, and what they look like is explained
2746: below.
2747:
1.25 wiz 2748: * LOCALBASE corresponds to the /usr directory in the base system. It is the "
2749: main" directory where the files are installed and contains the well-known
1.1 dsieger 2750: subdirectories like bin, include, lib, share and sbin.
2751:
2752: * VARBASE corresponds to /var in the base system. Some programs (especially
2753: games, network daemons) need write access to it during normal operation.
2754:
2755: * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
2756: configuration files of the packages, as well as pkgsrc's mk.conf itself.
2757:
1.6 rillig 2758: 8.1. File system layout in ${LOCALBASE}
1.1 dsieger 2759:
2760: The following directories exist in a typical pkgsrc installation in $
2761: {LOCALBASE}.
2762:
2763: bin
2764:
2765: Contains executable programs that are intended to be directly used by the
2766: end user.
2767:
2768: emul
2769:
2770: Contains files for the emulation layers of various other operating systems,
2771: especially for NetBSD.
2772:
2773: etc (the usual location of ${PKG_SYSCONFDIR})
2774:
2775: Contains the configuration files.
2776:
2777: include
2778:
2779: Contains headers for the C and C++ programming languages.
2780:
2781: info
2782:
2783: Contains GNU info files of various packages.
2784:
2785: lib
2786:
2787: Contains shared and static libraries.
2788:
2789: libdata
2790:
2791: Contains data files that don't change after installation. Other data files
2792: belong into ${VARBASE}.
2793:
2794: libexec
2795:
2796: Contains programs that are not intended to be used by end users, such as
2797: helper programs or network daemons.
2798:
2799: libexec/cgi-bin
2800:
2801: Contains programs that are intended to be executed as CGI scripts by a web
2802: server.
2803:
2804: man (the usual value of ${PKGMANDIR})
2805:
2806: Contains brief documentation in form of manual pages.
2807:
2808: sbin
2809:
2810: Contains programs that are intended to be used only by the super-user.
2811:
2812: share
2813:
2814: Contains platform-independent data files that don't change after
2815: installation.
2816:
2817: share/doc
2818:
2819: Contains documentation files provided by the packages.
2820:
2821: share/examples
2822:
2823: Contains example files provided by the packages. Among others, the original
2824: configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
2825: installation.
2826:
2827: share/examples/rc.d
2828:
2829: Contains the original files for rc.d scripts.
2830:
2831: var (the usual location of ${VARBASE})
2832:
2833: Contains files that may be modified after installation.
2834:
1.6 rillig 2835: 8.2. File system layout in ${VARBASE}
1.1 dsieger 2836:
2837: db/pkg (the usual location of ${PKG_DBDIR})
2838:
2839: Contains information about the currently installed packages.
2840:
2841: games
2842:
2843: Contains highscore files.
2844:
2845: log
2846:
2847: Contains log files.
2848:
2849: run
2850:
2851: Contains informational files about daemons that are currently running.
2852:
1.6 rillig 2853: Chapter 9. Frequently Asked Questions
1.1 dsieger 2854:
2855: Table of Contents
2856:
1.6 rillig 2857: 9.1. Are there any mailing lists for pkg-related discussion?
2858: 9.2. Where's the pkgviews documentation?
2859: 9.3. Utilities for package management (pkgtools)
2860: 9.4. How to use pkgsrc as non-root
2861: 9.5. How to resume transfers when fetching distfiles?
2862: 9.6. How can I install/use modular X.org from pkgsrc?
2863: 9.7. How to fetch files from behind a firewall
1.65 ! wiz 2864: 9.8. How to fetch files from HTTPS sites
! 2865: 9.9. How do I tell make fetch to do passive FTP?
! 2866: 9.10. How to fetch all distfiles at once
! 2867: 9.11. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
! 2868: 9.12. What does "Could not find bsd.own.mk" mean?
! 2869: 9.13. Using 'sudo' with pkgsrc
! 2870: 9.14. How do I change the location of configuration files?
! 2871: 9.15. Automated security checks
! 2872: 9.16. Why do some packages ignore my CFLAGS?
! 2873: 9.17. A package does not build. What shall I do?
! 2874: 9.18. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24 wiz 2875: conflicts" mean?
1.1 dsieger 2876:
2877: This section contains hints, tips & tricks on special things in pkgsrc that we
2878: didn't find a better place for in the previous chapters, and it contains items
2879: for both pkgsrc users and developers.
2880:
1.6 rillig 2881: 9.1. Are there any mailing lists for pkg-related discussion?
1.1 dsieger 2882:
2883: The following mailing lists may be of interest to pkgsrc users:
2884:
2885: * pkgsrc-users: This is a general purpose list for most issues regarding
2886: pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
2887: configuration, unexpected build failures, using particular packages,
2888: upgrading pkgsrc installations, questions regarding the pkgsrc release
2889: branches, etc. General announcements or proposals for changes that impact
2890: the pkgsrc user community, e.g. major infrastructure changes, new features,
2891: package removals, etc., may also be posted.
2892:
2893: * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
2894: discussed.
2895:
2896: * pkgsrc-changes: This list is for those who are interested in getting a
2897: commit message for every change committed to pkgsrc. It is also available
2898: in digest form, meaning one daily message containing all commit messages
2899: for changes to the package source tree in that 24 hour period.
2900:
2901: To subscribe, do:
2902:
2903: % echo subscribe listname | mail majordomo@NetBSD.org
2904:
2905: Archives for all these mailing lists are available from http://
2906: mail-index.NetBSD.org/.
2907:
1.6 rillig 2908: 9.2. Where's the pkgviews documentation?
1.1 dsieger 2909:
2910: Pkgviews is tightly integrated with buildlink. You can find a pkgviews User's
2911: guide in pkgsrc/mk/buildlink3/PKGVIEWS_UG.
2912:
1.6 rillig 2913: 9.3. Utilities for package management (pkgtools)
1.1 dsieger 2914:
2915: The directory pkgsrc/pkgtools contains a number of useful utilities for both
2916: users and developers of pkgsrc. This section attempts only to make the reader
2917: aware of the utilities and when they might be useful, and not to duplicate the
2918: documentation that comes with each package.
2919:
2920: Utilities used by pkgsrc (automatically installed when needed):
2921:
2922: * pkgtools/x11-links: Symlinks for use by buildlink.
2923:
2924: OS tool augmentation (automatically installed when needed):
2925:
2926: * pkgtools/digest: Calculates various kinds of checksums (including SHA1).
2927:
2928: * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
2929:
2930: * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
2931:
2932: * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
2933: for use on operating systems where pkg_install is not present.
2934:
2935: Utilities used by pkgsrc (not automatically installed):
2936:
2937: * pkgtools/pkg_tarup: Create a binary package from an already-installed
2938: package. Used by make replace to save the old package.
2939:
2940: * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
2941: distfiles from multiple locations. It currently supports the following
2942: methods: multiple CD-ROMs and network FTP/HTTP connections.
2943:
2944: * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24 wiz 2945: current CPU and compiler.
1.1 dsieger 2946:
2947: Utilities for keeping track of installed packages, being up to date, etc:
2948:
1.65 ! wiz 2949: * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
! 2950: and upgrade binary packages easily.
! 2951:
1.1 dsieger 2952: * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
2953: the latest pkgsrc entries.
2954:
2955: * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
2956: strategy for updating.
2957:
2958: * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
2959: graphviz).
2960:
1.12 weinem 2961: * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
2962:
2963: * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
2964: complete pkgsrc system.
1.1 dsieger 2965:
2966: * pkgtools/pkgsurvey: Report what packages you have installed.
2967:
2968: Utilities for people maintaining or creating individual packages:
2969:
2970: * pkgtools/pkgdiff: Automate making and maintaining patches for a package
2971: (includes pkgdiff, pkgvi, mkpatches, etc.).
2972:
1.65 ! wiz 2973: * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1 dsieger 2974:
2975: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
2976:
2977: * pkgtools/pkg_comp: Build packages in a chrooted area.
2978:
2979: * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
2980:
1.6 rillig 2981: 9.4. How to use pkgsrc as non-root
1.1 dsieger 2982:
2983: If you want to use pkgsrc as non-root user, you can set some variables to make
2984: pkgsrc work under these conditions. At the very least, you need to set
2985: UNPRIVILEGED to "yes"; this will turn on unprivileged mode and set multiple
2986: related variables to allow installation of packages as non-root.
2987:
2988: In case the defaults are not enough, you may want to tune some other variables
2989: used. For example, if the automatic user/group detection leads to incorrect
2990: values (or not the ones you would like to use), you can change them by setting
2991: UNPRIVILEGED_USER and UNPRIVILEGED_GROUP respectively.
2992:
2993: As regards bootstrapping, please note that the bootstrap script will ease
2994: non-root configuration when given the "--ignore-user-check" flag, as it will
2995: choose and use multiple default directories under ~/pkg as the installation
2996: targets. These directories can be overridden by the "--prefix" flag provided by
2997: the script, as well as some others that allow finer tuning of the tree layout.
2998:
1.6 rillig 2999: 9.5. How to resume transfers when fetching distfiles?
1.1 dsieger 3000:
3001: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4 rillig 3002: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
3003: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1 dsieger 3004:
1.61 wiz 3005: You can also use a different program than the platform default program by
3006: changing the FETCH_USING variable. You can specify the program by using of ftp,
3007: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
3008: manual. A value of custom disables the system defaults and dependency tracking
3009: for the fetch program. In that case you have to provide FETCH_CMD,
3010: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1 dsieger 3011:
1.16 jnemeth 3012: For example, if you want to use wget to download, you'll have to use something
3013: like:
1.1 dsieger 3014:
1.16 jnemeth 3015: FETCH_USING= wget
1.1 dsieger 3016:
1.6 rillig 3017: 9.6. How can I install/use modular X.org from pkgsrc?
1.1 dsieger 3018:
1.4 rillig 3019: If you want to use modular X.org from pkgsrc instead of your system's own X11
3020: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1 dsieger 3021: mk.conf:
3022:
1.4 rillig 3023: X11_TYPE=modular
1.1 dsieger 3024:
3025: Note
3026:
1.4 rillig 3027: The DragonFly operating system defaults to using modular X.org from pkgsrc.
1.1 dsieger 3028:
1.6 rillig 3029: 9.7. How to fetch files from behind a firewall
1.1 dsieger 3030:
3031: If you are sitting behind a firewall which does not allow direct connections to
3032: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
3033: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
3034: machine "orpheus.amdahl.com" is one of the firewalls, and it uses port 80 as
3035: the proxy port number. So the proxy environment variables are:
3036:
3037: ftp_proxy=ftp://orpheus.amdahl.com:80/
3038: http_proxy=http://orpheus.amdahl.com:80/
3039:
1.65 ! wiz 3040: 9.8. How to fetch files from HTTPS sites
! 3041:
! 3042: Some fetch tools are not prepared to support HTTPS by default (for example, the
! 3043: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
! 3044: openssl dependency that low in the dependency graph).
! 3045:
! 3046: Usually you won't notice, because distribution files are mirrored weekly to "
! 3047: ftp.NetBSD.org", but that might not be often enough if you are following
! 3048: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to "curl" or
! 3049: "wget", which are both compiled with HTTPS support by default. Of course, these
! 3050: tools need to be installed before you can use them this way.
! 3051:
! 3052: 9.9. How do I tell make fetch to do passive FTP?
1.1 dsieger 3053:
3054: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
3055: FETCH_CMD is assigned the first available command from the following list:
3056:
3057: * ${LOCALBASE}/bin/ftp
3058:
3059: * /usr/bin/ftp
3060:
3061: On a default NetBSD installation, this will be /usr/bin/ftp, which
3062: automatically tries passive connections first, and falls back to active
3063: connections if the server refuses to do passive. For the other tools, add the
1.4 rillig 3064: following to your mk.conf file: PASSIVE_FETCH=1.
1.1 dsieger 3065:
3066: Having that option present will prevent /usr/bin/ftp from falling back to
3067: active transfers.
3068:
1.65 ! wiz 3069: 9.10. How to fetch all distfiles at once
1.1 dsieger 3070:
3071: You would like to download all the distfiles in a single batch from work or
3072: university, where you can't run a make fetch. There is an archive of distfiles
3073: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
3074:
3075: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
3076: subdirectories, carry the resulting list to your machine at work/school and use
3077: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
3078: don't forget to set FETCH_CMD to something that fetches a URL:
3079:
3080: At home:
3081:
3082: % cd /usr/pkgsrc
3083: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
3084: % scp /tmp/fetch.sh work:/tmp
3085:
3086: At work:
3087:
3088: % sh /tmp/fetch.sh
3089:
3090: then tar up /tmp/distfiles and take it home.
3091:
3092: If you have a machine running NetBSD, and you want to get all distfiles (even
3093: ones that aren't for your machine architecture), you can do so by using the
3094: above-mentioned make fetch-list approach, or fetch the distfiles directly by
3095: running:
3096:
3097: % make mirror-distfiles
3098:
3099: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
3100: everything by running:
3101:
3102: % make fetch NO_SKIP=yes
3103:
1.65 ! wiz 3104: 9.11. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1.1 dsieger 3105:
3106: When compiling the pkgtools/pkg_install package, you get the error from make
3107: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
3108: that you don't have installed the "text" set (nroff, ...) from the NetBSD base
3109: distribution on your machine. It is recommended to do that to format man pages.
3110:
3111: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4 rillig 3112: NOMAN=YES either in the environment or in mk.conf.
1.1 dsieger 3113:
1.65 ! wiz 3114: 9.12. What does "Could not find bsd.own.mk" mean?
1.1 dsieger 3115:
3116: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
3117: machine. Please get and install it, by extracting it in /:
3118:
3119: # cd /
3120: # tar --unlink -zxvpf .../comp.tgz
3121:
3122: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
3123: release (determine via uname -r).
3124:
1.65 ! wiz 3125: 9.13. Using 'sudo' with pkgsrc
1.1 dsieger 3126:
3127: When installing packages as non-root user and using the just-in-time su(1)
3128: feature of pkgsrc, it can become annoying to type in the root password for each
3129: required package installed. To avoid this, the sudo package can be used, which
3130: does password caching over a limited time. To use it, install sudo (either as
1.4 rillig 3131: binary package or from security/sudo) and then put the following into your
3132: mk.conf, somewhere after the definition of the LOCALBASE variable:
1.1 dsieger 3133:
3134: .if exists(${LOCALBASE}/bin/sudo)
3135: SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
3136: .endif
3137:
1.65 ! wiz 3138: 9.14. How do I change the location of configuration files?
1.1 dsieger 3139:
3140: As the system administrator, you can choose where configuration files are
3141: installed. The default settings make all these files go into ${PREFIX}/etc or
3142: some of its subdirectories; this may be suboptimal depending on your
3143: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
3144: configuration of the provided packages).
3145:
3146: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4 rillig 3147: (in mk.conf) to point to your preferred configuration directory; some common
3148: examples include /etc or /etc/pkg.
1.1 dsieger 3149:
3150: Furthermore, you can change this value on a per-package basis by setting the
3151: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
3152: matches the name of the package you would like to modify, that is, the contents
3153: of PKGBASE.
3154:
3155: Note that after changing these settings, you must rebuild and reinstall any
3156: affected packages.
3157:
1.65 ! wiz 3158: 9.15. Automated security checks
1.1 dsieger 3159:
3160: Please be aware that there can often be bugs in third-party software, and some
3161: of these bugs can leave a machine vulnerable to exploitation by attackers. In
3162: an effort to lessen the exposure, the NetBSD packages team maintains a database
3163: of known-exploits to packages which have at one time been included in pkgsrc.
3164: The database can be downloaded automatically, and a security audit of all
1.14 jmcneill 3165: packages installed on a system can take place. To do this, refer to the
3166: following two tools (installed as part of the pkgtools/pkg_install package):
1.1 dsieger 3167:
1.21 snj 3168: 1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
3169: security vulnerabilities information. This list is kept up to date by the
1.26 spz 3170: pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1 dsieger 3171:
1.26 spz 3172: ftp://ftp.NetBSD.org/pkgsrc/distfiles/pkg-vulnerabilities
1.1 dsieger 3173:
1.21 snj 3174: 2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24 wiz 3175: known vulnerability. If a vulnerable package is installed, it will be shown
3176: by output to stdout, including a description of the type of vulnerability,
3177: and a URL containing more information.
1.1 dsieger 3178:
1.14 jmcneill 3179: Use of these tools is strongly recommended! After "pkg_install" is installed,
3180: please read the package's message, which you can get by running pkg_info -D
3181: pkg_install.
1.1 dsieger 3182:
3183: If this package is installed, pkgsrc builds will use it to perform a security
3184: check before building any package. See Section 5.2, "Variables affecting the
3185: build process" for ways to control this check.
3186:
1.65 ! wiz 3187: 9.16. Why do some packages ignore my CFLAGS?
1.1 dsieger 3188:
3189: When you add your own preferences to the CFLAGS variable in your mk.conf, these
3190: flags are passed in environment variables to the ./configure scripts and to
3191: make(1). Some package authors ignore the CFLAGS from the environment variable
3192: by overriding them in the Makefiles of their package.
3193:
3194: Currently there is no solution to this problem. If you really need the package
3195: to use your CFLAGS you should run make patch in the package directory and then
3196: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
3197: Usually you can remove these lines. But be aware that some "smart" programmers
3198: write so bad code that it only works for the specific combination of CFLAGS
3199: they have chosen.
3200:
1.65 ! wiz 3201: 9.17. A package does not build. What shall I do?
1.1 dsieger 3202:
3203: 1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
3204: is that people only update pkgsrc in parts, because of performance reasons.
3205: Since pkgsrc is one large system, not a collection of many small systems,
3206: there are sometimes changes that only work when the whole pkgsrc tree is
3207: updated.
3208:
1.25 wiz 3209: 2. Make sure that you don't have any CVS conflicts. Search for "<<<<<<" or "
3210: >>>>>>" in all your pkgsrc files.
1.1 dsieger 3211:
1.25 wiz 3212: 3. Make sure that you don't have old copies of the packages extracted. Run
1.1 dsieger 3213: make clean clean-depends to verify this.
3214:
3215: 4. If the problem still exists, write a mail to the pkgsrc-users mailing list.
3216:
1.65 ! wiz 3217: 9.18. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.1 dsieger 3218: conflicts" mean?
3219:
3220: You have modified a file from pkgsrc, and someone else has modified that same
3221: file afterwards in the CVS repository. Both changes are in the same region of
3222: the file, so when you updated pkgsrc, the cvs command marked the conflicting
3223: changes in the file. Because of these markers, the file is no longer a valid
3224: Makefile.
3225:
3226: Have a look at that file, and if you don't need your local changes anymore, you
3227: can remove that file and run cvs -q update -dP in that directory to download
3228: the current version.
3229:
3230: Part II. The pkgsrc developer's guide
3231:
3232: This part of the book deals with creating and modifying packages. It starts
3233: with a "HOWTO"-like guide on creating a new package. The remaining chapters are
3234: more like a reference manual for pkgsrc.
3235:
3236: Table of Contents
3237:
1.6 rillig 3238: 10. Creating a new pkgsrc package from scratch
1.1 dsieger 3239:
1.6 rillig 3240: 10.1. Common types of packages
1.1 dsieger 3241:
1.6 rillig 3242: 10.1.1. Perl modules
3243: 10.1.2. KDE applications
1.17 imil 3244: 10.1.3. Python modules and programs
1.1 dsieger 3245:
1.6 rillig 3246: 10.2. Examples
1.1 dsieger 3247:
1.6 rillig 3248: 10.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 3249:
1.6 rillig 3250: 11. Package components - files, directories and contents
1.1 dsieger 3251:
1.6 rillig 3252: 11.1. Makefile
3253: 11.2. distinfo
3254: 11.3. patches/*
1.1 dsieger 3255:
1.6 rillig 3256: 11.3.1. Structure of a single patch file
3257: 11.3.2. Creating patch files
3258: 11.3.3. Sources where the patch files come from
3259: 11.3.4. Patching guidelines
3260: 11.3.5. Feedback to the author
1.1 dsieger 3261:
1.6 rillig 3262: 11.4. Other mandatory files
3263: 11.5. Optional files
1.1 dsieger 3264:
1.6 rillig 3265: 11.5.1. Files affecting the binary package
3266: 11.5.2. Files affecting the build process
3267: 11.5.3. Files affecting nothing at all
1.1 dsieger 3268:
1.6 rillig 3269: 11.6. work*
3270: 11.7. files/*
1.1 dsieger 3271:
1.6 rillig 3272: 12. Programming in Makefiles
1.1 dsieger 3273:
1.6 rillig 3274: 12.1. Caveats
3275: 12.2. Makefile variables
1.1 dsieger 3276:
1.6 rillig 3277: 12.2.1. Naming conventions
1.1 dsieger 3278:
1.6 rillig 3279: 12.3. Code snippets
1.1 dsieger 3280:
1.6 rillig 3281: 12.3.1. Adding things to a list
3282: 12.3.2. Converting an internal list into an external list
3283: 12.3.3. Passing variables to a shell command
3284: 12.3.4. Quoting guideline
3285: 12.3.5. Workaround for a bug in BSD Make
1.1 dsieger 3286:
1.6 rillig 3287: 13. PLIST issues
1.1 dsieger 3288:
1.6 rillig 3289: 13.1. RCS ID
3290: 13.2. Semi-automatic PLIST generation
3291: 13.3. Tweaking output of make print-PLIST
3292: 13.4. Variable substitution in PLIST
3293: 13.5. Man page compression
3294: 13.6. Changing PLIST source with PLIST_SRC
3295: 13.7. Platform-specific and differing PLISTs
3296: 13.8. Sharing directories between packages
1.1 dsieger 3297:
1.6 rillig 3298: 14. Buildlink methodology
1.1 dsieger 3299:
1.6 rillig 3300: 14.1. Converting packages to use buildlink3
3301: 14.2. Writing buildlink3.mk files
1.1 dsieger 3302:
1.6 rillig 3303: 14.2.1. Anatomy of a buildlink3.mk file
1.27 wiz 3304: 14.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
3305: pkg in buildlink3.mk files
1.1 dsieger 3306:
1.6 rillig 3307: 14.3. Writing builtin.mk files
1.1 dsieger 3308:
1.6 rillig 3309: 14.3.1. Anatomy of a builtin.mk file
3310: 14.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 3311:
1.6 rillig 3312: 15. The pkginstall framework
1.1 dsieger 3313:
1.6 rillig 3314: 15.1. Files and directories outside the installation prefix
1.1 dsieger 3315:
1.6 rillig 3316: 15.1.1. Directory manipulation
3317: 15.1.2. File manipulation
1.1 dsieger 3318:
1.6 rillig 3319: 15.2. Configuration files
1.1 dsieger 3320:
1.6 rillig 3321: 15.2.1. How PKG_SYSCONFDIR is set
3322: 15.2.2. Telling the software where configuration files are
3323: 15.2.3. Patching installations
3324: 15.2.4. Disabling handling of configuration files
1.1 dsieger 3325:
1.6 rillig 3326: 15.3. System startup scripts
1.1 dsieger 3327:
1.6 rillig 3328: 15.3.1. Disabling handling of system startup scripts
1.1 dsieger 3329:
1.6 rillig 3330: 15.4. System users and groups
3331: 15.5. System shells
1.1 dsieger 3332:
1.6 rillig 3333: 15.5.1. Disabling shell registration
1.1 dsieger 3334:
1.6 rillig 3335: 15.6. Fonts
1.1 dsieger 3336:
1.6 rillig 3337: 15.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 3338:
1.6 rillig 3339: 16. Options handling
1.1 dsieger 3340:
1.6 rillig 3341: 16.1. Global default options
3342: 16.2. Converting packages to use bsd.options.mk
3343: 16.3. Option Names
1.7 rillig 3344: 16.4. Determining the options of dependencies
1.1 dsieger 3345:
1.6 rillig 3346: 17. The build process
1.1 dsieger 3347:
1.6 rillig 3348: 17.1. Introduction
3349: 17.2. Program location
3350: 17.3. Directories used during the build process
3351: 17.4. Running a phase
3352: 17.5. The fetch phase
1.1 dsieger 3353:
1.6 rillig 3354: 17.5.1. What to fetch and where to get it from
3355: 17.5.2. How are the files fetched?
1.1 dsieger 3356:
1.6 rillig 3357: 17.6. The checksum phase
3358: 17.7. The extract phase
3359: 17.8. The patch phase
3360: 17.9. The tools phase
3361: 17.10. The wrapper phase
3362: 17.11. The configure phase
3363: 17.12. The build phase
3364: 17.13. The test phase
3365: 17.14. The install phase
3366: 17.15. The package phase
3367: 17.16. Cleaning up
3368: 17.17. Other helpful targets
1.1 dsieger 3369:
1.6 rillig 3370: 18. Tools needed for building or running
1.1 dsieger 3371:
1.6 rillig 3372: 18.1. Tools for pkgsrc builds
3373: 18.2. Tools needed by packages
3374: 18.3. Tools provided by platforms
3375: 18.4. Questions regarding the tools
1.1 dsieger 3376:
1.6 rillig 3377: 19. Making your package work
1.1 dsieger 3378:
1.6 rillig 3379: 19.1. General operation
1.1 dsieger 3380:
1.6 rillig 3381: 19.1.1. Portability of packages
1.24 wiz 3382: 19.1.2. How to pull in user-settable variables from mk.conf
1.6 rillig 3383: 19.1.3. User interaction
3384: 19.1.4. Handling licenses
3385: 19.1.5. Restricted packages
3386: 19.1.6. Handling dependencies
3387: 19.1.7. Handling conflicts with other packages
3388: 19.1.8. Packages that cannot or should not be built
3389: 19.1.9. Packages which should not be deleted, once installed
3390: 19.1.10. Handling packages with security problems
3391: 19.1.11. How to handle incrementing versions when fixing an existing
1.1 dsieger 3392: package
1.6 rillig 3393: 19.1.12. Substituting variable text in the package files (the SUBST
1.1 dsieger 3394: framework)
3395:
1.6 rillig 3396: 19.2. Fixing problems in the fetch phase
1.1 dsieger 3397:
1.6 rillig 3398: 19.2.1. Packages whose distfiles aren't available for plain downloading
3399: 19.2.2. How to handle modified distfiles with the 'old' name
1.1 dsieger 3400:
1.6 rillig 3401: 19.3. Fixing problems in the configure phase
1.1 dsieger 3402:
1.6 rillig 3403: 19.3.1. Shared libraries - libtool
3404: 19.3.2. Using libtool on GNU packages that already support libtool
3405: 19.3.3. GNU Autoconf/Automake
3406:
3407: 19.4. Programming languages
3408:
3409: 19.4.1. C, C++, and Fortran
3410: 19.4.2. Java
3411: 19.4.3. Packages containing perl scripts
1.41 wiz 3412: 19.4.4. Packages containing shell scripts
3413: 19.4.5. Other programming languages
1.6 rillig 3414:
3415: 19.5. Fixing problems in the build phase
3416:
3417: 19.5.1. Compiling C and C++ code conditionally
3418: 19.5.2. How to handle compiler bugs
1.24 wiz 3419: 19.5.3. Undefined reference to "..."
1.6 rillig 3420: 19.5.4. Running out of memory
3421:
3422: 19.6. Fixing problems in the install phase
3423:
3424: 19.6.1. Creating needed directories
3425: 19.6.2. Where to install documentation
3426: 19.6.3. Installing highscore files
3427: 19.6.4. Adding DESTDIR support to packages
3428: 19.6.5. Packages with hardcoded paths to other interpreters
3429: 19.6.6. Packages installing perl modules
3430: 19.6.7. Packages installing info files
3431: 19.6.8. Packages installing man pages
1.7 rillig 3432: 19.6.9. Packages installing GConf data files
1.18 mishka 3433: 19.6.10. Packages installing scrollkeeper/rarian data files
1.6 rillig 3434: 19.6.11. Packages installing X11 fonts
3435: 19.6.12. Packages installing GTK2 modules
3436: 19.6.13. Packages installing SGML or XML data
3437: 19.6.14. Packages installing extensions to the MIME database
3438: 19.6.15. Packages using intltool
3439: 19.6.16. Packages installing startup scripts
3440: 19.6.17. Packages installing TeX modules
3441: 19.6.18. Packages supporting running binaries in emulation
3442: 19.6.19. Packages installing hicolor theme icons
3443: 19.6.20. Packages installing desktop files
3444:
3445: 19.7. Marking packages as having problems
3446:
3447: 20. Debugging
3448: 21. Submitting and Committing
3449:
3450: 21.1. Submitting binary packages
3451: 21.2. Submitting source packages (for non-NetBSD-developers)
3452: 21.3. General notes when adding, updating, or removing packages
1.34 wiz 3453: 21.4. Committing: Adding a package to CVS
1.6 rillig 3454: 21.5. Updating a package to a newer version
1.21 snj 3455: 21.6. Renaming a package in pkgsrc
3456: 21.7. Moving a package in pkgsrc
1.6 rillig 3457:
3458: 22. Frequently Asked Questions
3459: 23. GNOME packaging and porting
3460:
3461: 23.1. Meta packages
3462: 23.2. Packaging a GNOME application
3463: 23.3. Updating GNOME to a newer version
3464: 23.4. Patching guidelines
1.1 dsieger 3465:
1.6 rillig 3466: Chapter 10. Creating a new pkgsrc package from scratch
1.1 dsieger 3467:
3468: Table of Contents
3469:
1.6 rillig 3470: 10.1. Common types of packages
1.1 dsieger 3471:
1.6 rillig 3472: 10.1.1. Perl modules
3473: 10.1.2. KDE applications
1.17 imil 3474: 10.1.3. Python modules and programs
1.1 dsieger 3475:
1.6 rillig 3476: 10.2. Examples
1.1 dsieger 3477:
1.6 rillig 3478: 10.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 3479:
3480: When you find a package that is not yet in pkgsrc, you most likely have a URL
3481: from where you can download the source code. Starting with this URL, creating a
3482: package involves only a few steps.
3483:
3484: 1. First, install the packages pkgtools/url2pkg and pkgtools/pkglint.
3485:
3486: 2. Then, choose one of the top-level directories as the category in which you
3487: want to place your package. You can also create a directory of your own
3488: (maybe called local). In that category directory, create another directory
3489: for your package and change into it.
3490:
3491: 3. Run the program url2pkg, which will ask you for a URL. Enter the URL of the
3492: distribution file (in most cases a .tar.gz file) and watch how the basic
3493: ingredients of your package are created automatically. The distribution
3494: file is extracted automatically to fill in some details in the Makefile
3495: that would otherwise have to be done manually.
3496:
3497: 4. Examine the extracted files to determine the dependencies of your package.
3498: Ideally, this is mentioned in some README file, but things may differ. For
3499: each of these dependencies, look where it exists in pkgsrc, and if there is
3500: a file called buildlink3.mk in that directory, add a line to your package
3501: Makefile which includes that file just before the last line. If the
1.26 spz 3502: buildlink3.mk file does not exist, it must be created first. The
3503: buildlink3.mk file makes sure that the package's include files and
3504: libraries are provided.
3505:
3506: If you just need binaries from a package, add a DEPENDS line to the
3507: Makefile, which specifies the version of the dependency and where it can be
3508: found in pkgsrc. This line should be placed in the third paragraph. If the
1.1 dsieger 3509: dependency is only needed for building the package, but not when using it,
3510: use BUILD_DEPENDS instead of DEPENDS. Your package may then look like this:
3511:
3512: [...]
3513:
3514: BUILD_DEPENDS+= lua>=5.0:../../lang/lua
3515: DEPENDS+= screen-[0-9]*:../../misc/screen
3516: DEPENDS+= screen>=4.0:../../misc/screen
3517:
3518: [...]
3519:
3520: .include "../../category/package/buildlink3.mk"
3521: .include "../../devel/glib2/buildlink3.mk"
3522: .include "../../mk/bsd.pkg.mk"
3523:
3524: 5. Run pkglint to see what things still need to be done to make your package a
3525: "good" one. If you don't know what pkglint's warnings want to tell you, try
3526: pkglint --explain or pkglint -e, which outputs additional explanations.
3527:
3528: 6. In many cases the package is not yet ready to build. You can find
1.6 rillig 3529: instructions for the most common cases in the next section, Section 10.1,
1.1 dsieger 3530: "Common types of packages". After you have followed the instructions over
3531: there, you can hopefully continue here.
3532:
3533: 7. Run bmake clean to clean the working directory from the extracted files.
3534: Besides these files, a lot of cache files and other system information has
3535: been saved in the working directory, which may become wrong after you
3536: edited the Makefile.
3537:
3538: 8. Now, run bmake to build the package. For the various things that can go
1.6 rillig 3539: wrong in this phase, consult Chapter 19, Making your package work.
1.1 dsieger 3540:
1.25 wiz 3541: 9. When the package builds fine, the next step is to install the package. Run
1.1 dsieger 3542: bmake install and hope that everything works.
3543:
3544: 10. Up to now, the file PLIST, which contains a list of the files that are
3545: installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
3546: generate a probably correct list. Check the file using your preferred text
3547: editor to see if the list of files looks plausible.
3548:
3549: 11. Run pkglint again to see if the generated PLIST contains garbage or not.
3550:
3551: 12. When you ran bmake install, the package has been registered in the database
3552: of installed files, but with an empty list of files. To fix this, run bmake
3553: deinstall and bmake install again. Now the package is registered with the
3554: list of files from PLIST.
3555:
3556: 13. Run bmake package to create a binary package from the set of installed
3557: files.
3558:
1.6 rillig 3559: 10.1. Common types of packages
1.1 dsieger 3560:
1.6 rillig 3561: 10.1.1. Perl modules
1.1 dsieger 3562:
3563: Simple Perl modules are handled automatically by url2pkg, including
3564: dependencies.
3565:
1.6 rillig 3566: 10.1.2. KDE applications
1.1 dsieger 3567:
3568: KDE applications should always include meta-pkgs/kde3/kde3.mk, which contains
3569: numerous settings that are typical of KDE packages.
3570:
1.17 imil 3571: 10.1.3. Python modules and programs
3572:
3573: Python modules and programs packages are easily created using a set of
3574: predefined variables.
3575:
1.63 wiz 3576: If some Python versions are not supported by the software, set the
3577: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
3578: supported, e.g.
1.17 imil 3579:
1.64 wiz 3580: PYTHON_VERSIONS_INCOMPATIBLE= 26
1.17 imil 3581:
3582: If the packaged software is a Python module, include "../../lang/python/
1.25 wiz 3583: extension.mk". In this case, the package directory should be called "
3584: py-software" and PKGNAME should be set to "${PYPKGPREFIX}-${DISTNAME}", e.g.
1.17 imil 3585:
3586: DISTNAME= foopymodule-1.2.10
3587: PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
3588:
1.63 wiz 3589: If it is an application, include "../../lang/python/application.mk". In order
3590: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
3591: variable and set it to the list of files (paths relative to WRKSRC) that must
3592: be corrected. For example:
1.17 imil 3593:
1.63 wiz 3594: REPLACE_PYTHON= *.py
1.17 imil 3595:
1.63 wiz 3596: Most Python packages use either "distutils" or easy-setup ("eggs"). If the
3597: software uses "distutils", include "../../lang/python/distutils.mk". so pkgsrc
3598: will use this framework. "distutils" uses a script called setup.py, if the "
3599: distutils" driver is not called setup.py, set the PYSETUP variable to the name
3600: of the script.
3601:
3602: Otherwise, if the packaged software is egg-aware, you only need to include "..
3603: /../lang/python/egg.mk".
3604:
3605: Some Python modules have separate distributions for Python-2.x and Python-3.x
3606: support. In pkgsrc this is handled by the versioned_dependencies.mk file. Set
3607: PYTHON_VERSIONED_DEPENDENCIES to the list of packages that should be depended
3608: upon and include "../../lang/python/versioned_dependencies.mk", then the pkgsrc
3609: infrastructure will depend on the appropriate package version. For example:
1.17 imil 3610:
1.63 wiz 3611: PYTHON_VERSIONED_DEPENDENCIES=dateutil dns
3612:
3613: Look inside versioned_dependencies.mk for a list of supported packages.
1.17 imil 3614:
1.6 rillig 3615: 10.2. Examples
1.1 dsieger 3616:
1.6 rillig 3617: 10.2.1. How the www/nvu package came into pkgsrc
1.1 dsieger 3618:
1.6 rillig 3619: 10.2.1.1. The initial package
1.1 dsieger 3620:
3621: Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
3622: been imported into pkgsrc. As the description says it has to do with the web,
3623: the obvious choice for the category is "www".
3624:
3625: $ mkdir www/nvu
3626: $ cd www/nvu
3627:
3628: The web site says that the sources are available as a tar file, so I fed that
3629: URL to the url2pkg program:
3630:
3631: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
3632:
3633: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
3634: package name should not have the word "sources" in it. I also filled in the
3635: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
3636: that:
3637:
1.2 rillig 3638: # $NetBSD$
1.1 dsieger 3639: #
3640:
3641: DISTNAME= nvu-1.0-sources
3642: PKGNAME= nvu-1.0
3643: CATEGORIES= www
3644: MASTER_SITES= http://cvs.nvu.com/download/
3645: EXTRACT_SUFX= .tar.bz2
3646:
3647: MAINTAINER= rillig@NetBSD.org
3648: HOMEPAGE= http://cvs.nvu.com/
3649: COMMENT= Web Authoring System
3650:
3651: # url2pkg-marker (please do not remove this line.)
3652: .include "../../mk/bsd.pkg.mk"
3653:
3654: Then, I quit the editor and watched pkgsrc downloading a large source archive:
3655:
3656: url2pkg> Running "make makesum" ...
3657: => Required installed package digest>=20010302: digest-20060826 found
3658: => Fetching nvu-1.0-sources.tar.bz2
3659: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
3660: 100% |*************************************| 28992 KB 150.77 KB/s00:00 ETA
3661: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
3662: url2pkg> Running "make extract" ...
3663: => Required installed package digest>=20010302: digest-20060826 found
3664: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
3665: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
3666: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
3667: ===> Installing dependencies for nvu-1.0
3668: ===> Overriding tools for nvu-1.0
3669: ===> Extracting for nvu-1.0
3670: url2pkg> Adjusting the Makefile.
3671:
3672: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
3673:
3674: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
3675:
1.6 rillig 3676: 10.2.1.2. Fixing all kinds of problems to make the package work
1.1 dsieger 3677:
3678: Now that the package has been extracted, let's see what's inside it. The
3679: package has a README.txt, but that only says something about mozilla, so it's
3680: probably useless for seeing what dependencies this package has. But since there
3681: is a GNU configure script in the package, let's hope that it will complain
3682: about everything it needs.
3683:
3684: $ bmake
3685: => Required installed package digest>=20010302: digest-20060826 found
3686: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
3687: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
3688: ===> Patching for nvu-1.0
3689: ===> Creating toolchain wrappers for nvu-1.0
3690: ===> Configuring for nvu-1.0
3691: [...]
3692: configure: error: Perl 5.004 or higher is required.
3693: [...]
3694: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
3695: [...]
3696:
3697: That worked quite well. So I opened the package Makefile in my editor, and
3698: since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
3699: dependencies of the package have changed now, and since a perl wrapper is
3700: automatically installed in the "tools" phase, I need to build the package from
3701: scratch.
3702:
3703: $ bmake clean
3704: ===> Cleaning for nvu-1.0
3705: $ bmake
3706: [...]
3707: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
3708: GNU Make. You will not be able to build Mozilla without GNU Make.
3709: [...]
3710:
3711: So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
3712:
3713: [...]
3714: checking for GTK - version >= 1.2.0... no
3715: *** Could not run GTK test program, checking why...
3716: [...]
3717:
3718: Now to the other dependencies. The first question is: Where is the GTK package
3719: hidden in pkgsrc?
3720:
3721: $ echo ../../*/gtk*
3722: [many packages ...]
3723: $ echo ../../*/gtk
3724: ../../x11/gtk
3725: $ echo ../../*/gtk2
3726: ../../x11/gtk2
3727: $ echo ../../*/gtk2/bui*
3728: ../../x11/gtk2/buildlink3.mk
3729:
3730: The first try was definitely too broad. The second one had exactly one result,
3731: which is very good. But there is one pitfall with GNOME packages. Before GNOME
3732: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
3733: able to continue to use these packages, the GNOME 2 packages were imported as
3734: separate packages, and their names usually have a "2" appended. So I checked
3735: whether this was the case here, and indeed it was.
3736:
3737: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
3738: easy. I just inserted an .include line before the last line of the package
3739: Makefile, so that it now looks like this:
3740:
3741: [...]
3742: .include "../../x11/gtk2/buildlink3.mk"
3743: .include "../../mk/bsd.pkg.mk
3744:
3745: After another bmake clean && bmake, the answer was:
3746:
3747: [...]
3748: checking for gtk-config... /home/roland/pkg/bin/gtk-config
3749: checking for GTK - version >= 1.2.0... no
3750: *** Could not run GTK test program, checking why...
3751: *** The test program failed to compile or link. See the file config.log for the
3752: *** exact error that occured. This usually means GTK was incorrectly installed
3753: *** or that you have moved GTK since it was installed. In the latter case, you
3754: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
3755: configure: error: Test for GTK failed.
3756: [...]
3757:
3758: In this particular case, the assumption that "every package prefers GNOME 2"
3759: had been wrong. The first of the lines above told me that this package really
3760: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
3761: it would have looked for pkg-config instead of gtk-config. So I changed the x11
3762: /gtk2 to x11/gtk in the package Makefile, and tried again.
3763:
3764: [...]
1.59 jnemeth 3765: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\" [...]
1.1 dsieger 3766: In file included from xpidl.c:42:
3767: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
3768: In file included from xpidl.c:42:
3769: xpidl.h:132: error: parse error before "IDL_ns"
3770: [...]
3771:
3772: The package still does not find all of its dependencies. Now the question is:
3773: Which package provides the libIDL/IDL.h header file?
3774:
3775: $ echo ../../*/*idl*
3776: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
3777: $ echo ../../*/*IDL*
3778: ../../net/libIDL
3779:
3780: Let's take the one from the second try. So I included the ../../net/libIDL/
3781: buildlink3.mk file and tried again. But the error didn't change. After digging
3782: through some of the code, I concluded that the build process of the package was
3783: broken and couldn't have ever worked, but since the Mozilla source tree is
3784: quite large, I didn't want to fix it. So I added the following to the package
3785: Makefile and tried again:
3786:
3787: CPPFLAGS+= -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
3788: BUILDLINK_TRANSFORM+= -l:IDL:IDL-2
3789:
3790: The latter line is needed because the package expects the library libIDL.so,
3791: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
3792: that on the fly.
3793:
3794: The next problem was related to a recent change of the FreeType interface. I
3795: looked up in www/seamonkey which patch files were relevant for this issue and
3796: copied them to the patches directory. Then I retried, fixed the patches so that
3797: they applied cleanly and retried again. This time, everything worked.
3798:
1.6 rillig 3799: 10.2.1.3. Installing the package
1.1 dsieger 3800:
3801: $ bmake CHECK_FILES=no install
3802: [...]
3803: $ bmake print-PLIST >PLIST
3804: $ bmake deinstall
3805: $ bmake install
3806:
1.6 rillig 3807: Chapter 11. Package components - files, directories and contents
1.1 dsieger 3808:
3809: Table of Contents
3810:
1.6 rillig 3811: 11.1. Makefile
3812: 11.2. distinfo
3813: 11.3. patches/*
3814:
3815: 11.3.1. Structure of a single patch file
3816: 11.3.2. Creating patch files
3817: 11.3.3. Sources where the patch files come from
3818: 11.3.4. Patching guidelines
3819: 11.3.5. Feedback to the author
3820:
3821: 11.4. Other mandatory files
3822: 11.5. Optional files
3823:
3824: 11.5.1. Files affecting the binary package
3825: 11.5.2. Files affecting the build process
3826: 11.5.3. Files affecting nothing at all
1.1 dsieger 3827:
1.6 rillig 3828: 11.6. work*
3829: 11.7. files/*
1.1 dsieger 3830:
3831: Whenever you're preparing a package, there are a number of files involved which
3832: are described in the following sections.
3833:
1.6 rillig 3834: 11.1. Makefile
1.1 dsieger 3835:
3836: Building, installation and creation of a binary package are all controlled by
3837: the package's Makefile. The Makefile describes various things about a package,
3838: for example from where to get it, how to configure, build, and install it.
3839:
3840: A package Makefile contains several sections that describe the package.
3841:
3842: In the first section there are the following variables, which should appear
3843: exactly in the order given here. The order and grouping of the variables is
3844: mostly historical and has no further meaning.
3845:
3846: * DISTNAME is the basename of the distribution file to be downloaded from the
3847: package's website.
3848:
3849: * PKGNAME is the name of the package, as used by pkgsrc. You only need to
3850: provide it if DISTNAME (which is the default) is not a good name for the
3851: package in pkgsrc. Usually it is the pkgsrc directory name together with
3852: the version number. It must match the regular expression ^[A-Za-z0-9]
3853: [A-Za-z0-9-_.+]*$, that is, it starts with a letter or digit, and contains
3854: only letters, digits, dashes, underscores, dots and plus signs.
3855:
3856: * SVR4_PKGNAME is the name of the package file to create if the PKGNAME isn't
3857: unique on a SVR4 system. The default is PKGNAME, which may be shortened
3858: when you use pkgtools/gensolpkg. Only add SVR4_PKGNAME if PKGNAME does not
3859: produce an unique package name on a SVR4 system. The length of SVR4_PKGNAME
3860: is limited to 5 characters.
3861:
3862: * CATEGORIES is a list of categories which the package fits in. You can
3863: choose any of the top-level directories of pkgsrc for it.
3864:
3865: Currently the following values are available for CATEGORIES. If more than
3866: one is used, they need to be separated by spaces:
3867:
3868: archivers cross geography meta-pkgs security
3869: audio databases graphics misc shells
3870: benchmarks devel ham multimedia sysutils
3871: biology editors inputmethod net textproc
3872: cad emulators lang news time
3873: chat finance mail parallel wm
3874: comms fonts math pkgtools www
3875: converters games mbone print x11
3876:
3877: * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
1.6 rillig 3878: are discussed in detail in Section 17.5, "The fetch phase".
1.1 dsieger 3879:
3880: The second section contains information about separately downloaded patches, if
3881: any.
3882:
3883: * PATCHFILES: Name(s) of additional files that contain distribution patches.
3884: There is no default. pkgsrc will look for them at PATCH_SITES. They will
3885: automatically be uncompressed before patching if the names end with .gz or
3886: .Z.
3887:
3888: * PATCH_SITES: Primary location(s) for distribution patch files (see
3889: PATCHFILES below) if not found locally.
3890:
3891: The third section contains the following variables.
3892:
3893: * MAINTAINER is the email address of the person who feels responsible for
3894: this package, and who is most likely to look at problems or questions
3895: regarding this package which have been reported with send-pr(1). Other
1.14 jmcneill 3896: developers may contact the MAINTAINER before making changes to the package,
3897: but are not required to do so. When packaging a new program, set MAINTAINER
3898: to yourself. If you really can't maintain the package for future updates,
3899: set it to <pkgsrc-users@NetBSD.org>.
3900:
3901: * OWNER should be used instead of MAINTAINER when you do not want other
3902: developers to update or change the package without contacting you first. A
3903: package Makefile should contain one of MAINTAINER or OWNER, but not both.
1.1 dsieger 3904:
3905: * HOMEPAGE is a URL where users can find more information about the package.
3906:
3907: * COMMENT is a one-line description of the package (should not include the
3908: package name).
3909:
3910: Other variables that affect the build:
3911:
3912: * WRKSRC: The directory where the interesting distribution files of the
3913: package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
3914: most packages.
3915:
3916: If a package doesn't create a subdirectory for itself (most GNU software
3917: does, for instance), but extracts itself in the current directory, you
3918: should set WRKSRC=${WRKDIR}.
3919:
3920: If a package doesn't create a subdirectory with the name of DISTNAME but
3921: some different name, set WRKSRC to point to the proper name in ${WRKDIR},
3922: for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
3923: other examples.
3924:
3925: The name of the working directory created by pkgsrc is taken from the
3926: WRKDIR_BASENAME variable. By default, its value is work. If you want to use
3927: the same pkgsrc tree for building different kinds of binary packages, you
3928: can change the variable according to your needs. Two other variables handle
3929: common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
1.4 rillig 3930: defined in mk.conf, the first component of the host's name is attached to
3931: the directory name. If OBJMACHINE is defined, the platform name is
1.1 dsieger 3932: attached, which might look like work.i386 or work.sparc.
3933:
3934: Please pay attention to the following gotchas:
3935:
3936: * Add MANCOMPRESSED if man pages are installed in compressed form by the
3937: package. For packages using BSD-style makefiles which honor MANZ, there is
3938: MANCOMPRESSED_IF_MANZ.
3939:
3940: * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
3941:
1.6 rillig 3942: * If the package installs any info files, see Section 19.6.7, "Packages
1.1 dsieger 3943: installing info files".
3944:
1.6 rillig 3945: 11.2. distinfo
1.1 dsieger 3946:
3947: The distinfo file contains the message digest, or checksum, of each distfile
3948: needed for the package. This ensures that the distfiles retrieved from the
3949: Internet have not been corrupted during transfer or altered by a malign force
3950: to introduce a security hole. Due to recent rumor about weaknesses of digest
3951: algorithms, all distfiles are protected using both SHA1 and RMD160 message
3952: digests, as well as the file size.
3953:
3954: The distinfo file also contains the checksums for all the patches found in the
1.6 rillig 3955: patches directory (see Section 11.3, "patches/*").
1.1 dsieger 3956:
3957: To regenerate the distinfo file, use the make makedistinfo or make mdi command.
3958:
3959: Some packages have different sets of distfiles depending on the platform, for
1.24 wiz 3960: example lang/openjdk7. These are kept in the same distinfo file and care should
3961: be taken when upgrading such a package to ensure distfile information is not
3962: lost.
1.1 dsieger 3963:
1.6 rillig 3964: 11.3. patches/*
1.1 dsieger 3965:
3966: Many packages still don't work out-of-the box on the various platforms that are
3967: supported by pkgsrc. Therefore, a number of custom patch files are needed to
3968: make the package work. These patch files are found in the patches/ directory.
3969:
3970: In the patch phase, these patches are applied to the files in WRKSRC directory
1.25 wiz 3971: after extracting them, in alphabetic order.
1.1 dsieger 3972:
1.6 rillig 3973: 11.3.1. Structure of a single patch file
1.1 dsieger 3974:
3975: The patch-* files should be in diff -bu format, and apply without a fuzz to
3976: avoid problems. (To force patches to apply with fuzz you can set
3977: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
3978: a single file, and no file should be patched by more than one patch file. This
3979: helps to keep future modifications simple.
3980:
3981: Each patch file is structured as follows: In the first line, there is the RCS
3982: Id of the patch itself. The second line should be empty for aesthetic reasons.
3983: After that, there should be a comment for each change that the patch does.
3984: There are a number of standard cases:
3985:
3986: * Patches for commonly known vulnerabilities should mention the vulnerability
3987: ID (CAN, CVE).
3988:
3989: * Patches that change source code should mention the platform and other
3990: environment (for example, the compiler) that the patch is needed for.
3991:
1.25 wiz 3992: In all, the patch should be commented so that any developer who knows the code
3993: of the application can make some use of the patch. Special care should be taken
3994: for the upstream developers, since we generally want that they accept our
3995: patches, so we have less work in the future.
1.1 dsieger 3996:
1.6 rillig 3997: 11.3.2. Creating patch files
1.1 dsieger 3998:
3999: One important thing to mention is to pay attention that no RCS IDs get stored
4000: in the patch files, as these will cause problems when later checked into the
4001: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
4002: avoid these problems.
4003:
4004: For even more automation, we recommend using mkpatches from the same package to
4005: make a whole set of patches. You just have to backup files before you edit them
1.25 wiz 4006: to filename.orig, e.g. with cp -p filename filename.orig or, easier, by using
1.1 dsieger 4007: pkgvi again from the same package. If you upgrade a package this way, you can
1.25 wiz 4008: easily compare the new set of patches with the previously existing one with
4009: patchdiff. The files in patches are replaced by new files, so carefully check
4010: if you want to take all the changes.
1.1 dsieger 4011:
4012: When you have finished a package, remember to generate the checksums for the
1.6 rillig 4013: patch files by using the make makepatchsum command, see Section 11.2,
1.1 dsieger 4014: "distinfo".
4015:
4016: When adding a patch that corrects a problem in the distfile (rather than e.g.
4017: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
4018: report to the maintainer. This benefits non-pkgsrc users of the package, and
4019: usually makes it possible to remove the patch in future version.
4020:
1.25 wiz 4021: The file names of the patch files are usually of the form patch-
4022: path_to_file__with__underscores.c. Many packages still use the previous
4023: convention patch-[a-z][a-z], but new patches should be of the form containing
4024: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
4025: automatically.
1.2 rillig 4026:
1.6 rillig 4027: 11.3.3. Sources where the patch files come from
1.1 dsieger 4028:
4029: If you want to share patches between multiple packages in pkgsrc, e.g. because
4030: they use the same distfiles, set PATCHDIR to the path where the patch files can
4031: be found, e.g.:
4032:
4033: PATCHDIR= ${.CURDIR}/../xemacs/patches
4034:
4035: Patch files that are distributed by the author or other maintainers can be
4036: listed in PATCHFILES.
4037:
4038: If it is desired to store any patches that should not be committed into pkgsrc,
4039: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
4040: directory tree there is expected to have the same "category/package" structure
4041: as pkgsrc, and patches are expected to be stored inside these dirs (also known
4042: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
4043: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
4044: files in the named directory are expected to be patch files, and they are
4045: applied after pkgsrc patches are applied.
4046:
1.6 rillig 4047: 11.3.4. Patching guidelines
1.1 dsieger 4048:
4049: When fixing a portability issue in the code do not use preprocessor magic to
4050: check for the current operating system nor platform. Doing so hurts portability
4051: to other platforms because the OS-specific details are not abstracted
4052: appropriately.
4053:
4054: The general rule to follow is: instead of checking for the operating system the
4055: application is being built on, check for the specific features you need. For
4056: example, instead of assuming that kqueue is available under NetBSD and using
4057: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
4058: kqueue itself ? yes, this generally involves patching the configure script.
4059: There is absolutely nothing that prevents some OSes from adopting interfaces
4060: from other OSes (e.g. Linux implementing kqueue), something that the above
4061: checks cannot take into account.
4062:
4063: Of course, checking for features generally involves more work on the
4064: developer's side, but the resulting changes are cleaner and there are chances
4065: they will work on many other platforms. Not to mention that there are higher
4066: chances of being later integrated into the mainstream sources. Remember: It
4067: doesn't work unless it is right!
4068:
4069: Some typical examples:
4070:
1.6 rillig 4071: Table 11.1. Patching examples
1.1 dsieger 4072:
4073: +-------------------------------------------------------------------------------------------+
4074: | Where | Incorrect | Correct |
4075: |---------+--------------------------+------------------------------------------------------|
4076: | |case ${target_os} in | |
4077: |configure|netbsd*) have_kvm=yes ;; |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
4078: |script |*) have_kvm=no ;; | |
4079: | |esac | |
4080: |---------+--------------------------+------------------------------------------------------|
1.2 rillig 4081: |C source |#if defined(__NetBSD__) |#if defined(HAVE_SYS_EVENT_H) |
4082: |file |# include <sys/event.h> |# include <sys/event.h> |
4083: | |#endif |#endif |
1.1 dsieger 4084: |---------+--------------------------+------------------------------------------------------|
4085: | |int |int |
4086: | |monitor_file(...) |monitor_file(...) |
4087: | |{ |{ |
4088: | |#if defined(__NetBSD__) |#if defined(HAVE_KQUEUE) |
4089: |C source | int fd = kqueue();| int fd = kqueue(); |
4090: |file | ... | ... |
4091: | |#else |#else |
4092: | | ... | ... |
4093: | |#endif |#endif |
4094: | |} |} |
4095: +-------------------------------------------------------------------------------------------+
4096:
4097:
4098: For more information, please read the Making packager-friendly software article
4099: (part 1, part 2). It summarizes multiple details on how to make software easier
4100: to package; all the suggestions in it were collected from our experience in
4101: pkgsrc work, so they are possibly helpful when creating patches too.
4102:
1.6 rillig 4103: 11.3.5. Feedback to the author
1.1 dsieger 4104:
4105: Always, always, always feed back any portability fixes or improvements you do
4106: to a package to the mainstream developers. This is the only way to get their
4107: attention on portability issues and to ensure that future versions can be built
4108: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
4109: get the fixes straight from the packaged code.
4110:
4111: This generally involves cleaning up the patches (because sometimes the patches
1.41 wiz 4112: that are added to pkgsrc are quick hacks), filing bug reports in the
1.1 dsieger 4113: appropriate trackers for the projects and working with the mainstream authors
4114: to accept your changes. It is extremely important that you do it so that the
4115: packages in pkgsrc are kept simple and thus further changes can be done without
4116: much hassle.
4117:
1.25 wiz 4118: When you have done this, please add a URL to the upstream bug report to the
4119: patch comment.
4120:
1.1 dsieger 4121: Support the idea of free software!
4122:
1.6 rillig 4123: 11.4. Other mandatory files
1.1 dsieger 4124:
4125: DESCR
4126:
4127: A multi-line description of the piece of software. This should include any
4128: credits where they are due. Please bear in mind that others do not share
4129: your sense of humour (or spelling idiosyncrasies), and that others will
4130: read everything that you write here.
4131:
4132: PLIST
4133:
4134: This file governs the files that are installed on your system: all the
4135: binaries, manual pages, etc. There are other directives which may be
4136: entered in this file, to control the creation and deletion of directories,
1.6 rillig 4137: and the location of inserted files. See Chapter 13, PLIST issues for more
1.1 dsieger 4138: information.
4139:
1.6 rillig 4140: 11.5. Optional files
1.1 dsieger 4141:
1.6 rillig 4142: 11.5.1. Files affecting the binary package
1.1 dsieger 4143:
4144: INSTALL
4145:
4146: This shell script is invoked twice by pkg_add(1). First time after package
4147: extraction and before files are moved in place, the second time after the
4148: files to install are moved in place. This can be used to do any custom
4149: procedures not possible with @exec commands in PLIST. See pkg_add(1) and
1.6 rillig 4150: pkg_create(1) for more information. See also Section 15.1, "Files and
1.29 wiz 4151: directories outside the installation prefix". Please note that you can
4152: modify variables in it easily by using FILES_SUBST in the package's
4153: Makefile:
4154:
4155: FILES_SUBST+= SOMEVAR="somevalue"
4156:
4157: replaces "@SOMEVAR@" with "somevalue" in the INSTALL. By default,
4158: substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
4159: few others, type make help topic=FILES_SUBST for a complete list.
1.1 dsieger 4160:
4161: DEINSTALL
4162:
4163: This script is executed before and after any files are removed. It is this
4164: script's responsibility to clean up any additional messy details around the
4165: package's installation, since all pkg_delete knows is how to delete the
4166: files created in the original distribution. See pkg_delete(1) and
1.29 wiz 4167: pkg_create(1) for more information. The same methods to replace variables
4168: can be used as for the INSTALL file.
1.1 dsieger 4169:
4170: MESSAGE
4171:
4172: This file is displayed after installation of the package. Useful for things
4173: like legal notices on almost-free software and hints for updating config
4174: files after installing modules for apache, PHP etc. Please note that you
4175: can modify variables in it easily by using MESSAGE_SUBST in the package's
4176: Makefile:
4177:
4178: MESSAGE_SUBST+= SOMEVAR="somevalue"
4179:
4180: replaces "${SOMEVAR}" with "somevalue" in MESSAGE. By default, substitution
4181: is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11PREFIX, X11BASE,
1.16 jnemeth 4182: PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1 dsieger 4183:
4184: You can display a different or additional files by setting the MESSAGE_SRC
4185: variable. Its default is MESSAGE, if the file exists.
4186:
4187: ALTERNATIVES
4188:
4189: FIXME: There is no documentation on the alternatives framework.
4190:
1.6 rillig 4191: 11.5.2. Files affecting the build process
1.1 dsieger 4192:
4193: Makefile.common
4194:
4195: This file contains arbitrary things that could also go into a Makefile, but
4196: its purpose is to be used by more than one package. This file should only
4197: be used when the packages that will use the file are known in advance. For
4198: other purposes it is often better to write a *.mk file and give it a good
4199: name that describes what it does.
4200:
4201: buildlink3.mk
4202:
4203: This file contains the dependency information for the buildlink3 framework
1.6 rillig 4204: (see Chapter 14, Buildlink methodology).
1.1 dsieger 4205:
4206: hacks.mk
4207:
4208: This file contains workarounds for compiler bugs and similar things. It is
4209: included automatically by the pkgsrc infrastructure, so you don't need an
4210: extra .include line for it.
4211:
4212: options.mk
4213:
4214: This file contains the code for the package-specific options (see
1.6 rillig 4215: Chapter 16, Options handling) that can be selected by the user. If a
1.1 dsieger 4216: package has only one or two options, it is equally acceptable to put the
4217: code directly into the Makefile.
4218:
1.6 rillig 4219: 11.5.3. Files affecting nothing at all
1.1 dsieger 4220:
4221: README*
4222:
4223: These files do not take place in the creation of a package and thus are
4224: purely informative to the package developer.
4225:
4226: TODO
4227:
4228: This file contains things that need to be done to make the package even
4229: better.
4230:
1.6 rillig 4231: 11.6. work*
1.1 dsieger 4232:
4233: When you type make, the distribution files are unpacked into the directory
4234: denoted by WRKDIR. It can be removed by running make clean. Besides the
4235: sources, this directory is also used to keep various timestamp files. The
4236: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
4237: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
4238:
1.6 rillig 4239: 11.7. files/*
1.1 dsieger 4240:
4241: If you have any files that you wish to be placed in the package prior to
4242: configuration or building, you could place these files here and use a ${CP}
4243: command in the "pre-configure" target to achieve this. Alternatively, you could
4244: simply diff the file against /dev/null and use the patch mechanism to manage
4245: the creation of this file.
4246:
4247: If you want to share files in this way with other packages, set the FILESDIR
4248: variable to point to the other package's files directory, e.g.:
4249:
4250: FILESDIR=${.CURDIR}/../xemacs/files
4251:
1.6 rillig 4252: Chapter 12. Programming in Makefiles
1.1 dsieger 4253:
4254: Table of Contents
4255:
1.6 rillig 4256: 12.1. Caveats
4257: 12.2. Makefile variables
1.1 dsieger 4258:
1.6 rillig 4259: 12.2.1. Naming conventions
1.1 dsieger 4260:
1.6 rillig 4261: 12.3. Code snippets
1.1 dsieger 4262:
1.6 rillig 4263: 12.3.1. Adding things to a list
4264: 12.3.2. Converting an internal list into an external list
4265: 12.3.3. Passing variables to a shell command
4266: 12.3.4. Quoting guideline
4267: 12.3.5. Workaround for a bug in BSD Make
1.1 dsieger 4268:
4269: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
4270: part of the pkgsrc system. Using the make(1) system as a programming language
4271: for a big system like pkgsrc requires some discipline to keep the code correct
4272: and understandable.
4273:
4274: The basic ingredients for Makefile programming are variables (which are
4275: actually macros) and shell commands. Among these shell commands may even be
4276: more complex ones like awk(1) programs. To make sure that every shell command
4277: runs as intended it is necessary to quote all variables correctly when they are
4278: used.
4279:
4280: This chapter describes some patterns, that appear quite often in Makefiles,
4281: including the pitfalls that come along with them.
4282:
1.6 rillig 4283: 12.1. Caveats
1.1 dsieger 4284:
4285: * When you are creating a file as a target of a rule, always write the data
4286: to a temporary file first and finally rename that file. Otherwise there
4287: might occur an error in the middle of generating the file, and when the
4288: user runs make(1) for the second time, the file exists and will not be
4289: regenerated properly. Example:
4290:
4291: wrong:
4292: @echo "line 1" > ${.TARGET}
4293: @echo "line 2" >> ${.TARGET}
4294: @false
4295:
4296: correct:
4297: @echo "line 1" > ${.TARGET}.tmp
4298: @echo "line 2" >> ${.TARGET}.tmp
4299: @false
4300: @mv ${.TARGET}.tmp ${.TARGET}
4301:
4302: When you run make wrong twice, the file wrong will exist, although there
4303: was an error message in the first run. On the other hand, running make
4304: correct gives an error message twice, as expected.
4305:
4306: You might remember that make(1) sometimes removes ${.TARGET} in case of
4307: error, but this only happens when it is interrupted, for example by
4308: pressing ^C. This does not happen when one of the commands fails (like
4309: false(1) above).
4310:
1.6 rillig 4311: 12.2. Makefile variables
1.1 dsieger 4312:
4313: Makefile variables contain strings that can be processed using the five
4314: operators ``='', ``+='', ``?='', ``:='', and ``!='', which are described in the
4315: make(1) man page.
4316:
4317: When a variable's value is parsed from a Makefile, the hash character ``#'' and
4318: the backslash character ``\'' are handled specially. If a backslash is followed
4319: by a newline, any whitespace immediately in front of the backslash, the
4320: backslash, the newline, and any whitespace immediately behind the newline are
4321: replaced with a single space. A backslash character and an immediately
4322: following hash character are replaced with a single hash character. Otherwise,
4323: the backslash is passed as is. In a variable assignment, any hash character
4324: that is not preceded by a backslash starts a comment that continues upto the
4325: end of the logical line.
4326:
4327: Note: Because of this parsing algorithm the only way to create a variable
4328: consisting of a single backslash is using the ``!='' operator, for example:
4329: BACKSLASH!=echo "\\".
4330:
4331: So far for defining variables. The other thing you can do with variables is
4332: evaluating them. A variable is evaluated when it is part of the right side of
4333: the ``:='' or the ``!='' operator, or directly before executing a shell command
4334: which the variable is part of. In all other cases, make(1) performs lazy
4335: evaluation, that is, variables are not evaluated until there's no other way.
4336: The ``modifiers'' mentioned in the man page also evaluate the variable.
4337:
4338: Some of the modifiers split the string into words and then operate on the
4339: words, others operate on the string as a whole. When a string is split into
4340: words, it is split as you would expect it from sh(1).
4341:
4342: No rule without exception?the .for loop does not follow the shell quoting rules
4343: but splits at sequences of whitespace.
4344:
4345: There are several types of variables that should be handled differently.
4346: Strings and two types of lists.
4347:
4348: * Strings can contain arbitrary characters. Nevertheless, you should restrict
4349: yourself to only using printable characters. Examples are PREFIX and
4350: COMMENT.
4351:
4352: * Internal lists are lists that are never exported to any shell command.
4353: Their elements are separated by whitespace. Therefore, the elements
4354: themselves cannot have embedded whitespace. Any other characters are
4355: allowed. Internal lists can be used in .for loops. Examples are DEPENDS and
4356: BUILD_DEPENDS.
4357:
4358: * External lists are lists that may be exported to a shell command. Their
4359: elements can contain any characters, including whitespace. That's why they
4360: cannot be used in .for loops. Examples are DISTFILES and MASTER_SITES.
4361:
1.6 rillig 4362: 12.2.1. Naming conventions
1.1 dsieger 4363:
4364: * All variable names starting with an underscore are reserved for use by the
4365: pkgsrc infrastructure. They shall not be used by package Makefiles.
4366:
4367: * In .for loops you should use lowercase variable names for the iteration
4368: variables.
4369:
4370: * All list variables should have a ``plural'' name, e.g. PKG_OPTIONS or
4371: DISTFILES.
4372:
1.6 rillig 4373: 12.3. Code snippets
1.1 dsieger 4374:
4375: This section presents you with some code snippets you should use in your own
4376: code. If you don't find anything appropriate here, you should test your code
4377: and add it here.
4378:
1.6 rillig 4379: 12.3.1. Adding things to a list
1.1 dsieger 4380:
4381: STRING= foo * bar `date`
4382: INT_LIST= # empty
4383: ANOTHER_INT_LIST= apache-[0-9]*:../../www/apache
4384: EXT_LIST= # empty
4385: ANOTHER_EXT_LIST= a=b c=d
4386:
4387: INT_LIST+= ${STRING} # 1
4388: INT_LIST+= ${ANOTHER_INT_LIST} # 2
4389: EXT_LIST+= ${STRING:Q} # 3
4390: EXT_LIST+= ${ANOTHER_EXT_LIST} # 4
4391:
4392: When you add a string to an external list (example 3), it must be quoted. In
4393: all other cases, you must not add a quoting level. You must not merge internal
4394: and external lists, unless you are sure that all entries are correctly
4395: interpreted in both lists.
4396:
1.6 rillig 4397: 12.3.2. Converting an internal list into an external list
1.1 dsieger 4398:
4399: EXT_LIST= # empty
4400: .for i in ${INT_LIST}
4401: EXT_LIST+= ${i:Q}""
4402: .endfor
4403:
4404: This code converts the internal list INT_LIST into the external list EXT_LIST.
4405: As the elements of an internal list are unquoted they must be quoted here. The
4406: reason for appending "" is explained below.
4407:
1.6 rillig 4408: 12.3.3. Passing variables to a shell command
1.1 dsieger 4409:
4410: Sometimes you may want to print an arbitrary string. There are many ways to get
4411: it wrong and only few that can handle every nastiness.
4412:
4413: STRING= foo bar < > * `date` $$HOME ' "
4414: EXT_LIST= string=${STRING:Q} x=second\ item
4415:
4416: all:
4417: echo ${STRING} # 1
4418: echo "${STRING}" # 2
4419: echo "${STRING:Q}" # 3
4420: echo ${STRING:Q} # 4
4421: echo x${STRING:Q} | sed 1s,.,, # 5
4422: printf "%s\\n" ${STRING:Q}"" # 6
4423: env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
4424:
4425: Example 1 leads to a syntax error in the shell, as the characters are just
4426: copied.
4427:
4428: Example 2 leads to a syntax error too, and if you leave out the last "
4429: character from ${STRING}, date(1) will be executed. The $HOME shell variable
4430: would be evaluated, too.
4431:
4432: Example 3 outputs each space character preceded by a backslash (or not),
4433: depending on the implementation of the echo(1) command.
4434:
4435: Example 4 handles correctly every string that does not start with a dash. In
4436: that case, the result depends on the implementation of the echo(1) command. As
4437: long as you can guarantee that your input does not start with a dash, this form
4438: is appropriate.
4439:
4440: Example 5 handles even the case of a leading dash correctly.
4441:
4442: Example 6 also works with every string and is the light-weight solution, since
4443: it does not involve a pipe, which has its own problems.
4444:
4445: The EXT_LIST does not need to be quoted because the quoting has already been
4446: done when adding elements to the list.
4447:
4448: As internal lists shall not be passed to the shell, there is no example for it.
4449:
1.6 rillig 4450: 12.3.4. Quoting guideline
1.1 dsieger 4451:
4452: There are many possible sources of wrongly quoted variables. This section lists
4453: some of the commonly known ones.
4454:
4455: * Whenever you use the value of a list, think about what happens to leading
4456: or trailing whitespace. If the list is a well-formed shell expression, you
4457: can apply the :M* modifier to strip leading and trailing whitespace from
4458: each word. The :M operator first splits its argument according to the rules
4459: of the shell, and then creates a new list consisting of all words that
4460: match the shell glob expression *, that is: all. One class of situations
4461: where this is needed is when adding a variable like CPPFLAGS to
4462: CONFIGURE_ARGS. If the configure script invokes other configure scripts, it
4463: strips the leading and trailing whitespace from the variable and then
4464: passes it to the other configure scripts. But these configure scripts
4465: expect the (child) CPPFLAGS variable to be the same as the parent CPPFLAGS.
4466: That's why we better pass the CPPFLAGS value properly trimmed. And here is
4467: how we do it:
4468:
4469: CPPFLAGS= # empty
4470: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX:Q}\"
4471: CPPFLAGS+= ${MY_CPPFLAGS}
4472:
4473: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
4474:
4475: all:
4476: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
4477: echo x${CONFIGURE_ARGS}x # properly trimmed
4478:
4479: * The example above contains one bug: The ${PREFIX} is a properly quoted
4480: shell expression, but there is the C compiler after it, which also expects
4481: a properly quoted string (this time in C syntax). The version above is
4482: therefore only correct if ${PREFIX} does not have embedded backslashes or
4483: double quotes. If you want to allow these, you have to add another layer of
4484: quoting to each variable that is used as a C string literal. You cannot use
4485: the :Q operator for it, as this operator only works for the shell.
4486:
4487: * Whenever a variable can be empty, the :Q operator can have surprising
4488: results. Here are two completely different cases which can be solved with
4489: the same trick.
4490:
4491: EMPTY= # empty
4492: empty_test:
4493: for i in a ${EMPTY:Q} c; do \
4494: echo "$$i"; \
4495: done
4496:
4497: for_test:
4498: .for i in a:\ a:\test.txt
4499: echo ${i:Q}
4500: echo "foo"
4501: .endfor
4502:
4503: The first example will only print two of the three lines we might have
4504: expected. This is because ${EMPTY:Q} expands to the empty string, which the
4505: shell cannot see. The workaround is to write ${EMPTY:Q}"". This pattern can
4506: be often found as ${TEST} -z ${VAR:Q} or as ${TEST} -f ${FNAME:Q} (both of
4507: these are wrong).
4508:
4509: The second example will only print three lines instead of four. The first
4510: line looks like a:\ echo foo. This is because the backslash of the value a:
4511: \ is interpreted as a line-continuation by make(1), which makes the second
4512: line the arguments of the echo(1) command from the first line. To avoid
4513: this, write ${i:Q}"".
4514:
1.6 rillig 4515: 12.3.5. Workaround for a bug in BSD Make
1.1 dsieger 4516:
4517: The pkgsrc bmake program does not handle the following assignment correctly. In
4518: case _othervar_ contains a ``-'' character, one of the closing braces is
4519: included in ${VAR} after this code executes.
4520:
4521: VAR:= ${VAR:N${_othervar_:C/-//}}
4522:
4523: For a more complex code snippet and a workaround, see the package regress/
4524: make-quoting, testcase bug1.
4525:
1.6 rillig 4526: Chapter 13. PLIST issues
1.1 dsieger 4527:
4528: Table of Contents
4529:
1.6 rillig 4530: 13.1. RCS ID
4531: 13.2. Semi-automatic PLIST generation
4532: 13.3. Tweaking output of make print-PLIST
4533: 13.4. Variable substitution in PLIST
4534: 13.5. Man page compression
4535: 13.6. Changing PLIST source with PLIST_SRC
4536: 13.7. Platform-specific and differing PLISTs
4537: 13.8. Sharing directories between packages
1.1 dsieger 4538:
4539: The PLIST file contains a package's "packing list", i.e. a list of files that
4540: belong to the package (relative to the ${PREFIX} directory it's been installed
4541: in) plus some additional statements - see the pkg_create(1) man page for a full
4542: list. This chapter addresses some issues that need attention when dealing with
4543: the PLIST file (or files, see below!).
4544:
1.6 rillig 4545: 13.1. RCS ID
1.1 dsieger 4546:
4547: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
4548:
1.2 rillig 4549: @comment $NetBSD$
1.1 dsieger 4550:
4551:
1.6 rillig 4552: 13.2. Semi-automatic PLIST generation
1.1 dsieger 4553:
4554: You can use the make print-PLIST command to output a PLIST that matches any new
1.6 rillig 4555: files since the package was extracted. See Section 17.17, "Other helpful
1.1 dsieger 4556: targets" for more information on this target.
4557:
1.6 rillig 4558: 13.3. Tweaking output of make print-PLIST
1.1 dsieger 4559:
1.6 rillig 4560: If you have used any of the *-dirs packages, as explained in Section 13.8,
1.1 dsieger 4561: "Sharing directories between packages", you may have noticed that make
4562: print-PLIST outputs a set of @comments instead of real @dirrm lines. You can
4563: also do this for specific directories and files, so that the results of that
4564: command are very close to reality. This helps a lot during the update of
4565: packages.
4566:
4567: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
4568: used to filter the output of print-PLIST. You can append any chunk of AWK
4569: scripting you like to it, but be careful with quoting.
4570:
4571: For example, to get all files inside the libdata/foo directory removed from the
4572: resulting PLIST:
4573:
4574: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
4575:
4576:
4577: And to get all the @dirrm lines referring to a specific (shared) directory
4578: converted to @comments:
4579:
4580: PRINT_PLIST_AWK+= /^@dirrm share\/specific/ { print "@comment " $$0; next; }
4581:
4582:
1.6 rillig 4583: 13.4. Variable substitution in PLIST
1.1 dsieger 4584:
4585: A number of variables are substituted automatically in PLISTs when a package is
4586: installed on a system. This includes the following variables:
4587:
4588: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
4589:
4590: Some packages like emacs and perl embed information about which
4591: architecture they were built on into the pathnames where they install their
4592: files. To handle this case, PLIST will be preprocessed before actually
4593: used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
4594: gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
4595: PLIST somewhere - use this on packages that have GNU autoconf-created
4596: configure scripts.
4597:
4598: Legacy note
4599:
4600: There used to be a symbol "$ARCH" that was replaced by the output of uname
4601: -m, but that's no longer supported and has been removed.
4602:
4603: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
4604:
4605: Some packages want to embed the OS name and version into some paths. To do
4606: this, use these variables in the PLIST:
4607:
1.42 asau 4608: + ${OPSYS} - output of "uname -s"
1.1 dsieger 4609:
1.42 asau 4610: + ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
1.1 dsieger 4611:
1.42 asau 4612: + ${OS_VERSION} - "uname -r"
1.1 dsieger 4613:
4614: For a complete list of values which are replaced by default, please look in
4615: bsd.pkg.mk (and search for PLIST_SUBST).
4616:
4617: If you want to change other variables not listed above, you can add variables
4618: and their expansions to this variable in the following way, similar to
1.6 rillig 4619: MESSAGE_SUBST (see Section 11.5, "Optional files"):
1.1 dsieger 4620:
4621: PLIST_SUBST+= SOMEVAR="somevalue"
4622:
4623:
4624: This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
4625:
1.19 snj 4626: The PLIST_VARS variable can be used to simplify the common case of
4627: conditionally including some PLIST entries. It can be done by adding
4628: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
4629: entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
4630: either """" or ""@comment "". For example, in Makefile:
1.18 mishka 4631:
4632: PLIST_VARS+= foo
4633: .if condition
4634: PLIST.foo= yes
4635: .else
4636:
4637:
4638: And then in PLIST:
4639:
4640: @comment $NetBSD$
4641: bin/bar
4642: man/man1/bar.1
4643: ${PLIST.foo}bin/foo
4644: ${PLIST.foo}man/man1/foo.1
4645: ${PLIST.foo}share/bar/foo.data
4646: ${PLIST.foo}@dirrm share/bar
4647:
4648:
1.6 rillig 4649: 13.5. Man page compression
1.1 dsieger 4650:
4651: Man pages should be installed in compressed form if MANZ is set (in
4652: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
4653: suffix ".gz" is appended/removed automatically for man pages according to MANZ
4654: and MANCOMPRESSED being set or not, see above for details. This modification of
4655: the PLIST file is done on a copy of it, not PLIST itself.
4656:
1.6 rillig 4657: 13.6. Changing PLIST source with PLIST_SRC
1.1 dsieger 4658:
4659: To use one or more files as source for the PLIST used in generating the binary
4660: package, set the variable PLIST_SRC to the names of that file(s). The files are
4661: later concatenated using cat(1), and the order of things is important. The
4662: default for PLIST_SRC is ${PKGDIR}/PLIST.
4663:
1.6 rillig 4664: 13.7. Platform-specific and differing PLISTs
1.1 dsieger 4665:
4666: Some packages decide to install a different set of files based on the operating
4667: system being used. These differences can be automatically handled by using the
4668: following files:
4669:
4670: * PLIST.common
4671:
4672: * PLIST.${OPSYS}
4673:
4674: * PLIST.${MACHINE_ARCH}
4675:
4676: * PLIST.${OPSYS}-${MACHINE_ARCH}
4677:
4678: * PLIST.common_end
4679:
1.6 rillig 4680: 13.8. Sharing directories between packages
1.1 dsieger 4681:
4682: A "shared directory" is a directory where multiple (and unrelated) packages
1.23 jakllsch 4683: install files. These directories were problematic because you had to add
1.1 dsieger 4684: special tricks in the PLIST to conditionally remove them, or have some
4685: centralized package handle them.
4686:
1.23 jakllsch 4687: In pkgsrc, it is now easy: Each package should create directories and install
4688: files as needed; pkg_delete will remove any directories left empty after
4689: uninstalling a package.
1.1 dsieger 4690:
1.23 jakllsch 4691: If a package needs an empty directory to work, create the directory during
4692: installation as usual, and also add an entry to the PLIST:
1.1 dsieger 4693:
1.23 jakllsch 4694: @pkgdir path/to/empty/directory
1.1 dsieger 4695:
4696:
1.6 rillig 4697: Chapter 14. Buildlink methodology
1.1 dsieger 4698:
4699: Table of Contents
4700:
1.6 rillig 4701: 14.1. Converting packages to use buildlink3
4702: 14.2. Writing buildlink3.mk files
1.1 dsieger 4703:
1.6 rillig 4704: 14.2.1. Anatomy of a buildlink3.mk file
1.27 wiz 4705: 14.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
4706: buildlink3.mk files
1.1 dsieger 4707:
1.6 rillig 4708: 14.3. Writing builtin.mk files
1.1 dsieger 4709:
1.6 rillig 4710: 14.3.1. Anatomy of a builtin.mk file
4711: 14.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 4712:
4713: Buildlink is a framework in pkgsrc that controls what headers and libraries are
4714: seen by a package's configure and build processes. This is implemented in a two
4715: step process:
4716:
4717: 1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
4718: default is a subdirectory of WRKDIR.
4719:
4720: 2. Create wrapper scripts that are used in place of the normal compiler tools
4721: that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
4722: references to BUILDLINK_DIR. The wrapper scripts also make native compiler
4723: on some operating systems look like GCC, so that packages that expect GCC
4724: won't require modifications to build with those native compilers.
4725:
4726: This normalizes the environment in which a package is built so that the package
4727: may be built consistently despite what other software may be installed. Please
4728: note that the normal system header and library paths, e.g. /usr/include, /usr/
4729: lib, etc., are always searched -- buildlink3 is designed to insulate the
4730: package build from non-system-supplied software.
4731:
1.6 rillig 4732: 14.1. Converting packages to use buildlink3
1.1 dsieger 4733:
1.25 wiz 4734: The process of converting packages to use the buildlink3 framework ("bl3ifying"
4735: ) is fairly straightforward. The things to keep in mind are:
1.1 dsieger 4736:
4737: 1. Ensure that the build always calls the wrapper scripts instead of the
4738: actual toolchain. Some packages are tricky, and the only way to know for
4739: sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
4740: invoked.
4741:
4742: 2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
4743: standalone shells, etc., because the code to symlink files into $
4744: {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
4745:
4746: 3. Remember that only the buildlink3.mk files that you list in a package's
4747: Makefile are added as dependencies for that package.
4748:
4749: If a dependency on a particular package is required for its libraries and
4750: headers, then we replace:
4751:
4752: DEPENDS+= foo>=1.1.0:../../category/foo
4753:
4754: with
4755:
4756: .include "../../category/foo/buildlink3.mk"
4757:
4758: The buildlink3.mk files usually define the required dependencies. If you need a
4759: newer version of the dependency when using buildlink3.mk files, then you can
4760: define it in your Makefile; for example:
4761:
4762: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
4763: .include "../../category/foo/buildlink3.mk"
4764:
4765: There are several buildlink3.mk files in pkgsrc/mk that handle special package
4766: issues:
4767:
4768: * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
4769: implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
4770:
4771: * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
4772: this will take care to install the devel/ncurses package.
4773:
4774: * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
4775: a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
4776: implementation.
4777:
4778: * motif.buildlink3.mk checks for a system-provided Motif installation or adds
1.46 obache 4779: a dependency on x11/lesstif, x11/motif or x11/openmotif. The user can set
4780: MOTIF_TYPE to "dt", "lesstif", "motif" or "openmotif" to choose which Motif
4781: version will be used.
1.1 dsieger 4782:
1.57 wiz 4783: * readline.buildlink3.mk checks for a system-provided GNU readline or
4784: editline (libedit) installation, or adds a dependency on devel/readline,
4785: devel/editline. The user can set READLINE_DEFAULT to choose readline
1.56 ryoon 4786: implementation. If your package really needs GNU readline library, its
4787: Makefile should include devel/readline/buildlink3.mk instead of
4788: readline.buildlink3.mk.
4789:
1.1 dsieger 4790: * oss.buildlink3.mk defines several variables that may be used by packages
4791: that use the Open Sound System (OSS) API.
4792:
1.36 wiz 4793: * pgsql.buildlink3.mk will accept any of the Postgres versions in the
4794: variable PGSQL_VERSIONS_ACCEPTED and default to the version
4795: PGSQL_VERSION_DEFAULT. See the file for more information.
1.1 dsieger 4796:
4797: * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
4798: pthreads or adds a dependency on devel/pth as needed.
4799:
4800: * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
4801: widgets library.
4802:
4803: The comments in those buildlink3.mk files provide a more complete description
4804: of how to use them properly.
4805:
1.6 rillig 4806: 14.2. Writing buildlink3.mk files
1.1 dsieger 4807:
4808: A package's buildlink3.mk file is included by Makefiles to indicate the need to
4809: compile and link against header files and libraries provided by the package. A
4810: buildlink3.mk file should always provide enough information to add the correct
4811: type of dependency relationship and include any other buildlink3.mk files that
4812: it needs to find headers and libraries that it needs in turn.
4813:
4814: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
4815: pkgtools/createbuildlink package is highly recommended. For most packages, the
4816: following command will generate a good starting point for buildlink3.mk files:
4817:
4818: % cd pkgsrc/category/pkgdir
4819: % createbuildlink >buildlink3.mk
4820:
4821:
1.6 rillig 4822: 14.2.1. Anatomy of a buildlink3.mk file
1.1 dsieger 4823:
4824: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
4825: tiff:
4826:
1.19 snj 4827: # $NetBSD: buildlink3.mk,v 1.16 2009/03/20 19:24:45 joerg Exp $
1.1 dsieger 4828:
1.19 snj 4829: BUILDLINK_TREE+= tiff
1.1 dsieger 4830:
1.19 snj 4831: .if !defined(TIFF_BUILDLINK3_MK)
4832: TIFF_BUILDLINK3_MK:=
1.1 dsieger 4833:
1.19 snj 4834: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
4835: BUILDLINK_ABI_DEPENDS.tiff+= tiff>=3.7.2nb1
1.1 dsieger 4836: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
4837:
4838: .include "../../devel/zlib/buildlink3.mk"
4839: .include "../../graphics/jpeg/buildlink3.mk"
1.19 snj 4840: .endif # TIFF_BUILDLINK3_MK
1.1 dsieger 4841:
1.19 snj 4842: BUILDLINK_TREE+= -tiff
1.1 dsieger 4843:
1.19 snj 4844: The header and footer manipulate BUILDLINK_TREE, which is common across all
4845: buildlink3.mk files and is used to track the dependency tree.
1.1 dsieger 4846:
1.19 snj 4847: The main section is protected from multiple inclusion and controls how the
1.1 dsieger 4848: dependency on pkg is added. Several important variables are set in the section:
4849:
4850: * BUILDLINK_API_DEPENDS.pkg is the actual dependency recorded in the
4851: installed package; this should always be set using += to ensure that we're
4852: appending to any pre-existing list of values. This variable should be set
1.27 wiz 4853: to the first version of the package that had an backwards-incompatible API
4854: change.
1.1 dsieger 4855:
4856: * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
4857:
4858: * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
4859: BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
4860: is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
4861: full dependency is used.
4862:
4863: * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
4864: of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
4865: library search paths. These default to "include" and "lib" respectively.
4866:
4867: * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
4868: to add to CPPFLAGS, which are passed on to the configure and build phases.
4869: The "-I" option should be avoided and instead be handled using
4870: BUILDLINK_INCDIRS.pkg as above.
4871:
4872: The following variables are all optionally defined within this second section
4873: (protected against multiple inclusion) and control which package files are
4874: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
4875: symlinking:
4876:
4877: * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
4878: {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
4879: *.h.
4880:
4881: * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
4882: to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
4883: resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
4884: takes the +CONTENTS of a pkg and filters it through $
4885: {BUILDLINK_CONTENTS_FILTER.pkg}.
4886:
4887: * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
4888: filters +CONTENTS input into a list of files relative to $
4889: {BUILDLINK_PREFIX.pkg} on stdout. By default for overwrite packages,
4890: BUILDLINK_CONTENTS_FILTER.pkg outputs the contents of the include and lib
4891: directories in the package +CONTENTS, and for pkgviews packages, it outputs
4892: any libtool archives in lib directories.
4893:
4894: * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
4895: used to transform the name of the source filename into a destination
4896: filename, e.g. -e "s|/curses.h|/ncurses.h|g".
4897:
1.19 snj 4898: This section can additionally include any buildlink3.mk needed for pkg's
4899: library dependencies. Including these buildlink3.mk files means that the
4900: headers and libraries for these dependencies are also symlinked into $
4901: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
4902: are only added for directly include buildlink3.mk files.
1.1 dsieger 4903:
1.48 wiz 4904: When providing a buildlink3.mk and including other buildlink3.mk files in it,
1.51 wiz 4905: please only add necessary ones, i.e., those whose libraries or header files are
1.48 wiz 4906: automatically exposed when the package is use.
4907:
4908: In particular, if only an executable (bin/foo) is linked against a library,
4909: that library does not need to be propagated in the buildlink3.mk file.
4910:
4911: The following steps should help you decide if a buildlink3.mk file needs to be
4912: included:
4913:
4914: * Look at the installed header files: What headers do they include? The
4915: packages providing these files must be buildlinked.
4916:
1.50 wiz 4917: * Run ldd on all installed libraries and look against what other libraries
4918: they link. Some of the packages providing these probably need to be
4919: buildlinked; however, it's not automatic, since e.g. GTK on some systems
4920: pulls in the X libraries, so they will show up in the ldd output, while on
1.51 wiz 4921: others (like OS X) it won't. ldd output can thus only be used as a hint.
1.50 wiz 4922:
1.27 wiz 4923: 14.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
4924: buildlink3.mk files
1.1 dsieger 4925:
1.27 wiz 4926: These two variables differ in that one describes source compatibility (API) and
4927: the other binary compatibility (ABI). The difference is that a change in the
4928: API breaks compilation of programs while changes in the ABI stop compiled
4929: programs from running.
4930:
1.28 wiz 4931: Changes to the BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk file
4932: happen very rarely. One possible reason is that all packages depending on this
4933: already need a newer version. In case it is bumped see the description below.
1.27 wiz 4934:
4935: The most common example of an ABI change is that the major version of a shared
4936: library is increased. In this case, BUILDLINK_ABI_DEPENDS.pkg should be
4937: adjusted to require at least the new package version. Then the packages that
4938: depend on this package need their PKGREVISIONs increased and, if they have
4939: buildlink3.mk files, their BUILDLINK_ABI_DEPENDS.pkg adjusted, too. This is
4940: needed so pkgsrc will require the correct package dependency and not settle for
4941: an older one when building the source.
1.1 dsieger 4942:
1.6 rillig 4943: See Section 19.1.6, "Handling dependencies" for more information about
1.1 dsieger 4944: dependencies on other packages, including the BUILDLINK_ABI_DEPENDS and
4945: ABI_DEPENDS definitions.
4946:
4947: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
4948: BUILDLINK_ABI_DEPENDS.pkg as we don't want to cause unneeded package deletions
4949: and rebuilds. In many cases, new versions of packages work just fine with older
4950: dependencies.
4951:
4952: Also it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
4953: BUILDLINK_API_DEPENDS.pkg.
4954:
1.6 rillig 4955: 14.3. Writing builtin.mk files
1.1 dsieger 4956:
4957: Some packages in pkgsrc install headers and libraries that coincide with
4958: headers and libraries present in the base system. Aside from a buildlink3.mk
4959: file, these packages should also include a builtin.mk file that includes the
4960: necessary checks to decide whether using the built-in software or the pkgsrc
4961: software is appropriate.
4962:
4963: The only requirements of a builtin.mk file for pkg are:
4964:
4965: 1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
4966:
4967: 2. It should not override any USE_BUILTIN.pkg which is already set before the
4968: builtin.mk file is included.
4969:
4970: 3. It should be written to allow multiple inclusion. This is very important
4971: and takes careful attention to Makefile coding.
4972:
1.6 rillig 4973: 14.3.1. Anatomy of a builtin.mk file
1.1 dsieger 4974:
4975: The following is the recommended template for builtin.mk files:
4976:
4977: .if !defined(IS_BUILTIN.foo)
4978: #
4979: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
4980: # genuinely exists in the system or not.
4981: #
4982: IS_BUILTIN.foo?= no
4983:
4984: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
4985: # version can be determined.
4986: #
4987: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
4988: BUILTIN_PKG.foo?= foo-1.0
4989: . endif
4990: .endif # IS_BUILTIN.foo
4991:
4992: .if !defined(USE_BUILTIN.foo)
4993: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
4994: . if defined(BUILTIN_PKG.foo)
4995: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
4996: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
4997: USE_BUILTIN.foo!= \
4998: ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo} \
4999: && ${ECHO} "yes" || ${ECHO} "no"
5000: . endif
5001: . endfor
5002: . endif
5003: .endif # USE_BUILTIN.foo
5004:
5005: CHECK_BUILTIN.foo?= no
5006: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
5007: #
5008: # Here we place code that depends on whether USE_BUILTIN.foo is set to
5009: # "yes" or "no".
5010: #
5011: .endif # CHECK_BUILTIN.foo
5012:
5013: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
5014: base system. This should not be a base system software with similar
5015: functionality to pkg; it should only be "yes" if the actual package is included
5016: as part of the base system. This variable is only used internally within the
5017: builtin.mk file.
5018:
5019: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
5020: system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
5021: internally within the builtin.mk file.
5022:
5023: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
5024: The code in this section must make the determination whether the built-in
5025: software is adequate to satisfy the dependencies listed in
5026: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
1.25 wiz 5027: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg
1.1 dsieger 5028: must be set to the correct value by the end of the builtin.mk file. Note that
5029: USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
5030: the determination that the built-in version of the software is similar enough
5031: to be used as a replacement.
5032:
5033: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
5034: the value of USE_BUILTIN.pkg set in the previous section. This typically
5035: includes, e.g., adding additional dependency restrictions and listing
5036: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
5037:
1.6 rillig 5038: 14.3.2. Global preferences for native or pkgsrc software
1.1 dsieger 5039:
5040: When building packages, it's possible to choose whether to set a global
5041: preference for using either the built-in (native) version or the pkgsrc version
5042: of software to satisfy a dependency. This is controlled by setting
1.25 wiz 5043: PREFER_PKGSRC and PREFER_NATIVE. These variables take values of either "yes", "
5044: no", or a list of packages. PREFER_PKGSRC tells pkgsrc to use the pkgsrc
1.1 dsieger 5045: versions of software, while PREFER_NATIVE tells pkgsrc to use the built-in
5046: versions. Preferences are determined by the most specific instance of the
5047: package in either PREFER_PKGSRC or PREFER_NATIVE. If a package is specified in
5048: neither or in both variables, then PREFER_PKGSRC has precedence over
5049: PREFER_NATIVE. For example, to require using pkgsrc versions of software for
5050: all but the most basic bits on a NetBSD system, you can set:
5051:
5052: PREFER_PKGSRC= yes
5053: PREFER_NATIVE= getopt skey tcp_wrappers
5054:
5055: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
5056: it is simply ignored in that list.
5057:
1.6 rillig 5058: Chapter 15. The pkginstall framework
1.1 dsieger 5059:
5060: Table of Contents
5061:
1.6 rillig 5062: 15.1. Files and directories outside the installation prefix
1.1 dsieger 5063:
1.6 rillig 5064: 15.1.1. Directory manipulation
5065: 15.1.2. File manipulation
1.1 dsieger 5066:
1.6 rillig 5067: 15.2. Configuration files
1.1 dsieger 5068:
1.6 rillig 5069: 15.2.1. How PKG_SYSCONFDIR is set
5070: 15.2.2. Telling the software where configuration files are
5071: 15.2.3. Patching installations
5072: 15.2.4. Disabling handling of configuration files
1.1 dsieger 5073:
1.6 rillig 5074: 15.3. System startup scripts
1.1 dsieger 5075:
1.6 rillig 5076: 15.3.1. Disabling handling of system startup scripts
1.1 dsieger 5077:
1.6 rillig 5078: 15.4. System users and groups
5079: 15.5. System shells
1.1 dsieger 5080:
1.6 rillig 5081: 15.5.1. Disabling shell registration
1.1 dsieger 5082:
1.6 rillig 5083: 15.6. Fonts
1.1 dsieger 5084:
1.6 rillig 5085: 15.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 5086:
5087: This chapter describes the framework known as pkginstall, whose key features
5088: are:
5089:
5090: * Generic installation and manipulation of directories and files outside the
5091: pkgsrc-handled tree, LOCALBASE.
5092:
5093: * Automatic handling of configuration files during installation, provided
5094: that packages are correctly designed.
5095:
5096: * Generation and installation of system startup scripts.
5097:
5098: * Registration of system users and groups.
5099:
5100: * Registration of system shells.
5101:
5102: * Automatic updating of fonts databases.
5103:
5104: The following sections inspect each of the above points in detail.
5105:
5106: You may be thinking that many of the things described here could be easily done
5107: with simple code in the package's post-installation target (post-install). This
5108: is incorrect, as the code in them is only executed when building from source.
5109: Machines using binary packages could not benefit from it at all (as the code
5110: itself could be unavailable). Therefore, the only way to achieve any of the
5111: items described above is by means of the installation scripts, which are
5112: automatically generated by pkginstall.
5113:
1.6 rillig 5114: 15.1. Files and directories outside the installation prefix
1.1 dsieger 5115:
5116: As you already know, the PLIST file holds a list of files and directories that
5117: belong to a package. The names used in it are relative to the installation
5118: prefix (${PREFIX}), which means that it cannot register files outside this
5119: directory (absolute path names are not allowed). Despite this restriction, some
5120: packages need to install files outside this location; e.g., under ${VARBASE} or
5121: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
5122: installation time by using installation scripts.
5123:
5124: The generic installation scripts are shell scripts that can contain arbitrary
5125: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
5126: which defaults to INSTALL. A similar variable exists for package removal
5127: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
5128: commands, so they have the potential to create and manage files anywhere in the
5129: file system.
5130:
5131: Using these general installation files is not recommended, but may be needed in
5132: some special cases. One reason for avoiding them is that the user has to trust
5133: the packager that there is no unwanted or simply erroneous code included in the
5134: installation script. Also, previously there were many similar scripts for the
5135: same functionality, and fixing a common error involved finding and changing all
5136: of them.
5137:
5138: The pkginstall framework offers another, standardized way. It provides generic
5139: scripts to abstract the manipulation of such files and directories based on
5140: variables set in the package's Makefile. The rest of this section describes
5141: these variables.
5142:
1.6 rillig 5143: 15.1.1. Directory manipulation
1.1 dsieger 5144:
5145: The following variables can be set to request the creation of directories
5146: anywhere in the file system:
5147:
5148: * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
5149: and should attempt to be destroyed by the installation scripts. The
5150: difference between the two is that the latter prompts the administrator to
5151: remove any directories that may be left after deinstallation (because they
5152: were not empty), while the former does not.
5153:
5154: * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
5155: which directories should be created and should attempt to be destroyed by
5156: the installation scripts. Each tuple holds the following values, separated
5157: by spaces: the directory name, its owner, its group and its numerical mode.
5158: For example:
5159:
5160: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
5161:
5162: The difference between the two is exactly the same as their non-PERMS
5163: counterparts.
5164:
1.6 rillig 5165: 15.1.2. File manipulation
1.1 dsieger 5166:
5167: Creating non-empty files outside the installation prefix is tricky because the
5168: PLIST forces all files to be inside it. To overcome this problem, the only
5169: solution is to extract the file in the known place (i.e., inside the
5170: installation prefix) and copy it to the appropriate location during
5171: installation (done by the installation scripts generated by pkginstall). We
5172: will call the former the master file in the following paragraphs, which
5173: describe the variables that can be used to automatically and consistently
5174: handle files outside the installation prefix:
5175:
1.31 wiz 5176: * CONF_FILES and REQD_FILES are pairs of master and target files. During
1.1 dsieger 5177: installation time, the master file is copied to the target one if and only
5178: if the latter does not exist. Upon deinstallation, the target file is
5179: removed provided that it was not modified by the installation.
5180:
5181: The difference between the two is that the latter prompts the administrator
5182: to remove any files that may be left after deinstallation (because they
5183: were not empty), while the former does not.
5184:
1.31 wiz 5185: * CONF_FILES_PERMS and REQD_FILES_PERMS contain tuples describing master
1.1 dsieger 5186: files as well as their target locations. For each of them, it also
5187: specifies their owner, their group and their numeric permissions, in this
5188: order. For example:
5189:
1.31 wiz 5190: REQD_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 dsieger 5191:
5192: The difference between the two is exactly the same as their non-PERMS
5193: counterparts.
5194:
1.6 rillig 5195: 15.2. Configuration files
1.1 dsieger 5196:
5197: Configuration files are special in the sense that they are installed in their
5198: own specific directory, PKG_SYSCONFDIR, and need special treatment during
5199: installation (most of which is automated by pkginstall). The main concept you
5200: must bear in mind is that files marked as configuration files are automatically
5201: copied to the right place (somewhere inside PKG_SYSCONFDIR) during installation
5202: if and only if they didn't exist before. Similarly, they will not be removed if
5203: they have local modifications. This ensures that administrators never lose any
5204: custom changes they may have made.
5205:
1.6 rillig 5206: 15.2.1. How PKG_SYSCONFDIR is set
1.1 dsieger 5207:
5208: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
5209: shall be installed. Its contents are set based upon the following variables:
5210:
5211: * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
5212: etc although it may be overridden by the user to point to his preferred
5213: location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
5214:
5215: * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
5216: configuration files for the package being built shall be installed. The
5217: definition of this variable only makes sense in the package's Makefile
5218: (i.e., it is not user-customizable).
5219:
5220: As an example, consider the Apache package, www/apache2, which places its
5221: configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
5222: should be set in the package Makefile.
5223:
5224: * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
5225: package's configuration directory (if different from PKG_SYSCONFBASE). It
5226: defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
5227:
5228: * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
5229: configuration files for the package identified by PKG_SYSCONFVAR's shall be
5230: placed.
5231:
5232: Based on the above variables, pkginstall determines the value of
5233: PKG_SYSCONFDIR, which is the only variable that can be used within a package to
5234: refer to its configuration directory. The algorithm used to set its value is
5235: basically the following:
5236:
5237: 1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
5238:
5239: 2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
5240: package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
5241: {PKG_SYSCONFSUBDIR}.
5242:
5243: 3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
5244:
5245: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
1.16 jnemeth 5246: OWN_DIRS. See Section 15.1.1, "Directory manipulation" what this means. This
5247: does not apply to subdirectories of ${PKG_SYSCONFDIR}, they still have to be
5248: created with OWN_DIRS or MAKE_DIRS.
1.1 dsieger 5249:
1.6 rillig 5250: 15.2.2. Telling the software where configuration files are
1.1 dsieger 5251:
5252: Given that pkgsrc (and users!) expect configuration files to be in a known
5253: place, you need to teach each package where it shall install its files. In some
5254: cases you will have to patch the package Makefiles to achieve it. If you are
5255: lucky, though, it may be as easy as passing an extra flag to the configuration
5256: script; this is the case of GNU Autoconf- generated files:
5257:
5258: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
5259:
5260: Note that this specifies where the package has to look for its configuration
5261: files, not where they will be originally installed (although the difference is
5262: never explicit, unfortunately).
5263:
1.6 rillig 5264: 15.2.3. Patching installations
1.1 dsieger 5265:
5266: As said before, pkginstall automatically handles configuration files. This
5267: means that the packages themselves must not touch the contents of $
5268: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
5269: will, out of the box, mess with the contents of that directory. So what is the
5270: correct procedure to fix this issue?
5271:
5272: You must teach the package (usually by manually patching it) to install any
5273: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
5274: This way, the PLIST registers them and the administrator always has the
5275: original copies available.
5276:
5277: Once the required configuration files are in place (i.e., under the examples
5278: hierarchy), the pkginstall framework can use them as master copies during the
5279: package installation to update what is in ${PKG_SYSCONFDIR}. To achieve this,
5280: the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
1.6 rillig 5281: Section 15.1.2, "File manipulation" for information about their syntax and
1.1 dsieger 5282: their purpose. Here is an example, taken from the mail/mutt package:
5283:
5284: EGDIR= ${PREFIX}/share/doc/mutt/samples
5285: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
5286:
5287: Note that the EGDIR variable is specific to that package and has no meaning
5288: outside it.
5289:
1.6 rillig 5290: 15.2.4. Disabling handling of configuration files
1.1 dsieger 5291:
5292: The automatic copying of config files can be toggled by setting the environment
5293: variable PKG_CONFIG prior to package installation.
5294:
1.6 rillig 5295: 15.3. System startup scripts
1.1 dsieger 5296:
5297: System startup scripts are special files because they must be installed in a
5298: place known by the underlying OS, usually outside the installation prefix.
1.6 rillig 5299: Therefore, the same rules described in Section 15.1, "Files and directories
1.1 dsieger 5300: outside the installation prefix" apply, and the same solutions can be used.
5301: However, pkginstall provides a special mechanism to handle these files.
5302:
5303: In order to provide system startup scripts, the package has to:
5304:
5305: 1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
5306: Considering the print/cups package as an example, it has a cupsd.sh in its
5307: files directory.
5308:
5309: 2. Tell pkginstall to handle it, appending the name of the script, without its
5310: extension, to the RCD_SCRIPTS variable. Continuing the previous example:
5311:
5312: RCD_SCRIPTS+= cupsd
5313:
5314: Once this is done, pkginstall will do the following steps for each script in an
5315: automated fashion:
5316:
5317: 1. Process the file found in the files directory applying all the
5318: substitutions described in the FILES_SUBST variable.
5319:
5320: 2. Copy the script from the files directory to the examples hierarchy, $
5321: {PREFIX}/share/examples/rc.d/. Note that this master file must be
5322: explicitly registered in the PLIST.
5323:
5324: 3. Add code to the installation scripts to copy the startup script from the
5325: examples hierarchy into the system-wide startup scripts directory.
5326:
1.6 rillig 5327: 15.3.1. Disabling handling of system startup scripts
1.1 dsieger 5328:
5329: The automatic copying of config files can be toggled by setting the environment
5330: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
5331: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
5332: rc.d/, no matter what the value of this variable is.
5333:
1.6 rillig 5334: 15.4. System users and groups
1.1 dsieger 5335:
5336: If a package needs to create special users and/or groups during installation,
5337: it can do so by using the pkginstall framework.
5338:
5339: Users can be created by adding entries to the PKG_USERS variable. Each entry
5340: has the following syntax:
5341:
5342: user:group
5343:
5344: Further specification of user details may be done by setting per-user
5345: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
5346: user's description or comment. PKG_HOME.user is the user's home directory, and
5347: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
5348: and defaults to /sbin/nologin if not specified.
5349:
5350: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
5351: whose syntax is:
5352:
5353: group
5354:
5355: The numeric GID of the group may be set by defining PKG_GID.group.
5356:
5357: If a package needs to create the users and groups at an earlier stage, then it
5358: can set USERGROUP_PHASE to either configure or build to indicate the phase
5359: before which the users and groups are created. In this case, the numeric UIDs
5360: and GIDs of the created users and groups are automatically hardcoded into the
5361: final installation scripts.
5362:
1.6 rillig 5363: 15.5. System shells
1.1 dsieger 5364:
5365: Packages that install system shells should register them in the shell database,
5366: /etc/shells, to make things easier to the administrator. This must be done from
5367: the installation scripts to keep binary packages working on any system.
5368: pkginstall provides an easy way to accomplish this task.
5369:
5370: When a package provides a shell interpreter, it has to set the PKG_SHELL
5371: variable to its absolute file name. This will add some hooks to the
5372: installation scripts to handle it. Consider the following example, taken from
5373: shells/zsh:
5374:
5375: PKG_SHELL= ${PREFIX}/bin/zsh
5376:
1.6 rillig 5377: 15.5.1. Disabling shell registration
1.1 dsieger 5378:
5379: The automatic registration of shell interpreters can be disabled by the
5380: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
5381:
1.6 rillig 5382: 15.6. Fonts
1.1 dsieger 5383:
5384: Packages that install X11 fonts should update the database files that index the
5385: fonts within each fonts directory. This can easily be accomplished within the
5386: pkginstall framework.
5387:
5388: When a package installs X11 fonts, it must list the directories in which fonts
5389: are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
5390: "type1" or "x11". This will add hooks to the installation scripts to run the
5391: appropriate commands to update the fonts database files within each of those
5392: directories. For convenience, if the directory path is relative, it is taken to
5393: be relative to the package's installation prefix. Consider the following
5394: example, taken from fonts/dbz-ttf:
5395:
5396: FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
5397:
1.6 rillig 5398: 15.6.1. Disabling automatic update of the fonts databases
1.1 dsieger 5399:
5400: The automatic update of fonts databases can be disabled by the administrator by
5401: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
5402:
1.6 rillig 5403: Chapter 16. Options handling
1.1 dsieger 5404:
5405: Table of Contents
5406:
1.6 rillig 5407: 16.1. Global default options
5408: 16.2. Converting packages to use bsd.options.mk
5409: 16.3. Option Names
1.7 rillig 5410: 16.4. Determining the options of dependencies
1.1 dsieger 5411:
5412: Many packages have the ability to be built to support different sets of
5413: features. bsd.options.mk is a framework in pkgsrc that provides generic
5414: handling of those options that determine different ways in which the packages
5415: can be built. It's possible for the user to specify exactly which sets of
5416: options will be built into a package or to allow a set of global default
5417: options apply.
5418:
1.7 rillig 5419: There are two broad classes of behaviors that one might want to control via
5420: options. One is whether some particular feature is enabled in a program that
5421: will be built anyway, often by including or not including a dependency on some
5422: other package. The other is whether or not an additional program will be built
5423: as part of the package. Generally, it is better to make a split package for
5424: such additional programs instead of using options, because it enables binary
5425: packages to be built which can then be added separately. For example, the foo
5426: package might have minimal dependencies (those packages without which foo
5427: doesn't make sense), and then the foo-gfoo package might include the GTK
5428: frontend program gfoo. This is better than including a gtk option to foo that
5429: adds gfoo, because either that option is default, in which case binary users
5430: can't get foo without gfoo, or not default, in which case they can't get gfoo.
5431: With split packages, they can install foo without having GTK, and later decide
5432: to install gfoo (pulling in GTK at that time). This is an advantage to source
5433: users too, avoiding the need for rebuilds.
5434:
5435: Plugins with widely varying dependencies should usually be split instead of
5436: options.
5437:
5438: It is often more work to maintain split packages, especially if the upstream
5439: package does not support this. The decision of split vs. option should be made
5440: based on the likelihood that users will want or object to the various pieces,
5441: the size of the dependencies that are included, and the amount of work.
5442:
5443: A further consideration is licensing. Non-free parts, or parts that depend on
5444: non-free dependencies (especially plugins) should almost always be split if
5445: feasible.
5446:
1.6 rillig 5447: 16.1. Global default options
1.1 dsieger 5448:
5449: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
5450: the options that should be built into every package if that option is
1.4 rillig 5451: supported. This variable should be set in mk.conf.
1.1 dsieger 5452:
1.6 rillig 5453: 16.2. Converting packages to use bsd.options.mk
1.1 dsieger 5454:
5455: The following example shows how bsd.options.mk should be used by the
5456: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
5457: e.g. options.mk, that is included by the main package Makefile.
5458:
5459: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
5460: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
5461: PKG_OPTIONS_OPTIONAL_GROUPS= database
5462: PKG_OPTIONS_GROUP.database= mysql pgsql
5463: PKG_SUGGESTED_OPTIONS= wibble-foo
5464: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
5465: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
5466:
5467: .include "../../mk/bsd.prefs.mk"
5468:
5469: # this package was previously named wibble2
5470: .if defined(PKG_OPTIONS.wibble2)
5471: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
5472: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
5473: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
5474: .endif
5475:
5476: .include "../../mk/bsd.options.mk"
5477:
5478: # Package-specific option-handling
5479:
5480: ###
5481: ### FOO support
5482: ###
5483: .if !empty(PKG_OPTIONS:Mwibble-foo)
5484: CONFIGURE_ARGS+= --enable-foo
5485: .endif
5486:
5487: ###
5488: ### LDAP support
5489: ###
5490: .if !empty(PKG_OPTIONS:Mldap)
5491: . include "../../databases/openldap-client/buildlink3.mk"
5492: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
5493: .endif
5494:
5495: ###
5496: ### database support
5497: ###
5498: .if !empty(PKG_OPTIONS:Mmysql)
5499: . include "../../mk/mysql.buildlink3.mk"
5500: .endif
5501: .if !empty(PKG_OPTIONS:Mpgsql)
5502: . include "../../mk/pgsql.buildlink3.mk"
5503: .endif
5504:
5505: The first section contains the information about which build options are
5506: supported by the package, and any default options settings if needed.
5507:
5508: 1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
5509: to override the default options. It should be set to PKG_OPTIONS.pkgbase.
5510: Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
5511: the point where the options are processed.
5512:
5513: 2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
5514:
5515: 3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
5516: exclusive options. The options in each group are listed in
5517: PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
5518: the group takes precedence over all other options in the group. Options
5519: from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
5520:
5521: 4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
5522: building the packages will fail if no option from the group is selected.
5523:
5524: 5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
5525: one option from each set must be selected. The options in each set are
5526: listed in PKG_OPTIONS_SET.setname. Options from the sets will be
5527: automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
5528: fail if no option from the set is selected.
5529:
5530: 6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
5531: default.
5532:
5533: 7. PKG_OPTIONS_LEGACY_VARS is a list of "USE_VARIABLE:option" pairs that map
1.4 rillig 5534: legacy mk.conf variables to their option counterparts. Pairs should be
1.1 dsieger 5535: added with "+=" to keep the listing of global legacy variables. A warning
5536: will be issued if the user uses a legacy variable.
5537:
5538: 8. PKG_OPTIONS_LEGACY_OPTS is a list of "old-option:new-option" pairs that map
5539: options that have been renamed to their new counterparts. Pairs should be
5540: added with "+=" to keep the listing of global legacy options. A warning
5541: will be issued if the user uses a legacy option.
5542:
5543: 9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
5544: used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
5545: PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
5546:
5547: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
5548: variables or options used, and what to use instead.
5549:
5550: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
5551: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
5552: options, use PKG_SUGGESTED_OPTIONS.
5553:
5554: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
5555: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
5556: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
5557: options if none of them is supported on the current platform), PKG_OPTIONS is
5558: set to the empty list and the package is otherwise treated as not using the
5559: options framework.
5560:
5561: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
5562: list of selected build options, properly filtered to remove unsupported and
5563: duplicate options.
5564:
5565: The remaining sections contain the logic that is specific to each option. The
5566: correct way to check for an option is to check whether it is listed in
5567: PKG_OPTIONS:
5568:
5569: .if !empty(PKG_OPTIONS:Moption)
5570:
1.6 rillig 5571: 16.3. Option Names
1.1 dsieger 5572:
5573: Options that enable similar features in different packages (like optional
5574: support for a library) should use a common name in all packages that support it
5575: (like the name of the library). If another package already has an option with
5576: the same meaning, use the same name.
5577:
5578: Options that enable features specific to one package, where it's unlikely that
5579: another (unrelated) package has the same (or a similar) optional feature,
5580: should use a name prefixed with pkgname-.
5581:
5582: If a group of related packages share an optional feature specific to that
5583: group, prefix it with the name of the "main" package (e. g.
5584: djbware-errno-hack).
5585:
5586: For new options, add a line to mk/defaults/options.description. Lines have two
5587: fields, separated by tab. The first field is the option name, the second its
5588: description. The description should be a whole sentence (starting with an
5589: uppercase letter and ending with a period) that describes what enabling the
5590: option does. E. g. "Enable ispell support." The file is sorted by option names.
5591:
1.7 rillig 5592: 16.4. Determining the options of dependencies
5593:
5594: When writing buildlink3.mk files, it is often necessary to list different
5595: dependencies based on the options with which the package was built. For
5596: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
5597: A typical example looks like this:
5598:
5599: pkgbase := libpurple
5600: .include "../../mk/pkg-build-options.mk"
5601:
5602: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
5603: ...
5604: .endif
5605:
5606: Including pkg-build-options.mk here will set the variable
5607: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
5608: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
5609: pkg-build-options.mk for more details.
5610:
1.6 rillig 5611: Chapter 17. The build process
1.1 dsieger 5612:
5613: Table of Contents
5614:
1.6 rillig 5615: 17.1. Introduction
5616: 17.2. Program location
5617: 17.3. Directories used during the build process
5618: 17.4. Running a phase
5619: 17.5. The fetch phase
5620:
5621: 17.5.1. What to fetch and where to get it from
5622: 17.5.2. How are the files fetched?
5623:
5624: 17.6. The checksum phase
5625: 17.7. The extract phase
5626: 17.8. The patch phase
5627: 17.9. The tools phase
5628: 17.10. The wrapper phase
5629: 17.11. The configure phase
5630: 17.12. The build phase
5631: 17.13. The test phase
5632: 17.14. The install phase
5633: 17.15. The package phase
5634: 17.16. Cleaning up
5635: 17.17. Other helpful targets
1.1 dsieger 5636:
1.6 rillig 5637: 17.1. Introduction
1.1 dsieger 5638:
5639: This chapter gives a detailed description on how a package is built. Building a
5640: package is separated into different phases (for example fetch, build, install),
1.19 snj 5641: all of which are described in the following sections. Each phase is split into
5642: so-called stages, which take the name of the containing phase, prefixed by one
5643: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
5644: actual work is done in the do-* stages.
1.1 dsieger 5645:
5646: Never override the regular targets (like fetch), if you have to, override the
5647: do-* ones instead.
5648:
5649: The basic steps for building a program are always the same. First the program's
5650: source (distfile) must be brought to the local system and then extracted. After
5651: any pkgsrc-specific patches to compile properly are applied, the software can
5652: be configured, then built (usually by compiling), and finally the generated
5653: binaries, etc. can be put into place on the system.
5654:
5655: To get more details about what is happening at each step, you can set the
5656: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
5657: more details about the patch step.
5658:
1.6 rillig 5659: 17.2. Program location
1.1 dsieger 5660:
5661: Before outlining the process performed by the NetBSD package system in the next
5662: section, here's a brief discussion on where programs are installed, and which
5663: variables influence this.
5664:
5665: The automatic variable PREFIX indicates where all files of the final program
5666: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
5667: pkgs in the cross category. The value of PREFIX needs to be put into the
5668: various places in the program's source where paths to these files are encoded.
1.6 rillig 5669: See Section 11.3, "patches/*" and Section 19.3.1, "Shared libraries - libtool"
1.1 dsieger 5670: for more details.
5671:
5672: When choosing which of these variables to use, follow the following rules:
5673:
5674: * PREFIX always points to the location where the current pkg will be
1.25 wiz 5675: installed. When referring to a pkg's own installation path, use "${PREFIX}"
5676: .
1.1 dsieger 5677:
5678: * LOCALBASE is where all non-X11 pkgs are installed. If you need to construct
5679: a -I or -L argument to the compiler to find includes and libraries
5680: installed by another non-X11 pkg, use "${LOCALBASE}". The name LOCALBASE
5681: stems from FreeBSD, which installed all packages in /usr/local. As pkgsrc
5682: leaves /usr/local for the system administrator, this variable is a
5683: misnomer.
5684:
5685: * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
5686: installed. When looking for standard X11 includes (not those installed by a
5687: package), use "${X11BASE}".
5688:
5689: * X11-based packages are special in that they may be installed in either
5690: X11BASE or LOCALBASE.
5691:
5692: Usually, X11 packages should be installed under LOCALBASE whenever
5693: possible. Note that you will need to include ../../mk/x11.buildlink3.mk in
5694: them to request the presence of X11 and to get the right compilation flags.
5695:
5696: Even though, there are some packages that cannot be installed under
5697: LOCALBASE: those that come with app-defaults files. These packages are
5698: special and they must be placed under X11BASE. To accomplish this, set
5699: either USE_X11BASE or USE_IMAKE in your package.
5700:
5701: Some notes: If you need to find includes or libraries installed by a pkg
1.25 wiz 5702: that has USE_IMAKE or USE_X11BASE in its pkg Makefile, you need to look in
1.1 dsieger 5703: both ${X11BASE} and ${LOCALBASE}. To force installation of all X11 packages
5704: in LOCALBASE, the pkgtools/xpkgwedge package is enabled by default.
5705:
5706: * X11PREFIX should be used to refer to the installed location of an X11
5707: package. X11PREFIX will be set to X11BASE if xpkgwedge is not installed,
5708: and to LOCALBASE if xpkgwedge is installed.
5709:
5710: * If xpkgwedge is installed, it is possible to have some packages installed
5711: in X11BASE and some in LOCALBASE. To determine the prefix of an installed
5712: package, the EVAL_PREFIX definition can be used. It takes pairs in the
5713: format "DIRNAME=<package>", and the make(1) variable DIRNAME will be set to
5714: the prefix of the installed package <package>, or "${X11PREFIX}" if the
5715: package is not installed.
5716:
5717: This is best illustrated by example.
5718:
5719: The following lines are taken from pkgsrc/wm/scwm/Makefile:
5720:
5721: EVAL_PREFIX+= GTKDIR=gtk+
5722: CONFIGURE_ARGS+= --with-guile-prefix=${LOCALBASE:Q}
5723: CONFIGURE_ARGS+= --with-gtk-prefix=${GTKDIR:Q}
5724: CONFIGURE_ARGS+= --enable-multibyte
5725:
5726: Specific defaults can be defined for the packages evaluated using
5727: EVAL_PREFIX, by using a definition of the form:
5728:
5729: GTKDIR_DEFAULT= ${LOCALBASE}
5730:
5731: where GTKDIR corresponds to the first definition in the EVAL_PREFIX pair.
5732:
5733: * Within ${PREFIX}, packages should install files according to hier(7), with
5734: the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
5735: man.
5736:
1.6 rillig 5737: 17.3. Directories used during the build process
1.1 dsieger 5738:
1.14 jmcneill 5739: When building a package, various directories are used to store source files,
1.1 dsieger 5740: temporary files, pkgsrc-internal files, and so on. These directories are
5741: explained here.
5742:
5743: Some of the directory variables contain relative pathnames. There are two
5744: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
5745: used for directories that are pkgsrc-specific. WRKSRC is used for directories
5746: inside the package itself.
5747:
5748: PKGSRCDIR
5749:
5750: This is an absolute pathname that points to the pkgsrc root directory.
5751: Generally, you don't need it.
5752:
5753: PKGDIR
5754:
5755: This is an absolute pathname that points to the current package.
5756:
5757: PKGPATH
5758:
5759: This is a pathname relative to PKGSRCDIR that points to the current
5760: package.
5761:
5762: WRKDIR
5763:
5764: This is an absolute pathname pointing to the directory where all work takes
5765: place. The distfiles are extracted to this directory. It also contains
5766: temporary directories and log files used by the various pkgsrc frameworks,
5767: like buildlink or the wrappers.
5768:
5769: WRKSRC
5770:
5771: This is an absolute pathname pointing to the directory where the distfiles
5772: are extracted. It is usually a direct subdirectory of WRKDIR, and often
5773: it's the only directory entry that isn't hidden. This variable may be
5774: changed by a package Makefile.
5775:
1.14 jmcneill 5776: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
1.15 rillig 5777: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
1.14 jmcneill 5778: created in the pkgsrc entry's directory. If users would like to have their
5779: pkgsrc trees behave in a read-only manner, then the value of
5780: CREATE_WRKDIR_SYMLINK should be set to no.
5781:
1.6 rillig 5782: 17.4. Running a phase
1.1 dsieger 5783:
5784: You can run a particular phase by typing make phase, where phase is the name of
5785: the phase. This will automatically run all phases that are required for this
5786: phase. The default phase is build, that is, when you run make without
5787: parameters in a package directory, the package will be built, but not
5788: installed.
5789:
1.6 rillig 5790: 17.5. The fetch phase
1.1 dsieger 5791:
5792: The first step in building a package is to fetch the distribution files
1.25 wiz 5793: (distfiles) from the sites that are providing them. This is the task of the
1.1 dsieger 5794: fetch phase.
5795:
1.6 rillig 5796: 17.5.1. What to fetch and where to get it from
1.1 dsieger 5797:
5798: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
5799: name is derived from the DISTNAME variable, is fetched. The more complicated
5800: cases are described below.
5801:
5802: The variable DISTFILES specifies the list of distfiles that have to be fetched.
5803: Its value defaults to ${DISTNAME}${EXTRACT_SUFX}, so that most packages don't
5804: need to define it at all. EXTRACT_SUFX is .tar.gz by default, but can be
5805: changed freely. Note that if your package requires additional distfiles to the
5806: default one, you cannot just append the additional filenames using the +=
5807: operator, but you have write for example:
5808:
5809: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
5810:
5811: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
5812: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
5813: can set SITES.distfile to the list of URLs where the file distfile (including
5814: the suffix) can be found.
5815:
5816: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
5817: DISTFILES+= foo-file.tar.gz
5818: SITES.foo-file.tar.gz= \
5819: http://www.somewhere.com/somehow/ \
5820: http://www.somewhereelse.com/mirror/somehow/
5821:
5822: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
5823: gets the name of each distfile appended to it, without an intermediate slash.
5824: Therefore, all site values have to end with a slash or other separator
5825: character. This allows for example to set MASTER_SITES to a URL of a CGI script
5826: that gets the name of the distfile as a parameter. In this case, the definition
5827: would look like:
5828:
5829: MASTER_SITES= http://www.example.com/download.cgi?file=
5830:
1.23 jakllsch 5831: The exception to this rule are URLs starting with a dash. In that case the URL
5832: is taken as is, fetched and the result stored under the name of the distfile.
5833:
1.1 dsieger 5834: There are some predefined values for MASTER_SITES, which can be used in
5835: packages. The names of the variables should speak for themselves.
5836:
5837: ${MASTER_SITE_APACHE}
5838: ${MASTER_SITE_BACKUP}
5839: ${MASTER_SITE_CYGWIN}
5840: ${MASTER_SITE_DEBIAN}
5841: ${MASTER_SITE_FREEBSD}
5842: ${MASTER_SITE_FREEBSD_LOCAL}
5843: ${MASTER_SITE_GENTOO}
5844: ${MASTER_SITE_GNOME}
5845: ${MASTER_SITE_GNU}
5846: ${MASTER_SITE_GNUSTEP}
5847: ${MASTER_SITE_IFARCHIVE}
5848: ${MASTER_SITE_KDE}
5849: ${MASTER_SITE_MOZILLA}
5850: ${MASTER_SITE_MYSQL}
5851: ${MASTER_SITE_OPENOFFICE}
5852: ${MASTER_SITE_PERL_CPAN}
5853: ${MASTER_SITE_PGSQL}
5854: ${MASTER_SITE_R_CRAN}
5855: ${MASTER_SITE_SOURCEFORGE}
5856: ${MASTER_SITE_SOURCEFORGE_JP}
5857: ${MASTER_SITE_SUNSITE}
5858: ${MASTER_SITE_SUSE}
5859: ${MASTER_SITE_TEX_CTAN}
5860: ${MASTER_SITE_XCONTRIB}
5861: ${MASTER_SITE_XEMACS}
5862:
5863: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
5864: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
1.27 wiz 5865: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
1.26 spz 5866: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
5867: distfiles/LOCAL_PORTS/.
1.1 dsieger 5868:
5869: If you choose one of these predefined sites, you may want to specify a
5870: subdirectory of that site. Since these macros may expand to more than one
5871: actual site, you must use the following construct to specify a subdirectory:
5872:
5873: MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/}
5874: MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/}
5875:
5876: Note the trailing slash after the subdirectory name.
5877:
1.6 rillig 5878: 17.5.2. How are the files fetched?
1.1 dsieger 5879:
5880: The fetch phase makes sure that all the distfiles exist in a local directory
5881: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
5882: are fetched using commands of the form
5883:
5884: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
5885:
5886: where ${site} varies through several possibilities in turn: first,
5887: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
5888: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
5889: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
5890: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
5891: MASTER_SORT_AWK or MASTER_SORT_REGEX.
5892:
1.16 jnemeth 5893: The specific command and arguments used depend on the FETCH_USING parameter.
5894: The example above is for FETCH_USING=custom.
5895:
1.1 dsieger 5896: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
5897: target to mirror the distfiles, if they are freely distributable. Packages
5898: setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
5899: distfiles mirrored.
5900:
1.6 rillig 5901: 17.6. The checksum phase
1.1 dsieger 5902:
5903: After the distfile(s) are fetched, their checksum is generated and compared
5904: with the checksums stored in the distinfo file. If the checksums don't match,
5905: the build is aborted. This is to ensure the same distfile is used for building,
5906: and that the distfile wasn't changed, e.g. by some malign force, deliberately
5907: changed distfiles on the master distribution site or network lossage.
5908:
1.6 rillig 5909: 17.7. The extract phase
1.1 dsieger 5910:
5911: When the distfiles are present on the local system, they need to be extracted,
5912: as they usually come in the form of some compressed archive format.
5913:
5914: By default, all DISTFILES are extracted. If you only need some of them, you can
5915: set the EXTRACT_ONLY variable to the list of those files.
5916:
5917: Extracting the files is usually done by a little program, mk/extract/extract,
5918: which already knows how to extract various archive formats, so most likely you
5919: will not need to change anything here. But if you need, the following variables
5920: may help you:
5921:
5922: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
5923:
5924: Use these variables to override the default options for an extract command,
5925: which are defined in mk/extract/extract.
5926:
5927: EXTRACT_USING
5928:
1.14 jmcneill 5929: This variable can be set to bsdtar, gtar, nbtar (which is the default
5930: value), pax, or an absolute pathname pointing to the command with which tar
5931: archives should be extracted. It is preferred to choose bsdtar over gtar if
5932: NetBSD's pax-as-tar is not good enough.
1.1 dsieger 5933:
5934: If the extract program doesn't serve your needs, you can also override the
5935: EXTRACT_CMD variable, which holds the command used for extracting the files.
5936: This command is executed in the ${WRKSRC} directory. During execution of this
5937: command, the shell variable extract_file holds the absolute pathname of the
5938: file that is going to be extracted.
5939:
5940: And if that still does not suffice, you can override the do-extract target in
5941: the package Makefile.
5942:
1.6 rillig 5943: 17.8. The patch phase
1.1 dsieger 5944:
5945: After extraction, all the patches named by the PATCHFILES, those present in the
5946: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
5947: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
5948: are uncompressed before they are applied, files ending in .orig or .rej are
5949: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
1.6 rillig 5950: Section 11.3, "patches/*" for more details.
1.1 dsieger 5951:
5952: By default patch(1) is given special args to make it fail if the patches apply
5953: with some lines of fuzz. Please fix (regen) the patches so that they apply
5954: cleanly. The rationale behind this is that patches that don't apply cleanly may
5955: end up being applied in the wrong place, and cause severe harm there.
5956:
1.6 rillig 5957: 17.9. The tools phase
1.1 dsieger 5958:
1.6 rillig 5959: This is covered in Chapter 18, Tools needed for building or running.
1.1 dsieger 5960:
1.6 rillig 5961: 17.10. The wrapper phase
1.1 dsieger 5962:
5963: This phase creates wrapper programs for the compilers and linkers. The
5964: following variables can be used to tweak the wrappers.
5965:
5966: ECHO_WRAPPER_MSG
5967:
5968: The command used to print progress messages. Does nothing by default. Set
5969: to ${ECHO} to see the progress messages.
5970:
5971: WRAPPER_DEBUG
5972:
5973: This variable can be set to yes (default) or no, depending on whether you
5974: want additional information in the wrapper log file.
5975:
5976: WRAPPER_UPDATE_CACHE
5977:
5978: This variable can be set to yes or no, depending on whether the wrapper
5979: should use its cache, which will improve the speed. The default value is
5980: yes, but is forced to no if the platform does not support it.
5981:
5982: WRAPPER_REORDER_CMDS
5983:
5984: A list of reordering commands. A reordering command has the form reorder:l:
5985: lib1:lib2. It ensures that that -llib1 occurs before -llib2.
5986:
5987: WRAPPER_TRANSFORM_CMDS
5988:
5989: A list of transformation commands. [TODO: investigate further]
5990:
1.6 rillig 5991: 17.11. The configure phase
1.1 dsieger 5992:
5993: Most pieces of software need information on the header files, system calls, and
5994: library routines which are available on the platform they run on. The process
5995: of determining this information is known as configuration, and is usually
5996: automated. In most cases, a script is supplied with the distfiles, and its
5997: invocation results in generation of header files, Makefiles, etc.
5998:
5999: If the package contains a configure script, this can be invoked by setting
6000: HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
6001: should set GNU_CONFIGURE to "yes" instead. What happens in the configure phase
6002: is roughly:
6003:
6004: .for d in ${CONFIGURE_DIRS}
6005: cd ${WRKSRC} \
6006: && cd ${d} \
6007: && env ${CONFIGURE_ENV} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
6008: .endfor
6009:
6010: CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
6011: each of these directories, the configure script is run with the environment
6012: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
6013: CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
6014: by the package.
6015:
1.38 wiz 6016: If the program uses the Perl way of configuration (mainly Perl modules, but not
6017: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
6018: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
6019: (e.g., MAKE_PARAMS+=foo=bar
6020:
1.1 dsieger 6021: If the program uses an Imakefile for configuration, the appropriate steps can
6022: be invoked by setting USE_IMAKE to "yes". (If you only want the package
6023: installed in ${X11PREFIX} but xmkmf not being run, set USE_X11BASE instead.)
6024: You can add variables to xmkmf's environment by adding them to the SCRIPTS_ENV
6025: variable.
6026:
1.11 rillig 6027: If the program uses cmake for configuration, the appropriate steps can be
6028: invoked by setting USE_CMAKE to "yes". You can add variables to cmake's
6029: environment by adding them to the CONFIGURE_ENV variable and arguments to cmake
6030: by adding them to the CMAKE_ARGS variable. The top directory argument is given
6031: by the CMAKE_ARG_PATH variable, that defaults to "." (relative to
6032: CONFIGURE_DIRS)
6033:
1.1 dsieger 6034: If there is no configure step at all, set NO_CONFIGURE to "yes".
6035:
1.6 rillig 6036: 17.12. The build phase
1.1 dsieger 6037:
6038: For building a package, a rough equivalent of the following code is executed.
6039:
6040: .for d in ${BUILD_DIRS}
6041: cd ${WRKSRC} \
6042: && cd ${d} \
6043: && env ${MAKE_ENV} \
6044: ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
6045: -f ${MAKE_FILE} \
6046: ${BUILD_TARGET}
6047: .endfor
6048:
6049: BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
6050: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
6051: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
6052: and BUILD_TARGET may all be changed by the package.
6053:
1.25 wiz 6054: The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
6055: make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
6056: defaults to "all".
1.1 dsieger 6057:
6058: If there is no build step at all, set NO_BUILD to "yes".
6059:
1.6 rillig 6060: 17.13. The test phase
1.1 dsieger 6061:
6062: [TODO]
6063:
1.6 rillig 6064: 17.14. The install phase
1.1 dsieger 6065:
6066: Once the build stage has completed, the final step is to install the software
6067: in public directories, so users can access the programs and files.
6068:
6069: In the install phase, a rough equivalent of the following code is executed.
6070: Additionally, before and after this code, much magic is performed to do
6071: consistency checks, registering the package, and so on.
6072:
6073: .for d in ${INSTALL_DIRS}
6074: cd ${WRKSRC} \
6075: && cd ${d} \
6076: && env ${MAKE_ENV} \
6077: ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
6078: -f ${MAKE_FILE} \
6079: ${INSTALL_TARGET}
6080: .endfor
6081:
6082: The variable's meanings are analogous to the ones in the build phase.
6083: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
6084: plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
6085: defined.
6086:
6087: In the install phase, the following variables are useful. They are all
6088: variations of the install(1) command that have the owner, group and permissions
6089: preset. INSTALL is the plain install command. The specialized variants,
6090: together with their intended use, are:
6091:
6092: INSTALL_PROGRAM_DIR
6093:
6094: directories that contain binaries
6095:
6096: INSTALL_SCRIPT_DIR
6097:
6098: directories that contain scripts
6099:
6100: INSTALL_LIB_DIR
6101:
6102: directories that contain shared and static libraries
6103:
6104: INSTALL_DATA_DIR
6105:
6106: directories that contain data files
6107:
6108: INSTALL_MAN_DIR
6109:
6110: directories that contain man pages
6111:
6112: INSTALL_PROGRAM
6113:
6114: binaries that can be stripped from debugging symbols
6115:
6116: INSTALL_SCRIPT
6117:
6118: binaries that cannot be stripped
6119:
6120: INSTALL_GAME
6121:
6122: game binaries
6123:
6124: INSTALL_LIB
6125:
6126: shared and static libraries
6127:
6128: INSTALL_DATA
6129:
6130: data files
6131:
6132: INSTALL_GAME_DATA
6133:
6134: data files for games
6135:
6136: INSTALL_MAN
6137:
6138: man pages
6139:
6140: Some other variables are:
6141:
6142: INSTALLATION_DIRS
6143:
6144: A list of directories relative to PREFIX that are created by pkgsrc at the
6145: beginning of the install phase. The package is supposed to create all
6146: needed directories itself before installing files to it and list all other
6147: directories here.
6148:
1.25 wiz 6149: In the rare cases that a package shouldn't install anything, set NO_INSTALL to
1.1 dsieger 6150: "yes". This is mostly relevant for packages in the regress category.
6151:
1.6 rillig 6152: 17.15. The package phase
1.1 dsieger 6153:
6154: Once the install stage has completed, a binary package of the installed files
6155: can be built. These binary packages can be used for quick installation without
6156: previous compilation, e.g. by the make bin-install or by using pkg_add.
6157:
6158: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
6159: created in ${PACKAGES}/category, one for each category in the CATEGORIES
6160: variable. PACKAGES defaults to pkgsrc/packages.
6161:
1.6 rillig 6162: 17.16. Cleaning up
1.1 dsieger 6163:
6164: Once you're finished with a package, you can clean the work directory by
6165: running make clean. If you want to clean the work directories of all
6166: dependencies too, use make clean-depends.
6167:
1.6 rillig 6168: 17.17. Other helpful targets
1.1 dsieger 6169:
6170: pre/post-*
6171:
6172: For any of the main targets described in the previous section, two
6173: auxiliary targets exist with "pre-" and "post-" used as a prefix for the
6174: main target's name. These targets are invoked before and after the main
6175: target is called, allowing extra configuration or installation steps be
6176: performed from a package's Makefile, for example, which a program's
6177: configure script or install target omitted.
6178:
6179: do-*
6180:
6181: Should one of the main targets do the wrong thing, and should there be no
6182: variable to fix this, you can redefine it with the do-* target. (Note that
6183: redefining the target itself instead of the do-* target is a bad idea, as
6184: the pre-* and post-* targets won't be called anymore, etc.) You will not
6185: usually need to do this.
6186:
6187: reinstall
6188:
6189: If you did a make install and you noticed some file was not installed
6190: properly, you can repeat the installation with this target, which will
6191: ignore the "already installed" flag.
6192:
6193: This is the default value of DEPENDS_TARGET except in the case of make
6194: update and make package, where the defaults are "package" and "update",
6195: respectively.
6196:
6197: deinstall
6198:
6199: This target does a pkg_delete(1) in the current directory, effectively
6200: de-installing the package. The following variables can be used to tune the
6201: behaviour:
6202:
6203: PKG_VERBOSE
6204:
6205: Add a "-v" to the pkg_delete(1) command.
6206:
6207: DEINSTALLDEPENDS
6208:
6209: Remove all packages that require (depend on) the given package. This
6210: can be used to remove any packages that may have been pulled in by a
6211: given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
1.25 wiz 6212: pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
6213: " to the pkg_delete(1) command line.
1.1 dsieger 6214:
6215: bin-install
6216:
6217: Install a binary package from local disk and via FTP from a list of sites
6218: (see the BINPKG_SITES variable), and do a make package if no binary package
6219: is available anywhere. The arguments given to pkg_add can be set via
6220: BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
6221:
6222: update
6223:
6224: This target causes the current package to be updated to the latest version.
6225: The package and all depending packages first get de-installed, then current
6226: versions of the corresponding packages get compiled and installed. This is
6227: similar to manually noting which packages are currently installed, then
6228: performing a series of make deinstall and make install (or whatever
6229: UPDATE_TARGET is set to) for these packages.
6230:
6231: You can use the "update" target to resume package updating in case a
6232: previous make update was interrupted for some reason. However, in this
6233: case, make sure you don't call make clean or otherwise remove the list of
6234: dependent packages in WRKDIR. Otherwise, you lose the ability to
6235: automatically update the current package along with the dependent packages
6236: you have installed.
6237:
6238: Resuming an interrupted make update will only work as long as the package
6239: tree remains unchanged. If the source code for one of the packages to be
6240: updated has been changed, resuming make update will most certainly fail!
6241:
1.4 rillig 6242: The following variables can be used either on the command line or in
1.1 dsieger 6243: mk.conf to alter the behaviour of make update:
6244:
6245: UPDATE_TARGET
6246:
6247: Install target to recursively use for the updated package and the
6248: dependent packages. Defaults to DEPENDS_TARGET if set, "install"
1.25 wiz 6249: otherwise for make update. Other good targets are "package" or "
6250: bin-install". Do not set this to "update" or you will get stuck in an
1.1 dsieger 6251: endless loop!
6252:
6253: NOCLEAN
6254:
6255: Don't clean up after updating. Useful if you want to leave the work
6256: sources of the updated packages around for inspection or other
1.25 wiz 6257: purposes. Be sure you eventually clean up the source tree (see the "
6258: clean-update" target below) or you may run into troubles with old
1.1 dsieger 6259: source code still lying around on your next make or make update.
6260:
6261: REINSTALL
6262:
6263: Deinstall each package before installing (making DEPENDS_TARGET). This
6264: may be necessary if the "clean-update" target (see below) was called
6265: after interrupting a running make update.
6266:
6267: DEPENDS_TARGET
6268:
6269: Allows you to disable recursion and hardcode the target for packages.
6270: The default is "update" for the update target, facilitating a recursive
6271: update of prerequisite packages. Only set DEPENDS_TARGET if you want to
6272: disable recursive updates. Use UPDATE_TARGET instead to just set a
6273: specific target for each package to be installed during make update
6274: (see above).
6275:
6276: clean-update
6277:
6278: Clean the source tree for all packages that would get updated if make
6279: update was called from the current directory. This target should not be
6280: used if the current package (or any of its depending packages) have already
6281: been de-installed (e.g., after calling make update) or you may lose some
1.25 wiz 6282: packages you intended to update. As a rule of thumb: only use this target
1.1 dsieger 6283: before the first time you run make update and only if you have a dirty
6284: package tree (e.g., if you used NOCLEAN).
6285:
6286: If you are unsure about whether your tree is clean, you can either perform
6287: a make clean at the top of the tree, or use the following sequence of
6288: commands from the directory of the package you want to update (before
6289: running make update for the first time, otherwise you lose all the packages
6290: you wanted to update!):
6291:
6292: # make clean-update
6293: # make clean CLEANDEPENDS=YES
6294: # make update
6295:
6296:
1.4 rillig 6297: The following variables can be used either on the command line or in
1.1 dsieger 6298: mk.conf to alter the behaviour of make clean-update:
6299:
6300: CLEAR_DIRLIST
6301:
6302: After make clean, do not reconstruct the list of directories to update
6303: for this package. Only use this if make update successfully installed
6304: all packages you wanted to update. Normally, this is done automatically
6305: on make update, but may have been suppressed by the NOCLEAN variable
6306: (see above).
6307:
6308: replace
6309:
6310: Update the installation of the current package. This differs from update in
6311: that it does not replace dependent packages. You will need to install
6312: pkgtools/pkg_tarup for this target to work.
6313:
6314: Be careful when using this target! There are no guarantees that dependent
6315: packages will still work, in particular they will most certainly break if
6316: you make replace a library package whose shared library major version
6317: changed between your installed version and the new one. For this reason,
6318: this target is not officially supported and only recommended for advanced
6319: users.
6320:
6321: info
6322:
6323: This target invokes pkg_info(1) for the current package. You can use this
6324: to check which version of a package is installed.
6325:
6326: index
6327:
6328: This is a top-level command, i.e. it should be used in the pkgsrc
6329: directory. It creates a database of all packages in the local pkgsrc tree,
6330: including dependencies, comment, maintainer, and some other useful
6331: information. Individual entries are created by running make describe in the
6332: packages' directories. This index file is saved as pkgsrc/INDEX. It can be
6333: displayed in verbose format by running make print-index. You can search in
6334: it with make search key=something. You can extract a list of all packages
6335: that depend on a particular one by running make show-deps PKG=somepackage.
6336:
6337: Running this command takes a very long time, some hours even on fast
6338: machines!
6339:
6340: readme
6341:
6342: This target generates a README.html file, which can be viewed using a
6343: browser such as www/firefox or www/links. The generated files contain
6344: references to any packages which are in the PACKAGES directory on the local
6345: host. The generated files can be made to refer to URLs based on
6346: FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
6347: README.html files which pointed to binary packages on the local machine, in
6348: the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
6349: FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
6350: subdirectories will be searched for all the binary packages.
6351:
6352: The target can be run at the toplevel or in category directories, in which
6353: case it descends recursively.
6354:
6355: readme-all
6356:
6357: This is a top-level command, run it in pkgsrc. Use this target to create a
6358: file README-all.html which contains a list of all packages currently
6359: available in the NetBSD Packages Collection, together with the category
6360: they belong to and a short description. This file is compiled from the
6361: pkgsrc/*/README.html files, so be sure to run this after a make readme.
6362:
6363: cdrom-readme
6364:
6365: This is very much the same as the "readme" target (see above), but is to be
6366: used when generating a pkgsrc tree to be written to a CD-ROM. This target
6367: also produces README.html files, and can be made to refer to URLs based on
6368: CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
6369:
6370: show-distfiles
6371:
6372: This target shows which distfiles and patchfiles are needed to build the
6373: package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
6374: patches/*).
6375:
6376: show-downlevel
6377:
6378: This target shows nothing if the package is not installed. If a version of
6379: this package is installed, but is not the version provided in this version
6380: of pkgsrc, then a warning message is displayed. This target can be used to
6381: show which of your installed packages are downlevel, and so the old
6382: versions can be deleted, and the current ones added.
6383:
6384: show-pkgsrc-dir
6385:
6386: This target shows the directory in the pkgsrc hierarchy from which the
6387: package can be built and installed. This may not be the same directory as
6388: the one from which the package was installed. This target is intended to be
6389: used by people who may wish to upgrade many packages on a single host, and
1.25 wiz 6390: can be invoked from the top-level pkgsrc Makefile by using the "
6391: show-host-specific-pkgs" target.
1.1 dsieger 6392:
6393: show-installed-depends
6394:
6395: This target shows which installed packages match the current package's
6396: DEPENDS. Useful if out of date dependencies are causing build problems.
6397:
6398: check-shlibs
6399:
6400: After a package is installed, check all its binaries and (on ELF platforms)
6401: shared libraries to see if they find the shared libs they need. Run by
1.4 rillig 6402: default if PKG_DEVELOPER is set in mk.conf.
1.1 dsieger 6403:
6404: print-PLIST
6405:
6406: After a "make install" from a new or upgraded pkg, this prints out an
6407: attempt to generate a new PLIST from a find -newer work/.extract_done. An
6408: attempt is made to care for shared libs etc., but it is strongly
6409: recommended to review the result before putting it into PLIST. On upgrades,
6410: it's useful to diff the output of this command against an already existing
6411: PLIST file.
6412:
6413: If the package installs files via tar(1) or other methods that don't update
6414: file access times, be sure to add these files manually to your PLIST, as
6415: the "find -newer" command used by this target won't catch them!
6416:
1.6 rillig 6417: See Section 13.3, "Tweaking output of make print-PLIST" for more
1.1 dsieger 6418: information on this target.
6419:
6420: bulk-package
6421:
6422: Used to do bulk builds. If an appropriate binary package already exists, no
6423: action is taken. If not, this target will compile, install and package it
1.6 rillig 6424: (and its depends, if PKG_DEPENDS is set properly. See Section 7.3.1,
1.1 dsieger 6425: "Configuration"). After creating the binary package, the sources, the
6426: just-installed package and its required packages are removed, preserving
6427: free disk space.
6428:
6429: Beware that this target may deinstall all packages installed on a system!
6430:
6431: bulk-install
6432:
6433: Used during bulk-installs to install required packages. If an up-to-date
1.25 wiz 6434: binary package is available, it will be installed via pkg_add(1). If not,
1.1 dsieger 6435: make bulk-package will be executed, but the installed binary won't be
6436: removed.
6437:
6438: A binary package is considered "up-to-date" to be installed via pkg_add(1)
6439: if:
6440:
1.42 asau 6441: + None of the package's files (Makefile, ...) were modified since it was
1.1 dsieger 6442: built.
6443:
1.42 asau 6444: + None of the package's required (binary) packages were modified since it
1.1 dsieger 6445: was built.
6446:
6447: Beware that this target may deinstall all packages installed on a system!
6448:
1.6 rillig 6449: Chapter 18. Tools needed for building or running
1.1 dsieger 6450:
6451: Table of Contents
6452:
1.6 rillig 6453: 18.1. Tools for pkgsrc builds
6454: 18.2. Tools needed by packages
6455: 18.3. Tools provided by platforms
6456: 18.4. Questions regarding the tools
1.1 dsieger 6457:
6458: The USE_TOOLS definition is used both internally by pkgsrc and also for
6459: individual packages to define what commands are needed for building a package
6460: (like BUILD_DEPENDS) or for later run-time of an installed packaged (such as
6461: DEPENDS). If the native system provides an adequate tool, then in many cases, a
6462: pkgsrc package will not be used.
6463:
6464: When building a package, the replacement tools are made available in a
6465: directory (as symlinks or wrapper scripts) that is early in the executable
6466: search path. Just like the buildlink system, this helps with consistent builds.
6467:
6468: A tool may be needed to help build a specific package. For example, perl, GNU
6469: make (gmake) or yacc may be needed.
6470:
6471: Also a tool may be needed, for example, because the native system's supplied
6472: tool may be inefficient for building a package with pkgsrc. For example, a
6473: package may need GNU awk, bison (instead of yacc) or a better sed.
6474:
6475: The tools used by a package can be listed by running make show-tools.
6476:
1.6 rillig 6477: 18.1. Tools for pkgsrc builds
1.1 dsieger 6478:
6479: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
6480: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
6481: seen by running: make show-var VARNAME=USE_TOOLS.
6482:
6483: If a package needs a specific program to build then the USE_TOOLS variable can
6484: be used to define the tools needed.
6485:
1.6 rillig 6486: 18.2. Tools needed by packages
1.1 dsieger 6487:
1.29 wiz 6488: In the following examples, the :run means that it is needed at run-time (and
6489: becomes a DEPENDS). The default is a build dependency which can be set with
6490: :build. (So in this example, it is the same as gmake:build and
6491: pkg-config:build.)
1.1 dsieger 6492:
6493: USE_TOOLS+= gmake perl:run pkg-config
6494:
6495: When using the tools framework, a TOOLS_PATH.foo variable is defined which
6496: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
6497: could be "/bin/bash" on Linux systems.
6498:
6499: If you always need a pkgsrc version of the tool at run-time, then just use
6500: DEPENDS instead.
6501:
1.6 rillig 6502: 18.3. Tools provided by platforms
1.1 dsieger 6503:
6504: When improving or porting pkgsrc to a new platform, have a look at (or create)
6505: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
6506: tools.${OPSYS}.mk which defines the name of the common tools. For example:
6507:
6508: .if exists(/usr/bin/bzcat)
6509: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
6510: .elif exists(/usr/bin/bzip2)
6511: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
6512: .endif
6513:
6514: TOOLS_PLATFORM.true?= true # shell builtin
6515:
1.6 rillig 6516: 18.4. Questions regarding the tools
1.1 dsieger 6517:
1.6 rillig 6518: 18.4.1. How do I add a new tool?
6519: 18.4.2. How do I get a list of all available tools?
6520: 18.4.3. How can I get a list of all the tools that a package is using while
1.1 dsieger 6521: being built? I want to know whether it uses sed or not.
6522:
1.6 rillig 6523: 18.4.1. How do I add a new tool?
1.1 dsieger 6524:
6525: TODO
6526:
1.6 rillig 6527: 18.4.2. How do I get a list of all available tools?
1.1 dsieger 6528:
6529: TODO
6530:
1.6 rillig 6531: 18.4.3. How can I get a list of all the tools that a package is using while
1.1 dsieger 6532: being built? I want to know whether it uses sed or not.
6533:
6534: Currently, you can't. (TODO: But I want to be able to do it.)
6535:
1.6 rillig 6536: Chapter 19. Making your package work
1.1 dsieger 6537:
6538: Table of Contents
6539:
1.6 rillig 6540: 19.1. General operation
1.1 dsieger 6541:
1.6 rillig 6542: 19.1.1. Portability of packages
1.24 wiz 6543: 19.1.2. How to pull in user-settable variables from mk.conf
1.6 rillig 6544: 19.1.3. User interaction
6545: 19.1.4. Handling licenses
6546: 19.1.5. Restricted packages
6547: 19.1.6. Handling dependencies
6548: 19.1.7. Handling conflicts with other packages
6549: 19.1.8. Packages that cannot or should not be built
6550: 19.1.9. Packages which should not be deleted, once installed
6551: 19.1.10. Handling packages with security problems
6552: 19.1.11. How to handle incrementing versions when fixing an existing
1.1 dsieger 6553: package
1.6 rillig 6554: 19.1.12. Substituting variable text in the package files (the SUBST
1.1 dsieger 6555: framework)
6556:
1.6 rillig 6557: 19.2. Fixing problems in the fetch phase
1.1 dsieger 6558:
1.6 rillig 6559: 19.2.1. Packages whose distfiles aren't available for plain downloading
6560: 19.2.2. How to handle modified distfiles with the 'old' name
1.1 dsieger 6561:
1.6 rillig 6562: 19.3. Fixing problems in the configure phase
1.1 dsieger 6563:
1.6 rillig 6564: 19.3.1. Shared libraries - libtool
6565: 19.3.2. Using libtool on GNU packages that already support libtool
6566: 19.3.3. GNU Autoconf/Automake
6567:
6568: 19.4. Programming languages
6569:
6570: 19.4.1. C, C++, and Fortran
6571: 19.4.2. Java
6572: 19.4.3. Packages containing perl scripts
1.41 wiz 6573: 19.4.4. Packages containing shell scripts
6574: 19.4.5. Other programming languages
1.6 rillig 6575:
6576: 19.5. Fixing problems in the build phase
6577:
6578: 19.5.1. Compiling C and C++ code conditionally
6579: 19.5.2. How to handle compiler bugs
1.24 wiz 6580: 19.5.3. Undefined reference to "..."
1.6 rillig 6581: 19.5.4. Running out of memory
6582:
6583: 19.6. Fixing problems in the install phase
6584:
6585: 19.6.1. Creating needed directories
6586: 19.6.2. Where to install documentation
6587: 19.6.3. Installing highscore files
6588: 19.6.4. Adding DESTDIR support to packages
6589: 19.6.5. Packages with hardcoded paths to other interpreters
6590: 19.6.6. Packages installing perl modules
6591: 19.6.7. Packages installing info files
6592: 19.6.8. Packages installing man pages
1.7 rillig 6593: 19.6.9. Packages installing GConf data files
1.18 mishka 6594: 19.6.10. Packages installing scrollkeeper/rarian data files
1.6 rillig 6595: 19.6.11. Packages installing X11 fonts
6596: 19.6.12. Packages installing GTK2 modules
6597: 19.6.13. Packages installing SGML or XML data
6598: 19.6.14. Packages installing extensions to the MIME database
6599: 19.6.15. Packages using intltool
6600: 19.6.16. Packages installing startup scripts
6601: 19.6.17. Packages installing TeX modules
6602: 19.6.18. Packages supporting running binaries in emulation
6603: 19.6.19. Packages installing hicolor theme icons
6604: 19.6.20. Packages installing desktop files
1.1 dsieger 6605:
1.6 rillig 6606: 19.7. Marking packages as having problems
1.1 dsieger 6607:
1.6 rillig 6608: 19.1. General operation
1.1 dsieger 6609:
1.6 rillig 6610: 19.1.1. Portability of packages
1.1 dsieger 6611:
6612: One appealing feature of pkgsrc is that it runs on many different platforms. As
6613: a result, it is important to ensure, where possible, that packages in pkgsrc
6614: are portable. This chapter mentions some particular details you should pay
6615: attention to while working on pkgsrc.
6616:
1.6 rillig 6617: 19.1.2. How to pull in user-settable variables from mk.conf
1.1 dsieger 6618:
6619: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4 rillig 6620: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
6621: those variables in the preprocessor directives of make(1) (for example .if or
6622: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
6623: loads the user preferences.
1.1 dsieger 6624:
6625: But note that some variables may not be completely defined after ../../mk/
6626: bsd.prefs.mk has been included, as they may contain references to variables
6627: that are not yet defined. In shell commands this is no problem, since variables
6628: are actually macros, which are only expanded when they are used. But in the
6629: preprocessor directives mentioned above and in dependency lines (of the form
6630: target: dependencies) the variables are expanded at load time.
6631:
6632: Note
6633:
6634: Currently there is no exhaustive list of all variables that tells you whether
6635: they can be used at load time or only at run time, but it is in preparation.
6636:
1.6 rillig 6637: 19.1.3. User interaction
1.1 dsieger 6638:
6639: Occasionally, packages require interaction from the user, and this can be in a
6640: number of ways:
6641:
6642: * When fetching the distfiles, some packages require user interaction such as
6643: entering username/password or accepting a license on a web page.
6644:
6645: * When extracting the distfiles, some packages may ask for passwords.
6646:
6647: * help to configure the package before it is built
6648:
6649: * help during the build process
6650:
6651: * help during the installation of a package
6652:
6653: The INTERACTIVE_STAGE definition is provided to notify the pkgsrc mechanism of
6654: an interactive stage which will be needed, and this should be set in the
6655: package's Makefile, e.g.:
6656:
6657: INTERACTIVE_STAGE= build
6658:
6659:
6660: Multiple interactive stages can be specified:
6661:
6662: INTERACTIVE_STAGE= configure install
6663:
6664:
6665: The user can then decide to skip this package by setting the BATCH variable.
6666:
1.6 rillig 6667: 19.1.4. Handling licenses
1.1 dsieger 6668:
6669: Authors of software can choose the licence under which software can be copied.
6670: This is due to copyright law, and reasons for license choices are outside the
6671: scope of pkgsrc. The pkgsrc system recognizes that there are a number of
6672: licenses which some users may find objectionable or difficult or impossible to
6673: comply with. The Free Software Foundation has declared some licenses "Free",
6674: and the Open Source Initiative has a definition of "Open Source". The pkgsrc
6675: system, as a policy choice, does not label packages which have licenses that
6676: are Free or Open Source. However, packages without a license meeting either of
6677: those tests are labeled with a license tag denoting the license. Note that a
6678: package with no license to copy trivially does not meet either the Free or Open
6679: Source test.
6680:
6681: For packages which are not Free or Open Source, pkgsrc will not build the
6682: package unless the user has indicated to pkgsrc that packages with that
6683: particular license may be built. Note that this documentation avoids the term
6684: "accepted the license". The pkgsrc system is merely providing a mechanism to
6685: avoid accidentally building a package with a non-free license; judgement and
6686: responsibility remain with the user. (Installation of binary packages are not
6687: currently subject to this mechanism; this is a bug.)
6688:
6689: One might want to only install packages with a BSD license, or the GPL, and not
1.20 jnemeth 6690: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
6691: variable. The user can override the default by setting the ACCEPTABLE_LICENSES
6692: variable with "=" instead of "+=". The licenses accepted by default are:
6693:
1.49 rodent 6694: apache-1.1 apache-2.0
6695: arphic-public
6696: artistic artistic-2.0
6697: boost-license
6698: cc-by-sa-v3.0
1.56 ryoon 6699: cc0-1.0-universal
1.49 rodent 6700: cddl-1.0
6701: cpl-1.0
6702: epl-v1.0
1.33 wiz 6703: gnu-fdl-v1.1 gnu-fdl-v1.2 gnu-fdl-v1.3
6704: gnu-gpl-v1
6705: gnu-gpl-v2 gnu-lgpl-v2 gnu-lgpl-v2.1
6706: gnu-gpl-v3 gnu-lgpl-v3
1.49 rodent 6707: ibm-public-license-1.0
6708: ipafont
6709: isc
6710: lppl-1.3c
6711: lucent
6712: miros
6713: mit
6714: mpl-1.0 mpl-1.1 mpl-2.0
6715: mplusfont
6716: ofl-v1.0 ofl-v1.1
1.33 wiz 6717: original-bsd modified-bsd 2-clause-bsd
1.49 rodent 6718: php
6719: png-license
1.33 wiz 6720: postgresql-license
1.49 rodent 6721: public-domain
6722: python-software-foundation
6723: qpl-v1.0
1.53 rodent 6724: sgi-free-software-b-v2.0
1.49 rodent 6725: sleepycat-public
6726: unlicense
6727: x11
1.33 wiz 6728: zlib
6729: zpl
1.20 jnemeth 6730:
1.1 dsieger 6731:
6732: The license tag mechanism is intended to address copyright-related issues
6733: surrounding building, installing and using a package, and not to address
1.20 jnemeth 6734: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
6735: redistribution restrictions should set these tags.
1.1 dsieger 6736:
6737: Denoting that a package may be copied according to a particular license is done
6738: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
6739: string identifying the license, e.g. in graphics/xv:
6740:
6741: LICENSE= xv-license
6742:
6743:
6744: When trying to build, the user will get a notice that the package is covered by
6745: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
6746:
6747: % make
6748: ===> xv-3.10anb9 has an unacceptable license: xv-license.
6749: ===> To view the license, enter "/usr/bin/make show-license".
6750: ===> To indicate acceptance, add this line to your /etc/mk.conf:
6751: ===> ACCEPTABLE_LICENSES+=xv-license
6752: *** Error code 1
6753:
6754:
6755: The license can be viewed with make show-license, and if the user so chooses,
1.4 rillig 6756: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1 dsieger 6757: should not in the future fail because of that license:
6758:
6759: ACCEPTABLE_LICENSES+=xv-license
6760:
6761:
1.49 rodent 6762: When adding a package with a new license, the following steps are required:
6763:
6764: 1. Check if the file can avoid the -license filename tag as described above by
6765: referencing Various Licenses and Comments about Them and Licenses by Name |
6766: Open Source Initiative. If this is the case, additionally add the license
6767: filename to:
6768:
6769: + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
6770:
6771: + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
6772: license.c
6773:
1.53 rodent 6774: + the ACCEPTABLE_LICENSES list in pkgsrc/doc/guide/files/fixes.xml
6775:
1.49 rodent 6776: with the proper syntax as demonstrated in those files, respectively.
6777:
6778: 2. The license text should be added to pkgsrc/licenses for displaying. A list
6779: of known licenses can be seen in this directory.
1.1 dsieger 6780:
6781: When the license changes (in a way other than formatting), please make sure
6782: that the new license has a different name (e.g., append the version number if
6783: it exists, or the date). Just because a user told pkgsrc to build programs
6784: under a previous version of a license does not mean that pkgsrc should build
6785: programs under the new licenses. The higher-level point is that pkgsrc does not
6786: evaluate licenses for reasonableness; the only test is a mechanistic test of
6787: whether a particular text has been approved by either of two bodies.
6788:
6789: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
6790: is deprecated because it does not crisply refer to a particular license text.
6791: Another problem with such usage is that it does not enable a user to tell
6792: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
6793: for all packages with that tag.
6794:
1.6 rillig 6795: 19.1.5. Restricted packages
1.1 dsieger 6796:
6797: Some licenses restrict how software may be re-distributed. Because a license
6798: tag is required unless the package is Free or Open Source, all packages with
6799: restrictions should have license tags. By declaring the restrictions, package
6800: tools can automatically refrain from e.g. placing binary packages on FTP sites.
6801:
6802: There are four restrictions that may be encoded, which are the cross product of
6803: sources (distfiles) and binaries not being placed on FTP sites and CD-ROMs.
6804: Because this is rarely the exact language in any license, and because non-Free
6805: licenses tend to be different from each other, pkgsrc adopts a definition of
6806: FTP and CD-ROM. Pkgsrc uses "FTP" to mean that the source or binary file should
6807: not be made available over the Internet at no charge. Pkgsrc uses "CD-ROM" to
6808: mean that the source or binary may not be made available on some kind of media,
6809: together with other source and binary packages, and which is sold for a
6810: distribution charge.
6811:
6812: In order to encode these restrictions, the package system defines five make
6813: variables that can be set to note these restrictions:
6814:
6815: * RESTRICTED
6816:
6817: This variable should be set whenever a restriction exists (regardless of
6818: its kind). Set this variable to a string containing the reason for the
6819: restriction. It should be understood that those wanting to understand the
6820: restriction will have to read the license, and perhaps seek advice of
6821: counsel.
6822:
6823: * NO_BIN_ON_CDROM
6824:
6825: Binaries may not be placed on CD-ROM containing other binary packages, for
6826: which a distribution charge may be made. In this case, set this variable to
6827: ${RESTRICTED}.
6828:
6829: * NO_BIN_ON_FTP
6830:
6831: Binaries may not made available on the Internet without charge. In this
6832: case, set this variable to ${RESTRICTED}. If this variable is set, binary
6833: packages will not be included on ftp.NetBSD.org.
6834:
6835: * NO_SRC_ON_CDROM
6836:
6837: Distfiles may not be placed on CD-ROM, together with other distfiles, for
6838: which a fee may be charged. In this case, set this variable to $
6839: {RESTRICTED}.
6840:
6841: * NO_SRC_ON_FTP
6842:
6843: Distfiles may not made available via FTP at no charge. In this case, set
6844: this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
6845: will not be mirrored on ftp.NetBSD.org.
6846:
1.33 wiz 6847: Please note that packages will to be removed from pkgsrc when the distfiles are
6848: not distributable and cannot be obtained for a period of one full quarter
6849: branch. Packages with manual / interactive fetch must have a maintainer and it
6850: is his/her responsibility to ensure this.
6851:
1.6 rillig 6852: 19.1.6. Handling dependencies
1.1 dsieger 6853:
6854: Your package may depend on some other package being present - and there are
6855: various ways of expressing this dependency. pkgsrc supports the BUILD_DEPENDS
6856: and DEPENDS definitions, the USE_TOOLS definition, as well as dependencies via
6857: buildlink3.mk, which is the preferred way to handle dependencies, and which
1.6 rillig 6858: uses the variables named above. See Chapter 14, Buildlink methodology for more
1.1 dsieger 6859: information.
6860:
6861: The basic difference between the two variables is as follows: The DEPENDS
6862: definition registers that pre-requisite in the binary package so it will be
6863: pulled in when the binary package is later installed, whilst the BUILD_DEPENDS
6864: definition does not, marking a dependency that is only needed for building the
6865: package.
6866:
6867: This means that if you only need a package present whilst you are building, it
6868: should be noted as a BUILD_DEPENDS.
6869:
6870: The format for a BUILD_DEPENDS and a DEPENDS definition is:
6871:
6872: <pre-req-package-name>:../../<category>/<pre-req-package>
6873:
6874:
6875: Please note that the "pre-req-package-name" may include any of the wildcard
6876: version numbers recognized by pkg_info(1).
6877:
1.55 wiz 6878: 1. If your package needs another package's binaries or libraries to build and
1.1 dsieger 6879: run, and if that package has a buildlink3.mk file available, use it:
6880:
6881: .include "../../graphics/jpeg/buildlink3.mk"
6882:
6883:
1.55 wiz 6884: 2. If your package needs another package's binaries or libraries only for
6885: building, and if that package has a buildlink3.mk file available, use it:
6886:
6887: .include "../../graphics/jpeg/buildlink3.mk"
6888:
6889:
6890: but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
6891: This case is rather rare.
6892:
6893: 3. If your package needs binaries from another package to build, use the
1.26 spz 6894: BUILD_DEPENDS definition:
1.1 dsieger 6895:
1.26 spz 6896: BUILD_DEPENDS+= scons-[0-9]*:../../devel/scons
1.1 dsieger 6897:
6898:
1.55 wiz 6899: 4. If your package needs a library with which to link and there is no
1.26 spz 6900: buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
6901: because the include files and libraries will be hidden from the compiler.
1.1 dsieger 6902:
1.55 wiz 6903: 5. If your package needs some executable to be able to run correctly and if
1.26 spz 6904: there's no buildlink3.mk file, this is specified using the DEPENDS
6905: variable. The print/lyx package needs to be able to execute the latex
6906: binary from the teTeX package when it runs, and that is specified:
1.1 dsieger 6907:
1.26 spz 6908: DEPENDS+= teTeX-[0-9]*:../../print/teTeX
1.1 dsieger 6909:
6910:
1.55 wiz 6911: 6. You can use wildcards in package dependencies. Note that such wildcard
1.26 spz 6912: dependencies are retained when creating binary packages. The dependency is
6913: checked when installing the binary package and any package which matches
6914: the pattern will be used. Wildcard dependencies should be used with care.
1.1 dsieger 6915:
6916: The "-[0-9]*" should be used instead of "-*" to avoid potentially ambiguous
6917: matches such as "tk-postgresql" matching a "tk-*" DEPENDS.
6918:
6919: Wildcards can also be used to specify that a package will only build
6920: against a certain minimum version of a pre-requisite:
6921:
1.26 spz 6922: DEPENDS+= ImageMagick>=6.0:../../graphics/ImageMagick
1.1 dsieger 6923:
6924:
1.26 spz 6925: This means that the package will build using version 6.0 of ImageMagick or
6926: newer. Such a dependency may be warranted if, for example, the command line
6927: options of an executable have changed.
6928:
6929: If you need to depend on minimum versions of libraries, see the buildlink
6930: section of the pkgsrc guide.
1.1 dsieger 6931:
6932: For security fixes, please update the package vulnerabilities file. See
1.6 rillig 6933: Section 19.1.10, "Handling packages with security problems" for more
1.1 dsieger 6934: information.
6935:
1.59 jnemeth 6936: 7. If the package depends on either one of two (or more) packages, specify the
6937: "pre-req-package-name" as a comma-separated list between curly braces.
6938:
6939: As an example, take a package that depends on the Perl "version" module,
6940: which has been part of Perl itself since version 5.10.0. This either/or
6941: dependency is expressed as:
6942:
6943: DEPENDS+= {perl>=5.10.0,p5-version-[0-9]*}:../../devel/p5-version
6944:
6945:
1.1 dsieger 6946: If your package needs files from another package to build, add the relevant
6947: distribution files to DISTFILES, so they will be extracted automatically. See
6948: the print/ghostscript package for an example. (It relies on the jpeg sources
6949: being present in source form during the build.)
6950:
1.6 rillig 6951: 19.1.7. Handling conflicts with other packages
1.1 dsieger 6952:
6953: Your package may conflict with other packages a user might already have
6954: installed on his system, e.g. if your package installs the same set of files as
6955: another package in the pkgsrc tree.
6956:
6957: In this case you can set CONFLICTS to a space-separated list of packages
6958: (including version string) your package conflicts with.
6959:
6960: For example, x11/Xaw3d and x11/Xaw-Xpm install the same shared library, thus
6961: you set in pkgsrc/x11/Xaw3d/Makefile:
6962:
6963: CONFLICTS= Xaw-Xpm-[0-9]*
6964:
6965:
6966: and in pkgsrc/x11/Xaw-Xpm/Makefile:
6967:
6968: CONFLICTS= Xaw3d-[0-9]*
6969:
6970:
6971: Packages will automatically conflict with other packages with the name prefix
6972: and a different version string. "Xaw3d-1.5" e.g. will automatically conflict
6973: with the older version "Xaw3d-1.3".
6974:
1.6 rillig 6975: 19.1.8. Packages that cannot or should not be built
1.1 dsieger 6976:
6977: There are several reasons why a package might be instructed to not build under
6978: certain circumstances. If the package builds and runs on most platforms, the
6979: exceptions should be noted with NOT_FOR_PLATFORM. If the package builds and
6980: runs on a small handful of platforms, set ONLY_FOR_PLATFORM instead. Both
6981: ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS triples (OS-version-platform)
6982: that can use glob-style wildcards.
6983:
6984: Some packages are tightly bound to a specific version of an operating system,
6985: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
6986: with other versions of the OS, and should be uploaded to a version specific
6987: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
6988: to "yes". This variable is not currently used by any of the package system
6989: internals, but may be used in the future.
6990:
6991: If the package should be skipped (for example, because it provides
6992: functionality already provided by the system), set PKG_SKIP_REASON to a
6993: descriptive message. If the package should fail because some preconditions are
6994: not met, set PKG_FAIL_REASON to a descriptive message.
6995:
1.6 rillig 6996: 19.1.9. Packages which should not be deleted, once installed
1.1 dsieger 6997:
6998: To ensure that a package may not be deleted, once it has been installed, the
6999: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.25 wiz 7000: carried into any binary package that is made from this pkgsrc entry. A "
7001: preserved" package will not be deleted using pkg_delete(1) unless the "-f"
1.1 dsieger 7002: option is used.
7003:
1.6 rillig 7004: 19.1.10. Handling packages with security problems
1.1 dsieger 7005:
7006: When a vulnerability is found, this should be noted in localsrc/security/
1.32 wiz 7007: advisories/pkg-vulnerabilities, and after committing that file, ask
7008: pkgsrc-security@NetBSD.org to update the file on ftp.NetBSD.org.
1.1 dsieger 7009:
7010: After fixing the vulnerability by a patch, its PKGREVISION should be increased
7011: (this is of course not necessary if the problem is fixed by using a newer
1.32 wiz 7012: release of the software), and the pattern in the pkg-vulnerabilities file must
7013: be updated.
1.1 dsieger 7014:
7015: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
7016: submit a pullup request!
7017:
7018: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
7019: a weekly cron job.
7020:
1.6 rillig 7021: 19.1.11. How to handle incrementing versions when fixing an existing package
1.1 dsieger 7022:
7023: When making fixes to an existing package it can be useful to change the version
7024: number in PKGNAME. To avoid conflicting with future versions by the original
7025: author, a "nb1", "nb2", ... suffix can be used on package versions by setting
7026: PKGREVISION=1 (2, ...). The "nb" is treated like a "." by the package tools.
7027: e.g.
7028:
7029: DISTNAME= foo-17.42
7030: PKGREVISION= 9
7031:
7032:
7033: will result in a PKGNAME of "foo-17.42nb9". If you want to use the original
7034: value of PKGNAME without the "nbX" suffix, e.g. for setting DIST_SUBDIR, use
7035: PKGNAME_NOREV.
7036:
7037: When a new release of the package is released, the PKGREVISION should be
7038: removed, e.g. on a new minor release of the above package, things should be
7039: like:
7040:
7041: DISTNAME= foo-17.43
7042:
7043:
7044: PKGREVISION should be incremented for any non-trivial change in the resulting
7045: binary package. Without a PKGREVISION bump, someone with the previous version
7046: installed has no way of knowing that their package is out of date. Thus,
7047: changes without increasing PKGREVISION are essentially labeled "this is so
7048: trivial that no reasonable person would want to upgrade", and this is the rough
7049: test for when increasing PKGREVISION is appropriate. Examples of changes that
7050: do not merit increasing PKGREVISION are:
7051:
1.14 jmcneill 7052: * Changing HOMEPAGE, MAINTAINER, OWNER, or comments in Makefile.
1.1 dsieger 7053:
7054: * Changing build variables if the resulting binary package is the same.
7055:
7056: * Changing DESCR.
7057:
7058: * Adding PKG_OPTIONS if the default options don't change.
7059:
7060: Examples of changes that do merit an increase to PKGREVISION include:
7061:
7062: * Security fixes
7063:
7064: * Changes or additions to a patch file
7065:
7066: * Changes to the PLIST
7067:
1.12 weinem 7068: * A dependency is changed or renamed.
7069:
1.1 dsieger 7070: PKGREVISION must also be incremented when dependencies have ABI changes.
7071:
1.6 rillig 7072: 19.1.12. Substituting variable text in the package files (the SUBST framework)
1.1 dsieger 7073:
7074: When you want to replace the same text in multiple files or when the
7075: replacement text varies, patches alone cannot help. This is where the SUBST
7076: framework comes in. It provides an easy-to-use interface for replacing text in
7077: files. Example:
7078:
7079: SUBST_CLASSES+= fix-paths
7080: SUBST_STAGE.fix-paths= pre-configure
7081: SUBST_MESSAGE.fix-paths= Fixing absolute paths.
7082: SUBST_FILES.fix-paths= src/*.c
7083: SUBST_FILES.fix-paths+= scripts/*.sh
7084: SUBST_SED.fix-paths= -e 's,"/usr/local,"${PREFIX},g'
7085: SUBST_SED.fix-paths+= -e 's,"/var/log,"${VARBASE}/log,g'
7086:
7087:
7088: SUBST_CLASSES is a list of identifiers that are used to identify the different
7089: SUBST blocks that are defined. The SUBST framework is heavily used by pkgsrc,
7090: so it is important to always use the += operator with this variable. Otherwise
7091: some substitutions may be skipped.
7092:
7093: The remaining variables of each SUBST block are parameterized with the
7094: identifier from the first line (fix-paths in this case.) They can be seen as
7095: parameters to a function call.
7096:
7097: SUBST_STAGE.* specifies the stage at which the replacement will take place. All
7098: combinations of pre-, do- and post- together with a phase name are possible,
7099: though only few are actually used. Most commonly used are post-patch and
7100: pre-configure. Of these two, pre-configure should be preferred because then it
7101: is possible to run bmake patch and have the state after applying the patches
7102: but before making any other changes. This is especially useful when you are
7103: debugging a package in order to create new patches for it. Similarly,
7104: post-build is preferred over pre-install, because the install phase should
7105: generally be kept as simple as possible. When you use post-build, you have the
7106: same files in the working directory that will be installed later, so you can
7107: check if the substitution has succeeded.
7108:
7109: SUBST_MESSAGE.* is an optional text that is printed just before the
7110: substitution is done.
7111:
7112: SUBST_FILES.* is the list of shell globbing patterns that specifies the files
7113: in which the substitution will take place. The patterns are interpreted
7114: relatively to the WRKSRC directory.
7115:
7116: SUBST_SED.* is a list of arguments to sed(1) that specify the actual
7117: substitution. Every sed command should be prefixed with -e, so that all SUBST
7118: blocks look uniform.
7119:
7120: There are some more variables, but they are so seldomly used that they are only
7121: documented in the mk/subst.mk file.
7122:
1.6 rillig 7123: 19.2. Fixing problems in the fetch phase
1.1 dsieger 7124:
1.6 rillig 7125: 19.2.1. Packages whose distfiles aren't available for plain downloading
1.1 dsieger 7126:
7127: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
7128: a make fetch will call files/getsite.sh with the name of each file to download
7129: as an argument, expecting it to output the URL of the directory from which to
7130: download it. graphics/ns-cult3d is an example of this usage.
7131:
7132: If the download can't be automated, because the user must submit personal
7133: information to apply for a password, or must pay for the source, or whatever,
7134: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
7135: before aborting the build. Example:
7136:
7137: FETCH_MESSAGE= "Please download the files"
7138: FETCH_MESSAGE+= " "${DISTFILES:Q}
7139: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
7140:
7141:
1.6 rillig 7142: 19.2.2. How to handle modified distfiles with the 'old' name
1.1 dsieger 7143:
7144: Sometimes authors of a software package make some modifications after the
7145: software was released, and they put up a new distfile without changing the
7146: package's version number. If a package is already in pkgsrc at that time, the
7147: checksum will no longer match. The contents of the new distfile should be
7148: compared against the old one before changing anything, to make sure the
7149: distfile was really updated on purpose, and that no trojan horse or so crept
7150: in. Please mention that the distfiles were compared and what was found in your
1.54 rodent 7151: commit message.
7152:
7153: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
7154: directory name, usually based on PKGNAME_NOREV. All DISTFILES and PATCHFILES
7155: for this package will be put in that subdirectory of the local distfiles
7156: directory. (See Section 19.1.11, "How to handle incrementing versions when
7157: fixing an existing package" for more details.) In case this happens more often,
7158: PKGNAME can be used (thus including the nbX suffix) or a date stamp can be
7159: appended, like ${PKGNAME_NOREV}-YYYYMMDD.
7160:
7161: DIST_SUBDIR is also used when a distfile's name does not contain a version and
7162: the distfile is apt to change. In cases where the likelihood of this is very
7163: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
7164: removed unless the distfile name changes, even if a package is being moved or
7165: renamed.
7166:
7167: Do not forget regenerating the distinfo file after that, since it contains the
7168: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
7169: installed package is different. Furthermore, a mail to the package's authors
7170: seems appropriate telling them that changing distfiles after releases without
7171: changing the file names is not good practice.
1.1 dsieger 7172:
1.6 rillig 7173: 19.3. Fixing problems in the configure phase
1.1 dsieger 7174:
1.6 rillig 7175: 19.3.1. Shared libraries - libtool
1.1 dsieger 7176:
7177: pkgsrc supports many different machines, with different object formats like
7178: a.out and ELF, and varying abilities to do shared library and dynamic loading
7179: at all. To accompany this, varying commands and options have to be passed to
7180: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
7181: especially if you don't have all the machines at your hand to test things. The
7182: devel/libtool pkg can help here, as it just "knows" how to build both static
7183: and dynamic libraries from a set of source files, thus being
7184: platform-independent.
7185:
7186: Here's how to use libtool in a package in seven simple steps:
7187:
7188: 1. Add USE_LIBTOOL=yes to the package Makefile.
7189:
7190: 2. For library objects, use "${LIBTOOL} --mode=compile ${CC}" in place of "$
7191: {CC}". You could even add it to the definition of CC, if only libraries are
7192: being built in a given Makefile. This one command will build both PIC and
7193: non-PIC library objects, so you need not have separate shared and
7194: non-shared library rules.
7195:
7196: 3. For the linking of the library, remove any "ar", "ranlib", and "ld
7197: -Bshareable" commands, and instead use:
7198:
7199: ${LIBTOOL} --mode=link \
7200: ${CC} -o ${.TARGET:.a=.la} \
7201: ${OBJS:.o=.lo} \
7202: -rpath ${PREFIX}/lib \
7203: -version-info major:minor
7204:
7205:
7206: Note that the library is changed to have a .la extension, and the objects
7207: are changed to have a .lo extension. Change OBJS as necessary. This
7208: automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
7209: necessary) in the build directory. Be sure to include "-version-info",
7210: especially when major and minor are zero, as libtool will otherwise strip
7211: off the shared library version.
7212:
7213: From the libtool manual:
7214:
7215: So, libtool library versions are described by three integers:
7216:
7217: CURRENT
7218: The most recent interface number that this library implements.
7219:
7220: REVISION
7221: The implementation number of the CURRENT interface.
7222:
7223: AGE
7224: The difference between the newest and oldest interfaces that
7225: this library implements. In other words, the library implements
7226: all the interface numbers in the range from number `CURRENT -
7227: AGE' to `CURRENT'.
7228:
7229: If two libraries have identical CURRENT and AGE numbers, then the
7230: dynamic linker chooses the library with the greater REVISION number.
7231:
7232:
7233: The "-release" option will produce different results for a.out and ELF
1.25 wiz 7234: (excluding symlinks) in only one case. An ELF library of the form "
7235: libfoo-release.so.x.y" will have a symlink of "libfoo.so.x.y" on an a.out
1.1 dsieger 7236: platform. This is handled automatically.
7237:
7238: The "-rpath argument" is the install directory of the library being built.
7239:
7240: In the PLIST, include only the .la file, the other files will be added
7241: automatically.
7242:
7243: 4. When linking shared object (.so) files, i.e. files that are loaded via
7244: dlopen(3), NOT shared libraries, use "-module -avoid-version" to prevent
7245: them getting version tacked on.
7246:
7247: The PLIST file gets the foo.so entry.
7248:
7249: 5. When linking programs that depend on these libraries before they are
7250: installed, preface the cc(1) or ld(1) line with "${LIBTOOL} --mode=link",
7251: and it will find the correct libraries (static or shared), but please be
7252: aware that libtool will not allow you to specify a relative path in -L
7253: (such as "-L../somelib"), because it expects you to change that argument to
7254: be the .la file. e.g.
7255:
7256: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
7257:
7258:
7259: should be changed to:
7260:
7261: ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
7262:
7263:
7264: and it will do the right thing with the libraries.
7265:
7266: 6. When installing libraries, preface the install(1) or cp(1) command with "$
7267: {LIBTOOL} --mode=install", and change the library name to .la. e.g.
7268:
1.23 jakllsch 7269: ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1 dsieger 7270:
7271:
7272: This will install the static .a, shared library, any needed symlinks, and
7273: run ldconfig(8).
7274:
7275: 7. In your PLIST, include only the .la file (this is a change from previous
7276: behaviour).
7277:
1.6 rillig 7278: 19.3.2. Using libtool on GNU packages that already support libtool
1.1 dsieger 7279:
7280: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
7281: own libtool in most cases. For older libtool using packages, libtool is made by
7282: ltconfig script during the do-configure step; you can check the libtool script
7283: location by doing make configure; find work*/ -name libtool.
7284:
7285: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
7286: override. By default, it is set to "libtool */libtool */*/libtool". If this
7287: does not match the location of the package's libtool script(s), set it as
7288: appropriate.
7289:
7290: If you do not need *.a static libraries built and installed, then use
7291: SHLIBTOOL_OVERRIDE instead.
7292:
7293: If your package makes use of the platform-independent library for loading
7294: dynamic shared objects, that comes with libtool (libltdl), you should include
7295: devel/libltdl/buildlink3.mk.
7296:
7297: Some packages use libtool incorrectly so that the package may not work or build
7298: in some circumstances. Some of the more common errors are:
7299:
7300: * The inclusion of a shared object (-module) as a dependent library in an
7301: executable or library. This in itself isn't a problem if one of two things
7302: has been done:
7303:
7304: 1. The shared object is named correctly, i.e. libfoo.la, not foo.la
7305:
7306: 2. The -dlopen option is used when linking an executable.
7307:
7308: * The use of libltdl without the correct calls to initialisation routines.
7309: The function lt_dlinit() should be called and the macro
7310: LTDL_SET_PRELOADED_SYMBOLS included in executables.
7311:
1.6 rillig 7312: 19.3.3. GNU Autoconf/Automake
1.1 dsieger 7313:
7314: If a package needs GNU autoconf or automake to be executed to regenerate the
7315: configure script and Makefile.in makefile templates, then they should be
7316: executed in a pre-configure target.
7317:
7318: For packages that need only autoconf:
7319:
7320: AUTOCONF_REQD= 2.50 # if default version is not good enough
7321: USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
7322: ...
7323:
7324: pre-configure:
7325: cd ${WRKSRC} && autoconf
7326:
7327: ...
7328:
7329:
7330: and for packages that need automake and autoconf:
7331:
7332: AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
7333: USE_TOOLS+= automake # use "automake14" for automake-1.4
7334: ...
7335:
7336: pre-configure:
7337: set -e; cd ${WRKSRC}; \
7338: aclocal; autoheader; automake -a --foreign -i; autoconf
7339:
7340: ...
7341:
7342:
7343: Packages which use GNU Automake will almost certainly require GNU Make.
7344:
7345: There are times when the configure process makes additional changes to the
7346: generated files, which then causes the build process to try to re-execute the
7347: automake sequence. This is prevented by touching various files in the configure
7348: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
7349: NO in the package Makefile.
7350:
1.6 rillig 7351: 19.4. Programming languages
1.1 dsieger 7352:
1.6 rillig 7353: 19.4.1. C, C++, and Fortran
1.1 dsieger 7354:
7355: Compilers for the C, C++, and Fortran languages comes with the NetBSD base
7356: system. By default, pkgsrc assumes that a package is written in C and will hide
1.6 rillig 7357: all other compilers (via the wrapper framework, see Chapter 14, Buildlink
1.1 dsieger 7358: methodology).
7359:
7360: To declare which language's compiler a package needs, set the USE_LANGUAGES
7361: variable. Allowed values currently are "c", "c++", and "fortran" (and any
7362: combination). The default is "c". Packages using GNU configure scripts, even if
7363: written in C++, usually need a C compiler for the configure phase.
7364:
1.6 rillig 7365: 19.4.2. Java
1.1 dsieger 7366:
7367: If a program is written in Java, use the Java framework in pkgsrc. The package
7368: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
7369: variables:
7370:
7371: * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
7372: set to "run", then there is only a runtime dependency on the JDK. The
7373: default is "yes", which also adds a build dependency on the JDK.
7374:
7375: * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
7376: supported values are "yes", "1.4", and "1.5". "yes" accepts any Java2
7377: implementation, "1.4" insists on versions 1.4 or above, and "1.5" only
7378: accepts versions 1.5 or above. This variable is not set by default.
7379:
1.25 wiz 7380: * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
7381: implementation dependency. It may be used to set JAVA_HOME to a good value
7382: if the program needs this variable to be defined.
7383:
1.6 rillig 7384: 19.4.3. Packages containing perl scripts
1.1 dsieger 7385:
7386: If your package contains interpreted perl scripts, add "perl" to the USE_TOOLS
7387: variable and set REPLACE_PERL to ensure that the proper interpreter path is
7388: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
7389: you want adjusted. Every occurrence of */bin/perl will be replaced with the
7390: full path to the perl executable.
7391:
7392: If a particular version of perl is needed, set the PERL5_REQD variable to the
7393: version number. The default is "5.0".
7394:
1.6 rillig 7395: See Section 19.6.6, "Packages installing perl modules" for information about
1.1 dsieger 7396: handling perl modules.
7397:
1.41 wiz 7398: 19.4.4. Packages containing shell scripts
7399:
7400: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
7401: shell hash bangs in files. Please use the appropriate one, prefering REPLACE_SH
7402: in case this shell is sufficient. When using REPLACE_BASH, don't forget to add
7403: bash to USE_TOOLS.
7404:
7405: 19.4.5. Other programming languages
1.1 dsieger 7406:
7407: Currently, there is no special handling for other languages in pkgsrc. If a
7408: compiler package provides a buildlink3.mk file, include that, otherwise just
7409: add a (build) dependency on the appropriate compiler package.
7410:
1.6 rillig 7411: 19.5. Fixing problems in the build phase
1.1 dsieger 7412:
7413: The most common failures when building a package are that some platforms do not
7414: provide certain header files, functions or libraries, or they provide the
7415: functions in a library that the original package author didn't know. To work
7416: around this, you can rewrite the source code in most cases so that it does not
7417: use the missing functions or provides a replacement function.
7418:
1.6 rillig 7419: 19.5.1. Compiling C and C++ code conditionally
1.1 dsieger 7420:
7421: If a package already comes with a GNU configure script, the preferred way to
7422: fix the build failure is to change the configure script, not the code. In the
7423: other cases, you can utilize the C preprocessor, which defines certain macros
7424: depending on the operating system and hardware architecture it compiles for.
7425: These macros can be queried using for example #if defined(__i386). Almost every
7426: operating system, hardware architecture and compiler has its own macro. For
7427: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
7428: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
7429: GCC.
7430:
7431: The list of the following macros for hardware and operating system depends on
7432: the compiler that is used. For example, if you want to conditionally compile
7433: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
7434: Use __sun instead.
7435:
1.6 rillig 7436: 19.5.1.1. C preprocessor macros to identify the operating system
1.1 dsieger 7437:
7438: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
7439: should use the following code.
7440:
7441: #include <sys/param.h>
7442: #if (defined(BSD) && BSD >= 199306)
7443: /* BSD-specific code goes here */
7444: #else
7445: /* non-BSD-specific code goes here */
7446: #endif
7447:
7448: If this distinction is not fine enough, you can also test for the following
7449: macros.
7450:
1.46 obache 7451: Cygwin __CYGWIN__
7452: DragonFly __DragonFly__
1.1 dsieger 7453: FreeBSD __FreeBSD__
1.46 obache 7454: Haiku __HAIKU__
1.1 dsieger 7455: Interix __INTERIX
7456: IRIX __sgi (TODO: get a definite source for this)
7457: Linux linux, __linux, __linux__
1.46 obache 7458: MirBSD __MirBSD__ (__OpenBSD__ is also defined)
7459: Minix3 __minix
1.1 dsieger 7460: NetBSD __NetBSD__
7461: OpenBSD __OpenBSD__
7462: Solaris sun, __sun
7463:
1.6 rillig 7464: 19.5.1.2. C preprocessor macros to identify the hardware architecture
1.1 dsieger 7465:
7466: i386 i386, __i386, __i386__
7467: MIPS __mips
7468: SPARC sparc, __sparc
7469:
1.6 rillig 7470: 19.5.1.3. C preprocessor macros to identify the compiler
1.1 dsieger 7471:
7472: GCC __GNUC__ (major version), __GNUC_MINOR__
7473: MIPSpro _COMPILER_VERSION (0x741 for MIPSpro 7.41)
7474: SunPro __SUNPRO_C (0x570 for Sun C 5.7)
7475: SunPro C++ __SUNPRO_CC (0x580 for Sun C++ 5.8)
7476:
1.6 rillig 7477: 19.5.2. How to handle compiler bugs
1.1 dsieger 7478:
7479: Some source files trigger bugs in the compiler, based on combinations of
7480: compiler version and architecture and almost always relation to optimisation
7481: being enabled. Common symptoms are gcc internal errors or never finishing
7482: compiling a file.
7483:
7484: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
7485: disabling optimisation for that combination of file, MACHINE_ARCH and compiler,
7486: and documenting it in pkgsrc/doc/HACKS. See that file for a number of examples.
7487:
1.6 rillig 7488: 19.5.3. Undefined reference to "..."
1.1 dsieger 7489:
7490: This error message often means that a package did not link to a shared library
7491: it needs. The following functions are known to cause this error message over
7492: and over.
7493:
7494: +-----------------------------------------------------+
7495: | Function |Library |Affected platforms|
7496: |-------------------------+--------+------------------|
7497: |accept, bind, connect |-lsocket|Solaris |
7498: |-------------------------+--------+------------------|
7499: |crypt |-lcrypt |DragonFly, NetBSD |
7500: |-------------------------+--------+------------------|
7501: |dlopen, dlsym |-ldl |Linux |
7502: |-------------------------+--------+------------------|
7503: |gethost* |-lnsl |Solaris |
7504: |-------------------------+--------+------------------|
7505: |inet_aton |-lresolv|Solaris |
7506: |-------------------------+--------+------------------|
7507: |nanosleep, sem_*, timer_*|-lrt |Solaris |
7508: |-------------------------+--------+------------------|
7509: |openpty |-lutil |Linux |
7510: +-----------------------------------------------------+
7511:
7512: To fix these linker errors, it is often sufficient to say LIBS.OperatingSystem+
7513: = -lfoo to the package Makefile and then say bmake clean; bmake.
7514:
1.6 rillig 7515: 19.5.3.1. Special issue: The SunPro compiler
1.1 dsieger 7516:
7517: When you are using the SunPro compiler, there is another possibility. That
7518: compiler cannot handle the following code:
7519:
7520: extern int extern_func(int);
7521:
7522: static inline int
7523: inline_func(int x)
7524: {
7525: return extern_func(x);
7526: }
7527:
7528: int main(void)
7529: {
7530: return 0;
7531: }
7532:
7533: It generates the code for inline_func even if that function is never used. This
7534: code then refers to extern_func, which can usually not be resolved. To solve
7535: this problem you can try to tell the package to disable inlining of functions.
7536:
1.6 rillig 7537: 19.5.4. Running out of memory
1.1 dsieger 7538:
7539: Sometimes packages fail to build because the compiler runs into an operating
7540: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
7541: told to unlimit the resources. Currently, the allowed values are "datasize" and
7542: "stacksize" (or both). Setting this variable is similar to running the shell
7543: builtin ulimit command to raise the maximum data segment size or maximum stack
7544: size of a process, respectively, to their hard limits.
7545:
1.6 rillig 7546: 19.6. Fixing problems in the install phase
1.1 dsieger 7547:
1.6 rillig 7548: 19.6.1. Creating needed directories
1.1 dsieger 7549:
7550: The BSD-compatible install supplied with some operating systems cannot create
7551: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
7552: like this:
7553:
7554: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
7555: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
7556:
7557:
7558: You can also just append "dir1 dir2" to the INSTALLATION_DIRS variable, which
7559: will automatically do the right thing.
7560:
1.6 rillig 7561: 19.6.2. Where to install documentation
1.1 dsieger 7562:
7563: In general, documentation should be installed into ${PREFIX}/share/doc/$
7564: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME} (the latter includes the version
7565: number of the package).
7566:
7567: Many modern packages using GNU autoconf allow to set the directory where HTML
7568: documentation is installed with the "--with-html-dir" option. Sometimes using
7569: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
7570: share/doc/html or other places.
7571:
7572: An exception to the above is that library API documentation generated with the
7573: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
7574: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
7575: can be recognized from files ending in .devhelp or .devhelp2. (It is also
7576: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
7577: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
7578: then, no additional subdirectory level is allowed in this case. This is usually
7579: achieved by using "--with-html-dir=${PREFIX}/share/doc". ${PREFIX}/share/
7580: gtk-doc is preferred though.)
7581:
1.6 rillig 7582: 19.6.3. Installing highscore files
1.1 dsieger 7583:
7584: Certain packages, most of them in the games category, install a score file that
7585: allows all users on the system to record their highscores. In order for this to
7586: work, the binaries need to be installed setgid and the score files owned by the
1.36 wiz 7587: appropriate group and/or owner (traditionally the "games" user/group). Set
7588: USE_GAMESGROUP to yes to support this. The following variables, documented in
7589: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
7590: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER.
1.1 dsieger 7591:
1.14 jmcneill 7592: A package should therefore never hard code file ownership or access permissions
1.1 dsieger 7593: but rely on INSTALL_GAME and INSTALL_GAME_DATA to set these correctly.
7594:
1.6 rillig 7595: 19.6.4. Adding DESTDIR support to packages
1.4 rillig 7596:
1.14 jmcneill 7597: DESTDIR support means that a package installs into a staging directory, not the
7598: final location of the files. Then a binary package is created which can be used
7599: for installation as usual. There are two ways: Either the package must install
1.25 wiz 7600: as root ("destdir") or the package can install as non-root user ("user-destdir"
7601: ).
1.14 jmcneill 7602:
1.39 wiz 7603: * PKG_DESTDIR_SUPPORT has to be set to "none", "destdir", or "user-destdir".
7604: By default PKG_DESTDIR_SUPPORT is set to "user-destdir" to help catching
7605: more potential packaging problems. If bsd.prefs.mk is included in the
7606: Makefile, PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14 jmcneill 7607:
1.4 rillig 7608: * All installation operations have to be prefixed with ${DESTDIR}.
7609:
7610: * automake gets this DESTDIR mostly right automatically. Many manual rules
7611: and pre/post-install often are incorrect; fix them.
7612:
1.17 imil 7613: * If files are installed with special owner/group use SPECIAL_PERMS.
1.4 rillig 7614:
7615: * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
7616:
1.6 rillig 7617: 19.6.5. Packages with hardcoded paths to other interpreters
1.1 dsieger 7618:
7619: Your package may also contain scripts with hardcoded paths to other
7620: interpreters besides (or as well as) perl. To correct the full pathname to the
7621: script interpreter, you need to set the following definitions in your Makefile
7622: (we shall use tclsh in this example):
7623:
7624: REPLACE_INTERPRETER+= tcl
7625: REPLACE.tcl.old= .*/bin/tclsh
7626: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
7627: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
7628: # relative to ${WRKSRC}, just as in REPLACE_PERL
7629:
7630:
7631: Note
7632:
7633: Before March 2006, these variables were called _REPLACE.* and _REPLACE_FILES.*.
7634:
1.6 rillig 7635: 19.6.6. Packages installing perl modules
1.1 dsieger 7636:
7637: Makefiles of packages providing perl5 modules should include the Makefile
7638: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
7639: standard perl configuration for such modules as well as various hooks to tune
7640: this configuration. See comments in this file for details.
7641:
7642: Perl5 modules will install into different places depending on the version of
7643: perl used during the build process. To address this, pkgsrc will append lines
7644: to the PLIST corresponding to the files listed in the installed .packlist file
7645: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48 wiz 7646: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
7647: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1 dsieger 7648:
1.48 wiz 7649: PERL5_PACKLIST= auto/Pg/.packlist
1.1 dsieger 7650:
7651:
1.48 wiz 7652: The perl5 config variables installarchlib, installscript, installvendorbin,
7653: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
7654: and installvendorman3dir represent those locations in which components of perl5
7655: modules may be installed, provided as variable with uppercase and prefixed with
7656: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
7657: have a packlist. These variables are also substituted for in the PLIST as
7658: uppercase prefixed with PERL5_SUB_.
1.1 dsieger 7659:
1.6 rillig 7660: 19.6.7. Packages installing info files
1.1 dsieger 7661:
7662: Some packages install info files or use the "makeinfo" or "install-info"
7663: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
7664: and DEINSTALL scripts will be generated to handle registration of the info
7665: files in the Info directory file. The "install-info" command used for the info
7666: files registration is either provided by the system, or by a special purpose
7667: package automatically added as dependency if needed.
7668:
7669: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
7670: located. PKGINFODIR defaults to "info" and can be overridden by the user.
7671:
7672: The info files for the package should be listed in the package PLIST; however
7673: any split info files need not be listed.
7674:
7675: A package which needs the "makeinfo" command at build time must add "makeinfo"
7676: to USE_TOOLS in its Makefile. If a minimum version of the "makeinfo" command is
7677: needed it should be noted with the TEXINFO_REQD variable in the package
7678: Makefile. By default, a minimum version of 3.12 is required. If the system does
7679: not provide a makeinfo command or if it does not match the required minimum, a
7680: build dependency on the devel/gtexinfo package will be added automatically.
7681:
7682: The build and installation process of the software provided by the package
7683: should not use the install-info command as the registration of info files is
1.25 wiz 7684: the task of the package INSTALL script, and it must use the appropriate
1.1 dsieger 7685: makeinfo command.
7686:
7687: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
7688: the install-info and makeinfo commands in a directory listed early in PATH.
7689:
7690: The script overriding install-info has no effect except the logging of a
7691: message. The script overriding makeinfo logs a message and according to the
7692: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
7693: error.
7694:
1.6 rillig 7695: 19.6.8. Packages installing man pages
1.1 dsieger 7696:
7697: All packages that install manual pages should install them into the same
7698: directory, so that there is one common place to look for them. In pkgsrc, this
7699: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.25 wiz 7700: packages. The default for PKGMANDIR is "man". Another often-used value is "
7701: share/man".
1.1 dsieger 7702:
7703: Note
7704:
7705: The support for a custom PKGMANDIR is far from complete.
7706:
7707: The PLIST files can just use man/ as the top level directory for the man page
7708: file entries, and the pkgsrc framework will convert as needed. In all other
7709: places, the correct PKGMANDIR must be used.
7710:
7711: Packages that are configured with GNU_CONFIGURE set as "yes", by default will
7712: use the ./configure --mandir switch to set where the man pages should be
7713: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
7714: {PKGMANDIR}.
7715:
7716: Packages that use GNU_CONFIGURE but do not use --mandir, can set
7717: CONFIGURE_HAS_MANDIR to "no". Or if the ./configure script uses a non-standard
7718: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
7719:
1.6 rillig 7720: See Section 13.5, "Man page compression" for information on installation of
1.1 dsieger 7721: compressed manual pages.
7722:
1.7 rillig 7723: 19.6.9. Packages installing GConf data files
1.1 dsieger 7724:
1.7 rillig 7725: If a package installs .schemas or .entries files, used by GConf, you need to
1.1 dsieger 7726: take some extra steps to make sure they get registered in the database:
7727:
1.7 rillig 7728: 1. Include ../../devel/GConf/schemas.mk instead of its buildlink3.mk file.
7729: This takes care of rebuilding the GConf database at installation and
7730: deinstallation time, and tells the package where to install GConf data
1.1 dsieger 7731: files using some standard configure arguments. It also disallows any access
7732: to the database directly from the package.
7733:
7734: 2. Ensure that the package installs its .schemas files under ${PREFIX}/share/
7735: gconf/schemas. If they get installed under ${PREFIX}/etc, you will need to
7736: manually patch the package.
7737:
7738: 3. Check the PLIST and remove any entries under the etc/gconf directory, as
1.65 ! wiz 7739: they will be handled automatically. See Section 9.14, "How do I change the
1.1 dsieger 7740: location of configuration files?" for more information.
7741:
1.7 rillig 7742: 4. Define the GCONF_SCHEMAS variable in your Makefile with a list of all
1.1 dsieger 7743: .schemas files installed by the package, if any. Names must not contain any
7744: directories in them.
7745:
1.7 rillig 7746: 5. Define the GCONF_ENTRIES variable in your Makefile with a list of all
1.1 dsieger 7747: .entries files installed by the package, if any. Names must not contain any
7748: directories in them.
7749:
1.18 mishka 7750: 19.6.10. Packages installing scrollkeeper/rarian data files
1.1 dsieger 7751:
1.18 mishka 7752: If a package installs .omf files, used by scrollkeeper/rarian, you need to take
7753: some extra steps to make sure they get registered in the database:
1.1 dsieger 7754:
1.18 mishka 7755: 1. Include ../../mk/omf-scrollkeeper.mk instead of rarian's buildlink3.mk
7756: file. This takes care of rebuilding the scrollkeeper database at
7757: installation and deinstallation time, and disallows any access to it
7758: directly from the package.
1.1 dsieger 7759:
7760: 2. Check the PLIST and remove any entries under the libdata/scrollkeeper
7761: directory, as they will be handled automatically.
7762:
7763: 3. Remove the share/omf directory from the PLIST. It will be handled by
1.18 mishka 7764: rarian. (make print-PLIST does this automatically.)
1.1 dsieger 7765:
1.6 rillig 7766: 19.6.11. Packages installing X11 fonts
1.1 dsieger 7767:
7768: If a package installs font files, you will need to rebuild the fonts database
7769: in the directory where they get installed at installation and deinstallation
7770: time. This can be automatically done by using the pkginstall framework.
7771:
7772: You can list the directories where fonts are installed in the FONTS_DIRS.type
7773: variables, where type can be one of "ttf", "type1" or "x11". Also make sure
7774: that the database file fonts.dir is not listed in the PLIST.
7775:
7776: Note that you should not create new directories for fonts; instead use the
7777: standard ones to avoid that the user needs to manually configure his X server
7778: to find them.
7779:
1.6 rillig 7780: 19.6.12. Packages installing GTK2 modules
1.1 dsieger 7781:
7782: If a package installs GTK2 immodules or loaders, you need to take some extra
7783: steps to get them registered in the GTK2 database properly:
7784:
7785: 1. Include ../../x11/gtk2/modules.mk instead of its buildlink3.mk file. This
7786: takes care of rebuilding the database at installation and deinstallation
7787: time.
7788:
7789: 2. Set GTK2_IMMODULES=YES if your package installs GTK2 immodules.
7790:
7791: 3. Set GTK2_LOADERS=YES if your package installs GTK2 loaders.
7792:
7793: 4. Patch the package to not touch any of the GTK2 databases directly. These
7794: are:
7795:
1.42 asau 7796: + libdata/gtk-2.0/gdk-pixbuf.loaders
1.1 dsieger 7797:
1.42 asau 7798: + libdata/gtk-2.0/gtk.immodules
1.1 dsieger 7799:
7800: 5. Check the PLIST and remove any entries under the libdata/gtk-2.0 directory,
7801: as they will be handled automatically.
7802:
1.6 rillig 7803: 19.6.13. Packages installing SGML or XML data
1.1 dsieger 7804:
7805: If a package installs SGML or XML data files that need to be registered in
7806: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
7807: extra steps:
7808:
7809: 1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
7810: care of registering those files in system-wide catalogs at installation and
7811: deinstallation time.
7812:
7813: 2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
7814: package.
7815:
7816: 3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
7817: package.
7818:
7819: 4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
7820: These come in groups of three strings; see xmlcatmgr(1) for more
7821: information (specifically, arguments recognized by the 'add' action). Note
7822: that you will normally not use this variable.
7823:
7824: 5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
7825: come in groups of three strings; see xmlcatmgr(1) for more information
7826: (specifically, arguments recognized by the 'add' action). Note that you
7827: will normally not use this variable.
7828:
1.6 rillig 7829: 19.6.14. Packages installing extensions to the MIME database
1.1 dsieger 7830:
7831: If a package provides extensions to the MIME database by installing .xml files
7832: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
7833: ensure that the database is kept consistent with respect to these new files:
7834:
7835: 1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
7836: buildlink3.mk file from this same directory, which is reserved for
7837: inclusion from other buildlink3.mk files). It takes care of rebuilding the
7838: MIME database at installation and deinstallation time, and disallows any
7839: access to it directly from the package.
7840:
1.25 wiz 7841: 2. Check the PLIST and remove any entries under the share/mime directory,
1.1 dsieger 7842: except for files saved under share/mime/packages. The former are handled
7843: automatically by the update-mime-database program, but the latter are
7844: package-dependent and must be removed by the package that installed them in
7845: the first place.
7846:
7847: 3. Remove any share/mime/* directories from the PLIST. They will be handled by
7848: the shared-mime-info package.
7849:
1.6 rillig 7850: 19.6.15. Packages using intltool
1.1 dsieger 7851:
7852: If a package uses intltool during its build, add intltool to the USE_TOOLS,
7853: which forces it to use the intltool package provided by pkgsrc, instead of the
7854: one bundled with the distribution file.
7855:
7856: This tracks intltool's build-time dependencies and uses the latest available
7857: version; this way, the package benefits of any bug fixes that may have appeared
7858: since it was released.
7859:
1.6 rillig 7860: 19.6.16. Packages installing startup scripts
1.1 dsieger 7861:
7862: If a package contains a rc.d script, it won't be copied into the startup
7863: directory by default, but you can enable it, by adding the option
1.4 rillig 7864: PKG_RCD_SCRIPTS=YES in mk.conf. This option will copy the scripts into /etc/
7865: rc.d when a package is installed, and it will automatically remove the scripts
7866: when the package is deinstalled.
1.1 dsieger 7867:
1.6 rillig 7868: 19.6.17. Packages installing TeX modules
1.1 dsieger 7869:
7870: If a package installs TeX packages into the texmf tree, the ls-R database of
7871: the tree needs to be updated.
7872:
7873: Note
7874:
1.23 jakllsch 7875: Except the main TeX packages such as kpathsea, packages should install files
7876: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1 dsieger 7877:
1.23 jakllsch 7878: 1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
7879: ls-R database at installation and deinstallation time.
1.1 dsieger 7880:
1.23 jakllsch 7881: 2. If your package installs files into a texmf tree other than the one at $
7882: {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
7883: trees that need database update.
1.1 dsieger 7884:
7885: If your package also installs font map files that need to be registered
1.30 dholland 7886: using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
7887: and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then
7888: updmap will be run automatically at installation/deinstallation to enable/
7889: disable font map files for TeX output drivers.
1.1 dsieger 7890:
7891: 3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30 dholland 7892: be removed only by the kpathsea package.
1.1 dsieger 7893:
1.6 rillig 7894: 19.6.18. Packages supporting running binaries in emulation
1.1 dsieger 7895:
7896: There are some packages that provide libraries and executables for running
7897: binaries from a one operating system on a different one (if the latter supports
7898: it). One example is running Linux binaries on NetBSD.
7899:
7900: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
7901:
7902: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
7903: if all libraries for each installed executable can be found by the dynamic
7904: linker. Since the standard dynamic linker is run, this fails for emulation
7905: packages, because the libraries used by the emulation are not in the standard
7906: directories.
7907:
1.6 rillig 7908: 19.6.19. Packages installing hicolor theme icons
1.1 dsieger 7909:
7910: If a package installs images under the share/icons/hicolor and/or updates the
7911: share/icons/hicolor/icon-theme.cache database, you need to take some extra
7912: steps to make sure that the shared theme directory is handled appropriately and
7913: that the cache database is rebuilt:
7914:
7915: 1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
7916:
7917: 2. Check the PLIST and remove the entry that refers to the theme cache.
7918:
7919: 3. Ensure that the PLIST does not remove the shared icon directories from the
7920: share/icons/hicolor hierarchy because they will be handled automatically.
7921:
7922: The best way to verify that the PLIST is correct with respect to the last two
7923: points is to regenerate it using make print-PLIST.
7924:
1.6 rillig 7925: 19.6.20. Packages installing desktop files
1.1 dsieger 7926:
7927: If a package installs .desktop files under share/applications and these include
1.54 rodent 7928: MIME information (MimeType key), you need to take extra steps to ensure that
7929: they are registered into the MIME database:
1.1 dsieger 7930:
7931: 1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
7932:
7933: 2. Check the PLIST and remove the entry that refers to the share/applications/
7934: mimeinfo.cache file. It will be handled automatically.
7935:
7936: The best way to verify that the PLIST is correct with respect to the last point
7937: is to regenerate it using make print-PLIST.
7938:
1.6 rillig 7939: 19.7. Marking packages as having problems
1.1 dsieger 7940:
1.23 jakllsch 7941: In some cases one does not have the time to solve a problem immediately. In
7942: this case, one can plainly mark a package as broken. For this, one just sets
7943: the variable BROKEN to the reason why the package is broken (similar to the
7944: RESTRICTED variable). A user trying to build the package will immediately be
7945: shown this message, and the build will not be even tried.
1.1 dsieger 7946:
1.23 jakllsch 7947: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1 dsieger 7948:
1.6 rillig 7949: Chapter 20. Debugging
1.1 dsieger 7950:
7951: To check out all the gotchas when building a package, here are the steps that I
7952: do in order to get a package working. Please note this is basically the same as
7953: what was explained in the previous sections, only with some debugging aids.
7954:
1.4 rillig 7955: * Be sure to set PKG_DEVELOPER=yes in mk.conf.
1.1 dsieger 7956:
7957: * Install pkgtools/url2pkg, create a directory for a new package, change into
7958: it, then run url2pkg:
7959:
7960: % mkdir /usr/pkgsrc/category/examplepkg
7961: % cd /usr/pkgsrc/category/examplepkg
7962: % url2pkg http://www.example.com/path/to/distfile.tar.gz
7963:
7964: * Edit the Makefile as requested.
7965:
7966: * Fill in the DESCR file
7967:
7968: * Run make configure
7969:
7970: * Add any dependencies glimpsed from documentation and the configure step to
7971: the package's Makefile.
7972:
7973: * Make the package compile, doing multiple rounds of
7974:
7975: % make
7976: % pkgvi ${WRKSRC}/some/file/that/does/not/compile
7977: % mkpatches
7978: % patchdiff
7979: % mv ${WRKDIR}/.newpatches/* patches
7980: % make mps
7981: % make clean
7982:
7983: Doing this step as non-root user will ensure that no files are modified
7984: that shouldn't be, especially during the build phase. mkpatches, patchdiff
7985: and pkgvi are from the pkgtools/pkgdiff package.
7986:
1.6 rillig 7987: * Look at the Makefile, fix if necessary; see Section 11.1, "Makefile".
1.1 dsieger 7988:
7989: * Generate a PLIST:
7990:
7991: # make install
7992: # make print-PLIST >PLIST
7993: # make deinstall
7994: # make install
7995: # make deinstall
7996:
7997: You usually need to be root to do this. Look if there are any files left:
7998:
7999: # make print-PLIST
8000:
8001: If this reveals any files that are missing in PLIST, add them.
8002:
8003: * Now that the PLIST is OK, install the package again and make a binary
8004: package:
8005:
8006: # make reinstall
8007: # make package
8008:
8009: * Delete the installed package:
8010:
8011: # pkg_delete examplepkg
8012:
8013: * Repeat the above make print-PLIST command, which shouldn't find anything
8014: now:
8015:
8016: # make print-PLIST
8017:
8018: * Reinstall the binary package:
8019:
8020: # pkg_add .../examplepkg.tgz
8021:
8022: * Play with it. Make sure everything works.
8023:
8024: * Run pkglint from pkgtools/pkglint, and fix the problems it reports:
8025:
8026: # pkglint
8027:
1.6 rillig 8028: * Submit (or commit, if you have cvs access); see Chapter 21, Submitting and
1.1 dsieger 8029: Committing.
8030:
1.6 rillig 8031: Chapter 21. Submitting and Committing
1.1 dsieger 8032:
8033: Table of Contents
8034:
1.6 rillig 8035: 21.1. Submitting binary packages
8036: 21.2. Submitting source packages (for non-NetBSD-developers)
8037: 21.3. General notes when adding, updating, or removing packages
1.34 wiz 8038: 21.4. Committing: Adding a package to CVS
1.6 rillig 8039: 21.5. Updating a package to a newer version
1.21 snj 8040: 21.6. Renaming a package in pkgsrc
8041: 21.7. Moving a package in pkgsrc
1.1 dsieger 8042:
1.6 rillig 8043: 21.1. Submitting binary packages
1.1 dsieger 8044:
8045: Our policy is that we accept binaries only from pkgsrc developers to guarantee
8046: that the packages don't contain any trojan horses etc. This is not to annoy
8047: anyone but rather to protect our users! You're still free to put up your
8048: home-made binary packages and tell the world where to get them. NetBSD
8049: developers doing bulk builds and wanting to upload them please see
1.6 rillig 8050: Section 7.3.8, "Uploading results of a bulk build".
1.1 dsieger 8051:
1.6 rillig 8052: 21.2. Submitting source packages (for non-NetBSD-developers)
1.1 dsieger 8053:
8054: First, check that your package is complete, compiles and runs well; see
1.6 rillig 8055: Chapter 20, Debugging and the rest of this document. Next, generate an
1.1 dsieger 8056: uuencoded gzipped tar(1) archive that contains all files that make up the
8057: package. Finally, send this package to the pkgsrc bug tracking system, either
8058: with the send-pr(1) command, or if you don't have that, go to the web page
1.4 rillig 8059: http://www.NetBSD.org/support/send-pr.html, which contains some instructions
1.22 snj 8060: and a link to a form where you can submit packages. The sysutils/gtk-send-pr
8061: package is also available as a substitute for either of the above two tools.
1.1 dsieger 8062:
8063: In the form of the problem report, the category should be "pkg", the synopsis
8064: should include the package name and version number, and the description field
8065: should contain a short description of your package (contents of the COMMENT
1.25 wiz 8066: variable or DESCR file are OK). The uuencoded package data should go into the "
8067: fix" field.
1.1 dsieger 8068:
8069: If you want to submit several packages, please send a separate PR for each one,
8070: it's easier for us to track things that way.
8071:
8072: Alternatively, you can also import new packages into pkgsrc-wip ("pkgsrc
8073: work-in-progress"); see the homepage at http://pkgsrc-wip.sourceforge.net/ for
8074: details.
8075:
1.6 rillig 8076: 21.3. General notes when adding, updating, or removing packages
1.1 dsieger 8077:
8078: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
8079: CHANGES-YYYY. It's very important to keep this file up to date and conforming
8080: to the existing format, because it will be used by scripts to automatically
8081: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
8082: doc/TODO file and remove the entry for the package you updated or removed, in
8083: case it was mentioned there.
8084:
8085: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
8086: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
8087: that result from a dependency being updated should not be mentioned. In all
8088: other cases it's the developer's decision.
8089:
8090: There is a make target that helps in creating proper CHANGES-YYYY entries: make
8091: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
8092: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
8093: (to avoid having to resolve conflicts later-on) and then to cd to the package
8094: directory. For package updates, make changes-entry is enough. For new packages,
8095: or package moves or removals, set the CTYPE variable on the command line to
1.4 rillig 8096: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23 jakllsch 8097: your local login name is not the same as your NetBSD login name. The target
8098: also automatically removes possibly existing entries for the package in the
8099: TODO file. Don't forget to commit the changes, e.g. by using make
8100: changes-entry-commit! If you are not using a checkout directly from
8101: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
8102: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1 dsieger 8103:
1.34 wiz 8104: 21.4. Committing: Adding a package to CVS
1.1 dsieger 8105:
8106: This section is only of interest for pkgsrc developers with write access to the
1.34 wiz 8107: pkgsrc repository.
8108:
8109: When the package is finished, "cvs add" the files. Start by adding the
8110: directory and then files in the directory. Don't forget to add the new package
8111: to the category's Makefile. Make sure you don't forget any files; you can check
8112: by running "cvs status". An example:
8113:
8114: $ cd .../pkgsrc/category
8115: $ cvs add pkgname
8116: $ cd pkgname
8117: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
8118: $ cvs add patches/p*
8119: $ cvs status | less
1.35 wiz 8120: $ cvs commit
1.34 wiz 8121: $ cd ..
8122: $ vi Makefile # add SUBDIRS+=pkgname line
1.35 wiz 8123: $ cvs commit Makefile
1.1 dsieger 8124:
8125: The commit message of the initial import should include part of the DESCR file,
8126: so people reading the mailing lists know what the package is/does.
8127:
1.34 wiz 8128: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
8129:
8130: Previously, "cvs import" was suggested, but it was much easier to get wrong
8131: than "cvs add".
1.1 dsieger 8132:
1.6 rillig 8133: 21.5. Updating a package to a newer version
1.1 dsieger 8134:
8135: Please always put a concise, appropriate and relevant summary of the changes
8136: between old and new versions into the commit log when updating a package. There
8137: are various reasons for this:
8138:
8139: * A URL is volatile, and can change over time. It may go away completely or
8140: its information may be overwritten by newer information.
8141:
8142: * Having the change information between old and new versions in our CVS
8143: repository is very useful for people who use either cvs or anoncvs.
8144:
8145: * Having the change information between old and new versions in our CVS
8146: repository is very useful for people who read the pkgsrc-changes mailing
8147: list, so that they can make tactical decisions about when to upgrade the
8148: package.
8149:
8150: Please also recognize that, just because a new version of a package has been
8151: released, it should not automatically be upgraded in the CVS repository. We
8152: prefer to be conservative in the packages that are included in pkgsrc -
8153: development or beta packages are not really the best thing for most places in
8154: which pkgsrc is used. Please use your judgement about what should go into
8155: pkgsrc, and bear in mind that stability is to be preferred above new and
8156: possibly untested features.
8157:
1.21 snj 8158: 21.6. Renaming a package in pkgsrc
8159:
8160: Renaming packages is not recommended.
8161:
8162: When renaming packages, be sure to fix any references to old name in other
8163: Makefiles, options, buildlink files, etc.
8164:
8165: Also When renaming a package, please define SUPERSEDES to the package name and
8166: dewey version pattern(s) of the previous package name. This may be repeated for
8167: multiple renames. The new package would be an exact replacement.
8168:
8169: Note that "successor" in the CHANGES-YYYY file doesn't necessarily mean that it
8170: supersedes, as that successor may not be an exact replacement but is a
8171: suggestion for the replaced functionality.
8172:
8173: 21.7. Moving a package in pkgsrc
8174:
8175: It is preferred that packages are not renamed or moved, but if needed please
8176: follow these steps.
1.1 dsieger 8177:
8178: 1. Make a copy of the directory somewhere else.
8179:
8180: 2. Remove all CVS dirs.
8181:
8182: Alternatively to the first two steps you can also do:
8183:
8184: % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
8185:
8186: and use that for further work.
8187:
1.25 wiz 8188: 3. Fix CATEGORIES and any DEPENDS paths that just did "../package" instead of
1.1 dsieger 8189: "../../category/package".
8190:
1.21 snj 8191: 4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
8192: previous category/package pathname. The PREV_PKGPATH can be used by tools
8193: for doing an update using pkgsrc building; for example, it can search the
8194: pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
8195: the corresponding new PKGPATH for that moved package. Note that it may have
8196: multiple matches, so the tool should also check on the PKGBASE too. The
8197: PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
8198: PKGBASE stays the same.
8199:
8200: 5. cvs import the modified package in the new place.
1.1 dsieger 8201:
1.21 snj 8202: 6. Check if any package depends on it:
1.1 dsieger 8203:
8204: % cd /usr/pkgsrc
8205: % grep /package */*/Makefile* */*/buildlink*
8206:
1.21 snj 8207: 7. Fix paths in packages from step 5 to point to new location.
1.1 dsieger 8208:
1.21 snj 8209: 8. cvs rm (-f) the package at the old location.
1.1 dsieger 8210:
1.21 snj 8211: 9. Remove from oldcategory/Makefile.
1.1 dsieger 8212:
1.21 snj 8213: 10. Add to newcategory/Makefile.
1.1 dsieger 8214:
1.21 snj 8215: 11. Commit the changed and removed files:
1.1 dsieger 8216:
8217: % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
8218:
8219: (and any packages from step 5, of course).
8220:
1.6 rillig 8221: Chapter 22. Frequently Asked Questions
1.1 dsieger 8222:
8223: This section contains the answers to questions that may arise when you are
8224: writing a package. If you don't find your question answered here, first have a
8225: look in the other chapters, and if you still don't have the answer, ask on the
8226: pkgsrc-users mailing list.
8227:
1.6 rillig 8228: 22.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
8229: 22.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
8230: 22.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
8231: 22.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1 dsieger 8232: BUILDLINK_LIBS?
1.6 rillig 8233: 22.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
8234: 22.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1 dsieger 8235: the := inside it.
1.6 rillig 8236: 22.7. Which mailing lists are there for package developers?
8237: 22.8. Where is the pkgsrc documentation?
8238: 22.9. I have a little time to kill. What shall I do?
1.1 dsieger 8239:
1.6 rillig 8240: 22.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1 dsieger 8241:
8242: MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
8243: (1), while MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM
8244: when building the package. [FIXME: What is .MAKEFLAGS for?]
8245:
1.6 rillig 8246: 22.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1 dsieger 8247:
8248: MAKE is the path to the make(1) program that is used in the pkgsrc
8249: infrastructure. GMAKE is the path to GNU Make, but you need to say
8250: USE_TOOLS+=gmake to use that. MAKE_PROGRAM is the path to the Make
8251: program that is used for building the package.
8252:
1.6 rillig 8253: 22.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1 dsieger 8254:
8255: CC is the path to the real C compiler, which can be configured by the
8256: pkgsrc user. PKG_CC is the path to the compiler wrapper. PKGSRC_COMPILER
8257: is not a path to a compiler, but the type of compiler that should be
8258: used. See mk/compiler.mk for more information about the latter variable.
8259:
1.6 rillig 8260: 22.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1 dsieger 8261: BUILDLINK_LIBS?
8262:
8263: [FIXME]
8264:
1.6 rillig 8265: 22.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1 dsieger 8266:
1.25 wiz 8267: For optimization reasons, some variables are only available in the "
8268: wrapper" phase and later. To "simulate" the wrapper phase, append
1.1 dsieger 8269: PKG_PHASE=wrapper to the above command.
8270:
1.6 rillig 8271: 22.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1 dsieger 8272: the := inside it.
8273:
8274: The := is not really an assignment operator, like you might expect at
8275: first sight. Instead, it is a degenerate form of ${LIST:old_string=
8276: new_string}, which is documented in the make(1) man page and which you
8277: may have seen as in ${SRCS:.c=.o}. In the case of MASTER_SITE_*,
8278: old_string is the empty string and new_string is package/. That's where
8279: the : and the = fall together.
8280:
1.6 rillig 8281: 22.7. Which mailing lists are there for package developers?
1.1 dsieger 8282:
8283: tech-pkg
8284:
8285: This is a list for technical discussions related to pkgsrc
8286: development, e.g. soliciting feedback for changes to pkgsrc
8287: infrastructure, proposed new features, questions related to porting
8288: pkgsrc to a new platform, advice for maintaining a package, patches
8289: that affect many packages, help requests moved from pkgsrc-users when
8290: an infrastructure bug is found, etc.
8291:
8292: pkgsrc-bugs
8293:
8294: All bug reports in category "pkg" sent with send-pr(1) appear here.
8295: Please do not report your bugs here directly; use one of the other
8296: mailing lists.
8297:
1.6 rillig 8298: 22.8. Where is the pkgsrc documentation?
1.1 dsieger 8299:
8300: There are many places where you can find documentation about pkgsrc:
8301:
8302: * The pkgsrc guide (this document) is a collection of chapters that
8303: explain large parts of pkgsrc, but some chapters tend to be outdated.
8304: Which ones they are is hard to say.
8305:
8306: * On the mailing list archives (see http://mail-index.NetBSD.org/), you
8307: can find discussions about certain features, announcements of new
8308: parts of the pkgsrc infrastructure and sometimes even announcements
8309: that a certain feature has been marked as obsolete. The benefit here
8310: is that each message has a date appended to it.
8311:
8312: * Many of the files in the mk/ directory start with a comment that
8313: describes the purpose of the file and how it can be used by the
8314: pkgsrc user and package authors. An easy way to find this
8315: documentation is to run bmake help.
8316:
8317: * The CVS log messages are a rich source of information, but they tend
8318: to be highly abbreviated, especially for actions that occur often.
8319: Some contain a detailed description of what has changed, but they are
8320: geared towards the other pkgsrc developers, not towards an average
8321: pkgsrc user. They also only document changes, so if you don't know
8322: what has been before, these messages may not be worth too much to
8323: you.
8324:
8325: * Some parts of pkgsrc are only "implicitly documented", that is the
8326: documentation exists only in the mind of the developer who wrote the
8327: code. To get this information, use the cvs annotate command to see
8328: who has written it and ask on the tech-pkg mailing list, so that
8329: others can find your questions later (see above). To be sure that the
8330: developer in charge reads the mail, you may CC him or her.
8331:
1.6 rillig 8332: 22.9. I have a little time to kill. What shall I do?
1.1 dsieger 8333:
8334: This is not really an FAQ yet, but here's the answer anyway.
8335:
8336: * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
8337: about newer versions of installed packages that are available, but
8338: not yet updated in pkgsrc.
8339:
8340: * Browse pkgsrc/doc/TODO ? it contains a list of suggested new packages
8341: and a list of cleanups and enhancements for pkgsrc that would be nice
8342: to have.
8343:
8344: * Review packages for which review was requested on the pkgsrc-wip
8345: review mailing list.
8346:
1.6 rillig 8347: Chapter 23. GNOME packaging and porting
1.1 dsieger 8348:
8349: Table of Contents
8350:
1.6 rillig 8351: 23.1. Meta packages
8352: 23.2. Packaging a GNOME application
8353: 23.3. Updating GNOME to a newer version
8354: 23.4. Patching guidelines
1.1 dsieger 8355:
8356: Quoting GNOME's web site:
8357:
8358: The GNOME project provides two things: The GNOME desktop environment, an
8359: intuitive and attractive desktop for users, and the GNOME development
8360: platform, an extensive framework for building applications that integrate
8361: into the rest of the desktop.
8362:
8363: pkgsrc provides a seamless way to automatically build and install a complete
8364: GNOME environment under many different platforms. We can say with confidence
8365: that pkgsrc is one of the most advanced build and packaging systems for GNOME
8366: due to its included technologies buildlink3, the wrappers and tools framework
8367: and automatic configuration file management. Lots of efforts are put into
8368: achieving a completely clean deinstallation of installed software components.
8369:
8370: Given that pkgsrc is NetBSD's official packaging system, the above also means
8371: that great efforts are put into making GNOME work under this operating system.
8372: Recently, DragonFly BSD also adopted pkgsrc as its preferred packaging system,
8373: contributing lots of portability fixes to make GNOME build and install under
8374: it.
8375:
8376: This chapter is aimed at pkgsrc developers and other people interested in
8377: helping our GNOME porting and packaging efforts. It provides instructions on
8378: how to manage the existing packages and some important information regarding
8379: their internals.
8380:
8381: We need your help!
8382:
8383: Should you have some spare cycles to devote to NetBSD, pkgsrc and GNOME and are
8384: willing to learn new exciting stuff, please jump straight to the pending work
8385: list! There is still a long way to go to get a fully-functional GNOME desktop
8386: under NetBSD and we need your help to achieve it!
8387:
1.6 rillig 8388: 23.1. Meta packages
1.1 dsieger 8389:
8390: pkgsrc includes three GNOME-related meta packages:
8391:
8392: * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
8393: includes the necessary bits to get it to boot correctly, although it may
8394: lack important functionality for daily operation. The idea behind this
8395: package is to let end users build their own configurations on top of this
8396: one, first installing this meta package to achieve a functional setup and
8397: then adding individual applications.
8398:
8399: * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
8400: desktop as defined by the GNOME project; this is based on the components
8401: distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
8402: directories of the official FTP server. Developer-only tools found in those
8403: directories are not installed unless required by some other component to
8404: work properly. Similarly, packages from the bindings set (bindings/x.y/
8405: x.y.z/sources) are not pulled in unless required as a dependency for an
8406: end-user component. This package "extends" meta-pkgs/gnome-base.
8407:
8408: * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
8409: component when fetched from the CVS repository. These are required to let
8410: the autogen.sh scripts work appropriately.
8411:
8412: In all these packages, the DEPENDS lines are sorted in a way that eases
8413: updates: a package may depend on other packages listed before it but not on any
1.25 wiz 8414: listed after it. It is very important to keep this order to ease updates so...
1.1 dsieger 8415: do not change it to alphabetical sorting!
8416:
1.6 rillig 8417: 23.2. Packaging a GNOME application
1.1 dsieger 8418:
8419: Almost all GNOME applications are written in C and use a common set of tools as
8420: their build system. Things get different with the new bindings to other
8421: languages (such as Python), but the following will give you a general idea on
8422: the minimum required tools:
8423:
8424: * Almost all GNOME applications use the GNU Autotools as their build system.
8425: As a general rule you will need to tell this to your package:
8426:
8427: GNU_CONFIGURE=yes
8428: USE_LIBTOOL=yes
8429: USE_TOOLS+=gmake
8430:
8431: * If the package uses pkg-config to detect dependencies, add this tool to the
8432: list of required utilities:
8433:
8434: USE_TOOLS+=pkg-config
8435:
8436: Also use pkgtools/verifypc at the end of the build process to ensure that
8437: you did not miss to specify any dependency in your package and that the
8438: version requirements are all correct.
8439:
8440: * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
8441: handle dependencies and to force the package to use the latest available
8442: version.
8443:
8444: * If the package uses gtk-doc (a documentation generation utility), do not
8445: add a dependency on it. The tool is rather big and the distfile should come
8446: with pregenerated documentation anyway; if it does not, it is a bug that
8447: you ought to report. For such packages you should disable gtk-doc (unless
8448: it is the default):
8449:
8450: CONFIGURE_ARGS+=--disable-gtk-doc
8451:
8452: The default location of installed HTML files (share/gtk-doc/<package-name>)
8453: is correct and should not be changed unless the package insists on
8454: installing them somewhere else. Otherwise programs as devhelp will not be
8455: able to open them. You can do that with an entry similar to:
8456:
8457: CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...
8458:
8459: GNOME uses multiple shared directories and files under the installation prefix
8460: to maintain databases. In this context, shared means that those exact same
8461: directories and files are used among several different packages, leading to
8462: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
8463: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
8464: your file lists and omitting shared files from them. If you find yourself doing
8465: those, your package is most likely incorrect.
8466:
8467: The following table lists the common situations that result in using shared
8468: directories or files. For each of them, the appropriate solution is given.
1.25 wiz 8469: After applying the solution be sure to regenerate the package's file list with
1.1 dsieger 8470: make print-PLIST and ensure it is correct.
8471:
1.6 rillig 8472: Table 23.1. PLIST handling for GNOME packages
1.1 dsieger 8473:
8474: +-----------------------------------------------------------------------------+
8475: | If the package... | Then... |
8476: |-------------------------------------------+---------------------------------|
1.6 rillig 8477: | |See Section 19.6.10, "Packages |
1.18 mishka 8478: |Installs OMF files under share/omf. |installing scrollkeeper/rarian |
8479: | |data files". |
1.1 dsieger 8480: |-------------------------------------------+---------------------------------|
1.6 rillig 8481: |Installs icons under the share/icons/ |See Section 19.6.19, "Packages |
1.1 dsieger 8482: |hicolor hierarchy or updates share/icons/ |installing hicolor theme icons". |
8483: |hicolor/icon-theme.cache. | |
8484: |-------------------------------------------+---------------------------------|
1.6 rillig 8485: | |See Section 19.6.14, "Packages |
1.1 dsieger 8486: |Installs files under share/mime/packages. |installing extensions to the MIME|
8487: | |database". |
8488: |-------------------------------------------+---------------------------------|
1.6 rillig 8489: |Installs .desktop files under share/ |See Section 19.6.20, "Packages |
1.1 dsieger 8490: |applications and these include MIME |installing desktop files". |
8491: |information. | |
8492: +-----------------------------------------------------------------------------+
8493:
8494:
1.6 rillig 8495: 23.3. Updating GNOME to a newer version
1.1 dsieger 8496:
8497: When seeing GNOME as a whole, there are two kinds of updates:
8498:
8499: Major update
8500:
8501: Given that there is still a very long way for GNOME 3 (if it ever appears),
8502: we consider a major update one that goes from a 2.X version to a 2.Y one,
8503: where Y is even and greater than X. These are hard to achieve because they
8504: introduce lots of changes in the components' code and almost all GNOME
8505: distfiles are updated to newer versions. Some of them can even break API
8506: and ABI compatibility with the previous major version series. As a result,
8507: the update needs to be done all at once to minimize breakage.
8508:
8509: A major update typically consists of around 80 package updates and the
8510: addition of some new ones.
8511:
8512: Minor update
8513:
8514: We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
8515: one where Y is greater than X. These are easy to achieve because they do
8516: not update all GNOME components, can be done in an incremental way and do
8517: not break API nor ABI compatibility.
8518:
8519: A minor update typically consists of around 50 package updates, although
8520: the numbers here may vary a lot.
8521:
8522: In order to update the GNOME components in pkgsrc to a new stable release
8523: (either major or minor), the following steps should be followed:
8524:
8525: 1. Get a list of all the tarballs that form the new release by using the
1.19 snj 8526: following commands. These will leave the full list of the components'
1.1 dsieger 8527: distfiles into the list.txt file:
8528:
8529: % echo ls "*.tar.bz2" | \
8530: ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
8531: awk '{ print $9 }' >list.txt
8532: % echo ls "*.tar.bz2" | \
8533: ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
8534: awk '{ print $9 }' >>list.txt
8535:
8536: 2. Open each meta package's Makefile and bump their version to the release you
8537: are updating them to. The three meta packages should be always consistent
8538: with versioning. Obviously remove any PKGREVISIONs that might be in them.
8539:
8540: 3. For each meta package, update all its DEPENDS lines to match the latest
8541: versions as shown by the above commands. Do not list any newer version
8542: (even if found in the FTP) because the meta packages are supposed to list
8543: the exact versions that form a specific GNOME release. Exceptions are
8544: permitted here if a newer version solves a serious issue in the overall
8545: desktop experience; these typically come in the form of a revision bump in
8546: pkgsrc, not in newer versions from the developers.
8547:
8548: Packages not listed in the list.txt file should be updated to the latest
8549: version available (if found in pkgsrc). This is the case, for example, of
8550: the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
8551: package.
8552:
8553: 4. Generate a patch from the modified meta packages and extract the list of
8554: "new" lines. This will provide you an outline on what packages need to be
8555: updated in pkgsrc and in what order:
8556:
8557: % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
8558:
8559: 5. For major desktop updates it is recommended to zap all your installed
8560: packages and start over from scratch at this point.
8561:
8562: 6. Now comes the longest step by far: iterate over the contents of todo.txt
8563: and update the packages listed in it in order. For major desktop updates
8564: none of these should be committed until the entire set is completed because
8565: there are chances of breaking not-yet-updated packages.
8566:
8567: 7. Once the packages are up to date and working, commit them to the tree one
8568: by one with appropriate log messages. At the end, commit the three meta
8569: package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
8570: and pkgsrc/doc/TODO files.
8571:
1.6 rillig 8572: 23.4. Patching guidelines
1.1 dsieger 8573:
8574: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
8575: it is very important that you always, always, always feed back any portability
8576: fixes you do to a GNOME package to the mainstream developers (see
1.6 rillig 8577: Section 11.3.5, "Feedback to the author"). This is the only way to get their
1.1 dsieger 8578: attention on portability issues and to ensure that future versions can be built
8579: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
8580: updates are. Those developers in charge of issuing major GNOME updates will be
8581: grateful if you do that.
8582:
8583: The most common places to report bugs are the GNOME's Bugzilla and the
8584: freedesktop.org's Bugzilla. Not all components use these to track bugs, but
8585: most of them do. Do not be short on your reports: always provide detailed
8586: explanations of the current failure, how it can be improved to achieve maximum
8587: portability and, if at all possible, provide a patch against CVS head. The more
8588: verbose you are, the higher chances of your patch being accepted.
8589:
8590: Also, please avoid using preprocessor magic to fix portability issues. While
8591: the FreeBSD GNOME people are doing a great job in porting GNOME to their
8592: operating system, the official GNOME sources are now plagued by conditionals
8593: that check for __FreeBSD__ and similar macros. This hurts portability. Please
1.6 rillig 8594: see our patching guidelines (Section 11.3.4, "Patching guidelines") for more
1.1 dsieger 8595: details.
8596:
8597: Part III. The pkgsrc infrastructure internals
8598:
8599: This part of the guide deals with everything from the infrastructure that is
8600: behind the interfaces described in the developer's guide. A casual package
8601: maintainer should not need anything from this part.
8602:
8603: Table of Contents
8604:
1.6 rillig 8605: 24. Design of the pkgsrc infrastructure
1.1 dsieger 8606:
1.6 rillig 8607: 24.1. The meaning of variable definitions
8608: 24.2. Avoiding problems before they arise
8609: 24.3. Variable evaluation
1.1 dsieger 8610:
1.6 rillig 8611: 24.3.1. At load time
8612: 24.3.2. At runtime
1.1 dsieger 8613:
1.6 rillig 8614: 24.4. How can variables be specified?
8615: 24.5. Designing interfaces for Makefile fragments
1.1 dsieger 8616:
1.6 rillig 8617: 24.5.1. Procedures with parameters
8618: 24.5.2. Actions taken on behalf of parameters
1.1 dsieger 8619:
1.6 rillig 8620: 24.6. The order in which files are loaded
1.1 dsieger 8621:
1.6 rillig 8622: 24.6.1. The order in bsd.prefs.mk
8623: 24.6.2. The order in bsd.pkg.mk
1.1 dsieger 8624:
1.6 rillig 8625: 25. Regression tests
1.1 dsieger 8626:
1.6 rillig 8627: 25.1. The regression tests framework
8628: 25.2. Running the regression tests
8629: 25.3. Adding a new regression test
1.1 dsieger 8630:
1.6 rillig 8631: 25.3.1. Overridable functions
8632: 25.3.2. Helper functions
1.1 dsieger 8633:
1.6 rillig 8634: 26. Porting pkgsrc
1.1 dsieger 8635:
1.6 rillig 8636: 26.1. Porting pkgsrc to a new operating system
8637: 26.2. Adding support for a new compiler
1.1 dsieger 8638:
1.6 rillig 8639: Chapter 24. Design of the pkgsrc infrastructure
1.1 dsieger 8640:
8641: Table of Contents
8642:
1.6 rillig 8643: 24.1. The meaning of variable definitions
8644: 24.2. Avoiding problems before they arise
8645: 24.3. Variable evaluation
1.1 dsieger 8646:
1.6 rillig 8647: 24.3.1. At load time
8648: 24.3.2. At runtime
1.1 dsieger 8649:
1.6 rillig 8650: 24.4. How can variables be specified?
8651: 24.5. Designing interfaces for Makefile fragments
1.1 dsieger 8652:
1.6 rillig 8653: 24.5.1. Procedures with parameters
8654: 24.5.2. Actions taken on behalf of parameters
1.1 dsieger 8655:
1.6 rillig 8656: 24.6. The order in which files are loaded
1.1 dsieger 8657:
1.6 rillig 8658: 24.6.1. The order in bsd.prefs.mk
8659: 24.6.2. The order in bsd.pkg.mk
1.1 dsieger 8660:
8661: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
8662: fragment needs a properly specified interface. This chapter explains how such
8663: an interface looks like.
8664:
1.6 rillig 8665: 24.1. The meaning of variable definitions
1.1 dsieger 8666:
8667: Whenever a variable is defined in the pkgsrc infrastructure, the location and
8668: the way of definition provide much information about the intended use of that
8669: variable. Additionally, more documentation may be found in a header comment or
8670: in this pkgsrc guide.
8671:
8672: A special file is mk/defaults/mk.conf, which lists all variables that are
8673: intended to be user-defined. They are either defined using the ?= operator or
8674: they are left undefined because defining them to anything would effectively
8675: mean "yes". All these variables may be overridden by the pkgsrc user in the
8676: MAKECONF file.
8677:
8678: Outside this file, the following conventions apply: Variables that are defined
8679: using the ?= operator may be overridden by a package.
8680:
8681: Variables that are defined using the = operator may be used read-only at
8682: run-time.
8683:
8684: Variables whose name starts with an underscore must not be accessed outside the
8685: pkgsrc infrastructure at all. They may change without further notice.
8686:
8687: Note
8688:
8689: These conventions are currently not applied consistently to the complete pkgsrc
8690: infrastructure.
8691:
1.6 rillig 8692: 24.2. Avoiding problems before they arise
1.1 dsieger 8693:
8694: All variables that contain lists of things should default to being empty. Two
8695: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
8696: variables cannot simply be modified using the += operator in package Makefiles
8697: (or other files included by them), since there is no guarantee whether the
8698: variable is already set or not, and what its value is. In the case of
8699: DISTFILES, the packages "know" the default value and just define it as in the
8700: following example.
8701:
8702: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
8703:
8704: Because of the selection of this default value, the same value appears in many
8705: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
8706: value ("c") is so short that it doesn't stand out. Nevertheless it is mentioned
8707: in many files.
8708:
1.6 rillig 8709: 24.3. Variable evaluation
1.1 dsieger 8710:
1.6 rillig 8711: 24.3.1. At load time
1.1 dsieger 8712:
8713: Variable evaluation takes place either at load time or at runtime, depending on
8714: the context in which they occur. The contexts where variables are evaluated at
8715: load time are:
8716:
8717: * The right hand side of the := and != operators,
8718:
8719: * Make directives like .if or .for,
8720:
8721: * Dependency lines.
8722:
8723: A special exception are references to the iteration variables of .for loops,
8724: which are expanded inline, no matter in which context they appear.
8725:
8726: As the values of variables may change during load time, care must be taken not
8727: to evaluate them by accident. Typical examples for variables that should not be
8728: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
8729: clear, here is an example:
8730:
8731: CONFIGURE_ARGS= # none
8732: CFLAGS= -O
8733: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
8734:
8735: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
8736:
8737: CFLAGS+= -Wall
8738:
8739:
8740: This code shows how the use of the := operator can quickly lead to unexpected
8741: results. The first paragraph is fairly common code. The second paragraph
8742: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
8743: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
8744: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
8745: typically occur in completely unrelated files.
8746:
1.6 rillig 8747: 24.3.2. At runtime
1.1 dsieger 8748:
8749: After all the files have been loaded, the values of the variables cannot be
8750: changed anymore. Variables that are used in the shell commands are expanded at
8751: this point.
8752:
1.6 rillig 8753: 24.4. How can variables be specified?
1.1 dsieger 8754:
8755: There are many ways in which the definition and use of a variable can be
8756: restricted in order to detect bugs and violations of the (mostly unwritten)
8757: policies. See the pkglint developer's documentation for further details.
8758:
1.6 rillig 8759: 24.5. Designing interfaces for Makefile fragments
1.1 dsieger 8760:
8761: Most of the .mk files fall into one of the following classes. Cases where a
8762: file falls into more than one class should be avoided as it often leads to
8763: subtle bugs.
8764:
1.6 rillig 8765: 24.5.1. Procedures with parameters
1.1 dsieger 8766:
8767: In a traditional imperative programming language some of the .mk files could be
1.23 jakllsch 8768: described as procedures. They take some input parameters and?after
8769: inclusion?provide a result in output parameters. Since all variables in
8770: Makefiles have global scope care must be taken not to use parameter names that
8771: have already another meaning. For example, PKGNAME is a bad choice for a
8772: parameter name.
1.1 dsieger 8773:
8774: Procedures are completely evaluated at preprocessing time. That is, when
8775: calling a procedure all input parameters must be completely resolvable. For
8776: example, CONFIGURE_ARGS should never be an input parameter since it is very
8777: likely that further text will be added after calling the procedure, which would
8778: effectively apply the procedure to only a part of the variable. Also,
8779: references to other variables wit will be modified after calling the procedure.
8780:
8781: A procedure can declare its output parameters either as suitable for use in
8782: preprocessing directives or as only available at runtime. The latter
8783: alternative is for variables that contain references to other runtime
8784: variables.
8785:
8786: Procedures shall be written such that it is possible to call the procedure more
8787: than once. That is, the file must not contain multiple-inclusion guards.
8788:
8789: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
8790: To express that the parameters are evaluated at load time, they should be
8791: assigned using the := operator, which should be used only for this purpose.
8792:
1.6 rillig 8793: 24.5.2. Actions taken on behalf of parameters
1.1 dsieger 8794:
8795: Action files take some input parameters and may define runtime variables. They
8796: shall not define loadtime variables. There are action files that are included
8797: implicitly by the pkgsrc infrastructure, while other must be included
8798: explicitly.
8799:
8800: An example for action files is mk/subst.mk.
8801:
1.6 rillig 8802: 24.6. The order in which files are loaded
1.1 dsieger 8803:
8804: Package Makefiles usually consist of a set of variable definitions, and include
8805: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
8806: include various other *.mk files if they need to query the availability of
8807: certain features like the type of compiler or the X11 implementation. Due to
8808: the heavy use of preprocessor directives like .if and .for, the order in which
8809: the files are loaded matters.
8810:
8811: This section describes at which point the various files are loaded and gives
8812: reasons for that order.
8813:
1.6 rillig 8814: 24.6.1. The order in bsd.prefs.mk
1.1 dsieger 8815:
8816: The very first action in bsd.prefs.mk is to define some essential variables
8817: like OPSYS, OS_VERSION and MACHINE_ARCH.
8818:
1.4 rillig 8819: Then, the user settings are loaded from the file specified in MAKECONF, which
8820: is usually mk.conf. After that, those variables that have not been overridden
8821: by the user are loaded from mk/defaults/mk.conf.
1.1 dsieger 8822:
8823: After the user settings, the system settings and platform settings are loaded,
8824: which may override the user settings.
8825:
8826: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
8827: This only happens when building a package, so the proper variables must be used
8828: instead of the direct tool names.
8829:
8830: As the last steps, some essential variables from the wrapper and the package
8831: system flavor are loaded, as well as the variables that have been cached in
8832: earlier phases of a package build.
8833:
1.6 rillig 8834: 24.6.2. The order in bsd.pkg.mk
1.1 dsieger 8835:
8836: First, bsd.prefs.mk is loaded.
8837:
8838: Then, the various *-vars.mk files are loaded, which fill default values for
8839: those variables that have not been defined by the package. These variables may
8840: later be used even in unrelated files.
8841:
8842: Then, the file bsd.pkg.error.mk provides the target error-check that is added
8843: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
8844: DELAYED_WARNING_MSG.
8845:
8846: Then, the package-specific hacks from hacks.mk are included.
8847:
8848: Then, various other files follow. Most of them don't have any dependencies on
8849: what they need to have included before or after them, though some do.
8850:
8851: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
8852: restricts the use of these variables to all the files that have been included
8853: before. Appearances in later files will be silently ignored.
8854:
8855: Then, the files for the main targets are included, in the order of later
8856: execution, though the actual order should not matter.
8857:
8858: At last, some more files are included that don't set any interesting variables
8859: but rather just define make targets to be executed.
8860:
1.6 rillig 8861: Chapter 25. Regression tests
1.1 dsieger 8862:
8863: Table of Contents
8864:
1.6 rillig 8865: 25.1. The regression tests framework
8866: 25.2. Running the regression tests
8867: 25.3. Adding a new regression test
1.1 dsieger 8868:
1.6 rillig 8869: 25.3.1. Overridable functions
8870: 25.3.2. Helper functions
1.1 dsieger 8871:
8872: The pkgsrc infrastructure consists of a large codebase, and there are many
8873: corners where every little bit of a file is well thought out, making pkgsrc
8874: likely to fail as soon as anything is changed near those parts. To prevent most
8875: changes from breaking anything, a suite of regression tests should go along
8876: with every important part of the pkgsrc infrastructure. This chapter describes
8877: how regression tests work in pkgsrc and how you can add new tests.
8878:
1.6 rillig 8879: 25.1. The regression tests framework
1.1 dsieger 8880:
1.6 rillig 8881: 25.2. Running the regression tests
1.1 dsieger 8882:
1.25 wiz 8883: You first need to install the pkgtools/pkg_regress package, which provides the
1.1 dsieger 8884: pkg_regress command. Then you can simply run that command, which will run all
8885: tests in the regress category.
8886:
1.6 rillig 8887: 25.3. Adding a new regression test
1.1 dsieger 8888:
8889: Every directory in the regress category that contains a file called spec is
8890: considered a regression test. This file is a shell program that is included by
8891: the pkg_regress command. The following functions can be overridden to suit your
8892: needs.
8893:
1.6 rillig 8894: 25.3.1. Overridable functions
1.1 dsieger 8895:
8896: These functions do not take any parameters. They are all called in "set -e"
8897: mode, so you should be careful to check the exitcodes of any commands you run
8898: in the test.
8899:
8900: do_setup()
8901:
8902: This function prepares the environment for the test. By default it does
8903: nothing.
8904:
8905: do_test()
8906:
8907: This function runs the actual test. By default, it calls TEST_MAKE with the
8908: arguments MAKEARGS_TEST and writes its output including error messages into
8909: the file TEST_OUTFILE.
8910:
8911: check_result()
8912:
8913: This function is run after the test and is typically used to compare the
8914: actual output from the one that is expected. It can make use of the various
8915: helper functions from the next section.
8916:
8917: do_cleanup()
8918:
8919: This function cleans everything up after the test has been run. By default
8920: it does nothing.
8921:
1.6 rillig 8922: 25.3.2. Helper functions
1.1 dsieger 8923:
8924: exit_status(expected)
8925:
8926: This function compares the exitcode of the do_test() function with its
8927: first parameter. If they differ, the test will fail.
8928:
8929: output_require(regex...)
8930:
8931: This function checks for each of its parameters if the output from do_test
8932: () matches the extended regular expression. If it does not, the test will
8933: fail.
8934:
8935: output_prohibit(regex...)
8936:
8937: This function checks for each of its parameters if the output from do_test
8938: () does not match the extended regular expression. If any of the regular
8939: expressions matches, the test will fail.
8940:
1.6 rillig 8941: Chapter 26. Porting pkgsrc
1.1 dsieger 8942:
8943: Table of Contents
8944:
1.6 rillig 8945: 26.1. Porting pkgsrc to a new operating system
8946: 26.2. Adding support for a new compiler
1.1 dsieger 8947:
8948: The pkgsrc system has already been ported to many operating systems, hardware
8949: architectures and compilers. This chapter explains the necessary steps to make
8950: pkgsrc even more portable.
8951:
1.6 rillig 8952: 26.1. Porting pkgsrc to a new operating system
1.1 dsieger 8953:
8954: To port pkgsrc to a new operating system (called MyOS in this example), you
8955: need to touch the following files:
8956:
8957: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
8958:
8959: This file contains some basic definitions, for example the name of the C
8960: compiler.
8961:
8962: mk/bsd.prefs.mk
8963:
8964: Insert code that defines the variables OPSYS, OS_VERSION, LOWER_OS_VERSION,
8965: LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
8966: that appear in this file.
8967:
8968: mk/platform/MyOS.mk
8969:
8970: This file contains the platform-specific definitions that are used by
8971: pkgsrc. Start by copying one of the other files and edit it to your needs.
8972:
8973: mk/platform/MyOS.pkg.dist
8974:
8975: This file contains a list of directories, together with their permission
8976: bits and ownership. These directories will be created automatically with
8977: every package that explicitly sets USE_MTREE. This feature will be removed.
8978:
8979: mk/platform/MyOS.x11.dist
8980:
8981: Just copy one of the pre-existing x11.dist files to your MyOS.x11.dist.
8982:
8983: mk/tools/bootstrap.mk
8984:
8985: On some operating systems, the tools that are provided with the base system
8986: are not good enough for pkgsrc. For example, there are many versions of sed
8987: (1) that have a narrow limit on the line length they can process. Therefore
8988: pkgsrc brings its own tools, which can be enabled here.
8989:
8990: mk/tools/tools.MyOS.mk
8991:
8992: This file defines the paths to all the tools that are needed by one or the
8993: other package in pkgsrc, as well as by pkgsrc itself. Find out where these
8994: tools are on your platform and add them.
8995:
8996: Now, you should be able to build some basic packages, like lang/perl5, shells/
8997: bash.
8998:
1.6 rillig 8999: 26.2. Adding support for a new compiler
1.1 dsieger 9000:
9001: TODO
9002:
9003: Appendix A. A simple example package: bison
9004:
9005: Table of Contents
9006:
9007: A.1. files
9008:
9009: A.1.1. Makefile
9010: A.1.2. DESCR
9011: A.1.3. PLIST
9012: A.1.4. Checking a package with pkglint
9013:
9014: A.2. Steps for building, installing, packaging
9015:
9016: We checked to find a piece of software that wasn't in the packages collection,
1.25 wiz 9017: and picked GNU bison. Quite why someone would want to have bison when Berkeley
1.1 dsieger 9018: yacc is already present in the tree is beyond us, but it's useful for the
9019: purposes of this exercise.
9020:
9021: A.1. files
9022:
9023: A.1.1. Makefile
9024:
1.2 rillig 9025: # $NetBSD$
1.1 dsieger 9026: #
9027:
9028: DISTNAME= bison-1.25
9029: CATEGORIES= devel
9030: MASTER_SITES= ${MASTER_SITE_GNU}
9031:
1.30 dholland 9032: MAINTAINER= pkgsrc-users@NetBSD.org
1.1 dsieger 9033: HOMEPAGE= http://www.gnu.org/software/bison/bison.html
9034: COMMENT= GNU yacc clone
9035:
9036: GNU_CONFIGURE= yes
1.47 wiz 9037: INFO_FILES= yes
1.1 dsieger 9038:
9039: .include "../../mk/bsd.pkg.mk"
9040:
9041: A.1.2. DESCR
9042:
9043: GNU version of yacc. Can make re-entrant parsers, and numerous other
9044: improvements. Why you would want this when Berkeley yacc(1) is part
9045: of the NetBSD source tree is beyond me.
9046:
9047: A.1.3. PLIST
9048:
1.2 rillig 9049: @comment $NetBSD$
1.1 dsieger 9050: bin/bison
9051: man/man1/bison.1.gz
9052: share/bison.simple
9053: share/bison.hairy
9054:
9055: A.1.4. Checking a package with pkglint
9056:
9057: The NetBSD package system comes with pkgtools/pkglint which helps to check the
9058: contents of these files. After installation it is quite easy to use, just
9059: change to the directory of the package you wish to examine and execute pkglint:
9060:
9061: $ pkglint
9062: looks fine.
9063:
9064: Depending on the supplied command line arguments (see pkglint(1)), more checks
9065: will be performed. Use e.g. pkglint -Call -Wall for a very thorough check.
9066:
9067: A.2. Steps for building, installing, packaging
9068:
9069: Create the directory where the package lives, plus any auxiliary directories:
9070:
9071: # cd /usr/pkgsrc/lang
9072: # mkdir bison
9073: # cd bison
9074: # mkdir patches
9075:
1.6 rillig 9076: Create Makefile, DESCR and PLIST (see Chapter 11, Package components - files,
1.1 dsieger 9077: directories and contents) then continue with fetching the distfile:
9078:
9079: # make fetch
9080: >> bison-1.25.tar.gz doesn't seem to exist on this system.
9081: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
9082: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
9083: ftp: Error retrieving file: 500 Internal error
9084:
9085: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
9086: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
9087: ftp: Error retrieving file: 500 Internal error
9088:
9089: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
9090: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
9091: Successfully retrieved file.
9092:
9093: Generate the checksum of the distfile into distinfo:
9094:
9095: # make makedistinfo
9096:
9097: Now compile:
9098:
9099: # make
9100: >> Checksum OK for bison-1.25.tar.gz.
9101: ===> Extracting for bison-1.25
9102: ===> Patching for bison-1.25
9103: ===> Ignoring empty patch directory
9104: ===> Configuring for bison-1.25
9105: creating cache ./config.cache
9106: checking for gcc... cc
9107: checking whether we are using GNU C... yes
9108: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
9109: checking how to run the C preprocessor... cc -E
9110: checking for minix/config.h... no
9111: checking for POSIXized ISC... no
9112: checking whether cross-compiling... no
9113: checking for ANSI C header files... yes
9114: checking for string.h... yes
9115: checking for stdlib.h... yes
9116: checking for memory.h... yes
9117: checking for working const... yes
9118: checking for working alloca.h... no
9119: checking for alloca... yes
9120: checking for strerror... yes
9121: updating cache ./config.cache
9122: creating ./config.status
9123: creating Makefile
9124: ===> Building for bison-1.25
9125: 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
9126: 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
9127: 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
9128: 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
9129: 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
9130: 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
9131: 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
9132: 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
9133: 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
9134: 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
9135: 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
9136: 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
9137: 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
9138: 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
9139: 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
9140: 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
9141: 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
9142: 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
9143: 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
9144: 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
9145: 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
9146: 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
9147: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
9148: rm -f bison.s1
9149: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
9150:
9151: Everything seems OK, so install the files:
9152:
9153: # make install
9154: >> Checksum OK for bison-1.25.tar.gz.
9155: ===> Installing for bison-1.25
9156: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
9157: rm -f /usr/pkg/bin/bison
9158: cd /usr/pkg/share; rm -f bison.simple bison.hairy
9159: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
9160: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
9161: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
9162: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
9163: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
9164: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
9165: ===> Registering installation for bison-1.25
9166:
9167: You can now use bison, and also - if you decide so - remove it with pkg_delete
9168: bison. Should you decide that you want a binary package, do this now:
9169:
9170: # make package
9171: >> Checksum OK for bison-1.25.tar.gz.
9172: ===> Building package for bison-1.25
9173: Creating package bison-1.25.tgz
9174: Registering depends:.
9175: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
9176:
9177: Now that you don't need the source and object files any more, clean up:
9178:
9179: # make clean
9180: ===> Cleaning for bison-1.25
9181:
9182: Appendix B. Build logs
9183:
9184: Table of Contents
9185:
9186: B.1. Building figlet
9187: B.2. Packaging figlet
9188:
9189: B.1. Building figlet
9190:
9191: # make
9192: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9193: => figlet221.tar.gz doesn't seem to exist on this system.
9194: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
9195: => [172219 bytes]
9196: Connected to ftp.plig.net.
9197: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
9198: 331 Guest login ok, send your complete e-mail address as password.
9199: 230-You are user #5 of 500 simultaneous users allowed.
9200: 230-
9201: 230- ___ _ _ _
9202: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
9203: 230- | _| _| . |_| . | | | . |_| . | _| . |
9204: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
9205: 230- |_| |_| |___| |___|
9206: 230-
9207: 230-** Welcome to ftp.plig.org **
9208: 230-
9209: 230-Please note that all transfers from this FTP site are logged. If you
9210: 230-do not like this, please disconnect now.
9211: 230-
1.19 snj 9212: 230-This archive is available via
1.1 dsieger 9213: 230-
9214: 230-HTTP: http://ftp.plig.org/
9215: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
9216: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
9217: 230-
9218: 230-Please email comments, bug reports and requests for packages to be
9219: 230-mirrored to ftp-admin@plig.org.
9220: 230-
9221: 230-
9222: 230 Logged in anonymously.
9223: Remote system type is UNIX.
9224: Using binary mode to transfer files.
9225: 200 Type okay.
9226: 250 "/pub" is new cwd.
9227: 250-"/pub/figlet" is new cwd.
9228: 250-
9229: 250-Welcome to the figlet archive at ftp.figlet.org
9230: 250-
9231: 250- ftp://ftp.figlet.org/pub/figlet/
9232: 250-
9233: 250-The official FIGlet web page is:
9234: 250- http://www.figlet.org/
9235: 250-
9236: 250-If you have questions, please mailto:info@figlet.org. If you want to
9237: 250-contribute a font or something else, you can email us.
9238: 250
9239: 250 "/pub/figlet/program" is new cwd.
9240: 250 "/pub/figlet/program/unix" is new cwd.
9241: local: figlet221.tar.gz remote: figlet221.tar.gz
9242: 502 Unimplemented command.
9243: 227 Entering Passive Mode (195,40,6,41,246,104)
9244: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
9245: 38% |************** | 65800 64.16 KB/s 00:01 ETA
9246: 226 Transfer completed.
9247: 172219 bytes received in 00:02 (75.99 KB/s)
9248: 221 Goodbye.
9249: => Checksum OK for figlet221.tar.gz.
9250: ===> Extracting for figlet-2.2.1nb2
9251: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
9252: ===> Patching for figlet-2.2.1nb2
9253: ===> Applying pkgsrc patches for figlet-2.2.1nb2
9254: ===> Overriding tools for figlet-2.2.1nb2
9255: ===> Creating toolchain wrappers for figlet-2.2.1nb2
9256: ===> Configuring for figlet-2.2.1nb2
9257: ===> Building for figlet-2.2.1nb2
9258: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
9259: chmod a+x figlet
9260: gcc -O2 -o chkfont chkfont.c
9261: => Unwrapping files-to-be-installed.
9262: #
9263: # make install
9264: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9265: ===> Installing for figlet-2.2.1nb2
9266: install -d -o root -g wheel -m 755 /usr/pkg/bin
9267: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
9268: mkdir -p /usr/pkg/share/figlet
9269: cp figlet /usr/pkg/bin
9270: cp chkfont /usr/pkg/bin
9271: chmod 555 figlist showfigfonts
9272: cp figlist /usr/pkg/bin
9273: cp showfigfonts /usr/pkg/bin
9274: cp fonts/*.flf /usr/pkg/share/figlet
9275: cp fonts/*.flc /usr/pkg/share/figlet
9276: cp figlet.6 /usr/pkg/man/man6
9277: ===> Registering installation for figlet-2.2.1nb2
9278: #
9279:
9280: B.2. Packaging figlet
9281:
9282: # make package
9283: ===> Checking for vulnerabilities in figlet-2.2.1nb2
9284: ===> Packaging figlet-2.2.1nb2
9285: ===> Building binary package for figlet-2.2.1nb2
9286: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
9287: Using SrcDir value of /usr/pkg
9288: Registering depends:.
9289: #
9290:
9291: Appendix C. Directory layout of the pkgsrc FTP server
9292:
9293: Table of Contents
9294:
1.23 jakllsch 9295: C.1. distfiles: The distributed source files
9296: C.2. misc: Miscellaneous things
9297: C.3. packages: Binary packages
9298: C.4. reports: Bulk build reports
9299: C.5. current, pkgsrc-20xxQy: source packages
1.1 dsieger 9300:
9301: As in other big projects, the directory layout of pkgsrc is quite complex for
9302: newbies. This chapter explains where you find things on the FTP server. The
9303: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
9304: different, but inside this directory, everything should look the same, no
9305: matter on which server you are. This directory contains some subdirectories,
9306: which are explained below.
9307:
1.23 jakllsch 9308: C.1. distfiles: The distributed source files
1.1 dsieger 9309:
9310: The directory distfiles contains lots of archive files from all pkgsrc
9311: packages, which are mirrored here. The subdirectories are called after their
9312: package names and are used when the distributed files have names that don't
9313: explicitly contain a version number or are otherwise too generic (for example
9314: release.tar.gz).
9315:
1.23 jakllsch 9316: C.2. misc: Miscellaneous things
1.1 dsieger 9317:
9318: This directory contains things that individual pkgsrc developers find worth
9319: publishing.
9320:
1.23 jakllsch 9321: C.3. packages: Binary packages
1.1 dsieger 9322:
1.3 rillig 9323: This directory contains binary packages for the various platforms that are
9324: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
9325: The meaning of these variables is:
9326:
9327: * OPSYS is the name of the operating system for which the packages have been
1.9 rillig 9328: built. The name is taken from the output of the uname command, so it may
9329: differ from the one you are used to hear.
1.3 rillig 9330:
1.8 rillig 9331: * ARCH is the hardware architecture of the platform for which the packages
1.10 hubertf 9332: have been built. It also includes the ABI (Application Binary Interface)
9333: for platforms that have several of them.
1.3 rillig 9334:
1.8 rillig 9335: * OSVERSION is the version of the operating system. For version numbers that
9336: change often (for example NetBSD-current), the often-changing part should
9337: be replaced with an x, for example 4.99.x.
1.3 rillig 9338:
1.23 jakllsch 9339: * TAG is either 20xxQy for a stable branch, or head for packages built from
1.8 rillig 9340: the HEAD branch. The latter should only be used when the packages are
9341: updated on a regular basis. Otherwise the date from checking out pkgsrc
9342: should be appended, for example head_20071015.
1.3 rillig 9343:
9344: The rationale for exactly this scheme is that the pkgsrc users looking for
9345: binary packages can quickly click through the directories on the server and
9346: find the best binary packages for their machines. Since they usually know the
9347: operating system and the hardware architecture, OPSYS and ARCH are placed
9348: first. After these choices, they can select the best combination of OSVERSION
9349: and TAG together, since it is usually the case that packages stay compatible
9350: between different version of the operating system.
9351:
9352: In each of these directories, there is a whole binary packages collection for a
9353: specific platform. It has a directory called All which contains all binary
9354: packages. Besides that, there are various category directories that contain
9355: symbolic links to the real binary packages.
1.1 dsieger 9356:
1.23 jakllsch 9357: C.4. reports: Bulk build reports
1.8 rillig 9358:
9359: Here are the reports from bulk builds, for those who want to fix packages that
9360: didn't build on some of the platforms. The structure of subdirectories should
1.23 jakllsch 9361: look like the one in Section C.3, "packages: Binary packages".
1.8 rillig 9362:
1.23 jakllsch 9363: C.5. current, pkgsrc-20xxQy: source packages
1.1 dsieger 9364:
9365: These directories contain the "real" pkgsrc, that is the files that define how
9366: to create binary packages from source archives.
9367:
9368: The directory pkgsrc contains a snapshot of the CVS repository, which is
9369: updated regularly. The file pkgsrc.tar.gz contains the same as the directory,
9370: ready to be downloaded as a whole.
9371:
9372: In the directories for the quarterly branches, there is an additional file
1.23 jakllsch 9373: called pkgsrc-20xxQy.tar.gz, which contains the state of pkgsrc when it was
1.1 dsieger 9374: branched.
9375:
9376: Appendix D. Editing guidelines for the pkgsrc guide
9377:
9378: Table of Contents
9379:
9380: D.1. Make targets
9381: D.2. Procedure
9382:
9383: This section contains information on editing the pkgsrc guide itself.
9384:
9385: D.1. Make targets
9386:
9387: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
9388: files are created from it:
9389:
9390: * pkgsrc/doc/pkgsrc.txt
9391:
9392: * pkgsrc/doc/pkgsrc.html
9393:
1.2 rillig 9394: * http://www.NetBSD.org/docs/pkgsrc/
1.1 dsieger 9395:
1.2 rillig 9396: * http://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the pkgsrc
9397: guide.
1.1 dsieger 9398:
1.2 rillig 9399: * http://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
9400: pkgsrc guide.
1.1 dsieger 9401:
9402: D.2. Procedure
9403:
9404: The procedure to edit the pkgsrc guide is:
9405:
9406: 1. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46 obache 9407: other XML-based NetBSD documentation) installed. These are automatically
9408: installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1 dsieger 9409:
9410: 2. Run cd doc/guide to get to the right directory. All further steps will take
9411: place here.
9412:
9413: 3. Edit the XML file(s) in files/.
9414:
9415: 4. Run bmake to check the pkgsrc guide for valid XML and to build the final
9416: output files. If you get any errors at this stage, you can just edit the
9417: files, as there are only symbolic links in the working directory, pointing
9418: to the files in files/.
9419:
9420: 5. (cd files && cvs commit)
9421:
9422: 6. Run bmake clean && bmake to regenerate the output files with the proper RCS
9423: Ids.
9424:
9425: 7. Run bmake regen to install and commit the files in both pkgsrc/doc and
9426: htdocs.
9427:
9428: Note
9429:
9430: If you have added, removed or renamed some chapters, you need to
9431: synchronize them using cvs add or cvs delete in the htdocs directory.
9432:
CVSweb <webmaster@jp.NetBSD.org>