Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Merge pull request #209 from z0nt/master
Baptiste Daroussin committed 14 years ago
commit 9fbec3f011f7774cf9b027af02515ac951eb63c9
parent 5bfc621
5 files changed +12 -6
modified libpkg/pkg.h
@@ -708,6 +708,7 @@ int pkg_add(struct pkgdb *db, const char *path, int flags);
#define PKG_ADD_UPGRADE (1 << 0)
#define PKG_ADD_UPGRADE_NEW (1 << 1)
#define PKG_ADD_AUTOMATIC (1 << 2)
+
#define PKG_ADD_FORCE (1 << 3)

/**
 * Allocate a new pkg_jobs.
modified libpkg/pkg_add.c
@@ -166,8 +166,10 @@ pkg_add(struct pkgdb *db, const char *path, int flags)
	if (fnmatch(myarch, arch, FNM_CASEFOLD) == FNM_NOMATCH) {
		pkg_emit_error("wrong architecture: %s instead of %s",
		    arch, myarch);
-
		retcode = EPKG_FATAL;
-
		goto cleanup;
+
		if ((flags & PKG_ADD_FORCE) == 0) {
+
			retcode = EPKG_FATAL;
+
			goto cleanup;
+
		}
	}

	/*
modified libpkg/pkg_elf.c
@@ -286,7 +286,8 @@ pkg_get_myarch(char *dest, size_t sz)
	}

	if ((fd = open("/bin/sh", O_RDONLY)) < 0) {
-
		pkg_emit_errno("open()", "");
+
		pkg_emit_errno("open", "/bin/sh");
+
		snprintf(dest, sz, "%s", "unknown");
		return (EPKG_FATAL);
	}

modified libpkg/pkg_jobs.c
@@ -147,7 +147,7 @@ pkg_jobs_keep_files_to_del(struct pkg *p1, struct pkg *p2)
}

static int
-
pkg_jobs_install(struct pkg_jobs *j)
+
pkg_jobs_install(struct pkg_jobs *j, bool force)
{
	struct pkg *p = NULL;
	struct pkg *pkg = NULL;
@@ -246,6 +246,8 @@ pkg_jobs_install(struct pkg_jobs *j)
			}
		}

+
		if (force)
+
			flags |= PKG_ADD_FORCE;
		flags |= PKG_ADD_UPGRADE;
		if (automatic)
			flags |= PKG_ADD_AUTOMATIC;
@@ -294,7 +296,7 @@ int
pkg_jobs_apply(struct pkg_jobs *j, int force)
{
	if (j->type == PKG_JOBS_INSTALL)
-
		return (pkg_jobs_install(j));
+
		return (pkg_jobs_install(j, force));
	if (j->type == PKG_JOBS_DEINSTALL)
		return (pkg_jobs_deinstall(j, force));
	if (j->type == PKG_JOBS_FETCH)
modified pkg/install.c
@@ -136,7 +136,7 @@ exec_install(int argc, char **argv)
	}

	if (yes)
-
		if (pkg_jobs_apply(jobs, 0) != EPKG_OK)
+
		if (pkg_jobs_apply(jobs, force) != EPKG_OK)
			goto cleanup;

	if (messages != NULL) {