xbps-bin: added -F flag for the remove target.
Unless it's set, packages that are dependencies of other installed packages won't be removed. This flag overrides this behaviour and forces the package removal. While being here, misc cleanups.
This commit is contained in:
		@@ -42,6 +42,7 @@ int	show_pkg_namedesc(prop_object_t, void *, bool *);
 | 
			
		||||
int	list_strings_in_array(prop_object_t, void *, bool *);
 | 
			
		||||
int	list_strings_sep_in_array(prop_object_t, void *, bool *);
 | 
			
		||||
size_t	find_longest_pkgver(prop_dictionary_t);
 | 
			
		||||
void	print_package_line(const char *);
 | 
			
		||||
 | 
			
		||||
struct repo_search_data {
 | 
			
		||||
	char *pattern;
 | 
			
		||||
 
 | 
			
		||||
@@ -39,31 +39,8 @@ static void
 | 
			
		||||
usage(void)
 | 
			
		||||
{
 | 
			
		||||
	fprintf(stderr,
 | 
			
		||||
	"Usage: xbps-repo [options] [action] [arguments]\n\n"
 | 
			
		||||
	" Available actions:\n"
 | 
			
		||||
        "    add, genindex, list, remove, search, show, show-deps,\n"
 | 
			
		||||
	"    show-files, sync\n"
 | 
			
		||||
	" Actions with arguments:\n"
 | 
			
		||||
	"    add\t\t<URI>\n"
 | 
			
		||||
	"    genindex\t<path>\n"
 | 
			
		||||
	"    remove\t<URI>\n"
 | 
			
		||||
	"    search\t<string>\n"
 | 
			
		||||
	"    show\t<pkgname>\n"
 | 
			
		||||
	"    show-deps\t<pkgname>\n"
 | 
			
		||||
	"    show-files\t<pkgname>\n"
 | 
			
		||||
	" Options shared by all actions:\n"
 | 
			
		||||
	"    -c\t\t<cachedir>\n"
 | 
			
		||||
	"    -r\t\t<rootdir>\n"
 | 
			
		||||
	"    -V\t\tPrints xbps release version\n"
 | 
			
		||||
	"\n"
 | 
			
		||||
	" Examples:\n"
 | 
			
		||||
	"    $ xbps-repo add /path/to/directory\n"
 | 
			
		||||
	"    $ xbps-repo add http://www.location.org/xbps-repo\n"
 | 
			
		||||
	"    $ xbps-repo list\n"
 | 
			
		||||
	"    $ xbps-repo remove /path/to/directory\n"
 | 
			
		||||
	"    $ xbps-repo search klibc\n"
 | 
			
		||||
	"    $ xbps-repo show klibc\n"
 | 
			
		||||
	"    $ xbps-repo genindex /pkgdir\n");
 | 
			
		||||
	    "Usage: xbps-repo [options] [action] [arguments]\n"
 | 
			
		||||
	    "See xbps-repo(8) for more information.\n");
 | 
			
		||||
	exit(EXIT_FAILURE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -245,25 +245,11 @@ show_pkg_namedesc(prop_object_t obj, void *arg, bool *loop_done)
 | 
			
		||||
int
 | 
			
		||||
list_strings_in_array(prop_object_t obj, void *arg, bool *loop_done)
 | 
			
		||||
{
 | 
			
		||||
	static size_t cols;
 | 
			
		||||
	static bool first;
 | 
			
		||||
 | 
			
		||||
	(void)arg;
 | 
			
		||||
	(void)loop_done;
 | 
			
		||||
 | 
			
		||||
	assert(prop_object_type(obj) == PROP_TYPE_STRING);
 | 
			
		||||
 | 
			
		||||
	cols += strlen(prop_string_cstring_nocopy(obj)) + 4;
 | 
			
		||||
	if (cols <= 80) {
 | 
			
		||||
		if (first == false) {
 | 
			
		||||
			printf("  ");
 | 
			
		||||
			first = true;
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		printf("\n  ");
 | 
			
		||||
		cols = strlen(prop_string_cstring_nocopy(obj)) + 4;
 | 
			
		||||
	}
 | 
			
		||||
	printf("%s ", prop_string_cstring_nocopy(obj));
 | 
			
		||||
	print_package_line(prop_string_cstring_nocopy(obj));
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -276,8 +262,26 @@ list_strings_sep_in_array(prop_object_t obj, void *arg, bool *loop_done)
 | 
			
		||||
	(void)loop_done;
 | 
			
		||||
 | 
			
		||||
	assert(prop_object_type(obj) == PROP_TYPE_STRING);
 | 
			
		||||
 | 
			
		||||
	printf("%s%s\n", sep ? sep : "", prop_string_cstring_nocopy(obj));
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
print_package_line(const char *str)
 | 
			
		||||
{
 | 
			
		||||
	static size_t cols;
 | 
			
		||||
	static bool first;
 | 
			
		||||
 | 
			
		||||
	cols += strlen(str) + 4;
 | 
			
		||||
	if (cols <= 80) {
 | 
			
		||||
		if (first == false) {
 | 
			
		||||
			printf("  ");
 | 
			
		||||
			first = true;
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		printf("\n  ");
 | 
			
		||||
		cols = strlen(str) + 4;
 | 
			
		||||
	}
 | 
			
		||||
	printf("%s ", str);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user