Commit b4b95e9a authored by Ariadne Conill's avatar Ariadne Conill 🐰

manifest: new applet which dumps checksums in sha1sum format for a package

parent d5dad7b7
......@@ -27,7 +27,7 @@ endif
progs-y += apk
apk-objs := apk.o add.o del.o fix.o update.o info.o \
search.o upgrade.o cache.o ver.o index.o fetch.o \
audit.o verify.o dot.o policy.o stats.o
audit.o verify.o dot.o policy.o stats.o manifest.o := common.o database.o package.o archive.o \
version.o io.o url.o gunzip.o blob.o hash.o print.o \
/* manifest.c - Alpine Package Keeper (APK)
* Copyright (C) 2005-2017 Natanael Copa <>
* Copyright (C) 2008-2017 Timo Teräs <>
* Copyright (C) 2017 William Pitcock <>
* All rights reserved.
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation. See for details.
#include <stdio.h>
#include "apk_defines.h"
#include "apk_applet.h"
#include "apk_database.h"
#include "apk_version.h"
#include "apk_print.h"
/* TODO: support package files as well as generating manifest from the installed DB. */
static void process_package(struct apk_database *db, struct apk_package *pkg)
struct apk_installed_package *ipkg = pkg->ipkg;
struct apk_db_dir_instance *diri;
struct apk_db_file *file;
struct hlist_node *dc, *dn, *fc, *fn;
char csum_buf[(APK_CHECKSUM_SHA1 * 2) + 1];
if (ipkg == NULL)
hlist_for_each_entry_safe(diri, dc, dn, &ipkg->owned_dirs,
pkg_dirs_list) {
hlist_for_each_entry_safe(file, fc, fn, &diri->owned_files,
diri_files_list) {
apk_blob_t csum_blob = APK_BLOB_BUF(csum_buf);
memset(csum_buf, '\0', sizeof(csum_buf));
apk_blob_push_hexdump(&csum_blob, APK_BLOB_CSUM(file->csum));
if (apk_verbosity > 1)
printf("%s: ", pkg->name->name);
printf("%s " DIR_FILE_FMT "\n", csum_buf, DIR_FILE_PRINTF(diri->dir, file));
static void process_match(struct apk_database *db, const char *match, struct apk_name *name, void *ctx)
struct apk_provider *p;
if (name == NULL)
foreach_array_item(p, name->providers)
process_package(db, p->pkg);
static int manifest_main(void *ctx, struct apk_database *db, struct apk_string_array *args)
apk_name_foreach_matching(db, args, apk_foreach_genid(), process_match, NULL);
return 0;
static struct apk_applet apk_manifest = {
.name = "manifest",
.help = "Show checksums of package contents",
.open_flags = APK_OPENF_READ,
.main = manifest_main,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment