dpkg-maintscript-helper.1 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. .TH dpkg\-maintscript\-helper 1 "2011-08-14" "Debian Project" "dpkg suite"
  2. .SH NAME
  3. dpkg\-maintscript\-helper \- works around known dpkg limitations in maintainer scripts
  4. .
  5. .SH SYNOPSIS
  6. .B dpkg\-maintscript\-helper
  7. .IR command " [" parameter "...] \fB\-\-\fP " maint-script-parameter ...
  8. .
  9. .SH COMMANDS AND PARAMETERS
  10. .P
  11. \fBrm_conffile\fP \fIconffile\fP [\fIlastversion\fP [\fIpackage\fP]]
  12. .P
  13. \fBmv_conffile\fP \fIoldconffile\fP \fInewconffile\fP [\fIlastversion\fP [\fIpackage\fP]]
  14. .
  15. .SH DESCRIPTION
  16. .P
  17. This program is designed to be run within maintainer scripts to achieve
  18. some tasks that dpkg can't (yet) handle natively either because of design
  19. decisions or due to current limitations.
  20. .P
  21. Many of those tasks require coordinated actions from several maintainer
  22. scripts (\fBpreinst\fP, \fBpostinst\fP, \fBprerm\fP, \fBpostrm\fP). To
  23. avoid mistakes the same call simply needs to be put in all scripts and the
  24. program will automatically adapt its behaviour based on the environment
  25. variable \fBDPKG_MAINTSCRIPT_NAME\fP and on the maintainer scripts arguments
  26. that you have to forward after a double dash.
  27. .
  28. .SH CONFFILE RELATED TASKS
  29. .P
  30. When upgrading a package, dpkg will not automatically remove a conffile (a
  31. configuration file for which dpkg should preserve user changes) if it is
  32. not present in the newer version. There are two principal reasons for
  33. this; the first is that the conffile could've been dropped by accident and
  34. the next version could restore it, users wouldn't want their changes
  35. thrown away. The second is to allow packages to transition files from a
  36. dpkg\-maintained conffile to a file maintained by the package's maintainer
  37. scripts, usually with a tool like debconf or ucf.
  38. .P
  39. This means that if a package is intended to rename or remove a conffile,
  40. it must explicitly do so and \fBdpkg\-maintscript\-helper\fP can be used
  41. to implement graceful deletion and moving of conffiles within maintainer
  42. scripts.
  43. .
  44. .SS REMOVING A CONFFILE
  45. .P
  46. If a conffile is completely removed, it should be removed from disk,
  47. unless the user has modified it. If there are local modifications, they
  48. should be preserved. If the package upgrades aborts, the newly obsolete
  49. conffile should not disappear.
  50. .P
  51. All of this is implemented by putting the following shell snippet in the
  52. \fBpreinst\fP, \fBpostinst\fP and \fBpostrm\fP maintainer scripts:
  53. .P
  54. dpkg\-maintscript\-helper rm_conffile \\
  55. \fIconffile\fP \fIlastversion\fP \fIpackage\fP \-\- "$@"
  56. .P
  57. \fIconffile\fP is the filename of the conffile to remove.
  58. \fIlastversion\fP is the last version of the package that contained the
  59. conffile (or the last version of the package that did not take care to
  60. remove the obsolete conffile if this was not immediately implemented).
  61. If \fIlastversion\fP is empty or omitted, then the operation is tried
  62. on every upgrade. \fIpackage\fP is the package name, it's optional as it will
  63. default to $DPKG_MAINTSCRIPT_PACKAGE (this variable is set by dpkg to the
  64. name of the package acted upon). All the parameters of the maintainer
  65. scripts have to be forwarded to the program after "\-\-".
  66. .P
  67. Current implementation: in the \fBpreinst\fP, it checks if the conffile
  68. was modified and renames it either to \fIconffile\fP\fB.dpkg\-remove\fP (if not
  69. modified) or to \fIconffile\fP\fB.dpkg\-backup\fP (if modified). In the
  70. \fBpostinst\fP, the latter file is renamed to \fIconffile\fP\fB.dpkg\-bak\fP
  71. and kept for reference as it contains user modifications but the former will
  72. be removed. If the package upgrade aborts, the \fBpostrm\fP reinstalls the
  73. original conffile. During purge, the \fBpostrm\fP will also delete the
  74. \fB.dpkg\-bak\fP file kept up to now.
  75. .
  76. .SS RENAMING A CONFFILE
  77. .P
  78. If a conffile is moved from one location to another, you need to make sure
  79. you move across any changes the user has made. This may seem a simple
  80. change to the \fBpreinst\fP script at first, however that will result in
  81. the user being prompted by dpkg to approve the conffile edits even though
  82. they are not responsible of them.
  83. .P
  84. Graceful renaming can be implemented by putting the following shell
  85. snippet in the \fBpreinst\fP, \fBpostinst\fP and \fBpostrm\fP maintainer
  86. scripts:
  87. .P
  88. dpkg\-maintscript\-helper mv_conffile \\
  89. \fIoldconffile\fP \fInewconffile\fP \fIlastversion\fP \fIpackage\fP \-\- "$@"
  90. .P
  91. \fIoldconffile\fP and \fInewconffile\fP are the old and new name of the
  92. conffile to rename. \fIlastversion\fP is the last version of the package
  93. that contained the conffile with the old name. If \fIlastversion\fP is
  94. empty or omitted, then the operation is tried on every upgrade (note: it's
  95. safer to give the version and have the operation tried only once). \fIpackage\fP
  96. is the package name, it's optional as it will default to
  97. $DPKG_MAINTSCRIPT_PACKAGE (this variable is set by dpkg to the name of the
  98. package acted upon). All the parameters of the maintainer scripts have to
  99. be forwarded to the program after "\-\-".
  100. .P
  101. Current implementation: the \fBpreinst\fP checks if the conffile has been
  102. modified, if yes it's left on place otherwise it's renamed to
  103. \fIoldconffile\fP\fB.dpkg\-remove\fP. On configuration, the \fBpostinst\fP
  104. removes \fIoldconffile\fP\fB.dpkg\-remove\fP and renames \fIoldconffile\fP
  105. to \fInewconffile\fP if \fIoldconffile\fP is still available. On
  106. abort\-upgrade/abort\-install, the \fBpostrm\fP renames
  107. \fIoldconffile\fP\fB.dpkg\-remove\fP back to \fIoldconffile\fP if required.
  108. .
  109. .SH INTEGRATION IN PACKAGES
  110. .P
  111. Given that \fBdpkg\-maintscript\-helper\fP is used in the \fBpreinst\fP,
  112. using it unconditionally requires a pre-dependency to ensure that the
  113. required version of dpkg has been unpacked before. The required version
  114. depends on the command used, for \fBrm_conffile\fP and \fBmv_conffile\fP
  115. it is 1.15.7.2:
  116. .P
  117. \fBPre\-Depends:\fP dpkg (>= 1.15.7.2)
  118. .P
  119. But in many cases the operation done by the program is not critical for
  120. the package, and instead of using a pre-dependency we can call the
  121. program only if we know that the required command is supported by
  122. the currently installed dpkg:
  123. .P
  124. if dpkg\-maintscript\-helper supports \fIcommand\fP; then
  125. dpkg\-maintscript\-helper \fIcommand\fP ...
  126. fi
  127. .
  128. .SH AUTHORS
  129. Copyright \(co 2010 Rapha\[:e]l Hertzog
  130. .br
  131. Copyright \(co 2008 Joey Hess
  132. .br
  133. Copyright \(co 2007 Guillem Jover
  134. .br
  135. Copyright \(co 2005 Scott James Remnant
  136. .sp
  137. This is free software; see the GNU General Public Licence version 2 or
  138. later for copying conditions. There is NO WARRANTY.