diff options
author | Simon Tatham <anakin@pobox.com> | 2017-05-16 07:03:19 +0100 |
---|---|---|
committer | Simon Tatham <anakin@pobox.com> | 2017-05-16 07:03:19 +0100 |
commit | decda92874250a1e25d185fa8fd1f2d2f4b94d20 (patch) | |
tree | f68746732cb47d20ecb89f485b16d8278735e376 | |
parent | 0985b382d387f6868240928db1531b22c0915d24 (diff) | |
download | wix-on-linux-decda92874250a1e25d185fa8fd1f2d2f4b94d20.tar.gz wix-on-linux-decda92874250a1e25d185fa8fd1f2d2f4b94d20.tar.bz2 wix-on-linux-decda92874250a1e25d185fa8fd1f2d2f4b94d20.zip |
Use an LD_PRELOAD library in place of symlink to /home.
Apart from dependency on native-code DLLs, the one other quirk of
running WiX under mono is that it doesn't seem to quite get the right
answers when combining $PWD with a Unix absolute path to one of its
own supporting files - it doesn't interpret the leading slash on the
latter as meaning $PWD should be ignored, so it tries to look for
/home/my/build/dir/home/my/wix/install/dir/some.file. Previously I was
bodging around that by having my build dir contain a symlink 'home'
pointing at /home; this is marginally less intrusive.
-rw-r--r-- | Makefile.wixfakelibs | 4 | ||||
-rw-r--r-- | preload.c | 42 |
2 files changed, 45 insertions, 1 deletions
diff --git a/Makefile.wixfakelibs b/Makefile.wixfakelibs index f53c539..6cce710 100644 --- a/Makefile.wixfakelibs +++ b/Makefile.wixfakelibs | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | .SUFFIXES: .c .lo .la | 3 | .SUFFIXES: .c .lo .la |
4 | 4 | ||
5 | all: libwinterop.so.la libmsi.so.la | 5 | all: libwinterop.so.la libmsi.so.la libpreload.la |
6 | 6 | ||
7 | %.la: | 7 | %.la: |
8 | libtool --mode=link gcc -o $@ $^ -rpath /usr/local/lib | 8 | libtool --mode=link gcc -o $@ $^ -rpath /usr/local/lib |
@@ -14,6 +14,8 @@ libwinterop.so.la: fake-winterop.lo fake-lib.lo | |||
14 | 14 | ||
15 | libmsi.so.la: fake-msi.lo fake-lib.lo | 15 | libmsi.so.la: fake-msi.lo fake-lib.lo |
16 | 16 | ||
17 | libpreload.la: preload.lo | ||
18 | |||
17 | clean: | 19 | clean: |
18 | rm -rf .libs | 20 | rm -rf .libs |
19 | rm -f *.o *.lo *.la | 21 | rm -f *.o *.lo *.la |
diff --git a/preload.c b/preload.c new file mode 100644 index 0000000..1665515 --- /dev/null +++ b/preload.c | |||
@@ -0,0 +1,42 @@ | |||
1 | #define _GNU_SOURCE | ||
2 | #include <stdio.h> | ||
3 | #include <stdlib.h> | ||
4 | #include <string.h> | ||
5 | #include <dlfcn.h> | ||
6 | #include <sys/types.h> | ||
7 | #include <sys/stat.h> | ||
8 | #include <unistd.h> | ||
9 | |||
10 | static const char *munge(const char *n) { | ||
11 | static const char *e = NULL; | ||
12 | static size_t elen; | ||
13 | if (!e) { | ||
14 | e = getenv("WIX"); | ||
15 | if (!e) | ||
16 | return n; | ||
17 | elen = strlen(e); | ||
18 | } | ||
19 | |||
20 | const char *last_slash = strrchr(n, '/'); | ||
21 | if (!last_slash) | ||
22 | return n; | ||
23 | if (last_slash - n > elen && !strncmp(last_slash - elen, e, elen)) | ||
24 | return last_slash - elen; | ||
25 | return n; | ||
26 | } | ||
27 | |||
28 | #define dofunc(rettype,sym,proto,proto2) \ | ||
29 | rettype sym proto { \ | ||
30 | rettype (*real) proto; \ | ||
31 | real = dlsym(RTLD_NEXT, #sym); \ | ||
32 | fname = munge(fname); \ | ||
33 | return real proto2; \ | ||
34 | } | ||
35 | |||
36 | dofunc(int,open,(const char *fname,int flags,mode_t mode),(fname,flags,mode)) | ||
37 | dofunc(int,open64,(const char *fname,int flags,mode_t mode),(fname,flags,mode)) | ||
38 | dofunc(int,__open,(const char *fname,int flags,mode_t mode),(fname,flags,mode)) | ||
39 | dofunc(int,__open64,(const char *fname,int flags,mode_t mode),(fname,flags,mode)) | ||
40 | dofunc(int,stat,(const char *fname,struct stat *sbuf),(fname,sbuf)) | ||
41 | dofunc(int,lstat,(const char *fname,struct stat *sbuf),(fname,sbuf)) | ||
42 | dofunc(int,access,(const char *fname,int mode),(fname,mode)) | ||