librazor/razor.h
author J. Ali Harlow <ali@juiblex.co.uk>
Sat Aug 23 11:13:48 2014 +0100 (2014-08-23)
changeset 440 48204dea0b9f
parent 426 2e896ad9754b
child 441 cf499fd51df7
permissions -rw-r--r--
Remove INTLLIBS from librazor_la_LIBADD.

This partially reverts 611c84a3f4b4538a65d186050608c17adbf17770.
It's not clear what motivated the initial inclusion of INTLLIBS
here since the net effect is only seen in librazor.la and not
in razor.pc and librazor.la is not normally packaged. Certainly
neither the static nor the dynamic versions of librazor currently
use libintl. At best this would cause the linker to search a
static libintl for undefined symbols without finding any; at worse
it causes a static build of plover using librazor.la to fail if
no static version of libintl is installed.
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@418
     4
 * Copyright (C) 2009, 2011, 2012  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
ali@424
    98
enum razor_set_flags {
ali@424
    99
	/*
ali@424
   100
	 * Create a private copy of the razor set such that changes made
ali@424
   101
	 * to the underlying file are not visible in the razor set.
ali@424
   102
	 * If this flag is not set then the caller must ensure that the
ali@424
   103
	 * underlying file (if any) is not changed.
ali@424
   104
	 */
ali@424
   105
	RAZOR_SET_PRIVATE		= 1 << 0,
ali@424
   106
};
ali@424
   107
krh@262
   108
/**
ali@423
   109
 * SECTION:error
ali@423
   110
 * @title: Error reporting
ali@423
   111
 * @short_description: A system for reporting errors.
ali@423
   112
 *
ali@423
   113
 * This object represents an error condition.
ali@423
   114
 */
ali@423
   115
struct razor_error;
ali@423
   116
ali@424
   117
struct razor_error *razor_error_new_str(const char *path, const char *str);
ali@439
   118
struct razor_error *razor_error_dup(struct razor_error *src,
ali@439
   119
				    const char *summary);
ali@424
   120
ali@424
   121
#define razor_set_error(error, path, str) \
ali@424
   122
	if (error) \
ali@424
   123
		*(error) = razor_error_new_str(path, str); \
ali@424
   124
	else
ali@424
   125
ali@439
   126
#define razor_propagate_error(dest, src, summary) \
ali@439
   127
	if (dest) \
ali@439
   128
		*(dest) = razor_error_dup(src, summary); \
ali@439
   129
	else
ali@439
   130
ali@439
   131
const char *razor_error_get_primary_text(struct razor_error *error);
ali@439
   132
const char *razor_error_get_secondary_text(struct razor_error *error);
ali@423
   133
const char *razor_error_get_msg(struct razor_error *error);
ali@423
   134
void razor_error_free(struct razor_error *error);
ali@423
   135
ali@423
   136
/**
ali@403
   137
 * SECTION:atomic
ali@403
   138
 * @title: Atomic transactions
ali@403
   139
 * @short_description: File-based transactions that shouldn't half-succeed
ali@403
   140
 *
ali@403
   141
 * This is a helper object for issuing a sequence of file-based actions
ali@403
   142
 * that should either all succeed or all fail.
ali@403
   143
 *
ali@403
   144
 * Note that currently only Windows 7 has a native implementation and that
ali@416
   145
 * while the emulated fallback implementation attempts to rollback the
ali@416
   146
 * transaction if it fails, this is not guaranteed to succeed and that
ali@416
   147
 * the transaction is held in core (and thus vulnernable to program crashes,
ali@416
   148
 * power loss, etc.). This could (and should) be improved.
ali@416
   149
 *
ali@416
   150
 * Atomic transactions can be disabled via configure, in which case all
ali@416
   151
 * bets are off.
ali@403
   152
 **/
ali@403
   153
struct razor_atomic;
ali@403
   154
ali@403
   155
struct razor_atomic *razor_atomic_open(const char *description);
ali@403
   156
int razor_atomic_commit(struct razor_atomic *atomic);
ali@439
   157
