Subversion Repositories prayer

Compare Revisions

Ignore whitespace Rev 100 → Rev 101

/trunk/debian/changelog
1,3 → 1,15
prayer (1.3.2-dfsg1-2) unstable; urgency=low
 
* dlopen_templates.patch:
* templates/{cam,old}/Makefile: Define the symbols template_map and
template_map_count as aliases to the template_$(TYPE)_map and
template_$(TYPE)_map_count when linking, so that template libraries
can be loaded by other names than the original one. Also remove some
cruft.
* shared/dlopen_templates.c: Use those symbols instead.
 
-- Magnus Holmgren <holmgren@debian.org> Sun, 25 Oct 2009 18:50:51 +0100
 
prayer (1.3.2-dfsg1-1) unstable; urgency=low
 
* New upstream release (Closes: #546918).
/trunk/debian/patches/dlopen_templates.patch
3,7 → 3,7
one is unloaded first.
--- /dev/null
+++ b/shared/dlopen_templates.c
@@ -0,0 +1,40 @@
@@ -0,0 +1,34 @@
+#include <dlfcn.h>
+#include "shared.h"
+
21,10 → 21,6
+ if (!handle || strcmp(tmi->name, set)) {
+ char *filename = pool_printf(NIL, "/usr/lib/prayer/templates/%s%s.so",
+ set, suffix);
+ char *map_symbol = pool_printf(NIL, "template_map_%s",
+ set);
+ char *count_symbol = pool_printf(NIL, "template_map_%s_count",
+ set);
+
+ if (handle) {
+ dlclose(handle);
32,15 → 28,13
+ }
+ tmi->name = pool_strdup(NIL, set);
+ if (!(handle = dlopen(filename, RTLD_NOW))
+ || !(tmi->template_map = dlsym(handle, map_symbol))
+ || !(tmi->count = dlsym(handle, count_symbol))) {
+ || !(tmi->template_map = dlsym(handle, "template_map"))
+ || !(tmi->count = dlsym(handle, "template_map_count"))) {
+ log_fatal("Failed to load template library: %s",
+ dlerror());
+ }
+ log_debug("Loaded library %s with %d templates", filename, *tmi->count);
+ free(filename);
+ free(map_symbol);
+ free(count_symbol);
+ }
+ return tmi;
+}
50,8 → 44,15
+struct template_map_index *dlopen_templates(const char *set, const char *suffix);
--- a/templates/cam/Makefile
+++ b/templates/cam/Makefile
@@ -11,7 +11,7 @@ LDFLAGS = $(BASELDFLAGS)
@@ -8,10 +8,14 @@ endif
CFLAGS = $(BASECFLAGS)
LDFLAGS = $(BASELDFLAGS)
+LDFLAGS_TEMPLATELIB = \
+ -Wl,--defsym=template_map=template_map_$(TYPE) \
+ -Wl,--defsym=template_map_count=template_map_$(TYPE)_count
+LDFLAGS += $(LDFLAGS_TEMPLATELIB)
TYPE=cam
-TARGETS=templates.a templates_frontend.a
59,20 → 60,20
T_FILES_FRONTEND=login.t login_hermes.t \
frontend_login_error.t frontend_security.t frontend_session.t \
@@ -111,6 +111,12 @@ templates.a: $(O_FILES)
@@ -111,6 +115,12 @@ templates.a: $(O_FILES)
rm -f templates.a
ar q templates.a $(O_FILES)
+$(TYPE)_frontend.so: $(O_FILES_FRONTEND)
+ $(CC) $(LDFLAGS) -ldl -shared -o $@ $(O_FILES_FRONTEND)
+ $(CC) $(LDFLAGS) -shared -o $@ $(O_FILES_FRONTEND)
+
+$(TYPE).so: $(O_FILES)
+ $(CC) $(LDFLAGS) -ldl -shared -o $@ $(O_FILES)
+ $(CC) $(LDFLAGS) -shared -o $@ $(O_FILES)
+
%.o: %.c Makefile
$(CC) $(CFLAGS) -I../../lib -c $<
@@ -129,8 +135,12 @@ install:
@@ -129,6 +139,10 @@ install:
cp *.t $(BROOT)$(PREFIX)/templates/$(TYPE)
cp *.vars $(BROOT)$(PREFIX)/templates/$(TYPE)
81,15 → 82,19
+ cp *.so $(BROOT)$(LIB_PREFIX)/templates/
+
clean:
- rm -f $(TARGETS) *.html *.o *.c \#*\# *~
+ rm -f $(TARGETS) *.html *.o *.so *.c \#*\# *~
rm -f $(TARGETS) *.html *.o *.c \#*\# *~
include Makefile.deps
--- a/templates/old/Makefile
+++ b/templates/old/Makefile
@@ -11,7 +11,7 @@ LDFLAGS = $(BASELDFLAGS)
@@ -8,10 +8,14 @@ endif
CFLAGS = $(BASECFLAGS)
LDFLAGS = $(BASELDFLAGS)
+LDFLAGS_TEMPLATELIB = \
+ -Wl,--defsym=template_map=template_map_$(TYPE) \
+ -Wl,--defsym=template_map_count=template_map_$(TYPE)_count
+LDFLAGS += $(LDFLAGS_TEMPLATELIB)
TYPE=old
-TARGETS=templates.a templates_frontend.a
97,20 → 102,20
T_FILES_FRONTEND=login.t \
frontend_login_error.t frontend_security.t frontend_session.t \
@@ -110,6 +110,12 @@ templates.a: $(O_FILES)
@@ -110,6 +114,12 @@ templates.a: $(O_FILES)
rm -f templates.a
ar q templates.a $(O_FILES)
+$(TYPE)_frontend.so: $(O_FILES_FRONTEND)
+ $(CC) $(LDFLAGS) -ldl -shared -o $@ $(O_FILES_FRONTEND)
+ $(CC) $(LDFLAGS) -shared -o $@ $(O_FILES_FRONTEND)
+
+$(TYPE).so: $(O_FILES)
+ $(CC) $(LDFLAGS) -ldl -shared -o $@ $(O_FILES)
+ $(CC) $(LDFLAGS) -shared -o $@ $(O_FILES)
+
%.o: %.c Makefile
$(CC) $(CFLAGS) -I../../lib -c $<
@@ -128,8 +134,12 @@ install:
@@ -128,6 +138,10 @@ install:
cp *.t $(BROOT)$(PREFIX)/templates/$(TYPE)
cp *.vars $(BROOT)$(PREFIX)/templates/$(TYPE)
119,11 → 124,8
+ cp *.so $(BROOT)$(LIB_PREFIX)/templates/
+
clean:
- rm -f $(TARGETS) *.html *.o *.c \#*\# *~
+ rm -f $(TARGETS) *.html *.o *.so *.c \#*\# *~
rm -f $(TARGETS) *.html *.o *.c \#*\# *~
include Makefile.deps
--- a/servers/prayer_chroot.c
+++ b/servers/prayer_chroot.c
@@ -255,6 +255,8 @@ int main(int argc, char *argv[])