Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Merge pull request #750 from skinder/missing-deps-support
Vsevolod Stakhov committed 12 years ago
commit 9e1a3efea684903849baaaf8b23dc69e119bcd6d
parent 429d279
7 files changed +35 -13
modified docs/pkg-add.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd September 22, 2013
+
.Dd March 21, 2014
.Dt PKG-ADD 8
.Os
.Sh NAME
@@ -23,10 +23,10 @@
.Nd Registers a package and installs it on the system
.Sh SYNOPSIS
.Nm
-
.Op Fl IAfq
+
.Op Fl IAfMq
.Ar pkg-name ...
.Nm
-
.Op Fl IAfq
+
.Op Fl IAfMq
.Ar <protocol>://<path>/<pkg-name> ...
.Sh DESCRIPTION
.Nm
@@ -78,6 +78,8 @@ For more information please refer to
.Xr pkg-autoremove 8
.It Fl f
Force the reinstallation of the package if already installed.
+
.It Fl M
+
Force the installation of the package with missing dependencies.
.It Fl q
Force quiet output.
.El
modified docs/pkg-install.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd March 11, 2014
+
.Dd March 21, 2014
.Dt PKG-INSTALL 8
.Os
.Sh NAME
@@ -23,7 +23,7 @@
.Nd installs packages from remote package repositories or local archives
.Sh SYNOPSIS
.Nm
-
.Op Fl AfgIinFqRUxy
+
.Op Fl AfgIiMnFqRUxy
.Op Fl r Ar reponame
.Ar pkg-origin ...
.Sh DESCRIPTION
@@ -122,6 +122,8 @@ Make the standard or the regular expression
matching against
.Ar pkg-name
case insensitive.
+
.It Fl M
+
Force the installation of the package with missing dependencies.
.It Fl n
Dry-run mode.
The list of changes to packages is always printed, but
modified libpkg/pkg.h.in
@@ -331,7 +331,8 @@ typedef enum _pkg_flags {
	PKG_FLAG_NOSCRIPT = (1U << 5),
	PKG_FLAG_PKG_VERSION_TEST = (1U << 6),
	PKG_FLAG_UPGRADES_FOR_INSTALLED = (1U << 7),
-
	PKG_FLAG_SKIP_INSTALL = (1U << 8)
+
	PKG_FLAG_SKIP_INSTALL = (1U << 8),
+
	PKG_FLAG_FORCE_MISSING = (1U << 9)
} pkg_flags;

typedef enum _pkg_stats_t {
@@ -1130,6 +1131,7 @@ int pkg_add(struct pkgdb *db, const char *path, unsigned flags, struct pkg_manif
#define PKG_ADD_AUTOMATIC		(1U << 2)
#define PKG_ADD_FORCE			(1U << 3)
#define PKG_ADD_NOSCRIPT		(1U << 4)
+
#define PKG_ADD_FORCE_MISSING		(1U << 5)

/**
 * Allocate a new pkg_jobs.
modified libpkg/pkg_add.c
@@ -274,8 +274,10 @@ pkg_add(struct pkgdb *db, const char *path, unsigned flags, struct pkg_manifest_
				    "Origin: '%s' Version: '%s'",
				    pkg_dep_get(dep, PKG_DEP_ORIGIN),
				    pkg_dep_get(dep, PKG_DEP_VERSION));
-
				retcode = EPKG_FATAL;
-
				goto cleanup;
+
				if ((flags & PKG_ADD_FORCE_MISSING) == 0) {
+
					retcode = EPKG_FATAL;
+
					goto cleanup;
+
				}
			}
		} else {
			retcode = EPKG_FATAL;
modified libpkg/pkg_jobs.c
@@ -608,6 +608,9 @@ pkg_jobs_add_universe(struct pkg_jobs *j, struct pkg *pkg,
			if (npkg == NULL) {
				/* Cannot continue */
				pkg_emit_error("Missing dependency matching '%s'", pkg_dep_get(d, PKG_DEP_ORIGIN));
+
				if ((j->flags & PKG_FLAG_FORCE_MISSING) == PKG_FLAG_FORCE_MISSING) {
+
					continue;
+
				}
				return (EPKG_FATAL);
			}
		}
