Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add packages from the repo.
jlaffaye committed 14 years ago
commit e3ae210e106205e7273893330ee4dd798ba1397c
parent 5f8a9d6
2 files changed +35 -3
modified libpkg/pkg_jobs.c
@@ -73,13 +73,34 @@ int
pkg_jobs_apply(struct pkg_jobs *j, void *data, fetch_cb fcb, status_cb scb)
{
	struct pkg *p = NULL;
+
	struct pkg *pfile = NULL;
+
	const char *cachedir;
+
	char path[MAXPATHLEN];

	/* Fetch */
	while (pkg_jobs(j, &p) == EPKG_OK) {
		if (pkg_repo_fetch(p, data, fcb) != EPKG_OK)
			return (EPKG_FATAL);
	}
-
	(void)scb;
+

+
	/* Install */
+
	cachedir = pkg_config("PKG_CACHEDIR");
+
	p = NULL;
+
	while (pkg_jobs(j, &p) == EPKG_OK) {
+
		snprintf(path, sizeof(path), "%s/%s", cachedir,
+
				 pkg_get(p, PKG_REPOPATH));
+

+
		if (scb != NULL)
+
			scb(data, p);
+
		if (pkg_add(j->db, path, &pfile) != EPKG_OK) {
+
			pkg_free(pfile);
+
			return (EPKG_FATAL);
+
		}
+
		if (scb != NULL)
+
			scb(data, pfile);
+
	}
+

+
	pkg_free(pfile);
	return (EPKG_OK);
}

modified pkg/add.c
@@ -41,8 +41,19 @@ is_url(const char *pattern)
static void
install_status(__unused void *data, struct pkg *pkg)
{
-
	printf("Installing %s-%s...\n", pkg_get(pkg, PKG_NAME),
-
		   pkg_get(pkg, PKG_VERSION));
+
	const char *message;
+
	pkg_t type = pkg_type(pkg);
+

+
	if (type == PKG_REMOTE)
+
		printf("Installing %s-%s...", pkg_get(pkg, PKG_NAME),
+
			   pkg_get(pkg, PKG_VERSION));
+
	if (type == PKG_FILE) {
+
		printf(" Done!\n");
+
		message = pkg_get(pkg, PKG_MESSAGE);
+
		if (message != NULL)
+
			printf("----\n%s----\n", message);
+
	}
+
	fflush(stdout);
}

static int