struct razor_error *razor_atomic_get_error(struct razor_atomic *atomic);
ali@403
   158
const char *razor_atomic_get_error_msg(struct razor_atomic *atomic);
ali@403
   159
void razor_atomic_destroy(struct razor_atomic *atomic);
ali@403
   160
ali@403
   161
/**
ali@403
   162
 * razor_atomic_make_dirs
ali@403
   163
 * 
ali@403
   164
 * Create all sub-directories leading up to path. We know root exists
ali@403
   165
 * and is a dir, root does not end in a '/', and path either has a
ali@403
   166
 * leading '/' or (on MS-Windows only) root is the empty string
ali@403
   167
 * and path starts with drive (eg., "c:/windows").
ali@403
   168
 * Note: path itself is not created, only the directory in which it
ali@403
   169
 * (would) exist.
ali@403
   170
 *
ali@403
   171
 * Returns: non-zero on error.
ali@403
   172
 **/
ali@403
   173
int razor_atomic_make_dirs(struct razor_atomic *atomic, const char *root,
ali@403
   174
  const char *path);
ali@403
   175
int razor_atomic_remove(struct razor_atomic *atomic, const char *path);
ali@403
   176
int razor_atomic_rename_file(struct razor_atomic *atomic, const char *oldpath,
ali@403
   177
			     const char *newpath);
ali@403
   178
ali@403
   179
/**
ali@403
   180
 * razor_atomic_create_dir
ali@403
   181
 * 
ali@403
   182
 * Create a directory, replacing any existing object at this path except
ali@403
   183
 * an existing directory (which is not counted as a error).
ali@403
   184
 *
ali@403
   185
 * Returns: non-zero on error.
ali@403
   186
 */
ali@403
   187
int razor_atomic_create_dir(struct razor_atomic *atomic, const char *dirname,
ali@403
   188
  mode_t mode);
ali@403
   189
ali@403
   190
/**
ali@403
   191
 * razor_atomic_create_symlink
ali@403
   192
 * 
ali@403
   193
 * Create a symbolic link, replacing any existing object at this path except
ali@403
   194
 * a non-empty directory.
ali@403
   195
 *
ali@403
   196
 * Note: This function will always fail on platforms that don't support
ali@403
   197
 * symbolic links.
ali@403
   198
 *
ali@403
   199
 * Returns: non-zero on error.
ali@403
   200
 */
ali@403
   201
int razor_atomic_create_symlink(struct razor_atomic *atomic, const char *target,
ali@403
   202
  const char *path);
ali@403
   203
/**
ali@403
   204
 * razor_atomic_create_file
ali@403
   205
 * 
ali@403
   206
 * Create a file, replacing any existing object at this path except
ali@403
   207
 * a non-empty directory.
ali@403
   208
 *
ali@403
   209
 * Returns: A handle to be passed to razor_atomic_write() and
ali@403
   210
 * razor_atomic_close() or a negative value on error.
ali@403
   211
 */
ali@403
   212
int razor_atomic_create_file(struct razor_atomic *atomic, const char *filename,
ali@403
   213
  mode_t mode);
ali@403
   214
int razor_atomic_write(struct razor_atomic *atomic, int handle,
ali@403
   215
  const void *data, size_t size);
ali@403
   216
int razor_atomic_close(struct razor_atomic *atomic, int handle);
ali@403
   217
int razor_atomic_sync(struct razor_atomic *atomic, int handle);
ali@403
   218
void razor_atomic_abort(struct razor_atomic *atomic, const char *error_msg);
ali@403
   219
int razor_atomic_in_error_state(struct razor_atomic *atomic);
ali@403
   220
ali@403
   221
/**
krh@262
   222
 * SECTION:set
krh@262
   223
 * @title: Package Set
krh@262
   224
 * @short_description: Represents a set of packages and their metadata.
krh@262
   225
 *
krh@262
   226
 * This object represents a set of packages, their dependency
krh@262
   227
 * information, the file lists and a number of other details.
krh@262
   228
 **/
rhughes@241
   229
krh@262
   230
struct razor_set;
krh@262
   231
struct razor_package;
krh@262
   232
struct razor_property;
krh@262
   233
ali@403
   234
#define RAZOR_HEADER_VERSION		2	/* Current version */
ali@403
   235
#define RAZOR_HEADER_VERSION_MIN	1	/* Minimum version we support */
ali@403
   236
krh@262
   237
/**
krh@262
   238
 * razor_set_create:
krh@262
   239
 * 
krh@262
   240
 * Create a new #razor_set object.
krh@262
   241
 * 
krh@262
   242
 * Returns: the new #razor_set object.
krh@262
   243
 **/
ali@363
   244
struct razor_set *razor_set_create_without_root(void);
rhughes@241
   245
struct razor_set *razor_set_create(void);
ali@424
   246
struct razor_set *
ali@424
   247
razor_set_open(const char *filename, enum razor_set_flags flags,
ali@424
   248
	       struct razor_error **error);
ali@403
   249
uint32_t razor_set_get_header_version(struct razor_set *set);
ali@403
   250
int razor_set_set_header_version(struct razor_set *set,
ali@403
   251
				 uint32_t header_version);
ali@403
   252
void razor_set_unref(struct razor_set *set);
ali@403
   253
struct razor_set *razor_set_ref(struct razor_set *set);
ali@403
   254
void razor_set_write_to_handle(struct razor_set *set,
ali@403
   255
			       struct razor_atomic *atomic, int handle,
ali@403
   256
			       uint32_t section_mask);
ali@403
   257
int razor_set_write(struct razor_set *set, struct razor_atomic *atomic,
krh@373
   258
		    const char *filename, uint32_t setions);
ali@424
   259
int
ali@424
   260
razor_set_bind_sections(struct razor_set *set, const char *filename,
ali@424
   261
			enum razor_set_flags flags, struct razor_error **error);
rhughes@241
   262
rhughes@241
   263
struct razor_package *
rhughes@241
   264
razor_set_get_package(struct razor_set *set, const char *package);
rhughes@241
   265
jbowes@258
   266
void
richard@304
   267
razor_package_get_details(struct razor_set *set,
richard@307
   268
			  struct razor_package *package, ...);
ali@369
   269
int
ali@382
   270
razor_package_remove(struct razor_set *prev, struct razor_set *next,
ali@403
   271
		     struct razor_atomic *atomic, struct razor_package *package,
ali@403
   272
		     const char *root, int install_count,
ali@403
   273
		     enum razor_stage_type stage);
krh@262
   274
krh@262
   275
/**
krh@262
   276
 * SECTION:iterator
krh@262
   277
 * @title: Iterators
krh@262
   278
 * @short_description: Objects for traversing packages or properties.
krh@262
   279
 *
krh@262
   280
 * The razor iterator objects provides a way to iterate through a set
krh@262
   281
 * of packages or properties.
krh@262
   282
 **/
krh@262
   283
rhughes@241
   284
struct razor_package_iterator;
krh@262
   285
krh@262
   286
/**
krh@262
   287
 * razor_package_iterator_create:
krh@262
   288
 * 
krh@262
   289
 * Create a new #razor_package_iterator object.
krh@262
   290
 * 
krh@262
   291
 * Returns: the new #razor_package_iterator object.
krh@262
   292
 **/
krh@262
   293
rhughes@241
   294
struct razor_package_iterator *
rhughes@241
   295
razor_package_iterator_create(struct razor_set *set);
krh@262
   296
krh@262
   297
/**
krh@262
   298
 * razor_package_iterator_create_for_property:
krh@262
   299
 * 
krh@262
   300
 * Create a new #razor_package_iterator object for the packages that
krh@262
   301
 * own the given property.
krh@262
   302
 * 
krh@262
   303
 * Returns: the new #razor_package_iterator object.
krh@262
   304
 **/
rhughes@241
   305
struct razor_package_iterator *
rhughes@241
   306
razor_package_iterator_create_for_property(struct razor_set *set,
rhughes@241
   307
					   struct razor_property *property);
