Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
Be able to check for duplicate entries in jobs
Marin Atanasov Nikolov committed 14 years ago
commit dfd375c9a1f847dbd0c7530eb2c8509ed155b6de
parent 480faa0becdb7280b9a2b07c524c8367d6ecf554
2 files changed +28 -0
modified libpkg/pkg.h
@@ -581,6 +581,15 @@ int pkg_jobs_entry(struct pkg_jobs_entry *je, struct pkg **pkg);
int pkg_jobs_apply(struct pkg_jobs_entry *je, int force);

/**
+
 * Checks if a given job is already added in another jobs entry
+
 * @param jobs A valid jobs object as received from pkg_jobs_new()
+
 * @param pkg A package that will be checked if it exists already as a job
+
 * @param res A pkg where to store the result if a package is found to exist
+
 * @return EPKG_OK if the is not added yet and EPKG_FATAL otherwise
+
 */
+
int pkg_jobs_exists(struct pkg_jobs *jobs, struct pkg *pkg, struct pkg **res);
+

+
/**
 * Archive formats options.
 */
typedef enum pkg_formats { TAR, TGZ, TBZ, TXZ } pkg_formats;
modified libpkg/pkg_jobs.c
@@ -122,6 +122,25 @@ pkg_jobs_entry(struct pkg_jobs_entry *je, struct pkg **pkg)
		return (EPKG_OK);
}

+
int
+
pkg_jobs_exists(struct pkg_jobs *jobs, struct pkg *pkg, struct pkg **res)
+
{
+
	struct pkg_jobs_entry *je = NULL;
+
	struct pkg *p = NULL;
+

+
	while (pkg_jobs(jobs, &je) == EPKG_OK) {
+
		p = NULL; /* starts with the first package job */
+
		while (pkg_jobs_entry(je, &p) == EPKG_OK) {
+
			if (strcmp(pkg_get(p, PKG_ORIGIN), pkg_get(pkg, PKG_ORIGIN)) == 0) {
+
				*res = p;
+
				return (EPKG_FATAL);
+
			}
+
		}
+
	}
+

+
	return (EPKG_OK);
+
}
+

static int
pkg_jobs_install(struct pkg_jobs_entry *je)
{