Instead of runtime compiling during the installation compile this lib in package building and deliver as part of the package. Change-Id: Ic97adb0c958c57976ac5d23974b0efc306ccb326changes/66/23266/20
parent
c860c7f3ec
commit
a91baa2fff
@ -1 +1,2 @@
|
||||
src/fake-uname.so usr/lib/ngcp-deployment-scripts/
|
||||
templates/scripts/* usr/share/ngcp-deployment-scripts/
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
PACKAGE_VERSION := $(shell dpkg-parsechangelog -SVersion -l../debian/changelog)
|
||||
|
||||
CPPFLAGS ?=
|
||||
CPPFLAGS += -DPACKAGE_VERSION="\"$(PACKAGE_VERSION)\""
|
||||
|
||||
CFLAGS ?= -ggdb -O2 -Wall -Wextra -Wno-unused-parameter
|
||||
CFLAGS += -fPIC -ldl
|
||||
|
||||
PLUGIN = fake-uname.so
|
||||
|
||||
$(PLUGIN): fake-uname.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ -shared $<
|
||||
|
||||
clean:
|
||||
$(RM) *.o *.so
|
||||
@ -0,0 +1,44 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#ifndef UTS_RELEASE
|
||||
#define UTS_RELEASE "0.0.0"
|
||||
#endif
|
||||
|
||||
#ifndef RTLD_NEXT
|
||||
#define RTLD_NEXT ((void *) -1l)
|
||||
#endif
|
||||
|
||||
typedef int (*uname_t) (struct utsname * buf);
|
||||
|
||||
static void *get_libc_func(const char *funcname)
|
||||
{
|
||||
void *func;
|
||||
char *error;
|
||||
|
||||
func = dlsym(RTLD_NEXT, funcname);
|
||||
if ((error = dlerror()) != NULL) {
|
||||
fprintf(stderr, "Can't locate libc function '%s' error: %s", funcname, error);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
return func;
|
||||
}
|
||||
|
||||
int uname(struct utsname *buf)
|
||||
{
|
||||
int ret;
|
||||
char *env = NULL;
|
||||
uname_t real_uname = (uname_t) get_libc_func("uname");
|
||||
|
||||
ret = real_uname((struct utsname *) buf);
|
||||
strncpy(buf->release, ((env = getenv("UTS_RELEASE")) == NULL) ? UTS_RELEASE : env, 65);
|
||||
return ret;
|
||||
}
|
||||
Loading…
Reference in new issue