jbowes@277
   308
jbowes@277
   309
/**
jbowes@277
   310
 * razor_package_iterator_create_for_file:
jbowes@277
   311
 *
jbowes@277
   312
 * Create a new #razor_package_iterator object for the packages that
jbowes@277
   313
 * contain the given file name.
jbowes@277
   314
 *
jbowes@277
   315
 * Returns: the new #razor_package_iterator object.
jbowes@277
   316
 **/
rhughes@241
   317
struct razor_package_iterator *
rhughes@241
   318
razor_package_iterator_create_for_file(struct razor_set *set,
rhughes@241
   319
				       const char *filename);
rhughes@241
   320
rhughes@241
   321
int razor_package_iterator_next(struct razor_package_iterator *pi,
richard@307
   322
				struct razor_package **package, ...);
rhughes@241
   323
void razor_package_iterator_destroy(struct razor_package_iterator *pi);
rhughes@241
   324
rhughes@241
   325
struct razor_package_query *
rhughes@241
   326
razor_package_query_create(struct razor_set *set);
rhughes@241
   327
void
rhughes@241
   328
razor_package_query_add_package(struct razor_package_query *pq,
rhughes@241
   329
				struct razor_package *p);
rhughes@241
   330
void
rhughes@241
   331
razor_package_query_add_iterator(struct razor_package_query *pq,
rhughes@241
   332
				 struct razor_package_iterator *pi);
rhughes@241
   333
struct razor_package_iterator *
rhughes@241
   334
razor_package_query_finish(struct razor_package_query *pq);
rhughes@241
   335
rhughes@241
   336
struct razor_property_iterator;
rhughes@241
   337
struct razor_property_iterator *
rhughes@241
   338
razor_property_iterator_create(struct razor_set *set,
rhughes@241
   339
			       struct razor_package *package);
rhughes@241
   340
int razor_property_iterator_next(struct razor_property_iterator *pi,
rhughes@241
   341
				 struct razor_property **property,
rhughes@241
   342
				 const char **name,
krh@247
   343
				 uint32_t *flags,
krh@247
   344
				 const char **version);
rhughes@241
   345
void
rhughes@241
   346
razor_property_iterator_destroy(struct razor_property_iterator *pi);
rhughes@241
   347
ali@351
   348
struct razor_file_iterator;
ali@351
   349
struct razor_file_iterator *
ali@351
   350
razor_file_iterator_create(struct razor_set *set,
ali@377
   351
			   struct razor_package *package, int post_order);
ali@351
   352
int razor_file_iterator_next(struct razor_file_iterator *fi,
ali@351
   353
			     const char **name);
ali@351
   354
void razor_file_iterator_destroy(struct razor_file_iterator *fi);
ali@351
   355
rhughes@241
   356
void razor_set_list_files(struct razor_set *set, const char *prefix);
krh@306
   357
void razor_set_list_package_files(struct razor_set *set,
krh@306
   358
				  struct razor_package *package);
rhughes@241
   359
krh@253
   360
enum razor_diff_action {
krh@253
   361
	RAZOR_DIFF_ACTION_ADD,
krh@253
   362
	RAZOR_DIFF_ACTION_REMOVE,
krh@253
   363
};
krh@253
   364
krh@253
   365
typedef void (*razor_diff_callback_t)(enum razor_diff_action action,
krh@253
   366
				      struct razor_package *package,
krh@253
   367
				      const char *name,
krh@253
   368
				      const char *version,
krh@253
   369
				      const char *arch,
krh@253
   370
				      void *data);
krh@253
   371
rhughes@241
   372
void
rhughes@241
   373
razor_set_diff(struct razor_set *set, struct razor_set *upstream,
krh@253
   374
	       razor_diff_callback_t callback, void *data);
krh@316
   375
krh@316
   376
struct razor_install_iterator;
krh@316
   377
krh@316
   378
