diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/pacman/callback.c | 37 | ||||
| -rw-r--r-- | src/pacman/deptest.c | 46 | ||||
| -rw-r--r-- | src/pacman/pacman.c | 10 | ||||
| -rw-r--r-- | src/pacman/sync.c | 47 | ||||
| -rw-r--r-- | src/pacman/util.c | 31 | ||||
| -rw-r--r-- | src/util/testdb.c | 8 | 
6 files changed, 75 insertions, 104 deletions
| diff --git a/src/pacman/callback.c b/src/pacman/callback.c index 01e65a95..b16c79ee 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -34,9 +34,6 @@  #include "util.h"  #include "conf.h" -/* TODO this should not have to be defined twice- trans.c & log.c */ -#define LOG_STR_LEN 256 -  /* download progress bar */  static float rate_last;  static int xfered_last; @@ -157,8 +154,6 @@ static void fill_progress(const int graph_percent, const int display_percent,  /* callback to handle messages/notifications from libalpm transactions */  void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)  { -	char str[LOG_STR_LEN] = ""; -  	switch(event) {  		case PM_TRANS_EVT_CHECKDEPS_START:  		  printf(_("checking dependencies...\n")); @@ -180,10 +175,9 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)  			}  			break;  		case PM_TRANS_EVT_ADD_DONE: -			snprintf(str, LOG_STR_LEN, "installed %s (%s)\n", +			alpm_logaction("installed %s (%s)\n",  			         alpm_pkg_get_name(data1),  			         alpm_pkg_get_version(data1)); -			alpm_logaction(str);  			break;  		case PM_TRANS_EVT_REMOVE_START:  			if(config->noprogressbar) { @@ -191,10 +185,9 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)  			}  			break;  		case PM_TRANS_EVT_REMOVE_DONE: -			snprintf(str, LOG_STR_LEN, "removed %s (%s)\n", +			alpm_logaction("removed %s (%s)\n",  			         alpm_pkg_get_name(data1),  			         alpm_pkg_get_version(data1)); -			alpm_logaction(str);  			break;  		case PM_TRANS_EVT_UPGRADE_START:  			if(config->noprogressbar) { @@ -202,11 +195,10 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)  			}  			break;  		case PM_TRANS_EVT_UPGRADE_DONE: -			snprintf(str, LOG_STR_LEN, "upgraded %s (%s -> %s)\n", +			alpm_logaction("upgraded %s (%s -> %s)\n",  			         (char *)alpm_pkg_get_name(data1),  			         (char *)alpm_pkg_get_version(data2),  			         (char *)alpm_pkg_get_version(data1)); -			alpm_logaction(str);  			break;  		case PM_TRANS_EVT_INTEGRITY_START:  			printf(_("checking package integrity...\n")); @@ -255,34 +247,28 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)  void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,                     void *data3, int *response)  { -	char str[LOG_STR_LEN] = ""; -  	switch(event) {  		case PM_TRANS_CONV_INSTALL_IGNOREPKG:  			if(data2) {  				/* TODO we take this route based on data2 being not null? WTF */ -				snprintf(str, LOG_STR_LEN, _(":: %s requires installing %s from IgnorePkg/IgnoreGroup. Install anyway? [Y/n] "), +				*response = yesno(_(":: %s requires installing %s from IgnorePkg/IgnoreGroup. Install anyway? [Y/n] "),  						alpm_pkg_get_name(data1),  						alpm_pkg_get_name(data2)); -				*response = yesno(str);  			} else { -				snprintf(str, LOG_STR_LEN, _(":: %s is in IgnorePkg/IgnoreGroup. Install anyway? [Y/n] "), +				*response = yesno(_(":: %s is in IgnorePkg/IgnoreGroup. Install anyway? [Y/n] "),  						alpm_pkg_get_name(data1)); -				*response = yesno(str);  			}  			break;  		case PM_TRANS_CONV_REMOVE_HOLDPKG: -			snprintf(str, LOG_STR_LEN, _(":: %s is designated as a HoldPkg. Remove anyway? [Y/n] "), +			*response = yesno(_(":: %s is designated as a HoldPkg. Remove anyway? [Y/n] "),  					alpm_pkg_get_name(data1)); -			*response = yesno(str);  			break;  		case PM_TRANS_CONV_REPLACE_PKG:  			if(!config->noconfirm) { -				snprintf(str, LOG_STR_LEN, _(":: Replace %s with %s/%s? [Y/n] "), +				*response = yesno(_(":: Replace %s with %s/%s? [Y/n] "),  						alpm_pkg_get_name(data1),  						(char *)data3,  						alpm_pkg_get_name(data2)); -				*response = yesno(str);  			} else {  				printf(_("Replacing %s with %s/%s\n"),  						alpm_pkg_get_name(data1), @@ -292,27 +278,24 @@ void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,  			}  			break;  		case PM_TRANS_CONV_CONFLICT_PKG: -			snprintf(str, LOG_STR_LEN, _(":: %s conflicts with %s. Remove %s? [Y/n] "), +			*response = yesno(_(":: %s conflicts with %s. Remove %s? [Y/n] "),  					(char *)data1,  					(char *)data2,  					(char *)data2); -			*response = yesno(str);  			break;  		case PM_TRANS_CONV_LOCAL_NEWER:  			if(!config->op_s_downloadonly) { -				snprintf(str, LOG_STR_LEN, _(":: %s-%s: local version is newer. Upgrade anyway? [Y/n] "), +				*response = yesno(_(":: %s-%s: local version is newer. Upgrade anyway? [Y/n] "),  						alpm_pkg_get_name(data1),  						alpm_pkg_get_version(data1)); -				*response = yesno(str);  			} else {  				*response = 1;  			}  			break;  		case PM_TRANS_CONV_CORRUPTED_PKG:  			if(!config->noconfirm) { -				snprintf(str, LOG_STR_LEN, _(":: File %s is corrupted. Do you want to delete it? [Y/n] "), +				*response = yesno(_(":: File %s is corrupted. Do you want to delete it? [Y/n] "),  						(char *)data1); -				*response = yesno(str);  			} else {  				*response = 1;  			} diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c index 2481c0b6..2feca5c4 100644 --- a/src/pacman/deptest.c +++ b/src/pacman/deptest.c @@ -31,53 +31,23 @@  #include "util.h"  #include "conf.h" -/* TODO: This should use _alpm_checkdeps() */  int pacman_deptest(alpm_list_t *targets)  { -	int retval = 0;  	alpm_list_t *i; -	if(targets == NULL) { +	alpm_list_t *deps = alpm_deptest(alpm_option_get_localdb(), targets); +	if(deps == NULL) {  		return(0);  	} -	for(i = targets; i; i = alpm_list_next(i)) { -		int found = 0; -		pmpkg_t *pkg; -		pmdepend_t *dep; -		const char *target; -		alpm_list_t *j, *provides; +	for(i = deps; i; i = alpm_list_next(i)) { +		const char *dep; -		target = alpm_list_getdata(i); -		dep = alpm_splitdep(target); - -		pkg = alpm_db_get_pkg(alpm_option_get_localdb(), -				alpm_dep_get_name(dep)); -		if(pkg && alpm_depcmp(pkg, dep)) { -			found = 1; -		} else { -			/* not found, can we find anything that provides this in the local DB? */ -			provides = alpm_db_whatprovides(alpm_option_get_localdb(), -					alpm_dep_get_name(dep)); -			for(j = provides; j; j = alpm_list_next(j)) { -				pmpkg_t *pkg; -				pkg = alpm_list_getdata(j); - -				if(pkg && alpm_depcmp(pkg, dep)) { -					found = 1; -					break; -				} -			} -			alpm_list_free(provides); -		} - -		if(!found) { -			printf("%s\n", target); -			retval = 127; -		} -		free(dep); +		dep = alpm_list_getdata(i); +		printf("%s\n", dep);  	} -	return(retval); +	alpm_list_free(deps); +	return(127);  }  /* vim: set ts=2 sw=2 noet: */ diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 377ea3fe..f1853203 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -79,6 +79,7 @@ static void usage(int op, const char * const myname)  			printf("%s:  %s {-A --add} [%s] <%s>\n", str_usg, myname, str_opt, str_file);  			printf("%s:\n", str_opt);  			printf(_("      --asdeps         install packages as non-explicitly installed\n")); +			printf(_("      --asexplicit     install packages as explicitly installed\n"));  			printf(_("  -d, --nodeps         skip dependency checks\n"));  			printf(_("  -f, --force          force install, overwrite conflicting files\n"));  		} else if(op == PM_OP_REMOVE) { @@ -89,10 +90,12 @@ static void usage(int op, const char * const myname)  			printf(_("  -k, --dbonly         only remove database entry, do not remove files\n"));  			printf(_("  -n, --nosave         remove configuration files as well\n"));  			printf(_("  -s, --recursive      remove dependencies also (that won't break packages)\n")); +			printf(_("  -u, --unneeded       remove unneeded packages (that won't break packages)\n"));  		} else if(op == PM_OP_UPGRADE) {  			printf("%s:  %s {-U --upgrade} [%s] <%s>\n", str_usg, myname, str_opt, str_file);  			printf("%s:\n", str_opt);  			printf(_("      --asdeps         install packages as non-explicitly installed\n")); +			printf(_("      --asexplicit     install packages as explicitly installed\n"));  			printf(_("  -d, --nodeps         skip dependency checks\n"));  			printf(_("  -f, --force          force install, overwrite conflicting files\n"));  		} else if(op == PM_OP_QUERY) { @@ -115,6 +118,7 @@ static void usage(int op, const char * const myname)  			printf("%s:  %s {-S --sync} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg);  			printf("%s:\n", str_opt);  			printf(_("      --asdeps         install packages as non-explicitly installed\n")); +			printf(_("      --asexplicit     install packages as explicitly installed\n"));  			printf(_("  -c, --clean          remove old packages from cache directory (-cc for all)\n"));  			printf(_("  -d, --nodeps         skip dependency checks\n"));  			printf(_("  -e, --dependsonly    install dependencies only\n")); @@ -331,6 +335,7 @@ static int parseargs(int argc, char *argv[])  		{"unrequired", no_argument,       0, 't'},  		{"upgrades",   no_argument,       0, 'u'},  		{"sysupgrade", no_argument,       0, 'u'}, +		{"unneeded",   no_argument,       0, 'u'},  		{"verbose",    no_argument,       0, 'v'},  		{"downloadonly", no_argument,     0, 'w'},  		{"refresh",    no_argument,       0, 'y'}, @@ -345,6 +350,7 @@ static int parseargs(int argc, char *argv[])  		{"logfile",    required_argument, 0, 1009},  		{"ignoregroup", required_argument, 0, 1010},  		{"needed",     no_argument,       0, 1011}, +		{"asexplicit",     no_argument,   0, 1012},  		{0, 0, 0, 0}  	}; @@ -416,6 +422,9 @@ static int parseargs(int argc, char *argv[])  				FREELIST(list);  				break;  			case 1011: config->flags |= PM_TRANS_FLAG_NEEDED; break; +			case 1012: +				config->flags |= PM_TRANS_FLAG_ALLEXPLICIT; +				break;  			case 'A': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_ADD); break;  			case 'Q': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_QUERY); break;  			case 'R': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_REMOVE); break; @@ -469,6 +478,7 @@ static int parseargs(int argc, char *argv[])  			case 'u':  				config->op_s_upgrade = 1;  				config->op_q_upgrade = 1; +				config->flags |= PM_TRANS_FLAG_UNNEEDED;  				break;  			case 'v': (config->verbose)++; break;  			case 'w': diff --git a/src/pacman/sync.c b/src/pacman/sync.c index e3e87703..5cf146b6 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -232,6 +232,10 @@ static int sync_synctree(int level, alpm_list_t *syncs)  	alpm_list_t *i;  	int success = 0, ret; +	if(sync_trans_init(0) == -1) { +		return(0); +	} +  	for(i = syncs; i; i = alpm_list_next(i)) {  		pmdb_t *db = alpm_list_getdata(i); @@ -259,10 +263,16 @@ static int sync_synctree(int level, alpm_list_t *syncs)  		}  	} +	if(sync_trans_release() == -1) { +		return(0); +	}  	/* We should always succeed if at least one DB was upgraded - we may possibly  	 * fail later with unresolved deps, but that should be rare, and would be  	 * expected  	 */ +	if(!success) { +		fprintf(stderr, _("error: failed to synchronize any databases\n")); +	}  	return(success > 0);  } @@ -499,7 +509,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)  	return(0);  } -static int sync_trans(alpm_list_t *targets, int sync_only) +static int sync_trans(alpm_list_t *targets)  {  	int retval = 0;  	alpm_list_t *data = NULL; @@ -510,23 +520,8 @@ static int sync_trans(alpm_list_t *targets, int sync_only)  		return(1);  	} -	if(config->op_s_sync) { -		/* grab a fresh package list */ -		printf(_(":: Synchronizing package databases...\n")); -		alpm_logaction("synchronizing package lists\n"); -		if(!sync_synctree(config->op_s_sync, sync_dbs)) { -			fprintf(stderr, _("error: failed to synchronize any databases\n")); -			retval = 1; -			goto cleanup; -		} -		if(sync_only) { -			goto cleanup; -		} -	} -  	if(config->op_s_upgrade) {  		alpm_list_t *pkgs, *i; -  		printf(_(":: Starting full system upgrade...\n"));  		alpm_logaction("starting full system upgrade\n");  		if(alpm_trans_sysupgrade() == -1) { @@ -770,7 +765,6 @@ cleanup:  int pacman_sync(alpm_list_t *targets)  {  	alpm_list_t *sync_dbs = NULL; -	int sync_only = 0;  	/* clean the cache */  	if(config->op_s_clean) { @@ -797,18 +791,27 @@ int pacman_sync(alpm_list_t *targets)  		return(1);  	} -	if(config->op_s_search || config->group -			|| config->op_s_info || config->op_q_list) { -		sync_only = 1; -	} else if(targets == NULL && !(config->op_s_sync || config->op_s_upgrade)) { +	if(targets == NULL && !(config->op_s_sync || config->op_s_upgrade +				|| config->op_s_search || config->group +				|| config->op_s_info || config->op_q_list)) {  		/* don't proceed here unless we have an operation that doesn't require  		 * a target list */  		pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)\n"));  		return(1);  	} +	if(config->op_s_sync) { +		/* grab a fresh package list */ +		printf(_(":: Synchronizing package databases...\n")); +		alpm_logaction("synchronizing package lists\n"); +		if(!sync_synctree(config->op_s_sync, sync_dbs)) { +			return(1); +		} +		config->op_s_sync = 0; +	} +  	if(needs_transaction()) { -		if(sync_trans(targets, sync_only) == 1) { +		if(sync_trans(targets) == 1) {  			return(1);  		}  	} diff --git a/src/pacman/util.c b/src/pacman/util.c index aa08eb26..229f65a2 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -234,6 +234,10 @@ void indentprint(const char *str, int indent)  	p = wcstr;  	cidx = indent; +	if(!p) { +		return; +	} +  	while(*p) {  		if(*p == L' ') {  			const wchar_t *q, *next; @@ -464,20 +468,17 @@ void display_targets(const alpm_list_t *syncpkgs, pmdb_t *db_local)  		pmsyncpkg_t *sync = alpm_list_getdata(i);  		pmpkg_t *pkg = alpm_sync_get_pkg(sync); -		/* If this sync record is a replacement, the data member contains -		 * a list of packages to be removed due to the package that is being -		 * installed. */ -		if(alpm_sync_get_type(sync) == PM_SYNC_TYPE_REPLACE) { -			alpm_list_t *to_replace = alpm_sync_get_data(sync); +		/* The removes member contains a list of packages to be removed +		 * due to the package that is being installed. */ +		alpm_list_t *to_replace = alpm_sync_get_removes(sync); -			for(j = to_replace; j; j = alpm_list_next(j)) { -				pmpkg_t *rp = alpm_list_getdata(j); -				const char *name = alpm_pkg_get_name(rp); +		for(j = to_replace; j; j = alpm_list_next(j)) { +			pmpkg_t *rp = alpm_list_getdata(j); +			const char *name = alpm_pkg_get_name(rp); -				if(!alpm_list_find_str(to_remove, name)) { -					rsize += alpm_pkg_get_isize(rp); -					to_remove = alpm_list_add(to_remove, strdup(name)); -				} +			if(!alpm_list_find_str(to_remove, name)) { +				rsize += alpm_pkg_get_isize(rp); +				to_remove = alpm_list_add(to_remove, strdup(name));  			}  		} @@ -520,11 +521,7 @@ void display_targets(const alpm_list_t *syncpkgs, pmdb_t *db_local)  	printf("\n");  	printf(_("Total Download Size:    %.2f MB\n"), mbdlsize); - -	/* TODO because all pkgs don't include isize, this is a crude hack */ -	if(mbisize > mbdlsize) { -		printf(_("Total Installed Size:   %.2f MB\n"), mbisize); -	} +	printf(_("Total Installed Size:   %.2f MB\n"), mbisize);  	FREELIST(targets);  } diff --git a/src/util/testdb.c b/src/util/testdb.c index 122a3fb5..f354ecab 100644 --- a/src/util/testdb.c +++ b/src/util/testdb.c @@ -147,6 +147,14 @@ int main(int argc, char **argv)  		free(depstring);  	} +	/* check conflicts */ +	data = alpm_checkdbconflicts(db); +	for(i = data; i; i = i->next) { +		pmconflict_t *conflict = alpm_list_getdata(i); +		printf("%s conflicts with %s\n", alpm_conflict_get_package1(conflict), +				alpm_conflict_get_package2(conflict)); +	} +  	cleanup(retval);  } | 
