Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
@exec/@unexec are dead !!! \o/
Baptiste Daroussin committed 14 years ago
commit e6911dd475fc7932b25124a60eab059044554ccc
parent 4cab8e0
10 files changed +2 -251
modified libpkg/pkg.c
@@ -143,18 +143,6 @@ pkg_scripts(struct pkg *pkg)
	return ((struct pkg_script **)pkg->scripts.data);
}

-
struct pkg_exec **
-
pkg_execs(struct pkg *pkg)
-
{
-
	if (pkg == NULL) {
-
		ERROR_BAD_ARG("pkg");
-
		return (NULL);
-
	}
-

-
	array_init(&pkg->exec, 1);
-
	return (struct pkg_exec **) pkg->exec.data;
-
}
-

struct pkg **
pkg_deps(struct pkg *pkg)
{
@@ -442,7 +430,6 @@ pkg_reset(struct pkg *pkg)
	array_reset(&pkg->conflicts, &pkg_conflict_free_void);
	array_reset(&pkg->files, &free);
	array_reset(&pkg->scripts, &pkg_script_free_void);
-
	array_reset(&pkg->exec, &pkg_exec_free_void);
	array_reset(&pkg->options, &pkg_option_free_void);
}

@@ -460,7 +447,6 @@ pkg_free(struct pkg *pkg)
	array_free(&pkg->conflicts, &pkg_conflict_free_void);
	array_free(&pkg->files, &free);
	array_free(&pkg->scripts, &pkg_script_free_void);
-
	array_free(&pkg->exec, &pkg_exec_free_void);
	array_free(&pkg->options, &pkg_option_free_void);

	free(pkg);
modified libpkg/pkg.h
@@ -7,7 +7,6 @@
struct pkg;
struct pkg_file;
struct pkg_conflict;
-
struct pkg_exec;
struct pkg_script;

struct pkgdb;
@@ -118,15 +117,6 @@ typedef enum _pkg_script_t {
} pkg_script_t;

/**
-
 * Determine the type of a pkg_exec.
-
 * @warning Legacy interface, may be removed later.
-
 */
-
typedef enum {
-
	PKG_EXEC = 0,
-
	PKG_UNEXEC
-
} pkg_exec_t;
-

-
/**
 * Error type used everywhere by libpkg.
 */
