Add RAZOR_HAVE_ATOMIC_ROLLBACK
authorJ. Ali Harlow <ali@juiblex.co.uk>
Fri Oct 03 12:26:22 2014 +0100 (2014-10-03)
changeset 45206885e558546
parent 451 457307a3966b
child 453 1fd1d221092d
Add RAZOR_HAVE_ATOMIC_ROLLBACK
.gitignore
configure.ac
librazor/razor.h
librazor/razor.h.in
     1.1 --- a/.gitignore	Fri Oct 03 12:24:10 2014 +0100
     1.2 +++ b/.gitignore	Fri Oct 03 12:26:22 2014 +0100
     1.3 @@ -34,3 +34,4 @@
     1.4  /link-warning.h
     1.5  /arg-nonnull.h
     1.6  /warn-on-use.h
     1.7 +librazor/razor.h
     2.1 --- a/configure.ac	Fri Oct 03 12:24:10 2014 +0100
     2.2 +++ b/configure.ac	Fri Oct 03 12:26:22 2014 +0100
     2.3 @@ -66,6 +66,10 @@
     2.4  	      [enable_atomic=yes])
     2.5  if test "$enable_atomic" = "yes"; then
     2.6      AC_DEFINE([ENABLE_ATOMIC],[1],[Define if atomic transactions are wanted.])
     2.7 +    AC_SUBST([RAZOR_HAVE_ATOMIC_ROLLBACK],
     2.8 +      ['#define RAZOR_HAVE_ATOMIC_ROLLBACK 1'])
     2.9 +else
    2.10 +    AC_SUBST([RAZOR_HAVE_ATOMIC_ROLLBACK],['#undef RAZOR_HAVE_ATOMIC_ROLLBACK'])
    2.11  fi
    2.12  
    2.13  AC_MSG_CHECKING([for Microsoft Windows native API])
    2.14 @@ -303,6 +307,7 @@
    2.15  data/razor.pc
    2.16  data/Makefile
    2.17  librazor/Makefile
    2.18 +librazor/razor.h
    2.19  librazor/types/Makefile
    2.20  src/Makefile
    2.21  docs/Makefile
     3.1 --- a/librazor/razor.h	Fri Oct 03 12:24:10 2014 +0100
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,631 +0,0 @@
     3.4 -/*
     3.5 - * Copyright (C) 2008  Kristian Høgsberg <krh@redhat.com>
     3.6 - * Copyright (C) 2008  Red Hat, Inc
     3.7 - * Copyright (C) 2009, 2011, 2012, 2014  J. Ali Harlow <ali@juiblex.co.uk>
     3.8 - *
     3.9 - * This program is free software; you can redistribute it and/or modify
    3.10 - * it under the terms of the GNU General Public License as published by
    3.11 - * the Free Software Foundation; either version 2 of the License, or
    3.12 - * (at your option) any later version.
    3.13 - *
    3.14 - * This program is distributed in the hope that it will be useful,
    3.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.17 - * GNU General Public License for more details.
    3.18 - *
    3.19 - * You should have received a copy of the GNU General Public License along
    3.20 - * with this program; if not, write to the Free Software Foundation, Inc.,
    3.21 - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    3.22 - */
    3.23 -
    3.24 -#ifndef _RAZOR_H_
    3.25 -#define _RAZOR_H_
    3.26 -
    3.27 -#include <stdint.h>
    3.28 -#include <sys/types.h>
    3.29 -
    3.30 -/* GCC extensions */
    3.31 -#if defined(__GNUC__)
    3.32 -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
    3.33 -#define RAZOR_MALLOC __attribute__((__malloc__))
    3.34 -#else
    3.35 -#define RAZOR_MALLOC
    3.36 -#endif
    3.37 -#if __GNUC__ >= 4
    3.38 -#define RAZOR_NULL_TERMINATED __attribute__ ((__sentinel__))
    3.39 -#else
    3.40 -#define RAZOR_NULL_TERMINATED
    3.41 -#endif
    3.42 -#endif	/* __GNUC__ */
    3.43 -
    3.44 -enum razor_section_type {
    3.45 -	RAZOR_SECTION_MAIN = 0x01,
    3.46 -	RAZOR_SECTION_DETAILS = 0x02,
    3.47 -	RAZOR_SECTION_FILES = 0x04,
    3.48 -	RAZOR_SECTION_ALL = 0x07
    3.49 -};
    3.50 -
    3.51 -enum razor_stage_type {
    3.52 -	RAZOR_STAGE_SCRIPTS_PRE = 0x1,
    3.53 -	RAZOR_STAGE_FILES = 0x2,
    3.54 -	RAZOR_STAGE_SCRIPTS_POST = 0x4,
    3.55 -	RAZOR_STAGE_SCRIPTS = 0x5,
    3.56 -	RAZOR_STAGE_ALL = 0x7
    3.57 -};
    3.58 -
    3.59 -enum razor_detail_type {
    3.60 -	RAZOR_DETAIL_LAST = 0,	/* the sentinel */
    3.61 -	RAZOR_DETAIL_NAME,
    3.62 -	RAZOR_DETAIL_VERSION,
    3.63 -	RAZOR_DETAIL_ARCH,
    3.64 -	RAZOR_DETAIL_SUMMARY,
    3.65 -	RAZOR_DETAIL_DESCRIPTION,
    3.66 -	RAZOR_DETAIL_URL,
    3.67 -	RAZOR_DETAIL_LICENSE,
    3.68 -	RAZOR_DETAIL_PREUNPROG,
    3.69 -	RAZOR_DETAIL_PREUN,
    3.70 -	RAZOR_DETAIL_POSTUNPROG,
    3.71 -	RAZOR_DETAIL_POSTUN,
    3.72 -	RAZOR_DETAIL_PREFIXES
    3.73 -};
    3.74 -
    3.75 -enum razor_property_flags {
    3.76 -	RAZOR_PROPERTY_LESS		= 1 << 0,
    3.77 -	RAZOR_PROPERTY_GREATER		= 1 << 1,
    3.78 -	RAZOR_PROPERTY_EQUAL		= 1 << 2,
    3.79 -	RAZOR_PROPERTY_RELATION_MASK	=
    3.80 -		RAZOR_PROPERTY_LESS |
    3.81 -		RAZOR_PROPERTY_GREATER |
    3.82 -		RAZOR_PROPERTY_EQUAL,
    3.83 -
    3.84 -	RAZOR_PROPERTY_REQUIRES		= 0 << 3,
    3.85 -	RAZOR_PROPERTY_PROVIDES		= 1 << 3,
    3.86 -	RAZOR_PROPERTY_CONFLICTS	= 2 << 3,
    3.87 -	RAZOR_PROPERTY_OBSOLETES	= 3 << 3,
    3.88 -	RAZOR_PROPERTY_TYPE_MASK	= 3 << 3,
    3.89 -		
    3.90 -	RAZOR_PROPERTY_PRE		= 1 << 5,
    3.91 -	RAZOR_PROPERTY_POST		= 1 << 6,
    3.92 -	RAZOR_PROPERTY_PREUN		= 1 << 7,
    3.93 -	RAZOR_PROPERTY_POSTUN		= 1 << 8,
    3.94 -	RAZOR_PROPERTY_SCRIPT_MASK	=
    3.95 -		RAZOR_PROPERTY_PRE |
    3.96 -		RAZOR_PROPERTY_POST |
    3.97 -		RAZOR_PROPERTY_PREUN |
    3.98 -		RAZOR_PROPERTY_POSTUN
    3.99 -};
   3.100 -
   3.101 -enum razor_set_flags {
   3.102 -	/*
   3.103 -	 * Create a private copy of the razor set such that changes made
   3.104 -	 * to the underlying file are not visible in the razor set.
   3.105 -	 * If this flag is not set then the caller must ensure that the
   3.106 -	 * underlying file (if any) is not changed.
   3.107 -	 */
   3.108 -	RAZOR_SET_PRIVATE		= 1 << 0,
   3.109 -};
   3.110 -
   3.111 -/**
   3.112 - * SECTION:error
   3.113 - * @title: Error reporting
   3.114 - * @short_description: A system for reporting errors.
   3.115 - *
   3.116 - * This object represents an error condition.
   3.117 - */
   3.118 -struct razor_error;
   3.119 -
   3.120 -struct razor_error *razor_error_new_str(int domain, int code,
   3.121 -					const char *object, const char *str);
   3.122 -struct razor_error *razor_error_dup(struct razor_error *src,
   3.123 -				    const char *summary);
   3.124 -
   3.125 -#define razor_set_error(error, domain, code, object, str) \
   3.126 -	if (error) \
   3.127 -		*(error) = razor_error_new_str(domain, code, object, str); \
   3.128 -	else
   3.129 -
   3.130 -#define razor_propagate_error(dest, src, summary) \
   3.131 -	if (dest) \
   3.132 -		*(dest) = razor_error_dup(src, summary); \
   3.133 -	else
   3.134 -
   3.135 -#define RAZOR_ERROR_DOMAIN(i1,i2,i3,c) \
   3.136 -	(((i1)&0xff)<<24|((i2)&0xff)<<16|((i3)&0xff)<<8|(c)&0xff)
   3.137 -
   3.138 -#define RAZOR_GENERAL_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',0)
   3.139 -#define RAZOR_POSIX_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',1)
   3.140 -#define RAZOR_MSWIN_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',2)
   3.141 -#define RAZOR_ZLIB_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',3)
   3.142 -
   3.143 -enum razor_general_error {
   3.144 -	RAZOR_GENERAL_ERROR_FAILED,
   3.145 -	RAZOR_GENERAL_ERROR_DATABASE_CORRUPTED,
   3.146 -	RAZOR_GENERAL_ERROR_DATABASE_INCOMPATIBLE,
   3.147 -	RAZOR_GENERAL_ERROR_DATABASE_EXISTS,
   3.148 -	RAZOR_GENERAL_ERROR_DATABASE_LOCKED,
   3.149 -	RAZOR_GENERAL_ERROR_RPM_UNSUPPORTED,
   3.150 -};
   3.151 -
   3.152 -int razor_error_get_domain(struct razor_error *error);
   3.153 -int razor_error_get_code(struct razor_error *error);
   3.154 -const char *razor_error_get_object(struct razor_error *error);
   3.155 -const char *razor_error_get_primary_text(struct razor_error *error);
   3.156 -const char *razor_error_get_secondary_text(struct razor_error *error);
   3.157 -const char *razor_error_get_msg(struct razor_error *error);
   3.158 -void razor_error_free(struct razor_error *error);
   3.159 -
   3.160 -/**
   3.161 - * SECTION:atomic
   3.162 - * @title: Atomic transactions
   3.163 - * @short_description: File-based transactions that shouldn't half-succeed
   3.164 - *
   3.165 - * This is a helper object for issuing a sequence of file-based actions
   3.166 - * that should either all succeed or all fail.
   3.167 - *
   3.168 - * Note that currently only Windows 7 has a native implementation and that
   3.169 - * while the emulated fallback implementation attempts to rollback the
   3.170 - * transaction if it fails, this is not guaranteed to succeed and that
   3.171 - * the transaction is held in core (and thus vulnernable to program crashes,
   3.172 - * power loss, etc.). This could (and should) be improved.
   3.173 - *
   3.174 - * Atomic transactions can be disabled via configure, in which case all
   3.175 - * bets are off.
   3.176 - **/
   3.177 -struct razor_atomic;
   3.178 -
   3.179 -struct razor_atomic *razor_atomic_open(const char *description);
   3.180 -int razor_atomic_commit(struct razor_atomic *atomic);
   3.181 -struct razor_error *razor_atomic_get_error(struct razor_atomic *atomic);
   3.182 -const char *razor_atomic_get_error_msg(struct razor_atomic *atomic);
   3.183 -void razor_atomic_destroy(struct razor_atomic *atomic);
   3.184 -
   3.185 -/**
   3.186 - * razor_atomic_make_dirs
   3.187 - * 
   3.188 - * Create all sub-directories leading up to path. We know root exists
   3.189 - * and is a dir, root does not end in a '/', and path either has a
   3.190 - * leading '/' or (on MS-Windows only) root is the empty string
   3.191 - * and path starts with drive (eg., "c:/windows").
   3.192 - * Note: path itself is not created, only the directory in which it
   3.193 - * (would) exist.
   3.194 - *
   3.195 - * Returns: non-zero on error.
   3.196 - **/
   3.197 -int razor_atomic_make_dirs(struct razor_atomic *atomic, const char *root,
   3.198 -  const char *path);
   3.199 -int razor_atomic_remove(struct razor_atomic *atomic, const char *path);
   3.200 -int razor_atomic_rename_file(struct razor_atomic *atomic, const char *oldpath,
   3.201 -			     const char *newpath);
   3.202 -
   3.203 -/**
   3.204 - * razor_atomic_create_dir
   3.205 - * 
   3.206 - * Create a directory, replacing any existing object at this path except
   3.207 - * an existing directory (which is not counted as a error).
   3.208 - *
   3.209 - * Returns: non-zero on error.
   3.210 - */
   3.211 -int razor_atomic_create_dir(struct razor_atomic *atomic, const char *dirname,
   3.212 -  mode_t mode);
   3.213 -
   3.214 -/**
   3.215 - * razor_atomic_create_symlink
   3.216 - * 
   3.217 - * Create a symbolic link, replacing any existing object at this path except
   3.218 - * a non-empty directory.
   3.219 - *
   3.220 - * Note: This function will always fail on platforms that don't support
   3.221 - * symbolic links.
   3.222 - *
   3.223 - * Returns: non-zero on error.
   3.224 - */
   3.225 -int razor_atomic_create_symlink(struct razor_atomic *atomic, const char *target,
   3.226 -  const char *path);
   3.227 -/**
   3.228 - * razor_atomic_create_file
   3.229 - * 
   3.230 - * Create a file, replacing any existing object at this path except
   3.231 - * a non-empty directory.
   3.232 - *
   3.233 - * Returns: A handle to be passed to razor_atomic_write() and
   3.234 - * razor_atomic_close() or a negative value on error.
   3.235 - */
   3.236 -int razor_atomic_create_file(struct razor_atomic *atomic, const char *filename,
   3.237 -  mode_t mode);
   3.238 -int razor_atomic_write(struct razor_atomic *atomic, int handle,
   3.239 -  const void *data, size_t size);
   3.240 -int razor_atomic_close(struct razor_atomic *atomic, int handle);
   3.241 -int razor_atomic_sync(struct razor_atomic *atomic, int handle);
   3.242 -void razor_atomic_abort(struct razor_atomic *atomic, int domain, int code,
   3.243 -  const char *error_msg);
   3.244 -void razor_atomic_propagate_error(struct razor_atomic *atomic,
   3.245 -  struct razor_error *error, const char *summary);
   3.246 -int razor_atomic_in_error_state(struct razor_atomic *atomic);
   3.247 -
   3.248 -/**
   3.249 - * SECTION:set
   3.250 - * @title: Package Set
   3.251 - * @short_description: Represents a set of packages and their metadata.
   3.252 - *
   3.253 - * This object represents a set of packages, their dependency
   3.254 - * information, the file lists and a number of other details.
   3.255 - **/
   3.256 -
   3.257 -struct razor_set;
   3.258 -struct razor_package;
   3.259 -struct razor_property;
   3.260 -
   3.261 -#define RAZOR_HEADER_VERSION		2	/* Current version */
   3.262 -#define RAZOR_HEADER_VERSION_MIN	1	/* Minimum version we support */
   3.263 -
   3.264 -/**
   3.265 - * razor_set_create:
   3.266 - * 
   3.267 - * Create a new #razor_set object.
   3.268 - * 
   3.269 - * Returns: the new #razor_set object.
   3.270 - **/
   3.271 -struct razor_set *razor_set_create_without_root(void);
   3.272 -struct razor_set *razor_set_create(void);
   3.273 -struct razor_set *
   3.274 -razor_set_open(const char *filename, enum razor_set_flags flags,
   3.275 -	       struct razor_error **error);
   3.276 -uint32_t razor_set_get_header_version(struct razor_set *set);
   3.277 -int razor_set_set_header_version(struct razor_set *set,
   3.278 -				 uint32_t header_version);
   3.279 -void razor_set_unref(struct razor_set *set);
   3.280 -struct razor_set *razor_set_ref(struct razor_set *set);
   3.281 -void razor_set_write_to_handle(struct razor_set *set,
   3.282 -			       struct razor_atomic *atomic, int handle,
   3.283 -			       uint32_t section_mask);
   3.284 -int razor_set_write(struct razor_set *set, struct razor_atomic *atomic,
   3.285 -		    const char *filename, uint32_t setions);
   3.286 -int
   3.287 -razor_set_bind_sections(struct razor_set *set, const char *filename,
   3.288 -			enum razor_set_flags flags, struct razor_error **error);
   3.289 -
   3.290 -void
   3.291 -razor_package_get_details(struct razor_set *set,
   3.292 -			  struct razor_package *package, ...);
   3.293 -int
   3.294 -razor_package_remove(struct razor_set *prev, struct razor_set *next,
   3.295 -		     struct razor_atomic *atomic, struct razor_package *package,
   3.296 -		     const char *root, int install_count,
   3.297 -		     enum razor_stage_type stage);
   3.298 -
   3.299 -/**
   3.300 - * SECTION:iterator
   3.301 - * @title: Iterators
   3.302 - * @short_description: Objects for traversing packages or properties.
   3.303 - *
   3.304 - * The razor iterator objects provides a way to iterate through a set
   3.305 - * of packages or properties.
   3.306 - **/
   3.307 -
   3.308 -struct razor_package_iterator;
   3.309 -
   3.310 -/**
   3.311 - * razor_package_iterator_create:
   3.312 - * 
   3.313 - * Create a new #razor_package_iterator object.
   3.314 - * 
   3.315 - * Returns: the new #razor_package_iterator object.
   3.316 - **/
   3.317 -
   3.318 -struct razor_package_iterator *
   3.319 -razor_package_iterator_create(struct razor_set *set);
   3.320 -
   3.321 -/**
   3.322 - * razor_package_iterator_create_for_property:
   3.323 - * 
   3.324 - * Create a new #razor_package_iterator object for the packages that
   3.325 - * own the given property.
   3.326 - * 
   3.327 - * Returns: the new #razor_package_iterator object.
   3.328 - **/
   3.329 -struct razor_package_iterator *
   3.330 -razor_package_iterator_create_for_property(struct razor_set *set,
   3.331 -					   struct razor_property *property);
   3.332 -
   3.333 -/**
   3.334 - * razor_package_iterator_create_for_file:
   3.335 - *
   3.336 - * Create a new #razor_package_iterator object for the packages that
   3.337 - * contain the given file name.
   3.338 - *
   3.339 - * Returns: the new #razor_package_iterator object.
   3.340 - **/
   3.341 -struct razor_package_iterator *
   3.342 -razor_package_iterator_create_for_file(struct razor_set *set,
   3.343 -				       const char *filename);
   3.344 -
   3.345 -int razor_package_iterator_next(struct razor_package_iterator *pi,
   3.346 -				struct razor_package **package, ...);
   3.347 -void razor_package_iterator_destroy(struct razor_package_iterator *pi);
   3.348 -
   3.349 -struct razor_package_query *
   3.350 -razor_package_query_create(struct razor_set *set);
   3.351 -void
   3.352 -razor_package_query_add_package(struct razor_package_query *pq,
   3.353 -				struct razor_package *p);
   3.354 -void
   3.355 -razor_package_query_add_iterator(struct razor_package_query *pq,
   3.356 -				 struct razor_package_iterator *pi);
   3.357 -struct razor_package_iterator *
   3.358 -razor_package_query_finish(struct razor_package_query *pq);
   3.359 -
   3.360 -struct razor_property_iterator;
   3.361 -struct razor_property_iterator *
   3.362 -razor_property_iterator_create(struct razor_set *set,
   3.363 -			       struct razor_package *package);
   3.364 -int razor_property_iterator_next(struct razor_property_iterator *pi,
   3.365 -				 struct razor_property **property,
   3.366 -				 const char **name,
   3.367 -				 uint32_t *flags,
   3.368 -				 const char **version);
   3.369 -void
   3.370 -razor_property_iterator_destroy(struct razor_property_iterator *pi);
   3.371 -
   3.372 -struct razor_file_iterator;
   3.373 -struct razor_file_iterator *
   3.374 -razor_file_iterator_create(struct razor_set *set,
   3.375 -			   struct razor_package *package, int post_order);
   3.376 -int razor_file_iterator_next(struct razor_file_iterator *fi,
   3.377 -			     const char **name);
   3.378 -void razor_file_iterator_destroy(struct razor_file_iterator *fi);
   3.379 -
   3.380 -void razor_set_list_files(struct razor_set *set, const char *prefix);
   3.381 -void razor_set_list_package_files(struct razor_set *set,
   3.382 -				  struct razor_package *package);
   3.383 -
   3.384 -enum razor_diff_action {
   3.385 -	RAZOR_DIFF_ACTION_ADD,
   3.386 -	RAZOR_DIFF_ACTION_REMOVE,
   3.387 -};
   3.388 -
   3.389 -typedef void (*razor_diff_callback_t)(enum razor_diff_action action,
   3.390 -				      struct razor_package *package,
   3.391 -				      const char *name,
   3.392 -				      const char *version,
   3.393 -				      const char *arch,
   3.394 -				      void *data);
   3.395 -
   3.396 -void
   3.397 -razor_set_diff(struct razor_set *set, struct razor_set *upstream,
   3.398 -	       razor_diff_callback_t callback, void *data);
   3.399 -
   3.400 -struct razor_install_iterator;
   3.401 -
   3.402 -enum razor_install_action {
   3.403 -	RAZOR_INSTALL_ACTION_ADD,
   3.404 -	RAZOR_INSTALL_ACTION_REMOVE,
   3.405 -	RAZOR_INSTALL_ACTION_COMMIT
   3.406 -};
   3.407 -
   3.408 -struct razor_install_iterator *
   3.409 -razor_set_create_install_iterator(struct razor_set *set,
   3.410 -				  struct razor_set *next);
   3.411 -
   3.412 -int razor_install_iterator_next(struct razor_install_iterator *ii,
   3.413 -				struct razor_package **package,
   3.414 -				enum razor_install_action *action,
   3.415 -				int *count);
   3.416 -
   3.417 -/**
   3.418 - * razor_install_iterator_commit_set
   3.419 - *
   3.420 - * Immediately after razor_install_iterator_next() returns
   3.421 - * RAZOR_INSTALL_ACTION_COMMIT, this function will return the razor_set
   3.422 - * which should be committed.
   3.423 - *
   3.424 - * Returns: a new #razor_set object.
   3.425 - **/
   3.426 -struct razor_set *
   3.427 -razor_install_iterator_commit_set(struct razor_install_iterator *ii);
   3.428 -
   3.429 -void razor_install_iterator_rewind(struct razor_install_iterator *ii);
   3.430 -size_t razor_install_iterator_tell(struct razor_install_iterator *ii);
   3.431 -size_t razor_install_iterator_seek(struct razor_install_iterator *ii,
   3.432 -				   size_t pos);
   3.433 -void razor_install_iterator_destroy(struct razor_install_iterator *ii);
   3.434 -
   3.435 -/**
   3.436 - * SECTION:transaction
   3.437 - * @title: Transaction
   3.438 - * @short_description: Create a new package set by merging two or more sets.
   3.439 - *
   3.440 - * The razor transaction object provides a way to create a new package set
   3.441 - * from packages from one or more other package sets.
   3.442 - **/
   3.443 -
   3.444 -struct razor_rpm;
   3.445 -
   3.446 -struct razor_transaction *
   3.447 -razor_transaction_create(struct razor_set *system, struct razor_set *upstream);
   3.448 -void razor_transaction_install_package(struct razor_transaction *transaction,
   3.449 -				       struct razor_package *package);
   3.450 -void razor_transaction_remove_package(struct razor_transaction *transaction,
   3.451 -				      struct razor_package *package);
   3.452 -void razor_transaction_update_package(struct razor_transaction *trans,
   3.453 -				      struct razor_package *package);
   3.454 -void razor_transaction_fixup_package(struct razor_transaction *trans,
   3.455 -				     struct razor_package *package,
   3.456 -				     struct razor_rpm *rpm);
   3.457 -void razor_transaction_update_all(struct razor_transaction *transaction);
   3.458 -int razor_transaction_resolve(struct razor_transaction *trans);
   3.459 -
   3.460 -typedef void (*razor_unsatisfied_callback_t)(const char *requirement,
   3.461 -					     struct razor_package *package,
   3.462 -					     const char *name,
   3.463 -					     const char *version,
   3.464 -					     const char *arch,
   3.465 -					     void *data);
   3.466 -
   3.467 -int razor_transaction_unsatisfied(struct razor_transaction *trans,
   3.468 -				  razor_unsatisfied_callback_t callback,
   3.469 -				  void *data);
   3.470 -int razor_transaction_describe(struct razor_transaction *trans);
   3.471 -struct razor_set *razor_transaction_commit(struct razor_transaction *trans);
   3.472 -void razor_transaction_destroy(struct razor_transaction *trans);
   3.473 -
   3.474 -/* Temporary helper for test suite. */
   3.475 -int razor_transaction_unsatisfied_property(struct razor_transaction *trans,
   3.476 -					   const char *name,
   3.477 -					   uint32_t flags,
   3.478 -					   const char *version);
   3.479 -
   3.480 -/**
   3.481 - * SECTION:rpm
   3.482 - * @title: Razor RPM
   3.483 - * @short_description: Operating on RPM files.
   3.484 - *
   3.485 - * Functions for open RPM files and extracting information and
   3.486 - * installing or removing RPM files.
   3.487 - **/
   3.488 -
   3.489 -struct razor_relocations;
   3.490 -
   3.491 -struct razor_relocations *razor_relocations_create(void);
   3.492 -void razor_relocations_add(struct razor_relocations *relocations,
   3.493 -			   const char *oldpath, const char *newpath);
   3.494 -void razor_relocations_set_rpm(struct razor_relocations *relocations,
   3.495 -			       struct razor_rpm *rpm);
   3.496 -const char *razor_relocations_apply(struct razor_relocations *relocations,
   3.497 -				    const char *path);
   3.498 -void razor_relocations_destroy(struct razor_relocations *relocations);
   3.499 -
   3.500 -struct razor_rpm *razor_rpm_open(const char *filename,
   3.501 -				 struct razor_error **error);
   3.502 -void razor_rpm_get_details(struct razor_rpm *rpm, ...);
   3.503 -void razor_rpm_set_relocations(struct razor_rpm *rpm,
   3.504 -			       struct razor_relocations *relocations);
   3.505 -int razor_rpm_install(struct razor_rpm *rpm, struct razor_atomic *atomic,
   3.506 -		      const char *root, int install_count,
   3.507 -		      enum razor_stage_type stage);
   3.508 -int razor_rpm_close(struct razor_rpm *rpm);
   3.509 -
   3.510 -/**
   3.511 - * SECTION:importer
   3.512 - * @title: Importer
   3.513 - * @short_description: A mechanism for building #razor_set objects
   3.514 - *
   3.515 - * The %razor_importer is a helper object for building a razor set
   3.516 - * from external sources, like yum metadata, the RPM database or RPM
   3.517 - * files.
   3.518 - *
   3.519 - * The importer is a stateful object; it has the notion of a current
   3.520 - * package, and the caller can provide meta data such as properties,
   3.521 - * files and similiar for the package as it becomes available.  Once a
   3.522 - * package is fully described, the next pacakge can begin.  When all
   3.523 - * packages have been described to the importer, the importer will
   3.524 - * create a new %razor_set with the specified packages.
   3.525 - *
   3.526 - * A typical use
   3.527 - * of the importer will follow this template:
   3.528 - * |[
   3.529 - * importer = razor_importer_create();
   3.530 - *
   3.531 - * while ( /<!-- -->* more packages to import *<!-- -->/; ) {
   3.532 - *   /<!-- -->* get name, version and arch of next package *<!-- -->/
   3.533 - *   razor_importer_begin_package(importer, name, version, arch);
   3.534 - *   razor_importer_add_details(importer, summary, description, url, license);
   3.535 - *
   3.536 - *   while ( /<!-- -->* more properties to add *<!-- -->/ )
   3.537 - *     razor_importer_add_property(importer, name, flags, version);
   3.538 - *
   3.539 - *   while ( /<!-- -->* [more files to add *<!-- -->/ )
   3.540 - *     razor_importer_add_file(importer, name);
   3.541 - *
   3.542 - *   razor_importer_finish_package(importer);
   3.543 - * }
   3.544 - *
   3.545 - * return razor_importer_finish(importer);
   3.546 - * ]|
   3.547 - **/
   3.548 -struct razor_importer;
   3.549 -
   3.550 -struct razor_importer *razor_importer_create(void);
   3.551 -void razor_importer_destroy(struct razor_importer *importer);
   3.552 -void razor_importer_begin_package(struct razor_importer *importer,
   3.553 -				  const char *name,
   3.554 -				  const char *version,
   3.555 -				  const char *arch);
   3.556 -void razor_importer_add_details(struct razor_importer *importer,
   3.557 -				const char *summary,
   3.558 -				const char *description,
   3.559 -				const char *url,
   3.560 -				const char *license);
   3.561 -void razor_importer_add_script(struct razor_importer *importer,
   3.562 -			       enum razor_property_flags script,
   3.563 -			       const char *program,
   3.564 -			       const char *body);
   3.565 -void razor_importer_add_install_prefix(struct razor_importer *importer,
   3.566 -				       const char *install_prefix);
   3.567 -void razor_importer_add_property(struct razor_importer *importer,
   3.568 -				 const char *name,
   3.569 -				 uint32_t flags,
   3.570 -				 const char *version);
   3.571 -void razor_importer_add_file(struct razor_importer *importer,
   3.572 -			     const char *name);
   3.573 -void razor_importer_finish_package(struct razor_importer *importer);
   3.574 -
   3.575 -int razor_importer_add_rpm(struct razor_importer *importer,
   3.576 -			   struct razor_rpm *rpm);
   3.577 -
   3.578 -struct razor_set *razor_importer_finish(struct razor_importer *importer);
   3.579 -
   3.580 -struct razor_set *razor_set_create_from_yum(void);
   3.581 -struct razor_set *razor_set_create_from_rpmdb(void);
   3.582 -
   3.583 -/**
   3.584 - * SECTION:root
   3.585 - * @title: Root
   3.586 - * @short_description: Functions for accessing an install root.
   3.587 - *
   3.588 - * The #razor_root object encapsulate access to and locking of a razor
   3.589 - * install root.
   3.590 - **/
   3.591 -struct razor_root;
   3.592 -
   3.593 -const char *razor_get_database_path();
   3.594 -void razor_set_database_path(const char *database_path);
   3.595 -int razor_root_create(const char *root, struct razor_error **error);
   3.596 -struct razor_root *
   3.597 -razor_root_open(const char *root, struct razor_error **error);
   3.598 -struct razor_set *
   3.599 -razor_root_open_read_only(const char *root, struct razor_error **error);
   3.600 -struct razor_set *razor_root_get_system_set(struct razor_root *root);
   3.601 -int razor_root_close(struct razor_root *root);
   3.602 -int
   3.603 -razor_root_update(struct razor_root *root, struct razor_set *next,
   3.604 -		  struct razor_atomic *atomic);
   3.605 -
   3.606 -/**
   3.607 - * SECTION:misc
   3.608 - * @title: Miscellaneous Functions
   3.609 - * @short_description: Various helper functions
   3.610 - *
   3.611 - * Functions that doesn't fit anywhere else.
   3.612 - **/
   3.613 -
   3.614 -const char *
   3.615 -razor_property_relation_to_string(struct razor_property *p);
   3.616 -const char *
   3.617 -razor_property_type_to_string(struct razor_property *p);
   3.618 -
   3.619 -void razor_build_evr(char *evr_buf, int size, const char *epoch,
   3.620 -		     const char *version, const char *release);
   3.621 -int razor_versioncmp(const char *s1, const char *s2);
   3.622 -
   3.623 -void razor_disable_root_name_checks(int disable);
   3.624 -
   3.625 -void razor_set_lua_loader(const char *modname, void (*loader)());
   3.626 -void (*razor_get_lua_loader(const char *modname))();
   3.627 -
   3.628 -char *razor_concat(const char *s, ...) RAZOR_MALLOC RAZOR_NULL_TERMINATED;
   3.629 -
   3.630 -char *razor_path_add_root(const char *path, const char *root) RAZOR_MALLOC;
   3.631 -
   3.632 -const char *razor_system_arch(void);
   3.633 -
   3.634 -#endif /* _RAZOR_H_ */
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/librazor/razor.h.in	Fri Oct 03 12:26:22 2014 +0100
     4.3 @@ -0,0 +1,634 @@
     4.4 +/*
     4.5 + * Copyright (C) 2008  Kristian Høgsberg <krh@redhat.com>
     4.6 + * Copyright (C) 2008  Red Hat, Inc
     4.7 + * Copyright (C) 2009, 2011, 2012, 2014  J. Ali Harlow <ali@juiblex.co.uk>
     4.8 + *
     4.9 + * This program is free software; you can redistribute it and/or modify
    4.10 + * it under the terms of the GNU General Public License as published by
    4.11 + * the Free Software Foundation; either version 2 of the License, or
    4.12 + * (at your option) any later version.
    4.13 + *
    4.14 + * This program is distributed in the hope that it will be useful,
    4.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    4.17 + * GNU General Public License for more details.
    4.18 + *
    4.19 + * You should have received a copy of the GNU General Public License along
    4.20 + * with this program; if not, write to the Free Software Foundation, Inc.,
    4.21 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    4.22 + */
    4.23 +
    4.24 +#ifndef _RAZOR_H_
    4.25 +#define _RAZOR_H_
    4.26 +
    4.27 +#include <stdint.h>
    4.28 +#include <sys/types.h>
    4.29 +
    4.30 +/* GCC extensions */
    4.31 +#if defined(__GNUC__)
    4.32 +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
    4.33 +#define RAZOR_MALLOC __attribute__((__malloc__))
    4.34 +#else
    4.35 +#define RAZOR_MALLOC
    4.36 +#endif
    4.37 +#if __GNUC__ >= 4
    4.38 +#define RAZOR_NULL_TERMINATED __attribute__ ((__sentinel__))
    4.39 +#else
    4.40 +#define RAZOR_NULL_TERMINATED
    4.41 +#endif
    4.42 +#endif	/* __GNUC__ */
    4.43 +
    4.44 +enum razor_section_type {
    4.45 +	RAZOR_SECTION_MAIN = 0x01,
    4.46 +	RAZOR_SECTION_DETAILS = 0x02,
    4.47 +	RAZOR_SECTION_FILES = 0x04,
    4.48 +	RAZOR_SECTION_ALL = 0x07
    4.49 +};
    4.50 +
    4.51 +enum razor_stage_type {
    4.52 +	RAZOR_STAGE_SCRIPTS_PRE = 0x1,
    4.53 +	RAZOR_STAGE_FILES = 0x2,
    4.54 +	RAZOR_STAGE_SCRIPTS_POST = 0x4,
    4.55 +	RAZOR_STAGE_SCRIPTS = 0x5,
    4.56 +	RAZOR_STAGE_ALL = 0x7
    4.57 +};
    4.58 +
    4.59 +enum razor_detail_type {
    4.60 +	RAZOR_DETAIL_LAST = 0,	/* the sentinel */
    4.61 +	RAZOR_DETAIL_NAME,
    4.62 +	RAZOR_DETAIL_VERSION,
    4.63 +	RAZOR_DETAIL_ARCH,
    4.64 +	RAZOR_DETAIL_SUMMARY,
    4.65 +	RAZOR_DETAIL_DESCRIPTION,
    4.66 +	RAZOR_DETAIL_URL,
    4.67 +	RAZOR_DETAIL_LICENSE,
    4.68 +	RAZOR_DETAIL_PREUNPROG,
    4.69 +	RAZOR_DETAIL_PREUN,
    4.70 +	RAZOR_DETAIL_POSTUNPROG,
    4.71 +	RAZOR_DETAIL_POSTUN,
    4.72 +	RAZOR_DETAIL_PREFIXES
    4.73 +};
    4.74 +
    4.75 +enum razor_property_flags {
    4.76 +	RAZOR_PROPERTY_LESS		= 1 << 0,
    4.77 +	RAZOR_PROPERTY_GREATER		= 1 << 1,
    4.78 +	RAZOR_PROPERTY_EQUAL		= 1 << 2,
    4.79 +	RAZOR_PROPERTY_RELATION_MASK	=
    4.80 +		RAZOR_PROPERTY_LESS |
    4.81 +		RAZOR_PROPERTY_GREATER |
    4.82 +		RAZOR_PROPERTY_EQUAL,
    4.83 +
    4.84 +	RAZOR_PROPERTY_REQUIRES		= 0 << 3,
    4.85 +	RAZOR_PROPERTY_PROVIDES		= 1 << 3,
    4.86 +	RAZOR_PROPERTY_CONFLICTS	= 2 << 3,
    4.87 +	RAZOR_PROPERTY_OBSOLETES	= 3 << 3,
    4.88 +	RAZOR_PROPERTY_TYPE_MASK	= 3 << 3,
    4.89 +		
    4.90 +	RAZOR_PROPERTY_PRE		= 1 << 5,
    4.91 +	RAZOR_PROPERTY_POST		= 1 << 6,
    4.92 +	RAZOR_PROPERTY_PREUN		= 1 << 7,
    4.93 +	RAZOR_PROPERTY_POSTUN		= 1 << 8,
    4.94 +	RAZOR_PROPERTY_SCRIPT_MASK	=
    4.95 +		RAZOR_PROPERTY_PRE |
    4.96 +		RAZOR_PROPERTY_POST |
    4.97 +		RAZOR_PROPERTY_PREUN |
    4.98 +		RAZOR_PROPERTY_POSTUN
    4.99 +};
   4.100 +
   4.101 +enum razor_set_flags {
   4.102 +	/*
   4.103 +	 * Create a private copy of the razor set such that changes made
   4.104 +	 * to the underlying file are not visible in the razor set.
   4.105 +	 * If this flag is not set then the caller must ensure that the
   4.106 +	 * underlying file (if any) is not changed.
   4.107 +	 */
   4.108 +	RAZOR_SET_PRIVATE		= 1 << 0,
   4.109 +};
   4.110 +
   4.111 +/**
   4.112 + * SECTION:error
   4.113 + * @title: Error reporting
   4.114 + * @short_description: A system for reporting errors.
   4.115 + *
   4.116 + * This object represents an error condition.
   4.117 + */
   4.118 +struct razor_error;
   4.119 +
   4.120 +struct razor_error *razor_error_new_str(int domain, int code,
   4.121 +					const char *object, const char *str);
   4.122 +struct razor_error *razor_error_dup(struct razor_error *src,
   4.123 +				    const char *summary);
   4.124 +
   4.125 +#define razor_set_error(error, domain, code, object, str) \
   4.126 +	if (error) \
   4.127 +		*(error) = razor_error_new_str(domain, code, object, str); \
   4.128 +	else
   4.129 +
   4.130 +#define razor_propagate_error(dest, src, summary) \
   4.131 +	if (dest) \
   4.132 +		*(dest) = razor_error_dup(src, summary); \
   4.133 +	else
   4.134 +
   4.135 +#define RAZOR_ERROR_DOMAIN(i1,i2,i3,c) \
   4.136 +	(((i1)&0xff)<<24|((i2)&0xff)<<16|((i3)&0xff)<<8|(c)&0xff)
   4.137 +
   4.138 +#define RAZOR_GENERAL_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',0)
   4.139 +#define RAZOR_POSIX_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',1)
   4.140 +#define RAZOR_MSWIN_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',2)
   4.141 +#define RAZOR_ZLIB_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',3)
   4.142 +
   4.143 +enum razor_general_error {
   4.144 +	RAZOR_GENERAL_ERROR_FAILED,
   4.145 +	RAZOR_GENERAL_ERROR_DATABASE_CORRUPTED,
   4.146 +	RAZOR_GENERAL_ERROR_DATABASE_INCOMPATIBLE,
   4.147 +	RAZOR_GENERAL_ERROR_DATABASE_EXISTS,
   4.148 +	RAZOR_GENERAL_ERROR_DATABASE_LOCKED,
   4.149 +	RAZOR_GENERAL_ERROR_RPM_UNSUPPORTED,
   4.150 +};
   4.151 +
   4.152 +int razor_error_get_domain(struct razor_error *error);
   4.153 +int razor_error_get_code(struct razor_error *error);
   4.154 +const char *razor_error_get_object(struct razor_error *error);
   4.155 +const char *razor_error_get_primary_text(struct razor_error *error);
   4.156 +const char *razor_error_get_secondary_text(struct razor_error *error);
   4.157 +const char *razor_error_get_msg(struct razor_error *error);
   4.158 +void razor_error_free(struct razor_error *error);
   4.159 +
   4.160 +/**
   4.161 + * SECTION:atomic
   4.162 + * @title: Atomic transactions
   4.163 + * @short_description: File-based transactions that shouldn't half-succeed
   4.164 + *
   4.165 + * This is a helper object for issuing a sequence of file-based actions
   4.166 + * that should either all succeed or all fail.
   4.167 + *
   4.168 + * Note that currently only Windows 7 has a native implementation and that
   4.169 + * while the emulated fallback implementation attempts to rollback the
   4.170 + * transaction if it fails, this is not guaranteed to succeed and that
   4.171 + * the transaction is held in core (and thus vulnernable to program crashes,
   4.172 + * power loss, etc.). This could (and should) be improved.
   4.173 + *
   4.174 + * Atomic transactions can be disabled via configure, in which case all
   4.175 + * bets are off.
   4.176 + **/
   4.177 +
   4.178 +@RAZOR_HAVE_ATOMIC_ROLLBACK@
   4.179 +
   4.180 +struct razor_atomic;
   4.181 +
   4.182 +struct razor_atomic *razor_atomic_open(const char *description);
   4.183 +int razor_atomic_commit(struct razor_atomic *atomic);
   4.184 +struct razor_error *razor_atomic_get_error(struct razor_atomic *atomic);
   4.185 +const char *razor_atomic_get_error_msg(struct razor_atomic *atomic);
   4.186 +void razor_atomic_destroy(struct razor_atomic *atomic);
   4.187 +
   4.188 +/**
   4.189 + * razor_atomic_make_dirs
   4.190 + * 
   4.191 + * Create all sub-directories leading up to path. We know root exists
   4.192 + * and is a dir, root does not end in a '/', and path either has a
   4.193 + * leading '/' or (on MS-Windows only) root is the empty string
   4.194 + * and path starts with drive (eg., "c:/windows").
   4.195 + * Note: path itself is not created, only the directory in which it
   4.196 + * (would) exist.
   4.197 + *
   4.198 + * Returns: non-zero on error.
   4.199 + **/
   4.200 +int razor_atomic_make_dirs(struct razor_atomic *atomic, const char *root,
   4.201 +  const char *path);
   4.202 +int razor_atomic_remove(struct razor_atomic *atomic, const char *path);
   4.203 +int razor_atomic_rename_file(struct razor_atomic *atomic, const char *oldpath,
   4.204 +			     const char *newpath);
   4.205 +
   4.206 +/**
   4.207 + * razor_atomic_create_dir
   4.208 + * 
   4.209 + * Create a directory, replacing any existing object at this path except
   4.210 + * an existing directory (which is not counted as a error).
   4.211 + *
   4.212 + * Returns: non-zero on error.
   4.213 + */
   4.214 +int razor_atomic_create_dir(struct razor_atomic *atomic, const char *dirname,
   4.215 +  mode_t mode);
   4.216 +
   4.217 +/**
   4.218 + * razor_atomic_create_symlink
   4.219 + * 
   4.220 + * Create a symbolic link, replacing any existing object at this path except
   4.221 + * a non-empty directory.
   4.222 + *
   4.223 + * Note: This function will always fail on platforms that don't support
   4.224 + * symbolic links.
   4.225 + *
   4.226 + * Returns: non-zero on error.
   4.227 + */
   4.228 +int razor_atomic_create_symlink(struct razor_atomic *atomic, const char *target,
   4.229 +  const char *path);
   4.230 +/**
   4.231 + * razor_atomic_create_file
   4.232 + * 
   4.233 + * Create a file, replacing any existing object at this path except
   4.234 + * a non-empty directory.
   4.235 + *
   4.236 + * Returns: A handle to be passed to razor_atomic_write() and
   4.237 + * razor_atomic_close() or a negative value on error.
   4.238 + */
   4.239 +int razor_atomic_create_file(struct razor_atomic *atomic, const char *filename,
   4.240 +  mode_t mode);
   4.241 +int razor_atomic_write(struct razor_atomic *atomic, int handle,
   4.242 +  const void *data, size_t size);
   4.243 +int razor_atomic_close(struct razor_atomic *atomic, int handle);
   4.244 +int razor_atomic_sync(struct razor_atomic *atomic, int handle);
   4.245 +void razor_atomic_abort(struct razor_atomic *atomic, int domain, int code,
   4.246 +  const char *error_msg);
   4.247 +void razor_atomic_propagate_error(struct razor_atomic *atomic,
   4.248 +  struct razor_error *error, const char *summary);
   4.249 +int razor_atomic_in_error_state(struct razor_atomic *atomic);
   4.250 +
   4.251 +/**
   4.252 + * SECTION:set
   4.253 + * @title: Package Set
   4.254 + * @short_description: Represents a set of packages and their metadata.
   4.255 + *
   4.256 + * This object represents a set of packages, their dependency
   4.257 + * information, the file lists and a number of other details.
   4.258 + **/
   4.259 +
   4.260 +struct razor_set;
   4.261 +struct razor_package;
   4.262 +struct razor_property;
   4.263 +
   4.264 +#define RAZOR_HEADER_VERSION		2	/* Current version */
   4.265 +#define RAZOR_HEADER_VERSION_MIN	1	/* Minimum version we support */
   4.266 +
   4.267 +/**
   4.268 + * razor_set_create:
   4.269 + * 
   4.270 + * Create a new #razor_set object.
   4.271 + * 
   4.272 + * Returns: the new #razor_set object.
   4.273 + **/
   4.274 +struct razor_set *razor_set_create_without_root(void);
   4.275 +struct razor_set *razor_set_create(void);
   4.276 +struct razor_set *
   4.277 +razor_set_open(const char *filename, enum razor_set_flags flags,
   4.278 +	       struct razor_error **error);
   4.279 +uint32_t razor_set_get_header_version(struct razor_set *set);
   4.280 +int razor_set_set_header_version(struct razor_set *set,
   4.281 +				 uint32_t header_version);
   4.282 +void razor_set_unref(struct razor_set *set);
   4.283 +struct razor_set *razor_set_ref(struct razor_set *set);
   4.284 +void razor_set_write_to_handle(struct razor_set *set,
   4.285 +			       struct razor_atomic *atomic, int handle,
   4.286 +			       uint32_t section_mask);
   4.287 +int razor_set_write(struct razor_set *set, struct razor_atomic *atomic,
   4.288 +		    const char *filename, uint32_t setions);
   4.289 +int
   4.290 +razor_set_bind_sections(struct razor_set *set, const char *filename,
   4.291 +			enum razor_set_flags flags, struct razor_error **error);
   4.292 +
   4.293 +void
   4.294 +razor_package_get_details(struct razor_set *set,
   4.295 +			  struct razor_package *package, ...);
   4.296 +int
   4.297 +razor_package_remove(struct razor_set *prev, struct razor_set *next,
   4.298 +		     struct razor_atomic *atomic, struct razor_package *package,
   4.299 +		     const char *root, int install_count,
   4.300 +		     enum razor_stage_type stage);
   4.301 +
   4.302 +/**
   4.303 + * SECTION:iterator
   4.304 + * @title: Iterators
   4.305 + * @short_description: Objects for traversing packages or properties.
   4.306 + *
   4.307 + * The razor iterator objects provides a way to iterate through a set
   4.308 + * of packages or properties.
   4.309 + **/
   4.310 +
   4.311 +struct razor_package_iterator;
   4.312 +
   4.313 +/**
   4.314 + * razor_package_iterator_create:
   4.315 + * 
   4.316 + * Create a new #razor_package_iterator object.
   4.317 + * 
   4.318 + * Returns: the new #razor_package_iterator object.
   4.319 + **/
   4.320 +
   4.321 +struct razor_package_iterator *
   4.322 +razor_package_iterator_create(struct razor_set *set);
   4.323 +
   4.324 +/**
   4.325 + * razor_package_iterator_create_for_property:
   4.326 + * 
   4.327 + * Create a new #razor_package_iterator object for the packages that
   4.328 + * own the given property.
   4.329 + * 
   4.330 + * Returns: the new #razor_package_iterator object.
   4.331 + **/
   4.332 +struct razor_package_iterator *
   4.333 +razor_package_iterator_create_for_property(struct razor_set *set,
   4.334 +					   struct razor_property *property);
   4.335 +
   4.336 +/**
   4.337 + * razor_package_iterator_create_for_file:
   4.338 + *
   4.339 + * Create a new #razor_package_iterator object for the packages that
   4.340 + * contain the given file name.
   4.341 + *
   4.342 + * Returns: the new #razor_package_iterator object.
   4.343 + **/
   4.344 +struct razor_package_iterator *
   4.345 +razor_package_iterator_create_for_file(struct razor_set *set,
   4.346 +				       const char *filename);
   4.347 +
   4.348 +int razor_package_iterator_next(struct razor_package_iterator *pi,
   4.349 +				struct razor_package **package, ...);
   4.350 +void razor_package_iterator_destroy(struct razor_package_iterator *pi);
   4.351 +
   4.352 +struct razor_package_query *
   4.353 +razor_package_query_create(struct razor_set *set);
   4.354 +void
   4.355 +razor_package_query_add_package(struct razor_package_query *pq,
   4.356 +				struct razor_package *p);
   4.357 +void
   4.358 +razor_package_query_add_iterator(struct razor_package_query *pq,
   4.359 +				 struct razor_package_iterator *pi);
   4.360 +struct razor_package_iterator *
   4.361 +razor_package_query_finish(struct razor_package_query *pq);
   4.362 +
   4.363 +struct razor_property_iterator;
   4.364 +struct razor_property_iterator *
   4.365 +razor_property_iterator_create(struct razor_set *set,
   4.366 +			       struct razor_package *package);
   4.367 +int razor_property_iterator_next(struct razor_property_iterator *pi,
   4.368 +				 struct razor_property **property,
   4.369 +				 const char **name,
   4.370 +				 uint32_t *flags,
   4.371 +				 const char **version);
   4.372 +void
   4.373 +razor_property_iterator_destroy(struct razor_property_iterator *pi);
   4.374 +
   4.375 +struct razor_file_iterator;
   4.376 +struct razor_file_iterator *
   4.377 +razor_file_iterator_create(struct razor_set *set,
   4.378 +			   struct razor_package *package, int post_order);
   4.379 +int razor_file_iterator_next(struct razor_file_iterator *fi,
   4.380 +			     const char **name);
   4.381 +void razor_file_iterator_destroy(struct razor_file_iterator *fi);
   4.382 +
   4.383 +void razor_set_list_files(struct razor_set *set, const char *prefix);
   4.384 +void razor_set_list_package_files(struct razor_set *set,
   4.385 +				  struct razor_package *package);
   4.386 +
   4.387 +enum razor_diff_action {
   4.388 +	RAZOR_DIFF_ACTION_ADD,
   4.389 +	RAZOR_DIFF_ACTION_REMOVE,
   4.390 +};
   4.391 +
   4.392 +typedef void (*razor_diff_callback_t)(enum razor_diff_action action,
   4.393 +				      struct razor_package *package,
   4.394 +				      const char *name,
   4.395 +				      const char *version,
   4.396 +				      const char *arch,
   4.397 +				      void *data);
   4.398 +
   4.399 +void
   4.400 +razor_set_diff(struct razor_set *set, struct razor_set *upstream,
   4.401 +	       razor_diff_callback_t callback, void *data);
   4.402 +
   4.403 +struct razor_install_iterator;
   4.404 +
   4.405 +enum razor_install_action {
   4.406 +	RAZOR_INSTALL_ACTION_ADD,
   4.407 +	RAZOR_INSTALL_ACTION_REMOVE,
   4.408 +	RAZOR_INSTALL_ACTION_COMMIT
   4.409 +};
   4.410 +
   4.411 +struct razor_install_iterator *
   4.412 +razor_set_create_install_iterator(struct razor_set *set,
   4.413 +				  struct razor_set *next);
   4.414 +
   4.415 +int razor_install_iterator_next(struct razor_install_iterator *ii,
   4.416 +				struct razor_package **package,
   4.417 +				enum razor_install_action *action,
   4.418 +				int *count);
   4.419 +
   4.420 +/**
   4.421 + * razor_install_iterator_commit_set
   4.422 + *
   4.423 + * Immediately after razor_install_iterator_next() returns
   4.424 + * RAZOR_INSTALL_ACTION_COMMIT, this function will return the razor_set
   4.425 + * which should be committed.
   4.426 + *
   4.427 + * Returns: a new #razor_set object.
   4.428 + **/
   4.429 +struct razor_set *
   4.430 +razor_install_iterator_commit_set(struct razor_install_iterator *ii);
   4.431 +
   4.432 +void razor_install_iterator_rewind(struct razor_install_iterator *ii);
   4.433 +size_t razor_install_iterator_tell(struct razor_install_iterator *ii);
   4.434 +size_t razor_install_iterator_seek(struct razor_install_iterator *ii,
   4.435 +				   size_t pos);
   4.436 +void razor_install_iterator_destroy(struct razor_install_iterator *ii);
   4.437 +
   4.438 +/**
   4.439 + * SECTION:transaction
   4.440 + * @title: Transaction
   4.441 + * @short_description: Create a new package set by merging two or more sets.
   4.442 + *
   4.443 + * The razor transaction object provides a way to create a new package set
   4.444 + * from packages from one or more other package sets.
   4.445 + **/
   4.446 +
   4.447 +struct razor_rpm;
   4.448 +
   4.449 +struct razor_transaction *
   4.450 +razor_transaction_create(struct razor_set *system, struct razor_set *upstream);
   4.451 +void razor_transaction_install_package(struct razor_transaction *transaction,
   4.452 +				       struct razor_package *package);
   4.453 +void razor_transaction_remove_package(struct razor_transaction *transaction,
   4.454 +				      struct razor_package *package);
   4.455 +void razor_transaction_update_package(struct razor_transaction *trans,
   4.456 +				      struct razor_package *package);
   4.457 +void razor_transaction_fixup_package(struct razor_transaction *trans,
   4.458 +				     struct razor_package *package,
   4.459 +				     struct razor_rpm *rpm);
   4.460 +void razor_transaction_update_all(struct razor_transaction *transaction);
   4.461 +int razor_transaction_resolve(struct razor_transaction *trans);
   4.462 +
   4.463 +typedef void (*razor_unsatisfied_callback_t)(const char *requirement,
   4.464 +					     struct razor_package *package,
   4.465 +					     const char *name,
   4.466 +					     const char *version,
   4.467 +					     const char *arch,
   4.468 +					     void *data);
   4.469 +
   4.470 +int razor_transaction_unsatisfied(struct razor_transaction *trans,
   4.471 +				  razor_unsatisfied_callback_t callback,
   4.472 +				  void *data);
   4.473 +int razor_transaction_describe(struct razor_transaction *trans);
   4.474 +struct razor_set *razor_transaction_commit(struct razor_transaction *trans);
   4.475 +void razor_transaction_destroy(struct razor_transaction *trans);
   4.476 +
   4.477 +/* Temporary helper for test suite. */
   4.478 +int razor_transaction_unsatisfied_property(struct razor_transaction *trans,
   4.479 +					   const char *name,
   4.480 +					   uint32_t flags,
   4.481 +					   const char *version);
   4.482 +
   4.483 +/**
   4.484 + * SECTION:rpm
   4.485 + * @title: Razor RPM
   4.486 + * @short_description: Operating on RPM files.
   4.487 + *
   4.488 + * Functions for open RPM files and extracting information and
   4.489 + * installing or removing RPM files.
   4.490 + **/
   4.491 +
   4.492 +struct razor_relocations;
   4.493 +
   4.494 +struct razor_relocations *razor_relocations_create(void);
   4.495 +void razor_relocations_add(struct razor_relocations *relocations,
   4.496 +			   const char *oldpath, const char *newpath);
   4.497 +void razor_relocations_set_rpm(struct razor_relocations *relocations,
   4.498 +			       struct razor_rpm *rpm);
   4.499 +const char *razor_relocations_apply(struct razor_relocations *relocations,
   4.500 +				    const char *path);
   4.501 +void razor_relocations_destroy(struct razor_relocations *relocations);
   4.502 +
   4.503 +struct razor_rpm *razor_rpm_open(const char *filename,
   4.504 +				 struct razor_error **error);
   4.505 +void razor_rpm_get_details(struct razor_rpm *rpm, ...);
   4.506 +void razor_rpm_set_relocations(struct razor_rpm *rpm,
   4.507 +			       struct razor_relocations *relocations);
   4.508 +int razor_rpm_install(struct razor_rpm *rpm, struct razor_atomic *atomic,
   4.509 +		      const char *root, int install_count,
   4.510 +		      enum razor_stage_type stage);
   4.511 +int razor_rpm_close(struct razor_rpm *rpm);
   4.512 +
   4.513 +/**
   4.514 + * SECTION:importer
   4.515 + * @title: Importer
   4.516 + * @short_description: A mechanism for building #razor_set objects
   4.517 + *
   4.518 + * The %razor_importer is a helper object for building a razor set
   4.519 + * from external sources, like yum metadata, the RPM database or RPM
   4.520 + * files.
   4.521 + *
   4.522 + * The importer is a stateful object; it has the notion of a current
   4.523 + * package, and the caller can provide meta data such as properties,
   4.524 + * files and similiar for the package as it becomes available.  Once a
   4.525 + * package is fully described, the next pacakge can begin.  When all
   4.526 + * packages have been described to the importer, the importer will
   4.527 + * create a new %razor_set with the specified packages.
   4.528 + *
   4.529 + * A typical use
   4.530 + * of the importer will follow this template:
   4.531 + * |[
   4.532 + * importer = razor_importer_create();
   4.533 + *
   4.534 + * while ( /<!-- -->* more packages to import *<!-- -->/; ) {
   4.535 + *   /<!-- -->* get name, version and arch of next package *<!-- -->/
   4.536 + *   razor_importer_begin_package(importer, name, version, arch);
   4.537 + *   razor_importer_add_details(importer, summary, description, url, license);
   4.538 + *
   4.539 + *   while ( /<!-- -->* more properties to add *<!-- -->/ )
   4.540 + *     razor_importer_add_property(importer, name, flags, version);
   4.541 + *
   4.542 + *   while ( /<!-- -->* [more files to add *<!-- -->/ )
   4.543 + *     razor_importer_add_file(importer, name);
   4.544 + *
   4.545 + *   razor_importer_finish_package(importer);
   4.546 + * }
   4.547 + *
   4.548 + * return razor_importer_finish(importer);
   4.549 + * ]|
   4.550 + **/
   4.551 +struct razor_importer;
   4.552 +
   4.553 +struct razor_importer *razor_importer_create(void);
   4.554 +void razor_importer_destroy(struct razor_importer *importer);
   4.555 +void razor_importer_begin_package(struct razor_importer *importer,
   4.556 +				  const char *name,
   4.557 +				  const char *version,
   4.558 +				  const char *arch);
   4.559 +void razor_importer_add_details(struct razor_importer *importer,
   4.560 +				const char *summary,
   4.561 +				const char *description,
   4.562 +				const char *url,
   4.563 +				const char *license);
   4.564 +void razor_importer_add_script(struct razor_importer *importer,
   4.565 +			       enum razor_property_flags script,
   4.566 +			       const char *program,
   4.567 +			       const char *body);
   4.568 +void razor_importer_add_install_prefix(struct razor_importer *importer,
   4.569 +				       const char *install_prefix);
   4.570 +void razor_importer_add_property(struct razor_importer *importer,
   4.571 +				 const char *name,
   4.572 +				 uint32_t flags,
   4.573 +				 const char *version);
   4.574 +void razor_importer_add_file(struct razor_importer *importer,
   4.575 +			     const char *name);
   4.576 +void razor_importer_finish_package(struct razor_importer *importer);
   4.577 +
   4.578 +int razor_importer_add_rpm(struct razor_importer *importer,
   4.579 +			   struct razor_rpm *rpm);
   4.580 +
   4.581 +struct razor_set *razor_importer_finish(struct razor_importer *importer);
   4.582 +
   4.583 +struct razor_set *razor_set_create_from_yum(void);
   4.584 +struct razor_set *razor_set_create_from_rpmdb(void);
   4.585 +
   4.586 +/**
   4.587 + * SECTION:root
   4.588 + * @title: Root
   4.589 + * @short_description: Functions for accessing an install root.
   4.590 + *
   4.591 + * The #razor_root object encapsulate access to and locking of a razor
   4.592 + * install root.
   4.593 + **/
   4.594 +struct razor_root;
   4.595 +
   4.596 +const char *razor_get_database_path();
   4.597 +void razor_set_database_path(const char *database_path);
   4.598 +int razor_root_create(const char *root, struct razor_error **error);
   4.599 +struct razor_root *
   4.600 +razor_root_open(const char *root, struct razor_error **error);
   4.601 +struct razor_set *
   4.602 +razor_root_open_read_only(const char *root, struct razor_error **error);
   4.603 +struct razor_set *razor_root_get_system_set(struct razor_root *root);
   4.604 +int razor_root_close(struct razor_root *root);
   4.605 +int
   4.606 +razor_root_update(struct razor_root *root, struct razor_set *next,
   4.607 +		  struct razor_atomic *atomic);
   4.608 +
   4.609 +/**
   4.610 + * SECTION:misc
   4.611 + * @title: Miscellaneous Functions
   4.612 + * @short_description: Various helper functions
   4.613 + *
   4.614 + * Functions that doesn't fit anywhere else.
   4.615 + **/
   4.616 +
   4.617 +const char *
   4.618 +razor_property_relation_to_string(struct razor_property *p);
   4.619 +const char *
   4.620 +razor_property_type_to_string(struct razor_property *p);
   4.621 +
   4.622 +void razor_build_evr(char *evr_buf, int size, const char *epoch,
   4.623 +		     const char *version, const char *release);
   4.624 +int razor_versioncmp(const char *s1, const char *s2);
   4.625 +
   4.626 +void razor_disable_root_name_checks(int disable);
   4.627 +
   4.628 +void razor_set_lua_loader(const char *modname, void (*loader)());
   4.629 +void (*razor_get_lua_loader(const char *modname))();
   4.630 +
   4.631 +char *razor_concat(const char *s, ...) RAZOR_MALLOC RAZOR_NULL_TERMINATED;
   4.632 +
   4.633 +char *razor_path_add_root(const char *path, const char *root) RAZOR_MALLOC;
   4.634 +
   4.635 +const char *razor_system_arch(void);
   4.636 +
   4.637 +#endif /* _RAZOR_H_ */