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
This commit is contained in:
sobomax 2002-05-05 21:03:25 +00:00
parent c1ae331211
commit 842eb4b30a
6 changed files with 56 additions and 9 deletions

View File

@ -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]);

View File

@ -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

View File

@ -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:

View File

@ -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;
}
/*

View File

@ -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;

View File

@ -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);