Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
delete/unregister: clarify the message about locked and vital packages
Baptiste Daroussin committed 4 months ago
commit ca76cdc6fd027be3e71344b392058420c0d24aa4
parent 695bdd5
2 files changed +18 -3
modified src/utils.c
@@ -1167,8 +1167,23 @@ int
print_pkg(struct pkg *p, void *ctx)
{
	int *counter = ctx;
-

-
	pkg_printf("\t%n\n", p);
+
	bool locked, vital;
+
	const char *lock_type;
+

+
	pkg_get(p, PKG_ATTR_LOCKED, &locked);
+
	pkg_get(p, PKG_ATTR_VITAL, &vital);
+
	if (locked) {
+
		if (vital)
+
			lock_type = "vital and locked";
+
		else
+
			lock_type = "locked";
+
	} else {
+
		if (vital)
+
			lock_type = "vital";
+
		else
+
			lock_type = "invalid, report an issue";
+
	}
+
	pkg_printf("\t%n (%S)\n", p, lock_type);
	(*counter)++;

	return 0;
modified tests/frontend/vital.sh
@@ -39,7 +39,7 @@ EOF
		pkg -o REPOS_DIR=/dev/null -r ${TMPDIR}/target query "%V" test

	atf_check \
-
		-o inline:"The following package(s) are locked or vital and may not be removed:\n\n\ttest\n\n" \
+
		-o inline:"The following package(s) are locked or vital and may not be removed:\n\n\ttest (vital)\n\n" \
		-e empty  \
		-s exit:7 \
		pkg -r ${TMPDIR}/target delete -qy test