librazor/razor.h.in
author J. Ali Harlow <ali@juiblex.co.uk>
Fri Apr 15 16:57:55 2016 +0100 (2016-04-15)
changeset 468 45e2bb06c88d
parent 457 51a084acef49
child 475 008c75a5e08d
permissions -rw-r--r--
Support expat v2.1
     1 /*
     2  * Copyright (C) 2008  Kristian Høgsberg <krh@redhat.com>
     3  * Copyright (C) 2008  Red Hat, Inc
     4  * Copyright (C) 2009, 2011, 2012, 2014  J. Ali Harlow <ali@juiblex.co.uk>
     5  *
     6  * This program is free software; you can redistribute it and/or modify
     7  * it under the terms of the GNU General Public License as published by
     8  * the Free Software Foundation; either version 2 of the License, or
     9  * (at your option) any later version.
    10  *
    11  * This program is distributed in the hope that it will be useful,
    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  * GNU General Public License for more details.
    15  *
    16  * You should have received a copy of the GNU General Public License along
    17  * with this program; if not, write to the Free Software Foundation, Inc.,
    18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    19  */
    20 
    21 #ifndef _RAZOR_H_
    22 #define _RAZOR_H_
    23 
    24 #include <stdio.h>
    25 #include <stdint.h>
    26 #include <sys/types.h>
    27 
    28 /* GCC extensions */
    29 #if defined(__GNUC__)
    30 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
    31 #define RAZOR_MALLOC __attribute__((__malloc__))
    32 #else
    33 #define RAZOR_MALLOC
    34 #endif
    35 #if __GNUC__ >= 4
    36 #define RAZOR_NULL_TERMINATED __attribute__ ((__sentinel__))
    37 #else
    38 #define RAZOR_NULL_TERMINATED
    39 #endif
    40 #endif	/* __GNUC__ */
    41 
    42 enum razor_section_type {
    43 	RAZOR_SECTION_MAIN = 0x01,
    44 	RAZOR_SECTION_DETAILS = 0x02,
    45 	RAZOR_SECTION_FILES = 0x04,
    46 	RAZOR_SECTION_ALL = 0x07
    47 };
    48 
    49 enum razor_stage_type {
    50 	RAZOR_STAGE_SCRIPTS_PRE = 0x1,
    51 	RAZOR_STAGE_FILES = 0x2,
    52 	RAZOR_STAGE_SCRIPTS_POST = 0x4,
    53 	RAZOR_STAGE_SCRIPTS = 0x5,
    54 	RAZOR_STAGE_ALL = 0x7
    55 };
    56 
    57 enum razor_detail_type {
    58 	RAZOR_DETAIL_LAST = 0,	/* the sentinel */
    59 	RAZOR_DETAIL_NAME,
    60 	RAZOR_DETAIL_VERSION,
    61 	RAZOR_DETAIL_ARCH,
    62 	RAZOR_DETAIL_SUMMARY,
    63 	RAZOR_DETAIL_DESCRIPTION,
    64 	RAZOR_DETAIL_URL,
    65 	RAZOR_DETAIL_LICENSE,
    66 	RAZOR_DETAIL_PREUNPROG,
    67 	RAZOR_DETAIL_PREUN,
    68 	RAZOR_DETAIL_POSTUNPROG,
    69 	RAZOR_DETAIL_POSTUN,
    70 	RAZOR_DETAIL_PREFIXES
    71 };
    72 
    73 enum razor_property_flags {
    74 	RAZOR_PROPERTY_LESS		= 1 << 0,
    75 	RAZOR_PROPERTY_GREATER		= 1 << 1,
    76 	RAZOR_PROPERTY_EQUAL		= 1 << 2,
    77 	RAZOR_PROPERTY_RELATION_MASK	=
    78 		RAZOR_PROPERTY_LESS |
    79 		RAZOR_PROPERTY_GREATER |
    80 		RAZOR_PROPERTY_EQUAL,
    81 
    82 	RAZOR_PROPERTY_REQUIRES		= 0 << 3,
    83 	RAZOR_PROPERTY_PROVIDES		= 1 << 3,
    84 	RAZOR_PROPERTY_CONFLICTS	= 2 << 3,
    85 	RAZOR_PROPERTY_OBSOLETES	= 3 << 3,
    86 	RAZOR_PROPERTY_TYPE_MASK	= 3 << 3,
    87 		
    88 	RAZOR_PROPERTY_PRE		= 1 << 5,
    89 	RAZOR_PROPERTY_POST		= 1 << 6,
    90 	RAZOR_PROPERTY_PREUN		= 1 << 7,
    91 	RAZOR_PROPERTY_POSTUN		= 1 << 8,
    92 	RAZOR_PROPERTY_SCRIPT_MASK	=
    93 		RAZOR_PROPERTY_PRE |
    94 		RAZOR_PROPERTY_POST |
    95 		RAZOR_PROPERTY_PREUN |
    96 		RAZOR_PROPERTY_POSTUN
    97 };
    98 
    99 enum razor_set_flags {
   100 	/*
   101 	 * Create a private copy of the razor set such that changes made
   102 	 * to the underlying file are not visible in the razor set.
   103 	 * If this flag is not set then the caller must ensure that the
   104 	 * underlying file (if any) is not changed.
   105 	 */
   106 	RAZOR_SET_PRIVATE		= 1 << 0,
   107 };
   108 
   109 /**
   110  * SECTION:error
   111  * @title: Error reporting
   112  * @short_description: A system for reporting errors.
   113  *
   114  * This object represents an error condition.
   115  */
   116 struct razor_error;
   117 
   118 struct razor_error *razor_error_new_str(int domain, int code,
   119 					const char *object, const char *str);
   120 struct razor_error *razor_error_dup(struct razor_error *src,
   121 				    const char *summary);
   122 
   123 #define razor_set_error(error, domain, code, object, str) \
   124 	if (error) \
   125 		*(error) = razor_error_new_str(domain, code, object, str); \
   126 	else
   127 
   128 #define razor_propagate_error(dest, src, summary) \
   129 	if (dest) \
   130 		*(dest) = razor_error_dup(src, summary); \
   131 	else
   132 
   133 #define RAZOR_ERROR_DOMAIN(i1,i2,i3,c) \
   134 	(((i1)&0xff)<<24|((i2)&0xff)<<16|((i3)&0xff)<<8|(c)&0xff)
   135 
   136 #define RAZOR_GENERAL_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',0)
   137 #define RAZOR_POSIX_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',1)
   138 #define RAZOR_MSWIN_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',2)
   139 #define RAZOR_ZLIB_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',3)
   140 
   141 enum razor_general_error {
   142 	RAZOR_GENERAL_ERROR_FAILED,
   143 	RAZOR_GENERAL_ERROR_DATABASE_CORRUPTED,
   144 	RAZOR_GENERAL_ERROR_DATABASE_INCOMPATIBLE,
   145 	RAZOR_GENERAL_ERROR_DATABASE_EXISTS,
   146 	RAZOR_GENERAL_ERROR_DATABASE_LOCKED,
   147 	RAZOR_GENERAL_ERROR_RPM_UNSUPPORTED,
   148 };
   149 
   150 int razor_error_get_domain(struct razor_error *error);
   151 int razor_error_get_code(struct razor_error *error);
   152 const char *razor_error_get_object(struct razor_error *error);
   153 const char *razor_error_get_primary_text(struct razor_error *error);
   154 const char *razor_error_get_secondary_text(struct razor_error *error);
   155 const char *razor_error_get_msg(struct razor_error *error);
   156 void razor_error_free(struct razor_error *error);
   157 
   158 /**
   159  * SECTION:atomic
   160  * @title: Atomic transactions
   161  * @short_description: File-based transactions that shouldn't half-succeed
   162  *
   163  * This is a helper object for issuing a sequence of file-based actions
   164  * that should either all succeed or all fail.
   165  *
   166  * Note that currently only Windows 7 has a native implementation and that
   167  * while the emulated fallback implementation attempts to rollback the
   168  * transaction if it fails, this is not guaranteed to succeed and that
   169  * the transaction is held in core (and thus vulnernable to program crashes,
   170  * power loss, etc.). This could (and should) be improved.
   171  *
   172  * Atomic transactions can be disabled via configure, in which case all
   173  * bets are off.
   174  **/
   175 
   176 @RAZOR_HAVE_ATOMIC_ROLLBACK@
   177 
   178 struct razor_atomic;
   179 
   180 struct razor_atomic *razor_atomic_open(const char *description);
   181 int razor_atomic_commit(struct razor_atomic *atomic);
   182 struct razor_error *razor_atomic_get_error(struct razor_atomic *atomic);
   183 const char *razor_atomic_get_error_msg(struct razor_atomic *atomic);
   184 void razor_atomic_destroy(struct razor_atomic *atomic);
   185 
   186 /**
   187  * razor_atomic_make_dirs
   188  * 
   189  * Create all sub-directories leading up to path. We know root exists
   190  * and is a dir, root does not end in a '/', and path either has a
   191  * leading '/' or (on MS-Windows only) root is the empty string
   192  * and path starts with drive (eg., "c:/windows").
   193  * Note: path itself is not created, only the directory in which it
   194  * (would) exist.
   195  *
   196  * Returns: non-zero on error.
   197  **/
   198 int razor_atomic_make_dirs(struct razor_atomic *atomic, const char *root,
   199   const char *path);
   200 int razor_atomic_remove(struct razor_atomic *atomic, const char *path);
   201 int razor_atomic_rename_file(struct razor_atomic *atomic, const char *oldpath,
   202 			     const char *newpath);
   203 
   204 /**
   205  * razor_atomic_create_dir
   206  * 
   207  * Create a directory, replacing any existing object at this path except
   208  * an existing directory (which is not counted as a error).
   209  *
   210  * Returns: non-zero on error.
   211  */
   212 int razor_atomic_create_dir(struct razor_atomic *atomic, const char *dirname,
   213   mode_t mode);
   214 
   215 /**
   216  * razor_atomic_create_symlink
   217  * 
   218  * Create a symbolic link, replacing any existing object at this path except
   219  * a non-empty directory.
   220  *
   221  * Note: This function will always fail on platforms that don't support
   222  * symbolic links.
   223  *
   224  * Returns: non-zero on error.
   225  */
   226 int razor_atomic_create_symlink(struct razor_atomic *atomic, const char *target,
   227   const char *path);
   228 /**
   229  * razor_atomic_create_file
   230  * 
   231  * Create a file, replacing any existing object at this path except
   232  * a non-empty directory.
   233  *
   234  * Returns: A handle to be passed to razor_atomic_write() and
   235  * razor_atomic_close() or a negative value on error.
   236  */
   237 int razor_atomic_create_file(struct razor_atomic *atomic, const char *filename,
   238   mode_t mode);
   239 int razor_atomic_write(struct razor_atomic *atomic, int handle,
   240   const void *data, size_t size);
   241 int razor_atomic_close(struct razor_atomic *atomic, int handle);
   242 int razor_atomic_sync(struct razor_atomic *atomic, int handle);
   243 void razor_atomic_abort(struct razor_atomic *atomic, int domain, int code,
   244   const char *error_msg);
   245 void razor_atomic_propagate_error(struct razor_atomic *atomic,
   246   struct razor_error *error, const char *summary);
   247 int razor_atomic_in_error_state(struct razor_atomic *atomic);
   248 
   249 /**
   250  * SECTION:set
   251  * @title: Package Set
   252  * @short_description: Represents a set of packages and their metadata.
   253  *
   254  * This object represents a set of packages, their dependency
   255  * information, the file lists and a number of other details.
   256  **/
   257 
   258 struct razor_set;
   259 struct razor_package;
   260 struct razor_property;
   261 
   262 #define RAZOR_HEADER_VERSION		2	/* Current version */
   263 #define RAZOR_HEADER_VERSION_MIN	1	/* Minimum version we support */
   264 
   265 /**
   266  * razor_set_create:
   267  * 
   268  * Create a new #razor_set object.
   269  * 
   270  * Returns: the new #razor_set object.
   271  **/
   272 struct razor_set *razor_set_create_without_root(void);
   273 struct razor_set *razor_set_create(void);
   274 struct razor_set *
   275 razor_set_open(const char *filename, enum razor_set_flags flags,
   276 	       struct razor_error **error);
   277 uint32_t razor_set_get_header_version(struct razor_set *set);
   278 int razor_set_set_header_version(struct razor_set *set,
   279 				 uint32_t header_version);
   280 void razor_set_unref(struct razor_set *set);
   281 struct razor_set *razor_set_ref(struct razor_set *set);
   282 void razor_set_write_to_handle(struct razor_set *set,
   283 			       struct razor_atomic *atomic, int handle,
   284 			       uint32_t section_mask);
   285 int razor_set_write(struct razor_set *set, struct razor_atomic *atomic,
   286 		    const char *filename, uint32_t setions);
   287 int
   288 razor_set_bind_sections(struct razor_set *set, const char *filename,
   289 			enum razor_set_flags flags, struct razor_error **error);
   290 
   291 void
   292 razor_package_get_details(struct razor_set *set,
   293 			  struct razor_package *package, ...);
   294 int
   295 razor_package_remove(struct razor_set *prev, struct razor_set *next,
   296 		     struct razor_atomic *atomic, struct razor_package *package,
   297 		     const char *root, int install_count,
   298 		     enum razor_stage_type stage);
   299 
   300 /**
   301  * SECTION:iterator
   302  * @title: Iterators
   303  * @short_description: Objects for traversing packages or properties.
   304  *
   305  * The razor iterator objects provides a way to iterate through a set
   306  * of packages or properties.
   307  **/
   308 
   309 struct razor_package_iterator;
   310 
   311 /**
   312  * razor_package_iterator_create:
   313  * 
   314  * Create a new #razor_package_iterator object.
   315  * 
   316  * Returns: the new #razor_package_iterator object.
   317  **/
   318 
   319 struct razor_package_iterator *
   320 razor_package_iterator_create(struct razor_set *set);
   321 
   322 /**
   323  * razor_package_iterator_create_for_property:
   324  * 
   325  * Create a new #razor_package_iterator object for the packages that
   326  * own the given property.
   327  * 
   328  * Returns: the new #razor_package_iterator object.
   329  **/
   330 struct razor_package_iterator *
   331 razor_package_iterator_create_for_property(struct razor_set *set,
   332 					   struct razor_property *property);
   333 
   334 /**
   335  * razor_package_iterator_create_for_file:
   336  *
   337  * Create a new #razor_package_iterator object for the packages that
   338  * contain the given file name.
   339  *
   340  * Returns: the new #razor_package_iterator object.
   341  **/
   342 struct razor_package_iterator *
   343 razor_package_iterator_create_for_file(struct razor_set *set,
   344 				       const char *filename);
   345 
   346 int razor_package_iterator_next(struct razor_package_iterator *pi,
   347 				struct razor_package **package, ...);
   348 void razor_package_iterator_destroy(struct razor_package_iterator *pi);
   349 
   350 struct razor_package_query *
   351 razor_package_query_create(struct razor_set *set);
   352 void
   353 razor_package_query_add_package(struct razor_package_query *pq,
   354 				struct razor_package *p);
   355 void
   356 razor_package_query_add_iterator(struct razor_package_query *pq,
   357 				 struct razor_package_iterator *pi);
   358 struct razor_package_iterator *
   359 razor_package_query_finish(struct razor_package_query *pq);
   360 
   361 struct razor_property_iterator;
   362 struct razor_property_iterator *
   363 razor_property_iterator_create(struct razor_set *set,
   364 			       struct razor_package *package);
   365 int razor_property_iterator_next(struct razor_property_iterator *pi,
   366 				 struct razor_property **property,
   367 				 const char **name,
   368 				 uint32_t *flags,
   369 				 const char **version);
   370 void
   371 razor_property_iterator_destroy(struct razor_property_iterator *pi);
   372 
   373 struct razor_file_iterator;
   374 struct razor_file_iterator *
   375 razor_file_iterator_create(struct razor_set *set,
   376 			   struct razor_package *package, int post_order);
   377 int razor_file_iterator_next(struct razor_file_iterator *fi,
   378 			     const char **name);
   379 void razor_file_iterator_destroy(struct razor_file_iterator *fi);
   380 
   381 void razor_set_list_files(struct razor_set *set, const char *prefix);
   382 void razor_set_list_package_files(struct razor_set *set,
   383 				  struct razor_package *package);
   384 
   385 struct razor_string_iterator;
   386 struct razor_string_iterator *
   387 razor_install_prefix_iterator_create(struct razor_set *set,
   388 				     struct razor_package *package);
   389 int razor_string_iterator_next(struct razor_string_iterator *si,
   390 			       const char **string);
   391 void razor_string_iterator_destroy(struct razor_string_iterator *si);
   392 
   393 enum razor_diff_action {
   394 	RAZOR_DIFF_ACTION_ADD,
   395 	RAZOR_DIFF_ACTION_REMOVE,
   396 };
   397 
   398 typedef void (*razor_diff_callback_t)(enum razor_diff_action action,
   399 				      struct razor_package *package,
   400 				      const char *name,
   401 				      const char *version,
   402 				      const char *arch,
   403 				      void *data);
   404 
   405 void
   406 razor_set_diff(struct razor_set *set, struct razor_set *upstream,
   407 	       razor_diff_callback_t callback, void *data);
   408 
   409 struct razor_install_iterator;
   410 
   411 enum razor_install_action {
   412 	RAZOR_INSTALL_ACTION_ADD,
   413 	RAZOR_INSTALL_ACTION_REMOVE,
   414 	RAZOR_INSTALL_ACTION_COMMIT
   415 };
   416 
   417 struct razor_install_iterator *
   418 razor_set_create_install_iterator(struct razor_set *set,
   419 				  struct razor_set *next);
   420 
   421 int razor_install_iterator_next(struct razor_install_iterator *ii,
   422 				struct razor_package **package,
   423 				enum razor_install_action *action,
   424 				int *count);
   425 
   426 /**
   427  * razor_install_iterator_commit_set
   428  *
   429  * Immediately after razor_install_iterator_next() returns
   430  * RAZOR_INSTALL_ACTION_COMMIT, this function will return the razor_set
   431  * which should be committed.
   432  *
   433  * Returns: a new #razor_set object.
   434  **/
   435 struct razor_set *
   436 razor_install_iterator_commit_set(struct razor_install_iterator *ii);
   437 
   438 void razor_install_iterator_rewind(struct razor_install_iterator *ii);
   439 size_t razor_install_iterator_tell(struct razor_install_iterator *ii);
   440 size_t razor_install_iterator_seek(struct razor_install_iterator *ii,
   441 				   size_t pos);
   442 void razor_install_iterator_destroy(struct razor_install_iterator *ii);
   443 
   444 /**
   445  * SECTION:transaction
   446  * @title: Transaction
   447  * @short_description: Create a new package set by merging two or more sets.
   448  *
   449  * The razor transaction object provides a way to create a new package set
   450  * from packages from one or more other package sets.
   451  **/
   452 
   453 struct razor_rpm;
   454 
   455 struct razor_transaction *
   456 razor_transaction_create(struct razor_set *system, struct razor_set *upstream);
   457 void razor_transaction_install_package(struct razor_transaction *transaction,
   458 				       struct razor_package *package);
   459 void razor_transaction_remove_package(struct razor_transaction *transaction,
   460 				      struct razor_package *package);
   461 void razor_transaction_update_package(struct razor_transaction *trans,
   462 				      struct razor_package *package);
   463 void razor_transaction_fixup_package(struct razor_transaction *trans,
   464 				     struct razor_package *package,
   465 				     struct razor_rpm *rpm);
   466 void razor_transaction_update_all(struct razor_transaction *transaction);
   467 int razor_transaction_resolve(struct razor_transaction *trans);
   468 
   469 typedef void (*razor_unsatisfied_callback_t)(const char *requirement,
   470 					     struct razor_package *package,
   471 					     const char *name,
   472 					     const char *version,
   473 					     const char *arch,
   474 					     void *data);
   475 
   476 int razor_transaction_unsatisfied(struct razor_transaction *trans,
   477 				  razor_unsatisfied_callback_t callback,
   478 				  void *data);
   479 int razor_transaction_describe(struct razor_transaction *trans);
   480 struct razor_set *razor_transaction_commit(struct razor_transaction *trans);
   481 void razor_transaction_destroy(struct razor_transaction *trans);
   482 
   483 /* Temporary helper for test suite. */
   484 int razor_transaction_unsatisfied_property(struct razor_transaction *trans,
   485 					   const char *name,
   486 					   uint32_t flags,
   487 					   const char *version);
   488 
   489 /**
   490  * SECTION:rpm
   491  * @title: Razor RPM
   492  * @short_description: Operating on RPM files.
   493  *
   494  * Functions for open RPM files and extracting information and
   495  * installing or removing RPM files.
   496  **/
   497 
   498 struct razor_relocations;
   499 
   500 struct razor_relocations *razor_relocations_create(void);
   501 void razor_relocations_add(struct razor_relocations *relocations,
   502 			   const char *oldpath, const char *newpath);
   503 void razor_relocations_set_rpm(struct razor_relocations *relocations,
   504 			       struct razor_rpm *rpm);
   505 const char *razor_relocations_apply(struct razor_relocations *relocations,
   506 				    const char *path);
   507 void razor_relocations_destroy(struct razor_relocations *relocations);
   508 
   509 struct razor_rpm *razor_rpm_open(const char *filename,
   510 				 struct razor_error **error);
   511 void razor_rpm_get_details(struct razor_rpm *rpm, ...);
   512 void razor_rpm_set_relocations(struct razor_rpm *rpm,
   513 			       struct razor_relocations *relocations);
   514 int razor_rpm_install(struct razor_rpm *rpm, struct razor_atomic *atomic,
   515 		      const char *root, int install_count,
   516 		      enum razor_stage_type stage);
   517 int razor_rpm_close(struct razor_rpm *rpm);
   518 
   519 /**
   520  * SECTION:importer
   521  * @title: Importer
   522  * @short_description: A mechanism for building #razor_set objects
   523  *
   524  * The %razor_importer is a helper object for building a razor set
   525  * from external sources, like yum metadata, the RPM database or RPM
   526  * files.
   527  *
   528  * The importer is a stateful object; it has the notion of a current
   529  * package, and the caller can provide meta data such as properties,
   530  * files and similiar for the package as it becomes available.  Once a
   531  * package is fully described, the next pacakge can begin.  When all
   532  * packages have been described to the importer, the importer will
   533  * create a new %razor_set with the specified packages.
   534  *
   535  * A typical use
   536  * of the importer will follow this template:
   537  * |[
   538  * importer = razor_importer_create();
   539  *
   540  * while ( /<!-- -->* more packages to import *<!-- -->/; ) {
   541  *   /<!-- -->* get name, version and arch of next package *<!-- -->/
   542  *   razor_importer_begin_package(importer, name, version, arch);
   543  *   razor_importer_add_details(importer, summary, description, url, license);
   544  *
   545  *   while ( /<!-- -->* more properties to add *<!-- -->/ )
   546  *     razor_importer_add_property(importer, name, flags, version);
   547  *
   548  *   while ( /<!-- -->* [more files to add *<!-- -->/ )
   549  *     razor_importer_add_file(importer, name);
   550  *
   551  *   razor_importer_finish_package(importer);
   552  * }
   553  *
   554  * return razor_importer_finish(importer);
   555  * ]|
   556  **/
   557 struct razor_importer;
   558 
   559 struct razor_importer *razor_importer_create(void);
   560 void razor_importer_destroy(struct razor_importer *importer);
   561 void razor_importer_begin_package(struct razor_importer *importer,
   562 				  const char *name,
   563 				  const char *version,
   564 				  const char *arch);
   565 void razor_importer_add_details(struct razor_importer *importer,
   566 				const char *summary,
   567 				const char *description,
   568 				const char *url,
   569 				const char *license);
   570 void razor_importer_add_script(struct razor_importer *importer,
   571 			       enum razor_property_flags script,
   572 			       const char *program,
   573 			       const char *body);
   574 void razor_importer_add_install_prefix(struct razor_importer *importer,
   575 				       const char *install_prefix);
   576 void razor_importer_add_property(struct razor_importer *importer,
   577 				 const char *name,
   578 				 uint32_t flags,
   579 				 const char *version);
   580 void razor_importer_add_file(struct razor_importer *importer,
   581 			     const char *name);
   582 void razor_importer_finish_package(struct razor_importer *importer);
   583 
   584 int razor_importer_add_rpm(struct razor_importer *importer,
   585 			   struct razor_rpm *rpm);
   586 
   587 struct razor_set *razor_importer_finish(struct razor_importer *importer);
   588 
   589 struct razor_set *razor_set_create_from_yum(void);
   590 struct razor_set *razor_set_create_from_rpmdb(void);
   591 
   592 /**
   593  * SECTION:root
   594  * @title: Root
   595  * @short_description: Functions for accessing an install root.
   596  *
   597  * The #razor_root object encapsulate access to and locking of a razor
   598  * install root.
   599  **/
   600 struct razor_root;
   601 
   602 const char *razor_get_database_path();
   603 void razor_set_database_path(const char *database_path);
   604 int razor_root_create(const char *root, struct razor_error **error);
   605 struct razor_root *
   606 razor_root_open(const char *root, struct razor_error **error);
   607 struct razor_set *
   608 razor_root_open_read_only(const char *root, struct razor_error **error);
   609 struct razor_set *razor_root_get_system_set(struct razor_root *root);
   610 int razor_root_close(struct razor_root *root);
   611 int
   612 razor_root_update(struct razor_root *root, struct razor_set *next,
   613 		  struct razor_atomic *atomic);
   614 
   615 /**
   616  * SECTION:misc
   617  * @title: Miscellaneous Functions
   618  * @short_description: Various helper functions
   619  *
   620  * Functions that doesn't fit anywhere else.
   621  **/
   622 
   623 const char *
   624 razor_property_relation_to_string(struct razor_property *p);
   625 const char *
   626 razor_property_type_to_string(struct razor_property *p);
   627 
   628 void razor_build_evr(char *evr_buf, int size, const char *epoch,
   629 		     const char *version, const char *release);
   630 int razor_versioncmp(const char *s1, const char *s2);
   631 
   632 void razor_disable_root_name_checks(int disable);
   633 
   634 void razor_set_lua_loader(const char *modname, void (*loader)());
   635 void (*razor_get_lua_loader(const char *modname))();
   636 
   637 char *razor_concat(const char *s, ...) RAZOR_MALLOC RAZOR_NULL_TERMINATED;
   638 
   639 char *razor_path_add_root(const char *path, const char *root) RAZOR_MALLOC;
   640 char *razor_path_from_url(const char *url) RAZOR_MALLOC;
   641 
   642 const char *razor_system_arch(void);
   643 
   644 int razor_dump_database(FILE *fp, const char *root, const char *filename,
   645 			struct razor_error **error);
   646 
   647 #endif /* _RAZOR_H_ */