aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_install/create
diff options
context:
space:
mode:
authorMaxim Sobolev <sobomax@FreeBSD.org>2001-03-15 10:47:00 +0000
committerMaxim Sobolev <sobomax@FreeBSD.org>2001-03-15 10:47:00 +0000
commita6586506115ed34fc11089ada2f874a3a5c9d6df (patch)
tree62ed46bb4e9a17d154b1811540e4a8f9d4ee6c53 /usr.sbin/pkg_install/create
parentbdc8631e01562f18e4f3305428717739d8af83a4 (diff)
downloadsrc-a6586506115ed34fc11089ada2f874a3a5c9d6df.tar.gz
src-a6586506115ed34fc11089ada2f874a3a5c9d6df.zip
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
Notes
Notes: svn path=/head/; revision=74295
Diffstat (limited to 'usr.sbin/pkg_install/create')
-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 5307698f1eb5..8d073e45304e 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");
}