Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fix analyzing elf from a stage directory
Baptiste Daroussin committed 12 years ago
commit b9882e41a150fa928c182e0ab3d03483bb03c311
parent 7d5a634
4 files changed +19 -6
modified libpkg/pkg.h.in
@@ -638,7 +638,7 @@ struct pkg_note *pkg_annotation_lookup(const struct pkg *p, const char *tag);
#define PKG_CONTAINS_STATIC_LIBS	(1U << 25)
#define PKG_CONTAINS_H_OR_LA		(1U << 26)

-
int pkg_analyse_files(struct pkgdb *, struct pkg *);
+
int pkg_analyse_files(struct pkgdb *, struct pkg *, const char *);

/**
 * Suggest if a package could be marked architecture independent or
modified libpkg/pkg_elf.c
@@ -87,6 +87,8 @@ add_shlibs_to_pkg(__unused void *actdata, struct pkg *pkg, const char *fpath,
		  const char *name, bool is_shlib)
{
	const char *pkgname, *pkgversion;
+
	struct pkg_file *file = NULL;
+
	const char *filepath;

	switch(filter_system_shlibs(name, NULL, 0)) {
	case EPKG_OK:		/* A non-system library */
@@ -100,6 +102,14 @@ add_shlibs_to_pkg(__unused void *actdata, struct pkg *pkg, const char *fpath,
		if (is_shlib)
			return (EPKG_OK);

+
		while (pkg_files(pkg, &file) == EPKG_OK) {
+
			filepath = pkg_file_path(file);
+
			if (strcmp(&filepath[strlen(filepath) - strlen(name)], name) == 0) {
+
				pkg_addshlib_required(pkg, name);
+
				return (EPKG_OK);
+
			}
+
		}
+

		pkg_get(pkg, PKG_NAME, &pkgname, PKG_VERSION, &pkgversion);
		warnx("(%s-%s) %s - shared library %s not found",
		      pkgname, pkgversion, fpath, name);
@@ -374,11 +384,11 @@ analyse_fpath(struct pkg *pkg, const char *fpath)
}

int
-
pkg_analyse_files(struct pkgdb *db, struct pkg *pkg)
+
pkg_analyse_files(struct pkgdb *db, struct pkg *pkg, const char *stage)
{
	struct pkg_file *file = NULL;
	int ret = EPKG_OK;
-
	const char *fpath;
+
	char fpath[MAXPATHLEN];
	bool autodeps = false;
	bool developer = false;
	int (*action)(void *, struct pkg *, const char *, const char *, bool);
@@ -407,7 +417,10 @@ pkg_analyse_files(struct pkgdb *db, struct pkg *pkg)
				PKG_CONTAINS_H_OR_LA);

	while (pkg_files(pkg, &file) == EPKG_OK) {
-
		fpath = pkg_file_path(file);
+
		if (stage != NULL)
+
			snprintf(fpath, MAXPATHLEN, "%s/%s", stage, pkg_file_path(file));
+
		else
+
			strlcpy(fpath, pkg_file_path(file), MAXPATHLEN);

		ret = analyse_elf(pkg, fpath, action, db);
		if (developer) {
modified libpkg/pkgdb.c
@@ -2692,7 +2692,7 @@ pkgdb_reanalyse_shlibs(struct pkgdb *db, struct pkg *pkg)
		return (EPKG_FATAL);
	}

-
	if ((ret = pkg_analyse_files(db, pkg)) == EPKG_OK) {
+
	if ((ret = pkg_analyse_files(db, pkg, NULL)) == EPKG_OK) {
		if (!db->prstmt_initialized &&
		    prstmt_initialize(db) != EPKG_OK)
			return (EPKG_FATAL);
modified pkg/register.c
@@ -285,7 +285,7 @@ exec_register(int argc, char **argv)
	 */

	if (!testing_mode)
-
		pkg_analyse_files(db, pkg);
+
		pkg_analyse_files(db, pkg, input_path);

	pkg_get(pkg, PKG_ARCH, &arch);
	if (arch == NULL) {