Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Make pkg create work again.
jlaffaye committed 15 years ago
commit 52a4945d4e1e59117a3ed8ff13b6551ad550e924
parent d068c2a
3 files changed +18 -4
modified libpkg/pkg_create.c
@@ -10,6 +10,7 @@
#include <fcntl.h>

#include "pkg.h"
+
#include "pkg_error.h"
#include "pkg_private.h"

#define METADATA_GLOB "+{DEINSTALL,INSTALL,MTREE_DIRS}"
@@ -139,10 +140,20 @@ pkg_create(const char *mpath, pkg_formats format, const char *outdir, const char
	struct archive *pkg_archive;
	char archive_path[MAXPATHLEN];
	const char *ext;
+
	int required_flags = PKG_LOAD_DEPS | PKG_LOAD_CONFLICTS | PKG_LOAD_FILES |
+
						 PKG_LOAD_EXECS | PKG_LOAD_SCRIPTS | PKG_LOAD_OPTIONS |
+
						 PKG_LOAD_MTREE;

	(void)mpath;

-
	/* TODO: get stuff from db */
+
	if (pkg->type != PKG_INSTALLED)
+
		return (ERROR_BAD_ARG("pkg"));
+

+
	/*
+
	 * Ensure that we have all the information we need
+
	 */
+
	if ((pkg->flags & required_flags) != required_flags)
+
		return (ERROR_BAD_ARG("pkg"));

	pkg_archive = archive_write_new();

modified libpkg/pkgdb.c
@@ -555,7 +555,7 @@ pkgdb_loadconflicts(struct pkgdb *db, struct pkg *pkg)

	sqlite3_bind_int64(stmt, 1, pkg->rowid);

-
	while ((ret = sqlite3_step(stmt) == SQLITE_ROW)) {
+
	while ((ret = sqlite3_step(stmt)) == SQLITE_ROW) {
		pkg_conflict_new(&c);
		sbuf_set(&c->glob, sqlite3_column_text(stmt, 0));
		array_append(&pkg->conflicts, c);
@@ -744,7 +744,7 @@ pkgdb_loadmtree(struct pkgdb *db, struct pkg *pkg)
	const char sql[] = ""
		"SELECT m.content "
		"FROM mtree AS m, packages AS p "
-
		"WHERE id = p.mtree_id "
+
		"WHERE m.id = p.mtree_id "
			" AND p.id = ?1;";

	if (pkg->type != PKG_INSTALLED)
modified pkg/create.c
@@ -44,6 +44,9 @@ exec_create(int argc, char **argv)
	char ch;
	int retcode = 0;
	int ret;
+
	int query_flags = PKG_LOAD_DEPS | PKG_LOAD_CONFLICTS | PKG_LOAD_FILES |
+
					  PKG_LOAD_EXECS | PKG_LOAD_SCRIPTS | PKG_LOAD_OPTIONS |
+
					  PKG_LOAD_MTREE;

	while ((ch = getopt(argc, argv, "agxXf:r:m:o:")) != -1) {
		switch (ch) {
@@ -115,7 +118,7 @@ exec_create(int argc, char **argv)
		}

		pkg_new(&pkg);
-
		while ((ret = pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC)) == EPKG_OK) {
+
		while ((ret = pkgdb_it_next(it, &pkg, query_flags)) == EPKG_OK) {
			printf("Creating package for %s-%s\n", pkg_get(pkg, PKG_NAME),
				   pkg_get(pkg, PKG_VERSION));