index: add argument --no-warnings

When creating an index apk warns if a dependency is missing a provider.
However when using a multi-arch repository, it's not an error that
a certain architecture is missing a dependency because that dependency
could be in an other architecture. Since apk index doesn't know about
this, add an argument to disable that warning.

Maintainer note: rebased for new option handling, and minor stylistic
adjustments.

Signed-off-by: Fredrik Gustafsson <fredrigu@axis.com>
cute-signatures
Fredrik Gustafsson 2019-11-20 17:01:45 +01:00 committed by Timo Teräs
parent 1d7123d837
commit 6863928677
2 changed files with 16 additions and 1 deletions

View File

@ -30,6 +30,11 @@ will accept it. See *abuild-sign*(1) for details.
Read an existing index from _INDEX_ to speed up the creation of the new Read an existing index from _INDEX_ to speed up the creation of the new
index by reusing data when possible. index by reusing data when possible.
*--no-warnings*
Disable the warning about missing dependencies. This happens when A,
depends on package B, that does not have a provider in the indexed
repository.
# AUTHORS # AUTHORS
Natanael Copa <ncopa@alpinelinux.org>++ Natanael Copa <ncopa@alpinelinux.org>++

View File

@ -19,6 +19,8 @@
#include "apk_database.h" #include "apk_database.h"
#include "apk_print.h" #include "apk_print.h"
#define APK_INDEXF_NO_WARNINGS 0x0001
struct counts { struct counts {
int unsatisfied; int unsatisfied;
}; };
@ -30,11 +32,13 @@ struct index_ctx {
apk_blob_t *rewrite_arch; apk_blob_t *rewrite_arch;
time_t index_mtime; time_t index_mtime;
int method; int method;
unsigned short index_flags;
}; };
enum { enum {
OPT_INDEX_description, OPT_INDEX_description,
OPT_INDEX_index, OPT_INDEX_index,
OPT_INDEX_no_warnings,
OPT_INDEX_output, OPT_INDEX_output,
OPT_INDEX_rewrite_arch, OPT_INDEX_rewrite_arch,
}; };
@ -43,6 +47,7 @@ static const char option_desc[] =
APK_OPTAPPLET APK_OPTAPPLET
APK_OPT2R("description", "d") APK_OPT2R("description", "d")
APK_OPT2R("index", "x") APK_OPT2R("index", "x")
APK_OPT1n("no-warnings")
APK_OPT2R("output", "o") APK_OPT2R("output", "o")
APK_OPT1R("rewrite-arch"); APK_OPT1R("rewrite-arch");
@ -63,6 +68,9 @@ static int option_parse_applet(void *ctx, struct apk_db_options *dbopts, int opt
case OPT_INDEX_rewrite_arch: case OPT_INDEX_rewrite_arch:
ictx->rewrite_arch = apk_blob_atomize(APK_BLOB_STR(optarg)); ictx->rewrite_arch = apk_blob_atomize(APK_BLOB_STR(optarg));
break; break;
case OPT_INDEX_no_warnings:
ictx->index_flags |= APK_INDEXF_NO_WARNINGS;
break;
default: default:
return -ENOTSUP; return -ENOTSUP;
} }
@ -244,7 +252,9 @@ static int index_main(void *ctx, struct apk_database *db, struct apk_string_arra
} }
total = r; total = r;
apk_hash_foreach(&db->available.names, warn_if_no_providers, &counts); if (!(ictx->index_flags & APK_INDEXF_NO_WARNINGS)) {
apk_hash_foreach(&db->available.names, warn_if_no_providers, &counts);
}
if (counts.unsatisfied != 0) if (counts.unsatisfied != 0)
apk_warning("Total of %d unsatisfiable package " apk_warning("Total of %d unsatisfiable package "