Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
In case of ALLOw_BASE_SHLIB append the directories in the staging area corresponding to the base system library directories when looking up for required libs
Baptiste Daroussin committed 10 years ago
commit 74172be8a9af603e931d9c5ba77f68107db9e67b
parent 3ba1f30
3 files changed +30 -3
modified libpkg/elfhints.c
@@ -44,6 +44,7 @@
#include <uthash.h>

#include "pkg.h"
+
#include "private/pkg.h"
#include "private/ldconfig.h"

#define MAXDIRS		1024		/* Maximum directories in path */
@@ -328,6 +329,27 @@ shlib_list_from_elf_hints(const char *hintsfile)
	return (scan_dirs_for_shlibs(&shlibs, ndirs, dirs, true));
}

+
static const char *stage_dirs[] = {
+
	"/lib",
+
	"/usr/lib",
+
};
+

+
void
+
shlib_list_from_stage(const char *stage)
+
{
+
	int i;
+
	char *dir;
+

+
	if (stage == NULL)
+
		return;
+

+
	for (i = 0; i < NELEM(stage_dirs); i++) {
+
		asprintf(&dir, "%s%s", stage, stage_dirs[i]);
+
		scan_dirs_for_shlibs(&shlibs, 1, (const char **)&dir, true);
+
		free(dir);
+
	}
+
}
+

void
list_elf_hints(const char *hintsfile)
{
modified libpkg/pkg_elf.c
@@ -93,9 +93,8 @@ filter_system_shlibs(const char *name, char *path, size_t pathlen)
	}

	if (pkg_object_bool(pkg_config_get("ALLOW_BASE_SHLIBS"))) {
-
		if (strncmp(shlib_path, "/usr/lib32", 10) == 0) {
+
		if (strstr(shlib_path, "/lib32/") != NULL)
			return (EPKG_END);
-
		}
	} else {
		/* match /lib, /lib32, /usr/lib and /usr/lib32 */
		if (strncmp(shlib_path, "/lib", 4) == 0 ||
@@ -107,7 +106,7 @@ filter_system_shlibs(const char *name, char *path, size_t pathlen)
		strncpy(path, shlib_path, pathlen);

	return (EPKG_OK);
-
} 
+
}

/* ARGSUSED */
static int
@@ -463,6 +462,11 @@ pkg_analyse_files(struct pkgdb *db, struct pkg *pkg, const char *stage)

	shlib_list_init();

+
	if (stage != NULL && pkg_object_bool(pkg_config_get("ALLOW_BASE_SHLIBS"))) {
+
		/* Do not check the return */
+
		shlib_list_from_stage(stage);
+
	}
+

	ret = shlib_list_from_elf_hints(_PATH_ELF_HINTS);
	if (ret != EPKG_OK)
		goto cleanup;
modified libpkg/private/ldconfig.h
@@ -68,6 +68,7 @@ void shlib_list_free(void);
void		rpath_list_free(void);
int		shlib_list_from_elf_hints(const char *);
int		shlib_list_from_rpath(const char *, const char *);
+
void		shlib_list_from_stage(const char *);

void		list_elf_hints(const char *);
void		update_elf_hints(const char *, int, char **, int);