diff options
author | sobomax <sobomax@FreeBSD.org> | 2002-05-05 21:03:25 +0000 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2002-05-05 21:03:25 +0000 |
commit | 842eb4b30ab12533f948111da9947ebc3af975a3 (patch) | |
tree | 7c9f1e55ee95af60dec0886ffed805ea8d577125 /usr.sbin/pkg_install/lib | |
parent | c1ae331211aba15b32979855d8c599ba5e6ae4f3 (diff) | |
download | FreeBSD-src-842eb4b30ab12533f948111da9947ebc3af975a3.zip FreeBSD-src-842eb4b30ab12533f948111da9947ebc3af975a3.tar.gz |
New feature: allow origins of all dependencies be recorded into package list
using new `@comment DEPORIGIN:...' directive. This would allow us to make
many neat things including:
- easier binary upgrades;
- source upgrades without using external tools by simply extending
bsd.port.mk and pkg_install tools;
- mixed-mode upgrades (source + binary);
- depreciate and deorbit silly +REQUIRED_BY files in the near future.
This feature is no-op until appropriate bsd.port.mk patch is committed, and
even when it is already committed packages generated will remain 100%
compatible with old set of pkg_install tools (module all those neat
features, of course).
MFC after: 6 days
Diffstat (limited to 'usr.sbin/pkg_install/lib')
-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 |
3 files changed, 32 insertions, 7 deletions
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); |