summaryrefslogtreecommitdiff
blob: 7ad678c4ff900b00df4cab9c8369106bfa192f1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
Index: vzctl-3.0.11/src/Makefile
===================================================================
--- vzctl-3.0.11.orig/src/Makefile
+++ vzctl-3.0.11/src/Makefile
@@ -17,7 +17,7 @@
      INSTALL = install
       PREFIX = /usr
      SBINDIR = $(PREFIX)/sbin
-      LIBDIR = $(PREFIX)/lib/vzctl/lib
+      LIBDIR = $(PREFIX)/lib
      CONFDIR = /etc/vz
    GLBCONFIG = $(CONFDIR)/vz.conf
   VPSCONFDIR = $(CONFDIR)/conf
@@ -33,7 +33,7 @@ NETSCRIPTDIR = /etc/sysconfig/network-sc
    VZDUMPDIR = $(VZDIR)/dump
  VEIPDUMPDIR = /var/lib/vzctl/veip
      LOGRDIR = /etc/logrotate.d
-     LIB_VER = 0.0.2
+     LIB_VER = 0.0.3
 
 export LD_LIBRARY_PATH=.
 CC = gcc
@@ -43,13 +43,14 @@ SHAREDLIB_CFLAGS = -fPIC
 INC = -I ../include
 ARCH ?= $(shell uname -m)
 
-OBJ_libvzctl = lib/env.lo lib/ub.lo lib/net.lo lib/logger.lo lib/exec.lo \
+OBJ_libvzctl = lib/env.lo lib/ub.lo lib/net.lo lib/exec.lo \
 	lib/cap.lo lib/cpu.lo lib/res.lo lib/util.lo lib/dist.lo lib/list.lo \
 	lib/script.lo lib/dev.lo lib/config.lo lib/lock.lo lib/quota.lo \
 	lib/modules.lo lib/iptables.lo lib/fs.lo lib/create.lo lib/readelf.lo \
 	lib/cpt.lo lib/destroy.lo lib/vps_configure.lo lib/meminfo.lo \
 	lib/veth.lo
 OBJ_simfs=lib/fs_simfs.lo
+OBJ_logger = lib/logger.lo
 OBJ_vzctl = vzctl.o vzctl-actions.o modules.o enter.o
 OBJ_vzlist = vzlist.o
 OBJ_arp = arpsend.o
@@ -59,17 +60,17 @@ OBJ_cfgvalidate = vzcfgvalidate.o valida
 OBJ_calc = vzcalc.o
 OBJ = $(OBJ_vzctl) $(OBJ_vzlist) $(OBJ_arp) $(OBJ_split) $(OBJ_memcheck) \
 	$(OBJ_cfgvalidate) $(OBJ_calc)
-LOBJ = $(OBJ_libvzctl) $(OBJ_simfs)
+LOBJ = $(OBJ_libvzctl) $(OBJ_simfs) $(OBJ_logger)
 LIB_vzctl = libvzctl.so.$(LIB_VER)
 LIB_simfs = libvzctl-simfs.so.$(LIB_VER)
+LIB_logger = libvzlogger.so.$(LIB_VER)
 LIB_fs = $(LIB_simfs)
 
-LDFLAGS += -Wl,-rpath=$(LIBDIR)
 LIBSCRIPTS = vps-create vps-postcreate vps-net_add vps-net_del vps-stop \
      vps-functions
 
 PROGS = vzctl vzlist arpsend vzsplit vzcfgvalidate vzmemcheck vzcalc
-LIBS = $(LIB_vzctl) $(LIB_fs)
+LIBS = $(LIB_vzctl) $(LIB_fs) $(LIB_logger)
 
 INITSCRIPTS = vz
 CRONSCRIPTS = vpsreboot vpsnetclean
@@ -102,23 +103,26 @@ check-version:
 %.lo: %.c
 	$(CC) -c $(CFLAGS) $(SHAREDLIB_CFLAGS) $(INC) $< -o $@
 
-$(LIB_fs) : $(OBJ_simfs) lib/logger.lo 
-	$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -shared -o $@
+$(LIB_logger) : $(OBJ_logger)
+	$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -shared -Wl,-soname,$@ -o $@
 
