librazor/razor.h.in
author J. Ali Harlow <ali@juiblex.co.uk>
Thu Oct 09 17:27:41 2014 +0100 (2014-10-09)
changeset 455 df914f383f5c
child 457 51a084acef49
permissions -rw-r--r--
Support downloading from local repository even without libcurl

Using the --url option of the razor executable, it is possible
to specify a yum repository on the local machine (eg., on installation
media) and import from there, eg.,:

C> razor --url file:///d:/ import-yum

This will be handled by libcurl if available but if not, an internal
copy routine will be used.

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