2020-02-14 11:49:41 +00:00
|
|
|
/* app_update.c - Alpine Package Keeper (APK)
|
2009-04-16 17:05:22 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2005-2008 Natanael Copa <n@tanael.org>
|
2011-09-13 08:53:01 +00:00
|
|
|
* Copyright (C) 2008-2011 Timo Teräs <timo.teras@iki.fi>
|
2009-04-16 17:05:22 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2020-04-22 13:33:41 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only
|
2009-04-16 17:05:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "apk_defines.h"
|
|
|
|
#include "apk_applet.h"
|
|
|
|
#include "apk_database.h"
|
|
|
|
#include "apk_version.h"
|
2010-03-05 08:13:25 +00:00
|
|
|
#include "apk_print.h"
|
2009-04-16 17:05:22 +00:00
|
|
|
|
2020-10-09 09:44:32 +00:00
|
|
|
static int update_main(void *ctx, struct apk_ctx *ac, struct apk_string_array *args)
|
2009-04-16 17:05:22 +00:00
|
|
|
{
|
2020-10-09 09:44:32 +00:00
|
|
|
struct apk_out *out = &ac->out;
|
|
|
|
struct apk_database *db = ac->db;
|
2009-09-03 10:56:24 +00:00
|
|
|
struct apk_repository *repo;
|
|
|
|
int i;
|
2015-04-07 07:57:42 +00:00
|
|
|
char buf[32] = "OK:";
|
2009-09-03 10:56:24 +00:00
|
|
|
|
2020-10-05 15:52:51 +00:00
|
|
|
if (apk_out_verbosity(out) < 1)
|
2015-04-10 17:33:21 +00:00
|
|
|
return db->repo_update_errors;
|
2009-09-03 10:56:24 +00:00
|
|
|
|
|
|
|
for (i = 0; i < db->num_repos; i++) {
|
|
|
|
repo = &db->repos[i];
|
|
|
|
|
|
|
|
if (APK_BLOB_IS_NULL(repo->description))
|
|
|
|
continue;
|
|
|
|
|
2020-10-05 15:52:51 +00:00
|
|
|
apk_msg(out, BLOB_FMT " [%s]",
|
|
|
|
BLOB_PRINTF(repo->description),
|
|
|
|
db->repos[i].url);
|
2009-09-03 10:56:24 +00:00
|
|
|
}
|
|
|
|
|
2015-04-07 07:57:42 +00:00
|
|
|
if (db->repo_update_errors != 0)
|
|
|
|
snprintf(buf, sizeof(buf), "%d errors;",
|
|
|
|
db->repo_update_errors);
|
2020-10-05 15:52:51 +00:00
|
|
|
apk_msg(out, "%s %d distinct packages available", buf,
|
2011-12-27 12:05:49 +00:00
|
|
|
db->available.packages.num_items);
|
|
|
|
|
2015-04-07 07:57:42 +00:00
|
|
|
return db->repo_update_errors;
|
2009-04-16 17:05:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct apk_applet apk_update = {
|
|
|
|
.name = "update",
|
2009-08-06 11:50:51 +00:00
|
|
|
.open_flags = APK_OPENF_WRITE,
|
2018-01-04 07:46:03 +00:00
|
|
|
.forced_force = APK_FORCE_REFRESH,
|
2009-04-16 17:05:22 +00:00
|
|
|
.main = update_main,
|
|
|
|
};
|
|
|
|
|
|
|
|
APK_DEFINE_APPLET(apk_update);
|
|
|
|
|