static void add_required_by(const char *pattern, const char *required_by) { char *best_installed, *path; int fd; size_t len; best_installed = find_best_matching_installed_pkg(pattern); if (best_installed == NULL) { warnx("Dependency %s of %s unresolved", pattern, required_by); return; } path = pkgdb_pkg_file(best_installed, REQUIRED_BY_FNAME); free(best_installed); if ((fd = open(path, O_WRONLY | O_APPEND | O_CREAT, 0644)) == -1) errx(EXIT_FAILURE, "Cannot write to %s", path); free(path); len = strlen(required_by); if (write(fd, required_by, len) != (ssize_t)len || write(fd, "\n", 1) != 1 || close(fd) == -1) errx(EXIT_FAILURE, "Cannot write to %s", path); }
static void register_depends(package_t *plist, char *deps, int build_only) { char *cp; if (Verbose && !PlistOnly) { if (build_only) printf("Registering build depends:"); else printf("Registering depends:"); } while (deps) { cp = strsep(&deps, " \t\n"); if (*cp) { char *best_installed; best_installed = find_best_matching_installed_pkg(cp); if (best_installed != NULL) { add_plist(plist, PLIST_BLDDEP, best_installed); if (Verbose && !PlistOnly && build_only) printf(" %s", cp); } else warnx("No matching package installed for %s", cp); free(best_installed); if (!build_only) { add_plist(plist, PLIST_PKGDEP, cp); if (Verbose && !PlistOnly) printf(" %s", cp); } } } if (Verbose && !PlistOnly) printf(".\n"); }