Improve advice for sync ops when db.lck is present

When the database is locked, sync operations involving transactions, such as
pacman -Syy, show the following:

:: Synchronizing package databases...
error: failed to update core (unable to lock database)
error: failed to update extra (unable to lock database)
error: failed to update community (unable to lock database)
error: failed to update multilib (unable to lock database)
error: failed to synchronize any databases

Whereas pacman -U <pkg> shows:

error: failed to init transaction (unable to lock database)
  if you're sure a package manager is not already
  running, you can remove /var/lib/pacman/db.lck

Which is much more meaningful, since the presence of db.lck may indicate an
erroneous lockfile instead of an ongoing transaction.

Improve the error messages for sync operations by advising the user to remove
db.lck if he is sure that no package manager is running.

Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Pang Yan Han 2011-08-30 00:58:48 +08:00 committed by Dan McGee
parent 234b6ffc2c
commit 2c5f000d5b
3 changed files with 15 additions and 9 deletions

View file

@ -304,6 +304,7 @@ static int sync_synctree(int level, alpm_list_t *syncs)
*/
if(!success) {
pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to synchronize any databases\n"));
trans_init_error();
}
return (success > 0);
}

View file

@ -63,6 +63,14 @@ int trans_init(alpm_transflag_t flags, int check_valid)
}
if(ret == -1) {
trans_init_error();
return -1;
}
return 0;
}
void trans_init_error(void)
{
enum _alpm_errno_t err = alpm_errno(config->handle);
pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to init transaction (%s)\n"),
alpm_strerror(err));
@ -71,10 +79,6 @@ int trans_init(alpm_transflag_t flags, int check_valid)
" running, you can remove %s\n"),
alpm_option_get_lockfile(config->handle));
}
return -1;
}
return 0;
}
int trans_release(void)

View file

@ -39,6 +39,7 @@
/* update speed for the fill_progress based functions */
#define UPDATE_SPEED_SEC 0.2f
void trans_init_error(void);
int trans_init(alpm_transflag_t flags, int check_valid);
int trans_release(void);
int needs_root(void);