typedef enum {
@@ -242,12 +232,6 @@ struct pkg_conflict ** pkg_conflicts(struct pkg *);
struct pkg_script ** pkg_scripts(struct pkg *);

/**
-
 * @return NULL-terminated array of pkg_exec.
-
 * @warning Legacy interface, may be removed later.
-
 */
-
struct pkg_exec ** pkg_execs(struct pkg *);
-

-
/**
 * @return NULL-terminated array of pkg_option
 */
struct pkg_option ** pkg_options(struct pkg *);
@@ -364,12 +348,6 @@ void pkg_script_free(struct pkg_script *);
const char *pkg_script_data(struct pkg_script *);
pkg_script_t pkg_script_type(struct pkg_script *);

-
int pkg_exec_new(struct pkg_exec **);
-
void pkg_exec_reset(struct pkg_exec *);
-
void pkg_exec_free(struct pkg_exec *);
-
const char *pkg_exec_cmd(struct pkg_exec *);
-
pkg_exec_t pkg_exec_type(struct pkg_exec *);
-

/* pkg_option */
int pkg_option_new(struct pkg_option **);
void pkg_option_reset(struct pkg_option *);
@@ -449,7 +427,6 @@ struct pkgdb_it * pkgdb_query_which(struct pkgdb *db, const char *path);
#define PKG_LOAD_RDEPS (1<<1)
#define PKG_LOAD_CONFLICTS (1<<2)
#define PKG_LOAD_FILES (1<<3)
-
#define PKG_LOAD_EXECS (1<<4)
#define PKG_LOAD_SCRIPTS (1<<5)
#define PKG_LOAD_OPTIONS (1<<6)
#define PKG_LOAD_MTREE (1<<7)
@@ -472,7 +449,6 @@ int pkgdb_loaddeps(struct pkgdb *db, struct pkg *pkg);
int pkgdb_loadrdeps(struct pkgdb *db, struct pkg *pkg);
int pkgdb_loadconflicts(struct pkgdb *db, struct pkg *pkg);
int pkgdb_loadfiles(struct pkgdb *db, struct pkg *pkg);
-
int pkgdb_loadexecs(struct pkgdb *db, struct pkg *pkg);
int pkgdb_loadscripts(struct pkgdb *db, struct pkg *pkg);
int pkgdb_loadoptions(struct pkgdb *db, struct pkg *pkg);
int pkgdb_loadmtree(struct pkgdb *db, struct pkg *pkg);
@@ -527,7 +503,6 @@ int pkg_repo_fetch(struct pkg *pkg, void *data, fetch_cb cb);
 * @return An error code on failure, or EPKG_OK.
 */
int pkg_delete_files(struct pkg *pkg, int force);
-
int pkg_run_unexecs(struct pkg *pkg);

/**
 * Get the value of a configuration key
modified libpkg/pkg_add.c
@@ -58,7 +58,6 @@ pkg_add(struct pkgdb *db, const char *path, struct pkg **pkg_p)
	struct pkg *p = NULL;
	struct pkg *pkg = NULL;
	struct pkg **deps;
-
	struct pkg_exec **execs;
	bool extract = true;
	char dpath[MAXPATHLEN];
	const char *basedir;
@@ -167,14 +166,6 @@ pkg_add(struct pkgdb *db, const char *path, struct pkg **pkg_p)
	 */
	pkg_script_post_install(pkg);

-
	/*
-
	 * Execute @exec
-
	 */
-
	if ((execs = pkg_execs(pkg)) != NULL)
-
		for (i = 0; execs[i] != NULL; i++)
-
			if (pkg_exec_type(execs[i]) == PKG_EXEC)
-
				system(pkg_exec_cmd(execs[i]));
-

	cleanup:

	pkgdb_register_finale(db, retcode);
modified libpkg/pkg_create.c
@@ -163,7 +163,7 @@ pkg_create_installed(const char *outdir, pkg_formats format, const char *rootdir
{
	struct packing *pkg_archive;
	int required_flags = PKG_LOAD_DEPS | PKG_LOAD_CONFLICTS | PKG_LOAD_FILES |
-
						 PKG_LOAD_EXECS | PKG_LOAD_SCRIPTS | PKG_LOAD_OPTIONS |
+
						 PKG_LOAD_SCRIPTS | PKG_LOAD_OPTIONS |
						 PKG_LOAD_MTREE;

	if (pkg->type != PKG_INSTALLED)
modified libpkg/pkg_delete.c
@@ -32,8 +32,6 @@ pkg_delete(struct pkg *pkg, struct pkgdb *db, int force)
		return (ret);
	if ((ret = pkgdb_loadscripts(db, pkg)) != EPKG_OK)
		return (ret);
-
	if ((ret = pkgdb_loadexecs(db, pkg)) != EPKG_OK)
-
		return (ret);
	if ((ret = pkgdb_loadmtree(db, pkg)) != EPKG_OK)
		return (ret);

@@ -67,30 +65,10 @@ pkg_delete(struct pkg *pkg, struct pkgdb *db, int force)
	if ((ret = pkg_script_post_deinstall(pkg)) != EPKG_OK)
		return (ret);

-
	if ((ret = pkg_run_unexecs(pkg)) != EPKG_OK)
-
		return (ret);
-

	return (pkgdb_unregister_pkg(db, pkg_get(pkg, PKG_ORIGIN)));
}

int
-
pkg_run_unexecs(struct pkg *pkg)
-
{
-
	int ret = EPKG_OK;
-
	int i;
-
	struct pkg_exec **execs;
-

-
	execs = pkg_execs(pkg);
-

-
	/* run the @unexec */
-
	for (i = 0; execs[i] != NULL; i++)
-
		if (pkg_exec_type(execs[i]) == PKG_UNEXEC)
-
			system(pkg_exec_cmd(execs[i]));
-

-
	return (ret);
-
}
-

-
int
pkg_delete_files(struct pkg *pkg, int force)
{
	int do_remove, i;
modified libpkg/pkg_exec.c
@@ -47,47 +47,3 @@ pkg_script_free_void(void *s)
	if (s != NULL)
		pkg_script_free((struct pkg_script *)s);
}
-

-
const char *
-
pkg_exec_cmd(struct pkg_exec *exec)
-
{
-
	return (sbuf_get(exec->cmd));
-
}
-

-
pkg_exec_t
-
pkg_exec_type(struct pkg_exec *exec)
-
{
-
	return (exec->type);
-
}
-

-
int
-
pkg_exec_new(struct pkg_exec **exec)
-
{
-
	if ((*exec = calloc(1, sizeof(struct pkg_exec))) == NULL)
-
		err(EXIT_FAILURE, "calloc()");
-

-
	return (0);
-
}
-

-
void
-
pkg_exec_reset(struct pkg_exec *exec)
-
{
-
	sbuf_reset(exec->cmd);
-
}
-

-
void
-
pkg_exec_free(struct pkg_exec *exec)
-
{
-
	if (exec == NULL)
-
		return;
-

-
	sbuf_free(exec->cmd);
-
	free(exec);
-
}
-

-
void
-
pkg_exec_free_void(void *e)
-
{
-
	if (e != NULL)
-
		pkg_exec_free((struct pkg_exec *)e);
-
}
modified libpkg/pkg_manifest.c
@@ -27,8 +27,6 @@ static int m_parse_option(struct pkg *pkg, char *buf);
static int m_parse_dep(struct pkg *pkg, char *buf);
static int m_parse_conflict(struct pkg *pkg, char *buf);
static int m_parse_maintainer(struct pkg *pkg, char *buf);
-
static int m_parse_exec(struct pkg *pkg, char *buf);
-
static int m_parse_unexec(struct pkg *pkg, char *buf);
static int m_parse_prefix(struct pkg *pkg, char *buf);
static int m_parse_file(struct pkg *pkg, char *buf);
static int m_parse_set_string(struct pkg *pkg, char *buf, pkg_attr attr);
@@ -51,8 +49,6 @@ static struct manifest_key {
	{ "@dep", m_parse_dep},
	{ "@conflict", m_parse_conflict},
	{ "@maintainer", m_parse_maintainer},
-
	{ "@exec", m_parse_exec},
-
	{ "@unexec", m_parse_unexec},
	{ "@prefix", m_parse_prefix},
	{ "@file", m_parse_file},
};
@@ -144,34 +140,6 @@ m_parse_flatsize(struct pkg *pkg, char *buf)
}

static int
-
m_parse_exec(struct pkg *pkg, char *buf)
-
{
-
	while (isspace(*buf))
-
		buf++;
-

-
	if (*buf == '\0')
-
		return (EPKG_FATAL);
-

-
	pkg_addexec(pkg, buf, PKG_EXEC);
-

-
	return (EPKG_OK);
-
}
-

-
static int
-
m_parse_unexec(struct pkg *pkg, char *buf)
-
{
-
	while (isspace(*buf))
-
		buf++;
-

-
	if (*buf == '\0')
-
		return (EPKG_FATAL);
-

-
	pkg_addexec(pkg, buf, PKG_UNEXEC);
-

-
	return (EPKG_OK);
-
}
-

-
static int
m_parse_option(struct pkg *pkg, char *buf)
{
	char *value;
@@ -316,7 +284,6 @@ pkg_emit_manifest(struct pkg *pkg, char **dest)
	struct sbuf *manifest;
	struct pkg **deps;
	struct pkg_conflict **conflicts;
-
	struct pkg_exec **execs;
	struct pkg_option **options;
	struct pkg_file **files;
	int i;
@@ -362,14 +329,6 @@ pkg_emit_manifest(struct pkg *pkg, char **dest)
		}
	}

