2008-04-17 14:09:13 +00:00
|
|
|
/* apk_database.h - Alpine Package Keeper (APK)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005-2008 Natanael Copa <n@tanael.org>
|
|
|
|
* Copyright (C) 2008 Timo Teräs <timo.teras@iki.fi>
|
|
|
|
* 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"
|
2008-04-17 14:09:13 +00:00
|
|
|
|
|
|
|
struct apk_database;
|
|
|
|
struct apk_name;
|
|
|
|
|
2008-11-07 11:05:55 +00:00
|
|
|
#define APK_SCRIPT_INVALID -1
|
|
|
|
#define APK_SCRIPT_PRE_INSTALL 1
|
|
|
|
#define APK_SCRIPT_POST_INSTALL 2
|
|
|
|
#define APK_SCRIPT_PRE_DEINSTALL 3
|
|
|
|
#define APK_SCRIPT_POST_DEINSTALL 4
|
|
|
|
#define APK_SCRIPT_PRE_UPGRADE 5
|
|
|
|
#define APK_SCRIPT_POST_UPGRADE 6
|
2008-04-17 14:09:13 +00:00
|
|
|
|
2009-04-14 15:48:02 +00:00
|
|
|
#define APK_PKG_NOT_INSTALLED 0
|
|
|
|
#define APK_PKG_INSTALLED 1
|
|
|
|
|
2008-04-17 14:09:13 +00:00
|
|
|
struct apk_script {
|
|
|
|
struct hlist_node script_list;
|
|
|
|
unsigned int type;
|
|
|
|
unsigned int size;
|
|
|
|
char script[];
|
|
|
|
};
|
|
|
|
|
2009-04-14 15:48:02 +00:00
|
|
|
#define APK_DEPMASK_REQUIRE (APK_VERSION_EQUAL|APK_VERSION_LESS|\
|
|
|
|
APK_VERSION_GREATER)
|
|
|
|
#define APK_DEPMASK_CONFLICT (0)
|
|
|
|
|
2008-04-17 14:09:13 +00:00
|
|
|
struct apk_dependency {
|
|
|
|
struct apk_name *name;
|
2009-04-14 15:48:02 +00:00
|
|
|
int result_mask;
|
|
|
|
char *version;
|
2008-04-17 14:09:13 +00:00
|
|
|
};
|
|
|
|
APK_ARRAY(apk_dependency_array, struct apk_dependency);
|
|
|
|
|
|
|
|
struct apk_package {
|
|
|
|
apk_hash_node hash_node;
|
|
|
|
|
2009-04-14 15:48:02 +00:00
|
|
|
unsigned repos;
|
2008-04-17 14:09:13 +00:00
|
|
|
struct apk_name *name;
|
|
|
|
char *version;
|
|
|
|
char *url, *description, *license;
|
|
|
|
struct apk_dependency_array *depends;
|
2008-11-28 14:28:54 +00:00
|
|
|
size_t installed_size, size;
|
2008-11-28 11:34:40 +00:00
|
|
|
char *filename;
|
2009-07-14 16:14:05 +00:00
|
|
|
struct apk_checksum csum;
|
2008-04-17 14:09:13 +00:00
|
|
|
|
|
|
|
/* for installed packages only */
|
2008-11-27 18:25:01 +00:00
|
|
|
struct list_head installed_pkgs_list;
|
2009-01-06 17:44:54 +00:00
|
|
|
struct hlist_head owned_dirs;
|
2008-04-17 14:09:13 +00:00
|
|
|
struct hlist_head scripts;
|
|
|
|
};
|
|
|
|
APK_ARRAY(apk_package_array, struct apk_package *);
|
|
|
|
|
2009-07-14 16:14:05 +00:00
|
|
|
extern const char *apk_script_types[];
|
|
|
|
|
2008-04-17 14:09:13 +00:00
|
|
|
int apk_deps_add(struct apk_dependency_array **depends,
|
|
|
|
struct apk_dependency *dep);
|
2009-04-16 13:32:04 +00:00
|
|
|
void apk_deps_del(struct apk_dependency_array **deps,
|
|
|
|
struct apk_name *name);
|
2008-04-17 14:09:13 +00:00
|
|
|
void apk_deps_parse(struct apk_database *db,
|
|
|
|
struct apk_dependency_array **depends,
|
|
|
|
apk_blob_t blob);
|
2009-03-17 11:19:06 +00:00
|
|
|
int apk_deps_write(struct apk_dependency_array *deps, struct apk_ostream *os);
|
2008-04-17 14:09:13 +00:00
|
|
|
int apk_script_type(const char *name);
|
|
|
|
|
2008-11-28 11:15:06 +00:00
|
|
|
struct apk_package *apk_pkg_new(void);
|
2008-04-17 14:09:13 +00:00
|
|
|
struct apk_package *apk_pkg_read(struct apk_database *db, const char *name);
|
|
|
|
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);
|
2008-04-17 14:09:13 +00:00
|
|
|
int apk_pkg_get_state(struct apk_package *pkg);
|
2008-11-28 11:15:06 +00:00
|
|
|
void apk_pkg_set_state(struct apk_database *db, struct apk_package *pkg, int state);
|
2008-11-07 15:11:08 +00:00
|
|
|
int apk_pkg_add_script(struct apk_package *pkg, struct apk_istream *is,
|
2008-04-17 14:09:13 +00:00
|
|
|
unsigned int type, unsigned int size);
|
2008-04-22 08:16:26 +00:00
|
|
|
int apk_pkg_run_script(struct apk_package *pkg, int root_fd,
|
2008-04-17 14:09:13 +00:00
|
|
|
unsigned int type);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2009-06-16 09:59:21 +00:00
|
|
|
struct apk_dependency apk_dep_from_str(struct apk_database *db,
|
|
|
|
char *str);
|
|
|
|
struct apk_dependency apk_dep_from_pkg(struct apk_database *db,
|
|
|
|
struct apk_package *pkg);
|
2008-04-17 14:09:13 +00:00
|
|
|
#endif
|