archrelease: copy trunk to extra-x86_64
[arch-packages.git] / iproute2 / repos / core-x86_64 / 0001-make-iproute2-fhs-compliant.patch
blob2d6a9c966226cbc8a7dc348dec0659b02cbdc801
1 From d8d8dd628302f5bde4f55f11137690bf40abaa88 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
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(-)
14 diff --git a/Makefile b/Makefile
15 index f6214534..f80f46c9 100644
16 --- a/Makefile
17 +++ b/Makefile
18 @@ -32,7 +32,7 @@ DBM_INCLUDE:=$(DESTDIR)/usr/include
20 SHARED_LIBS = y
22 -DEFINES= -DRESOLVE_HOSTNAMES -DLIBDIR=\"$(LIBDIR)\"
23 +DEFINES= -DRESOLVE_HOSTNAMES -DLIBDIR=\"$(LIBDIR)\" -DDATADIR=\"$(DATADIR)\"
24 ifneq ($(SHARED_LIBS),y)
25 DEFINES+= -DNO_SHARED_LIBS
26 endif
27 diff --git a/netem/Makefile b/netem/Makefile
28 index ba4c5a76..cb197afa 100644
29 --- a/netem/Makefile
30 +++ b/netem/Makefile
31 @@ -23,9 +23,9 @@ stats: stats.c
32 $(HOSTCC) $(CCOPTS) -I../include -o $@ $@.c -lm
34 install: all
35 - mkdir -p $(DESTDIR)$(LIBDIR)/tc
36 + mkdir -p $(DESTDIR)$(DATADIR)/tc
37 for i in $(DISTDATA); \
38 - do install -m 644 $$i $(DESTDIR)$(LIBDIR)/tc; \
39 + do install -m 644 $$i $(DESTDIR)$(DATADIR)/tc; \
40 done
42 clean:
43 diff --git a/tc/q_netem.c b/tc/q_netem.c
44 index f45a64b9..83fa952d 100644
45 --- a/tc/q_netem.c
46 +++ b/tc/q_netem.c
47 @@ -128,7 +128,7 @@ static int get_distribution(const char *type, __s16 *data, int maxdata)
48 char *line = NULL;
49 char name[128];
51 - snprintf(name, sizeof(name), "%s/%s.dist", get_tc_lib(), type);
52 + snprintf(name, sizeof(name), "%s/%s.dist", get_tc_datadir(), type);
53 f = fopen(name, "r");
54 if (f == NULL) {
55 fprintf(stderr, "No distribution data for %s (%s: %s)\n",
56 diff --git a/tc/tc_util.c b/tc/tc_util.c
57 index ba34aed7..0adbb9ba 100644
58 --- a/tc/tc_util.c
59 +++ b/tc/tc_util.c
60 @@ -31,6 +31,10 @@
61 #define LIBDIR "/usr/lib"
62 #endif
64 +#ifndef DATADIR
65 +#define DATADIR "/usr/share"
66 +#endif
68 static struct db_names *cls_names;
70 #define NAMES_DB "/etc/iproute2/tc_cls"
71 @@ -72,6 +76,17 @@ const char *get_tc_lib(void)
72 return lib_dir;
75 +const char *get_tc_datadir(void)
77 + const char *data_dir;
79 + data_dir = getenv("TC_DATA_DIR");
80 + if (!data_dir)
81 + data_dir = DATADIR "/tc/";
83 + return data_dir;
86 int get_qdisc_handle(__u32 *h, const char *str)
88 __u32 maj;
89 diff --git a/tc/tc_util.h b/tc/tc_util.h
90 index b197bcdd..e812b895 100644
91 --- a/tc/tc_util.h
92 +++ b/tc/tc_util.h
93 @@ -71,6 +71,7 @@ struct exec_util {
96 const char *get_tc_lib(void);
97 +const char *get_tc_datadir(void);
99 struct qdisc_util *get_qdisc_kind(const char *str);
100 struct filter_util *get_filter_kind(const char *str);
102 2.35.1