Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
make reinstall on a ports now works
Baptiste Daroussin committed 15 years ago
commit 47f808ad0965d91ef23ee415928a2a40290cbf52
parent b2cfdad6c854f157c2be93837d3f61d642040cde
8 files changed +89 -46
modified libpkg/pkg.c
@@ -274,11 +274,19 @@ pkg_setdesc(struct pkg *pkg, const char *desc)
}

int
-
pkg_adddep(struct pkg *pkg, struct pkg *dep)
+
pkg_adddep(struct pkg *pkg, const char *name, const char *origin, const char *version)
{
-
	if (dep == NULL)
+
	struct pkg *dep;
+

+
	if (name == NULL || origin == NULL || version == NULL)
		return (-1);

+
	pkg_new(&dep);
+

+
	pkg_setname(dep, name);
+
	pkg_setorigin(dep, origin);
+
	pkg_setversion(dep, version);
+

	array_init(&pkg->deps, 5);
	array_append(&pkg->deps, dep);

modified libpkg/pkg.h
@@ -47,7 +47,7 @@ int pkg_setcomment(struct pkg *, const char *);
int pkg_setorigin(struct pkg *, const char *);
int pkg_setdesc(struct pkg *, const char *);
int pkg_setdesc_from_file(struct pkg *, const char *);
-
int pkg_adddep(struct pkg *, struct pkg *);
+
int pkg_adddep(struct pkg *, const char *, const char *, const char *);
int pkg_addfile(struct pkg *, const char *, const char *);
int pkg_addconflict(struct pkg *, const char *);

modified libpkg/pkg_ports.c
@@ -79,9 +79,8 @@ ports_parse_plist(struct pkg *pkg, char *plist, const char *prefix)
int
ports_parse_depends(struct pkg *pkg, char *depends)
{
-
	struct pkg *dep;
	int nbel, i;
-
	char *dep_p, *buf, *v;
+
	char *dep_p, *buf, *v, *name;;
	size_t next;

	if (depends == NULL)
@@ -99,22 +98,18 @@ ports_parse_depends(struct pkg *pkg, char *depends)
	dep_p = depends;

	for (i = 0; i <= nbel; i++) {
+

		buf = dep_p;
		split_chr(dep_p, ':');
		v = strrchr(dep_p, '-');
		v[0] = '\0';
		v++;
		
-
		pkg_new(&dep);
-
		pkg_setname(dep, buf);
+
		name = buf;
		buf += strlen(buf) + 1;
-

-
		pkg_setversion(dep, buf);
		buf += strlen(buf) + 1;

-
		pkg_setorigin(dep, buf);
-

-
		pkg_adddep(pkg, dep);
+
		pkg_adddep(pkg, name, buf, v);

		dep_p += next + 1;
		next = strlen(dep_p);
modified libpkg/pkgdb.c
@@ -493,19 +493,19 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg)

	sqlite3_exec(db->sqlite, "BEGIN TRANSACTION;", NULL, NULL, NULL);

-
	sqlite3_prepare(db->sqlite, "INSERT INTO packages (origin, name, version, comment, desc)"
+
	sqlite3_prepare(db->sqlite, "INSERT OR REPLACE INTO packages (origin, name, version, comment, desc)"
			"VALUES (?1, ?2, ?3, ?4, ?5);",
			-1, &stmt_pkg, NULL);

-
	sqlite3_prepare(db->sqlite, "INSERT INTO deps (origin, name, version, package_id)"
+
	sqlite3_prepare(db->sqlite, "INSERT OR REPLACE INTO deps (origin, name, version, package_id)"
			"VALUES (?1, ?2, ?3, ?4);",
			-1, &stmt_dep, NULL);

-
	sqlite3_prepare(db->sqlite, "INSERT INTO conflicts (name, package_id)"
+
	sqlite3_prepare(db->sqlite, "INSERT OR REPLACE INTO conflicts (name, package_id)"
			"VALUES (?1, ?2, ?3, ?4);",
			-1, &stmt_conflicts, NULL);

-
	sqlite3_prepare(db->sqlite, "INSERT INTO files (path, sha256, package_id)"
+
	sqlite3_prepare(db->sqlite, "INSERT OR REPLACE INTO files (path, sha256, package_id)"
			"VALUES (?1, ?2, ?3);",
			-1, &stmt_file, NULL);

@@ -520,35 +520,34 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg)
	deps = pkg_deps(pkg);

	if (deps != NULL)
-
	for (i = 0; deps[i] != NULL; i++) {
-
		sqlite3_bind_text(stmt_dep, 1, pkg_origin(deps[i]), -1, SQLITE_STATIC);
-
		sqlite3_bind_text(stmt_dep, 2, pkg_name(deps[i]), -1, SQLITE_STATIC);
-
		sqlite3_bind_text(stmt_dep, 3, pkg_version(deps[i]), -1, SQLITE_STATIC);
-
		sqlite3_bind_text(stmt_dep, 4, pkg_comment(deps[i]), -1, SQLITE_STATIC);
-
		sqlite3_bind_text(stmt_dep, 5, pkg_origin(pkg), -1, SQLITE_STATIC);
-

-
		sqlite3_step(stmt_dep);
-
		sqlite3_reset(stmt_dep);
-
	}
+
		for (i = 0; deps[i] != NULL; i++) {
+
			sqlite3_bind_text(stmt_dep, 1, pkg_origin(deps[i]), -1, SQLITE_STATIC);
+
			sqlite3_bind_text(stmt_dep, 2, pkg_name(deps[i]), -1, SQLITE_STATIC);
+
			sqlite3_bind_text(stmt_dep, 3, pkg_version(deps[i]), -1, SQLITE_STATIC);
+
			sqlite3_bind_text(stmt_dep, 4, pkg_origin(pkg), -1, SQLITE_STATIC);
+

+
			sqlite3_step(stmt_dep);
+
			sqlite3_reset(stmt_dep);
+
		}

	conflicts = pkg_conflicts(pkg);
	if (conflicts != NULL)
-
	for (i = 0; conflicts[i] != NULL; i++) {
-
		sqlite3_bind_text(stmt_conflicts, 1, pkg_conflict_glob(conflicts[i]), -1, SQLITE_STATIC);
-
		sqlite3_bind_text(stmt_conflicts, 2, pkg_origin(pkg), -1, SQLITE_STATIC);
-
	}
+
		for (i = 0; conflicts[i] != NULL; i++) {
+
			sqlite3_bind_text(stmt_conflicts, 1, pkg_conflict_glob(conflicts[i]), -1, SQLITE_STATIC);
+
			sqlite3_bind_text(stmt_conflicts, 2, pkg_origin(pkg), -1, SQLITE_STATIC);
+
		}


	files = pkg_files(pkg);
	if (files != NULL)
-
	for (i = 0; files[i] != NULL; i++) {
-
		sqlite3_bind_text(stmt_file, 1, pkg_file_path(files[i]), -1, SQLITE_STATIC);
-
		sqlite3_bind_text(stmt_file, 2, pkg_file_sha256(files[i]), -1, SQLITE_STATIC);
-
		sqlite3_bind_text(stmt_file, 3, pkg_origin(pkg), -1, SQLITE_STATIC);
+
		for (i = 0; files[i] != NULL; i++) {
+
			sqlite3_bind_text(stmt_file, 1, pkg_file_path(files[i]), -1, SQLITE_STATIC);
+
			sqlite3_bind_text(stmt_file, 2, pkg_file_sha256(files[i]), -1, SQLITE_STATIC);
+
			sqlite3_bind_text(stmt_file, 3, pkg_origin(pkg), -1, SQLITE_STATIC);

-
		sqlite3_step(stmt_file);
-
		sqlite3_reset(stmt_file);
-
	}
+
			sqlite3_step(stmt_file);
+
			sqlite3_reset(stmt_file);
+
		}

	sqlite3_finalize(stmt_pkg);
	sqlite3_finalize(stmt_dep);
modified pkg/info.c
@@ -94,8 +94,11 @@ exec_info(int argc, char **argv)
	bool gotone = false;

	/* TODO: exclusive opts ? */
-
	while ((ch = getopt(argc, argv, "egxXdrlsqO")) != -1) {
+
	while ((ch = getopt(argc, argv, "egxXdrlsqoO")) != -1) {
		switch (ch) {
+
			case 'O':
+
				opt |= INFO_ORIGIN_SEARCH;  /* this is only for ports compat */
+
				break;
			case 'e':
				opt |= INFO_EXISTS;
				retcode = 1;
@@ -127,7 +130,7 @@ exec_info(int argc, char **argv)
			case 'q':
				opt |= INFO_QUIET;
				break;
-
			case 'O':
+
			case 'o':
				opt |= INFO_ORIGIN;
				break;
		}
@@ -156,7 +159,7 @@ exec_info(int argc, char **argv)

	/* ports infrastructure expects pkg info -q -O to always return 0 even
	 * if the ports doesn't exists */
-
	if (opt & INFO_ORIGIN)
+
	if (opt & INFO_ORIGIN_SEARCH)
		gotone = true;


@@ -202,10 +205,13 @@ exec_info(int argc, char **argv)
			if (opt & INFO_QUIET)
				printf("%s\n", pkg_origin(pkg));
			else
-
				printf("%s-%s's origin: %s\n", pkg_name(pkg), pkg_version(pkg), pkg_origin(pkg));
+
				printf("%s-%s: %s\n", pkg_name(pkg), pkg_version(pkg), pkg_origin(pkg));

		} else {
-
			printf("%s-%s: %s\n", pkg_name(pkg), pkg_version(pkg), pkg_comment(pkg));
+
			if (opt & INFO_QUIET)
+
				printf("%s-%s\n", pkg_name(pkg), pkg_version(pkg));
+
			else
+
				printf("%s-%s: %s\n", pkg_name(pkg), pkg_version(pkg), pkg_comment(pkg));
		}
	}
	pkg_free(pkg);
@@ -215,10 +221,11 @@ exec_info(int argc, char **argv)
		retcode = -1;
	}

-
	if (retcode == 0 && !gotone)
+
	if (retcode == 0 && !gotone && match != MATCH_ALL)
		retcode = EX_SOFTWARE;

	pkgdb_it_free(it);
	pkgdb_close(db);
+

	return (retcode);
}
modified pkg/info.h
@@ -8,6 +8,7 @@
#define INFO_SIZE (1<<4)
#define INFO_QUIET (1<<5)
#define INFO_ORIGIN (1<<6)
+
#define INFO_ORIGIN_SEARCH (1<<7)

int exec_info(int, char **);
void usage_info(void);
modified pkg/register.c
@@ -87,6 +87,12 @@ exec_register(int argc, char **argv)
		if (ret < 0)
			return (ret);
	}
+
	struct pkg **deps = pkg_deps(pkg);
+
	if (deps != NULL) {
+
		for (int i = 0; deps[i] != NULL; i++) {
+
			printf("----> %s\n", pkg_name(deps[i]));
+
		}
+
	}

	if (conflicts != NULL) {
		ret += ports_parse_conflicts(pkg, conflicts);
modified ports/bsd.port.mk.patch
@@ -1,5 +1,5 @@
--- /usr/ports/Mk/bsd.port.mk.prepkgng	2011-01-14 00:14:59.962893785 +0100
-
+++ /usr/ports/Mk/bsd.port.mk	2011-01-14 00:28:29.620436183 +0100
+
+++ /usr/ports/Mk/bsd.port.mk	2011-01-14 14:34:44.686169759 +0100
@@ -2493,6 +2493,9 @@
 
 .if !defined(PKG_ARGS)
@@ -10,7 +10,34 @@
 .if !defined(NO_MTREE)
 PKG_ARGS+=		-m ${MTREE_FILE}
 .endif
-
@@ -5993,6 +5996,7 @@
+
@@ -5552,6 +5555,7 @@
+
 		fi; \
+
 	done
+
 
+
+.if !defined(PKGNG)
+
 ACTUAL-PACKAGE-DEPENDS?= \
+
 	if [ "${_LIB_RUN_DEPENDS}" != "  " ]; then \
+
 		origins=$$(for pkgname in ${PKG_DBDIR}/*; do \
+
@@ -5579,8 +5583,17 @@
+
 				shift 2; \
+
 			done; \
+
 		done; \
+
-		[ -z "$$packagelist" ] || ${AWK} -F '( |:)' 'BEGIN { pkgname="broken_contents" } /@pkgdep / { pkgname=$$2 } /@comment DEPORIGIN:/ { printf "%s:%s\n", pkgname, $$3; pkgname="broken_contents" }' $$packagelist; \
+
+		[ -z "$$packagelist" ] || ${AWK} -F '( |:)' 'BEGIN { pkgname="broken_contents" } /@pkgdep / { pkgname=$$3 } /@comment DEPORIGIN:/ { printf "%s:%s\n", pkgname, $$3; pkgname="broken_contents" }' $$packagelist; \
+
+	fi
+
+.else
+
+ACTUAL-PACKAGE-DEPENDS?= \
+
+	if [ "${_LIB_RUN_DEPENDS}" != "  " ]; then \
+
+		for dir in ${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,}; do \
+
+			pkgname=$$(${PKG_INFO} -q $${dir\#\#${PORTSDIR}/}); \
+
+			${ECHO_CMD} $$pkgname:$${dir\#\#${PORTSDIR}/}; \
+
+		done; \
+
 	fi
+
+.endif
+
 
+
 # Print out package names.
+
 
+
@@ -5993,6 +6006,7 @@
 	fi
 	@${RM} -rf ${PKG_DBDIR}/${PKGNAME}
 .endif
@@ -18,7 +45,7 @@
 	@if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \
 		${ECHO_MSG} "===>   Registering installation for ${PKGNAME}"; \
 		${MKDIR} ${PKG_DBDIR}/${PKGNAME}; \
-
@@ -6031,6 +6035,10 @@
+
@@ -6031,6 +6045,10 @@
 		${RM} -f /tmp/${PKGNAME}-required-by; \
 	fi
 .else