/* * archive.h - tar archive operations for mkpkg * https://rawnix.org * * Copyright (c) 2025 zorz@gmx.com * SPDX-License-Identifier: BSD-2-Clause */ #ifndef ARCHIVE_H #define ARCHIVE_H #include "util.h" /* detect archive type by file extension */ int arc_is_archive(const char *filename); /* mkpkg: extract upstream source tarball into destdir, --no-same-owner */ int arc_extract_src(const char *file, const char *destdir); /* Observe bytes as they are written somewhere (e.g. hash them) */ typedef void (*arc_sink_fn)(const void *buf, size_t len, void *ctx); /* mkpkg: walk pkgdir, sort entries, pipe to tar | -> pkgfile. * compression is one of "gz", "xz", "zst", "bz2", "lz" — selects the * external compressor program. NULL or "" means "gz". * When sink is non-NULL it is called with every chunk of compressed * output as it is written to pkgfile (mkpkg uses this to compute the * package SHA256 during the build instead of re-reading the file). * Pass NULL/NULL to skip. */ int arc_create_pkg(const char *pkgfile, const char *pkgdir, const char *compression, arc_sink_fn sink, void *sink_ctx); /* parse pkgfile name and list its contents */ int arc_list(const char *pkgfile, char **name, char **version, strarray_t **files); /* extract package into root, honouring keep/skip lists */ int arc_extract_pkg(const char *pkgfile, const char *root, strarray_t *keep, strarray_t *skip); /* extract one member of an archive into destdir (quiet). * Goes through the same content-sniffed decompressor pipeline as * full extraction. */ int arc_extract_single(const char *pkgfile, const char *member, const char *destdir); /* extract a specific list of members into destdir. * tar takes member names as positional arguments, so this unpacks * only what was asked for rather than the whole archive. */ int arc_extract_members(const char *pkgfile, strarray_t *members, const char *destdir); /* print footprint of a package archive to stdout */ int arc_footprint(const char *pkgfile); #endif /* ARCHIVE_H */