state: write status for each package change
prints like: (1/12) Installing... (2/12) Installing... etc...cute-signatures
parent
69b5357390
commit
028990d576
25
src/state.c
25
src/state.c
|
@ -529,11 +529,16 @@ int apk_state_lock_name(struct apk_state *state,
|
||||||
|
|
||||||
static void apk_print_change(struct apk_database *db,
|
static void apk_print_change(struct apk_database *db,
|
||||||
struct apk_package *oldpkg,
|
struct apk_package *oldpkg,
|
||||||
struct apk_package *newpkg)
|
struct apk_package *newpkg,
|
||||||
|
int num, int total)
|
||||||
{
|
{
|
||||||
const char *msg = NULL;
|
const char *msg = NULL;
|
||||||
int r;
|
int r;
|
||||||
struct apk_name *name;
|
struct apk_name *name;
|
||||||
|
char status[64];
|
||||||
|
|
||||||
|
snprintf(status, sizeof(status), "(%i/%i)", num, total);
|
||||||
|
status[sizeof(status) - 1] = '\0';
|
||||||
|
|
||||||
if (oldpkg != NULL)
|
if (oldpkg != NULL)
|
||||||
name = oldpkg->name;
|
name = oldpkg->name;
|
||||||
|
@ -541,11 +546,11 @@ static void apk_print_change(struct apk_database *db,
|
||||||
name = newpkg->name;
|
name = newpkg->name;
|
||||||
|
|
||||||
if (oldpkg == NULL) {
|
if (oldpkg == NULL) {
|
||||||
apk_message("Installing %s (%s)",
|
apk_message("%s Installing %s (%s)",
|
||||||
name->name, newpkg->version);
|
status, name->name, newpkg->version);
|
||||||
} else if (newpkg == NULL) {
|
} else if (newpkg == NULL) {
|
||||||
apk_message("Purging %s (%s)",
|
apk_message("%s Purging %s (%s)",
|
||||||
name->name, oldpkg->version);
|
status, name->name, oldpkg->version);
|
||||||
} else {
|
} else {
|
||||||
r = apk_pkg_version_compare(newpkg, oldpkg);
|
r = apk_pkg_version_compare(newpkg, oldpkg);
|
||||||
switch (r) {
|
switch (r) {
|
||||||
|
@ -559,8 +564,8 @@ static void apk_print_change(struct apk_database *db,
|
||||||
msg = "Upgrading";
|
msg = "Upgrading";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
apk_message("%s %s (%s -> %s)",
|
apk_message("%s %s %s (%s -> %s)",
|
||||||
msg, name->name, oldpkg->version,
|
status, msg, name->name, oldpkg->version,
|
||||||
newpkg->version);
|
newpkg->version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -726,10 +731,12 @@ int apk_state_commit(struct apk_state *state,
|
||||||
struct progress prog;
|
struct progress prog;
|
||||||
struct apk_change *change;
|
struct apk_change *change;
|
||||||
int r = 0, size_diff = 0, toplevel = FALSE, deleteonly = TRUE;
|
int r = 0, size_diff = 0, toplevel = FALSE, deleteonly = TRUE;
|
||||||
|
int n = 0, numpkg = 0;
|
||||||
|
|
||||||
/* Count what needs to be done */
|
/* Count what needs to be done */
|
||||||
memset(&prog, 0, sizeof(prog));
|
memset(&prog, 0, sizeof(prog));
|
||||||
list_for_each_entry(change, &state->change_list_head, change_list) {
|
list_for_each_entry(change, &state->change_list_head, change_list) {
|
||||||
|
numpkg++;
|
||||||
if (change->newpkg == NULL) {
|
if (change->newpkg == NULL) {
|
||||||
apk_state_autoclean(state, change->oldpkg);
|
apk_state_autoclean(state, change->oldpkg);
|
||||||
if (change->oldpkg->name->flags & APK_NAME_TOPLEVEL)
|
if (change->oldpkg->name->flags & APK_NAME_TOPLEVEL)
|
||||||
|
@ -781,8 +788,10 @@ int apk_state_commit(struct apk_state *state,
|
||||||
|
|
||||||
/* Go through changes */
|
/* Go through changes */
|
||||||
r = 0;
|
r = 0;
|
||||||
|
n = 0;
|
||||||
list_for_each_entry(change, &state->change_list_head, change_list) {
|
list_for_each_entry(change, &state->change_list_head, change_list) {
|
||||||
apk_print_change(db, change->oldpkg, change->newpkg);
|
n++;
|
||||||
|
apk_print_change(db, change->oldpkg, change->newpkg, n, numpkg);
|
||||||
prog.pkg = change->newpkg;
|
prog.pkg = change->newpkg;
|
||||||
|
|
||||||
if (!(apk_flags & APK_SIMULATE)) {
|
if (!(apk_flags & APK_SIMULATE)) {
|
||||||
|
|
Loading…
Reference in New Issue