Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Remove never used upgrade scripts
Baptiste Daroussin committed 6 years ago
commit 5278d0bb075e3f3b41409ed314c199e6da7a78ab
parent 18a2d9b
8 files changed +9 -65
modified libpkg/pkg.c
@@ -911,15 +911,6 @@ pkg_addscript_fileat(int fd, struct pkg *pkg, const char *filename)
	} else if (strcmp(filename, "pkg-deinstall") == 0 ||
			strcmp(filename, "+DEINSTALL") == 0) {
		type = PKG_SCRIPT_DEINSTALL;
-
	} else if (strcmp(filename, "pkg-pre-upgrade") == 0 ||
-
			strcmp(filename, "+PRE_UPGRADE") == 0) {
-
		type = PKG_SCRIPT_PRE_UPGRADE;
-
	} else if (strcmp(filename, "pkg-post-upgrade") == 0 ||
-
			strcmp(filename, "+POST_UPGRADE") == 0) {
-
		type = PKG_SCRIPT_POST_UPGRADE;
-
	} else if (strcmp(filename, "pkg-upgrade") == 0 ||
-
			strcmp(filename, "+UPGRADE") == 0) {
-
		type = PKG_SCRIPT_UPGRADE;
	} else {
		pkg_emit_error("unknown script '%s'", filename);
		ret = EPKG_FATAL;
modified libpkg/pkg.h.in
@@ -340,11 +340,11 @@ typedef enum {
	PKG_SCRIPT_POST_INSTALL,
	PKG_SCRIPT_PRE_DEINSTALL,
	PKG_SCRIPT_POST_DEINSTALL,
-
	PKG_SCRIPT_PRE_UPGRADE,
-
	PKG_SCRIPT_POST_UPGRADE,
+
	__DO_NOT_USE_ME1,
+
	__DO_NOT_USE_ME2,
	PKG_SCRIPT_INSTALL,
	PKG_SCRIPT_DEINSTALL,
-
	PKG_SCRIPT_UPGRADE,
+
	__DO_NOT_USE_ME3,
	PKG_SCRIPT_UNKNOWN
} pkg_script;

@@ -1012,7 +1012,7 @@ int pkg_add_from_remote(struct pkgdb *db, const char *path, unsigned flags,
    struct pkg_manifest_key *keys, const char *location, struct pkg *rp);

#define PKG_ADD_UPGRADE			(1U << 0)
-
#define PKG_ADD_USE_UPGRADE_SCRIPTS	(1U << 1)
+
/* (1U << 1) removed intentionally */
#define PKG_ADD_AUTOMATIC		(1U << 2)
#define PKG_ADD_FORCE			(1U << 3)
#define PKG_ADD_NOSCRIPT		(1U << 4)
modified libpkg/pkg_add.c
@@ -964,10 +964,7 @@ pkg_add_cleanup_old(struct pkgdb *db, struct pkg *old, struct pkg *new, int flag
	 * Execute pre deinstall scripts
	 */
	if ((flags & PKG_ADD_NOSCRIPT) == 0) {
-
		if ((flags & PKG_ADD_USE_UPGRADE_SCRIPTS) == PKG_ADD_USE_UPGRADE_SCRIPTS)
-
			ret = pkg_script_run(old, PKG_SCRIPT_PRE_UPGRADE);
-
		else
-
			ret = pkg_script_run(old, PKG_SCRIPT_PRE_DEINSTALL);
+
		ret = pkg_script_run(old, PKG_SCRIPT_PRE_DEINSTALL);
		if (ret != EPKG_OK && ctx.developer_mode) {
			return (ret);
		} else {
@@ -1119,7 +1116,7 @@ pkg_add_common(struct pkgdb *db, const char *path, unsigned flags,
	/*
	 * Execute pre-install scripts
	 */
-
	if ((flags & (PKG_ADD_NOSCRIPT | PKG_ADD_USE_UPGRADE_SCRIPTS)) == 0) {
+
	if ((flags & PKG_ADD_NOSCRIPT) == 0) {
		if ((retcode = pkg_script_run(pkg, PKG_SCRIPT_PRE_INSTALL)) != EPKG_OK)
			goto cleanup;
		if ((retcode = pkg_lua_script_run(pkg, PKG_LUA_PRE_INSTALL)) != EPKG_OK)
@@ -1168,10 +1165,7 @@ cleanup_reg:
	if (retcode != EPKG_OK)
		goto cleanup;
	if ((flags & PKG_ADD_NOSCRIPT) == 0) {
-
		if ((flags & PKG_ADD_USE_UPGRADE_SCRIPTS) == PKG_ADD_USE_UPGRADE_SCRIPTS)
-
			pkg_script_run(pkg, PKG_SCRIPT_POST_UPGRADE);
-
		else
-
			pkg_script_run(pkg, PKG_SCRIPT_POST_INSTALL);
+
		pkg_script_run(pkg, PKG_SCRIPT_POST_INSTALL);
		pkg_lua_script_run(pkg, PKG_LUA_POST_INSTALL);
	}

modified libpkg/pkg_create.c
@@ -1,5 +1,5 @@
/*-
-
 * Copyright (c) 2011-2014 Baptiste Daroussin <bapt@FreeBSD.org>
+
 * Copyright (c) 2011-2020 Baptiste Daroussin <bapt@FreeBSD.org>
 * Copyright (c) 2011-2012 Julien Laffaye <jlaffaye@FreeBSD.org>
 * Copyright (c) 2014-2015 Matthew Seaman <matthew@FreeBSD.org>
 * Copyright (c) 2014 Vsevolod Stakhov <vsevolod@FreeBSD.org>
@@ -204,18 +204,12 @@ static const char * const scripts[] = {
	"+DEINSTALL",
	"+PRE_DEINSTALL",
	"+POST_DEINSTALL",
-
	"+UPGRADE",
-
	"+PRE_UPGRADE",
-
	"+POST_UPGRADE",
	"pkg-install",
	"pkg-pre-install",
	"pkg-post-install",
	"pkg-deinstall",
	"pkg-pre-deinstall",
	"pkg-post-deinstall",
-
	"pkg-upgrade",
-
	"pkg-pre-upgrade",
-
	"pkg-post-upgrade",
	NULL
};

modified libpkg/pkg_delete.c
@@ -90,11 +90,7 @@ pkg_delete(struct pkg *pkg, struct pkgdb *db, unsigned flags)
		pkg_start_stop_rc_scripts(pkg, PKG_RC_STOP);

	if ((flags & PKG_DELETE_NOSCRIPT) == 0) {
-
		if (flags & PKG_DELETE_UPGRADE) {
-
			ret = pkg_script_run(pkg, PKG_SCRIPT_PRE_UPGRADE);
-
			if (ret != EPKG_OK)
-
				return (ret);
-
		} else {
+
		if (!(flags & PKG_DELETE_UPGRADE)) {
			ret = pkg_script_run(pkg, PKG_SCRIPT_PRE_DEINSTALL);
			if (ret != EPKG_OK && ctx.developer_mode)
				return (ret);
modified libpkg/pkg_manifest.c
@@ -337,12 +337,6 @@ script_type_str(const char *str)
		return (PKG_SCRIPT_INSTALL);
	if (strcmp(str, "post-install") == 0)
		return (PKG_SCRIPT_POST_INSTALL);
-
	if (strcmp(str, "pre-upgrade") == 0)
-
		return (PKG_SCRIPT_PRE_UPGRADE);
-
	if (strcmp(str, "upgrade") == 0)
-
		return (PKG_SCRIPT_UPGRADE);
-
	if (strcmp(str, "post-upgrade") == 0)
-
		return (PKG_SCRIPT_POST_UPGRADE);
	if (strcmp(str, "pre-deinstall") == 0)
		return (PKG_SCRIPT_PRE_DEINSTALL);
	if (strcmp(str, "deinstall") == 0)
@@ -1253,15 +1247,6 @@ pkg_emit_object(struct pkg *pkg, short flags)
			case PKG_SCRIPT_POST_INSTALL:
				script_types = "post-install";
				break;
-
			case PKG_SCRIPT_PRE_UPGRADE:
-
				script_types = "pre-upgrade";
-
				break;
-
			case PKG_SCRIPT_UPGRADE:
-
				script_types = "upgrade";
-
				break;
-
			case PKG_SCRIPT_POST_UPGRADE:
-
				script_types = "post-upgrade";
-
				break;
			case PKG_SCRIPT_PRE_DEINSTALL:
				script_types = "pre-deinstall";
				break;
modified libpkg/pkg_ports.c
@@ -108,8 +108,6 @@ keyword_open_schema(void)
		"    post-install = { type = string }; "
		"    pre-deinstall = { type = string }; "
		"    post-deinstall = { type = string }; "
-
		"    pre-upgrade = { type = string }; "
-
		"    post-upgrade = { type = string }; "
		"    pre-install-lua = { type = string }; "
		"    post-install-lua = { type = string }; "
		"    pre-deinstall-lua = { type = string }; "
@@ -741,8 +739,6 @@ static struct script_map {
	{ "post-install", PKG_SCRIPT_POST_INSTALL },
	{ "pre-deinstall", PKG_SCRIPT_PRE_DEINSTALL },
	{ "post-deinstall", PKG_SCRIPT_POST_DEINSTALL },
-
	{ "pre-upgrade", PKG_SCRIPT_PRE_UPGRADE },
-
	{ "post-upgrade", PKG_SCRIPT_POST_UPGRADE },
};

static void
@@ -868,12 +864,6 @@ append_script(struct plist *p, pkg_script t, const char *cmd)
	case PKG_SCRIPT_POST_DEINSTALL:
		utstring_printf(p->post_deinstall_buf, "%s\n", cmd);
		break;
-
	case PKG_SCRIPT_PRE_UPGRADE:
-
		utstring_printf(p->pre_upgrade_buf, "%s\n", cmd);
-
		break;
-
	case PKG_SCRIPT_POST_UPGRADE:
-
		utstring_printf(p->post_upgrade_buf, "%s\n", cmd);
-
		break;
	}
}

@@ -1294,10 +1284,6 @@ ports_parse_plist(struct pkg *pkg, const char *plist, const char *stage)
	    PKG_SCRIPT_PRE_DEINSTALL);
	flush_script_buffer(pplist->post_deinstall_buf, pkg,
	    PKG_SCRIPT_POST_DEINSTALL);
-
	flush_script_buffer(pplist->pre_upgrade_buf, pkg,
-
	    PKG_SCRIPT_PRE_UPGRADE);
-
	flush_script_buffer(pplist->post_upgrade_buf, pkg,
-
	    PKG_SCRIPT_POST_UPGRADE);

	fclose(plist_f);

modified libpkg/scripts.c
@@ -89,8 +89,6 @@ pkg_script_run(struct pkg * const pkg, pkg_script type)
		/* a implies b with argument arg */
		{"PRE-INSTALL",    PKG_SCRIPT_INSTALL,   PKG_SCRIPT_PRE_INSTALL},
		{"POST-INSTALL",   PKG_SCRIPT_INSTALL,   PKG_SCRIPT_POST_INSTALL},
-
		{"PRE-UPGRADE",    PKG_SCRIPT_UPGRADE,   PKG_SCRIPT_PRE_UPGRADE},
-
		{"POST-UPGRADE",   PKG_SCRIPT_UPGRADE,   PKG_SCRIPT_POST_UPGRADE},
		{"DEINSTALL",      PKG_SCRIPT_DEINSTALL, PKG_SCRIPT_PRE_DEINSTALL},
		{"POST-DEINSTALL", PKG_SCRIPT_DEINSTALL, PKG_SCRIPT_POST_DEINSTALL},
	};