2009-08-17 22:37:20 +05:30
|
|
|
/*-
|
|
|
|
* Copyright (c) 2008-2009 Juan Romero Pardines.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _XBPS_API_H_
|
|
|
|
#define _XBPS_API_H_
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <inttypes.h>
|
2009-11-18 14:32:12 +05:30
|
|
|
#include <sys/cdefs.h>
|
2009-08-17 22:37:20 +05:30
|
|
|
#include <sys/queue.h>
|
2009-11-28 07:08:41 +05:30
|
|
|
#ifndef DEBUG
|
|
|
|
# define NDEBUG
|
|
|
|
#endif
|
2009-08-17 22:37:20 +05:30
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include <prop/proplib.h>
|
|
|
|
#include <archive.h>
|
|
|
|
#include <archive_entry.h>
|
|
|
|
|
2009-10-18 13:53:52 +05:30
|
|
|
/* Current release version */
|
2009-11-28 07:08:41 +05:30
|
|
|
#define XBPS_RELVER "20091128"
|
2009-10-18 13:53:52 +05:30
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
/* Default root PATH for xbps to store metadata info. */
|
|
|
|
#define XBPS_META_PATH "/var/db/xbps"
|
|
|
|
|
2009-11-28 07:08:41 +05:30
|
|
|
/* Default cache PATH for xbps to store downloaded binpkgs. */
|
|
|
|
#define XBPS_CACHE_PATH "/var/cache/xbps"
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
/* Filename for the repositories plist file. */
|
|
|
|
#define XBPS_REPOLIST "repositories.plist"
|
|
|
|
|
|
|
|
/* Filename of the package index plist for a repository. */
|
|
|
|
#define XBPS_PKGINDEX "pkg-index.plist"
|
|
|
|
|
|
|
|
/* Filename of the packages register. */
|
|
|
|
#define XBPS_REGPKGDB "regpkgdb.plist"
|
|
|
|
|
|
|
|
/* Package metadata files. */
|
|
|
|
#define XBPS_PKGPROPS "props.plist"
|
|
|
|
#define XBPS_PKGFILES "files.plist"
|
|
|
|
|
|
|
|
/* Current version of the package index format. */
|
2009-11-25 10:08:09 +05:30
|
|
|
#define XBPS_PKGINDEX_VERSION "1.1"
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
#define XBPS_FLAG_VERBOSE 0x00000001
|
|
|
|
#define XBPS_FLAG_FORCE 0x00000002
|
|
|
|
|
|
|
|
#define ARCHIVE_READ_BLOCKSIZE 10240
|
|
|
|
|
2009-11-28 10:13:21 +05:30
|
|
|
#define EXTRACT_FLAGS ARCHIVE_EXTRACT_SECURE_NODOTDOT | \
|
|
|
|
ARCHIVE_EXTRACT_SECURE_SYMLINKS | \
|
|
|
|
ARCHIVE_EXTRACT_NO_OVERWRITE | \
|
|
|
|
ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER
|
|
|
|
#define FEXTRACT_FLAGS ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | \
|
|
|
|
ARCHIVE_EXTRACT_TIME | EXTRACT_FLAGS
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
#ifndef __UNCONST
|
|
|
|
#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
|
|
|
|
#endif
|
|
|
|
|
2009-11-21 11:42:42 +05:30
|
|
|
#ifdef DEBUG
|
|
|
|
#define DPRINTF(x) printf x
|
|
|
|
#else
|
|
|
|
#define DPRINTF(x)
|
|
|
|
#endif
|
|
|
|
|
2009-10-27 06:16:00 +05:30
|
|
|
#if __GNUC__ >= 4
|
|
|
|
#define SYMEXPORT __attribute__ ((visibility("default")))
|
|
|
|
#else
|
|
|
|
#define SYMEXPORT
|
|
|
|
#endif
|
|
|
|
|
2009-11-18 14:32:12 +05:30
|
|
|
__BEGIN_DECLS
|
|
|
|
|
2009-11-28 10:13:21 +05:30
|
|
|
/* From lib/config_files.c */
|
|
|
|
int xbps_config_file_from_archive_entry(prop_dictionary_t,
|
|
|
|
struct archive_entry *,
|
|
|
|
const char *,
|
|
|
|
int *,
|
|
|
|
bool *);
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
/* From lib/configure.c */
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_configure_pkg(const char *, const char *, bool);
|
|
|
|
int SYMEXPORT xbps_configure_all_pkgs(void);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
/* from lib/cmpver.c */
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_cmpver(const char *, const char *);
|
|
|
|
|
|
|
|
/* From lib/download.c */
|
2009-11-18 11:58:14 +05:30
|
|
|
int SYMEXPORT xbps_fetch_file(const char *, const char *, bool, const char *);
|
2009-10-30 07:43:03 +05:30
|
|
|
const char SYMEXPORT *xbps_fetch_error_string(void);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
/* From lib/fexec.c */
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_file_exec(const char *, ...);
|
|
|
|
int SYMEXPORT xbps_file_exec_skipempty(const char *, ...);
|
|
|
|
int SYMEXPORT xbps_file_chdir_exec(const char *, const char *, ...);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
/* From lib/humanize_number.c */
|
|
|
|
#define HN_DECIMAL 0x01
|
|
|
|
#define HN_NOSPACE 0x02
|
|
|
|
#define HN_B 0x04
|
|
|
|
#define HN_DIVISOR_1000 0x08
|
|
|
|
#define HN_GETSCALE 0x10
|
|
|
|
#define HN_AUTOSCALE 0x20
|
|
|
|
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_humanize_number(char *, size_t, int64_t, const char *,
|
2009-08-17 22:37:20 +05:30
|
|
|
int, int);
|
|
|
|
|
|
|
|
/* From lib/findpkg.c */
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_prepare_pkg(const char *);
|
|
|
|
int SYMEXPORT xbps_find_new_pkg(const char *, prop_dictionary_t);
|
|
|
|
int SYMEXPORT xbps_find_new_packages(void);
|
|
|
|
prop_dictionary_t SYMEXPORT xbps_get_pkg_props(void);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
/* From lib/depends.c */
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_find_deps_in_pkg(prop_dictionary_t, prop_dictionary_t);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-11-28 07:08:41 +05:30
|
|
|
/* From lib/mkpath.c */
|
|
|
|
int SYMEXPORT xbps_mkpath(char *, mode_t);
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
/* From lib/orphans.c */
|
2009-10-27 06:16:00 +05:30
|
|
|
prop_array_t SYMEXPORT xbps_find_orphan_packages(void);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-11-07 09:26:20 +05:30
|
|
|
/* From lib/pkgmatch.c */
|
|
|
|
int SYMEXPORT xbps_pkgdep_match(const char *, char *);
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
/* From lib/plist.c */
|
2009-10-27 06:16:00 +05:30
|
|
|
bool SYMEXPORT xbps_add_obj_to_dict(prop_dictionary_t, prop_object_t,
|
2009-08-17 22:37:20 +05:30
|
|
|
const char *);
|
2009-10-27 06:16:00 +05:30
|
|
|
bool SYMEXPORT xbps_add_obj_to_array(prop_array_t, prop_object_t);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_callback_array_iter_in_dict(prop_dictionary_t,
|
2009-08-17 22:37:20 +05:30
|
|
|
const char *,
|
|
|
|
int (*fn)(prop_object_t, void *, bool *),
|
|
|
|
void *);
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_callback_array_iter_reverse_in_dict(prop_dictionary_t,
|
2009-08-17 22:37:20 +05:30
|
|
|
const char *,
|
|
|
|
int (*fn)(prop_object_t, void *, bool *),
|
|
|
|
void *);
|
|
|
|
|
2009-10-27 06:16:00 +05:30
|
|
|
prop_dictionary_t SYMEXPORT xbps_find_pkg_in_dict(prop_dictionary_t,
|
2009-08-17 22:37:20 +05:30
|
|
|
const char *, const char *);
|
2009-10-27 06:16:00 +05:30
|
|
|
prop_dictionary_t SYMEXPORT xbps_find_pkg_from_plist(const char *,
|
|
|
|
const char *);
|
2009-11-07 09:26:20 +05:30
|
|
|
prop_dictionary_t SYMEXPORT
|
2009-11-24 16:17:04 +05:30
|
|
|
xbps_find_pkg_installed_from_plist(const char *);
|
2009-10-27 06:16:00 +05:30
|
|
|
bool SYMEXPORT xbps_find_string_in_array(prop_array_t, const char *);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-10-27 06:16:00 +05:30
|
|
|
prop_object_iterator_t SYMEXPORT
|
|
|
|
xbps_get_array_iter_from_dict(prop_dictionary_t, const char *);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-11-28 10:13:21 +05:30
|
|
|
prop_dictionary_t SYMEXPORT
|
|
|
|
xbps_read_dict_from_archive_entry(struct archive *,
|
|
|
|
struct archive_entry *);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_remove_pkg_dict_from_file(const char *, const char *);
|
2009-11-28 10:13:21 +05:30
|
|
|
int SYMEXPORT
|
|
|
|
xbps_remove_pkg_from_dict(prop_dictionary_t, const char *,
|
|
|
|
const char *);
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_remove_string_from_array(prop_array_t, const char *);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
/* From lib/purge.c */
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_purge_pkg(const char *, bool);
|
|
|
|
int SYMEXPORT xbps_purge_all_pkgs(void);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
/* From lib/register.c */
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_register_pkg(prop_dictionary_t, bool);
|
|
|
|
int SYMEXPORT xbps_unregister_pkg(const char *);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-11-26 07:52:50 +05:30
|
|
|
/* From lib/regpkgs_dictionary.c */
|
|
|
|
prop_dictionary_t SYMEXPORT xbps_regpkgs_dictionary_init(void);
|
|
|
|
void SYMEXPORT xbps_regpkgs_dictionary_release(void);
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
/* From lib/remove.c */
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_remove_pkg(const char *, const char *, bool);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-11-28 10:13:21 +05:30
|
|
|
/* From lib/remove_obsoletes.c */
|
|
|
|
int xbps_remove_obsoletes(prop_dictionary_t, prop_dictionary_t);
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
/* From lib/repository.c */
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_register_repository(const char *);
|
|
|
|
int SYMEXPORT xbps_unregister_repository(const char *);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-11-25 07:39:36 +05:30
|
|
|
/* From lib/repository_plist.c */
|
2009-11-25 09:59:53 +05:30
|
|
|
char SYMEXPORT
|
|
|
|
*xbps_get_path_from_pkg_dict_repo(prop_dictionary_t, const char *);
|
2009-11-25 07:39:36 +05:30
|
|
|
prop_dictionary_t SYMEXPORT
|
|
|
|
xbps_get_pkg_plist_dict_from_repo(const char *, const char *);
|
2009-11-25 08:22:58 +05:30
|
|
|
prop_dictionary_t SYMEXPORT
|
|
|
|
xbps_get_pkg_plist_dict_from_url(const char *, const char *);
|
2009-11-25 07:39:36 +05:30
|
|
|
|
2009-11-26 07:52:50 +05:30
|
|
|
/* From lib/repository_pool.c */
|
|
|
|
struct repository_data {
|
|
|
|
SIMPLEQ_ENTRY(repository_data) chain;
|
|
|
|
prop_dictionary_t rd_repod;
|
|
|
|
char *rd_uri;
|
|
|
|
};
|
|
|
|
SYMEXPORT SIMPLEQ_HEAD(, repository_data) repodata_queue;
|
|
|
|
|
|
|
|
int SYMEXPORT xbps_repository_pool_init(void);
|
|
|
|
void SYMEXPORT xbps_repository_pool_release(void);
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
/* From lib/requiredby.c */
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_requiredby_pkg_add(prop_array_t, prop_dictionary_t);
|
|
|
|
int SYMEXPORT xbps_requiredby_pkg_remove(const char *);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
/* From lib/sortdeps.c */
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_sort_pkg_deps(prop_dictionary_t);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
/* From lib/state.c */
|
|
|
|
typedef enum pkg_state {
|
|
|
|
XBPS_PKG_STATE_UNPACKED = 1,
|
|
|
|
XBPS_PKG_STATE_INSTALLED,
|
|
|
|
XBPS_PKG_STATE_BROKEN,
|
|
|
|
XBPS_PKG_STATE_CONFIG_FILES,
|
|
|
|
XBPS_PKG_STATE_NOT_INSTALLED
|
|
|
|
} pkg_state_t;
|
2009-11-24 16:17:04 +05:30
|
|
|
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_get_pkg_state_installed(const char *, pkg_state_t *);
|
|
|
|
int SYMEXPORT xbps_get_pkg_state_dictionary(prop_dictionary_t, pkg_state_t *);
|
|
|
|
int SYMEXPORT xbps_set_pkg_state_installed(const char *, pkg_state_t);
|
|
|
|
int SYMEXPORT xbps_set_pkg_state_dictionary(prop_dictionary_t, pkg_state_t);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-10-27 09:10:00 +05:30
|
|
|
/* From lib/sync_remote_pkgidx.c */
|
|
|
|
int SYMEXPORT xbps_sync_repository_pkg_index(const char *);
|
|
|
|
char SYMEXPORT *xbps_get_remote_repo_string(const char *);
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
/* From lib/unpack.c */
|
2009-10-27 06:16:00 +05:30
|
|
|
int SYMEXPORT xbps_unpack_binary_pkg(prop_dictionary_t, bool);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
/* From lib/util.c */
|
2009-10-27 06:16:00 +05:30
|
|
|
char SYMEXPORT *xbps_xasprintf(const char *, ...);
|
|
|
|
char SYMEXPORT *xbps_get_file_hash(const char *);
|
|
|
|
int SYMEXPORT xbps_check_file_hash(const char *, const char *);
|
|
|
|
int SYMEXPORT xbps_check_is_installed_pkg(const char *);
|
|
|
|
bool SYMEXPORT xbps_check_is_installed_pkgname(const char *);
|
2009-11-23 09:53:16 +05:30
|
|
|
bool SYMEXPORT xbps_check_is_repo_string_remote(const char *);
|
2009-11-28 07:51:29 +05:30
|
|
|
char SYMEXPORT
|
|
|
|
*xbps_get_binpkg_local_path(prop_dictionary_t, const char *);
|
2009-10-27 06:16:00 +05:30
|
|
|
char SYMEXPORT *xbps_get_pkg_index_plist(const char *);
|
|
|
|
char SYMEXPORT *xbps_get_pkg_name(const char *);
|
2009-11-07 09:26:20 +05:30
|
|
|
char SYMEXPORT *xbps_get_pkgdep_name(const char *);
|
2009-10-27 06:16:00 +05:30
|
|
|
const char SYMEXPORT *xbps_get_pkg_version(const char *);
|
2009-11-07 09:26:20 +05:30
|
|
|
const char SYMEXPORT *xbps_get_pkgdep_version(const char *);
|
2009-10-27 06:16:00 +05:30
|
|
|
const char SYMEXPORT *xbps_get_pkg_revision(const char *);
|
2009-11-22 09:45:47 +05:30
|
|
|
const char SYMEXPORT *xbps_get_pkgver_from_dict(prop_dictionary_t);
|
2009-10-27 06:16:00 +05:30
|
|
|
bool SYMEXPORT xbps_pkg_has_rundeps(prop_dictionary_t);
|
|
|
|
void SYMEXPORT xbps_set_rootdir(const char *);
|
|
|
|
const char SYMEXPORT *xbps_get_rootdir(void);
|
2009-11-28 07:08:41 +05:30
|
|
|
void SYMEXPORT xbps_set_cachedir(const char *);
|
|
|
|
const char SYMEXPORT *xbps_get_cachedir(void);
|
2009-10-27 06:16:00 +05:30
|
|
|
void SYMEXPORT xbps_set_flags(int);
|
|
|
|
int SYMEXPORT xbps_get_flags(void);
|
|
|
|
bool SYMEXPORT xbps_yesno(const char *, ...);
|
|
|
|
bool SYMEXPORT xbps_noyes(const char *, ...);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-11-18 14:32:12 +05:30
|
|
|
__END_DECLS
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
#endif /* !_XBPS_API_H_ */
|