Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Merge pull request #477 from vstakhov/master
Baptiste Daroussin committed 13 years ago
commit e3b979d6c8edf6d9dad3d1ab43b36d3c4ba382e7
parent 0358022
2 files changed +20 -8
modified pkg/check.c
@@ -50,14 +50,14 @@ struct deps_entry {

STAILQ_HEAD(deps_head, deps_entry);

-
static int check_deps(struct pkgdb *db, struct pkg *pkg, struct deps_head *dh);
+
static int check_deps(struct pkgdb *db, struct pkg *pkg, struct deps_head *dh, bool noinstall);
static void add_missing_dep(struct pkg_dep *d, struct deps_head *dh, int *nbpkgs);
static void deps_free(struct deps_head *dh);
static int fix_deps(struct pkgdb *db, struct deps_head *dh, int nbpkgs, bool yes);
static void check_summary(struct pkgdb *db, struct deps_head *dh);

static int
-
check_deps(struct pkgdb *db, struct pkg *p, struct deps_head *dh)
+
check_deps(struct pkgdb *db, struct pkg *p, struct deps_head *dh, bool noinstall)
{
	struct pkg_dep *dep = NULL;
	char *name, *version, *origin;
@@ -72,8 +72,11 @@ check_deps(struct pkgdb *db, struct pkg *p, struct deps_head *dh)
	while (pkg_deps(p, &dep) == EPKG_OK) {
		/* do we have a missing dependency? */
		if (pkg_is_installed(db, pkg_dep_origin(dep)) != EPKG_OK) {
-
			printf("%s has a missing dependency: %s\n", origin,
-
			       pkg_dep_origin(dep)),
+
			if (noinstall)
+
				printf("%s\n", pkg_dep_origin(dep));
+
			else
+
				printf("%s has a missing dependency: %s\n", origin,
+
			       pkg_dep_origin(dep));
			add_missing_dep(dep, dh, &nbpkgs);
		}
	}
@@ -253,6 +256,7 @@ exec_check(int argc, char **argv)
	bool recompute = false;
	bool reanalyse_shlibs = false;
	bool shlibs;
+
	bool noinstall = false;
	int nbpkgs = 0;
	int i;
	int verbose = 0;
@@ -261,7 +265,7 @@ exec_check(int argc, char **argv)

	struct deps_head dh = STAILQ_HEAD_INITIALIZER(dh);

-
	while ((ch = getopt(argc, argv, "yagidBxsrv")) != -1) {
+
	while ((ch = getopt(argc, argv, "yagidnBxsrv")) != -1) {
		switch (ch) {
		case 'a':
			match = MATCH_ALL;
@@ -284,6 +288,9 @@ exec_check(int argc, char **argv)
		case 'i':
			pkgdb_set_case_sensitivity(false);
			break;
+
		case 'n':
+
			noinstall = true;
+
			break;
		case 'r':
			recompute = true;
			flags |= PKG_LOAD_FILES;
@@ -352,7 +359,7 @@ exec_check(int argc, char **argv)
			if (dcheck) {
				if (verbose)
					printf("Checking dependencies: %s\n", pkgname);
-
				nbpkgs += check_deps(db, pkg, &dh);
+
				nbpkgs += check_deps(db, pkg, &dh, noinstall);
			}
			if (checksums) {
				if (verbose)
@@ -372,7 +379,7 @@ exec_check(int argc, char **argv)
			}
		}

-
		if (dcheck && nbpkgs > 0 ) {
+
		if (dcheck && nbpkgs > 0 && !noinstall) {
			printf("\n>>> Missing package dependencies were detected.\n");
			printf(">>> Found %d issue(s) in total with your package database.\n\n", nbpkgs);

@@ -392,5 +399,8 @@ exec_check(int argc, char **argv)
	pkg_free(pkg);
	pkgdb_close(db);

+
	if (noinstall && nbpkgs > 0)
+
		return (EX_UNAVAILABLE);
+

	return (EX_OK);
}
modified pkg/pkg-check.8
@@ -24,7 +24,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl Bdsr
-
.Op Fl vy
+
.Op Fl vyn
.Op Fl a | gix Ar <pattern>
.Sh DESCRIPTION
.Nm
@@ -53,6 +53,8 @@ The following options are supported by
Assume yes when asked for confirmation before installing missing dependencies.
.It Fl v
Be verbose.
+
.It Fl n
+
Merely check for missing dependencies and do not install them. 
.It Fl a
Process all packages.
.It Fl i