enum razor_install_action {
krh@316
   379
	RAZOR_INSTALL_ACTION_ADD,
ali@416
   380
	RAZOR_INSTALL_ACTION_REMOVE,
ali@416
   381
	RAZOR_INSTALL_ACTION_COMMIT
krh@316
   382
};
krh@316
   383
krh@316
   384
struct razor_install_iterator *
krh@254
   385
razor_set_create_install_iterator(struct razor_set *set,
krh@254
   386
				  struct razor_set *next);
rhughes@241
   387
krh@316
   388
int razor_install_iterator_next(struct razor_install_iterator *ii,
krh@316
   389
				struct razor_package **package,
krh@316
   390
				enum razor_install_action *action,
krh@316
   391
				int *count);
krh@316
   392
ali@418
   393
/**
ali@418
   394
 * razor_install_iterator_commit_set
ali@418
   395
 *
ali@418
   396
 * Immediately after razor_install_iterator_next() returns
ali@418
   397
 * RAZOR_INSTALL_ACTION_COMMIT, this function will return the razor_set
ali@418
   398
 * which should be committed.
ali@418
   399
 *
ali@418
   400
 * Returns: a new #razor_set object.
ali@418
   401
 **/
ali@418
   402
struct razor_set *
ali@418
   403
razor_install_iterator_commit_set(struct razor_install_iterator *ii);
ali@418
   404
ali@403
   405
void razor_install_iterator_rewind(struct razor_install_iterator *ii);
ali@418
   406
size_t razor_install_iterator_tell(struct razor_install_iterator *ii);
ali@418
   407
size_t razor_install_iterator_seek(struct razor_install_iterator *ii,
ali@418
   408
				   size_t pos);
krh@316
   409
void razor_install_iterator_destroy(struct razor_install_iterator *ii);
krh@316
   410
krh@262
   411
/**
krh@262
   412
 * SECTION:transaction
krh@262
   413
 * @title: Transaction
krh@262
   414
 * @short_description: Create a new package set by merging two or more sets.
krh@262
   415
 *
krh@262
   416
 * The razor transaction object provides a way to create a new package set
krh@262
   417
 * from packages from one or more other package sets.
krh@262
   418
 **/
rhughes@241
   419
ali@369
   420
struct razor_rpm;
ali@369
   421
rhughes@241
   422
struct razor_transaction *
rhughes@241
   423
razor_transaction_create(struct razor_set *system, struct razor_set *upstream);
rhughes@241
   424
void razor_transaction_install_package(struct razor_transaction *transaction,
rhughes@241
   425
				       struct razor_package *package);
rhughes@241
   426
void razor_transaction_remove_package(struct razor_transaction *transaction,
rhughes@241
   427
				      struct razor_package *package);
rhughes@241
   428
void razor_transaction_update_package(struct razor_transaction *trans,
rhughes@241
   429
				      struct razor_package *package);
ali@369
   430
void razor_transaction_fixup_package(struct razor_transaction *trans,
ali@369
   431
				     struct razor_package *package,
ali@369
   432
				     struct razor_rpm *rpm);
rhughes@241
   433
void razor_transaction_update_all(struct razor_transaction *transaction);
rhughes@241
   434
int razor_transaction_resolve(struct razor_transaction *trans);
rhughes@241
   435
int razor_transaction_describe(struct razor_transaction *trans);
ali@369
   436
struct razor_set *razor_transaction_commit(struct razor_transaction *trans);
rhughes@241
   437
void razor_transaction_destroy(struct razor_transaction *trans);
rhughes@241
   438
rhughes@241
   439
/* Temporary helper for test suite. */
rhughes@241
   440
int razor_transaction_unsatisfied_property(struct razor_transaction *trans,
rhughes@241
   441
					   const char *name,
krh@247
   442
					   uint32_t flags,
krh@247
   443
					   const char *version);
rhughes@241
   444
krh@262
   445
/**
krh@262
   446
 * SECTION:rpm
krh@262
   447
 * @title: Razor RPM
krh@262
   448
 * @short_description: Operating on RPM files.
krh@262
   449
 *
krh@262
   450
 * Functions for open RPM files and extracting information and
krh@262
   451
 * installing or removing RPM files.
krh@262
   452
 **/
