dpkg-maintscript-helper.1 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. .TH dpkg\-maintscript\-helper 1 "2010-04-16" "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 " [" parameters "...] \-\- " maint-script-parameters
  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 DPKG_MAINTSCRIPT_NAME 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. \fIpackage\fP is the package name, it's optional as it will
  60. default to $DPKG_MAINTSCRIPT_PACKAGE (this variable is set by dpkg to the
  61. name of the package acted upon). All the parameters of the maintainer
  62. scripts have to be forwarded to the program after "\-\-".
  63. .P
  64. Current implementation: in the \fBpreinst\fP, it checks if the conffile
  65. was modified and renames it either to \fIconffile\fP\fB.dpkg\-remove\fP (if not
  66. modified) or to \fIconffile\fP\fB.dpkg\-bak\fP (if modified). The latter file is
  67. kept for reference as it contains user modifications but the former will
  68. be removed in the \fBpostinst\fP. If the package upgrade aborts, the
  69. \fBpostrm\fP reinstalls the original conffile. During purge, the
  70. \fBpostrm\fP will also delete the \fB.dpkg\-bak\fP file kept up to now.
  71. .
  72. .SS RENAMING A CONFFILE
  73. .P
  74. If a conffile is moved from one location to another, you need to make sure
  75. you move across any changes the user has made. This may seem a simple
  76. change to the \fBpreinst\fP script at first, however that will result in
  77. the user being prompted by dpkg to approve the conffile edits even though
  78. they are not responsible of them.
  79. .P
  80. Graceful renaming can be implemented by putting the following shell
  81. snippet in the \fBpreinst\fP, \fBpostinst\fP and \fBpostrm\fP maintainer
  82. scripts:
  83. .P
  84. dpkg\-maintscript\-helper mv_conffile \\
  85. \fIoldconffile\fP \fInewconffile\fP \fIlastversion\fP \fIpackage\fP \-\- "$@"
  86. .P
  87. \fIoldconffile\fP and \fInewconffile\fP are the old and new name of the
  88. conffile to rename. \fIlastversion\fP is the last version of the package
  89. that contained the conffile with the old name. \fIpackage\fP is the
  90. package name, it's optional as it will default to
  91. $DPKG_MAINTSCRIPT_PACKAGE (this variable is set by dpkg to the name of the
  92. package acted upon). All the parameters of the maintainer scripts have to
  93. be forwarded to the program after "\-\-".
  94. .P
  95. Current implementation: the \fBpreinst\fP checks if the conffile has been
  96. modified, if yes it's left on place otherwise it's renamed to
  97. \fIoldconffile\fP\fB.dpkg\-remove\fP. On configuration, the \fBpostinst\fP
  98. removes \fIoldconffile\fP\fB.dpkg\-remove\fP and renames \fIoldconffile\fP
  99. to \fInewconffile\fP if \fIoldconffile\fP is still available. On
  100. abort\-upgrade/abort\-install, the \fBpostrm\fP renames
  101. \fIoldconffile\fP\fB.dpkg\-remove\fP back to \fIoldconffile\fP if required.
  102. .
  103. .SH INTEGRATION IN PACKAGES
  104. .P
  105. Given that \fBdpkg\-maintscript\-helper\fP is used in the \fBpreinst\fP,
  106. using it unconditionnaly requires a pre-dependency to ensure that the
  107. required version of dpkg has been configured before. The required version
  108. depends on the command used, for \fBrm_conffile\fP and \fBmv_conffile\fP
  109. it is 1.15.7.2:
  110. .P
  111. Pre-Depends: dpkg (>= 1.15.7.2)
  112. .P
  113. But in many cases the operation done by the program is not critical for
  114. the package, and instead of using a pre-dependency we can call the
  115. program only if we know that the required command is supported by
  116. the currently installed dpkg:
  117. .P
  118. if dpkg-maintscript-helper supports <command>; then
  119. dpkg-maintscript-helper <command> ...
  120. fi
  121. .
  122. .SH AUTHORS
  123. Copyright \(co 2010 Rapha\[:e]l Hertzog
  124. .br
  125. Copyright \(co 2008 Joey Hess
  126. .br
  127. Copyright \(co 2007 Guillem Jover
  128. .br
  129. Copyright \(co 2005 Scott James Remnant
  130. .sp
  131. This is free software; see the GNU General Public Licence version 2 or
  132. later for copying conditions. There is NO WARRANTY.