Policy
Policy
Release 4.7.2.0
3 Binary packages 13
3.1 The package name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.1.1 Packages with potentially offensive content . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2 The version of a package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.2.1 Version numbers based on dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2.2 Uniqueness of version numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.3 The maintainer of a package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4 The description of a package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.4.1 The single line synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.4.2 The extended description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.5 Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.6 Virtual packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.7 Base system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.8 Essential packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.9 Maintainer Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.9.1 Prompting in maintainer scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4 Source packages 19
i
4.1 Standards conformance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2 Package relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.3 Changes to the upstream sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.4 Debian changelog: debian/changelog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.5 Copyright: debian/copyright . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.6 Error trapping in makefiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.7 Time Stamps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.8 Restrictions on objects in source packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.9 Main building script: debian/rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.9.1 debian/rules and DEB_BUILD_OPTIONS . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.9.2 debian/rules and Rules-Requires-Root . . . . . . . . . . . . . . . . . . . . . . . . 27
4.10 Variable substitutions: debian/substvars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.11 Upstream source location: debian/watch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.12 Generated files list: debian/files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.13 Embedded code copies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.14 Source package handling: debian/README.source . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.15 Reproducibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.16 Missing sources: debian/missing-sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.17 Vendor-specific patch series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
ii
5.6.25 DM-Upload-Allowed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.6.26 Version Control System (VCS) fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.6.27 Package-List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.6.28 Package-Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.6.29 Dgit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.6.30 Testsuite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.6.31 Rules-Requires-Root . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.6.31.1 Remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.6.31.2 Definition of the keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.6.31.3 Provided keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
5.7 User-defined fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.8 Obsolete fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.8.1 DM-Upload-Allowed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
8 Shared libraries 67
8.1 Run-time shared libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
8.1.1 ldconfig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
8.2 Shared library support files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
8.3 Static libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
8.4 Development files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
8.5 Dependencies between the packages of the same library . . . . . . . . . . . . . . . . . . . . . . . . . 70
8.6 Dependencies between the library and other packages . . . . . . . . . . . . . . . . . . . . . . . . . . 70
8.6.1 Generating dependencies on shared libraries . . . . . . . . . . . . . . . . . . . . . . . . . . 70
8.6.2 Shared library ABI changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
8.6.3 The symbols system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
8.6.3.1 The symbols files present on the system . . . . . . . . . . . . . . . . . . . . . . . 72
8.6.3.2 The symbols File Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
8.6.3.3 Providing a symbols file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
8.6.4 The shlibs system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
8.6.4.1 The shlibs files present on the system . . . . . . . . . . . . . . . . . . . . . . . . 75
8.6.4.2 The shlibs File Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
iii
8.6.4.3 Providing a shlibs file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
10 Files 89
10.1 Binaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
10.2 Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
10.3 Shared libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
10.4 Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
10.5 Symbolic links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
10.6 Device files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
10.7 Configuration files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
10.7.1 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
10.7.2 Location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
10.7.3 Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
10.7.4 Sharing configuration files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
10.7.5 User configuration files (“dotfiles”) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
10.8 Log files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
10.9 Locale files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
10.10 Permissions and owners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
10.10.1 The use of dpkg-statoverride . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
10.11 File names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
iv
11 Customized programs 99
11.1 Architecture specification strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
11.1.1 Architecture wildcards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
11.2 Daemons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
11.3 Using pseudo-ttys and modifying wtmp, utmp and lastlog . . . . . . . . . . . . . . . . . . . . . . . . 99
11.4 Editors and pagers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
11.5 Web servers and applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
11.6 Mail transport, delivery and user agents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
11.7 News system configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
11.8 Programs for the X Window System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
11.8.1 Providing X support and package priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
11.8.2 Packages providing an X server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
11.8.3 Packages providing a terminal emulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
11.8.4 Packages providing a window manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
11.8.5 Packages providing fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
11.8.6 Application defaults files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
11.8.7 Installation directory issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
11.9 Perl programs and modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
11.10 Emacs lisp programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
11.11 Games . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
12 Documentation 107
12.1 Manual pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
12.2 Info documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
12.3 Additional documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
12.4 Preferred documentation formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
12.5 Copyright information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
12.5.1 Machine-readable copyright information . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
12.6 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
12.7 Changelog files and release notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
v
15.4 Unpacking a Debian source package without dpkg-source . . . . . . . . . . . . . . . . . . . . . . 120
15.4.1 Restrictions on objects in source packages . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
16 Control files and their fields (from old Packaging Manual) 123
16.1 Syntax of control files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
16.2 List of fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
16.2.1 Filename and MSDOS-Filename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
16.2.2 Size and MD5sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
16.2.3 Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
16.2.4 Config-Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
16.2.5 Conffiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
16.2.6 Obsolete fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
19 Diversions - overriding a package’s version of a file (from old Packaging Manual) 129
vi
22.19 Version 4.1.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
22.20 Version 4.1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
22.21 Version 4.0.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
22.22 Version 4.0.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
22.23 Version 3.9.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
22.24 Version 3.9.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
22.25 Version 3.9.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
22.26 Version 3.9.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
22.27 Version 3.9.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
22.28 Version 3.9.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
22.29 Version 3.9.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
22.30 Version 3.9.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
22.31 Version 3.9.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
22.32 Version 3.8.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
22.33 Version 3.8.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
22.34 Version 3.8.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
22.35 Version 3.8.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
22.36 Version 3.8.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
22.37 Version 3.7.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
22.38 Version 3.7.2.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
22.39 Version 3.7.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
22.40 Version 3.7.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
22.41 Version 3.7.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
22.42 Version 3.6.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
22.43 Version 3.6.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
22.44 Version 3.6.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
22.45 Version 3.5.10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
22.46 Version 3.5.9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
22.47 Version 3.5.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
22.48 Version 3.5.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
22.49 Version 3.5.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
22.50 Version 3.5.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
22.51 Version 3.5.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
22.52 Version 3.5.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
22.53 Version 3.5.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
22.54 Version 3.5.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
22.55 Version 3.5.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
22.56 Version 3.2.1.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
22.57 Version 3.2.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
22.58 Version 3.2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
22.59 Version 3.1.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
22.60 Version 3.1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
22.61 Version 3.0.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
22.62 Version 3.0.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
22.63 Version 2.5.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
22.64 Version 2.4.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
22.65 Version 2.4.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
22.66 Version 2.3.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
22.67 Version 2.2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
22.68 Version 2.1.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
22.69 Version 2.1.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
22.70 Version 2.1.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
22.71 Version 2.1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
vii
23 License 173
Index 175
viii
Debian Policy Manual, Release 4.7.2.0
This manual describes the policy requirements for the Debian distribution. This includes the structure and contents of
the Debian archive and several design issues of the operating system, as well as technical requirements that each package
must satisfy to be included in the distribution.
This is Debian Policy version 4.7.2.0, released on 2025-02-27.
CONTENTS 1
Debian Policy Manual, Release 4.7.2.0
2 CONTENTS
CHAPTER
ONE
1.1 Scope
This manual describes the policy requirements for the Debian distribution. This includes the structure and contents of
the Debian archive and several design issues of the operating system, as well as technical requirements that each package
must satisfy to be included in the distribution.
This manual also describes Debian policy as it relates to creating Debian packages. It is not a tutorial on how to build
packages, nor is it exhaustive where it comes to describing the behavior of the packaging system. Instead, this manual
attempts to define the interface to the package management system with which the developers must be conversant.1
This manual cannot and does not prohibit every possible bug or undesirable behaviour. The fact that something is not
prohibited by Debian policy does not mean that it is not a bug, let alone that it is desirable. Questions not covered by
policy should be evaluated on their merits.
The footnotes present in this manual are merely informative, and are not part of Debian policy itself.
The appendices to this manual are not necessarily normative, either. Please see Introduction and scope of these appendices
for more information.
In the normative part of this manual, the following terms are used to describe the importance of each statement:2
• The terms must and must not, and the adjectives required and prohibited, denote strong requirements. Packages that
do not conform to these requirements will generally not be considered acceptable for the Debian distribution. These
statements correspond to the critical, grave, and serious bug severities (normally serious). They are collectively
called Policy requirements.
• The terms should and should not, and the adjective recommended, denote best practices. Non-conformance with
these guidelines will generally be considered a bug, but will not necessarily render a package unsuitable for dis-
tribution. These statements correspond to bug severities of important, normal, and minor. They are collectively
called Policy recommendations.
• The adjectives encouraged and discouraged denote places where Policy offers advice to maintainers, but maintainers
are free to follow or not follow that advice. Non-conformance with this advice is normally not considered a bug;
if a bug seems worthwhile, normally it would have a severity of wishlist. These statements are collectively called
Policy advice.
1 Informally, the criteria used for inclusion is that the material meet one of the following requirements:
Standard interfaces
The material presented represents an interface to the packaging system that is mandated for use, and is used by, a significant number of packages,
and therefore should not be changed without peer review. Package maintainers can then rely on this interface not changing, and the package
management software authors need to ensure compatibility with this interface definition. (Control file and changelog file formats are examples.)
Chosen Convention
If there are a number of technically viable choices that can be made, but one needs to select one of these options for inter-operability. The
version number format is one example.
Please note that these are not mutually exclusive; selected conventions often become parts of standard interfaces.
2 Compare RFC 2119. Note, however, that these words are used in a different way in this document.
3
Debian Policy Manual, Release 4.7.2.0
• The term may and the adjective optional are used to clarify cases where it may otherwise appear that Policy is
specifying a requirement or recommendation. In those cases, these words describe decisions that are truly optional
and at the maintainer’s discretion.
The Release Team can, at their discretion, downgrade a Policy requirement to a Policy recommendation for a given release
of the Debian distribution. This may be done for only a specific package or for the archive as a whole. This provision
is intended to provide flexibility to balance the quality standards of the distribution against the release schedule and the
importance of making a stable release.
Much of the information presented in this manual will be useful even when building a package which is to be distributed
in some other way or is intended for local use only.
udebs (stripped-down binary packages used by the Debian Installer) and source packages that produce only udebs do not
comply with all of the requirements discussed here. See the Debian Installer internals manual for more information about
them.
1.3.3 Improvements
While the authors of this document have tried hard to avoid typos and other errors, these do still occur. If you discover
an error in this manual or if you want to give any comments, suggestions, or criticisms please send an email to the Debian
Policy Mailing List, [email protected], or submit a bug report against the debian-policy package.
Please do not try to reach the individual authors or maintainers of the Policy Manual regarding changes to the Policy.
New techniques and functionality are generally implemented in the Debian archive (long) before they are detailed in this
document. This is not considered to be a problem: there is a consensus in the Debian Project that the task of keeping this
document up-to-date should never block making improvements to Debian. Nevertheless, it is better to submit patches
to this document sooner rather than later. This reduces the amount of work that is needed on the part of others to get
themselves up-to-speed on new best practices.
1.5 Definitions
The following terms are used in this Policy Manual:
ASCII
The character encoding specified by ANSI X3.4-1986 and its predecessor standards, referred to in MIME as US-
ASCII, and corresponding to an encoding in eight bits per character of the first 128 Unicode characters, with the
eighth bit always zero.
upstream
The source of software that is being packaged, or the portion of a software package that originates from outside of
Debian. For example, suppose Alice writes and releases a free software package, and then Bob creates a Debian
package of that software package. Alice is the upstream maintainer (sometimes abbreviated as upstream) of the
package, Alice’s releases are the upstream releases, and the version number she puts on a release is the upstream
version. Bob may make Debian-specific modifications to the package, and then later send those modifications
upstream to be incorporated in Alice’s releases.
The packager and upstream developer may be the same person. For example, Alice may choose to package her
own software for Debian. However, this manual still distinguishes between the role of upstream and the role of
Debian packager, even when the same person is filling both of those roles, since they have some implications for
the details of packaging.
UTF-8
The transformation format (sometimes called encoding) of Unicode defined by RFC 3629. UTF-8 has the useful
property of having ASCII as a subset, so any text encoded in ASCII is trivially also valid UTF-8.
1.6 Translations
When translations of this document into languages other than English disagree with the English text, the English text
takes precedence.
TWO
The Debian system is maintained and distributed as a collection of packages. Since there are so many of them (currently
well over 15000), they are split into sections and given priorities to simplify the handling of them.
The effort of the Debian project is to build a free operating system, but not every package we want to make accessible is
free in our sense (see the Debian Free Software Guidelines, below), or may be imported/exported without restrictions.
Thus, the archive is split into areas1 based on their licenses and other restrictions.
The aims of this are:
• to allow us to make as much software available as we can
• to allow us to encourage everyone to write free software, and
• to allow us to make it easy for people to produce CD-ROMs of our system without violating any licenses, im-
port/export restrictions, or any other laws.
The main archive area forms the Debian distribution.
Packages in the other archive areas (non-free-firmware, contrib, non-free) are not considered to be part of the
Debian distribution, although we support their use and provide infrastructure for them (such as our bug-tracking system
and mailing lists). This Debian Policy Manual applies to these packages as well.
Social Contract simply refers to “areas.” This document uses terminology similar to the Social Contract.
7
Debian Policy Manual, Release 4.7.2.0
compromise. The Debian Project encourages all authors to not restrict any files, source or binary, from being
modified.)
5. No Discrimination Against Persons or Groups
The license must not discriminate against any person or group of persons.
6. No Discrimination Against Fields of Endeavor
The license must not restrict anyone from making use of the program in a specific field of endeavor. For
example, it may not restrict the program from being used in a business, or from being used for genetic
research.
7. Distribution of License
The rights attached to the program must apply to all to whom the program is redistributed without the need
for execution of an additional license by those parties.
8. License Must Not Be Specific to Debian
The rights attached to the program must not depend on the program’s being part of a Debian system. If the
program is extracted from Debian and used or distributed without Debian but otherwise within the terms of
the program’s license, all parties to whom the program is redistributed must have the same rights as those
that are granted in conjunction with the Debian system.
9. License Must Not Contaminate Other Software
The license must not place restrictions on other software that is distributed along with the licensed software.
For example, the license must not insist that all other programs distributed on the same medium must be free
software.
10. Example Licenses
The “GPL,” “BSD,” and “Artistic” licenses are examples of licenses that we consider free.
When a main source package has a mixture of main and contrib binary packages, the source package and the main
binary packages must follow the requirements for main packages, but the contrib binary packages may follow the weaker
requirements for contrib packages. In particular, source packages in main must not have build dependencies outside main,
but the contrib binary packages may have runtime dependencies outside main.
The copyright information for files in a package must be copied verbatim into /usr/share/doc/PACKAGE/
copyright, when all of the following hold:
1. the distribution license for those files requires that copyright information be included in all copies and/or binary
distributions;
2. the files are shipped in the binary package, either in source or compiled form; and
3. the form in which the files are present in the binary package does not include a plain text version of their copyright
notices.
Thus, the copyright information for files in the source package which are only part of its build process, such as autotools
files, need not be included in /usr/share/doc/PACKAGE/copyright, because those files do not get installed into the
binary package. Similarly, plain text files which include their own copyright information and are installed into the binary
package unmodified need not have that copyright information copied into /usr/share/doc/PACKAGE/copyright
However, the copyright notices for any files which are compiled into the object code shipped in the binary package must
all be included in /usr/share/doc/PACKAGE/copyright when the license requires that copyright information be
included in all copies and/or binary distributions, as most do.5
See Copyright information for further details.
We reserve the right to restrict files from being included anywhere in our archives if
• their use or distribution would break a law,
• there is an ethical conflict in their distribution or use,
• we would have to sign a license for them, or
• their distribution would conflict with other project policies.
Programs whose authors encourage the user to make donations are fine for the main distribution, provided that the authors
do not claim that not donating is immoral, unethical, illegal or something similar; in such a case they must go in non-free.
Packages whose copyright permission notices (or patent problems) do not even allow redistribution of binaries only, and
where no special permission has been obtained, must not be placed on the Debian FTP site and its mirrors at all.
Note that under international copyright law (this applies in the United States, too), no distribution or modification of a
work is allowed without an explicit notice saying so. Therefore a program without a copyright notice is copyrighted and
you may not do anything to it without risking being sued! Likewise if a program has a copyright notice but no statement
saying what is permitted then nothing is permitted.
Many authors are unaware of the problems that restrictive copyrights (or lack of copyright notices) can cause for the
users of their supposedly-free software. It is often worthwhile contacting such authors diplomatically to ask them to
modify their license terms. However, this can be a politically difficult thing to do and you should ask for advice on the
debian-legal mailing list first, as explained below.
When in doubt about a copyright, send mail to [email protected]. Be prepared to provide us with the copyright
statement. Software covered by the GPL, public domain software and BSD-like copyrights are safe; be wary of the phrases
“commercial use prohibited” and “distribution restricted”.
5 Licenses that are not thought to require the copying of all copyright notices into Debian’s copyright file include Apache-2.0 and the Boost Software
License, version 1.0. Final determination as to whether a package’s copyright file is sufficient lies with the FTP team.
To help find copyright notices you need to copy, you might try grep --color=always -Eir '(copyright|©)' * | less -R
2.4 Sections
The packages in the archive areas main, non-free-firmware, contrib and non-free are grouped further into sections to
simplify handling.
The archive area and section for each package should be specified in the package’s Section control field (see Section).
However, the maintainer of the Debian archive may override this selection to ensure the consistency of the Debian
distribution. The Section field should be of the form:
• section if the package is in the main archive area,
• area/section if the package is in the non-free-firmware, contrib or non-free archive areas.
The Debian archive maintainers provide the authoritative list of sections. At present, they are: admin, cli-mono, comm,
database, debug, devel, doc, editors, education, electronics, embedded, fonts, games, gnome, gnu-r, gnustep, graphics,
hamradio, haskell, httpd, interpreters, introspection, java, javascript, kde, kernel, libdevel, libs, lisp, localization, mail,
math, metapackages, misc, net, news, ocaml, oldlibs, otherosfs, perl, php, python, ruby, rust, science, shells, sound, tasks,
tex, text, utils, vcs, video, web, x11, xfce, zope. The additional section debian-installer contains special packages used by
the installer and is not used for normal Debian packages.
For more information about the sections and their definitions, see the list of sections in unstable.
2.5 Priorities
Each package must have a priority value, which is set in the metadata for the Debian archive and is also included in
the package’s control files (see Priority). This information is used to control which packages are included in standard or
minimal Debian installations.
Most Debian packages will have a priority of optional. Priority levels other than optional are only used for packages
that should be included by default in a standard installation of Debian.
The priority of a package is determined solely by the functionality it provides directly to the user. The priority of a
package should not be increased merely because another higher-priority package depends on it; instead, the tools used to
construct Debian installations will correctly handle package dependencies. In particular, this means that C-like libraries
will almost never have a priority above optional, since they do not provide functionality directly to users. However,
as an exception, the maintainers of Debian installers may request an increase of the priority of a package to resolve
installation issues and ensure that the correct set of packages is included in a standard or minimal install.
The following priority levels are recognized by the Debian package management tools.
required
Packages which are necessary for the proper functioning of the system (usually, this means that dpkg functionality
depends on these packages). Removing a required package may cause your system to become totally broken and
you may not even be able to use dpkg to put things back, so only do so if you know what you are doing.
Systems with only the required packages installed have at least enough functionality for the sysadmin to boot the
system and install more software.
important
Important programs, including those which one would expect to find on any Unix-like system. If the expectation
is that an experienced Unix person who found it missing would say “What on earth is going on, where is foo?”,
it must be an important package.6 Other packages without which the system will not run well or be usable
must also have priority important. This does not include Emacs, the X Window System, TeX or any other large
applications. The important packages are just a bare minimum of commonly-expected and necessary tools.
standard
These packages provide a reasonably small but not too limited character-mode system. This is what will be installed
by default if the user doesn’t select anything else. It doesn’t include many large applications.
6 This is an important criterion because we are trying to produce, amongst other things, a free Unix.
2.4. Sections 11
Debian Policy Manual, Release 4.7.2.0
Two packages that both have a priority of standard or higher must not conflict with each other.
optional
This is the default priority for the majority of the archive. Unless a package should be installed by default on
standard Debian systems, it should have a priority of optional. Packages with a priority of optional may
conflict with each other.
extra
This priority is deprecated. Use the optional priority instead. This priority should be treated as equivalent to
optional.
The extra priority was previously used for packages that conflicted with other packages and packages that were
only likely to be useful to people with specialized requirements. However, this distinction was somewhat arbitrary,
not consistently followed, and not useful enough to warrant the maintenance effort.
THREE
BINARY PACKAGES
The Debian distribution is based on the Debian package management system, called dpkg. Thus, all packages in the
Debian distribution must be provided in the .deb file format.
A .deb package contains two sets of files: a set of files to install on the system when the package is installed, and a
set of files that provide additional metadata about the package or which are executed when the package is installed or
removed. This second set of files is called package metadata files. Among those files are the package maintainer scripts
and control, the binary package control file that contains the control fields for the package. Other package metadata
files include symbols or shlibs used to store shared library dependency information and the conffiles file that lists the
package’s configuration files (described in Configuration files).
There is unfortunately a collision of terminology here between control information files and files in the Debian control
file format. Throughout this document, a control file refers to a file in the Debian control file format. These files are
documented in Control files and their fields. Only files referred to specifically as package metadata files are the files
included in the package metadata member (called control.tar) of the .deb file format used by binary packages.
Most package metadata files are not in the Debian control file format.
13
Debian Policy Manual, Release 4.7.2.0
If an upstream package has problematic version numbers they should be converted to a sane form for use in the Version
field.
//alioth-lists.debian.net/.
3.5 Dependencies
Every package must specify the dependency information about other packages that are required for the first to work
correctly.
For example, a dependency entry must be provided for any shared libraries required by a dynamically-linked executable
binary in a package.
2 The detailed procedure for gracefully orphaning a package can be found in the Debian Developer’s Reference (see Related documents).
3 The blurb that comes with a program in its announcements and/or README files is rarely suitable for use in a description. It is usually aimed at
people who are already in the community where the package is used.
Packages are not required to declare any dependencies they have on other packages which are marked Essential (see
below), and should not do so unless they depend on a particular version of that package.4
Sometimes, unpacking one package requires that another package be first unpacked and configured. In this case, the
depending package must specify this dependency in the Pre-Depends control field.
You should not specify a Pre-Depends entry for a package before this has been discussed on the debian-devel mailing
list and a consensus about doing that has been reached.
The format of the package interrelationship control fields is described in Declaring relationships between packages.
the chances that there will be an unresolvable dependency loop caused by forcing these Essential packages to be configured first before they need to be
is greatly increased. It also increases the chances that frontends will be unable to calculate an upgrade path, even if one exists.
Also, functionality is rarely ever removed from the Essential set, but packages have been removed from the Essential set when the functionality
moved to a different package. So depending on these packages just in case they stop being essential does way more harm than good.
Maintainers should take great care in adding any programs, interfaces, or functionality to essential packages. Pack-
ages may assume that functionality provided by essential packages is always available without declaring explicit
dependencies, which means that removing functionality from the Essential set is very difficult and is almost never done.
Any capability added to an essential package therefore creates an obligation to support that capability as part of the
Essential set in perpetuity.
You must not tag any packages essential before this has been discussed on the debian-devel mailing list and a
consensus about doing that has been reached.
All packages which supply an instance of a common command name (or, in general, filename) should generally use
update-alternatives so that they can be installed together. If update-alternatives is not used, then each
package must use Conflicts to ensure that other packages are removed. (In this case, it may be appropriate to specify
a conflict against earlier versions of something that previously did not use update-alternatives; this is an exception
to the usual rule that versioned conflicts should be avoided.)
Diversions are primarily intended as a tool for local administrators and local packages to override the behavior of Debian.
While there are some circumstances where one Debian package may need to divert a file installed by another Debian
package, such circumstances are rare. Maintainers should strongly prefer using other overriding mechanisms, instead of
diversions, whenever those other mechanisms are sufficient to accomplish the same goal. In other words, diversions in
packages should be considered a last resort. Diversion of a file in one Debian package by another Debian package should
be coordinated between the maintainers of those packages.
One specific case of this rule is that configuration files used by systemd components, such as units, udev
rules, tmpfiles.d, modules-load.d, sysusers and other such files, including those specific to systemd daemons (e.g.:
/etc/systemd/system.conf). must not be diverted by any Debian package. Instead, use masking and drop-ins.
Alternatives must not be used for systemd configuration files. The alternatives system does not know how to apply
changes to services when updating alternatives, so the resulting behavior would be confusing and unpredictable. Instead,
aliases can be used to provide alternative implementations of the same named unit.
contains templates used for user prompting. The config script might be run before the preinst script and before the
package is unpacked or any of its dependencies or pre-dependencies are satisfied. Therefore it must work using only the
tools present in essential packages.5
Packages which use the Debian Configuration Management Specification must allow for translation of their user-visible
messages by using a gettext-based system such as the one provided by the po-debconf package.
Packages should try to minimize the amount of prompting they need to do, and they should ensure that the user will only
ever be asked each question once. This means that packages should try to use appropriate shared configuration files (such
as /etc/papersize and /etc/news/server), and shared debconf variables rather than each prompting for their own
list of required pieces of information.
It also means that an upgrade should not ask the same questions again, unless the user has used dpkg --purge to remove
the package’s configuration. The answers to configuration questions should be stored in an appropriate place in /etc so
that the user can modify them, and how this has been done should be documented.
If a package has a vitally important piece of information to pass to the user (such as “don’t run me as I am, you must edit
the following configuration files first or you risk your system emitting badly-formatted messages”), it should display this
in the config or postinst script and prompt the user to hit return to acknowledge the message. Copyright messages
do not count as vitally important (they belong in /usr/share/doc/PACKAGE/copyright); neither do instructions on
how to use a program (these should be in on-line documentation, where all the users can see them).
Any necessary prompting should almost always be confined to the config or postinst script. If it is done in the
postinst, it should be protected with a conditional so that unnecessary prompting doesn’t happen if a package’s instal-
lation fails and the postinst is called with abort-upgrade, abort-remove or abort-deconfigure.
5 Debconf or another tool that implements the Debian Configuration Management Specification will also be installed, and any versioned dependen-
FOUR
SOURCE PACKAGES
A Debian source package contains the source material used to construct one or more binary packages. A source package
consists of a .dsc file (see Debian source package control files – .dsc), one or more compressed tar files, and possibly
other files depending on the type and format of source package. Binary packages are contructed from the source package
via a build process defined by debian/rules and other files in the debian directory of the unpacked source package.
Debian source packages are classified as native or non-native.
A native source package is one that does not distinguish between Debian packaging releases and upstream releases. A
native source package contains a single tar file of source material, and the versioning does not have a Debian-specific
component. Native packages are normally (but not exclusively) used for software that has no independent existence
outside of Debian, such as software written specifically to be a Debian package.
A non-native source package separates the upstream release from the Debian packaging and any Debian-specific changes.
The source in a non-native source package is divided into one or more upstream tar files plus a collection of Debian-specific
files. (Depending on the format of the source package, those Debian-specific files may come in the form of another tar
file or in the form of a compressed diff.) The version of a non-native package has an upstream component and a Debian
component, and there may be multiple Debian package versions associated with a single upstream release version and
sharing the same upstream source tar files.
Most source packages in Debian are non-native.
19
Debian Policy Manual, Release 4.7.2.0
When specifying the set of build-time dependencies, one should list only those packages explicitly required by the build.
It is not necessary to list packages which are required merely because some other package in the list of build-time depen-
dencies depends on them.2
If build-time dependencies are specified, it must be possible to build the package and produce working binaries on a system
with only essential and build-essential packages installed and also those required to satisfy the build-time relationships
(including any implied relationships). In particular, this means that version clauses should be used rigorously in build-time
relationships so that one cannot produce bad or inconsistently configured packages when the relationships are properly
satisfied.
Declaring relationships between packages explains the technical details.
2 The reason for this is that dependencies change, and you should list all those packages, and only those packages that you need directly. What
others need is their business. For example, if you only link against libimlib, you will need to build-depend on libimlib2-dev but not against any
libjpeg* packages, even though libimlib2-dev currently depends on them: installation of libimlib2-dev will automatically ensure that all of its
run-time dependencies are satisfied.
package and version are the source package name and version number.
distribution(s) lists the distributions where this version should be installed when it is uploaded - it is copied to the
Distribution field in the .changes file. See Distribution.
urgency is the value for the Urgency field in the .changes file for the upload (see Urgency). It is not possible to
specify an urgency containing commas; commas are used to separate keyword=value settings in the dpkg changelog
format (though there is currently only one useful keyword, urgency).
The change details may in fact be any series of lines starting with at least two spaces, but conventionally each change
starts with an asterisk and a separating space and continuation lines are indented so as to bring them in line with the start
of the text above. Blank lines may be used here to separate groups of changes, if desired.
If this upload resolves bugs recorded in the Bug Tracking System (BTS), they may be automatically closed on the inclusion
of this package into the Debian archive by including the string: closes: Bug#nnnnn in the change details, where
#nnnnn is the bug number.5 This information is conveyed via the Closes field in the .changes file (see Closes).
The maintainer name and email address used in the changelog should be the details of the person who prepared this
release of the package. They are not necessarily those of the uploader or usual package maintainer.6 The information
here will be copied to the Changed-By field in the .changes file (see Changed-By), and then later used to send an
acknowledgement when the upload has been installed.
The date has the following format7 (compatible and with the same semantics of RFC 2822 and RFC 5322):
3 Mistakes in changelogs are usually best rectified by making a new changelog entry rather than “rewriting history” by editing old changelog entries.
4 Although there is nothing stopping an author who is also the Debian maintainer from using this changelog for all their changes, it will have to be
renamed if the Debian and upstream maintainers become different people. In such a case, however, it might be better to maintain the package as a
non-native package.
5 To be precise, the string should match the following Perl regular expression:
/closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i
That is: The string should consist of the word closes: followed by a comma-separated list of bug numbers. Bug numbers may be preceded by the
word bug and/or a # sign, as in Closes: 42, bug#43, #44, bug 45.
The list of bug numbers may span multiple lines.
All of the bug numbers listed will be closed by the archive maintenance software (dak) using the version of the changelog entry.
The words closes: and bug are not case sensitive.
6 In the case of a sponsored upload, the uploader signs the files, but the changelog maintainer name and address are those of the person who prepared
this release. If the preparer of the release is not one of the usual maintainers of the package (as listed in the Maintainer or Uploaders control fields of
the package), the first line of the changelog is conventionally used to explain why a non-maintainer is uploading the package. The Debian Developer’s
Reference (see Related documents) documents the conventions used.
7 This is the same as the format generated by date -R.
where:
• day-of-week is one of: Mon, Tue, Wed, Thu, Fri, Sat, Sun
• dd is a one- or two-digit day of the month (01-31)
• month is one of: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
• yyyy is the four-digit year (e.g. 2010)
• hh is the two-digit hour (00-23)
• mm is the two-digit minutes (00-59)
• ss is the two-digit seconds (00-60)
• +zzzz or -zzzz is the time zone offset from Coordinated
Universal Time (UTC). “+” indicates that the time is ahead of (i.e., east of) UTC and “-” indicates that the
time is behind (i.e., west of) UTC. The first two digits indicate the hour difference from UTC and the last
two digits indicate the number of additional minutes difference from UTC. The last two digits must be in the
range 00-59.
The first “title” line with the package name must start at the left hand margin. The “trailer” line with the maintainer and
date details must be preceded by exactly one space. The maintainer details and the date must be separated by exactly two
spaces.
The entire changelog must be encoded in UTF-8.
For more information on placement of the changelog files within binary packages, please see Changelog files and release
notes.
This file is often required to contain a verbatim copy of the package’s copyright information, too; see Copyright information
and Copyright considerations for details, and for further considerations related to copyrights for packages.
The recommended way to implement the build process of a Debian package, in the absence of a good reason to use
a different approach, is the dh tool. This includes the contents of the debian/rules building script. dh is the most
common packaging helper tool in Debian. Using it will usually save effort in complying with the rules in this document,
because dh will automatically implement many of them without requiring explicit instructions.
There are sometimes good reasons to use a different approach. For example, the standard tools for packaging software
written in some languages may use another tool; some rarer packaging patterns, such as multiple builds of the same
software with different options, are easier to express with other tools; and a packager working on a different packaging
helper might want to use their tool. The recommendation to use dh does not always apply, and use of dh is not required.
For more information about how to use dh, see the documentation in the debhelper package, most notably the dh(1)
manual page.
The following targets are required and must be implemented by debian/rules: clean, binary, binary-arch,
binary-indep, build, build-arch and build-indep. These are the targets called by dpkg-buildpackage.
Since an interactive debian/rules script makes it impossible to auto-compile that package and also makes it hard for
other people to reproduce the same binary package, all required targets must be non-interactive. It also follows that any
target that these targets depend on must also be non-interactive.
The package build should be as verbose as reasonably possible, except where the terse tag is included in
DEB_BUILD_OPTIONS (see debian/rules and DEB_BUILD_OPTIONS). This makes life easier for porters and bug squash-
ers more generally, who can look at build logs for possible problems. To accomplish this, debian/rules should pass to
the commands it invokes options that cause them to produce verbose output. For example, the build target should pass
--disable-silent-rules to any configure scripts. See also Binaries.
Except for packages in the non-free archive with the Autobuild control field unset or set to no, required targets must
not attempt network access, except, via the loopback interface, to services on the build host that have been started by the
build.
Required targets must not attempt to write outside of the unpacked source package tree. There are two exceptions. Firstly,
the binary targets may write the binary packages to the parent directory of the unpacked source package tree. Secondly,
required targets may write to /tmp, /var/tmp and to the directory specified by the TMPDIR environment variable, but
must not depend on the contents of any of these.
8 The rationale is that there is some information conveyed by knowing the age of the file, for example, you could recognize that some documentation
is very old by looking at the modification time, so it would be nice if the modification time of the upstream source would be preserved.
9 Setgid directories are allowed.
This restriction is intended to prevent source package builds creating and depending on state outside of themselves, thus
affecting multiple independent rebuilds. In particular, the required targets must not attempt to write into HOME.
The targets are as follows:
build (required)
The build target should perform all the configuration and compilation of the package. If a package has an in-
teractive pre-build configuration routine, the Debian source package must either be built after this has taken place
(so that the binary package can be built without rerunning the configuration) or the configuration routine modi-
fied to become non-interactive. (The latter is preferable if there are architecture-specific features detected by the
configuration routine.)
For some packages, notably ones where the same source tree is compiled in different ways to produce two binary
packages, the build target does not make much sense. For these packages it is good enough to provide two (or
more) targets (build-a and build-b or whatever) for each of the ways of building the package, and a build
target that does nothing. The binary target will have to build the package in each of the possible ways and make
the binary package out of each.
The build target must not do anything that might require root privilege.
The build target may need to run the clean target first - see below.
When a package has a configuration and build routine which takes a long time, or when the makefiles are poorly
designed, or when build needs to run clean first, it is a good idea to touch build when the build process is
complete. This will ensure that if debian/rules build is run again it will not rebuild the whole program.10
build-arch (required), build-indep (required)
The build-arch target must perform all the configuration and compilation required for producing all architecture-
dependent binary packages (those packages for which the body of the Architecture field in debian/control
is not all). Similarly, the build-indep target must perform all the configuration and compilation required for
producing all architecture-independent binary packages (those packages for which the body of the Architecture
field in debian/control is all). The build target should either depend on those targets or take the same actions
as invoking those targets would perform.11
The build-arch and build-indep targets must not do anything that might require root privilege.
binary (required), binary-arch (required), binary-indep (required)
The binary target must be all that is necessary for the user to build the binary package(s) produced from this source
package. It is split into two parts: binary-arch builds the binary packages which are specific to a particular
architecture, and binary-indep builds those which are not.
binary may be (and commonly is) a target with no commands which simply depends on binary-arch and
binary-indep.
Both binary-* targets should depend on the build target, or on the appropriate build-arch or build-indep
target, so that the package is built if it has not been already. It should then create the relevant binary package(s),
using dpkg-gencontrol to make their control files and dpkg-deb to build them and place them in the parent
of the top level directory.
Both the binary-arch and binary-indep targets must exist. If one of them has nothing to do (which will
always be the case if the source generates only a single binary package, whether architecture-dependent or not), it
must still exist and must always succeed.
The binary targets may need to be invoked as root depending on the value of the Rules-Requires-Root field.12
10 Another common way to do this is for build to depend on build-stamp and to do nothing else, and for the build-stamp target to do the
building and to touch build-stamp on completion. This is especially useful if the build routine creates a file or directory called build; in such a
case, build will need to be listed as a phony target (i.e., as a dependency of the .PHONY target). See the documentation of make for more information
on phony targets.
11 This split allows binary-only builds to not install the dependencies required for the build-indep target and skip any resource-intensive build
tasks that are only required when building architecture-independent binary packages.
12 The fakeroot package often allows one to build a package correctly even without being root.
clean (required)
This must undo any effects that the build and binary targets may have had, except that it should leave alone any
output files created in the parent directory by a run of a binary target.
If a build file is touched at the end of the build target, as suggested above, it should be removed as the first
action that clean performs, so that running build again after an interrupted clean doesn’t think that everything
is already done.
The clean target may need to be invoked as root if binary has been invoked since the last clean, or if build
has been invoked as root (since build may create directories, for example).
The clean target cannot be used to remove files in the source tree that are not compatible with the DFSG. This
is because the files would remain in the upstream tarball, and thus in the source package, so the source package
would continue to violate DFSG. Instead, the upstream source should be repacked to remove those files.
patch (optional)
This target performs whatever additional actions are required to make the source ready for editing (unpacking
additional upstream archives, applying patches, etc.). It is recommended to be implemented for any package
where dpkg-source -x does not result in source ready for additional modification. See Source package handling:
debian/README.source.
The build, binary and clean targets must be invoked with the current directory being the package’s top-level directory.
Additional targets may exist in debian/rules, either as published or undocumented interfaces or for the package’s
internal use.
The architectures we build on and build for are determined by make variables using the utility dpkg-architecture.
You can determine the Debian architecture and the GNU style architecture specification string for the build architecture
as well as for the host architecture. The build architecture is the architecture on which debian/rules is run and the
package build is performed. The host architecture is the architecture on which the resulting package will be installed and
run. The target architecture is the architecture of the packages that the compiler currently being built will generate. These
are normally the same, but may be different in the case of cross-compilation (building packages for one architecture on
machines of a different architecture), building a cross-compiler (a compiler package that will generate objects for one
architecture, built on a machine of a different architecture) or a Canadian cross-compiler (a compiler that will generate
objects for one architecture, built on a machine of a different architecture, that will run on yet a different architecture).
Here is a list of supported make variables:
• DEB_*_ARCH (the Debian architecture)
• DEB_*_ARCH_CPU (the Debian CPU name)
• DEB_*_ARCH_BITS (the Debian CPU pointer size in bits)
• DEB_*_ARCH_ENDIAN (the Debian CPU endianness)
• DEB_*_ARCH_OS (the Debian System name)
• DEB_*_GNU_TYPE (the GNU style architecture specification string)
• DEB_*_GNU_CPU (the CPU part of DEB_*_GNU_TYPE)
• DEB_*_GNU_SYSTEM (the System part of DEB_*_GNU_TYPE)
where * is either BUILD for specification of the build architecture, HOST for specification of the host architecture or
TARGET for specification of the target architecture.
Backward compatibility can be provided in the rules file by setting the needed variables to suitable default values; please
refer to the documentation of dpkg-architecture for details.
It is important to understand that the DEB_*_ARCH string only determines which Debian architecture we are building
on or for. It should not be used to get the CPU or system information; the DEB_*_ARCH_CPU and DEB_*_ARCH_OS
variables should be used for that. GNU style variables should generally only be used with upstream build systems.
The builder may set DEB_RULES_REQUIRES_ROOT environment variable when calling any of the mandatory targets as
defined in Rules-Requires-Root. If the variable is not set, the package must behave as if it was set to binary-targets.
CFLAGS = -Wall -g
INSTALL = install
INSTALL_FILE = $(INSTALL) -p -o root -g root -m 644
INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 755
(continues on next page)
13 Some packages support any delimiter, but whitespace is the easiest to parse inside a makefile and avoids ambiguity with flag values that contain
commas.
14 Packages built with make can often implement this by passing the -jn option to make.
build:
# ...
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
# Code to run the package test suite.
endif
The gain root command is passed to the build script via the DEB_GAIN_ROOT_CMD environment variable. The contents
of this variable is a space separated list, the first entry of which is the command, and the proceeding entries of which are
arguments to the command. The gain root command must be available via PATH. The gain root command must not rely
on shell features because it will not necessarily be invoked via a shell.
The gain root command must not run interactively, including prompting for any user input. It must be possible to prepend
the gain root command to an existing command and its arguments, without needing to alter or quote the existing command
and its arguments. Furthermore, the gain root command must preserve all environment variables without the caller having
to explicitly request any preservation.
The following are examples of valid gain root commands (in syntax of sh), assuming the tools used are available and
properly configured:
# perl
my @cmd = ('some-cmd', '--which-requires-root');
(continues on next page)
The debian/substvars file is usually generated and modified dynamically by debian/rules targets, in which case
it must be removed by the clean target.
See deb-substvars(5) for full details about source variable substitutions, including the format of debian/
substvars.
4.15 Reproducibility
Packages should build reproducibly, which for the purposes of this document18 means that given
• a version of a source package unpacked at a given path;
• a set of versions of installed build dependencies;
• a set of environment variable values;
• a build architecture; and
• a host architecture,
repeatedly building the source package for the build architecture on any machine of the host architecture with those
versions of the build dependencies installed and exactly those environment variable values set will produce bit-for-bit
identical binary packages.
16 For example, parts of the GNU build system work like this.
17 Having multiple copies of the same code in Debian is inefficient, often creates either static linking or shared library conflicts, and, most importantly,
increases the difficulty of handling security vulnerabilities in the duplicated code.
18 This is Debian’s precisification of the reproducible-builds.org definition.
It is recommended that packages produce bit-for-bit identical binaries even if most environment variables and build paths
are varied. It is intended for this stricter standard to replace the above when it is easier for packages to meet it.
FIVE
The package management system manipulates data represented in a common format, known as control data, stored in
control files. Control files are used for source packages, binary packages and the .changes files which control the
installation of uploaded files.1
The field ends at the end of the line or at the end of the last continuation line (see below). Horizontal whitespace (spaces
and tabs) may occur immediately before or after the value and is ignored there; it is conventional to put a single space
after the colon. For example, a field might be:
Package: libc6
31
Debian Policy Manual, Release 4.7.2.0
lines and must start with a space or a tab. Whitespace, including any newlines, is not significant in the field values
of folded fields.3
multiline
The value of a multiline field may comprise multiple continuation lines. The first line of the value, the part on the
same line as the field name, often has special significance or may have to be empty. Other lines are added following
the same syntax as the continuation lines of the folded fields. Whitespace, including newlines, is significant in the
values of multiline fields.
Whitespace must not appear inside names (of packages, architectures, files or anything else) or version numbers, or
between the characters of multi-character version relationships.
The presence and purpose of a field, and the syntax of its value, may differ between types of control files.
Field names are not case-sensitive, but it is usual to capitalize the field names using mixed case as shown below. Field
values are case-sensitive unless the description of the field says otherwise.
Stanza separators (empty lines), and lines consisting only of U+0020 SPACE and U+0009 TAB, are not allowed within
field values or between fields. Empty lines in field values are usually escaped by representing them by a U+0020 SPACE
followed by a U+002E (.).
Lines starting with U+0023 (#), without any preceding whitespace, are comment lines that are only permitted in source
package control files (debian/control). These comment lines are ignored, even between two continuation lines. They
do not end logical lines.
All control files must be encoded in UTF-8.
• Package (mandatory)
• Architecture (mandatory)
• Section (recommended)
• Priority (recommended)
• Essential
• Depends et al
• Description (mandatory)
• Homepage
• Built-Using
• Package-Type
The syntax and semantics of the fields are described below.
These fields are used by dpkg-gencontrol to generate control files for binary packages (see below), by
dpkg-genchanges to generate the .changes file to accompany the upload, and by dpkg-source when it creates
the .dsc source control file as part of a source archive. Some fields are folded in debian/control, but not in any other
control file. These tools are responsible for removing the line breaks from such fields when using fields from debian/
control to generate other control files. They are also responsible for discarding empty fields.
The fields here may contain variable references - their values will be substituted by dpkg-gencontrol,
dpkg-genchanges or dpkg-source when they generate output control files. See Variable substitutions: de-
bian/substvars for details.
.changes files have a format version that is incremented whenever the documented fields or their meaning change. This
document describes format 1.8.
The fields in this file are:
• Format (mandatory)
• Date (mandatory)
• Source (mandatory)
• Binary (mandatory in some cases)
• Architecture (mandatory)
• Version (mandatory)
• Distribution (mandatory)
• Urgency (recommended)
• Maintainer (mandatory)
• Changed-By
• Description (mandatory in some cases)
• Closes
• Changes (mandatory)
• Checksums-Sha1 and Checksums-Sha256 (mandatory)
• Files (mandatory)
5.6.2 Maintainer
The package maintainer’s name and email address. The name must come first, then the email address inside angle brackets
<> (in RFC822 format).
If the maintainer’s name contains a full stop then the whole field will not work directly as an email address due to a
misfeature in the syntax specified in RFC822; a program using this field as an address must check for this and correct
the problem if necessary (for example by putting the name in round brackets and moving it to the end, and bringing the
email address forward).
See The maintainer of a package for additional requirements and information about package maintainers.
5.6.3 Uploaders
List of the names and email addresses of co-maintainers of the package, if any. If the package has other maintainers
besides the one named in the Maintainer field, their names and email addresses should be listed here. The format of each
entry is the same as that of the Maintainer field, and multiple entries must be comma separated.
This is normally an optional field, but if the Maintainer control field names a group of people and a shared email
address, the Uploaders field must be present and must contain at least one human with their personal email address.
The Uploaders field in debian/control can be folded.
4 It is customary to leave a space after the package name if a version number is specified.
5.6.4 Changed-By
The name and email address of the person who prepared this version of the package, usually a maintainer. The syntax is
the same as for the Maintainer field.
5.6.5 Section
This field specifies an application area into which the package has been classified. See Sections.
When it appears in the debian/control file, it gives the value for the subfield of the same name in the Files field of
the .changes file. It also gives the default for the same field in the binary packages.
5.6.6 Priority
This field represents how important it is that the user have the package installed. See Priorities.
When it appears in the debian/control file, it gives the value for the subfield of the same name in the Files field of
the .changes file. It also gives the default for the same field in the binary packages.
5.6.7 Package
The name of the binary package.
Binary package names must follow the same syntax and restrictions as source package names. See Source for the details.
5.6.8 Architecture
Depending on context and the control file used, the Architecture field can include the following sets of values:
• A unique single word identifying a Debian machine architecture as described in Architecture specification strings.
• An architecture wildcard identifying a set of Debian machine architectures, see Architecture wildcards. any
matches all Debian machine architectures and is the most frequently used.
• all, which indicates an architecture-independent package.
• source, which indicates a source package.
In the main debian/control file in the source package, this field may contain the special value all, the special archi-
tecture wildcard any, or a list of specific and wildcard architectures separated by spaces. If all or any appears, that
value must be the entire contents of the field. Most packages will use either all or any.
Specifying a specific list of architectures indicates that the source will build an architecture-dependent package only
on architectures included in the list. Specifying a list of architecture wildcards indicates that the source will build an
architecture-dependent package on only those architectures that match any of the specified architecture wildcards. Spec-
ifying a list of architectures or architecture wildcards other than any is for the minority of cases where a program is not
portable or is not useful on some architectures. Where possible, the program should be made portable instead.
In the Debian source package control file .dsc, this field contains a list of architectures and architecture wildcards
separated by spaces. When the list contains the architecture wildcard any, the only other value allowed in the list is all.
The list may include (or consist solely of) the special value all. In other words, in .dsc files unlike the debian/
control, all may occur in combination with specific architectures. The Architecture field in the Debian source
package control file .dsc is generally constructed from the Architecture fields in the debian/control in the source
package.
Specifying only any indicates that the source package isn’t dependent on any particular architecture and should compile
fine on any one. The produced binary package(s) will be specific to whatever the current build architecture is.
Specifying only all indicates that the source package will only build architecture-independent packages.
Specifying any all indicates that the source package isn’t dependent on any particular architecture. The set of produced
binary packages will include at least one architecture-dependent package and one architecture-independent package.
Specifying a list of architectures or architecture wildcards indicates that the source will build an architecture-dependent
package, and will only work correctly on the listed or matching architectures. If the source package also builds at least
one architecture-independent package, all will also be included in the list.
In a .changes file, the Architecture field lists the architecture(s) of the package(s) currently being uploaded. This
will be a list; if the source for the package is also being uploaded, the special entry source is also present. all will
be present if any architecture-independent packages are being uploaded. Architecture wildcards such as any must never
occur in the Architecture field in the .changes file.
See Main building script: debian/rules for information on how to get the architecture for the build process.
5.6.9 Essential
This is a boolean field which may occur only in the control file of a binary package or in a binary package stanza of a
source package template control file.
If set to yes then the package management system will refuse to remove the package (upgrading and replacing it is still
possible). The other possible value is no, which is the same as not having the field at all.
5.6.11 Standards-Version
The most recent version of the standards (the policy manual and associated texts) with which the package complies. See
Standards conformance.
The version number has four components: major and minor version number and major and minor patch level. When the
standards change in a way that requires every package to change the major number will be changed. Significant changes
that will require work in many packages will be signaled by a change to the minor number. The major patch level will
be changed for any change to the meaning of the standards, however small; the minor patch level will be changed when
only cosmetic, typographical or other edits are made which neither change the meaning of the document nor affect the
contents of packages.
Thus only the first three components of the policy version are significant in the Standards-Version control field, and so
either these three components or all four components may be specified.5
udebs and source packages that only produce udebs do not use Standards-Version.
5.6.12 Version
The version number of a package. The format is: [epoch:]upstream_version[-debian_revision].
The three components here are:
epoch
This is a single (generally small) unsigned integer. It may be omitted, in which case zero is assumed.
Epochs can help when the upstream version numbering scheme changes, but they must be used with care. You
should not change the epoch, even in experimental, without getting consensus on debian-devel first.
5 In the past, people specified the full version number in the Standards-Version field, for example “2.3.0.0”. Since minor patch-level changes don’t
introduce new policy, it was thought it would be better to relax policy and only require the first 3 components to be specified, in this example “2.3.0”.
All four components may still be used if someone wishes to do so.
upstream_version
This is the main part of the version number. It is usually the version number of the original (“upstream”) package
from which the .deb file has been made, if this is applicable. Usually this will be in the same format as that
specified by the upstream author(s); however, it may need to be reformatted to fit into the package management
system’s format and comparison scheme.
The comparison behavior of the package management system with respect to the upstream_version is described
below. The upstream_version portion of the version number is mandatory.
The upstream_version must contain only alphanumerics6 and the characters . + - ~ (full stop, plus, hyphen,
tilde) and should start with a digit. If there is no debian_revision then hyphens are not allowed.
debian_revision
This part of the version number specifies the version of the Debian package based on the upstream version. It must
contain only alphanumerics and the characters + . ~ (plus, full stop, tilde) and is compared in the same way as the
upstream_version is.
Epochs are also not intended to cope with version numbers containing strings of letters which the package management
system cannot interpret (such as ALPHA or pre-), or with silly orderings.8
2. For stable updates to a new upstream version that is based on a newer unstable package, the de-
bian_revision component will end in ~debNuX. The portion before that string will be the unstable version
on which the package is based.
3. If a stable update is based on a new upstream version but is not based on a newer unstable package, the
convention is to form the version number by taking the upstream version, appending -0, and then appending
+debNuX (so the debian_revision component will be 0+debNuX).
In all cases, these versions are chosen so that they will sort earlier than a subsequent unstable package of the same
upstream version and thus that the stable package will upgrade to a newer version during a subsequent system
upgrade.
For example, suppose Debian 10 released with a package with version 1.4-5. If that package later receives a stable
update in Debian 10 that uses the same upstream version, the first update would have the version 1.4-5+deb10u1.
A subsequent update would have version 1.4-5+deb10u2.
If instead the package receives a stable update based on a 1.5-1 unstable package, the first such stable update
would have the version 1.5-1~deb10u1 and a subsequent update would have the version 1.5-1~deb10u2.
8 The author of this manual has heard of a package whose versions went 1.1, 1.2, 1.3, 1, 2.1, 2.2, 2 and so forth.
If there were no unstable 1.5-1 package, but there were a stable update to an upstream 1.5 release, the first such
stable update would have the version 1.5-0+deb10u1.
• upstream_version components in native packages ending in +debNuX indicate a stable update. This is a version
of the package uploaded directly to a stable release, and the version is chosen to sort before any later version of the
package uploaded to Debian’s unstable or a later stable distribution. As with non-native packages, N is the major
version number of the Debian stable release to which the package was uploaded, and X is a number, starting at 1,
that is increased for each stable upload of this package.
For example, suppose Debian 10 released with a package with version 1.4. The first stable update of that package
would have the version 1.4+deb10u1, and a subsequent update would have the version 1.4+deb10u2. These
versions are chosen to sort before 1.5 (the next unstable version) or 1.4+deb11u1 (a stable update to a subsequent
Debian 11 release).
Backports:
• upstream_version components in native packages or debian_revision components in non-native packages
ending in ~bpoNuX indicate a backport of a version of the package to an older stable release. The part of the
version before ~bpo is the version of the package being backported, N is the major version number of the Debian
stable release to which the package was backported, and X is a number, starting at 1, that is increased for each
revision of the backport of that package version. The rationale is the same as for stable updates, with the additional
goal of ensuring a backported version sorts earlier than a stable update with the same upstream version.
Be aware that the stable update and backport conventions can stack. If, for example, Debian 10 contains a package
with version 1.4-5+deb10u1 and that package is backported to Debian 9, the version of the Debian 9 backport
would be 1.4-5+deb10u1~bpo9u1 (although this scenario is rare).
This list of version conventions is not exhaustive.
5.6.13 Description
In a source template control file or binary control file, the Description field contains a description of the binary
package, consisting of two parts, the synopsis or the short description, and the long description. It is a multiline field with
the following format:
In a .changes file, the Description field contains a summary of the descriptions of the binary packages being up-
loaded. If no binary packages are being uploaded, this field will not be present.
When used inside a .changes file, the Description field has a different format than in source or binary control files.
It is a multiline field with one line per binary package. The first line of the field value (the part on the same line as
Description:) is always empty. Each subsequent line is indented by one space and contains the name of a binary
package, a space, a hyphen (-), a space, and the short description line from that package.
5.6.14 Distribution
In a .changes file or parsed changelog output this contains the (space-separated) name(s) of the distribution(s) where this
version of the package should be installed. Valid distributions are determined by the archive maintainers.10 The Debian
archive software only supports listing a single distribution. Migration of packages to other distributions is handled outside
of the upload process.
5.6.15 Date
This field includes the date the package was built or last edited. It must be in the same format as the date in a debian/
changelog entry.
The value of this field is usually extracted from the debian/changelog file - see Debian changelog: debian/changelog).
5.6.16 Format
In .changes files, this field declares the format version of that file. The syntax of the field value is the same as that of
a package version number except that no epoch or Debian revision is allowed. The format described in this document is
1.8.
In .dsc Debian source control files, this field declares the format of the source package. The field value is used by
programs acting on a source package to interpret the list of files in the source package and determine how to unpack it.
The syntax of the field value is a numeric major revision, a period, a numeric minor revision, and then an optional subtype
after whitespace, which if specified is an alphanumeric word in parentheses. The subtype is optional in the syntax but
may be mandatory for particular source format revisions.11
5.6.17 Urgency
This is a description of how important it is to upgrade to this version from previous ones. It consists of a single keyword
taking one of the values low, medium, high, emergency, or critical12 (not case-sensitive) followed by an optional
commentary (separated by a space) which is usually in parentheses. For example:
The value of this field is usually extracted from the debian/changelog file - see Debian changelog: debian/changelog.
10 Example distribution names in the Debian archive used in .changes files are:
unstable
This distribution value refers to the developmental part of the Debian distribution tree. Most new packages, new upstream versions of packages
and bug fixes go into the unstable directory tree.
experimental
The packages with this distribution value are deemed by their maintainers to be high risk. Oftentimes they represent early beta or developmental
packages from various sources that the maintainers want people to try, but are not ready to be a part of the other parts of the Debian distribution
tree.
Others are used for updating stable releases or for security uploads. More information is available in the Debian Developer’s Reference, section “The
Debian archive”.
11 The source formats currently supported by the Debian archive software are 1.0, 3.0 (native), and 3.0 (quilt).
12 Other urgency values are supported with configuration changes in the archive software but are not used in Debian. The urgency affects how quickly
a package will be considered for inclusion into the testing distribution and gives an indication of the importance of any fixes included in the upload.
Emergency and critical are treated as synonymous.
5.6.18 Changes
This multiline field contains the human-readable changes data, describing the differences between the last version and the
current one.
The first line of the field value (the part on the same line as Changes:) is always empty. The content of the field is
expressed as continuation lines, with each line indented by at least one space. Blank lines must be represented by a line
consisting only of a space and a full stop (.).
The value of this field is usually extracted from the debian/changelog file - see Debian changelog: debian/changelog.
Each version’s change information should be preceded by a “title” line giving at least the version, distribution(s) and
urgency, in a human-readable way.
If data from several versions is being returned the entry for the most recent version should be returned first, and entries
should be separated by the representation of a blank line (the “title” line may also be followed by the representation of a
blank line).
5.6.19 Binary
This folded field is a list of binary packages. Its syntax and meaning varies depending on the control file in which it
appears.
When it appears in the .dsc file, it lists binary packages which a source package can produce, separated by commas13 .
The source package does not necessarily produce all of these binary packages for every architecture. The source control
file doesn’t contain details of which architectures are appropriate for which of the binary packages.
When it appears in a .changes file, it lists the names of the binary packages being uploaded, separated by whitespace
(not commas). If no binary packages are being uploaded, this field will not be present.
5.6.20 Installed-Size
This field appears in the binary package control files, and in the Packages files. It gives an estimate of the total amount
of disk space required to install the named package. Actual installed size may vary based on block size, file system
properties, or actions taken by package maintainer scripts.
The disk space is given as the accumulated size of each regular file and symlink rounded to 1 KiB used units, and a
baseline of 1 KiB for any other filesystem object type.
5.6.21 Files
This field contains a list of files with information about each one. The exact information and syntax varies with the context.
In all cases, Files is a multiline field. The first line of the field value (the part on the same line as Files:) is always
empty. The content of the field is expressed as continuation lines, one line per file. Each line must be indented by one
space and contain a number of sub-fields, separated by spaces, as described below.
In the .dsc file, each line contains the MD5 checksum, size and filename of the tar file and (if applicable) diff file which
make up the remainder of the source package.14 For example:
Files:
c6f698f19f2a2aa07dbb9bbda90a2754 571925 example_1.2.orig.tar.gz
938512f08422f3509ff36f125f5873ba 6220 example_1.2-1.diff.gz
The exact forms of the filenames are described in Source packages as archives.
In the .changes file this contains one line per file being uploaded. Each line contains the MD5 checksum, size, section
and priority and the filename. For example:
13 A space after each comma is conventional.
14 That is, the parts which are not the .dsc.
Files:
4c31ab7bfc40d3cf49d7811987390357 1428 text extra example_1.2-1.dsc
c6f698f19f2a2aa07dbb9bbda90a2754 571925 text extra example_1.2.orig.tar.gz
938512f08422f3509ff36f125f5873ba 6220 text extra example_1.2-1.diff.gz
7c98fe853b3bbb47a00e5cd129b6cb56 703542 text extra example_1.2-1_i386.deb
The section and priority are the values of the corresponding fields in the source template control file. If no section or
priority is specified then - should be used, though section and priority values must be specified for new packages to be
installed properly.
The special value byhand for the section in a .changes file indicates that the file in question is not an ordinary package
file and must be installed by hand by the distribution maintainers. If the section is byhand the priority should be -.
If a new Debian revision of a package is being shipped and no new original source archive is being distributed the .dsc
must still contain the Files field entry for the original source archive package_upstream-version.orig.tar.gz,
but the .changes file should leave it out. In this case the original source archive on the distribution site must match
exactly, byte-for-byte, the original source archive which was used to generate the .dsc file and diff which are being
uploaded.
5.6.22 Closes
A space-separated list of bug report numbers that the upload governed by the .changes file closes.
5.6.23 Homepage
The URL of the web site for this package, preferably (when applicable) the site from which the original source can be
obtained and any additional upstream documentation or information may be found. The content of this field is a simple
URL without any surrounding characters such as <>.
Checksums-Sha1:
1f418afaa01464e63cc1ee8a66a05f0848bd155c 1276 example_1.0-1.dsc
a0ed1456fad61116f868b1855530dbe948e20f06 171602 example_1.0.orig.tar.gz
5e86ecf0671e113b63388dac81dd8d00e00ef298 6137 example_1.0-1.debian.tar.gz
71a0ff7da0faaf608481195f9cf30974b142c183 548402 example_1.0-1_i386.deb
Checksums-Sha256:
ac9d57254f7e835bed299926fd51bf6f534597cc3fcc52db01c4bffedae81272 1276 example_1.0-1.
,→dsc
In the .dsc file, these fields list all files that make up the source package. In the .changes file, these fields list all files
being uploaded. The list of files in these fields must match the list of files in the Files field.
5.6.25 DM-Upload-Allowed
Obsolete, see below.
where the portions enclosed in brackets are optional and the portions enclosed in double quotes are literal strings.
<url> indicates the repository. If the <branch> portion is present, it names a branch in the indicated repository.
If no branch is specified, the packaging should be on the default branch. If the <path> portion is present, it
specifies the relative path to the top of the packaging tree (the parent directory of the debian directory). If no
path is specified, it defaults to . (the top level of the indicated repository and branch).
For example:
indicates a subdirectory named p/package in the debian branch of the repository at https://example.org/
repo.
In the case of Mercurial, the value must have the following syntax:
This is interpreted the same way as the Git syntax except a path within the repository is not supported.
A package control file must not have more than one Vcs-<type> field. If the package is maintained in multiple
version control systems, the maintainer should specify the one that they would prefer other people to use as the
basis for proposing changes to the package.
For both fields, any URLs given should use a scheme that provides confidentiality (https, for example, rather than http
or git) if the VCS repository supports it.
5.6.27 Package-List
Multiline field listing all the packages that can be built from the source package, considering every architecture. The
first line of the field value is empty. Each one of the next lines describes one binary package, by listing its name, type,
section and priority separated by spaces. Fifth and subsequent space-separated items may be present and parsers must
allow them. See the Package-Type field for a list of package types.
5.6.28 Package-Type
Simple field containing a word indicating the type of package: deb for binary packages and udeb for micro binary
packages. Other types not defined here may be indicated. In source package template control files, the Package-Type
field should be omitted instead of giving it a value of deb, as this value is assumed for stanzas lacking this field.
5.6.29 Dgit
Folded field containing a single git commit hash, presented in full, followed optionally by whitespace and other data to
be defined in future extensions.
Declares that the source package corresponds exactly to a referenced commit in a Git repository available at the canonical
location called dgit-repos, used by dgit, a bidirectional gateway between the Debian archive and Git. The commit is
reachable from at least one reference whose name matches refs/dgit/*. See the manual page of dgit for further
details.
5.6.30 Testsuite
Simple field containing a comma-separated list of values allowing test execution environments to discover packages which
provide tests.
This field is automatically added to Debian source control files (.dsc) by dpkg, with the value autopkgtest, when a
debian/tests/control file is present in the source package. This field may also be used in source package template
control files (debian/control) if needed in other situations.
5.6.31 Rules-Requires-Root
Simple field that defines if the source package requires access to root (or fakeroot) during selected targets in the Main
building script: debian/rules.
The field can consist of exactly one of the following three items:
• no (default): Declares that neither root nor fakeroot is required. Package builders (e.g. dpkg-buildpackage) may
choose to invoke any target in debian/rules with an unprivileged user.
• binary-targets (previous default): Declares that the package will need the root (or fakeroot) when either of
the binary, binary-arch or binary-indep targets are called. This is how every tool behaved before this field
was defined.
• A space separated list of keywords described below. These keywords must always contain a forward slash, which
sets them apart from the other possible values of Rules-Requires-Root. When this list is provided, the builder
must provide a “gain root command” (as defined in debian/rules and Rules-Requires-Root) or pretend that the value
was set to binary-targets, and both the builder and the package’s debian/rules script must downgrade
accordingly (see below).
The default depends on the dpkg-build-api level (see dpkg-build-api(7)). If the dpkg-build-api level is undeclared, it is
equivalent to level 0.
If the package builder supports the Rules-Requires-Root field and wants to enable the feature, then it must set the
environment variable DEB_RULES_REQUIRES_ROOT when invoking the package building script debian/rules. The
value of DEB_RULES_REQUIRES_ROOT should be one of:
• The value of Rules-Requires-Root if the builder can support that value. The builder may trim unnecessary
whitespace used to format the field for readability.
• The value binary-targets if it cannot support the value of Rules-Requires-Root.
A compliant builder may also leave DEB_RULES_REQUIRES_ROOT unset or set it to binary-targets if it has been
requested to test whether the package it builds correctly implements the fall-back for legacy builders.
5.6.31.1 Remarks
All packages and builders must support binary-targets as this was the historical behaviour prior to the introduction
of this field.
Any tool (particularly older versions of them) may be unaware of this field and behave like the field was set to
binary-targets. The package build must gracefully cope with this and produce a semantically equivalent result.
This field intentionally does not enable a package to request a true root over fakeroot.
This list is intentionally incomplete. You should consult the documentation of the tool or package in question for which
keywords it defines and when they are needed.
then the binary and Debian source control files will contain the field
5.8.1 DM-Upload-Allowed
Indicates that Debian Maintainers may upload this package to the Debian archive. The only valid value is yes. This
field was used to regulate uploads by Debian Maintainers, See the General Resolution Endorse the concept of Debian
Maintainers for more details.
SIX
49
Debian Policy Manual, Release 4.7.2.0
new-preinst install
new-preinst install old-version new-version
new-preinst upgrade old-version new-version
The package will not yet be unpacked, so the preinst script cannot rely on any files included in its pack-
age. Only essential packages and pre-dependencies (Pre-Depends) may be assumed to be available. Pre-
dependencies will have been configured at least once, but at the time the preinst is called they may only
be in an “Unpacked” or “Half-Configured” state if a previous version of the pre-dependency was completely
configured and has not been removed since then.
old-preinst abort-upgrade new-version
Called during error handling of an upgrade that failed after unpacking the new package because the postrm
upgrade action failed. The unpacked files may be partly from the new version or partly missing, so the script
cannot rely on files included in the package. Package dependencies may not be available. Pre-dependencies will
be at least “Unpacked” following the same rules as above, except they may be only “Half-Installed” if an upgrade
of the pre-dependency failed.2
The postinst script may be called in the following ways:
postinst configure most-recently-configured-version
The files contained in the package will be unpacked. All package dependencies will at least be “Unpacked”. If
there are no circular dependencies involved, all package dependencies will be configured. For behavior in the case
of circular dependencies, see the discussion in Binary Dependencies - Depends, Recommends, Suggests, Enhances,
Pre-Depends.
The files contained in the package will be unpacked. All package dependencies will at least be “Half-
Installed” and will have previously been configured and not removed. However, dependencies may not be
configured or even fully unpacked in some error situations.3 The postinst should still attempt any actions
for which its dependencies are required, since they will normally be available, but consider the correct error
handling approach if those actions fail. Aborting the postinst action if commands or facilities from the
package dependencies are not available is often the best approach.
The prerm script may be called in the following ways:
prerm remove
old-prerm upgrade new-version
conflictor's-prerm remove in-favour package new-version
deconfigured's-prerm deconfigure in-favour package-being-installed version [removing conflicting-package
version]
The package whose prerm is being called will be at least “Half-Installed”. All package dependencies will at
least be “Half-Installed” and will have previously been configured and not removed. If there was no error,
all dependencies will at least be “Unpacked”, but these actions may be called in various error states where
dependencies are only “Half-Installed” due to a partial upgrade.
new-prerm failed-upgrade old-version new-version
Called during error handling when prerm upgrade fails. The new package will not yet be unpacked, and all the
same constraints as for preinst upgrade apply.
The postrm script may be called in the following ways:
postrm remove
postrm purge
old-postrm upgrade new-version
disappearer's-postrm disappear overwriter overwriter-version
The postrm script is called after the package’s files have been removed or replaced. The package whose
postrm is being called may have previously been deconfigured and only be “Unpacked”, at which point
subsequent package changes do not consider its dependencies. Therefore, all postrm actions must only rely
on essential packages and must gracefully skip any actions that require the package’s dependencies if those
dependencies are unavailable.4
new-postrm failed-upgrade old-version new-version
Called when the old postrm upgrade action fails. The new package will be unpacked, but only essential packages
3 For example, suppose packages foo and bar are “Installed” with foo depending on bar. If an upgrade of bar were started and then aborted, and
then an attempt to remove foo failed because its prerm script failed, foo’s postinst abort-remove would be called with bar only “Half-Installed”.
4 This is often done by checking whether the command or facility the postrm intends to call is available before calling it. For example:
and pre-dependencies can be relied on. Pre-dependencies will either be configured or will be “Unpacked” or “Half-
Configured” but previously had been configured and was never removed.
new-postrm abort-install
new-postrm abort-install old-version new-version
new-postrm abort-upgrade old-version new-version
Called before unpacking the new package as part of the error handling of preinst failures. May assume
the same state as preinst can assume.
b. If the script runs but exits with a non-zero exit status, dpkg will attempt:
new-prerm failed-upgrade old-version new-version
If this works, the upgrade continues. If this does not work, the error unwind:
old-postinst abort-upgrade new-version
If this works, then the old-version is “Installed”, if not, the old version is in a “Half-Configured” state.
2. If a “conflicting” package is being removed at the same time, or if any package will be broken (due to Breaks):
a. If --auto-deconfigure is specified, call, for each package to be deconfigured due to Breaks:
deconfigured's-prerm deconfigure \
in-favour package-being-installed version
Error unwind:
deconfigured's-postinst abort-deconfigure \
in-favour package-being-installed-but-failed version
The deconfigured packages are marked as requiring configuration, so that if --install is used they will be
configured again if possible.
b. If any packages depended on a conflicting package being removed and --auto-deconfigure is specified,
call, for each such package:
deconfigured's-prerm deconfigure \
in-favour package-being-installed version \
removing conflicting-package version
Error unwind:
5 See Maintainer script flowcharts for flowcharts illustrating the processes described here.
deconfigured's-postinst abort-deconfigure \
in-favour package-being-installed-but-failed version \
removing conflicting-package version
The deconfigured packages are marked as requiring configuration, so that if --install is used they will be
configured again if possible.
c. To prepare for removal of each conflicting package, call:
conflictor's-prerm remove \
in-favour package new-version
Error unwind:
conflictor's-postinst abort-remove \
in-favour package new-version
Error unwind:
new-postrm abort-install old-version new-version
If this fails, the package is left in a “Half-Installed” state, which requires a reinstall. If it works, the packages
is left in a “Config-Files” state.
c. Otherwise (i.e., the package was completely purged):
new-preinst install
Error unwind:
new-postrm abort-install
If the error-unwind fails, the package is in a “Half-Installed” phase, and requires a reinstall. If the error
unwind works, the package is in the “Not-Installed” state.
4. The new package’s files are unpacked, overwriting any that may be on the system already, for example any from
the old version of the same package or from another package. Backups of the old files are kept temporarily, and if
anything goes wrong the package management system will attempt to put them back as part of the error unwind.
It is an error for a package to contain files which are on the system in another package, unless Replaces is used
(see Overwriting files and replacing packages - Replaces).
It is a more serious error for a package to contain a plain file or other kind of non-directory where another
package has a directory (again, unless Replaces is used). This error can be overridden if desired using
--force-overwrite-dir, but this is not advisable.
Packages which overwrite each other’s files produce behavior which, though deterministic, is hard for the system
administrator to understand. It can easily lead to “missing” programs if, for example, a package is unpacked which
overwrites a file from another package, and is then removed again.6
A directory will never be replaced by a symbolic link to a directory or vice versa; instead, the existing state (symlink
or not) will be left alone and dpkg will follow the symlink if there is one.
5. If the package is being upgraded:
a. Call:
old-postrm upgrade new-version
If this fails, the old version is left in a “Half-Installed” state. If it works, dpkg now calls:
new-postrm abort-upgrade old-version new-version
If this fails, the old version is left in a “Half-Installed” state. If it works, dpkg now calls:
old-postinst abort-upgrade new-version
12. The new package’s status is now sane, and recorded as “Unpacked”.
Here is another point of no return: if the conflicting package’s removal fails we do not unwind the rest of the
installation. The conflicting package is left in a half-removed limbo.
13. If there was a conflicting package we go and do the removal actions (described below), starting with the removal
of the conflicting package’s files (any that are also in the package being unpacked have already been removed from
the conflicting package’s file list, and so do not get removed now).
No attempt is made to unwind after errors during configuration. If the configuration fails, the package is in a “Half-
Configured” state, and an error message is generated.
If there is no most recently configured version dpkg will pass a null argument.7
Or else we call:
postinst abort-remove
7 Historical note: Truly ancient (pre-1997) versions of dpkg passed <unknown> (including the angle brackets) in this case. Even older ones did
not pass a second argument at all, under any circumstance. Note that upgrades using such an old dpkg version are unlikely to work for other reasons,
even if this old argument behavior is handled by your postinst script.
SEVEN
Package: mutt
Version: 1.3.17-1
Depends: libc6 (>= 2.2.1), default-mta | mail-transport-agent
Relationships may be restricted to a certain set of architectures. This is indicated in brackets after each individual package
name and the optional version specification. The brackets enclose a non-empty list of Debian architecture names in the
format described in Architecture specification strings, separated by whitespace. Exclamation marks may be prepended to
each of the names. (It is not permitted for some names to be prepended with exclamation marks while others aren’t.)
For build relationship fields (Build-Depends, Build-Depends-Indep, Build-Depends-Arch,
Build-Conflicts, Build-Conflicts-Indep and Build-Conflicts-Arch), if the current Debian host
architecture is not in this list and there are no exclamation marks in the list, or it is in the list with a prepended
exclamation mark, the package name and the associated version specification are ignored completely for the purposes of
defining the relationships.
1 The relations < and > were previously allowed, but they were confusingly defined to mean earlier/later or equal rather than strictly earlier/later.
dpkg still supports them with a warning, but they are no longer allowed by Debian Policy.
57
Debian Policy Manual, Release 4.7.2.0
For example:
Source: glibc
Build-Depends-Indep: texinfo
Build-Depends: kernel-headers-2.2.10 [!hurd-i386],
hurd-dev [hurd-i386], gnumach-dev [hurd-i386]
requires kernel-headers-2.2.10 on all architectures other than hurd-i386 and requires hurd-dev and
gnumach-dev only on hurd-i386. Here is another example showing multiple architectures separated by spaces:
Build-Depends:
libluajit5.1-dev [i386 amd64 kfreebsd-i386 armel armhf powerpc mips],
liblua5.1-dev [hurd-i386 ia64 kfreebsd-amd64 s390x sparc],
For binary relationship fields and the Built-Using field, the architecture restriction syntax is only supported in the
source package template control file debian/control. When the corresponding binary package control file is generated,
the relationship will either be omitted or included without the architecture restriction based on the architecture of the
binary package. This means that architecture restrictions must not be used in binary relationship fields for architecture-
independent packages (Architecture: all).
For example:
becomes Depends: foo when the package is built on the i386 architecture, Depends: bar when the package is
built on the amd64 architecture, and omitted entirely in binary packages built on all other architectures.
If the architecture-restricted dependency is part of a set of alternatives using |, that alternative is ignored completely on
architectures that do not match the restriction. For example:
is equivalent to bar on the i386 architecture, to foo on the amd64 architecture, and to foo | bar on all other
architectures.
Relationships may also be restricted to a certain set of architectures using architecture wildcards in the format described
in Architecture wildcards. The syntax for declaring such restrictions is the same as declaring restrictions using a certain
set of architectures without architecture wildcards. For example:
is equivalent to foo on architectures using the Linux kernel and any cpu, bar on architectures using any kernel and an
i386 cpu, and baz on any architecture using a kernel other than Linux.
Note that the binary package relationship fields such as Depends appear in one of the binary package stanzas of the
template control file, whereas the build-time relationships such as Build-Depends appear in the source package stanza
of the template control file (which is the first section).
The Depends field should be used if the depended-on package is required for the depending package to provide a
significant amount of functionality.
The Depends field should also be used if the postinst or prerm scripts require the depended-on package to
be unpacked or configured in order to run. In the case of postinst configure, the depended-on packages
will be unpacked and configured first. (If both packages are involved in a dependency loop, this might not work
as expected; see the explanation a few paragraphs back.) In the case of prerm or other postinst actions, the
package dependencies will normally be at least unpacked, but they may be only “Half-Installed” if a previous
upgrade of the dependency failed.
Finally, the Depends field should be used if the depended-on package is needed by the postrm script to fully clean
up after the package removal. There is no guarantee that package dependencies will be available when postrm is
run, but the depended-on package is more likely to be available if the package declares a dependency (particularly
in the case of postrm remove). The postrm script must gracefully skip actions that require a dependency if that
dependency isn’t available.
Recommends
This declares a strong, but not absolute, dependency.
The Recommends field should list packages that would be found together with this one in all but unusual installa-
tions.
2 This approach makes dependency resolution easier. If two packages A and B are being upgraded, the installed package A depends on exactly the
installed package B, and the new package A depends on exactly the new package B (a common situation when upgrading shared libraries and their
corresponding development packages), satisfying the dependencies at every stage of the upgrade would be impossible. This relaxed restriction means
that both new packages can be unpacked together and then configured in their dependency order.
Suggests
This is used to declare that one package may be more useful with one or more others. Using this field tells the
packaging system and the user that the listed packages are related to this one and can perhaps enhance its usefulness,
but that installing this one without them is perfectly reasonable.
Enhances
This field is similar to Suggests but works in the opposite direction. It is used to declare that a package can enhance
the functionality of another package.
Pre-Depends
This field is like Depends, except that it also forces dpkg to complete installation of the packages named before
even starting the installation of the package which declares the pre-dependency, as follows:
When a package declaring a pre-dependency is about to be unpacked the pre-dependency can be satisfied if the
depended-on package is either fully configured, or even if the depended-on package(s) are only in the “Unpacked”
or the “Half-Configured” state, provided that they have been configured correctly at some point in the past (and
not removed or partially removed since). In this case, both the previously-configured and currently “Unpacked” or
“Half-Configured” versions must satisfy any version clause in the Pre-Depends field.
When the package declaring a pre-dependency is about to be configured, the pre-dependency will be treated as a
normal Depends. It will be considered satisfied only if the depended-on package has been correctly configured.
However, unlike with Depends, Pre-Depends does not permit circular dependencies to be broken. If a circular
dependency is encountered while attempting to honor Pre-Depends, the installation will be aborted.
Pre-Depends are also required if the preinst script depends on the named package. It is best to avoid this
situation if possible.
Pre-Depends should be used sparingly, preferably only by packages whose premature upgrade or installation
would hamper the ability of the system to continue with any upgrade that might be in progress.
You should not specify a Pre-Depends entry for a package before this has been discussed on the debian-devel
mailing list and a consensus about doing that has been reached. See Dependencies.
When selecting which level of dependency to use you should consider how important the depended-on package is to
the functionality of the one declaring the dependency. Some packages are composed of components of varying degrees
of importance. Such a package should list using Depends the package(s) which are required by the more important
components. The other components’ requirements may be mentioned as Suggestions or Recommendations, as appropriate
to the components’ relative importance.
Many of the cases where Breaks should be used were previously handled with Conflicts because Breaks did not yet
exist. Many Conflicts fields should now be Breaks. See Conflicting binary packages - Conflicts for more information
about the differences.
A package will not cause a conflict merely because its configuration files are still installed; it must be at least “Half-
Installed”.
A special exception is made for packages which declare a conflict with their own package name, or with a virtual package
which they provide (see below): this does not prevent their installation, and allows a package to conflict with others
providing a replacement for it. You use this feature when you want the package in question to be the only package
providing some feature.
Normally, Breaks should be used instead of Conflicts since Conflicts imposes a stronger restriction on the ordering
of package installation or upgrade and can make it more difficult for the package manager to find a correct solution to an
upgrade or installation problem. Breaks should be used
• when moving a file from one package to another (see Overwriting files and replacing packages - Replaces),
• when splitting a package (a special case of the previous one), or
• when the breaking package exposes a bug in or interacts badly with particular versions of the broken package.
Conflicts should be used
• when two packages provide the same file and will continue to do so,
• in conjunction with Provides when only one package providing a given virtual facility can be unpacked at a time
(see Virtual packages - Provides),
• in other cases where one must prevent simultaneous installation of two packages for reasons that are ongoing (not
fixed in a later version of one of the packages) or that must prevent both packages from being unpacked at the same
time, not just configured.
Be aware that adding Conflicts is normally not the best solution when two packages provide the same files. Depending
on the reason for that conflict, using alternatives or renaming the files is often a better approach. See, for example,
Binaries.
Neither Breaks nor Conflicts should be used unless two packages cannot be installed at the same time or installing
them both causes one of them to be broken or unusable. Having similar functionality or performing the same tasks as
another package is not sufficient reason to declare Breaks or Conflicts with that package.
A Conflicts entry may have an “earlier than” version clause if the reason for the conflict is corrected in a later version
of one of the packages. However, normally the presence of an “earlier than” version clause is a sign that Breaks should
have been used instead. An “earlier than” version clause in Conflicts prevents dpkg from upgrading or installing the
package which declares such a conflict until the upgrade or removal of the conflicted-with package has been completed,
which is a strong restriction.
Package: foo
Depends: bar
and someone else releases an enhanced version of the bar package they can say:
Package: bar-plus
Provides: bar
and the bar-plus package will now also satisfy the dependency for the foo package.
A Provides field may contain version numbers, and such a version number will be considered when considering a
dependency on or conflict with the virtual package name. For example, given the following packages:
Package: foo
Depends: bar (>= 1.0)
Package: bar
Version: 0.9
Package: bar-plus
Provides: bar (= 1.0)
the bar-plus package will satisfy the dependency for the foo package with the virtual package name, as above. If
the Provides field does not specify a version number, it will not satisfy versioned dependencies or violate versioned
Conflicts or Breaks. For example, given the following packages:
Package: foo
Depends: bar (>= 1.0)
Package: bar
Version: 0.9
Package: bar-plus
Provides: bar (= 1.0)
Package: bar-clone
Provides: bar
the bar-plus package will satisfy the dependency for the foo package, but the bar-clone package will not.
To specify which of a set of real packages should be the default to satisfy a particular dependency on a virtual package,
list the real package as an alternative before the virtual one.
If the virtual package represents a facility that can only be provided by one real package at a time, such as the mail-
transport-agent virtual package that requires installation of a binary that would conflict with all other providers of that
virtual package (see Mail transport, delivery and user agents), all packages providing that virtual package should also
declare a conflict with it using Conflicts. This will ensure that at most one provider of that virtual package is unpacked
or installed at a time.
in its control file. The new version of the package foo would normally have the field
(or possibly Recommends or even Suggests if the files moved into foo-data are not required for normal operation).
If a package is completely replaced in this way, so that dpkg does not know of any files it still contains, it is considered
to have “disappeared”. It will be marked as not wanted on the system (selected for removal) and “Not-Installed”. Any
conffiles details noted for the package will be ignored, as they will have been taken over by the overwriting package.
The package’s postrm script will be run with a special argument to allow the package to do any final cleanup required.
See Summary of ways maintainer scripts are called.4
For this usage of Replaces, virtual packages (see Virtual packages - Provides) are not considered when looking at a
Replaces field. The packages declared as being replaced must be mentioned by their real names.
This usage of Replaces only takes effect when both packages are at least partially on the system at once. It is not relevant
if the packages conflict unless the conflict has been overridden.
foo-data. Replaces will allow foo-data to be installed and take over that file. However, without Breaks, nothing requires foo to be upgraded to a
newer version that knows it does not include that file and instead depends on foo-data. Nothing would prevent the new foo-data package from being
installed and then removed, removing the file that it took over from foo. After that operation, the package manager would think the system was in a
consistent state, but the foo package would be missing one of its files.
4 Replaces is a one way relationship. You have to install the replacing package after the replaced package.
Provides: mail-transport-agent
Conflicts: mail-transport-agent
Replaces: mail-transport-agent
ensuring that only one MTA can be unpacked at any one time. See Virtual packages - Provides for more information
about this example.
Build-dependencies on “build-essential” binary packages can be omitted. Please see Package relationships for more in-
formation.
The dependencies and conflicts they define must be satisfied (as defined earlier for binary packages) in order to invoke
the targets in debian/rules, as follows:
clean
Only the Build-Depends and Build-Conflicts fields must be satisfied when this target is invoked.
build-arch, and binary-arch
The Build-Depends, Build-Conflicts, Build-Depends-Arch, and Build-Conflicts-Arch fields
must be satisfied when these targets are invoked.
build-indep, and binary-indep
The Build-Depends, Build-Conflicts, Build-Depends-Indep, and Build-Conflicts-Indep fields
must be satisfied when these targets are invoked.
build and binary
The Build-Depends, Build-Conflicts, Build-Depends-Indep, Build-Conflicts-Indep,
Build-Depends-Arch, and Build-Conflicts-Arch fields must be satisfied when these targets are
invoked.
Alternative dependencies are allowed in the Build-Depends, Build-Depends-Indep, and Build-Depends-Arch
fields, but Debian’s autobuilders normally discard the dependencies after the first. This is done to give alternative de-
pendencies a consistent interpretation that reduces the risk of inconsistencies between repeated builds. If, for example,
the first-listed dependency would normally be available but is temporarily not installable, the autobuilder fails rather than
install a subsequent dependency that may significantly change the behavior of the package.
More specifically, Debian autobuilders perform the following transformation on alternative dependencies in the
Build-Depends, Build-Depends-Indep, and Build-Depends-Arch fields:
1. Discard any alternatives that are restricted to architectures that do not match the host architecture.
2. Discard any alternatives specifying different package names than the now-first alternative. (Alternatives specifying
the same package name are kept to permit relationships such as foo (<= x) | foo (>= y).)
For example, an autobuilder for the amd64 architecture would treat the following dependency:
as if it were:
The normal effect is to use only the first alternative that is valid on the relevant architecture and fail if that alternative is
not installable.
While this rule for build dependencies may limit the usefulness of alternatives, they can still be used to provide flexibility
when building the package outside of Debian’s autobuilders.
The autobuilders for the Debian backports and experimental suites do not perform this transformation and instead use
the same dependency resolution rules as normal package installations to choose which alternative dependency to install.
A package including binaries from grub2 and loadlin would have this field in its control file:
This field should be used only when there are license or DFSG requirements to retain the referenced source packages.
It should not be added solely as a way to locate packages that need to be rebuilt against newer versions of their build
dependencies.
5 Build-Depends in the source package is not adequate since it (rightfully) does not document the exact version used in the build.
6 The archive software might reject packages that refer to non-existent sources.
EIGHT
SHARED LIBRARIES
Packages containing shared libraries must be constructed with a little care to make sure that the shared library is always
available. This is especially important for packages whose shared libraries are vitally important, such as the C library
(currently libc6).
This section deals only with public shared libraries: shared libraries that are placed in directories searched by the dynamic
linker by default or which are intended to be linked against normally and possibly used by other, independent packages.
Shared libraries that are internal to a particular package or that are only loaded as dynamic modules are not covered by
this section and are not subject to its requirements.
A shared library is identified by the SONAME attribute stored in its dynamic section. When a binary is linked against a
shared library, the SONAME of the shared library is recorded in the binary’s NEEDED section so that the dynamic linker
knows that library must be loaded at runtime. The shared library file’s full name (which usually contains additional version
information not needed in the SONAME) is therefore normally not referenced directly. Instead, the shared library is loaded
by its SONAME, which exists on the file system as a symlink pointing to the full name of the shared library. This symlink
must be provided by the package. Run-time shared libraries describes how to do this.1
When linking a binary or another shared library against a shared library, the SONAME for that shared library is not yet
known. Instead, the shared library is found by looking for a file matching the library name with .so appended. This file
exists on the file system as a symlink pointing to the shared library.
Shared libraries are normally split into several binary packages. The SONAME symlink is installed by the runtime shared
library package, and the bare .so symlink is installed in the development package since it’s only used when linking
binaries or shared libraries. However, there are some exceptions for unusual shared libraries or for shared libraries that
are also loaded as dynamic modules by other programs.
This section is primarily concerned with how the separation of shared libraries into multiple packages should be done
and how dependencies on and between shared library binary packages are managed in Debian. Libraries should be read
in conjunction with this section and contains additional rules for the files contained in the shared library packages.
therefore do not need a symlink. Most, however, encode additional information about backwards-compatible revisions as a minor version number in
the file name. The SONAME itself only changes when binaries linked with the earlier version of the shared library may no longer work, but the filename
may change with each release of the library. See Run-time shared libraries for more information.
2 There are some exceptional situations in which co-installation of two versions of a shared library is not safe, and the new shared library package has
to conflict with the previous shared library package. This is never desirable, since it causes significant disruption during upgrades and potentially breaks
unpackaged third-party binaries, but is sometimes unavoidable. These situations are sufficiently rare that they usually warrant project-wide discussion,
and are complex enough that the rules for them cannot be codified in Debian Policy.
67
Debian Policy Manual, Release 4.7.2.0
Normally, the run-time shared library and its SONAME symlink should be placed in a package named librarynamesoversion,
where soversion is the version number in the SONAME of the shared library. Alternatively, if it would be confusing to di-
rectly append soversion to libraryname (if, for example, libraryname itself ends in a number), you should use libraryname-
soversion instead.3
To determine the soversion, look at the SONAME of the library, stored in the ELF SONAME attribute. It is usually of the
form name.so.major-version (for example, libz.so.1). The version part is the part which comes after .so., so
in that example it is 1. The soname may instead be of the form name-major-version.so, such as libdb-5.1.so,
in which case the name would be libdb and the version would be 5.1.
If you have several shared libraries built from the same source tree, you may lump them all together into a single shared
library package provided that all of their SONAMEs will always change together. Be aware that this is not normally the
case, and if the SONAMEs do not change together, upgrading such a merged shared library package will be unnecessarily
difficult because of file conflicts with the old version of the package. When in doubt, always split shared library packages
so that each binary package installs a single shared library.
Every time the shared library ABI changes in a way that could break binaries linked against older versions of the shared
library, the SONAME of the library and the corresponding name for the binary package containing the runtime shared
library should change. Normally, this means the SONAME should change any time an interface is removed from the shared
library or the signature of an interface (the number of parameters or the types of parameters that it takes, for example)
is changed. This practice is vital to allowing clean upgrades from older versions of the package and clean transitions
between the old ABI and new ABI without having to upgrade every affected package simultaneously.
The SONAME and binary package name need not, and indeed normally should not, change if new interfaces are added but
none are removed or changed, since this will not break binaries linked against the old shared library. Correct versioning of
dependencies on the newer shared library by binaries that use the new interfaces is handled via the symbols or shlibs
system (see Dependencies between the library and other packages).
The package should install the shared libraries under their normal names. For example, the libgdbm3 package should
install libgdbm.so.3.0.0 as /usr/lib/libgdbm.so.3.0.0. The files should not be renamed or re-linked by any
prerm or postrm scripts; dpkg will take care of renaming things safely without affecting running programs, and attempts
to interfere with this are likely to lead to problems.
Shared libraries should not be installed executable, since the dynamic linker does not require this and trying to execute a
shared library usually results in a core dump.
The run-time library package should include the symbolic link for the SONAME that ldconfig would create for the
shared libraries. For example, the libgdbm3 package should include a symbolic link from /usr/lib/libgdbm.so.3
to libgdbm.so.3.0.0. This is needed so that the dynamic linker (for example ld.so or ld-linux.so.*) can find
the library between the time that dpkg installs it and the time that ldconfig is run in the postinst script.4
8.1.1 ldconfig
Any package installing shared libraries in one of the default library directories of the dynamic linker (which are currently
/usr/lib and /lib) or a directory that is listed in /etc/ld.so.conf5 must use ldconfig to update the shared
library system.
3 The following command, when run on a shared library, will output the name to be used for the Debian package containing that shared library:
objdump -p /path/to/libfoo-bar.so.1.2.3 \
| sed -n -e's/^[[:space:]]*SONAME[[:space:]]*//p' \
| LC_ALL=C sed -r -e's/([0-9])\.so\./\1-/; s/\.so(\.|$)//; y/_/-/; s/(.*)/\L&/'
4 The package management system requires the library to be placed before the symbolic link pointing to it in the .deb file. This is so that when
dpkg comes to install the symlink (overwriting the previous symlink pointing at an older version of the library), the new shared library is already in
place. In the past, this was achieved by creating the library in the temporary packaging directory before creating the symlink. Unfortunately, this was
not always effective, since the building of the tar file in the .deb depended on the behavior of the underlying file system. Some file systems (such
as reiserfs) reorder the files so that the order of creation is forgotten. Since version 1.7.0, dpkg reorders the files itself as necessary when building a
package. Thus it is no longer important to concern oneself with the order of file creation.
5 These are currently /usr/local/lib plus directories under /lib and /usr/lib matching the multiarch triplet for the system architecture.
Any such package must have the line activate-noawait ldconfig in its triggers control file (i.e. DEBIAN/
triggers).
If the package provides Ada Library Information (*.ali) files for use with GNAT, these files must be installed read-only
(mode 0444) so that GNAT will not attempt to recompile them. This overrides the normal file mode requirements given
in Permissions and owners.
binaries, libraries, or loadable modules in your package.11 dpkg-shlibdeps will use the symbols or shlibs files
installed by the shared libraries to generate dependency information. The package must then provide a substitution
variable into which the discovered dependency information can be placed.
If you are creating a udeb for use in the Debian Installer, you will need to specify that dpkg-shlibdeps should use
the dependency line of type udeb by adding the -tudeb option.12 If there is no dependency line of type udeb in the
shlibs file, dpkg-shlibdeps will fall back to the regular dependency line.
dpkg-shlibdeps puts the dependency information into the debian/substvars file by default, which is then used by
dpkg-gencontrol. You will need to place a ${shlibs:Depends} variable in the Depends field in the control file of
every binary package built by this source package that contains compiled binaries, libraries, or loadable modules. If you
have multiple binary packages, you will need to call dpkg-shlibdeps on each one which contains compiled libraries
or binaries. For example, you could use the -T option to the dpkg utilities to specify a different substvars file for each
binary package.13
For more details on dpkg-shlibdeps, see its manual page.
We say that a binary foo directly uses a library libbar if it is explicitly linked with that library (that is, the library is
listed in the ELF NEEDED attribute, caused by adding -lbar to the link line when the binary is created). Other libraries
that are needed by libbar are linked indirectly to foo, and the dynamic linker will load them automatically when it
loads libbar. A package should depend on the libraries it directly uses, but not the libraries it only uses indirectly. The
dependencies for the libraries used directly will automatically pull in the indirectly-used libraries. dpkg-shlibdeps
will handle this logic automatically, but package maintainers need to be aware of this distinction between directly and
indirectly using a library if they have to override its results for some reason.14
dh_shlibdeps program will do this work for you. It will also correctly handle multi-binary packages.
12 dh_shlibdeps from the debhelper suite will automatically add this option if it knows it is processing a udeb.
13 Again, dh_shlibdeps and dh_gencontrol will handle everything except the addition of the variable to the control file for you if you’re using
debhelper, including generating separate substvars files for each binary package and calling dpkg-gencontrol with the appropriate flags.
14 A good example of where this helps is the following: We could update libimlib with a new version that supports a new revision of a graphics
format called dgf (but retaining the same major version number) and depends on a new library package libdgf4 instead of the older libdgf3. If we used
ldd to add dependencies for every library directly or indirectly linked with a binary, every package that uses libimlib would need to be recompiled
so it would also depend on libdgf4 in order to retire the older libdgf3 package. Since dependencies are only added based on ELF NEEDED attribute,
packages using libimlib can rely on libimlib itself having the dependency on an appropriate version of libdgf and do not need rebuilding.
15 An example of an “unreasonable” program is one that uses library interfaces that are documented as internal and unsupported. If the only programs
or libraries affected by a change are “unreasonable” ones, other techniques, such as declaring Breaks relationships with affected packages or treating
their usage of the library as bugs in those packages, may be appropriate instead of changing the SONAME. However, the default approach is to change
the SONAME for any change to the ABI that could break a program.
Backward-compatible changes require either updating or recording the minimal-version for that symbol in symbols files
or updating the version in the dependencies in shlibs files. For more information on how to do this in the two formats,
see The symbols File Format and The shlibs File Format. Below are general rules that apply to both files.
The easy case is when a public symbol is added. Simply add the version at which the symbol was introduced (for symbols
files) or update the dependency version (for shlibs) files. But special care should be taken to update dependency versions
when the behavior of a public symbol changes. This is easy to neglect, since there is no automated method of determining
such changes, but failing to update versions in this case could result in binary packages with too-weak dependencies that
will fail at runtime, possibly in ways that can cause security vulnerabilities. If the package maintainer believes that a
symbol behavior change could have occurred but isn’t sure, it’s safer to update the version rather than leave it unmodified.
This may result in unnecessarily strict dependencies, but it ensures that packages whose dependencies are satisfied will
work properly.
A common example of when a change to the dependency version is required is a function that takes an enum or struct
argument that controls what the function does. For example:
If a new operation, OP_BAZ, is added, the minimal-version of library_do_operation (for symbols files) or the
version in the dependency for the shared library (for shlibs files) must be increased to the version at which OP_BAZ
was introduced. Otherwise, a binary built against the new version of the library (having detected at compile-time that
the library supports OP_BAZ) may be installed with a shared library that doesn’t support OP_BAZ and will fail at runtime
when it tries to pass OP_BAZ into this function.
Dependency versions in either symbols or shlibs files normally should not contain the Debian revision of the package,
since the library behavior is normally fixed for a particular upstream version and any Debian packaging of that upstream
version will have the same behavior. In the rare case that the library behavior was changed in a particular Debian revision,
appending ~ to the end of the version that includes the Debian revision is recommended, since this allows backports of
the shared library package using the normal backport versioning convention to satisfy the dependency.
binary packages, the contents of the packages are staged in the directories debian/libfoo2 and debian/foo-runtime respectively. (debian/
tmp could be used instead of one of these.) Since libfoo2 provides the libfoo shared library, it will contain a symbols file, which will be installed in
debian/libfoo2/DEBIAN/symbols, eventually to be included as a control file in that package. When dpkg-shlibdeps is run on the executable
debian/foo-runtime/usr/bin/foo-prog, it will examine the debian/libfoo2/DEBIAN/symbols file to determine whether foo-prog’s
library dependencies are satisfied by any of the libraries provided by libfoo2. Since those binaries were linked against the just-built shared library as
part of the build process, the symbols file for the newly-built libfoo2 must take precedence over a symbols file for any other libfoo2 package
already installed on the system.
Be aware that if a debian/shlibs.local exists in the source package, it will override any symbols files. This is the
only case where a shlibs is used despite symbols files being present. See The shlibs files present on the system and The
shlibs system for more information.
library-soname main-dependency-template
[| alternative-dependency-template]
[...]
[* field-name: field-value]
[...]
symbol minimal-version[ id-of-dependency-template]
To explain this format, we’ll use the zlib1g package as an example, which (at the time of writing) installs the shared
library /usr/lib/libz.so.1.2.3.4. Mandatory lines will be described first, followed by optional lines.
library-soname must contain exactly the value of the ELF SONAME attribute of the shared library. In our example,
this is libz.so.1.17
main-dependency-template has the same syntax as a dependency field in a binary package control file, except that
the string #MINVER# is replaced by a version restriction like (>= version) or by nothing if an unversioned dependency
is deemed sufficient. The version restriction will be based on which symbols from the shared library are referenced and the
version at which they were introduced (see below). In nearly all cases, main-dependency-template will be package
#MINVER#, where package is the name of the binary package containing the shared library. This adds a simple, possibly-
versioned dependency on the shared library package. In some rare cases, such as when multiple packages provide the
same shared library ABI, the dependency template may need to be more complex.
In our example, the first line of the zlib1g symbols file would be:
Each public symbol exported by the shared library must have a corresponding symbol line, indented by one space. symbol
is the exported symbol (which, for C++, means the mangled symbol) followed by @ and the symbol version, or the string
Base if there is no symbol version. minimal-version is the most recent version of the shared library that changed the
behavior of that symbol, whether by adding it, changing its function signature (the parameters, their types, or the return
17 This can be determined by using the command
readelf -d /usr/lib/libz.so.1.2.3.4 | grep SONAME
type), or changing its behavior in a way that is visible to a caller. id-of-dependency-template is an optional field
that references an alternative-dependency-template; see below for a full description.
For example, libz.so.1 contains the symbols compress and compressBound. compress has no symbol version
and last changed its behavior in upstream version 1:1.1.4. compressBound has the symbol version ZLIB_1.2.0,
was introduced in upstream version 1:1.2.0, and has not changed its behavior. Its symbols file therefore contains the
lines:
compress@Base 1:1.1.4
compressBound@ZLIB_1.2.0 1:1.2.0
Packages using only compress would then get a dependency on zlib1g (>= 1:1.1.4), but packages using com-
pressBound would get a dependency on zlib1g (>= 1:1.2.0).
One or more alternative-dependency-template lines may be provided. These are used in cases where some
symbols in the shared library should use one dependency template while others should use a different template. The
alternative dependency templates are used only if a symbol line contains the id-of-dependency-template field.
The first alternative dependency template is numbered 1, the second 2, and so forth.18
Finally, the entry for the library may contain one or more metadata fields. Currently, the only supported field-name
is Build-Depends-Package, whose value lists the library development package on which packages using this shared
library declare a build dependency. If this field is present, dpkg-shlibdeps uses it to ensure that the resulting binary
package dependency on the shared library is at least as strict as the source package dependency on the shared library
development package.19 For our example, the zlib1g symbols file would contain:
* Build-Depends-Package: zlib1g-dev
base interfaces, and then may provide some additional interfaces only used by programs that require that specific GL implementation. So, for example,
libgl1-mesa-glx may use the following symbols file:
libGL.so.1 libgl1
| libgl1-mesa-glx #MINVER#
publicGlSymbol@Base 6.3-1 [...]
implementationSpecificSymbol@Base 6.5.2-7 1
[...]
Binaries or shared libraries using only publicGlSymbol would depend only on libgl1 (which may be provided by multiple packages), but ones
using implementationSpecificSymbol would get a dependency on libgl1-mesa-glx (>= 6.5.2-7).
19 This field should normally not be necessary, since if the behavior of any symbol has changed, the corresponding symbol minimal-version should
have been increased. But including it makes the symbols system more robust by tightening the dependency in cases where the package using the
shared library specifically requires at least a particular version of the shared library development package for some reason.
20 If you are using debhelper, dh_makeshlibs will take care of calling either dpkg-gensymbols or generating a shlibs file as appropriate.
when the library changes SONAME. Removing a public symbol from the symbols file because it’s no longer provided by
the library normally requires changing the SONAME of the library. See Run-time shared libraries for more information on
SONAMEs.
In the following sections, we will first describe where the various shlibs files are to be found, then how to use
dpkg-shlibdeps, and finally the shlibs file format and how to create them.
We will explain this by reference to the example of the zlib1g package, which (at the time of writing) installs the shared
library /usr/lib/libz.so.1.2.3.4.
type is an optional element that indicates the type of package for which the line is valid. The only type currently in use
is udeb. The colon and space after the type are required.
library-name is the name of the shared library, in this case libz. (This must match the name part of the soname, see
below.)
soname-version is the version part of the ELF SONAME attribute of the library, determined the same way that the
soversion component of the recommended shared library package name is determined. See Run-time shared libraries for
the details.
dependencies has the same syntax as a dependency field in a binary package control file. It should give details of which
packages are required to satisfy a binary built against the version of the library contained in the package. See Syntax of
relationship fields for details on the syntax, and Shared library ABI changes for details on how to maintain the dependency
version constraint.
In our example, if the last change to the zlib1g package that could change behavior for a client of that library was in
version 1:1.2.3.3.dfsg-1, then the shlibs entry for this library could say:
This version restriction must be new enough that any binary built against the current version of the library will work with
any version of the shared library that satisfies that dependency.
As zlib1g also provides a udeb containing the shared library, there would also be a second line:
21 This is what dh_makeshlibs in the debhelper suite does. If your package also has a udeb that provides a shared library, dh_makeshlibs can
automatically generate the udeb: lines if you specify the name of the udeb with the --add-udeb option.
NINE
77
Debian Policy Manual, Release 4.7.2.0
7. The requirement that boot manager configuration files live in /etc, or at least are symlinked there, is relaxed to a
recommendation.
8. /var/run is required to be a symbolic link to /run, and /var/lock is required to be a symbolic link to /run/
lock.
9. The /var/www directory is additionally allowed.
10. The requirement for /usr/local/share/color to exist if /usr/share/color exists is relaxed to a recom-
mendation.
11. The requirement for /usr/local/libqual to exist if /libqual or /usr/libqual exists (where libqual is
a variant of lib such as lib32 or lib64) is removed.
12. On GNU/Hurd systems, the following additional directories are allowed in the root filesystem: /hurd and /
servers.3
13. As an exception to the requirement for there to be no subdirectories in /usr/bin, the mh mail-handling suite may
create /usr/bin/mh/, as was allowed in FHS version 2.3. Other subdirectories are not allowed.
The version of this document referred here can be found in the debian-policy package or on FHS (Debian copy)
alongside this manual (or, if you have the debian-policy installed, you can try FHS (local copy)). The latest version,
which may be a more recent version, may be found on FHS (upstream). Specific questions about following the standard
may be asked on the debian-devel mailing list, or referred to the FHS mailing list (see the FHS web site for more
information).
Since /usr/local can be mounted read-only from a remote server, /usr/local/*/dir/ directories must be created
and removed by the postinst and prerm maintainer scripts and not be included in the .deb archive. These scripts
must not fail if either of these operations fail.
For example, the emacsen-common package could contain something like
if [ ! -e /usr/local/share/emacs ]; then
if mkdir /usr/local/share/emacs 2>/dev/null; then
if test -e /etc/staff-group-for-usr-local ; then
if chown root:staff /usr/local/share/emacs; then
chmod 2775 /usr/local/share/emacs || true
fi
elif chown root:root /usr/local/share/emacs; then
(continues on next page)
3 These directories are used to store translators and as a set of standard names for mount points, respectively.
in the prerm script. (Note that this form is used to ensure that if the script is interrupted, the directory /usr/local/
share/emacs will still be removed.)
If you do create a directory in /usr/local for local additions to a package, you should ensure that settings in /usr/
local take precedence over the equivalents in /usr.
However, because /usr/local and its contents are for exclusive use of the local administrator, a package must not rely
on the presence or absence of files or directories in /usr/local for normal operation.
9.3.1 Introduction
The default init system and service manager in Debian is systemd. Packages that wish to automatically start and stop
system services must include systemd service units to do so, unless the service is only intended for use on systems
running alternate init systems. See systemd.service(5) for details on the syntax of a service unit file.
In the common case that a package includes a single system service, the service unit should have the same name as the
package plus the .service extension.
Packages including a service unit may optionally include an init script to support other init systems. In this case, the
init script should have the same name as the systemd service unit so that systemd will ignore it and use the service
unit instead. Packages may also support other init systems by including configuration in the native format of those init
systems.
systemd uses dependency and ordering information contained within the enabled unit files to decide which services to run
and in which order. The sysv-rc runlevel system for sysvinit uses symlinks in /etc/rcn.d to decide which scripts
to run and in which order at boot time and when the init state (or “runlevel”) is changed. See the README.runlevels
file shipped with sysv-rc for implementation details. Other alternatives might exist.
The sections below describe how to write those scripts and configure those symlinks.
Be careful of using set -e in init.d scripts. Writing correct init.d scripts requires accepting various error exit
statuses when daemons are already running or already stopped without aborting the init.d script, and common init.
d function libraries are not safe to call with set -e in effect.4 For init.d scripts, it’s often easier to not use set -e
and instead check the result of each command separately.
If a service reloads its configuration automatically (as in the case of cron, for example), the reload option of the init.d
script should behave as if the configuration has been reloaded successfully.
The /etc/init.d scripts must be treated as configuration files, either (if they are present in the package, that is, in
the .deb file) by marking them as conffiles, or, (if they do not exist in the .deb) by managing them correctly in the
maintainer scripts (see Configuration files). This is important since we want to give the local system administrator the
chance to adapt the scripts to the local system, e.g., to disable a service without de-installing the package, or to specify
some special command line options when starting a service, while making sure their changes aren’t lost during the next
package upgrade.
These scripts should not fail obscurely when the configuration files remain but the package has been removed, as config-
uration files remain on the system after the package has been removed. Only when dpkg is executed with the --purge
option will configuration files be removed. In particular, as the /etc/init.d/package script itself is usually a conf-
file, it will remain on the system if the package is removed but not purged. Therefore, you should include a test
statement at the top of the script, like this:
Often there are some variables in the init.d scripts whose values control the behavior of the scripts, and which a system
administrator is likely to want to change. As the scripts themselves are frequently conffiles, modifying them requires
that the administrator merge in their changes each time the package is upgraded and the conffile changes. To ease
the burden on the system administrator, such configurable values should not be placed directly in the script. Instead, they
should be placed in a file in /etc/default, which typically will have the same base name as the init.d script. This
extra file should be sourced by the script when the script runs. It must contain only variable settings and comments in
POSIX.1-2017 sh format. It must either be a conffile or a configuration file maintained by the package maintainer
scripts. See Configuration files for more details.
To ensure that vital configurable values are always available, the init.d script should set default values for each of
the shell variables it uses, either before sourcing the /etc/default/ file or afterwards using something like the :
${VAR:=default} syntax. Also, the init.d script must behave sensibly and not fail if the /etc/default file is
deleted.
Files and directories under /run, including ones referred to via the compatibility paths /var/run and /var/lock, are
normally stored on a temporary filesystem and are normally not persistent across a reboot. The init.d scripts must
handle this correctly. This will typically mean creating any required subdirectories dynamically when the init.d script
is run. See /run and /run/lock for more information.
The default behaviour is to enable autostarting your package’s daemon. The local administrator can override this using
the command update-rc.d package disable. If, however, the daemon should not be autostarted unless the local
administrator has explicitly requested this, instead add to your postinst script:
and add a dependency on init-system-helpers (>= 1.50), which introduced the defaults-disabled option.
Then the local administrator can enable autostarting the daemon using the command update-rc.d package enable.
An older practice, which should not be used, was to include a line like DISABLED=yes in the package’s /etc/default
file. The package’s init script would not start the service until the local system administrator changed this to DIS-
ABLED=no, or similar. The problem with this approach was that it hides from the init system whether or not the daemon
should actually be started, which leads to inconsistent and confusing behavior: service <package> start could
return success but not start the service; services with a dependency on this service will be started even though the service
isn’t running; and init system status commands could incorrectly claim that the service was started.
Note that if your package changes runlevels or priority, you may have to remove and recreate the links, since otherwise
the old links may persist. Refer to the documentation of update-rc.d.
For more information about using update-rc.d, please consult its man page, update-rc.d(8).
It is easiest for packages not to call update-rc.d directly, but instead use debhelper programs that add the required
update-rc.d calls automatically. See dh_installinit, dh_installsystemd, etc.
9.3.5 Example
Examples on which you can base your systemd service units are available in the man page systemd.unit(5). An
example on which you can base your init scripts is available in the man page init-d-script(5).
If a package wants to install a job that has to be executed via cron, it should place a file named as specified in Cron job
file names into one or more of the following directories:
• /etc/cron.hourly
• /etc/cron.daily
• /etc/cron.weekly
• /etc/cron.monthly
As these directory names imply, the files within them are executed on an hourly, daily, weekly, or monthly basis, respec-
tively. The exact times are listed in /etc/crontab.
All files installed in any of these directories must be scripts (e.g., shell scripts or Perl scripts) so that they can easily be
modified by the local system administrator. In addition, they must be treated as configuration files.
If a certain job has to be executed at some other frequency or at a specific time, the package should install a file in /
etc/cron.d with a name as specified in Cron job file names. This file uses the same syntax as /etc/crontab and is
processed by cron automatically. The file must also be treated as a configuration file. (Note that entries in the /etc/
cron.d directory are not handled by anacron. Thus, you should only use this directory for jobs which may be skipped
if the system is not running.)
Unlike crontab files described in the IEEE Std 1003.1-2008 (POSIX.1) available from The Open Group, the files in
/etc/cron.d and the file /etc/crontab have seven fields; namely:
1. Minute [0,59]
2. Hour [0,23]
9.6 Menus
Packages shipping applications that comply with minimal requirements described below for integration with desktop
environments should register these applications in the desktop menu, following the FreeDesktop standard, using text
files called desktop entries. Their format is described in the Desktop Entry Specification at https://standards.freedesktop.
org/desktop-entry-spec/latest/ and complementary information can be found in the Desktop Menu Specification at https:
//standards.freedesktop.org/menu-spec/latest/.
The desktop entry files are installed by the packages in the directory /usr/share/applications and the FreeDesktop
menus are refreshed using dpkg triggers. It is therefore not necessary to depend on packages providing FreeDesktop menu
systems.
Entries displayed in the FreeDesktop menu should conform to the following minima for relevance and visual integration.
• Unless hidden by default, the desktop entry must point to a PNG or SVG icon with a transparent background,
providing at least the 22×22 size, and preferably up to 64×64. The icon should be neutral enough to integrate well
with the default icon themes. It is encouraged to ship the icon in the default hicolor icon theme directories, or to
use an existing icon from the hicolor theme.
• If the menu entry is not useful in the general case as a standalone application, the desktop entry should set the
NoDisplay key to true, so that it can be configured to be displayed only by those who need it.
• In doubt, the package maintainer should coordinate with the maintainers of menu implementations through the
debian-desktop mailing list in order to avoid problems with categories or bad interactions with other icons. Espe-
cially for packages which are part of installation tasks, the contents of the NotShowIn/OnlyShowIn keys should
be validated by the maintainers of the relevant environments.
9.6. Menus 85
Debian Policy Manual, Release 4.7.2.0
Since the FreeDesktop menu is a cross-distribution standard, the desktop entries written for Debian should be forwarded
upstream, where they will benefit to other users and are more likely to receive extra contributions such as translations.
If a package installs a FreeDesktop desktop entry, it must not also install a Debian menu entry.
be done by calling dpkg-trigger --no-await /usr/lib/mime/packages from the maintainer script after creating, modifying, or removing
the file.
• Other applications use the stty erase character and kdch1 for the two delete keys, with ASCII DEL being
“delete previous character” and kdch1 being “delete character under cursor”.
This will solve the problem except for the following cases:
• Some terminals have a <-- key that cannot be made to produce anything except ^H. On these terminals Emacs
help will be unavailable on ^H (assuming that the stty erase character takes precedence in Emacs, and has been
set correctly). M-x help or F1 (if available) can be used instead.
• Some operating systems use ^H for stty erase. However, modern telnet versions and all rlogin versions propagate
stty settings, and almost all UNIX versions honour stty erase. Where the stty settings are not propagated
correctly, things can be made to work by using stty manually.
• Some systems (including previous Debian versions) use xmodmap to arrange for both <-- and Delete to generate
KB_Delete. We can change the behavior of their X clients using the same X resources that we use to do it for
our own clients, or configure our clients using their resources when things are the other way around. On displays
configured like this Delete will not work, but <-- will.
• Some operating systems have different kdch1 settings in their terminfo database for xterm and others. On these
systems the Delete key will not work correctly when you log in from a system conforming to our policy, but <--
will.
#!/bin/sh
BAR=${BAR:-/var/lib/fubar}
export BAR
exec /usr/lib/foo/foo "$@"
TEN
FILES
10.1 Binaries
Two different packages must not install programs with different functionality but with the same filenames. This also
applies when they are installed into different directories on the default (user or root) PATH. (The case of two programs
having the same functionality but different implementations is handled via “alternatives” or the “Conflicts” mechanism.
See Maintainer Scripts and Conflicting binary packages - Conflicts respectively.) If this case happens, one of the programs
must be renamed. The maintainers should report this to the debian-devel mailing list and try to find a consensus about
which program will have to be renamed. If a consensus cannot be reached, both programs must be renamed.
There is an exception to the above rules for /usr/games: packages that already install programs to /usr/games, where
another package installs a program of the same with different functionality to a different directory on the default PATH,
may continue to do so. However, packages must not install any newly conflicting programs to /usr/games, and packages
already doing so are encouraged to move these programs to non-conflicting names.
Packages must not install files to paths whose first component is a name directly under the file system root and which is a
symbolic link to a directory of the same name under /usr. That is, packages must not install files to paths matching the
glob patterns /bin/*, /lib/*, /lib*/* and /sbin/*. The base-files package is an exception, for it installs aliasing
symbolic links from /bin to /usr/bin, /lib to /usr/lib, et cetera. This restriction is necessary to avoid triggering
undefined behaviour in dpkg.
Packages may assume that /bin, /lib and /sbin are always symbolic links such that files under /usr/bin, /usr/lib
and /usr/sbin are always accessible via these aliases.
Binary executables must not be statically linked with the GNU C library, since this prevents the binary from benefiting
from fixes and improvements to the C library without being rebuilt and complicates security updates. This requirement
may be relaxed for binary executables whose intended purpose is to diagnose and fix the system in situations where the
GNU C library may not be usable (such as system recovery shells or utilities like ldconfig) or for binary executables where
the security benefits of static linking outweigh the drawbacks.
By default, when a package is being built, any binaries created should include debugging information, as well as being
compiled with optimization. You should also turn on as many reasonable compilation warnings as possible (see Main
building script: debian/rules). For the C programming language, this means the following compilation parameters should
be used:
CC = gcc
CFLAGS = -O2 -g -Wall # sane warning options vary between programs
LDFLAGS = # none
on the binaries after they have been copied into debian/tmp but before the tree is made into a package.
89
Debian Policy Manual, Release 4.7.2.0
It is not recommended to strip binaries by passing the -s flag to install, because this fails to remove .comment and
.note sections, and also prevents the automatic creation of dbgsym binary packages by tools like dh_strip.
Although binaries in the build tree should be compiled with debugging information by default, it can often be difficult to
debug programs if they are also subjected to compiler optimization. For this reason, it is recommended to support the
standardized environment variable DEB_BUILD_OPTIONS (see debian/rules and DEB_BUILD_OPTIONS). This variable
can contain several flags to change how a package is compiled and built.
It is up to the package maintainer to decide what compilation options are best for the package. Certain binaries (such
as computationally-intensive programs) will function better with certain flags (-O3, for example); feel free to use them.
Please use good judgment here. Don’t use flags for the sake of it; only use them if there is good reason to do so. Feel
free to override the upstream author’s ideas about which compilation options are best: they are often inappropriate for
our environment.
10.2 Libraries
If the package is architecture: any, then the shared library compilation and linking flags must have -fPIC, or the
package shall not build on some of the supported architectures.1 Any exception to this rule must be discussed on the
mailing list [email protected], and a rough consensus obtained. The reasons for not compiling with -fPIC
flag must be recorded in the file README.Debian, and care must be taken to either restrict the architecture or arrange
for -fPIC to be used on architectures where it is required.2
As to the static libraries, the common case is not to have relocatable code, since there is no benefit, unless in specific cases;
therefore the static version must not be compiled with the -fPIC flag. Any exception to this rule should be discussed on
the mailing list [email protected], and the reasons for compiling with the -fPIC flag must be recorded in the
file README.Debian.3
In other words, if both a shared and a static library is being built, each source unit (*.c, for example, for C files) will
need to be compiled twice, for the normal case.
Libraries should be built with threading support and to be thread-safe if the library supports this.
Although not enforced by the build tools, shared libraries must be linked against all libraries that they use symbols from
in the same way that binaries are. This ensures the correct functioning of the symbols and shlibs systems and guarantees
that all libraries can be safely opened with dlopen(). Packagers may wish to use the gcc option -Wl,-z,defs when
building a shared library. Since this option enforces symbol resolution at build time, a missing library reference will be
caught early as a fatal build error.
All installed shared libraries should be stripped with
(The option --strip-unneeded makes strip remove only the symbols which aren’t needed for relocation processing.)
Shared libraries can function perfectly well when stripped, since the symbols for dynamic linking are in a separate part
of the ELF object file.4
1 If you are using GCC, -fPIC produces code with relocatable position independent code, which is required for most architectures to create a
shared library, with i386 and perhaps some others where non position independent code is permitted in a shared library.
Position independent code may have a performance penalty, especially on i386. However, in most cases the speed penalty must be measured against
the memory wasted on the few architectures where non position independent code is even possible.
2 Some of the reasons why this might be required is if the library contains hand crafted assembly code that is not relocatable, the speed penalty is
development, and has an unstable API, so shared libraries are pointless at this phase of the library’s development. In that case, since Perl needs a library
with relocatable code, it may make sense to create a static library with relocatable code. Another reason cited is if you are distilling various libraries
into a common shared library, like mklibs does in the Debian installer project.
4 You might want to replace --strip-unneeded with --strip-debug for static libraries, as dh_strip does. When stripping static libraries, you
should also pass --enable-deterministic-archives to ensure that your package build is reproducible.
Note that under some circumstances it may be useful to install a shared library unstripped, for example when building a
separate package to support debugging. The debhelper dh_strip tool can create such packages automatically.
Shared object files (often .so files) that are not public libraries, that is, they are not meant to be linked to by third party
executables (binaries of other packages), should be installed in subdirectories of the /usr/lib or /usr/lib/triplet
directories (see the FHS for a definition). Such files are exempt from the rules that govern ordinary shared libraries,
except that they must not be installed executable and should be stripped.5
Packages that use libtool to create and install their shared libraries install a file containing additional metadata (ending
in .la) alongside the library. For public libraries intended for use by other packages, these files normally should not
be included in the Debian package, since the information they include is not necessary to link with the shared library on
Debian and can add unnecessary additional dependencies to other programs or libraries.6 If the .la file is required for that
library (if, for instance, it’s loaded via libltdl in a way that requires that meta-information), the dependency_libs
setting in the .la file should normally be set to the empty string. If the shared library development package has historically
included the .la, it must be retained in the development package (with dependency_libs emptied) until all libraries
that depend on it have removed or emptied dependency_libs in their .la files to prevent linking with those other
libraries using libtool from failing.
If the .la must be included, it should be included in the development (-dev) package, unless the library will be loaded
by libtool’s libltdl library. If it is intended for use with libltdl, the .la files must go in the run-time library
package.
These requirements for handling of .la files do not apply to loadable modules or libraries not installed in directories
searched by default by the dynamic linker. Packages installing loadable modules will frequently need to install the .la
files alongside the modules so that they can be loaded by libltdl. dependency_libs does not need to be modified
for libraries or modules that are not installed in directories searched by the dynamic linker by default and not intended
for use by other packages.
You must make sure that you use only released versions of shared libraries to build your packages; otherwise other users
will not be able to run your binaries properly. Producing source packages that depend on unreleased compilers is also
usually a bad idea.
10.4 Scripts
All command scripts, including the package maintainer scripts inside the package and used by dpkg, should have a #!
line naming the shell to be used to interpret them.
In the case of Perl scripts this should be #!/usr/bin/perl.
When scripts are installed into a directory in the system PATH, the script name should not include an extension such as
.sh or .pl that denotes the scripting language currently used to implement it.
Shell scripts (sh and bash) other than init.d scripts should almost certainly start with set -e so that errors are
detected. init.d scripts are something of a special case, due to how frequently they need to call commands that are
allowed to fail, and it may instead be easier to check the exit status of commands directly. See Writing the scripts for more
information about writing init.d scripts.
Every script should use set -e or check the exit status of every command.
5 A common example are the so-called “plug-ins”, internal shared objects that are dynamically loaded by programs using dlopen(3).
6 These files store, among other things, all libraries on which that shared library depends. Unfortunately, if the .la file is present and contains
that dependency information, using libtool when linking against that library will cause the resulting program or library to be linked against those
dependencies as well, even if this is unnecessary. This can create unneeded dependencies on shared library packages that would otherwise be hidden
behind the library ABI, and can make library transitions to new SONAMEs unnecessarily complicated and difficult to manage.
Scripts may assume that /bin/sh implements the POSIX.1-2017 Shell Command Language7 plus the following addi-
tional features not mandated by POSIX.1-2017..8
• echo -n, if implemented as a shell built-in, must not generate a newline.
• test, if implemented as a shell built-in, must support -a and -o as binary logical operators.
• local to create a scoped variable must be supported, including listing multiple variables in a single local command
and assigning a value to a variable at the same time as localizing it. local may or may not preserve the variable
value from an outer scope if no assignment is present. Uses such as:
fname () {
local a b c=delta d
# ... use a, b, c, d ...
}
but /var were a symbolic link to /srv/disk1, the symbolic link would point to /srv/run rather than the intended target.
Note that when creating a relative link using ln it is not necessary for the target of the link to exist relative to the working
directory you’re running ln from, nor is it necessary to change directory to the directory where the link is to be made.
Simply include the string that should appear as the target of the link (this will be a pathname relative to the directory in
which the link resides) as the first argument to ln.
For example, in your Makefile or debian/rules, you can do things like:
A symbolic link pointing to a compressed file (in the sense that it is meant to be uncompressed with unzip or zless
etc.) should always have the same file extension as the referenced file. (For example, if a file foo.gz is referenced by a
symbolic link, the filename of the link has to end with “.gz” too, as in bar.gz.)
device files.
10.7.2 Location
Any configuration files created or used by your package must reside in /etc. If there are several, consider creating a
subdirectory of /etc named after your package.
If your package creates or uses configuration files outside of /etc, and it is not feasible to modify the package to use
/etc directly, put the files in /etc and create symbolic links to those files from the location that the package requires.
10.7.3 Behavior
Configuration file handling must conform to the following behavior:
• local changes must be preserved during a package upgrade, and
• configuration files must be preserved when the package is removed, and only deleted when the package is purged.
Obsolete configuration files without local changes should be removed by the package during upgrade.11
The easy way to achieve this behavior is to make the configuration file a conffile. This is appropriate only if it is possible
to distribute a default version that will work for most installations, although some system administrators may choose to
modify it. This implies that the default version will be part of the package distribution, and must not be modified by the
maintainer scripts during installation (or at any other time).
In order to ensure that local changes are preserved correctly, packages must not contain or make hard links to conffiles.12
The other way to do it is via the maintainer scripts. In this case, the configuration file must not be listed as a conffile and
must not be part of the package distribution. If the existence of a file is required for the package to be sensibly configured
it is the responsibility of the package maintainer to provide maintainer scripts which correctly create, update and maintain
the file and remove it on purge. (See Package maintainer scripts and installation procedure for more information.) These
scripts must be idempotent (i.e., must work correctly if dpkg needs to re-run them due to errors during installation
or removal), must cope with all the variety of ways dpkg can call maintainer scripts, must not overwrite or otherwise
mangle the user’s configuration without asking, must not ask unnecessary questions (particularly during upgrades), and
must otherwise be good citizens.
The scripts are not required to configure every possible option for the package, but only those necessary to get the
package running on a given system. Ideally the sysadmin should not have to do any configuration other than that done
(semi-)automatically by the postinst script.
A common practice is to create a script called package-configure and have the package’s postinst call it if and
only if the configuration file does not already exist. In certain cases it is useful for there to be an example or template file
which the maintainer scripts use. Such files should be in /usr/share/package or /usr/lib/package (depending
on whether they are architecture-independent or not). There should be symbolic links to them from /usr/share/doc/
package/examples if they are examples, and should be perfectly ordinary dpkg-handled files (not configuration files).
These two styles of configuration file handling must not be mixed, for that way lies madness: dpkg will ask about over-
writing the file every time the package is upgraded.
1. One of the related packages (the “owning” package) will manage the configuration file with maintainer scripts as
described in the previous section.
2. The owning package should also provide a program that the other packages may use to modify the configuration
file.
3. The related packages must use the provided program to make any desired modifications to the configuration file.
They should either depend on the core package to guarantee that the configuration modifier program is available
or accept gracefully that they cannot modify the configuration file if it is not. (This is in addition to the fact that
the configuration file may not even be present in the latter scenario.)
Sometimes it’s appropriate to create a new package which provides the basic infrastructure for the other packages and
which manages the shared configuration files. (The sgml-base package is a good example.)
If the configuration file cannot be shared as described above, the packages must be marked as conflicting with each other.
Two packages that specify the same file as a conffile must conflict. This is an instance of the general rule about not
sharing files. Neither alternatives nor diversions are likely to be appropriate in this case; in particular, dpkg does not
handle diverted conffiles well.
When two packages both declare the same conffile, they may see left-over configuration files from each other even
though they conflict with each other. If a user removes (without purging) one of the packages and installs the other, the
new package will take over the conffile from the old package. If the file was modified by the user, it will be treated
the same as any other locally modified conffile during an upgrade.
The maintainer scripts must not alter a conffile of any package, including the one the scripts belong to.
However, programs that require dotfiles in order to operate sensibly are a bad thing, unless they do create the dotfiles
themselves automatically.
Furthermore, programs should be configured by the Debian default installation to behave as closely to the upstream default
behavior as possible.
Therefore, if a program in a Debian package needs to be configured in some way in order to operate sensibly, that should
be done using a site-wide configuration file placed in /etc. Only if the program doesn’t support a site-wide default
configuration and the package maintainer doesn’t have time to add it may a default per-user file be placed in /etc/skel.
/etc/skel should be as empty as we can make it. This is particularly true because there is no easy (or necessarily
desirable) mechanism for ensuring that the appropriate dotfiles are copied into the accounts of existing users when a
package is installed.
use the facilities provided by logrotate.13 Here is a good example for a logrotate config file (for more information see
logrotate(8)):
/var/log/foo/*.log {
rotate 12
weekly
compress
missingok
postrotate
start-stop-daemon -K -p /var/run/foo.pid -s HUP -x /usr/sbin/foo -q
endscript
}
This rotates all files under /var/log/foo, saves 12 compressed generations, and tells the daemon to reopen its log files
after the log rotation. It skips this log rotation (via missingok) if no such log file is present, which avoids errors if the
package is removed but not purged.
Log files should be removed when the package is purged (but not when it is only removed). This should be done by the
postrm script when it is called with the argument purge (see Details of removal and/or configuration purging).
highly customizable, it requires quite a lot of sysadmin work. Even though the original Debian system helped a little by automatically installing a system
which can be used as a template, this was deemed not enough.
The use of logrotate, a program developed by Red Hat, is better, as it centralizes log management. It has both a configuration file (/etc/
logrotate.conf) and a directory where packages can drop their individual log rotation configurations (/etc/logrotate.d).
14 When a package is upgraded, and the owner or permissions of a file included in the package has changed, dpkg arranges for the ownership and
permissions to be correctly set upon installation. However, this does not extend to directories; the permissions and ownership of directories already on
the system does not change on install or upgrade of packages. This makes sense, since otherwise common directories like /usr would always be in
flux. To correctly change permissions of a directory the package owns, explicit action is required, usually in the postinst script. Care must be taken
to handle downgrades as well, in that case.
Some setuid programs need to be restricted to particular sets of users, using file permissions. In this case they should be
owned by the uid to which they are set-id, and by the group which should be allowed to execute them. They should have
mode 4754; again there is no point in making them unreadable to those users who must not be allowed to execute them.
It is possible to arrange that the system administrator can reconfigure the package to correspond to their local security
policy by changing the permissions on a binary: they can do this by using dpkg-statoverride, as described below.15
Another method you should consider is to create a group for people allowed to use the program(s) and make any setuid
executables executable only by that group.
If you need to create a new user or group for your package there are two possibilities. Firstly, you may need to make
some files in the binary package be owned by this user or group, or you may need to compile the user or group id (rather
than just the name) into the binary (though this latter should be avoided if possible, as in this case you need a statically
allocated id).
If you need a statically allocated id, you must ask for a user or group id from the base-passwd maintainer, and must
not release the package until you have been allocated one. Once you have been allocated one you must either make
the package depend on a version of the base-passwd package with the id present in /etc/passwd or /etc/group,
or arrange for your package to create the user or group itself with the correct id (using adduser) in its preinst or
postinst. (Doing it in the postinst is to be preferred if it is possible, otherwise a pre-dependency will be needed on
the adduser package.)
On the other hand, the program might be able to determine the uid or gid from the user or group name at runtime, so
that a dynamically allocated id can be used. In this case you should choose an appropriate user or group name, discussing
this on debian-devel and checking that it is unique. When this has been checked you must arrange for your package
to create the user or group if necessary using adduser in the preinst or postinst script (again, the latter is to be
preferred if it is possible).
Note that changing the numeric value of an id associated with a name is very difficult, and involves searching the file
system for all appropriate files. You need to think carefully whether a static or dynamic id is required, since changing
your mind later will cause problems.
The corresponding code to remove the override when the package is purged would be:
ELEVEN
CUSTOMIZED PROGRAMS
11.2 Daemons
The configuration files /etc/services, /etc/protocols, and /etc/rpc are managed by the netbase package and
must not be modified by other packages.
If a package requires a new entry in one of these files, the maintainer should get in contact with the netbase maintainer,
who will add the entries and release a new version of the netbase package.
The configuration file /etc/inetd.conf must not be modified by the package’s scripts except via the update-inetd
script or the DebianNet.pm Perl module. See their documentation for details on how to add entries.
If a package wants to install an example entry into /etc/inetd.conf, the entry must be preceded with exactly one
hash character (#). Such lines are treated as “commented out by user” by the update-inetd script and are not changed
or activated during package updates.
triplets), with the first component of the triplet representing the libc and ABI in use, and then does matching against those triplets. However, such
triplets are an internal implementation detail that should not be used by packages directly. The libc and ABI portion is handled internally by the package
system based on the os and cpu.
99
Debian Policy Manual, Release 4.7.2.0
/usr/lib/cgi-bin
/usr/lib/cgi-bin/.../cgi-bin-name
should be referred to as
http://localhost/cgi-bin/.../cgi-bin-name
2. (Deleted)
3. Access to images
Images for a package should be stored in /usr/share/images/package and referred to through an alias /
images/ as:
http://localhost/images/package/filename
2 The Debian base system already provides an editor and a pager program.
/var/www/html
as the Document Root. This might be just a symbolic link to the location where the system administrator has put
the real document root.
5. Providing httpd and/or httpd-cgi
All web servers should provide the virtual package httpd. If a web server has CGI support it should provide
httpd-cgi additionally.
All web applications which do not contain CGI scripts should depend on httpd, all those web applications which
do contain CGI scripts, should depend on httpd-cgi.
The mail spool is /var/mail and the interface to send a mail message is /usr/sbin/sendmail (as per the FHS). On
older systems, the mail spool may be physically located in /var/spool/mail, but all access to the mail spool should
be via the /var/mail symlink. The mail spool is part of the base system and not part of the MTA package.
All Debian MUAs, MTAs, MDAs and other mailbox accessing programs (such as IMAP daemons) must lock the mailbox
in an NFS-safe way. This means that fcntl() locking must be combined with dot locking. To avoid deadlocks, a
program should use fcntl() first and dot locking after this, or alternatively implement the two locking methods in a
non blocking way.3 Using the functions maillock and mailunlock provided by the liblockfile* packages is the
recommended way to accomplish this.
Mailboxes are generally either mode 600 and owned by user or mode 660 and owned by user:mail.4 The local system
administrator may choose a different permission scheme; packages should not make assumptions about the permission
and ownership of mailboxes unless required (such as when creating a new mailbox). A MUA may remove a mailbox
(unless it has nonstandard permissions) in which case the MTA or another MUA must recreate it if needed.
The mail spool is 2775 root:mail, and MUAs should be setgid mail to do the locking mentioned above (and must
obviously avoid accessing other users’ mailboxes using this privilege).
/etc/aliases is the source file for the system mail aliases (e.g., postmaster, usenet, etc.), it is the one which the
sysadmin and postinst scripts may edit. After /etc/aliases is edited the program or human editing it must call
newaliases. All MTA packages must come with a newaliases program, even if it does nothing, but older MTA
packages did not do this so programs should not fail if newaliases cannot be found. Note that because of this, all MTA
packages must have Provides, Conflicts and Replaces: mail-transport-agent control fields.
The convention of writing forward to address in the mailbox itself is not supported. Use a .forward file instead.
The rmail program used by UUCP for incoming mail should be /usr/sbin/rmail. Likewise, rsmtp, for receiving
batch-SMTP-over-UUCP, should be /usr/sbin/rsmtp if it is supported.
3 If it is not possible to establish both locks, the system shouldn’t wait for the second lock to be established, but remove the first lock, wait a (random)
or mode 660 and owned by group mail with mail delivery done by a process running as a system user in group mail. Historically, Debian required mode
660 mail spools to enable the latter model, but that model has become increasingly uncommon and the principle of least privilege indicates that mail
systems that use the first model should use permissions of 600. If delivery to programs is permitted, it’s easier to keep the mail system secure if the
delivery agent runs as the destination user. Debian Policy therefore permits either scheme.
If your package needs to know what hostname to use on (for example) outgoing news and mail messages which are
generated locally, you should use the file /etc/mailname. It will contain the portion after the username and @ (at) sign
for email addresses of users on the machine (followed by a newline).
Such a package should check for the existence of this file when it is being configured. If it exists, it should be used
without comment, although an MTA’s configuration script may wish to prompt the user even if it finds that this file exists.
If the file does not exist, the package should prompt the user for the value (preferably using debconf) and store it in
/etc/mailname as well as using it in the package’s configuration. The prompt should make it clear that the name will
not just be used by that package. For example, in this situation the inn package could say something like:
Please enter the "mail name" of your system. This is the hostname portion
of the address to be shown on outgoing news and mail messages. The
default is syshostname, your system's host name.
list. In a nutshell, X servers that interface directly with the display and input hardware or via another subsystem (e.g., GGI) should provide xserver.
Things like Xvfb, Xnest, and Xprt should not.
console, for PostScript renderer, or any other purpose, do not fit this definition. Any tool which makes such fonts available to the X Window System,
however, must abide by this font policy.
8 This is because an X client may be displayed by a remote X server, in which case X fonts are provided by the remote X server, not retrieved
locally; the Debian package system is empowered to deal only with the local file system.
11.11 Games
The permissions on /var/games are mode 755, owner root and group root.
Each game decides on its own security policy.
Games which require protected, privileged access to high-score files, saved games, etc., may be made set-group-id (mode
2755) and owned by root:games, and use files and directories with appropriate permissions (770 root:games, for
example). They must not be made set-user-id, as this causes security problems. (If an attacker can subvert any set-user-id
game they can overwrite the executable of any other, causing other players of these games to run a Trojan horse program.
With a set-group-id game the attacker only gets access to less important game data, and if they can get at the other players’
accounts at all it will take considerably more effort.)
Some packages, for example some fortune cookie programs, are configured by the upstream authors to install with their
data files or other static information made unreadable so that they can only be accessed through set-id programs provided.
You should not do this in a Debian package: anyone can download the .deb file and read the data from it, so there is
no point making the files unreadable. Not making the files unreadable also means that you don’t have to make so many
programs set-id, which reduces the risk of a security hole.
As described in the FHS, binaries of games should be installed in the directory /usr/games. This also applies to games
that use the X Window System. Manual pages for games (X and non-X games) should be installed in /usr/share/
man/man6.
resources are stored in the X server and affect all connecting clients.
TWELVE
DOCUMENTATION
A country name (the DE in de_DE) should not be included in the subdirectory name unless it indicates a significant
difference in the language, as this excludes speakers of the language in other countries.4
If a localized version of a manual page is provided, it should either be up-to-date or it should be obvious to the reader that
it is outdated and the original manual page should be used instead. This can be done either by a note at the beginning of
the manual page or by showing the missing or changed portions in the original language instead of the target language.
1 It is not very hard to write a man page. See the Man-Page-HOWTO, man(7), the examples created by dh_make, the helper program help2man,
man’s database that would be better left in the file system. This support is therefore deprecated and will cease to be present in the future.
3 man will automatically detect whether UTF-8 is in use. In future, all manual pages will be required to use UTF-8.
4 At the time of writing, Chinese and Portuguese are the main languages with such differences, so pt_BR, zh_CN, and zh_TW are all allowed.
107
Debian Policy Manual, Release 4.7.2.0
Packages (other than manual page readers) must not require the existence of any files in /usr/share/man/ in order to
function. A package that optionally displays its own manual pages, such as to provide user help, must fail gracefully if
the manual pages aren’t installed.
To determine which section to use, you should look at /usr/share/info/dir on your system and choose the most
relevant (or create a new section if none of the current sections are relevant).5
Packages (other than info readers) must not require the existence of any files in /usr/share/info/ in order to function.
commands like:
@dircategory Individual utilities
@direntry
* example: (example). An example info directory entry.
@end direntry
to the Texinfo source of the document and ensure that the info documents are rebuilt from source during the package build.
package-doc provides HTML or other formats, package should declare at most a Suggests on package-doc. Otherwise,
package should declare at most a Recommends on package-doc.
Additional documentation included in the package should be installed under /usr/share/doc/package. If the doc-
umentation is packaged separately, as package-doc for example, it may be installed under either that path or into the
documentation directory for the separate documentation package (/usr/share/doc/package-doc in this example).
However, installing the documentation into the documentation directory of the main package is encouraged since it is
independent of the packaging method and will be easier for users to find.
Any separate package providing documentation must still install standard documentation files in its own /usr/share/
doc directory as specified in the rest of this policy. See, for example, Copyright information and Changelog files and
release notes.
Packages must not require the existence of any files in /usr/share/doc/ in order to function.6 Any files that are
used or read by programs but are also useful as stand alone documentation should be installed elsewhere, such as under
/usr/share/package/, and then included via symbolic links in /usr/share/doc/package.
A verbatim copy of the package’s copyright information is often required to be present in /usr/share/doc/PACKAGE/
copyright, too; see Copyright considerations.
In addition, the copyright file must say where the upstream sources (if any) were obtained, and should include a name or
contact address for the upstream authors. This can be the name of an individual or an organization, an email address, a
web forum or bugtracker, or any other means to unambiguously identify who to contact to participate in the development
of the upstream source code.
Packages in the contrib or non-free archive areas should state in the copyright file that the package is not part of the
Debian distribution and briefly explain why.
A copy of the file which will be installed in /usr/share/doc/PACKAGE/copyright should be in debian/
copyright in the source package.
/usr/share/doc/package is permitted be a symbolic link to another directory in /usr/share/doc only if the two
packages both come from the same source and the first package Depends on the second. Otherwise, /usr/share/
6 The system administrator should be able to delete files in /usr/share/doc/ without causing any programs to break.
7 Please note that this does not override the section on changelog files below, so the file /usr/share/doc/package/changelog.Debian.gz
must refer to the changelog for the current version of package in question. In practice, this means that the sources of the target and the destination of
the symlink must be the same (same source package and version).
8 Rationale: The important thing here is that HTML documentation should be available from some binary package.
doc/package must not be a symbolic link. These rules are important because copyright files must be extractable by
mechanical means.
Packages distributed under the Apache license (version 2.0), the Artistic license, the Creative Commons CC0-1.0 li-
cense, the GNU GPL (versions 1, 2, or 3), the GNU LGPL (versions 2, 2.1, or 3), the GNU FDL (versions 1.2 or
1.3), and the Mozilla Public License (version 1.1 or 2.0) should refer to the corresponding files under /usr/share/
common-licenses,9 rather than quoting them in the copyright file.
You should not use the copyright file as a general README file. If your package has such a file it should be installed in
/usr/share/doc/package/README or README.Debian or some other appropriate place.
12.6 Examples
Any examples (configurations, source files, whatever), should be installed in a directory /usr/share/doc/package/
examples. These files should not be referenced by any program: they’re there for the benefit of the system administrator
and users as documentation only. Architecture-specific example files should be installed in a directory /usr/lib/
package/examples with symbolic links to them from /usr/share/doc/package/examples, or the latter directory
itself may be a symbolic link to the former.
If the purpose of a package is to provide examples, then the example files may be installed into /usr/share/doc/
package.
If the upstream release notes or changelog do not already conform to this naming convention, then this may be achieved
either by renaming the files, or by adding a symbolic link, at the maintainer’s discretion.10
All of these files should be installed compressed using gzip -9, as they will become large with time even if they start
out small.
If the package has only one file which is used both as the Debian changelog and the upstream release notes or changelog,
because there is no separate upstream maintainer, then that file should usually be installed as /usr/share/doc/
package/NEWS.gz or /usr/share/doc/package/changelog.gz (depending on whether the file is release notes
or a changelog); if there is a separate upstream maintainer, but no upstream release notes or changelog, then the Debian
changelog should still be called changelog.Debian.gz.
For details about the format and contents of the Debian changelog file, please see Debian changelog: debian/changelog.
10 Rationale: People should not have to look in places for upstream changelogs merely because they are given different names or are distributed in
HTML format.
THIRTEEN
These appendices, except the final three, are taken essentially verbatim from the now-deprecated Packaging Manual,
version 3.2.1.0. They are the chapters which are likely to be of use to package maintainers and which have not already
been included in the policy document itself. Most of these sections are very likely not relevant to policy; they should
be treated as documentation for the packaging system. Please note that these appendices are included for convenience,
and for historical reasons: they used to be part of policy package, and they have not yet been incorporated into dpkg
documentation. However, they still have value, and hence they are presented here.
They have not yet been checked to ensure that they are compatible with the contents of policy, and if there are any
contradictions, the version in the main policy document takes precedence. The remaining chapters of the old Packaging
Manual have also not been read in detail to ensure that there are not parts which have been left out. Both of these will be
done in due course.
Certain parts of the Packaging manual were integrated into the Policy Manual proper, and removed from the appendices.
Links have been placed from the old locations to the new ones.
dpkg is a suite of programs for creating binary package files and installing and removing them on Unix systems.1
The binary packages are designed for the management of installed executable programs (usually compiled binaries) and
their associated data, though source code examples and documentation are provided as part of some packages.
This manual describes the technical aspects of creating Debian binary packages (.deb files). It documents the behavior
of the package management programs dpkg, dselect et al. and the way they interact with packages.
This manual does not go into detail about the options and usage of the package building and installation tools. It should
therefore be read in conjunction with those programs’ man pages.
The utility programs which are provided with dpkg not described in detail here, are documented in their man pages.
It is assumed that the reader is reasonably familiar with the dpkg System Administrators’ manual. Unfortunately this
manual does not yet exist.
The Debian version of the FSF’s GNU hello program is provided as an example for people wishing to create Debian
packages. However, while the examples are helpful, they do not replace the need to read and follow the Policy and
Programmer’s Manual.
1 dpkg is targeted primarily at Debian, but may work on or be ported to other systems.
113
Debian Policy Manual, Release 4.7.2.0
FOURTEEN
They should have the locations (relative to the root of the directory tree you’re constructing) ownerships and permissions
which you want them to have on the system when they are installed.
With current versions of dpkg the uid/username and gid/groupname mappings for the users and groups being used should
be the same on the system where the package is built and the one where it is installed.
You need to add one special directory to the root of the miniature file system tree you’re creating: DEBIAN. It should
contain the control information files, notably the binary package control file (see The binary package control file: control).
The DEBIAN directory will not appear in the file system archive of the package, and so won’t be installed by dpkg when
the package is unpacked.
When you’ve prepared the package, you should invoke:
This will build the package in directory.deb. (dpkg knows that --build is a dpkg-deb option, so it invokes
dpkg-deb with the same arguments to build the package.)
See the dpkg-deb(8) man page for details of how to examine the contents of this newly-created file. You may find the
output of following commands enlightening:
To view the copyright file for a package you could use this command:
115
Debian Policy Manual, Release 4.7.2.0
FIFTEEN
The Debian binary packages in the distribution are generated from Debian sources, which are in a special format to assist
the easy and automatic building of binaries.
dpkg-source -x .../path/to/filename.dsc
with the filename.tar.gz and filename.diff.gz (if applicable) in the same directory. It unpacks into
package-version, and if applicable package-version.orig, in the current directory.
To create a packed source archive it is typically invoked:
dpkg-source -b package-version
This will create the .dsc, .tar.gz and .diff.gz (if appropriate) in the current directory. dpkg-source does not
clean the source tree first - this must be done separately if it is required.
See also Source packages as archives.
117
Debian Policy Manual, Release 4.7.2.0
The -P tells dpkg-gencontrol that the package is being built in a non-default directory, and the -p tells it which binary
package’s control file should be generated.
dpkg-gencontrol also adds information to the list of files in debian/files, for the benefit of (for example) a future
invocation of dpkg-genchanges.
The filename is relative to the directory where dpkg-genchanges will expect to find it - this is usually the directory
above the top level of the source tree. The debian/rules target should put the file there just before or just after calling
dpkg-distaddfile.
The section and priority are passed unchanged into the resulting .changes file.
15.2.3 debian/files
See Generated files list: debian/files.
15.2.4 debian/tmp
This is the default temporary location for the construction of binary packages by the binary target. The directory tmp
serves as the root of the file system tree as it is being constructed (for example, by using the package’s upstream makefiles
install targets and redirecting the output there), and it also contains the DEBIAN subdirectory. See Creating package files
- dpkg-deb.
This is only a default and can be easily overridden. Most packaging tools no longer use debian/tmp, instead preferring
debian/pkg for the common case of a source package building only one binary package. Such tools usually only use
debian/tmp as a temporary staging area for built files and do not construct packages from it.
If several binary packages are generated from the same source tree, it is usual to use a separate debian/pkg directory
for each binary package as the temporary construction locations.
Whatever temporary directories are created and used by the binary target must of course be removed by the clean
target.
SIXTEEN
Many of the tools in the dpkg suite manipulate data in a common format, known as control files. Binary and source
packages have control data as do the .changes files which control the installation of uploaded files, and dpkg’s internal
databases are in a similar format.
16.2.3 Status
This field in dpkg’s status file records whether the user wants a package installed, removed or left alone, whether it is
broken (requiring re-installation) or not and what its current state on the system is. Each of these pieces of information
is a single word.
123
Debian Policy Manual, Release 4.7.2.0
16.2.4 Config-Version
If a package is not installed or not configured, this field in dpkg’s status file records the last version of the package which
was successfully configured.
16.2.5 Conffiles
This field in dpkg’s status file contains information about the automatically-managed configuration files held by a package.
This field should not appear anywhere in a package!
124 Chapter 16. Control files and their fields (from old Packaging Manual)
CHAPTER
SEVENTEEN
Whether this mechanism is appropriate depends on a number of factors, but basically there are two approaches to any
particular configuration file.
The easy method is to ship a best-effort configuration in the package, and use dpkg’s conffile mechanism to handle updates.
If the user is unlikely to want to edit the file, but you need them to be able to without losing their changes, and a new
package with a changed version of the file is only released infrequently, this is a good approach.
The hard method is to build the configuration file from scratch in the postinst script, and to take the responsibility for
fixing any mistakes made in earlier versions of the package automatically. This will be appropriate if the file is likely to
need to be different on each system.
125
Debian Policy Manual, Release 4.7.2.0
126 Chapter 17. Configuration file handling (from old Packaging Manual)
CHAPTER
EIGHTEEN
When several packages all provide different versions of the same program or file it is useful to have the system select a
default, but to allow the system administrator to change it and have their decisions respected.
For example, there are several versions of the vi editor, and there is no reason to prevent all of them from being installed
at once, each under their own name (nvi, vim or whatever). Nevertheless it is desirable to have the name vi refer to
something, at least by default.
If all the packages involved cooperate, this can be done with update-alternatives.
Each package provides its own version under its own name, and calls update-alternatives in its postinst to register
its version (and again in its prerm to deregister it).
See the update-alternatives(8) man page for details.
If update-alternatives does not seem appropriate you may wish to consider using diversions instead.
Do not use alternatives for systemd configuration files. See Binary packages for more information.
127
Debian Policy Manual, Release 4.7.2.0
128 Chapter 18. Alternative versions of an interface - update-alternatives (from old Packaging
Manual)
CHAPTER
NINETEEN
It is possible to have dpkg not overwrite a file when it reinstalls the package it belongs to, and to have it put the file from
the package somewhere else instead.
This can be used locally to override a package’s version of a file, or by one package to override another’s version (or
provide a wrapper for it).
Before deciding to use a diversion, read Alternative versions of an interface - update-alternatives (from old Packaging
Manual) to see if you really want a diversion rather than several alternative versions of a program.
There is a diversion list, which is read by dpkg, and updated by a special program dpkg-divert. Please see
dpkg-divert(8) for full details of its operation.
When a package wishes to divert a file from another, it should call dpkg-divert in its preinst to add the diversion
and rename the existing file. For example, supposing that a smailwrapper package wishes to install a wrapper around
/usr/sbin/smail:
The --package smailwrapper ensures that smailwrapper’s copy of /usr/sbin/smail can bypass the diversion
and get installed as the true version. It’s safe to add the diversion unconditionally on upgrades since it will be left unchanged
if it already exists, but dpkg-divert will display a message. To suppress that message, make the command conditional
on the version from which the package is being upgraded:
where 1.0-2 is the version at which the diversion was first added to the package. Running the command during abort-
upgrade is pointless but harmless.
The postrm has to do the reverse:
If the diversion was added at a particular version, the postrm should also handle the failure case of upgrading from an
older version (unless the older version is so old that direct upgrades are no longer supported):
129
Debian Policy Manual, Release 4.7.2.0
where 1.0-2 is the version at which the diversion was first added to the package. The postrm should not remove the
diversion on upgrades both because there’s no reason to remove the diversion only to immediately re-add it and since the
postrm of the old package is run after unpacking so the removal of the diversion will fail.
Do not attempt to divert a file which is vitally important for the system’s operation - when using dpkg-divert there is
a time, after it has been diverted but before dpkg has installed the new version, when the file does not exist.
Do not attempt to divert a conffile, as dpkg does not handle it well.
Do not use diversions for files that have their own native override mechanisms, such as systemd unit files. See Binary
packages for more information.
130 Chapter 19. Diversions - overriding a package’s version of a file (from old Packaging Manual)
CHAPTER
TWENTY
20.1 Introduction
To introduce a change in the current Debian Policy, the change proposal has to go through a certain process.1
cated the ‘issue’ usertag and added use of the ‘moreinfo’ tag, after discussions at DebConf17.
131
Debian Policy Manual, Release 4.7.2.0
The packaging tag is used for bugs about the packaging and build process of the debian-policy Debian package. These
bugs do not follow the normal process and will not have the other tags except for pending and wontfix (used with their
normal meanings).
TAG: packaging
TWENTYONE
1 These flowcharts were originally created by Margarita Manterola for the Debian Women project wiki.
135
Debian Policy Manual, Release 4.7.2.0
Fig. 2: Installing a package that was previously removed, but not purged
137
Debian Policy Manual, Release 4.7.2.0
139
Debian Policy Manual, Release 4.7.2.0
TWENTYTWO
UPGRADING CHECKLIST
141
Debian Policy Manual, Release 4.7.2.0
11.8.4
When computing the priority for alternatives for /usr/bin/x-window-manager, start with a priority of 40, not
20, and don’t increase the priority based on support for the (obsolete) Debian menu system.
1. the distribution license for those files requires that copyright information be included in all copies and/or
binary distributions;
2. the files are shipped in the binary package, either in source or compiled form; and
3. the form in which the files are present in the binary package does not include a plain text version of their
copyright notices.
Note that there is no change to the requirement to copy all licensing information into /usr/share/doc/
PACKAGE/copyright.
(Previously, it was always required for all copyright information to be copied into /usr/share/doc/PACKAGE/
copyright.)
4.17
Packages must not contain a non-default series file. That is, dpkg’s vendor-specific patch series feature must not be
used for packages in the Debian archive.
(previously a “should not”)
12.5
The Creative Commons CC0 1.0 Universal license (CC0-1.0) is now included in /usr/share/
common-licenses and does not need to be copied verbatim in the package copyright file.
convention to use -off. As before, whether the contents of a package needs this content warning is a matter of
maintainer discretion.
10.2
Private shared object files should be installed in subdirectories of /usr/lib or /usr/lib/triplet. This change
permits private shared object files to take advantage of multiarch, and also removes the implication that it is per-
missible to install private shared object files directly into /usr/lib/triplet.
10.4
The shebang at the top of Perl command scripts must be #!/usr/bin/perl. (Previously, this was a ‘should’
rather than a ‘must’.)
7.7
New Build-Depends-Arch and Build-Conflicts-Arch fields are now supported.
8.4
The recommended package name for shared library development files is now libraryname-dev or
librarynameapiversion-dev, not librarynamesoversion-dev.
9.1.1
The stable release of Debian supports /run, so packages may now assume that it exists and do not need any special
dependency on a version of initscripts.
9.3.2
New optional try-restart standard init script argument, which (if supported) should restart the service if it is
already running and otherwise just report success.
9.3.2
Support for the status init script argument is recommended.
9.3.3.2
Packages must not call /etc/init.d scripts directly even as a fallback, and instead must always use invoke-rc.
d (which is essential and shouldn’t require any conditional).
9.11.1
Instructions for upstart integration removed since upstart is no longer maintained in Debian.
10.1
Packages may not install files in both /path and /usr/path, and must manage any backward-compatibility
symlinks so that they don’t break if /path and /usr/path are the same directory.
10.6
Packages should assume device files in /dev are dynamically managed and don’t have to be created by the package.
Packages other than those whose purpose is to manage /dev must not create or remove files there when a dynamic
management facility is in use. Named pipes and device files outside of /dev should normally be created on demand
via init scripts, systemd units, or similar mechanisms, but may be created and removed in maintainer scripts if they
must be created during package installation.
10.9
Checking with the base-passwd maintainer is no longer required (or desirable) when creating a new dynamic user
or group in a package.
12.3
Dependencies on *-doc packages should be at most Recommends (Suggests if they only include documentation in
supplemental formats).
12.5
The Mozilla Public License 1.1 and 2.0 (MPL-1.1 and MPL-2.0) are now included in /usr/share/
common-licenses and do not need to be copied verbatim in the package copyright file.
copyright-format
The https form of the copyright-format URL is now allowed and preferred in the Format field.
perl
The Perl search path now includes multiarch directories. The vendor directory for architecture-specific modules is
now versioned to support multiarch.
virtual
New adventure virtual package for implementations of the classic Colossal Cave Adventure game.
virtual
New httpd-wsgi3 virtual package for Python 3 WSGI-capable HTTP servers. The existing httpd-wsgi virtual
package is for Python 2 WSGI-capable HTTP servers.
virtual
New virtual-mysql-client, virtual-mysql-client-core, virtual-mysql-server,
virtual-mysql-server-core, and virtual-mysql-testsuite virtual packages for MySQL-compatible
software.
10.1
Binaries must not be statically linked with the GNU C library, see policy for exceptions.
4.4
It is clarified that signature appearing in debian/changelog should be the details of the person who prepared this
release of the package.
11.5
The default web document root is now /var/www/html
virtual
java1-runtime and java2-runtime are removed, javaN-runtime and javaN-runtime-headless are
added for all N between 5 and 9.
virtual
Added httpd-wsgi for WSGI capable HTTP servers.
perl
Perl packages should use the %Config hash to locate module paths instead of hardcoding paths in @INC.
perl
Perl binary modules and any modules installed into $Config{vendorarch} must depend on the relevant perlapi-
* package.
5.6.25, 5.8.1
The DM-Upload-Allowed field is obsolete. Permissions are now granted via dak-commands files.
5.6.27
New section documenting the Package-List field in Debian source control files.
5.6.28
New section documenting the Package-Type field in source package control files.
5.6.29
New section documenting the Dgit field in Debian source control files.
9.1.1.8
The exception to the FHS for the /selinux was removed.
10.7.3
Packages should remove all obsolete configuration files without local changes during upgrades. The
dpkg-maintscript-helper tool, available from the dpkg package since Wheezy, can help with this.
10.10
The name of the files and directories installed by binary packages must be encoded in UTF-8 and should be re-
stricted to ASCII when possible. In the system PATH, they must be restricted to ASCII.
11.5.2
Stop recommending to serve HTML documents from /usr/share/doc/package.
12.2
Packages distributing Info documents should use install-info’s trigger, and do not need anymore to depend on dpkg
(>= 1.15.4) | install-info.
debconf
The escape capability is now documented.
virtual
mp3-decoder and mp3-encoder are removed.
5.6.26
New section documenting the Vcs-* fields, which are already in widespread use. Note the mechanism for speci-
fying the Git branch used for packaging in the Vcs-Git field.
7.1
The deprecated relations < and > now must not be used.
7.8
New Built-Using field, which must be used to document the source packages for any binaries that are incor-
porated into this package at build time. This is used to ensure that the archive meets license requirements for
providing source for all binaries.
8.6
Policy for dependencies between shared libraries and other packages has been largely rewritten to document the
symbols system and more clearly document handling of shared library ABI changes. symbols files are now
recommended over shlibs files in most situations. All maintainers of shared library packages should review the
entirety of this section.
9.1.1
Packages must not assume the /run directory exists or is usable without a dependency on initscripts (>=
2.88dsf-13.3) until the stable release of Debian supports /run.
9.7
Packages including MIME configuration can now rely on triggers and do not need to call update-mime.
9.11
New section documenting general requirements for alternate init systems and specific requirements for integrating
with upstart.
12.5
All copyright files must be encoded in UTF-8.
7.1
If a dependency is restricted to particular architectures, the list of architectures must be non-empty.
9.1.1
/run is allowed as an exception to the FHS and replaces /var/run. /run/lock replaces /var/lock. The
FHS requirements for the older directories apply to these directories as well. Backward compatibility links will
be maintained and packages need not switch to referencing /run directly yet. Files in /run should be stored in a
temporary file system.
9.1.4
New section spelling out the requirements for packages that use files in /run, /var/run, or /var/lock. This
generalizes information previously only in 9.3.2.
9.5
Cron job file names must not contain . or + or they will be ignored by cron. They should replace those characters
with _. If a package provides multiple cron job files in the same directory, they should each start with the package
name (possibly modified as above), -, and then some suitable suffix.
9.10
Packages using doc-base do not need to call install-docs anymore.
10.7.4
Packages that declare the same conffile may see left-over configuration files from each other even if they conflict.
11.8
The Policy rules around Motif libraries were just a special case of normal rules for non-free dependencies and were
largely obsolete, so they have been removed.
12.5
debian/copyright is no longer required to list the Debian maintainers involved in the creation of the package
(although note that the requirement to list copyright information is unchanged).
copyright-format
Version 1.0 of the “Machine-readable debian/copyright file” specification is included.
mime
This separate document has been retired and and its (short) contents merged into Policy section 9.7. There are no
changes to the requirements.
perl
Packages may declare an interest in the perl-major-upgrade trigger to be notified of major upgrades of perl.
virtual
ttf-japanese-{mincho, gothic} is renamed to fonts-japanese-{mincho, gothic}.
5
All control fields are now classified as simple, folded, or multiline, which governs whether their values must be a
single line or may be continued across multiple lines and whether line breaks are significant.
5.1
Parsers are allowed to accept stanza separation lines containing whitespace, but control files should use completely
empty lines. Ordering of stanzas is significant. Field names must be composed of printable ASCII characters
except colon and must not begin with #.
5.6.25
The DM-Upload-Allowed field is now documented.
6.5
The system state maintainer scripts can rely upon during each possible invocation is now documented. In several
less-common cases, this is stricter than Policy had previously documented. Packages with complex maintainer
scripts should be reviewed in light of this new documentation.
7.2
The impact on system state when maintainer scripts that are part of a circular dependency are run is now docu-
mented. Circular dependencies are now a should not.
7.2
The system state when postinst and prerm scripts are run is now documented, and the documentation of the
special case of dependency state for postrm scripts has been improved. postrm scripts are required to gracefully
skip actions if their dependencies are not available.
9.1.1
GNU/Hurd systems are allowed /hurd and /servers directories in the root filesystem.
9.1.1
Packages installing to architecture-specific subdirectories of /usr/lib must use the value returned by
dpkg-architecture -qDEB_HOST_MULTIARCH, not by dpkg-architecture -qDEB_HOST_GNU_TYPE;
this is a path change on i386 architectures and a no-op for other architectures.
virtual
mailx is now a virtual package provided by packages that install /usr/bin/mailx and implement at least the
POSIX-required interface.
7.1
Architecture restrictions and wildcards are also allowed in binary package relationships provided that the binary
package is not architecture-independent.
7.4
Conflicts and Breaks should only be used when there are file conflicts or one package breaks the other, not
just because two packages provide similar functionality but don’t interfere.
8.1
The SONAME of a library should change whenever the ABI of the library changes in a way that isn’t backward-
compatible. It should not change if the library ABI changes are backward-compatible. Discourage bundling shared
libraries together in one package.
8.4
Ada Library Information (*.ali) files must be installed read-only.
8.6.1, 8.6.2, 8.6.5
Packages should normally not include a shlibs.local file since we now have complete shlibs coverage.
8.6.3
The SONAME of a library may instead be of the form name-major-version.so.
10.2
Libtool .la files should not be installed for public libraries. If they’re required (for libltdl, for instance), the
dependency_libs setting should be emptied. Library packages historically including .la files must continue to
include them (with dependency_libs emptied) until all libraries that depend on that library have removed or
emptied their .la files.
10.2
Libraries no longer need to be built with -D_REENTRANT, which was an obsolete LinuxThreads requirement.
Instead, say explicitly that libraries should be built with threading support and to be thread-safe if the library
supports this.
10.4
/bin/sh scripts may assume that kill supports an argument of -signal, that kill and trap support the
numeric signals listed in the XSI extension, and that signal 13 (SIGPIPE) can be trapped with trap.
10.8
Use of /etc/logrotate.d/package for logrotate rules is now recommended.
10.9
Control information files should be owned by root:root and either mode 644 or mode 755.
11.4, 11.8.3, 11.8.4
Packages providing alternatives for editor, pager, x-terminal-emulator, or x-window-manager should
also provide a slave alternative for the corresponding manual page.
11.5
Cgi-bin executable files may be installed in subdirectories of /usr/lib/cgi-bin and web servers should serve
out executables in those subdirectories.
12.5
The GPL version 1 is now included in common-licenses and should be referenced from there instead of included
in the copyright file.
7.4
Breaks should normally be used instead of Conflicts for transient issues and moving files between packages.
New documentation of when each should be used.
7.5
Use Conflicts with Provides if only one provider of a virtual facility can be installed at a time.
8.4
All shared library development files are no longer required to be in the -dev package, only be available when the
-dev package is installed. This allows the -dev package to be split as long as it depends on the additional packages.
9.2.2
The UID range of user accounts is extended to 1000-59999.
9.3.2, 10.4
init.d scripts are a possible exception from the normal requirement to use set -e in each shell script.
12.5
The UCB BSD license was removed from the list of licenses that should be referenced from /usr/share/
common-licenses/BSD. It should instead be included directly in debian/copyright, although it will still
be in common-licenses for the time being.
debconf
SETTITLE is now documented (it has been supported for some time). SETTITLE is like TITLE but takes a template
instead of a string to allow translation.
perl
perl-base now provides perlapi-abiname instead of a package based solely on the Perl version. Perl packages must
now depend on perlapi-$Config{debian_abi}, falling back on $Config{version} if $Config{debian_abi} is
not set.
perl
Packages using Makefile.PL should use DESTDIR rather than PREFIX to install into the package staging area.
PREFIX only worked due to a Debian-local patch.
10.6
Packages may not contain named pipes and should instead create them in postinst and remove them in prerm or
postrm.
9.1.1
/sys and /selinux directories are explicitly allowed as an exception to the FHS.
9.3.2
The start action of an init script must exit successfully and not start the daemon again if it’s already running.
9.3.2
/var/run and /var/lock may be mounted as temporary filesystems, and init scripts must therefore create any
necessary subdirectories dynamically.
10.4
/bin/sh scripts may assume that local can take multiple variable arguments and supports assignment.
11.6
User mailboxes may be mode 600 and owned by the user rather than mode 660, owned by user, and group mail.
9.5
Files in /etc/cron.{hourly,daily,weekly,monthly} must be configuration files (upgraded from should).
Mention the hourly directory.
11.8.6
Packages providing /etc/X11/Xresources files need not conflict with xbase (<< 3.3.2.3a-2), which is
long-obsolete.
12.1
Manual pages in locale-specific directories should use either the legacy encoding for that directory or UTF-8.
Country names should not be included in locale-specific manual page directories unless indicating a significant
difference in the language. All characters in the manual page source should be representable in the legacy encoding
for a locale even if the man page is encoded in UTF-8.
12.5
The Apache 2.0 license is now in common-licenses and should be referenced rather than quoted in debian/
copyright.
12.5
Packages in contrib and non-free should state in the copyright file that the package is not part of Debian GNU/Linux
and briefly explain why.
debconf
Underscore (_) is allowed in debconf template names.
12.5
GFDL 1.2, GPL 3, and LGPL 3 are now in common-licenses and should be referenced rather than quoted in
debian/copyright.
10.4
When scripts are installed into a directory in the system PATH, the script name should not include an extension
that denotes the scripting language currently used to implement it.
9.3.3.2
packages that invoke initscripts now must use invoke-rc.d to do so since it also pays attention to run levels and other
local constraints.
11.8.5.2, 11.8.7, etc
We no longer use /usr/X11R6, since we have migrated away to using Xorg paths. This means, for one thing, fonts
live in /usr/share/fonts/X11/ now, and /usr/X11R6 is gone.
10.2
shared libraries must be linked against all libraries that they use symbols from in the same way that binaries are.
7.6
build-depends-indep need not be satisfied during clean target.
Clarified note in 3.5.3.0 upgrading checklist regarding examples and templates: this refers only to those examples
used by scripts; see section 10.7.3 for the whole story
Included a new section 10.9.1 describing the use of dpkg-statoverride; this does not have the weight of policy
Clarify Standards-Version: you don’t need to rebuild your packages just to change the Standards-Version!
10.2
Plugins are no longer bound by all the rules of shared libraries
X Windows related things:
11.8.1
Clarification of priority levels of X Window System related packages
11.8.3
Rules for defining x-terminal-emulator improved
11.8.5
X Font policy rewritten: you must read this if you provide fonts for the X Window System
11.8.6
Packages must not ship /usr/X11R6/lib/X11/app-defaults/
11.8.7
X-related packages should usually use the regular FHS locations; imake-using packages are exempted from
this
11.8.8
OpenMotif linked binaries have the same rules as OSF/Motif-linked ones
11.8.6
X app-defaults directory has moved from /usr/X11R6/lib/X11/app-defaults to /etc/X11/
app-defaults
Policy for packages providing the following X-based features has been codified:
11.8.2
X server (virtual package xserver)
11.8.3
X terminal emulator (virtual package x-terminal-emulator)
11.8.4
X window manager (virtual package x-window-manager, and /usr/bin/x-window-manager alternative,
with priority calculation guidelines)
12.8.5
X fonts (this section has been written from scratch)
11.8.6
X application defaults
11.8.7
Policy for packages using the X Window System and FHS issues has been clarified;
11.7.3
No package may contain or make hard links to conffiles
8
Noted that newer dpkg versions do not require extreme care in always creating the shared lib before the symlink,
so the unpack order be correct
9.1.1
Updated FHS to a 2.1 draft; this reverts /var/state to /var/lib
9.7; mime-policy
Added MIME sub-policy document
12.4
VISUAL is allowed as a (higher priority) alternative to EDITOR
11.6
Modified liblockfile description, which affects mailbox-accessing programs. Please see the policy document for
details
12.7
If a package provides a changelog in HTML format, a text-only version should also be included. (Such a version
may be prepared using lynx -dump -nolist.)
3.2.1
Description of how to handle version numbers based on dates added
• updated section about `Configuration files’: packages may not touch other packages’ configuration files
• MUAs and MTAs have to use liblockfile
TWENTYTHREE
LICENSE
173
Debian Policy Manual, Release 4.7.2.0
R
reboot
signaling, 88
reboot-required, 88
reboot-required.pkgs, 88
S
signaling
reboot, 88
175