-libvzctl.a: $(OBJ_libvzctl) $(LIB_fs)
+$(LIB_fs) : $(OBJ_simfs) $(LIB_logger)
+	$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -shared -Wl,-soname,$@ -o $@
+
+$(LIB_vzctl) : $(OBJ_libvzctl) $(LIB_fs) $(LIB_logger)
+	$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ $(LD_FLAGS) -shared -Wl,-soname,$@ -o $@
+
+libvzctl.a: $(OBJ_libvzctl) $(OBJ_simfs) $(OBJ_logger)
 	ar scq $@ $+
 	ranlib $@
 
-$(LIB_vzctl) : $(LIB_fs) $(OBJ_libvzctl)
-	$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ $(LD_FLAGS) -shared -o $@
-
 vzctl-static: $(OBJ_vzctl) libvzctl.a
 	$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -rdynamic -ldl -lutil -o $@
 
-vzctl: check-version $(OBJ_vzctl) $(LIB_vzctl) $(LIB_fs)
-	$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $(OBJ_vzctl) $(LIB_vzctl) $(LIB_fs) -ldl -lutil -o $@
+vzctl: check-version $(OBJ_vzctl) $(LIB_vzctl) $(LIB_fs) $(LIB_logger)
+	$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $(OBJ_vzctl) $(LIB_vzctl) $(LIB_fs) $(LIB_logger) -ldl -lutil -o $@
 
-vzlist: $(OBJ_vzlist) $(LIB_vzctl) $(LIB_fs)
+vzlist: $(OBJ_vzlist) $(LIB_vzctl) $(LIB_logger)
 	$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -o $@
 
 arpsend: $(OBJ_arp)
@@ -127,10 +131,10 @@ arpsend: $(OBJ_arp)
 vzsplit: $(OBJ_split)
 	$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -o $@
 
-vzmemcheck: $(OBJ_memcheck) $(LIB_vzctl)
+vzmemcheck: $(OBJ_memcheck) $(LIB_vzctl) $(LIB_logger)
 	$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -o $@
 
-vzcfgvalidate: $(OBJ_cfgvalidate) $(LIB_vzctl)
+vzcfgvalidate: $(OBJ_cfgvalidate) $(LIB_vzctl) $(LIB_logger)
 	$(CC) $(CFLAGS) $(INC) $(LDFLAGS) $^ -o $@
 
 vzcalc: $(OBJ_calc) $(LIB_vzctl)
@@ -145,6 +149,7 @@ install-lib: $(LIB_vzctl) $(LIB_fs)
 	$(INSTALL) -d $(DESTDIR)$(LIBSCRIPTSDIR)
 	$(INSTALL) $(LIB_vzctl) $(DESTDIR)$(LIBDIR)/$(LIB_vzctl)
 	$(INSTALL) $(LIB_fs) $(DESTDIR)$(LIBDIR)/$(LIB_fs)
+	$(INSTALL) $(LIB_logger) $(DESTDIR)$(LIBDIR)/$(LIB_logger)
 	for file in $(LIBSCRIPTS); do 					\
 		$(INSTALL) -m 755 ../etc/$$file $(DESTDIR)$(LIBSCRIPTSDIR)/$$file; \
 	done
@@ -208,7 +213,7 @@ inst-dirs:
 install: $(PROGS) inst-dirs install-lib inst-sbin inst-scripts \
 	inst-netscripts inst-configs inst-initd inst-cron 
 clean:
-	rm -f *.o lib/*.lo $(PROGS) $(LIB_vzctl) $(LIB_fs) $(LIB_fs) .depend
+	rm -f *.o lib/*.lo $(PROGS) $(LIB_vzctl) $(LIB_fs) $(LIB_logger) .depend
 
 .depend:: $(OBJ:.o=.c) $(LOBJ:.lo=.c)
 	$(CC) -M $(FLAGS) $(DEPFLAGS) $(INC) $^ >.depend
Index: vzctl-3.0.11/src/lib/logger.c
===================================================================
--- vzctl-3.0.11.orig/src/lib/logger.c
+++ vzctl-3.0.11/src/lib/logger.c
@@ -30,7 +30,7 @@
 #include "types.h"
 #include "logger.h"
 
-extern log_param g_log;
+LOG_DATA
 
 static inline void get_date(char *buf, int len)
 {
Index: vzctl-3.0.11/src/vzcalc.c
===================================================================
--- vzctl-3.0.11.orig/src/vzcalc.c
+++ vzctl-3.0.11/src/vzcalc.c
@@ -27,8 +27,6 @@
 #include "config.h"
 #include "util.h"
 
-LOG_DATA
-
 void usage()
 {
 	printf("Usage: vzcalc [-v] <veid>\n");
Index: vzctl-3.0.11/src/vzcfgvalidate.c
===================================================================
--- vzctl-3.0.11.orig/src/vzcfgvalidate.c
+++ vzctl-3.0.11/src/vzcfgvalidate.c
@@ -26,8 +26,6 @@
 #include "validate.h"
 #include "logger.h"
 
-log_param g_log;
-
 void usage()
 {
 	printf("Usage: vzcfgvalidate [-r|-i] <configfile>\n");
Index: vzctl-3.0.11/src/vzctl.c
===================================================================
--- vzctl-3.0.11.orig/src/vzctl.c
+++ vzctl-3.0.11/src/vzctl.c
@@ -32,8 +32,6 @@
 #include "util.h"
 #include "modules.h"
 
-LOG_DATA
-
 struct mod_action g_action;
 char *_proc_title;
 int _proc_title_len;
Index: vzctl-3.0.11/src/vzlist.c
===================================================================
--- vzctl-3.0.11.orig/src/vzlist.c
+++ vzctl-3.0.11/src/vzlist.c
@@ -42,7 +42,6 @@
 #include "util.h"
 #include "types.h"
 
-LOG_DATA
 static struct Cveinfo *veinfo = NULL; 
 static int n_veinfo = 0;
 
Index: vzctl-3.0.11/src/vzmemcheck.c
===================================================================
--- vzctl-3.0.11.orig/src/vzmemcheck.c
+++ vzctl-3.0.11/src/vzmemcheck.c
@@ -29,8 +29,6 @@
 #include "util.h"
 #include "logger.h"
 
-LOG_DATA
-
 void usage()
 {
 	printf("Usage: vzmemcheck [-v] [-A]\n");
Index: vzctl-3.0.11/vzctl.spec
===================================================================
--- vzctl-3.0.11.orig/vzctl.spec
+++ vzctl-3.0.11/vzctl.spec
@@ -5,9 +5,10 @@
 %define _dumpdir %{_vzdir}/dump 
 %define _cachedir %{_vzdir}/template/cache 
 %define _veipdir /var/lib/vzctl/veip 
-%define _libdir /usr/lib/vzctl
+%define _libvzdir /usr/lib/vzctl
+%define _libscriptdir %{_libvzdir}/scripts
 %define _configdir /etc/vz
-%define _scriptdir /usr/share/vzctl//scripts
+%define _scriptdir /usr/share/vzctl/scripts
 %define _vpsconfdir /etc/sysconfig/vz-scripts
 %define _netdir	/etc/sysconfig/network-scripts
 %define _logrdir /etc/logrotate.d
@@ -156,13 +157,17 @@ Virtual Private Servers control API libr
 
 %files lib
 %defattr(-,root,root)
-%dir %{_libdir}/lib
-%attr(755,root,root) %{_libdir}/lib/libvzctl.so.*
-%attr(755,root,root) %{_libdir}/lib/libvzctl-simfs.so.*
-%attr(755,root,root) %{_libdir}/scripts/vps-stop
-%attr(755,root,root) %{_libdir}/scripts/vps-functions
-%attr(755,root,root) %{_libdir}/scripts/vps-net_add
-%attr(755,root,root) %{_libdir}/scripts/vps-net_del
-%attr(755,root,root) %{_libdir}/scripts/vps-create
-%attr(755,root,root) %{_libdir}/scripts/vps-postcreate
+%attr(755,root,root) %{_libdir}/libvzlogger.so.*
+%attr(755,root,root) %{_libdir}/libvzctl.so.*
+%attr(755,root,root) %{_libdir}/libvzctl-simfs.so.*
+%dir %{_libvzdir}
+%dir %{_libscriptdir}
+%attr(755,root,root) %{_libscriptdir}/vps-stop
+%attr(755,root,root) %{_libscriptdir}/vps-functions
+%attr(755,root,root) %{_libscriptdir}/vps-net_add
+%attr(755,root,root) %{_libscriptdir}/vps-net_del
+%attr(755,root,root) %{_libscriptdir}/vps-create
+%attr(755,root,root) %{_libscriptdir}/vps-postcreate
 
+%post lib -p /sbin/ldconfig
+%postun lib -p /sbin/ldconfig