Subject: [alpine-devel] [PATCH 01/15] cosmetic changes

From: Dubiousjim <[email-masked]>
Date: Thu, 27 Jun 2013 15:28:46 -0400

---
 src/add.c         |  5 +++--
 src/apk.c         |  2 +-
 src/apk_package.h |  2 +-
 src/archive.c     |  2 +-
 src/database.c    | 14 ++++++--------
 src/dot.c         |  2 +-
 src/fetch.c       |  2 +-
 src/index.c       |  2 +-
 src/info.c        |  4 ++--
 src/lua-apk.c     |  2 +-
 src/search.c      |  2 +-
 src/ver.c         |  4 ++--
 12 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/src/add.c b/src/add.c
index 08fbf37..16e8dd1 100644
--- a/src/add.c
+++ b/src/add.c
@@ -154,14 +154,15 @@ static struct apk_option add_options[] = {
 	{ 'u',		"upgrade",	"Prefer to upgrade package" },
 	{ 't',		"virtual",
 	  "Instead of adding all the packages to 'world', create a new virtual "
-	  "package with the listed dependencies and add that to 'world'. The "
+	  "package with the listed dependencies and add that to 'world'; the "
 	  "actions of the command are easily reverted by deleting the virtual "
 	  "package", required_argument, "NAME" },
 };
 
 static struct apk_applet apk_add = {
 	.name = "add",
-	.help = "Add/update PACKAGEs to main dependencies and install them",
+	.help = "Add PACKAGEs to main dependencies and install (or upgrade) "
+		"them, while ensuring that all dependencies are met",
 	.arguments = "PACKAGE...",
 	.open_flags = APK_OPENF_WRITE,
 	.context_size = sizeof(struct add_ctx),
diff --git a/src/apk.c b/src/apk.c
index 7739079..17e87d5 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -42,7 +42,7 @@ static struct apk_option generic_options[] = {
 	{ 'X', "repository",	"Use packages from REPO",
 				required_argument, "REPO" },
 	{ 'q', "quiet",		"Print less information" },
-	{ 'v', "verbose",	"Print more information" },
+	{ 'v', "verbose",	"Print more information (can be doubled)" },
 	{ 'i', "interactive",	"Ask confirmation for certain operations" },
 	{ 'V', "version",	"Print program version and exit" },
 	{ 'f', "force",		"Do what was asked even if it looks dangerous" },
diff --git a/src/apk_package.h b/src/apk_package.h
index 8945cd8..0d61e23 100644
--- a/src/apk_package.h
+++ b/src/apk_package.h
@@ -1,4 +1,4 @@
-/* apk_database.h - Alpine Package Keeper (APK)
+/* apk_package.h - Alpine Package Keeper (APK)
  *
  * Copyright (C) 2005-2008 Natanael Copa <[email-masked]>
  * Copyright (C) 2008-2011 Timo Teräs <[email-masked]>
diff --git a/src/archive.c b/src/archive.c
index 8f22f42..771e548 100644
--- a/src/archive.c
+++ b/src/archive.c
@@ -45,7 +45,7 @@ struct tar_header {
 	char devmajor[8];   /* 329-336 */
 	char devminor[8];   /* 337-344 */
 	char prefix[155];   /* 345-499 */
-	char padding[12];   /* 500-512 */
+	char padding[12];   /* 500-511 */
 };
 
 struct apk_tar_digest_info {
diff --git a/src/database.c b/src/database.c
index d4becb9..33f7af8 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1119,12 +1119,10 @@ static int apk_db_read_state(struct apk_database *db, int flags)
 	int r;
 
 	/* Read:
-	 * 1. installed repository
-	 * 2. source repositories
-	 * 3. master dependencies
-	 * 4. package statuses
-	 * 5. files db
-	 * 6. script db
+	 * 1. /etc/apk/world
+	 * 2. installed packages db
+	 * 3. triggers db
+	 * 4. scripts db
 	 */
 	if (!(flags & APK_OPENF_NO_WORLD)) {
 		blob = world = apk_blob_from_file(db->root_fd, apk_world_file);
@@ -1574,14 +1572,14 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
 		db->cache_fd = fd;
 		if ((dbopts->open_flags & (APK_OPENF_WRITE | APK_OPENF_CACHE_WRITE)) &&
 		    fstatvfs(fd, &stvfs) == 0 && (stvfs.f_flag & ST_RDONLY) != 0) {
-			/* remount cache read-write */
+			/* remount cache read/write */
 			db->cache_remount_dir = find_mountpoint(db->root_fd, db->cache_dir);
 			if (db->cache_remount_dir == NULL) {
 				apk_warning("Unable to find cache directory mount point");
 			} else if (do_remount(db->cache_remount_dir, "rw") != 0) {
 				free(db->cache_remount_dir);
 				db->cache_remount_dir = NULL;
-				apk_error("Unable to remount cache read-write");
+				apk_error("Unable to remount cache read/write");
 				r = EROFS;
 				goto ret_r;
 			}
diff --git a/src/dot.c b/src/dot.c
index 6738682..ccf5435 100644
--- a/src/dot.c
+++ b/src/dot.c
@@ -157,7 +157,7 @@ static int dot_main(void *pctx, struct apk_database *db, struct apk_string_array
 
 static struct apk_option dot_options[] = {
 	{ 0x10000,	"errors",	"Output only parts of the graph which are considered "
-					"errorneus: e.g. cycles and missing packages" },
+					"erroneous: e.g. cycles and missing packages" },
 	{ 0x10001,	"installed",	"Consider only installed packages" },
 };
 
diff --git a/src/fetch.c b/src/fetch.c
index 1d7389c..cf2fde7 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -260,7 +260,7 @@ static int fetch_main(void *pctx, struct apk_database *db, struct apk_string_arr
 
 static struct apk_option fetch_options[] = {
 	{ 'L', "link",		"Create hard links if possible" },
-	{ 'R', "recursive",	"Fetch the PACKAGE and all it's dependencies" },
+	{ 'R', "recursive",	"Fetch the PACKAGE and all its dependencies" },
 	{ 's', "stdout",
 	  "Dump the .apk to stdout (incompatible with -o and -R)" },
 	{ 'o', "output",	"Directory to place the PACKAGEs to",
diff --git a/src/index.c b/src/index.c
index c61c78b..4a97911 100644
--- a/src/index.c
+++ b/src/index.c
@@ -245,7 +245,7 @@ static struct apk_option index_options[] = {
 	{ 'd', "description", "Embed TEXT as description and version "
 	  "information of the repository index",
 	  required_argument, "TEXT" },
-	{ 0x10000, "rewrite-arch", "Use ARCH as architery for all packages",
+	{ 0x10000, "rewrite-arch", "Use ARCH as architecture for all packages",
 	  required_argument, "ARCH" },
 };
 
diff --git a/src/info.c b/src/info.c
index 9eb9e78..9a9154e 100644
--- a/src/info.c
+++ b/src/info.c
@@ -419,8 +419,8 @@ static struct apk_option info_options[] = {
 	{ 'P', "provides",	"List virtual packages provided by PACKAGE" },
 	{ 'r', "rdepends",	"List all packages depending on PACKAGE" },
 	{ 0x10000, "replaces",	"List packages whom files PACKAGE might replace" },
-	{ 'i', "install-if",	"List the PACKAGE's install-if rule" },
-	{ 'I', "rinstall-if",	"List all packages having install-if referencing PACKAGE" },
+	{ 'i', "install-if",	"List the PACKAGE's install_if rule" },
+	{ 'I', "rinstall-if",	"List all packages having install_if referencing PACKAGE" },
 	{ 'w', "webpage",	"Show URL for more information about PACKAGE" },
 	{ 's', "size",		"Show installed size of PACKAGE" },
 	{ 'd', "description",	"Print description for PACKAGE" },
diff --git a/src/lua-apk.c b/src/lua-apk.c
index 28eee61..bae0ee7 100644
--- a/src/lua-apk.c
+++ b/src/lua-apk.c
@@ -75,7 +75,7 @@ static int Pversion_compare(lua_State *L)
 }
 
 /* version_is_less(verstr1, verstr2)
-   returns either '<', '=' or '>'
+   returns whether version is '<'
 */
 static int Pversion_is_less(lua_State *L)
 {
diff --git a/src/search.c b/src/search.c
index 2b7b5e1..7ccf98a 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1,4 +1,4 @@
-/* info.c - Alpine Package Keeper (APK)
+/* search.c - Alpine Package Keeper (APK)
  *
  * Copyright (C) 2005-2009 Natanael Copa <[email-masked]>
  * Copyright (C) 2008-2011 Timo Teräs <[email-masked]>
diff --git a/src/ver.c b/src/ver.c
index 94220a9..99da504 100644
--- a/src/ver.c
+++ b/src/ver.c
@@ -186,8 +186,8 @@ static struct apk_option ver_options[] = {
 	{ 't', "test",		"Compare two given versions" },
 	{ 'c', "check", 	"Check if the given version string is valid" },
 	{ 'a', "all",		"Consider packages from all repository tags" },
-	{ 'l', "limit",		"Limit output to packages with status matching one of LIMCHARS",
-	  required_argument, "LIMCHARS" },
+	{ 'l', "limit",		"Limit output to packages with status matching one of LIMCHARs",
+	  required_argument, "LIMCHARs" },
 };
 
 static struct apk_applet apk_ver = {
-- 
1.8.3.1

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Dubiousjim <[email-masked]>
Date: Thu, 27 Jun 2013 15:28:47 -0400

---
 src/add.c | 2 +-
 src/del.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/add.c b/src/add.c
index 16e8dd1..2a0a36c 100644
--- a/src/add.c
+++ b/src/add.c
@@ -161,7 +161,7 @@ static struct apk_option add_options[] = {
 
 static struct apk_applet apk_add = {
 	.name = "add",
-	.help = "Add PACKAGEs to main dependencies and install (or upgrade) "
+	.help = "Add PACKAGEs to 'world' and install (or upgrade) "
 		"them, while ensuring that all dependencies are met",
 	.arguments = "PACKAGE...",
 	.open_flags = APK_OPENF_WRITE,
diff --git a/src/del.c b/src/del.c
index cd15415..7b5fd6c 100644
--- a/src/del.c
+++ b/src/del.c
@@ -135,7 +135,7 @@ static struct apk_option del_options[] = {
 
 static struct apk_applet apk_del = {
 	.name = "del",
-	.help = "Remove PACKAGEs from the main dependencies and uninstall them",
+	.help = "Remove PACKAGEs from 'world' and uninstall them",
 	.arguments = "PACKAGE...",
 	.open_flags = APK_OPENF_WRITE,
 	.context_size = sizeof(struct del_ctx),
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Thu, 27 Jun 2013 15:28:48 -0400

---
 src/ver.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/ver.c b/src/ver.c
index 99da504..fc7df5a 100644
--- a/src/ver.c
+++ b/src/ver.c
@@ -183,8 +183,8 @@ static int ver_main(void *pctx, struct apk_database *db, struct apk_string_array
 
 static struct apk_option ver_options[] = {
 	{ 'I', "indexes",	"Print description and versions of indexes" },
-	{ 't', "test",		"Compare two given versions" },
-	{ 'c', "check", 	"Check if the given version string is valid" },
+	{ 't', "test",		"Compare two given versions, output '<' '=' or '>'" },
+	{ 'c', "check", 	"Check the given version strings, output any that are invalid" },
 	{ 'a', "all",		"Consider packages from all repository tags" },
 	{ 'l', "limit",		"Limit output to packages with status matching one of LIMCHARs",
 	  required_argument, "LIMCHARs" },
@@ -192,7 +192,8 @@ static struct apk_option ver_options[] = {
 
 static struct apk_applet apk_ver = {
 	.name = "version",
-	.help = "Compare package versions",
+	.help = "Compare package versions (in installed database vs. available) "
+		"or do tests on literal version strings (with or without -rN suffixes)",
 	.open_flags = APK_OPENF_READ,
 	.context_size = sizeof(struct ver_ctx),
 	.num_options = ARRAY_SIZE(ver_options),
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Thu, 27 Jun 2013 15:28:49 -0400

---
 src/fix.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/fix.c b/src/fix.c
index 4672813..3a7a8e6 100644
--- a/src/fix.c
+++ b/src/fix.c
@@ -86,8 +86,8 @@ static int fix_main(void *pctx, struct apk_database *db, struct apk_string_array
 
 static struct apk_option fix_options[] = {
 	{ 'd',		"depends",	"Fix all dependencies too" },
-	{ 'u',		"upgrade",	"Upgrade package if possible" },
-	{ 'r',		"reinstall",	"Reinstall the package" },
+	{ 'r',		"reinstall",	"Reinstall the package (default)" },
+	{ 'u',		"upgrade",	"Prefer to upgrade package" },
 	{ 0x10000,	"directory-permissions", "Reset all directory permissions" },
 };
 
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Thu, 27 Jun 2013 15:28:50 -0400

---
 src/upgrade.c | 4 ++--

diff --git a/src/upgrade.c b/src/upgrade.c
index 9eb7890..0d7155a 100644
--- a/src/upgrade.c
+++ b/src/upgrade.c
@@ -64,7 +64,7 @@ int apk_do_self_upgrade(struct apk_database *db, unsigned short solver_flags)
 		goto ret;
 
 	if (apk_flags & APK_SIMULATE) {
-		apk_warning("This simulation is not reliable as apk-tools upgrade is available.");
+		apk_warning("This simulation is not reliable if apk-tools upgrade is available.");
 		goto ret;
 	}
 
@@ -72,7 +72,7 @@ int apk_do_self_upgrade(struct apk_database *db, unsigned short solver_flags)
 	apk_solver_commit_changeset(db, &changeset, db->world);
 	apk_db_close(db);
 
-	apk_message("Continuing the upgrade transaction with new apk-tools:");
+	apk_message("Continuing the upgrade transaction:");
 	for (r = 0; apk_argv[r] != NULL; r++)
 		;
 	apk_argv[r] = "--no-self-upgrade";
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Thu, 27 Jun 2013 15:28:51 -0400

---
 src/add.c     | 4 ++++
 src/apk.c     | 4 ----
 src/dot.c     | 4 ++++
 src/fetch.c   | 4 ++++
 src/fix.c     | 4 ++++
 src/info.c    | 4 ++++
 src/search.c  | 4 ++++
 src/upgrade.c | 4 ++++
 src/ver.c     | 4 ++++
 9 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/src/add.c b/src/add.c
index 2a0a36c..832e601 100644
--- a/src/add.c
+++ b/src/add.c
@@ -36,6 +36,9 @@ static int add_parse(void *ctx, struct apk_db_options *dbopts,
 	case 't':
 		actx->virtpkg = optarg;
 		break;
+	case 'U':
+		apk_flags |= APK_UPDATE_CACHE;
+		break;
 	default:
 		return -1;
 	}
@@ -151,6 +154,7 @@ static int add_main(void *ctx, struct apk_database *db, struct apk_string_array
 
 static struct apk_option add_options[] = {
 	{ 0x10000,	"initdb",	"Initialize database" },
+	{ 'U',          "update-cache",	"Update the repository cache first" },
 	{ 'u',		"upgrade",	"Prefer to upgrade package" },
 	{ 't',		"virtual",
 	  "Instead of adding all the packages to 'world', create a new virtual "
diff --git a/src/apk.c b/src/apk.c
index 17e87d5..a1b26fb 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -46,7 +46,6 @@ static struct apk_option generic_options[] = {
 	{ 'i', "interactive",	"Ask confirmation for certain operations" },
 	{ 'V', "version",	"Print program version and exit" },
 	{ 'f', "force",		"Do what was asked even if it looks dangerous" },
-	{ 'U', "update-cache",	"Update the repository cache" },
 	{ 0x101, "progress",	"Show a progress bar" },
 	{ 0x10f, "progress-fd",	"Write progress to fd", required_argument, "FD" },
 	{ 0x110, "no-progress",	"Disable progress bar even for TTYs" },
@@ -378,9 +377,6 @@ int main(int argc, char **argv)
 		case 'i':
 			apk_flags |= APK_INTERACTIVE;
 			break;
-		case 'U':
-			apk_flags |= APK_UPDATE_CACHE;
-			break;
 		case 0x101:
 			apk_flags |= APK_PROGRESS;
 			break;
diff --git a/src/dot.c b/src/dot.c
index ccf5435..42a83fb 100644
--- a/src/dot.c
+++ b/src/dot.c
@@ -37,6 +37,9 @@ static int dot_parse(void *pctx, struct apk_db_options *dbopts,
 		ctx->installed_only = 1;
 		dbopts->open_flags &= ~APK_OPENF_NO_INSTALLED;
 		break;
+	case 'U':
+		apk_flags |= APK_UPDATE_CACHE;
+		break;
 	default:
 		return -1;
 	}
@@ -156,6 +159,7 @@ static int dot_main(void *pctx, struct apk_database *db, struct apk_string_array
 }
 
 static struct apk_option dot_options[] = {
+	{ 'U',          "update-cache",	"Update the repository cache first" },
 	{ 0x10000,	"errors",	"Output only parts of the graph which are considered "
 					"erroneous: e.g. cycles and missing packages" },
 	{ 0x10001,	"installed",	"Consider only installed packages" },
diff --git a/src/fetch.c b/src/fetch.c
index cf2fde7..60c31f4 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -73,6 +73,9 @@ static int fetch_parse(void *ctx, struct apk_db_options *dbopts,
 	struct fetch_ctx *fctx = (struct fetch_ctx *) ctx;
 
 	switch (optch) {
+	case 'U':
+		apk_flags |= APK_UPDATE_CACHE;
+		break;
 	case 'R':
 		fctx->flags |= FETCH_RECURSIVE;
 		break;
@@ -259,6 +262,7 @@ static int fetch_main(void *pctx, struct apk_database *db, struct apk_string_arr
 }
 
 static struct apk_option fetch_options[] = {
+	{ 'U', "update-cache",	"Update the repository cache first" },
 	{ 'L', "link",		"Create hard links if possible" },
 	{ 'R', "recursive",	"Fetch the PACKAGE and all its dependencies" },
 	{ 's', "stdout",
diff --git a/src/fix.c b/src/fix.c
index 3a7a8e6..e772bd9 100644
--- a/src/fix.c
+++ b/src/fix.c
@@ -30,6 +30,9 @@ static int fix_parse(void *pctx, struct apk_db_options *dbopts,
 	case 'd':
 		ctx->fix_depends = 1;
 		break;
+	case 'U':
+		apk_flags |= APK_UPDATE_CACHE;
+		break;
 	case 'u':
 		ctx->solver_flags |= APK_SOLVERF_UPGRADE;
 		break;
@@ -85,6 +88,7 @@ static int fix_main(void *pctx, struct apk_database *db, struct apk_string_array
 }
 
 static struct apk_option fix_options[] = {
+	{ 'U',          "update-cache",	"Update the repository cache first" },
 	{ 'd',		"depends",	"Fix all dependencies too" },
 	{ 'r',		"reinstall",	"Reinstall the package (default)" },
 	{ 'u',		"upgrade",	"Prefer to upgrade package" },
diff --git a/src/info.c b/src/info.c
index 9a9154e..f4d5b92 100644
--- a/src/info.c
+++ b/src/info.c
@@ -344,6 +344,9 @@ static int info_parse(void *pctx, struct apk_db_options *dbopts,
 		ctx->action = info_who_owns;
 		dbopts->open_flags |= APK_OPENF_NO_REPOS;
 		break;
+	case 'U':
+		apk_flags |= APK_UPDATE_CACHE;
+		break;
 	case 'w':
 		ctx->subaction_mask |= APK_INFO_URL;
 		break;
@@ -412,6 +415,7 @@ static int info_main(void *ctx, struct apk_database *db, struct apk_string_array
 }
 
 static struct apk_option info_options[] = {
+	{ 'U', "update-cache",	"Update the repository cache first" },
 	{ 'L', "contents",	"List contents of the PACKAGE" },
 	{ 'e', "installed",	"Check if PACKAGE is installed" },
 	{ 'W', "who-owns",	"Print the package owning the specified file" },
diff --git a/src/search.c b/src/search.c
index 7ccf98a..ef3d254 100644
--- a/src/search.c
+++ b/src/search.c
@@ -70,6 +70,9 @@ static int search_parse(void *ctx, struct apk_db_options *dbopts,
 	struct search_ctx *ictx = (struct search_ctx *) ctx;
 
 	switch (optch) {
+	case 'U':
+		apk_flags |= APK_UPDATE_CACHE;
+		break;
 	case 'a':
 		ictx->show_all = 1;
 		break;
@@ -164,6 +167,7 @@ static int search_main(void *pctx, struct apk_database *db, struct apk_string_ar
 }
 
 static struct apk_option search_options[] = {
+	{ 'U', "update-cache",	"Update the repository cache first" },
 	{ 'a', "all",		"Show all package versions (instead of latest only)" },
 	{ 'd', "description",	"Search package descriptions (implies -a)" },
 	{ 'e', "exact",		"Require exact match (instead of substring match)" },
diff --git a/src/upgrade.c b/src/upgrade.c
index 0d7155a..020fda0 100644
--- a/src/upgrade.c
+++ b/src/upgrade.c
@@ -32,6 +32,9 @@ static int upgrade_parse(void *ctx, struct apk_db_options *dbopts,
 	case 0x10000:
 		uctx->no_self_upgrade = 1;
 		break;
+	case 'U':
+		apk_flags |= APK_UPDATE_CACHE;
+		break;
 	case 'a':
 		uctx->solver_flags |= APK_SOLVERF_AVAILABLE;
 		break;
@@ -129,6 +132,7 @@ static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_ar
 }
 
 static struct apk_option upgrade_options[] = {
+	{ 'U', "update-cache",	"Update the repository cache first" },
 	{ 'a', "available",
 	  "Resets versioned world dependencies, and changes to prefer "
 	  "replacing or downgrading packages (instead of holding them) "
diff --git a/src/ver.c b/src/ver.c
index fc7df5a..e15eaeb 100644
--- a/src/ver.c
+++ b/src/ver.c
@@ -90,6 +90,9 @@ static int ver_parse(void *ctx, struct apk_db_options *dbopts,
 	case 'a':
 		ictx->all_tags = 1;
 		break;
+	case 'U':
+		apk_flags |= APK_UPDATE_CACHE;
+		break;
 	default:
 		return -1;
 	}
@@ -182,6 +185,7 @@ static int ver_main(void *pctx, struct apk_database *db, struct apk_string_array
 }
 
 static struct apk_option ver_options[] = {
+	{ 'U', "update-cache",	"Update the repository cache first" },
 	{ 'I', "indexes",	"Print description and versions of indexes" },
 	{ 't', "test",		"Compare two given versions, output '<' '=' or '>'" },
 	{ 'c', "check", 	"Check the given version strings, output any that are invalid" },
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Thu, 27 Jun 2013 15:28:52 -0400

Also add infrastructure for short-option-only synonyms
---
 src/apk.c    | 17 +++++++++--------
 src/audit.c  |  4 +++-
 src/del.c    |  4 +++-
 src/fetch.c  |  4 +++-
 src/fix.c    |  4 +++-
 src/info.c   |  8 +++++---
 src/search.c |  4 +++-
 7 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/src/apk.c b/src/apk.c
index a1b26fb..3e3461c 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -110,13 +110,14 @@ static void print_usage(const char *cmd, const char *args, int num_opts,
 	int i, j;
 
 	indent.x = printf("\nusage: apk %s", cmd) - 1;
-	for (i = 0; i < num_opts; i++) {
-		j = 0;
-		word[j++] = '[';
-		j += format_option(&word[j], sizeof(word) - j, &opts[i], "|");
-		word[j++] = ']';
-		apk_print_indented(&indent, APK_BLOB_PTR_LEN(word, j));
-	}
+	for (i = 0; i < num_opts; i++)
+		if (opts[i].name != NULL) {
+			j = 0;
+			word[j++] = '[';
+			j += format_option(&word[j], sizeof(word) - j, &opts[i], "|");
+			word[j++] = ']';
+			apk_print_indented(&indent, APK_BLOB_PTR_LEN(word, j));
+		}
 	if (args != NULL)
 		apk_print_indented(&indent, APK_BLOB_STR(args));
 	printf("\n");
@@ -229,7 +230,7 @@ static void merge_options(struct option *opts, struct apk_option *ao, int num)
 	int i;
 
 	for (i = 0; i < num; i++, opts++, ao++) {
-		opts->name = ao->name;
+		opts->name = ao->name ?: "";
 		opts->has_arg = ao->has_arg;
 		opts->flag = NULL;
 		opts->val = ao->val;
diff --git a/src/audit.c b/src/audit.c
index 1b82c28..fb92aff 100644
--- a/src/audit.c
+++ b/src/audit.c
@@ -52,6 +52,7 @@ static int audit_parse(void *ctx, struct apk_db_options *dbopts,
 		actx->packages_only = 1;
 		break;
 	case 'r':
+	case 'R':
 		actx->recursive = 1;
 		break;
 	default:
@@ -279,7 +280,8 @@ static struct apk_option audit_options[] = {
 			     "protected_paths.d) that need to be backed up" },
 	{ 0x10001, "system", "Verify checksums of all installed non-configuration files " },
 	{ 0x10002, "check-permissions", "Check file and directory uid/gid/mode too" },
-	{ 'r', "recursive",  "List individually all entries in new directories" },
+	{ 'R', "recursive",  "List individually all entries in new directories" },
+	{ 'r', NULL,	     "Synonym for -R (deprecated)" },
 	{ 0x10003, "packages", "List only the changed packages (or names only with -q)" },
 };
 
diff --git a/src/del.c b/src/del.c
index 7b5fd6c..f268b33 100644
--- a/src/del.c
+++ b/src/del.c
@@ -27,6 +27,7 @@ static int del_parse(void *pctx, struct apk_db_options *db,
 
 	switch (optch) {
 	case 'r':
+	case 'R':
 		ctx->recursive_delete = 1;
 		break;
 	default:
@@ -129,8 +130,9 @@ static int del_main(void *pctx, struct apk_database *db, struct apk_string_array
 }
 
 static struct apk_option del_options[] = {
-	{ 'r', "rdepends",	"Recursively delete all top-level reverse "
+	{ 'R', "rdepends",	"Recursively delete all top-level reverse "
 				"dependencies too" },
+	{ 'r', NULL,	        "Synonym for -R (deprecated)" },
 };
 
 static struct apk_applet apk_del = {
diff --git a/src/fetch.c b/src/fetch.c
index 60c31f4..059f1c8 100644
--- a/src/fetch.c
+++ b/src/fetch.c
@@ -77,6 +77,7 @@ static int fetch_parse(void *ctx, struct apk_db_options *dbopts,
 		apk_flags |= APK_UPDATE_CACHE;
 		break;
 	case 'R':
+	case 'D':
 		fctx->flags |= FETCH_RECURSIVE;
 		break;
 	case 's':
@@ -264,7 +265,8 @@ static int fetch_main(void *pctx, struct apk_database *db, struct apk_string_arr
 static struct apk_option fetch_options[] = {
 	{ 'U', "update-cache",	"Update the repository cache first" },
 	{ 'L', "link",		"Create hard links if possible" },
-	{ 'R', "recursive",	"Fetch the PACKAGE and all its dependencies" },
+	{ 'D', "depends",	"Fetch the PACKAGE and all its dependencies" },
+	{ 'R', "recursive",	"Synonyms for -D (deprecated)" },
 	{ 's', "stdout",
 	  "Dump the .apk to stdout (incompatible with -o and -R)" },
 	{ 'o', "output",	"Directory to place the PACKAGEs to",
diff --git a/src/fix.c b/src/fix.c
index e772bd9..b59af0b 100644
--- a/src/fix.c
+++ b/src/fix.c
@@ -28,6 +28,7 @@ static int fix_parse(void *pctx, struct apk_db_options *dbopts,
 	struct fix_ctx *ctx = (struct fix_ctx *) pctx;
 	switch (optch) {
 	case 'd':
+	case 'D':
 		ctx->fix_depends = 1;
 		break;
 	case 'U':
@@ -89,7 +90,8 @@ static int fix_main(void *pctx, struct apk_database *db, struct apk_string_array
 
 static struct apk_option fix_options[] = {
 	{ 'U',          "update-cache",	"Update the repository cache first" },
-	{ 'd',		"depends",	"Fix all dependencies too" },
+	{ 'D',		"depends",	"Fix all dependencies too" },
+	{ 'd',          NULL,	        "Synonym for -D (deprecated)" },
 	{ 'r',		"reinstall",	"Reinstall the package (default)" },
 	{ 'u',		"upgrade",	"Prefer to upgrade package" },
 	{ 0x10000,	"directory-permissions", "Reset all directory permissions" },
diff --git a/src/info.c b/src/info.c
index f4d5b92..6859268 100644
--- a/src/info.c
+++ b/src/info.c
@@ -350,13 +350,14 @@ static int info_parse(void *pctx, struct apk_db_options *dbopts,
 	case 'w':
 		ctx->subaction_mask |= APK_INFO_URL;
 		break;
-	case 'R':
+	case 'D':
 		ctx->subaction_mask |= APK_INFO_DEPENDS;
 		break;
 	case 'P':
 		ctx->subaction_mask |= APK_INFO_PROVIDES;
 		break;
 	case 'r':
+	case 'R':
 		ctx->subaction_mask |= APK_INFO_RDEPENDS;
 		break;
 	case 'I':
@@ -419,9 +420,10 @@ static struct apk_option info_options[] = {
 	{ 'L', "contents",	"List contents of the PACKAGE" },
 	{ 'e', "installed",	"Check if PACKAGE is installed" },
 	{ 'W', "who-owns",	"Print the package owning the specified file" },
-	{ 'R', "depends",	"List packages that the PACKAGE depends on" },
+	{ 'D', "depends",	"List packages that the PACKAGE (directly) depends on" },
+	{ 'R', "rdepends",	"List all packages (directly) depending on PACKAGE" },
+	{ 'r', NULL,	        "Synonym for -R (deprecated)" },
 	{ 'P', "provides",	"List virtual packages provided by PACKAGE" },
-	{ 'r', "rdepends",	"List all packages depending on PACKAGE" },
 	{ 0x10000, "replaces",	"List packages whom files PACKAGE might replace" },
 	{ 'i', "install-if",	"List the PACKAGE's install_if rule" },
 	{ 'I', "rinstall-if",	"List all packages having install_if referencing PACKAGE" },
diff --git a/src/search.c b/src/search.c
index ef3d254..e5044a9 100644
--- a/src/search.c
+++ b/src/search.c
@@ -88,6 +88,7 @@ static int search_parse(void *ctx, struct apk_db_options *dbopts,
 		ictx->print_package = print_origin_name;
 		break;
 	case 'r':
+	case 'R':
 		ictx->print_result = print_rdepends;
 		break;
 	default:
@@ -172,7 +173,8 @@ static struct apk_option search_options[] = {
 	{ 'd', "description",	"Search package descriptions (implies -a)" },
 	{ 'e', "exact",		"Require exact match (instead of substring match)" },
 	{ 'o', "origin",	"Print origin package name instead of the subpackage" },
-	{ 'r', "rdepends",	"Print reverse dependencies of package" },
+	{ 'R', "rdepends",	"Print reverse dependencies of package" },
+	{ 'r', NULL,	        "Synonym for -R (deprecated)" },
 };
 
 static struct apk_applet apk_search = {
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Thu, 27 Jun 2013 15:28:53 -0400

---
 src/info.c   | 2 +-
 src/search.c | 2 +-

diff --git a/src/info.c b/src/info.c
index 6859268..578e118 100644
--- a/src/info.c
+++ b/src/info.c
@@ -421,7 +421,7 @@ static struct apk_option info_options[] = {
 	{ 'e', "installed",	"Check if PACKAGE is installed" },
 	{ 'W', "who-owns",	"Print the package owning the specified file" },
 	{ 'D', "depends",	"List packages that the PACKAGE (directly) depends on" },
-	{ 'R', "rdepends",	"List all packages (directly) depending on PACKAGE" },
+	{ 'R', "rdepends",	"List all installed packages (directly) depending on PACKAGE" },
 	{ 'r', NULL,	        "Synonym for -R (deprecated)" },
 	{ 'P', "provides",	"List virtual packages provided by PACKAGE" },
 	{ 0x10000, "replaces",	"List packages whom files PACKAGE might replace" },
diff --git a/src/search.c b/src/search.c
index e5044a9..122affe 100644
--- a/src/search.c
+++ b/src/search.c
@@ -173,7 +173,7 @@ static struct apk_option search_options[] = {
 	{ 'd', "description",	"Search package descriptions (implies -a)" },
 	{ 'e', "exact",		"Require exact match (instead of substring match)" },
 	{ 'o', "origin",	"Print origin package name instead of the subpackage" },
-	{ 'R', "rdepends",	"Print reverse dependencies of package" },
+	{ 'R', "rdepends",	"List all (installed and uninstalled) packages depending on PACKAGE" },
 	{ 'r', NULL,	        "Synonym for -R (deprecated)" },
 };
 
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Thu, 27 Jun 2013 15:28:54 -0400

---
 src/search.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/search.c b/src/search.c
index 122affe..4ef804d 100644
--- a/src/search.c
+++ b/src/search.c
@@ -82,6 +82,7 @@ static int search_parse(void *ctx, struct apk_db_options *dbopts,
 		ictx->show_all = 1;
 		break;
 	case 'e':
+	case 'x':
 		ictx->search_exact = 1;
 		break;
 	case 'o':
@@ -171,7 +172,8 @@ static struct apk_option search_options[] = {
 	{ 'U', "update-cache",	"Update the repository cache first" },
 	{ 'a', "all",		"Show all package versions (instead of latest only)" },
 	{ 'd', "description",	"Search package descriptions (implies -a)" },
-	{ 'e', "exact",		"Require exact match (instead of substring match)" },
+	{ 'x', "exact",		"Require exact match (instead of substring match)" },
+	{ 'e', NULL,	        "Synonym for -x (deprecated)" },
 	{ 'o', "origin",	"Print origin package name instead of the subpackage" },
 	{ 'R', "rdepends",	"List all (installed and uninstalled) packages depending on PACKAGE" },
 	{ 'r', NULL,	        "Synonym for -R (deprecated)" },
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Thu, 27 Jun 2013 15:28:55 -0400

I'm not sure if either the short or long options work presently (try it with
abuildhelper). But in any case, I noticed in an earlier version of apk-tools
that the short option wasn't working, perhaps because the generic command-line
option '-i' is parsed first. This option for "apk info" is uncommon enough that
a short form (polluting the usage namespace) doesn't seem necessary.

Would be nice to also delete the short option -I (leaving just the long options
--install-if and --rinstall-if), but I haven't implemented that here.
---
 src/info.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/info.c b/src/info.c
index 578e118..62866eb 100644
--- a/src/info.c
+++ b/src/info.c
@@ -363,7 +363,7 @@ static int info_parse(void *pctx, struct apk_db_options *dbopts,
 	case 'I':
 		ctx->subaction_mask |= APK_INFO_INSTALL_IF;
 		break;
-	case 'i':
+	case 0x10001:
 		ctx->subaction_mask |= APK_INFO_RINSTALL_IF;
 		break;
 	case 's':
@@ -425,7 +425,7 @@ static struct apk_option info_options[] = {
 	{ 'r', NULL,	        "Synonym for -R (deprecated)" },
 	{ 'P', "provides",	"List virtual packages provided by PACKAGE" },
 	{ 0x10000, "replaces",	"List packages whom files PACKAGE might replace" },
-	{ 'i', "install-if",	"List the PACKAGE's install_if rule" },
+	{ 0x10001, "install-if", "List the PACKAGE's install_if rule" },
 	{ 'I', "rinstall-if",	"List all packages having install_if referencing PACKAGE" },
 	{ 'w', "webpage",	"Show URL for more information about PACKAGE" },
 	{ 's', "size",		"Show installed size of PACKAGE" },
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Thu, 27 Jun 2013 15:28:56 -0400

---
 src/index.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/index.c b/src/index.c
index 4a97911..dafb5fc 100644
--- a/src/index.c
+++ b/src/index.c
@@ -251,7 +251,7 @@ static struct apk_option index_options[] = {
 
 static struct apk_applet apk_index = {
 	.name = "index",
-	.help = "Create repository index file from FILEs",
+	.help = "Create repository index file from FILEs (deprecated, use mkindex instead)",
 	.arguments = "FILE...",
 	.open_flags = APK_OPENF_READ | APK_OPENF_NO_STATE | APK_OPENF_NO_REPOS,
 	.context_size = sizeof(struct index_ctx),
@@ -263,3 +263,16 @@ static struct apk_applet apk_index = {
 
 APK_DEFINE_APPLET(apk_index);
 
+static struct apk_applet apk_mkindex = {
+	.name = "mkindex",
+	.help = "Create repository index file from FILEs",
+	.arguments = "FILE...",
+	.open_flags = APK_OPENF_READ | APK_OPENF_NO_STATE | APK_OPENF_NO_REPOS,
+	.context_size = sizeof(struct index_ctx),
+	.num_options = ARRAY_SIZE(index_options),
+	.options = index_options,
+	.parse = index_parse,
+	.main = index_main,
+};
+
+APK_DEFINE_APPLET(apk_mkindex);
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Thu, 27 Jun 2013 15:28:57 -0400

---
 src/add.c   | 2 +-
 src/audit.c | 4 ++--
 src/info.c  | 8 ++++----
 src/ver.c   | 6 +++---
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/add.c b/src/add.c
index 832e601..021b878 100644
--- a/src/add.c
+++ b/src/add.c
@@ -153,7 +153,6 @@ static int add_main(void *ctx, struct apk_database *db, struct apk_string_array
 }
 
 static struct apk_option add_options[] = {
-	{ 0x10000,	"initdb",	"Initialize database" },
 	{ 'U',          "update-cache",	"Update the repository cache first" },
 	{ 'u',		"upgrade",	"Prefer to upgrade package" },
 	{ 't',		"virtual",
@@ -161,6 +160,7 @@ static struct apk_option add_options[] = {
 	  "package with the listed dependencies and add that to 'world'; the "
 	  "actions of the command are easily reverted by deleting the virtual "
 	  "package", required_argument, "NAME" },
+	{ 0x10000,	"initdb",	"Initialize database" },
 };
 
 static struct apk_applet apk_add = {
diff --git a/src/audit.c b/src/audit.c
index fb92aff..e913020 100644
--- a/src/audit.c
+++ b/src/audit.c
@@ -276,12 +276,12 @@ static int audit_main(void *ctx, struct apk_database *db, struct apk_string_arra
 }
 
 static struct apk_option audit_options[] = {
+	{ 'R', "recursive",  "List individually all entries in new directories" },
+	{ 'r', NULL,	     "Synonym for -R (deprecated)" },
 	{ 0x10000, "backup", "List all modified configuration files (in "
 			     "protected_paths.d) that need to be backed up" },
 	{ 0x10001, "system", "Verify checksums of all installed non-configuration files " },
 	{ 0x10002, "check-permissions", "Check file and directory uid/gid/mode too" },
-	{ 'R', "recursive",  "List individually all entries in new directories" },
-	{ 'r', NULL,	     "Synonym for -R (deprecated)" },
 	{ 0x10003, "packages", "List only the changed packages (or names only with -q)" },
 };
 
diff --git a/src/info.c b/src/info.c
index 62866eb..a68281c 100644
--- a/src/info.c
+++ b/src/info.c
@@ -420,18 +420,18 @@ static struct apk_option info_options[] = {
 	{ 'L', "contents",	"List contents of the PACKAGE" },
 	{ 'e', "installed",	"Check if PACKAGE is installed" },
 	{ 'W', "who-owns",	"Print the package owning the specified file" },
+	{ 'a', "all",		"Print all information about PACKAGE" },
+	{ 'd', "description",	"Print description for PACKAGE" },
 	{ 'D', "depends",	"List packages that the PACKAGE (directly) depends on" },
 	{ 'R', "rdepends",	"List all installed packages (directly) depending on PACKAGE" },
 	{ 'r', NULL,	        "Synonym for -R (deprecated)" },
+	{ 's', "size",		"Show installed size of PACKAGE" },
+	{ 'w', "webpage",	"Show URL for more information about PACKAGE" },
 	{ 'P', "provides",	"List virtual packages provided by PACKAGE" },
 	{ 0x10000, "replaces",	"List packages whom files PACKAGE might replace" },
 	{ 0x10001, "install-if", "List the PACKAGE's install_if rule" },
 	{ 'I', "rinstall-if",	"List all packages having install_if referencing PACKAGE" },
-	{ 'w', "webpage",	"Show URL for more information about PACKAGE" },
-	{ 's', "size",		"Show installed size of PACKAGE" },
-	{ 'd', "description",	"Print description for PACKAGE" },
 	{ 't', "triggers",	"Print active triggers of PACKAGE" },
-	{ 'a', "all",		"Print all information about PACKAGE" },
 };
 
 static struct apk_applet apk_info = {
diff --git a/src/ver.c b/src/ver.c
index e15eaeb..567c15b 100644
--- a/src/ver.c
+++ b/src/ver.c
@@ -186,12 +186,12 @@ static int ver_main(void *pctx, struct apk_database *db, struct apk_string_array
 
 static struct apk_option ver_options[] = {
 	{ 'U', "update-cache",	"Update the repository cache first" },
-	{ 'I', "indexes",	"Print description and versions of indexes" },
-	{ 't', "test",		"Compare two given versions, output '<' '=' or '>'" },
-	{ 'c', "check", 	"Check the given version strings, output any that are invalid" },
 	{ 'a', "all",		"Consider packages from all repository tags" },
 	{ 'l', "limit",		"Limit output to packages with status matching one of LIMCHARs",
 	  required_argument, "LIMCHARs" },
+	{ 'I', "indexes",	"Print description and versions of indexes" },
+	{ 't', "test",		"Compare two given versions, output '<' '=' or '>'" },
+	{ 'c', "check", 	"Check the given version strings, output any that are invalid" },
 };

---

---

From: Dubiousjim <[email-masked]>
Date: Thu, 27 Jun 2013 15:28:58 -0400

---
 src/apk.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/apk.c b/src/apk.c
index 3e3461c..604378c 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -37,15 +37,15 @@ char **apk_argv;
 
 static struct apk_option generic_options[] = {
 	{ 'h', "help",		"Show generic help or applet specific help" },
-	{ 'p', "root",		"Install packages to DIR",
-				required_argument, "DIR" },
-	{ 'X', "repository",	"Use packages from REPO",
-				required_argument, "REPO" },
+	{ 'V', "version",	"Print program version and exit" },
 	{ 'q', "quiet",		"Print less information" },
 	{ 'v', "verbose",	"Print more information (can be doubled)" },
 	{ 'i', "interactive",	"Ask confirmation for certain operations" },
-	{ 'V', "version",	"Print program version and exit" },
 	{ 'f', "force",		"Do what was asked even if it looks dangerous" },
+	{ 'p', "root",		"Install packages to DIR",
+				required_argument, "DIR" },
+	{ 'X', "repository",	"Use packages from REPO",
+				required_argument, "REPO" },
 	{ 0x101, "progress",	"Show a progress bar" },
 	{ 0x10f, "progress-fd",	"Write progress to fd", required_argument, "FD" },
 	{ 0x110, "no-progress",	"Disable progress bar even for TTYs" },
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Thu, 27 Jun 2013 15:28:59 -0400

---
 src/add.c     | 5 +++++
 src/apk.c     | 5 -----
 src/del.c     | 5 +++++
 src/fix.c     | 5 +++++
 src/upgrade.c | 5 +++++
 5 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/add.c b/src/add.c
index 021b878..ea4bd47 100644
--- a/src/add.c
+++ b/src/add.c
@@ -30,6 +30,9 @@ static int add_parse(void *ctx, struct apk_db_options *dbopts,
 	case 0x10000:
 		dbopts->open_flags |= APK_OPENF_CREATE;
 		break;
+	case 0x10002:
+		apk_flags |= APK_PURGE;
+		break;
 	case 'u':
 		actx->solver_flags |= APK_SOLVERF_UPGRADE;
 		break;
@@ -160,6 +163,8 @@ static struct apk_option add_options[] = {
 	  "package with the listed dependencies and add that to 'world'; the "
 	  "actions of the command are easily reverted by deleting the virtual "
 	  "package", required_argument, "NAME" },
+	{ 0x10002,      "purge",	"Delete also modified configuration files on "
+				        "package removal" },
 	{ 0x10000,	"initdb",	"Initialize database" },
 };
 
diff --git a/src/apk.c b/src/apk.c
index 604378c..8c05d9f 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -51,8 +51,6 @@ static struct apk_option generic_options[] = {
 	{ 0x110, "no-progress",	"Disable progress bar even for TTYs" },
 	{ 0x102, "clean-protected", "Do not create .apk-new files to "
 				"configuration dirs" },
-	{ 0x106, "purge",	"Delete also modified configuration files on "
-				"package removal" },
 	{ 0x103, "allow-untrusted", "Blindly install packages with untrusted "
 				"signatures or no signature at all" },
 	{ 0x104, "simulate",	"Show what would be done without actually "
@@ -396,9 +394,6 @@ int main(int argc, char **argv)
 		case 0x104:
 			apk_flags |= APK_SIMULATE;
 			break;
-		case 0x106:
-			apk_flags |= APK_PURGE;
-			break;
 		case 0x105:
 			dbopts.lock_wait = atoi(optarg);
 			break;
diff --git a/src/del.c b/src/del.c
index f268b33..bbf4080 100644
--- a/src/del.c
+++ b/src/del.c
@@ -30,6 +30,9 @@ static int del_parse(void *pctx, struct apk_db_options *db,
 	case 'R':
 		ctx->recursive_delete = 1;
 		break;
+	case 0x10002:
+		apk_flags |= APK_PURGE;
+		break;
 	default:
 		return -1;
 	}
@@ -133,6 +136,8 @@ static struct apk_option del_options[] = {
 	{ 'R', "rdepends",	"Recursively delete all top-level reverse "
 				"dependencies too" },
 	{ 'r', NULL,	        "Synonym for -R (deprecated)" },
+	{ 0x10002, "purge",	"Delete also modified configuration files on "
+			        "package removal" },
 };
 
 static struct apk_applet apk_del = {
diff --git a/src/fix.c b/src/fix.c
index b59af0b..da08b73 100644
--- a/src/fix.c
+++ b/src/fix.c
@@ -43,6 +43,9 @@ static int fix_parse(void *pctx, struct apk_db_options *dbopts,
 	case 0x10000:
 		ctx->fix_directory_permissions = 1;
 		break;
+	case 0x10002:
+		apk_flags |= APK_PURGE;
+		break;
 	default:
 		return -1;
 	}
@@ -95,6 +98,8 @@ static struct apk_option fix_options[] = {
 	{ 'r',		"reinstall",	"Reinstall the package (default)" },
 	{ 'u',		"upgrade",	"Prefer to upgrade package" },
 	{ 0x10000,	"directory-permissions", "Reset all directory permissions" },
+	{ 0x10002,      "purge",	"Delete also modified configuration files on "
+				        "package removal" },
 };
 
 static struct apk_applet apk_fix = {
diff --git a/src/upgrade.c b/src/upgrade.c
index 020fda0..28ce020 100644
--- a/src/upgrade.c
+++ b/src/upgrade.c
@@ -41,6 +41,9 @@ static int upgrade_parse(void *ctx, struct apk_db_options *dbopts,
 	case 'l':
 		uctx->solver_flags |= APK_SOLVERF_LATEST;
 		break;
+	case 0x10002:
+		apk_flags |= APK_PURGE;
+		break;
 	default:
 		return -1;
 	}
@@ -141,6 +144,8 @@ static struct apk_option upgrade_options[] = {
 	{ 'l', "latest",
 	  "Select latest version of package (if it is not pinned), and "
 	  "print error if it cannot be installed due to other dependencies" },
+	{ 0x10002, "purge",	"Delete also modified configuration files on "
+				"package removal" },
 	{ 0x10000, "no-self-upgrade",
 	  "Do not do early upgrade of 'apk-tools' package" },
 };
-- 
1.8.3.1

---

---

From: Dubiousjim <[email-masked]>
Date: Thu, 27 Jun 2013 15:29:00 -0400

---
 src/add.c     | 5 +++++
 src/apk.c     | 5 -----
 src/del.c     | 5 +++++
 src/fix.c     | 5 +++++
 src/upgrade.c | 5 +++++

diff --git a/src/add.c b/src/add.c
index ea4bd47..e3baa74 100644
--- a/src/add.c
+++ b/src/add.c
@@ -30,6 +30,9 @@ static int add_parse(void *ctx, struct apk_db_options *dbopts,
 	case 0x10000:
 		dbopts->open_flags |= APK_OPENF_CREATE;
 		break;
+	case 0x10003:
+		apk_flags |= APK_CLEAN_PROTECTED;
+		break;
 	case 0x10002:
 		apk_flags |= APK_PURGE;
 		break;
@@ -163,6 +166,8 @@ static struct apk_option add_options[] = {
 	  "package with the listed dependencies and add that to 'world'; the "
 	  "actions of the command are easily reverted by deleting the virtual "
 	  "package", required_argument, "NAME" },
+	{ 0x10003,      "clean-protected", "Do not create .apk-new files in "
+				        "configuration dirs" },
 	{ 0x10002,      "purge",	"Delete also modified configuration files on "
 				        "package removal" },
 	{ 0x10000,	"initdb",	"Initialize database" },
diff --git a/src/apk.c b/src/apk.c
index 8c05d9f..c3709e7 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -49,8 +49,6 @@ static struct apk_option generic_options[] = {
 	{ 0x101, "progress",	"Show a progress bar" },
 	{ 0x10f, "progress-fd",	"Write progress to fd", required_argument, "FD" },
 	{ 0x110, "no-progress",	"Disable progress bar even for TTYs" },
-	{ 0x102, "clean-protected", "Do not create .apk-new files to "
-				"configuration dirs" },
 	{ 0x103, "allow-untrusted", "Blindly install packages with untrusted "
 				"signatures or no signature at all" },
 	{ 0x104, "simulate",	"Show what would be done without actually "
@@ -385,9 +383,6 @@ int main(int argc, char **argv)
 		case 0x10f:
 			apk_progress_fd = atoi(optarg);
 			break;
-		case 0x102:
-			apk_flags |= APK_CLEAN_PROTECTED;
-			break;
 		case 0x103:
 			apk_flags |= APK_ALLOW_UNTRUSTED;
 			break;
diff --git a/src/del.c b/src/del.c
index bbf4080..21da5d1 100644
--- a/src/del.c
+++ b/src/del.c
@@ -30,6 +30,9 @@ static int del_parse(void *pctx, struct apk_db_options *db,
 	case 'R':
 		ctx->recursive_delete = 1;
 		break;
+	case 0x10003:
+		apk_flags |= APK_CLEAN_PROTECTED;
+		break;
 	case 0x10002:
 		apk_flags |= APK_PURGE;
 		break;
@@ -136,6 +139,8 @@ static struct apk_option del_options[] = {
 	{ 'R', "rdepends",	"Recursively delete all top-level reverse "
 				"dependencies too" },
 	{ 'r', NULL,	        "Synonym for -R (deprecated)" },
+	{ 0x10003,      "clean-protected", "Do not create .apk-new files in "
+				        "configuration dirs" },
 	{ 0x10002, "purge",	"Delete also modified configuration files on "
 			        "package removal" },
 };
diff --git a/src/fix.c b/src/fix.c
index da08b73..c04abe1 100644
--- a/src/fix.c
+++ b/src/fix.c
@@ -43,6 +43,9 @@ static int fix_parse(void *pctx, struct apk_db_options *dbopts,
 	case 0x10000:
 		ctx->fix_directory_permissions = 1;
 		break;
+	case 0x10003:
+		apk_flags |= APK_CLEAN_PROTECTED;
+		break;
 	case 0x10002:
 		apk_flags |= APK_PURGE;
 		break;
@@ -98,6 +101,8 @@ static struct apk_option fix_options[] = {
 	{ 'r',		"reinstall",	"Reinstall the package (default)" },
 	{ 'u',		"upgrade",	"Prefer to upgrade package" },
 	{ 0x10000,	"directory-permissions", "Reset all directory permissions" },
+	{ 0x10003,      "clean-protected", "Do not create .apk-new files in "
+				        "configuration dirs" },
 	{ 0x10002,      "purge",	"Delete also modified configuration files on "
 				        "package removal" },
 };
diff --git a/src/upgrade.c b/src/upgrade.c
index 28ce020..8a476e9 100644
--- a/src/upgrade.c
+++ b/src/upgrade.c
@@ -41,6 +41,9 @@ static int upgrade_parse(void *ctx, struct apk_db_options *dbopts,
 	case 'l':
 		uctx->solver_flags |= APK_SOLVERF_LATEST;
 		break;
+	case 0x10003:
+		apk_flags |= APK_CLEAN_PROTECTED;
+		break;
 	case 0x10002:
 		apk_flags |= APK_PURGE;
 		break;
@@ -144,6 +147,8 @@ static struct apk_option upgrade_options[] = {
 	{ 'l', "latest",
 	  "Select latest version of package (if it is not pinned), and "
 	  "print error if it cannot be installed due to other dependencies" },
+	{ 0x10003, "clean-protected", "Do not create .apk-new files in "
+				      "configuration dirs" },
 	{ 0x10002, "purge",	"Delete also modified configuration files on "
 				"package removal" },
 	{ 0x10000, "no-self-upgrade",
-- 
1.8.3.1

---