rhughes@241
   453
ali@351
   454
struct razor_relocations;
krh@262
   455
ali@351
   456
struct razor_relocations *razor_relocations_create(void);
ali@351
   457
void razor_relocations_add(struct razor_relocations *relocations,
ali@351
   458
			   const char *oldpath, const char *newpath);
ali@351
   459
void razor_relocations_set_rpm(struct razor_relocations *relocations,
ali@351
   460
			       struct razor_rpm *rpm);
ali@351
   461
const char *razor_relocations_apply(struct razor_relocations *relocations,
ali@351
   462
				    const char *path);
ali@351
   463
void razor_relocations_destroy(struct razor_relocations *relocations);
ali@351
   464
ali@403
   465
struct razor_rpm *razor_rpm_open(const char *filename,
ali@426
   466
				 struct razor_error **error);
ali@369
   467
void razor_rpm_get_details(struct razor_rpm *rpm, ...);
ali@351
   468
void razor_rpm_set_relocations(struct razor_rpm *rpm,
ali@351
   469
			       struct razor_relocations *relocations);
ali@403
   470
int razor_rpm_install(struct razor_rpm *rpm, struct razor_atomic *atomic,
ali@403
   471
		      const char *root, int install_count,
ali@403
   472
		      enum razor_stage_type stage);
krh@262
   473
int razor_rpm_close(struct razor_rpm *rpm);
krh@262
   474
krh@262
   475
/**
krh@262
   476
 * SECTION:importer
krh@262
   477
 * @title: Importer
krh@262
   478
 * @short_description: A mechanism for building #razor_set objects
krh@262
   479
 *
krh@309
   480
 * The %razor_importer is a helper object for building a razor set
krh@309
   481
 * from external sources, like yum metadata, the RPM database or RPM
krh@309
   482
 * files.
krh@309
   483
 *
krh@309
   484
 * The importer is a stateful object; it has the notion of a current
krh@309
   485
 * package, and the caller can provide meta data such as properties,
krh@309
   486
 * files and similiar for the package as it becomes available.  Once a
krh@309
   487
 * package is fully described, the next pacakge can begin.  When all
krh@309
   488
 * packages have been described to the importer, the importer will
krh@309
   489
 * create a new %razor_set with the specified packages.
krh@309
   490
 *
krh@309
   491
 * A typical use
krh@309
   492
 * of the importer will follow this template:
krh@309
   493
 * |[
krh@309
   494
 * importer = razor_importer_create();
krh@309
   495
 *
krh@309
   496
 * while ( /<!-- -->* more packages to import *<!-- -->/; ) {
krh@309
   497
 *   /<!-- -->* get name, version and arch of next package *<!-- -->/
krh@309
   498
 *   razor_importer_begin_package(importer, name, version, arch);
krh@309
   499
 *   razor_importer_add_details(importer, summary, description, url, license);
krh@309
   500
 *
krh@309
   501
 *   while ( /<!-- -->* more properties to add *<!-- -->/ )
krh@309
   502
 *     razor_importer_add_property(importer, name, flags, version);
krh@309
   503
 *
krh@309
   504
 *   while ( /<!-- -->* [more files to add *<!-- -->/ )
krh@309
   505
 *     razor_importer_add_file(importer, name);
krh@309
   506
 *
krh@309
   507
 *   razor_importer_finish_package(importer);
krh@309
   508
 * }
krh@309
   509
 *
krh@309
   510
 * return razor_importer_finish(importer);
krh@309
   511
 * ]|
krh@262
   512
 **/
rhughes@241
   513
struct razor_importer;
rhughes@241
   514
krh@249
   515
struct razor_importer *razor_importer_create(void);
rhughes@241
   516
void razor_importer_destroy(struct razor_importer *importer);
rhughes@241
   517
void razor_importer_begin_package(struct razor_importer *importer,
rhughes@241
   518
				  const char *name,
rhughes@241
   519
				  const char *version,
rhughes@241
   520
				  const char *arch);
