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