Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Remove the ability to generate pkg_* packages
Baptiste Daroussin committed 11 years ago
commit a177614e98e46cdb400781d5505d91801c0790bb
parent f9dfaa7
9 files changed +42 -498
modified docs/pkg-convert.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd May 25, 2014
+
.Dd November 02, 2014
.Dt PKG-CONVERT 8
.Os
.Sh NAME
@@ -24,11 +24,11 @@
.Sh SYNOPSIS
.Nm
.Op Fl d Ar pkg_dbdir
-
.Op Fl nr
+
.Op Fl n
.Pp
.Nm
.Op Cm --pkg-dbdir Ar pkg_dbdir
-
.Op Cm --{dry-run,revert}
+
.Op Cm --dry-run
.Sh DESCRIPTION
.Nm
is used to convert from/to
@@ -48,8 +48,6 @@ Defaults to
Dry-run mode.
Do not actually convert anything.
Just show what would be done.
-
.It Fl r , Cm --revert
-
Revert conversion
.El
.Sh FILES
See
modified docs/pkg-register.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd October 30, 2014
+
.Dd November 02, 2014
.Dt PKG-REGISTER 8
.Os
.Sh NAME
@@ -23,22 +23,22 @@
.Nd register a package into the local package database
.Sh SYNOPSIS
.Nm
-
.Op Fl dlOt
+
.Op Fl dlt
.Op Fl f Ar plist-file
.Fl m Ar metadatadir
.Fl i Ar input-path
.Nm
-
.Op Fl dlOt
+
.Op Fl dlt
.Fl M Ar metadatafile
.Pp
.Nm
-
.Op Cm --{debug,legacy,old,test}
+
.Op Cm --{debug,legacy,test}
.Op Cm --relocate Ar location
.Op Cm --plist Ar plist-file
.Cm --metadata Ar metadatadir
.Cm --root Ar input-path
.Nm
-
.Op Cm --{debug,legacy,old,test}
+
.Op Cm --{debug,legacy,test}
.Op Cm --relocate Ar location
.Cm --manifest Ar metadatafile
.Sh DESCRIPTION
@@ -158,15 +158,6 @@ This option should only be used with caution, and preferably only
for the intended purpose of performing regression tests on
.Xr pkg 8
itself.
-
.It Fl O, Cm --old
-
This is a temporary compatibility flag for internal use within the
-
ports tree only.
-
This flag will be removed once
-
.Xr pkg_tools 8
-
reaches end-of-life.
-
Generates an old-style packing list on
-
.Pa stdout ,
-
without registering the port in the package database.
.It Cm --relocate Ar location
Annotates the package as having been relocated to
.Pa location ,
modified libpkg/libpkg.ver
@@ -87,7 +87,6 @@ global:
	pkg_object_key;
	pkg_object_string;
	pkg_object_type;
-
	pkg_old_emit_content;
	pkg_old_load_from_path;
	pkg_open;
	pkg_open_fd;
@@ -113,7 +112,6 @@ global:
	pkg_provides;
	pkg_rdeps;
	pkg_recompute;
-
	pkg_register_old;
	pkg_repo_cached_name;
	pkg_repo_enabled;
	pkg_repo_find;
@@ -147,7 +145,6 @@ global:
	pkg_status;
	pkg_suggest_arch;
	pkg_test_filesum;
-
	pkg_to_old;
	pkg_try_installed;
	pkg_type;
	pkg_update;
modified libpkg/pkg.h.in
@@ -1418,10 +1418,7 @@ int pkg_get_myarch_legacy(char *pkgarch, size_t sz);

void pkgdb_cmd(int argc, char **argv);
int pkg_old_load_from_path(struct pkg *pkg, const char *path);
-
int pkg_old_emit_content(struct pkg *pkg, char **dest);
int pkg_from_old(struct pkg *pkg);
-
int pkg_to_old(struct pkg *pkg);
-
int pkg_register_old(struct pkg *pkg);
int pkg_sshserve(int fd);

int pkg_repos_total_count(void);
@@ -1626,7 +1623,7 @@ void pkg_audit_free (struct pkg_audit *audit);
char *pkg_utils_tokenize(char **);
int pkg_utils_count_spaces(const char *);
int pkg_add_port(struct pkgdb *db, struct pkg *pkg, const char *root, \
-
    const char *locationn, bool testing, bool old);
