2013-06-27 19:28:46 +00:00
|
|
|
/* apk_package.h - Alpine Package Keeper (APK)
|
2008-04-17 14:09:13 +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>
|
2008-04-17 14:09:13 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2009-07-14 16:14:05 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
2008-04-17 14:09:13 +00:00
|
|
|
* under the terms of the GNU General Public License version 2 as published
|
|
|
|
* by the Free Software Foundation. See http://www.gnu.org/ for details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef APK_PKG_H
|
|
|
|
#define APK_PKG_H
|
|
|
|
|
|
|
|
#include "apk_version.h"
|
|
|
|
#include "apk_hash.h"
|
2008-11-07 15:11:08 +00:00
|
|
|
#include "apk_io.h"
|
2013-06-11 11:06:06 +00:00
|
|
|
#include "apk_solver_data.h"
|
2008-04-17 14:09:13 +00:00
|
|
|
|
|
|
|
struct apk_database;
|
|
|
|
struct apk_name;
|
2012-02-24 13:50:39 +00:00
|
|
|
struct apk_provider;
|
2008-04-17 14:09:13 +00:00
|
|
|
|
2008-11-07 11:05:55 +00:00
|
|
|
#define APK_SCRIPT_INVALID -1
|
2009-08-12 16:17:46 +00:00
|
|
|
#define APK_SCRIPT_PRE_INSTALL 0
|
|
|
|
#define APK_SCRIPT_POST_INSTALL 1
|
|
|
|
#define APK_SCRIPT_PRE_DEINSTALL 2
|
|
|
|
#define APK_SCRIPT_POST_DEINSTALL 3
|
|
|
|
#define APK_SCRIPT_PRE_UPGRADE 4
|
|
|
|
#define APK_SCRIPT_POST_UPGRADE 5
|
|
|
|
#define APK_SCRIPT_TRIGGER 6
|
|
|
|
#define APK_SCRIPT_MAX 7
|
2008-04-17 14:09:13 +00:00
|
|
|
|
2009-07-20 08:13:03 +00:00
|
|
|
#define APK_SIGN_NONE 0
|
|
|
|
#define APK_SIGN_VERIFY 1
|
|
|
|
#define APK_SIGN_VERIFY_IDENTITY 2
|
|
|
|
#define APK_SIGN_GENERATE 4
|
2009-07-22 18:04:54 +00:00
|
|
|
#define APK_SIGN_VERIFY_AND_GENERATE 5
|
2009-07-16 12:16:05 +00:00
|
|
|
|
2013-06-15 17:39:05 +00:00
|
|
|
#define APK_DEP_IRRELEVANT 0x01
|
|
|
|
#define APK_DEP_SATISFIES 0x02
|
|
|
|
#define APK_DEP_CONFLICTS 0x04
|
|
|
|
#define APK_FOREACH_INSTALLED 0x10
|
|
|
|
#define APK_FOREACH_MARKED 0x20
|
2013-06-19 17:55:01 +00:00
|
|
|
#define APK_FOREACH_NULL_MATCHES_ALL 0x40
|
2013-06-15 17:39:05 +00:00
|
|
|
#define APK_FOREACH_GENID_MASK 0xffffff00
|
2013-06-13 15:20:39 +00:00
|
|
|
|
2009-07-17 10:07:52 +00:00
|
|
|
struct apk_sign_ctx {
|
2009-07-31 13:08:09 +00:00
|
|
|
int keys_fd;
|
2009-07-17 10:07:52 +00:00
|
|
|
int action;
|
|
|
|
const EVP_MD *md;
|
|
|
|
int num_signatures;
|
|
|
|
int control_started : 1;
|
|
|
|
int data_started : 1;
|
|
|
|
int has_data_checksum : 1;
|
|
|
|
int control_verified : 1;
|
|
|
|
int data_verified : 1;
|
|
|
|
char data_checksum[EVP_MAX_MD_SIZE];
|
|
|
|
struct apk_checksum identity;
|
2009-07-17 12:56:09 +00:00
|
|
|
EVP_MD_CTX mdctx;
|
2009-07-17 10:07:52 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
apk_blob_t data;
|
|
|
|
EVP_PKEY *pkey;
|
|
|
|
char *identity;
|
|
|
|
} signature;
|
|
|
|
};
|
|
|
|
|
2008-04-17 14:09:13 +00:00
|
|
|
struct apk_dependency {
|
|
|
|
struct apk_name *name;
|
2010-12-14 17:51:16 +00:00
|
|
|
apk_blob_t *version;
|
2013-06-12 14:00:43 +00:00
|
|
|
unsigned broken : 1;
|
2012-10-08 09:25:43 +00:00
|
|
|
unsigned repository_tag : 6;
|
2012-02-29 06:53:43 +00:00
|
|
|
unsigned conflict : 1;
|
2011-10-21 19:24:24 +00:00
|
|
|
unsigned result_mask : 3;
|
2008-04-17 14:09:13 +00:00
|
|
|
};
|
|
|
|
APK_ARRAY(apk_dependency_array, struct apk_dependency);
|
|
|
|
|
2009-08-12 16:17:46 +00:00
|
|
|
struct apk_installed_package {
|
|
|
|
struct apk_package *pkg;
|
|
|
|
struct list_head installed_pkgs_list;
|
|
|
|
struct list_head trigger_pkgs_list;
|
|
|
|
struct hlist_head owned_dirs;
|
|
|
|
apk_blob_t script[APK_SCRIPT_MAX];
|
|
|
|
struct apk_string_array *triggers;
|
2009-08-13 11:10:30 +00:00
|
|
|
struct apk_string_array *pending_triggers;
|
2011-10-18 22:11:26 +00:00
|
|
|
struct apk_dependency_array *replaces;
|
2013-06-20 10:12:44 +00:00
|
|
|
|
|
|
|
unsigned short replaces_priority;
|
|
|
|
unsigned repository_tag : 6;
|
|
|
|
unsigned run_all_triggers : 1;
|
|
|
|
unsigned broken_files : 1;
|
|
|
|
unsigned broken_script : 1;
|
2015-04-17 06:44:52 +00:00
|
|
|
unsigned broken_xattr : 1;
|
2009-08-12 16:17:46 +00:00
|
|
|
};
|
|
|
|
|
2008-04-17 14:09:13 +00:00
|
|
|
struct apk_package {
|
|
|
|
apk_hash_node hash_node;
|
2011-08-05 08:53:26 +00:00
|
|
|
union {
|
2013-06-11 11:06:06 +00:00
|
|
|
struct apk_solver_package_state ss;
|
2013-06-13 17:48:38 +00:00
|
|
|
struct {
|
2013-06-15 17:39:05 +00:00
|
|
|
unsigned int foreach_genid;
|
2013-06-13 17:48:38 +00:00
|
|
|
union {
|
|
|
|
int state_int;
|
|
|
|
void *state_ptr;
|
|
|
|
};
|
|
|
|
};
|
2011-08-05 08:53:26 +00:00
|
|
|
};
|
2008-04-17 14:09:13 +00:00
|
|
|
struct apk_name *name;
|
2010-12-14 17:51:16 +00:00
|
|
|
struct apk_installed_package *ipkg;
|
|
|
|
apk_blob_t *version, *arch, *license;
|
2011-04-04 11:05:52 +00:00
|
|
|
apk_blob_t *origin, *maintainer;
|
|
|
|
char *url, *description, *commit;
|
2010-12-14 17:51:16 +00:00
|
|
|
char *filename;
|
2012-02-24 07:37:17 +00:00
|
|
|
struct apk_dependency_array *depends, *install_if, *provides;
|
2008-11-28 14:28:54 +00:00
|
|
|
size_t installed_size, size;
|
2011-04-04 11:05:52 +00:00
|
|
|
time_t build_time;
|
2014-05-19 08:50:10 +00:00
|
|
|
unsigned repos : APK_MAX_REPOS;
|
2013-06-17 14:51:41 +00:00
|
|
|
unsigned marked : 1;
|
2013-06-20 11:08:16 +00:00
|
|
|
unsigned uninstallable : 1;
|
2014-05-19 08:50:10 +00:00
|
|
|
unsigned cached_non_repository : 1;
|
2009-07-14 16:14:05 +00:00
|
|
|
struct apk_checksum csum;
|
2008-04-17 14:09:13 +00:00
|
|
|
};
|
|
|
|
APK_ARRAY(apk_package_array, struct apk_package *);
|
|
|
|
|
2012-02-24 13:50:39 +00:00
|
|
|
#define APK_PROVIDER_FROM_PACKAGE(pkg) (struct apk_provider){(pkg),(pkg)->version}
|
|
|
|
#define APK_PROVIDER_FROM_PROVIDES(pkg,p) (struct apk_provider){(pkg),(p)->version}
|
|
|
|
|
2010-12-14 17:51:16 +00:00
|
|
|
#define PKG_VER_FMT "%s-" BLOB_FMT
|
|
|
|
#define PKG_VER_PRINTF(pkg) pkg->name->name, BLOB_PRINTF(*pkg->version)
|
2013-06-17 11:24:34 +00:00
|
|
|
#define PKG_FILE_FMT PKG_VER_FMT ".apk"
|
|
|
|
#define PKG_FILE_PRINTF(pkg) PKG_VER_PRINTF(pkg)
|
2010-12-14 17:51:16 +00:00
|
|
|
|
2009-07-14 16:14:05 +00:00
|
|
|
extern const char *apk_script_types[];
|
|
|
|
|
2009-07-20 08:13:03 +00:00
|
|
|
void apk_sign_ctx_init(struct apk_sign_ctx *ctx, int action,
|
2009-07-31 13:08:09 +00:00
|
|
|
struct apk_checksum *identity, int keys_fd);
|
2009-07-17 10:07:52 +00:00
|
|
|
void apk_sign_ctx_free(struct apk_sign_ctx *ctx);
|
|
|
|
int apk_sign_ctx_process_file(struct apk_sign_ctx *ctx,
|
|
|
|
const struct apk_file_info *fi,
|
|
|
|
struct apk_istream *is);
|
2009-08-04 13:54:15 +00:00
|
|
|
int apk_sign_ctx_parse_pkginfo_line(void *ctx, apk_blob_t line);
|
2009-07-20 08:13:03 +00:00
|
|
|
int apk_sign_ctx_verify_tar(void *ctx, const struct apk_file_info *fi,
|
|
|
|
struct apk_istream *is);
|
2009-07-17 12:56:09 +00:00
|
|
|
int apk_sign_ctx_mpart_cb(void *ctx, int part, apk_blob_t blob);
|
2009-07-17 10:07:52 +00:00
|
|
|
|
2009-07-22 11:24:19 +00:00
|
|
|
void apk_dep_from_pkg(struct apk_dependency *dep, struct apk_database *db,
|
|
|
|
struct apk_package *pkg);
|
2012-02-24 13:50:39 +00:00
|
|
|
int apk_dep_is_materialized(struct apk_dependency *dep, struct apk_package *pkg);
|
|
|
|
int apk_dep_is_provided(struct apk_dependency *dep, struct apk_provider *p);
|
2013-06-13 15:20:39 +00:00
|
|
|
int apk_dep_analyze(struct apk_dependency *dep, struct apk_package *pkg);
|
|
|
|
char *apk_dep_snprintf(char *buf, size_t n, struct apk_dependency *dep);
|
2011-10-18 22:11:26 +00:00
|
|
|
|
2011-10-29 02:18:21 +00:00
|
|
|
void apk_blob_push_dep(apk_blob_t *to, struct apk_database *, struct apk_dependency *dep);
|
|
|
|
void apk_blob_push_deps(apk_blob_t *to, struct apk_database *, struct apk_dependency_array *deps);
|
2011-10-18 22:11:26 +00:00
|
|
|
void apk_blob_pull_dep(apk_blob_t *from, struct apk_database *, struct apk_dependency *);
|
|
|
|
void apk_blob_pull_deps(apk_blob_t *from, struct apk_database *, struct apk_dependency_array **);
|
|
|
|
|
2011-10-29 02:18:21 +00:00
|
|
|
int apk_deps_write(struct apk_database *db, struct apk_dependency_array *deps,
|
2012-01-12 12:33:29 +00:00
|
|
|
struct apk_ostream *os, apk_blob_t separator);
|
2010-06-01 08:49:32 +00:00
|
|
|
|
2013-06-18 05:03:40 +00:00
|
|
|
void apk_deps_add(struct apk_dependency_array **depends, struct apk_dependency *dep);
|
|
|
|
void apk_deps_del(struct apk_dependency_array **deps, struct apk_name *name);
|
2008-04-17 14:09:13 +00:00
|
|
|
int apk_script_type(const char *name);
|
|
|
|
|
2012-02-24 13:50:39 +00:00
|
|
|
struct apk_package *apk_pkg_get_installed(struct apk_name *name);
|
|
|
|
|
2008-11-28 11:15:06 +00:00
|
|
|
struct apk_package *apk_pkg_new(void);
|
2009-07-22 11:56:27 +00:00
|
|
|
int apk_pkg_read(struct apk_database *db, const char *name,
|
|
|
|
struct apk_sign_ctx *ctx, struct apk_package **pkg);
|
2008-04-17 14:09:13 +00:00
|
|
|
void apk_pkg_free(struct apk_package *pkg);
|
|
|
|
|
2009-07-15 12:59:06 +00:00
|
|
|
int apk_pkg_parse_name(apk_blob_t apkname, apk_blob_t *name, apk_blob_t *version);
|
|
|
|
|
2008-11-28 11:15:06 +00:00
|
|
|
int apk_pkg_add_info(struct apk_database *db, struct apk_package *pkg,
|
|
|
|
char field, apk_blob_t value);
|
2009-08-12 16:17:46 +00:00
|
|
|
|
|
|
|
struct apk_installed_package *apk_pkg_install(struct apk_database *db, struct apk_package *pkg);
|
|
|
|
void apk_pkg_uninstall(struct apk_database *db, struct apk_package *pkg);
|
|
|
|
|
|
|
|
int apk_ipkg_add_script(struct apk_installed_package *ipkg,
|
|
|
|
struct apk_istream *is,
|
|
|
|
unsigned int type, unsigned int size);
|
2013-06-20 10:12:44 +00:00
|
|
|
void apk_ipkg_run_script(struct apk_installed_package *ipkg, struct apk_database *db,
|
|
|
|
unsigned int type, char **argv);
|
2008-04-17 14:09:13 +00:00
|
|
|
|
|
|
|
struct apk_package *apk_pkg_parse_index_entry(struct apk_database *db, apk_blob_t entry);
|
2009-04-16 14:05:27 +00:00
|
|
|
int apk_pkg_write_index_entry(struct apk_package *pkg, struct apk_ostream *os);
|
2008-04-17 14:09:13 +00:00
|
|
|
|
2009-06-20 10:38:07 +00:00
|
|
|
int apk_pkg_version_compare(struct apk_package *a, struct apk_package *b);
|
|
|
|
|
2013-06-15 17:39:05 +00:00
|
|
|
unsigned int apk_foreach_genid(void);
|
2013-06-13 17:48:38 +00:00
|
|
|
void apk_pkg_foreach_matching_dependency(
|
2013-06-15 17:39:05 +00:00
|
|
|
struct apk_package *pkg, struct apk_dependency_array *deps,
|
|
|
|
unsigned int match, struct apk_package *mpkg,
|
2013-06-13 17:48:38 +00:00
|
|
|
void cb(struct apk_package *pkg0, struct apk_dependency *dep0, struct apk_package *pkg, void *ctx),
|
|
|
|
void *ctx);
|
|
|
|
void apk_pkg_foreach_reverse_dependency(
|
2013-06-15 17:39:05 +00:00
|
|
|
struct apk_package *pkg, unsigned int match,
|
2013-06-13 17:48:38 +00:00
|
|
|
void cb(struct apk_package *pkg0, struct apk_dependency *dep0, struct apk_package *pkg, void *ctx),
|
|
|
|
void *ctx);
|
|
|
|
|
2008-04-17 14:09:13 +00:00
|
|
|
#endif
|