upgrades+errors.txt 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. From ian Wed Nov 16 15:12:56 1994
  2. X-VM-v5-Data: ([nil nil nil nil t nil nil nil nil]
  3. [nil "Wed" "16" "November" "1994" "15:12:56" nil "ian" "ian" "" nil "dpkg - upgrades and error handling, take 2" "^To:" nil nil "11" nil nil nil nil]
  4. nil)
  5. To: Debian dpkg list <debian-dpkg@pixar.com>
  6. Subject: dpkg - upgrades and error handling, take 2
  7. Here is a revised scheme for upgrade procedure and error handling.
  8. If you can see any serious problems with this please say so; if there
  9. are no compelling reasons not to I intend to implement the following.
  10. Procedure for new unpack:
  11. * Run the preinst script (argument: `install').
  12. * Back up the conffiles.
  13. * Unpack the files in the package.
  14. This leaves the package in the `unpacked but not configured'
  15. state.
  16. If the preinst fails the installation is aborted immediately, leaving
  17. the package in whatever state it was originally. The preinst should
  18. clean up after its own failure.
  19. If the conffiles can't be backed up then any which have been are
  20. restored to their original names, if possible, and the postrm script
  21. is run if there is one (argument: `abort-install'). This leaves the
  22. package in its original state.
  23. If the unpack fails any files already unpacked are removed, the
  24. conffiles are restored to their original names, and the postrm is run
  25. (argument: `abort-install'). Again, the package remains in its
  26. original state.
  27. Errors found when running the postrm are ignored.
  28. Procedure for configuration:
  29. * Do the conffile updating, including prompting, as in the spec.
  30. * Run the postinst (argument: `configure').
  31. If the conffile updating fails anything that has been done is undone
  32. if possible and the package is left in the `unpacked but not
  33. configured' state.
  34. If the postinst fails dpkg gives up and leaves the package in the
  35. `postinst failed' state. Next time it will just rerun the
  36. postinst; if the postinst has a bug a new *.deb can be provided. In
  37. that case installation of the new *.deb will proceed almost as if it
  38. were a normal upgrade.
  39. Procedure for removal:
  40. * Run the prerm (argument: `remove').
  41. * Delete the files in the package and any resulting empty
  42. directories.
  43. * Run the postrm (argument: `remove').
  44. If the prerm fails dpkg leaves the package in the original state; if
  45. the user asks again to remove the package the prerm will be run again.
  46. If the deletion fails the removal is aborted, and the package left in
  47. the `removal failed' state.
  48. If the postrm fails dpkg leaves the package in the `removal failed'
  49. state.
  50. If the package is in the `removal failed' state to start with it will
  51. start again with deleting the files and empty directories and rerun
  52. the postrm.
  53. If the postrm has a bug a new *.deb must be installed first (using the
  54. upgrade procedure) and then removed. This is so that a working postrm
  55. script is provided.
  56. Procedure for upgrade:
  57. * Run the old prerm script (arguments: `upgrade <new-version>').
  58. * Move aside all existing files (not directories) for the
  59. package being overwritten.
  60. * Run the old postrm script (arguments: `upgrade <new-version>').
  61. * Run the new preinst script (arguments: `upgrade <old-version>').
  62. * Back up the conffiles.
  63. * Unpack the files in the package.
  64. * Remove the files which were moved aside.
  65. This leaves the package in the `unpacked but not configured'
  66. state.
  67. Errors during the removal of the files which were moved aside are
  68. flagged, but don't cause dpkg to attempt to abort the upgrade.
  69. If the old prerm or postrm script fails the corresponding script from
  70. the new package is run instead (arguments: `failed-upgrade
  71. <old-version>'). If there is no corresponding script in the new
  72. package the error is ignored.
  73. If any other stage fails, or if we try to use the script in the new
  74. package because the old prerm/postrm script failed but the new script
  75. fails too, we attempt to undo everything in reverse order, as follows:
  76. Unpacking the files in the package is undone by removing the files we
  77. unpacked and any empty directories, in reverse order. Errors are
  78. ignored.
  79. The conffiles backup is undone as much as possible, ignoring errors.
  80. The new preinst is undone by running the new postrm (arguments:
  81. `abort-upgrade <old-version>'); errors are ignored.
  82. The old postrm is undone by running the old preinst (arguments:
  83. `abort-upgrade <new-version>'); errors are ignored.
  84. Files we backed up are restored if possible; errors here leave the
  85. package in the `removal failed' state.
  86. The old prerm is undone by running the old postinst (arguments:
  87. `abort-upgrade <new-version>'). Errors here leave the package in the
  88. `postinst failed' state.
  89. Ian.
  90. From ian Wed May 17 02:14:09 +0100 1995
  91. X-VM-v5-Data: ([nil nil nil nil nil nil nil nil nil]
  92. [nil nil nil nil nil nil nil nil nil nil nil nil "^To:" nil nil nil nil nil nil nil]
  93. nil)
  94. To: Debian developers list <debian-devel@pixar.com>
  95. Subject: New dpkg overwriting handling
  96. Here is a comment that describes how I plan to have the new C dpkg act
  97. with respect to overwriting, upgrades, &c.
  98. The sequence of events during upgrade will change, because the removal
  99. of the old package and the installation of the new will take place
  100. together. So we have,
  101. (noninteractive, during `dpkg --unpack' ...)
  102. old prerm
  103. new preinst
  104. unpack new archive, possibly overwriting old files
  105. delete any files in the old but not the new package
  106. old postrm
  107. run `postrm disappear' for any vanished packages, then forget them
  108. (interactive, during `dpkg --configure' ...)
  109. conffile updates
  110. new postinst
  111. Furthermore, conffiles will not be backed up before unpack and have
  112. the user's old version hang around as `.dpkg-tmp'; instead, the old
  113. file will be left in place and the new one extracted into `.dpkg-new'.
  114. It will only be installed (if desired) at a conffile update.
  115. Thanks to Bruce for providing nice tar-in-a-function code that will
  116. allow me to handle each file individually rather than having tar splat
  117. them all out (and often do it buggily anyway).
  118. Ian.
  119. /*
  120. * Now we unpack the archive, backing things up as we go.
  121. * For each file, we check to see if it already exists.
  122. * There are several possibilities:
  123. * + We are trying to install a non-directory ...
  124. * - It doesn't exist. In this case we simply extract it.
  125. * - It is a plain file, device, symlink, &c. We do an `atomic
  126. * overwrite' using link() and rename(), but leave a backup copy.
  127. * Later, when we delete the backup, we remove it from any other
  128. * packages' lists.
  129. * - It is a directory. We move it aside and extract the file.
  130. * Later, when we delete the backed-up directory, we remove it
  131. * from any other packages' lists.
  132. * + We are trying to install a directory ...
  133. * - It doesn't exist. We create it with the appropriate modes.
  134. * - It is a plain file or a symlink. We move it aside and create
  135. * the directory. Later, when we delete the backup, we remove it
  136. * from any other packages' lists.
  137. * - It exists as a directory. We do nothing.
  138. *
  139. * Install non-dir Install dir
  140. * Exists not X C
  141. * File/node/symlink LXR BCR
  142. * Directory BXR -
  143. *
  144. * C: create directory
  145. * X: extract file/node/link
  146. * LX: atomic overwrite leaving backup
  147. * B: ordinary backup
  148. * R: later remove from other packages' lists
  149. * -: do nothing
  150. *
  151. * After we've done this we go through the remaining things in the
  152. * lists of packages we're trying to remove (including the old
  153. * version of the current package). This happens in reverse order,
  154. * so that we process files before the directories (or symlinks-to-
  155. * directories) containing them.
  156. * + If the thing is a conffile then we leave it alone for the purge
  157. * operation.
  158. * + Otherwise, there are several possibilities too:
  159. * - The listed thing does not exist. We ignore it.
  160. * - The listed thing is a directory or a symlink to a directory.
  161. * We delete it only if it isn't listed in any other package.
  162. * - The listed thing is not a directory or a symlink to one (ie,
  163. * it's a plain file, device, pipe, &c, or a symlink to one, or a
  164. * dangling symlink). We delete it.
  165. * The removed packages' list becomes empty (of course, the new
  166. * version of the package we're installing will have a new list,
  167. * which replaces the old version's list).
  168. *
  169. * If at any stage we remove a file from a package's list, and the
  170. * package isn't one we're already processing, and the package's
  171. * list becomes empty as a result, we `vanish' the package. This
  172. * means that we run its postrm with the `disappear' argument, and
  173. * put the package in the `not-installed' state. Its conffiles are
  174. * ignored and forgotten about.
  175. *
  176. * NOTE THAT THE OLD POSTRM IS RUN AFTER THE NEW PREINST, since the
  177. * files get replaced `as we go'.
  178. */