+
    const char *locationn, bool testing);
char *pkg_absolutepath(const char *src, char *dest, size_t dest_len);

#endif
modified libpkg/pkg_create.c
@@ -46,7 +46,6 @@ pkg_create_from_dir(struct pkg *pkg, const char *root,
	char		 fpath[MAXPATHLEN];
	struct pkg_file	*file = NULL;
	struct pkg_dir	*dir = NULL;
-
	char		*m;
	int		 ret;
	struct stat	 st;
	char		 sha256[SHA256_DIGEST_LENGTH * 2 + 1];
@@ -109,16 +108,8 @@ pkg_create_from_dir(struct pkg *pkg, const char *root,
	HASH_FREE(hardlinks, free);

	if (pkg->type == PKG_OLD_FILE) {
-
		char oldcomment[BUFSIZ];
-

-
		pkg_old_emit_content(pkg, &m);
-
		packing_append_buffer(pkg_archive, m, "+CONTENTS", strlen(m));
-
		free(m);
-

-
		packing_append_buffer(pkg_archive, pkg->desc, "+DESC", strlen(pkg->desc));
-
		packing_append_buffer(pkg_archive, pkg->message, "+DISPLAY", strlen(pkg->message));
-
		pkg_snprintf(oldcomment, sizeof(oldcomment), "%c\n", pkg);
-
		packing_append_buffer(pkg_archive, oldcomment, "+COMMENT", strlen(oldcomment));
+
		pkg_emit_error("Cannot create an old format package");
+
		return (EPKG_FATAL);
	} else {
		/*
		 * Register shared libraries used by the package if
modified libpkg/pkg_old.c
@@ -108,89 +108,6 @@ pkg_old_load_from_path(struct pkg *pkg, const char *path)
}

int
-
pkg_old_emit_content(struct pkg *pkg, char **dest)
-
{
-
	struct sbuf *content = sbuf_new_auto();
-

-
	struct pkg_dep *dep = NULL;
-
	struct pkg_file *file = NULL;
-
	struct pkg_dir *dir = NULL;
-
	struct pkg_option *option = NULL;
-

-
	char option_type = 0;
-

-
	pkg_sbuf_printf(content,
-
	    "@comment PKG_FORMAT_REVISION:1.1\n"
-
	    "@name %n-%v\n"
-
	    "@comment ORIGIN:%o\n"
-
	    "@cwd %p\n"
-
	    /* hack because we can recreate the prefix split or origin */
-
	    "@cwd /\n", pkg, pkg, pkg, pkg);
-

-
	while (pkg_deps(pkg, &dep) == EPKG_OK) {
-
		sbuf_printf(content,
-
		    "@pkgdep %s-%s\n"
-
		    "@comment DEPORIGIN:%s\n",
-
		    dep->name,
-
		    dep->version,
-
		    dep->origin);
-
	}
-

-
	while (pkg_files(pkg, &file) == EPKG_OK) {
-
		sbuf_printf(content,
-
		    "%s\n"
-
		    "@comment MD5:%s\n",
-
		     file->path + 1,
-
		     file->sum);
-
	}
-

-
	while (pkg_dirs(pkg, &dir) == EPKG_OK) {
-
		sbuf_printf(content,
-
		    "@unexec /sbin/rmdir \"%s\" 2>/dev/null\n",
-
		    dir->path);
-
	}
-

-
	sbuf_printf(content, "@comment OPTIONS:");
-
	while (pkg_options(pkg, &option) == EPKG_OK) {
-
		/* Add space for previous option, if not the first. */
-
		if (option_type != 0)
-
			sbuf_cat(content, " ");
-

-
		if (strcmp(option->value, "on") == 0)
-
			option_type = '+';
-
		else
-
			option_type = '-';
-
		sbuf_printf(content, "%c%s",
-
		    option_type,
-
		    option->key);
-
	}
-
	sbuf_printf(content, "\n");
-

-
	sbuf_finish(content);
-
	*dest = strdup(sbuf_get(content));
-
	sbuf_delete(content);
-

-
	return (EPKG_OK);
-
}
-

-
int
-
pkg_to_old(struct pkg *p)
-
{
-
	struct pkg_file *f = NULL;
-
	char md5[MD5_DIGEST_LENGTH * 2 + 1];
-

-
	p->type = PKG_OLD_FILE;
-
	while (pkg_files(p, &f) == EPKG_OK) {
-
		if (f->sum[0] == '\0')
-
			continue;
-
		if (md5_file(f->path, md5) == EPKG_OK)
-
			strlcpy(f->sum, md5, sizeof(f->sum));
-
	}
-

-
	return (EPKG_OK);
-
}
-

-
int
pkg_from_old(struct pkg *p)
{
	struct pkg_file *f = NULL;
@@ -206,128 +123,3 @@ pkg_from_old(struct pkg *p)

	return (EPKG_OK);
}
-

-
int
-
pkg_register_old(struct pkg *pkg)
-
{
-
	FILE *fp;
-
	char *content;
-
	const char *pkgdbdir, *tmp;
-
	char path[MAXPATHLEN];
-
	struct sbuf *install_script = sbuf_new_auto();
-
	struct sbuf *deinstall_script = sbuf_new_auto();
-
	struct pkg_dep *dep = NULL;
-

-
	pkg_to_old(pkg);
-
	pkg_old_emit_content(pkg, &content);
-

-
	pkgdbdir = pkg_object_string(pkg_config_get("PKG_DBDIR"));
-
	pkg_snprintf(path, sizeof(path), "%S/%n-%v", pkgdbdir, pkg, pkg);
-
	mkdir(path, 0755);
-

-
	pkg_snprintf(path, sizeof(path), "%S/%n-%v/+CONTENTS", pkgdbdir, pkg, pkg);
-
	fp = fopen(path, "w");
-
	fputs(content, fp);
-
	fclose(fp);
-

-
	pkg_snprintf(path, sizeof(path), "%S/%n-%v/+DESC", pkgdbdir, pkg, pkg);
-
	fp = fopen(path, "w");
-
	pkg_fprintf(fp, "%e", pkg);
-
	fclose(fp);
-

-
	pkg_snprintf(path, sizeof(path), "%s/%n-%v/+COMMENT", pkgdbdir, pkg, pkg);
-
	fp = fopen(path, "w");
-
	pkg_fprintf(fp, "%c\n", pkg);
-
	fclose(fp);
-

-
	if (pkg_has_message(pkg)) {
-
		pkg_snprintf(path, sizeof(path), "%s/%n-%v/+DISPLAY", pkgdbdir, pkg, pkg);
-
		fp = fopen(path, "w");
-
		pkg_fprintf(fp, "%M", pkg);
-
		fclose(fp);
-
	}
-

-
	sbuf_clear(install_script);
-
	tmp = pkg_script_get(pkg, PKG_SCRIPT_PRE_INSTALL);
-
	if (tmp != NULL && *tmp != '\0') {
-
		if (sbuf_len(install_script) == 0)
-
			sbuf_cat(install_script, "#!/bin/sh\n\n");
-
		sbuf_printf(install_script,
-
		    "if [ \"$2\" = \"PRE-INSTALL\" ]; then\n"
-
		    "%s\n"
-
		    "fi\n",
-
		    tmp);
-
	}
-

-
	tmp = pkg_script_get(pkg, PKG_SCRIPT_INSTALL);
-
	if (tmp != NULL && *tmp != '\0') {
-
		if (sbuf_len(install_script) == 0)
-
			sbuf_cat(install_script, "#!/bin/sh\n\n");
-
		sbuf_cat(install_script, tmp);
-
	}
-

-
	tmp = pkg_script_get(pkg, PKG_SCRIPT_POST_INSTALL);
-
	if (tmp != NULL && *tmp != '\0') {
-
		if (sbuf_len(install_script) == 0)
-
			sbuf_cat(install_script, "#!/bin/sh\n\n");
-
		sbuf_printf(install_script,
-
		    "if [ \"$2\" = \"POST-INSTALL\" ]; then\n"
-
		    "%s\n"
-
		    "fi\n",
-
		    tmp);
-
	}
-
	if (sbuf_len(install_script) > 0) {
-
		sbuf_finish(install_script);
-
		pkg_snprintf(path, sizeof(path), "%s/%n-%v/+INSTALL", pkgdbdir, pkg, pkg);
-
		fp = fopen(path, "w");
-
		fputs(sbuf_data(install_script), fp);
-
		fclose(fp);
-
	}
-

-
	sbuf_clear(deinstall_script);
-
	tmp = pkg_script_get(pkg, PKG_SCRIPT_PRE_DEINSTALL);
-
	if (tmp != NULL && *tmp != '\0') {
-
		if (sbuf_len(deinstall_script) == 0)
-
			sbuf_cat(deinstall_script, "#!/bin/sh\n\n");
-
		sbuf_printf(deinstall_script,
-
		    "if [ \"$2\" = \"DEINSTALL\" ]; then\n"
-
		    "%s\n"
-
		    "fi\n",
-
		    tmp);
-
	}
-

-
	tmp = pkg_script_get(pkg, PKG_SCRIPT_DEINSTALL);
-
	if (tmp != NULL && *tmp != '\0') {
-
		if (sbuf_len(deinstall_script) == 0)
-
			sbuf_cat(deinstall_script, "#!/bin/sh\n\n");
-
		sbuf_cat(deinstall_script, tmp);
-
	}
-

-
	tmp = pkg_script_get(pkg, PKG_SCRIPT_POST_DEINSTALL);
-
	if (tmp != NULL && tmp[0] != '\0') {
-
		if (sbuf_len(deinstall_script) == 0)
-
			sbuf_cat(deinstall_script, "#!/bin/sh\n\n");
-
		sbuf_printf(deinstall_script,
-
		    "if [ \"$2\" = \"POST-DEINSTALL\" ]; then\n"
-
		    "%s\n"
-
		    "fi\n",
-
		    tmp);
-
	}
-
	if (sbuf_len(deinstall_script) > 0) {
-
		sbuf_finish(deinstall_script);
-
		pkg_snprintf(path, sizeof(path), "%s/%n-%v/+DEINSTALL", pkgdbdir, pkg, pkg);
-
		fp = fopen(path, "w");
-
		fputs(sbuf_data(deinstall_script), fp);
-
		fclose(fp);
-
	}
-

-
	while (pkg_deps(pkg, &dep)) {
-
		snprintf(path, sizeof(path), "%s/%s-%s/+REQUIRED_BY", pkgdbdir,
-
		    dep->name, dep->version);
-
		fp = fopen(path, "a");
-
		pkg_fprintf(fp, "%n-%v\n", pkg, pkg);
-
		fclose(fp);
-
	}
-

-
	return (EPKG_OK);
-
}
modified libpkg/pkg_ports.c
@@ -1221,7 +1221,7 @@ ports_parse_plist(struct pkg *pkg, const char *plist, const char *stage)

int
pkg_add_port(struct pkgdb *db, struct pkg *pkg, const char *input_path,
-
    const char *location, bool testing, bool old)
+
    const char *location, bool testing)
{
	int rc = EPKG_OK;

@@ -1230,8 +1230,7 @@ pkg_add_port(struct pkgdb *db, struct pkg *pkg, const char *input_path,

	pkg_emit_install_begin(pkg);

-
	if (!old)
-
		rc = pkgdb_register_pkg(db, pkg, 0, 0);
+
	rc = pkgdb_register_pkg(db, pkg, 0, 0);

	if (rc != EPKG_OK)
		goto cleanup;
@@ -1252,9 +1251,6 @@ pkg_add_port(struct pkgdb *db, struct pkg *pkg, const char *input_path,
		pkg_emit_install_finished(pkg);

cleanup:
-
	if (old)
-
		return (pkg_register_old(pkg));
-

	pkgdb_register_finale(db, rc);

	return (rc);
modified src/convert.c
@@ -45,210 +45,11 @@
void
usage_convert(void)
{
-
	fprintf(stderr, "Usage: pkg convert [-d dir] [-nr]\n\n");
+
	fprintf(stderr, "Usage: pkg convert [-d dir] [-n]\n\n");
	fprintf(stderr, "For more information see 'pkg help convert'.\n");
}

static int
-
convert_to_old(const char *pkg_add_dbdir, bool dry_run)
-
{
-
	struct pkgdb	*db = NULL;
-
	struct pkg	*pkg = NULL;
-
	struct pkg_dep	*dep = NULL;
-
	struct pkgdb_it	*it = NULL;
-
	char		*content;
-
	const char	*tmp;
-
	int		 ret;
-
	char		 path[MAXPATHLEN];
-
	int		 query_flags = PKG_LOAD_DEPS    | PKG_LOAD_FILES   |
-
				       PKG_LOAD_DIRS    | PKG_LOAD_SCRIPTS |
-
				       PKG_LOAD_OPTIONS |
-
				       PKG_LOAD_USERS   | PKG_LOAD_GROUPS  |
-
				       PKG_LOAD_RDEPS;
-
	FILE		*fp, *rq;
-
	struct sbuf	*install_script = sbuf_new_auto();
-
	struct sbuf	*deinstall_script = sbuf_new_auto();
-

-
	if (mkdir(pkg_add_dbdir, 0755) != 0 && errno != EEXIST)
-
		err(EX_CANTCREAT, "%s", pkg_add_dbdir);
-

-
	ret = pkgdb_access(PKGDB_MODE_READ, PKGDB_DB_LOCAL);
-

-
	if (ret == EPKG_ENOACCESS) {
-
		warnx("Insufficient privileges to read database");
-
		return (EX_NOPERM);
-
	} else if (ret == EPKG_ENODB) {
-
		warnx("No package database installed.  Nothing to do!");
-
		return (EX_OK);
-
	} else if (ret != EPKG_OK) {
-
		warnx("Error accessing the package database");
-
		return (EX_SOFTWARE);
-
	}
-

-
	ret = EX_OK;
-

-
	if (pkgdb_open(&db, PKGDB_DEFAULT) != EPKG_OK)
-
		return (EX_IOERR);
-

-
	if (pkgdb_obtain_lock(db, PKGDB_LOCK_READONLY) != EPKG_OK) {
-
		pkgdb_close(db);
-
		warnx("Cannot get an exclusive lock on a database, it is locked by another process");
-
		return (EX_TEMPFAIL);
-
	}
-

-
	if ((it = pkgdb_query(db, NULL, MATCH_ALL)) == NULL) {
-
		ret = EPKG_FATAL;
-
		goto cleanup;
-
	}
-

-
	while (pkgdb_it_next(it, &pkg, query_flags) == EPKG_OK) {
-
		rq = NULL;
-
		pkg_printf("Converting %n-%v...", pkg, pkg);
-
		if (dry_run) {
-
			printf("\n");
-
			continue;
-
		}
-
		pkg_to_old(pkg);
-
		pkg_old_emit_content(pkg, &content);
-

-
		pkg_snprintf(path, sizeof(path), "%S/%n-%V", pkg_add_dbdir,
-
		    pkg, pkg);
-
		if (mkdir(path, 0755) != 0) {
-
			pkg_fprintf(stderr, "Error converting %n-%v to %s: %s\n",
-
			    pkg, pkg, path, strerror(errno));
-
			printf("\n");
-
			free(content);
-
			continue;
-
		}
-

-
		pkg_snprintf(path, sizeof(path), "%s/%n-%v/+CONTENTS",
-
		    pkg_add_dbdir, pkg, pkg);
-
		fp = fopen(path, "w");
-
		fputs(content, fp);
-
		fclose(fp);
-

-
		pkg_snprintf(path, sizeof(path), "%s/%n-%v/+DESC",
-
		    pkg_add_dbdir, pkg, pkg);
-
		fp = fopen(path, "w");
-
		pkg_fprintf(fp, "%e", pkg);
-
		fclose(fp);
-

-
		pkg_snprintf(path, sizeof(path), "%s/%n-%v/+COMMENT",
-
		    pkg_add_dbdir, pkg, pkg);
-
		fp = fopen(path, "w");
-
		pkg_fprintf(fp, "%c\n", pkg);
-
		fclose(fp);
-

-
		if (pkg_has_message(pkg)) {
-
			pkg_snprintf(path, sizeof(path), "%s/%n-%v/+DISPLAY",
-
			    pkg_add_dbdir, pkg, pkg);
-
			fp = fopen(path, "w");
-
			pkg_fprintf(fp, "%M", pkg);
-
			fclose(fp);
-
		}
-

-
		sbuf_clear(install_script);
-
		tmp = pkg_script_get(pkg, PKG_SCRIPT_PRE_INSTALL);
-
		if (tmp != NULL && tmp[0] != '\0') {
-
			if (sbuf_len(install_script) == 0)
-
				sbuf_cat(install_script, "#!/bin/sh\n\n");
-
			sbuf_printf(install_script,
-
			    "if [ \"$2\" = \"PRE-INSTALL\" ]; then\n"
-
			    "%s\n"
-
			    "fi\n",
-
			    tmp);
-
		}
-

-
		tmp = pkg_script_get(pkg, PKG_SCRIPT_INSTALL);
-
		if (tmp != NULL && tmp[0] != '\0') {
-
			if (sbuf_len(install_script) == 0)
-
				sbuf_cat(install_script, "#!/bin/sh\n\n");
-
			sbuf_cat(install_script, tmp);
-
		}
-

-
		tmp = pkg_script_get(pkg, PKG_SCRIPT_POST_INSTALL);
-
		if (tmp != NULL && tmp[0] != '\0') {
-
			if (sbuf_len(install_script) == 0)
-
				sbuf_cat(install_script, "#!/bin/sh\n\n");
-
			sbuf_printf(install_script,
-
			    "if [ \"$2\" = \"POST-INSTALL\" ]; then\n"
-
			    "%s\n"
-
			    "fi\n",
-
			    tmp);
-
		}
-
		if (sbuf_len(install_script) > 0) {
-
			sbuf_finish(install_script);
-
			pkg_snprintf(path, sizeof(path), "%s/%n-%v/+INSTALL",
-
			    pkg_add_dbdir, pkg, pkg);
-
			fp = fopen(path, "w");
-
			fputs(sbuf_data(install_script), fp);
-
			fclose(fp);
-
		}
-

-
		sbuf_clear(deinstall_script);
-
		tmp = pkg_script_get(pkg, PKG_SCRIPT_PRE_DEINSTALL);
-
		if (tmp != NULL && tmp[0] != '\0') {
-
			if (sbuf_len(deinstall_script) == 0)
-
				sbuf_cat(deinstall_script, "#!/bin/sh\n\n");
-
			sbuf_printf(deinstall_script,
-
			    "if [ \"$2\" = \"DEINSTALL\" ]; then\n"
-
			    "%s\n"
-
			    "fi\n",
-
			    tmp);
-
		}
-

-
		tmp = pkg_script_get(pkg, PKG_SCRIPT_DEINSTALL);
-
		if (tmp != NULL && tmp[0] != '\0') {
-
			if (sbuf_len(deinstall_script) == 0)
-
				sbuf_cat(deinstall_script, "#!/bin/sh\n\n");
-
			sbuf_cat(deinstall_script, tmp);
-
		}
-

-
		tmp = pkg_script_get(pkg, PKG_SCRIPT_POST_DEINSTALL);
-
		if (tmp != NULL && tmp[0] != '\0') {
-
			if (sbuf_len(deinstall_script) == 0)
-
				sbuf_cat(deinstall_script, "#!/bin/sh\n\n");
-
			sbuf_printf(deinstall_script,
-
			    "if [ \"$2\" = \"POST-DEINSTALL\" ]; then\n"
-
			    "%s\n"
-
			    "fi\n",
-
			    tmp);
-
		}
-
		if (sbuf_len(deinstall_script) > 0) {
-
			sbuf_finish(deinstall_script);
-
			pkg_snprintf(path, sizeof(path), "%s/%n-%v/+DEINSTALL",
-
			    pkg_add_dbdir, pkg, pkg);
-
			fp = fopen(path, "w");
-
			fputs(sbuf_data(deinstall_script), fp);
-
			fclose(fp);
-
		}
-

-
		pkg_snprintf(path, sizeof(path), "%s/%n-%v/+REQUIRED_BY",
-
		    pkg_add_dbdir, pkg, pkg);
-
		while (pkg_rdeps(pkg, &dep) == EPKG_OK) {
-
			if (rq == NULL)
-
				rq = fopen(path, "w");
-
			pkg_fprintf(rq, "%dn-%dv\n", dep, dep);
-
		}
-
		if (rq != NULL)
-
			fclose(rq);
-
		printf("done.\n");
-

-
		free(content);
-
	}
-
	sbuf_delete(install_script);
-
	sbuf_delete(deinstall_script);
-

-
cleanup:
-
	pkg_free(pkg);
-
	pkgdb_it_free(it);
-
	pkgdb_release_lock(db, PKGDB_LOCK_READONLY);
-
	pkgdb_close(db);
-

-
	return (ret);
-
}
-

-
static int
convert_from_old(const char *pkg_add_dbdir, bool dry_run)
{
	DIR		*d;
@@ -294,11 +95,10 @@ convert_from_old(const char *pkg_add_dbdir, bool dry_run)
			if (strcmp(dp->d_name, ".") == 0 ||
			    strcmp(dp->d_name, "..") == 0)
				continue;
-
			if (p == NULL) {
-
				if (pkg_new(&p, PKG_OLD_FILE) != EPKG_OK)
-
					err(EX_OSERR, "malloc");
-
			} else
-
				pkg_reset(p, PKG_OLD_FILE);
+
			if (p != NULL)
+
				pkg_free(p);
+
			if (pkg_new(&p, PKG_OLD_FILE) != EPKG_OK)
+
				err(EX_OSERR, "malloc");
			printf("Converting %s...\n", dp->d_name);
			snprintf(path, sizeof(path), "%s/%s", pkg_add_dbdir, dp->d_name);
			if (pkg_old_load_from_path(p, path) != EPKG_OK) {
@@ -321,18 +121,16 @@ int
exec_convert(__unused int argc, __unused char **argv)
{
	int		 ch;
-
	bool		 revert = false;
	bool		 dry_run = false;
	const char	*pkg_add_dbdir = "/var/db/pkg";

	struct option longopts[] = {
		{ "pkg-dbdir",	required_argument,	NULL,	'd' },
		{ "dry-run",	no_argument,		NULL,	'n' },
-
		{ "revert",	no_argument,		NULL,	'r' },
		{ NULL,		0,			NULL,	0   },
	};

-
	while ((ch = getopt_long(argc, argv, "+d:nr", longopts, NULL)) != -1) {
+
	while ((ch = getopt_long(argc, argv, "+d:n", longopts, NULL)) != -1) {
		switch (ch) {
		case 'd':
			pkg_add_dbdir = optarg;
@@ -340,9 +138,6 @@ exec_convert(__unused int argc, __unused char **argv)
		case 'n':
			dry_run = true;
			break;
-
		case 'r':
-
			revert = true;
-
			break;
		default:
			usage_convert();
			return (EX_USAGE);
@@ -356,10 +151,7 @@ exec_convert(__unused int argc, __unused char **argv)
		return (EX_USAGE);
	}

-
	printf("Converting packages %s %s\n", revert ? "to" : "from", pkg_add_dbdir);
+
	printf("Converting packages from %s\n", pkg_add_dbdir);

-
	if (revert)
-
		return (convert_to_old(pkg_add_dbdir, dry_run));
-
	else
-
		return (convert_from_old(pkg_add_dbdir, dry_run));
+
	return (convert_from_old(pkg_add_dbdir, dry_run));
}
modified src/register.c
@@ -68,9 +68,9 @@ static const char * const scripts[] = {
void
usage_register(void)
{
-
	fprintf(stderr, "Usage: pkg register [-Oldt] [-i <input-path>]"
+
	fprintf(stderr, "Usage: pkg register [-ldt] [-i <input-path>]"
	                " [-f <plist-file>] -m <metadatadir>\n");
-
	fprintf(stderr, "       pkg register [-Oldt] [-i <input_path>]"
+
	fprintf(stderr, "       pkg register [-ldt] [-i <input_path>]"
		        " -M <manifest>\n\n");
	fprintf(stderr, "For more information see 'pkg help register'.\n");
}
@@ -102,7 +102,6 @@ exec_register(int argc, char **argv)

	bool		 developer;
	bool		 legacy        = false;
-
	bool		 old           = false;
	bool		 __unused metadata_only = false;
	bool		 testing_mode  = false;

@@ -118,7 +117,6 @@ exec_register(int argc, char **argv)
		{ "legacy",	no_argument,		NULL,	'l' },
		{ "manifest",	required_argument,	NULL,	'M' },
		{ "metadata",	required_argument,	NULL,	'm' },
-
		{ "old",	no_argument,		NULL,	'O' },
		{ "plist",	required_argument,	NULL,	'f' },
		{ "relocate",	required_argument,	NULL, 	1 },
		{ "root",	required_argument,	NULL,	'i' },
@@ -131,7 +129,7 @@ exec_register(int argc, char **argv)
	if (pkg_new(&pkg, PKG_INSTALLED) != EPKG_OK)
		err(EX_OSERR, "malloc");

-
	while ((ch = getopt_long(argc, argv, "+Adf:i:lM:m:Ot", longopts, NULL)) != -1) {
+
	while ((ch = getopt_long(argc, argv, "+Adf:i:lM:m:t", longopts, NULL)) != -1) {
		switch (ch) {
		case 'A':
		case 'd':
@@ -153,9 +151,6 @@ exec_register(int argc, char **argv)
		case 'm':
			mdir = optarg;
			break;
-
		case 'O':
-
			old = true;
-
			break;
		case 't':
			testing_mode = true;
			break;
@@ -169,19 +164,17 @@ exec_register(int argc, char **argv)
		}
	}

-
	if (!old) {
-
		retcode = pkgdb_access(PKGDB_MODE_READ  |
-
				       PKGDB_MODE_WRITE |
-
				       PKGDB_MODE_CREATE,
-
				       PKGDB_DB_LOCAL);
-
		if (retcode == EPKG_ENOACCESS) {
-
			warnx("Insufficient privileges to register packages");
-
			return (EX_NOPERM);
-
		} else if (retcode != EPKG_OK)
-
			return (EX_IOERR);
-
		else
-
			retcode = EX_OK;
-
	}
+
	retcode = pkgdb_access(PKGDB_MODE_READ  |
+
			       PKGDB_MODE_WRITE |
+
			       PKGDB_MODE_CREATE,
+
			       PKGDB_DB_LOCAL);
+
	if (retcode == EPKG_ENOACCESS) {
+
		warnx("Insufficient privileges to register packages");
+
		return (EX_NOPERM);
+
	} else if (retcode != EPKG_OK)
+
		return (EX_IOERR);
+
	else
+
		retcode = EX_OK;

	/*
	 * Ideally, the +MANIFEST should be all that is necessary,
@@ -291,15 +284,13 @@ exec_register(int argc, char **argv)
	}


-
	if (!old) {
-
		if (pkgdb_open(&db, PKGDB_DEFAULT) != EPKG_OK)
-
			return (EX_IOERR);
+
	if (pkgdb_open(&db, PKGDB_DEFAULT) != EPKG_OK)
+
		return (EX_IOERR);

-
		if (pkgdb_obtain_lock(db, PKGDB_LOCK_EXCLUSIVE) != EPKG_OK) {
-
			pkgdb_close(db);
-
			warnx("Cannot get an exclusive lock on a database, it is locked by another process");
-
			return (EX_TEMPFAIL);
-
		}
+
	if (pkgdb_obtain_lock(db, PKGDB_LOCK_EXCLUSIVE) != EPKG_OK) {
+
		pkgdb_close(db);
+
		warnx("Cannot get an exclusive lock on a database, it is locked by another process");
+
		return (EX_TEMPFAIL);
	}

	/*
@@ -327,8 +318,7 @@ exec_register(int argc, char **argv)
			pkg_suggest_arch(pkg, arch, false);
	}

-
	retcode = pkg_add_port(db, pkg, input_path, location, testing_mode, \
-
	    old);
+
	retcode = pkg_add_port(db, pkg, input_path, location, testing_mode);

	if (!legacy && pkg_has_message(pkg))
		pkg_printf("%M\n", pkg);