Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
install: small behaviour change!
Baptiste Daroussin committed 1 month ago
commit 85173eeedd70b6eff1e793ab07dedcb83b3ab2df
parent f2f1f4d
2 files changed +53 -5
modified docs/pkg-install.8
@@ -64,9 +64,19 @@ See
.Xr pkg-autoremove 8
for details.
.Pp
-
Autoremoval flags are sticky, and will persist over reinstallation or
-
upgrade of the packages concerned, even if subsequently the packages
-
are named explicitly on a command line.
+
If a requested package is already installed at the latest version,
+
.Nm
+
will check whether its autoremoval flag matches the requested state.
+
If
+
.Nm
+
is run without
+
.Fl A
+
and the package is marked as automatically installed,
+
the user will be prompted to clear the autoremoval flag.
+
Conversely, if
+
.Fl A
+
is specified and the package is not marked as automatic,
+
the user will be prompted to set it.
See
.Xr pkg-query 8
for finding the autoremoval status of a package, and
modified src/install.c
@@ -276,8 +276,46 @@ exec_install(int argc, char **argv)
		break;
	}

-
	if (done == 0 && rc)
-
		printf("The most recent versions of packages are already installed\n");
+
	if (done == 0 && rc) {
+
		bool want_automatic = (f & PKG_FLAG_AUTOMATIC) != 0;
+
		bool suggested = false;
+

+
		for (int i = 0; i < argc; i++) {
+
			struct pkgdb_it *lit;
+
			struct pkg *lpkg = NULL;
+
			bool automatic;
+

+
			lit = pkgdb_query(db, argv[i], match);
+
			if (lit == NULL)
+
				continue;
+
			if (pkgdb_it_next(lit, &lpkg, PKG_LOAD_BASIC) != EPKG_OK) {
+
				pkgdb_it_free(lit);
+
				continue;
+
			}
+
			pkgdb_it_free(lit);
+
			pkg_get(lpkg, PKG_ATTR_AUTOMATIC, &automatic);
+
			if (!want_automatic && automatic) {
+
				if (query_yesno(false,
+
				    "%n-%v is already installed as automatic. "
+
				    "Mark as non-automatic? ",
+
				    lpkg, lpkg))
+
					pkgdb_set(db, lpkg,
+
					    PKG_SET_AUTOMATIC, (int)false);
+
				suggested = true;
+
			} else if (want_automatic && !automatic) {
+
				if (query_yesno(false,
+
				    "%n-%v is already installed. "
+
				    "Mark as automatically installed? ",
+
				    lpkg, lpkg))
+
					pkgdb_set(db, lpkg,
+
					    PKG_SET_AUTOMATIC, (int)true);
+
				suggested = true;
+
			}
+
			pkg_free(lpkg);
+
		}
+
		if (!suggested)
+
			printf("The most recent versions of packages are already installed\n");
+
	}

	if (!rc)
		status = EXIT_FAILURE;