jbowes@258
   521
void razor_importer_add_details(struct razor_importer *importer,
jbowes@258
   522
				const char *summary,
jbowes@258
   523
				const char *description,
jbowes@258
   524
				const char *url,
jbowes@258
   525
				const char *license);
ali@369
   526
void razor_importer_add_script(struct razor_importer *importer,
ali@369
   527
			       enum razor_property_flags script,
ali@369
   528
			       const char *program,
ali@369
   529
			       const char *body);
ali@372
   530
void razor_importer_add_install_prefix(struct razor_importer *importer,
ali@372
   531
				       const char *install_prefix);
rhughes@241
   532
void razor_importer_add_property(struct razor_importer *importer,
rhughes@241
   533
				 const char *name,
krh@247
   534
				 uint32_t flags,
krh@247
   535
				 const char *version);
rhughes@241
   536
void razor_importer_add_file(struct razor_importer *importer,
rhughes@241
   537
			     const char *name);
rhughes@241
   538
void razor_importer_finish_package(struct razor_importer *importer);
rhughes@241
   539
rhughes@241
   540
int razor_importer_add_rpm(struct razor_importer *importer,
rhughes@241
   541
			   struct razor_rpm *rpm);
rhughes@241
   542
rhughes@241
   543
struct razor_set *razor_importer_finish(struct razor_importer *importer);
rhughes@241
   544
rhughes@241
   545
struct razor_set *razor_set_create_from_yum(void);
rhughes@241
   546
struct razor_set *razor_set_create_from_rpmdb(void);
rhughes@241
   547
krh@262
   548
/**
krh@262
   549
 * SECTION:root
krh@262
   550
 * @title: Root
krh@262
   551
 * @short_description: Functions for accessing an install root.
krh@262
   552
 *
krh@262
   553
 * The #razor_root object encapsulate access to and locking of a razor
krh@262
   554
 * install root.
krh@262
   555
 **/
rhughes@241
   556
struct razor_root;
rhughes@241
   557
ali@425
   558
int razor_root_create(const char *root, struct razor_error **error);
ali@403
   559
struct razor_root *
ali@424
   560
razor_root_open(const char *root, struct razor_error **error);
ali@424
   561
struct razor_set *
ali@424
   562
razor_root_open_read_only(const char *root, struct razor_error **error);
krh@250
   563
struct razor_set *razor_root_get_system_set(struct razor_root *root);
krh@250
   564
int razor_root_close(struct razor_root *root);
ali@424
   565
int
ali@424
   566
razor_root_update(struct razor_root *root, struct razor_set *next,
ali@424
   567
		  struct razor_atomic *atomic);
rhughes@241
   568
krh@262
   569
/**
krh@262
   570
 * SECTION:misc
krh@262
   571
 * @title: Miscellaneous Functions
krh@262
   572
 * @short_description: Various helper functions
krh@262
   573
 *
krh@262
   574
 * Functions that doesn't fit anywhere else.
krh@262
   575
 **/
krh@262
   576
krh@262
   577
const char *
krh@262
   578
razor_property_relation_to_string(struct razor_property *p);
krh@262
   579
const char *
krh@262
   580
razor_property_type_to_string(struct razor_property *p);
krh@262
   581
krh@262
   582
void razor_build_evr(char *evr_buf, int size, const char *epoch,
krh@262
   583
		     const char *version, const char *release);
krh@262
   584
int razor_versioncmp(const char *s1, const char *s2);
krh@262
   585
ali@359
   586
void razor_disable_root_name_checks(int disable);
ali@359
   587
ali@361
   588
void razor_set_lua_loader(const char *modname, void (*loader)());
ali@368
   589
void (*razor_get_lua_loader(const char *modname))();
ali@361
   590
ali@403
   591
char *razor_concat(const char *s, ...) RAZOR_MALLOC RAZOR_NULL_TERMINATED;
ali@403
   592
ali@403
   593
const char *razor_system_arch(void);
krh@262
   594
rhughes@241
   595
#endif /* _RAZOR_H_ */