* Fixed some alpm_get_option calls (long params were used for C99 compliance,

but were used in error)
* Cleaned up some output newlines
* Added "local database is up to date" when no packages are upgraded
This commit is contained in:
Aaron Griffin 2006-11-02 02:29:10 +00:00
parent 22ce4a2a00
commit fbf1aa6539
6 changed files with 27 additions and 29 deletions

View file

@ -164,6 +164,9 @@ int yesno(char *fmt, ...)
*++pch = 0; *++pch = 0;
strtrim(response); strtrim(response);
/* User hits 'enter', forcing a newline here */
neednl = 0;
if(!strcasecmp(response, _("Y")) || !strcasecmp(response, _("YES")) || !strlen(response)) { if(!strcasecmp(response, _("Y")) || !strcasecmp(response, _("YES")) || !strlen(response)) {
return(1); return(1);
} }

View file

@ -91,7 +91,7 @@ void dump_pkg_full(PM_PKG *pkg, int level)
long lroot; long lroot;
char *root; char *root;
alpm_get_option(PM_OPT_ROOT, &lroot); alpm_get_option(PM_OPT_ROOT, &lroot);
root = (void *)&root; root = (void *)lroot;
fprintf(stdout, "\n"); fprintf(stdout, "\n");
for(i = alpm_list_first(alpm_pkg_getinfo(pkg, PM_PKG_BACKUP)); i; i = alpm_list_next(i)) { for(i = alpm_list_first(alpm_pkg_getinfo(pkg, PM_PKG_BACKUP)); i; i = alpm_list_next(i)) {
struct stat buf; struct stat buf;

View file

@ -543,10 +543,10 @@ int main(int argc, char *argv[])
FREE(config->dbpath); FREE(config->dbpath);
long ldbpath, lcachedir; long ldbpath, lcachedir;
alpm_get_option(PM_OPT_DBPATH, &ldbpath); alpm_get_option(PM_OPT_DBPATH, &ldbpath);
config->dbpath = (void *)&ldbpath; config->dbpath = (char *)ldbpath;
FREE(config->cachedir); FREE(config->cachedir);
alpm_get_option(PM_OPT_CACHEDIR, &lcachedir); alpm_get_option(PM_OPT_CACHEDIR, &lcachedir);
config->cachedir = (void *)&lcachedir; config->cachedir = (char *)lcachedir;
for(lp = config->op_s_ignore; lp; lp = lp->next) { for(lp = config->op_s_ignore; lp; lp = lp->next) {
if(alpm_set_option(PM_OPT_IGNOREPKG, (long)lp->data) == -1) { if(alpm_set_option(PM_OPT_IGNOREPKG, (long)lp->data) == -1) {

View file

@ -63,7 +63,7 @@ static int query_fileowner(PM_DB *db, char *filename)
} }
alpm_get_option(PM_OPT_ROOT, &lroot); alpm_get_option(PM_OPT_ROOT, &lroot);
root = (void *)&lroot; root = (char *)lroot;
for(lp = alpm_db_getpkgcache(db); lp && !gotcha; lp = alpm_list_next(lp)) { for(lp = alpm_db_getpkgcache(db); lp && !gotcha; lp = alpm_list_next(lp)) {
PM_PKG *info; PM_PKG *info;
@ -74,9 +74,10 @@ static int query_fileowner(PM_DB *db, char *filename)
for(i = alpm_pkg_getinfo(info, PM_PKG_FILES); i && !gotcha; i = alpm_list_next(i)) { for(i = alpm_pkg_getinfo(info, PM_PKG_FILES); i && !gotcha; i = alpm_list_next(i)) {
char path[PATH_MAX]; char path[PATH_MAX];
snprintf(path, PATH_MAX, "%s%s", root, (char *)alpm_list_getdata(i)); char *filename = (char *)alpm_list_getdata(i);
snprintf(path, PATH_MAX, "%s%s", root, filename);
if(!strcmp(path, rpath)) { if(!strcmp(path, rpath)) {
printf(_("%s is owned by %s %s\n"), filename, (char *)alpm_pkg_getinfo(info, PM_PKG_NAME), printf(_("%s is owned by %s %s\n"), path, (char *)alpm_pkg_getinfo(info, PM_PKG_NAME),
(char *)alpm_pkg_getinfo(info, PM_PKG_VERSION)); (char *)alpm_pkg_getinfo(info, PM_PKG_VERSION));
gotcha = 1; gotcha = 1;
break; break;
@ -266,7 +267,7 @@ int pacman_query(list_t *targets)
long ldbpath; long ldbpath;
char *dbpath; char *dbpath;
alpm_get_option(PM_OPT_DBPATH, &ldbpath); alpm_get_option(PM_OPT_DBPATH, &ldbpath);
dbpath = (void *)&ldbpath; dbpath = (char *)ldbpath;
snprintf(changelog, PATH_MAX, "%s%s/%s/%s-%s/changelog", snprintf(changelog, PATH_MAX, "%s%s/%s/%s-%s/changelog",
config->root, dbpath, config->root, dbpath,
(char*)alpm_db_getinfo(db_local, PM_DB_TREENAME), (char*)alpm_db_getinfo(db_local, PM_DB_TREENAME),

View file

@ -173,13 +173,18 @@ static int sync_synctree(int level, list_t *syncs)
} else { } else {
ERR(NL, _("failed to update %s (%s)\n"), sync->treename, alpm_strerror(pm_errno)); ERR(NL, _("failed to update %s (%s)\n"), sync->treename, alpm_strerror(pm_errno));
} }
success--;
} else if(ret == 1) { } else if(ret == 1) {
MSG(NL, _(" %s is up to date\n"), sync->treename); MSG(NL, _(" %s is up to date\n"), sync->treename);
} else {
success++;
} }
} }
return(success); /* 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
*/
return(success > 0);
} }
static int sync_search(list_t *syncs, list_t *targets) static int sync_search(list_t *syncs, list_t *targets)
@ -569,6 +574,7 @@ int pacman_sync(list_t *targets)
packages = alpm_trans_getinfo(PM_TRANS_PACKAGES); packages = alpm_trans_getinfo(PM_TRANS_PACKAGES);
if(packages == NULL) { if(packages == NULL) {
/* nothing to do: just exit without complaining */ /* nothing to do: just exit without complaining */
MSG(NL," local database is up to date");
goto cleanup; goto cleanup;
} }

View file

@ -70,8 +70,6 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2)
case PM_TRANS_EVT_FILECONFLICTS_DONE: case PM_TRANS_EVT_FILECONFLICTS_DONE:
if(config->noprogressbar) { if(config->noprogressbar) {
MSG(CL, _("done.\n")); MSG(CL, _("done.\n"));
} else {
MSG(NL, "");
} }
break; break;
case PM_TRANS_EVT_CHECKDEPS_DONE: case PM_TRANS_EVT_CHECKDEPS_DONE:
@ -80,8 +78,8 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2)
pm_fprintf(stderr, CL, _("done.\n")); pm_fprintf(stderr, CL, _("done.\n"));
break; break;
case PM_TRANS_EVT_EXTRACT_DONE: case PM_TRANS_EVT_EXTRACT_DONE:
if(!config->noprogressbar) { if(config->noprogressbar) {
MSG(NL, ""); MSG(CL, _("done.\n"));
} }
break; break;
case PM_TRANS_EVT_ADD_START: case PM_TRANS_EVT_ADD_START:
@ -106,8 +104,6 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2)
case PM_TRANS_EVT_REMOVE_DONE: case PM_TRANS_EVT_REMOVE_DONE:
if(config->noprogressbar) { if(config->noprogressbar) {
MSG(CL, _("done.\n")); MSG(CL, _("done.\n"));
} else {
MSG(NL, "");
} }
snprintf(str, LOG_STR_LEN, _("removed %s (%s)"), snprintf(str, LOG_STR_LEN, _("removed %s (%s)"),
(char *)alpm_pkg_getinfo(data1, PM_PKG_NAME), (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME),
@ -153,7 +149,7 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2)
MSG(NL, "%s%s\n", (char*)data1, (char*)data2); MSG(NL, "%s%s\n", (char*)data1, (char*)data2);
break; break;
case PM_TRANS_EVT_RETRIEVE_START: case PM_TRANS_EVT_RETRIEVE_START:
MSG(NL, _("\n:: Retrieving packages from %s...\n"), (char*)data1); MSG(NL, _(":: Retrieving packages from %s...\n"), (char*)data1);
fflush(stdout); fflush(stdout);
break; break;
case PM_TRANS_EVT_RETRIEVE_LOCAL: case PM_TRANS_EVT_RETRIEVE_LOCAL:
@ -292,11 +288,7 @@ void cb_trans_progress(unsigned char event, char *pkgname, int percent, int howm
int i, hash; int i, hash;
long chomp = 0; long chomp = 0;
unsigned int maxpkglen, progresslen = maxcols - 57; unsigned int maxpkglen, progresslen = maxcols - 57;
char *addstr, *upgstr, *removestr, *conflictstr, *ptr = NULL; char *ptr = NULL;
addstr = strdup(_("installing"));
upgstr = strdup(_("upgrading"));
removestr = strdup(_("removing"));
conflictstr = strdup(_("checking for file conflicts"));
if(config->noprogressbar) { if(config->noprogressbar) {
return; return;
@ -312,19 +304,19 @@ void cb_trans_progress(unsigned char event, char *pkgname, int percent, int howm
prevpercent=percent; prevpercent=percent;
switch (event) { switch (event) {
case PM_TRANS_PROGRESS_ADD_START: case PM_TRANS_PROGRESS_ADD_START:
ptr = addstr; ptr = _("installing");
break; break;
case PM_TRANS_PROGRESS_UPGRADE_START: case PM_TRANS_PROGRESS_UPGRADE_START:
ptr = upgstr; ptr = _("upgrading");
break; break;
case PM_TRANS_PROGRESS_REMOVE_START: case PM_TRANS_PROGRESS_REMOVE_START:
ptr = removestr; ptr = _("removing");
break; break;
case PM_TRANS_PROGRESS_CONFLICTS_START: case PM_TRANS_PROGRESS_CONFLICTS_START:
ptr = conflictstr; ptr = _("checking for file conflicts");
break; break;
} }
hash=percent*progresslen/100; hash=percent*progresslen/100;
@ -399,10 +391,6 @@ void cb_trans_progress(unsigned char event, char *pkgname, int percent, int howm
if(percent == 100) { if(percent == 100) {
printf("\n"); printf("\n");
} }
FREE(addstr);
FREE(upgstr);
FREE(removestr);
} }
/* vim: set ts=2 sw=2 noet: */ /* vim: set ts=2 sw=2 noet: */