install-info.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This is distributed in the hope that it will be useful,
  12. * but 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 License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <config.h>
  20. #include <compat.h>
  21. #include <errno.h>
  22. #include <string.h>
  23. #include <unistd.h>
  24. #include <stdlib.h>
  25. #include <stdio.h>
  26. #define SELF "/usr/sbin/install-info"
  27. #define WRAPPED "/usr/bin/install-info"
  28. #define warn(...) fprintf(stderr, "install-info: warning: " __VA_ARGS__)
  29. #define error(...) fprintf(stderr, "install-info: error: " __VA_ARGS__)
  30. int
  31. main(int argc, char **argv)
  32. {
  33. if (strcmp(argv[0], SELF) == 0) {
  34. warn("don't call programs like install-info with an absolute path,\n");
  35. warn("%s provided by dpkg is deprecated and will go away soon;\n",
  36. SELF);
  37. warn("its replacement lives in /usr/bin/.\n");
  38. }
  39. execv(WRAPPED, argv);
  40. if (errno == ENOENT) {
  41. if (getenv("DPKG_RUNNING_VERSION") != NULL) {
  42. const char *pkg;
  43. pkg = getenv("DPKG_MAINTSCRIPT_PACKAGE");
  44. warn("maintainer scripts should not call install-info anymore,\n");
  45. warn("this is handled now by a dpkg trigger provided by the\n");
  46. warn("install-info package; package %s should be updated.\n",
  47. pkg);
  48. } else {
  49. warn("nothing done since %s doesn't exist,\n", WRAPPED);
  50. warn("you might want to install an info-browser package.\n");
  51. }
  52. } else {
  53. error("can't execute %s: %s\n", WRAPPED, strerror(errno));
  54. return 1;
  55. }
  56. return 0;
  57. }