diff options
Diffstat (limited to 'usr.sbin/pkg_install')
-rw-r--r-- | usr.sbin/pkg_install/create/perform.c | 7 | ||||
-rw-r--r-- | usr.sbin/pkg_install/create/pkg_create.1 | 12 | ||||
-rw-r--r-- | usr.sbin/pkg_install/info/show.c | 7 | ||||
-rw-r--r-- | usr.sbin/pkg_install/lib/deps.c | 30 | ||||
-rw-r--r-- | usr.sbin/pkg_install/lib/lib.h | 2 | ||||
-rw-r--r-- | usr.sbin/pkg_install/lib/plist.c | 7 |
6 files changed, 56 insertions, 9 deletions
diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c index 2c0b0ef..d27840e 100644 --- a/usr.sbin/pkg_install/create/perform.c +++ b/usr.sbin/pkg_install/create/perform.c @@ -101,7 +101,7 @@ pkg_perform(char **pkgs) /* Stick the dependencies, if any, at the top */ if (Pkgdeps) { - char **deps; + char **deps, *deporigin; int i; int ndeps = 0; @@ -133,6 +133,11 @@ pkg_perform(char **pkgs) sortdeps(deps); for (i = 0; i < ndeps; i++) { + deporigin = strchr(deps[i], ':'); + if (deporigin != NULL) { + *deporigin = '\0'; + add_plist_top(&plist, PLIST_DEPORIGIN, ++deporigin); + } add_plist_top(&plist, PLIST_PKGDEP, deps[i]); if (Verbose && !PlistOnly) printf(" %s", deps[i]); diff --git a/usr.sbin/pkg_install/create/pkg_create.1 b/usr.sbin/pkg_install/create/pkg_create.1 index 15be28e..e556880 100644 --- a/usr.sbin/pkg_install/create/pkg_create.1 +++ b/usr.sbin/pkg_install/create/pkg_create.1 @@ -149,6 +149,18 @@ This is assumed to be a whitespace separated list of package names and is meant as a convenient shorthand for specifying multiple .Cm @pkgdep directives in the packing list (see PACKING LIST DETAILS section below). +Each argiment from the +.Ar pkgs +list could be in the form +.Ar pkgname Ns Op Ar :pkgorigin , +where optional +.Ar pkgorigin +element denotes origin of each dependency from the list and it is +recorded into the packing list along with the +.Ar pkgname +using +.Cm @comment +directive. .It Fl p Ar prefix Set .Ar prefix diff --git a/usr.sbin/pkg_install/info/show.c b/usr.sbin/pkg_install/info/show.c index 1931ae5..940e55a 100644 --- a/usr.sbin/pkg_install/info/show.c +++ b/usr.sbin/pkg_install/info/show.c @@ -150,7 +150,12 @@ show_plist(const char *title, Package *plist, plist_t type, Boolean showall) break; case PLIST_PKGDEP: - printf(Quiet ? "@pkgdep %s\n" : "\t%s\n", p->name); + printf(Quiet ? "@pkgdep %s\n" : "Dependency: %s\n", p->name); + break; + + case PLIST_DEPORIGIN: + printf(Quiet ? "@comment DEPORIGIN:%s\n" : + "\tdependency origin: %s\n", p->name); break; case PLIST_MTREE: diff --git a/usr.sbin/pkg_install/lib/deps.c b/usr.sbin/pkg_install/lib/deps.c index 2bda517..aea2788 100644 --- a/usr.sbin/pkg_install/lib/deps.c +++ b/usr.sbin/pkg_install/lib/deps.c @@ -83,25 +83,43 @@ sortdeps(char **pkgs) int chkifdepends(const char *pkgname1, const char *pkgname2) { + char *cp1, *cp2; char pkgdir[FILENAME_MAX]; int errcode; struct reqr_by_entry *rb_entry; struct reqr_by_head *rb_list; + cp2 = strchr(pkgname2, ':'); + if (cp2 != NULL) + *cp2 = '\0'; + cp1 = strchr(pkgname1, ':'); + if (cp1 != NULL) + *cp1 = '\0'; + + errcode = 0; /* Check that pkgname2 is actually installed */ snprintf(pkgdir, sizeof(pkgdir), "%s/%s", LOG_DIR, pkgname2); if (!isdir(pkgdir)) - return 0; + goto exit; errcode = requiredby(pkgname2, &rb_list, FALSE, TRUE); if (errcode < 0) - return errcode; + goto exit; - STAILQ_FOREACH(rb_entry, rb_list, link) - if (strcmp(rb_entry->pkgname, pkgname1) == 0) /* match */ - return 1; + errcode = 0; + STAILQ_FOREACH(rb_entry, rb_list, link) { + if (strcmp(rb_entry->pkgname, pkgname1) == 0) { /* match */ + errcode = 1; + break; + } + } - return 0; +exit: + if (cp1 != NULL) + *cp1 = ':'; + if (cp2 != NULL) + *cp2 = ':'; + return errcode; } /* diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h index 2b12d2f..181c3a2 100644 --- a/usr.sbin/pkg_install/lib/lib.h +++ b/usr.sbin/pkg_install/lib/lib.h @@ -91,7 +91,7 @@ enum _plist_t { PLIST_CHOWN, PLIST_CHGRP, PLIST_COMMENT, PLIST_IGNORE, PLIST_NAME, PLIST_UNEXEC, PLIST_SRC, PLIST_DISPLAY, PLIST_PKGDEP, PLIST_MTREE, PLIST_DIR_RM, PLIST_IGNORE_INST, - PLIST_OPTION, PLIST_ORIGIN + PLIST_OPTION, PLIST_ORIGIN, PLIST_DEPORIGIN }; typedef enum _plist_t plist_t; diff --git a/usr.sbin/pkg_install/lib/plist.c b/usr.sbin/pkg_install/lib/plist.c index 648b67c..7c59929 100644 --- a/usr.sbin/pkg_install/lib/plist.c +++ b/usr.sbin/pkg_install/lib/plist.c @@ -226,6 +226,9 @@ plist_cmd(const char *s, char **arg) if (!strncmp(*arg, "ORIGIN:", 7)) { *arg += 7; return PLIST_ORIGIN; + } else if (!strncmp(*arg, "DEPORIGIN:", 10)) { + *arg += 10; + return PLIST_DEPORIGIN; } return PLIST_COMMENT; } else if (!strcmp(cmd, "ignore")) @@ -375,6 +378,10 @@ write_plist(Package *pkg, FILE *fp) fprintf(fp, "%ccomment ORIGIN:%s\n", CMD_CHAR, plist->name); break; + case PLIST_DEPORIGIN: + fprintf(fp, "%ccomment DEPORIGIN:%s\n", CMD_CHAR, plist->name); + break; + default: cleanup(0); errx(2, __FUNCTION__ ": unknown command type %d (%s)", plist->type, plist->name); |