Deleted Added
sdiff udiff text old ( 93520 ) new ( 96076 )
full compact
1/*
2 * FreeBSD install - a package for the installation and maintainance
3 * of non-core utilities.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 6 unchanged lines hidden (view full) ---

15 * 14 March 2001
16 *
17 * Routines used to do various operations with dependencies
18 * among installed packages.
19 *
20 */
21
22#include <sys/cdefs.h>
23__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/lib/deps.c 93520 2002-04-01 09:39:07Z obrien $");
24
25#include "lib.h"
26#include <err.h>
27#include <stdio.h>
28
29/*
30 * Sort given NULL-terminated list of installed packages (pkgs) in
31 * such a way that if package A depends on package B then after

--- 46 unchanged lines hidden (view full) ---

78
79/*
80 * Check to see if pkgname1 depends on pkgname2.
81 * Returns 1 if depends, 0 if not, and -1 if error occured.
82 */
83int
84chkifdepends(const char *pkgname1, const char *pkgname2)
85{
86 char pkgdir[FILENAME_MAX];
87 int errcode;
88 struct reqr_by_entry *rb_entry;
89 struct reqr_by_head *rb_list;
90
91 /* Check that pkgname2 is actually installed */
92 snprintf(pkgdir, sizeof(pkgdir), "%s/%s", LOG_DIR, pkgname2);
93 if (!isdir(pkgdir))
94 return 0;
95
96 errcode = requiredby(pkgname2, &rb_list, FALSE, TRUE);
97 if (errcode < 0)
98 return errcode;
99
100 STAILQ_FOREACH(rb_entry, rb_list, link)
101 if (strcmp(rb_entry->pkgname, pkgname1) == 0) /* match */
102 return 1;
103
104 return 0;
105}
106
107/*
108 * Load +REQUIRED_BY file and return a list with names of
109 * packages that require package reffered to by `pkgname'.
110 *
111 * Optionally check that packages listed there are actually
112 * installed and filter out those that don't (filter == TRUE).

--- 68 unchanged lines hidden ---