-
	if ((execs = pkg_execs(pkg)) != NULL) {
-
		for (i = 0; execs[i] != NULL; i++) {
-
			sbuf_printf(manifest, "@%s %s\n",
-
					pkg_exec_type(execs[i]) == PKG_EXEC ? "exec" : "unexec",
-
					pkg_exec_cmd(execs[i]));
-
		}
-
	}
-

	if ((options = pkg_options(pkg)) != NULL)  {
		for (i = 0; options[i] != NULL; i++) {
			sbuf_printf(manifest, "@option %s %s\n",
modified libpkg/pkg_private.h
@@ -29,7 +29,6 @@ struct pkg {
	struct array conflicts;
	struct array files;
	struct array scripts;
-
	struct array exec;
	struct array options;
	int flags;
	int64_t rowid;
@@ -45,11 +44,6 @@ struct pkg_script {
	pkg_script_t type;
};

-
struct pkg_exec {
-
	struct sbuf *cmd;
-
	pkg_exec_t type;
-
};
-

struct pkg_file {
	char path[MAXPATHLEN];
	char sha256[65];
@@ -62,7 +56,6 @@ struct pkg_option {

void pkg_conflict_free_void(void *);
void pkg_script_free_void(void *);
-
void pkg_exec_free_void(void *);
void pkg_option_free_void(void *);

int pkg_open2(struct pkg **p, struct archive **a, struct archive_entry **ae, const char *path);
modified libpkg/pkgdb.c
@@ -117,10 +117,6 @@ pkgdb_pkggt(sqlite3_context *ctx, int argc, sqlite3_value **argv)
 * - 7: DEINSTALL
 * - 8: UPGRADE
 * 
-
 * exec.type can be:
-
 * - 0: exec
-
 * - 1: unexec
-
 *
 */

static int
@@ -176,13 +172,6 @@ pkgdb_init(sqlite3 *sdb)
		"PRIMARY KEY (package_id, type)"
	");"
	"CREATE INDEX scripts_package ON scripts(package_id);"
-
	"CREATE TABLE exec ("
-
		"package_id INTEGER REFERENCES packages(id) ON DELETE CASCADE"
-
			" ON UPDATE CASCADE,"
-
		"cmd TEXT,"
-
		"type INTEGER"
-
	");"
-
	"CREATE INDEX exec_package ON exec(package_id);"
	"CREATE TABLE options ("
		"package_id INTEGER REFERENCES packages(id) ON DELETE CASCADE"
			" ON UPDATE CASCADE,"
@@ -417,10 +406,6 @@ pkgdb_it_next(struct pkgdb_it *it, struct pkg **pkg_p, int flags)
			if ((ret = pkgdb_loadfiles(it->db, pkg)) != EPKG_OK)
				return (ret);

-
		if (flags & PKG_LOAD_EXECS)
-
			if ((ret = pkgdb_loadexecs(it->db, pkg)) != EPKG_OK)
-
				return (ret);
-

		if (flags & PKG_LOAD_SCRIPTS)
			if ((ret = pkgdb_loadscripts(it->db, pkg)) != EPKG_OK)
				return (ret);
@@ -733,47 +718,6 @@ pkgdb_loadfiles(struct pkgdb *db, struct pkg *pkg)
}

int
-
pkgdb_loadexecs(struct pkgdb *db, struct pkg *pkg)
-
{
-
	sqlite3_stmt *stmt;
-
	struct pkg_exec *e;
-
	int ret;
-
	const char sql[] = ""
-
		"SELECT cmd, type "
-
		"FROM exec "
-
		"WHERE package_id = ?1";
-

-
	if (pkg->type != PKG_INSTALLED)
-
		return (ERROR_BAD_ARG("pkg"));
-

-
	if (pkg->flags & PKG_LOAD_EXECS)
-
		return (EPKG_OK);
-

-
	array_init(&pkg->exec, 5);
-

-
	if (sqlite3_prepare_v2(db->sqlite, sql, -1, &stmt, NULL) != SQLITE_OK)
-
		return (ERROR_SQLITE(db->sqlite));
-

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

-
	while ((ret = sqlite3_step(stmt)) == SQLITE_ROW) {
-
		pkg_exec_new(&e);
-
		sbuf_set(&e->cmd, sqlite3_column_text(stmt, 0));
-
		e->type = sqlite3_column_int(stmt, 1);
-
		array_append(&pkg->exec, e);
-
	}
-
	sqlite3_finalize(stmt);
-

-
	if (ret != SQLITE_DONE) {
-
		array_reset(&pkg->exec, &pkg_exec_free_void);
-
		return (ERROR_SQLITE(db->sqlite));
-
	}
-

-
	pkg->flags |= PKG_LOAD_EXECS;
-
	return (EPKG_OK);
-
}
-

-
int
pkgdb_loadscripts(struct pkgdb *db, struct pkg *pkg)
{
	sqlite3_stmt *stmt;
@@ -910,7 +854,6 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg)
	struct pkg **deps;
	struct pkg_file **files;
	struct pkg_conflict **conflicts;
-
	struct pkg_exec **execs;
	struct pkg_script **scripts;
	struct pkg_option **options;

@@ -920,7 +863,6 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg)
	sqlite3_stmt *stmt_dep = NULL;
	sqlite3_stmt *stmt_conflict = NULL;
	sqlite3_stmt *stmt_file = NULL;
-
	sqlite3_stmt *stmt_exec = NULL;
	sqlite3_stmt *stmt_script = NULL;
	sqlite3_stmt *stmt_option = NULL;
	sqlite3_stmt *stmt_dirs = NULL;
@@ -953,9 +895,6 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg)
	const char sql_script[] = ""
		"INSERT INTO scripts (script, type, package_id) "
		"VALUES (?1, ?2, ?3);";
-
	const char sql_exec[] = ""
-
		"INSERT INTO exec (cmd, type, package_id) "
-
		"VALUES (?1, ?2, ?3);";
	const char sql_option[] = ""
		"INSERT INTO options (option, value, package_id) "
		"VALUES (?1, ?2, ?3);";
@@ -1157,29 +1096,6 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg)
	}

	/*
-
	 * Insert execs
-
	 */
-

-
	if (sqlite3_prepare_v2(s, sql_exec, -1, &stmt_exec, NULL) != SQLITE_OK) {
-
		retcode = ERROR_SQLITE(s);
-
		goto cleanup;
-
	}
-

-
	execs = pkg_execs(pkg);
-
	for (i = 0; execs[i] != NULL; i++) {
-
		sqlite3_bind_text(stmt_exec, 1, pkg_exec_cmd(execs[i]), -1, SQLITE_STATIC);
-
		sqlite3_bind_int(stmt_exec, 2, pkg_exec_type(execs[i]));
-
		sqlite3_bind_int64(stmt_exec, 3, package_id);
-

-
		if (sqlite3_step(stmt_exec) != SQLITE_DONE) {
-
			retcode = ERROR_SQLITE(s);
-
			goto cleanup;
-
		}
-

-
		sqlite3_reset(stmt_exec);
-
	}
-

-
	/*
	 * Insert options
	 */

@@ -1222,9 +1138,6 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg)
	if (stmt_script != NULL)
		sqlite3_finalize(stmt_script);

-
	if (stmt_exec != NULL)
-
		sqlite3_finalize(stmt_exec);
-

	if (stmt_option != NULL)
		sqlite3_finalize(stmt_option);
	
modified pkg/create.c
@@ -26,7 +26,7 @@ pkg_create_matches(int argc, char **argv, match_t match, pkg_formats fmt, const
	struct pkgdb_it *it = NULL;
	struct pkg *pkg = NULL;
	int query_flags = PKG_LOAD_DEPS | PKG_LOAD_CONFLICTS | PKG_LOAD_FILES |
-
					  PKG_LOAD_EXECS | PKG_LOAD_SCRIPTS | PKG_LOAD_OPTIONS |
+
					  PKG_LOAD_SCRIPTS | PKG_LOAD_OPTIONS |
					  PKG_LOAD_MTREE;

	if (pkgdb_open(&db, PKGDB_DEFAULT, R_OK) != EPKG_OK) {