install-info.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * install-info.c - transitional ginstall-info wrapper
  3. *
  4. * Copyright © 2009 Raphaël Hertzog <hertzog@debian.org>
  5. *
  6. * This is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2,
  9. * or (at your option) any later version.
  10. *
  11. * This is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public
  17. * License along with dpkg; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20. #include <config.h>
  21. #include <unistd.h>
  22. #include <errno.h>
  23. #include <string.h>
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #define SELF "/usr/sbin/install-info"
  27. #define WRAPPED "/usr/bin/install-info"
  28. #if HAVE_C99
  29. #define warn(...) fprintf(stderr, "install-info: warning: " __VA_ARGS__)
  30. #define error(...) fprintf(stderr, "install-info: error: " __VA_ARGS__)
  31. #else
  32. #define warn(msg...) fprintf(stderr, "install-info: warning: " msg)
  33. #define error(msg...) fprintf(stderr, "install-info: error: " msg)
  34. #endif
  35. int
  36. main(int argc, char **argv)
  37. {
  38. if (strcmp(argv[0], SELF) == 0) {
  39. warn("don't call programs like install-info with an absolute path,\n");
  40. warn("%s provided by dpkg is deprecated and will go away soon;\n",
  41. SELF);
  42. warn("its replacement lives in /usr/bin/.\n");
  43. }
  44. if (access(WRAPPED, X_OK) == 0) {
  45. execv(WRAPPED, argv);
  46. error("can't execute %s: %s\n", WRAPPED, strerror(errno));
  47. return 1; /* exec failed */
  48. } else {
  49. if (errno == ENOENT) {
  50. if (getenv("DPKG_RUNNING_VERSION") != NULL) {
  51. const char *pkg;
  52. pkg = getenv("DPKG_MAINTSCRIPT_PACKAGE");
  53. warn("maintainer scripts should not call install-info anymore,\n");
  54. warn("this is handled now by a dpkg trigger provided by the\n");
  55. warn("install-info package; package %s should be updated.\n",
  56. pkg);
  57. } else {
  58. warn("nothing done since %s doesn't exist,\n", WRAPPED);
  59. warn("you might want to install an info-browser package.\n");
  60. }
  61. } else {
  62. error("can't execute %s: %s\n", WRAPPED, strerror(errno));
  63. return 1;
  64. }
  65. }
  66. return 0;
  67. }