auc: support queue_position status from server
Display position in queue while waiting for build. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
parent
70bb71fdff
commit
5b7ff1ad65
1 changed files with 19 additions and 2 deletions
|
@ -238,6 +238,7 @@ enum {
|
||||||
TARGET_METADATA_VERSION,
|
TARGET_METADATA_VERSION,
|
||||||
TARGET_REQUEST_HASH,
|
TARGET_REQUEST_HASH,
|
||||||
TARGET_SOURCE_DATE_EPOCH,
|
TARGET_SOURCE_DATE_EPOCH,
|
||||||
|
TARGET_QUEUE_POSITION,
|
||||||
TARGET_STATUS,
|
TARGET_STATUS,
|
||||||
TARGET_STDERR,
|
TARGET_STDERR,
|
||||||
TARGET_STDOUT,
|
TARGET_STDOUT,
|
||||||
|
@ -263,6 +264,7 @@ static const struct blobmsg_policy target_policy[__TARGET_MAX] = {
|
||||||
[TARGET_METADATA_VERSION] = { .name = "metadata_version", .type = BLOBMSG_TYPE_INT32 },
|
[TARGET_METADATA_VERSION] = { .name = "metadata_version", .type = BLOBMSG_TYPE_INT32 },
|
||||||
[TARGET_REQUEST_HASH] = { .name = "request_hash", .type = BLOBMSG_TYPE_STRING },
|
[TARGET_REQUEST_HASH] = { .name = "request_hash", .type = BLOBMSG_TYPE_STRING },
|
||||||
[TARGET_SOURCE_DATE_EPOCH] = { .name = "source_date_epoch", .type = BLOBMSG_TYPE_STRING },
|
[TARGET_SOURCE_DATE_EPOCH] = { .name = "source_date_epoch", .type = BLOBMSG_TYPE_STRING },
|
||||||
|
[TARGET_QUEUE_POSITION] = { .name = "queue_position", .type = BLOBMSG_TYPE_INT32 },
|
||||||
[TARGET_STATUS] = { .name = "status", .type = BLOBMSG_TYPE_STRING },
|
[TARGET_STATUS] = { .name = "status", .type = BLOBMSG_TYPE_STRING },
|
||||||
[TARGET_STDERR] = { .name = "stderr", .type = BLOBMSG_TYPE_STRING },
|
[TARGET_STDERR] = { .name = "stderr", .type = BLOBMSG_TYPE_STRING },
|
||||||
[TARGET_STDOUT] = { .name = "stdout", .type = BLOBMSG_TYPE_STRING },
|
[TARGET_STDOUT] = { .name = "stdout", .type = BLOBMSG_TYPE_STRING },
|
||||||
|
@ -424,6 +426,9 @@ static int verrevcmp(const char *val, const char *ref)
|
||||||
#define ANSI_COLOR_RESET ANSI_ESC "[0m"
|
#define ANSI_COLOR_RESET ANSI_ESC "[0m"
|
||||||
#define ANSI_COLOR_RED ANSI_ESC "[1;31m"
|
#define ANSI_COLOR_RED ANSI_ESC "[1;31m"
|
||||||
#define ANSI_COLOR_GREEN ANSI_ESC "[1;32m"
|
#define ANSI_COLOR_GREEN ANSI_ESC "[1;32m"
|
||||||
|
#define ANSI_CURSOR_SAFE "[s"
|
||||||
|
#define ANSI_CURSOR_RESTORE "[u"
|
||||||
|
#define ANSI_ERASE_LINE "[K"
|
||||||
|
|
||||||
#define PKG_UPGRADE 0x1
|
#define PKG_UPGRADE 0x1
|
||||||
#define PKG_DOWNGRADE 0x2
|
#define PKG_DOWNGRADE 0x2
|
||||||
|
@ -1395,7 +1400,7 @@ int main(int args, char *argv[]) {
|
||||||
int upg_check = 0;
|
int upg_check = 0;
|
||||||
int revcmp;
|
int revcmp;
|
||||||
unsigned char argc = 1;
|
unsigned char argc = 1;
|
||||||
bool force = false, use_get = false;
|
bool force = false, use_get = false, in_queue = false;
|
||||||
|
|
||||||
snprintf(user_agent, sizeof(user_agent), "%s (%s)", argv[0], AUC_VERSION);
|
snprintf(user_agent, sizeof(user_agent), "%s (%s)", argv[0], AUC_VERSION);
|
||||||
fprintf(stdout, "%s\n", user_agent);
|
fprintf(stdout, "%s\n", user_agent);
|
||||||
|
@ -1559,7 +1564,19 @@ int main(int args, char *argv[]) {
|
||||||
fputs("Requesting build", stderr);
|
fputs("Requesting build", stderr);
|
||||||
|
|
||||||
retry_delay = 2;
|
retry_delay = 2;
|
||||||
|
if (tb[TARGET_QUEUE_POSITION]) {
|
||||||
|
fprintf(stderr, "%s%s (position in queue: %d)",
|
||||||
|
ANSI_ESC, in_queue?ANSI_CURSOR_RESTORE:ANSI_CURSOR_SAFE,
|
||||||
|
blobmsg_get_u32(tb[TARGET_QUEUE_POSITION]));
|
||||||
|
in_queue = true;
|
||||||
|
} else {
|
||||||
|
if (in_queue)
|
||||||
|
fprintf(stderr, "%s%s%s%s",
|
||||||
|
ANSI_ESC, ANSI_CURSOR_RESTORE,
|
||||||
|
ANSI_ESC, ANSI_ERASE_LINE);
|
||||||
fputc('.', stderr);
|
fputc('.', stderr);
|
||||||
|
in_queue = false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
retry_delay = 0;
|
retry_delay = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue