diversions.text 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. (These messages have been edited to conform to the terminology
  2. eventually decided on, and to make them give better and clearer
  3. examples.)
  4. ------- start of digest (2 messages) (RFC 934 encapsulation) -------
  5. Resent-Message-Id: <m0tcceI-0002c6C@chiark.chu.cam.ac.uk>
  6. Resent-From: ijackson (Ian Jackson)
  7. Resent-To: ian
  8. From: ian@chiark.chu.cam.ac.uk (Ian Jackson)
  9. To: Debian developers list <debian-devel@pixar.com>
  10. Subject: `diverting' dpkg for a particular file
  11. Date: Wed, 17 Jan 96 18:31 GMT
  12. I'm almost finished with the implementation of a feature for dpkg that
  13. will allow the sysadmin or package maintainer to prevent dpkg from
  14. overwriting a particular file.
  15. Instead, whenever dpkg finds a package containing that file it
  16. `redirects' the reference to an alternative name.
  17. Eg, if you were to `divert' /usr/sbin/smail to /usr/sbin/smail.real
  18. then any package containing /usr/sbin/smail would have the file placed
  19. as /usr/sbin/smail.real instead. The feature will work during package
  20. removal, as well.
  21. There's provision for a single package to be named which is allowed to
  22. provide a version of the file which will installed under the original
  23. name.
  24. This feature shouldn't be mixed with the conffiles update mechanism,
  25. as this is unlikely to produce useful results and likely to produce
  26. confusion on the part of the user at the very least and possibly on
  27. the part of dpkg too :-).
  28. No package should contain a file whose name is the diverted name of
  29. another file; dpkg will spot this and balk if such a package is
  30. installed when the diversion is in place, or if a diversion is set up
  31. which involves overwriting an existing file whether managed by dpkg
  32. or not (this latter check only happens if dpkg-divert is given the
  33. --rename option which makes it actually rename any copy of the file
  34. found in the filesystem).
  35. Only one diversion for a particular file is allowed, and you can't
  36. divert A to B and then B to C.
  37. [...]
  38. This feature is intended to be used sparingly; a system administrator
  39. can use it to keep a locally-installed version of a piece of system
  40. software that has to live in a particular place.
  41. A package should preferably only use it if the package's main function
  42. is to replace the file in question (whether or not the diverted - ie,
  43. replaced, in this case - version of the file needs to be available);
  44. otherwise a sysadmin might find that the feature wasn't available to
  45. them when they wanted to install their own version of the file because
  46. a package had already done so.
  47. It's possible that I might introduce a facility that would allow
  48. *requests* for redirection of files to be redirected themselves, by
  49. using a special 2nd-level redirection option.
  50. Ian.
  51. ------------------------------
  52. To: debian-devel@Pixar.com
  53. Subject: Re: `overriding' dpkg for a particular file
  54. [...]
  55. Forgive me for being perhaps rather baseic, but here are two examples,
  56. diagrammatically:
  57. 1. Administrator wants to replace a Debian-provided program with
  58. their own version, or wants to put a wrapper around it:
  59. ____________________
  60. smail.deb___________ / \
  61. | ... | |\____________________/|
  62. | /usr/sbin/smail --+----. | |
  63. | ... | \ | / |
  64. |___________________| \ | /usr |
  65. \ | /usr/sbin |
  66. `-------> /usr/sbin/smail.real |
  67. .-------> /usr/sbin/smail |
  68. ~/stuff/smail/wrapper.c / | |
  69. ~/stuff/smail/wrapper ----' \____________________/
  70. # dpkg-divert --divert /usr/sbin/smail.real /usr/sbin/smail
  71. # cp ~fred/stuff/smail/wrapper /usr/sbin/smail
  72. 2. Package maintainer wants to provide an `improved' version of a
  73. file in another package.
  74. fileutils.deb_______ ____________________
  75. | ... | / \
  76. | /bin/ls ----------+----. |\____________________/|
  77. | ... | \ | |
  78. |___________________| \ | / |
  79. \ | /bin |
  80. colour-ls.deb_______ `-------> /bin/ls.mono |
  81. | ... | .--------> /bin/ls |
  82. | /bin/ls ----------+------' | |
  83. | ... | \____________________/
  84. |...................|
  85. |preinst: |
  86. | case "$1" in install)
  87. | dpkg-divert --rename --divert /bin/ls.mono \
  88. | --package colour-ls /bin/ls ;;
  89. | esac |
  90. |...................|
  91. |postrm: |
  92. | case "$1" in remove|abort-install)
  93. | dpkg-divert --remove --rename --divert /bin/ls.mono \
  94. | --package colour-ls /bin/ls ;;
  95. | esac |
  96. |___________________|
  97. We need a name that applies to `/usr/sbin/smail.real' and
  98. `/bin/ls.mono', the filenames, in both situations, and another name
  99. to apply to `/usr/sbin/smail' and `/bin/ls'.
  100. Raul Miller writes ("Re: `overriding' dpkg for a particular file"):
  101. [...]
  102. > Also, it would be nice to see either some documentation or some sort
  103. > of warning about the case where the file is a directory.
  104. If the file is a directory there will be no good effect. This is
  105. because the redirection would affect only the entry for the directory
  106. itself in the packages whose instances if it were being redirected,
  107. and would not affect any of the files in it.
  108. The most likely result is that dpkg will fail to install the package
  109. because one of the directories where it has files doesn't exist. It
  110. would probably create the `diverted' name of the directory, fail, and
  111. then clean it up.
  112. Ian.
  113. ------- end -------