summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install/create/perform.c
diff options
context:
space:
mode:
authorsobomax <sobomax@FreeBSD.org>2001-03-15 10:47:00 +0000
committersobomax <sobomax@FreeBSD.org>2001-03-15 10:47:00 +0000
commit801d4794c43ef1ce0dd0ad2fc50cc62c37ccd254 (patch)
tree494d42bf9a9d558387f64ce96c787ef441418fe0 /usr.sbin/pkg_install/create/perform.c
parent31506730180d3458142004a1c65d53a06429a691 (diff)
downloadFreeBSD-src-801d4794c43ef1ce0dd0ad2fc50cc62c37ccd254.zip
FreeBSD-src-801d4794c43ef1ce0dd0ad2fc50cc62c37ccd254.tar.gz
When creating a package sort dependencies in such a way that if dependency
A depends on dependency B then dependency A will be in all cases listed before B, so ``pkg_add -r'' will fetch/install packages in the correct order. Previously dependencies were sorted just by its names, which is why ``pkg_add -r'' never actually worked properly. To be usefull, hovewer, this fix requires that all packages have been rebuilt, so it will take some time until users would be able to feel posititive improvements. For the same reasons it is desirable to propagate these changes to the 4-stable package building cluster *before* 4.3 ports freeze, so packages for 4.3-RELEASE would be properly prepared. Prompted by: kris Insanely appreciated by: obrien Silently approved by: jkh, -ports
Diffstat (limited to 'usr.sbin/pkg_install/create/perform.c')
-rw-r--r--usr.sbin/pkg_install/create/perform.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c
index 5307698..8d073e4 100644
--- a/usr.sbin/pkg_install/create/perform.c
+++ b/usr.sbin/pkg_install/create/perform.c
@@ -97,16 +97,41 @@ pkg_perform(char **pkgs)
/* Stick the dependencies, if any, at the top */
if (Pkgdeps) {
+ char **deps;
+ int i;
+ int ndeps = 0;
+
if (Verbose && !PlistOnly)
printf("Registering depends:");
- while (Pkgdeps) {
- cp = strsep(&Pkgdeps, " \t\n");
- if (*cp) {
- add_plist_top(&plist, PLIST_PKGDEP, cp);
+
+ /* Count number of dependencies */
+ for (cp = Pkgdeps; cp != NULL && *cp != '\0';
+ cp = strpbrk(++cp, " \t\n")) {
+ ndeps++;
+ }
+
+ if (ndeps != 0) {
+ /* Create easy to use NULL-terminated list */
+ deps = alloca(sizeof(*deps) * ndeps + 1);
+ if (deps == NULL) {
+ errx(2, "%s: alloca() failed", __FUNCTION__);
+ /* Not reached */
+ }
+ for (i = 0; Pkgdeps; i++) {
+ cp = strsep(&Pkgdeps, " \t\n");
+ if (*cp)
+ deps[i] = cp;
+ }
+ deps[ndeps] = NULL;
+
+ sortdeps(deps);
+ for (i = 0; i < ndeps; i++) {
+ add_plist_top(&plist, PLIST_PKGDEP, deps[i]);
if (Verbose && !PlistOnly)
- printf(" %s", cp);
+ printf(" %s", deps[i]);
}
}
+
if (Verbose && !PlistOnly)
printf(".\n");
}
OpenPOWER on IntegriCloud