int pkg_register_shlibs(struct pkg *pkg, const char *root) { struct pkg_file *file = NULL; char fpath[MAXPATHLEN]; pkg_list_free(pkg, PKG_SHLIBS_REQUIRED); if (elf_version(EV_CURRENT) == EV_NONE) return (EPKG_FATAL); shlib_list_init(); if (shlib_list_from_elf_hints(_PATH_ELF_HINTS) != EPKG_OK) { shlib_list_free(); return (EPKG_FATAL); } while(pkg_files(pkg, &file) == EPKG_OK) { if (root != NULL) { snprintf(fpath, sizeof(fpath), "%s%s", root, pkg_file_path(file)); analyse_elf(pkg, fpath, add_shlibs_to_pkg, NULL); } else analyse_elf(pkg, pkg_file_path(file), add_shlibs_to_pkg, NULL); } shlib_list_free(); return (EPKG_OK); }
int pkg_register_shlibs(struct pkg *pkg) { struct pkg_file *file = NULL; bool shlibs; pkg_config_bool(PKG_CONFIG_SHLIBS, &shlibs); pkg_list_free(pkg, PKG_SHLIBS_REQUIRED); if (!shlibs) return (EPKG_OK); if (elf_version(EV_CURRENT) == EV_NONE) return (EPKG_FATAL); shlib_list_init(); if (shlib_list_from_elf_hints(_PATH_ELF_HINTS) != EPKG_OK) { shlib_list_free(); return (EPKG_FATAL); } while(pkg_files(pkg, &file) == EPKG_OK) analyse_elf(pkg, pkg_file_path(file), add_shlibs_to_pkg, NULL); shlib_list_free(); return (EPKG_OK); }
int pkg_analyse_files(struct pkgdb *db, struct pkg *pkg) { struct pkg_file *file = NULL; int ret = EPKG_OK; const char *fpath; bool shlibs = false; bool autodeps = false; bool developer = false; int (*action)(void *, struct pkg *, const char *, const char *, bool); pkg_config_bool(PKG_CONFIG_SHLIBS, &shlibs); pkg_config_bool(PKG_CONFIG_AUTODEPS, &autodeps); pkg_config_bool(PKG_CONFIG_DEVELOPER_MODE, &developer); if (!autodeps && !shlibs && !developer) return (EPKG_OK); if (elf_version(EV_CURRENT) == EV_NONE) return (EPKG_FATAL); if (autodeps) action = test_depends; else if (shlibs) action = add_shlibs_to_pkg; else action = do_nothing; if (autodeps || shlibs) { shlib_list_init(); ret = shlib_list_from_elf_hints(_PATH_ELF_HINTS); if (ret != EPKG_OK) goto cleanup; } /* Assume no architecture dependence, for contradiction */ if (developer) pkg->flags &= ~(PKG_CONTAINS_ELF_OBJECTS | PKG_CONTAINS_STATIC_LIBS | PKG_CONTAINS_H_OR_LA); while (pkg_files(pkg, &file) == EPKG_OK) { fpath = pkg_file_path(file); ret = analyse_elf(pkg, fpath, action, db); if (developer) { if (ret != EPKG_OK && ret != EPKG_END) goto cleanup; analyse_fpath(pkg, fpath); } } ret = EPKG_OK; cleanup: if (autodeps || shlibs) shlib_list_free(); return (ret); }
int pkg_analyse_files(struct pkgdb *db, struct pkg *pkg, const char *stage) { struct pkg_file *file = NULL; int ret = EPKG_OK; char fpath[MAXPATHLEN]; bool autodeps = false; bool developer = false; int (*action)(void *, struct pkg *, const char *, const char *, bool); pkg_config_bool(PKG_CONFIG_AUTODEPS, &autodeps); pkg_config_bool(PKG_CONFIG_DEVELOPER_MODE, &developer); if (elf_version(EV_CURRENT) == EV_NONE) return (EPKG_FATAL); if (autodeps) action = test_depends; else action = add_shlibs_to_pkg; shlib_list_init(); ret = shlib_list_from_elf_hints(_PATH_ELF_HINTS); if (ret != EPKG_OK) goto cleanup; /* Assume no architecture dependence, for contradiction */ if (developer) pkg->flags &= ~(PKG_CONTAINS_ELF_OBJECTS | PKG_CONTAINS_STATIC_LIBS | PKG_CONTAINS_H_OR_LA); while (pkg_files(pkg, &file) == EPKG_OK) { if (stage != NULL) snprintf(fpath, sizeof(fpath), "%s/%s", stage, pkg_file_path(file)); else strlcpy(fpath, pkg_file_path(file), sizeof(fpath)); ret = analyse_elf(pkg, fpath, action, db); if (developer) { if (ret != EPKG_OK && ret != EPKG_END) goto cleanup; analyse_fpath(pkg, fpath); } } ret = EPKG_OK; cleanup: shlib_list_free(); return (ret); }
int pkg_analyse_files(struct pkgdb *db, struct pkg *pkg, const char *stage) { struct pkg_file *file = NULL; char *sh; khint_t k; int ret = EPKG_OK; char fpath[MAXPATHLEN]; const char *lib; bool failures = false; if (kh_count(pkg->shlibs_required) != 0) pkg_list_free(pkg, PKG_SHLIBS_REQUIRED); if (kh_count(pkg->shlibs_provided) != 0) pkg_list_free(pkg, PKG_SHLIBS_PROVIDED); if (elf_version(EV_CURRENT) == EV_NONE) return (EPKG_FATAL); 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; /* Assume no architecture dependence, for contradiction */ if (developer_mode) pkg->flags &= ~(PKG_CONTAINS_ELF_OBJECTS | PKG_CONTAINS_STATIC_LIBS | PKG_CONTAINS_H_OR_LA); while (pkg_files(pkg, &file) == EPKG_OK) { if (stage != NULL) snprintf(fpath, sizeof(fpath), "%s/%s", stage, file->path); else strlcpy(fpath, file->path, sizeof(fpath)); ret = analyse_elf(pkg, fpath); if (developer_mode) { if (ret != EPKG_OK && ret != EPKG_END) { failures = true; continue; } analyse_fpath(pkg, fpath); } } /* * Do not depend on libraries that a package provides itself */ kh_each_value(pkg->shlibs_required, sh, { if (kh_contains(strings, pkg->shlibs_provided, sh)) { pkg_debug(2, "remove %s from required shlibs as the " "package %s provides this library itself", sh, pkg->name); k = kh_get_strings(pkg->shlibs_required, sh); kh_del_strings(pkg->shlibs_required, k); continue; } file = NULL; while (pkg_files(pkg, &file) == EPKG_OK) { if ((lib = strstr(file->path, sh)) != NULL && strlen(lib) == strlen(sh) && lib[-1] == '/') { pkg_debug(2, "remove %s from required shlibs as " "the package %s provides this library itself", sh, pkg->name); k = kh_get_strings(pkg->shlibs_required, sh); kh_del_strings(pkg->shlibs_required, k); break; } } });