0001-make-iproute2-fhs-compliant.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. From f0624f6cc656cb177b64e2664f2a806221bfab58 Mon Sep 17 00:00:00 2001
  2. From: Christian Hesse <mail@eworm.de>
  3. Date: Thu, 28 Jul 2016 08:49:20 +0200
  4. Subject: [PATCH 1/1] make iproute2 fhs compliant
  5. Signed-off-by: Christian Hesse <mail@eworm.de>
  6. ---
  7. Makefile | 2 +-
  8. netem/Makefile | 4 ++--
  9. tc/q_netem.c | 2 +-
  10. tc/tc_util.c | 15 +++++++++++++++
  11. tc/tc_util.h | 1 +
  12. 5 files changed, 20 insertions(+), 4 deletions(-)
  13. diff --git a/Makefile b/Makefile
  14. index eb571a5..db0a04c 100644
  15. --- a/Makefile
  16. +++ b/Makefile
  17. @@ -14,7 +14,7 @@ DBM_INCLUDE:=$(DESTDIR)/usr/include
  18. SHARED_LIBS = y
  19. -DEFINES= -DRESOLVE_HOSTNAMES -DLIBDIR=\"$(LIBDIR)\"
  20. +DEFINES= -DRESOLVE_HOSTNAMES -DLIBDIR=\"$(LIBDIR)\" -DDATADIR=\"$(DATADIR)\"
  21. ifneq ($(SHARED_LIBS),y)
  22. DEFINES+= -DNO_SHARED_LIBS
  23. endif
  24. diff --git a/netem/Makefile b/netem/Makefile
  25. index e52e125..5b4d283 100644
  26. --- a/netem/Makefile
  27. +++ b/netem/Makefile
  28. @@ -20,9 +20,9 @@ stats: stats.c
  29. $(HOSTCC) $(CCOPTS) -I../include -o $@ $@.c -lm
  30. install: all
  31. - mkdir -p $(DESTDIR)$(LIBDIR)/tc
  32. + mkdir -p $(DESTDIR)$(DATADIR)/tc
  33. for i in $(DISTDATA); \
  34. - do install -m 644 $$i $(DESTDIR)$(LIBDIR)/tc; \
  35. + do install -m 644 $$i $(DESTDIR)$(DATADIR)/tc; \
  36. done
  37. clean:
  38. diff --git a/tc/q_netem.c b/tc/q_netem.c
  39. index 8fe2204..a15a5c7 100644
  40. --- a/tc/q_netem.c
  41. +++ b/tc/q_netem.c
  42. @@ -113,7 +113,7 @@ static int get_distribution(const char *type, __s16 *data, int maxdata)
  43. char *line = NULL;
  44. char name[128];
  45. - snprintf(name, sizeof(name), "%s/%s.dist", get_tc_lib(), type);
  46. + snprintf(name, sizeof(name), "%s/%s.dist", get_tc_datadir(), type);
  47. if ((f = fopen(name, "r")) == NULL) {
  48. fprintf(stderr, "No distribution data for %s (%s: %s)\n",
  49. type, name, strerror(errno));
  50. diff --git a/tc/tc_util.c b/tc/tc_util.c
  51. index afc4cf5..728b854 100644
  52. --- a/tc/tc_util.c
  53. +++ b/tc/tc_util.c
  54. @@ -32,6 +32,10 @@
  55. #define LIBDIR "/usr/lib"
  56. #endif
  57. +#ifndef DATADIR
  58. +#define DATADIR "/usr/share"
  59. +#endif
  60. +
  61. static struct db_names *cls_names;
  62. #define NAMES_DB "/etc/iproute2/tc_cls"
  63. @@ -73,6 +77,17 @@ const char *get_tc_lib(void)
  64. return lib_dir;
  65. }
  66. +const char *get_tc_datadir(void)
  67. +{
  68. + const char *data_dir;
  69. +
  70. + data_dir = getenv("TC_DATA_DIR");
  71. + if (!data_dir)
  72. + data_dir = DATADIR "/tc/";
  73. +
  74. + return data_dir;
  75. +}
  76. +
  77. int get_qdisc_handle(__u32 *h, const char *str)
  78. {
  79. __u32 maj;
  80. diff --git a/tc/tc_util.h b/tc/tc_util.h
  81. index 61e60b1..6d448de 100644
  82. --- a/tc/tc_util.h
  83. +++ b/tc/tc_util.h
  84. @@ -55,6 +55,7 @@ struct exec_util {
  85. };
  86. const char *get_tc_lib(void);
  87. +const char *get_tc_datadir(void);
  88. struct qdisc_util *get_qdisc_kind(const char *str);
  89. struct filter_util *get_filter_kind(const char *str);