2020-02-14 11:49:41 +00:00
|
|
|
/* app_verify.c - Alpine Package Keeper (APK)
|
2009-07-17 10:07:52 +00:00
|
|
|
*
|
2011-09-13 08:53:01 +00:00
|
|
|
* Copyright (C) 2008-2011 Timo Teräs <timo.teras@iki.fi>
|
2009-07-17 10:07:52 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2020-04-22 13:33:41 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only
|
2009-07-17 10:07:52 +00:00
|
|
|
*/
|
|
|
|
|
2009-07-30 14:29:20 +00:00
|
|
|
#include <errno.h>
|
2009-07-17 10:07:52 +00:00
|
|
|
#include <stdio.h>
|
2009-07-31 13:08:09 +00:00
|
|
|
#include <fcntl.h>
|
2009-07-17 10:07:52 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "apk_applet.h"
|
2010-03-05 08:13:25 +00:00
|
|
|
#include "apk_print.h"
|
2021-07-26 13:25:03 +00:00
|
|
|
#include "apk_extract.h"
|
2009-07-17 10:07:52 +00:00
|
|
|
|
2020-10-09 09:44:32 +00:00
|
|
|
static int verify_main(void *ctx, struct apk_ctx *ac, struct apk_string_array *args)
|
2009-07-17 10:07:52 +00:00
|
|
|
{
|
2020-10-09 09:44:32 +00:00
|
|
|
struct apk_out *out = &ac->out;
|
2021-07-26 13:25:03 +00:00
|
|
|
struct apk_extract_ctx ectx;
|
2013-06-18 10:01:51 +00:00
|
|
|
char **parg;
|
2021-07-26 13:25:03 +00:00
|
|
|
int r, rc = 0;
|
2009-07-17 10:07:52 +00:00
|
|
|
|
2021-07-26 13:25:03 +00:00
|
|
|
apk_extract_init(&ectx, ac, 0);
|
2020-10-09 10:40:14 +00:00
|
|
|
|
2013-06-18 10:01:51 +00:00
|
|
|
foreach_array_item(parg, args) {
|
2021-07-26 13:25:03 +00:00
|
|
|
r = apk_extract(&ectx, apk_istream_from_file(AT_FDCWD, *parg));
|
2020-10-05 15:52:51 +00:00
|
|
|
if (apk_out_verbosity(out) >= 1)
|
2021-07-26 13:25:03 +00:00
|
|
|
apk_msg(out, "%s: %s", *parg,
|
|
|
|
r < 0 ? apk_error_str(r) : "OK");
|
|
|
|
else if (r < 0)
|
2020-10-05 15:52:51 +00:00
|
|
|
apk_out(out, "%s", *parg);
|
2021-07-26 13:25:03 +00:00
|
|
|
if (r < 0) rc++;
|
2009-07-17 10:07:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2021-06-09 15:21:40 +00:00
|
|
|
static struct apk_applet apk_verify_applet = {
|
2009-07-17 10:07:52 +00:00
|
|
|
.name = "verify",
|
|
|
|
.main = verify_main,
|
|
|
|
};
|
|
|
|
|
2021-06-09 15:21:40 +00:00
|
|
|
APK_DEFINE_APPLET(apk_verify_applet);
|
2009-07-17 10:07:52 +00:00
|
|
|
|