@@ -650,6 +653,9 @@ pkg_jobs_add_universe(struct pkg_jobs *j, struct pkg *pkg,
			if (npkg == NULL) {
				/* Cannot continue */
				pkg_emit_error("Missing dependency matching '%s'", pkg_dep_get(d, PKG_DEP_ORIGIN));
+
				if ((j->flags & PKG_FLAG_FORCE_MISSING) == PKG_FLAG_FORCE_MISSING) {
+
					continue;
+
				}
				return (EPKG_FATAL);
			}
		}
@@ -1657,6 +1663,8 @@ pkg_jobs_handle_install(struct pkg_solved *ps, struct pkg_jobs *j, bool handle_r
		flags |= PKG_ADD_FORCE;
	if ((j->flags & PKG_FLAG_NOSCRIPT) == PKG_FLAG_NOSCRIPT)
		flags |= PKG_ADD_NOSCRIPT;
+
	if ((j->flags & PKG_FLAG_FORCE_MISSING) == PKG_FLAG_FORCE_MISSING)
+
		flags |= PKG_ADD_FORCE_MISSING;
	flags |= PKG_ADD_UPGRADE;
	if (automatic)
		flags |= PKG_ADD_AUTOMATIC;
modified src/add.c
@@ -54,8 +54,8 @@ is_url(const char * const pattern)
void
usage_add(void)
{
-
	fprintf(stderr, "Usage: pkg add [-IAfq] <pkg-name> ...\n");
-
	fprintf(stderr, "       pkg add [-IAfq] <protocol>://<path>/<pkg-name> ...\n\n");
+
	fprintf(stderr, "Usage: pkg add [-IAfqM] <pkg-name> ...\n");
+
	fprintf(stderr, "       pkg add [-IAfqM] <protocol>://<path>/<pkg-name> ...\n\n");
	fprintf(stderr, "For more information see 'pkg help add'.\n");
}

@@ -73,7 +73,7 @@ exec_add(int argc, char **argv)
	pkg_flags f = PKG_FLAG_NONE;
	struct pkg_manifest_key *keys = NULL;

-
	while ((ch = getopt(argc, argv, "IAfq")) != -1) {
+
	while ((ch = getopt(argc, argv, "IAfqM")) != -1) {
		switch (ch) {
		case 'I':
			f |= PKG_ADD_NOSCRIPT;
@@ -84,6 +84,9 @@ exec_add(int argc, char **argv)
		case 'f':
			f |= PKG_FLAG_FORCE;
			break;
+
		case 'M':
+
			f |= PKG_ADD_FORCE_MISSING;
+
			break;
		case 'q':
			quiet = true;
			break;
modified src/install.c
@@ -46,7 +46,7 @@ void
usage_install(void)
{
	fprintf(stderr,
-
	    "Usage: pkg install [-AfgIinFqRUxy] [-r reponame] <pkg-name> ...\n\n");
+
	    "Usage: pkg install [-AfgIinFMqRUxy] [-r reponame] <pkg-name> ...\n\n");
	fprintf(stderr, "For more information see 'pkg help install'.\n");
}

@@ -81,7 +81,7 @@ exec_install(int argc, char **argv)
		quiet = true;
	}

-
	while ((ch = getopt(argc, argv, "AfgIiFnqRr:Uxyl")) != -1) {
+
	while ((ch = getopt(argc, argv, "AfgIiFMnqRr:Uxyl")) != -1) {
		switch (ch) {
		case 'A':
			f |= PKG_FLAG_AUTOMATIC;
@@ -105,6 +105,9 @@ exec_install(int argc, char **argv)
		case 'U':
			auto_update = false;
			break;
+
		case 'M':
+
			f |= PKG_FLAG_FORCE_MISSING;
+
			break;
		case 'n':
			f |= PKG_FLAG_DRY_RUN;
			lock_type = PKGDB_LOCK_READONLY;