Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
Implement the pkg_install to pkgng
Baptiste Daroussin committed 13 years ago
commit fd375e679048851d7273bbae08d664727116287f
parent 1a65c03220d37bca93759290fab7da53bee73f2e
2 files changed +38 -4
modified libpkg/pkg_ports.c
@@ -165,15 +165,14 @@ name_key(struct plist *p, char *line, struct file_attr *a)
	char *tmp;

	pkg_get(p->pkg, PKG_NAME, &name);
-
	if (name == NULL) {
+
	if (name != NULL && *name != '\0') {
		free(a);
		return (EPKG_OK);
	}
-

	tmp = strrchr(line, '-');
	tmp[0] = '\0';
	tmp++;
-
	pkg_set(p->pkg, PKG_NAME, line, PKG_ORIGIN, tmp);
+
	pkg_set(p->pkg, PKG_NAME, line, PKG_VERSION, tmp);

	free(a);
	return (EPKG_OK);
@@ -1034,7 +1033,8 @@ ports_parse_plist(struct pkg *pkg, char *plist, const char *stage)
		return (ret);

	pkg_get(pkg, PKG_PREFIX, &pplist.prefix);
-
	pplist.slash = pplist.prefix[strlen(pplist.prefix) - 1] == '/' ? "" : "/";
+
	if (pplist.prefix != NULL)
+
		pplist.slash = pplist.prefix[strlen(pplist.prefix) - 1] == '/' ? "" : "/";

	walk = plist_buf;

modified pkg/convert.c
@@ -29,6 +29,7 @@

#include <string.h>
#include <sysexits.h>
+
#include <dirent.h>

#include <pkg.h>

@@ -123,6 +124,39 @@ cleanup:
static int
convert_from_old(void)
{
+
	DIR *d;
+
	struct dirent *dp;
+
	struct pkg *p = NULL;
+
	char path[MAXPATHLEN];
+
	char *name, *version;
+
	struct pkgdb *db = NULL;
+

+
	if ((d = opendir("/var/db/pkg")) == NULL)
+
		return (EX_NOINPUT);
+

+
	if (pkgdb_open(&db, PKGDB_DEFAULT) != EPKG_OK) {
+
		return (EX_IOERR);
+
	}
+
	while ((dp = readdir(d)) != NULL) {
+
		if (dp->d_type == DT_DIR) {
+
			if (strcmp(dp->d_name, ".") == 0 ||
+
			    strcmp(dp->d_name, "..") == 0)
+
				continue;
+
			if (p == NULL)
+
				pkg_new(&p, PKG_OLD_FILE);
+
			else
+
				pkg_reset(p, PKG_OLD_FILE);
+
			snprintf(path, MAXPATHLEN, "/var/db/pkg/%s/", dp->d_name);
+
			pkg_old_load_from_path(p, path);
+
			pkg_from_old(p);
+
			pkg_get(p, PKG_NAME, &name, PKG_VERSION, &version);
+
			printf("Converting %s-%s...\n", name, version);
+
			pkgdb_register_ports(db, p);
+
		}
+
	}
+

+
	pkg_free(p);
+
	pkgdb_close(db);
	return (EX_OK);
}