deps.c (93520) | deps.c (96076) |
---|---|
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> | 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 $"); | 23__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/lib/deps.c 96076 2002-05-05 21:03:25Z sobomax $"); |
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{ | 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 *cp1, *cp2; |
|
86 char pkgdir[FILENAME_MAX]; 87 int errcode; 88 struct reqr_by_entry *rb_entry; 89 struct reqr_by_head *rb_list; 90 | 87 char pkgdir[FILENAME_MAX]; 88 int errcode; 89 struct reqr_by_entry *rb_entry; 90 struct reqr_by_head *rb_list; 91 |
92 cp2 = strchr(pkgname2, ':'); 93 if (cp2 != NULL) 94 *cp2 = '\0'; 95 cp1 = strchr(pkgname1, ':'); 96 if (cp1 != NULL) 97 *cp1 = '\0'; 98 99 errcode = 0; |
|
91 /* Check that pkgname2 is actually installed */ 92 snprintf(pkgdir, sizeof(pkgdir), "%s/%s", LOG_DIR, pkgname2); 93 if (!isdir(pkgdir)) | 100 /* Check that pkgname2 is actually installed */ 101 snprintf(pkgdir, sizeof(pkgdir), "%s/%s", LOG_DIR, pkgname2); 102 if (!isdir(pkgdir)) |
94 return 0; | 103 goto exit; |
95 96 errcode = requiredby(pkgname2, &rb_list, FALSE, TRUE); 97 if (errcode < 0) | 104 105 errcode = requiredby(pkgname2, &rb_list, FALSE, TRUE); 106 if (errcode < 0) |
98 return errcode; | 107 goto exit; |
99 | 108 |
100 STAILQ_FOREACH(rb_entry, rb_list, link) 101 if (strcmp(rb_entry->pkgname, pkgname1) == 0) /* match */ 102 return 1; | 109 errcode = 0; 110 STAILQ_FOREACH(rb_entry, rb_list, link) { 111 if (strcmp(rb_entry->pkgname, pkgname1) == 0) { /* match */ 112 errcode = 1; 113 break; 114 } 115 } |
103 | 116 |
104 return 0; | 117exit: 118 if (cp1 != NULL) 119 *cp1 = ':'; 120 if (cp2 != NULL) 121 *cp2 = ':'; 122 return errcode; |
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 --- | 123} 124 125/* 126 * Load +REQUIRED_BY file and return a list with names of 127 * packages that require package reffered to by `pkgname'. 128 * 129 * Optionally check that packages listed there are actually 130 * installed and filter out those that don't (filter == TRUE). --- 68 unchanged lines hidden --- |